mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
make Compiler::store take both a source size and a destination size to avoid endianness issues; change order of Compiler::load parameters to match
This commit is contained in:
parent
10c75f4783
commit
d6bd2e7308
@ -2133,35 +2133,35 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case aaload:
|
case aaload:
|
||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->load
|
(c->load
|
||||||
(BytesPerWord, BytesPerWord,
|
(BytesPerWord, c->memory(array, ArrayBody, index, BytesPerWord),
|
||||||
c->memory(array, ArrayBody, index, BytesPerWord)));
|
BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case faload:
|
case faload:
|
||||||
case iaload:
|
case iaload:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load(4, BytesPerWord, c->memory(array, ArrayBody, index, 4)));
|
(c->load(4, c->memory(array, ArrayBody, index, 4), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case baload:
|
case baload:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load(1, BytesPerWord, c->memory(array, ArrayBody, index, 1)));
|
(c->load(1, c->memory(array, ArrayBody, index, 1), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case caload:
|
case caload:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->loadz(2, BytesPerWord, c->memory(array, ArrayBody, index, 2)));
|
(c->loadz(2, c->memory(array, ArrayBody, index, 2), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case daload:
|
case daload:
|
||||||
case laload:
|
case laload:
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->load(8, 8, c->memory(array, ArrayBody, index, 8)));
|
(c->load(8, c->memory(array, ArrayBody, index, 8), 8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case saload:
|
case saload:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load(2, BytesPerWord, c->memory(array, ArrayBody, index, 2)));
|
(c->load(2, c->memory(array, ArrayBody, index, 2), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -2209,21 +2209,24 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
case fastore:
|
case fastore:
|
||||||
case iastore:
|
case iastore:
|
||||||
c->store(4, value, c->memory(array, ArrayBody, index, 4));
|
c->store
|
||||||
|
(BytesPerWord, value, 4, c->memory(array, ArrayBody, index, 4));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case bastore:
|
case bastore:
|
||||||
c->store(1, value, c->memory(array, ArrayBody, index, 1));
|
c->store
|
||||||
|
(BytesPerWord, value, 1, c->memory(array, ArrayBody, index, 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case castore:
|
case castore:
|
||||||
case sastore:
|
case sastore:
|
||||||
c->store(2, value, c->memory(array, ArrayBody, index, 2));
|
c->store
|
||||||
|
(BytesPerWord, value, 2, c->memory(array, ArrayBody, index, 2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case dastore:
|
case dastore:
|
||||||
case lastore:
|
case lastore:
|
||||||
c->store(8, value, c->memory(array, ArrayBody, index, 8));
|
c->store(8, value, 8, c->memory(array, ArrayBody, index, 8));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -2277,8 +2280,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case arraylength: {
|
case arraylength: {
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load
|
(c->load
|
||||||
(BytesPerWord, BytesPerWord,
|
(BytesPerWord, c->memory(frame->popObject(), ArrayLength, 0, 1),
|
||||||
c->memory(frame->popObject(), ArrayLength, 0, 1)));
|
BytesPerWord));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case astore:
|
case astore:
|
||||||
@ -2629,39 +2632,39 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
case BooleanField:
|
case BooleanField:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load
|
(c->load
|
||||||
(1, BytesPerWord, c->memory(table, fieldOffset(t, field), 0, 1)));
|
(1, c->memory(table, fieldOffset(t, field), 0, 1), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CharField:
|
case CharField:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->loadz
|
(c->loadz
|
||||||
(2, BytesPerWord, c->memory(table, fieldOffset(t, field), 0, 1)));
|
(2, c->memory(table, fieldOffset(t, field), 0, 1), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShortField:
|
case ShortField:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load
|
(c->load
|
||||||
(2, BytesPerWord, c->memory(table, fieldOffset(t, field), 0, 1)));
|
(2, c->memory(table, fieldOffset(t, field), 0, 1), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FloatField:
|
case FloatField:
|
||||||
case IntField:
|
case IntField:
|
||||||
frame->pushInt
|
frame->pushInt
|
||||||
(c->load
|
(c->load
|
||||||
(4, BytesPerWord, c->memory(table, fieldOffset(t, field), 0, 1)));
|
(4, c->memory(table, fieldOffset(t, field), 0, 1), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DoubleField:
|
case DoubleField:
|
||||||
case LongField:
|
case LongField:
|
||||||
frame->pushLong
|
frame->pushLong
|
||||||
(c->load(8, 8, c->memory(table, fieldOffset(t, field), 0, 1)));
|
(c->load(8, c->memory(table, fieldOffset(t, field), 0, 1), 8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ObjectField:
|
case ObjectField:
|
||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->load
|
(c->load
|
||||||
(BytesPerWord, BytesPerWord,
|
(BytesPerWord, c->memory(table, fieldOffset(t, field), 0, 1),
|
||||||
c->memory(table, fieldOffset(t, field), 0, 1)));
|
BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2688,11 +2691,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2b: {
|
case i2b: {
|
||||||
frame->pushInt(c->load(1, BytesPerWord, frame->popInt()));
|
frame->pushInt(c->load(1, frame->popInt(), BytesPerWord));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2c: {
|
case i2c: {
|
||||||
frame->pushInt(c->loadz(2, BytesPerWord, frame->popInt()));
|
frame->pushInt(c->loadz(2, frame->popInt(), BytesPerWord));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2d: {
|
case i2d: {
|
||||||
@ -2710,11 +2713,11 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case i2l:
|
case i2l:
|
||||||
frame->pushLong(c->load(4, 8, frame->popInt()));
|
frame->pushLong(c->load(4, frame->popInt(), 8));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case i2s: {
|
case i2s: {
|
||||||
frame->pushInt(c->load(2, BytesPerWord, frame->popInt()));
|
frame->pushInt(c->load(2, frame->popInt(), BytesPerWord));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case iadd: {
|
case iadd: {
|
||||||
@ -3168,7 +3171,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case l2i:
|
case l2i:
|
||||||
frame->pushInt(c->load(8, BytesPerWord, frame->popLong()));
|
frame->pushInt(c->load(8, frame->popLong(), BytesPerWord));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ladd: {
|
case ladd: {
|
||||||
@ -3560,22 +3563,25 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
switch (fieldCode(t, field)) {
|
switch (fieldCode(t, field)) {
|
||||||
case ByteField:
|
case ByteField:
|
||||||
case BooleanField:
|
case BooleanField:
|
||||||
c->store(1, value, c->memory(table, fieldOffset(t, field), 0, 1));
|
c->store(BytesPerWord, value, 1,
|
||||||
|
c->memory(table, fieldOffset(t, field), 0, 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CharField:
|
case CharField:
|
||||||
case ShortField:
|
case ShortField:
|
||||||
c->store(2, value, c->memory(table, fieldOffset(t, field), 0, 1));
|
c->store(BytesPerWord, value, 2,
|
||||||
|
c->memory(table, fieldOffset(t, field), 0, 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FloatField:
|
case FloatField:
|
||||||
case IntField:
|
case IntField:
|
||||||
c->store(4, value, c->memory(table, fieldOffset(t, field), 0, 1));
|
c->store(BytesPerWord, value, 4,
|
||||||
|
c->memory(table, fieldOffset(t, field), 0, 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DoubleField:
|
case DoubleField:
|
||||||
case LongField:
|
case LongField:
|
||||||
c->store(8, value, c->memory(table, fieldOffset(t, field), 0, 1));
|
c->store(8, value, 8, c->memory(table, fieldOffset(t, field), 0, 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ObjectField:
|
case ObjectField:
|
||||||
@ -3661,9 +3667,9 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
saveStateAndCompile(t, frame, defaultIp);
|
saveStateAndCompile(t, frame, defaultIp);
|
||||||
|
|
||||||
c->jmp(c->load(BytesPerWord, BytesPerWord,
|
c->jmp(c->load(BytesPerWord,
|
||||||
c->memory(start, 0, c->sub(4, c->constant(bottom), key),
|
c->memory(start, 0, c->sub(4, c->constant(bottom), key),
|
||||||
BytesPerWord)));
|
BytesPerWord), BytesPerWord));
|
||||||
|
|
||||||
Compiler::State* state = c->saveState();
|
Compiler::State* state = c->saveState();
|
||||||
|
|
||||||
|
@ -4913,12 +4913,14 @@ class MyCompiler: public Compiler {
|
|||||||
lengthOffset, static_cast<Value*>(index), handler);
|
lengthOffset, static_cast<Value*>(index), handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void store(unsigned size, Operand* src, Operand* dst) {
|
virtual void store(unsigned srcSize, Operand* src, unsigned dstSize,
|
||||||
appendMove(&c, Move, size, static_cast<Value*>(src),
|
Operand* dst)
|
||||||
size, static_cast<Value*>(dst));
|
{
|
||||||
|
appendMove(&c, Move, srcSize, static_cast<Value*>(src),
|
||||||
|
dstSize, static_cast<Value*>(dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* load(unsigned srcSize, unsigned dstSize, Operand* src) {
|
virtual Operand* load(unsigned srcSize, Operand* src, unsigned dstSize) {
|
||||||
assert(&c, dstSize >= BytesPerWord);
|
assert(&c, dstSize >= BytesPerWord);
|
||||||
|
|
||||||
Value* dst = value(&c);
|
Value* dst = value(&c);
|
||||||
@ -4926,7 +4928,7 @@ class MyCompiler: public Compiler {
|
|||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* loadz(unsigned srcSize, unsigned dstSize, Operand* src) {
|
virtual Operand* loadz(unsigned srcSize, Operand* src, unsigned dstSize) {
|
||||||
assert(&c, dstSize >= BytesPerWord);
|
assert(&c, dstSize >= BytesPerWord);
|
||||||
|
|
||||||
Value* dst = value(&c);
|
Value* dst = value(&c);
|
||||||
|
@ -98,9 +98,10 @@ class Compiler {
|
|||||||
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
||||||
Operand* index, intptr_t handler) = 0;
|
Operand* index, intptr_t handler) = 0;
|
||||||
|
|
||||||
virtual void store(unsigned size, Operand* src, Operand* dst) = 0;
|
virtual void store(unsigned srcSize, Operand* src, unsigned dstSize,
|
||||||
virtual Operand* load(unsigned srcSize, unsigned dstSize, Operand* src) = 0;
|
Operand* dst) = 0;
|
||||||
virtual Operand* loadz(unsigned size, unsigned dstSize, Operand* src) = 0;
|
virtual Operand* load(unsigned srcSize, Operand* src, unsigned dstSize) = 0;
|
||||||
|
virtual Operand* loadz(unsigned size, Operand* src, unsigned dstSize) = 0;
|
||||||
virtual Operand* lcmp(Operand* a, Operand* b) = 0;
|
virtual Operand* lcmp(Operand* a, Operand* b) = 0;
|
||||||
virtual void cmp(unsigned size, Operand* a, Operand* b) = 0;
|
virtual void cmp(unsigned size, Operand* a, Operand* b) = 0;
|
||||||
virtual void jl(Operand* address) = 0;
|
virtual void jl(Operand* address) = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user