diff --git a/src/wasm/module-instantiate.cc b/src/wasm/module-instantiate.cc index e1409952b2..e7d6ba55c8 100644 --- a/src/wasm/module-instantiate.cc +++ b/src/wasm/module-instantiate.cc @@ -1507,15 +1507,15 @@ int InstanceBuilder::ProcessImports(Handle instance) { } case kExternalException: { if (!value->IsWasmExceptionObject()) { - ReportLinkError("exception import requires a WebAssembly.Exception", - index, module_name, import_name); + ReportLinkError("tag import requires a WebAssembly.Tag", index, + module_name, import_name); return -1; } Handle imported_exception = Handle::cast(value); if (!imported_exception->MatchesSignature( module_->exceptions[import.index].sig)) { - ReportLinkError("imported exception does not match the expected type", + ReportLinkError("imported tag does not match the expected type", index, module_name, import_name); return -1; } diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc index a452e51855..c9e1bc433c 100644 --- a/src/wasm/wasm-js.cc +++ b/src/wasm/wasm-js.cc @@ -1408,19 +1408,19 @@ uint32_t GetIterableLength(i::Isolate* isolate, Local context, } // namespace -// WebAssembly.Exception -void WebAssemblyException(const v8::FunctionCallbackInfo& args) { +// WebAssembly.Tag +void WebAssemblyTag(const v8::FunctionCallbackInfo& args) { v8::Isolate* isolate = args.GetIsolate(); i::Isolate* i_isolate = reinterpret_cast(isolate); HandleScope scope(isolate); - ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Exception()"); + ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Tag()"); if (!args.IsConstructCall()) { - thrower.TypeError("WebAssembly.Exception must be invoked with 'new'"); + thrower.TypeError("WebAssembly.Tag must be invoked with 'new'"); return; } if (!args[0]->IsObject()) { - thrower.TypeError("Argument 0 must be an exception type"); + thrower.TypeError("Argument 0 must be a tag type"); return; } @@ -1435,7 +1435,7 @@ void WebAssemblyException(const v8::FunctionCallbackInfo& args) { v8::Local parameters_value; if (!parameters_maybe.ToLocal(¶meters_value) || !parameters_value->IsObject()) { - thrower.TypeError("Argument 0 must be an exception type with 'parameters'"); + thrower.TypeError("Argument 0 must be a tag type with 'parameters'"); return; } Local parameters = parameters_value.As(); @@ -2287,8 +2287,8 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { // Setup Exception if (enabled_features.has_eh()) { - Handle exception_constructor = InstallConstructorFunc( - isolate, webassembly, "Exception", WebAssemblyException); + Handle exception_constructor = + InstallConstructorFunc(isolate, webassembly, "Tag", WebAssemblyTag); context->set_wasm_exception_constructor(*exception_constructor); SetDummyInstanceTemplate(isolate, exception_constructor); JSFunction::EnsureHasInitialMap(exception_constructor); @@ -2349,7 +2349,7 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { void WasmJs::InstallConditionalFeatures(Isolate* isolate, Handle context) { // Exception handling may have been enabled by an origin trial. If so, make - // sure that the {WebAssembly.Exception} constructor is set up. + // sure that the {WebAssembly.Tag} constructor is set up. auto enabled_features = i::wasm::WasmFeatures::FromContext(isolate, context); if (enabled_features.has_eh()) { Handle global = handle(context->global_object(), isolate); @@ -2368,7 +2368,7 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate, } Handle webassembly = Handle::cast(webassembly_obj); // Setup Exception - Handle exception_name = v8_str(isolate, "Exception"); + Handle exception_name = v8_str(isolate, "Tag"); if (JSObject::HasOwnProperty(webassembly, exception_name).FromMaybe(true)) { // The {Exception} constructor already exists, there is nothing more to // do. @@ -2377,14 +2377,14 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate, bool has_prototype = true; Handle exception_constructor = - CreateFunc(isolate, exception_name, WebAssemblyException, has_prototype, + CreateFunc(isolate, exception_name, WebAssemblyTag, has_prototype, SideEffectType::kHasNoSideEffect); exception_constructor->shared().set_length(1); auto result = Object::SetProperty( isolate, webassembly, exception_name, exception_constructor, StoreOrigin::kNamed, Just(ShouldThrow::kDontThrow)); if (result.is_null()) { - // Setting the {Exception} constructor failed. We just bail out. + // Setting the {Tag} constructor failed. We just bail out. return; } // Install the constructor on the context. diff --git a/test/mjsunit/wasm/exceptions-api.js b/test/mjsunit/wasm/exceptions-api.js index 0f30c6e59f..fb3828abdd 100644 --- a/test/mjsunit/wasm/exceptions-api.js +++ b/test/mjsunit/wasm/exceptions-api.js @@ -9,27 +9,27 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function TestImport() { print(arguments.callee.name); - assertThrows(() => new WebAssembly.Exception(), TypeError, - /Argument 0 must be an exception type/); - assertThrows(() => new WebAssembly.Exception({}), TypeError, - /Argument 0 must be an exception type with 'parameters'/); - assertThrows(() => new WebAssembly.Exception({parameters: ['foo']}), TypeError, + assertThrows(() => new WebAssembly.Tag(), TypeError, + /Argument 0 must be a tag type/); + assertThrows(() => new WebAssembly.Tag({}), TypeError, + /Argument 0 must be a tag type with 'parameters'/); + assertThrows(() => new WebAssembly.Tag({parameters: ['foo']}), TypeError, /Argument 0 parameter type at index #0 must be a value type/); - assertThrows(() => new WebAssembly.Exception({parameters: {}}), TypeError, + assertThrows(() => new WebAssembly.Tag({parameters: {}}), TypeError, /Argument 0 contains parameters without 'length'/); - let js_except_i32 = new WebAssembly.Exception({parameters: ['i32']}); - let js_except_v = new WebAssembly.Exception({parameters: []}); + let js_except_i32 = new WebAssembly.Tag({parameters: ['i32']}); + let js_except_v = new WebAssembly.Tag({parameters: []}); let builder = new WasmModuleBuilder(); builder.addImportedException("m", "ex", kSig_v_i); assertDoesNotThrow(() => builder.instantiate({ m: { ex: js_except_i32 }})); assertThrows( () => builder.instantiate({ m: { ex: js_except_v }}), WebAssembly.LinkError, - /imported exception does not match the expected type/); + /imported tag does not match the expected type/); assertThrows( () => builder.instantiate({ m: { ex: js_except_v }}), WebAssembly.LinkError, - /imported exception does not match the expected type/); + /imported tag does not match the expected type/); })(); (function TestExport() { @@ -41,14 +41,14 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex')); assertEquals("object", typeof instance.exports.ex); - assertInstanceof(instance.exports.ex, WebAssembly.Exception); - assertSame(instance.exports.ex.constructor, WebAssembly.Exception); + assertInstanceof(instance.exports.ex, WebAssembly.Tag); + assertSame(instance.exports.ex.constructor, WebAssembly.Tag); })(); (function TestImportExport() { print(arguments.callee.name); - let js_ex_i32 = new WebAssembly.Exception({parameters: ['i32']}); + let js_ex_i32 = new WebAssembly.Tag({parameters: ['i32']}); let builder = new WasmModuleBuilder(); let index = builder.addImportedException("m", "ex", kSig_v_i); builder.addExportOfKind("ex", kExternalException, index); diff --git a/test/mjsunit/wasm/exceptions-import.js b/test/mjsunit/wasm/exceptions-import.js index 500a9168de..2e472054c1 100644 --- a/test/mjsunit/wasm/exceptions-import.js +++ b/test/mjsunit/wasm/exceptions-import.js @@ -53,7 +53,7 @@ function NewExportedException() { /module is not an object or function/); assertThrows( () => builder.instantiate({ m: {}}), WebAssembly.LinkError, - /exception import requires a WebAssembly.Exception/); + /tag import requires a WebAssembly.Tag/); })(); (function TestImportValueMismatch() { @@ -63,14 +63,14 @@ function NewExportedException() { assertThrows( () => builder.instantiate({ m: { ex: 23 }}), WebAssembly.LinkError, - /exception import requires a WebAssembly.Exception/); + /tag import requires a WebAssembly.Tag/); assertThrows( () => builder.instantiate({ m: { ex: {} }}), WebAssembly.LinkError, - /exception import requires a WebAssembly.Exception/); + /tag import requires a WebAssembly.Tag/); var monkey = Object.create(NewExportedException()); assertThrows( () => builder.instantiate({ m: { ex: monkey }}), WebAssembly.LinkError, - /exception import requires a WebAssembly.Exception/); + /tag import requires a WebAssembly.Tag/); })(); (function TestImportSignatureMismatch() { @@ -81,7 +81,7 @@ function NewExportedException() { assertThrows( () => builder.instantiate({ m: { ex: exported }}), WebAssembly.LinkError, - /imported exception does not match the expected type/); + /imported tag does not match the expected type/); })(); (function TestImportModuleGetImports() {