From f05f9199732895782740b1b5afef6ef733bcd72c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 17 Nov 2007 04:31:26 -0500 Subject: [PATCH] Fix code heap compaction bug introduced recently --- vm/code_gc.c | 15 +++++++++++++++ vm/cpu-arm.h | 17 ----------------- vm/cpu-ppc.h | 17 ----------------- vm/cpu-x86.h | 17 ----------------- vm/layouts.h | 17 +++++++++++++++++ 5 files changed, 32 insertions(+), 51 deletions(-) mode change 100644 => 100755 vm/code_gc.c diff --git a/vm/code_gc.c b/vm/code_gc.c old mode 100644 new mode 100755 index 3d74ae0e4c..a088e56024 --- a/vm/code_gc.c +++ b/vm/code_gc.c @@ -379,6 +379,8 @@ CELL compute_heap_forwarding(F_HEAP *heap) scan->forwarding = (F_BLOCK *)address; address += scan->size; } + else if(scan->status == B_MARKED) + critical_error("Why is the block marked?",0); scan = next_block(heap,scan); } @@ -391,6 +393,14 @@ F_COMPILED *forward_xt(F_COMPILED *compiled) return block_to_compiled(compiled_to_block(compiled)->forwarding); } +void forward_frame_xt(F_STACK_FRAME *frame) +{ + CELL offset = (CELL)FRAME_RETURN_ADDRESS(frame) - (CELL)frame_code(frame); + F_COMPILED *forwarded = forward_xt(frame_code(frame)); + frame->xt = (XT)(forwarded + 1); + FRAME_RETURN_ADDRESS(frame) = (XT)((CELL)forwarded + offset); +} + void forward_object_xts(void) { begin_scan(); @@ -413,6 +423,11 @@ void forward_object_xts(void) if(quot->compiledp != F) set_quot_xt(quot,forward_xt(quot->code)); } + else if(type_of(obj) == CALLSTACK_TYPE) + { + F_CALLSTACK *stack = untag_object(obj); + iterate_callstack_object(stack,forward_frame_xt); + } } /* End the heap scan */ diff --git a/vm/cpu-arm.h b/vm/cpu-arm.h index 67dadb2906..8402824579 100755 --- a/vm/cpu-arm.h +++ b/vm/cpu-arm.h @@ -5,23 +5,6 @@ register CELL rs asm("r6"); #define F_FASTCALL -typedef struct -{ - /* In compiled quotation frames, position within the array. - In compiled word frames, unused. */ - CELL scan; - - /* In compiled quotation frames, the quot->array slot. - In compiled word frames, unused. */ - CELL array; - - /* In all compiled frames, the XT on entry. */ - XT xt; - - /* Frame size in bytes */ - CELL size; -} F_STACK_FRAME; - #define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1) void c_to_factor(CELL quot); diff --git a/vm/cpu-ppc.h b/vm/cpu-ppc.h index dc9e0bbbf6..88bbde5661 100755 --- a/vm/cpu-ppc.h +++ b/vm/cpu-ppc.h @@ -1,20 +1,3 @@ -typedef struct -{ - /* In compiled quotation frames, position within the array. - In compiled word frames, unused. */ - CELL scan; - - /* In compiled quotation frames, the quot->array slot. - In compiled word frames, unused. */ - CELL array; - - /* In all compiled frames, the XT on entry. */ - XT xt; - - /* Frame size in bytes */ - CELL size; -} F_STACK_FRAME; - #define FACTOR_CPU_STRING "ppc" #define F_FASTCALL diff --git a/vm/cpu-x86.h b/vm/cpu-x86.h index f119db5761..7983c139af 100755 --- a/vm/cpu-x86.h +++ b/vm/cpu-x86.h @@ -1,22 +1,5 @@ #define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1) -typedef struct -{ - /* In compiled quotation frames, position within the array. - In compiled word frames, unused. */ - CELL scan; - - /* In compiled quotation frames, the quot->array slot. - In compiled word frames, unused. */ - CELL array; - - /* In all compiled frames, the XT on entry. */ - XT xt; - - /* Frame size in bytes */ - CELL size; -} F_STACK_FRAME; - INLINE void flush_icache(CELL start, CELL len) {} F_FASTCALL void c_to_factor(CELL quot); diff --git a/vm/layouts.h b/vm/layouts.h index 94a2fe3a1b..65d9fa4359 100755 --- a/vm/layouts.h +++ b/vm/layouts.h @@ -255,3 +255,20 @@ typedef struct { /* tagged */ CELL length; } F_CALLSTACK; + +typedef struct +{ + /* In compiled quotation frames, position within the array. + In compiled word frames, unused. */ + CELL scan; + + /* In compiled quotation frames, the quot->array slot. + In compiled word frames, unused. */ + CELL array; + + /* In all compiled frames, the XT on entry. */ + XT xt; + + /* Frame size in bytes */ + CELL size; +} F_STACK_FRAME;