Преглед на файлове

Fix arm stack offset computation in the presence of inlining and try

Fixes OS#14210293
meg-gupta преди 8 години
родител
ревизия
005965b683
променени са 6 файла, в които са добавени 60 реда и са изтрити 26 реда
  1. 7 5
      lib/Backend/arm/EncoderMD.cpp
  2. 6 8
      lib/Backend/arm/LowerMD.cpp
  3. 7 6
      lib/Backend/arm64/EncoderMD.cpp
  4. 7 7
      lib/Backend/arm64/LowerMD.cpp
  5. 28 0
      test/EH/ehinlinearmbug.js
  6. 5 0
      test/EH/rlexe.xml

+ 7 - 5
lib/Backend/arm/EncoderMD.cpp

@@ -2205,16 +2205,18 @@ EncoderMD::BaseAndOffsetFromSym(IR::SymOpnd *symOpnd, RegNum *pBaseReg, int32 *p
 
     RegNum baseReg = func->GetLocalsPointer();
     int32 offset = stackSym->m_offset + symOpnd->m_offset;
+
     if (baseReg == RegSP)
     {
         // SP points to the base of the argument area. Non-reg SP points directly to the locals.
         offset += (func->m_argSlotsForFunctionsCalled * MachRegInt);
-        if (func->HasInlinee())
+    }
+
+    if (func->HasInlinee())
+    {
+        if ((!stackSym->IsArgSlotSym() || stackSym->m_isOrphanedArg) && !stackSym->IsParamSlotSym())
         {
-            if ((!stackSym->IsArgSlotSym() || stackSym->m_isOrphanedArg) && !stackSym->IsParamSlotSym())
-            {
-                offset += func->GetInlineeArgumentStackSize();
-            }
+            offset += func->GetInlineeArgumentStackSize();
         }
     }
 

+ 6 - 8
lib/Backend/arm/LowerMD.cpp

@@ -1051,7 +1051,12 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
 //    }
 //#endif
 
-
+    if (this->m_func->HasInlinee())
+    {
+        // Allocate the inlined arg out stack in the locals. Allocate an additional slot so that
+        // we can unconditionally clear the first slot past the current frame.
+        this->m_func->m_localStackHeight += this->m_func->GetInlineeArgumentStackSize();
+    }
     //First calculate the local stack
     if (hasTry)
     {
@@ -1062,13 +1067,6 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
         this->m_func->m_localStackHeight = Math::Align<int32>(this->m_func->m_localStackHeight, MachStackAlignment);
     }
 
-    if (this->m_func->HasInlinee())
-    {
-        // Allocate the inlined arg out stack in the locals. Allocate an additional slot so that
-        // we can unconditionally clear the first slot past the current frame.
-        this->m_func->m_localStackHeight += this->m_func->GetInlineeArgumentStackSize();
-    }
-
     int32 stackAdjust = this->m_func->m_localStackHeight + (this->m_func->m_argSlotsForFunctionsCalled * MachPtr);
     if (stackAdjust != 0)
     {

+ 7 - 6
lib/Backend/arm64/EncoderMD.cpp

@@ -1374,13 +1374,14 @@ EncoderMD::BaseAndOffsetFromSym(IR::SymOpnd *symOpnd, RegNum *pBaseReg, int32 *p
     {
         // SP points to the base of the argument area. Non-reg SP points directly to the locals.
         offset += (func->m_argSlotsForFunctionsCalled * MachRegInt);
-        if (func->HasInlinee())
+    }
+
+    if (func->HasInlinee())
+    {
+        Assert(func->HasInlinee());
+        if ((!stackSym->IsArgSlotSym() || stackSym->m_isOrphanedArg) && !stackSym->IsParamSlotSym())
         {
-            Assert(func->HasInlinee());
-            if ((!stackSym->IsArgSlotSym() || stackSym->m_isOrphanedArg) && !stackSym->IsParamSlotSym())
-            {
-                offset += func->GetInlineeArgumentStackSize();
-            }
+            offset += func->GetInlineeArgumentStackSize();
         }
     }
 

+ 7 - 7
lib/Backend/arm64/LowerMD.cpp

@@ -953,6 +953,13 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
     UnwindInfoManager *unwindInfo = &this->m_func->m_unwindInfo;
     unwindInfo->Init(this->m_func);
 
+    if (this->m_func->HasInlinee())
+    {
+        // Allocate the inlined arg out stack in the locals. Allocate an additional slot so that
+        // we can unconditionally clear the first slot past the current frame.
+        this->m_func->m_localStackHeight += this->m_func->GetInlineeArgumentStackSize();
+    }
+
     //First calculate the local stack
     if (hasTry)
     {
@@ -963,13 +970,6 @@ LowererMD::LowerEntryInstr(IR::EntryInstr * entryInstr)
         this->m_func->m_localStackHeight = Math::Align<int32>(this->m_func->m_localStackHeight, MachStackAlignment);
     }
 
-    if (this->m_func->HasInlinee())
-    {
-        // Allocate the inlined arg out stack in the locals. Allocate an additional slot so that
-        // we can unconditionally clear the first slot past the current frame.
-        this->m_func->m_localStackHeight += this->m_func->GetInlineeArgumentStackSize();
-    }
-
     int32 stackAdjust = this->m_func->m_localStackHeight + (this->m_func->m_argSlotsForFunctionsCalled * MachPtr);
     if (stackAdjust != 0)
     {

+ 28 - 0
test/EH/ehinlinearmbug.js

@@ -0,0 +1,28 @@
+//-------------------------------------------------------------------------------------------------------
+// Copyright (C) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
+//-------------------------------------------------------------------------------------------------------
+
+var obj0 = {};
+var arrObj0 = {};
+var litObj0 = {};
+var func0 = function () {
+};
+var i16 = new Int16Array(256);
+var ui16 = new Uint16Array();
+var func5 = function () {
+};
+
+for (var _strvar0 of i16) {
+  (function () {
+     try {} 
+     catch (ex) {
+     }
+     function func23() {
+     }
+     var uniqobj9 = new func23();
+     arrObj0.prop6 = (func5(+Infinity, ui16[func5(obj0, func0, Error(), litObj0, func5()) & 255]));
+  }());
+}
+
+WScript.Echo("Passed");

+ 5 - 0
test/EH/rlexe.xml

@@ -155,4 +155,9 @@
       <files>asyncintrystackwalkbug.js</files>
     </default>
   </test>
+  <test>
+    <default>
+      <files>ehinlinearmbug.js</files>
+    </default>
+  </test>
 </regress-exe>