From 0f5e0eada5e9a445e09816cd4998fec346936412 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 5 Sep 2011 23:30:13 -0700 Subject: [PATCH] vm: fix high_fragmentation_p assertion --- vm/compaction.cpp | 4 ++-- vm/gc.cpp | 9 +++++---- vm/vm.hpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/vm/compaction.cpp b/vm/compaction.cpp index b7d9b611a3..3d1ed89a47 100644 --- a/vm/compaction.cpp +++ b/vm/compaction.cpp @@ -341,11 +341,11 @@ void factor_vm::collect_compact(bool trace_contexts_p) code->flush_icache(); } -void factor_vm::collect_growing_heap(cell requested_bytes, bool trace_contexts_p) +void factor_vm::collect_growing_heap(cell requested_size, bool trace_contexts_p) { /* Grow the data heap and copy all live objects to the new heap. */ data_heap *old = data; - set_data_heap(data->grow(requested_bytes)); + set_data_heap(data->grow(requested_size)); collect_mark_impl(trace_contexts_p); collect_compact_code_impl(trace_contexts_p); code->flush_icache(); diff --git a/vm/gc.cpp b/vm/gc.cpp index ba4753d400..b1cdaa52af 100755 --- a/vm/gc.cpp +++ b/vm/gc.cpp @@ -143,7 +143,7 @@ void factor_vm::set_current_gc_op(gc_op op) if(gc_events) current_gc->event->op = op; } -void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p) +void factor_vm::gc(gc_op op, cell requested_size, bool trace_contexts_p) { assert(!gc_off); assert(!current_gc); @@ -198,7 +198,7 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p) collect_compact(trace_contexts_p); break; case collect_growing_heap_op: - collect_growing_heap(requested_bytes,trace_contexts_p); + collect_growing_heap(requested_size,trace_contexts_p); break; default: critical_error("Bad GC op",current_gc->op); @@ -298,12 +298,13 @@ void factor_vm::primitive_compact_gc() object *factor_vm::allot_large_object(cell type, cell size) { /* If tenured space does not have enough room, collect and compact */ - if(!data->tenured->can_allot_p(size + data->high_water_mark())) + cell requested_size = size + data->high_water_mark(); + if(!data->tenured->can_allot_p(requested_size)) { primitive_compact_gc(); /* If it still won't fit, grow the heap */ - if(!data->tenured->can_allot_p(size)) + if(!data->tenured->can_allot_p(requested_size)) { gc(collect_growing_heap_op, size, /* requested size */ diff --git a/vm/vm.hpp b/vm/vm.hpp index 9539ba04e1..28e9c8c1aa 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -314,8 +314,8 @@ struct factor_vm void collect_compact_impl(bool trace_contexts_p); void collect_compact_code_impl(bool trace_contexts_p); void collect_compact(bool trace_contexts_p); - void collect_growing_heap(cell requested_bytes, bool trace_contexts_p); - void gc(gc_op op, cell requested_bytes, bool trace_contexts_p); + void collect_growing_heap(cell requested_size, bool trace_contexts_p); + void gc(gc_op op, cell requested_size, bool trace_contexts_p); void scrub_context(context *ctx); void scrub_contexts(); void primitive_minor_gc();