Skip to content

Commit

Permalink
[wasm] Bumped DEPS for public js api tests, fixed failures.
Browse files Browse the repository at this point in the history
This also fixes an existing discrepancy.

BUG=v8:6017

Review-Url: https://codereview.chromium.org/2808403002
Cr-Commit-Position: refs/heads/master@{#44590}
  • Loading branch information
mtrofin authored and Commit bot committed Apr 11, 2017
1 parent cb4ceee commit 53908d0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ deps = {
"v8/tools/clang":
Var("chromium_url") + "/chromium/src/tools/clang.git" + "@" + "49df471350a60efaec6951f321dd65475496ba17",
"v8/test/wasm-js":
Var("chromium_url") + "/external/github.com/WebAssembly/spec.git" + "@" + "002e57c86ccf5c80db0de6e40246665340350c43",
Var("chromium_url") + "/external/github.com/WebAssembly/spec.git" + "@" + "7c62b17f547b80c9c717cc6ef3a8aba1e04e4bcb",
}

deps_os = {
Expand Down
40 changes: 22 additions & 18 deletions src/wasm/wasm-module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1455,22 +1455,26 @@ class InstantiationHelper {
std::vector<Handle<JSFunction>> js_wrappers_;
JSToWasmWrapperCache js_to_wasm_cache_;

// Helper routines to print out errors with imports.
void ReportLinkError(const char* error, uint32_t index,
Handle<String> module_name, Handle<String> import_name) {
thrower_->LinkError(
"Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", index,
module_name->length(), module_name->ToCString().get(),
import_name->length(), import_name->ToCString().get(), error);
}

MaybeHandle<Object> ReportLinkError(const char* error, uint32_t index,
Handle<String> module_name) {
thrower_->LinkError("Import #%d module=\"%.*s\" error: %s", index,
module_name->length(), module_name->ToCString().get(),
error);
return MaybeHandle<Object>();
}
// Helper routines to print out errors with imports.
#define ERROR_THROWER_WITH_MESSAGE(TYPE) \
void Report##TYPE(const char* error, uint32_t index, \
Handle<String> module_name, Handle<String> import_name) { \
thrower_->TYPE("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", \
index, module_name->length(), \
module_name->ToCString().get(), import_name->length(), \
import_name->ToCString().get(), error); \
} \
\
MaybeHandle<Object> Report##TYPE(const char* error, uint32_t index, \
Handle<String> module_name) { \
thrower_->TYPE("Import #%d module=\"%.*s\" error: %s", index, \
module_name->length(), module_name->ToCString().get(), \
error); \
return MaybeHandle<Object>(); \
}

ERROR_THROWER_WITH_MESSAGE(LinkError)
ERROR_THROWER_WITH_MESSAGE(TypeError)

// Look up an import value in the {ffi_} object.
MaybeHandle<Object> LookupImport(uint32_t index, Handle<String> module_name,
Expand All @@ -1483,14 +1487,14 @@ class InstantiationHelper {
MaybeHandle<Object> result =
Object::GetPropertyOrElement(ffi_, module_name);
if (result.is_null()) {
return ReportLinkError("module not found", index, module_name);
return ReportTypeError("module not found", index, module_name);
}

Handle<Object> module = result.ToHandleChecked();

// Look up the value in the module.
if (!module->IsJSReceiver()) {
return ReportLinkError("module is not an object or function", index,
return ReportTypeError("module is not an object or function", index,
module_name);
}

Expand Down
24 changes: 15 additions & 9 deletions test/mjsunit/wasm/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,31 @@ function assertConversionError(bytes, imports) {
assertCompileError(builder().addStart(0).toBuffer());
})();

(function TestLinkingError() {
(function TestTypeError() {
let b;

b = builder();
b.addImport("foo", "bar", kSig_v_v);
assertLinkError(b.toBuffer(), {});
assertTypeError(b.toBuffer(), {});

b = builder();
b.addImportedGlobal("foo", "bar", kWasmI32);
assertTypeError(b.toBuffer(), {});

b = builder();
b.addImportedMemory("foo", "bar");
assertTypeError(b.toBuffer(), {});
})();

(function TestLinkingError() {
let b;

b = builder();
b.addImport("foo", "bar", kSig_v_v);
assertLinkError(b.toBuffer(), {foo: {}});
b = builder();
b.addImport("foo", "bar", kSig_v_v);
assertLinkError(b.toBuffer(), {foo: {bar: 9}});

b = builder();
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {});
b = builder();
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {foo: {}});
Expand All @@ -112,9 +121,6 @@ function assertConversionError(bytes, imports) {
b.addImportedGlobal("foo", "bar", kWasmI32);
assertLinkError(b.toBuffer(), {foo: {bar: () => 9}});

b = builder();
b.addImportedMemory("foo", "bar");
assertLinkError(b.toBuffer(), {});
b = builder();
b.addImportedMemory("foo", "bar");
assertLinkError(b.toBuffer(), {foo: {}});
Expand Down
10 changes: 5 additions & 5 deletions test/mjsunit/wasm/js-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ assertErrorMessage(
assertErrorMessage(
() => new Instance(importingModule, {'': {g: () => {}}}), LinkError, '');
assertErrorMessage(
() => new Instance(importingModule, {t: {f: () => {}}}), LinkError, '');
() => new Instance(importingModule, {t: {f: () => {}}}), TypeError, '');

assertTrue(new Instance(emptyModule) instanceof Instance);
assertTrue(new Instance(emptyModule, {}) instanceof Instance);
Expand Down Expand Up @@ -793,23 +793,23 @@ assertInstantiateError(
assertInstantiateError(
[importingModuleBinary, undefined], TypeError, /TODO: error messages?/);
assertInstantiateError(
[importingModuleBinary, {}], LinkError, /TODO: error messages?/);
[importingModuleBinary, {}], TypeError, /TODO: error messages?/);
assertInstantiateError(
[importingModuleBinary, {'': {g: () => {}}}], LinkError,
/TODO: error messages?/);
assertInstantiateError(
[importingModuleBinary, {t: {f: () => {}}}], LinkError,
[importingModuleBinary, {t: {f: () => {}}}], TypeError,
/TODO: error messages?/);
assertInstantiateError(
[memoryImportingModuleBinary, null], TypeError, /TODO: error messages?/);
assertInstantiateError(
[memoryImportingModuleBinary, undefined], TypeError,
/TODO: error messages?/);
assertInstantiateError(
[memoryImportingModuleBinary, {}], LinkError, /TODO: error messages?/);
[memoryImportingModuleBinary, {}], TypeError, /TODO: error messages?/);
assertInstantiateError(
[memoryImportingModuleBinary, {'mod': {'my_memory': scratch_memory}}],
LinkError, /TODO: error messages?/);
TypeError, /TODO: error messages?/);
assertInstantiateError(
[memoryImportingModuleBinary, {'': {'memory': scratch_memory}}], LinkError,
/TODO: error messages?/);
Expand Down
2 changes: 0 additions & 2 deletions test/mjsunit/wasm/jsapi-harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const known_failures = {
'https://bugs.chromium.org/p/v8/issues/detail?id=5507',
"'WebAssembly.Table.prototype.set' method":
'https://bugs.chromium.org/p/v8/issues/detail?id=5507',
"'WebAssembly.Instance' constructor function":
'https://bugs.chromium.org/p/v8/issues/detail?id=6017',
};

let failures = [];
Expand Down

0 comments on commit 53908d0

Please sign in to comment.