simplify function prologs

db4
Joe Groff 2011-12-13 15:13:32 -08:00
parent 2f20ee6fb0
commit 079025559d
11 changed files with 17 additions and 48 deletions

View File

@ -89,11 +89,6 @@ M: x86.32 return-regs
{ float-regs { ST0 } } { float-regs { ST0 } }
} ; } ;
M: x86.32 %prologue ( n -- )
dup PUSH
0 PUSH rc-absolute-cell rel-this
3 cells - decr-stack-reg ;
M: x86.32 %prepare-jump M: x86.32 %prepare-jump
pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here ; pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here ;

View File

@ -37,15 +37,6 @@ IN: bootstrap.x86
: jit-call ( name -- ) : jit-call ( name -- )
0 CALL f rc-relative rel-dlsym ; 0 CALL f rc-relative rel-dlsym ;
[
! alignment
ESP stack-frame-size bootstrap-cell - SUB
! store entry point
ESP stack-frame-size 3 bootstrap-cells - [+] 0 MOV rc-absolute-cell rel-this
! store stack frame size
ESP stack-frame-size 2 bootstrap-cells - [+] stack-frame-size MOV
] jit-prolog jit-define
[ [
pic-tail-reg 0 MOV 0 rc-absolute-cell rel-here pic-tail-reg 0 MOV 0 rc-absolute-cell rel-here
0 JMP f rc-relative rel-word-pic-tail 0 JMP f rc-relative rel-word-pic-tail

View File

@ -59,12 +59,6 @@ M: x86.64 %set-vm-field ( src offset -- )
M: x86.64 %vm-field-ptr ( dst offset -- ) M: x86.64 %vm-field-ptr ( dst offset -- )
[ vm-reg ] dip [+] LEA ; [ vm-reg ] dip [+] LEA ;
M: x86.64 %prologue ( n -- )
RAX 0 MOV rc-absolute-cell rel-this
stack-reg over cell - SUB
stack-reg over 3 cells - [+] RAX MOV
stack-reg over 2 cells - [+] swap MOV ;
M: x86.64 %prepare-jump M: x86.64 %prepare-jump
pic-tail-reg xt-tail-pic-offset [RIP+] LEA ; pic-tail-reg xt-tail-pic-offset [RIP+] LEA ;

View File

@ -33,17 +33,6 @@ IN: bootstrap.x86
RAX 0 MOV f rc-absolute-cell rel-dlsym RAX 0 MOV f rc-absolute-cell rel-dlsym
RAX CALL ; RAX CALL ;
[
! load entry point
RAX 0 MOV rc-absolute-cell rel-this
! alignment
RSP stack-frame-size bootstrap-cell - SUB
! store entry point
RSP stack-frame-size 3 bootstrap-cells - [+] RAX MOV
! store stack frame size
RSP stack-frame-size 2 bootstrap-cells - [+] stack-frame-size MOV
] jit-prolog jit-define
[ [
pic-tail-reg 5 [RIP+] LEA pic-tail-reg 5 [RIP+] LEA
0 JMP f rc-relative rel-word-pic-tail 0 JMP f rc-relative rel-word-pic-tail
@ -96,18 +85,12 @@ IN: bootstrap.x86
:: jit-signal-handler-prolog ( -- frame-size ) :: jit-signal-handler-prolog ( -- frame-size )
signal-handler-save-regs :> save-regs signal-handler-save-regs :> save-regs
save-regs length 1 + bootstrap-cells 16 align stack-frame-size + :> frame-size signal-handler-stack-frame-size :> frame-size
frame-size signal-handler-stack-frame-size =
[ "unexpected signal handler frame size" throw ] unless
! minus a cell each for flags, return address ! minus a cell each for flags, return address
! use LEA so we don't dirty flags ! use LEA so we don't dirty flags
RSP RSP frame-size 2 bootstrap-cells - neg [+] LEA RSP RSP frame-size 2 bootstrap-cells - neg [+] LEA
save-regs [| r i | RSP i bootstrap-cells [+] r MOV ] each-index save-regs [| r i | RSP i bootstrap-cells [+] r MOV ] each-index
PUSHF PUSHF
! Now that the registers are saved, we can make the stack frame
RAX 0 MOV rc-absolute-cell rel-this
RSP frame-size 3 bootstrap-cells - [+] RAX MOV
RSP frame-size 2 bootstrap-cells - [+] frame-size MOV
frame-size ; frame-size ;
:: jit-signal-handler-epilog ( frame-size -- ) :: jit-signal-handler-epilog ( frame-size -- )

View File

@ -5,8 +5,8 @@ cpu.x86.assembler.operands kernel layouts namespaces parser
sequences system vocabs ; sequences system vocabs ;
IN: bootstrap.x86 IN: bootstrap.x86
: leaf-stack-frame-size ( -- n ) 4 bootstrap-cells ; : leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
: signal-handler-stack-frame-size ( -- n ) 20 bootstrap-cells ; : signal-handler-stack-frame-size ( -- n ) 18 bootstrap-cells ;
: stack-frame-size ( -- n ) 4 bootstrap-cells ; : stack-frame-size ( -- n ) 4 bootstrap-cells ;
: nv-regs ( -- seq ) { RBX R12 R13 R14 R15 } ; : nv-regs ( -- seq ) { RBX R12 R13 R14 R15 } ;
: volatile-regs ( -- seq ) { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; : volatile-regs ( -- seq ) { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ;

View File

@ -7,8 +7,8 @@ IN: bootstrap.x86
DEFER: stack-reg DEFER: stack-reg
: leaf-stack-frame-size ( -- n ) 4 bootstrap-cells ; : leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
: signal-handler-stack-frame-size ( -- n ) 24 bootstrap-cells ; : signal-handler-stack-frame-size ( -- n ) 22 bootstrap-cells ;
: stack-frame-size ( -- n ) 8 bootstrap-cells ; : stack-frame-size ( -- n ) 8 bootstrap-cells ;
: nv-regs ( -- seq ) { RBX RSI RDI R12 R13 R14 R15 } ; : nv-regs ( -- seq ) { RBX RSI RDI R12 R13 R14 R15 } ;
: volatile-regs ( -- seq ) { RAX RCX RDX R8 R9 R10 R11 } ; : volatile-regs ( -- seq ) { RAX RCX RDX R8 R9 R10 R11 } ;

View File

@ -223,6 +223,10 @@ big-endian off
temp0 word-entry-point-offset [+] JMP temp0 word-entry-point-offset [+] JMP
] jit-execute jit-define ] jit-execute jit-define
[
stack-reg stack-frame-size bootstrap-cell - SUB
] jit-prolog jit-define
[ [
stack-reg stack-frame-size bootstrap-cell - ADD stack-reg stack-frame-size bootstrap-cell - ADD
] jit-epilog jit-define ] jit-epilog jit-define

View File

@ -515,6 +515,8 @@ M: x86 %call-gc ( gc-map -- )
M: x86 %alien-global ( dst symbol library -- ) M: x86 %alien-global ( dst symbol library -- )
[ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ; [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
M: x86 %prologue ( n -- ) cell - decr-stack-reg ;
M: x86 %epilogue ( n -- ) cell - incr-stack-reg ; M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
:: (%boolean) ( dst temp insn -- ) :: (%boolean) ( dst temp insn -- )

View File

@ -30,8 +30,8 @@ inline static void uap_clear_fpu_status(void *uap)
/* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size, /* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size,
and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */ and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */
static const unsigned LEAF_FRAME_SIZE = 32; static const unsigned LEAF_FRAME_SIZE = 16;
static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160; static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
static const unsigned JIT_FRAME_SIZE = 32; static const unsigned JIT_FRAME_SIZE = 32;
} }

View File

@ -75,8 +75,8 @@ inline static void uap_clear_fpu_status(void *uap)
/* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size, /* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size,
and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */ and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */
static const unsigned LEAF_FRAME_SIZE = 32; static const unsigned LEAF_FRAME_SIZE = 16;
static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160; static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
static const unsigned JIT_FRAME_SIZE = 32; static const unsigned JIT_FRAME_SIZE = 32;
} }

View File

@ -11,7 +11,7 @@ namespace factor
/* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size, /* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size,
and stack-frame-size constants in basis/cpu/x86/64/windows/bootstrap.factor */ and stack-frame-size constants in basis/cpu/x86/64/windows/bootstrap.factor */
static const unsigned LEAF_FRAME_SIZE = 32; static const unsigned LEAF_FRAME_SIZE = 16;
static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 192; static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 176;
static const unsigned JIT_FRAME_SIZE = 64; static const unsigned JIT_FRAME_SIZE = 64;
} }