Skip to content

Commit 872a3bf

Browse files
authored
[NFC] Rename StructNew::descriptor to desc (#7679)
For consistency with the corresponding members of RefCast and BrOn. The shorter name also matches the usage in the standards-track instruction mnemonics.
1 parent 482a548 commit 872a3bf

11 files changed

+31
-32
lines changed

src/ir/child-typer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
948948
}
949949
auto desc = curr->type.getHeapType().getDescriptorType();
950950
if (desc) {
951-
note(&curr->descriptor, Type(*desc, NonNullable, Exact));
951+
note(&curr->desc, Type(*desc, NonNullable, Exact));
952952
}
953953
}
954954

src/ir/cost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
694694
for (auto* child : curr->operands) {
695695
ret += visit(child);
696696
}
697-
ret += maybeVisit(curr->descriptor);
697+
ret += maybeVisit(curr->desc);
698698
return ret;
699699
}
700700
CostType visitStructGet(StructGet* curr) {

src/passes/Heap2Local.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,8 @@ struct Struct2Local : PostWalker<Struct2Local> {
612612
for (auto field : fields) {
613613
localIndexes.push_back(builder.addVar(func, field.type));
614614
}
615-
if (allocation->descriptor) {
616-
localIndexes.push_back(
617-
builder.addVar(func, allocation->descriptor->type));
615+
if (allocation->desc) {
616+
localIndexes.push_back(builder.addVar(func, allocation->desc->type));
618617
}
619618

620619
// Replace the things we need to using the visit* methods.
@@ -732,7 +731,7 @@ struct Struct2Local : PostWalker<Struct2Local> {
732731
// computed do we copy them into the locals representing the fields.
733732
std::vector<Index> tempIndexes;
734733
Index numTemps =
735-
(curr->isWithDefault() ? 0 : fields.size()) + bool(curr->descriptor);
734+
(curr->isWithDefault() ? 0 : fields.size()) + bool(curr->desc);
736735
tempIndexes.reserve(numTemps);
737736

738737
// Create the temp variables.
@@ -741,8 +740,8 @@ struct Struct2Local : PostWalker<Struct2Local> {
741740
tempIndexes.push_back(builder.addVar(func, field.type));
742741
}
743742
}
744-
if (curr->descriptor) {
745-
tempIndexes.push_back(builder.addVar(func, curr->descriptor->type));
743+
if (curr->desc) {
744+
tempIndexes.push_back(builder.addVar(func, curr->desc->type));
746745
}
747746

748747
// Store the initial values into the temp locals.
@@ -752,9 +751,9 @@ struct Struct2Local : PostWalker<Struct2Local> {
752751
builder.makeLocalSet(tempIndexes[i], curr->operands[i]));
753752
}
754753
}
755-
if (curr->descriptor) {
754+
if (curr->desc) {
756755
contents.push_back(
757-
builder.makeLocalSet(tempIndexes[numTemps - 1], curr->descriptor));
756+
builder.makeLocalSet(tempIndexes[numTemps - 1], curr->desc));
758757
}
759758

760759
// Store the values into the locals representing the fields.
@@ -765,9 +764,9 @@ struct Struct2Local : PostWalker<Struct2Local> {
765764
: builder.makeLocalGet(tempIndexes[i], fields[i].type);
766765
contents.push_back(builder.makeLocalSet(localIndexes[i], val));
767766
}
768-
if (curr->descriptor) {
767+
if (curr->desc) {
769768
auto* val =
770-
builder.makeLocalGet(tempIndexes[numTemps - 1], curr->descriptor->type);
769+
builder.makeLocalGet(tempIndexes[numTemps - 1], curr->desc->type);
771770
contents.push_back(
772771
builder.makeLocalSet(localIndexes[fields.size()], val));
773772
}
@@ -851,8 +850,8 @@ struct Struct2Local : PostWalker<Struct2Local> {
851850
// also know the cast must fail if the optimized allocation flows in as
852851
// the descriptor, since it cannot possibly have been used in the
853852
// allocation of the cast value without having been considered to escape.
854-
if (!allocation->descriptor || analyzer.getInteraction(curr->desc) ==
855-
ParentChildInteraction::Flows) {
853+
if (!allocation->desc || analyzer.getInteraction(curr->desc) ==
854+
ParentChildInteraction::Flows) {
856855
// The allocation does not have a descriptor, so there is no way for the
857856
// cast to succeed.
858857
replaceCurrent(builder.blockify(builder.makeDrop(curr->ref),
@@ -861,7 +860,7 @@ struct Struct2Local : PostWalker<Struct2Local> {
861860
} else {
862861
// The cast succeeds iff the optimized allocation's descriptor is the
863862
// same as the given descriptor and traps otherwise.
864-
auto type = allocation->descriptor->type;
863+
auto type = allocation->desc->type;
865864
replaceCurrent(builder.blockify(
866865
builder.makeDrop(curr->ref),
867866
builder.makeIf(
@@ -897,7 +896,7 @@ struct Struct2Local : PostWalker<Struct2Local> {
897896
return;
898897
}
899898

900-
auto type = allocation->descriptor->type;
899+
auto type = allocation->desc->type;
901900
if (type != curr->type) {
902901
// We know exactly the allocation that flows into this expression, so we
903902
// know the exact type of the descriptor. This type may be more precise

src/passes/RemoveUnusedModuleElements.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ struct Analyzer {
485485

486486
// Use the descriptor right now, normally. (We only have special
487487
// optimization for struct.new operands, below.)
488-
if (new_->descriptor) {
489-
use(new_->descriptor);
488+
if (new_->desc) {
489+
use(new_->desc);
490490
}
491491

492492
auto type = new_->type.getHeapType();

src/wasm-builder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ class Builder {
931931
Expression* descriptor = nullptr) {
932932
auto* ret = wasm.allocator.alloc<StructNew>();
933933
ret->operands.set(args);
934-
ret->descriptor = descriptor;
934+
ret->desc = descriptor;
935935
ret->type = Type(type, NonNullable, Exact);
936936
ret->finalize();
937937
return ret;
@@ -941,7 +941,7 @@ class Builder {
941941
Expression* descriptor = nullptr) {
942942
auto* ret = wasm.allocator.alloc<StructNew>();
943943
ret->operands = std::move(args);
944-
ret->descriptor = descriptor;
944+
ret->desc = descriptor;
945945
ret->type = Type(type, NonNullable, Exact);
946946
ret->finalize();
947947
return ret;
@@ -952,7 +952,7 @@ class Builder {
952952
Expression* descriptor = nullptr) {
953953
auto* ret = wasm.allocator.alloc<StructNew>();
954954
ret->operands.set(args);
955-
ret->descriptor = descriptor;
955+
ret->desc = descriptor;
956956
ret->type = Type(type, NonNullable, Exact);
957957
ret->finalize();
958958
return ret;

src/wasm-delegations-fields.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ DELEGATE_FIELD_CHILD(BrOn, ref)
671671
DELEGATE_FIELD_CASE_END(BrOn)
672672

673673
DELEGATE_FIELD_CASE_START(StructNew)
674-
DELEGATE_FIELD_OPTIONAL_CHILD(StructNew, descriptor)
674+
DELEGATE_FIELD_OPTIONAL_CHILD(StructNew, desc)
675675
DELEGATE_FIELD_CHILD_VECTOR(StructNew, operands)
676676
DELEGATE_FIELD_CASE_END(StructNew)
677677

src/wasm-interpreter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,8 +1781,8 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
17811781
return value;
17821782
}
17831783
}
1784-
if (curr->descriptor) {
1785-
auto value = self()->visit(curr->descriptor);
1784+
if (curr->desc) {
1785+
auto value = self()->visit(curr->desc);
17861786
if (value.breaking()) {
17871787
return value;
17881788
}
@@ -1804,10 +1804,10 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
18041804
data[i] = truncateForPacking(value.getSingleValue(), field);
18051805
}
18061806
}
1807-
if (!curr->descriptor) {
1807+
if (!curr->desc) {
18081808
return makeGCData(std::move(data), curr->type);
18091809
}
1810-
auto desc = self()->visit(curr->descriptor);
1810+
auto desc = self()->visit(curr->desc);
18111811
if (desc.breaking()) {
18121812
return desc;
18131813
}

src/wasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ class StructNew : public SpecificExpression<Expression::StructNewId> {
16831683
// case, and binaryen doesn't guarantee roundtripping binaries anyhow.
16841684
ExpressionList operands;
16851685

1686-
Expression* descriptor = nullptr;
1686+
Expression* desc = nullptr;
16871687

16881688
bool isWithDefault() { return operands.empty(); }
16891689

src/wasm/wasm-ir-builder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,15 +2230,15 @@ Result<> IRBuilder::makeStructNew(HeapType type) {
22302230
curr.type = Type(type, NonNullable, Exact);
22312231
curr.operands.resize(type.getStruct().fields.size());
22322232
CHECK_ERR(visitStructNew(&curr));
2233-
push(builder.makeStructNew(type, std::move(curr.operands), curr.descriptor));
2233+
push(builder.makeStructNew(type, std::move(curr.operands), curr.desc));
22342234
return Ok{};
22352235
}
22362236

22372237
Result<> IRBuilder::makeStructNewDefault(HeapType type) {
22382238
StructNew curr(wasm.allocator);
22392239
curr.type = Type(type, NonNullable, Exact);
22402240
CHECK_ERR(visitStructNew(&curr));
2241-
push(builder.makeStructNew(type, {}, curr.descriptor));
2241+
push(builder.makeStructNew(type, {}, curr.desc));
22422242
return Ok{};
22432243
}
22442244

src/wasm/wasm-validator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,11 +3159,11 @@ void FunctionValidator::visitStructNew(StructNew* curr) {
31593159

31603160
auto descType = curr->type.getHeapType().getDescriptorType();
31613161
if (!descType) {
3162-
shouldBeFalse(curr->descriptor,
3162+
shouldBeFalse(curr->desc,
31633163
curr,
31643164
"struct.new of type without descriptor should lack one");
31653165
} else {
3166-
shouldBeSubType(curr->descriptor->type,
3166+
shouldBeSubType(curr->desc->type,
31673167
Type(*descType, Nullable, Exact),
31683168
curr,
31693169
"struct.new descriptor operand should have proper type");

0 commit comments

Comments
 (0)