This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Simplify HostThreadMacOSX
ClosedPublic

Authored by labath on Feb 22 2022, 6:32 AM.

Details

Summary

The class is using an incredibly elaborate setup to create and destroy
an NSAutoreleasePool object. We can do it in a much simpler way by
making those calls inside our thread startup function.

The only effect of this patch is that the pool gets released at the end
of the ThreadCreateTrampoline function, instead of slightly later, when
pthreads begin thread-specific cleanup. However, the key destruction
order is unspecified, so nothing should be relying on that.

I didn't find a specific reason for why this would have to be done that
way in git history. It seems that before D5198, this was thread-specific
keys were the only way an os implementation (in Host::ThreadCreated)
could attach some value to a thread.

Diff Detail

Event Timeline

labath requested review of this revision.Feb 22 2022, 6:32 AM
labath created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2022, 6:32 AM
JDevlieghere added inline comments.Feb 22 2022, 1:22 PM
lldb/source/Host/macosx/objcxx/HostThreadMacOSX.mm
19–20

I believe it's recommended to use an @autoreleasepool block instead of using the NSAutoreleasePool directly.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 23 2022, 5:26 AM
This revision was automatically updated to reflect the committed changes.