From d66cc11c2f446d202d9e9f8ddd3c3fe69f21ac32 Mon Sep 17 00:00:00 2001 From: Thibaud Michaud Date: Thu, 29 Jul 2021 13:09:02 +0200 Subject: [PATCH] [wasm][eh] Rename exception to tag The JS API constructor was renamed to "WebAssembly.Tag" to match the spec: https://github.com/WebAssembly/exception-handling/issues/159 Rename "exception" to "tag" throughout the codebase for consistency with the JS API, and to match the spec terminology (e.g. "tag section"). R=clemensb@chromium.org,nicohartmann@chromium.org Bug: v8:11992 Change-Id: I63f9f3101abfeefd49117461bd59c594ca5dab70 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3053583 Reviewed-by: Clemens Backes Reviewed-by: Nico Hartmann Commit-Queue: Clemens Backes Cr-Commit-Position: refs/heads/master@{#75994} --- src/compiler/code-assembler.h | 2 +- src/compiler/types.cc | 2 +- src/compiler/wasm-compiler.cc | 24 +++-- src/compiler/wasm-compiler.h | 7 +- src/diagnostics/objects-printer.cc | 6 +- src/objects/contexts.h | 2 +- src/objects/js-objects.cc | 4 +- src/objects/map.cc | 2 +- src/objects/object-list-macros.h | 2 +- src/objects/objects-body-descriptors-inl.h | 2 +- src/objects/objects.h | 2 +- src/runtime/runtime-test-wasm.cc | 8 +- src/runtime/runtime.h | 2 +- src/wasm/baseline/liftoff-compiler.cc | 23 +++-- src/wasm/c-api.cc | 2 +- src/wasm/function-body-decoder-impl.h | 42 ++++---- src/wasm/graph-builder-interface.cc | 16 +-- src/wasm/module-decoder.cc | 57 +++++------ src/wasm/module-instantiate.cc | 75 +++++++------- src/wasm/wasm-constants.h | 4 +- src/wasm/wasm-js.cc | 98 +++++++++---------- src/wasm/wasm-limits.h | 2 +- src/wasm/wasm-module-builder.cc | 4 +- src/wasm/wasm-module.cc | 14 +-- src/wasm/wasm-module.h | 16 +-- src/wasm/wasm-objects-inl.h | 5 +- src/wasm/wasm-objects.cc | 30 +++--- src/wasm/wasm-objects.h | 30 +++--- src/wasm/wasm-objects.tq | 4 +- test/cctest/wasm/wasm-run-utils.cc | 10 +- test/common/wasm/wasm-interpreter.cc | 63 ++++++------ test/common/wasm/wasm-interpreter.h | 2 +- test/message/fail/wasm-exception-rethrow.js | 2 +- test/message/fail/wasm-exception-throw.js | 2 +- test/mjsunit/regress/wasm/regress-1188825.js | 2 +- test/mjsunit/regress/wasm/regress-8094.js | 2 +- test/mjsunit/regress/wasm/regress-8846.js | 4 +- test/mjsunit/regress/wasm/regress-8896.js | 2 +- test/mjsunit/wasm/exceptions-api.js | 24 ++--- test/mjsunit/wasm/exceptions-export.js | 30 +++--- test/mjsunit/wasm/exceptions-externref.js | 8 +- test/mjsunit/wasm/exceptions-import.js | 38 +++---- test/mjsunit/wasm/exceptions-rethrow.js | 10 +- test/mjsunit/wasm/exceptions-shared.js | 22 ++--- test/mjsunit/wasm/exceptions-simd.js | 6 +- .../wasm/exceptions-type-reflection.js | 8 +- test/mjsunit/wasm/exceptions-utils.js | 2 +- test/mjsunit/wasm/exceptions.js | 70 ++++++------- test/mjsunit/wasm/loop-unrolling.js | 8 +- test/mjsunit/wasm/wasm-module-builder.js | 40 ++++---- .../wasm/function-body-decoder-unittest.cc | 6 +- .../unittests/wasm/module-decoder-unittest.cc | 58 +++++------ tools/v8heapconst.py | 12 +-- 53 files changed, 448 insertions(+), 470 deletions(-) diff --git a/src/compiler/code-assembler.h b/src/compiler/code-assembler.h index 4e0afd8ea5..0e6872aa66 100644 --- a/src/compiler/code-assembler.h +++ b/src/compiler/code-assembler.h @@ -125,7 +125,7 @@ class SymbolWrapper; class Undetectable; class UniqueName; class WasmCapiFunctionData; -class WasmExceptionObject; +class WasmTagObject; class WasmExceptionPackage; class WasmExceptionTag; class WasmExportedFunctionData; diff --git a/src/compiler/types.cc b/src/compiler/types.cc index 39f54763ba..a1f9b93dce 100644 --- a/src/compiler/types.cc +++ b/src/compiler/types.cc @@ -258,7 +258,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) { case JS_PROMISE_TYPE: #if V8_ENABLE_WEBASSEMBLY case WASM_ARRAY_TYPE: - case WASM_EXCEPTION_OBJECT_TYPE: + case WASM_TAG_OBJECT_TYPE: case WASM_GLOBAL_OBJECT_TYPE: case WASM_INSTANCE_OBJECT_TYPE: case WASM_MEMORY_OBJECT_TYPE: diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc index 6a05e1dff3..cb5561cbac 100644 --- a/src/compiler/wasm-compiler.cc +++ b/src/compiler/wasm-compiler.cc @@ -2364,12 +2364,11 @@ Node* WasmGraphBuilder::MemoryGrow(Node* input) { return diamond_result; } -Node* WasmGraphBuilder::Throw(uint32_t exception_index, - const wasm::WasmException* exception, +Node* WasmGraphBuilder::Throw(uint32_t tag_index, const wasm::WasmTag* tag, const base::Vector values, wasm::WasmCodePosition position) { needs_stack_check_ = true; - uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(exception); + uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(tag); Node* values_array = gasm_->CallRuntimeStub(wasm::WasmCode::kWasmAllocateFixedArray, @@ -2377,7 +2376,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index, SetSourcePosition(values_array, position); uint32_t index = 0; - const wasm::WasmExceptionSig* sig = exception->sig; + const wasm::WasmTagSig* sig = tag->sig; MachineOperatorBuilder* m = mcgraph()->machine(); for (size_t i = 0; i < sig->parameter_count(); ++i) { Node* value = values[i]; @@ -2429,7 +2428,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index, } DCHECK_EQ(encoded_size, index); - Node* exception_tag = LoadExceptionTagFromTable(exception_index); + Node* exception_tag = LoadTagFromTable(tag_index); Node* throw_call = gasm_->CallRuntimeStub(wasm::WasmCode::kWasmThrow, exception_tag, values_array); @@ -2486,11 +2485,10 @@ Node* WasmGraphBuilder::ExceptionTagEqual(Node* caught_tag, return gasm_->WordEqual(caught_tag, expected_tag); } -Node* WasmGraphBuilder::LoadExceptionTagFromTable(uint32_t exception_index) { - Node* exceptions_table = - LOAD_INSTANCE_FIELD(ExceptionsTable, MachineType::TaggedPointer()); - Node* tag = - gasm_->LoadFixedArrayElementPtr(exceptions_table, exception_index); +Node* WasmGraphBuilder::LoadTagFromTable(uint32_t tag_index) { + Node* tags_table = + LOAD_INSTANCE_FIELD(TagsTable, MachineType::TaggedPointer()); + Node* tag = gasm_->LoadFixedArrayElementPtr(tags_table, tag_index); return tag; } @@ -2502,14 +2500,14 @@ Node* WasmGraphBuilder::GetExceptionTag(Node* except_obj) { } Node* WasmGraphBuilder::GetExceptionValues(Node* except_obj, - const wasm::WasmException* exception, + const wasm::WasmTag* tag, base::Vector values) { Node* values_array = gasm_->CallBuiltin( Builtin::kWasmGetOwnProperty, Operator::kEliminatable, except_obj, LOAD_ROOT(wasm_exception_values_symbol, wasm_exception_values_symbol), LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer())); uint32_t index = 0; - const wasm::WasmExceptionSig* sig = exception->sig; + const wasm::WasmTagSig* sig = tag->sig; DCHECK_EQ(sig->parameter_count(), values.size()); for (size_t i = 0; i < sig->parameter_count(); ++i) { Node* value; @@ -2559,7 +2557,7 @@ Node* WasmGraphBuilder::GetExceptionValues(Node* except_obj, } values[i] = value; } - DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(exception)); + DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(tag)); return values_array; } diff --git a/src/compiler/wasm-compiler.h b/src/compiler/wasm-compiler.h index e1993fbf42..71e3111c8c 100644 --- a/src/compiler/wasm-compiler.h +++ b/src/compiler/wasm-compiler.h @@ -266,15 +266,14 @@ class WasmGraphBuilder { Node* Unop(wasm::WasmOpcode opcode, Node* input, wasm::WasmCodePosition position = wasm::kNoCodePosition); Node* MemoryGrow(Node* input); - Node* Throw(uint32_t exception_index, const wasm::WasmException* exception, + Node* Throw(uint32_t tag_index, const wasm::WasmTag* tag, const base::Vector values, wasm::WasmCodePosition position); Node* Rethrow(Node* except_obj); Node* ExceptionTagEqual(Node* caught_tag, Node* expected_tag); - Node* LoadExceptionTagFromTable(uint32_t exception_index); + Node* LoadTagFromTable(uint32_t tag_index); Node* GetExceptionTag(Node* except_obj); - Node* GetExceptionValues(Node* except_obj, - const wasm::WasmException* exception, + Node* GetExceptionValues(Node* except_obj, const wasm::WasmTag* tag, base::Vector values_out); bool IsPhiWithMerge(Node* phi, Node* merge); bool ThrowsException(Node* node, Node** if_success, Node** if_exception); diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc index adc84d71ff..b18b9ee8ca 100644 --- a/src/diagnostics/objects-printer.cc +++ b/src/diagnostics/objects-printer.cc @@ -2076,10 +2076,10 @@ void WasmMemoryObject::WasmMemoryObjectPrint(std::ostream& os) { os << "\n"; } -void WasmExceptionObject::WasmExceptionObjectPrint(std::ostream& os) { - PrintHeader(os, "WasmExceptionObject"); +void WasmTagObject::WasmTagObjectPrint(std::ostream& os) { + PrintHeader(os, "WasmTagObject"); os << "\n - serialized_signature: " << Brief(serialized_signature()); - os << "\n - exception_tag: " << Brief(exception_tag()); + os << "\n - tag: " << Brief(tag()); os << "\n"; } diff --git a/src/objects/contexts.h b/src/objects/contexts.h index ef1ee10faf..878a9e4371 100644 --- a/src/objects/contexts.h +++ b/src/objects/contexts.h @@ -291,7 +291,7 @@ enum ContextLookupFlags { V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \ V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ V(WASM_EXPORTED_FUNCTION_MAP_INDEX, Map, wasm_exported_function_map) \ - V(WASM_EXCEPTION_CONSTRUCTOR_INDEX, JSFunction, wasm_exception_constructor) \ + V(WASM_TAG_CONSTRUCTOR_INDEX, JSFunction, wasm_tag_constructor) \ V(WASM_GLOBAL_CONSTRUCTOR_INDEX, JSFunction, wasm_global_constructor) \ V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor) \ V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor) \ diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc index 22aec00cd1..a71f1fa8d0 100644 --- a/src/objects/js-objects.cc +++ b/src/objects/js-objects.cc @@ -2334,8 +2334,8 @@ int JSObject::GetHeaderSize(InstanceType type, return WasmTableObject::kHeaderSize; case WASM_VALUE_OBJECT_TYPE: return WasmValueObject::kHeaderSize; - case WASM_EXCEPTION_OBJECT_TYPE: - return WasmExceptionObject::kHeaderSize; + case WASM_TAG_OBJECT_TYPE: + return WasmTagObject::kHeaderSize; #endif // V8_ENABLE_WEBASSEMBLY default: { std::stringstream ss; diff --git a/src/objects/map.cc b/src/objects/map.cc index 50d5728b0e..ecfe91fc98 100644 --- a/src/objects/map.cc +++ b/src/objects/map.cc @@ -286,7 +286,7 @@ VisitorId Map::GetVisitorId(Map map) { case JS_SEGMENTS_TYPE: #endif // V8_INTL_SUPPORT #if V8_ENABLE_WEBASSEMBLY - case WASM_EXCEPTION_OBJECT_TYPE: + case WASM_TAG_OBJECT_TYPE: case WASM_GLOBAL_OBJECT_TYPE: case WASM_MEMORY_OBJECT_TYPE: case WASM_MODULE_OBJECT_TYPE: diff --git a/src/objects/object-list-macros.h b/src/objects/object-list-macros.h index 4e817a23f1..13960d62c0 100644 --- a/src/objects/object-list-macros.h +++ b/src/objects/object-list-macros.h @@ -217,7 +217,7 @@ class ZoneForwardList; V(UniqueName) \ IF_WASM(V, WasmArray) \ IF_WASM(V, WasmCapiFunctionData) \ - IF_WASM(V, WasmExceptionObject) \ + IF_WASM(V, WasmTagObject) \ IF_WASM(V, WasmExceptionPackage) \ IF_WASM(V, WasmExportedFunctionData) \ IF_WASM(V, WasmFunctionData) \ diff --git a/src/objects/objects-body-descriptors-inl.h b/src/objects/objects-body-descriptors-inl.h index 9be9739b1c..daed10a8cc 100644 --- a/src/objects/objects-body-descriptors-inl.h +++ b/src/objects/objects-body-descriptors-inl.h @@ -1133,7 +1133,7 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) { case JS_SEGMENTS_TYPE: #endif // V8_INTL_SUPPORT #if V8_ENABLE_WEBASSEMBLY - case WASM_EXCEPTION_OBJECT_TYPE: + case WASM_TAG_OBJECT_TYPE: case WASM_GLOBAL_OBJECT_TYPE: case WASM_MEMORY_OBJECT_TYPE: case WASM_MODULE_OBJECT_TYPE: diff --git a/src/objects/objects.h b/src/objects/objects.h index 9ca08df612..de398deec1 100644 --- a/src/objects/objects.h +++ b/src/objects/objects.h @@ -81,7 +81,7 @@ // - JSSegments // If V8_INTL_SUPPORT enabled. // - JSSegmentIterator // If V8_INTL_SUPPORT enabled. // - JSV8BreakIterator // If V8_INTL_SUPPORT enabled. -// - WasmExceptionObject +// - WasmTagObject // - WasmGlobalObject // - WasmInstanceObject // - WasmMemoryObject diff --git a/src/runtime/runtime-test-wasm.cc b/src/runtime/runtime-test-wasm.cc index 72598c7345..8425b1fa18 100644 --- a/src/runtime/runtime-test-wasm.cc +++ b/src/runtime/runtime-test-wasm.cc @@ -293,7 +293,7 @@ RUNTIME_FUNCTION(Runtime_GetWasmRecoveredTrapCount) { return *isolate->factory()->NewNumberFromSize(trap_count); } -RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) { +RUNTIME_FUNCTION(Runtime_GetWasmExceptionTagId) { HandleScope scope(isolate); DCHECK_EQ(2, args.length()); CONVERT_ARG_HANDLE_CHECKED(WasmExceptionPackage, exception, 0); @@ -301,9 +301,9 @@ RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) { Handle tag = WasmExceptionPackage::GetExceptionTag(isolate, exception); CHECK(tag->IsWasmExceptionTag()); - Handle exceptions_table(instance->exceptions_table(), isolate); - for (int index = 0; index < exceptions_table->length(); ++index) { - if (exceptions_table->get(index) == *tag) return Smi::FromInt(index); + Handle tags_table(instance->tags_table(), isolate); + for (int index = 0; index < tags_table->length(); ++index) { + if (tags_table->get(index) == *tag) return Smi::FromInt(index); } UNREACHABLE(); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index e1336f4111..39af5b7c21 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -597,7 +597,7 @@ namespace internal { F(DeserializeWasmModule, 2, 1) \ F(DisallowWasmCodegen, 1, 1) \ F(FreezeWasmLazyCompilation, 1, 1) \ - F(GetWasmExceptionId, 2, 1) \ + F(GetWasmExceptionTagId, 2, 1) \ F(GetWasmExceptionValues, 1, 1) \ F(GetWasmRecoveredTrapCount, 0, 1) \ F(IsAsmWasmCode, 1, 1) \ diff --git a/src/wasm/baseline/liftoff-compiler.cc b/src/wasm/baseline/liftoff-compiler.cc index 7a2fffa5a2..f344022f3e 100644 --- a/src/wasm/baseline/liftoff-compiler.cc +++ b/src/wasm/baseline/liftoff-compiler.cc @@ -1141,8 +1141,8 @@ class LiftoffCompiler { } void CatchException(FullDecoder* decoder, - const ExceptionIndexImmediate& imm, - Control* block, base::Vector values) { + const TagIndexImmediate& imm, Control* block, + base::Vector values) { DCHECK(block->is_try_catch()); __ emit_jump(block->label.get()); @@ -1171,7 +1171,7 @@ class LiftoffCompiler { CODE_COMMENT("load expected exception tag"); Register imm_tag = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp(); - LOAD_TAGGED_PTR_INSTANCE_FIELD(imm_tag, ExceptionsTable, pinned); + LOAD_TAGGED_PTR_INSTANCE_FIELD(imm_tag, TagsTable, pinned); __ LoadTaggedPointer( imm_tag, imm_tag, no_reg, wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(imm.index), {}); @@ -1189,8 +1189,7 @@ class LiftoffCompiler { block->try_info->in_handler = true; num_exceptions_++; } - GetExceptionValues(decoder, __ cache_state()->stack_state.back(), - imm.exception); + GetExceptionValues(decoder, __ cache_state()->stack_state.back(), imm.tag); } void Rethrow(FullDecoder* decoder, @@ -4227,18 +4226,18 @@ class LiftoffCompiler { void GetExceptionValues(FullDecoder* decoder, LiftoffAssembler::VarState& exception_var, - const WasmException* exception) { + const WasmTag* tag) { LiftoffRegList pinned; CODE_COMMENT("get exception values"); LiftoffRegister values_array = GetExceptionProperty( exception_var, RootIndex::kwasm_exception_values_symbol); pinned.set(values_array); uint32_t index = 0; - const WasmExceptionSig* sig = exception->sig; + const WasmTagSig* sig = tag->sig; for (ValueType param : sig->parameters()) { LoadExceptionValue(param.kind(), values_array, &index, pinned); } - DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(exception)); + DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(tag)); } void EmitLandingPad(FullDecoder* decoder, int handler_offset) { @@ -4273,12 +4272,12 @@ class LiftoffCompiler { __ DropValues(1); } - void Throw(FullDecoder* decoder, const ExceptionIndexImmediate& imm, + void Throw(FullDecoder* decoder, const TagIndexImmediate& imm, const base::Vector& /* args */) { LiftoffRegList pinned; // Load the encoded size in a register for the builtin call. - int encoded_size = WasmExceptionPackage::GetEncodedSize(imm.exception); + int encoded_size = WasmExceptionPackage::GetEncodedSize(imm.tag); LiftoffRegister encoded_size_reg = pinned.set(__ GetUnusedRegister(kGpReg, pinned)); __ LoadConstant(encoded_size_reg, WasmValue(encoded_size)); @@ -4300,7 +4299,7 @@ class LiftoffCompiler { // first value, such that we can just pop them from the value stack. CODE_COMMENT("fill values array"); int index = encoded_size; - auto* sig = imm.exception->sig; + auto* sig = imm.tag->sig; for (size_t param_idx = sig->parameter_count(); param_idx > 0; --param_idx) { ValueType type = sig->GetParam(param_idx - 1); @@ -4312,7 +4311,7 @@ class LiftoffCompiler { CODE_COMMENT("load exception tag"); LiftoffRegister exception_tag = pinned.set(__ GetUnusedRegister(kGpReg, pinned)); - LOAD_TAGGED_PTR_INSTANCE_FIELD(exception_tag.gp(), ExceptionsTable, pinned); + LOAD_TAGGED_PTR_INSTANCE_FIELD(exception_tag.gp(), TagsTable, pinned); __ LoadTaggedPointer( exception_tag.gp(), exception_tag.gp(), no_reg, wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(imm.index), {}); diff --git a/src/wasm/c-api.cc b/src/wasm/c-api.cc index de9904ae4a..5a1ab579e7 100644 --- a/src/wasm/c-api.cc +++ b/src/wasm/c-api.cc @@ -167,7 +167,7 @@ own GetImportExportType(const i::wasm::WasmModule* module, Mutability mutability = global.mutability ? VAR : CONST; return GlobalType::make(std::move(content), mutability); } - case i::wasm::kExternalException: + case i::wasm::kExternalTag: UNREACHABLE(); } } diff --git a/src/wasm/function-body-decoder-impl.h b/src/wasm/function-body-decoder-impl.h index c175acd8a0..d1ed3aca53 100644 --- a/src/wasm/function-body-decoder-impl.h +++ b/src/wasm/function-body-decoder-impl.h @@ -33,7 +33,7 @@ namespace internal { namespace wasm { struct WasmGlobal; -struct WasmException; +struct WasmTag; #define TRACE(...) \ do { \ @@ -486,11 +486,11 @@ struct IndexImmediate { }; template -struct ExceptionIndexImmediate : public IndexImmediate { - const WasmException* exception = nullptr; +struct TagIndexImmediate : public IndexImmediate { + const WasmTag* tag = nullptr; - ExceptionIndexImmediate(Decoder* decoder, const byte* pc) - : IndexImmediate(decoder, pc, "exception index") {} + TagIndexImmediate(Decoder* decoder, const byte* pc) + : IndexImmediate(decoder, pc, "tag index") {} }; template @@ -1020,11 +1020,11 @@ struct ControlBase : public PcForErrors { F(S128Const, const Simd128Immediate& imm, Value* result) \ F(Simd8x16ShuffleOp, const Simd128Immediate& imm, \ const Value& input0, const Value& input1, Value* result) \ - F(Throw, const ExceptionIndexImmediate& imm, \ + F(Throw, const TagIndexImmediate& imm, \ const base::Vector& args) \ F(Rethrow, Control* block) \ - F(CatchException, const ExceptionIndexImmediate& imm, \ - Control* block, base::Vector caught_values) \ + F(CatchException, const TagIndexImmediate& imm, Control* block, \ + base::Vector caught_values) \ F(Delegate, uint32_t depth, Control* block) \ F(CatchAll, Control* block) \ F(AtomicOp, WasmOpcode opcode, base::Vector args, \ @@ -1266,12 +1266,12 @@ class WasmDecoder : public Decoder { return VALIDATE(decoder->ok()) ? assigned : nullptr; } - bool Validate(const byte* pc, ExceptionIndexImmediate& imm) { - if (!VALIDATE(imm.index < module_->exceptions.size())) { - DecodeError(pc, "Invalid exception index: %u", imm.index); + bool Validate(const byte* pc, TagIndexImmediate& imm) { + if (!VALIDATE(imm.index < module_->tags.size())) { + DecodeError(pc, "Invalid tag index: %u", imm.index); return false; } - imm.exception = &module_->exceptions[imm.index]; + imm.tag = &module_->tags[imm.index]; return true; } @@ -1635,7 +1635,7 @@ class WasmDecoder : public Decoder { } case kExprThrow: case kExprCatch: { - ExceptionIndexImmediate imm(decoder, pc + 1); + TagIndexImmediate imm(decoder, pc + 1); return 1 + imm.length; } case kExprLet: { @@ -1991,10 +1991,10 @@ class WasmDecoder : public Decoder { imm.sig->return_count()}; } case kExprThrow: { - ExceptionIndexImmediate imm(this, pc + 1); + TagIndexImmediate imm(this, pc + 1); CHECK(Validate(pc + 1, imm)); - DCHECK_EQ(0, imm.exception->sig->return_count()); - return {imm.exception->sig->parameter_count(), 0}; + DCHECK_EQ(0, imm.tag->sig->return_count()); + return {imm.tag->sig->parameter_count(), 0}; } case kExprBr: case kExprBlock: @@ -2565,11 +2565,11 @@ class WasmFullDecoder : public WasmDecoder { DECODE(Throw) { CHECK_PROTOTYPE_OPCODE(eh); - ExceptionIndexImmediate imm(this, this->pc_ + 1); + TagIndexImmediate imm(this, this->pc_ + 1); if (!this->Validate(this->pc_ + 1, imm)) return 0; - ArgVector args = PeekArgs(imm.exception->ToFunctionSig()); + ArgVector args = PeekArgs(imm.tag->ToFunctionSig()); CALL_INTERFACE_IF_OK_AND_REACHABLE(Throw, imm, base::VectorOf(args)); - DropArgs(imm.exception->ToFunctionSig()); + DropArgs(imm.tag->ToFunctionSig()); EndControl(); return 1 + imm.length; } @@ -2592,7 +2592,7 @@ class WasmFullDecoder : public WasmDecoder { DECODE(Catch) { CHECK_PROTOTYPE_OPCODE(eh); - ExceptionIndexImmediate imm(this, this->pc_ + 1); + TagIndexImmediate imm(this, this->pc_ + 1); if (!this->Validate(this->pc_ + 1, imm)) return 0; DCHECK(!control_.empty()); Control* c = &control_.back(); @@ -2611,7 +2611,7 @@ class WasmFullDecoder : public WasmDecoder { DCHECK_LE(stack_ + c->stack_depth, stack_end_); stack_end_ = stack_ + c->stack_depth; c->reachability = control_at(1)->innerReachability(); - const WasmExceptionSig* sig = imm.exception->sig; + const WasmTagSig* sig = imm.tag->sig; EnsureStackSpace(static_cast(sig->parameter_count())); for (size_t i = 0, e = sig->parameter_count(); i < e; ++i) { Push(CreateValue(sig->GetParam(i))); diff --git a/src/wasm/graph-builder-interface.cc b/src/wasm/graph-builder-interface.cc index e53269d72e..b81433f1d7 100644 --- a/src/wasm/graph-builder-interface.cc +++ b/src/wasm/graph-builder-interface.cc @@ -715,16 +715,16 @@ class WasmGraphBuildingInterface { result->node = builder_->Simd8x16ShuffleOp(imm.value, input_nodes); } - void Throw(FullDecoder* decoder, const ExceptionIndexImmediate& imm, + void Throw(FullDecoder* decoder, const TagIndexImmediate& imm, const base::Vector& value_args) { int count = value_args.length(); ZoneVector args(count, decoder->zone()); for (int i = 0; i < count; ++i) { args[i] = value_args[i].node; } - CheckForException( - decoder, builder_->Throw(imm.index, imm.exception, base::VectorOf(args), - decoder->position())); + CheckForException(decoder, + builder_->Throw(imm.index, imm.tag, base::VectorOf(args), + decoder->position())); TerminateThrow(decoder); } @@ -737,8 +737,8 @@ class WasmGraphBuildingInterface { } void CatchException(FullDecoder* decoder, - const ExceptionIndexImmediate& imm, - Control* block, base::Vector values) { + const TagIndexImmediate& imm, Control* block, + base::Vector values) { DCHECK(block->is_try_catch()); // The catch block is unreachable if no possible throws in the try block // exist. We only build a landing pad if some node in the try block can @@ -756,7 +756,7 @@ class WasmGraphBuildingInterface { // Get the exception tag and see if it matches the expected one. TFNode* caught_tag = builder_->GetExceptionTag(exception); - TFNode* exception_tag = builder_->LoadExceptionTagFromTable(imm.index); + TFNode* exception_tag = builder_->LoadTagFromTable(imm.index); TFNode* compare = builder_->ExceptionTagEqual(caught_tag, exception_tag); builder_->BranchNoHint(compare, &if_catch, &if_no_catch); @@ -773,7 +773,7 @@ class WasmGraphBuildingInterface { SetEnv(if_catch_env); NodeVector caught_values(values.size()); base::Vector caught_vector = base::VectorOf(caught_values); - builder_->GetExceptionValues(exception, imm.exception, caught_vector); + builder_->GetExceptionValues(exception, imm.tag, caught_vector); for (size_t i = 0, e = values.size(); i < e; ++i) { values[i].node = caught_values[i]; } diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc index 5e0c76025b..f2022b8ccb 100644 --- a/src/wasm/module-decoder.cc +++ b/src/wasm/module-decoder.cc @@ -50,8 +50,8 @@ const char* ExternalKindName(ImportExportKindCode kind) { return "memory"; case kExternalGlobal: return "global"; - case kExternalException: - return "exception"; + case kExternalTag: + return "tag"; } return "unknown"; } @@ -84,8 +84,8 @@ const char* SectionName(SectionCode code) { return "Element"; case kDataSectionCode: return "Data"; - case kExceptionSectionCode: - return "Exception"; + case kTagSectionCode: + return "Tag"; case kDataCountSectionCode: return "DataCount"; case kNameSectionCode: @@ -413,7 +413,7 @@ class ModuleDecoderImpl : public Decoder { kCodeSectionCode)) return; break; - case kExceptionSectionCode: + case kTagSectionCode: if (!CheckUnorderedSection(section_code)) return; if (!CheckSectionOrder(section_code, kMemorySectionCode, kGlobalSectionCode)) @@ -526,9 +526,9 @@ class ModuleDecoderImpl : public Decoder { case kDataCountSectionCode: DecodeDataCountSection(); break; - case kExceptionSectionCode: + case kTagSectionCode: if (enabled_features_.has_eh()) { - DecodeExceptionSection(); + DecodeTagSection(); } else { errorf(pc(), "unexpected section <%s> (enable with --experimental-wasm-eh)", @@ -680,17 +680,17 @@ class ModuleDecoderImpl : public Decoder { } break; } - case kExternalException: { - // ===== Imported exception ========================================== + case kExternalTag: { + // ===== Imported tag ================================================ if (!enabled_features_.has_eh()) { errorf(pos, "unknown import kind 0x%02x", import->kind); break; } - import->index = static_cast(module_->exceptions.size()); - const WasmExceptionSig* exception_sig = nullptr; + import->index = static_cast(module_->tags.size()); + const WasmTagSig* tag_sig = nullptr; consume_exception_attribute(); // Attribute ignored for now. - consume_exception_sig_index(module_.get(), &exception_sig); - module_->exceptions.emplace_back(exception_sig); + consume_tag_sig_index(module_.get(), &tag_sig); + module_->tags.emplace_back(tag_sig); break; } default: @@ -845,13 +845,13 @@ class ModuleDecoderImpl : public Decoder { } break; } - case kExternalException: { + case kExternalTag: { if (!enabled_features_.has_eh()) { errorf(pos, "invalid export kind 0x%02x", exp->kind); break; } - WasmException* exception = nullptr; - exp->index = consume_exception_index(module_.get(), &exception); + WasmTag* tag = nullptr; + exp->index = consume_tag_index(module_.get(), &tag); break; } default: @@ -1259,16 +1259,14 @@ class ModuleDecoderImpl : public Decoder { consume_count("data segments count", kV8MaxWasmDataSegments); } - void DecodeExceptionSection() { - uint32_t exception_count = - consume_count("exception count", kV8MaxWasmExceptions); - for (uint32_t i = 0; ok() && i < exception_count; ++i) { - TRACE("DecodeException[%d] module+%d\n", i, - static_cast(pc_ - start_)); - const WasmExceptionSig* exception_sig = nullptr; + void DecodeTagSection() { + uint32_t tag_count = consume_count("tag count", kV8MaxWasmTags); + for (uint32_t i = 0; ok() && i < tag_count; ++i) { + TRACE("DecodeTag[%d] module+%d\n", i, static_cast(pc_ - start_)); + const WasmTagSig* tag_sig = nullptr; consume_exception_attribute(); // Attribute ignored for now. - consume_exception_sig_index(module_.get(), &exception_sig); - module_->exceptions.emplace_back(exception_sig); + consume_tag_sig_index(module_.get(), &tag_sig); + module_->tags.emplace_back(tag_sig); } } @@ -1544,12 +1542,11 @@ class ModuleDecoderImpl : public Decoder { return sig_index; } - uint32_t consume_exception_sig_index(WasmModule* module, - const FunctionSig** sig) { + uint32_t consume_tag_sig_index(WasmModule* module, const FunctionSig** sig) { const byte* pos = pc_; uint32_t sig_index = consume_sig_index(module, sig); if (*sig && (*sig)->return_count() != 0) { - errorf(pos, "exception signature %u has non-void return", sig_index); + errorf(pos, "tag signature %u has non-void return", sig_index); *sig = nullptr; return 0; } @@ -1579,8 +1576,8 @@ class ModuleDecoderImpl : public Decoder { return consume_index("table index", &module->tables, table); } - uint32_t consume_exception_index(WasmModule* module, WasmException** except) { - return consume_index("exception index", &module->exceptions, except); + uint32_t consume_tag_index(WasmModule* module, WasmTag** tag) { + return consume_index("tag index", &module->tags, tag); } template diff --git a/src/wasm/module-instantiate.cc b/src/wasm/module-instantiate.cc index 22e6511d7c..7b081966c4 100644 --- a/src/wasm/module-instantiate.cc +++ b/src/wasm/module-instantiate.cc @@ -292,7 +292,7 @@ class InstanceBuilder { Handle memory_object_; Handle untagged_globals_; Handle tagged_globals_; - std::vector> exception_wrappers_; + std::vector> tags_wrappers_; Handle start_function_; std::vector sanitized_imports_; Zone init_expr_zone_; @@ -405,9 +405,9 @@ class InstanceBuilder { void LoadTableSegments(Handle instance); - // Creates new exception tags for all exceptions. Note that some tags might - // already exist if they were imported, those tags will be re-used. - void InitializeExceptions(Handle instance); + // Creates new tags. Note that some tags might already exist if they were + // imported, those tags will be re-used. + void InitializeTags(Handle instance); }; MaybeHandle InstantiateToInstanceObject( @@ -584,14 +584,14 @@ MaybeHandle InstanceBuilder::Build() { } //-------------------------------------------------------------------------- - // Set up the exception table used for exception tag checks. + // Set up the tag table used for exception tag checks. //-------------------------------------------------------------------------- - int exceptions_count = static_cast(module_->exceptions.size()); - if (exceptions_count > 0) { - Handle exception_table = isolate_->factory()->NewFixedArray( - exceptions_count, AllocationType::kOld); - instance->set_exceptions_table(*exception_table); - exception_wrappers_.resize(exceptions_count); + int tags_count = static_cast(module_->tags.size()); + if (tags_count > 0) { + Handle tag_table = + isolate_->factory()->NewFixedArray(tags_count, AllocationType::kOld); + instance->set_tags_table(*tag_table); + tags_wrappers_.resize(tags_count); } //-------------------------------------------------------------------------- @@ -696,10 +696,10 @@ MaybeHandle InstanceBuilder::Build() { } //-------------------------------------------------------------------------- - // Initialize the exceptions table. + // Initialize the tags table. //-------------------------------------------------------------------------- - if (exceptions_count > 0) { - InitializeExceptions(instance); + if (tags_count > 0) { + InitializeTags(instance); } //-------------------------------------------------------------------------- @@ -1511,24 +1511,22 @@ int InstanceBuilder::ProcessImports(Handle instance) { } break; } - case kExternalException: { - if (!value->IsWasmExceptionObject()) { + case kExternalTag: { + if (!value->IsWasmTagObject()) { 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)) { + Handle imported_tag = Handle::cast(value); + if (!imported_tag->MatchesSignature(module_->tags[import.index].sig)) { ReportLinkError("imported tag does not match the expected type", index, module_name, import_name); return -1; } - Object exception_tag = imported_exception->exception_tag(); - DCHECK(instance->exceptions_table().get(import.index).IsUndefined()); - instance->exceptions_table().set(import.index, exception_tag); - exception_wrappers_[import.index] = imported_exception; + Object tag = imported_tag->tag(); + DCHECK(instance->tags_table().get(import.index).IsUndefined()); + instance->tags_table().set(import.index, tag); + tags_wrappers_[import.index] = imported_tag; break; } default: @@ -1740,16 +1738,15 @@ void InstanceBuilder::ProcessExports(Handle instance) { desc.set_value(global_obj); break; } - case kExternalException: { - const WasmException& exception = module_->exceptions[exp.index]; - Handle wrapper = exception_wrappers_[exp.index]; + case kExternalTag: { + const WasmTag& tag = module_->tags[exp.index]; + Handle wrapper = tags_wrappers_[exp.index]; if (wrapper.is_null()) { - Handle exception_tag( - HeapObject::cast(instance->exceptions_table().get(exp.index)), + Handle tag_object( + HeapObject::cast(instance->tags_table().get(exp.index)), isolate_); - wrapper = - WasmExceptionObject::New(isolate_, exception.sig, exception_tag); - exception_wrappers_[exp.index] = wrapper; + wrapper = WasmTagObject::New(isolate_, tag.sig, tag_object); + tags_wrappers_[exp.index] = wrapper; } desc.set_value(wrapper); break; @@ -1980,14 +1977,12 @@ void InstanceBuilder::LoadTableSegments(Handle instance) { } } -void InstanceBuilder::InitializeExceptions( - Handle instance) { - Handle exceptions_table(instance->exceptions_table(), isolate_); - for (int index = 0; index < exceptions_table->length(); ++index) { - if (!exceptions_table->get(index).IsUndefined(isolate_)) continue; - Handle exception_tag = - WasmExceptionTag::New(isolate_, index); - exceptions_table->set(index, *exception_tag); +void InstanceBuilder::InitializeTags(Handle instance) { + Handle tags_table(instance->tags_table(), isolate_); + for (int index = 0; index < tags_table->length(); ++index) { + if (!tags_table->get(index).IsUndefined(isolate_)) continue; + Handle tag = WasmExceptionTag::New(isolate_, index); + tags_table->set(index, *tag); } } diff --git a/src/wasm/wasm-constants.h b/src/wasm/wasm-constants.h index f960e7c201..ecfaa65217 100644 --- a/src/wasm/wasm-constants.h +++ b/src/wasm/wasm-constants.h @@ -57,7 +57,7 @@ enum ImportExportKindCode : uint8_t { kExternalTable = 1, kExternalMemory = 2, kExternalGlobal = 3, - kExternalException = 4 + kExternalTag = 4 }; enum LimitsFlags : uint8_t { @@ -91,7 +91,7 @@ enum SectionCode : int8_t { kCodeSectionCode = 10, // Function code kDataSectionCode = 11, // Data segments kDataCountSectionCode = 12, // Number of data segments - kExceptionSectionCode = 13, // Exception section + kTagSectionCode = 13, // Tag section // The following sections are custom sections, and are identified using a // string rather than an integer. Their enumeration values are not guaranteed diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc index 6407e7e9c2..8d30161966 100644 --- a/src/wasm/wasm-js.cc +++ b/src/wasm/wasm-js.cc @@ -1474,7 +1474,7 @@ void WebAssemblyTag(const v8::FunctionCallbackInfo& args) { return; } - // Decode the exception type and construct a signature. + // Decode the tag type and construct a signature. std::vector param_types(parameters_len, i::wasm::kWasmVoid); for (uint32_t i = 0; i < parameters_len; ++i) { @@ -1491,20 +1491,20 @@ void WebAssemblyTag(const v8::FunctionCallbackInfo& args) { // Set the tag index to 0. It is only used for debugging purposes, and has no // meaningful value when declared outside of a wasm module. auto tag = i::WasmExceptionTag::New(i_isolate, 0); - i::Handle exception = - i::WasmExceptionObject::New(i_isolate, &sig, tag); - args.GetReturnValue().Set(Utils::ToLocal(exception)); + i::Handle tag_object = + i::WasmTagObject::New(i_isolate, &sig, tag); + args.GetReturnValue().Set(Utils::ToLocal(tag_object)); } namespace { -uint32_t GetEncodedSize(i::Handle tag_object) { +uint32_t GetEncodedSize(i::Handle tag_object) { auto serialized_sig = tag_object->serialized_signature(); - i::wasm::WasmExceptionSig sig{0, static_cast(serialized_sig.length()), - reinterpret_cast( - serialized_sig.GetDataStartAddress())}; - i::wasm::WasmException exception(&sig); - return i::WasmExceptionPackage::GetEncodedSize(&exception); + i::wasm::WasmTagSig sig{0, static_cast(serialized_sig.length()), + reinterpret_cast( + serialized_sig.GetDataStartAddress())}; + i::wasm::WasmTag tag(&sig); + return i::WasmExceptionPackage::GetEncodedSize(&tag); } void EncodeExceptionValues(v8::Isolate* isolate, @@ -1598,13 +1598,13 @@ void WebAssemblyException(const v8::FunctionCallbackInfo& args) { return; } i::Handle arg0 = Utils::OpenHandle(*args[0]); - if (!i::HeapObject::cast(*arg0).IsWasmExceptionObject()) { + if (!i::HeapObject::cast(*arg0).IsWasmTagObject()) { thrower.TypeError("Argument 0 must be a WebAssembly tag"); return; } - auto tag_object = i::Handle::cast(arg0); + auto tag_object = i::Handle::cast(arg0); auto tag = i::Handle( - i::WasmExceptionTag::cast(tag_object->exception_tag()), i_isolate); + i::WasmExceptionTag::cast(tag_object->tag()), i_isolate); uint32_t size = GetEncodedSize(tag_object); i::Handle runtime_exception = i::WasmExceptionPackage::New(i_isolate, tag, size); @@ -1769,7 +1769,7 @@ constexpr const char* kName_WasmGlobalObject = "WebAssembly.Global"; constexpr const char* kName_WasmMemoryObject = "WebAssembly.Memory"; constexpr const char* kName_WasmInstanceObject = "WebAssembly.Instance"; constexpr const char* kName_WasmTableObject = "WebAssembly.Table"; -constexpr const char* kName_WasmExceptionObject = "WebAssembly.Tag"; +constexpr const char* kName_WasmTagObject = "WebAssembly.Tag"; #define EXTRACT_THIS(var, WasmType) \ i::Handle var; \ @@ -2008,7 +2008,7 @@ void WebAssemblyTagType(const v8::FunctionCallbackInfo& args) { i::Isolate* i_isolate = reinterpret_cast(isolate); ScheduledErrorThrower thrower(i_isolate, "WebAssembly.Tag.type()"); - EXTRACT_THIS(tag, WasmExceptionObject); + EXTRACT_THIS(tag, WasmTagObject); if (thrower.error()) return; int n = tag->serialized_signature().length(); @@ -2457,26 +2457,25 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { // Setup Exception if (enabled_features.has_eh()) { - Handle exception_constructor = + Handle tag_constructor = InstallConstructorFunc(isolate, webassembly, "Tag", WebAssemblyTag); - context->set_wasm_exception_constructor(*exception_constructor); + context->set_wasm_tag_constructor(*tag_constructor); - SetDummyInstanceTemplate(isolate, exception_constructor); - JSFunction::EnsureHasInitialMap(exception_constructor); - Handle exception_proto( - JSObject::cast(exception_constructor->instance_prototype()), isolate); + SetDummyInstanceTemplate(isolate, tag_constructor); + JSFunction::EnsureHasInitialMap(tag_constructor); + Handle tag_proto( + JSObject::cast(tag_constructor->instance_prototype()), isolate); if (enabled_features.has_type_reflection()) { - InstallFunc(isolate, exception_proto, "type", WebAssemblyTagType, 0); + InstallFunc(isolate, tag_proto, "type", WebAssemblyTagType, 0); } - Handle exception_map = isolate->factory()->NewMap( - i::WASM_EXCEPTION_OBJECT_TYPE, WasmExceptionObject::kHeaderSize); - JSFunction::SetInitialMap(isolate, exception_constructor, exception_map, - exception_proto); + Handle tag_map = isolate->factory()->NewMap( + i::WASM_TAG_OBJECT_TYPE, WasmTagObject::kHeaderSize); + JSFunction::SetInitialMap(isolate, tag_constructor, tag_map, tag_proto); // Set up runtime exception constructor. - Handle runtime_exception_constructor = InstallConstructorFunc( + Handle exception_constructor = InstallConstructorFunc( isolate, webassembly, "Exception", WebAssemblyException); - SetDummyInstanceTemplate(isolate, runtime_exception_constructor); + SetDummyInstanceTemplate(isolate, exception_constructor); Handle initial_map( isolate->native_context()->wasm_runtime_error_function().initial_map(), isolate); @@ -2484,8 +2483,8 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) { ->wasm_runtime_error_function() .instance_prototype(), isolate); - JSFunction::SetInitialMap(isolate, runtime_exception_constructor, - initial_map, instance_prototype); + JSFunction::SetInitialMap(isolate, exception_constructor, initial_map, + instance_prototype); } // Setup Function @@ -2546,48 +2545,47 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate, Handle webassembly_obj; if (!maybe_webassembly.ToHandle(&webassembly_obj)) { // There is not {WebAssembly} object. We just return without adding the - // {Exception} constructor. + // {Tag} constructor. return; } if (!webassembly_obj->IsJSObject()) { - // The {WebAssembly} object is invalid. As we cannot add the {Exception} + // The {WebAssembly} object is invalid. As we cannot add the {Tag} // constructor, we just return. return; } Handle webassembly = Handle::cast(webassembly_obj); // Setup Exception - Handle exception_name = v8_str(isolate, "Tag"); - if (JSObject::HasOwnProperty(webassembly, exception_name).FromMaybe(true)) { + Handle tag_name = v8_str(isolate, "Tag"); + if (JSObject::HasOwnProperty(webassembly, tag_name).FromMaybe(true)) { // The {Exception} constructor already exists, there is nothing more to // do. return; } bool has_prototype = true; - Handle exception_constructor = - CreateFunc(isolate, exception_name, WebAssemblyTag, has_prototype, + Handle tag_constructor = + CreateFunc(isolate, tag_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)); + tag_constructor->shared().set_length(1); + auto result = + Object::SetProperty(isolate, webassembly, tag_name, tag_constructor, + StoreOrigin::kNamed, Just(ShouldThrow::kDontThrow)); if (result.is_null()) { // Setting the {Tag} constructor failed. We just bail out. return; } // Install the constructor on the context. - context->set_wasm_exception_constructor(*exception_constructor); - SetDummyInstanceTemplate(isolate, exception_constructor); - JSFunction::EnsureHasInitialMap(exception_constructor); - Handle exception_proto( - JSObject::cast(exception_constructor->instance_prototype()), isolate); + context->set_wasm_tag_constructor(*tag_constructor); + SetDummyInstanceTemplate(isolate, tag_constructor); + JSFunction::EnsureHasInitialMap(tag_constructor); + Handle tag_proto( + JSObject::cast(tag_constructor->instance_prototype()), isolate); if (enabled_features.has_type_reflection()) { - InstallFunc(isolate, exception_proto, "type", WebAssemblyTagType, 0); + InstallFunc(isolate, tag_proto, "type", WebAssemblyTagType, 0); } - Handle exception_map = isolate->factory()->NewMap( - i::WASM_EXCEPTION_OBJECT_TYPE, WasmExceptionObject::kHeaderSize); - JSFunction::SetInitialMap(isolate, exception_constructor, exception_map, - exception_proto); + Handle tag_map = isolate->factory()->NewMap( + i::WASM_TAG_OBJECT_TYPE, WasmTagObject::kHeaderSize); + JSFunction::SetInitialMap(isolate, tag_constructor, tag_map, tag_proto); } } #undef ASSIGN diff --git a/src/wasm/wasm-limits.h b/src/wasm/wasm-limits.h index 9e2ddc7fcc..b7806af797 100644 --- a/src/wasm/wasm-limits.h +++ b/src/wasm/wasm-limits.h @@ -31,7 +31,7 @@ constexpr size_t kV8MaxWasmFunctions = 1000000; constexpr size_t kV8MaxWasmImports = 100000; constexpr size_t kV8MaxWasmExports = 100000; constexpr size_t kV8MaxWasmGlobals = 1000000; -constexpr size_t kV8MaxWasmExceptions = 1000000; +constexpr size_t kV8MaxWasmTags = 1000000; constexpr size_t kV8MaxWasmExceptionTypes = 1000000; constexpr size_t kV8MaxWasmDataSegments = 100000; // This indicates the maximum memory size our implementation supports. diff --git a/src/wasm/wasm-module-builder.cc b/src/wasm/wasm-module-builder.cc index e5209cdcde..2bf20ea3ec 100644 --- a/src/wasm/wasm-module-builder.cc +++ b/src/wasm/wasm-module-builder.cc @@ -687,7 +687,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const { // Emit event section. if (exceptions_.size() > 0) { - size_t start = EmitSection(kExceptionSectionCode, buffer); + size_t start = EmitSection(kTagSectionCode, buffer); buffer->write_size(exceptions_.size()); for (int type : exceptions_) { buffer->write_u32v(kExceptionAttribute); @@ -730,7 +730,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const { // yet, so there is no index offset to add. buffer->write_size(ex.index); break; - case kExternalException: + case kExternalTag: UNREACHABLE(); } } diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc index caa2f7d59a..97a31487ea 100644 --- a/src/wasm/wasm-module.cc +++ b/src/wasm/wasm-module.cc @@ -354,7 +354,7 @@ Handle GetImports(Isolate* isolate, Handle table_string = factory->InternalizeUtf8String("table"); Handle memory_string = factory->InternalizeUtf8String("memory"); Handle global_string = factory->InternalizeUtf8String("global"); - Handle exception_string = factory->InternalizeUtf8String("exception"); + Handle tag_string = factory->InternalizeUtf8String("tag"); // Create the result array. const WasmModule* module = module_object->module(); @@ -413,8 +413,8 @@ Handle GetImports(Isolate* isolate, } import_kind = global_string; break; - case kExternalException: - import_kind = exception_string; + case kExternalTag: + import_kind = tag_string; break; } DCHECK(!import_kind->is_null()); @@ -453,7 +453,7 @@ Handle GetExports(Isolate* isolate, Handle table_string = factory->InternalizeUtf8String("table"); Handle memory_string = factory->InternalizeUtf8String("memory"); Handle global_string = factory->InternalizeUtf8String("global"); - Handle exception_string = factory->InternalizeUtf8String("exception"); + Handle tag_string = factory->InternalizeUtf8String("tag"); // Create the result array. const WasmModule* module = module_object->module(); @@ -510,8 +510,8 @@ Handle GetExports(Isolate* isolate, } export_kind = global_string; break; - case kExternalException: - export_kind = exception_string; + case kExternalTag: + export_kind = tag_string; break; default: UNREACHABLE(); @@ -618,7 +618,7 @@ size_t EstimateStoredSize(const WasmModule* module) { VectorSize(module->canonicalized_type_ids) + VectorSize(module->functions) + VectorSize(module->data_segments) + VectorSize(module->tables) + VectorSize(module->import_table) + - VectorSize(module->export_table) + VectorSize(module->exceptions) + + VectorSize(module->export_table) + VectorSize(module->tags) + VectorSize(module->elem_segments); } diff --git a/src/wasm/wasm-module.h b/src/wasm/wasm-module.h index 7c67a5a71b..d1f874a908 100644 --- a/src/wasm/wasm-module.h +++ b/src/wasm/wasm-module.h @@ -80,16 +80,16 @@ struct WasmGlobal { bool exported; // true if exported. }; -// Note: An exception signature only uses the params portion of a -// function signature. -using WasmExceptionSig = FunctionSig; +// Note: An exception tag signature only uses the params portion of a function +// signature. +using WasmTagSig = FunctionSig; -// Static representation of a wasm exception type. -struct WasmException { - explicit WasmException(const WasmExceptionSig* sig) : sig(sig) {} +// Static representation of a wasm tag type. +struct WasmTag { + explicit WasmTag(const WasmTagSig* sig) : sig(sig) {} const FunctionSig* ToFunctionSig() const { return sig; } - const WasmExceptionSig* sig; // type signature of the exception. + const WasmTagSig* sig; // type signature of the tag. }; // Static representation of a wasm data segment. @@ -342,7 +342,7 @@ struct V8_EXPORT_PRIVATE WasmModule { std::vector tables; std::vector import_table; std::vector export_table; - std::vector exceptions; + std::vector tags; std::vector elem_segments; std::vector compilation_hints; BranchHintInfo branch_hints; diff --git a/src/wasm/wasm-objects-inl.h b/src/wasm/wasm-objects-inl.h index 69668e225b..a75d83df02 100644 --- a/src/wasm/wasm-objects-inl.h +++ b/src/wasm/wasm-objects-inl.h @@ -35,7 +35,7 @@ namespace internal { #include "torque-generated/src/wasm/wasm-objects-tq-inl.inc" -TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExceptionObject) +TQ_OBJECT_CONSTRUCTORS_IMPL(WasmTagObject) TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExceptionTag) TQ_OBJECT_CONSTRUCTORS_IMPL(WasmCapiFunctionData) TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExportedFunctionData) @@ -249,8 +249,7 @@ OPTIONAL_ACCESSORS(WasmInstanceObject, indirect_function_table_refs, FixedArray, kIndirectFunctionTableRefsOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, managed_native_allocations, Foreign, kManagedNativeAllocationsOffset) -OPTIONAL_ACCESSORS(WasmInstanceObject, exceptions_table, FixedArray, - kExceptionsTableOffset) +OPTIONAL_ACCESSORS(WasmInstanceObject, tags_table, FixedArray, kTagsTableOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, wasm_external_functions, FixedArray, kWasmExternalFunctionsOffset) ACCESSORS(WasmInstanceObject, managed_object_maps, FixedArray, diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc index c71e68e158..4c91cc283e 100644 --- a/src/wasm/wasm-objects.cc +++ b/src/wasm/wasm-objects.cc @@ -1704,11 +1704,11 @@ Address WasmArray::ElementAddress(uint32_t index) { } // static -Handle WasmExceptionObject::New( - Isolate* isolate, const wasm::FunctionSig* sig, - Handle exception_tag) { - Handle exception_cons( - isolate->native_context()->wasm_exception_constructor(), isolate); +Handle WasmTagObject::New(Isolate* isolate, + const wasm::FunctionSig* sig, + Handle tag) { + Handle tag_cons(isolate->native_context()->wasm_tag_constructor(), + isolate); // Serialize the signature. DCHECK_EQ(0, sig->return_count()); @@ -1721,18 +1721,17 @@ Handle WasmExceptionObject::New( serialized_sig->set(index++, param); } - Handle exception_object = - isolate->factory()->NewJSObject(exception_cons, AllocationType::kOld); - Handle exception = - Handle::cast(exception_object); - exception->set_serialized_signature(*serialized_sig); - exception->set_exception_tag(*exception_tag); + Handle tag_object = + isolate->factory()->NewJSObject(tag_cons, AllocationType::kOld); + Handle tag_wrapper = Handle::cast(tag_object); + tag_wrapper->set_serialized_signature(*serialized_sig); + tag_wrapper->set_tag(*tag); - return exception; + return tag_wrapper; } // TODO(9495): Update this if function type variance is introduced. -bool WasmExceptionObject::MatchesSignature(const wasm::FunctionSig* sig) { +bool WasmTagObject::MatchesSignature(const wasm::FunctionSig* sig) { DCHECK_EQ(0, sig->return_count()); DCHECK_LE(sig->parameter_count(), std::numeric_limits::max()); int sig_size = static_cast(sig->parameter_count()); @@ -1844,9 +1843,8 @@ size_t ComputeEncodedElementSize(wasm::ValueType type) { #endif // DEBUG // static -uint32_t WasmExceptionPackage::GetEncodedSize( - const wasm::WasmException* exception) { - const wasm::WasmExceptionSig* sig = exception->sig; +uint32_t WasmExceptionPackage::GetEncodedSize(const wasm::WasmTag* tag) { + const wasm::WasmTagSig* sig = tag->sig; uint32_t encoded_size = 0; for (size_t i = 0; i < sig->parameter_count(); ++i) { switch (sig->GetParam(i).kind()) { diff --git a/src/wasm/wasm-objects.h b/src/wasm/wasm-objects.h index a4e2ef0abe..c91e512768 100644 --- a/src/wasm/wasm-objects.h +++ b/src/wasm/wasm-objects.h @@ -31,9 +31,9 @@ namespace wasm { class InterpretedFrame; class NativeModule; class WasmCode; -struct WasmException; struct WasmGlobal; struct WasmModule; +struct WasmTag; class WasmValue; class WireBytesRef; } // namespace wasm @@ -351,7 +351,7 @@ class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject { DECL_ACCESSORS(imported_function_refs, FixedArray) DECL_OPTIONAL_ACCESSORS(indirect_function_table_refs, FixedArray) DECL_OPTIONAL_ACCESSORS(managed_native_allocations, Foreign) - DECL_OPTIONAL_ACCESSORS(exceptions_table, FixedArray) + DECL_OPTIONAL_ACCESSORS(tags_table, FixedArray) DECL_OPTIONAL_ACCESSORS(wasm_external_functions, FixedArray) DECL_ACCESSORS(managed_object_maps, FixedArray) DECL_PRIMITIVE_ACCESSORS(memory_start, byte*) @@ -429,7 +429,7 @@ class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject { V(kTablesOffset, kTaggedSize) \ V(kIndirectFunctionTablesOffset, kTaggedSize) \ V(kManagedNativeAllocationsOffset, kTaggedSize) \ - V(kExceptionsTableOffset, kTaggedSize) \ + V(kTagsTableOffset, kTaggedSize) \ V(kWasmExternalFunctionsOffset, kTaggedSize) \ V(kManagedObjectMapsOffset, kTaggedSize) \ V(kBreakOnEntryOffset, kUInt8Size) \ @@ -465,7 +465,7 @@ class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject { kTablesOffset, kIndirectFunctionTablesOffset, kManagedNativeAllocationsOffset, - kExceptionsTableOffset, + kTagsTableOffset, kWasmExternalFunctionsOffset, kManagedObjectMapsOffset}; @@ -552,21 +552,21 @@ class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject { }; // Representation of WebAssembly.Exception JavaScript-level object. -class WasmExceptionObject - : public TorqueGeneratedWasmExceptionObject { +class WasmTagObject + : public TorqueGeneratedWasmTagObject { public: // Dispatched behavior. - DECL_PRINTER(WasmExceptionObject) + DECL_PRINTER(WasmTagObject) // Checks whether the given {sig} has the same parameter types as the - // serialized signature stored within this exception object. + // serialized signature stored within this tag object. bool MatchesSignature(const wasm::FunctionSig* sig); - static Handle New(Isolate* isolate, - const wasm::FunctionSig* sig, - Handle exception_tag); + static Handle New(Isolate* isolate, + const wasm::FunctionSig* sig, + Handle tag); - TQ_OBJECT_CONSTRUCTORS(WasmExceptionObject) + TQ_OBJECT_CONSTRUCTORS(WasmTagObject) }; // A Wasm exception that has been thrown out of Wasm code. @@ -584,7 +584,7 @@ class V8_EXPORT_PRIVATE WasmExceptionPackage : public JSObject { Isolate* isolate, Handle exception_package); // Determines the size of the array holding all encoded exception values. - static uint32_t GetEncodedSize(const wasm::WasmException* exception); + static uint32_t GetEncodedSize(const wasm::WasmTag* tag); DECL_CAST(WasmExceptionPackage) OBJECT_CONSTRUCTORS(WasmExceptionPackage, JSObject); @@ -822,8 +822,8 @@ class WasmScript : public AllStatic { // Tags provide an object identity for each exception defined in a wasm module // header. They are referenced by the following fields: -// - {WasmExceptionObject::exception_tag} : The tag of the exception object. -// - {WasmInstanceObject::exceptions_table}: List of tags used by an instance. +// - {WasmTagObject::tag}: The tag of the {Tag} object. +// - {WasmInstanceObject::tags_table}: List of tags used by an instance. class WasmExceptionTag : public TorqueGeneratedWasmExceptionTag { public: diff --git a/src/wasm/wasm-objects.tq b/src/wasm/wasm-objects.tq index f97d1bf691..dfdee08eed 100644 --- a/src/wasm/wasm-objects.tq +++ b/src/wasm/wasm-objects.tq @@ -112,9 +112,9 @@ extern class WasmGlobalObject extends JSObject { is_mutable: Smi; } -extern class WasmExceptionObject extends JSObject { +extern class WasmTagObject extends JSObject { serialized_signature: PodArrayOfWasmValueType; - exception_tag: HeapObject; + tag: HeapObject; } type WasmExportedFunction extends JSFunction; diff --git a/test/cctest/wasm/wasm-run-utils.cc b/test/cctest/wasm/wasm-run-utils.cc index 940a42beaa..2638adad28 100644 --- a/test/cctest/wasm/wasm-run-utils.cc +++ b/test/cctest/wasm/wasm-run-utils.cc @@ -246,12 +246,12 @@ uint32_t TestingModuleBuilder::AddBytes(base::Vector bytes) { uint32_t TestingModuleBuilder::AddException(const FunctionSig* sig) { DCHECK_EQ(0, sig->return_count()); - uint32_t index = static_cast(test_module_->exceptions.size()); - test_module_->exceptions.push_back(WasmException{sig}); + uint32_t index = static_cast(test_module_->tags.size()); + test_module_->tags.push_back(WasmTag{sig}); Handle tag = WasmExceptionTag::New(isolate_, index); - Handle table(instance_object_->exceptions_table(), isolate_); + Handle table(instance_object_->tags_table(), isolate_); table = isolate_->factory()->CopyFixedArrayAndGrow(table, 1); - instance_object_->set_exceptions_table(*table); + instance_object_->set_tags_table(*table); table->set(index, *tag); return index; } @@ -351,7 +351,7 @@ Handle TestingModuleBuilder::InitInstanceObject() { native_module_->ReserveCodeTableForTesting(kMaxFunctions); auto instance = WasmInstanceObject::New(isolate_, module_object); - instance->set_exceptions_table(*isolate_->factory()->empty_fixed_array()); + instance->set_tags_table(*isolate_->factory()->empty_fixed_array()); instance->set_globals_start(globals_data_); return instance; } diff --git a/test/common/wasm/wasm-interpreter.cc b/test/common/wasm/wasm-interpreter.cc index 3f5e34102d..240d59c35b 100644 --- a/test/common/wasm/wasm-interpreter.cc +++ b/test/common/wasm/wasm-interpreter.cc @@ -607,7 +607,7 @@ class SideTable : public ZoneObject { const int32_t stack_height; }; struct CatchTarget { - int exception_index; + int tag_index; int target_control_index; const byte* pc; }; @@ -628,8 +628,8 @@ class SideTable : public ZoneObject { target = pc; } - void Bind(const byte* pc, int exception_index, int target_control_index) { - catch_targets.push_back({exception_index, target_control_index, pc}); + void Bind(const byte* pc, int tag_index, int target_control_index) { + catch_targets.push_back({tag_index, target_control_index, pc}); } // Reference this label from the given location. @@ -665,12 +665,12 @@ class SideTable : public ZoneObject { "control transfer @%zu: Δpc %d, stack %u->%u, exn: %d = " "-%u\n", offset, pcdiff, ref.stack_height, target_stack_height, - p.exception_index, spdiff); + p.tag_index, spdiff); CatchControlTransferEntry entry; entry.pc_diff = pcdiff; entry.sp_diff = spdiff; entry.target_arity = arity; - entry.exception_index = p.exception_index; + entry.tag_index = p.tag_index; entry.target_control_index = p.target_control_index; catch_entries.emplace_back(entry); } @@ -731,10 +731,9 @@ class SideTable : public ZoneObject { }; int max_exception_arity = 0; if (module) { - for (auto& exception : module->exceptions) { - max_exception_arity = - std::max(max_exception_arity, - static_cast(exception.sig->parameter_count())); + for (auto& tag : module->tags) { + max_exception_arity = std::max( + max_exception_arity, static_cast(tag.sig->parameter_count())); } } for (BytecodeIterator i(code->start, code->end, &code->locals); @@ -898,7 +897,7 @@ class SideTable : public ZoneObject { // Only pop the exception stack once when we enter the first catch. exception_stack.pop_back(); } - ExceptionIndexImmediate imm(&i, i.pc() + 1); + TagIndexImmediate imm(&i, i.pc() + 1); Control* c = &control_stack.back(); copy_unreachable(); TRACE("control @%u: Catch\n", i.pc_offset()); @@ -911,9 +910,8 @@ class SideTable : public ZoneObject { DCHECK_IMPLIES(!unreachable, stack_height >= c->end_label->target_stack_height); - const FunctionSig* exception_sig = module->exceptions[imm.index].sig; - int catch_in_arity = - static_cast(exception_sig->parameter_count()); + const FunctionSig* tag_sig = module->tags[imm.index].sig; + int catch_in_arity = static_cast(tag_sig->parameter_count()); stack_height = c->end_label->target_stack_height + catch_in_arity; break; } @@ -1459,24 +1457,22 @@ class WasmInterpreterInternals { } CatchControlTransferEntry* handler = nullptr; for (auto& entry : it->second) { - if (entry.exception_index < 0) { + if (entry.tag_index < 0) { ResetStack(StackHeight() - entry.sp_diff); *pc += entry.pc_diff; - if (entry.exception_index == kRethrowOrDelegateExceptionIndex) { + if (entry.tag_index == kRethrowOrDelegateExceptionIndex) { // Recursively try to find a handler in the next enclosing try block // (for the implicit rethrow) or in the delegate target. return JumpToHandlerDelta(code, exception_object, pc); } handler = &entry; break; - } else if (MatchingExceptionTag(exception_object, - entry.exception_index)) { + } else if (MatchingExceptionTag(exception_object, entry.tag_index)) { handler = &entry; - const WasmException* exception = - &module()->exceptions[entry.exception_index]; - const FunctionSig* sig = exception->sig; + const WasmTag* tag = &module()->tags[entry.tag_index]; + const FunctionSig* sig = tag->sig; int catch_in_arity = static_cast(sig->parameter_count()); - DoUnpackException(exception, exception_object); + DoUnpackException(tag, exception_object); DoStackTransfer(entry.sp_diff + catch_in_arity, catch_in_arity); *pc += handler->pc_diff; break; @@ -3086,13 +3082,13 @@ class WasmInterpreterInternals { // Allocate, initialize and throw a new exception. The exception values are // being popped off the operand stack. Returns true if the exception is being // handled locally by the interpreter, false otherwise (interpreter exits). - bool DoThrowException(const WasmException* exception, + bool DoThrowException(const WasmTag* tag, uint32_t index) V8_WARN_UNUSED_RESULT { HandleScope handle_scope(isolate_); // Avoid leaking handles. Handle exception_tag( - WasmExceptionTag::cast(instance_object_->exceptions_table().get(index)), + WasmExceptionTag::cast(instance_object_->tags_table().get(index)), isolate_); - uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(exception); + uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(tag); Handle exception_object = WasmExceptionPackage::New(isolate_, exception_tag, encoded_size); Handle encoded_values = Handle::cast( @@ -3100,7 +3096,7 @@ class WasmInterpreterInternals { // Encode the exception values on the operand stack into the exception // package allocated above. This encoding has to be in sync with other // backends so that exceptions can be passed between them. - const WasmExceptionSig* sig = exception->sig; + const WasmTagSig* sig = tag->sig; uint32_t encoded_index = 0; sp_t base_index = StackHeight() - sig->parameter_count(); for (size_t i = 0; i < sig->parameter_count(); ++i) { @@ -3185,7 +3181,7 @@ class WasmInterpreterInternals { Handle caught_tag = WasmExceptionPackage::GetExceptionTag( isolate_, Handle::cast(exception_object)); Handle expected_tag = - handle(instance_object_->exceptions_table().get(index), isolate_); + handle(instance_object_->tags_table().get(index), isolate_); DCHECK(expected_tag->IsWasmExceptionTag()); return expected_tag.is_identical_to(caught_tag); } @@ -3208,15 +3204,14 @@ class WasmInterpreterInternals { // Unpack the values encoded in the given exception. The exception values are // pushed onto the operand stack. Callers must perform a tag check to ensure // the encoded values match the expected signature of the exception. - void DoUnpackException(const WasmException* exception, - Handle exception_object) { + void DoUnpackException(const WasmTag* tag, Handle exception_object) { Handle encoded_values = Handle::cast(WasmExceptionPackage::GetExceptionValues( isolate_, Handle::cast(exception_object))); // Decode the exception values from the given exception package and push // them onto the operand stack. This encoding has to be in sync with other // backends so that exceptions can be passed between them. - const WasmExceptionSig* sig = exception->sig; + const WasmTagSig* sig = tag->sig; uint32_t encoded_index = 0; for (size_t i = 0; i < sig->parameter_count(); ++i) { WasmValue value; @@ -3285,7 +3280,7 @@ class WasmInterpreterInternals { } Push(value); } - DCHECK_EQ(WasmExceptionPackage::GetEncodedSize(exception), encoded_index); + DCHECK_EQ(WasmExceptionPackage::GetEncodedSize(tag), encoded_index); } void Execute(InterpreterCode* code, pc_t pc, int max) { @@ -3375,11 +3370,11 @@ class WasmInterpreterInternals { break; } case kExprThrow: { - ExceptionIndexImmediate imm(&decoder, - code->at(pc + 1)); + TagIndexImmediate imm(&decoder, + code->at(pc + 1)); CommitPc(pc); // Needed for local unwinding. - const WasmException* exception = &module()->exceptions[imm.index]; - if (!DoThrowException(exception, imm.index)) return; + const WasmTag* tag = &module()->tags[imm.index]; + if (!DoThrowException(tag, imm.index)) return; ReloadFromFrameOnException(&decoder, &code, &pc, &limit); continue; // Do not bump pc. } diff --git a/test/common/wasm/wasm-interpreter.h b/test/common/wasm/wasm-interpreter.h index ab89f5dc15..97fdaa426f 100644 --- a/test/common/wasm/wasm-interpreter.h +++ b/test/common/wasm/wasm-interpreter.h @@ -40,7 +40,7 @@ struct ControlTransferEntry { }; struct CatchControlTransferEntry : public ControlTransferEntry { - int exception_index; + int tag_index; int target_control_index; }; diff --git a/test/message/fail/wasm-exception-rethrow.js b/test/message/fail/wasm-exception-rethrow.js index d7b615653c..fb600726f1 100644 --- a/test/message/fail/wasm-exception-rethrow.js +++ b/test/message/fail/wasm-exception-rethrow.js @@ -7,7 +7,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); let builder = new WasmModuleBuilder(); -let except = builder.addException(kSig_v_i); +let except = builder.addTag(kSig_v_i); builder.addFunction("rethrow0", kSig_v_v) .addBody([ kExprTry, kWasmVoid, diff --git a/test/message/fail/wasm-exception-throw.js b/test/message/fail/wasm-exception-throw.js index 63ed2f76a0..827ff86dd4 100644 --- a/test/message/fail/wasm-exception-throw.js +++ b/test/message/fail/wasm-exception-throw.js @@ -7,7 +7,7 @@ d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js'); let builder = new WasmModuleBuilder(); -let except = builder.addException(kSig_v_i); +let except = builder.addTag(kSig_v_i); builder.addFunction("throw0", kSig_v_v) .addBody([ kExprI32Const, 23, diff --git a/test/mjsunit/regress/wasm/regress-1188825.js b/test/mjsunit/regress/wasm/regress-1188825.js index a575b61324..89ac80eac3 100644 --- a/test/mjsunit/regress/wasm/regress-1188825.js +++ b/test/mjsunit/regress/wasm/regress-1188825.js @@ -9,7 +9,7 @@ let proxy = new Proxy(obj, {}); let builder = new WasmModuleBuilder(); builder.addType(kSig_v_v); let imports = builder.addImport("m","f", kSig_v_v); -let exception = builder.addException(kSig_v_v); +let exception = builder.addTag(kSig_v_v); builder.addFunction("foo", kSig_v_v) .addBody([ kExprTry, diff --git a/test/mjsunit/regress/wasm/regress-8094.js b/test/mjsunit/regress/wasm/regress-8094.js index ea21614e5b..42947e5eb4 100644 --- a/test/mjsunit/regress/wasm/regress-8094.js +++ b/test/mjsunit/regress/wasm/regress-8094.js @@ -8,7 +8,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); // Instantiate a throwing module. var builder = new WasmModuleBuilder(); -builder.addException(kSig_v_v); +builder.addTag(kSig_v_v); builder.addFunction("propel", kSig_v_v) .addBody([kExprThrow, 0]) .exportFunc(); diff --git a/test/mjsunit/regress/wasm/regress-8846.js b/test/mjsunit/regress/wasm/regress-8846.js index 9e9ca4f819..d8acc3741b 100644 --- a/test/mjsunit/regress/wasm/regress-8846.js +++ b/test/mjsunit/regress/wasm/regress-8846.js @@ -6,10 +6,10 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); -(function TestAsyncCompileExceptionSection() { +(function TestAsyncCompileTagSection() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("thrw", kSig_v_v) .addBody([ kExprThrow, except, diff --git a/test/mjsunit/regress/wasm/regress-8896.js b/test/mjsunit/regress/wasm/regress-8896.js index 7f73846f92..e89ed6cb8b 100644 --- a/test/mjsunit/regress/wasm/regress-8896.js +++ b/test/mjsunit/regress/wasm/regress-8896.js @@ -10,7 +10,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); (function TestSerializeDeserializeRuntimeCall() { var builder = new WasmModuleBuilder(); - var except = builder.addException(kSig_v_v); + var except = builder.addTag(kSig_v_v); builder.addFunction("f", kSig_v_v) .addBody([ kExprThrow, except, diff --git a/test/mjsunit/wasm/exceptions-api.js b/test/mjsunit/wasm/exceptions-api.js index 708a5cfa24..16e4aa8697 100644 --- a/test/mjsunit/wasm/exceptions-api.js +++ b/test/mjsunit/wasm/exceptions-api.js @@ -21,7 +21,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); 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); + builder.addImportedTag("m", "ex", kSig_v_i); assertDoesNotThrow(() => builder.instantiate({ m: { ex: js_except_i32 }})); assertThrows( @@ -35,8 +35,8 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); (function TestExport() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex", kExternalException, except); + let except = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex", kExternalTag, except); let instance = builder.instantiate(); assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex')); @@ -50,8 +50,8 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); 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); + let index = builder.addImportedTag("m", "ex", kSig_v_i); + builder.addExportOfKind("ex", kExternalTag, index); let instance = builder.instantiate({ m: { ex: js_ex_i32 }}); let res = instance.exports.ex; @@ -77,7 +77,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); // Check prototype of a thrown exception. let builder = new WasmModuleBuilder(); - let wasm_tag = builder.addException(kSig_v_v); + let wasm_tag = builder.addTag(kSig_v_v); builder.addFunction("throw", kSig_v_v) .addBody([kExprThrow, wasm_tag]).exportFunc(); let instance = builder.instantiate(); @@ -102,9 +102,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); let builder = new WasmModuleBuilder(); let js_tag = new WebAssembly.Tag({parameters: []}); let js_func_index = builder.addImport('m', 'js_func', kSig_v_v); - let js_tag_index = builder.addImportedException("m", "js_tag", kSig_v_v); - let tag_index = builder.addException(kSig_v_v); - builder.addExportOfKind("wasm_tag", kExternalException, tag_index); + let js_tag_index = builder.addImportedTag("m", "js_tag", kSig_v_v); + let tag_index = builder.addTag(kSig_v_v); + builder.addExportOfKind("wasm_tag", kExternalTag, tag_index); builder.addFunction("catch", kSig_i_v) .addBody([ kExprTry, kWasmI32, @@ -134,10 +134,10 @@ function TestCatchJS(types_str, types, values) { let js_func_index = builder.addImport('m', 'js_func', kSig_v_v); let sig1 = makeSig(types, []); let sig2 = makeSig([], types); - let js_tag_index = builder.addImportedException("m", "js_tag", sig1); - let tag_index = builder.addException(sig1); + let js_tag_index = builder.addImportedTag("m", "js_tag", sig1); + let tag_index = builder.addTag(sig1); let return_type = builder.addType(sig2); - builder.addExportOfKind("wasm_tag", kExternalException, tag_index); + builder.addExportOfKind("wasm_tag", kExternalTag, tag_index); builder.addFunction("catch", sig2) .addBody([ kExprTry, return_type, diff --git a/test/mjsunit/wasm/exceptions-export.js b/test/mjsunit/wasm/exceptions-export.js index 823688bdee..1bd2cc0602 100644 --- a/test/mjsunit/wasm/exceptions-export.js +++ b/test/mjsunit/wasm/exceptions-export.js @@ -9,11 +9,11 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); (function TestExportMultiple() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_i); - builder.addExportOfKind("ex1a", kExternalException, except1); - builder.addExportOfKind("ex1b", kExternalException, except1); - builder.addExportOfKind("ex2", kExternalException, except2); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_i); + builder.addExportOfKind("ex1a", kExternalTag, except1); + builder.addExportOfKind("ex1b", kExternalTag, except1); + builder.addExportOfKind("ex2", kExternalTag, except2); let instance = builder.instantiate(); assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex1a')); @@ -26,32 +26,32 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); (function TestExportOutOfBounds() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex_oob", kExternalException, except + 1); + let except = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex_oob", kExternalTag, except + 1); assertThrows( () => builder.instantiate(), WebAssembly.CompileError, - 'WebAssembly.Module(): exception index 1 out of bounds (1 entry) @+30'); + 'WebAssembly.Module(): tag index 1 out of bounds (1 entry) @+30'); })(); (function TestExportSameNameTwice() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex", kExternalException, except); - builder.addExportOfKind("ex", kExternalException, except); + let except = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex", kExternalTag, except); + builder.addExportOfKind("ex", kExternalTag, except); assertThrows( () => builder.instantiate(), WebAssembly.CompileError, 'WebAssembly.Module(): Duplicate export name \'ex\' ' + - 'for exception 0 and exception 0 @+28'); + 'for tag 0 and tag 0 @+28'); })(); (function TestExportModuleGetExports() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex", kExternalException, except); + let except = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex", kExternalTag, except); let module = new WebAssembly.Module(builder.toBuffer()); let exports = WebAssembly.Module.exports(module); - assertArrayEquals([{ name: "ex", kind: "exception" }], exports); + assertArrayEquals([{ name: "ex", kind: "tag" }], exports); })(); diff --git a/test/mjsunit/wasm/exceptions-externref.js b/test/mjsunit/wasm/exceptions-externref.js index 6bc5ffd71b..130c73e693 100644 --- a/test/mjsunit/wasm/exceptions-externref.js +++ b/test/mjsunit/wasm/exceptions-externref.js @@ -11,7 +11,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowRefNull() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_r); + let except = builder.addTag(kSig_v_r); builder.addFunction("throw_null", kSig_v_v) .addBody([ kExprRefNull, kWasmExternRef, @@ -26,7 +26,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchRefNull() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_r); + let except = builder.addTag(kSig_v_r); builder.addFunction("throw_catch_null", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -57,7 +57,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowRefParam() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_r); + let except = builder.addTag(kSig_v_r); builder.addFunction("throw_param", kSig_v_r) .addBody([ kExprLocalGet, 0, @@ -76,7 +76,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchRefParam() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_r); + let except = builder.addTag(kSig_v_r); builder.addFunction("throw_catch_param", kSig_r_r) .addBody([ kExprTry, kWasmExternRef, diff --git a/test/mjsunit/wasm/exceptions-import.js b/test/mjsunit/wasm/exceptions-import.js index 2e472054c1..8297c90ce7 100644 --- a/test/mjsunit/wasm/exceptions-import.js +++ b/test/mjsunit/wasm/exceptions-import.js @@ -9,32 +9,32 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); // Helper function to return a new exported exception with the {kSig_v_v} type // signature from an anonymous module. The underlying module is thrown away. // This allows tests to reason solely about importing exceptions. -function NewExportedException() { +function NewExportedTag() { let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex", kExternalException, except); + let tag = builder.addTag(kSig_v_v); + builder.addExportOfKind("t", kExternalTag, tag); let instance = builder.instantiate(); - return instance.exports.ex; + return instance.exports.t; } (function TestImportSimple() { print(arguments.callee.name); - let exported = NewExportedException(); + let exported = NewExportedTag(); let builder = new WasmModuleBuilder(); - let except = builder.addImportedException("m", "ex", kSig_v_v); + let except = builder.addImportedTag("m", "ex", kSig_v_v); assertDoesNotThrow(() => builder.instantiate({ m: { ex: exported }})); })(); (function TestImportMultiple() { print(arguments.callee.name); - let exported = NewExportedException(); + let exported = NewExportedTag(); let builder = new WasmModuleBuilder(); - let except1 = builder.addImportedException("m", "ex1", kSig_v_v); - let except2 = builder.addImportedException("m", "ex2", kSig_v_v); - let except3 = builder.addException(kSig_v_v); - builder.addExportOfKind("ex2", kExternalException, except2); - builder.addExportOfKind("ex3", kExternalException, except3); + let except1 = builder.addImportedTag("m", "ex1", kSig_v_v); + let except2 = builder.addImportedTag("m", "ex2", kSig_v_v); + let except3 = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex2", kExternalTag, except2); + builder.addExportOfKind("ex3", kExternalTag, except3); let instance = builder.instantiate({ m: { ex1: exported, ex2: exported }}); assertTrue(except1 < except3 && except2 < except3); @@ -46,7 +46,7 @@ function NewExportedException() { (function TestImportMissing() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addImportedException("m", "ex", kSig_v_v); + let except = builder.addImportedTag("m", "ex", kSig_v_v); assertThrows( () => builder.instantiate({}), TypeError, @@ -59,7 +59,7 @@ function NewExportedException() { (function TestImportValueMismatch() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addImportedException("m", "ex", kSig_v_v); + let except = builder.addImportedTag("m", "ex", kSig_v_v); assertThrows( () => builder.instantiate({ m: { ex: 23 }}), WebAssembly.LinkError, @@ -67,7 +67,7 @@ function NewExportedException() { assertThrows( () => builder.instantiate({ m: { ex: {} }}), WebAssembly.LinkError, /tag import requires a WebAssembly.Tag/); - var monkey = Object.create(NewExportedException()); + var monkey = Object.create(NewExportedTag()); assertThrows( () => builder.instantiate({ m: { ex: monkey }}), WebAssembly.LinkError, /tag import requires a WebAssembly.Tag/); @@ -75,9 +75,9 @@ function NewExportedException() { (function TestImportSignatureMismatch() { print(arguments.callee.name); - let exported = NewExportedException(); + let exported = NewExportedTag(); let builder = new WasmModuleBuilder(); - let except = builder.addImportedException("m", "ex", kSig_v_i); + let except = builder.addImportedTag("m", "ex", kSig_v_i); assertThrows( () => builder.instantiate({ m: { ex: exported }}), WebAssembly.LinkError, @@ -87,9 +87,9 @@ function NewExportedException() { (function TestImportModuleGetImports() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addImportedException("m", "ex", kSig_v_v); + let except = builder.addImportedTag("m", "ex", kSig_v_v); let module = new WebAssembly.Module(builder.toBuffer()); let imports = WebAssembly.Module.imports(module); - assertArrayEquals([{ module: "m", name: "ex", kind: "exception" }], imports); + assertArrayEquals([{ module: "m", name: "ex", kind: "tag" }], imports); })(); diff --git a/test/mjsunit/wasm/exceptions-rethrow.js b/test/mjsunit/wasm/exceptions-rethrow.js index 7920ac73f8..13421a4cf1 100644 --- a/test/mjsunit/wasm/exceptions-rethrow.js +++ b/test/mjsunit/wasm/exceptions-rethrow.js @@ -11,7 +11,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestRethrowInCatch() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("rethrow0", kSig_v_v) .addBody([ kExprTry, kWasmVoid, @@ -44,7 +44,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestRethrowInCatchAll() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("rethrow0", kSig_v_v) .addBody([ kExprTry, kWasmVoid, @@ -78,8 +78,8 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestRethrowNested() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); builder.addFunction("rethrow_nested", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -116,7 +116,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestRethrowRecatch() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("rethrow_recatch", kSig_i_i) .addBody([ kExprTry, kWasmI32, diff --git a/test/mjsunit/wasm/exceptions-shared.js b/test/mjsunit/wasm/exceptions-shared.js index 4c2f8a7fde..f4b90c09e6 100644 --- a/test/mjsunit/wasm/exceptions-shared.js +++ b/test/mjsunit/wasm/exceptions-shared.js @@ -10,8 +10,8 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js"); // signature from an anonymous module. The underlying module is thrown away. function NewExportedException() { let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); - builder.addExportOfKind("ex", kExternalException, except); + let except = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex", kExternalTag, except); let instance = builder.instantiate(); return instance.exports.ex; } @@ -23,7 +23,7 @@ function NewExportedException() { let builder = new WasmModuleBuilder(); let sig_index = builder.addType(kSig_v_v); let fun = builder.addImport("m", "f", sig_index); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("throw", kSig_v_v) .addBody([ kExprThrow, except @@ -55,7 +55,7 @@ function NewExportedException() { let builder = new WasmModuleBuilder(); let sig_index = builder.addType(kSig_v_v); let fun = builder.addImport("m", "f", sig_index); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("throw", kSig_v_v) .addBody([ kExprThrow, except @@ -88,9 +88,9 @@ function NewExportedException() { let builder = new WasmModuleBuilder(); let sig_index = builder.addType(kSig_v_v); let fun = builder.addImport("m", "f", sig_index); - let except1 = builder.addImportedException("m", "ex1", kSig_v_v); - let except2 = builder.addException(kSig_v_v); - builder.addExportOfKind("ex2", kExternalException, except2); + let except1 = builder.addImportedTag("m", "ex1", kSig_v_v); + let except2 = builder.addTag(kSig_v_v); + builder.addExportOfKind("ex2", kExternalTag, except2); builder.addFunction("throw", kSig_v_v) .addBody([ kExprThrow, except2 @@ -123,9 +123,9 @@ function NewExportedException() { (function TestMultiModuleShared() { print(arguments.callee.name); let builder1 = new WasmModuleBuilder(); - let except1 = builder1.addException(kSig_v_v); - let except2 = builder1.addException(kSig_v_v); - builder1.addExportOfKind("ex", kExternalException, except2); + let except1 = builder1.addTag(kSig_v_v); + let except2 = builder1.addTag(kSig_v_v); + builder1.addExportOfKind("ex", kExternalTag, except2); builder1.addFunction("throw", kSig_v_v) .addBody([ kExprThrow, except2 @@ -133,7 +133,7 @@ function NewExportedException() { let builder2 = new WasmModuleBuilder(); let sig_index = builder2.addType(kSig_v_v); let fun = builder2.addImport("m", "f", sig_index); - let except = builder2.addImportedException("m", "ex", kSig_v_v); + let except = builder2.addImportedTag("m", "ex", kSig_v_v); builder2.addFunction("catch", kSig_v_v) .addBody([ kExprTry, kWasmVoid, diff --git a/test/mjsunit/wasm/exceptions-simd.js b/test/mjsunit/wasm/exceptions-simd.js index ace3322480..ed6b287ddd 100644 --- a/test/mjsunit/wasm/exceptions-simd.js +++ b/test/mjsunit/wasm/exceptions-simd.js @@ -11,7 +11,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); print(arguments.callee.name); var builder = new WasmModuleBuilder(); var kSig_v_s = makeSig([kWasmS128], []); - var except = builder.addException(kSig_v_s); + var except = builder.addTag(kSig_v_s); builder.addFunction("throw_simd", kSig_v_v) .addLocals(kWasmS128, 1) .addBody([ @@ -29,7 +29,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); print(arguments.callee.name); var builder = new WasmModuleBuilder(); var kSig_v_s = makeSig([kWasmS128], []); - var except = builder.addException(kSig_v_s); + var except = builder.addTag(kSig_v_s); builder.addFunction("throw_catch_simd", kSig_i_v) .addLocals(kWasmS128, 1) .addBody([ @@ -52,7 +52,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); print(arguments.callee.name); var builder = new WasmModuleBuilder(); var kSig_v_s = makeSig([kWasmS128], []); - var except = builder.addException(kSig_v_s); + var except = builder.addTag(kSig_v_s); const in_idx = 0x10; // Input index in memory. const out_idx = 0x20; // Output index in memory. builder.addImportedMemory("env", "memory"); diff --git a/test/mjsunit/wasm/exceptions-type-reflection.js b/test/mjsunit/wasm/exceptions-type-reflection.js index 3358ae330d..a17d30ed10 100644 --- a/test/mjsunit/wasm/exceptions-type-reflection.js +++ b/test/mjsunit/wasm/exceptions-type-reflection.js @@ -19,8 +19,8 @@ let testcases = [ let builder = new WasmModuleBuilder(); testcases.forEach(function(expected, i) { - let except = builder.addException(expected.sig); - builder.addExportOfKind("ex" + i, kExternalException, except); + let except = builder.addTag(expected.sig); + builder.addExportOfKind("ex" + i, kExternalTag, except); }); let instance = builder.instantiate(); @@ -37,8 +37,8 @@ let testcases = [ testcases.forEach(function(expected, i) { let t = new WebAssembly.Tag(expected.types); - let index = builder.addImportedException("m", "ex" + i, expected.sig); - builder.addExportOfKind("ex" + i, kExternalException, index); + let index = builder.addImportedTag("m", "ex" + i, expected.sig); + builder.addExportOfKind("ex" + i, kExternalTag, index); imports.m["ex" + i] = t; }); diff --git a/test/mjsunit/wasm/exceptions-utils.js b/test/mjsunit/wasm/exceptions-utils.js index 344ca64da1..edd7cb2800 100644 --- a/test/mjsunit/wasm/exceptions-utils.js +++ b/test/mjsunit/wasm/exceptions-utils.js @@ -16,7 +16,7 @@ function assertWasmThrows(instance, runtime_id, values, code) { } } catch (e) { assertInstanceof(e, WebAssembly.RuntimeError); - var e_runtime_id = %GetWasmExceptionId(e, instance); + var e_runtime_id = %GetWasmExceptionTagId(e, instance); assertTrue(Number.isInteger(e_runtime_id)); assertEquals(e_runtime_id, runtime_id); var e_values = %GetWasmExceptionValues(e); diff --git a/test/mjsunit/wasm/exceptions.js b/test/mjsunit/wasm/exceptions.js index 578fa09e25..0096622f80 100644 --- a/test/mjsunit/wasm/exceptions.js +++ b/test/mjsunit/wasm/exceptions.js @@ -11,7 +11,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowSimple() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("throw_if_param_not_zero", kSig_i_i) .addBody([ kExprLocalGet, 0, @@ -33,7 +33,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchEmptyBlocks() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("catch_empty_try", kSig_v_v) .addBody([ kExprTry, kWasmVoid, @@ -49,7 +49,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchSimple() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction("simple_throw_catch_to_0_1", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -173,7 +173,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestExnWithWasmProtoNotCaught() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); let imp = builder.addImport('imp', 'ort', kSig_v_v); let throw_fn = builder.addFunction('throw', kSig_v_v) .addBody([kExprThrow, except]) @@ -241,9 +241,9 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchComplex1() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); - let except3 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); + let except3 = builder.addTag(kSig_v_v); builder.addFunction("catch_complex", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -282,9 +282,9 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchComplex2() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); - let except3 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); + let except3 = builder.addTag(kSig_v_v); builder.addFunction("catch_complex", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -320,7 +320,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowMultipleValues() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_ii); + let except = builder.addTag(kSig_v_ii); builder.addFunction("throw_1_2", kSig_v_v) .addBody([ kExprI32Const, 1, @@ -336,7 +336,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchParamI() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_i); + let except = builder.addTag(kSig_v_i); builder.addFunction("throw_catch_param", kSig_i_i) .addBody([ kExprTry, kWasmI32, @@ -358,7 +358,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowParamI() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_i); + let except = builder.addTag(kSig_v_i); builder.addFunction("throw_param", kSig_v_i) .addBody([ kExprLocalGet, 0, @@ -374,7 +374,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchParamF() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_f); + let except = builder.addTag(kSig_v_f); builder.addFunction("throw_catch_param", kSig_f_f) .addBody([ kExprTry, kWasmF32, @@ -395,7 +395,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowParamF() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_f); + let except = builder.addTag(kSig_v_f); builder.addFunction("throw_param", kSig_v_f) .addBody([ kExprLocalGet, 0, @@ -411,7 +411,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchParamL() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_l); + let except = builder.addTag(kSig_v_l); builder.addFunction("throw_catch_param", kSig_i_i) .addLocals(kWasmI64, 1) .addBody([ @@ -443,7 +443,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowParamL() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_l); + let except = builder.addTag(kSig_v_l); builder.addFunction("throw_param", kSig_v_ii) .addBody([ kExprLocalGet, 0, @@ -465,7 +465,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatchParamD() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_d); + let except = builder.addTag(kSig_v_d); builder.addFunction("throw_catch_param", kSig_d_d) .addBody([ kExprTry, kWasmF64, @@ -486,7 +486,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowParamD() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_d); + let except = builder.addTag(kSig_v_d); builder.addFunction("throw_param", kSig_v_f) .addBody([ kExprLocalGet, 0, @@ -503,7 +503,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowParamComputed() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_i); + let except = builder.addTag(kSig_v_i); builder.addFunction("throw_expr_with_params", kSig_v_ddi) .addBody([ // p2 * (p0 + min(p0, p1))|0 - 20 @@ -530,7 +530,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchCrossFunctions() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_i); + let except = builder.addTag(kSig_v_i); // Helper function for throwing from JS. It is imported by the Wasm module // as throw_i. @@ -816,7 +816,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateNoThrow() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); builder.addFunction('test', kSig_i_v) .addBody([ kExprTry, kWasmI32, @@ -835,7 +835,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateThrow() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); let throw_if = builder.addFunction('throw', kSig_v_i) .addBody([ kExprLocalGet, 0, @@ -863,8 +863,8 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateThrowNoCatch() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); let throw_fn = builder.addFunction('throw', kSig_v_v) .addBody([kExprThrow, except1]) .exportFunc(); @@ -890,8 +890,8 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateMerge() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); // throw_fn: 0 -> returns // 1 -> throw except1 // 2 -> throw except2 @@ -935,7 +935,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegate1() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); let throw_fn = builder.addFunction('throw', kSig_v_v) .addBody([kExprThrow, except]) .exportFunc(); @@ -961,8 +961,8 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateUnreachable() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); builder.addFunction('test', kSig_i_v) .addBody([ kExprTry, kWasmI32, @@ -983,7 +983,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestDelegateToCaller() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction('test', kSig_v_v) .addBody([ kExprTry, kWasmVoid, @@ -1000,7 +1000,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowBeforeUnreachable() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction('throw_before_unreachable', kSig_i_v) .addBody([ kExprTry, kWasmI32, @@ -1018,7 +1018,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestUnreachableInCatchAll() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction('throw_before_unreachable', kSig_i_v) .addBody([ kExprTry, kWasmI32, @@ -1035,7 +1035,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowWithLocal() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction('throw_with_local', kSig_i_v) .addLocals(kWasmI32, 4) .addBody([ @@ -1058,7 +1058,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestCatchlessTry() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except = builder.addException(kSig_v_v); + let except = builder.addTag(kSig_v_v); builder.addFunction('catchless_try', kSig_v_i) .addBody([ kExprTry, kWasmVoid, diff --git a/test/mjsunit/wasm/loop-unrolling.js b/test/mjsunit/wasm/loop-unrolling.js index a20701f381..881a4567cc 100644 --- a/test/mjsunit/wasm/loop-unrolling.js +++ b/test/mjsunit/wasm/loop-unrolling.js @@ -93,8 +93,8 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestRethrowNested() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); - let except2 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); + let except2 = builder.addTag(kSig_v_v); builder.addFunction("rethrow_nested", kSig_i_i) .addBody([ kExprLoop, kWasmI32, @@ -139,7 +139,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrow() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); builder.addFunction("throw", kSig_i_i) .addBody([ kExprLoop, kWasmVoid, @@ -167,7 +167,7 @@ d8.file.execute("test/mjsunit/wasm/exceptions-utils.js"); (function TestThrowCatch() { print(arguments.callee.name); let builder = new WasmModuleBuilder(); - let except1 = builder.addException(kSig_v_v); + let except1 = builder.addTag(kSig_v_v); builder.addFunction("throw_catch", kSig_i_i) .addBody([ kExprLoop, kWasmI32, diff --git a/test/mjsunit/wasm/wasm-module-builder.js b/test/mjsunit/wasm/wasm-module-builder.js index 563af6f8b7..9eff8cc2e5 100644 --- a/test/mjsunit/wasm/wasm-module-builder.js +++ b/test/mjsunit/wasm/wasm-module-builder.js @@ -67,7 +67,7 @@ let kElementSectionCode = 9; // Elements section let kCodeSectionCode = 10; // Function code let kDataSectionCode = 11; // Data segments let kDataCountSectionCode = 12; // Data segment count (between Element & Code) -let kExceptionSectionCode = 13; // Exception section (between Memory & Global) +let kTagSectionCode = 13; // Tag section (between Memory & Global) // Name section types let kModuleNameCode = 0; @@ -136,7 +136,7 @@ let kExternalFunction = 0; let kExternalTable = 1; let kExternalMemory = 2; let kExternalGlobal = 3; -let kExternalException = 4; +let kExternalTag = 4; let kTableZero = 0; let kMemoryZero = 0; @@ -1276,7 +1276,7 @@ class WasmModuleBuilder { this.exports = []; this.globals = []; this.tables = []; - this.exceptions = []; + this.tags = []; this.functions = []; this.compilation_hints = []; this.element_segments = []; @@ -1285,7 +1285,7 @@ class WasmModuleBuilder { this.num_imported_funcs = 0; this.num_imported_globals = 0; this.num_imported_tables = 0; - this.num_imported_exceptions = 0; + this.num_imported_tags = 0; return this; } @@ -1382,11 +1382,11 @@ class WasmModuleBuilder { return table; } - addException(type) { + addTag(type) { let type_index = (typeof type) == 'number' ? type : this.addType(type); - let except_index = this.exceptions.length + this.num_imported_exceptions; - this.exceptions.push(type_index); - return except_index; + let tag_index = this.tags.length + this.num_imported_tags; + this.tags.push(type_index); + return tag_index; } addFunction(name, type, arg_names) { @@ -1461,19 +1461,19 @@ class WasmModuleBuilder { return this.num_imported_tables++; } - addImportedException(module, name, type) { - if (this.exceptions.length != 0) { - throw new Error('Imported exceptions must be declared before local ones'); + addImportedTag(module, name, type) { + if (this.tags.length != 0) { + throw new Error('Imported tags must be declared before local ones'); } let type_index = (typeof type) == 'number' ? type : this.addType(type); let o = { module: module, name: name, - kind: kExternalException, + kind: kExternalTag, type_index: type_index }; this.imports.push(o); - return this.num_imported_exceptions++; + return this.num_imported_tags++; } addExport(name, index) { @@ -1644,7 +1644,7 @@ class WasmModuleBuilder { section.emit_u8(has_max ? 1 : 0); // flags section.emit_u32v(imp.initial); // initial if (has_max) section.emit_u32v(imp.maximum); // maximum - } else if (imp.kind == kExternalException) { + } else if (imp.kind == kExternalTag) { section.emit_u32v(kExceptionAttribute); section.emit_u32v(imp.type_index); } else { @@ -1708,12 +1708,12 @@ class WasmModuleBuilder { }); } - // Add event section. - if (wasm.exceptions.length > 0) { - if (debug) print('emitting events @ ' + binary.length); - binary.emit_section(kExceptionSectionCode, section => { - section.emit_u32v(wasm.exceptions.length); - for (let type_index of wasm.exceptions) { + // Add tag section. + if (wasm.tags.length > 0) { + if (debug) print('emitting tags @ ' + binary.length); + binary.emit_section(kTagSectionCode, section => { + section.emit_u32v(wasm.tags.length); + for (let type_index of wasm.tags) { section.emit_u32v(kExceptionAttribute); section.emit_u32v(type_index); } diff --git a/test/unittests/wasm/function-body-decoder-unittest.cc b/test/unittests/wasm/function-body-decoder-unittest.cc index 2c4cec927b..f9caa1b310 100644 --- a/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/test/unittests/wasm/function-body-decoder-unittest.cc @@ -109,10 +109,10 @@ class TestModuleBuilder { mod.functions[result].imported = true; return result; } - byte AddException(WasmExceptionSig* sig) { - mod.exceptions.emplace_back(sig); + byte AddException(WasmTagSig* sig) { + mod.tags.emplace_back(sig); CHECK_LE(mod.types.size(), kMaxByteSizedLeb128); - return static_cast(mod.exceptions.size() - 1); + return static_cast(mod.tags.size() - 1); } byte AddTable(ValueType type, uint32_t initial_size, bool has_maximum_size, diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc index 762725cfea..271d6fe1b9 100644 --- a/test/unittests/wasm/module-decoder-unittest.cc +++ b/test/unittests/wasm/module-decoder-unittest.cc @@ -1303,28 +1303,28 @@ TEST_F(WasmModuleVerifyTest, InvalidArrayTypeDef) { } TEST_F(WasmModuleVerifyTest, ZeroExceptions) { - static const byte data[] = {SECTION(Exception, ENTRY_COUNT(0))}; + static const byte data[] = {SECTION(Tag, ENTRY_COUNT(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(0u, result.value()->exceptions.size()); + EXPECT_EQ(0u, result.value()->tags.size()); } TEST_F(WasmModuleVerifyTest, OneI32Exception) { static const byte data[] = { SECTION(Type, ENTRY_COUNT(1), SIG_ENTRY_v_x(kI32Code)), // sig#0 (i32) - SECTION(Exception, ENTRY_COUNT(1), + SECTION(Tag, ENTRY_COUNT(1), EXCEPTION_ENTRY(SIG_INDEX(0)))}; // except[0] (sig#0) FAIL_IF_NO_EXPERIMENTAL_EH(data); WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(1u, result.value()->exceptions.size()); + EXPECT_EQ(1u, result.value()->tags.size()); - const WasmException& e0 = result.value()->exceptions.front(); + const WasmTag& e0 = result.value()->tags.front(); EXPECT_EQ(1u, e0.sig->parameter_count()); EXPECT_EQ(kWasmI32, e0.sig->GetParam(0)); } @@ -1334,7 +1334,7 @@ TEST_F(WasmModuleVerifyTest, TwoExceptions) { SECTION(Type, ENTRY_COUNT(2), SIG_ENTRY_v_x(kI32Code), // sig#0 (i32) SIG_ENTRY_v_xx(kF32Code, kI64Code)), // sig#1 (f32, i64) - SECTION(Exception, ENTRY_COUNT(2), + SECTION(Tag, ENTRY_COUNT(2), EXCEPTION_ENTRY(SIG_INDEX(1)), // except[0] (sig#1) EXCEPTION_ENTRY(SIG_INDEX(0)))}; // except[1] (sig#0) FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1342,19 +1342,19 @@ TEST_F(WasmModuleVerifyTest, TwoExceptions) { WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(2u, result.value()->exceptions.size()); - const WasmException& e0 = result.value()->exceptions.front(); + EXPECT_EQ(2u, result.value()->tags.size()); + const WasmTag& e0 = result.value()->tags.front(); EXPECT_EQ(2u, e0.sig->parameter_count()); EXPECT_EQ(kWasmF32, e0.sig->GetParam(0)); EXPECT_EQ(kWasmI64, e0.sig->GetParam(1)); - const WasmException& e1 = result.value()->exceptions.back(); + const WasmTag& e1 = result.value()->tags.back(); EXPECT_EQ(kWasmI32, e1.sig->GetParam(0)); } TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_index) { static const byte data[] = { TYPE_SECTION_ONE_SIG_VOID_VOID, - SECTION(Exception, ENTRY_COUNT(1), + SECTION(Tag, ENTRY_COUNT(1), EXCEPTION_ENTRY( SIG_INDEX(23)))}; // except[0] (sig#23 [out-of-bounds]) FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1368,7 +1368,7 @@ TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_index) { TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_return) { static const byte data[] = { SECTION(Type, ENTRY_COUNT(1), SIG_ENTRY_i_i), - SECTION(Exception, ENTRY_COUNT(1), + SECTION(Tag, ENTRY_COUNT(1), EXCEPTION_ENTRY( SIG_INDEX(0)))}; // except[0] (sig#0 [invalid-return-type]) FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1376,13 +1376,13 @@ TEST_F(WasmModuleVerifyTest, Exception_invalid_sig_return) { // Should fail decoding exception section. WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); - EXPECT_NOT_OK(result, "exception signature 0 has non-void return"); + EXPECT_NOT_OK(result, "tag signature 0 has non-void return"); } TEST_F(WasmModuleVerifyTest, Exception_invalid_attribute) { static const byte data[] = { SECTION(Type, ENTRY_COUNT(1), SIG_ENTRY_i_i), - SECTION(Exception, ENTRY_COUNT(1), 23, + SECTION(Tag, ENTRY_COUNT(1), 23, SIG_INDEX(0))}; // except[0] (sig#0) [invalid-attribute] FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1392,9 +1392,9 @@ TEST_F(WasmModuleVerifyTest, Exception_invalid_attribute) { EXPECT_NOT_OK(result, "exception attribute 23 not supported"); } -TEST_F(WasmModuleVerifyTest, ExceptionSectionCorrectPlacement) { +TEST_F(WasmModuleVerifyTest, TagSectionCorrectPlacement) { static const byte data[] = {SECTION(Memory, ENTRY_COUNT(0)), - SECTION(Exception, ENTRY_COUNT(0)), + SECTION(Tag, ENTRY_COUNT(0)), SECTION(Global, ENTRY_COUNT(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1403,19 +1403,19 @@ TEST_F(WasmModuleVerifyTest, ExceptionSectionCorrectPlacement) { EXPECT_OK(result); } -TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterGlobal) { +TEST_F(WasmModuleVerifyTest, TagSectionAfterGlobal) { static const byte data[] = {SECTION(Global, ENTRY_COUNT(0)), - SECTION(Exception, ENTRY_COUNT(0))}; + SECTION(Tag, ENTRY_COUNT(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_NOT_OK(result, - "The Exception section must appear before the Global section"); + "The Tag section must appear before the Global section"); } -TEST_F(WasmModuleVerifyTest, ExceptionSectionBeforeMemory) { - static const byte data[] = {SECTION(Exception, ENTRY_COUNT(0)), +TEST_F(WasmModuleVerifyTest, TagSectionBeforeMemory) { + static const byte data[] = {SECTION(Tag, ENTRY_COUNT(0)), SECTION(Memory, ENTRY_COUNT(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1424,10 +1424,10 @@ TEST_F(WasmModuleVerifyTest, ExceptionSectionBeforeMemory) { EXPECT_NOT_OK(result, "unexpected section "); } -TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterTableBeforeMemory) { +TEST_F(WasmModuleVerifyTest, TagSectionAfterTableBeforeMemory) { STATIC_ASSERT(kMemorySectionCode + 1 == kGlobalSectionCode); static const byte data[] = {SECTION(Table, ENTRY_COUNT(0)), - SECTION(Exception, ENTRY_COUNT(0)), + SECTION(Tag, ENTRY_COUNT(0)), SECTION(Memory, ENTRY_COUNT(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); @@ -1436,39 +1436,39 @@ TEST_F(WasmModuleVerifyTest, ExceptionSectionAfterTableBeforeMemory) { EXPECT_NOT_OK(result, "unexpected section "); } -TEST_F(WasmModuleVerifyTest, ExceptionImport) { +TEST_F(WasmModuleVerifyTest, TagImport) { static const byte data[] = { TYPE_SECTION_ONE_SIG_VOID_VOID, SECTION(Import, // section header ENTRY_COUNT(1), // number of imports ADD_COUNT('m'), // module name - ADD_COUNT('e', 'x'), // exception name - kExternalException, // import kind + ADD_COUNT('e', 'x'), // tag name + kExternalTag, // import kind EXCEPTION_ENTRY(SIG_INDEX(0)))}; // except[0] (sig#0) FAIL_IF_NO_EXPERIMENTAL_EH(data); WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(1u, result.value()->exceptions.size()); + EXPECT_EQ(1u, result.value()->tags.size()); EXPECT_EQ(1u, result.value()->import_table.size()); } TEST_F(WasmModuleVerifyTest, ExceptionExport) { static const byte data[] = { TYPE_SECTION_ONE_SIG_VOID_VOID, - SECTION(Exception, ENTRY_COUNT(1), + SECTION(Tag, ENTRY_COUNT(1), EXCEPTION_ENTRY(SIG_INDEX(0))), // except[0] (sig#0) SECTION(Export, ENTRY_COUNT(1), // -- NO_NAME, // -- - kExternalException, // -- + kExternalTag, // -- EXCEPTION_INDEX(0))}; FAIL_IF_NO_EXPERIMENTAL_EH(data); WASM_FEATURE_SCOPE(eh); ModuleResult result = DecodeModule(data, data + sizeof(data)); EXPECT_OK(result); - EXPECT_EQ(1u, result.value()->exceptions.size()); + EXPECT_EQ(1u, result.value()->tags.size()); EXPECT_EQ(1u, result.value()->export_table.size()); } diff --git a/tools/v8heapconst.py b/tools/v8heapconst.py index 7540dc6c98..39d337bf4f 100644 --- a/tools/v8heapconst.py +++ b/tools/v8heapconst.py @@ -224,12 +224,12 @@ INSTANCE_TYPES = { 1108: "JS_STRING_ITERATOR_TYPE", 1109: "JS_V8_BREAK_ITERATOR_TYPE", 1110: "JS_WEAK_REF_TYPE", - 1111: "WASM_EXCEPTION_OBJECT_TYPE", - 1112: "WASM_GLOBAL_OBJECT_TYPE", - 1113: "WASM_INSTANCE_OBJECT_TYPE", - 1114: "WASM_MEMORY_OBJECT_TYPE", - 1115: "WASM_MODULE_OBJECT_TYPE", - 1116: "WASM_TABLE_OBJECT_TYPE", + 1111: "WASM_GLOBAL_OBJECT_TYPE", + 1112: "WASM_INSTANCE_OBJECT_TYPE", + 1113: "WASM_MEMORY_OBJECT_TYPE", + 1114: "WASM_MODULE_OBJECT_TYPE", + 1115: "WASM_TABLE_OBJECT_TYPE", + 1116: "WASM_TAG_OBJECT_TYPE", 1117: "WASM_VALUE_OBJECT_TYPE", }