Skip to content

Commit d66cc11

Browse files
thibaudmichaudV8 LUCI CQ
authored and
V8 LUCI CQ
committed
[wasm][eh] Rename exception to tag
The JS API constructor was renamed to "WebAssembly.Tag" to match the spec: WebAssembly/exception-handling#159 Rename "exception" to "tag" throughout the codebase for consistency with the JS API, and to match the spec terminology (e.g. "tag section"). [email protected],[email protected] Bug: v8:11992 Change-Id: I63f9f3101abfeefd49117461bd59c594ca5dab70 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3053583 Reviewed-by: Clemens Backes <[email protected]> Reviewed-by: Nico Hartmann <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Commit-Position: refs/heads/master@{#75994}
1 parent ce1a9ab commit d66cc11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+448
-470
lines changed

src/compiler/code-assembler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class SymbolWrapper;
125125
class Undetectable;
126126
class UniqueName;
127127
class WasmCapiFunctionData;
128-
class WasmExceptionObject;
128+
class WasmTagObject;
129129
class WasmExceptionPackage;
130130
class WasmExceptionTag;
131131
class WasmExportedFunctionData;

src/compiler/types.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
258258
case JS_PROMISE_TYPE:
259259
#if V8_ENABLE_WEBASSEMBLY
260260
case WASM_ARRAY_TYPE:
261-
case WASM_EXCEPTION_OBJECT_TYPE:
261+
case WASM_TAG_OBJECT_TYPE:
262262
case WASM_GLOBAL_OBJECT_TYPE:
263263
case WASM_INSTANCE_OBJECT_TYPE:
264264
case WASM_MEMORY_OBJECT_TYPE:

src/compiler/wasm-compiler.cc

+11-13
Original file line numberDiff line numberDiff line change
@@ -2364,20 +2364,19 @@ Node* WasmGraphBuilder::MemoryGrow(Node* input) {
23642364
return diamond_result;
23652365
}
23662366

2367-
Node* WasmGraphBuilder::Throw(uint32_t exception_index,
2368-
const wasm::WasmException* exception,
2367+
Node* WasmGraphBuilder::Throw(uint32_t tag_index, const wasm::WasmTag* tag,
23692368
const base::Vector<Node*> values,
23702369
wasm::WasmCodePosition position) {
23712370
needs_stack_check_ = true;
2372-
uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(exception);
2371+
uint32_t encoded_size = WasmExceptionPackage::GetEncodedSize(tag);
23732372

23742373
Node* values_array =
23752374
gasm_->CallRuntimeStub(wasm::WasmCode::kWasmAllocateFixedArray,
23762375
gasm_->IntPtrConstant(encoded_size));
23772376
SetSourcePosition(values_array, position);
23782377

23792378
uint32_t index = 0;
2380-
const wasm::WasmExceptionSig* sig = exception->sig;
2379+
const wasm::WasmTagSig* sig = tag->sig;
23812380
MachineOperatorBuilder* m = mcgraph()->machine();
23822381
for (size_t i = 0; i < sig->parameter_count(); ++i) {
23832382
Node* value = values[i];
@@ -2429,7 +2428,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index,
24292428
}
24302429
DCHECK_EQ(encoded_size, index);
24312430

2432-
Node* exception_tag = LoadExceptionTagFromTable(exception_index);
2431+
Node* exception_tag = LoadTagFromTable(tag_index);
24332432

24342433
Node* throw_call = gasm_->CallRuntimeStub(wasm::WasmCode::kWasmThrow,
24352434
exception_tag, values_array);
@@ -2486,11 +2485,10 @@ Node* WasmGraphBuilder::ExceptionTagEqual(Node* caught_tag,
24862485
return gasm_->WordEqual(caught_tag, expected_tag);
24872486
}
24882487

2489-
Node* WasmGraphBuilder::LoadExceptionTagFromTable(uint32_t exception_index) {
2490-
Node* exceptions_table =
2491-
LOAD_INSTANCE_FIELD(ExceptionsTable, MachineType::TaggedPointer());
2492-
Node* tag =
2493-
gasm_->LoadFixedArrayElementPtr(exceptions_table, exception_index);
2488+
Node* WasmGraphBuilder::LoadTagFromTable(uint32_t tag_index) {
2489+
Node* tags_table =
2490+
LOAD_INSTANCE_FIELD(TagsTable, MachineType::TaggedPointer());
2491+
Node* tag = gasm_->LoadFixedArrayElementPtr(tags_table, tag_index);
24942492
return tag;
24952493
}
24962494

@@ -2502,14 +2500,14 @@ Node* WasmGraphBuilder::GetExceptionTag(Node* except_obj) {
25022500
}
25032501

25042502
Node* WasmGraphBuilder::GetExceptionValues(Node* except_obj,
2505-
const wasm::WasmException* exception,
2503+
const wasm::WasmTag* tag,
25062504
base::Vector<Node*> values) {
25072505
Node* values_array = gasm_->CallBuiltin(
25082506
Builtin::kWasmGetOwnProperty, Operator::kEliminatable, except_obj,
25092507
LOAD_ROOT(wasm_exception_values_symbol, wasm_exception_values_symbol),
25102508
LOAD_INSTANCE_FIELD(NativeContext, MachineType::TaggedPointer()));
25112509
uint32_t index = 0;
2512-
const wasm::WasmExceptionSig* sig = exception->sig;
2510+
const wasm::WasmTagSig* sig = tag->sig;
25132511
DCHECK_EQ(sig->parameter_count(), values.size());
25142512
for (size_t i = 0; i < sig->parameter_count(); ++i) {
25152513
Node* value;
@@ -2559,7 +2557,7 @@ Node* WasmGraphBuilder::GetExceptionValues(Node* except_obj,
25592557
}
25602558
values[i] = value;
25612559
}
2562-
DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(exception));
2560+
DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(tag));
25632561
return values_array;
25642562
}
25652563

src/compiler/wasm-compiler.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,14 @@ class WasmGraphBuilder {
266266
Node* Unop(wasm::WasmOpcode opcode, Node* input,
267267
wasm::WasmCodePosition position = wasm::kNoCodePosition);
268268
Node* MemoryGrow(Node* input);
269-
Node* Throw(uint32_t exception_index, const wasm::WasmException* exception,
269+
Node* Throw(uint32_t tag_index, const wasm::WasmTag* tag,
270270
const base::Vector<Node*> values,
271271
wasm::WasmCodePosition position);
272272
Node* Rethrow(Node* except_obj);
273273
Node* ExceptionTagEqual(Node* caught_tag, Node* expected_tag);
274-
Node* LoadExceptionTagFromTable(uint32_t exception_index);
274+
Node* LoadTagFromTable(uint32_t tag_index);
275275
Node* GetExceptionTag(Node* except_obj);
276-
Node* GetExceptionValues(Node* except_obj,
277-
const wasm::WasmException* exception,
276+
Node* GetExceptionValues(Node* except_obj, const wasm::WasmTag* tag,
278277
base::Vector<Node*> values_out);
279278
bool IsPhiWithMerge(Node* phi, Node* merge);
280279
bool ThrowsException(Node* node, Node** if_success, Node** if_exception);

src/diagnostics/objects-printer.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -2076,10 +2076,10 @@ void WasmMemoryObject::WasmMemoryObjectPrint(std::ostream& os) {
20762076
os << "\n";
20772077
}
20782078

2079-
void WasmExceptionObject::WasmExceptionObjectPrint(std::ostream& os) {
2080-
PrintHeader(os, "WasmExceptionObject");
2079+
void WasmTagObject::WasmTagObjectPrint(std::ostream& os) {
2080+
PrintHeader(os, "WasmTagObject");
20812081
os << "\n - serialized_signature: " << Brief(serialized_signature());
2082-
os << "\n - exception_tag: " << Brief(exception_tag());
2082+
os << "\n - tag: " << Brief(tag());
20832083
os << "\n";
20842084
}
20852085

src/objects/contexts.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ enum ContextLookupFlags {
291291
V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \
292292
V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \
293293
V(WASM_EXPORTED_FUNCTION_MAP_INDEX, Map, wasm_exported_function_map) \
294-
V(WASM_EXCEPTION_CONSTRUCTOR_INDEX, JSFunction, wasm_exception_constructor) \
294+
V(WASM_TAG_CONSTRUCTOR_INDEX, JSFunction, wasm_tag_constructor) \
295295
V(WASM_GLOBAL_CONSTRUCTOR_INDEX, JSFunction, wasm_global_constructor) \
296296
V(WASM_INSTANCE_CONSTRUCTOR_INDEX, JSFunction, wasm_instance_constructor) \
297297
V(WASM_MEMORY_CONSTRUCTOR_INDEX, JSFunction, wasm_memory_constructor) \

src/objects/js-objects.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2334,8 +2334,8 @@ int JSObject::GetHeaderSize(InstanceType type,
23342334
return WasmTableObject::kHeaderSize;
23352335
case WASM_VALUE_OBJECT_TYPE:
23362336
return WasmValueObject::kHeaderSize;
2337-
case WASM_EXCEPTION_OBJECT_TYPE:
2338-
return WasmExceptionObject::kHeaderSize;
2337+
case WASM_TAG_OBJECT_TYPE:
2338+
return WasmTagObject::kHeaderSize;
23392339
#endif // V8_ENABLE_WEBASSEMBLY
23402340
default: {
23412341
std::stringstream ss;

src/objects/map.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ VisitorId Map::GetVisitorId(Map map) {
286286
case JS_SEGMENTS_TYPE:
287287
#endif // V8_INTL_SUPPORT
288288
#if V8_ENABLE_WEBASSEMBLY
289-
case WASM_EXCEPTION_OBJECT_TYPE:
289+
case WASM_TAG_OBJECT_TYPE:
290290
case WASM_GLOBAL_OBJECT_TYPE:
291291
case WASM_MEMORY_OBJECT_TYPE:
292292
case WASM_MODULE_OBJECT_TYPE:

src/objects/object-list-macros.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class ZoneForwardList;
217217
V(UniqueName) \
218218
IF_WASM(V, WasmArray) \
219219
IF_WASM(V, WasmCapiFunctionData) \
220-
IF_WASM(V, WasmExceptionObject) \
220+
IF_WASM(V, WasmTagObject) \
221221
IF_WASM(V, WasmExceptionPackage) \
222222
IF_WASM(V, WasmExportedFunctionData) \
223223
IF_WASM(V, WasmFunctionData) \

src/objects/objects-body-descriptors-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
11331133
case JS_SEGMENTS_TYPE:
11341134
#endif // V8_INTL_SUPPORT
11351135
#if V8_ENABLE_WEBASSEMBLY
1136-
case WASM_EXCEPTION_OBJECT_TYPE:
1136+
case WASM_TAG_OBJECT_TYPE:
11371137
case WASM_GLOBAL_OBJECT_TYPE:
11381138
case WASM_MEMORY_OBJECT_TYPE:
11391139
case WASM_MODULE_OBJECT_TYPE:

src/objects/objects.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// - JSSegments // If V8_INTL_SUPPORT enabled.
8282
// - JSSegmentIterator // If V8_INTL_SUPPORT enabled.
8383
// - JSV8BreakIterator // If V8_INTL_SUPPORT enabled.
84-
// - WasmExceptionObject
84+
// - WasmTagObject
8585
// - WasmGlobalObject
8686
// - WasmInstanceObject
8787
// - WasmMemoryObject

src/runtime/runtime-test-wasm.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,17 @@ RUNTIME_FUNCTION(Runtime_GetWasmRecoveredTrapCount) {
293293
return *isolate->factory()->NewNumberFromSize(trap_count);
294294
}
295295

296-
RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) {
296+
RUNTIME_FUNCTION(Runtime_GetWasmExceptionTagId) {
297297
HandleScope scope(isolate);
298298
DCHECK_EQ(2, args.length());
299299
CONVERT_ARG_HANDLE_CHECKED(WasmExceptionPackage, exception, 0);
300300
CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 1);
301301
Handle<Object> tag =
302302
WasmExceptionPackage::GetExceptionTag(isolate, exception);
303303
CHECK(tag->IsWasmExceptionTag());
304-
Handle<FixedArray> exceptions_table(instance->exceptions_table(), isolate);
305-
for (int index = 0; index < exceptions_table->length(); ++index) {
306-
if (exceptions_table->get(index) == *tag) return Smi::FromInt(index);
304+
Handle<FixedArray> tags_table(instance->tags_table(), isolate);
305+
for (int index = 0; index < tags_table->length(); ++index) {
306+
if (tags_table->get(index) == *tag) return Smi::FromInt(index);
307307
}
308308
UNREACHABLE();
309309
}

src/runtime/runtime.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ namespace internal {
597597
F(DeserializeWasmModule, 2, 1) \
598598
F(DisallowWasmCodegen, 1, 1) \
599599
F(FreezeWasmLazyCompilation, 1, 1) \
600-
F(GetWasmExceptionId, 2, 1) \
600+
F(GetWasmExceptionTagId, 2, 1) \
601601
F(GetWasmExceptionValues, 1, 1) \
602602
F(GetWasmRecoveredTrapCount, 0, 1) \
603603
F(IsAsmWasmCode, 1, 1) \

src/wasm/baseline/liftoff-compiler.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,8 @@ class LiftoffCompiler {
11411141
}
11421142

11431143
void CatchException(FullDecoder* decoder,
1144-
const ExceptionIndexImmediate<validate>& imm,
1145-
Control* block, base::Vector<Value> values) {
1144+
const TagIndexImmediate<validate>& imm, Control* block,
1145+
base::Vector<Value> values) {
11461146
DCHECK(block->is_try_catch());
11471147
__ emit_jump(block->label.get());
11481148

@@ -1171,7 +1171,7 @@ class LiftoffCompiler {
11711171

11721172
CODE_COMMENT("load expected exception tag");
11731173
Register imm_tag = pinned.set(__ GetUnusedRegister(kGpReg, pinned)).gp();
1174-
LOAD_TAGGED_PTR_INSTANCE_FIELD(imm_tag, ExceptionsTable, pinned);
1174+
LOAD_TAGGED_PTR_INSTANCE_FIELD(imm_tag, TagsTable, pinned);
11751175
__ LoadTaggedPointer(
11761176
imm_tag, imm_tag, no_reg,
11771177
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(imm.index), {});
@@ -1189,8 +1189,7 @@ class LiftoffCompiler {
11891189
block->try_info->in_handler = true;
11901190
num_exceptions_++;
11911191
}
1192-
GetExceptionValues(decoder, __ cache_state()->stack_state.back(),
1193-
imm.exception);
1192+
GetExceptionValues(decoder, __ cache_state()->stack_state.back(), imm.tag);
11941193
}
11951194

11961195
void Rethrow(FullDecoder* decoder,
@@ -4227,18 +4226,18 @@ class LiftoffCompiler {
42274226

42284227
void GetExceptionValues(FullDecoder* decoder,
42294228
LiftoffAssembler::VarState& exception_var,
4230-
const WasmException* exception) {
4229+
const WasmTag* tag) {
42314230
LiftoffRegList pinned;
42324231
CODE_COMMENT("get exception values");
42334232
LiftoffRegister values_array = GetExceptionProperty(
42344233
exception_var, RootIndex::kwasm_exception_values_symbol);
42354234
pinned.set(values_array);
42364235
uint32_t index = 0;
4237-
const WasmExceptionSig* sig = exception->sig;
4236+
const WasmTagSig* sig = tag->sig;
42384237
for (ValueType param : sig->parameters()) {
42394238
LoadExceptionValue(param.kind(), values_array, &index, pinned);
42404239
}
4241-
DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(exception));
4240+
DCHECK_EQ(index, WasmExceptionPackage::GetEncodedSize(tag));
42424241
}
42434242

42444243
void EmitLandingPad(FullDecoder* decoder, int handler_offset) {
@@ -4273,12 +4272,12 @@ class LiftoffCompiler {
42734272
__ DropValues(1);
42744273
}
42754274

4276-
void Throw(FullDecoder* decoder, const ExceptionIndexImmediate<validate>& imm,
4275+
void Throw(FullDecoder* decoder, const TagIndexImmediate<validate>& imm,
42774276
const base::Vector<Value>& /* args */) {
42784277
LiftoffRegList pinned;
42794278

42804279
// Load the encoded size in a register for the builtin call.
4281-
int encoded_size = WasmExceptionPackage::GetEncodedSize(imm.exception);
4280+
int encoded_size = WasmExceptionPackage::GetEncodedSize(imm.tag);
42824281
LiftoffRegister encoded_size_reg =
42834282
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
42844283
__ LoadConstant(encoded_size_reg, WasmValue(encoded_size));
@@ -4300,7 +4299,7 @@ class LiftoffCompiler {
43004299
// first value, such that we can just pop them from the value stack.
43014300
CODE_COMMENT("fill values array");
43024301
int index = encoded_size;
4303-
auto* sig = imm.exception->sig;
4302+
auto* sig = imm.tag->sig;
43044303
for (size_t param_idx = sig->parameter_count(); param_idx > 0;
43054304
--param_idx) {
43064305
ValueType type = sig->GetParam(param_idx - 1);
@@ -4312,7 +4311,7 @@ class LiftoffCompiler {
43124311
CODE_COMMENT("load exception tag");
43134312
LiftoffRegister exception_tag =
43144313
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
4315-
LOAD_TAGGED_PTR_INSTANCE_FIELD(exception_tag.gp(), ExceptionsTable, pinned);
4314+
LOAD_TAGGED_PTR_INSTANCE_FIELD(exception_tag.gp(), TagsTable, pinned);
43164315
__ LoadTaggedPointer(
43174316
exception_tag.gp(), exception_tag.gp(), no_reg,
43184317
wasm::ObjectAccess::ElementOffsetInTaggedFixedArray(imm.index), {});

src/wasm/c-api.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ own<ExternType> GetImportExportType(const i::wasm::WasmModule* module,
167167
Mutability mutability = global.mutability ? VAR : CONST;
168168
return GlobalType::make(std::move(content), mutability);
169169
}
170-
case i::wasm::kExternalException:
170+
case i::wasm::kExternalTag:
171171
UNREACHABLE();
172172
}
173173
}

0 commit comments

Comments
 (0)