Revert "[wasm][eh] Rename Exception to Tag in the JS API"
This reverts commit 0b091e9bd3
.
Reason for revert: Causes Web Platform Test failures, blocking roll
E.g., https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Blink%20Linux/12616/overview
Original change's description:
> [wasm][eh] Rename Exception to Tag in the JS API
>
> See:
> https://github.com/WebAssembly/exception-handling/issues/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.
>
> R=ahaas@chromium.org
>
> Bug: v8:8091
> Change-Id: Iec1118194981dfd33be6e30256b6e72d12143e1f
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3021172
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#75718}
Bug: v8:8091
Change-Id: Id2067e1cdc33fa657ef738ef5fafad84057f7209
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3027261
Auto-Submit: Adam Klein <adamk@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#75725}
This commit is contained in:
parent
95b2f02dea
commit
98c6744962
@ -1507,15 +1507,15 @@ int InstanceBuilder::ProcessImports(Handle<WasmInstanceObject> instance) {
|
||||
}
|
||||
case kExternalException: {
|
||||
if (!value->IsWasmExceptionObject()) {
|
||||
ReportLinkError("tag import requires a WebAssembly.Tag", index,
|
||||
module_name, import_name);
|
||||
ReportLinkError("exception import requires a WebAssembly.Exception",
|
||||
index, module_name, import_name);
|
||||
return -1;
|
||||
}
|
||||
Handle<WasmExceptionObject> imported_exception =
|
||||
Handle<WasmExceptionObject>::cast(value);
|
||||
if (!imported_exception->MatchesSignature(
|
||||
module_->exceptions[import.index].sig)) {
|
||||
ReportLinkError("imported tag does not match the expected type",
|
||||
ReportLinkError("imported exception does not match the expected type",
|
||||
index, module_name, import_name);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1408,19 +1408,19 @@ uint32_t GetIterableLength(i::Isolate* isolate, Local<Context> context,
|
||||
|
||||
} // namespace
|
||||
|
||||
// WebAssembly.Tag
|
||||
void WebAssemblyTag(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
// WebAssembly.Exception
|
||||
void WebAssemblyException(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
HandleScope scope(isolate);
|
||||
|
||||
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Tag()");
|
||||
ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Exception()");
|
||||
if (!args.IsConstructCall()) {
|
||||
thrower.TypeError("WebAssembly.Tag must be invoked with 'new'");
|
||||
thrower.TypeError("WebAssembly.Exception must be invoked with 'new'");
|
||||
return;
|
||||
}
|
||||
if (!args[0]->IsObject()) {
|
||||
thrower.TypeError("Argument 0 must be a tag type");
|
||||
thrower.TypeError("Argument 0 must be an exception type");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1435,7 +1435,7 @@ void WebAssemblyTag(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Local<v8::Value> parameters_value;
|
||||
if (!parameters_maybe.ToLocal(¶meters_value) ||
|
||||
!parameters_value->IsObject()) {
|
||||
thrower.TypeError("Argument 0 must be a tag type with 'parameters'");
|
||||
thrower.TypeError("Argument 0 must be an exception type with 'parameters'");
|
||||
return;
|
||||
}
|
||||
Local<Object> parameters = parameters_value.As<Object>();
|
||||
@ -2287,8 +2287,8 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
|
||||
|
||||
// Setup Exception
|
||||
if (enabled_features.has_eh()) {
|
||||
Handle<JSFunction> exception_constructor =
|
||||
InstallConstructorFunc(isolate, webassembly, "Tag", WebAssemblyTag);
|
||||
Handle<JSFunction> exception_constructor = InstallConstructorFunc(
|
||||
isolate, webassembly, "Exception", WebAssemblyException);
|
||||
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> context) {
|
||||
// Exception handling may have been enabled by an origin trial. If so, make
|
||||
// sure that the {WebAssembly.Tag} constructor is set up.
|
||||
// sure that the {WebAssembly.Exception} constructor is set up.
|
||||
auto enabled_features = i::wasm::WasmFeatures::FromContext(isolate, context);
|
||||
if (enabled_features.has_eh()) {
|
||||
Handle<JSGlobalObject> global = handle(context->global_object(), isolate);
|
||||
@ -2368,7 +2368,7 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate,
|
||||
}
|
||||
Handle<JSObject> webassembly = Handle<JSObject>::cast(webassembly_obj);
|
||||
// Setup Exception
|
||||
Handle<String> exception_name = v8_str(isolate, "Tag");
|
||||
Handle<String> exception_name = v8_str(isolate, "Exception");
|
||||
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<JSFunction> exception_constructor =
|
||||
CreateFunc(isolate, exception_name, WebAssemblyTag, has_prototype,
|
||||
CreateFunc(isolate, exception_name, WebAssemblyException, 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 {Tag} constructor failed. We just bail out.
|
||||
// Setting the {Exception} constructor failed. We just bail out.
|
||||
return;
|
||||
}
|
||||
// Install the constructor on the context.
|
||||
|
@ -9,27 +9,27 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
(function TestImport() {
|
||||
print(arguments.callee.name);
|
||||
|
||||
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,
|
||||
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,
|
||||
/Argument 0 parameter type at index #0 must be a value type/);
|
||||
assertThrows(() => new WebAssembly.Tag({parameters: {}}), TypeError,
|
||||
assertThrows(() => new WebAssembly.Exception({parameters: {}}), TypeError,
|
||||
/Argument 0 contains parameters without 'length'/);
|
||||
|
||||
let js_except_i32 = new WebAssembly.Tag({parameters: ['i32']});
|
||||
let js_except_v = new WebAssembly.Tag({parameters: []});
|
||||
let js_except_i32 = new WebAssembly.Exception({parameters: ['i32']});
|
||||
let js_except_v = new WebAssembly.Exception({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 tag does not match the expected type/);
|
||||
/imported exception does not match the expected type/);
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: { ex: js_except_v }}), WebAssembly.LinkError,
|
||||
/imported tag does not match the expected type/);
|
||||
/imported exception 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.Tag);
|
||||
assertSame(instance.exports.ex.constructor, WebAssembly.Tag);
|
||||
assertInstanceof(instance.exports.ex, WebAssembly.Exception);
|
||||
assertSame(instance.exports.ex.constructor, WebAssembly.Exception);
|
||||
})();
|
||||
|
||||
(function TestImportExport() {
|
||||
print(arguments.callee.name);
|
||||
|
||||
let js_ex_i32 = new WebAssembly.Tag({parameters: ['i32']});
|
||||
let js_ex_i32 = new WebAssembly.Exception({parameters: ['i32']});
|
||||
let builder = new WasmModuleBuilder();
|
||||
let index = builder.addImportedException("m", "ex", kSig_v_i);
|
||||
builder.addExportOfKind("ex", kExternalException, index);
|
||||
|
@ -53,7 +53,7 @@ function NewExportedException() {
|
||||
/module is not an object or function/);
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: {}}), WebAssembly.LinkError,
|
||||
/tag import requires a WebAssembly.Tag/);
|
||||
/exception import requires a WebAssembly.Exception/);
|
||||
})();
|
||||
|
||||
(function TestImportValueMismatch() {
|
||||
@ -63,14 +63,14 @@ function NewExportedException() {
|
||||
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: { ex: 23 }}), WebAssembly.LinkError,
|
||||
/tag import requires a WebAssembly.Tag/);
|
||||
/exception import requires a WebAssembly.Exception/);
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: { ex: {} }}), WebAssembly.LinkError,
|
||||
/tag import requires a WebAssembly.Tag/);
|
||||
/exception import requires a WebAssembly.Exception/);
|
||||
var monkey = Object.create(NewExportedException());
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: { ex: monkey }}), WebAssembly.LinkError,
|
||||
/tag import requires a WebAssembly.Tag/);
|
||||
/exception import requires a WebAssembly.Exception/);
|
||||
})();
|
||||
|
||||
(function TestImportSignatureMismatch() {
|
||||
@ -81,7 +81,7 @@ function NewExportedException() {
|
||||
|
||||
assertThrows(
|
||||
() => builder.instantiate({ m: { ex: exported }}), WebAssembly.LinkError,
|
||||
/imported tag does not match the expected type/);
|
||||
/imported exception does not match the expected type/);
|
||||
})();
|
||||
|
||||
(function TestImportModuleGetImports() {
|
||||
|
Loading…
Reference in New Issue
Block a user