vm: use C++ exceptions instead of longjmp(), to make Windows crash more
parent
d24ce84dde
commit
b740a1fe5d
|
@ -1,6 +1,8 @@
|
||||||
namespace factor
|
namespace factor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct must_start_gc_again {};
|
||||||
|
|
||||||
template<typename TargetGeneration, typename Policy> struct data_workhorse {
|
template<typename TargetGeneration, typename Policy> struct data_workhorse {
|
||||||
factor_vm *parent;
|
factor_vm *parent;
|
||||||
TargetGeneration *target;
|
TargetGeneration *target;
|
||||||
|
@ -27,8 +29,7 @@ template<typename TargetGeneration, typename Policy> struct data_workhorse {
|
||||||
{
|
{
|
||||||
cell size = untagged->size();
|
cell size = untagged->size();
|
||||||
object *newpointer = target->allot(size);
|
object *newpointer = target->allot(size);
|
||||||
/* XXX not exception-safe */
|
if(!newpointer) throw must_start_gc_again();
|
||||||
if(!newpointer) longjmp(parent->current_gc->gc_unwind,1);
|
|
||||||
|
|
||||||
memcpy(newpointer,untagged,size);
|
memcpy(newpointer,untagged,size);
|
||||||
untagged->forward_to(newpointer);
|
untagged->forward_to(newpointer);
|
||||||
|
|
18
vm/gc.cpp
18
vm/gc.cpp
|
@ -135,12 +135,10 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
|
||||||
|
|
||||||
/* Keep trying to GC higher and higher generations until we don't run out
|
/* Keep trying to GC higher and higher generations until we don't run out
|
||||||
of space */
|
of space */
|
||||||
if(setjmp(current_gc->gc_unwind))
|
for(;;)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
/* We come back here if a generation is full */
|
|
||||||
start_gc_again();
|
|
||||||
}
|
|
||||||
|
|
||||||
current_gc->event->op = current_gc->op;
|
current_gc->event->op = current_gc->op;
|
||||||
|
|
||||||
switch(current_gc->op)
|
switch(current_gc->op)
|
||||||
|
@ -180,6 +178,16 @@ void factor_vm::gc(gc_op op, cell requested_bytes, bool trace_contexts_p)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch(const must_start_gc_again e)
|
||||||
|
{
|
||||||
|
/* We come back here if a generation is full */
|
||||||
|
start_gc_again();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end_gc();
|
end_gc();
|
||||||
|
|
||||||
delete current_gc;
|
delete current_gc;
|
||||||
|
|
|
@ -45,7 +45,6 @@ struct gc_event {
|
||||||
struct gc_state {
|
struct gc_state {
|
||||||
gc_op op;
|
gc_op op;
|
||||||
u64 start_time;
|
u64 start_time;
|
||||||
jmp_buf gc_unwind;
|
|
||||||
gc_event *event;
|
gc_event *event;
|
||||||
|
|
||||||
explicit gc_state(gc_op op_, factor_vm *parent);
|
explicit gc_state(gc_op op_, factor_vm *parent);
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <setjmp.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
Loading…
Reference in New Issue