From 869d8b98ab2249229f3c318ce94d917157a8766d Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 20 Jun 2023 13:55:14 -0700 Subject: [PATCH 1/2] jets: let +bex create atoms 256MB or more --- pkg/noun/jets/c/bex.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/pkg/noun/jets/c/bex.c b/pkg/noun/jets/c/bex.c index 5c17fc0fe9..abc5b41cb6 100644 --- a/pkg/noun/jets/c/bex.c +++ b/pkg/noun/jets/c/bex.c @@ -9,17 +9,34 @@ u3_noun u3qc_bex(u3_atom a) { - mpz_t a_mp; + c3_d a_d; + u3i_slab sab_u; - if ( !_(u3a_is_cat(a)) ) { - return u3m_bail(c3__fail); + if ( a < 31 ) { + return 1 << a; + } + + if ( c3y == u3a_is_cat(a) ) { + a_d = a; } else { - mpz_init_set_ui(a_mp, 1); - mpz_mul_2exp(a_mp, a_mp, a); + if ( c3n == u3r_safe_chub(a, &a_d) ) { + return u3m_bail(c3__fail); + } - return u3i_mp(a_mp); + // We don't currently support atoms 2GB or larger (fails while + // mugging). The extra term of 16 is experimentally determined. + if ( a_d >= ((c3_d)1 << (c3_d)34) - 16 ) { + u3l_log("bex: overflow"); + return u3m_bail(c3__fail); + } } + + u3i_slab_init(&sab_u, 0, a_d + 1); + + sab_u.buf_w[a_d >> 5] = 1 << (a_d & 31); + + return u3i_slab_mint(&sab_u); } u3_noun From 25505af9a63489b4917a49c192f1320e146e0dce Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Tue, 20 Jun 2023 15:27:09 -0700 Subject: [PATCH 2/2] jets: mint -> moot --- pkg/noun/jets/c/bex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/noun/jets/c/bex.c b/pkg/noun/jets/c/bex.c index abc5b41cb6..f064dc7a79 100644 --- a/pkg/noun/jets/c/bex.c +++ b/pkg/noun/jets/c/bex.c @@ -36,7 +36,7 @@ u3qc_bex(u3_atom a) sab_u.buf_w[a_d >> 5] = 1 << (a_d & 31); - return u3i_slab_mint(&sab_u); + return u3i_slab_moot(&sab_u); } u3_noun