summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-09-22 01:10:40 -0700
committerRuss Cox <rsc@golang.org>2009-09-22 01:10:40 -0700
commit1e3247ad5231cdeac824391038909fdbef8bcd90 (patch)
tree697d9c2eeaa85f0b4896fdea5d1f874940ced93e
parente38215fa033153699335e975ec1d3f847aa79323 (diff)
downloadgolang-1e3247ad5231cdeac824391038909fdbef8bcd90.tar.gz
nacl:
add jmp to constant pc. generate HLT for INT $3 do not insert NOPs between REP/REPN and subsequent instruction. allow very long time for convergence. R=ken OCL=34879 CL=34879
-rw-r--r--src/cmd/8l/l.h1
-rw-r--r--src/cmd/8l/optab.c3
-rw-r--r--src/cmd/8l/pass.c1
-rw-r--r--src/cmd/8l/span.c35
4 files changed, 35 insertions, 5 deletions
diff --git a/src/cmd/8l/l.h b/src/cmd/8l/l.h
index 98d35de62..b62d9f8fd 100644
--- a/src/cmd/8l/l.h
+++ b/src/cmd/8l/l.h
@@ -201,6 +201,7 @@ enum
Zil_rp,
Zilo_m,
Zjmp,
+ Zjmpcon,
Zloop,
Zm_o,
Zm_r,
diff --git a/src/cmd/8l/optab.c b/src/cmd/8l/optab.c
index 14e6daa32..0e3659934 100644
--- a/src/cmd/8l/optab.c
+++ b/src/cmd/8l/optab.c
@@ -267,7 +267,8 @@ uchar ycall[] =
uchar yjmp[] =
{
Ynone, Yml, Zo_m, 2,
- Ynone, Ybr, Zjmp, 1,
+ Ynone, Ybr, Zjmp, 0,
+ Ynone, Yi32, Zjmpcon, 1,
0
};
diff --git a/src/cmd/8l/pass.c b/src/cmd/8l/pass.c
index bc3e1649f..576e51bfd 100644
--- a/src/cmd/8l/pass.c
+++ b/src/cmd/8l/pass.c
@@ -464,7 +464,6 @@ dostkoff(void)
int a, f, curframe, curbecome, maxbecome;
Prog *pmorestack;
Sym *symmorestack;
- static int fsreg;
pmorestack = P;
symmorestack = lookup("sys·morestack", 0);
diff --git a/src/cmd/8l/span.c b/src/cmd/8l/span.c
index 184a37d31..7745c361c 100644
--- a/src/cmd/8l/span.c
+++ b/src/cmd/8l/span.c
@@ -72,8 +72,9 @@ start:
if(debug['v'])
Bprint(&bso, "%5.2f span %d\n", cputime(), n);
Bflush(&bso);
- if(n > 50) {
- print("span must be looping\n");
+ if(n > 500) {
+ // TODO(rsc): figure out why nacl takes so long to converge.
+ print("span must be looping - %d\n", textsize);
errorexit();
}
c = INITTEXT;
@@ -1045,6 +1046,12 @@ found:
case Z_ib:
v = vaddr(&p->to);
case Zib_:
+ if(HEADTYPE == 8 && p->as == AINT && v == 3) {
+ // native client disallows all INT instructions.
+ // translate INT $3 to HLT.
+ *andptr++ = 0xf4;
+ break;
+ }
*andptr++ = op;
*andptr++ = v;
break;
@@ -1194,6 +1201,15 @@ found:
}
break;
+ case Zjmpcon:
+ v = p->to.offset - p->pc - 5;
+ *andptr++ = o->op[z+1];
+ *andptr++ = v;
+ *andptr++ = v>>8;
+ *andptr++ = v>>16;
+ *andptr++ = v>>24;
+ break;
+
case Zloop:
q = p->pcond;
if(q) {
@@ -1371,6 +1387,7 @@ asmins(Prog *p)
{
if(HEADTYPE == 8) {
ulong npc;
+ static Prog *prefix;
// native client
// - pad indirect jump targets (aka ATEXT) to 32-byte boundary
@@ -1386,15 +1403,27 @@ asmins(Prog *p)
npc = p->pc + (andptr - and);
p->pc += 31 & -npc;
}
+ if(p->as == AREP || p->as == AREPN) {
+ // save prefix for next instruction,
+ // so that inserted NOPs do not split (e.g.) REP / MOVSL sequence.
+ prefix = p;
+ andptr = and;
+ return;
+ }
andptr = and;
+ if(prefix)
+ doasm(prefix);
doasm(p);
npc = p->pc + (andptr - and);
- if((p->pc&~31) != ((npc-1)&~31)) {
+ if(andptr > and && (p->pc&~31) != ((npc-1)&~31)) {
// crossed 32-byte boundary; pad to boundary and try again
p->pc += 31 & -p->pc;
andptr = and;
+ if(prefix)
+ doasm(prefix);
doasm(p);
}
+ prefix = nil;
} else {
andptr = and;
doasm(p);