]> gitweb.factorcode.org Git - factor.git/commitdiff
simplify function prologs
authorJoe Groff <arcata@gmail.com>
Tue, 13 Dec 2011 23:13:32 +0000 (15:13 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 14 Dec 2011 17:56:49 +0000 (09:56 -0800)
basis/cpu/x86/32/32.factor
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/64.factor
basis/cpu/x86/64/bootstrap.factor
basis/cpu/x86/64/unix/bootstrap.factor
basis/cpu/x86/64/windows/bootstrap.factor
basis/cpu/x86/bootstrap.factor
basis/cpu/x86/x86.factor
vm/os-linux-x86.64.hpp
vm/os-macosx-x86.64.hpp
vm/os-windows.64.hpp

index 54a25310d6ec6aa084ced5b16ac3b59c14965c28..c15e43c848f0c9db45d835f6e277eb61c5efbd25 100755 (executable)
@@ -89,11 +89,6 @@ M: x86.32 return-regs
         { 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
     pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here ;
 
index 03a39715d44ab3aef3c22b25d08e71df99205746..1f78c477404ad8fd5ebfd36006b5a3ceefdcefbd 100755 (executable)
@@ -37,15 +37,6 @@ IN: bootstrap.x86
 : jit-call ( name -- )
     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
     0 JMP f rc-relative rel-word-pic-tail
index 6c2acac628698cc33949403f17b69986c67d2bc0..1934b0ebb671a262547fde680de3e90436c8f8d6 100644 (file)
@@ -59,12 +59,6 @@ M: x86.64 %set-vm-field ( src offset -- )
 M: x86.64 %vm-field-ptr ( dst offset -- )
     [ 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
     pic-tail-reg xt-tail-pic-offset [RIP+] LEA ;
 
index 047d15654bd9d70e028af73ffe124574530a7db8..b5de844f47daa69cf99b41edc29d994087ceef31 100755 (executable)
@@ -33,17 +33,6 @@ IN: bootstrap.x86
     RAX 0 MOV f rc-absolute-cell rel-dlsym
     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
     0 JMP f rc-relative rel-word-pic-tail
@@ -96,18 +85,12 @@ IN: bootstrap.x86
 
 :: jit-signal-handler-prolog ( -- frame-size )
     signal-handler-save-regs :> save-regs
-    save-regs length 1 + bootstrap-cells 16 align stack-frame-size + :> frame-size
-    frame-size signal-handler-stack-frame-size =
-    [ "unexpected signal handler frame size" throw ] unless
+    signal-handler-stack-frame-size :> frame-size
     ! minus a cell each for flags, return address
     ! use LEA so we don't dirty flags
     RSP RSP frame-size 2 bootstrap-cells - neg [+] LEA
     save-regs [| r i | RSP i bootstrap-cells [+] r MOV ] each-index
     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 ;
 
 :: jit-signal-handler-epilog ( frame-size -- )
index f5265dc0201c24b549e45b9d7404afc7acf5e149..cf9415441a8ae3c2dbde0f0365bdc94670854514 100644 (file)
@@ -5,8 +5,8 @@ cpu.x86.assembler.operands kernel layouts namespaces parser
 sequences system vocabs ;
 IN: bootstrap.x86
 
-: leaf-stack-frame-size ( -- n ) 4 bootstrap-cells ;
-: signal-handler-stack-frame-size ( -- n ) 20 bootstrap-cells ;
+: leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
+: signal-handler-stack-frame-size ( -- n ) 18 bootstrap-cells ;
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
 : nv-regs ( -- seq ) { RBX R12 R13 R14 R15 } ;
 : volatile-regs ( -- seq ) { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ;
index 00f1cc1acba8cc3c3245e395f4ee967675561e8b..a88122510363f8ac61c37acbebcd15e882aa681e 100644 (file)
@@ -7,8 +7,8 @@ IN: bootstrap.x86
 
 DEFER: stack-reg
 
-: leaf-stack-frame-size ( -- n ) 4 bootstrap-cells ;
-: signal-handler-stack-frame-size ( -- n ) 24 bootstrap-cells ;
+: leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
+: signal-handler-stack-frame-size ( -- n ) 22 bootstrap-cells ;
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
 : nv-regs ( -- seq ) { RBX RSI RDI R12 R13 R14 R15 } ;
 : volatile-regs ( -- seq ) { RAX RCX RDX R8 R9 R10 R11 } ;
index ee84ff2dbd8b314db8b4e1a7d1aae7a61c5539fd..d09657f33ceb995d398f5c0873400fe4db1dcd3f 100644 (file)
@@ -223,6 +223,10 @@ big-endian off
     temp0 word-entry-point-offset [+] JMP
 ] jit-execute jit-define
 
+[
+    stack-reg stack-frame-size bootstrap-cell - SUB
+] jit-prolog jit-define
+
 [
     stack-reg stack-frame-size bootstrap-cell - ADD
 ] jit-epilog jit-define
index 832ee51bd5ea91a8fad7d929fc7d6a429d3d3660..80740214294cb8781bbce3bcf1d078c51df885c0 100644 (file)
@@ -515,6 +515,8 @@ M: x86 %call-gc ( gc-map -- )
 M: x86 %alien-global ( dst symbol library -- )
     [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
 
+M: x86 %prologue ( n -- ) cell - decr-stack-reg ;
+
 M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
 
 :: (%boolean) ( dst temp insn -- )
index 366a1357517e334dc79e9e0be9777183a0e77f6c..022636012b7b92854174fbdb0b5ea4bd4924db01 100644 (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,
 and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */
-static const unsigned LEAF_FRAME_SIZE = 32;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160;
+static const unsigned LEAF_FRAME_SIZE = 16;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
 static const unsigned JIT_FRAME_SIZE = 32;
 
 }
index 2b1c02beb0d2d8880c30c1f64dd0bf5da5d07f6f..023dfec86743b144836cf169cecd14fed41d2875 100644 (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,
 and stack-frame-size constants in basis/cpu/x86/64/unix/bootstrap.factor */
-static const unsigned LEAF_FRAME_SIZE = 32;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160;
+static const unsigned LEAF_FRAME_SIZE = 16;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
 static const unsigned JIT_FRAME_SIZE = 32;
 
 }
index 19b43a74f53ce92d6c8e4e4ede36246672e5c53c..d5171b089ed48a281f7362b86dff1f2aec2ea10c 100644 (file)
@@ -11,7 +11,7 @@ namespace factor
 /* 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 */
 
-static const unsigned LEAF_FRAME_SIZE = 32;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 192;
+static const unsigned LEAF_FRAME_SIZE = 16;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 176;
 static const unsigned JIT_FRAME_SIZE = 64;
 }