Skip to content

Commit 0a0e9d7

Browse files
committed
Merge branch 'develop' into ml/64
2 parents 2cc6f05 + 765bcbe commit 0a0e9d7

12 files changed

Lines changed: 74 additions & 460 deletions

File tree

ext/urcrypt/build.zig.zon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
.hash = "N-V-__8AAJ4DSwC7aDpt90TmGPWKAI6q4-titwp4M0zsZ2vY",
1616
},
1717
.urcrypt = .{
18-
.url = "https://github.com/urbit/urcrypt/archive/465aad6262f2710f76f75adfe74effb5751c5ab3.tar.gz",
19-
.hash = "N-V-__8AAL3OSQDA9xQasK60FkxcKuQoSANeWy_f9SxmxX1X",
18+
.url = "https://github.com/urbit/urcrypt/archive/6c93535d46adffcd1495f904bac91d43b2d6d555.tar.gz",
19+
.hash = "N-V-__8AAEPPSQAFB28-gqWMJB7_zp5ZIS8wIN4boyLzAWRb",
2020
},
2121
},
2222
.paths = .{

pkg/noun/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub fn build(b: *std.Build) !void {
183183
if (t.os.tag == .windows) {
184184
pkg_noun.addCSourceFiles(.{
185185
.root = b.path("platform/windows"),
186-
.files = &.{ "veh_handler.c", "rsignal.c" },
186+
.files = &.{ "veh_handler.c", "rsignal.c", "setjmp.c" },
187187
.flags = flags.items,
188188
});
189189
}

pkg/noun/hashtable.c

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@
1414
*/
1515
#define BIT_SET(a_w, b_w) ((a_w) & ((c3_h)1 << (b_w)))
1616

17-
/* asserting noun deconstruction to make sure HAMTs are bail-safe
18-
*/
19-
static inline u3_noun
20-
_h_need(u3_noun som)
21-
{
22-
u3_assert( _(u3a_is_cell(som)) );
23-
return ((u3a_cell *)u3a_to_ptr(som))->hed;
24-
}
25-
26-
static inline u3_noun
27-
_t_need(u3_noun som)
28-
{
29-
u3_assert( _(u3a_is_cell(som)) );
30-
return ((u3a_cell *)u3a_to_ptr(som))->tel;
31-
}
32-
3317
static u3_weak
3418
_ch_trim_slot(u3h_root* har_u, u3h_slot *sot_w, c3_h lef_h, c3_h rem_h);
3519

@@ -149,8 +133,8 @@ _ch_buck_add(u3h_buck* hab_u, u3_noun kev, c3_w *use_w)
149133
// then replace that key-value pair with kev.
150134
//
151135
for ( i_h = 0; i_h < hab_u->len_h; i_h++ ) {
152-
u3_noun kov = u3h_slot_to_noun(hab_u->sot_w[i_h]);
153-
if ( c3y == u3r_sing(_h_need(kev), _h_need(kov)) ) {
136+
u3_noun kov = u3h_slot_to_noun(hab_u->sot_h[i_h]);
137+
if ( c3y == u3r_sing(u3h(kev), u3h(kov)) ) {
154138
hab_u->sot_w[i_h] = u3h_noun_to_slot(kev);
155139
u3z(kov);
156140
return hab_u;
@@ -250,13 +234,13 @@ _ch_slot_put(u3h_slot* sot_w, u3_noun kev, c3_h lef_h, c3_h rem_h, c3_w* use_w)
250234
else {
251235
u3_noun kov = u3h_slot_to_noun(*sot_w);
252236
u3h_slot add_w = u3h_noun_be_warm(u3h_noun_to_slot(kev));
253-
if ( c3y == u3r_sing(_h_need(kev), _h_need(kov)) ) {
237+
if ( c3y == u3r_sing(u3h(kev), u3h(kov)) ) {
254238
// replace old value
255239
u3z(kov);
256240
*sot_w = add_w;
257241
}
258242
else {
259-
c3_h ham_h = CUT_END(u3r_mug(_h_need(kov)), lef_h);
243+
c3_h ham_h = CUT_END(u3r_mug(u3h(kov)), lef_h);
260244
*sot_w = _ch_two(*sot_w, add_w, lef_h, ham_h, rem_h);
261245
*use_w += 1;
262246
}
@@ -327,7 +311,7 @@ _ch_buck_del(u3h_slot* sot_w, u3_noun key)
327311
//
328312
for ( i_h = 0; i_h < hab_u->len_h; i_h++ ) {
329313
u3_noun kov = u3h_slot_to_noun(hab_u->sot_w[i_h]);
330-
if ( c3y == u3r_sing(key, _h_need(kov)) ) {
314+
if ( c3y == u3r_sing(key, u3h(kov)) ) {
331315
fin_h = i_h;
332316
u3z(kov);
333317
break;
@@ -464,7 +448,7 @@ _ch_uni_with(u3_noun kev, void* wit)
464448
{
465449
u3p(u3h_root) har_p = *(u3p(u3h_root)*)wit;
466450
u3_noun key, val;
467-
u3_assert(c3y == u3r_cell(kev, &key, &val));
451+
u3x_cell(kev, &key, &val);
468452

469453
u3h_put(har_p, key, u3k(val));
470454
}
@@ -668,7 +652,7 @@ _ch_buck_hum(u3h_buck* hab_u, c3_h mug_h)
668652
c3_h i_h;
669653

670654
for ( i_h = 0; i_h < hab_u->len_h; i_h++ ) {
671-
if ( mug_h == u3r_mug(_h_need(u3h_slot_to_noun(hab_u->sot_w[i_h]))) ) {
655+
if ( mug_h == u3r_mug(u3h(u3h_slot_to_noun(hab_u->sot_w[i_h]))) ) {
672656
return c3y;
673657
}
674658
}
@@ -697,7 +681,7 @@ _ch_node_hum(u3h_node* han_u, c3_h lef_h, c3_h rem_h, c3_h mug_h)
697681
if ( _(u3h_slot_is_noun(sot_w)) ) {
698682
u3_noun kev = u3h_slot_to_noun(sot_w);
699683

700-
if ( mug_h == u3r_mug(_h_need(kev)) ) {
684+
if ( mug_h == u3r_mug(u3h(kev)) ) {
701685
return c3y;
702686
}
703687
else {
@@ -733,7 +717,7 @@ u3h_hum(u3p(u3h_root) har_p, c3_h mug_h)
733717
else if ( _(u3h_slot_is_noun(sot_w)) ) {
734718
u3_noun kev = u3h_slot_to_noun(sot_w);
735719

736-
if ( mug_h == u3r_mug(_h_need(kev)) ) {
720+
if ( mug_h == u3r_mug(u3h(kev)) ) {
737721
return c3y;
738722
}
739723
else {
@@ -756,7 +740,7 @@ _ch_buck_git(u3h_buck* hab_u, u3_noun key)
756740

757741
for ( i_h = 0; i_h < hab_u->len_h; i_h++ ) {
758742
u3_noun kev = u3h_slot_to_noun(hab_u->sot_w[i_h]);
759-
if ( _(u3r_sing(key, _h_need(kev))) ) {
743+
if ( _(u3r_sing(key, u3h(kev))) ) {
760744
return u3t(kev);
761745
}
762746
}
@@ -785,8 +769,8 @@ _ch_node_git(u3h_node* han_u, c3_h lef_h, c3_h rem_h, u3_noun key)
785769
if ( _(u3h_slot_is_noun(sot_w)) ) {
786770
u3_noun kev = u3h_slot_to_noun(sot_w);
787771

788-
if ( _(u3r_sing(key, _h_need(kev))) ) {
789-
return _t_need(kev);
772+
if ( _(u3r_sing(key, u3h(kev))) ) {
773+
return u3t(kev);
790774
}
791775
else {
792776
return u3_none;
@@ -822,7 +806,7 @@ u3h_git(u3p(u3h_root) har_p, u3_noun key)
822806
else if ( _(u3h_slot_is_noun(sot_w)) ) {
823807
u3_noun kev = u3h_slot_to_noun(sot_w);
824808

825-
if ( _(u3r_sing(key, _h_need(kev))) ) {
809+
if ( _(u3r_sing(key, u3h(kev))) ) {
826810
har_u->sot_w[inx_h] = u3h_noun_be_warm(sot_w);
827811
return u3t(kev);
828812
}
@@ -1009,8 +993,8 @@ static u3h_slot
1009993
_ch_take_noun(u3h_slot sot_w, u3_funk fun_f)
1010994
{
1011995
u3_noun kov = u3h_slot_to_noun(sot_w);
1012-
u3_noun kev = u3nc(u3a_take(_h_need(kov)),
1013-
fun_f(_t_need(kov)));
996+
u3_noun kev = u3nc(u3a_take(u3h(kov)),
997+
fun_f(u3t(kov)));
1014998

1015999
return u3h_noun_to_slot(kev);
10161000
}

pkg/noun/manage.c

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,7 @@ _cm_stack_unwind(void)
290290
u3_noun tax;
291291

292292
while ( u3R != &(u3H->rod_u) ) {
293-
u3_noun yat = u3R->bug.tax;
294-
u3m_fall();
295-
yat = u3a_take(yat);
296-
// pop the stack
297-
//
298-
u3a_drop_heap(u3R->cap_p, u3R->ear_p);
299-
u3R->cap_p = u3R->ear_p;
300-
u3R->ear_p = 0;
293+
u3_noun yat = u3m_love(u3R->bug.tax);
301294

302295
u3R->bug.tax = u3kb_weld(yat, u3R->bug.tax);
303296
}
@@ -1387,43 +1380,6 @@ u3m_love(u3_noun pro)
13871380
return pro;
13881381
}
13891382

1390-
/* u3m_warm(): return product from leap without promoting state
1391-
*/
1392-
u3_noun
1393-
u3m_warm(u3_noun pro)
1394-
{
1395-
c3_o tim_o = u3du(u3R->tim);
1396-
u3m_fall();
1397-
if ( _(tim_o) ) _m_renew_now();
1398-
pro = u3a_take(pro);
1399-
1400-
// pop the stack
1401-
//
1402-
u3a_drop_heap(u3R->cap_p, u3R->ear_p);
1403-
u3R->cap_p = u3R->ear_p;
1404-
u3R->ear_p = 0;
1405-
return pro;
1406-
}
1407-
1408-
/* u3m_pour(): return error ball from leap, promoting the state if the error
1409-
* is deterministic
1410-
*/
1411-
u3_noun
1412-
u3m_pour(u3_noun why)
1413-
{
1414-
u3_assert(c3y == u3du(why));
1415-
switch (u3h(why)) {
1416-
case 0:
1417-
case 1: {
1418-
return u3m_love(why);
1419-
} break;
1420-
1421-
default: {
1422-
return u3m_warm(why);
1423-
} break;
1424-
}
1425-
}
1426-
14271383
/* u3m_golf(): record cap_p length for u3m_flog().
14281384
*/
14291385
c3_w
@@ -1564,7 +1520,7 @@ u3m_soft_top(c3_w mil_w, // timer ms
15641520
#endif
15651521
/* Overload the error result.
15661522
*/
1567-
pro = u3m_pour(why);
1523+
pro = u3m_love(why);
15681524
}
15691525

15701526
/* Revert to external signal regime.
@@ -1695,7 +1651,7 @@ u3m_soft_cax(u3_funq fun_f,
16951651
} break;
16961652

16971653
case 3: { // failure; rebail w/trace
1698-
u3_noun yod = u3m_warm(u3t(why));
1654+
u3_noun yod = u3m_love(u3t(why));
16991655

17001656
u3m_bail
17011657
(u3nt(3,
@@ -1808,7 +1764,7 @@ u3m_soft_run(u3_noun gul,
18081764
} break;
18091765

18101766
case 3: { // failure; rebail w/trace
1811-
u3_noun yod = u3m_warm(u3t(why));
1767+
u3_noun yod = u3m_love(u3t(why));
18121768

18131769
u3m_bail
18141770
(u3nt(3,
@@ -1817,7 +1773,7 @@ u3m_soft_run(u3_noun gul,
18171773
} break;
18181774

18191775
case 4: { // meta-bail
1820-
u3m_bail(u3m_pour(u3t(why)));
1776+
u3m_bail(u3m_love(u3t(why)));
18211777
} break;
18221778
}
18231779
}
@@ -1887,7 +1843,7 @@ u3m_soft_esc(u3_noun ref, u3_noun sam)
18871843
/* Push the error back up to the calling context - not the run we
18881844
** are in, but the caller of the run, matching pure nock semantics.
18891845
*/
1890-
u3m_bail(u3nc(4, u3m_pour(why)));
1846+
u3m_bail(u3nc(4, u3m_love(why)));
18911847
}
18921848

18931849
/* Release the sample. Note that we used it above, but in a junior

pkg/noun/platform/windows/setjmp.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// We want to use __builtin_setjmp but clang has a longstanding bug that causes
2+
// __builtin_setjmp to store a corrupt frame pointer. Until that is fixed we
3+
// write our own. See https://github.com/llvm/llvm-project/pull/186843 for
4+
// details.
5+
6+
__attribute__((naked,returns_twice))
7+
int windows_setjmp(void** buf)
8+
{
9+
// We store the frame pointer, instruction pointer and stack pointer into the
10+
// buffer. Note that we can keep using __builtin_longjmp because we store
11+
// exactly what it expects.
12+
__asm(
13+
"mov %rbp, 0(%rcx)\n"
14+
"mov (%rsp), %rax\n"
15+
"mov %rax, 8(%rcx)\n"
16+
"lea 8(%rsp), %rax\n"
17+
"mov %rax, 16(%rcx)\n"
18+
"xor %eax, %eax\n"
19+
"ret\n"
20+
);
21+
}

pkg/noun/platform/windows/setjmp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ typedef struct jmp_buf {
1010
#define _setjmp setjmp
1111
#define _longjmp longjmp
1212
#define longjmp(buf, val) {(buf).retval = (val); __builtin_longjmp((void**)((buf).buffer), 1);}
13-
#define setjmp(buf) (__builtin_setjmp((void**)(buf.buffer)) ? (buf.retval) : 0)
13+
#define setjmp(buf) (windows_setjmp((void**)(buf.buffer)) ? (buf.retval) : 0)
14+
15+
__attribute__((naked,returns_twice)) int windows_setjmp(void** buf);
1416

1517
#endif// _SETJMP_H

pkg/vere/io/conn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,10 @@ _conn_ef_handle(u3_conn* con_u,
867867
can_u->mor_u.bal_f(can_u, -4, "handle-unknown");
868868
u3_king_bail();
869869
}
870+
871+
if ( !uv_is_readable((uv_stream_t*)&con_u->san_u->pyp_u) ) {
872+
_conn_close_chan(con_u->san_u, can_u);
873+
}
870874
}
871875
else {
872876
u3l_log("conn: handle-no-coq %" PRIxc3_h " %" PRIc3_h,

0 commit comments

Comments
 (0)