Skip to content

Commit

Permalink
review: check element initializers
Browse files Browse the repository at this point in the history
  • Loading branch information
abrown committed Nov 7, 2024
1 parent 648c733 commit 740c560
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@
(module quote "(table shared i64 (ref null (shared func)) (elem (ref.null (shared func))))")
"expected a u64")

;; A shared table must be initialized from shared objects.
(module
(type $f (shared (func)))
(global $g (shared (ref null $f)) (ref.null $f))
(table $t shared 1 (ref null $f))

This comment has been minimized.

Copy link
@rossberg

rossberg Nov 7, 2024

Member

The element segment is passive, so this table is unused (same below).

(elem (ref null $f) (global.get $g))
)
(assert_invalid
(module
(type $f (shared (func)))
(global $g (ref null $f) (ref.null $f))
(table $t shared 1 (ref null $f))
;; When we initialize a shared element, everything must be shared, including
;; the used global.

This comment has been minimized.

Copy link
@rossberg

rossberg Nov 7, 2024

Member

Oh. Why is that? The resulting element does not reference the global, so this restriction should be unnecessary.

Also, I'm not sure in what sense this element initializes anything shared, it appears to be unused. There is nothing invalid about this module AFAICS.

This comment has been minimized.

Copy link
@abrown

abrown Nov 8, 2024

Author Collaborator

The elem syntax is confusing. Perhaps you want to comment on the original PR since @tlively is the one asking for this kind of check?

(elem (ref null $f) (global.get $g)))
"invalid type")

;; Check `table.atomic.*` instructions.
(module (;eq;)
(table $a (import "spectest" "table_eq") shared 1 (ref null (shared eq)))
Expand Down

0 comments on commit 740c560

Please sign in to comment.