Skip to content

Change the default type system to isorecursive #5239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ full changeset diff at the end of each section.
Current Trunk
-------------

- The isorecursive WasmGC type system (i.e. --hybrid) is now the default to
match the spec.

v111
----

Expand Down
15 changes: 6 additions & 9 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 ";
Expand Down Expand Up @@ -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) << ')';
}
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

namespace wasm {

static TypeSystem typeSystem = TypeSystem::Equirecursive;
static TypeSystem typeSystem = TypeSystem::Isorecursive;

void setTypeSystem(TypeSystem system) { typeSystem = system; }

Expand Down
2 changes: 1 addition & 1 deletion test/atomics-unshared.wast.from-wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(memory $0 1 1)
(func $foo
(func $foo (type $none_=>_none)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not print these if GC is not on? That is, even if the type system is isorecursive, we don't need these types if the features don't require it. It would also make the diff here much smaller I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I added that logic and it helped some of the lit tests, but the problem is that most of these tests run with -all.

(drop
(i32.atomic.rmw.cmpxchg
(i32.const 0)
Expand Down
2 changes: 1 addition & 1 deletion test/atomics-unshared.wast.fromBinary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(memory $0 1 1)
(func $foo
(func $foo (type $none_=>_none)
(drop
(i32.atomic.rmw.cmpxchg
(i32.const 0)
Expand Down
2 changes: 1 addition & 1 deletion test/atomics-unshared.wast.fromBinary.noDebugInfo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(memory $0 1 1)
(func $0
(func $0 (type $none_=>_none)
(drop
(i32.atomic.rmw.cmpxchg
(i32.const 0)
Expand Down
10 changes: 5 additions & 5 deletions test/atomics.wast.from-wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $0 (func))
(memory $0 (shared 23 256))
(func $atomic-loadstore
(func $atomic-loadstore (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -68,7 +68,7 @@
(local.get $1)
)
)
(func $atomic-rmw
(func $atomic-rmw (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -102,7 +102,7 @@
)
)
)
(func $atomic-cmpxchg
(func $atomic-cmpxchg (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -134,7 +134,7 @@
)
)
)
(func $atomic-wait-notify
(func $atomic-wait-notify (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -178,7 +178,7 @@
)
)
)
(func $atomic-fence
(func $atomic-fence (type $0)
(atomic.fence)
)
)
10 changes: 5 additions & 5 deletions test/atomics.wast.fromBinary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $0 (func))
(memory $0 (shared 23 256))
(func $atomic-loadstore
(func $atomic-loadstore (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -68,7 +68,7 @@
(local.get $1)
)
)
(func $atomic-rmw
(func $atomic-rmw (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -102,7 +102,7 @@
)
)
)
(func $atomic-cmpxchg
(func $atomic-cmpxchg (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -134,7 +134,7 @@
)
)
)
(func $atomic-wait-notify
(func $atomic-wait-notify (type $0)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -178,7 +178,7 @@
)
)
)
(func $atomic-fence
(func $atomic-fence (type $0)
(atomic.fence)
)
)
Expand Down
10 changes: 5 additions & 5 deletions test/atomics.wast.fromBinary.noDebugInfo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(memory $0 (shared 23 256))
(func $0
(func $0 (type $none_=>_none)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -68,7 +68,7 @@
(local.get $1)
)
)
(func $1
(func $1 (type $none_=>_none)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -102,7 +102,7 @@
)
)
)
(func $2
(func $2 (type $none_=>_none)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -134,7 +134,7 @@
)
)
)
(func $3
(func $3 (type $none_=>_none)
(local $0 i32)
(local $1 i64)
(drop
Expand Down Expand Up @@ -178,7 +178,7 @@
)
)
)
(func $4
(func $4 (type $none_=>_none)
(atomic.fence)
)
)
Expand Down
10 changes: 5 additions & 5 deletions test/atomics64.wast.from-wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $0 (func))
(memory $0 (shared i64 23 256))
(func $atomic-loadstore
(func $atomic-loadstore (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -69,7 +69,7 @@
(local.get $1)
)
)
(func $atomic-rmw
(func $atomic-rmw (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -104,7 +104,7 @@
)
)
)
(func $atomic-cmpxchg
(func $atomic-cmpxchg (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -137,7 +137,7 @@
)
)
)
(func $atomic-wait-notify
(func $atomic-wait-notify (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -182,7 +182,7 @@
)
)
)
(func $atomic-fence
(func $atomic-fence (type $0)
(atomic.fence)
)
)
10 changes: 5 additions & 5 deletions test/atomics64.wast.fromBinary
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $0 (func))
(memory $0 (shared i64 23 256))
(func $atomic-loadstore
(func $atomic-loadstore (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -69,7 +69,7 @@
(local.get $1)
)
)
(func $atomic-rmw
(func $atomic-rmw (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -104,7 +104,7 @@
)
)
)
(func $atomic-cmpxchg
(func $atomic-cmpxchg (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -137,7 +137,7 @@
)
)
)
(func $atomic-wait-notify
(func $atomic-wait-notify (type $0)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -182,7 +182,7 @@
)
)
)
(func $atomic-fence
(func $atomic-fence (type $0)
(atomic.fence)
)
)
Expand Down
10 changes: 5 additions & 5 deletions test/atomics64.wast.fromBinary.noDebugInfo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(type $none_=>_none (func))
(memory $0 (shared i64 23 256))
(func $0
(func $0 (type $none_=>_none)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -69,7 +69,7 @@
(local.get $1)
)
)
(func $1
(func $1 (type $none_=>_none)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -104,7 +104,7 @@
)
)
)
(func $2
(func $2 (type $none_=>_none)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -137,7 +137,7 @@
)
)
)
(func $3
(func $3 (type $none_=>_none)
(local $0 i64)
(local $1 i64)
(local $2 i32)
Expand Down Expand Up @@ -182,7 +182,7 @@
)
)
)
(func $4
(func $4 (type $none_=>_none)
(atomic.fence)
)
)
Expand Down
Loading