Bug 1479603 - [Part 2] Cleanup Ion SharedStubs code r=jandem
authorMatthew Gaudet <mgaudet@mozilla.com>
Wed, 15 Aug 2018 19:59:34 -0700
changeset 831130 402c68b550d1aede856016eee0325f2c4cd75729
parent 831129 7518b4bbc6c740d8f63c1cfaf765c9e136b6c011
child 831131 9a64325eeacb61c7de1e00977233a234627b7f44
push id118868
push userbmo:zjz@zjz.name
push dateFri, 24 Aug 2018 07:04:39 +0000
reviewersjandem
bugs1479603
milestone63.0a1
Bug 1479603 - [Part 2] Cleanup Ion SharedStubs code r=jandem
js/src/jit/CodeGenerator.cpp
js/src/jit/CodeGenerator.h
js/src/jit/IonBuilder.cpp
js/src/jit/Lowering.cpp
js/src/jit/MIR.h
js/src/jit/shared/LIR-shared.h
js/src/jit/shared/Lowering-shared-inl.h
js/src/jit/shared/Lowering-shared.h
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -2860,53 +2860,16 @@ CodeGenerator::visitStringReplace(LStrin
 
     if (lir->mir()->isFlatReplacement())
         callVM(StringFlatReplaceInfo, lir);
     else
         callVM(StringReplaceInfo, lir);
 }
 
 void
-CodeGenerator::emitSharedStub(ICStub::Kind kind, LInstruction* lir)
-{
-    JSScript* script = lir->mirRaw()->block()->info().script();
-    jsbytecode* pc = lir->mirRaw()->toInstruction()->resumePoint()->pc();
-
-#ifdef JS_USE_LINK_REGISTER
-    // Some architectures don't push the return address on the stack but
-    // use the link register. In that case the stack isn't aligned. Push
-    // to make sure we are aligned.
-    masm.Push(Imm32(0));
-#endif
-
-    // Create descriptor signifying end of Ion frame.
-    uint32_t descriptor = MakeFrameDescriptor(masm.framePushed(), JitFrame_IonJS,
-                                              JitStubFrameLayout::Size());
-    masm.Push(Imm32(descriptor));
-
-    // Call into the stubcode.
-    CodeOffset patchOffset;
-    IonICEntry entry(script->pcToOffset(pc), ICEntry::Kind_Op, script);
-    EmitCallIC(&patchOffset, masm);
-    entry.setReturnOffset(CodeOffset(masm.currentOffset()));
-
-    SharedStub sharedStub(kind, entry, patchOffset);
-    masm.propagateOOM(sharedStubs_.append(sharedStub));
-
-    // Fix up upon return.
-    uint32_t callOffset = masm.currentOffset();
-#ifdef JS_USE_LINK_REGISTER
-    masm.freeStack(sizeof(intptr_t) * 2);
-#else
-    masm.freeStack(sizeof(intptr_t));
-#endif
-    markSafepointAt(callOffset, lir);
-}
-
-void
 CodeGenerator::visitBinaryCache(LBinaryCache* lir)
 {
     LiveRegisterSet liveRegs = lir->safepoint()->liveRegs();
     TypedOrValueRegister lhs = TypedOrValueRegister(ToValue(lir, LBinaryCache::LhsInput));
     TypedOrValueRegister rhs = TypedOrValueRegister(ToValue(lir, LBinaryCache::RhsInput));
     ValueOperand output = ToOutValue(lir);
 
     JSOp jsop = JSOp(*lir->mirRaw()->toInstruction()->resumePoint()->pc());
@@ -2945,42 +2908,16 @@ CodeGenerator::visitUnaryCache(LUnaryCac
     LiveRegisterSet liveRegs = lir->safepoint()->liveRegs();
     TypedOrValueRegister input = TypedOrValueRegister(ToValue(lir, LUnaryCache::Input));
     ValueOperand output = ToOutValue(lir);
 
     IonUnaryArithIC ic(liveRegs, input, output);
     addIC(lir, allocateIC(ic));
 }
 
-void
-CodeGenerator::visitNullarySharedStub(LNullarySharedStub* lir)
-{
-    jsbytecode* pc = lir->mir()->resumePoint()->pc();
-    JSOp jsop = JSOp(*pc);
-    switch (jsop) {
-      case JSOP_NEWARRAY: {
-        uint32_t length = GET_UINT32(pc);
-        MOZ_ASSERT(length <= INT32_MAX,
-                   "the bytecode emitter must fail to compile code that would "
-                   "produce JSOP_NEWARRAY with a length exceeding int32_t range");
-
-        // Pass length in R0.
-        masm.move32(Imm32(AssertedCast<int32_t>(length)), R0.scratchReg());
-        emitSharedStub(ICStub::Kind::NewArray_Fallback, lir);
-        break;
-      }
-      case JSOP_NEWINIT:
-      case JSOP_NEWOBJECT:
-        emitSharedStub(ICStub::Kind::NewObject_Fallback, lir);
-        break;
-      default:
-        MOZ_CRASH("Unsupported jsop in shared stubs.");
-    }
-}
-
 typedef JSFunction* (*MakeDefaultConstructorFn)(JSContext*, HandleScript,
                                                 jsbytecode*, HandleObject);
 static const VMFunction MakeDefaultConstructorInfo =
     FunctionInfo<MakeDefaultConstructorFn>(js::MakeDefaultConstructor,
                                            "MakeDefaultConstructor");
 
 void
 CodeGenerator::visitClassConstructor(LClassConstructor* lir)
--- a/js/src/jit/CodeGenerator.h
+++ b/js/src/jit/CodeGenerator.h
@@ -108,17 +108,16 @@ class CodeGenerator final : public CodeG
 
     void visitOutOfLineCallPostWriteBarrier(OutOfLineCallPostWriteBarrier* ool);
     void visitOutOfLineCallPostWriteElementBarrier(OutOfLineCallPostWriteElementBarrier* ool);
 
     void visitOutOfLineNewArray(OutOfLineNewArray* ool);
     void visitOutOfLineNewObject(OutOfLineNewObject* ool);
 
   private:
-    void emitSharedStub(ICStub::Kind kind, LInstruction* lir);
 
     void emitPostWriteBarrier(const LAllocation* obj);
     void emitPostWriteBarrier(Register objreg);
     void emitPostWriteBarrierS(Address address, Register prev, Register next);
 
     template <class LPostBarrierType, MIRType nurseryType>
     void visitPostWriteBarrierCommon(LPostBarrierType* lir, OutOfLineCode* ool);
     template <class LPostBarrierType>
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -6484,20 +6484,17 @@ IonBuilder::initializeArrayElement(MDefi
 
     // Get the elements vector.
     MElements* elements = MElements::New(alloc(), obj);
     current->add(elements);
 
     if (needsPostBarrier(value))
         current->add(MPostWriteBarrier::New(alloc(), obj, value));
 
-    if ((obj->isNewArray() && obj->toNewArray()->convertDoubleElements()) ||
-        (obj->isNullarySharedStub() &&
-         obj->resultTypeSet()->convertDoubleElements(constraints()) == TemporaryTypeSet::AlwaysConvertToDoubles))
-    {
+    if (obj->isNewArray() && obj->toNewArray()->convertDoubleElements()) {
         MInstruction* valueDouble = MToDouble::New(alloc(), value);
         current->add(valueDouble);
         value = valueDouble;
     }
 
     // Store the value.
     MStoreElement* store = MStoreElement::New(alloc(), elements, id, value,
                                               /* needsHoleCheck = */ false);
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -2536,27 +2536,16 @@ LIRGenerator::visitUnaryCache(MUnaryCach
     MOZ_ASSERT(ins->type() == MIRType::Value);
 
     LUnaryCache* lir = new(alloc()) LUnaryCache(useBox(input));
     defineBox(lir, ins);
     assignSafepoint(lir, ins);
 }
 
 void
-LIRGenerator::visitNullarySharedStub(MNullarySharedStub* ins)
-{
-    MOZ_ASSERT(ins->type() == MIRType::Value);
-
-    LNullarySharedStub* lir = new(alloc()) LNullarySharedStub();
-
-    defineSharedStubReturn(lir, ins);
-    assignSafepoint(lir, ins);
-}
-
-void
 LIRGenerator::visitClassConstructor(MClassConstructor* ins)
 {
     LClassConstructor* lir = new(alloc()) LClassConstructor();
     defineReturn(lir, ins);
     assignSafepoint(lir, ins);
 }
 
 void
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -7138,30 +7138,16 @@ class MUnaryCache
         setResultType(MIRType::Value);
     }
 
   public:
     INSTRUCTION_HEADER(UnaryCache)
     TRIVIAL_NEW_WRAPPERS
 };
 
-class MNullarySharedStub
-  : public MNullaryInstruction
-{
-    explicit MNullarySharedStub()
-      : MNullaryInstruction(classOpcode)
-    {
-        setResultType(MIRType::Value);
-    }
-
-  public:
-    INSTRUCTION_HEADER(NullarySharedStub)
-    TRIVIAL_NEW_WRAPPERS
-};
-
 // Check the current frame for over-recursion past the global stack limit.
 class MCheckOverRecursed
   : public MNullaryInstruction
 {
     MCheckOverRecursed()
       : MNullaryInstruction(classOpcode)
     { }
 
--- a/js/src/jit/shared/LIR-shared.h
+++ b/js/src/jit/shared/LIR-shared.h
@@ -4839,30 +4839,16 @@ class LUnaryCache : public LInstructionH
 
     const LAllocation* input() {
         return getOperand(Input);
     }
 
     static const size_t Input = 0;
 };
 
-class LNullarySharedStub : public LCallInstructionHelper<BOX_PIECES, 0, 0>
-{
-  public:
-    LIR_HEADER(NullarySharedStub)
-
-    const MNullarySharedStub* mir() const {
-        return mir_->toNullarySharedStub();
-    }
-
-    LNullarySharedStub()
-      : LCallInstructionHelper(classOpcode)
-    {}
-};
-
 class LClassConstructor : public LCallInstructionHelper<1, 0, 0>
 {
   public:
     LIR_HEADER(ClassConstructor)
 
     const MClassConstructor* mir() const {
         return mir_->toClassConstructor();
     }
--- a/js/src/jit/shared/Lowering-shared-inl.h
+++ b/js/src/jit/shared/Lowering-shared-inl.h
@@ -241,40 +241,16 @@ LIRGeneratorShared::defineInt64(LInstruc
 #endif
     lir->setMir(mir);
 
     mir->setVirtualRegister(vreg);
     add(lir);
 }
 
 void
-LIRGeneratorShared::defineSharedStubReturn(LInstruction* lir, MDefinition* mir)
-{
-    lir->setMir(mir);
-
-    MOZ_ASSERT(lir->isNullarySharedStub());
-    MOZ_ASSERT(mir->type() == MIRType::Value);
-
-    uint32_t vreg = getVirtualRegister();
-
-#if defined(JS_NUNBOX32)
-    lir->setDef(TYPE_INDEX, LDefinition(vreg + VREG_TYPE_OFFSET, LDefinition::TYPE,
-                                        LGeneralReg(JSReturnReg_Type)));
-    lir->setDef(PAYLOAD_INDEX, LDefinition(vreg + VREG_DATA_OFFSET, LDefinition::PAYLOAD,
-                                           LGeneralReg(JSReturnReg_Data)));
-    getVirtualRegister();
-#elif defined(JS_PUNBOX64)
-    lir->setDef(0, LDefinition(vreg, LDefinition::BOX, LGeneralReg(JSReturnReg)));
-#endif
-
-    mir->setVirtualRegister(vreg);
-    add(lir);
-}
-
-void
 LIRGeneratorShared::defineReturn(LInstruction* lir, MDefinition* mir)
 {
     lir->setMir(mir);
 
     MOZ_ASSERT(lir->isCall());
     gen->setNeedsStaticStackAlignment();
 
     uint32_t vreg = getVirtualRegister();
--- a/js/src/jit/shared/Lowering-shared.h
+++ b/js/src/jit/shared/Lowering-shared.h
@@ -171,17 +171,16 @@ class LIRGeneratorShared
     template <size_t Ops, size_t Temps>
     inline void defineInt64Fixed(LInstructionHelper<INT64_PIECES, Ops, Temps>* lir, MDefinition* mir,
                                  const LInt64Allocation& output);
 
     template <size_t Ops, size_t Temps>
     inline void defineSinCos(LInstructionHelper<2, Ops, Temps> *lir, MDefinition *mir,
                              LDefinition::Policy policy = LDefinition::REGISTER);
 
-    inline void defineSharedStubReturn(LInstruction* lir, MDefinition* mir);
     inline void defineReturn(LInstruction* lir, MDefinition* mir);
 
     template <size_t X>
     inline void define(details::LInstructionFixedDefsTempsHelper<1, X>* lir, MDefinition* mir,
                        LDefinition::Policy policy = LDefinition::REGISTER);
     template <size_t X>
     inline void define(details::LInstructionFixedDefsTempsHelper<1, X>* lir, MDefinition* mir,
                        const LDefinition& def);