Skip to content

Update the binary format for exact heap types #7502

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 43 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
233601e
Revert exact HeapTypes
tlively Apr 7, 2025
a0633ed
Restore exact references
tlively Apr 7, 2025
76a4ee8
Type RefNull as inexact
tlively Apr 8, 2025
a3762c7
Update exact reference semantics
tlively Apr 9, 2025
061ad11
[NFC] Represent exactness and sharedness with one bit
tlively Apr 9, 2025
79934a1
Update text format for exact heap types
tlively Apr 10, 2025
17d7099
Update the binary format for exact heap types
tlively Apr 15, 2025
8587ddc
update test
tlively Apr 15, 2025
2511cd4
Merge branch 'main' into massive-unrevert
tlively Apr 15, 2025
43d11e9
Merge branch 'massive-unrevert' into inexact-ref-null
tlively Apr 15, 2025
986e09d
Merge branch 'inexact-ref-null' into no-basic-exact-types
tlively Apr 15, 2025
9a15e23
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 15, 2025
6a4e039
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 15, 2025
5e88ede
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 15, 2025
3677e19
update tests
tlively Apr 15, 2025
cb116dd
Merge branch 'inexact-ref-null' into no-basic-exact-types
tlively Apr 15, 2025
09f4b7d
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 15, 2025
e9c6045
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 15, 2025
09f3ebe
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 15, 2025
f8e690b
updates
tlively Apr 15, 2025
c77a943
Merge branch 'inexact-ref-null' into no-basic-exact-types
tlively Apr 15, 2025
8bed563
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 15, 2025
3a251e0
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 15, 2025
6438844
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 15, 2025
bded440
comment
tlively Apr 15, 2025
a9a209b
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 15, 2025
c5f8860
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 15, 2025
74b0ce1
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 15, 2025
883543f
update test
tlively Apr 15, 2025
2467a8b
Merge branch 'inexact-ref-null' into no-basic-exact-types
tlively Apr 15, 2025
b601653
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 15, 2025
489ae99
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 15, 2025
a205843
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 15, 2025
4c3a506
remove unused builder method with incorrect assertion
tlively Apr 15, 2025
14d14ca
Merge branch 'main' into no-basic-exact-types
tlively Apr 16, 2025
f787b2d
Merge branch 'no-basic-exact-types' into exact-shared-same-bit
tlively Apr 16, 2025
e8591a1
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 16, 2025
c1138b1
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 16, 2025
249275a
Merge branch 'main' into exact-shared-same-bit
tlively Apr 16, 2025
541f0e1
Merge branch 'exact-shared-same-bit' into text-parse-exact-heap-types
tlively Apr 16, 2025
feaa315
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 16, 2025
a1a2c02
Merge branch 'main' into text-parse-exact-heap-types
tlively Apr 16, 2025
708d864
Merge branch 'text-parse-exact-heap-types' into binary-exact-heap-types
tlively Apr 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updates
  • Loading branch information
tlively committed Apr 15, 2025
commit f8e690b256f609dbe87fb46a22866a416c96a214
2 changes: 1 addition & 1 deletion src/literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class Literal {
}
}
static Literal makeNull(HeapType type) {
return Literal(Type(type.getBottom(), Nullable, Exact));
return Literal(Type(type.getBottom(), Nullable));
}
static Literal makeFunc(Name func, HeapType type) {
return Literal(func, type);
Expand Down
2 changes: 1 addition & 1 deletion src/wasm-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class Builder {
}
RefNull* makeRefNull(HeapType type) {
auto* ret = wasm.allocator.alloc<RefNull>();
ret->finalize(Type(type.getBottom(), Nullable, Exact));
ret->finalize(Type(type.getBottom(), Nullable));
return ret;
}
RefNull* makeRefNull(Type type) {
Expand Down
4 changes: 0 additions & 4 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2288,10 +2288,6 @@ void FunctionValidator::visitRefNull(RefNull* curr) {
curr->type.isNullable(), curr, "ref.null types must be nullable")) {
return;
}
if (!shouldBeTrue(
curr->type.isExact(), curr, "ref.null types must be exact")) {
return;
}
shouldBeTrue(
curr->type.isNull(), curr, "ref.null must have a bottom heap type");
}
Expand Down
16 changes: 8 additions & 8 deletions test/lit/basic/reference-types.wast
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: (drop
;; CHECK-BIN-NEXT: (block $block2 (result eqref)
;; CHECK-BIN-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NEXT: (ref.cast nullref
;; CHECK-BIN-NEXT: (br_if $block2
;; CHECK-BIN-NEXT: (ref.null none)
;; CHECK-BIN-NEXT: (i32.const 1)
Expand All @@ -987,7 +987,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: (drop
;; CHECK-BIN-NEXT: (block $block5 (result funcref)
;; CHECK-BIN-NEXT: (ref.cast (exact nullfuncref)
;; CHECK-BIN-NEXT: (ref.cast nullfuncref
;; CHECK-BIN-NEXT: (br_if $block5
;; CHECK-BIN-NEXT: (ref.null nofunc)
;; CHECK-BIN-NEXT: (i32.const 1)
Expand Down Expand Up @@ -1023,7 +1023,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: (drop
;; CHECK-BIN-NEXT: (block $block9 (result anyref)
;; CHECK-BIN-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NEXT: (ref.cast nullref
;; CHECK-BIN-NEXT: (br_if $block9
;; CHECK-BIN-NEXT: (ref.null none)
;; CHECK-BIN-NEXT: (i32.const 1)
Expand All @@ -1043,7 +1043,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: (drop
;; CHECK-BIN-NEXT: (block $block11 (result anyref)
;; CHECK-BIN-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NEXT: (ref.cast nullref
;; CHECK-BIN-NEXT: (br_if $block11
;; CHECK-BIN-NEXT: (ref.null none)
;; CHECK-BIN-NEXT: (i32.const 1)
Expand Down Expand Up @@ -2298,7 +2298,7 @@
;; CHECK-BIN-NODEBUG-NEXT: )
;; CHECK-BIN-NODEBUG-NEXT: (drop
;; CHECK-BIN-NODEBUG-NEXT: (block $block2 (result eqref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast nullref
;; CHECK-BIN-NODEBUG-NEXT: (br_if $block2
;; CHECK-BIN-NODEBUG-NEXT: (ref.null none)
;; CHECK-BIN-NODEBUG-NEXT: (i32.const 1)
Expand All @@ -2324,7 +2324,7 @@
;; CHECK-BIN-NODEBUG-NEXT: )
;; CHECK-BIN-NODEBUG-NEXT: (drop
;; CHECK-BIN-NODEBUG-NEXT: (block $block5 (result funcref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast (exact nullfuncref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast nullfuncref
;; CHECK-BIN-NODEBUG-NEXT: (br_if $block5
;; CHECK-BIN-NODEBUG-NEXT: (ref.null nofunc)
;; CHECK-BIN-NODEBUG-NEXT: (i32.const 1)
Expand Down Expand Up @@ -2360,7 +2360,7 @@
;; CHECK-BIN-NODEBUG-NEXT: )
;; CHECK-BIN-NODEBUG-NEXT: (drop
;; CHECK-BIN-NODEBUG-NEXT: (block $block9 (result anyref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast nullref
;; CHECK-BIN-NODEBUG-NEXT: (br_if $block9
;; CHECK-BIN-NODEBUG-NEXT: (ref.null none)
;; CHECK-BIN-NODEBUG-NEXT: (i32.const 1)
Expand All @@ -2380,7 +2380,7 @@
;; CHECK-BIN-NODEBUG-NEXT: )
;; CHECK-BIN-NODEBUG-NEXT: (drop
;; CHECK-BIN-NODEBUG-NEXT: (block $block11 (result anyref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast (exact nullref)
;; CHECK-BIN-NODEBUG-NEXT: (ref.cast nullref
;; CHECK-BIN-NODEBUG-NEXT: (br_if $block11
;; CHECK-BIN-NODEBUG-NEXT: (ref.null none)
;; CHECK-BIN-NODEBUG-NEXT: (i32.const 1)
Expand Down
4 changes: 2 additions & 2 deletions test/lit/heap-types.wast
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(type $struct.B (struct i32))
;; CHECK: (func $test (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.test (ref exact none)
;; CHECK-NEXT: (ref.test (ref none)
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand All @@ -29,7 +29,7 @@
(type $struct.B (struct i32))
;; CHECK: (func $test (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.cast (exact nullref)
;; CHECK-NEXT: (ref.cast nullref
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/cfp.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block (result (exact nullref))
;; CHECK-NEXT: (block (result nullref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (local.get $struct3)
Expand Down Expand Up @@ -1233,7 +1233,7 @@
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block (result (exact nullref))
;; CHECK-NEXT: (block (result nullref)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (local.get $struct3)
Expand Down
4 changes: 2 additions & 2 deletions test/lit/passes/code-pushing-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block $out (result (ref func))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (br_on_cast $out (exact nullfuncref) (ref exact nofunc)
;; CHECK-NEXT: (br_on_cast $out nullfuncref (ref nofunc)
;; CHECK-NEXT: (ref.null nofunc)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down Expand Up @@ -48,7 +48,7 @@
;; CHECK-NEXT: (ref.func $br_on_no)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (br_on_cast $out (exact nullfuncref) (ref exact nofunc)
;; CHECK-NEXT: (br_on_cast $out nullfuncref (ref nofunc)
;; CHECK-NEXT: (ref.null nofunc)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/dae-gc-refine-params.wast
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
)
;; This function is called in ways that allow us to make the first parameter
;; non-nullable.
;; CHECK: (func $various-params-null (type $13) (param $x (ref exact none)) (param $y (ref null $"{i32}"))
;; CHECK: (func $various-params-null (type $13) (param $x (ref none)) (param $y (ref null $"{i32}"))
;; CHECK-NEXT: (local $temp i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $x)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/dae-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
)

;; CHECK: (func $bar (type $2) (param $0 i31ref)
;; CHECK-NEXT: (local $1 (exact nullref))
;; CHECK-NEXT: (local $1 nullref)
;; CHECK-NEXT: (local.set $1
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
Expand Down
6 changes: 3 additions & 3 deletions test/lit/passes/flatten_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3581,8 +3581,8 @@
;; CHECK: (func $subtype (type $7) (result anyref)
;; CHECK-NEXT: (local $0 eqref)
;; CHECK-NEXT: (local $1 anyref)
;; CHECK-NEXT: (local $2 (exact nullref))
;; CHECK-NEXT: (local $3 (exact nullref))
;; CHECK-NEXT: (local $2 nullref)
;; CHECK-NEXT: (local $3 nullref)
;; CHECK-NEXT: (local $4 eqref)
;; CHECK-NEXT: (local $5 eqref)
;; CHECK-NEXT: (local $6 eqref)
Expand Down Expand Up @@ -3680,7 +3680,7 @@
;; CHECK: (type $0 (func (result funcref)))

;; CHECK: (func $0 (type $0) (result funcref)
;; CHECK-NEXT: (local $0 (ref exact nofunc))
;; CHECK-NEXT: (local $0 (ref nofunc))
;; CHECK-NEXT: (local.set $0
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (ref.null nofunc)
Expand Down
18 changes: 9 additions & 9 deletions test/lit/passes/global-refining.wast
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
;; CLOSD: (type $foo_t (func))
(type $foo_t (func))

;; CHECK: (global $func-null-init (mut (exact nullfuncref)) (ref.null nofunc))
;; CLOSD: (global $func-null-init (mut (exact nullfuncref)) (ref.null nofunc))
;; CHECK: (global $func-null-init (mut nullfuncref) (ref.null nofunc))
;; CLOSD: (global $func-null-init (mut nullfuncref) (ref.null nofunc))
(global $func-null-init (mut funcref) (ref.null $foo_t))
;; CHECK: (global $func-func-init (mut (ref $foo_t)) (ref.func $foo))
;; CLOSD: (global $func-func-init (mut (ref $foo_t)) (ref.func $foo))
Expand All @@ -32,8 +32,8 @@
;; CLOSD: (type $foo_t (func))
(type $foo_t (func))

;; CHECK: (global $func-null-init (mut (exact nullfuncref)) (ref.null nofunc))
;; CLOSD: (global $func-null-init (mut (exact nullfuncref)) (ref.null nofunc))
;; CHECK: (global $func-null-init (mut nullfuncref) (ref.null nofunc))
;; CLOSD: (global $func-null-init (mut nullfuncref) (ref.null nofunc))
(global $func-null-init (mut funcref) (ref.null $foo_t))
;; CHECK: (global $func-func-init (mut (ref null $foo_t)) (ref.func $foo))
;; CLOSD: (global $func-func-init (mut (ref null $foo_t)) (ref.func $foo))
Expand Down Expand Up @@ -202,16 +202,16 @@
;; (ref null func) to nullfuncref only when not exported, and if exported, then
;; only when immutable in open world.
(module
;; CHECK: (global $mut (mut (exact nullfuncref)) (ref.null nofunc))
;; CLOSD: (global $mut (mut (exact nullfuncref)) (ref.null nofunc))
;; CHECK: (global $mut (mut nullfuncref) (ref.null nofunc))
;; CLOSD: (global $mut (mut nullfuncref) (ref.null nofunc))
(global $mut (mut (ref null func)) (ref.null nofunc))
;; CHECK: (global $imm (exact nullfuncref) (ref.null nofunc))
;; CLOSD: (global $imm (exact nullfuncref) (ref.null nofunc))
;; CHECK: (global $imm nullfuncref (ref.null nofunc))
;; CLOSD: (global $imm nullfuncref (ref.null nofunc))
(global $imm (ref null func) (ref.null nofunc))
;; CHECK: (global $mut-exp (mut funcref) (ref.null nofunc))
;; CLOSD: (global $mut-exp (mut funcref) (ref.null nofunc))
(global $mut-exp (mut (ref null func)) (ref.null nofunc))
;; CHECK: (global $imm-exp (exact nullfuncref) (ref.null nofunc))
;; CHECK: (global $imm-exp nullfuncref (ref.null nofunc))
;; CLOSD: (global $imm-exp funcref (ref.null nofunc))
(global $imm-exp (ref null func) (ref.null nofunc))

Expand Down
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.