-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Translate global.gets of defined, immutable globals into constants
#12234
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
fitzgen
merged 1 commit into
bytecodealliance:main
from
fitzgen:global-get-of-defined-immutable-globals
Jan 5, 2026
+160
−5
Merged
Changes from all commits
Commits
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
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
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,94 @@ | ||
| ;;! target = "x86_64" | ||
|
|
||
| (module | ||
| ;; Imported and immutable: should become a vmctx load. | ||
| (import "env" "a" (global $imp-imm i32)) | ||
|
|
||
| ;; Imported and mutable: should become a vmctx load. | ||
| (import "env" "b" (global $imp-mut (mut i32))) | ||
|
|
||
| ;; Defined and immutable: should become a constant. | ||
| (global $def-imm i32 (i32.const 42)) | ||
|
|
||
| ;; Defined and mutable: should become a vmctx load. | ||
| (global $def-mut (mut i32) (i32.const 36)) | ||
|
|
||
| (func $f0 (result i32) | ||
| (global.get $imp-imm) | ||
| ) | ||
|
|
||
| (func $f1 (result i32) | ||
| (global.get $imp-mut) | ||
| ) | ||
|
|
||
| (func $f2 (result i32) | ||
| (global.get $def-imm) | ||
| ) | ||
|
|
||
| (func $f3 (result i32) | ||
| (global.get $def-mut) | ||
| ) | ||
| ) | ||
|
|
||
| ;; function u0:0(i64 vmctx, i64) -> i32 tail { | ||
| ;; gv0 = vmctx | ||
| ;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
| ;; gv2 = load.i64 notrap aligned gv1+16 | ||
| ;; gv3 = vmctx | ||
| ;; gv4 = load.i64 notrap aligned readonly can_move gv3+48 | ||
| ;; stack_limit = gv2 | ||
| ;; | ||
| ;; block0(v0: i64, v1: i64): | ||
| ;; @003d v3 = load.i64 notrap aligned readonly can_move v0+48 | ||
| ;; @003d v4 = load.i32 notrap aligned table v3 | ||
| ;; @003f jump block1 | ||
| ;; | ||
| ;; block1: | ||
| ;; @003f return v4 | ||
| ;; } | ||
| ;; | ||
| ;; function u0:1(i64 vmctx, i64) -> i32 tail { | ||
| ;; gv0 = vmctx | ||
| ;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
| ;; gv2 = load.i64 notrap aligned gv1+16 | ||
| ;; gv3 = vmctx | ||
| ;; gv4 = load.i64 notrap aligned readonly can_move gv3+72 | ||
| ;; stack_limit = gv2 | ||
| ;; | ||
| ;; block0(v0: i64, v1: i64): | ||
| ;; @0042 v3 = load.i64 notrap aligned readonly can_move v0+72 | ||
| ;; @0042 v4 = load.i32 notrap aligned table v3 | ||
| ;; @0044 jump block1 | ||
| ;; | ||
| ;; block1: | ||
| ;; @0044 return v4 | ||
| ;; } | ||
| ;; | ||
| ;; function u0:2(i64 vmctx, i64) -> i32 tail { | ||
| ;; gv0 = vmctx | ||
| ;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
| ;; gv2 = load.i64 notrap aligned gv1+16 | ||
| ;; stack_limit = gv2 | ||
| ;; | ||
| ;; block0(v0: i64, v1: i64): | ||
| ;; @0047 v3 = iconst.i32 42 | ||
| ;; @0049 jump block1 | ||
| ;; | ||
| ;; block1: | ||
| ;; @0049 return v3 ; v3 = 42 | ||
| ;; } | ||
| ;; | ||
| ;; function u0:3(i64 vmctx, i64) -> i32 tail { | ||
| ;; gv0 = vmctx | ||
| ;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
| ;; gv2 = load.i64 notrap aligned gv1+16 | ||
| ;; gv3 = vmctx | ||
| ;; stack_limit = gv2 | ||
| ;; | ||
| ;; block0(v0: i64, v1: i64): | ||
| ;; @004c v4 = load.i32 notrap aligned table v0+112 | ||
| ;; @004e jump block1 | ||
| ;; | ||
| ;; block1: | ||
| ;; @004e return v4 | ||
| ;; } |
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.
Uh oh!
There was an error while loading. Please reload this page.