-
Notifications
You must be signed in to change notification settings - Fork 381
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
enable optimizer in tests and procmacros #5155
base: master
Are you sure you want to change the base?
Changes from all commits
112b8f3
9531071
3a892cc
40a2be1
e0ba967
3627c25
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 |
---|---|---|
|
@@ -1277,13 +1277,6 @@ pub mod tests { | |
} | ||
} | ||
|
||
fn get_executable_byte(&self) -> u8 { | ||
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. This change seems unrelated to the unit tests speed up. 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. The only reason this change is happening is to make optimizations possible for unittests. For more substantial changes separate PRs have been made by teams handling respective pieces of the code. I'll be making some as well. 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. If this check is not really useful (as is claimed in the discussion) it can be done in a separate PR, as it has value by itself. For example, should you end up introducing a separate compilation profile for the CI, this PR will increase in size and will take some time to land. But this particular change might go in pretty quickly on its own. It is up to you, of course. I was just speaking from personal experience :) |
||
let executable_bool: bool = self.executable(); | ||
// UNSAFE: Force to interpret mmap-backed bool as u8 to really read the actual memory content | ||
let executable_byte: u8 = unsafe { std::mem::transmute::<bool, u8>(executable_bool) }; | ||
executable_byte | ||
} | ||
|
||
fn set_executable_as_byte(&self, new_executable_byte: u8) { | ||
// UNSAFE: Force to interpret mmap-backed &bool as &u8 to write some crafted value; | ||
unsafe { | ||
|
@@ -1830,7 +1823,6 @@ pub mod tests { | |
{ | ||
let executable_bool: bool = account.executable(); | ||
assert!(!executable_bool); | ||
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. Removed this assert as per advice from @roryharr 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. More Context: This assert was added a long time ago by ryoqun just to monitor some undefined behaviour. The executable bit is a boolean which uses a byte of storage. The only valid values for the byte are zero and one. This is verified during account load by the function sanitize_executable. This test corrupts the byte, and verifies that sanitize executable fails, which it does. Afterwards it has various asserts to see how it behaves in the event the sanitize check was not present. As per ryoquns comments these are purely for his interest. When compiling with optimizations on, the compiler behaviour changes when accessing the byte by value. 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. @ryoqun In case you are still interested |
||
assert_eq!(account.get_executable_byte(), 0); // Wow, not crafted_executable! | ||
} | ||
}) | ||
.unwrap(); | ||
|
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 function was only used in a test