OK, garbage collection is now working a little bit.
This commit is contained in:
parent
235d455b80
commit
9425506e2a
5 changed files with 45 additions and 30 deletions
|
|
@ -209,13 +209,13 @@ struct pso_pointer write( struct pso_pointer frame_pointer ) {
|
|||
bool nl_before = c_truep( fetch_arg( frame, 3 ) );
|
||||
bool nl_after = c_truep( fetch_arg( frame, 4 ) );
|
||||
struct pso_pointer result = object;
|
||||
URL_FILE *output = writep( stream )
|
||||
? pointer_to_object( stream )->payload.stream.stream
|
||||
: file_to_url_file( stdout );
|
||||
struct pso2* stream_obj = pointer_to_object( stream );
|
||||
|
||||
if ( writep( stream ) ) {
|
||||
inc_ref( stream );
|
||||
|
||||
URL_FILE *output = stream_obj->payload.stream.stream;
|
||||
|
||||
if ( nl_before )
|
||||
url_fputwc( L'\n', output );
|
||||
|
||||
|
|
|
|||
|
|
@ -199,6 +199,10 @@ struct pso_pointer inc_ref( struct pso_pointer pointer ) {
|
|||
struct pso_pointer dec_ref( struct pso_pointer pointer ) {
|
||||
struct pso2 *object = pointer_to_object( pointer );
|
||||
|
||||
if (freep(pointer)) {
|
||||
fputws( L"WARNING: SHOULDN'T: Decrementing free object?\n", stderr);
|
||||
}
|
||||
|
||||
if ( !c_nilp( pointer ) && object->header.count > 0
|
||||
&& object->header.count != MAXREFERENCE ) {
|
||||
object->header.count--;
|
||||
|
|
@ -217,12 +221,11 @@ struct pso_pointer dec_ref( struct pso_pointer pointer ) {
|
|||
debug_println( DEBUG_ALLOC );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
if ( object->header.count == 0 ) {
|
||||
free_object( pointer );
|
||||
pointer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
return pointer;
|
||||
}
|
||||
|
|
@ -259,8 +262,6 @@ struct pso_pointer free_object( struct pso_pointer pointer ) {
|
|||
object->payload.words[i] = 0;
|
||||
}
|
||||
|
||||
push_freelist( pointer );
|
||||
|
||||
#ifdef DEBUG
|
||||
debug_printf( DEBUG_ALLOC, 0,
|
||||
L"Freeing object of type %3.3s, size class %d, at page %d, offset %d.\n",
|
||||
|
|
@ -271,5 +272,10 @@ struct pso_pointer free_object( struct pso_pointer pointer ) {
|
|||
|
||||
allocation_table[size_class][allocation_table_freed]++;
|
||||
#endif
|
||||
|
||||
strncpy((char*) (object->header.tag.bytes.
|
||||
mnemonic ), FREETAG, TAGLENGTH );
|
||||
|
||||
push_freelist( pointer );
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ struct pso_pointer make_exception( struct pso_pointer frame_pointer ) {
|
|||
if ( !c_nilp( result ) && !exceptionp( result ) ) {
|
||||
struct pso3 *object = ( struct pso3 * ) pointer_to_object( result );
|
||||
|
||||
object->payload.exception.message = message;
|
||||
object->payload.exception.message = inc_ref(message);
|
||||
object->payload.exception.stack =
|
||||
stackp( frame_pointer ) ? frame_pointer : nil;
|
||||
stackp( frame_pointer ) ? inc_ref(frame_pointer) : nil;
|
||||
object->payload.exception.meta = ( consp( meta )
|
||||
|| hashtabp( meta ) ) ? meta : nil;
|
||||
object->payload.exception.cause = exceptionp( cause ) ? cause : nil;
|
||||
|| hashtabp( meta ) ) ? inc_ref(meta) : nil;
|
||||
object->payload.exception.cause = exceptionp( cause ) ? inc_ref(cause) : nil;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ struct pso_pointer make_frame( int arg_count, struct pso_pointer previous,
|
|||
new_frame->payload.stack_frame.depth = 0;
|
||||
}
|
||||
|
||||
new_frame->payload.stack_frame.previous = inc_ref( previous);
|
||||
|
||||
debug_printf( DEBUG_ALLOC, 1, L"depth is %d...\n",
|
||||
new_frame->payload.stack_frame.depth );
|
||||
|
||||
|
|
@ -127,7 +129,7 @@ struct pso_pointer make_frame_with_env( int arg_count,
|
|||
arg_count, new_pointer.page, new_pointer.offset );
|
||||
#endif
|
||||
|
||||
prev_frame->payload.stack_frame.previous = previous;
|
||||
prev_frame->payload.stack_frame.previous = inc_ref(previous);
|
||||
|
||||
if ( stackp( previous ) ) {
|
||||
new_frame->payload.stack_frame.depth =
|
||||
|
|
@ -201,7 +203,7 @@ struct pso_pointer make_frame_with_arglist_and_env( struct pso_pointer
|
|||
arg_count, new_pointer.page, new_pointer.offset );
|
||||
#endif
|
||||
|
||||
prev_frame->payload.stack_frame.previous = previous;
|
||||
prev_frame->payload.stack_frame.previous = inc_ref( previous);
|
||||
|
||||
if ( stackp( previous ) ) {
|
||||
new_frame->payload.stack_frame.depth =
|
||||
|
|
@ -277,6 +279,12 @@ struct pso_pointer destroy_stack_frame( struct pso_pointer fp,
|
|||
dec_ref( frame->payload.stack_frame.arg[i] );
|
||||
}
|
||||
|
||||
frame->payload.stack_frame.previous = nil;
|
||||
frame->payload.stack_frame.function = nil;
|
||||
frame->payload.stack_frame.more = nil;
|
||||
frame->payload.stack_frame.locals = nil;
|
||||
frame->payload.stack_frame.env = nil;
|
||||
|
||||
frame->payload.stack_frame.args = 0;
|
||||
frame->payload.stack_frame.depth = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ int main( int argc, char *argv[] ) {
|
|||
bool show_prompt = false;
|
||||
char *infilename = NULL;
|
||||
|
||||
if ( initialise_io( ) != 0 ) {
|
||||
fputs( "Failed to initialise I/O subsystem\n", stderr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
while ( ( option = getopt( argc, argv, "dhi:ps:v:" ) ) != -1 ) {
|
||||
switch ( option ) {
|
||||
case 'd':
|
||||
|
|
@ -109,10 +114,6 @@ int main( int argc, char *argv[] ) {
|
|||
}
|
||||
|
||||
setlocale( LC_ALL, "" );
|
||||
if ( initialise_io( ) != 0 ) {
|
||||
fputs( "Failed to initialise I/O subsystem\n", stderr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
oblist = initialise_node( 0 );
|
||||
debug_print( L"Oblist: ", DEBUG_BOOTSTRAP, 0 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue