Commit 582cddde authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm][asm.js] Require exported asm.js functions have be names.

The asm.js spec requires exports to be identifiers,
this was DCHECKED in the asm-wasm-builder, but not the typer.

BUG=672046
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2552913004
Cr-Commit-Position: refs/heads/master@{#41557}
parent ebe94192
...@@ -935,6 +935,10 @@ AsmType* AsmTyper::ValidateExport(ReturnStatement* exports) { ...@@ -935,6 +935,10 @@ AsmType* AsmTyper::ValidateExport(ReturnStatement* exports) {
"Only normal object properties may be used in the export object " "Only normal object properties may be used in the export object "
"literal."); "literal.");
} }
if (!prop->key()->AsLiteral()->IsPropertyName()) {
FAIL(prop->key(),
"Exported functions must have valid identifier names.");
}
auto* export_obj = prop->value()->AsVariableProxy(); auto* export_obj = prop->value()->AsVariableProxy();
if (export_obj == nullptr) { if (export_obj == nullptr) {
......
...@@ -1484,6 +1484,19 @@ assertWasm(-34359738370.75, TestNegativeDouble); ...@@ -1484,6 +1484,19 @@ assertWasm(-34359738370.75, TestNegativeDouble);
})(); })();
(function TestBadExportKey() {
function Module() {
"use asm";
function func() {
}
return {123: func};
}
Module(stdlib);
assertTrue(%IsNotAsmWasmCode(Module));
})();
function TestAndIntAndHeapValue(stdlib, foreign, buffer) { function TestAndIntAndHeapValue(stdlib, foreign, buffer) {
"use asm"; "use asm";
var HEAP32 = new stdlib.Int32Array(buffer); var HEAP32 = new stdlib.Int32Array(buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment