[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}
This commit is contained in:
bradnelson 2016-12-08 00:52:33 -08:00 committed by Commit bot
parent 6505e02266
commit c4f9e42934
2 changed files with 20 additions and 3 deletions

View File

@ -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});
}
}
}

View File

@ -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);