From 0658e25d59681a4350c88288183d2eb4ddee6f22 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 17 Dec 2013 08:46:37 -0800 Subject: [PATCH] Bug 950703 - SpiderMonkey: Merge DOUBLE_SLOT and DOUBLE_ARGUMENT with STACK_SLOT and INT_ARGUMENT. r=jandem --- js/src/jit/BacktrackingAllocator.cpp | 2 +- js/src/jit/CodeGenerator.cpp | 3 +-- js/src/jit/LIR.cpp | 10 ++-------- js/src/jit/LIR.h | 27 ++++++++++----------------- js/src/jit/LinearScan.cpp | 5 +++-- js/src/jit/LiveRangeAllocator.h | 2 +- js/src/jit/Lowering.cpp | 15 ++++++--------- js/src/jit/Safepoints.cpp | 2 +- js/src/jit/StupidAllocator.cpp | 4 +--- 9 files changed, 26 insertions(+), 44 deletions(-) diff --git a/js/src/jit/BacktrackingAllocator.cpp b/js/src/jit/BacktrackingAllocator.cpp index 803079fc287..28e2e0bb098 100644 --- a/js/src/jit/BacktrackingAllocator.cpp +++ b/js/src/jit/BacktrackingAllocator.cpp @@ -869,7 +869,7 @@ BacktrackingAllocator::spill(LiveInterval *interval) stackSlot = stackSlotAllocator.allocateSlot(); JS_ASSERT(stackSlot <= stackSlotAllocator.stackHeight()); - LStackSlot alloc(stackSlot, reg->isDouble()); + LStackSlot alloc(stackSlot); interval->setAllocation(alloc); IonSpew(IonSpew_RegAlloc, " Allocating spill location %s", alloc.toString()); diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index c5a4552512a..61ad9d49a06 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -981,7 +981,7 @@ CodeGenerator::visitTableSwitch(LTableSwitch *ins) Label *defaultcase = mir->getDefault()->lir()->label(); const LAllocation *temp; - if (ins->index()->isDouble()) { + if (mir->getOperand(0)->type() != MIRType_Int32) { temp = ins->tempInt()->output(); // The input is a double, so try and convert it to an integer. @@ -1193,7 +1193,6 @@ CodeGenerator::visitMoveGroup(LMoveGroup *group) // No bogus moves. JS_ASSERT(*from != *to); JS_ASSERT(!from->isConstant()); - JS_ASSERT(from->isDouble() == to->isDouble()); MoveOp::Kind kind; switch (type) { diff --git a/js/src/jit/LIR.cpp b/js/src/jit/LIR.cpp index 863befaea27..814ca368fee 100644 --- a/js/src/jit/LIR.cpp +++ b/js/src/jit/LIR.cpp @@ -269,15 +269,9 @@ LAllocation::toString() const JS_snprintf(buf, sizeof(buf), "=%s", toFloatReg()->reg().name()); return buf; case LAllocation::STACK_SLOT: - JS_snprintf(buf, sizeof(buf), "stack:i%d", toStackSlot()->slot()); + JS_snprintf(buf, sizeof(buf), "stack:%d", toStackSlot()->slot()); return buf; - case LAllocation::DOUBLE_SLOT: - JS_snprintf(buf, sizeof(buf), "stack:d%d", toStackSlot()->slot()); - return buf; - case LAllocation::INT_ARGUMENT: - JS_snprintf(buf, sizeof(buf), "arg:%d", toArgument()->index()); - return buf; - case LAllocation::DOUBLE_ARGUMENT: + case LAllocation::ARGUMENT_SLOT: JS_snprintf(buf, sizeof(buf), "arg:%d", toArgument()->index()); return buf; case LAllocation::USE: diff --git a/js/src/jit/LIR.h b/js/src/jit/LIR.h index d31ade88a65..d6c5a522d46 100644 --- a/js/src/jit/LIR.h +++ b/js/src/jit/LIR.h @@ -60,7 +60,7 @@ class LAllocation : public TempObject static const uintptr_t TAG_BIT = 1; static const uintptr_t TAG_SHIFT = 0; static const uintptr_t TAG_MASK = 1 << TAG_SHIFT; - static const uintptr_t KIND_BITS = 4; + static const uintptr_t KIND_BITS = 3; static const uintptr_t KIND_SHIFT = TAG_SHIFT + TAG_BIT; static const uintptr_t KIND_MASK = (1 << KIND_BITS) - 1; @@ -76,10 +76,8 @@ class LAllocation : public TempObject CONSTANT_INDEX, // Constant arbitrary index. GPR, // General purpose register. FPU, // Floating-point register. - STACK_SLOT, // 32-bit stack slot. - DOUBLE_SLOT, // 64-bit stack slot. - INT_ARGUMENT, // Argument slot that gets loaded into a GPR. - DOUBLE_ARGUMENT // Argument slot to be loaded into an FPR + STACK_SLOT, // Stack slot. + ARGUMENT_SLOT // Argument slot. }; protected: @@ -155,10 +153,10 @@ class LAllocation : public TempObject return kind() == FPU; } bool isStackSlot() const { - return kind() == STACK_SLOT || kind() == DOUBLE_SLOT; + return kind() == STACK_SLOT; } bool isArgument() const { - return kind() == INT_ARGUMENT || kind() == DOUBLE_ARGUMENT; + return kind() == ARGUMENT_SLOT; } bool isRegister() const { return isGeneralReg() || isFloatReg(); @@ -169,9 +167,6 @@ class LAllocation : public TempObject bool isMemory() const { return isStackSlot() || isArgument(); } - bool isDouble() const { - return kind() == DOUBLE_SLOT || kind() == FPU || kind() == DOUBLE_ARGUMENT; - } inline LUse *toUse(); inline const LUse *toUse() const; inline const LGeneralReg *toGeneralReg() const; @@ -359,8 +354,8 @@ class LConstantIndex : public LAllocation class LStackSlot : public LAllocation { public: - explicit LStackSlot(uint32_t slot, bool isDouble = false) - : LAllocation(isDouble ? DOUBLE_SLOT : STACK_SLOT, slot) + explicit LStackSlot(uint32_t slot) + : LAllocation(STACK_SLOT, slot) { } uint32_t slot() const { @@ -374,11 +369,9 @@ class LStackSlot : public LAllocation class LArgument : public LAllocation { public: - explicit LArgument(LAllocation::Kind kind, int32_t index) - : LAllocation(kind, index) - { - JS_ASSERT(kind == INT_ARGUMENT || kind == DOUBLE_ARGUMENT); - } + explicit LArgument(int32_t index) + : LAllocation(ARGUMENT_SLOT, index) + { } int32_t index() const { return data(); diff --git a/js/src/jit/LinearScan.cpp b/js/src/jit/LinearScan.cpp index 6a46531ab37..ef692df7a26 100644 --- a/js/src/jit/LinearScan.cpp +++ b/js/src/jit/LinearScan.cpp @@ -875,7 +875,7 @@ LinearScanAllocator::spill() } JS_ASSERT(stackSlot <= stackSlotAllocator.stackHeight()); - return assign(LStackSlot(stackSlot, reg->isDouble())); + return assign(LStackSlot(stackSlot)); } void @@ -884,7 +884,8 @@ LinearScanAllocator::freeAllocation(LiveInterval *interval, LAllocation *alloc) LinearScanVirtualRegister *mine = &vregs[interval->vreg()]; if (!IsNunbox(mine)) { if (alloc->isStackSlot()) { - if (alloc->toStackSlot()->isDouble()) + LDefinition::Type type = mine->type(); + if (type == LDefinition::DOUBLE || type == LDefinition::FLOAT32) finishedDoubleSlots_.append(interval); else finishedSlots_.append(interval); diff --git a/js/src/jit/LiveRangeAllocator.h b/js/src/jit/LiveRangeAllocator.h index 993f1c49545..36718fcce60 100644 --- a/js/src/jit/LiveRangeAllocator.h +++ b/js/src/jit/LiveRangeAllocator.h @@ -137,7 +137,7 @@ DefinitionCompatibleWith(LInstruction *ins, const LDefinition *def, LAllocation { if (ins->isPhi()) { if (def->type() == LDefinition::DOUBLE || def->type() == LDefinition::FLOAT32) - return alloc.isFloatReg() || alloc.kind() == LAllocation::DOUBLE_SLOT; + return alloc.isFloatReg() || alloc.kind() == LAllocation::STACK_SLOT; return alloc.isGeneralReg() || alloc.kind() == LAllocation::STACK_SLOT; } diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index 67d8af97494..8675534762f 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -42,14 +42,14 @@ LIRGenerator::visitParameter(MParameter *param) offset *= sizeof(Value); #if defined(JS_NUNBOX32) # if defined(IS_BIG_ENDIAN) - ins->getDef(0)->setOutput(LArgument(LAllocation::INT_ARGUMENT, offset)); - ins->getDef(1)->setOutput(LArgument(LAllocation::INT_ARGUMENT, offset + 4)); + ins->getDef(0)->setOutput(LArgument(offset)); + ins->getDef(1)->setOutput(LArgument(offset + 4)); # else - ins->getDef(0)->setOutput(LArgument(LAllocation::INT_ARGUMENT, offset + 4)); - ins->getDef(1)->setOutput(LArgument(LAllocation::INT_ARGUMENT, offset)); + ins->getDef(0)->setOutput(LArgument(offset + 4)); + ins->getDef(1)->setOutput(LArgument(offset)); # endif #elif defined(JS_PUNBOX64) - ins->getDef(0)->setOutput(LArgument(LAllocation::INT_ARGUMENT, offset)); + ins->getDef(0)->setOutput(LArgument(offset)); #endif return true; @@ -3295,10 +3295,7 @@ LIRGenerator::visitAsmJSParameter(MAsmJSParameter *ins) return defineFixed(new(alloc()) LAsmJSParameter, ins, LAllocation(abi.reg())); JS_ASSERT(IsNumberType(ins->type())); - LAllocation::Kind argKind = ins->type() == MIRType_Int32 - ? LAllocation::INT_ARGUMENT - : LAllocation::DOUBLE_ARGUMENT; - return defineFixed(new(alloc()) LAsmJSParameter, ins, LArgument(argKind, abi.offsetFromArgBase())); + return defineFixed(new(alloc()) LAsmJSParameter, ins, LArgument(abi.offsetFromArgBase())); } bool diff --git a/js/src/jit/Safepoints.cpp b/js/src/jit/Safepoints.cpp index 520fc575755..76399d35e58 100644 --- a/js/src/jit/Safepoints.cpp +++ b/js/src/jit/Safepoints.cpp @@ -452,7 +452,7 @@ PartFromStream(CompactBufferReader &stream, NunboxPartKind kind, uint32_t info) return LStackSlot(info); JS_ASSERT(kind == Part_Arg); - return LArgument(LAllocation::INT_ARGUMENT, info); + return LArgument(info); } bool diff --git a/js/src/jit/StupidAllocator.cpp b/js/src/jit/StupidAllocator.cpp index 8f9751faba7..b77a72b0f0a 100644 --- a/js/src/jit/StupidAllocator.cpp +++ b/js/src/jit/StupidAllocator.cpp @@ -28,9 +28,7 @@ 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 || - def->type() == LDefinition::FLOAT32); + return new(alloc()) LStackSlot(DefaultStackSlot(vreg)); } StupidAllocator::RegisterIndex