assume stack grows towards negative addresses when loading and storing multiword locals

This commit is contained in:
Joel Dice 2009-01-31 12:05:06 -07:00
parent a11d018dc2
commit 8b6319fbc8

View File

@ -4569,14 +4569,19 @@ class MyCompiler: public Compiler {
} }
virtual void initLocal(unsigned footprint, unsigned index) { virtual void initLocal(unsigned footprint, unsigned index) {
assert(&c, index < c.localFootprint); assert(&c, index + footprint <= c.localFootprint);
Value* v = value(&c); Value* v = value(&c);
if (BytesPerWord == 4 and footprint > 1) { if (footprint > 1) {
assert(&c, footprint == 2); assert(&c, footprint == 2);
initLocal(1, index + 1);
v->high = c.locals[index + 1].value; if (BytesPerWord == 4) {
initLocal(1, index);
v->high = c.locals[index].value;
}
++ index;
} }
if (DebugFrame) { if (DebugFrame) {
@ -4609,13 +4614,18 @@ class MyCompiler: public Compiler {
} }
virtual void storeLocal(unsigned footprint, Operand* src, unsigned index) { virtual void storeLocal(unsigned footprint, Operand* src, unsigned index) {
assert(&c, index < c.localFootprint); assert(&c, index + footprint <= c.localFootprint);
if (BytesPerWord == 4 and footprint > 1) { if (footprint > 1) {
assert(&c, footprint == 2); assert(&c, footprint == 2);
if (BytesPerWord == 4) {
assert(&c, static_cast<Value*>(src)->high); assert(&c, static_cast<Value*>(src)->high);
storeLocal(1, static_cast<Value*>(src)->high, index + 1); storeLocal(1, static_cast<Value*>(src)->high, index);
}
++ index;
} }
Local* local = c.locals + index; Local* local = c.locals + index;
@ -4637,6 +4647,13 @@ class MyCompiler: public Compiler {
virtual Operand* loadLocal(unsigned footprint UNUSED, unsigned index) { virtual Operand* loadLocal(unsigned footprint UNUSED, unsigned index) {
assert(&c, index + footprint <= c.localFootprint); assert(&c, index + footprint <= c.localFootprint);
if (footprint > 1) {
assert(&c, footprint == 2);
++ index;
}
assert(&c, c.locals[index].value); assert(&c, c.locals[index].value);
assert(&c, c.locals[index].value->home >= 0); assert(&c, c.locals[index].value->home >= 0);