Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Jsrt/ChakraCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ JsGetModuleHostInfo(
_In_ JsModuleHostInfoKind moduleHostInfo,
_Outptr_result_maybenull_ void** hostInfo);

#ifdef CHAKRACOREBUILD_
/// <summary>
/// Called by the runtime to load the source code of the serialized script.
/// </summary>
Expand Down Expand Up @@ -493,5 +494,5 @@ CHAKRA_API
_In_ JsSourceContext sourceContext,
_In_ JsValueRef sourceUrl,
_Out_ JsValueRef *result);

#endif // CHAKRACOREBUILD_
#endif // _CHAKRACORE_H_
5 changes: 5 additions & 0 deletions lib/Runtime/Language/AsmJsModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,11 @@ namespace Js
AsmJsFunc* AsmJsModuleCompiler::CreateNewFunctionEntry( ParseNode* pnodeFnc )
{
PropertyName name = ParserWrapper::FunctionName( pnodeFnc );
if ( !name )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name [](start = 14, length = 4)

Do we need use a default name like 'anonymous function' for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this should be invalid asm.js. Returning null here will invalidate the asm.js module and then be parsed as normal javascript

{
return nullptr;
}

GetByteCodeGenerator()->AssignPropertyId(name);
AsmJsFunc* func = Anew( &mAllocator, AsmJsFunc, name, pnodeFnc, &mAllocator, mCx->scriptContext );
if( func )
Expand Down
11 changes: 11 additions & 0 deletions test/AsmJs/bugGH2270.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

(function() {
"use asm";
(function(){});
})();

print("Pass");
3 changes: 3 additions & 0 deletions test/AsmJs/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -813,5 +813,8 @@
<baseline>vardeclnorhs.baseline</baseline>
<compile-flags>-testtrace:asmjs -maic:1</compile-flags>
</default>
<default>
<files>bugGH2270.js</files>
</default>
</test>
</regress-exe>