Skip to content

Commit aa85680

Browse files
committed
Force SharedBailOutKind to be true on the BailOutInfo of CheckFuncInfo instrs; stop GC of BailOutInfo with SharedBailOutKind.
1 parent 6f09895 commit aa85680

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

lib/Backend/IR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ Instr::ReplaceBailOutInfo(BailOutInfo *newBailOutInfo)
12811281
__assume(UNREACHED);
12821282
}
12831283

1284-
if (oldBailOutInfo->bailOutInstr == this)
1284+
if (oldBailOutInfo->bailOutInstr == this && !oldBailOutInfo->sharedBailOutKind)
12851285
{
12861286
Assert(!oldBailOutInfo->wasCloned && !oldBailOutInfo->wasCopied);
12871287
JitArenaAllocator * alloc = this->m_func->m_alloc;

lib/Backend/Inline.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4632,7 +4632,7 @@ Inline::PrepareInsertionPoint(IR::Instr *callInstr, const FunctionJITTimeInfo *f
46324632
Assert(insertBeforeInstr);
46334633
Assert(insertBeforeInstr->m_func == callInstr->m_func);
46344634

4635-
IR::Instr *checkFuncInfo = IR::BailOutInstr::New(Js::OpCode::CheckFuncInfo, IR::BailOutOnInlineFunction, insertBeforeInstr, callInstr->m_func);
4635+
IR::Instr* checkFuncInfo = IR::BailOutInstr::New(Js::OpCode::CheckFuncInfo, IR::BailOutOnInlineFunction, insertBeforeInstr, callInstr->m_func);
46364636
checkFuncInfo->SetSrc1(callInstr->GetSrc1()->AsRegOpnd());
46374637

46384638
IR::AddrOpnd* inlinedFuncInfo = IR::AddrOpnd::New(funcInfo->GetFunctionInfoAddr(), IR::AddrOpndKindDynamicFunctionInfo, insertBeforeInstr->m_func);
@@ -4641,6 +4641,10 @@ Inline::PrepareInsertionPoint(IR::Instr *callInstr, const FunctionJITTimeInfo *f
46414641
checkFuncInfo->SetByteCodeOffset(insertBeforeInstr);
46424642
insertBeforeInstr->InsertBefore(checkFuncInfo);
46434643

4644+
// checkFuncInfo can be hoisted later and then have its BailOutInfo garbage collected. Other instructions (ex: BailOnNotStackArgs) share
4645+
// checkFuncInfo's BailOutInfo. Explicitly force sharedBailOutKind to be true to stop this BailOutInfo from being garbage collected.
4646+
checkFuncInfo->ShareBailOut();
4647+
46444648
return checkFuncInfo;
46454649
}
46464650

test/FixedFields/NonFixedFieldHoist.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,42 @@ catch(e)
4242
{
4343
WScript.Echo(e);
4444
}
45+
46+
// Will hoist CheckFuncInfo instr
47+
// and then GC its BailOutInfo.
48+
function test0() {
49+
var obj0 = {};
50+
var obj1 = {};
51+
var func2 = function () {
52+
};
53+
var func4 = function () {
54+
for (var _strvar2 in ary) {
55+
function v0() {
56+
throw '';
57+
}
58+
function v2() {
59+
var v3 = 0;
60+
for (var _strvar0 in f32) {
61+
if (v3++) {
62+
func2.apply(obj1, arguments);
63+
v0();
64+
}
65+
}
66+
}
67+
try {
68+
v2();
69+
} catch (ex) {
70+
}
71+
}
72+
};
73+
obj0.method0 = func4;
74+
var ary = Array();
75+
var f32 = new Float32Array(256);
76+
ary[0] = 1;
77+
ary[1] = 1;
78+
function v14() {
79+
var v15 = obj0.method0();
80+
}
81+
v14();
82+
}
83+
test0();

test/inlining/InlineCallbackCallBailout.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ foo
88
INLINING : Found callback def instr for call/apply target callback at CallSite: 0 Caller: Dispatch ( (#1.5), #6)
99
INLINING CALLBACK : Inlining callback for call/apply target : foo ( (#1.4), #5)
1010
foo
11-
BailOut: function Dispatch, Opcode: BailOnNotEqual Kind: BailOutOnInlineFunction
11+
BailOut: function Dispatch, Opcode: BailTarget Kind: BailOutOnInlineFunction
1212
bar
1313
BailOut: function CallDispatch, Opcode: InlineeEnd Kind: BailOutOnInlineFunction
1414
foo

0 commit comments

Comments
 (0)