-
Notifications
You must be signed in to change notification settings - Fork 879
[wasm-split] Split active segments (part 1) #8840
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
aheejin
merged 6 commits into
WebAssembly:main
from
aheejin:wasm_split_active_segments1
Jun 17, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2968c1
[wasm-split] Split active segments (part 1)
aheejin 2284f52
Merge branch 'main' into wasm_split_active_segments1
aheejin 266750c
Remove offset trap checking
aheejin 09f81a9
Remove Table::kPageSize
aheejin bff8917
AddressType -> uint64_t
aheejin c98a0f4
Merge branch 'main' into wasm_split_active_segments1
aheejin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| ;; RUN: wasm-split -all -g %s --keep-funcs=keep -o1 %t.1.wasm -o2 %t.2.wasm | ||
| ;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY | ||
|
|
||
| (module | ||
| (global $g i32 (i32.const 42)) | ||
| (table $t 1 1 funcref) | ||
|
|
||
| ;; This elem $e stays in the primary module because table $t is used both in | ||
| ;; the primary and secondary modules. So, this elem should be marked as "used" | ||
| ;; in the secondary module, and global $g should not be exported / imported. | ||
| (elem $e (table $t) (global.get $g) funcref (item (ref.null nofunc))) | ||
|
|
||
| (func $keep | ||
| (drop | ||
| (table.get $t | ||
| (i32.const 0) | ||
| ) | ||
| ) | ||
| ) | ||
| (func $split | ||
| (drop | ||
| (table.get $t | ||
| (i32.const 0) | ||
| ) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ;; PRIMARY: (module | ||
| ;; PRIMARY-NEXT: (type $0 (func)) | ||
| ;; PRIMARY-NEXT: (global $g i32 (i32.const 42)) | ||
| ;; PRIMARY-NEXT: (table $t 1 1 funcref) | ||
| ;; PRIMARY-NEXT: (elem $e (table $t) (global.get $g) funcref (item (ref.null nofunc))) | ||
| ;; PRIMARY-NEXT: (export "table" (table $t)) | ||
| ;; PRIMARY-NEXT: (func $keep | ||
| ;; PRIMARY-NEXT: (drop | ||
| ;; PRIMARY-NEXT: (table.get $t | ||
| ;; PRIMARY-NEXT: (i32.const 0) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
|
|
||
| ;; SECONDARY: (module | ||
| ;; SECONDARY-NEXT: (type $0 (func)) | ||
| ;; SECONDARY-NEXT: (import "primary" "table" (table $t 1 1 funcref)) | ||
| ;; SECONDARY-NEXT: (func $split | ||
| ;; SECONDARY-NEXT: (drop | ||
| ;; SECONDARY-NEXT: (table.get $t | ||
| ;; SECONDARY-NEXT: (i32.const 0) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
| ;; RUN: wasm-split %s -all -g -o1 %t.1.wasm -o2 %t.2.wasm --split-funcs=split | ||
| ;; RUN: wasm-dis -all %t.1.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis -all %t.2.wasm | filecheck %s --check-prefix SECONDARY | ||
|
|
||
| (module | ||
| ;; PRIMARY: (type $0 (func)) | ||
|
|
||
| ;; PRIMARY: (global $g funcref (ref.null nofunc)) | ||
| (global $g funcref (ref.null nofunc)) | ||
|
|
||
| ;; We should scan this passive element segment's data and correctly mark $g as | ||
| ;; used in the primary module. | ||
| ;; PRIMARY: (elem $passive-elem funcref (item (global.get $g))) | ||
| (elem $passive-elem funcref (item (global.get $g))) | ||
|
|
||
| ;; PRIMARY: (export "global" (global $g)) | ||
|
|
||
| ;; PRIMARY: (func $keep (type $0) | ||
| ;; PRIMARY-NEXT: (elem.drop $passive-elem) | ||
| ;; PRIMARY-NEXT: ) | ||
| (func $keep | ||
| (elem.drop $passive-elem) | ||
| ) | ||
|
|
||
| ;; SECONDARY: (type $0 (func)) | ||
|
|
||
| ;; SECONDARY: (import "primary" "global" (global $g funcref)) | ||
|
|
||
| ;; SECONDARY: (func $split (type $0) | ||
| ;; SECONDARY-NEXT: (drop | ||
| ;; SECONDARY-NEXT: (global.get $g) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| (func $split | ||
| (drop (global.get $g)) | ||
| ) | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this pattern of having compute and check all the using secondaries could also be simplified if we computed the single owning module for every item as suggested in #8832 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I do that as a followup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!