]> gitweb.factorcode.org Git - factor.git/commitdiff
cpu.*.bootstrap: clear faulting flag directly
authorJoe Groff <arcata@gmail.com>
Sat, 12 Nov 2011 20:57:24 +0000 (12:57 -0800)
committerJoe Groff <arcata@gmail.com>
Sat, 12 Nov 2011 21:02:57 +0000 (13:02 -0800)
No reason to go through a safepoint in unwind-native-frames really.

basis/compiler/constants/constants.factor
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/bootstrap.factor
basis/vm/vm.factor
vm/errors.cpp
vm/vm.hpp

index 85aa5c443938bdb3552c323498ba3018982c781b..7951c1ef0bc690538efd1fac1bd9e3849c3dd542 100644 (file)
@@ -30,6 +30,7 @@ CONSTANT: deck-bits 18
 : vm-context-offset ( -- n ) 0 bootstrap-cells ; inline
 : vm-spare-context-offset ( -- n ) 1 bootstrap-cells ; inline
 : vm-signal-handler-addr-offset ( -- n ) 8 bootstrap-cells ; inline
+: vm-fault-flag-offset ( -- n ) 9 bootstrap-cells ; inline
 : context-callstack-top-offset ( -- n ) 0 bootstrap-cells ; inline
 : context-callstack-bottom-offset ( -- n ) 1 bootstrap-cells ; inline
 : context-datastack-offset ( -- n ) 2 bootstrap-cells ; inline
index c234d03a441f653be307c3d026f27d87eb19fc3f..23b05548b0a859ec95319459318fe38b3b0d06e3 100755 (executable)
@@ -140,16 +140,14 @@ IN: bootstrap.x86
 [ jit-jump-quot ]
 \ (call) define-combinator-primitive
 
-: (jit-safepoint) ( -- )
-    0 EAX MOVABS rc-absolute rel-safepoint ;
 [
     ! Load ds and rs registers
     jit-load-vm
     jit-load-context
     jit-restore-context
 
-    ! Safepoint to clear the faulting flag in the VM
-     (jit-safepoint)
+    ! clear the fault flag
+    vm-reg vm-fault-flag-offset [+] 0 MOV
 
     ! Windows-specific setup
     ctx-reg jit-update-seh
@@ -400,7 +398,9 @@ IN: bootstrap.x86
     EAX EDX [] MOV
     jit-jump-quot ;
 
-[ (jit-safepoint) ] \ jit-safepoint jit-define
+[
+    0 EAX MOVABS rc-absolute rel-safepoint
+] \ jit-safepoint jit-define
 
 [
     jit-start-context-and-delete
index 77e76db9b7c1623b934a9c4180f8f03bbcf8a200..e299dbf34835047830587793dbf5c04e57898693 100755 (executable)
@@ -122,9 +122,6 @@ IN: bootstrap.x86
 [ jit-jump-quot ]
 \ (call) define-combinator-primitive
 
-: (jit-safepoint)
-    0 [RIP+] EAX MOV rc-relative rel-safepoint ;
-
 [
     ! Unwind stack frames
     RSP arg2 MOV
@@ -137,8 +134,8 @@ IN: bootstrap.x86
     jit-load-context
     jit-restore-context
 
-    ! Safepoint to clear the faulting flag in the VM
-    (jit-safepoint)
+    ! Clear the fault flag
+    vm-reg vm-fault-flag-offset [+] 0 MOV
 
     ! Call quotation
     jit-jump-quot
@@ -342,7 +339,9 @@ IN: bootstrap.x86
     jit-push-param
     jit-jump-quot ;
 
-[ (jit-safepoint) ] \ jit-safepoint jit-define
+[
+    0 [RIP+] EAX MOV rc-relative rel-safepoint
+] \ jit-safepoint jit-define
 
 [
     jit-start-context-and-delete
index 46bf2954dd55e86a0652f930086701cc92042bad..3f18699c4d3e0ba48e54a204e7c1eda4ba40ac39 100644 (file)
@@ -31,6 +31,7 @@ STRUCT: vm
 { cards-offset cell }
 { decks-offset cell }
 { signal-handler-addr cell }
+{ faulting? cell }
 { special-objects cell[special-object-count] } ;
 
 : vm-field-offset ( field -- offset ) vm offset-of ; inline
index 14a8700dcff6172b912a8fa189cd77dd24fc29d0..b775eec01561123e17cb724978de073dd3052cd3 100755 (executable)
@@ -73,9 +73,8 @@ void factor_vm::general_error(vm_error_type error, cell arg1, cell arg2)
 
                ctx->push(error_object);
 
-               /* Guard the safepoint, which will clear faulting_p if unwind-native-frames
-               succeeds */
-               code->guard_safepoint();
+               /* The unwind-native-frames subprimitive will clear faulting_p
+               if it was successfully reached. */
                unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
                        ctx->callstack_top);
        }
index 5cd8b1f05c2308f4610517bf75f303238c7616e7..cfe77bd7fd646bda34cbab619fe0985927a95b26 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -28,6 +28,9 @@ struct factor_vm
        /* cdecl signal handler address, used by signal handler subprimitives */
        cell signal_handler_addr;
 
+       /* are we handling a memory error? used to detect double faults */
+       cell faulting_p;
+
        /* Various special objects, accessed by special-object and
        set-special-object primitives */
        cell special_objects[special_object_count];
@@ -142,7 +145,6 @@ struct factor_vm
        segment *signal_callstack_seg;
 
        /* Are we already handling a fault? Used to catch double memory faults */
-       bool faulting_p;
        static bool fatal_erroring_p;
 
        /* Safepoint state */