]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: frame size for signal handler code blocks
authorJoe Groff <arcata@gmail.com>
Wed, 30 Nov 2011 20:39:21 +0000 (12:39 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 14 Dec 2011 17:56:46 +0000 (09:56 -0800)
12 files changed:
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
vm/cpu-x86.32.hpp
vm/inline_cache.cpp
vm/jit.cpp
vm/jit.hpp
vm/os-linux-x86.64.hpp
vm/os-macosx-x86.64.hpp
vm/os-windows.64.hpp
vm/quotations.cpp

index 5930ba910a68a5d47fd304963cf0799029937df3..268597d41e4b3216691da73cfe94799871995851 100755 (executable)
@@ -10,6 +10,7 @@ IN: bootstrap.x86
 4 \ cell set
 
 : leaf-stack-frame-size ( -- n ) 4 bootstrap-cells ;
+: signal-handler-stack-frame-size ( -- n ) 12 bootstrap-cells ;
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
 : shift-arg ( -- reg ) ECX ;
 : div-arg ( -- reg ) EAX ;
@@ -104,7 +105,7 @@ IN: bootstrap.x86
 ! peform their own prolog/epilog preserving registers.
 
 :: jit-signal-handler-prolog ( -- frame-size )
-    stack-frame-size 8 bootstrap-cells + :> 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
index 8ed80af2c694c530c681f019333adc5143b899c5..8367b54ae48bf30f21cda1a10d6f6034fc42e0f8 100755 (executable)
@@ -97,6 +97,8 @@ 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
     ! 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
index deeb31cd77171211f952d8049ace92c1cc5cc046..f5265dc0201c24b549e45b9d7404afc7acf5e149 100644 (file)
@@ -6,6 +6,7 @@ sequences system vocabs ;
 IN: bootstrap.x86
 
 : leaf-stack-frame-size ( -- n ) 4 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 cc701a6b6349c233435df20f1fcededf76f8a320..00f1cc1acba8cc3c3245e395f4ee967675561e8b 100644 (file)
@@ -8,6 +8,7 @@ IN: bootstrap.x86
 DEFER: stack-reg
 
 : leaf-stack-frame-size ( -- n ) 4 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 0bc90416f1a26b0d3a6e7cf0af3d2e72ff65806b..c0afc9f683b4756e1da2efb1c214e6b0f641b4b5 100644 (file)
@@ -3,9 +3,10 @@ namespace factor
 
 #define FACTOR_CPU_STRING "x86.32"
 
-/* Must match the leaf-stack-frame-size stack-frame-size constants in
-cpu/x86/32/bootstrap.factor */
+/* Must match the leaf-stack-frame-size, signal-handler-stack-frame-size,
+and stack-frame-size constants in cpu/x86/32/bootstrap.factor */
 static const unsigned LEAF_FRAME_SIZE = 16;
+static const unsigned SIGNAL_HANDLER_STACK_FRAME_SIZE = 48;
 static const unsigned JIT_FRAME_SIZE = 32;
 
 }
index b7cd7630acd42e4b7848fef29d392f9f0965ccf2..4f1e907d7f474c231816dd38a71ede45c10cd6bf 100755 (executable)
@@ -141,7 +141,7 @@ code_block *factor_vm::compile_inline_cache(fixnum index,
                                 methods.value(),
                                 cache_entries.value(),
                                 tail_call_p);
-       code_block *code = jit.to_code_block();
+       code_block *code = jit.to_code_block(JIT_FRAME_SIZE);
        initialize_code_block(code);
        return code;
 }
index 29eb6f19db23c7dbcd1d9f7a833ed725e6bb6905..9f3d7b5ed765549492d32e654f05c98b42ba6cc9 100644 (file)
@@ -124,7 +124,7 @@ void jit::compute_position(cell offset_)
 }
 
 /* Allocates memory */
-code_block *jit::to_code_block()
+code_block *jit::to_code_block(cell frame_size)
 {
        /* Emit dummy GC info */
        code.grow_bytes(alignment_for(code.count + 4,data_alignment));
@@ -144,7 +144,7 @@ code_block *jit::to_code_block()
                relocation.elements.value(),
                parameters.elements.value(),
                literals.elements.value(),
-               JIT_FRAME_SIZE);
+               frame_size);
 }
 
 }
index 1024751747f2a068930eb64b3d65e8423d204d3f..a20788a4991ce0d5965b8c419a1b247aae97d5e3 100644 (file)
@@ -68,7 +68,7 @@ struct jit {
        }
 
        
-       code_block *to_code_block();
+       code_block *to_code_block(cell frame_size);
 
 private:
        jit(const jit&);
index 94e102c37ff5d97c609c3193265ea0a37d6c5a59..366a1357517e334dc79e9e0be9777183a0e77f6c 100644 (file)
@@ -28,9 +28,10 @@ inline static void uap_clear_fpu_status(void *uap)
 
 #define UAP_STACK_POINTER_TYPE greg_t
 
-/* Must match the leaf-stack-frame-size and stack-frame-size constants
-in basis/cpu/x86/64/unix/bootstrap.factor */
+/* 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 JIT_FRAME_SIZE = 32;
 
 }
index d8bb82167869fa9b1a82343f9adeaf2e63a8d319..2b1c02beb0d2d8880c30c1f64dd0bf5da5d07f6f 100644 (file)
@@ -73,9 +73,10 @@ inline static void uap_clear_fpu_status(void *uap)
        mach_clear_fpu_status(UAP_FS(uap));
 }
 
-/* Must match the leaf-stack-frame-size and stack-frame-size constants
-in basis/cpu/x86/64/unix/bootstrap.factor */
+/* 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 JIT_FRAME_SIZE = 32;
 
 }
index 42b4362b1a069193a193e7420a993aae7f8af6c8..19b43a74f53ce92d6c8e4e4ede36246672e5c53c 100644 (file)
@@ -8,9 +8,10 @@ namespace factor
 
 #define MXCSR(ctx) (ctx)->MxCsr
 
-/* Must match the leaf-stack-frame-size and stack-frame-size constants
-in basis/cpu/x86/64/windows/bootstrap.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 JIT_FRAME_SIZE = 64;
 }
index 0f591e35038d63a3fa68ce16ed79ca621dce1fd9..dc84ef506e5e14edbbbf2c7d0c3df9d1f7d2bb3c 100755 (executable)
@@ -319,7 +319,11 @@ code_block *factor_vm::jit_compile_quot(cell owner_, cell quot_, bool relocating
        compiler.init_quotation(quot.value());
        compiler.iterate_quotation();
 
-       code_block *compiled = compiler.to_code_block();
+       cell frame_size = compiler.special_subprimitive_p(owner_)
+               ? SIGNAL_HANDLER_STACK_FRAME_SIZE
+               : JIT_FRAME_SIZE;
+
+       code_block *compiled = compiler.to_code_block(frame_size);
 
        if(relocating) initialize_code_block(compiled);