Sfoglia il codice sorgente

Insert StatementBoundary at the right position for polymorphic inlining

Since polymorphic inlining using fixed methods emits a helper block in the
inliner itself, the inliner should emit a StatementBoundary for the helper
block so that it stays with the block if/when the block gets moved around
in the flowgraph builder and/or globopt.
Rajat Dua 9 anni fa
parent
commit
97b2764d55

+ 1 - 0
lib/Backend/Inline.cpp

@@ -864,6 +864,7 @@ Inline::InlinePolymorphicFunctionUsingFixedMethods(IR::Instr *callInstr, const J
 
     this->topFunc->SetHasInlinee();
     InsertStatementBoundary(instrNext);
+    InsertStatementBoundary(ldMethodFldInstr);
 
     return instrNext;
 }

+ 4 - 0
test/inlining/polyInliningFixedMethods.baseline

@@ -7,3 +7,7 @@ a
 b1
 f
 f
+TypeError: Unable to get property 'method0' of undefined or null reference
+	at v15 (polyinliningfixedmethods.js:94:7)
+	at func3 (polyinliningfixedmethods.js:99:3)
+	at Global code (polyinliningfixedmethods.js:104:3)

+ 47 - 1
test/inlining/polyInliningFixedMethods.js

@@ -3,6 +3,22 @@
 // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 //-------------------------------------------------------------------------------------------------------
 
+if (this.WScript && this.WScript.LoadScriptFile) {
+    this.WScript.LoadScriptFile("TrimStackTracePath.js");
+}
+
+function Dump(output)
+{
+  if (this.WScript)
+  {
+    WScript.Echo(output);
+  }
+  else
+  {
+    alert(output);
+  }
+}
+
 function a() { }
 a.prototype.x = function () { WScript.Echo(1); this.y(); };
 a.prototype.y = function () { WScript.Echo("a"); };
@@ -58,4 +74,34 @@ foo(d1);
 foo(a1);
 foo(b1);
 foo(c1);
-foo(d1);
+foo(d1);
+
+var obj1 = {};
+var func3 = function () {
+  function v6() {
+  }
+  v6.prototype.method0 = function () {
+  };
+  var v7 = new v6();
+  function v8() {
+  }
+  v8.method0 = function () {
+  };
+  v6.prototype = v8;
+  var v9 = new v6();
+  function v15(v16) {
+    for (var v18 = 0; v18 < 2; v18++) {
+      v16.method0();
+    }
+  }
+  v15(v7);
+  v15(v9);
+  v15();
+};
+
+obj1.method1 = func3;
+try {
+  obj1.method1();
+} catch(e) {
+  Dump(TrimStackTracePath(e.stack));
+}

+ 1 - 1
test/inlining/rlexe.xml

@@ -127,7 +127,7 @@
     <default>
       <files>polyInliningFixedMethods.js</files>
       <baseline>polyInliningFixedMethods.baseline</baseline>
-      <compile-flags>-maxInterpretCount:1 -maxSimpleJitRunCount:1</compile-flags>
+      <compile-flags>-maxInterpretCount:1 -maxSimpleJitRunCount:1 -extendederrorstackfortesthost</compile-flags>
     </default>
   </test>
   <test>