add asserts

This commit is contained in:
Joshua Warner 2014-05-01 12:37:01 -06:00
parent 42fec084b0
commit 865041b688
3 changed files with 18 additions and 12 deletions

View File

@ -73,7 +73,7 @@ class Compiler {
virtual Operand* constant(int64_t value, ir::Type type) = 0;
virtual Operand* promiseConstant(Promise* value, ir::Type type) = 0;
virtual Operand* address(Promise* address) = 0;
virtual Operand* address(ir::Type type, Promise* address) = 0;
virtual Operand* memory(Operand* base,
ir::Type type,
int displacement = 0,

View File

@ -1252,6 +1252,13 @@ Value* loadLocal(Context* c, ir::Type type, unsigned index)
fprintf(stderr, "load local %p at %d\n", c->locals[index].value, index);
}
assert(c,
type.flavor() != ir::Type::Object
|| c->locals[index].value->type.flavor() == ir::Type::Object
// TODO: this is a very java-specific hole in the type system. Get
// rid of it:
|| c->locals[index].value->type.flavor() == ir::Type::Address);
return c->locals[index].value;
}
@ -2311,10 +2318,9 @@ class MyCompiler: public Compiler {
return compiler::value(&c, type, compiler::constantSite(&c, value));
}
virtual Operand* address(Promise* address) {
return value(&c,
ir::Type(ir::Type::Address, TargetBytesPerWord),
compiler::addressSite(&c, address));
virtual Operand* address(ir::Type type, Promise* address)
{
return value(&c, type, compiler::addressSite(&c, address));
}
virtual Operand* memory(Operand* base,

View File

@ -1414,14 +1414,14 @@ class Frame {
return c->binaryOp(
lir::Add,
types.address,
types.object,
c->memory(
c->threadRegister(), types.address, TARGET_THREAD_HEAPIMAGE),
c->promiseConstant(p, types.address));
c->threadRegister(), types.object, TARGET_THREAD_HEAPIMAGE),
c->promiseConstant(p, types.object));
} else {
for (PoolElement* e = context->objectPool; e; e = e->next) {
if (o == e->target) {
return c->address(e);
return c->address(types.object, e);
}
}
@ -1429,7 +1429,7 @@ class Frame {
++ context->objectPoolCount;
return c->address(context->objectPool);
return c->address(types.object, context->objectPool);
}
}
@ -1711,7 +1711,7 @@ class Frame {
}
void pushObject(Value o) {
// assert(t, o->type == types.object);
assert(t, o->type == types.object || o->type.flavor() == ir::Type::Address);
pushQuiet(types.object, o);
pushedObject();
}
@ -3130,7 +3130,7 @@ ir::Type operandTypeForFieldCode(Thread* t, unsigned code)
return types.i8;
case ObjectField:
return types.address;
return types.object;
case FloatField:
return types.f4;