-
Notifications
You must be signed in to change notification settings - Fork 34
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
Validate i32/i64.load/store alignment #310
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
#pragma once | ||
|
||
#include <cassert> | ||
#include <cstdint> | ||
|
||
namespace fizzy | ||
|
@@ -16,6 +17,24 @@ struct InstructionMetrics | |
/// The stack height change caused by the instruction execution, | ||
/// i.e. stack height _after_ execution - stack height _before_ execution. | ||
int8_t stack_height_change; | ||
|
||
/// The largest acceptable alignment value satisfying `2 ** max_align < memory_width` where | ||
/// memory_width is the number of bytes the instruction operates on. | ||
/// | ||
/// This field may contain invalid value for instructions not needing it. | ||
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. It's default-initialized to 0, I wouldn't call it invalid 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. 0 is invalid on non-memory ops, because the change preferred by @chfast makes 0 a valid value (1<<0 = 1). 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. 0 is valid value for memory instructions, and nonrelevant for non-memory instructions. To me it never contains "invalid value" like garbage. 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. It does contain invalid value for non-memory ops. |
||
uint8_t max_align; | ||
|
||
InstructionMetrics() = default; | ||
|
||
constexpr InstructionMetrics( | ||
int8_t _stack_height_required, int8_t _stack_height_change, uint8_t _max_align = 0) noexcept | ||
: stack_height_required(_stack_height_required), | ||
stack_height_change(_stack_height_change), | ||
max_align(_max_align) | ||
{ | ||
// The valid range is between 0 and 3. | ||
assert(max_align <= 3); | ||
} | ||
}; | ||
|
||
const InstructionMetrics* get_instruction_metrics_table() noexcept; | ||
|
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.
Hmm.
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.
This is due to another shortcoming in the spectest, will submit an issue.