diff --git a/include/avian/codegen/compiler.h b/include/avian/codegen/compiler.h index e35486bf01..e83e00a9f0 100644 --- a/include/avian/codegen/compiler.h +++ b/include/avian/codegen/compiler.h @@ -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, diff --git a/src/codegen/compiler.cpp b/src/codegen/compiler.cpp index b89b7f6cbf..86a3ffea29 100644 --- a/src/codegen/compiler.cpp +++ b/src/codegen/compiler.cpp @@ -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, diff --git a/src/compile.cpp b/src/compile.cpp index e208a6bb13..071664717d 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -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;