Factor can now recover from certain out of memory conditions
parent
2d1c7f5e0f
commit
f9f708739e
|
@ -60,6 +60,10 @@ DEFER: objc-error. ( alien -- )
|
||||||
: callstack-underflow. "Call" stack-underflow. ;
|
: callstack-underflow. "Call" stack-underflow. ;
|
||||||
: callstack-overflow. "Call" stack-overflow. ;
|
: callstack-overflow. "Call" stack-overflow. ;
|
||||||
|
|
||||||
|
: memory-error.
|
||||||
|
"Allocation of " write second pprint
|
||||||
|
" bytes failed due to insufficient room in data heap" print ;
|
||||||
|
|
||||||
: kernel-error ( error -- word )
|
: kernel-error ( error -- word )
|
||||||
#! Kernel errors are indexed by integers.
|
#! Kernel errors are indexed by integers.
|
||||||
second {
|
second {
|
||||||
|
@ -80,7 +84,8 @@ DEFER: objc-error. ( alien -- )
|
||||||
retainstack-overflow.
|
retainstack-overflow.
|
||||||
callstack-underflow.
|
callstack-underflow.
|
||||||
callstack-overflow.
|
callstack-overflow.
|
||||||
objc-error.
|
memory-error.
|
||||||
|
objc-error.
|
||||||
} nth ;
|
} nth ;
|
||||||
|
|
||||||
M: kernel-error error. dup kernel-error execute ;
|
M: kernel-error error. dup kernel-error execute ;
|
||||||
|
|
|
@ -253,7 +253,12 @@ INLINE void maybe_gc(CELL a)
|
||||||
if(nursery.here + a + ALLOT_BUFFER_ZONE > nursery.limit)
|
if(nursery.here + a + ALLOT_BUFFER_ZONE > nursery.limit)
|
||||||
garbage_collection(NURSERY,false);
|
garbage_collection(NURSERY,false);
|
||||||
if(nursery.here + a + ALLOT_BUFFER_ZONE > nursery.limit)
|
if(nursery.here + a + ALLOT_BUFFER_ZONE > nursery.limit)
|
||||||
critical_error("Out of memory in maybe_gc",0);
|
{
|
||||||
|
if(nursery.here + ALLOT_BUFFER_ZONE > nursery.limit)
|
||||||
|
critical_error("Out of memory in maybe_gc",0);
|
||||||
|
else
|
||||||
|
memory_error(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void *allot(CELL a)
|
INLINE void *allot(CELL a)
|
||||||
|
|
5
vm/run.c
5
vm/run.c
|
@ -349,3 +349,8 @@ void type_error(CELL type, CELL tagged)
|
||||||
{
|
{
|
||||||
general_error(ERROR_TYPE,tag_fixnum(type),tagged,true);
|
general_error(ERROR_TYPE,tag_fixnum(type),tagged,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void memory_error(CELL bytes)
|
||||||
|
{
|
||||||
|
general_error(ERROR_MEMORY,allot_cell(bytes),F,false);
|
||||||
|
}
|
||||||
|
|
2
vm/run.h
2
vm/run.h
|
@ -168,6 +168,7 @@ typedef enum
|
||||||
ERROR_RS_OVERFLOW,
|
ERROR_RS_OVERFLOW,
|
||||||
ERROR_CS_UNDERFLOW,
|
ERROR_CS_UNDERFLOW,
|
||||||
ERROR_CS_OVERFLOW,
|
ERROR_CS_OVERFLOW,
|
||||||
|
ERROR_MEMORY,
|
||||||
ERROR_OBJECTIVE_C
|
ERROR_OBJECTIVE_C
|
||||||
} F_ERRORTYPE;
|
} F_ERRORTYPE;
|
||||||
|
|
||||||
|
@ -192,6 +193,7 @@ void general_error(F_ERRORTYPE error, CELL arg1, CELL arg2, bool keep_stacks);
|
||||||
void memory_protection_error(CELL addr, int signal);
|
void memory_protection_error(CELL addr, int signal);
|
||||||
void signal_error(int signal);
|
void signal_error(int signal);
|
||||||
void type_error(CELL type, CELL tagged);
|
void type_error(CELL type, CELL tagged);
|
||||||
|
void memory_error(CELL bytes);
|
||||||
void primitive_throw(void);
|
void primitive_throw(void);
|
||||||
void primitive_die(void);
|
void primitive_die(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue