summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-05-01 09:07:03 -0700
committerOri Bernstein <ori@eigenstate.org>2018-05-01 09:07:03 -0700
commite1bfd3ee239d17bd45b7cc2caa671a91e0774304 (patch)
tree8172fa0cad3e0a050a18a173dd96de04b89691ac
parentb9cf124f492b69a0c76c9cb89d07a046c0e6c7e8 (diff)
parent89331eff71ab876a5b6b534141b1422b2ca42e0b (diff)
downloadmc-e1bfd3ee239d17bd45b7cc2caa671a91e0774304.tar.gz
Merge branch 'master' of /git/ori/mc
-rw-r--r--6/blob.c2
-rw-r--r--6/simp.c1
-rw-r--r--lib/thread/exit+openbsd-x64.s7
-rw-r--r--lib/thread/spawn+openbsd.myr10
-rw-r--r--lib/thread/test/spawn.myr1
5 files changed, 20 insertions, 1 deletions
diff --git a/6/blob.c b/6/blob.c
index 4c1fa0b..410acab 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -205,7 +205,7 @@ blobslice(Blob *seq, Htab *globls, Htab *strtab, Node *n)
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");
diff --git a/6/simp.c b/6/simp.c
index 803c5d3..121dcd5 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1479,6 +1479,7 @@ extractsub(Simp *s, Node *e)
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]);
diff --git a/lib/thread/exit+openbsd-x64.s b/lib/thread/exit+openbsd-x64.s
index 23f92b5..6421cc3 100644
--- a/lib/thread/exit+openbsd-x64.s
+++ b/lib/thread/exit+openbsd-x64.s
@@ -10,6 +10,13 @@ thread$exit:
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 */
diff --git a/lib/thread/spawn+openbsd.myr b/lib/thread/spawn+openbsd.myr
index c925349..a72e752 100644
--- a/lib/thread/spawn+openbsd.myr
+++ b/lib/thread/spawn+openbsd.myr
@@ -5,11 +5,21 @@ pkg thread =
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)
}
diff --git a/lib/thread/test/spawn.myr b/lib/thread/test/spawn.myr
index 2bd3b24..9fd0580 100644
--- a/lib/thread/test/spawn.myr
+++ b/lib/thread/test/spawn.myr
@@ -21,5 +21,6 @@ const main = {
;;
std.assert(capture == 333, "capture wasn't written to correctly\n")
+ std.usleep(100_000)
}