Another inconclusive session: still nothing works, still making progress.

This commit is contained in:
Simon Brooke 2026-04-22 18:16:00 +01:00
parent ef59563e25
commit eed4711fee
35 changed files with 317 additions and 232 deletions

View file

@ -30,6 +30,7 @@
#include "memory/page.h"
#include "memory/pointer.h"
#include "memory/pso.h"
#include "memory/pso4.h"
#include "memory/tags.h"
#include "ops/truth.h"
@ -45,18 +46,14 @@
* for some objects (e.g. those cons cells on the locals list) this isn't
* possible due to infinite recursion, but those special cases need to be
* audited carefully.
*
* The stack frame pointer is DELIBERATELY a C pointer, not a Lisp pointer,
* because you are definitely not supposed to be calling this function from
* Lisp. Please do not!
*
* @param stack_pointer C (NOT Lisp!) pointer to an active stack frame (or
* NULL, but only during initialisation).
* @param frame_pointer pointer to an active stack frame (or
* nil, but only during initialisation).
* @param tag The tag. Only the first three bytes will be used;
* @param size_class The size class for the object to be allocated;
* @return struct pso_pointer a pointer to the newly allocated object
*/
struct pso_pointer allocate( struct pso4 *stack_pointer, char *tag,
struct pso_pointer allocate( struct pso_pointer frame_pointer, char *tag,
uint8_t size_class ) {
// todo: issue #21: must have stack frame passed in.
@ -67,19 +64,19 @@ struct pso_pointer allocate( struct pso4 *stack_pointer, char *tag,
#endif
struct pso_pointer result = pop_freelist( size_class );
struct pso4* frame = pointer_to_pso4(frame_pointer);
if ( !nilp( result ) ) {
if ( !c_nilp( result ) ) {
strncpy( ( char * ) ( pointer_to_object( result )->header.tag.
bytes.mnemonic ), tag, TAGLENGTH );
debug_printf( DEBUG_ALLOC, 0, L"at page %d, offset %d... ",
result.page, result.offset );
if ( stack_pointer != NULL &&
( stack_pointer->header.tag.value & 0xffffff ) == STACKTV ) {
if ( stackp(frame_pointer)) {
struct pso_pointer locals = make_cons( result,
stack_pointer->payload.
frame->payload.
stack_frame.locals );
stack_pointer->payload.stack_frame.locals = locals;
frame->payload.stack_frame.locals = locals;
} else if ( memory_initialised ) {
fputws( L"WARNING: No stack frame passed to `allocate`.\n",
@ -151,7 +148,7 @@ 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 ( !nilp( pointer ) && object->header.count > 0
if ( !c_nilp( pointer ) && object->header.count > 0
&& object->header.count != MAXREFERENCE ) {
object->header.count--;
#ifdef DEBUG