Parcourir la source

move GenerateLdThisStrict to MI Lowerer

Matt Gardner il y a 8 ans
Parent
commit
c00d96fe06

+ 65 - 2
lib/Backend/Lower.cpp

@@ -1226,7 +1226,7 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
             }
             else
             {
-                 m_lowererMD.GenerateLdThisStrict(instr);
+                 this->GenerateLdThisStrict(instr);
                  instr->Remove();
             }
             break;
@@ -1238,7 +1238,7 @@ Lowerer::LowerRange(IR::Instr *instrStart, IR::Instr *instrEnd, bool defaultDoFa
             break;
 
         case Js::OpCode::StrictCheckThis:
-            m_lowererMD.GenerateLdThisStrict(instr);
+            this->GenerateLdThisStrict(instr);
             instr->FreeSrc1();
             this->GenerateBailOut(instr);
             break;
@@ -20912,6 +20912,69 @@ Lowerer::GenerateLdThisCheck(IR::Instr * instr)
     return true;
 }
 
+//
+// TEST src, Js::AtomTag
+// JNE $done
+// MOV typeReg, objectSrc + offsetof(RecyclableObject::type)
+// CMP [typeReg + offsetof(Type::typeid)], TypeIds_ActivationObject
+// JEQ $helper
+// $done:
+// MOV dst, src
+// JMP $fallthru
+// helper:
+// MOV dst, undefined
+// $fallthru:
+bool
+Lowerer::GenerateLdThisStrict(IR::Instr* instr)
+{
+    IR::RegOpnd * src1 = instr->GetSrc1()->AsRegOpnd();
+    IR::RegOpnd * typeReg = IR::RegOpnd::New(TyMachReg, this->m_func);
+    IR::LabelInstr * done = IR::LabelInstr::New(Js::OpCode::Label, m_func);
+    IR::LabelInstr * fallthru = IR::LabelInstr::New(Js::OpCode::Label, m_func);
+    IR::LabelInstr * helper = IR::LabelInstr::New(Js::OpCode::Label, m_func, /*helper*/true);
+
+    bool assign = instr->GetDst() && !instr->GetDst()->IsEqual(src1);
+    if (!src1->IsNotTaggedValue())
+    {
+        // TEST src1, Js::AtomTag
+        // JNE $done
+        this->m_lowererMD.GenerateObjectTest(src1, instr, assign ? done : fallthru);
+    }
+
+    IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(src1, Js::RecyclableObject::GetOffsetOfType(), TyMachReg, this->m_func);
+    Lowerer::InsertMove(typeReg, indirOpnd, instr);
+
+    IR::IndirOpnd * typeID = IR::IndirOpnd::New(typeReg, Js::Type::GetOffsetOfTypeId(), TyInt32, this->m_func);
+    IR::Opnd * activationObject = IR::IntConstOpnd::New(Js::TypeIds_ActivationObject, TyMachReg, this->m_func);
+    Lowerer::InsertCompare(typeID, activationObject, instr);
+
+    // JEQ $helper
+    Lowerer::InsertBranch(Js::OpCode::BrEq_A, helper, instr);
+
+    if (assign)
+    {
+        // $done:
+        instr->InsertBefore(done);
+
+        // MOV dst, src
+        Lowerer::InsertMove(instr->GetDst(), src1, instr);
+    }
+
+    // JMP $fallthru
+    Lowerer::InsertBranch(Js::OpCode::Br, fallthru, instr);
+
+    instr->InsertBefore(helper);
+    if (instr->GetDst())
+    {
+        // MOV dst, undefined
+        Lowerer::InsertMove(instr->GetDst(), LoadLibraryValueOpnd(instr, LibraryValue::ValueUndefined), instr);
+    }
+    // $fallthru:
+    instr->InsertAfter(fallthru);
+
+    return true;
+}
+
 void Lowerer::GenerateBooleanNegate(IR::Instr * instr, IR::Opnd * srcBool, IR::Opnd * dst)
 {
     // dst = src

+ 1 - 0
lib/Backend/Lower.h

@@ -155,6 +155,7 @@ private:
     void            GenerateIsDynamicObject(IR::RegOpnd *regOpnd, IR::Instr *insertInstr, IR::LabelInstr *labelHelper, bool fContinueLabel = false);
     void            GenerateIsRecyclableObject(IR::RegOpnd *regOpnd, IR::Instr *insertInstr, IR::LabelInstr *labelHelper, bool checkObjectAndDynamicObject = true);
     bool            GenerateLdThisCheck(IR::Instr * instr);
+    bool            GenerateLdThisStrict(IR::Instr * instr);
 
 
 

+ 0 - 69
lib/Backend/LowerMDShared.cpp

@@ -7637,75 +7637,6 @@ bool LowererMD::GenerateFastShiftRight(IR::Instr * instrShift)
     return this->lowererMDArch.GenerateFastShiftRight(instrShift);
 }
 
-//
-// TEST src, Js::AtomTag
-// JNE $done
-// MOV typeReg, objectSrc + offsetof(RecyclableObject::type)
-// CMP [typeReg + offsetof(Type::typeid)], TypeIds_ActivationObject
-// JEQ $helper
-// $done:
-// MOV dst, src
-// JMP $fallthru
-// helper:
-// MOV dst, undefined
-// $fallthru:
-bool
-LowererMD::GenerateLdThisStrict(IR::Instr* instr)
-{
-    IR::RegOpnd * src1 = instr->GetSrc1()->AsRegOpnd();
-    IR::RegOpnd * typeReg = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::LabelInstr * done = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * fallthru = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * helper = IR::LabelInstr::New(Js::OpCode::Label, m_func, /*helper*/true);
-
-    bool assign = instr->GetDst() && !instr->GetDst()->IsEqual(src1);
-    // TEST src1, Js::AtomTag
-    // JNE $done
-    if(!src1->IsNotTaggedValue())
-    {
-        GenerateObjectTest(src1, instr, assign ? done : fallthru);
-    }
-
-    // MOV typeReg, objectSrc + offsetof(RecyclableObject::type)
-    instr->InsertBefore(IR::Instr::New(Js::OpCode::MOV, typeReg,
-        IR::IndirOpnd::New(src1, Js::RecyclableObject::GetOffsetOfType(), TyMachReg, m_func),
-        m_func));
-
-    // CMP [typeReg + offsetof(Type::typeid)], TypeIds_ActivationObject
-    {
-        IR::Instr * cmp = IR::Instr::New(Js::OpCode::CMP, m_func);
-        cmp->SetSrc1(IR::IndirOpnd::New(typeReg, Js::Type::GetOffsetOfTypeId(), TyInt32, m_func));
-        cmp->SetSrc2(IR::IntConstOpnd::New(Js::TypeId::TypeIds_ActivationObject, TyInt32, m_func));
-        instr->InsertBefore(cmp);
-    }
-
-    // JEQ $helper
-    instr->InsertBefore(IR::BranchInstr::New(Js::OpCode::JEQ, helper, m_func));
-
-    if (assign)
-    {
-        // $done:
-        // MOV dst, src
-        instr->InsertBefore(done);
-        instr->InsertBefore(IR::Instr::New(Js::OpCode::MOV, instr->GetDst(), src1, m_func));
-    }
-
-    // JMP $fallthru
-    instr->InsertBefore(IR::BranchInstr::New(Js::OpCode::JMP, fallthru, m_func));
-
-    instr->InsertBefore(helper);
-    if (instr->GetDst())
-    {
-        // MOV dst, undefined
-        instr->InsertBefore(IR::Instr::New(Js::OpCode::MOV, instr->GetDst(),
-            m_lowerer->LoadLibraryValueOpnd(instr, LibraryValue::ValueUndefined), m_func));
-    }
-    // $fallthru:
-    instr->InsertAfter(fallthru);
-
-    return true;
-}
-
 // given object instanceof function, functionReg is a register with function,
 // objectReg is a register with instance and inlineCache is an InstIsInlineCache.
 // We want to generate:

+ 0 - 1
lib/Backend/LowerMDShared.h

@@ -170,7 +170,6 @@ public:
             IR::RegOpnd*    MaterializeConstFromBits(int intConst, IRType type, IR::Instr* instr);
             IR::Opnd*       Subtract2To31(IR::Opnd* src1, IR::Opnd* intMinFP, IRType type, IR::Instr* instr);
             bool            TryGenerateFastMulAdd(IR::Instr * instrAdd, IR::Instr ** pInstrPrev);
-            bool            GenerateLdThisStrict(IR::Instr * instr);
             BVSparse<JitArenaAllocator>* GatherFltTmps();
             void            GenerateFastInlineBuiltInCall(IR::Instr* instr, IR::JnHelperMethod helperMethod);
             void            HelperCallForAsmMathBuiltin(IR::Instr* instr, IR::JnHelperMethod helperMethodFloat, IR::JnHelperMethod helperMethodDouble);

+ 0 - 65
lib/Backend/arm/LowerMD.cpp

@@ -6564,71 +6564,6 @@ LowererMD::EnsureEpilogLabel()
     return labelInstr;
 }
 
-bool
-LowererMD::GenerateLdThisStrict(IR::Instr* insertInstr)
-{
-    IR::RegOpnd * src1 = insertInstr->GetSrc1()->AsRegOpnd();
-    IR::RegOpnd * typeId = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::RegOpnd * type = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::LabelInstr * done = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * fallthrough = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * helper = IR::LabelInstr::New(Js::OpCode::Label, m_func, /*helper*/ true);
-    IR::Instr* instr;
-
-    bool assign = insertInstr->GetDst() && !insertInstr->GetDst()->IsEqual(src1);
-    if (!src1->m_sym->m_isNotInt)
-    {
-        GenerateObjectTest(src1, insertInstr, assign ? done : fallthrough);
-    }
-
-    // LDR r1, [src1 + offset(type)]
-    {
-        IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(src1->AsRegOpnd(), Js::RecyclableObject::GetOffsetOfType(), TyMachReg, this->m_func);
-        Lowerer::InsertMove(type, indirOpnd, insertInstr);
-    }
-
-    // LDR r1, [r1 + offset(typeId)]
-    {
-        IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(type, Js::Type::GetOffsetOfTypeId(), TyMachReg, this->m_func);
-        Lowerer::InsertMove(typeId, indirOpnd, insertInstr);
-    }
-
-    // CMP typeid, TypeIds_ActivationObject
-    instr = IR::Instr::New(Js::OpCode::CMP, this->m_func);
-    instr->SetSrc1(typeId);
-    instr->SetSrc2(IR::IntConstOpnd::New(Js::TypeIds_ActivationObject, TyMachReg, this->m_func));
-    insertInstr->InsertBefore(instr);
-    LegalizeMD::LegalizeInstr(instr, false);
-
-    // BE $helper
-    instr = IR::BranchInstr::New(Js::OpCode::BEQ, helper, this->m_func);
-    insertInstr->InsertBefore(instr);
-
-    if(assign)
-    {
-        //$done:
-        insertInstr->InsertBefore(done);
-
-        // LDR $dest, $src
-        Lowerer::InsertMove(insertInstr->GetDst(), insertInstr->GetSrc1(), insertInstr);
-    }
-
-    // B $fallthrough
-    instr = IR::BranchInstr::New(Js::OpCode::B, fallthrough, this->m_func);
-    insertInstr->InsertBefore(instr);
-
-    insertInstr->InsertBefore(helper);
-    if(insertInstr->GetDst())
-    {
-        // LDR dst, undefined
-        Lowerer::InsertMove(insertInstr->GetDst(), m_lowerer->LoadLibraryValueOpnd(insertInstr, LibraryValue::ValueUndefined), insertInstr);
-    }
-
-    // $fallthrough:
-    insertInstr->InsertAfter(fallthrough);
-    return true;
-}
-
 // given object instanceof function, functionReg is a register with function,
 // objectReg is a register with instance and inlineCache is an InstIsInlineCache.
 // We want to generate:

+ 0 - 1
lib/Backend/arm/LowerMD.h

@@ -128,7 +128,6 @@ public:
             bool            GenerateFastCharAt(Js::BuiltinFunction index, IR::Opnd *dst, IR::Opnd *srcStr, IR::Opnd *srcIndex, IR::Instr *callInstr, IR::Instr *insertInstr,
                 IR::LabelInstr *labelHelper, IR::LabelInstr *doneLabel);
             bool            TryGenerateFastMulAdd(IR::Instr * instrAdd, IR::Instr ** pInstrPrev);
-            bool            GenerateLdThisStrict(IR::Instr* instr);
             void            GenerateFloatTest(IR::RegOpnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr* labelHelper, const bool checkForNullInLoopBody = false);
 
      static void            EmitInt4Instr(IR::Instr *instr);

+ 0 - 65
lib/Backend/arm64/LowerMD.cpp

@@ -6067,71 +6067,6 @@ LowererMD::EnsureEHEpilogLabel()
     return labelInstr;
 }
 
-bool
-LowererMD::GenerateLdThisStrict(IR::Instr* insertInstr)
-{
-    IR::RegOpnd * src1 = insertInstr->GetSrc1()->AsRegOpnd();
-    IR::RegOpnd * typeId = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::RegOpnd * type = IR::RegOpnd::New(TyMachReg, this->m_func);
-    IR::LabelInstr * done = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * fallthrough = IR::LabelInstr::New(Js::OpCode::Label, m_func);
-    IR::LabelInstr * helper = IR::LabelInstr::New(Js::OpCode::Label, m_func, /*helper*/ true);
-    IR::Instr* instr;
-
-    bool assign = insertInstr->GetDst() && !insertInstr->GetDst()->IsEqual(src1);
-    if (!src1->m_sym->m_isNotInt)
-    {
-        GenerateObjectTest(src1, insertInstr, assign ? done : fallthrough);
-    }
-
-    // LDR r1, [src1 + offset(type)]
-    {
-        IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(src1->AsRegOpnd(), Js::RecyclableObject::GetOffsetOfType(), TyMachReg, this->m_func);
-        Lowerer::InsertMove(type, indirOpnd, insertInstr);
-    }
-
-    // LDR r1, [r1 + offset(typeId)]
-    {
-        IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New(type, Js::Type::GetOffsetOfTypeId(), TyInt32, this->m_func);
-        Lowerer::InsertMove(typeId, indirOpnd, insertInstr);
-    }
-
-    // CMP typeid, TypeIds_ActivationObject
-    instr = IR::Instr::New(Js::OpCode::CMP, this->m_func);
-    instr->SetSrc1(typeId);
-    instr->SetSrc2(IR::IntConstOpnd::New(Js::TypeIds_ActivationObject, TyMachReg, this->m_func));
-    insertInstr->InsertBefore(instr);
-    LegalizeMD::LegalizeInstr(instr, false);
-
-    // BE $helper
-    instr = IR::BranchInstr::New(Js::OpCode::BEQ, helper, this->m_func);
-    insertInstr->InsertBefore(instr);
-
-    if(assign)
-    {
-        //$done:
-        insertInstr->InsertBefore(done);
-
-        // LDR $dest, $src
-        Lowerer::InsertMove(insertInstr->GetDst(), insertInstr->GetSrc1(), insertInstr);
-    }
-
-    // B $fallthrough
-    instr = IR::BranchInstr::New(Js::OpCode::B, fallthrough, this->m_func);
-    insertInstr->InsertBefore(instr);
-
-    insertInstr->InsertBefore(helper);
-    if(insertInstr->GetDst())
-    {
-        // LDR dst, undefined
-        Lowerer::InsertMove(insertInstr->GetDst(), m_lowerer->LoadLibraryValueOpnd(insertInstr, LibraryValue::ValueUndefined), insertInstr);
-    }
-
-    // $fallthrough:
-    insertInstr->InsertAfter(fallthrough);
-    return true;
-}
-
 // given object instanceof function, functionReg is a register with function,
 // objectReg is a register with instance and inlineCache is an InstIsInlineCache.
 // We want to generate:

+ 0 - 1
lib/Backend/arm64/LowerMD.h

@@ -126,7 +126,6 @@ public:
             bool            GenerateFastCharAt(Js::BuiltinFunction index, IR::Opnd *dst, IR::Opnd *srcStr, IR::Opnd *srcIndex, IR::Instr *callInstr, IR::Instr *insertInstr,
                 IR::LabelInstr *labelHelper, IR::LabelInstr *doneLabel);
             bool            TryGenerateFastMulAdd(IR::Instr * instrAdd, IR::Instr ** pInstrPrev);
-            bool            GenerateLdThisStrict(IR::Instr* instr);
             void            GenerateFloatTest(IR::RegOpnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr* labelHelper, const bool checkForNullInLoopBody = false);
             IR::RegOpnd*    CheckFloatAndUntag(IR::RegOpnd * opndSrc, IR::Instr * insertInstr, IR::LabelInstr* labelHelper);