Skip to content

Commit f5e33d5

Browse files
committed
[MERGE #5247 @boingoing] Fix redeferral for deserialized DeferDeserializeFunctionInfo functions
Merge pull request #5247 from boingoing:deferdeserialize_redeferral When DeferDeserializeFunctionInfo transitions into a FunctionBody during Deserialize, the deferredPrototypeType and undeferredFunctionType from FunctionProxy are not copied into the FunctionBody because copying them is only done in ParseableFunctionInfo::Copy (DeferDeserializeFunctionInfo does not call this). If the FunctionBody is then redeferred, we'll fail to reset the type since it wasn't saved. Fix is to copy these two fields in FunctionProxy::Copy which is called by DeferDeserializeFunctionInfo::Deserialize.
2 parents 05331f9 + 5e93b03 commit f5e33d5

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/Runtime/Base/FunctionBody.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,11 @@ namespace Js
14331433
{
14341434
other->SetIsJsBuiltInCode();
14351435
}
1436+
1437+
#define CopyDeferParseField(field) other->field = this->field;
1438+
CopyDeferParseField(deferredPrototypeType);
1439+
CopyDeferParseField(undeferredFunctionType);
1440+
#undef CopyDeferParseField
14361441
}
14371442

14381443
void ParseableFunctionInfo::Copy(ParseableFunctionInfo * other)
@@ -1466,8 +1471,6 @@ namespace Js
14661471
other->SetCachedSourceStringWeakRef(this->GetCachedSourceStringWeakRef());
14671472
CopyDeferParseField(m_isAsmjsMode);
14681473
CopyDeferParseField(m_isAsmJsFunction);
1469-
CopyDeferParseField(deferredPrototypeType);
1470-
CopyDeferParseField(undeferredFunctionType);
14711474

14721475
other->SetFunctionObjectTypeList(this->GetFunctionObjectTypeList());
14731476

test/Function/bug_os17698041.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
// Should not crash with switches:
7+
// -off:deferparse -force:redeferral -collectgarbage -parserstatecache -useparserstatecache
8+
9+
function test() { }
10+
11+
test();
12+
CollectGarbage();
13+
test();
14+
15+
console.log('pass');

test/Function/rlexe.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,4 +449,10 @@
449449
<compile-flags>-force:deferparse -force:redeferral</compile-flags>
450450
</default>
451451
</test>
452+
<test>
453+
<default>
454+
<files>bug_os17698041.js</files>
455+
<compile-flags>-off:deferparse -force:redeferral -collectgarbage -parserstatecache -useparserstatecache</compile-flags>
456+
</default>
457+
</test>
452458
</regress-exe>

0 commit comments

Comments
 (0)