ref: e1bfd3ee239d17bd45b7cc2caa671a91e0774304
parent: b9cf124f492b69a0c76c9cb89d07a046c0e6c7e8
parent: 89331eff71ab876a5b6b534141b1422b2ca42e0b
author: Ori Bernstein <ori@eigenstate.org>
date: Tue May 1 05:07:03 EDT 2018
Merge branch 'master' of /git/ori/mc
--- a/6/blob.c
+++ b/6/blob.c
@@ -205,7 +205,7 @@
sz = tysize(tybase(exprtype(base))->sub[0]);
lbl = htget(globls, base);
slbase = mkblobref(lbl, loval*sz, 1);
- } else if (exprop(base) == Olit) {
+ } else if (exprop(base) == Olit || exprop(base) == Oarr) {
slbase = mkblobi(Bti64, getintlit(base, "invalid base expr"));
} else {
fatal(base, "slice base is not a constant value");
--- a/6/simp.c
+++ b/6/simp.c
@@ -1479,6 +1479,7 @@
switch (exprop(e)) {
case Oslice:
sub = e->expr.args[0];
+ extractsub(s, sub);
if (exprop(sub) == Oarr) {
if (sub->expr.nargs > 0) {
e->expr.args[0] = simpblob(s, e->expr.args[0]);
--- a/lib/thread/exit+openbsd-x64.s
+++ b/lib/thread/exit+openbsd-x64.s
@@ -10,6 +10,13 @@
andq $~0xfff,%rdi /* align it */
addq $0x1000,%rdi
+ /*
+ Because OpenBSD wants a valid stack whenever
+ we enter the kernel, we need to toss a preallocated
+ stack pointer into %rsp.
+ */
+ movq thread$exitstk,%rsp
+
/* munmap(base, size) */
movq $73,%rax /* munmap */
movq -8(%rdi),%rsi /* size */
--- a/lib/thread/spawn+openbsd.myr
+++ b/lib/thread/spawn+openbsd.myr
@@ -5,10 +5,20 @@
type tid = uint64
const spawn : (fn : (-> void) -> std.result(tid, byte[:]))
+ pkglocal var exitstk : byte#
;;
const Stacksz = 8*std.MiB
extern const exit : (-> void)
+
+var exitstk
+const __init__ = {
+ /*
+ We need a valid stack at all times, so we allocate one ahead of
+ time to swap to before we invalidate a stack.
+ */
+ exitstk = getstk(16)
+}
const spawn = {fn;
-> spawnstk(fn, Stacksz)
--- a/lib/thread/test/spawn.myr
+++ b/lib/thread/test/spawn.myr
@@ -21,5 +21,6 @@
;;
std.assert(capture == 333, "capture wasn't written to correctly\n")
+ std.usleep(100_000)
}