Commit c4f9e429 authored by bradnelson's avatar bradnelson Committed by Commit bot

[wasm][asm.js] Utf8 encode exported function names.

BUG=672047
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2555203002
Cr-Commit-Position: refs/heads/master@{#41576}
parent 6505e022
......@@ -714,11 +714,13 @@ class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
Literal* name = prop->key()->AsLiteral();
DCHECK_NOT_NULL(name);
DCHECK(name->IsPropertyName());
const AstRawString* raw_name = name->AsRawPropertyName();
Handle<String> function_name = name->AsPropertyName();
int length;
std::unique_ptr<char[]> utf8 = function_name->ToCString(
DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length);
if (var->is_function()) {
WasmFunctionBuilder* function = LookupOrInsertFunction(var);
function->ExportAs({reinterpret_cast<const char*>(raw_name->raw_data()),
raw_name->length()});
function->ExportAs({utf8.get(), length});
}
}
}
......
......@@ -1497,6 +1497,21 @@ assertWasm(-34359738370.75, TestNegativeDouble);
})();
(function TestUnicodeExportKey() {
function Module() {
"use asm";
function func() {
return 42;
}
return {"\u00d1\u00e6": func};
}
var m = Module(stdlib);
assertEquals(42, m.Ñæ());
assertValidAsm(Module);
})();
function TestAndIntAndHeapValue(stdlib, foreign, buffer) {
"use asm";
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