diff options
author | Thomas Lively <tlively@google.com> | 2022-11-22 20:48:58 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-23 02:48:58 +0000 |
commit | 853b31ec89416bef0014e06f2defaef74f47b81e (patch) | |
tree | a288eeab1797ae6623c86cef6a6425c754cf498b /src/passes/Print.cpp | |
parent | f8e6d0253ba96bd26013146282ea4063f5853289 (diff) | |
download | binaryen-853b31ec89416bef0014e06f2defaef74f47b81e.tar.gz binaryen-853b31ec89416bef0014e06f2defaef74f47b81e.tar.bz2 binaryen-853b31ec89416bef0014e06f2defaef74f47b81e.zip |
Change the default type system to isorecursive (#5239)
This makes Binaryen's default type system match the WasmGC spec.
Update the way type definitions without supertypes are printed to reduce the
output diff for MVP tests that do not involve WasmGC. Also port some
type-builder.cpp tests from test/example to test/gtest since they needed to be
rewritten to work with isorecursive type anyway.
A follow-on PR will remove equirecursive types completely.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index d4b86f93d..a92b0a16a 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2832,9 +2832,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { void handleSignature(HeapType curr, Name name = Name()) { Signature sig = curr.getSignature(); - bool hasSupertype = - !name.is() && (getTypeSystem() == TypeSystem::Nominal || - getTypeSystem() == TypeSystem::Isorecursive); + bool hasSupertype = !name.is() && !!curr.getSuperType(); if (hasSupertype) { o << "(func_subtype"; } else { @@ -2891,8 +2889,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { } } void handleArray(HeapType curr) { - bool hasSupertype = getTypeSystem() == TypeSystem::Nominal || - getTypeSystem() == TypeSystem::Isorecursive; + bool hasSupertype = !!curr.getSuperType(); if (hasSupertype) { o << "(array_subtype "; } else { @@ -2906,8 +2903,7 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { o << ')'; } void handleStruct(HeapType curr) { - bool hasSupertype = getTypeSystem() == TypeSystem::Nominal || - getTypeSystem() == TypeSystem::Isorecursive; + bool hasSupertype = !!curr.getSuperType(); const auto& fields = curr.getStruct().fields; if (hasSupertype) { o << "(struct_subtype "; @@ -3038,8 +3034,9 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> { o << '('; printMajor(o, "func "); printName(curr->name, o); - if (getTypeSystem() == TypeSystem::Nominal || - getTypeSystem() == TypeSystem::Isorecursive) { + if (currModule && currModule->features.hasGC() && + (getTypeSystem() == TypeSystem::Nominal || + getTypeSystem() == TypeSystem::Isorecursive)) { o << " (type "; printHeapType(o, curr->type, currModule) << ')'; } |