diff --git a/src/asmjs/asm-wasm-builder.cc b/src/asmjs/asm-wasm-builder.cc index 30eb0274f9..9415a84521 100644 --- a/src/asmjs/asm-wasm-builder.cc +++ b/src/asmjs/asm-wasm-builder.cc @@ -714,11 +714,13 @@ class AsmWasmBuilderImpl final : public AstVisitor { Literal* name = prop->key()->AsLiteral(); DCHECK_NOT_NULL(name); DCHECK(name->IsPropertyName()); - const AstRawString* raw_name = name->AsRawPropertyName(); + Handle function_name = name->AsPropertyName(); + int length; + std::unique_ptr utf8 = function_name->ToCString( + DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &length); if (var->is_function()) { WasmFunctionBuilder* function = LookupOrInsertFunction(var); - function->ExportAs({reinterpret_cast(raw_name->raw_data()), - raw_name->length()}); + function->ExportAs({utf8.get(), length}); } } } diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js index 3d302c5f7a..dac8cbe497 100644 --- a/test/mjsunit/wasm/asm-wasm.js +++ b/test/mjsunit/wasm/asm-wasm.js @@ -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);