Conversation
There was a problem hiding this comment.
Pull request overview
This pull request modifies alignment checks in the reference counting garbage collector (refc) for Nim. The changes split the alignment assertions in rawNewObj and newObjRC1 into two branches based on whether custom alignment exceeds the default memory alignment.
Changes:
- Modified alignment assertions in
rawNewObjto check Cell pointer alignment when alignment equals MemAlign, instead of always checking user data alignment - Applied the same change to
newObjRC1for consistency
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ringabout please explain your reasoning behind this change. |
|
In my old PR, when e.g. on i386, type
MyType16 = object
a {.align(16).}: intMoreover, we perhaps need to take into consideration the case where the custom alignment is equal to the |
|
Well but if I want 16 byte alignment I should be able to get it, even on a 32bit machine. |
|
Yeah, I will enforce alignment allocation for all the custom alignment soon, though I need to examine the ramification more. This PR should fix the cases that does not need aligned allocation gcAssert((cast[int](cellToUsr(res)) and (alignment-1)) == 0, "newObj: 2")This is wrong for allocation doesn't need alignment, because only if alignment > MemAlign:
gcAssert((cast[int](cellToUsr(res)) and (alignment-1)) == 0, "newObj: 2.1")
else:
gcAssert((cast[int](res) and (MemAlign-1)) == 0, "newObj: 2.2")In this PR, I add the else branch to cover unaligned allocation |
No description provided.