mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +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 Operand* register_(int number) = 0;
|
||||||
|
|
||||||
virtual void push(unsigned footprint) = 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 void save(unsigned footprint, Operand* value) = 0;
|
||||||
virtual Operand* pop(unsigned footprint) = 0;
|
virtual Operand* pop(unsigned footprint) = 0;
|
||||||
virtual void pushed() = 0;
|
virtual void pushed() = 0;
|
||||||
|
@ -2110,6 +2110,20 @@ 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:
|
||||||
|
return 1;
|
||||||
|
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,
|
||||||
@ -2335,8 +2349,12 @@ class MyCompiler: public Compiler {
|
|||||||
c.stack = s;
|
c.stack = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void push(unsigned footprint, Operand* value) {
|
virtual void push(ir::Type type, Operand* value)
|
||||||
compiler::push(&c, footprint, static_cast<Value*>(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) {
|
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;
|
typedef Compiler::Operand* Value;
|
||||||
|
|
||||||
Frame(Context* context, uint8_t* stackMap):
|
Frame(Context* context, uint8_t* stackMap)
|
||||||
context(context),
|
: context(context),
|
||||||
t(context->thread),
|
t(context->thread),
|
||||||
c(context->compiler),
|
c(context->compiler),
|
||||||
subroutine(0),
|
subroutine(0),
|
||||||
stackMap(stackMap),
|
stackMap(stackMap),
|
||||||
ip(0),
|
ip(0),
|
||||||
sp(localSize()),
|
sp(localSize()),
|
||||||
level(0)
|
level(0),
|
||||||
|
types(TargetBytesPerWord)
|
||||||
{
|
{
|
||||||
memset(stackMap, 0, codeMaxStack(t, methodCode(t, context->method)));
|
memset(stackMap, 0, codeMaxStack(t, methodCode(t, context->method)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame(Frame* f, uint8_t* stackMap):
|
Frame(Frame* f, uint8_t* stackMap)
|
||||||
context(f->context),
|
: context(f->context),
|
||||||
t(context->thread),
|
t(context->thread),
|
||||||
c(context->compiler),
|
c(context->compiler),
|
||||||
subroutine(f->subroutine),
|
subroutine(f->subroutine),
|
||||||
stackMap(stackMap),
|
stackMap(stackMap),
|
||||||
ip(f->ip),
|
ip(f->ip),
|
||||||
sp(f->sp),
|
sp(f->sp),
|
||||||
level(f->level + 1)
|
level(f->level + 1),
|
||||||
|
types(TargetBytesPerWord)
|
||||||
{
|
{
|
||||||
memcpy(stackMap, f->stackMap, codeMaxStack
|
memcpy(stackMap, f->stackMap, codeMaxStack
|
||||||
(t, methodCode(t, context->method)));
|
(t, methodCode(t, context->method)));
|
||||||
@ -1677,12 +1679,13 @@ class Frame {
|
|||||||
this->ip = ip;
|
this->ip = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushQuiet(unsigned footprint, Value o) {
|
void pushQuiet(ir::Type type, Value o)
|
||||||
c->push(footprint, o);
|
{
|
||||||
|
c->push(type, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushLongQuiet(Value o) {
|
void pushLongQuiet(Value o) {
|
||||||
pushQuiet(2, o);
|
pushQuiet(types.i8, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value popQuiet(unsigned footprint) {
|
Value popQuiet(unsigned footprint) {
|
||||||
@ -1694,17 +1697,17 @@ class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pushInt(Value o) {
|
void pushInt(Value o) {
|
||||||
pushQuiet(1, o);
|
pushQuiet(types.i4, o);
|
||||||
pushedInt();
|
pushedInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushAddress(Value o) {
|
void pushAddress(Value o) {
|
||||||
pushQuiet(1, o);
|
pushQuiet(types.i4, o);
|
||||||
pushedInt();
|
pushedInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pushObject(Value o) {
|
void pushObject(Value o) {
|
||||||
pushQuiet(1, o);
|
pushQuiet(types.object, o);
|
||||||
pushedObject();
|
pushedObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1784,7 +1787,7 @@ class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dup() {
|
void dup() {
|
||||||
pushQuiet(1, c->peek(1, 0));
|
pushQuiet(types.i4, c->peek(1, 0));
|
||||||
|
|
||||||
dupped();
|
dupped();
|
||||||
}
|
}
|
||||||
@ -1793,9 +1796,9 @@ class Frame {
|
|||||||
Value s0 = popQuiet(1);
|
Value s0 = popQuiet(1);
|
||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
|
|
||||||
duppedX1();
|
duppedX1();
|
||||||
}
|
}
|
||||||
@ -1806,17 +1809,17 @@ class Frame {
|
|||||||
if (get(sp - 2) == Long) {
|
if (get(sp - 2) == Long) {
|
||||||
Value s1 = popLongQuiet();
|
Value s1 = popLongQuiet();
|
||||||
|
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushLongQuiet(s1);
|
pushLongQuiet(s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
} else {
|
} else {
|
||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
Value s2 = popQuiet(1);
|
Value s2 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s2);
|
pushQuiet(types.i4, s2);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
duppedX2();
|
duppedX2();
|
||||||
@ -1829,10 +1832,10 @@ class Frame {
|
|||||||
Value s0 = popQuiet(1);
|
Value s0 = popQuiet(1);
|
||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dupped2();
|
dupped2();
|
||||||
@ -1844,18 +1847,18 @@ class Frame {
|
|||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
|
|
||||||
pushLongQuiet(s0);
|
pushLongQuiet(s0);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushLongQuiet(s0);
|
pushLongQuiet(s0);
|
||||||
} else {
|
} else {
|
||||||
Value s0 = popQuiet(1);
|
Value s0 = popQuiet(1);
|
||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
Value s2 = popQuiet(1);
|
Value s2 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s2);
|
pushQuiet(types.i4, s2);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dupped2X1();
|
dupped2X1();
|
||||||
@ -1876,8 +1879,8 @@ class Frame {
|
|||||||
Value s2 = popQuiet(1);
|
Value s2 = popQuiet(1);
|
||||||
|
|
||||||
pushLongQuiet(s0);
|
pushLongQuiet(s0);
|
||||||
pushQuiet(1, s2);
|
pushQuiet(types.i4, s2);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushLongQuiet(s0);
|
pushLongQuiet(s0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1886,12 +1889,12 @@ class Frame {
|
|||||||
Value s2 = popQuiet(1);
|
Value s2 = popQuiet(1);
|
||||||
Value s3 = popQuiet(1);
|
Value s3 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s3);
|
pushQuiet(types.i4, s3);
|
||||||
pushQuiet(1, s2);
|
pushQuiet(types.i4, s2);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
dupped2X2();
|
dupped2X2();
|
||||||
@ -1901,8 +1904,8 @@ class Frame {
|
|||||||
Value s0 = popQuiet(1);
|
Value s0 = popQuiet(1);
|
||||||
Value s1 = popQuiet(1);
|
Value s1 = popQuiet(1);
|
||||||
|
|
||||||
pushQuiet(1, s0);
|
pushQuiet(types.i4, s0);
|
||||||
pushQuiet(1, s1);
|
pushQuiet(types.i4, s1);
|
||||||
|
|
||||||
swapped();
|
swapped();
|
||||||
}
|
}
|
||||||
@ -1996,6 +1999,7 @@ class Frame {
|
|||||||
unsigned ip;
|
unsigned ip;
|
||||||
unsigned sp;
|
unsigned sp;
|
||||||
unsigned level;
|
unsigned level;
|
||||||
|
ir::Types types;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
Loading…
Reference in New Issue
Block a user