From 20a98a38fb23d61bf92bb25b2062f0d07f7af91d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Lindqvist?= Date: Thu, 15 Dec 2016 00:49:38 +0100 Subject: [PATCH] VM: undo 7d9bad465ca447dc5b407044a6ce4f49c4f40686 It cause the code heap to run out of memory to soon and without growth, it crashed windows. --- vm/allot.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vm/allot.hpp b/vm/allot.hpp index 49ace31043..b6bb8c1b71 100644 --- a/vm/allot.hpp +++ b/vm/allot.hpp @@ -6,20 +6,20 @@ namespace factor { // Allocates memory inline code_block* factor_vm::allot_code_block(cell size, code_block_type type) { - cell block_size = size + sizeof(code_block); - cell required_free = block_size + code->high_water_mark(); - if (!code->allocator->can_allot_p(required_free)) { + code_block* block = code->allocator->allot(block_size); + if (block == NULL) { // If allocation failed, do a full GC and compact the code heap. // A full GC that occurs as a result of the data heap filling up does not // trigger a compaction. This setup ensures that most GCs do not compact // the code heap, but if the code fills up, it probably means it will be // fragmented after GC anyway, so its best to compact. primitive_compact_gc(); + block = code->allocator->allot(block_size); // Insufficient room even after code GC, give up - if (!code->allocator->can_allot_p(required_free)) { + if (block == NULL) { std::cout << "Code heap used: " << code->allocator->occupied_space() << "\n"; std::cout << "Code heap free: " << code->allocator->free_space << "\n"; @@ -27,7 +27,6 @@ inline code_block* factor_vm::allot_code_block(cell size, fatal_error("Out of memory in allot_code_block", 0); } } - code_block* block = code->allocator->allot(block_size); // next time we do a minor GC, we have to trace this code block, since // the fields of the code_block struct might point into nursery or aging -- 2.34.1