mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
use ir::Type in Compiler::loadLocal
This commit is contained in:
parent
53b68a693d
commit
85f114ea0f
@ -101,7 +101,7 @@ class Compiler {
|
|||||||
virtual void initLocalsFromLogicalIp(unsigned logicalIp) = 0;
|
virtual void initLocalsFromLogicalIp(unsigned logicalIp) = 0;
|
||||||
virtual void storeLocal(unsigned footprint, Operand* src,
|
virtual void storeLocal(unsigned footprint, Operand* src,
|
||||||
unsigned index) = 0;
|
unsigned index) = 0;
|
||||||
virtual Operand* loadLocal(unsigned footprint, unsigned index) = 0;
|
virtual Operand* loadLocal(ir::Type type, unsigned index) = 0;
|
||||||
virtual void saveLocals() = 0;
|
virtual void saveLocals() = 0;
|
||||||
|
|
||||||
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
virtual void checkBounds(Operand* object, unsigned lengthOffset,
|
||||||
|
@ -1214,9 +1214,27 @@ storeLocal(Context* c, unsigned footprint, Value* v, unsigned index, bool copy)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value*
|
unsigned typeFootprint(Context* c, ir::Type type)
|
||||||
loadLocal(Context* c, unsigned footprint, unsigned index)
|
|
||||||
{
|
{
|
||||||
|
// TODO: this function is very Java-specific in nature. Generalize.
|
||||||
|
switch (type.flavor()) {
|
||||||
|
case ir::Type::Float:
|
||||||
|
case ir::Type::Integer:
|
||||||
|
return type.size() / 4;
|
||||||
|
case ir::Type::Object:
|
||||||
|
case ir::Type::Address:
|
||||||
|
case ir::Type::Half:
|
||||||
|
return 1;
|
||||||
|
case ir::Type::Void:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
abort(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value* loadLocal(Context* c, ir::Type type, unsigned index)
|
||||||
|
{
|
||||||
|
unsigned footprint = typeFootprint(c, type);
|
||||||
assert(c, index + footprint <= c->localFootprint);
|
assert(c, index + footprint <= c->localFootprint);
|
||||||
|
|
||||||
if (footprint > 1) {
|
if (footprint > 1) {
|
||||||
@ -2103,24 +2121,6 @@ class Client: public Assembler::Client {
|
|||||||
Context* c;
|
Context* c;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned typeFootprint(Context* c, ir::Type type)
|
|
||||||
{
|
|
||||||
// TODO: this function is very Java-specific in nature. Generalize.
|
|
||||||
switch (type.flavor()) {
|
|
||||||
case ir::Type::Float:
|
|
||||||
case ir::Type::Integer:
|
|
||||||
return type.size() / 4;
|
|
||||||
case ir::Type::Object:
|
|
||||||
case ir::Type::Address:
|
|
||||||
case ir::Type::Half:
|
|
||||||
return 1;
|
|
||||||
case ir::Type::Void:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
abort(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyCompiler: public Compiler {
|
class MyCompiler: public Compiler {
|
||||||
public:
|
public:
|
||||||
MyCompiler(System* s, Assembler* assembler, Zone* zone,
|
MyCompiler(System* s, Assembler* assembler, Zone* zone,
|
||||||
@ -2593,8 +2593,9 @@ class MyCompiler: public Compiler {
|
|||||||
compiler::storeLocal(&c, footprint, static_cast<Value*>(src), index, true);
|
compiler::storeLocal(&c, footprint, static_cast<Value*>(src), index, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Operand* loadLocal(unsigned footprint, unsigned index) {
|
virtual Operand* loadLocal(ir::Type type, unsigned index)
|
||||||
return compiler::loadLocal(&c, footprint, index);
|
{
|
||||||
|
return compiler::loadLocal(&c, type, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void saveLocals() {
|
virtual void saveLocals() {
|
||||||
|
@ -1331,11 +1331,13 @@ translateLocalIndex(Context* context, unsigned footprint, unsigned index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Compiler::Operand*
|
Compiler::Operand* loadLocal(Context* context,
|
||||||
loadLocal(Context* context, unsigned footprint, unsigned index)
|
unsigned footprint,
|
||||||
|
ir::Type type,
|
||||||
|
unsigned index)
|
||||||
{
|
{
|
||||||
return context->compiler->loadLocal
|
return context->compiler->loadLocal(
|
||||||
(footprint, translateLocalIndex(context, footprint, index));
|
type, translateLocalIndex(context, footprint, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1746,17 +1748,17 @@ class Frame {
|
|||||||
|
|
||||||
void loadInt(unsigned index) {
|
void loadInt(unsigned index) {
|
||||||
assert(t, index < localSize());
|
assert(t, index < localSize());
|
||||||
pushInt(loadLocal(context, 1, index));
|
pushInt(loadLocal(context, 1, types.i4, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLong(unsigned index) {
|
void loadLong(unsigned index) {
|
||||||
assert(t, index < static_cast<unsigned>(localSize() - 1));
|
assert(t, index < static_cast<unsigned>(localSize() - 1));
|
||||||
pushLong(loadLocal(context, 2, index));
|
pushLong(loadLocal(context, 2, types.i8, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadObject(unsigned index) {
|
void loadObject(unsigned index) {
|
||||||
assert(t, index < localSize());
|
assert(t, index < localSize());
|
||||||
pushObject(loadLocal(context, 1, index));
|
pushObject(loadLocal(context, 1, types.object, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void storeInt(unsigned index) {
|
void storeInt(unsigned index) {
|
||||||
@ -1973,8 +1975,12 @@ class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void returnFromSubroutine(unsigned returnAddressLocal) {
|
void returnFromSubroutine(unsigned returnAddressLocal) {
|
||||||
c->returnFromSubroutine
|
c->returnFromSubroutine(
|
||||||
(subroutine->handle, loadLocal(context, 1, returnAddressLocal));
|
subroutine->handle,
|
||||||
|
loadLocal(context,
|
||||||
|
1,
|
||||||
|
ir::Type(ir::Type::Address, TargetBytesPerWord),
|
||||||
|
returnAddressLocal));
|
||||||
|
|
||||||
subroutine->stackIndex = localOffsetFromStack
|
subroutine->stackIndex = localOffsetFromStack
|
||||||
(t, translateLocalIndex(context, 1, returnAddressLocal),
|
(t, translateLocalIndex(context, 1, returnAddressLocal),
|
||||||
@ -3421,7 +3427,8 @@ handleMonitorEvent(MyThread* t, Frame* frame, intptr_t function)
|
|||||||
|
|
||||||
lock = frame->append(methodClass(t, method));
|
lock = frame->append(methodClass(t, method));
|
||||||
} else {
|
} else {
|
||||||
lock = loadLocal(frame->context, 1, savedTargetIndex(t, method));
|
lock = loadLocal(
|
||||||
|
frame->context, 1, frame->types.object, savedTargetIndex(t, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
c->call(c->constant(function, types.address),
|
c->call(c->constant(function, types.address),
|
||||||
@ -3444,7 +3451,10 @@ handleEntrance(MyThread* t, Frame* frame)
|
|||||||
{
|
{
|
||||||
// save 'this' pointer in case it is overwritten.
|
// save 'this' pointer in case it is overwritten.
|
||||||
unsigned index = savedTargetIndex(t, method);
|
unsigned index = savedTargetIndex(t, method);
|
||||||
storeLocal(frame->context, 1, loadLocal(frame->context, 1, 0), index);
|
storeLocal(frame->context,
|
||||||
|
1,
|
||||||
|
loadLocal(frame->context, 1, frame->types.object, 0),
|
||||||
|
index);
|
||||||
frame->set(index, Frame::Object);
|
frame->set(index, Frame::Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4937,7 +4947,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
c->binaryOp(lir::Add,
|
c->binaryOp(lir::Add,
|
||||||
types.i4,
|
types.i4,
|
||||||
c->constant(count, types.i4),
|
c->constant(count, types.i4),
|
||||||
loadLocal(context, 1, index)),
|
loadLocal(context, 1, types.i4, index)),
|
||||||
index);
|
index);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -6047,7 +6057,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
c->binaryOp(lir::Add,
|
c->binaryOp(lir::Add,
|
||||||
types.i4,
|
types.i4,
|
||||||
c->constant(count, types.i4),
|
c->constant(count, types.i4),
|
||||||
loadLocal(context, 1, index)),
|
loadLocal(context, 1, types.i4, index)),
|
||||||
index);
|
index);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -6069,7 +6079,10 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
|
|
||||||
case ret: {
|
case ret: {
|
||||||
unsigned index = codeReadInt16(t, code, ip);
|
unsigned index = codeReadInt16(t, code, ip);
|
||||||
c->jmp(loadLocal(context, 1, index));
|
c->jmp(loadLocal(context,
|
||||||
|
1,
|
||||||
|
ir::Type(ir::Type::Address, TargetBytesPerWord),
|
||||||
|
index));
|
||||||
frame->returnFromSubroutine(index);
|
frame->returnFromSubroutine(index);
|
||||||
} goto next;
|
} goto next;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user