Commit f210fd1f authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/6g, runtime: alignment fixes for amd64p32.

LGTM=rsc
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/75820044
parent d8e68811
...@@ -22,7 +22,7 @@ defframe(Prog *ptxt) ...@@ -22,7 +22,7 @@ defframe(Prog *ptxt)
// fill in final stack size // fill in final stack size
ptxt->to.offset <<= 32; ptxt->to.offset <<= 32;
frame = rnd(stksize+maxarg, widthptr); frame = rnd(stksize+maxarg, widthreg);
ptxt->to.offset |= frame; ptxt->to.offset |= frame;
// insert code to contain ambiguously live variables // insert code to contain ambiguously live variables
......
...@@ -12,15 +12,16 @@ ...@@ -12,15 +12,16 @@
#pragma textflag NOSPLIT #pragma textflag NOSPLIT
void void
HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value) HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, GoOutput base, ...)
{ {
uintptr bucket, i; uintptr bucket, i;
Bucket *b; Bucket *b;
KEYTYPE *k; KEYTYPE *k;
byte *v; byte *v, **valueptr;
uint8 top; uint8 top;
int8 keymaybe; int8 keymaybe;
valueptr = (byte**)&base;
if(debug) { if(debug) {
runtime·prints("runtime.mapaccess1_fastXXX: map="); runtime·prints("runtime.mapaccess1_fastXXX: map=");
runtime·printpointer(h); runtime·printpointer(h);
...@@ -29,8 +30,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value) ...@@ -29,8 +30,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value)
runtime·prints("\n"); runtime·prints("\n");
} }
if(h == nil || h->count == 0) { if(h == nil || h->count == 0) {
value = t->elem->zero; *valueptr = t->elem->zero;
FLUSH(&value);
return; return;
} }
if(raceenabled) if(raceenabled)
...@@ -48,8 +48,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value) ...@@ -48,8 +48,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value)
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) { if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) {
value = v; *valueptr = v;
FLUSH(&value);
return; return;
} }
} }
...@@ -61,8 +60,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value) ...@@ -61,8 +60,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value)
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k)) { if(QUICK_EQ(key, *k)) {
value = v; *valueptr = v;
FLUSH(&value);
return; return;
} }
if(MAYBE_EQ(key, *k)) { if(MAYBE_EQ(key, *k)) {
...@@ -80,8 +78,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value) ...@@ -80,8 +78,7 @@ HASH_LOOKUP1(MapType *t, Hmap *h, KEYTYPE key, byte *value)
if(keymaybe >= 0) { if(keymaybe >= 0) {
k = (KEYTYPE*)b->data + keymaybe; k = (KEYTYPE*)b->data + keymaybe;
if(SLOW_EQ(key, *k)) { if(SLOW_EQ(key, *k)) {
value = (byte*)((KEYTYPE*)b->data + BUCKETSIZE) + keymaybe * h->valuesize; *valueptr = (byte*)((KEYTYPE*)b->data + BUCKETSIZE) + keymaybe * h->valuesize;
FLUSH(&value);
return; return;
} }
} }
...@@ -110,29 +107,30 @@ dohash: ...@@ -110,29 +107,30 @@ dohash:
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) { if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) {
value = v; *valueptr = v;
FLUSH(&value);
return; return;
} }
} }
b = b->overflow; b = b->overflow;
} while(b != nil); } while(b != nil);
} }
value = t->elem->zero; *valueptr = t->elem->zero;
FLUSH(&value);
} }
#pragma textflag NOSPLIT #pragma textflag NOSPLIT
void void
HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res) HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, GoOutput base, ...)
{ {
uintptr bucket, i; uintptr bucket, i;
Bucket *b; Bucket *b;
KEYTYPE *k; KEYTYPE *k;
byte *v; byte *v, **valueptr;
uint8 top; uint8 top;
int8 keymaybe; int8 keymaybe;
bool *okptr;
valueptr = (byte**)&base;
okptr = (bool*)(valueptr+1);
if(debug) { if(debug) {
runtime·prints("runtime.mapaccess2_fastXXX: map="); runtime·prints("runtime.mapaccess2_fastXXX: map=");
runtime·printpointer(h); runtime·printpointer(h);
...@@ -141,10 +139,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res) ...@@ -141,10 +139,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res)
runtime·prints("\n"); runtime·prints("\n");
} }
if(h == nil || h->count == 0) { if(h == nil || h->count == 0) {
value = t->elem->zero; *valueptr = t->elem->zero;
res = false; *okptr = false;
FLUSH(&value);
FLUSH(&res);
return; return;
} }
if(raceenabled) if(raceenabled)
...@@ -162,10 +158,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res) ...@@ -162,10 +158,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res)
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) { if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) {
value = v; *valueptr = v;
res = true; *okptr = true;
FLUSH(&value);
FLUSH(&res);
return; return;
} }
} }
...@@ -177,10 +171,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res) ...@@ -177,10 +171,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res)
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k)) { if(QUICK_EQ(key, *k)) {
value = v; *valueptr = v;
res = true; *okptr = true;
FLUSH(&value);
FLUSH(&res);
return; return;
} }
if(MAYBE_EQ(key, *k)) { if(MAYBE_EQ(key, *k)) {
...@@ -198,10 +190,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res) ...@@ -198,10 +190,8 @@ HASH_LOOKUP2(MapType *t, Hmap *h, KEYTYPE key, byte *value, bool res)
if(keymaybe >= 0) { if(keymaybe >= 0) {
k = (KEYTYPE*)b->data + keymaybe; k = (KEYTYPE*)b->data + keymaybe;
if(SLOW_EQ(key, *k)) { if(SLOW_EQ(key, *k)) {
value = (byte*)((KEYTYPE*)b->data + BUCKETSIZE) + keymaybe * h->valuesize; *valueptr = (byte*)((KEYTYPE*)b->data + BUCKETSIZE) + keymaybe * h->valuesize;
res = true; *okptr = true;
FLUSH(&value);
FLUSH(&res);
return; return;
} }
} }
...@@ -230,18 +220,14 @@ dohash: ...@@ -230,18 +220,14 @@ dohash:
if(QUICK_NE(key, *k)) if(QUICK_NE(key, *k))
continue; continue;
if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) { if(QUICK_EQ(key, *k) || SLOW_EQ(key, *k)) {
value = v; *valueptr = v;
res = true; *okptr = true;
FLUSH(&value);
FLUSH(&res);
return; return;
} }
} }
b = b->overflow; b = b->overflow;
} while(b != nil); } while(b != nil);
} }
value = t->elem->zero; *valueptr = t->elem->zero;
res = false; *okptr = false;
FLUSH(&value);
FLUSH(&res);
} }
...@@ -353,10 +353,11 @@ runtime·unwindstack(G *gp, byte *sp) ...@@ -353,10 +353,11 @@ runtime·unwindstack(G *gp, byte *sp)
// find the stack segment of its caller. // find the stack segment of its caller.
#pragma textflag NOSPLIT #pragma textflag NOSPLIT
void void
runtime·recover(byte *argp, Eface ret) runtime·recover(byte *argp, GoOutput retbase, ...)
{ {
Panic *p; Panic *p;
Stktop *top; Stktop *top;
Eface *ret;
// Must be an unrecovered panic in progress. // Must be an unrecovered panic in progress.
// Must be on a stack segment created for a deferred call during a panic. // Must be on a stack segment created for a deferred call during a panic.
...@@ -367,16 +368,16 @@ runtime·recover(byte *argp, Eface ret) ...@@ -367,16 +368,16 @@ runtime·recover(byte *argp, Eface ret)
// do not count as official calls to adjust what we consider the top frame // do not count as official calls to adjust what we consider the top frame
// while they are active on the stack. The linker emits adjustments of // while they are active on the stack. The linker emits adjustments of
// g->panicwrap in the prologue and epilogue of functions marked as wrappers. // g->panicwrap in the prologue and epilogue of functions marked as wrappers.
ret = (Eface*)&retbase;
top = (Stktop*)g->stackbase; top = (Stktop*)g->stackbase;
p = g->panic; p = g->panic;
if(p != nil && !p->recovered && top->panic && argp == (byte*)top - top->argsize - g->panicwrap) { if(p != nil && !p->recovered && top->panic && argp == (byte*)top - top->argsize - g->panicwrap) {
p->recovered = 1; p->recovered = 1;
ret = p->arg; *ret = p->arg;
} else { } else {
ret.type = nil; ret->type = nil;
ret.data = nil; ret->data = nil;
} }
FLUSH(&ret);
} }
void void
......
...@@ -115,11 +115,11 @@ vprintf(int8 *s, byte *base) ...@@ -115,11 +115,11 @@ vprintf(int8 *s, byte *base)
case 'U': case 'U':
case 'X': case 'X':
case 'f': case 'f':
arg = ROUND(arg, sizeof(uintptr)); arg = ROUND(arg, sizeof(uintreg));
siz = 8; siz = 8;
break; break;
case 'C': case 'C':
arg = ROUND(arg, sizeof(uintptr)); arg = ROUND(arg, sizeof(uintreg));
siz = 16; siz = 16;
break; break;
case 'p': // pointer-sized case 'p': // pointer-sized
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment