Compare commits

...

2 commits

34 changed files with 784 additions and 286 deletions

View file

@ -119,7 +119,7 @@ We don't currently have any other mutable objects, but in future at least lazy o
Secondly, reading from a namespace does not happen in a single clock tick, it takes quite a long time. So it's no good setting a lock bit on the namespace object itself and then immediately assuming that it's now mutable. A reading process could already have started, and be proceeding.
So what I think is, that we have a single top level function, `(::substrate:search-store key store return-key?)` (which we already sort of have in the 0.0.6 prototype, [here](https://www.journeyman.cc/post-scarcity/doc/html/intern_8c.html#a2189c0ab60e57a70adeb32aca99dbc43)). This searches a store (hashmap, namespace, association list, or hybrid association list) to find a binding for a key, and, having found that binding, then, if there is a namespace on the search path, checks whether the lock on the any namespace on the search path is set, and it it is, aborts the search and tries again; but otherwise returns either the key found (if `return-key?` is non-`nil`), or the value found otherwise.
So what I think is, that we have a single top level function, `(::substrate:search-store key store return-key?)` (which we already sort of have in the 0.0.6 prototype, [here](https://www.journeyman.cc/post-scarcity/doc/html/intern_8c.html#a2189c0ab60e57a70adeb32aca99dbc43)). This searches a store (hashmap, namespace, association list, or hybrid association list) to find a binding for a key, and, having found that binding, then, if there is a namespace on the search path, checks whether the lock on the any namespace on the search path is set, and if it is, aborts the search and tries again; but otherwise returns either the key found (if `return-key?` is non-`nil`), or the value found otherwise.
This function implements the user-level Lisp functions `assoc`, `interned`, and `interned?`. It also implements *hashmap-in-function-position* and *keyword-in-function-position*, in so far as both of these are treated as calls to `assoc`.

View file

@ -17,6 +17,11 @@
#include <stddef.h>
#include <stdio.h>
/*
* wide characters
*/
#include <wchar.h>
#include <wctype.h>
/**
* @brief Print messages debugging memory allocation.

View file

@ -29,7 +29,7 @@ struct pso_header {
char mnemonic[TAGLENGTH];
/** size class for this object */
uint8_t size_class;
} tag;
} bytes;
/** the tag considered as a number */
uint32_t value;
} tag;

View file

@ -21,7 +21,7 @@
* since managed objects require a two word header; it's unlikely that
* these undersized size classes will be used at all.
*/
#define MAX_SIZE_CLASS = 0xf
#define MAX_SIZE_CLASS 0xf
int initialise_memory( );

View file

@ -9,7 +9,10 @@
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "debug.h"
#include "memory/memory.h"
#include "memory/node.h"
#include "memory/page.h"
@ -36,13 +39,13 @@
* to hold the number of pages we *might* create at start up time. We need a
* way to grow the number of pages, while keeping access to them cheap.
*/
struct page * pages[NPAGES];
union page * pages[NPAGES];
/**
* @brief the number of pages which have thus far been allocated.
*
*/
uint32_t npages_allocated = 0
uint32_t npages_allocated = 0;
/**
* @brief private to allocate_page; do not use.
@ -51,10 +54,11 @@ uint32_t npages_allocated = 0
* @param page_index its location in the pages[] array;
* @param size_class the size class of objects in this page;
* @param freelist the freelist for objects of this size class.
* @return struct cons_pointer the new head for the freelist for this size_class,
* @return struct pso_pointer the new head for the freelist for this size_class,
*/
struct cons_pointer initialise_page( struct page * page_addr, uint16_t page_index, uint8_t size_class, pso_pointer freelist) {
struct cons_pointer result = freelist;
struct pso_pointer initialise_page( union page* page_addr, uint16_t page_index,
uint8_t size_class, struct pso_pointer freelist) {
struct pso_pointer result = freelist;
int obj_size = pow(2, size_class);
int obj_bytes = obj_size * sizeof(uint64_t);
int objs_in_page = PAGE_BYTES/obj_bytes;
@ -64,16 +68,14 @@ struct cons_pointer initialise_page( struct page * page_addr, uint16_t page_inde
// `nil` and the next on for `t`.
for (int i = objs_in_page - 1; i >= 0; i--) {
// it should be safe to cast any pso object to a pso2
struct pso2* object = (pso2 *)(page_addr + (i * obj_bytes));
struct pso2* object = (struct pso2 *)(page_addr + (i * obj_bytes));
object->header.tag.size_class = size_class;
strncpy( (char *)(object->header.tag.mnemonic), FREETAG, TAGLENGTH);
object->header.tag.bytes.size_class = size_class;
strncpy( (char *)(object->header.tag.bytes.mnemonic), FREETAG, TAGLENGTH);
object->payload.free.next = result;
result = make_pointer( node_index, page_index, (uint16_t)( i * obj_size));
}
return result;
}
/**
@ -89,8 +91,8 @@ struct cons_pointer initialise_page( struct page * page_addr, uint16_t page_inde
* @param size_class an integer in the range 0...MAX_SIZE_CLASS.
* @return t on success, an exception if an error occurred.
*/
struct cons_pointer allocate_page( uint8_t size_class ) {
struct cons_pointer result = t;
struct pso_pointer allocate_page( uint8_t size_class ) {
struct pso_pointer result = t;
if ( npages_allocated == 0) {
for (int i = 0; i < NPAGES; i++) {
@ -101,17 +103,17 @@ struct cons_pointer allocate_page( uint8_t size_class ) {
if ( npages_allocated < NPAGES) {
if ( size_class >= 2 && size_class <= MAX_SIZE_CLASS ) {
result = malloc( sizeof( page ) );
void* pg = malloc( sizeof( union page ) );
if ( result != NULL ) {
memset( result, 0, sizeof( page ) );
pages[ npages_allocated] = result;
if ( pg != NULL ) {
memset( pg, 0, sizeof( union page ) );
pages[ npages_allocated] = pg;
debug_printf( DEBUG_ALLOC, 0,
L"Allocated page %d for objects of size class %x.\n",
npages_allocated, size_class);
freelists[size_class] =
initialise_page( result, npages_allocated, size_class, freelists[size_class] );
initialise_page( (union page*)pg, npages_allocated, size_class, freelists[size_class] );
debug_printf( DEBUG_ALLOC, 0,
L"Initialised page %d; freelist for size class %x updated.\n",

View file

@ -10,6 +10,7 @@
#ifndef __psse_memory_page_h
#define __psse_memory_page_h
#include "memory/pointer.h"
#include "memory/pso2.h"
#include "memory/pso3.h"
#include "memory/pso4.h"
@ -38,7 +39,7 @@
*/
#define NPAGES 64
extern struct page *pages[NPAGES];
extern union page *pages[NPAGES];
/**
* @brief A page is a megabyte of memory which contains objects all of which
@ -53,22 +54,25 @@ extern struct page *pages[NPAGES];
* collection they will be returned to that freelist.
*/
union page {
uint8_t[PAGE_BYTES] bytes;
uint64_t[PAGE_BYTES / 8] words;
struct pso2[PAGE_BYTES / 32] pso2s;
struct pso3[PAGE_BYTES / 64] pso3s;
struct pso4[PAGE_BYTES / 128] pso4s;
struct pso5[PAGE_BYTES / 256] pso5s;
struct pso6[PAGE_BYTES / 512] pso6s;
struct pso7[PAGE_BYTES / 1024] pso7s;
struct pso8[PAGE_BYTES / 2048] pso8s;
struct pso9[PAGE_BYTES / 4096] pso9s;
struct psoa[PAGE_BYTES / 8192] psoas;
struct psob[PAGE_BYTES / 16384] psobs;
struct psoc[PAGE_BYTES / 32768] psocs;
struct psod[PAGE_BYTES / 65536] psods;
struct psoe[PAGE_BYTES / 131072] psoes;
struct psof[PAGE_BYTES / 262144] psofs;
uint8_t bytes[PAGE_BYTES];
uint64_t words[PAGE_BYTES / 8];
struct pso2 pso2s[PAGE_BYTES / 32];
struct pso3 pso3s[PAGE_BYTES / 64];
struct pso4 pso4s[PAGE_BYTES / 128];
struct pso5 pso5s[PAGE_BYTES / 256];
struct pso6 pso6s[PAGE_BYTES / 512];
struct pso7 pso7s[PAGE_BYTES / 1024];
struct pso8 pso8s[PAGE_BYTES / 2048];
struct pso9 pso9s[PAGE_BYTES / 4096];
struct psoa psoas[PAGE_BYTES / 8192];
struct psob psobs[PAGE_BYTES / 16384];
struct psoc psocs[PAGE_BYTES / 32768];
struct psod psods[PAGE_BYTES / 65536];
struct psoe psoes[PAGE_BYTES / 131072];
struct psof psofs[PAGE_BYTES / 262144];
};
struct pso_pointer initialise_page( union page * page_addr, uint16_t page_index,
uint8_t size_class, struct pso_pointer freelist);
#endif

View file

@ -14,234 +14,234 @@
#include "memory/header.h"
#include "memory/pointer.h"
#include "payloads/cons.h"
#include "payloads/exception.h"
#include "payloads/free.h"
#include "payloads/function.h"
#include "payloads/hashtable.h"
#include "payloads/integer.h"
#include "payloads/keyword.h"
#include "payloads/lambda.h"
#include "payloads/mutex.h"
#include "payloads/namespace.h"
#include "payloads/nlambda.h"
#include "payloads/read_stream.h"
#include "payloads/special.h"
#include "payloads/stack.h"
#include "payloads/string.h"
#include "payloads/symbol.h"
#include "payloads/time.h"
#include "payloads/vector_pointer.h"
#include "payloads/write_stream.h"
// #include "payloads/cons.h"
// #include "payloads/exception.h"
// #include "payloads/free.h"
// #include "payloads/function.h"
// #include "payloads/hashtable.h"
// #include "payloads/integer.h"
// #include "payloads/keyword.h"
// #include "payloads/lambda.h"
// #include "payloads/mutex.h"
// #include "payloads/namespace.h"
// #include "payloads/nlambda.h"
// #include "payloads/read_stream.h"
// #include "payloads/special.h"
// #include "payloads/stack.h"
// #include "payloads/string.h"
// #include "payloads/symbol.h"
// #include "payloads/time.h"
// #include "payloads/vector_pointer.h"
// #include "payloads/write_stream.h"
/**
* @brief A paged space object of size class 2, four words total, two words
* payload.
*
*/
struct pso2 {
struct pso_header header;
union {
char bytes[16];
uint64_t words[2];
struct cons_payload cons;
struct free_payload free;
struct function_payload function;
struct integer_payload integer;
struct lambda_payload lambda;
struct special_payload special;
struct stream_payload stream;
struct time_payload time;
struct vectorp_payload vectorp;
} payload;
};
// /**
// * @brief A paged space object of size class 2, four words total, two words
// * payload.
// *
// */
// struct pso2 {
// struct pso_header header;
// union {
// char bytes[16];
// uint64_t words[2];
// struct cons_payload cons;
// struct free_payload free;
// struct function_payload function;
// struct integer_payload integer;
// struct lambda_payload lambda;
// struct special_payload special;
// struct stream_payload stream;
// struct time_payload time;
// struct vectorp_payload vectorp;
// } payload;
// };
/**
* @brief A paged space object of size class 3, 8 words total, 6 words
* payload.
*
*/
struct pso3 {
struct pso_header header;
union {
char bytes[48];
uint64_t words[6];
struct exception_payload exception;
struct free_payload free;
struct mutex_payload mutex;
} payload;
};
// /**
// * @brief A paged space object of size class 3, 8 words total, 6 words
// * payload.
// *
// */
// struct pso3 {
// struct pso_header header;
// union {
// char bytes[48];
// uint64_t words[6];
// struct exception_payload exception;
// struct free_payload free;
// struct mutex_payload mutex;
// } payload;
// };
/**
* @brief A paged space object of size class 4, 16 words total, 14 words
* payload.
*
*/
struct pso4 {
struct pso_header header;
union {
char bytes[112];
uint64_t words[14];
struct free_payload free;
struct stack_frame_payload stack_frame;
} payload;
};
// /**
// * @brief A paged space object of size class 4, 16 words total, 14 words
// * payload.
// *
// */
// struct pso4 {
// struct pso_header header;
// union {
// char bytes[112];
// uint64_t words[14];
// struct free_payload free;
// struct stack_frame_payload stack_frame;
// } payload;
// };
/**
* @brief A paged space object of size class 5, 32 words total, 30 words
* payload.
*
*/
struct pso5 {
struct pso_header header;
union {
char bytes[240];
uint64_t words[30];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class 5, 32 words total, 30 words
// * payload.
// *
// */
// struct pso5 {
// struct pso_header header;
// union {
// char bytes[240];
// uint64_t words[30];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class 6, 64 words total, 62 words
* payload.
*
*/
struct pso6 {
struct pso_header header;
union {
char bytes[496];
uint64_t words[62];
struct free_payload free;
struct hashtable_payload hashtable;
struct namespace_payload namespace;
} payload;
};
// /**
// * @brief A paged space object of size class 6, 64 words total, 62 words
// * payload.
// *
// */
// struct pso6 {
// struct pso_header header;
// union {
// char bytes[496];
// uint64_t words[62];
// struct free_payload free;
// struct hashtable_payload hashtable;
// struct namespace_payload namespace;
// } payload;
// };
/**
* @brief A paged space object of size class 7, 128 words total, 126 words
* payload.
*
*/
struct pso7 {
struct pso_header header;
union {
char bytes[1008];
uint64_t words[126];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class 7, 128 words total, 126 words
// * payload.
// *
// */
// struct pso7 {
// struct pso_header header;
// union {
// char bytes[1008];
// uint64_t words[126];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class 8, 256 words total, 254 words
* payload.
*
*/
struct pso8 {
struct pso_header header;
union {
char bytes[2032];
uint64_t words[254];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class 8, 256 words total, 254 words
// * payload.
// *
// */
// struct pso8 {
// struct pso_header header;
// union {
// char bytes[2032];
// uint64_t words[254];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class 9, 512 words total, 510 words
* payload.
*
*/
struct pso9 {
struct pso_header header;
union {
char bytes[4080];
uint64_t words[510];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class 9, 512 words total, 510 words
// * payload.
// *
// */
// struct pso9 {
// struct pso_header header;
// union {
// char bytes[4080];
// uint64_t words[510];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class a, 1024 words total, 1022 words
* payload.
*
*/
struct psoa {
struct pso_header header;
union {
char bytes[8176];
uint64_t words[1022];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class a, 1024 words total, 1022 words
// * payload.
// *
// */
// struct psoa {
// struct pso_header header;
// union {
// char bytes[8176];
// uint64_t words[1022];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class b, 2048 words total, 2046 words
* payload.
*
*/
struct psob {
struct pso_header header;
union {
char bytes[16368];
uint64_t words[2046];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class b, 2048 words total, 2046 words
// * payload.
// *
// */
// struct psob {
// struct pso_header header;
// union {
// char bytes[16368];
// uint64_t words[2046];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class c, 4096 words total, 4094 words
* payload.
*
*/
struct psoc {
struct pso_header header;
union {
char bytes[32752];
uint64_t words[4094];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class c, 4096 words total, 4094 words
// * payload.
// *
// */
// struct psoc {
// struct pso_header header;
// union {
// char bytes[32752];
// uint64_t words[4094];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class d, 8192 words total, 8190 words
* payload.
*
*/
struct psod {
struct pso_header header;
union {
char bytes[65520];
uint64_t words[8190];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class d, 8192 words total, 8190 words
// * payload.
// *
// */
// struct psod {
// struct pso_header header;
// union {
// char bytes[65520];
// uint64_t words[8190];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class e, 16384 words total, 16382 words
* payload.
*
*/
struct psoe {
struct pso_header header;
union {
char bytes[131056];
uint64_t words[16382];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class e, 16384 words total, 16382 words
// * payload.
// *
// */
// struct psoe {
// struct pso_header header;
// union {
// char bytes[131056];
// uint64_t words[16382];
// struct free_payload free;
// } payload;
// };
/**
* @brief A paged space object of size class f, 32768 words total, 32766 words
* payload.
*
*/
struct psof {
struct pso_header header;
union {
char bytes[262128];
uint64_t words[32766];
struct free_payload free;
} payload;
};
// /**
// * @brief A paged space object of size class f, 32768 words total, 32766 words
// * payload.
// *
// */
// struct psof {
// struct pso_header header;
// union {
// char bytes[262128];
// uint64_t words[32766];
// struct free_payload free;
// } payload;
// };
struct pso_pointer allocate( char* tag, uint8_t size_class);

53
src/c/memory/pso2.h Normal file
View file

@ -0,0 +1,53 @@
/**
* memory/pso2.h
*
* Paged space object of size class 2, four words total, two words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso2_h
#define __psse_memory_pso2_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/cons.h"
#include "payloads/free.h"
#include "payloads/function.h"
#include "payloads/integer.h"
#include "payloads/keyword.h"
#include "payloads/lambda.h"
#include "payloads/nlambda.h"
#include "payloads/read_stream.h"
#include "payloads/special.h"
#include "payloads/string.h"
#include "payloads/symbol.h"
// #include "payloads/time.h"
#include "payloads/vector_pointer.h"
#include "payloads/write_stream.h"
/**
* @brief A paged space object of size class 2, four words total, two words
* payload.
*
*/
struct pso2 {
struct pso_header header;
union {
char bytes[16];
uint64_t words[2];
struct cons_payload cons;
struct free_payload free;
struct function_payload function;
struct integer_payload integer;
struct lambda_payload lambda;
// struct special_payload special;
struct stream_payload stream;
// struct time_payload time;
struct vectorp_payload vectorp;
} payload;
};
#endif

37
src/c/memory/pso3.h Normal file
View file

@ -0,0 +1,37 @@
/**
* memory/pso3.h
*
* Paged space object of size class 3, 8 words total, 6 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso3_h
#define __psse_memory_pso3_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/exception.h"
#include "payloads/free.h"
#include "payloads/mutex.h"
/**
* @brief A paged space object of size class 3, 8 words total, 6 words
* payload.
*
*/
struct pso3 {
struct pso_header header;
union {
char bytes[48];
uint64_t words[6];
struct exception_payload exception;
struct free_payload free;
struct mutex_payload mutex;
} payload;
};
#endif

34
src/c/memory/pso4.h Normal file
View file

@ -0,0 +1,34 @@
/**
* memory/pso4.h
*
* Paged space object of size class 4, 16 words total, 14 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso4_h
#define __psse_memory_pso4_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
#include "payloads/stack.h"
/**
* @brief A paged space object of size class 4, 16 words total, 14 words
* payload.
*
*/
struct pso4 {
struct pso_header header;
union {
char bytes[112];
uint64_t words[14];
struct free_payload free;
struct stack_frame_payload stack_frame;
} payload;
};
#endif

32
src/c/memory/pso5.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/pso5.h
*
* Paged space object of size class 5, 32 words total, 30 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso5_h
#define __psse_memory_pso5_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class 5, 32 words total, 30 words
* payload.
*
*/
struct pso5 {
struct pso_header header;
union {
char bytes[240];
uint64_t words[30];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/pso6.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/pso6.h
*
* Paged space object of size class 6, 64 words total, 62 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso6_h
#define __psse_memory_pso6_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class 6, 64 words total, 62 words
* payload.
*
*/
struct pso6 {
struct pso_header header;
union {
char bytes[496];
uint64_t words[62];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/pso7.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/pso7.h
*
* Paged space object of size class 7, 128 words total, 126 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso7_h
#define __psse_memory_pso7_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class 7, 128 words total, 126 words
* payload.
*
*/
struct pso7 {
struct pso_header header;
union {
char bytes[1008];
uint64_t words[126];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/pso8.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/pso8.h
*
* Paged space object of size class 8, 256 words total, 254 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso8_h
#define __psse_memory_pso8_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class 8, 256 words total, 254 words
* payload.
*
*/
struct pso8 {
struct pso_header header;
union {
char bytes[2032];
uint64_t words[254];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/pso9.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/pso9.h
*
* Paged space object of size class 9, 512 words total, 510 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_pso9_h
#define __psse_memory_pso9_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class 9, 512 words total, 510 words
* payload.
*
*/
struct pso9 {
struct pso_header header;
union {
char bytes[4080];
uint64_t words[510];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psoa.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psoa.h
*
* Paged space object of size class a, 1024 words total, 1022 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psoa_h
#define __psse_memory_psoa_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class a, 1024 words total, 1022 words
* payload.
*
*/
struct psoa {
struct pso_header header;
union {
char bytes[8176];
uint64_t words[1022];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psob.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psob.h
*
* Paged space object of size class b, 2048 words total, 2046 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psob_h
#define __psse_memory_psob_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class b, 2048 words total, 2046 words
* payload.
*
*/
struct psob {
struct pso_header header;
union {
char bytes[16368];
uint64_t words[2046];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psoc.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psoc.h
*
* Paged space object of size class c, 4096 words total, 4094 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psoc_h
#define __psse_memory_psoc_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class c, 4096 words total, 4094 words
* payload.
*
*/
struct psoc {
struct pso_header header;
union {
char bytes[32752];
uint64_t words[4094];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psod.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psod.h
*
* Paged space object of size class d, 8192 words total, 8190 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psod_h
#define __psse_memory_psod_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class d, 8192 words total, 8190 words
* payload.
*
*/
struct psod {
struct pso_header header;
union {
char bytes[65520];
uint64_t words[8190];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psoe.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psoe.h
*
* Paged space object of size class e, 16384 words total, 16382 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psoe_h
#define __psse_memory_psoe_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class e, 16384 words total, 16382 words
* payload.
*
*/
struct psoe {
struct pso_header header;
union {
char bytes[131056];
uint64_t words[16382];
struct free_payload free;
} payload;
};
#endif

32
src/c/memory/psof.h Normal file
View file

@ -0,0 +1,32 @@
/**
* memory/psof.h
*
* Paged space object of size class f, 32768 words total, 32766 words payload.
*
* (c) 2026 Simon Brooke <simon@journeyman.cc>
* Licensed under GPL version 2.0, or, at your option, any later version.
*/
#ifndef __psse_memory_psof_h
#define __psse_memory_psof_h
#include <stdint.h>
#include "memory/header.h"
#include "payloads/free.h"
/**
* @brief A paged space object of size class f, 32768 words total, 32766 words
* payload.
*
*/
struct psof {
struct pso_header header;
union {
char bytes[262128];
uint64_t words[32766];
struct free_payload free;
} payload;
};
#endif

View file

@ -12,6 +12,7 @@
#include "memory/node.h"
#include "memory/pointer.h"
#include "memory/pso.h"
#include "memory/pso2.h"
#include "payloads/cons.h"
/**

View file

@ -11,7 +11,7 @@
#define __psse_payloads_function_h
#include "memory/pointer.h"
#include "memory/pso.h"
#include "memory/pso4.h"
/**
* @brief Tag for an ordinary Lisp function - one whose arguments are pre-evaluated.
@ -41,7 +41,7 @@ struct function_payload {
* a cons pointer (representing its result).
* \todo check this documentation is current!
*/
struct pso_pointer ( *executable ) ( struct pso4 *,
struct pso_pointer ( *executable ) ( struct pso4*,
struct pso_pointer,
struct pso_pointer );
};

View file

@ -45,10 +45,10 @@
* i.e. either an assoc list or a further hashtable.
*/
struct hashtable_payload {
struct cons_pointer hash_fn; /* function for hashing values in this hashtable, or `NIL` to use
struct pso_pointer hash_fn; /* function for hashing values in this hashtable, or `NIL` to use
the default hashing function */
uint32_t n_buckets; /* number of hash buckets */
struct cons_pointer buckets[]; /* actual hash buckets, which should be `NIL`
struct pso_pointer buckets[]; /* actual hash buckets, which should be `NIL`
* or assoc lists or (possibly) further hashtables. */
};

View file

@ -48,16 +48,16 @@
* i.e. either an assoc list or a further namespace.
*/
struct namespace_payload {
struct cons_pointer hash_fn; /* function for hashing values in this namespace, or
struct pso_pointer hash_fn; /* function for hashing values in this namespace, or
* `NIL` to use the default hashing function */
uint32_t n_buckets; /* number of hash buckets */
uint32_t unused; /* for word alignment and possible later expansion */
struct cons_pointer write_acl; /* it seems to me that it is likely that the
struct pso_pointer write_acl; /* it seems to me that it is likely that the
* principal difference between a hashtable and a
* namespace is that a hashtable has a write ACL
* of `NIL`, meaning not writeable by anyone */
struct cons_pointer mutex; /* the mutex to lock when modifying this namespace.*/
struct cons_pointer buckets[]; /* actual hash buckets, which should be `NIL`
struct pso_pointer mutex; /* the mutex to lock when modifying this namespace.*/
struct pso_pointer buckets[]; /* actual hash buckets, which should be `NIL`
* or assoc lists or (possibly) further hashtables. */
};

View file

@ -14,6 +14,7 @@
#include <curl/curl.h>
#include "io/fopen.h"
#include "memory/pointer.h"
/**
@ -31,7 +32,7 @@ struct stream_payload {
/** metadata on the stream (e.g. its file attributes if a file, its HTTP
* headers if a URL, etc). Expected to be an association, or nil. Not yet
* implemented. */
struct cons_pointer meta;
struct pso_pointer meta;
};
#endif

View file

@ -11,6 +11,7 @@
#define __psse_payloads_special_h
#include "memory/pointer.h"
#include "memory/pso4.h"
/**
* A special form - one whose arguments are not pre-evaluated but passed as
@ -20,25 +21,25 @@
#define SPECIALTAG "SFM"
#define SPECIALTV 5064275
/**
* @brief Payload of a special form cell.
*
* Currently identical to the payload of a function cell.
* \see function_payload
*/
struct special_payload {
/**
* pointer to the source from which the special form was compiled, or NIL
* if it is a primitive.
*/
struct pso_pointer meta;
/** pointer to a function which takes a cons pointer (representing
* its argument list) and a cons pointer (representing its environment) and a
* stack frame (representing the previous stack frame) as arguments and returns
* a cons pointer (representing its result). */
struct pso_pointer ( *executable ) ( struct pso4 *,
struct pso_pointer,
struct pso_pointer );
};
// /**
// * @brief Payload of a special form cell.
// *
// * Currently identical to the payload of a function cell.
// * \see function_payload
// */
// struct special_payload {
// /**
// * pointer to the source from which the special form was compiled, or NIL
// * if it is a primitive.
// */
// struct pso_pointer meta;
// /** pointer to a function which takes a cons pointer (representing
// * its argument list) and a cons pointer (representing its environment) and a
// * stack frame (representing the previous stack frame) as arguments and returns
// * a cons pointer (representing its result). */
// struct pso_pointer ( *executable ) ( struct pso4*,
// struct pso_pointer,
// struct pso_pointer );
// };
#endif

View file

@ -8,7 +8,8 @@
*/
#include "memory/node.h"
#include "memory/pso.h"
#include "memory/pso2.h"
#include "memory/pso4.h"
#include "payloads/stack.h"
/**

View file

@ -14,6 +14,9 @@
#include "memory/pointer.h"
#define STACKTAG "STK"
#define STACKTV 4936787
/*
* number of arguments stored in a stack frame
*/

View file

@ -10,6 +10,8 @@
#ifndef __psse_payloads_cons_h
#define __psse_payloads_cons_h
#include <stdint.h>
#include "memory/pointer.h"
/**
@ -24,7 +26,7 @@
* convenience, 14Bn years before 1st Jan 1970 (the UNIX epoch))
*/
struct time_payload {
unsigned __int128 value;
unsigned __int128_t value;
};
#endif

View file

@ -16,6 +16,7 @@
* A pointer to an object in vector space.
*/
#define VECTORPOINTTAG "VSP"
#define VECTORPOINTTV 5264214
/**
* @brief payload of a vector pointer cell.

View file

@ -10,6 +10,7 @@
#ifndef __psse_payloads_write_stream_h
#define __psse_payloads_write_stream_h
#include "io/fopen.h"
#include "memory/pointer.h"
/**

View file

@ -99,7 +99,7 @@ int main( int argc, char *argv[] ) {
initialise_node( 0 );
repl( );
// repl( );
exit( 0 );
}

View file

@ -24,7 +24,7 @@
#include "debug.h"
#include "memory/memory.h"
#include "memory/stack.h"
#include "payloads/stack.h"
#include "version.h"
#endif