mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
expose Value::type and add asserts
This commit is contained in:
parent
00253ce528
commit
42fec084b0
@ -40,7 +40,15 @@ class Compiler {
|
|||||||
static const unsigned TailJump = 1 << 2;
|
static const unsigned TailJump = 1 << 2;
|
||||||
static const unsigned LongJumpOrCall = 1 << 3;
|
static const unsigned LongJumpOrCall = 1 << 3;
|
||||||
|
|
||||||
class Operand { };
|
class Operand {
|
||||||
|
public:
|
||||||
|
ir::Type type;
|
||||||
|
|
||||||
|
Operand(ir::Type type) : type(type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class State { };
|
class State { };
|
||||||
class Subroutine { };
|
class Subroutine { };
|
||||||
|
|
||||||
@ -121,7 +129,7 @@ class Compiler {
|
|||||||
ir::Type dstType) = 0;
|
ir::Type dstType) = 0;
|
||||||
|
|
||||||
virtual void condJump(lir::TernaryOperation op,
|
virtual void condJump(lir::TernaryOperation op,
|
||||||
unsigned size,
|
ir::Type type,
|
||||||
Operand* a,
|
Operand* a,
|
||||||
Operand* b,
|
Operand* b,
|
||||||
Operand* address) = 0;
|
Operand* address) = 0;
|
||||||
|
@ -2663,7 +2663,7 @@ class MyCompiler: public Compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void condJump(lir::TernaryOperation op,
|
virtual void condJump(lir::TernaryOperation op,
|
||||||
unsigned size,
|
ir::Type type,
|
||||||
Operand* a,
|
Operand* a,
|
||||||
Operand* b,
|
Operand* b,
|
||||||
Operand* address)
|
Operand* address)
|
||||||
@ -2672,9 +2672,15 @@ class MyCompiler: public Compiler {
|
|||||||
(isGeneralBranch(op) and isGeneralValue(a) and isGeneralValue(b))or(
|
(isGeneralBranch(op) and isGeneralValue(a) and isGeneralValue(b))or(
|
||||||
isFloatBranch(op) and isFloatValue(a) and isFloatValue(b)));
|
isFloatBranch(op) and isFloatValue(a) and isFloatValue(b)));
|
||||||
|
|
||||||
|
// assert(&c, type.flavor() == static_cast<Value*>(a)->type.flavor());
|
||||||
|
// assert(&c, type.flavor() == static_cast<Value*>(b)->type.flavor());
|
||||||
|
assert(&c,
|
||||||
|
static_cast<Value*>(address)->type
|
||||||
|
== ir::Type(ir::Type::Integer, TargetBytesPerWord));
|
||||||
|
|
||||||
appendBranch(&c,
|
appendBranch(&c,
|
||||||
op,
|
op,
|
||||||
size,
|
type.size(),
|
||||||
static_cast<Value*>(a),
|
static_cast<Value*>(a),
|
||||||
static_cast<Value*>(b),
|
static_cast<Value*>(b),
|
||||||
static_cast<Value*>(address));
|
static_cast<Value*>(address));
|
||||||
|
@ -18,7 +18,8 @@ namespace codegen {
|
|||||||
namespace compiler {
|
namespace compiler {
|
||||||
|
|
||||||
Value::Value(Site* site, Site* target, ir::Type type)
|
Value::Value(Site* site, Site* target, ir::Type type)
|
||||||
: reads(0),
|
: Compiler::Operand(type),
|
||||||
|
reads(0),
|
||||||
lastRead(0),
|
lastRead(0),
|
||||||
sites(site),
|
sites(site),
|
||||||
source(0),
|
source(0),
|
||||||
@ -26,9 +27,9 @@ Value::Value(Site* site, Site* target, ir::Type type)
|
|||||||
buddy(this),
|
buddy(this),
|
||||||
nextWord(this),
|
nextWord(this),
|
||||||
home(NoFrameIndex),
|
home(NoFrameIndex),
|
||||||
wordIndex(0),
|
wordIndex(0)
|
||||||
type(type)
|
{
|
||||||
{ }
|
}
|
||||||
|
|
||||||
bool Value::findSite(Site* site) {
|
bool Value::findSite(Site* site) {
|
||||||
for (Site* s = this->sites; s; s = s->next) {
|
for (Site* s = this->sites; s; s = s->next) {
|
||||||
|
@ -37,7 +37,6 @@ class Value: public Compiler::Operand {
|
|||||||
Value* nextWord;
|
Value* nextWord;
|
||||||
int16_t home;
|
int16_t home;
|
||||||
uint8_t wordIndex;
|
uint8_t wordIndex;
|
||||||
ir::Type type;
|
|
||||||
|
|
||||||
Value(Site* site, Site* target, ir::Type type);
|
Value(Site* site, Site* target, ir::Type type);
|
||||||
|
|
||||||
|
@ -1711,6 +1711,7 @@ class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pushObject(Value o) {
|
void pushObject(Value o) {
|
||||||
|
// assert(t, o->type == types.object);
|
||||||
pushQuiet(types.object, o);
|
pushQuiet(types.object, o);
|
||||||
pushedObject();
|
pushedObject();
|
||||||
}
|
}
|
||||||
@ -3595,10 +3596,14 @@ lir::TernaryOperation toCompilerJumpOp(MyThread* t, unsigned instruction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool integerBranch(MyThread* t,
|
||||||
integerBranch(MyThread* t, Frame* frame, object code, unsigned& ip,
|
Frame* frame,
|
||||||
unsigned size, Compiler::Operand* a, Compiler::Operand* b,
|
object code,
|
||||||
unsigned* newIpp)
|
unsigned& ip,
|
||||||
|
ir::Type type,
|
||||||
|
Compiler::Operand* a,
|
||||||
|
Compiler::Operand* b,
|
||||||
|
unsigned* newIpp)
|
||||||
{
|
{
|
||||||
if (ip + 3 > codeLength(t, code)) {
|
if (ip + 3 > codeLength(t, code)) {
|
||||||
return false;
|
return false;
|
||||||
@ -3619,7 +3624,7 @@ integerBranch(MyThread* t, Frame* frame, object code, unsigned& ip,
|
|||||||
case ifge:
|
case ifge:
|
||||||
case iflt:
|
case iflt:
|
||||||
case ifle:
|
case ifle:
|
||||||
c->condJump(toCompilerJumpOp(t, instruction), size, a, b, target);
|
c->condJump(toCompilerJumpOp(t, instruction), type, a, b, target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -3669,10 +3674,15 @@ lir::TernaryOperation toCompilerFloatJumpOp(MyThread* t,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool floatBranch(MyThread* t,
|
||||||
floatBranch(MyThread* t, Frame* frame, object code, unsigned& ip,
|
Frame* frame,
|
||||||
unsigned size, bool lessIfUnordered, Compiler::Operand* a,
|
object code,
|
||||||
Compiler::Operand* b, unsigned* newIpp)
|
unsigned& ip,
|
||||||
|
ir::Type type,
|
||||||
|
bool lessIfUnordered,
|
||||||
|
Compiler::Operand* a,
|
||||||
|
Compiler::Operand* b,
|
||||||
|
unsigned* newIpp)
|
||||||
{
|
{
|
||||||
if (ip + 3 > codeLength(t, code)) {
|
if (ip + 3 > codeLength(t, code)) {
|
||||||
return false;
|
return false;
|
||||||
@ -3694,7 +3704,7 @@ floatBranch(MyThread* t, Frame* frame, object code, unsigned& ip,
|
|||||||
case iflt:
|
case iflt:
|
||||||
case ifle:
|
case ifle:
|
||||||
c->condJump(toCompilerFloatJumpOp(t, instruction, lessIfUnordered),
|
c->condJump(toCompilerFloatJumpOp(t, instruction, lessIfUnordered),
|
||||||
size,
|
type,
|
||||||
a,
|
a,
|
||||||
b,
|
b,
|
||||||
target);
|
target);
|
||||||
@ -4426,7 +4436,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
if (floatBranch(t, frame, code, ip, 8, false, a, b, &newIp)) {
|
if (floatBranch(t, frame, code, ip, types.f8, false, a, b, &newIp)) {
|
||||||
goto branch;
|
goto branch;
|
||||||
} else {
|
} else {
|
||||||
frame->pushInt(c->call(
|
frame->pushInt(c->call(
|
||||||
@ -4446,7 +4456,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
if (floatBranch(t, frame, code, ip, 8, true, a, b, &newIp)) {
|
if (floatBranch(t, frame, code, ip, types.f8, true, a, b, &newIp)) {
|
||||||
goto branch;
|
goto branch;
|
||||||
} else {
|
} else {
|
||||||
frame->pushInt(c->call(
|
frame->pushInt(c->call(
|
||||||
@ -4526,7 +4536,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
if (floatBranch(t, frame, code, ip, 4, false, a, b, &newIp)) {
|
if (floatBranch(t, frame, code, ip, types.f4, false, a, b, &newIp)) {
|
||||||
goto branch;
|
goto branch;
|
||||||
} else {
|
} else {
|
||||||
frame->pushInt(c->call(
|
frame->pushInt(c->call(
|
||||||
@ -4544,7 +4554,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popInt();
|
Compiler::Operand* a = frame->popInt();
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
if (floatBranch(t, frame, code, ip, 4, true, a, b, &newIp)) {
|
if (floatBranch(t, frame, code, ip, types.f4, true, a, b, &newIp)) {
|
||||||
goto branch;
|
goto branch;
|
||||||
} else {
|
} else {
|
||||||
frame->pushInt(c->call(
|
frame->pushInt(c->call(
|
||||||
@ -4880,7 +4890,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* b = frame->popObject();
|
Compiler::Operand* b = frame->popObject();
|
||||||
Compiler::Operand* target = frame->machineIp(newIp);
|
Compiler::Operand* target = frame->machineIp(newIp);
|
||||||
|
|
||||||
c->condJump(toCompilerJumpOp(t, instruction), TargetBytesPerWord, a, b, target);
|
c->condJump(toCompilerJumpOp(t, instruction), types.object, a, b, target);
|
||||||
} goto branch;
|
} goto branch;
|
||||||
|
|
||||||
case if_icmpeq:
|
case if_icmpeq:
|
||||||
@ -4901,7 +4911,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
Compiler::Operand* target = frame->machineIp(newIp);
|
Compiler::Operand* target = frame->machineIp(newIp);
|
||||||
|
|
||||||
c->condJump(toCompilerJumpOp(t, instruction), 4, a, b, target);
|
c->condJump(toCompilerJumpOp(t, instruction), types.i4, a, b, target);
|
||||||
} goto branch;
|
} goto branch;
|
||||||
|
|
||||||
case ifeq:
|
case ifeq:
|
||||||
@ -4923,7 +4933,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = c->constant(0, types.i4);
|
Compiler::Operand* a = c->constant(0, types.i4);
|
||||||
Compiler::Operand* b = frame->popInt();
|
Compiler::Operand* b = frame->popInt();
|
||||||
|
|
||||||
c->condJump(toCompilerJumpOp(t, instruction), 4, a, b, target);
|
c->condJump(toCompilerJumpOp(t, instruction), types.i4, a, b, target);
|
||||||
} goto branch;
|
} goto branch;
|
||||||
|
|
||||||
case ifnull:
|
case ifnull:
|
||||||
@ -4940,7 +4950,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* b = frame->popObject();
|
Compiler::Operand* b = frame->popObject();
|
||||||
Compiler::Operand* target = frame->machineIp(newIp);
|
Compiler::Operand* target = frame->machineIp(newIp);
|
||||||
|
|
||||||
c->condJump(toCompilerJumpOp(t, instruction), TargetBytesPerWord, a, b, target);
|
c->condJump(toCompilerJumpOp(t, instruction), types.object, a, b, target);
|
||||||
} goto branch;
|
} goto branch;
|
||||||
|
|
||||||
case iinc: {
|
case iinc: {
|
||||||
@ -5319,7 +5329,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* a = frame->popLong();
|
Compiler::Operand* a = frame->popLong();
|
||||||
Compiler::Operand* b = frame->popLong();
|
Compiler::Operand* b = frame->popLong();
|
||||||
|
|
||||||
if (integerBranch(t, frame, code, ip, 8, a, b, &newIp)) {
|
if (integerBranch(t, frame, code, ip, types.i8, a, b, &newIp)) {
|
||||||
goto branch;
|
goto branch;
|
||||||
} else {
|
} else {
|
||||||
frame->pushInt(
|
frame->pushInt(
|
||||||
@ -6029,7 +6039,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
Compiler::Operand* key = frame->popInt();
|
Compiler::Operand* key = frame->popInt();
|
||||||
|
|
||||||
c->condJump(lir::JumpIfLess,
|
c->condJump(lir::JumpIfLess,
|
||||||
4,
|
types.i4,
|
||||||
c->constant(bottom, types.i4),
|
c->constant(bottom, types.i4),
|
||||||
key,
|
key,
|
||||||
frame->machineIp(defaultIp));
|
frame->machineIp(defaultIp));
|
||||||
@ -6123,7 +6133,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
|
|||||||
c->restoreState(s->state);
|
c->restoreState(s->state);
|
||||||
|
|
||||||
c->condJump(lir::JumpIfGreater,
|
c->condJump(lir::JumpIfGreater,
|
||||||
4,
|
types.i4,
|
||||||
c->constant(s->top, types.i4),
|
c->constant(s->top, types.i4),
|
||||||
s->key,
|
s->key,
|
||||||
frame->machineIp(s->defaultIp));
|
frame->machineIp(s->defaultIp));
|
||||||
|
Loading…
Reference in New Issue
Block a user