Skip to content

Commit 0b091e9

Browse files
thibaudmichaudV8 LUCI CQ
authored and
V8 LUCI CQ
committed
[wasm][eh] Rename Exception to Tag in the JS API
See: WebAssembly/exception-handling#159 This change only does the rename where it's observable. This should also be renamed throughout the codebase for consistency and will be done separately. [email protected] Bug: v8:8091 Change-Id: Iec1118194981dfd33be6e30256b6e72d12143e1f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3021172 Reviewed-by: Andreas Haas <[email protected]> Commit-Queue: Thibaud Michaud <[email protected]> Cr-Commit-Position: refs/heads/master@{#75718}
1 parent 6071c6d commit 0b091e9

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

src/wasm/module-instantiate.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,15 +1507,15 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
15071507
}
15081508
case kExternalException: {
15091509
if (!value->IsWasmExceptionObject()) {
1510-
ReportLinkError("exception import requires a WebAssembly.Exception",
1511-
index, module_name, import_name);
1510+
ReportLinkError("tag import requires a WebAssembly.Tag", index,
1511+
module_name, import_name);
15121512
return -1;
15131513
}
15141514
Handle<WasmExceptionObject> imported_exception =
15151515
Handle<WasmExceptionObject>::cast(value);
15161516
if (!imported_exception->MatchesSignature(
15171517
module_->exceptions[import.index].sig)) {
1518-
ReportLinkError("imported exception does not match the expected type",
1518+
ReportLinkError("imported tag does not match the expected type",
15191519
index, module_name, import_name);
15201520
return -1;
15211521
}

src/wasm/wasm-js.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,19 +1408,19 @@ uint32_t GetIterableLength(i::Isolate* isolate, Local<Context> context,
14081408

14091409
} // namespace
14101410

1411-
// WebAssembly.Exception
1412-
void WebAssemblyException(const v8::FunctionCallbackInfo<v8::Value>& args) {
1411+
// WebAssembly.Tag
1412+
void WebAssemblyTag(const v8::FunctionCallbackInfo<v8::Value>& args) {
14131413
v8::Isolate* isolate = args.GetIsolate();
14141414
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
14151415
HandleScope scope(isolate);
14161416

1417-
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Exception()");
1417+
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Tag()");
14181418
if (!args.IsConstructCall()) {
1419-
thrower.TypeError("WebAssembly.Exception must be invoked with 'new'");
1419+
thrower.TypeError("WebAssembly.Tag must be invoked with 'new'");
14201420
return;
14211421
}
14221422
if (!args[0]->IsObject()) {
1423-
thrower.TypeError("Argument 0 must be an exception type");
1423+
thrower.TypeError("Argument 0 must be a tag type");
14241424
return;
14251425
}
14261426

@@ -1435,7 +1435,7 @@ void WebAssemblyException(const v8::FunctionCallbackInfo<v8::Value>& args) {
14351435
v8::Local<v8::Value> parameters_value;
14361436
if (!parameters_maybe.ToLocal(&parameters_value) ||
14371437
!parameters_value->IsObject()) {
1438-
thrower.TypeError("Argument 0 must be an exception type with 'parameters'");
1438+
thrower.TypeError("Argument 0 must be a tag type with 'parameters'");
14391439
return;
14401440
}
14411441
Local<Object> parameters = parameters_value.As<Object>();
@@ -2287,8 +2287,8 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
22872287

22882288
// Setup Exception
22892289
if (enabled_features.has_eh()) {
2290-
Handle<JSFunction> exception_constructor = InstallConstructorFunc(
2291-
isolate, webassembly, "Exception", WebAssemblyException);
2290+
Handle<JSFunction> exception_constructor =
2291+
InstallConstructorFunc(isolate, webassembly, "Tag", WebAssemblyTag);
22922292
context->set_wasm_exception_constructor(*exception_constructor);
22932293
SetDummyInstanceTemplate(isolate, exception_constructor);
22942294
JSFunction::EnsureHasInitialMap(exception_constructor);
@@ -2349,7 +2349,7 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
23492349
void WasmJs::InstallConditionalFeatures(Isolate* isolate,
23502350
Handle<Context> context) {
23512351
// Exception handling may have been enabled by an origin trial. If so, make
2352-
// sure that the {WebAssembly.Exception} constructor is set up.
2352+
// sure that the {WebAssembly.Tag} constructor is set up.
23532353
auto enabled_features = i::wasm::WasmFeatures::FromContext(isolate, context);
23542354
if (enabled_features.has_eh()) {
23552355
Handle<JSGlobalObject> global = handle(context->global_object(), isolate);
@@ -2368,7 +2368,7 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate,
23682368
}
23692369
Handle<JSObject> webassembly = Handle<JSObject>::cast(webassembly_obj);
23702370
// Setup Exception
2371-
Handle<String> exception_name = v8_str(isolate, "Exception");
2371+
Handle<String> exception_name = v8_str(isolate, "Tag");
23722372
if (JSObject::HasOwnProperty(webassembly, exception_name).FromMaybe(true)) {
23732373
// The {Exception} constructor already exists, there is nothing more to
23742374
// do.
@@ -2377,14 +2377,14 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate,
23772377

23782378
bool has_prototype = true;
23792379
Handle<JSFunction> exception_constructor =
2380-
CreateFunc(isolate, exception_name, WebAssemblyException, has_prototype,
2380+
CreateFunc(isolate, exception_name, WebAssemblyTag, has_prototype,
23812381
SideEffectType::kHasNoSideEffect);
23822382
exception_constructor->shared().set_length(1);
23832383
auto result = Object::SetProperty(
23842384
isolate, webassembly, exception_name, exception_constructor,
23852385
StoreOrigin::kNamed, Just(ShouldThrow::kDontThrow));
23862386
if (result.is_null()) {
2387-
// Setting the {Exception} constructor failed. We just bail out.
2387+
// Setting the {Tag} constructor failed. We just bail out.
23882388
return;
23892389
}
23902390
// Install the constructor on the context.

test/mjsunit/wasm/exceptions-api.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
99
(function TestImport() {
1010
print(arguments.callee.name);
1111

12-
assertThrows(() => new WebAssembly.Exception(), TypeError,
13-
/Argument 0 must be an exception type/);
14-
assertThrows(() => new WebAssembly.Exception({}), TypeError,
15-
/Argument 0 must be an exception type with 'parameters'/);
16-
assertThrows(() => new WebAssembly.Exception({parameters: ['foo']}), TypeError,
12+
assertThrows(() => new WebAssembly.Tag(), TypeError,
13+
/Argument 0 must be a tag type/);
14+
assertThrows(() => new WebAssembly.Tag({}), TypeError,
15+
/Argument 0 must be a tag type with 'parameters'/);
16+
assertThrows(() => new WebAssembly.Tag({parameters: ['foo']}), TypeError,
1717
/Argument 0 parameter type at index #0 must be a value type/);
18-
assertThrows(() => new WebAssembly.Exception({parameters: {}}), TypeError,
18+
assertThrows(() => new WebAssembly.Tag({parameters: {}}), TypeError,
1919
/Argument 0 contains parameters without 'length'/);
2020

21-
let js_except_i32 = new WebAssembly.Exception({parameters: ['i32']});
22-
let js_except_v = new WebAssembly.Exception({parameters: []});
21+
let js_except_i32 = new WebAssembly.Tag({parameters: ['i32']});
22+
let js_except_v = new WebAssembly.Tag({parameters: []});
2323
let builder = new WasmModuleBuilder();
2424
builder.addImportedException("m", "ex", kSig_v_i);
2525

2626
assertDoesNotThrow(() => builder.instantiate({ m: { ex: js_except_i32 }}));
2727
assertThrows(
2828
() => builder.instantiate({ m: { ex: js_except_v }}), WebAssembly.LinkError,
29-
/imported exception does not match the expected type/);
29+
/imported tag does not match the expected type/);
3030
assertThrows(
3131
() => builder.instantiate({ m: { ex: js_except_v }}), WebAssembly.LinkError,
32-
/imported exception does not match the expected type/);
32+
/imported tag does not match the expected type/);
3333
})();
3434

3535
(function TestExport() {
@@ -41,14 +41,14 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
4141

4242
assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex'));
4343
assertEquals("object", typeof instance.exports.ex);
44-
assertInstanceof(instance.exports.ex, WebAssembly.Exception);
45-
assertSame(instance.exports.ex.constructor, WebAssembly.Exception);
44+
assertInstanceof(instance.exports.ex, WebAssembly.Tag);
45+
assertSame(instance.exports.ex.constructor, WebAssembly.Tag);
4646
})();
4747

4848
(function TestImportExport() {
4949
print(arguments.callee.name);
5050

51-
let js_ex_i32 = new WebAssembly.Exception({parameters: ['i32']});
51+
let js_ex_i32 = new WebAssembly.Tag({parameters: ['i32']});
5252
let builder = new WasmModuleBuilder();
5353
let index = builder.addImportedException("m", "ex", kSig_v_i);
5454
builder.addExportOfKind("ex", kExternalException, index);

test/mjsunit/wasm/exceptions-import.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function NewExportedException() {
5353
/module is not an object or function/);
5454
assertThrows(
5555
() => builder.instantiate({ m: {}}), WebAssembly.LinkError,
56-
/exception import requires a WebAssembly.Exception/);
56+
/tag import requires a WebAssembly.Tag/);
5757
})();
5858

5959
(function TestImportValueMismatch() {
@@ -63,14 +63,14 @@ function NewExportedException() {
6363

6464
assertThrows(
6565
() => builder.instantiate({ m: { ex: 23 }}), WebAssembly.LinkError,
66-
/exception import requires a WebAssembly.Exception/);
66+
/tag import requires a WebAssembly.Tag/);
6767
assertThrows(
6868
() => builder.instantiate({ m: { ex: {} }}), WebAssembly.LinkError,
69-
/exception import requires a WebAssembly.Exception/);
69+
/tag import requires a WebAssembly.Tag/);
7070
var monkey = Object.create(NewExportedException());
7171
assertThrows(
7272
() => builder.instantiate({ m: { ex: monkey }}), WebAssembly.LinkError,
73-
/exception import requires a WebAssembly.Exception/);
73+
/tag import requires a WebAssembly.Tag/);
7474
})();
7575

7676
(function TestImportSignatureMismatch() {
@@ -81,7 +81,7 @@ function NewExportedException() {
8181

8282
assertThrows(
8383
() => builder.instantiate({ m: { ex: exported }}), WebAssembly.LinkError,
84-
/imported exception does not match the expected type/);
84+
/imported tag does not match the expected type/);
8585
})();
8686

8787
(function TestImportModuleGetImports() {

0 commit comments

Comments
 (0)