diff --git a/pkg/noun/v2/allocate.h b/pkg/noun/v2/allocate.h index 48ef44267f..bbce4ad121 100644 --- a/pkg/noun/v2/allocate.h +++ b/pkg/noun/v2/allocate.h @@ -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 @@ -26,7 +25,7 @@ # 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 @@ -34,6 +33,75 @@ # 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. diff --git a/pkg/noun/v2/vortex.h b/pkg/noun/v2/vortex.h index dd002eb9e5..d9fc8fcbbb 100644 --- a/pkg/noun/v2/vortex.h +++ b/pkg/noun/v2/vortex.h @@ -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. **/