-
Notifications
You must be signed in to change notification settings - Fork 320
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
fix: let cppgc align to 16 bytes #1677
Conversation
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.
LGTM
@@ -343,6 +344,11 @@ pub unsafe fn make_garbage_collected<T: GarbageCollected + 'static>( | |||
heap: &Heap, | |||
obj: T, | |||
) -> Ptr<T> { | |||
const { | |||
// max alignment in cppgc is 16 | |||
assert!(std::mem::align_of::<T>() <= 16); |
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.
assert!(std::mem::align_of::<T>() <= 16); | |
assert!(std::mem::align_of::<T>() <= 16, "cppgc objects have a max alignment of 16"); |
) | ||
}; | ||
|
||
assert!(!pointer.is_null()); |
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.
assert!(!pointer.is_null()); | |
// Sanity check: this is already checked by the const assertion above. | |
debug_assert!(!pointer.is_null()); |
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.
LGTM, needs to be clang-format
ted
4bb46e1
to
0e02f31
Compare
cppgc supports exactly two alignments: 8 byte and 16 byte. We can support this by dispatching to a different base C++ class.
Fixes: #1676