Added debug messages to initialisation functions, but getting a segfault.
Not going to debug that tonight!
This commit is contained in:
parent
f751fc8a09
commit
25c87aac6e
4 changed files with 29 additions and 1 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include "memory/memory.h"
|
#include "memory/memory.h"
|
||||||
#include "memory/node.h"
|
#include "memory/node.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
|
|
@ -39,6 +41,7 @@ struct pso_pointer initialise_environment( uint32_t node ) {
|
||||||
struct pso_pointer result = initialise_memory( node );
|
struct pso_pointer result = initialise_memory( node );
|
||||||
|
|
||||||
if ( !exceptionp( result ) ) {
|
if ( !exceptionp( result ) ) {
|
||||||
|
debug_print( L"Initialising `nil`... ", DEBUG_BOOTSTRAP, 0);
|
||||||
struct pso_pointer n = allocate( NILTAG, 2 );
|
struct pso_pointer n = allocate( NILTAG, 2 );
|
||||||
|
|
||||||
if ( ( n.page == 0 ) && ( n.offset == 0 ) ) {
|
if ( ( n.page == 0 ) && ( n.offset == 0 ) ) {
|
||||||
|
|
@ -47,14 +50,17 @@ struct pso_pointer initialise_environment( uint32_t node ) {
|
||||||
object->payload.cons.cdr = nil;
|
object->payload.cons.cdr = nil;
|
||||||
|
|
||||||
nil = n;
|
nil = n;
|
||||||
|
debug_print( L"success\n", DEBUG_BOOTSTRAP, 0);
|
||||||
} else {
|
} else {
|
||||||
result =
|
result =
|
||||||
make_exception( c_string_to_lisp_string
|
make_exception( c_string_to_lisp_string
|
||||||
( L"Unexpected cell while allocating `nil`." ),
|
( L"Unexpected cell while allocating `nil`." ),
|
||||||
nil, n );
|
nil, n );
|
||||||
|
debug_print( L"fail\n", DEBUG_BOOTSTRAP, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !exceptionp( result ) ) {
|
if ( !exceptionp( result ) ) {
|
||||||
|
debug_print( L"Initialising `t`... ", DEBUG_BOOTSTRAP, 0);
|
||||||
struct pso_pointer n = allocate( TRUETAG, 2 );
|
struct pso_pointer n = allocate( TRUETAG, 2 );
|
||||||
|
|
||||||
if ( ( n.page == 0 ) && ( n.offset == 1 ) ) {
|
if ( ( n.page == 0 ) && ( n.offset == 1 ) ) {
|
||||||
|
|
@ -63,11 +69,13 @@ struct pso_pointer initialise_environment( uint32_t node ) {
|
||||||
object->payload.cons.cdr = t;
|
object->payload.cons.cdr = t;
|
||||||
|
|
||||||
t = n;
|
t = n;
|
||||||
|
debug_print( L"success\n", DEBUG_BOOTSTRAP, 0);
|
||||||
} else {
|
} else {
|
||||||
result =
|
result =
|
||||||
make_exception( c_string_to_lisp_string
|
make_exception( c_string_to_lisp_string
|
||||||
( L"Unexpected cell while allocating `t`." ),
|
( L"Unexpected cell while allocating `t`." ),
|
||||||
nil, n );
|
nil, n );
|
||||||
|
debug_print( L"fail\n", DEBUG_BOOTSTRAP, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !exceptionp( result ) ) {
|
if ( !exceptionp( result ) ) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include "memory/memory.h"
|
#include "memory/memory.h"
|
||||||
#include "memory/node.h"
|
#include "memory/node.h"
|
||||||
#include "memory/pointer.h"
|
#include "memory/pointer.h"
|
||||||
|
|
@ -47,12 +49,15 @@ struct pso_pointer initialise_memory( uint32_t node ) {
|
||||||
if ( memory_initialised ) {
|
if ( memory_initialised ) {
|
||||||
result =
|
result =
|
||||||
make_exception( c_string_to_lisp_string
|
make_exception( c_string_to_lisp_string
|
||||||
( L"Attenpt to reinitialise environment" ), nil,
|
( L"Attenpt to reinitialise memory." ), nil,
|
||||||
nil );
|
nil );
|
||||||
} else {
|
} else {
|
||||||
for ( uint8_t i = 0; i <= MAX_SIZE_CLASS; i++ ) {
|
for ( uint8_t i = 0; i <= MAX_SIZE_CLASS; i++ ) {
|
||||||
freelists[i] = nil;
|
freelists[i] = nil;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
debug_print(L"Memory initialised", DEBUG_BOOTSTRAP, 0);
|
||||||
|
#endif
|
||||||
memory_initialised = true;
|
memory_initialised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,10 @@ struct pso_pointer initialise_page( union page *page_addr, uint16_t page_index,
|
||||||
int obj_bytes = obj_size * sizeof( uint64_t );
|
int obj_bytes = obj_size * sizeof( uint64_t );
|
||||||
int objs_in_page = PAGE_BYTES / obj_bytes;
|
int objs_in_page = PAGE_BYTES / obj_bytes;
|
||||||
|
|
||||||
|
debug_printf(DEBUG_ALLOC, 0,
|
||||||
|
L"Initialising page %d for objects of size class %d...",
|
||||||
|
page_index, size_class);
|
||||||
|
|
||||||
// we do this backwards (i--) so that object {0, 0, 0} will be first on the
|
// we do this backwards (i--) so that object {0, 0, 0} will be first on the
|
||||||
// freelist when the first page is initiated, so we can grab that one for
|
// freelist when the first page is initiated, so we can grab that one for
|
||||||
// `nil` and the next on for `t`.
|
// `nil` and the next on for `t`.
|
||||||
|
|
@ -86,6 +90,8 @@ struct pso_pointer initialise_page( union page *page_addr, uint16_t page_index,
|
||||||
( uint16_t ) ( i * obj_size ) );
|
( uint16_t ) ( i * obj_size ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug_print( L"page allocated.\n", DEBUG_ALLOC, 0);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include "memory/destroy.h"
|
#include "memory/destroy.h"
|
||||||
#include "memory/header.h"
|
#include "memory/header.h"
|
||||||
#include "memory/memory.h"
|
#include "memory/memory.h"
|
||||||
|
|
@ -39,6 +40,10 @@
|
||||||
struct pso_pointer allocate( char *tag, uint8_t size_class ) {
|
struct pso_pointer allocate( char *tag, uint8_t size_class ) {
|
||||||
struct pso_pointer result = nil;
|
struct pso_pointer result = nil;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
debug_printf( DEBUG_ALLOC, 0, L"Allocating object of size class %d with tag `%s`... ", size_class, tag);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( size_class <= MAX_SIZE_CLASS ) {
|
if ( size_class <= MAX_SIZE_CLASS ) {
|
||||||
if ( nilp( freelists[size_class] ) ) {
|
if ( nilp( freelists[size_class] ) ) {
|
||||||
result = allocate_page( size_class );
|
result = allocate_page( size_class );
|
||||||
|
|
@ -66,6 +71,10 @@ struct pso_pointer allocate( char *tag, uint8_t size_class ) {
|
||||||
}
|
}
|
||||||
} // TODO: else throw exception
|
} // TODO: else throw exception
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
debug_print(exceptionp(result)? L"fail\n" : L"success\n", DEBUG_ALLOC, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue