-
Notifications
You must be signed in to change notification settings - Fork 6
[interpreter] Add page type to IR of memory types #50
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
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -104,6 +104,9 @@ let check_limits {min; max} range at msg = | |
| require (I64.le_u min max) at | ||
| "size minimum must not be greater than maximum" | ||
|
|
||
| let check_pagesize (PageT ps) at = | ||
| require (ps = 0x10000 || ps = 1) at "page size must be 1 or 64KiB" | ||
|
|
||
| let check_numtype (c : context) (t : numtype) at = | ||
| () | ||
|
|
||
|
|
@@ -196,13 +199,14 @@ let check_globaltype (c : context) (gt : globaltype) at = | |
| check_valtype c t at | ||
|
|
||
| let check_memorytype (c : context) (mt : memorytype) at = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you need to check here that pt is either 1 or 0x10000?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| let MemoryT (at_, lim) = mt in | ||
| let MemoryT (at_, lim, pt) = mt in | ||
| let sz, s = | ||
| match at_ with | ||
| | I32AT -> 0x1_0000L, "2^16 pages (4 GiB) for i32" | ||
| | I64AT -> 0x1_0000_0000_0000L, "2^48 pages (256 TiB) for i64" | ||
| in | ||
| check_limits lim sz at ("memory size must be at most " ^ s) | ||
| check_limits lim sz at ("memory size must be at most " ^ s); | ||
| check_pagesize pt at | ||
|
|
||
| let check_tabletype (c : context) (tt : tabletype) at = | ||
| let TableT (at_, lim, t) = tt in | ||
|
|
@@ -384,7 +388,7 @@ let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at = | |
| in | ||
| require (1 lsl memop.align >= 1 && 1 lsl memop.align <= size) at | ||
| "alignment must not be larger than natural"; | ||
| let MemoryT (at_, _lim) = memory c (0l @@ at) in | ||
| let MemoryT (at_, _lim, _pt) = memory c (0l @@ at) in | ||
| if at_ = I32AT then | ||
| require (I64.lt_u memop.offset 0x1_0000_0000L) at | ||
| "offset out of range"; | ||
|
|
@@ -648,60 +652,60 @@ let rec check_instr (c : context) (e : instr) (s : infer_resulttype) : infer_ins | |
| [] --> [], [] | ||
|
|
||
| | Load (x, memop) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop num_size (Lib.Option.map fst) e.at in | ||
| [NumT (numtype_of_addrtype at)] --> [NumT t], [] | ||
|
|
||
| | Store (x, memop) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop num_size (fun sz -> sz) e.at in | ||
| [NumT (numtype_of_addrtype at); NumT t] --> [], [] | ||
|
|
||
| | VecLoad (x, memop) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop vec_size (Lib.Option.map fst) e.at in | ||
| [NumT (numtype_of_addrtype at)] --> [VecT t], [] | ||
|
|
||
| | VecStore (x, memop) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop vec_size (fun _ -> None) e.at in | ||
| [NumT (numtype_of_addrtype at); VecT t] --> [], [] | ||
|
|
||
| | VecLoadLane (x, memop, i) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop vec_size (fun sz -> Some sz) e.at in | ||
| require (I8.to_int_u i < vec_size t / Pack.packed_size memop.pack) e.at | ||
| "invalid lane index"; | ||
| [NumT (numtype_of_addrtype at); VecT t] --> [VecT t], [] | ||
|
|
||
| | VecStoreLane (x, memop, i) -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| let t = check_memop c memop vec_size (fun sz -> Some sz) e.at in | ||
| require (I8.to_int_u i < vec_size t / Pack.packed_size memop.pack) e.at | ||
| "invalid lane index"; | ||
| [NumT (numtype_of_addrtype at); VecT t] --> [], [] | ||
|
|
||
| | MemorySize x -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| [] --> [NumT (numtype_of_addrtype at)], [] | ||
|
|
||
| | MemoryGrow x -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| [NumT (numtype_of_addrtype at)] --> [NumT (numtype_of_addrtype at)], [] | ||
|
|
||
| | MemoryFill x -> | ||
| let MemoryT (at, _lim) = memory c x in | ||
| let MemoryT (at, _lim, _pt) = memory c x in | ||
| [NumT (numtype_of_addrtype at); NumT I32T; | ||
| NumT (numtype_of_addrtype at)] --> [], [] | ||
|
|
||
| | MemoryCopy (x, y)-> | ||
| let MemoryT (at1, _lib1) = memory c x in | ||
| let MemoryT (at2, _lib2) = memory c y in | ||
| let MemoryT (at1, _pt, _lib1) = memory c x in | ||
| let MemoryT (at2, _pt, _lib2) = memory c y in | ||
| [NumT (numtype_of_addrtype at1); NumT (numtype_of_addrtype at2); | ||
| NumT (numtype_of_addrtype (min at1 at2))] --> [], [] | ||
|
|
||
| | MemoryInit (x, y) -> | ||
| let MemoryT (at, _lib) = memory c x in | ||
| let MemoryT (at, _pt, _lib) = memory c x in | ||
| let () = data c y in | ||
| [NumT (numtype_of_addrtype at); NumT I32T; NumT I32T] --> [], [] | ||
|
|
||
|
|
@@ -1071,7 +1075,7 @@ let check_datamode (c : context) (mode : segmentmode) = | |
| match mode.it with | ||
| | Passive -> () | ||
| | Active (x, offset) -> | ||
| let MemoryT (at, _) = memory c x in | ||
| let MemoryT (at, _, _) = memory c x in | ||
| check_const c offset (NumT (numtype_of_addrtype at)) | ||
| | Declarative -> assert false | ||
|
|
||
|
|
||
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.
Nit:
check_pagetype, since that's what you named the thing.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.
Done.