summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/v3
diff options
context:
space:
mode:
Diffstat (limited to 'vere/pkg/noun/v3')
-rw-r--r--vere/pkg/noun/v3/allocate.h17
-rw-r--r--vere/pkg/noun/v3/hashtable.c33
-rw-r--r--vere/pkg/noun/v3/hashtable.h18
-rw-r--r--vere/pkg/noun/v3/jets.h12
-rw-r--r--vere/pkg/noun/v3/manage.c109
-rw-r--r--vere/pkg/noun/v3/manage.h13
-rw-r--r--vere/pkg/noun/v3/nock.h17
-rw-r--r--vere/pkg/noun/v3/vortex.h19
8 files changed, 238 insertions, 0 deletions
diff --git a/vere/pkg/noun/v3/allocate.h b/vere/pkg/noun/v3/allocate.h
new file mode 100644
index 0000000..a47cc1f
--- /dev/null
+++ b/vere/pkg/noun/v3/allocate.h
@@ -0,0 +1,17 @@
+#ifndef U3_ALLOCATE_V3_H
+#define U3_ALLOCATE_V3_H
+
+#include "../allocate.h"
+
+#include "v3/manage.h"
+#include "options.h"
+
+ /** Aliases.
+ **/
+# define u3R_v3 u3a_Road
+# define u3a_v3_balign u3a_balign
+# define u3a_v3_road u3a_road
+# define u3a_v3_walign u3a_walign
+# define u3a_v3_walloc u3a_walloc
+
+#endif /* ifndef U3_ALLOCATE_V3_H */
diff --git a/vere/pkg/noun/v3/hashtable.c b/vere/pkg/noun/v3/hashtable.c
new file mode 100644
index 0000000..3044758
--- /dev/null
+++ b/vere/pkg/noun/v3/hashtable.c
@@ -0,0 +1,33 @@
+/// @file
+
+#include "v3/hashtable.h"
+
+#include "../allocate.h"
+#include "../vortex.h"
+
+#include "v3/allocate.h"
+#include "v3/vortex.h"
+
+/* u3h_v3_new_cache(): create hashtable with bounded size.
+*/
+u3p(u3h_v3_root)
+u3h_v3_new_cache(c3_w max_w)
+{
+ // set globals (required for aliased functions)
+ u3H = (u3v_home*) u3H_v3;
+ u3R = (u3a_road*) u3R_v3;
+
+ u3h_v3_root* har_u = u3a_v3_walloc(c3_wiseof(u3h_v3_root));
+ u3p(u3h_v3_root) har_p = u3of(u3h_v3_root, har_u);
+ c3_w i_w;
+
+ har_u->max_w = max_w;
+ har_u->use_w = 0;
+ har_u->arm_u.mug_w = 0;
+ har_u->arm_u.inx_w = 0;
+
+ for ( i_w = 0; i_w < 64; i_w++ ) {
+ har_u->sot_w[i_w] = 0;
+ }
+ return har_p;
+}
diff --git a/vere/pkg/noun/v3/hashtable.h b/vere/pkg/noun/v3/hashtable.h
new file mode 100644
index 0000000..1d00a86
--- /dev/null
+++ b/vere/pkg/noun/v3/hashtable.h
@@ -0,0 +1,18 @@
+#ifndef U3_HASHTABLE_V3_H
+#define U3_HASHTABLE_V3_H
+
+#define u3h_v3_free u3h_free
+#define u3h_v3_new u3h_new
+#define u3h_v3_root u3h_root
+#define u3h_v3_walk u3h_walk
+
+#include "../hashtable.h"
+
+ /** Functions.
+ **/
+ /* u3h_v3_new_cache(): create hashtable with bounded size.
+ */
+ u3p(u3h_v3_root)
+ u3h_v3_new_cache(c3_w clk_w);
+
+#endif /* U3_HASHTABLE_V3_H */
diff --git a/vere/pkg/noun/v3/jets.h b/vere/pkg/noun/v3/jets.h
new file mode 100644
index 0000000..089ff64
--- /dev/null
+++ b/vere/pkg/noun/v3/jets.h
@@ -0,0 +1,12 @@
+/// @file
+
+#ifndef U3_JETS_V3_H
+#define U3_JETS_V3_H
+
+#include "../jets.h"
+
+ /** Aliases.
+ **/
+# define u3j_v3_free_hank u3j_free_hank
+
+#endif /* ifndef U3_JETS_V3_H */
diff --git a/vere/pkg/noun/v3/manage.c b/vere/pkg/noun/v3/manage.c
new file mode 100644
index 0000000..0cde37a
--- /dev/null
+++ b/vere/pkg/noun/v3/manage.c
@@ -0,0 +1,109 @@
+/// @file
+
+#include "v3/manage.h"
+
+#include "v2/jets.h"
+#include "v2/nock.h"
+#include "v2/vortex.h"
+
+#include "v3/allocate.h"
+#include "v3/hashtable.h"
+#include "../version.h"
+#include "v3/vortex.h"
+#include "v2/allocate.h"
+
+/* u3m_v3_migrate: perform loom migration if necessary.
+*/
+void
+u3m_v3_migrate(void)
+{
+ fprintf(stderr, "loom: memoization migration running...\r\n");
+
+
+ c3_w *mem_w = u3_Loom + u3a_v3_walign;
+ c3_w len_w = u3C.wor_i - u3a_v3_walign;
+ c3_w suz_w = c3_wiseof(u3v_v2_home);
+ c3_w *mut_w = c3_align(mem_w + len_w - suz_w, u3a_v3_balign, C3_ALGLO);
+
+ // old road
+ u3v_v2_home* hum_u = (u3v_v2_home*)mut_w;
+ u3a_v2_road* rud_u = &hum_u->rod_u;
+
+ // set v2 globals
+ u3H_v2 = (void *)mut_w;
+ u3R_v2 = &u3H_v2->rod_u;
+ u3R_v2->cap_p = u3R_v2->mat_p = u3a_v2_outa(u3H_v2);
+
+ u3R = (u3a_road*)u3R_v2;
+ u3H = (u3v_home*)u3H_v2;
+ u3a_ream();
+
+ // free bytecode caches in old road
+ u3j_v2_reclaim();
+ u3n_v2_reclaim();
+
+ // new home, new road
+ u3v_v3_home hom_u = {0};
+ u3a_v3_road rod_u = {0};
+
+ // copy members, one-by-one, from old road to new road
+ rod_u.par_p = rud_u->par_p;
+ rod_u.kid_p = rud_u->kid_p;
+ rod_u.nex_p = rud_u->nex_p;
+
+ rod_u.cap_p = rud_u->cap_p;
+ rod_u.hat_p = rud_u->hat_p;
+ rod_u.mat_p = rud_u->mat_p;
+ rod_u.rut_p = rud_u->rut_p;
+ rod_u.ear_p = rud_u->ear_p;
+
+ // no need to zero-out fut_w
+ // no need to do anything with esc
+
+ rod_u.how.fag_w = rud_u->how.fag_w;
+
+ memcpy(rod_u.all.fre_p, rud_u->all.fre_p, sizeof(rud_u->all.fre_p));
+ rod_u.all.cel_p = rud_u->all.cel_p;
+ rod_u.all.fre_w = rud_u->all.fre_w;
+ rod_u.all.max_w = rud_u->all.max_w;
+
+ rod_u.jed.hot_p = rud_u->jed.hot_p;
+ rod_u.jed.war_p = rud_u->jed.war_p;
+ rod_u.jed.cod_p = rud_u->jed.cod_p;
+ rod_u.jed.han_p = rud_u->jed.han_p;
+ rod_u.jed.bas_p = rud_u->jed.bas_p;
+
+ rod_u.byc.har_p = rud_u->byc.har_p;
+
+ rod_u.ski.gul = rud_u->ski.gul;
+
+ rod_u.bug.tax = rud_u->bug.tax;
+ rod_u.bug.mer = rud_u->bug.mer;
+
+ rod_u.pro.nox_d = rud_u->pro.nox_d;
+ rod_u.pro.cel_d = rud_u->pro.cel_d;
+ rod_u.pro.don = rud_u->pro.don;
+ rod_u.pro.trace = rud_u->pro.trace;
+ rod_u.pro.day = rud_u->pro.day;
+
+ rod_u.cax.har_p = rud_u->cax.har_p;
+
+ // prepare the new home, update the version
+ hom_u.arv_u = hum_u->arv_u;
+ hom_u.rod_u = rod_u;
+
+ // place the new home over the old one
+ c3_w siz_w = c3_wiseof(u3v_v3_home);
+ c3_w *mat_w = c3_align(mem_w + len_w - siz_w, u3a_v3_balign, C3_ALGLO);
+ memcpy(mat_w, &hom_u, sizeof(u3v_v3_home));
+
+ // set globals
+ u3H_v3 = (void*)mat_w;
+ u3R_v3 = &u3H_v3->rod_u;
+ u3H_v3->ver_w = U3V_VER3;
+
+ // initialize persistent cache
+ u3R_v3->cax.per_p = u3h_v3_new_cache(u3C.per_w);
+
+ fprintf(stderr, "loom: memoization migration done\r\n");
+}
diff --git a/vere/pkg/noun/v3/manage.h b/vere/pkg/noun/v3/manage.h
new file mode 100644
index 0000000..1cdd28a
--- /dev/null
+++ b/vere/pkg/noun/v3/manage.h
@@ -0,0 +1,13 @@
+/// @file
+
+#ifndef U3_MANAGE_V3_H
+#define U3_MANAGE_V3_H
+
+ /** System management.
+ **/
+ /* u3m_v3_migrate: perform memoization loom migration if necessary.
+ */
+ void
+ u3m_v3_migrate(void);
+
+#endif /* ifndef U3_MANAGE_V3_H */
diff --git a/vere/pkg/noun/v3/nock.h b/vere/pkg/noun/v3/nock.h
new file mode 100644
index 0000000..ee76eb9
--- /dev/null
+++ b/vere/pkg/noun/v3/nock.h
@@ -0,0 +1,17 @@
+/// @file
+
+#ifndef U3_NOCK_V3_H
+#define U3_NOCK_V3_H
+
+#include "../nock.h"
+
+#include "types.h"
+
+ /** Aliases.
+ **/
+# define u3n_v3_free u3n_free
+# define u3n_v3_memo u3n_memo
+# define u3n_v3_prog u3n_prog
+# define u3n_v3_reclaim u3n_reclaim
+
+#endif /* ifndef U3_NOCK_V3_H */
diff --git a/vere/pkg/noun/v3/vortex.h b/vere/pkg/noun/v3/vortex.h
new file mode 100644
index 0000000..9a4c9ef
--- /dev/null
+++ b/vere/pkg/noun/v3/vortex.h
@@ -0,0 +1,19 @@
+/// @file
+
+#ifndef U3_VORTEX_V3_H
+#define U3_VORTEX_V3_H
+
+#include "../vortex.h"
+
+#include "v3/allocate.h"
+#include "../version.h"
+
+ /** Aliases.
+ **/
+# define u3v_v3_arvo u3v_arvo
+# define u3H_v3 u3v_Home
+# define u3A_v3 (&(u3H_v3)->arv_u)
+# define u3v_v3_home u3v_home
+# define u3v_v3_rewrite_compact u3v_rewrite_compact
+
+#endif /* ifndef U3_VORTEX_V3_H */