]> gitweb.factorcode.org Git - factor.git/commitdiff
cpu.x86.*: clean up signal handler prolog code
authorJoe Groff <arcata@gmail.com>
Wed, 14 Dec 2011 03:31:59 +0000 (19:31 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 14 Dec 2011 17:56:50 +0000 (09:56 -0800)
Also bump the signal handler frame sizes up again since it looks like we shrank them too much.

basis/cpu/x86/32/bootstrap.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
vm/os-linux-x86.64.hpp
vm/os-macosx-x86.64.hpp
vm/os-windows.64.hpp

index 1f78c477404ad8fd5ebfd36006b5a3ceefdcefbd..2bb9eac877d57a5e1d35ee8c86559cb596549934 100755 (executable)
@@ -91,39 +91,8 @@ IN: bootstrap.x86
     "end_callback" jit-call
 ] \ c-to-factor define-sub-primitive
 
-! The signal-handler and leaf-signal-handler subprimitives are special-cased
-! in vm/quotations.cpp not to trigger generation of a stack frame, so they can
-! peform their own prolog/epilog preserving registers.
-
-:: jit-signal-handler-prolog ( -- frame-size )
-    signal-handler-stack-frame-size :> frame-size
-    ! minus a cell each for flags and return address
-    ! use LEA so we don't dirty flags
-    ESP ESP frame-size 2 bootstrap-cells - neg [+] LEA
-    ESP []                    EAX MOV
-    ESP 1 bootstrap-cells [+] ECX MOV
-    ESP 2 bootstrap-cells [+] EDX MOV
-    ESP 3 bootstrap-cells [+] EBX MOV
-    ESP 4 bootstrap-cells [+] EBP MOV
-    ESP 5 bootstrap-cells [+] ESI MOV
-    ESP 6 bootstrap-cells [+] EDI MOV
-    PUSHF
-    ESP frame-size 3 bootstrap-cells - [+] 0 MOV rc-absolute-cell rel-this
-    ESP frame-size 2 bootstrap-cells - [+] frame-size MOV
-    ! subprimitive definition assumes vm's been loaded
-    jit-load-vm
-    frame-size ;
-
-:: jit-signal-handler-epilog ( frame-size -- )
-    POPF
-    EAX ESP []                    MOV
-    ECX ESP 1 bootstrap-cells [+] MOV
-    EDX ESP 2 bootstrap-cells [+] MOV
-    EBX ESP 3 bootstrap-cells [+] MOV
-    EBP ESP 4 bootstrap-cells [+] MOV
-    ESI ESP 5 bootstrap-cells [+] MOV
-    EDI ESP 6 bootstrap-cells [+] MOV
-    ESP ESP frame-size 2 bootstrap-cells - [+] LEA ;
+: signal-handler-save-regs ( -- regs )
+    { EAX ECX EDX EBX EBP ESI EDI } ;
 
 [
     EAX ds-reg [] MOV
index b5de844f47daa69cf99b41edc29d994087ceef31..5fef6382a5af79a909af1bbc24faec265148a8e9 100755 (executable)
@@ -83,22 +83,6 @@ IN: bootstrap.x86
 : signal-handler-save-regs ( -- regs )
     { RAX RCX RDX RBX RBP RSI RDI R8 R9 R10 R11 R12 R13 R14 R15 } ;
 
-:: jit-signal-handler-prolog ( -- frame-size )
-    signal-handler-save-regs :> save-regs
-    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
-    frame-size ;
-
-:: jit-signal-handler-epilog ( frame-size -- )
-    POPF
-    signal-handler-save-regs
-    [| r i | r RSP i bootstrap-cells [+] MOV ] each-index
-    RSP RSP frame-size 2 bootstrap-cells - [+] LEA ;
-
 [
     arg1 ds-reg [] MOV
     ds-reg bootstrap-cell SUB
index cf9415441a8ae3c2dbde0f0365bdc94670854514..c4abe962cf06762b5fb9d13bd41c8ad0a7bd0db4 100644 (file)
@@ -6,7 +6,7 @@ sequences system vocabs ;
 IN: bootstrap.x86
 
 : leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
-: signal-handler-stack-frame-size ( -- n ) 18 bootstrap-cells ;
+: signal-handler-stack-frame-size ( -- n ) 20 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 a88122510363f8ac61c37acbebcd15e882aa681e..d622161f32e0d1e454536bf33540e97421a17c72 100644 (file)
@@ -8,7 +8,7 @@ IN: bootstrap.x86
 DEFER: stack-reg
 
 : leaf-stack-frame-size ( -- n ) 2 bootstrap-cells ;
-: signal-handler-stack-frame-size ( -- n ) 22 bootstrap-cells ;
+: signal-handler-stack-frame-size ( -- n ) 24 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 d09657f33ceb995d398f5c0873400fe4db1dcd3f..42ea87a5be3d5e814aef24d2e07c539be1cc0acb 100644 (file)
@@ -93,38 +93,58 @@ big-endian off
 ! not to trigger generation of a stack frame, so they can
 ! peform their own prolog/epilog preserving registers.
 
+: jit-signal-handler-prolog ( -- )
+    ! minus a cell each for flags, return address
+    ! use LEA so we don't dirty flags
+    stack-reg stack-reg signal-handler-stack-frame-size
+    2 bootstrap-cells - neg [+] LEA
+
+    signal-handler-save-regs
+    [| r i | stack-reg i bootstrap-cells [+] r MOV ] each-index
+
+    PUSHF ;
+
+: jit-signal-handler-epilog ( -- )
+    POPF
+
+    signal-handler-save-regs
+    [| r i | r stack-reg i bootstrap-cells [+] MOV ] each-index
+
+    stack-reg stack-reg signal-handler-stack-frame-size
+    2 bootstrap-cells - [+] LEA ;
+
 [| |
-    jit-signal-handler-prolog :> frame-size
+    jit-signal-handler-prolog
     jit-save-context
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
-    frame-size jit-signal-handler-epilog
+    jit-signal-handler-epilog
     0 RET
 ] \ signal-handler define-sub-primitive
 
 [| |
-    jit-signal-handler-prolog :> frame-size
+    jit-signal-handler-prolog
     jit-save-context
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
-    frame-size jit-signal-handler-epilog
+    jit-signal-handler-epilog
     ! Pop the fake leaf frame along with our return address
     leaf-stack-frame-size bootstrap-cell - RET
 ] \ leaf-signal-handler define-sub-primitive
 
 [| |
-    jit-signal-handler-prolog :> frame-size
+    jit-signal-handler-prolog
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
-    frame-size jit-signal-handler-epilog
+    jit-signal-handler-epilog
     red-zone-size RET
 ] \ ffi-signal-handler define-sub-primitive
 
 [| |
-    jit-signal-handler-prolog :> frame-size
+    jit-signal-handler-prolog
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
-    frame-size jit-signal-handler-epilog
+    jit-signal-handler-epilog
     red-zone-size 16 bootstrap-cell - + RET
 ] \ ffi-leaf-signal-handler define-sub-primitive
 
index 022636012b7b92854174fbdb0b5ea4bd4924db01..f0b178607113e91f321581d91900636951520345 100644 (file)
@@ -31,7 +31,7 @@ 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 = 16;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160;
 static const unsigned JIT_FRAME_SIZE = 32;
 
 }
index 023dfec86743b144836cf169cecd14fed41d2875..9a339881e689e89ecf197d3a284485b3f87cfdc9 100644 (file)
@@ -76,7 +76,7 @@ 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 = 16;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 144;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 160;
 static const unsigned JIT_FRAME_SIZE = 32;
 
 }
index d5171b089ed48a281f7362b86dff1f2aec2ea10c..7dad29c6d22fd48b5f649c2b8b3ce683dc0c4541 100644 (file)
@@ -12,6 +12,6 @@ namespace factor
 and stack-frame-size constants in basis/cpu/x86/64/windows/bootstrap.factor */
 
 static const unsigned LEAF_FRAME_SIZE = 16;
-static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 176;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 192;
 static const unsigned JIT_FRAME_SIZE = 64;
 }