Skip to content

Commit 97b2764

Browse files
committed
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.
1 parent 333f98a commit 97b2764

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

lib/Backend/Inline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ Inline::InlinePolymorphicFunctionUsingFixedMethods(IR::Instr *callInstr, const J
864864

865865
this->topFunc->SetHasInlinee();
866866
InsertStatementBoundary(instrNext);
867+
InsertStatementBoundary(ldMethodFldInstr);
867868

868869
return instrNext;
869870
}

test/inlining/polyInliningFixedMethods.baseline

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ a
77
b1
88
f
99
f
10+
TypeError: Unable to get property 'method0' of undefined or null reference
11+
at v15 (polyinliningfixedmethods.js:94:7)
12+
at func3 (polyinliningfixedmethods.js:99:3)
13+
at Global code (polyinliningfixedmethods.js:104:3)

test/inlining/polyInliningFixedMethods.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55

6+
if (this.WScript && this.WScript.LoadScriptFile) {
7+
this.WScript.LoadScriptFile("TrimStackTracePath.js");
8+
}
9+
10+
function Dump(output)
11+
{
12+
if (this.WScript)
13+
{
14+
WScript.Echo(output);
15+
}
16+
else
17+
{
18+
alert(output);
19+
}
20+
}
21+
622
function a() { }
723
a.prototype.x = function () { WScript.Echo(1); this.y(); };
824
a.prototype.y = function () { WScript.Echo("a"); };
@@ -58,4 +74,34 @@ foo(d1);
5874
foo(a1);
5975
foo(b1);
6076
foo(c1);
61-
foo(d1);
77+
foo(d1);
78+
79+
var obj1 = {};
80+
var func3 = function () {
81+
function v6() {
82+
}
83+
v6.prototype.method0 = function () {
84+
};
85+
var v7 = new v6();
86+
function v8() {
87+
}
88+
v8.method0 = function () {
89+
};
90+
v6.prototype = v8;
91+
var v9 = new v6();
92+
function v15(v16) {
93+
for (var v18 = 0; v18 < 2; v18++) {
94+
v16.method0();
95+
}
96+
}
97+
v15(v7);
98+
v15(v9);
99+
v15();
100+
};
101+
102+
obj1.method1 = func3;
103+
try {
104+
obj1.method1();
105+
} catch(e) {
106+
Dump(TrimStackTracePath(e.stack));
107+
}

test/inlining/rlexe.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<default>
128128
<files>polyInliningFixedMethods.js</files>
129129
<baseline>polyInliningFixedMethods.baseline</baseline>
130-
<compile-flags>-maxInterpretCount:1 -maxSimpleJitRunCount:1</compile-flags>
130+
<compile-flags>-maxInterpretCount:1 -maxSimpleJitRunCount:1 -extendederrorstackfortesthost</compile-flags>
131131
</default>
132132
</test>
133133
<test>

0 commit comments

Comments
 (0)