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_before = c_truep( fetch_arg( frame, 3 ) );
|
||||||
bool nl_after = c_truep( fetch_arg( frame, 4 ) );
|
bool nl_after = c_truep( fetch_arg( frame, 4 ) );
|
||||||
struct pso_pointer result = object;
|
struct pso_pointer result = object;
|
||||||
URL_FILE *output = writep( stream )
|
struct pso2* stream_obj = pointer_to_object( stream );
|
||||||
? pointer_to_object( stream )->payload.stream.stream
|
|
||||||
: file_to_url_file( stdout );
|
|
||||||
|
|
||||||
if ( writep( stream ) ) {
|
if ( writep( stream ) ) {
|
||||||
inc_ref( stream );
|
inc_ref( stream );
|
||||||
|
|
||||||
|
URL_FILE *output = stream_obj->payload.stream.stream;
|
||||||
|
|
||||||
if ( nl_before )
|
if ( nl_before )
|
||||||
url_fputwc( L'\n', output );
|
url_fputwc( L'\n', output );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,10 @@ struct pso_pointer inc_ref( struct pso_pointer pointer ) {
|
||||||
*/
|
*/
|
||||||
struct pso_pointer dec_ref( struct pso_pointer pointer ) {
|
struct pso_pointer dec_ref( struct pso_pointer pointer ) {
|
||||||
struct pso2 *object = pointer_to_object( 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
|
if ( !c_nilp( pointer ) && object->header.count > 0
|
||||||
&& object->header.count != MAXREFERENCE ) {
|
&& object->header.count != MAXREFERENCE ) {
|
||||||
|
|
@ -217,12 +221,11 @@ struct pso_pointer dec_ref( struct pso_pointer pointer ) {
|
||||||
debug_println( DEBUG_ALLOC );
|
debug_println( DEBUG_ALLOC );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( object->header.count == 0 ) {
|
|
||||||
free_object( pointer );
|
|
||||||
pointer = nil;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ( object->header.count == 0 ) {
|
||||||
|
free_object( pointer );
|
||||||
|
pointer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
return pointer;
|
return pointer;
|
||||||
}
|
}
|
||||||
|
|
@ -259,17 +262,20 @@ struct pso_pointer free_object( struct pso_pointer pointer ) {
|
||||||
object->payload.words[i] = 0;
|
object->payload.words[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
push_freelist( pointer );
|
#ifdef DEBUG
|
||||||
|
debug_printf( DEBUG_ALLOC, 0,
|
||||||
#ifdef DEBUG
|
L"Freeing object of type %3.3s, size class %d, at page %d, offset %d.\n",
|
||||||
debug_printf( DEBUG_ALLOC, 0,
|
( ( char * ) ( object->header.tag.bytes.mnemonic ) ),
|
||||||
L"Freeing object of type %3.3s, size class %d, at page %d, offset %d.\n",
|
(int)object->header.tag.bytes.size_class,
|
||||||
( ( char * ) ( object->header.tag.bytes.mnemonic ) ),
|
pointer.page, pointer.offset, object->header.count
|
||||||
(int)object->header.tag.bytes.size_class,
|
);
|
||||||
pointer.page, pointer.offset, object->header.count
|
|
||||||
);
|
allocation_table[size_class][allocation_table_freed]++;
|
||||||
|
#endif
|
||||||
|
|
||||||
allocation_table[size_class][allocation_table_freed]++;
|
strncpy((char*) (object->header.tag.bytes.
|
||||||
#endif
|
mnemonic ), FREETAG, TAGLENGTH );
|
||||||
|
|
||||||
|
push_freelist( pointer );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,12 +59,12 @@ struct pso_pointer make_exception( struct pso_pointer frame_pointer ) {
|
||||||
if ( !c_nilp( result ) && !exceptionp( result ) ) {
|
if ( !c_nilp( result ) && !exceptionp( result ) ) {
|
||||||
struct pso3 *object = ( struct pso3 * ) pointer_to_object( 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 =
|
object->payload.exception.stack =
|
||||||
stackp( frame_pointer ) ? frame_pointer : nil;
|
stackp( frame_pointer ) ? inc_ref(frame_pointer) : nil;
|
||||||
object->payload.exception.meta = ( consp( meta )
|
object->payload.exception.meta = ( consp( meta )
|
||||||
|| hashtabp( meta ) ) ? meta : nil;
|
|| hashtabp( meta ) ) ? inc_ref(meta) : nil;
|
||||||
object->payload.exception.cause = exceptionp( cause ) ? cause : nil;
|
object->payload.exception.cause = exceptionp( cause ) ? inc_ref(cause) : nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ struct pso_pointer make_frame( int arg_count, struct pso_pointer previous,
|
||||||
} else {
|
} else {
|
||||||
new_frame->payload.stack_frame.depth = 0;
|
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",
|
debug_printf( DEBUG_ALLOC, 1, L"depth is %d...\n",
|
||||||
new_frame->payload.stack_frame.depth );
|
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 );
|
arg_count, new_pointer.page, new_pointer.offset );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prev_frame->payload.stack_frame.previous = previous;
|
prev_frame->payload.stack_frame.previous = inc_ref(previous);
|
||||||
|
|
||||||
if ( stackp( previous ) ) {
|
if ( stackp( previous ) ) {
|
||||||
new_frame->payload.stack_frame.depth =
|
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 );
|
arg_count, new_pointer.page, new_pointer.offset );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prev_frame->payload.stack_frame.previous = previous;
|
prev_frame->payload.stack_frame.previous = inc_ref( previous);
|
||||||
|
|
||||||
if ( stackp( previous ) ) {
|
if ( stackp( previous ) ) {
|
||||||
new_frame->payload.stack_frame.depth =
|
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] );
|
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.args = 0;
|
||||||
frame->payload.stack_frame.depth = 0;
|
frame->payload.stack_frame.depth = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
src/c/psse.c
11
src/c/psse.c
|
|
@ -77,6 +77,11 @@ int main( int argc, char *argv[] ) {
|
||||||
bool dump_at_end = false;
|
bool dump_at_end = false;
|
||||||
bool show_prompt = false;
|
bool show_prompt = false;
|
||||||
char *infilename = NULL;
|
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 ) {
|
while ( ( option = getopt( argc, argv, "dhi:ps:v:" ) ) != -1 ) {
|
||||||
switch ( option ) {
|
switch ( option ) {
|
||||||
|
|
@ -109,11 +114,7 @@ int main( int argc, char *argv[] ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setlocale( LC_ALL, "" );
|
setlocale( LC_ALL, "" );
|
||||||
if ( initialise_io( ) != 0 ) {
|
|
||||||
fputs( "Failed to initialise I/O subsystem\n", stderr );
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
oblist = initialise_node( 0 );
|
oblist = initialise_node( 0 );
|
||||||
debug_print( L"Oblist: ", DEBUG_BOOTSTRAP, 0 );
|
debug_print( L"Oblist: ", DEBUG_BOOTSTRAP, 0 );
|
||||||
debug_print_object( oblist, DEBUG_BOOTSTRAP, 0 );
|
debug_print_object( oblist, DEBUG_BOOTSTRAP, 0 );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue