-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use
MemoryStyle
for heap base pointer relocations
Instead add a helper method to `Memory` which indicates whether the base pointer of memory can move. Use this and plumb the result around to the various locations that require it. This improves the `readonly` application of the base pointer in Cranelift by having the optimization kick in in more scenarios. It additionally fixes combining shared linear memories with 64-bit addressing or a page size of 1 by adding a runtime check before relocation of a linear memory that it's allowed to do so. A few codegen tests are added to ensure that `readonly` is applied where it wasn't previously and additionally a new `*.wast` test was added with the cross product of various features of linear memories and some basic tests to ensure that the memories all work as expected. This refactoring fixes two preexisting issues about `shared` memories requiring a "static" memory style. The restriction is now based on whether the pointer can relocate or not and that's upheld via the new trait method added here. To account for these bug fixes the fuzzers have been updated to allow mixing the `threads` proposal with `memory64` or `custom-page-sizes`. Closes #4267 Closes #9523
- Loading branch information
1 parent
cc6cf63
commit cb16230
Showing
13 changed files
with
500 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,32 @@ | ||
;;! test = "optimize" | ||
;;! target = "x86_64" | ||
;;! flags = ["-Omemory-reservation=0x20000", "-Omemory-may-move=n"] | ||
|
||
(module | ||
(memory 1) | ||
(func $load (param i32) (result i32) | ||
(i32.load (local.get 0))) | ||
) | ||
;; function u0:0(i64 vmctx, i64, i32) -> i32 tail { | ||
;; gv0 = vmctx | ||
;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
;; gv2 = load.i64 notrap aligned gv1 | ||
;; gv3 = vmctx | ||
;; gv4 = load.i64 notrap aligned gv3+104 | ||
;; gv5 = load.i64 notrap aligned readonly checked gv3+96 | ||
;; stack_limit = gv2 | ||
;; | ||
;; block0(v0: i64, v1: i64, v2: i32): | ||
;; @0020 v4 = uextend.i64 v2 | ||
;; @0020 v5 = iconst.i64 0x0001_fffc | ||
;; @0020 v6 = icmp ugt v4, v5 ; v5 = 0x0001_fffc | ||
;; @0020 v9 = iconst.i64 0 | ||
;; @0020 v7 = load.i64 notrap aligned readonly checked v0+96 | ||
;; @0020 v8 = iadd v7, v4 | ||
;; @0020 v10 = select_spectre_guard v6, v9, v8 ; v9 = 0 | ||
;; @0020 v11 = load.i32 little heap v10 | ||
;; @0023 jump block1 | ||
;; | ||
;; block1: | ||
;; @0023 return v11 | ||
;; } |
This file contains 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,34 @@ | ||
;;! test = "optimize" | ||
;;! target = "x86_64" | ||
;;! flags = ["-Omemory-reservation=0x20000"] | ||
|
||
(module | ||
(memory 1 200 shared) | ||
(func $load (param i32) (result i32) | ||
(i32.load (local.get 0))) | ||
) | ||
;; function u0:0(i64 vmctx, i64, i32) -> i32 tail { | ||
;; gv0 = vmctx | ||
;; gv1 = load.i64 notrap aligned readonly gv0+8 | ||
;; gv2 = load.i64 notrap aligned gv1 | ||
;; gv3 = vmctx | ||
;; gv4 = load.i64 notrap aligned readonly gv3+88 | ||
;; gv5 = load.i64 notrap aligned gv4+8 | ||
;; gv6 = load.i64 notrap aligned readonly checked gv4 | ||
;; stack_limit = gv2 | ||
;; | ||
;; block0(v0: i64, v1: i64, v2: i32): | ||
;; @0022 v12 = load.i64 notrap aligned readonly v0+88 | ||
;; @0022 v5 = load.i64 notrap aligned v12+8 | ||
;; @0022 v4 = uextend.i64 v2 | ||
;; @0022 v6 = icmp ugt v4, v5 | ||
;; @0022 v9 = iconst.i64 0 | ||
;; @0022 v7 = load.i64 notrap aligned readonly checked v12 | ||
;; @0022 v8 = iadd v7, v4 | ||
;; @0022 v10 = select_spectre_guard v6, v9, v8 ; v9 = 0 | ||
;; @0022 v11 = load.i32 little heap v10 | ||
;; @0025 jump block1 | ||
;; | ||
;; block1: | ||
;; @0025 return v11 | ||
;; } |
Oops, something went wrong.