Bug 949668 - SpiderMonkey: Add an LDefinition::Float32 r=jandem

This commit is contained in:
Dan Gohman 2013-12-13 08:27:47 -08:00
Родитель 3a62ff8315
Коммит 3a820e1318
13 изменённых файлов: 52 добавлений и 33 удалений

Просмотреть файл

@ -1128,7 +1128,9 @@ BacktrackingAllocator::populateSafepoints()
if (ins == reg->ins() && !reg->isTemp()) {
DebugOnly<LDefinition*> def = reg->def();
JS_ASSERT_IF(def->policy() == LDefinition::MUST_REUSE_INPUT,
def->type() == LDefinition::GENERAL || def->type() == LDefinition::DOUBLE);
def->type() == LDefinition::GENERAL ||
def->type() == LDefinition::FLOAT32 ||
def->type() == LDefinition::DOUBLE);
continue;
}

Просмотреть файл

@ -197,10 +197,11 @@ static const char * const TypeChars[] =
{
"i", // INTEGER
"o", // OBJECT
"f", // DOUBLE
"f", // FLOAT32
"d", // DOUBLE
#ifdef JS_NUNBOX32
"t", // TYPE
"d" // PAYLOAD
"p" // PAYLOAD
#elif JS_PUNBOX64
"x" // BOX
#endif

Просмотреть файл

@ -446,7 +446,8 @@ class LDefinition
GENERAL, // Generic, integer or pointer-width data (GPR).
OBJECT, // Pointer that may be collected as garbage (GPR).
SLOTS, // Slots/elements pointer that may be moved by minor GCs (GPR).
DOUBLE, // 64-bit point value (FPU).
FLOAT32, // 32-bit floating-point value (FPU).
DOUBLE, // 64-bit floating-point value (FPU).
#ifdef JS_NUNBOX32
// A type virtual register must be followed by a payload virtual
// register, as both will be tracked as a single gcthing.
@ -540,8 +541,9 @@ class LDefinition
case MIRType_Object:
return LDefinition::OBJECT;
case MIRType_Double:
case MIRType_Float32:
return LDefinition::DOUBLE;
case MIRType_Float32:
return LDefinition::FLOAT32;
#if defined(JS_PUNBOX64)
case MIRType_Value:
return LDefinition::BOX;

Просмотреть файл

@ -515,7 +515,9 @@ LinearScanAllocator::populateSafepoints()
if (ins == reg->ins() && !reg->isTemp()) {
DebugOnly<LDefinition*> def = reg->def();
JS_ASSERT_IF(def->policy() == LDefinition::MUST_REUSE_INPUT,
def->type() == LDefinition::GENERAL || def->type() == LDefinition::DOUBLE);
def->type() == LDefinition::GENERAL ||
def->type() == LDefinition::FLOAT32 ||
def->type() == LDefinition::DOUBLE);
continue;
}
@ -792,7 +794,7 @@ LinearScanAllocator::allocateSlotFor(const LiveInterval *interval)
LinearScanVirtualRegister *reg = &vregs[interval->vreg()];
SlotList *freed;
if (reg->type() == LDefinition::DOUBLE)
if (reg->type() == LDefinition::DOUBLE || reg->type() == LDefinition::FLOAT32)
freed = &finishedDoubleSlots_;
#ifdef JS_NUNBOX32
else if (IsNunbox(reg))

Просмотреть файл

@ -468,6 +468,7 @@ AddRegisterToSafepoint(LSafepoint *safepoint, AnyRegister reg, const LDefinition
JS_ASSERT(def.type() == LDefinition::GENERAL ||
def.type() == LDefinition::DOUBLE ||
def.type() == LDefinition::FLOAT32 ||
def.type() == LDefinition::OBJECT);
if (def.type() == LDefinition::OBJECT)

Просмотреть файл

@ -136,7 +136,7 @@ static inline bool
DefinitionCompatibleWith(LInstruction *ins, const LDefinition *def, LAllocation alloc)
{
if (ins->isPhi()) {
if (def->type() == LDefinition::DOUBLE)
if (def->type() == LDefinition::DOUBLE || def->type() == LDefinition::FLOAT32)
return alloc.isFloatReg() || alloc.kind() == LAllocation::DOUBLE_SLOT;
return alloc.isGeneralReg() || alloc.kind() == LAllocation::STACK_SLOT;
}
@ -145,7 +145,7 @@ DefinitionCompatibleWith(LInstruction *ins, const LDefinition *def, LAllocation
case LDefinition::DEFAULT:
if (!alloc.isRegister())
return false;
return alloc.isFloatReg() == (def->type() == LDefinition::DOUBLE);
return alloc.isFloatReg() == (def->type() == LDefinition::DOUBLE || def->type() == LDefinition::FLOAT32);
case LDefinition::PRESET:
return alloc == *def->output();
case LDefinition::MUST_REUSE_INPUT:
@ -473,7 +473,7 @@ class VirtualRegister
return intervals_.insert(found, interval);
}
bool isDouble() const {
return def_->type() == LDefinition::DOUBLE;
return def_->type() == LDefinition::DOUBLE || def_->type() == LDefinition::FLOAT32;
}
LiveInterval *intervalFor(CodePosition pos);

Просмотреть файл

@ -660,7 +660,7 @@ LIRGenerator::visitTest(MTest *test)
temp0 = LDefinition::BogusTemp();
temp1 = LDefinition::BogusTemp();
}
LTestVAndBranch *lir = new(alloc()) LTestVAndBranch(ifTrue, ifFalse, tempFloat(), temp0, temp1);
LTestVAndBranch *lir = new(alloc()) LTestVAndBranch(ifTrue, ifFalse, tempDouble(), temp0, temp1);
if (!useBox(lir, LTestVAndBranch::Input, opd))
return false;
return add(lir, test);
@ -1027,7 +1027,7 @@ LIRGenerator::visitTypeOf(MTypeOf *ins)
bool
LIRGenerator::visitToId(MToId *ins)
{
LToIdV *lir = new(alloc()) LToIdV(tempFloat());
LToIdV *lir = new(alloc()) LToIdV(tempDouble());
if (!useBox(lir, LToIdV::Object, ins->lhs()))
return false;
if (!useBox(lir, LToIdV::Index, ins->rhs()))
@ -1176,7 +1176,7 @@ bool
LIRGenerator::visitRound(MRound *ins)
{
JS_ASSERT(ins->num()->type() == MIRType_Double);
LRound *lir = new(alloc()) LRound(useRegister(ins->num()), tempFloat());
LRound *lir = new(alloc()) LRound(useRegister(ins->num()), tempDouble());
if (!assignSnapshot(lir))
return false;
return define(lir, ins);
@ -1755,7 +1755,7 @@ LIRGenerator::visitToInt32(MToInt32 *convert)
switch (opd->type()) {
case MIRType_Value:
{
LValueToInt32 *lir = new(alloc()) LValueToInt32(tempFloat(), temp(), LValueToInt32::NORMAL);
LValueToInt32 *lir = new(alloc()) LValueToInt32(tempDouble(), temp(), LValueToInt32::NORMAL);
if (!useBox(lir, LValueToInt32::Input, opd))
return false;
return assignSnapshot(lir) && define(lir, convert) && assignSafepoint(lir, convert);
@ -1800,7 +1800,7 @@ LIRGenerator::visitTruncateToInt32(MTruncateToInt32 *truncate)
switch (opd->type()) {
case MIRType_Value:
{
LValueToInt32 *lir = new(alloc()) LValueToInt32(tempFloat(), temp(), LValueToInt32::TRUNCATE);
LValueToInt32 *lir = new(alloc()) LValueToInt32(tempDouble(), temp(), LValueToInt32::TRUNCATE);
if (!useBox(lir, LValueToInt32::Input, opd))
return false;
return assignSnapshot(lir) && define(lir, truncate) && assignSafepoint(lir, truncate);
@ -2026,7 +2026,7 @@ LIRGenerator::visitMaybeToDoubleElement(MMaybeToDoubleElement *ins)
LMaybeToDoubleElement *lir = new(alloc()) LMaybeToDoubleElement(useRegisterAtStart(ins->elements()),
useRegisterAtStart(ins->value()),
tempFloat());
tempDouble());
return defineBox(lir, ins);
}
@ -2343,7 +2343,7 @@ LIRGenerator::visitNot(MNot *ins)
temp1 = LDefinition::BogusTemp();
}
LNotV *lir = new(alloc()) LNotV(tempFloat(), temp0, temp1);
LNotV *lir = new(alloc()) LNotV(tempDouble(), temp0, temp1);
if (!useBox(lir, LNotV::Input, op))
return false;
return define(lir, ins);
@ -2626,7 +2626,7 @@ LIRGenerator::visitClampToUint8(MClampToUint8 *ins)
case MIRType_Value:
{
LClampVToUint8 *lir = new(alloc()) LClampVToUint8(tempFloat());
LClampVToUint8 *lir = new(alloc()) LClampVToUint8(tempDouble());
if (!useBox(lir, LClampVToUint8::Input, in))
return false;
return assignSnapshot(lir) && define(lir, ins) && assignSafepoint(lir, ins);
@ -2913,15 +2913,15 @@ LIRGenerator::visitAssertRange(MAssertRange *ins)
break;
case MIRType_Double:
lir = new(alloc()) LAssertRangeD(useRegister(input), tempFloat());
lir = new(alloc()) LAssertRangeD(useRegister(input), tempDouble());
break;
case MIRType_Float32:
lir = new(alloc()) LAssertRangeF(useRegister(input), tempFloat());
lir = new(alloc()) LAssertRangeF(useRegister(input), tempFloat32());
break;
case MIRType_Value:
lir = new(alloc()) LAssertRangeV(tempToUnbox(), tempFloat(), tempFloat());
lir = new(alloc()) LAssertRangeV(tempToUnbox(), tempDouble(), tempDouble());
if (!useBox(lir, LAssertRangeV::Input, input))
return false;
break;
@ -3027,7 +3027,7 @@ LIRGenerator::visitSetElementCache(MSetElementCache *ins)
LInstruction *lir;
if (ins->value()->type() == MIRType_Value) {
lir = new(alloc()) LSetElementCacheV(useByteOpRegister(ins->object()), tempToUnbox(),
temp(), tempFloat());
temp(), tempDouble());
if (!useBox(lir, LSetElementCacheV::Index, ins->index()))
return false;
@ -3036,7 +3036,7 @@ LIRGenerator::visitSetElementCache(MSetElementCache *ins)
} else {
lir = new(alloc()) LSetElementCacheT(useByteOpRegister(ins->object()),
useRegisterOrConstant(ins->value()),
tempToUnbox(), temp(), tempFloat());
tempToUnbox(), temp(), tempDouble());
if (!useBox(lir, LSetElementCacheT::Index, ins->index()))
return false;

Просмотреть файл

@ -369,7 +369,7 @@ class RegisterAllocator
static inline AnyRegister
GetFixedRegister(const LDefinition *def, const LUse *use)
{
return def->type() == LDefinition::DOUBLE
return (def->type() == LDefinition::DOUBLE || def->type() == LDefinition::FLOAT32)
? AnyRegister(FloatRegister::FromCode(use->registerCode()))
: AnyRegister(Register::FromCode(use->registerCode()));
}

Просмотреть файл

@ -28,7 +28,9 @@ StupidAllocator::stackLocation(uint32_t vreg)
if (def->policy() == LDefinition::PRESET && def->output()->isArgument())
return def->output();
return new(alloc()) LStackSlot(DefaultStackSlot(vreg), def->type() == LDefinition::DOUBLE);
return new(alloc()) LStackSlot(DefaultStackSlot(vreg),
def->type() == LDefinition::DOUBLE ||
def->type() == LDefinition::FLOAT32);
}
StupidAllocator::RegisterIndex
@ -162,7 +164,7 @@ StupidAllocator::allocateRegister(LInstruction *ins, uint32_t vreg)
for (size_t i = 0; i < registerCount; i++) {
AnyRegister reg = registers[i].reg;
if (reg.isFloat() != (def->type() == LDefinition::DOUBLE))
if (reg.isFloat() != (def->type() == LDefinition::DOUBLE || def->type() == LDefinition::FLOAT32))
continue;
// Skip the register if it is in use for an allocated input or output.

Просмотреть файл

@ -362,7 +362,7 @@ LIRGeneratorARM::newLTableSwitch(const LAllocation &in, const LDefinition &input
LTableSwitchV *
LIRGeneratorARM::newLTableSwitchV(MTableSwitch *tableswitch)
{
return new(alloc()) LTableSwitchV(temp(), tempFloat(), tableswitch);
return new(alloc()) LTableSwitchV(temp(), tempDouble(), tableswitch);
}
bool

Просмотреть файл

@ -149,12 +149,14 @@ LIRGeneratorShared::defineReturn(LInstruction *lir, MDefinition *mir)
#endif
break;
case MIRType_Float32:
lir->setDef(0, LDefinition(vreg, LDefinition::FLOAT32, LFloatReg(ReturnFloatReg)));
break;
case MIRType_Double:
lir->setDef(0, LDefinition(vreg, LDefinition::DOUBLE, LFloatReg(ReturnFloatReg)));
break;
default:
LDefinition::Type type = LDefinition::TypeFrom(mir->type());
JS_ASSERT(type != LDefinition::DOUBLE);
JS_ASSERT(type != LDefinition::DOUBLE && type != LDefinition::FLOAT32);
lir->setDef(0, LDefinition(vreg, type, LGeneralReg(ReturnReg)));
break;
}
@ -421,7 +423,13 @@ LIRGeneratorShared::tempFixed(Register reg)
}
LDefinition
LIRGeneratorShared::tempFloat()
LIRGeneratorShared::tempFloat32()
{
return temp(LDefinition::FLOAT32);
}
LDefinition
LIRGeneratorShared::tempDouble()
{
return temp(LDefinition::DOUBLE);
}

Просмотреть файл

@ -104,7 +104,8 @@ class LIRGeneratorShared : public MInstructionVisitorWithDefaults
// These create temporary register requests.
inline LDefinition temp(LDefinition::Type type = LDefinition::GENERAL,
LDefinition::Policy policy = LDefinition::DEFAULT);
inline LDefinition tempFloat();
inline LDefinition tempFloat32();
inline LDefinition tempDouble();
inline LDefinition tempCopy(MDefinition *input, uint32_t reusedInput);
// Note that the fixed register has a GENERAL type.

Просмотреть файл

@ -27,7 +27,7 @@ LIRGeneratorX86Shared::newLTableSwitch(const LAllocation &in, const LDefinition
LTableSwitchV *
LIRGeneratorX86Shared::newLTableSwitchV(MTableSwitch *tableswitch)
{
return new(alloc()) LTableSwitchV(temp(), tempFloat(), temp(), tableswitch);
return new(alloc()) LTableSwitchV(temp(), tempDouble(), temp(), tableswitch);
}
bool
@ -333,7 +333,7 @@ LIRGeneratorX86Shared::lowerTruncateDToInt32(MTruncateToInt32 *ins)
MDefinition *opd = ins->input();
JS_ASSERT(opd->type() == MIRType_Double);
LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempFloat();
LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempDouble();
return define(new(alloc()) LTruncateDToInt32(useRegister(opd), maybeTemp), ins);
}
@ -343,6 +343,6 @@ LIRGeneratorX86Shared::lowerTruncateFToInt32(MTruncateToInt32 *ins)
MDefinition *opd = ins->input();
JS_ASSERT(opd->type() == MIRType_Float32);
LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempFloat();
LDefinition maybeTemp = Assembler::HasSSE3() ? LDefinition::BogusTemp() : tempFloat32();
return define(new(alloc()) LTruncateFToInt32(useRegister(opd), maybeTemp), ins);
}