Skip to content

Commit 9cef51c

Browse files
authored
[NFC] Take a HeapType instead of Type in RefFunc::finalize (#7442)
This removes from the callers the burden of constructing the type with the correct nullability and other future attributes.
1 parent 01e0eea commit 9cef51c

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/passes/Precompute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ struct Precompute
313313
if (auto* r = curr->value->template dynCast<RefFunc>()) {
314314
r->func = singleValue.getFunc();
315315
auto heapType = getModule()->getFunction(r->func)->type;
316-
r->finalize(Type(heapType, NonNullable));
316+
r->finalize(heapType);
317317
curr->finalize();
318318
return;
319319
}

src/wasm-builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ class Builder {
688688
RefFunc* makeRefFunc(Name func, HeapType heapType) {
689689
auto* ret = wasm.allocator.alloc<RefFunc>();
690690
ret->func = func;
691-
ret->finalize(Type(heapType, NonNullable));
691+
ret->finalize(heapType);
692692
return ret;
693693
}
694694
RefEq* makeRefEq(Expression* left, Expression* right) {

src/wasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ class RefFunc : public SpecificExpression<Expression::RefFuncId> {
13641364
Name func;
13651365

13661366
void finalize();
1367-
void finalize(Type type_);
1367+
void finalize(HeapType heapType);
13681368
};
13691369

13701370
class RefEq : public SpecificExpression<Expression::RefEqId> {

src/wasm/wasm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,9 @@ void RefFunc::finalize() {
821821
assert(type.isSignature());
822822
}
823823

824-
void RefFunc::finalize(Type type_) { type = type_; }
824+
void RefFunc::finalize(HeapType heapType) {
825+
type = Type(heapType, NonNullable);
826+
}
825827

826828
void RefEq::finalize() {
827829
if (left->type == Type::unreachable || right->type == Type::unreachable) {

0 commit comments

Comments
 (0)