-
Notifications
You must be signed in to change notification settings - Fork 1.2k
swb: annotate BaseDictionary entry items #1819
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
Conversation
BaseDictionary Key or Value can be of GC pointer type, potentially needs write barrier on each entry item. Use macro and template type traits to replace underlying entry Key/Value type with WriteBarrierPtr when Key or Value is pointer type and used with recycler allocators. BaseDictionary methods still use original Key/Value types. Only the underlying EntryType may contain swapped type. Most methods are not affected. However, when WriteBarrierPtr is used, only immutable TryGetReference should be used. (We cannot get a mutable reference and possibly change the pointer underneath WriteBarrierPtr.) Allow WriteBarrierPtr to take immutable address to support TryGetReference (used a lot). Fixed a bunch of incorrect `const` usage.
|
@dotnet-bot test Linux tests please |
|
@leirocks @digitalinfinity @curtisman Please help CR, thanks! |
Apply template traits to field types to simplify write barrier field annotations. Now most annotations are Field or FieldNoBarrier (for pointers known not needing write barrier). Replaced `WB_ITEM_TYPE` with `Field`.
| return &ptr; | ||
| } | ||
| T** operator&() | ||
| // Taking immutable address is ok |
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.
Taking immutable address is ok [](start = 7, length = 30)
we might need const_cast check in our tool? if so please add a TODO here
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.
Talked offline. @leirocks's idea is to examine and baseline our usage of const_cast to prevent future incorrect use related to this code. That is doable. Will add a note here.
|
|
|
Thanks @leirocks ! |
Merge pull request #1819 from jianchun:wbdict BaseDictionary Key or Value can be of GC pointer type, potentially needs write barrier on each entry item. Use macro and template type traits to replace underlying entry Key/Value type with WriteBarrierPtr when Key or Value is pointer type and used with recycler allocators. BaseDictionary methods still use original Key/Value types. Only the underlying EntryType may contain swapped type. Most methods are not affected. However, when WriteBarrierPtr is used, only immutable TryGetReference should be used. (We cannot get a mutable reference and possibly change the pointer underneath WriteBarrierPtr.) Allow WriteBarrierPtr to take immutable address to support TryGetReference (used a lot). Fixed a bunch of incorrect `const` usage. Update: Apply template traits to field types to simplify write barrier field annotations. Now most annotations are Field or FieldNoBarrier (for pointers known not needing write barrier).
BaseDictionary Key or Value can be of GC pointer type, potentially needs
write barrier on each entry item.
Use macro and template type traits to replace underlying entry Key/Value
type with WriteBarrierPtr when Key or Value is pointer type and used with
recycler allocators.
BaseDictionary methods still use original Key/Value types. Only the
underlying EntryType may contain swapped type. Most methods are not
affected. However, when WriteBarrierPtr is used, only immutable
TryGetReference should be used. (We cannot get a mutable reference and
possibly change the pointer underneath WriteBarrierPtr.)
Allow WriteBarrierPtr to take immutable address to support TryGetReference
(used a lot). Fixed a bunch of incorrect
constusage.Update: Apply template traits to field types to simplify write barrier field
annotations. Now most annotations are Field or FieldNoBarrier (for pointers
known not needing write barrier).