From 99a42aa0891e24ca03c68c9329cecb7e243cb44d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 26 Sep 2007 00:34:10 -0400 Subject: [PATCH] Fix crash if GC runs during lazy_jit_compile --- vm/cpu-ppc.S | 2 -- vm/cpu-x86.32.S | 2 +- vm/cpu-x86.64.S | 2 +- vm/jit.c | 7 ++++++- vm/jit.h | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/vm/cpu-ppc.S b/vm/cpu-ppc.S index ba539c1fdc..295fffa1a5 100644 --- a/vm/cpu-ppc.S +++ b/vm/cpu-ppc.S @@ -173,9 +173,7 @@ DEF(void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)): DEF(void,lazy_jit_compile,(CELL quot)): mr r4,r1 /* save stack pointer */ PROLOGUE - SAVE(r3,18) /* save quot */ bl MANGLE(jit_compile) - RESTORE(r3,18) EPILOGUE JUMP_QUOT /* call the quotation */ diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S index 19a735ec88..d8630ce9b3 100644 --- a/vm/cpu-x86.32.S +++ b/vm/cpu-x86.32.S @@ -20,7 +20,7 @@ and the callstack top is passed in EDX */ pop %ebp ; \ pop %ebx -#define QUOT_XT_OFFSET 5 +#define QUOT_XT_OFFSET 9 #define PROFILING_OFFSET 25 #define WORD_DEF_OFFSET 13 #define WORD_XT_OFFSET 29 diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S index 1725c0cbd5..6cddb7e53b 100644 --- a/vm/cpu-x86.64.S +++ b/vm/cpu-x86.64.S @@ -20,7 +20,7 @@ pop %rbp ; \ pop %rbx -#define QUOT_XT_OFFSET 13 +#define QUOT_XT_OFFSET 21 #define PROFILING_OFFSET 53 #define WORD_DEF_OFFSET 29 #define WORD_XT_OFFSET 61 diff --git a/vm/jit.c b/vm/jit.c index d10f25c325..6faf0a6a17 100644 --- a/vm/jit.c +++ b/vm/jit.c @@ -34,10 +34,12 @@ bool jit_stack_frame_p(F_ARRAY *array) return false; } -FASTCALL void jit_compile(CELL tagged, F_STACK_FRAME *stack) +FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack) { stack_chain->callstack_top = stack; + REGISTER_ROOT(tagged); + F_QUOTATION *quot = untag_quotation(tagged); F_ARRAY *array = untag_object(quot->array); @@ -154,6 +156,9 @@ FASTCALL void jit_compile(CELL tagged, F_STACK_FRAME *stack) UNREGISTER_UNTAGGED(quot); quot->xt = xt; quot->compiled = T; + + UNREGISTER_ROOT(tagged); + return tagged; } XT quot_offset_to_pc(F_QUOTATION *quot, F_FIXNUM offset) diff --git a/vm/jit.h b/vm/jit.h index 26a67490f4..a9f1399472 100644 --- a/vm/jit.h +++ b/vm/jit.h @@ -1,2 +1,2 @@ -DLLEXPORT FASTCALL void jit_compile(CELL tagged, F_STACK_FRAME *stack); +DLLEXPORT FASTCALL CELL jit_compile(CELL tagged, F_STACK_FRAME *stack); XT quot_offset_to_pc(F_QUOTATION *quot, F_FIXNUM offset);