Skip to content

Commit fa43b50

Browse files
dcodeIOtlively
andauthored
Add new compound Signature, Struct and Array types (#3012)
Extends the `Type` hash-consing infrastructure to handle type-parameterized and constructed types introduced in the typed function references and GC proposals. This should be a non-functional change since the new types are not used anywhere yet. Recursive type construction and canonicalization is also left as future work. Co-authored-by: Thomas Lively <[email protected]>
1 parent d2e2521 commit fa43b50

16 files changed

+875
-157
lines changed

src/asmjs/asm_v_wasm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ std::string getSig(Function* func) {
101101
}
102102

103103
std::string getSig(Type results, Type params) {
104-
assert(!results.isMulti());
104+
assert(!results.isTuple());
105105
std::string sig;
106106
sig += getSig(results);
107107
for (const auto& param : params) {

src/ir/module-utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ collectSignatures(Module& wasm,
409409
counts[call->sig]++;
410410
} else if (Properties::isControlFlowStructure(curr)) {
411411
// TODO: Allow control flow to have input types as well
412-
if (curr->type.isMulti()) {
412+
if (curr->type.isTuple()) {
413413
counts[Signature(Type::none, curr->type)]++;
414414
}
415415
}

src/passes/Print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct SExprType {
6666

6767
static std::ostream& operator<<(std::ostream& o, const SExprType& localType) {
6868
Type type = localType.type;
69-
if (type.isMulti()) {
69+
if (type.isTuple()) {
7070
o << '(';
7171
auto sep = "";
7272
for (const auto& t : type) {

src/passes/RemoveUnusedBrs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
319319
// be further optimizable, and if select does not branch we also
320320
// avoid one branch.
321321
// Multivalue selects are not supported
322-
if (br->value && br->value->type.isMulti()) {
322+
if (br->value && br->value->type.isTuple()) {
323323
return;
324324
}
325325
// If running the br's condition unconditionally is too expensive,

src/tools/fuzzing.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class TranslateToFuzzReader {
306306
double getDouble() { return Literal(get64()).reinterpretf64(); }
307307

308308
Type getSubType(Type type) {
309-
if (type.isMulti()) {
309+
if (type.isTuple()) {
310310
std::vector<Type> types;
311311
for (const auto& t : type) {
312312
types.push_back(getSubType(t));
@@ -850,7 +850,7 @@ class TranslateToFuzzReader {
850850

851851
Expression* _makeConcrete(Type type) {
852852
bool canMakeControlFlow =
853-
!type.isMulti() || wasm.features.has(FeatureSet::Multivalue);
853+
!type.isTuple() || wasm.features.has(FeatureSet::Multivalue);
854854
using Self = TranslateToFuzzReader;
855855
FeatureOptions<Expression* (Self::*)(Type)> options;
856856
using WeightedOption = decltype(options)::WeightedOption;
@@ -886,7 +886,7 @@ class TranslateToFuzzReader {
886886
if (type == Type::i32) {
887887
options.add(FeatureSet::ReferenceTypes, &Self::makeRefIsNull);
888888
}
889-
if (type.isMulti()) {
889+
if (type.isTuple()) {
890890
options.add(FeatureSet::Multivalue, &Self::makeTupleMake);
891891
}
892892
return (this->*pick(options))(type);
@@ -1265,7 +1265,7 @@ class TranslateToFuzzReader {
12651265

12661266
Expression* makeTupleMake(Type type) {
12671267
assert(wasm.features.hasMultivalue());
1268-
assert(type.isMulti());
1268+
assert(type.isTuple());
12691269
std::vector<Expression*> elements;
12701270
for (const auto& t : type) {
12711271
elements.push_back(make(t));
@@ -1765,7 +1765,7 @@ class TranslateToFuzzReader {
17651765
}
17661766
return builder.makeRefNull();
17671767
}
1768-
if (type.isMulti()) {
1768+
if (type.isTuple()) {
17691769
std::vector<Expression*> operands;
17701770
for (const auto& t : type) {
17711771
operands.push_back(makeConst(t));
@@ -1783,7 +1783,7 @@ class TranslateToFuzzReader {
17831783
}
17841784

17851785
Expression* makeUnary(Type type) {
1786-
assert(!type.isMulti());
1786+
assert(!type.isTuple());
17871787
if (type == Type::unreachable) {
17881788
if (auto* unary = makeUnary(getSingleConcreteType())->dynCast<Unary>()) {
17891789
return builder.makeUnary(unary->op, make(Type::unreachable));
@@ -2004,7 +2004,7 @@ class TranslateToFuzzReader {
20042004
}
20052005

20062006
Expression* makeBinary(Type type) {
2007-
assert(!type.isMulti());
2007+
assert(!type.isTuple());
20082008
if (type == Type::unreachable) {
20092009
if (auto* binary =
20102010
makeBinary(getSingleConcreteType())->dynCast<Binary>()) {

src/tools/wasm-reduce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ struct Reducer
10191019
RefNull* n = builder->makeRefNull();
10201020
return tryToReplaceCurrent(n);
10211021
}
1022-
if (curr->type.isMulti()) {
1022+
if (curr->type.isTuple()) {
10231023
Expression* n =
10241024
builder->makeConstantExpression(Literal::makeZero(curr->type));
10251025
return tryToReplaceCurrent(n);

src/tools/wasm2c-wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int main(int argc, char** argv) {
164164
};
165165

166166
ret += wasm2cSignature(result);
167-
if (func->sig.params.isMulti()) {
167+
if (func->sig.params.isTuple()) {
168168
for (const auto& param : func->sig.params) {
169169
ret += wasm2cSignature(param);
170170
}

src/wasm-builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ class Builder {
795795
// minimal contents. as a replacement, this may reuse the
796796
// input node
797797
template<typename T> Expression* replaceWithIdenticalType(T* curr) {
798-
if (curr->type.isMulti()) {
798+
if (curr->type.isTuple()) {
799799
return makeConstantExpression(Literal::makeZero(curr->type));
800800
}
801801
Literal value;

0 commit comments

Comments
 (0)