reset_context_objects();
}
+void context::fix_stacks() {
+ if (datastack + sizeof(cell) < datastack_seg->start ||
+ datastack + stack_reserved >= datastack_seg->end)
+ reset_datastack();
+
+ if (retainstack + sizeof(cell) < retainstack_seg->start ||
+ retainstack + stack_reserved >= retainstack_seg->end)
+ reset_retainstack();
+}
+
context::~context() {
delete datastack_seg;
delete retainstack_seg;
faulting_p = true;
- /* If we had an underflow or overflow, data or retain stack pointers
- might be out of bounds, or some of their slots might be
- uninitialized, so reset them before allocating anything. */
- ctx->reset_datastack();
- ctx->reset_retainstack();
+ /* If we had an underflow or overflow, data or retain stack
+ pointers might be out of bounds, so fix them before allocating
+ anything */
+ ctx->fix_stacks();
/* If error was thrown during heap scan, we re-enable the GC */
gc_off = false;
- cell error_handler = special_objects[ERROR_HANDLER_QUOT];
/* If the error handler is set, we rewind any C stack frames and
pass the error to user-space. */
- if (!current_gc && to_boolean(error_handler)) {
+ if (!current_gc && to_boolean(special_objects[ERROR_HANDLER_QUOT])) {
#ifdef FACTOR_DEBUG
/* Doing a GC here triggers all kinds of funny errors */
primitive_compact_gc();
/* The unwind-native-frames subprimitive will clear faulting_p
if it was successfully reached. */
- unwind_native_frames(error_handler, ctx->callstack_top);
+ unwind_native_frames(special_objects[ERROR_HANDLER_QUOT],
+ ctx->callstack_top);
} /* Error was thrown in early startup before error handler is set, so just
crash. */
else {