VM: get rid of the odd RT_EXCEPTION_HANDLER relocation
The address to the win32 relocation handler can be stored in a special object and be accessed by jit-install-seh. Doing it that way is better because you can remove a lot of special code related to that relocation type.db4
parent
68c0c0f53a
commit
22887c5816
|
@ -11,13 +11,15 @@ IN: bootstrap.x86
|
|||
<< "vocab:bootstrap/assembler/x86.windows.factor" parse-file suffix! >> call
|
||||
|
||||
: jit-install-seh ( -- )
|
||||
! VM pointer must be in vm-reg already
|
||||
! Create a new exception record and store it in the TIB.
|
||||
! Clobbers tib-temp.
|
||||
! Align stack
|
||||
ESP 3 bootstrap-cells ADD
|
||||
! Exception handler address filled in by callback.cpp
|
||||
tib-temp 0 MOV rc-absolute-cell rel-exception-handler
|
||||
tib-temp EBX 50 vm-special-object-offset [+] MOV
|
||||
tib-temp tib-temp alien-offset [+] MOV
|
||||
tib-temp PUSH
|
||||
|
||||
! No next handler
|
||||
0 PUSH
|
||||
! This is the new exception handler
|
||||
|
|
|
@ -89,9 +89,6 @@ MEMO: cached-string>symbol ( symbol -- obj ) string>symbol ;
|
|||
: rel-megamorphic-cache-hits ( class -- )
|
||||
rt-megamorphic-cache-hits add-relocation ;
|
||||
|
||||
: rel-exception-handler ( class -- )
|
||||
rt-exception-handler add-relocation ;
|
||||
|
||||
: rel-inline-cache-miss ( class -- )
|
||||
rt-inline-cache-miss add-relocation ;
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@ CONSTANT: deck-bits 18
|
|||
: array-start-offset ( -- n ) 2 array type-number slot-offset ; inline
|
||||
: callstack-length-offset ( -- n ) 1 \ callstack type-number slot-offset ; inline
|
||||
: callstack-top-offset ( -- n ) 2 \ callstack type-number slot-offset ; inline
|
||||
: vm-context-offset ( -- n ) 0 bootstrap-cells ; inline
|
||||
: vm-spare-context-offset ( -- n ) 1 bootstrap-cells ; inline
|
||||
: vm-signal-handler-addr-offset ( -- n ) 8 bootstrap-cells ; inline
|
||||
: vm-fault-flag-offset ( -- n ) 9 bootstrap-cells ; inline
|
||||
: context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
|
||||
: context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
|
||||
: context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
|
||||
|
@ -33,6 +29,15 @@ CONSTANT: deck-bits 18
|
|||
: segment-start-offset ( -- n ) 0 bootstrap-cells ; inline
|
||||
: segment-end-offset ( -- n ) 2 bootstrap-cells ; inline
|
||||
|
||||
! Offsets in vm struct
|
||||
: vm-context-offset ( -- n ) 0 bootstrap-cells ; inline
|
||||
: vm-spare-context-offset ( -- n ) 1 bootstrap-cells ; inline
|
||||
: vm-signal-handler-addr-offset ( -- n ) 8 bootstrap-cells ; inline
|
||||
: vm-fault-flag-offset ( -- n ) 9 bootstrap-cells ; inline
|
||||
: vm-special-object-offset ( n -- offset )
|
||||
! Can't reuse the one in compiler.cfg.intrinsics.misc :(
|
||||
bootstrap-cells 10 bootstrap-cells + ;
|
||||
|
||||
! Relocation classes
|
||||
CONSTANT: rc-absolute-cell 0
|
||||
CONSTANT: rc-absolute 1
|
||||
|
@ -58,7 +63,6 @@ CONSTANT: rt-megamorphic-cache-hits 8
|
|||
CONSTANT: rt-vm 9
|
||||
CONSTANT: rt-cards-offset 10
|
||||
CONSTANT: rt-decks-offset 11
|
||||
CONSTANT: rt-exception-handler 12
|
||||
CONSTANT: rt-dlsym-toc 13
|
||||
CONSTANT: rt-inline-cache-miss 14
|
||||
CONSTANT: rt-safepoint 15
|
||||
|
|
|
@ -23,14 +23,6 @@ void factor_vm::init_callbacks(cell size) {
|
|||
callbacks = new callback_heap(size, this);
|
||||
}
|
||||
|
||||
bool callback_heap::setup_seh_p() {
|
||||
#if defined(WINDOWS) && defined(FACTOR_X86)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool callback_heap::return_takes_param_p() {
|
||||
#if defined(FACTOR_X86) || defined(FACTOR_AMD64)
|
||||
return true;
|
||||
|
@ -49,23 +41,23 @@ instruction_operand callback_heap::callback_operand(code_block* stub,
|
|||
return instruction_operand(entry, stub, 0);
|
||||
}
|
||||
|
||||
void callback_heap::store_callback_operand(code_block* stub, cell index) {
|
||||
instruction_operand op = callback_operand(stub, index);
|
||||
op.store_value(parent->compute_external_address(op));
|
||||
}
|
||||
|
||||
void callback_heap::store_callback_operand(code_block* stub, cell index,
|
||||
cell value) {
|
||||
callback_operand(stub, index).store_value(value);
|
||||
instruction_operand op = callback_operand(stub, index);
|
||||
op.store_value(value);
|
||||
}
|
||||
|
||||
void callback_heap::update(code_block* stub) {
|
||||
store_callback_operand(stub, setup_seh_p() ? 2 : 1,
|
||||
callback_entry_point(stub));
|
||||
store_callback_operand(stub, 1, callback_entry_point(stub));
|
||||
stub->flush_icache();
|
||||
}
|
||||
|
||||
code_block* callback_heap::add(cell owner, cell return_rewind) {
|
||||
|
||||
/* code_template is a 2-tuple where the first element contains the
|
||||
relocations and the second a byte array of compiled assembly
|
||||
code. The code assumes that there are four relocations on x86 and
|
||||
three on ppc. */
|
||||
tagged<array> code_template(parent->special_objects[CALLBACK_STUB]);
|
||||
tagged<byte_array> insns(array_nth(code_template.untagged(), 1));
|
||||
cell size = array_capacity(insns.untagged());
|
||||
|
@ -88,21 +80,13 @@ code_block* callback_heap::add(cell owner, cell return_rewind) {
|
|||
/* Store VM pointer */
|
||||
store_callback_operand(stub, 0, (cell)parent);
|
||||
|
||||
cell index;
|
||||
|
||||
if (setup_seh_p()) {
|
||||
store_callback_operand(stub, 1);
|
||||
index = 1;
|
||||
} else
|
||||
index = 0;
|
||||
|
||||
/* Store VM pointer */
|
||||
store_callback_operand(stub, index + 2, (cell) parent);
|
||||
store_callback_operand(stub, 2, (cell) parent);
|
||||
|
||||
/* On x86, the RET instruction takes an argument which depends on
|
||||
the callback's calling convention */
|
||||
if (return_takes_param_p())
|
||||
store_callback_operand(stub, index + 3, return_rewind);
|
||||
store_callback_operand(stub, 3, return_rewind);
|
||||
|
||||
update(stub);
|
||||
|
||||
|
|
|
@ -36,16 +36,11 @@ struct callback_heap {
|
|||
return w->entry_point;
|
||||
}
|
||||
|
||||
bool setup_seh_p();
|
||||
bool return_takes_param_p();
|
||||
instruction_operand callback_operand(code_block* stub, cell index);
|
||||
void store_callback_operand(code_block* stub, cell index);
|
||||
void store_callback_operand(code_block* stub, cell index, cell value);
|
||||
|
||||
void update(code_block* stub);
|
||||
|
||||
code_block* add(cell owner, cell return_rewind);
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
|
|
|
@ -201,10 +201,6 @@ cell factor_vm::lookup_external_address(relocation_type rel_type,
|
|||
return cards_offset;
|
||||
case RT_DECKS_OFFSET:
|
||||
return decks_offset;
|
||||
#ifdef WINDOWS
|
||||
case RT_EXCEPTION_HANDLER:
|
||||
return (cell)&factor::exception_handler;
|
||||
#endif
|
||||
#ifdef FACTOR_PPC
|
||||
case RT_DLSYM_TOC:
|
||||
return compute_dlsym_address(parameters, index, true);
|
||||
|
|
|
@ -153,7 +153,10 @@ void factor_vm::init_factor(vm_parameters* p) {
|
|||
{OBJ_VM_COMPILE_TIME, (cell)FACTOR_COMPILE_TIME},
|
||||
{OBJ_VM_COMPILER, (cell)FACTOR_COMPILER_VERSION},
|
||||
{OBJ_VM_GIT_LABEL, (cell)FACTOR_STRINGIZE(FACTOR_GIT_LABEL)},
|
||||
{OBJ_VM_VERSION, (cell)FACTOR_STRINGIZE(FACTOR_VERSION)}
|
||||
{OBJ_VM_VERSION, (cell)FACTOR_STRINGIZE(FACTOR_VERSION)},
|
||||
#if defined(WINDOWS)
|
||||
{UNUSED1, (cell)&factor::exception_handler}
|
||||
#endif
|
||||
};
|
||||
int n_items = sizeof(aliens) / sizeof(cell[2]);
|
||||
for (int n = 0; n < n_items; n++) {
|
||||
|
|
|
@ -111,7 +111,6 @@ struct relocation_entry {
|
|||
case RT_MEGAMORPHIC_CACHE_HITS:
|
||||
case RT_CARDS_OFFSET:
|
||||
case RT_DECKS_OFFSET:
|
||||
case RT_EXCEPTION_HANDLER:
|
||||
case RT_INLINE_CACHE_MISS:
|
||||
case RT_SAFEPOINT:
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue