]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/cpu/x86/bootstrap.factor
vm: strip out call-counting profiler
[factor.git] / basis / cpu / x86 / bootstrap.factor
index 480b0efa90aa020373109bc1348b5e7ea24229d6..c600fa5309185bc31425f3c32ab24a04093bbf1e 100644 (file)
@@ -76,19 +76,6 @@ big-endian off
     HEX: ffff RET f rc-absolute-2 rel-untagged
 ] callback-stub jit-define
 
-[
-    ! Load word
-    temp0 0 MOV f rc-absolute-cell rel-literal
-    ! Bump profiling counter
-    temp0 profile-count-offset [+] 1 tag-fixnum ADD
-    ! Load word->code
-    temp0 temp0 word-code-offset [+] MOV
-    ! Compute word entry point
-    temp0 compiled-header-size ADD
-    ! Jump to entry point
-    temp0 JMP
-] jit-profiling jit-define
-
 [
     ! load literal
     temp0 0 MOV f rc-absolute-cell rel-literal
@@ -102,8 +89,8 @@ big-endian off
     0 CALL f rc-relative rel-word-pic
 ] jit-word-call jit-define
 
-! 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
+! The *-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.
 
 [| |
@@ -112,28 +99,37 @@ big-endian off
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
     frame-size jit-signal-handler-epilog
+    0 RET
 ] \ signal-handler define-sub-primitive
 
+: leaf-frame-size ( -- n ) 4 bootstrap-cells ;
+
 [| |
     jit-signal-handler-prolog :> frame-size
     jit-save-context
     temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
     temp0 CALL
-    ! Stack at this point has a fake stack frame set up to represent the
-    ! leaf procedure we interrupted. We must tear down that frame in
-    ! addition to our own before resuming.
-    ! Grab our frame's return address and place it just underneath the leaf proc's
-    ! return address, since we can't touch any registers once they've been
-    ! restored. If we got this far there should be no faults here and we
-    ! can get away with corrupting the stack frame.
-    temp0 stack-reg frame-size bootstrap-cell - [+] MOV
-    stack-reg frame-size stack-frame-size + 2 bootstrap-cells - [+] temp0 MOV
-
-    ! Pop enough of the fake frame to leave the resume address at the top of the
-    ! stack when we RET.
-    frame-size stack-frame-size + bootstrap-cell - jit-signal-handler-epilog
+    frame-size jit-signal-handler-epilog
+    ! Pop the fake leaf frame along with our return address
+    leaf-frame-size bootstrap-cell - RET
 ] \ leaf-signal-handler define-sub-primitive
 
+[| |
+    jit-signal-handler-prolog :> frame-size
+    temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
+    temp0 CALL
+    frame-size jit-signal-handler-epilog
+    red-zone-size RET
+] \ ffi-signal-handler define-sub-primitive
+
+[| |
+    jit-signal-handler-prolog :> frame-size
+    temp0 vm-reg vm-signal-handler-addr-offset [+] MOV
+    temp0 CALL
+    frame-size jit-signal-handler-epilog
+    red-zone-size 16 bootstrap-cell - + RET
+] \ ffi-leaf-signal-handler define-sub-primitive
+
 [
     ! load boolean
     temp0 ds-reg [] MOV
@@ -230,7 +226,6 @@ big-endian off
 ] jit-execute jit-define
 
 [
-    jit-safepoint
     stack-reg stack-frame-size bootstrap-cell - ADD
 ] jit-epilog jit-define