|
Post Scarcity
A prototype for a post scarcity programming environment
|
#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "memory/consspaceobject.h"#include "memory/conspage.h"#include "debug.h"#include "memory/dump.h"#include "memory/stack.h"#include "memory/vectorspace.h"Go to the source code of this file.
Functions | |
| struct cons_pointer | allocate_cell (uint32_t tag) |
Allocates a cell with the specified tag. | |
| void | dump_pages (URL_FILE *output) |
dump the allocated pages to this output stream. | |
| void | free_cell (struct cons_pointer pointer) |
Frees the cell at the specified pointer; for all the types of cons-space object which point to other cons-space objects, cascade the decrement. | |
| void | initialise_cons_pages () |
| initialise the cons page system; to be called exactly once during startup. | |
| void | make_cons_page () |
| Make a cons page. | |
| void | summarise_allocation () |
Variables | |
| bool | conspageinitihasbeencalled = false |
| Flag indicating whether conspage initialisation has been done. | |
| struct cons_page * | conspages [NCONSPAGES] |
| An array of pointers to cons pages. | |
| struct cons_pointer | freelist = NIL |
| The (global) pointer to the (global) freelist. | |
| int | initialised_cons_pages = 0 |
| the number of cons pages which have thus far been initialised. | |
| uint64_t | total_cells_allocated = 0 |
| keep track of total cells allocated and freed to check for leakage. | |
| uint64_t | total_cells_freed = 0 |
| struct cons_pointer allocate_cell | ( | uint32_t | tag | ) |
Allocates a cell with the specified tag.
Dangerous, primitive, low level.
| tag | the tag of the cell to allocate - must be a valid cons space tag. |
Definition at line 222 of file conspage.c.
References allocate_cell(), cons_space_object::count, DEBUG_ALLOC, debug_printf(), freelist, FREETAG, make_cons_page(), NIL, cons_pointer::offset, cons_pointer::page, cons_space_object::payload, pointer2cell, cons_space_object::tag, TAGLENGTH, and total_cells_allocated.
Referenced by allocate_cell(), make_cons(), make_exception(), make_function(), make_integer(), make_lambda(), make_nlambda(), make_ratio(), make_read_stream(), make_real(), make_special(), make_string_like_thing(), make_time(), make_vec_pointer(), and make_write_stream().
| void dump_pages | ( | URL_FILE * | output | ) |
dump the allocated pages to this output stream.
Definition at line 124 of file conspage.c.
References CONSPAGESIZE, dump_object(), initialised_cons_pages, and url_fwprintf.
Referenced by main().
| void free_cell | ( | struct cons_pointer | pointer | ) |
Frees the cell at the specified pointer; for all the types of cons-space object which point to other cons-space objects, cascade the decrement.
Dangerous, primitive, low level.
@pointer the cell to free
Definition at line 143 of file conspage.c.
References check_tag(), CONSTV, cons_space_object::count, DEBUG_ALLOC, debug_dump_object(), debug_printf(), dec_ref(), EXCEPTIONTV, free_vso(), freelist, FREETAG, FREETV, FUNCTIONTV, INTEGERTV, LAMBDATV, NIL, NLAMBDATV, cons_pointer::offset, cons_pointer::page, cons_space_object::payload, pointer2cell, RATIOTV, READTV, SPECIALTV, STRINGTV, SYMBOLTV, cons_space_object::tag, TAGLENGTH, total_cells_freed, url_fclose(), VECTORPOINTTV, and WRITETV.
Referenced by dec_ref().
| void initialise_cons_pages | ( | ) |
initialise the cons page system; to be called exactly once during startup.
Definition at line 257 of file conspage.c.
References conspageinitihasbeencalled, conspages, DEBUG_ALLOC, debug_printf(), make_cons_page(), and NCONSPAGES.
Referenced by main().
| void make_cons_page | ( | ) |
Make a cons page.
Initialise all cells and prepend each to the freelist; if initialised_cons_pages is zero, do not prepend cells 0 and 1 to the freelist but initialise them as NIL and T respectively.
Definition at line 61 of file conspage.c.
References cons_page::cell, conspages, CONSPAGESIZE, cons_space_object::count, DEBUG_ALLOC, debug_printf(), freelist, FREETAG, initialised_cons_pages, MAXREFERENCE, NIL, NILTAG, cons_pointer::offset, cons_pointer::page, cons_space_object::payload, cons_space_object::tag, TAGLENGTH, and TRUETAG.
Referenced by allocate_cell(), and initialise_cons_pages().
| void summarise_allocation | ( | ) |
Definition at line 271 of file conspage.c.
References total_cells_allocated, and total_cells_freed.
Referenced by main().
| bool conspageinitihasbeencalled = false |
Flag indicating whether conspage initialisation has been done.
Definition at line 29 of file conspage.c.
Referenced by initialise_cons_pages().
| struct cons_page* conspages[NCONSPAGES] |
An array of pointers to cons pages.
Definition at line 51 of file conspage.c.
Referenced by initialise_cons_pages(), and make_cons_page().
| struct cons_pointer freelist = NIL |
The (global) pointer to the (global) freelist.
Not sure whether this ultimately belongs in this file.
Definition at line 46 of file conspage.c.
Referenced by allocate_cell(), free_cell(), and make_cons_page().
| int initialised_cons_pages = 0 |
the number of cons pages which have thus far been initialised.
Definition at line 40 of file conspage.c.
Referenced by dump_pages(), and make_cons_page().
| uint64_t total_cells_allocated = 0 |
keep track of total cells allocated and freed to check for leakage.
Definition at line 34 of file conspage.c.
Referenced by allocate_cell(), and summarise_allocation().
| uint64_t total_cells_freed = 0 |
Definition at line 35 of file conspage.c.
Referenced by free_cell(), and summarise_allocation().