Skip to content

Commit f6ef9d7

Browse files
author
Kevin Smith
committed
[MERGE #6227 @zenparsing] Do not attempt to reuse Utf8SourceInfo if asmjs parse fails
Merge pull request #6227 from zenparsing:asm-error-utf8source-2 Fixes #6222 When an asmjs parse fails, we reparse with asmjs disabled. However, currently we are reusing the same Utf8SourceInfo data, which contains a dictionary of FunctionBody objects. FunctionBody objects that were added in the first parse are still present in the source info dictionary. This causes an assert to fire in `DebugContext.cpp` because it expects there to be only one FunctionBody per source code function. This PR simply discards the old Utf8SourceInfo when an asmjs parse fails. The downside is that the source data has to be re-memcpyd. Another (more complex) solution would be to try to fully clear out the existing Utf8SourceInfo.
2 parents ab68b02 + c90e5dc commit f6ef9d7

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

lib/Runtime/Base/ScriptContext.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,23 +1995,20 @@ namespace Js
19951995
else
19961996
{
19971997
// We do not own the memory passed into DefaultLoadScriptUtf8. We need to save it so we copy the memory.
1998-
if (*ppSourceInfo == nullptr)
1999-
{
20001998
#ifndef NTBUILD
2001-
if (loadScriptFlag & LoadScriptFlag_ExternalArrayBuffer)
2002-
{
2003-
*ppSourceInfo = Utf8SourceInfo::NewWithNoCopy(this,
2004-
script, (int)length, cb, pSrcInfo, isLibraryCode,
2005-
scriptSource);
2006-
}
2007-
else
1999+
if (loadScriptFlag & LoadScriptFlag_ExternalArrayBuffer)
2000+
{
2001+
*ppSourceInfo = Utf8SourceInfo::NewWithNoCopy(this,
2002+
script, (int)length, cb, pSrcInfo, isLibraryCode,
2003+
scriptSource);
2004+
}
2005+
else
20082006
#endif
2009-
{
2010-
// the 'length' here is not correct - we will get the length from the parser - however parser hasn't done yet.
2011-
// Once the parser is done we will update the utf8sourceinfo's lenght correctly with parser's
2012-
*ppSourceInfo = Utf8SourceInfo::New(this, script,
2013-
(int)length, cb, pSrcInfo, isLibraryCode);
2014-
}
2007+
{
2008+
// The 'length' here is not correct (we will get the length from the parser) however parser isn't done yet.
2009+
// Once the parser is done we will update the utf8sourceinfo's length correctly
2010+
*ppSourceInfo = Utf8SourceInfo::New(this, script,
2011+
(int)length, cb, pSrcInfo, isLibraryCode);
20152012
}
20162013
}
20172014
}

lib/Runtime/Base/Utf8SourceInfo.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ namespace Js
148148
}
149149
#endif
150150

151-
void ClearFunctions()
152-
{
153-
if (this->functionBodyDictionary)
154-
{
155-
this->functionBodyDictionary->Clear();
156-
}
157-
}
158-
159151
bool HasFunctions() const
160152
{
161153
return (this->functionBodyDictionary ? this->functionBodyDictionary->Count() > 0 : false);

0 commit comments

Comments
 (0)