diff --git a/core/cpu/x86/32/32.factor b/core/cpu/x86/32/32.factor index 998e87c7a0..4ef7777dd4 100644 --- a/core/cpu/x86/32/32.factor +++ b/core/cpu/x86/32/32.factor @@ -206,10 +206,10 @@ M: x86-backend %box-small-struct ( size -- ) M: x86-backend %prepare-alien-indirect ( -- ) "unbox_alien" f %alien-invoke - ESP cell temp@ [+] EAX MOV ; + cell temp@ EAX MOV ; M: x86-backend %alien-indirect ( -- ) - ESP cell temp@ [+] CALL ; + cell temp@ CALL ; M: x86-backend %alien-callback ( quot -- ) 4 [ diff --git a/core/cpu/x86/64/64.factor b/core/cpu/x86/64/64.factor index 94da29eb6d..708c75e0bd 100644 --- a/core/cpu/x86/64/64.factor +++ b/core/cpu/x86/64/64.factor @@ -16,10 +16,10 @@ M: amd64-backend stack-reg RSP ; M: x86-backend xt-reg RCX ; M: x86-backend stack-save-reg RSI ; -M: temp-reg v>operand drop R13 ; +M: temp-reg v>operand drop RBX ; M: int-regs return-reg drop RAX ; -M: int-regs vregs drop { RAX RBX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 } ; +M: int-regs vregs drop { RAX RCX RDX RBP RSI RDI R8 R9 R10 R11 R12 R13 } ; M: int-regs param-regs drop { RDI RSI RDX RCX R8 R9 } ; M: float-regs return-reg drop XMM0 ; @@ -146,17 +146,17 @@ M: amd64-backend %alien-indirect ( -- ) cell temp@ CALL ; M: amd64-backend %alien-callback ( quot -- ) - RDI load-indirect "run_callback" f compile-c-call ; + RDI load-indirect "c_to_factor" f compile-c-call ; M: amd64-backend %callback-value ( ctype -- ) ! Save top of data stack %prepare-unbox ! Put former top of data stack in RDI - temp@ RDI MOV + cell temp@ RDI MOV ! Restore data/call/retain stacks "unnest_stacks" f %alien-invoke ! Put former top of data stack in RDI - RDI temp@ MOV + RDI cell temp@ MOV ! Unbox former top of data stack to return registers unbox-return ; diff --git a/core/cpu/x86/architecture/architecture.factor b/core/cpu/x86/architecture/architecture.factor index 6879e23051..4acd4d8c46 100644 --- a/core/cpu/x86/architecture/architecture.factor +++ b/core/cpu/x86/architecture/architecture.factor @@ -150,7 +150,7 @@ M: x86-backend small-enough? ( n -- ? ) : %tag-fixnum ( reg -- ) tag-bits get SHL ; -: temp@ \ stack-frame get swap - ; +: temp@ stack-reg \ stack-frame get rot - [+] ; : struct-return@ ( size n -- n ) [ diff --git a/vm/cpu-x86.S b/vm/cpu-x86.S index a84ae6c480..3e2a97dd5c 100644 --- a/vm/cpu-x86.S +++ b/vm/cpu-x86.S @@ -29,7 +29,7 @@ DEF(FASTCALL void,dosym,(CELL word)): /* Here we have two entry points. The first one is taken when profiling is enabled */ DEF(FASTCALL void,docol_profiling,(CELL word)): - add $CELL_SIZE,PROFILING_OFFSET(%eax) /* Increment profile-count slot */ + add $CELL_SIZE,PROFILING_OFFSET(ARG0) /* Increment profile-count slot */ DEF(FASTCALL void,docol,(CELL word)): mov WORD_DEF_OFFSET(ARG0),ARG0 /* Load word-def slot */ JUMP_QUOT diff --git a/vm/factor.c b/vm/factor.c index e74662a8a4..6a6dc8f154 100644 --- a/vm/factor.c +++ b/vm/factor.c @@ -135,6 +135,7 @@ void init_factor_from_args(F_CHAR *image, int argc, F_CHAR **argv, bool embedded } nest_stacks(); + printf("%lx\n",untag_quotation(userenv[BOOT_ENV])->xt); c_to_factor_toplevel(userenv[BOOT_ENV]); unnest_stacks(); diff --git a/vm/os-linux-x86-64.h b/vm/os-linux-x86-64.h new file mode 100644 index 0000000000..2bbae86f6e --- /dev/null +++ b/vm/os-linux-x86-64.h @@ -0,0 +1,2 @@ +#define UAP_PROGRAM_COUNTER(ucontext) \ + (((ucontext_t *)(ucontext))->uc_mcontext.gregs[16])