mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
use ir::Type in Compiler::push
This commit is contained in:
parent
d9fee1025c
commit
49a5a9f398
@ -83,7 +83,7 @@ class Compiler {
|
||||
virtual Operand* register_(int number) = 0;
|
||||
|
||||
virtual void push(unsigned footprint) = 0;
|
||||
virtual void push(unsigned footprint, Operand* value) = 0;
|
||||
virtual void push(ir::Type type, Operand* value) = 0;
|
||||
virtual void save(unsigned footprint, Operand* value) = 0;
|
||||
virtual Operand* pop(unsigned footprint) = 0;
|
||||
virtual void pushed() = 0;
|
||||
|
@ -2110,6 +2110,20 @@ class Client: public Assembler::Client {
|
||||
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:
|
||||
return 1;
|
||||
default:
|
||||
abort(c);
|
||||
}
|
||||
}
|
||||
|
||||
class MyCompiler: public Compiler {
|
||||
public:
|
||||
MyCompiler(System* s, Assembler* assembler, Zone* zone,
|
||||
@ -2335,8 +2349,12 @@ class MyCompiler: public Compiler {
|
||||
c.stack = s;
|
||||
}
|
||||
|
||||
virtual void push(unsigned footprint, Operand* value) {
|
||||
compiler::push(&c, footprint, static_cast<Value*>(value));
|
||||
virtual void push(ir::Type type, Operand* value)
|
||||
{
|
||||
// TODO: once type information is flowed properly, enable this assert.
|
||||
// Some time later, we can remove the parameter.
|
||||
// assert(&c, static_cast<Value*>(value)->type == type);
|
||||
compiler::push(&c, typeFootprint(&c, type), static_cast<Value*>(value));
|
||||
}
|
||||
|
||||
virtual void save(unsigned footprint, Operand* value) {
|
||||
|
112
src/compile.cpp
112
src/compile.cpp
@ -1358,28 +1358,30 @@ class Frame {
|
||||
|
||||
typedef Compiler::Operand* Value;
|
||||
|
||||
Frame(Context* context, uint8_t* stackMap):
|
||||
context(context),
|
||||
t(context->thread),
|
||||
c(context->compiler),
|
||||
subroutine(0),
|
||||
stackMap(stackMap),
|
||||
ip(0),
|
||||
sp(localSize()),
|
||||
level(0)
|
||||
Frame(Context* context, uint8_t* stackMap)
|
||||
: context(context),
|
||||
t(context->thread),
|
||||
c(context->compiler),
|
||||
subroutine(0),
|
||||
stackMap(stackMap),
|
||||
ip(0),
|
||||
sp(localSize()),
|
||||
level(0),
|
||||
types(TargetBytesPerWord)
|
||||
{
|
||||
memset(stackMap, 0, codeMaxStack(t, methodCode(t, context->method)));
|
||||
}
|
||||
|
||||
Frame(Frame* f, uint8_t* stackMap):
|
||||
context(f->context),
|
||||
t(context->thread),
|
||||
c(context->compiler),
|
||||
subroutine(f->subroutine),
|
||||
stackMap(stackMap),
|
||||
ip(f->ip),
|
||||
sp(f->sp),
|
||||
level(f->level + 1)
|
||||
Frame(Frame* f, uint8_t* stackMap)
|
||||
: context(f->context),
|
||||
t(context->thread),
|
||||
c(context->compiler),
|
||||
subroutine(f->subroutine),
|
||||
stackMap(stackMap),
|
||||
ip(f->ip),
|
||||
sp(f->sp),
|
||||
level(f->level + 1),
|
||||
types(TargetBytesPerWord)
|
||||
{
|
||||
memcpy(stackMap, f->stackMap, codeMaxStack
|
||||
(t, methodCode(t, context->method)));
|
||||
@ -1677,12 +1679,13 @@ class Frame {
|
||||
this->ip = ip;
|
||||
}
|
||||
|
||||
void pushQuiet(unsigned footprint, Value o) {
|
||||
c->push(footprint, o);
|
||||
void pushQuiet(ir::Type type, Value o)
|
||||
{
|
||||
c->push(type, o);
|
||||
}
|
||||
|
||||
void pushLongQuiet(Value o) {
|
||||
pushQuiet(2, o);
|
||||
pushQuiet(types.i8, o);
|
||||
}
|
||||
|
||||
Value popQuiet(unsigned footprint) {
|
||||
@ -1694,17 +1697,17 @@ class Frame {
|
||||
}
|
||||
|
||||
void pushInt(Value o) {
|
||||
pushQuiet(1, o);
|
||||
pushQuiet(types.i4, o);
|
||||
pushedInt();
|
||||
}
|
||||
|
||||
void pushAddress(Value o) {
|
||||
pushQuiet(1, o);
|
||||
pushQuiet(types.i4, o);
|
||||
pushedInt();
|
||||
}
|
||||
|
||||
void pushObject(Value o) {
|
||||
pushQuiet(1, o);
|
||||
pushQuiet(types.object, o);
|
||||
pushedObject();
|
||||
}
|
||||
|
||||
@ -1784,7 +1787,7 @@ class Frame {
|
||||
}
|
||||
|
||||
void dup() {
|
||||
pushQuiet(1, c->peek(1, 0));
|
||||
pushQuiet(types.i4, c->peek(1, 0));
|
||||
|
||||
dupped();
|
||||
}
|
||||
@ -1793,9 +1796,9 @@ class Frame {
|
||||
Value s0 = popQuiet(1);
|
||||
Value s1 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
|
||||
duppedX1();
|
||||
}
|
||||
@ -1806,17 +1809,17 @@ class Frame {
|
||||
if (get(sp - 2) == Long) {
|
||||
Value s1 = popLongQuiet();
|
||||
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushLongQuiet(s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s0);
|
||||
} else {
|
||||
Value s1 = popQuiet(1);
|
||||
Value s2 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s2);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s2);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
}
|
||||
|
||||
duppedX2();
|
||||
@ -1829,10 +1832,10 @@ class Frame {
|
||||
Value s0 = popQuiet(1);
|
||||
Value s1 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
}
|
||||
|
||||
dupped2();
|
||||
@ -1844,18 +1847,18 @@ class Frame {
|
||||
Value s1 = popQuiet(1);
|
||||
|
||||
pushLongQuiet(s0);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushLongQuiet(s0);
|
||||
} else {
|
||||
Value s0 = popQuiet(1);
|
||||
Value s1 = popQuiet(1);
|
||||
Value s2 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s2);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s2);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
}
|
||||
|
||||
dupped2X1();
|
||||
@ -1876,8 +1879,8 @@ class Frame {
|
||||
Value s2 = popQuiet(1);
|
||||
|
||||
pushLongQuiet(s0);
|
||||
pushQuiet(1, s2);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(types.i4, s2);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushLongQuiet(s0);
|
||||
}
|
||||
} else {
|
||||
@ -1886,12 +1889,12 @@ class Frame {
|
||||
Value s2 = popQuiet(1);
|
||||
Value s3 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s3);
|
||||
pushQuiet(1, s2);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s3);
|
||||
pushQuiet(types.i4, s2);
|
||||
pushQuiet(types.i4, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
}
|
||||
|
||||
dupped2X2();
|
||||
@ -1901,8 +1904,8 @@ class Frame {
|
||||
Value s0 = popQuiet(1);
|
||||
Value s1 = popQuiet(1);
|
||||
|
||||
pushQuiet(1, s0);
|
||||
pushQuiet(1, s1);
|
||||
pushQuiet(types.i4, s0);
|
||||
pushQuiet(types.i4, s1);
|
||||
|
||||
swapped();
|
||||
}
|
||||
@ -1996,6 +1999,7 @@ class Frame {
|
||||
unsigned ip;
|
||||
unsigned sp;
|
||||
unsigned level;
|
||||
ir::Types types;
|
||||
};
|
||||
|
||||
unsigned
|
||||
|
Loading…
Reference in New Issue
Block a user