[libcxxabi] Re-organized inheritance structure to remove CRTP in cxa_guard
Currently, the `InitByte...` classes inherit from `GuardObject` so they can access the `base_address`, `init_byte_address` and `thread_id_address`. Then, since `GuardObject` needs to call `acquire`/`release`/`abort_init_byte`, it uses the curiously recurring template pattern (CRTP). This is rather messy. Instead, we'll have `GuardObject` contain an instance of `InitByte`, and pass it the addresses it needs in the constructor. `GuardObject` doesn't need the addresses anyways, so it makes more sense for `InitByte` to keep them instead of `GuardObject`. Then, `GuardObject` can call `acquire`/`release`/`abort` as one of `InitByte`'s member functions. Organizing things this way not only gets rid of the use of the CRTP, but also improves separation of concerns a bit since the `InitByte` classes are no longer indirectly responsible for things because of their inheritance from `GuardObject`. This means we no longer have strange things like calling `InitByteFutex.cxa_guard_acquire`, instead we call `GuardObject<InitByteFutex>.cxa_guard_acquire`. This is the 4th of 5 changes to overhaul cxa_guard. See D108343 for what the final result will be. Depends on D115367 Reviewed By: ldionne, #libc_abi Differential Revision: https://reviews.llvm.org/D115368
Loading
Please sign in to comment