add type asserts in appendCombine and appendTranslate

This commit is contained in:
Joshua Warner 2014-05-03 20:52:02 -06:00 committed by Joshua Warner
parent 008bb6b86e
commit d67820054e
3 changed files with 67 additions and 52 deletions

View File

@ -2668,9 +2668,9 @@ class MyCompiler: public Compiler {
appendCombine(&c, appendCombine(&c,
op, op,
type.size(), a->type.size(),
static_cast<Value*>(a), static_cast<Value*>(a),
type.size(), b->type.size(),
static_cast<Value*>(b), static_cast<Value*>(b),
type.size(), type.size(),
result); result);

View File

@ -1008,29 +1008,32 @@ class CombineEvent: public Event {
Value* resultValue; Value* resultValue;
}; };
void void appendCombine(Context* c,
appendCombine(Context* c, lir::TernaryOperation type, lir::TernaryOperation op,
unsigned firstSize, Value* firstValue, unsigned firstSize,
unsigned secondSize, Value* secondValue, Value* firstValue,
unsigned resultSize, Value* resultValue) unsigned secondSize,
Value* secondValue,
unsigned resultSize,
Value* resultValue)
{ {
assert(c, firstSize == firstValue->type.size());
assert(c, secondSize == secondValue->type.size());
assert(c, resultSize == resultValue->type.size());
bool thunk; bool thunk;
OperandMask firstMask; OperandMask firstMask;
OperandMask secondMask; OperandMask secondMask;
c->arch->planSource(type, c->arch->planSource(
firstSize, firstMask, op, firstSize, firstMask, secondSize, secondMask, resultSize, &thunk);
secondSize, secondMask,
resultSize,
&thunk);
if (thunk) { if (thunk) {
FixedSliceStack<ir::Value*, 6> slice; FixedSliceStack<ir::Value*, 6> slice;
size_t stackBase = c->stack ? c->stack->index + 1 : 0; size_t stackBase = c->stack ? c->stack->index + 1 : 0;
bool threadParameter; bool threadParameter;
intptr_t handler = c->client->getThunk intptr_t handler
(type, firstSize, resultSize, &threadParameter); = c->client->getThunk(op, firstSize, resultSize, &threadParameter);
unsigned stackSize = ceilingDivide(secondSize, vm::TargetBytesPerWord) unsigned stackSize = ceilingDivide(secondSize, vm::TargetBytesPerWord)
+ ceilingDivide(firstSize, vm::TargetBytesPerWord); + ceilingDivide(firstSize, vm::TargetBytesPerWord);
@ -1063,17 +1066,19 @@ appendCombine(Context* c, lir::TernaryOperation type,
resultSize, resultSize,
slice); slice);
} else { } else {
append append(c,
(c, new(c->zone) new (c->zone) CombineEvent(c,
CombineEvent op,
(c, type, firstSize,
firstSize, firstValue, firstValue,
secondSize, secondValue, secondSize,
resultSize, resultValue, secondValue,
SiteMask::lowPart(firstMask), resultSize,
SiteMask::highPart(firstMask), resultValue,
SiteMask::lowPart(secondMask), SiteMask::lowPart(firstMask),
SiteMask::highPart(secondMask))); SiteMask::highPart(firstMask),
SiteMask::lowPart(secondMask),
SiteMask::highPart(secondMask)));
} }
} }
@ -1155,15 +1160,20 @@ class TranslateEvent: public Event {
SiteMask resultHighMask; SiteMask resultHighMask;
}; };
void void appendTranslate(Context* c,
appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize, lir::BinaryOperation op,
Value* firstValue, unsigned resultSize, Value* resultValue) unsigned firstSize,
Value* firstValue,
unsigned resultSize,
Value* resultValue)
{ {
assert(c, firstSize == firstValue->type.size());
assert(c, resultSize == resultValue->type.size());
bool thunk; bool thunk;
OperandMask first; OperandMask first;
c->arch->planSource(type, firstSize, first, c->arch->planSource(op, firstSize, first, resultSize, &thunk);
resultSize, &thunk);
if (thunk) { if (thunk) {
size_t stackBase = c->stack ? c->stack->index + 1 : 0; size_t stackBase = c->stack ? c->stack->index + 1 : 0;
@ -1175,23 +1185,27 @@ appendTranslate(Context* c, lir::BinaryOperation type, unsigned firstSize,
stackBase, stackBase,
slice); slice);
appendCall(c, appendCall(
value(c, c,
ir::Type(ir::Type::Address, vm::TargetBytesPerWord), value(c,
constantSite( ir::Type(ir::Type::Address, vm::TargetBytesPerWord),
c, c->client->getThunk(type, firstSize, resultSize))), constantSite(c, c->client->getThunk(op, firstSize, resultSize))),
ir::NativeCallingConvention, ir::NativeCallingConvention,
0, 0,
0, 0,
resultValue, resultValue,
resultSize, resultSize,
slice); slice);
} else { } else {
append(c, new(c->zone) append(c,
TranslateEvent new (c->zone) TranslateEvent(c,
(c, type, firstSize, firstValue, resultSize, resultValue, op,
SiteMask::lowPart(first), firstSize,
SiteMask::highPart(first))); firstValue,
resultSize,
resultValue,
SiteMask::lowPart(first),
SiteMask::highPart(first)));
} }
} }

View File

@ -5178,12 +5178,13 @@ compile(MyThread* t, Frame* initialFrame, unsigned initialIp,
ir::Value* instance = c->peek(1, parameterFootprint - 1); ir::Value* instance = c->peek(1, parameterFootprint - 1);
frame->stackCall( frame->stackCall(
c->memory(c->binaryOp(lir::And, c->memory(
types.address, c->binaryOp(lir::And,
c->constant(TargetPointerMask, types.i4), types.address,
c->memory(instance, types.object)), c->constant(TargetPointerMask, types.address),
types.object, c->memory(instance, types.object)),
offset), types.object,
offset),
target, target,
tailCall ? Compiler::TailJump : 0, tailCall ? Compiler::TailJump : 0,
frame->trace(0, 0)); frame->trace(0, 0));