Skip to content

Commit dc487e3

Browse files
committed
[MERGE chakra-core#2257 @Cellule] WASM - misc fixes
Merge pull request chakra-core#2257 from Cellule:users/micfer/wasm/misc Fix an error type when trying to convert int64 from Js value. https://github.com/WebAssembly/design/blob/master/JS.md#towebassemblyvalue I don't know when it was changed, but there is no longer a concept of default namespace for imports https://github.com/WebAssembly/design/blob/master/JS.md#webassemblyinstance-constructor. The steps shows that we should always perform 2 GetProperty to get teh import
2 parents 6a8a129 + 432fd72 commit dc487e3

3 files changed

Lines changed: 8 additions & 19 deletions

File tree

lib/Runtime/Language/AsmJsUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ namespace Js
238238
if (!allowTestInputs)
239239
#endif
240240
{
241-
JavascriptError::ThrowWebAssemblyRuntimeError(scriptContext, WASMERR_InvalidTypeConversion);
241+
JavascriptError::ThrowTypeError(scriptContext, WASMERR_InvalidTypeConversion);
242242
}
243243

244244
#if ENABLE_DEBUG_CONFIG_OPTIONS

lib/Runtime/Library/WebAssemblyInstance.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,14 @@ Var GetImportVariable(Wasm::WasmImport* wi, ScriptContext* ctx, Var ffi)
2222

2323
const char16* name = wi->importName;
2424
uint32 nameLen = wi->importNameLen;
25-
Var prop = nullptr;
26-
if (nameLen > 0)
27-
{
28-
PropertyRecord const * propertyRecord = nullptr;
29-
ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
25+
PropertyRecord const * propertyRecord = nullptr;
26+
ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
3027

31-
if (!RecyclableObject::Is(modProp))
32-
{
33-
JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
34-
}
35-
prop = JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
36-
}
37-
else
28+
if (!RecyclableObject::Is(modProp))
3829
{
39-
// Use only first level if name is missing
40-
prop = modProp;
30+
JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
4131
}
42-
43-
return prop;
32+
return JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
4433
}
4534

4635
WebAssemblyInstance::WebAssemblyInstance(WebAssemblyModule * wasmModule, DynamicType * type) :

test/wasm/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const imports = {
1515
g1: 45,
1616
g2: -8,
1717
},
18-
table: new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})
18+
table: {"": new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})}
1919
};
2020

2121
function overrideImports(overrides) {
2222
return {
2323
test: Object.assign({}, imports.test, overrides),
24-
table: overrides.table || imports.table
24+
table: overrides.table ? {"":overrides.table} : imports.table
2525
};
2626
}
2727

0 commit comments

Comments
 (0)