Skip to content

Commit bb75362

Browse files
committed
Bug with missing StatementBoundary in native span sequence
When we get rid of the arguments overhead for an inlinee, we are inadvertently missing to add the StatementBoundary for the inlinee call to the native span sequence. If the inlinee throws, this leads to a difference in line numbers in the stack trace between interpreter and jit. Fixed by adding the missing StatementBoundary to the span sequence
1 parent 52f10a4 commit bb75362

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

lib/Backend/Encoder.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ Encoder::Encode()
170170

171171
if (instr->m_opcode == Js::OpCode::InlineeStart)
172172
{
173+
Assert(!instr->isInlineeEntryInstr);
174+
if (pragmaInstr)
175+
{
176+
m_pragmaInstrToRecordMap->Add(pragmaInstr);
177+
pragmaInstr = nullptr;
178+
}
173179
Func* inlinee = instr->m_func;
174180
if (inlinee->frameInfo && inlinee->frameInfo->record)
175181
{

test/inlining/TrimStackTracePath.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function TrimStackTracePath(line) {
7+
return line && line.replace(/\(.+\\test.StackTrace./ig, "(");
8+
}

test/inlining/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,11 @@
226226
<baseline>builtInApplyTarget.baseline</baseline>
227227
</default>
228228
</test>
229+
<test>
230+
<default>
231+
<files>stackTrace.js</files>
232+
<compile-flags>-extendederrorstackfortesthost</compile-flags>
233+
<baseline>stackTrace.baseline</baseline>
234+
</default>
235+
</test>
229236
</regress-exe>

test/inlining/stackTrace.baseline

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ReferenceError: 'argMath5' is undefined
2+
at func0 (stacktrace.js:31:7)
3+
at func4 (stacktrace.js:27:5)
4+
at test0 (stacktrace.js:39:3)
5+
at Global code (stacktrace.js:43:3)

test/inlining/stackTrace.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
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+
22+
function test0() {
23+
var obj0 = {};
24+
25+
var func4 = function () {
26+
var a = ui8;
27+
func0();
28+
};
29+
var func0 = function() {
30+
for (; prop0 < 100; ) {
31+
argMath5;
32+
}
33+
}
34+
obj0.method1 = func4;
35+
var ui8 = new Uint8Array(256);
36+
prop0 = Infinity;
37+
obj0.method1();
38+
prop0 = -1766989739;
39+
obj0.method1();
40+
}
41+
42+
try {
43+
test0();
44+
} catch(e) {
45+
Dump(TrimStackTracePath(e.stack));
46+
}
47+

0 commit comments

Comments
 (0)