Skip to content

Commit

Permalink
wip: add versioned home and road structs/globals
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-levan committed Sep 15, 2023
1 parent 92f4843 commit ef7b8a6
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 4 deletions.
72 changes: 70 additions & 2 deletions pkg/noun/v2/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/** Aliases.
**/
# define u3R_v2 u3R
# define u3a_v2_botox u3a_botox
# define u3a_v2_box u3a_box
# define u3a_v2_cell u3a_cell
Expand All @@ -26,14 +25,83 @@
# define u3a_v2_rewrite u3a_rewrite
# define u3a_v2_rewrite_ptr u3a_rewrite_ptr
# define u3a_v2_rewritten u3a_rewritten
# define u3a_v2_road u3a_road
# define u3a_v2_road u3a_v2_road
# define u3a_v2_wfree u3a_wfree
# define u3a_v2_to_off u3a_to_off
# define u3a_v2_to_ptr u3a_to_ptr
# define u3a_v2_to_wtr u3a_to_wtr
# define u3a_v2_to_pug u3a_to_pug
# define u3a_v2_to_pom u3a_to_pom

/** Data structures.
**/
/* u3a_v2_road: contiguous allocation and execution context.
*/
typedef struct _u3a_v2_road {
u3p(struct _u3a_v2_road) par_p; // parent road
u3p(struct _u3a_v2_road) kid_p; // child road list
u3p(struct _u3a_v2_road) nex_p; // sibling road

u3p(c3_w) cap_p; // top of transient region
u3p(c3_w) hat_p; // top of durable region
u3p(c3_w) mat_p; // bottom of transient region
u3p(c3_w) rut_p; // bottom of durable region
u3p(c3_w) ear_p; // original cap if kid is live

c3_w fut_w[32]; // futureproof buffer

struct { // escape buffer
union {
jmp_buf buf;
c3_w buf_w[256]; // futureproofing
};
} esc;

struct { // miscellaneous config
c3_w fag_w; // flag bits
} how; //

struct { // allocation pools
u3p(u3a_fbox) fre_p[u3a_fbox_no]; // heap by node size log
u3p(u3a_fbox) cel_p; // custom cell allocator
c3_w fre_w; // number of free words
c3_w max_w; // maximum allocated
} all;

u3a_jets jed; // jet dashboard

struct { // bytecode state
u3p(u3h_root) har_p; // formula->post of bytecode
} byc;

struct { // namespace
u3_noun gul; // (list $+(* (unit (unit)))) now
} ski;

struct { // trace stack
u3_noun tax; // (list ,*)
u3_noun mer; // emergency buffer to release
} bug;

struct { // profile stack
c3_d nox_d; // nock steps
c3_d cel_d; // cell allocations
u3_noun don; // (list batt)
u3_noun trace; // (list trace)
u3_noun day; // doss, only in u3H (moveme)
} pro;

struct { // memoization
u3p(u3h_root) har_p; // (map (pair term noun) noun)
} cax;
} u3a_v2_road;

/** Globals.
**/
/// Current road (thread-local).
extern u3a_v2_road* u3a_v2_Road;
# define u3R_v2 u3a_v2_Road

/** Functions.
**/
/** Allocation.
Expand Down
22 changes: 20 additions & 2 deletions pkg/noun/v2/vortex.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,29 @@

#include "pkg/noun/vortex.h"

#include "pkg/noun/v2/allocate.h"
#include "pkg/noun/version.h"

/** Aliases.
**/
# define u3H_v2 u3H
# define u3v_v2_arvo u3v_arvo
# define u3v_v2_home u3v_home

/** Data structures.
**/
/* u3v_v2_home: all internal (within image) state.
** NB: version must be last for discriminability in north road
*/
typedef struct _u3v_v2_home {
u3a_v2_road rod_u; // storage state
u3v_v2_arvo arv_u; // arvo state
u3v_version ver_w; // version number
} u3v_v2_home;

/** Globals.
**/
/// Arvo internal state.
extern u3v_v2_home* u3v_v2_Home;
# define u3H_v2 u3v_v2_Home

/** Functions.
**/
Expand Down

0 comments on commit ef7b8a6

Please sign in to comment.