-
Notifications
You must be signed in to change notification settings - Fork 52
Make non-natural alignment a validation error in spec interpreter / test #242
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
Open
stevenfontanella
wants to merge
2
commits into
WebAssembly:main
Choose a base branch
from
stevenfontanella:alignment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+430
−20
Open
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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -189,7 +189,7 @@ let check_vec_binop binop at = | |||||||||||||||||||||||||
| error at "invalid lane index" | ||||||||||||||||||||||||||
| | _ -> () | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at = | ||||||||||||||||||||||||||
| let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at ~(isAtomic : bool) = | ||||||||||||||||||||||||||
| let _mt = memory c (0l @@ at) in | ||||||||||||||||||||||||||
| let size = | ||||||||||||||||||||||||||
| match get_sz memop.pack with | ||||||||||||||||||||||||||
|
|
@@ -199,7 +199,9 @@ let check_memop (c : context) (memop : ('t, 's) memop) ty_size get_sz at = | |||||||||||||||||||||||||
| packed_size sz | ||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||
| require (1 lsl memop.align <= size) at | ||||||||||||||||||||||||||
| "alignment must not be larger than natural" | ||||||||||||||||||||||||||
| "alignment must not be larger than natural"; | ||||||||||||||||||||||||||
| if isAtomic then | ||||||||||||||||||||||||||
| require (1 lsl memop.align == size) at "atomic memory instruction's alignment must equal the instruction's natural alignment" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
201
to
205
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. Only one of the two conditions needs to apply.
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| (* | ||||||||||||||||||||||||||
|
|
@@ -354,29 +356,29 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type | |||||||||||||||||||||||||
| [] --> [] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | Load memop -> | ||||||||||||||||||||||||||
| check_memop c memop num_size (Lib.Option.map fst) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop num_size (Lib.Option.map fst) e.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.
Suggested change
...and so on. |
||||||||||||||||||||||||||
| [NumType I32Type] --> [NumType memop.ty] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | Store memop -> | ||||||||||||||||||||||||||
| check_memop c memop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType memop.ty] --> [] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | VecLoad memop -> | ||||||||||||||||||||||||||
| check_memop c memop vec_size (Lib.Option.map fst) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop vec_size (Lib.Option.map fst) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type] --> [VecType memop.ty] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | VecStore memop -> | ||||||||||||||||||||||||||
| check_memop c memop vec_size (fun _ -> None) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop vec_size (fun _ -> None) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; VecType memop.ty] --> [] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | VecLoadLane (memop, i) -> | ||||||||||||||||||||||||||
| check_memop c memop vec_size (fun sz -> Some sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop vec_size (fun sz -> Some sz) e.at; | ||||||||||||||||||||||||||
| require (i < vec_size memop.ty / packed_size memop.pack) e.at | ||||||||||||||||||||||||||
| "invalid lane index"; | ||||||||||||||||||||||||||
| [NumType I32Type; VecType memop.ty] --> [VecType memop.ty] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| | VecStoreLane (memop, i) -> | ||||||||||||||||||||||||||
| check_memop c memop vec_size (fun sz -> Some sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:false c memop vec_size (fun sz -> Some sz) e.at; | ||||||||||||||||||||||||||
| require (i < vec_size memop.ty / packed_size memop.pack) e.at | ||||||||||||||||||||||||||
| "invalid lane index"; | ||||||||||||||||||||||||||
| [NumType I32Type; VecType memop.ty] --> [] | ||||||||||||||||||||||||||
|
|
@@ -514,23 +516,23 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type | |||||||||||||||||||||||||
| "invalid lane index"; | ||||||||||||||||||||||||||
| [t; NumType t2] --> [t] | ||||||||||||||||||||||||||
| | MemoryAtomicWait atomicop -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType atomicop.ty; NumType I64Type] --> [NumType I32Type] | ||||||||||||||||||||||||||
| | MemoryAtomicNotify atomicop -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType I32Type] --> [NumType I32Type] | ||||||||||||||||||||||||||
| | AtomicFence -> [] --> [] | ||||||||||||||||||||||||||
| | AtomicLoad atomicop -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type] --> [NumType atomicop.ty] | ||||||||||||||||||||||||||
| | AtomicStore atomicop -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType atomicop.ty] --> [] | ||||||||||||||||||||||||||
| | AtomicRmw (rmwop, atomicop) -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic:true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType atomicop.ty] --> [NumType atomicop.ty] | ||||||||||||||||||||||||||
| | AtomicRmwCmpXchg atomicop -> | ||||||||||||||||||||||||||
| check_memop c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| check_memop ~isAtomic: true c atomicop num_size (fun sz -> sz) e.at; | ||||||||||||||||||||||||||
| [NumType I32Type; NumType atomicop.ty; NumType atomicop.ty] --> [NumType atomicop.ty] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| and check_seq (c : context) (s : infer_result_type) (es : instr list) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Labelled arguments are a somewhat controversial language feature, let's avoid them if we can. I suggest: