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
Put ThreadGlobalData in Thread #521
Put ThreadGlobalData in Thread #521
Conversation
EWS failures look real:
|
Yup, this looks like a real issue. |
Interesting, we are still having some crashes, looking. |
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.
Might be even better to not have to dereference a second pointer at all, and store all this inside the Thread
object, allocated with an appropriate size.
I’m not sure the reference counting is needed here. This is a nice improvement.
Source/WTF/wtf/Threading.h
Outdated
@@ -109,6 +109,11 @@ class WTF_CAPABILITY("is current") Thread : public ThreadSafeRefCounted<Thread> | |||
friend class ThreadGroup; | |||
friend WTF_EXPORT_PRIVATE void initialize(); | |||
|
|||
class ApplicationData : public ThreadSafeRefCounted<ApplicationData> { |
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.
I don’t think application is a great term to use here. I understand we need some abstract way to refer to WebCore
from JavaScriptCore
, but application has a pretty specific meaning as a term of art on platforms like iOS, and WebCore
is not one of those things.
Why does this need to be reference counted? What is the second owner besides the Thread
?
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.
How about ClientData?
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.
ClientData
sounds good.
Why does this need to be reference counted? What is the second owner besides the Thread?
Because WebThread is sharing it with the main thread. So, in iOS, WebKitLegacy, it is shared by multiple threads (WebThread and OS main thread).
if (LIKELY(applicationData)) | ||
return *static_cast<ThreadGlobalData*>(applicationData); | ||
|
||
auto data = adoptRef(*new ThreadGlobalData()); |
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.
No need to add the ()
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.
Dropped.
if (LIKELY(applicationData)) | ||
return *static_cast<ThreadGlobalData*>(applicationData); | ||
|
||
auto data = adoptRef(*new ThreadGlobalData()); |
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.
No need to add the ()
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.
Nice, dropped.
Source/WTF/wtf/Threading.h
Outdated
@@ -109,6 +109,11 @@ class WTF_CAPABILITY("is current") Thread : public ThreadSafeRefCounted<Thread> | |||
friend class ThreadGroup; | |||
friend WTF_EXPORT_PRIVATE void initialize(); | |||
|
|||
class ApplicationData : public ThreadSafeRefCounted<ApplicationData> { |
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.
How about ClientData?
@@ -76,42 +63,42 @@ void ThreadGlobalData::setWebCoreThreadData() | |||
ASSERT(&threadGlobalData() != sharedMainThreadStaticData); | |||
|
|||
// Set WebThread's ThreadGlobalData object to be the same as the main UI thread. | |||
**staticData = adoptRef(sharedMainThreadStaticData); | |||
Thread::current().m_applicationData = adoptRef(sharedMainThreadStaticData); |
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(&threadGlobalData() != sharedMainThreadStaticData);
implies that Thread::current().m_applicationData
should already be pointing to sharedMainThreadStaticData
. Do we still need this ThreadGlobalData::setWebCoreThreadData
function?
Maybe remove this assignment, and rename this function to assertWebCoreThreadData()
instead?
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.
Ah, no. ASSERT(&threadGlobalData() != sharedMainThreadStaticData);
means that Thread::current().m_applicationData
is not pointing to sharedMainThreadStaticData
.
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.
Thanks!
if (LIKELY(applicationData)) | ||
return *static_cast<ThreadGlobalData*>(applicationData); | ||
|
||
auto data = adoptRef(*new ThreadGlobalData()); |
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.
Nice, dropped.
@@ -76,42 +63,42 @@ void ThreadGlobalData::setWebCoreThreadData() | |||
ASSERT(&threadGlobalData() != sharedMainThreadStaticData); | |||
|
|||
// Set WebThread's ThreadGlobalData object to be the same as the main UI thread. | |||
**staticData = adoptRef(sharedMainThreadStaticData); | |||
Thread::current().m_applicationData = adoptRef(sharedMainThreadStaticData); |
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.
Ah, no. ASSERT(&threadGlobalData() != sharedMainThreadStaticData);
means that Thread::current().m_applicationData
is not pointing to sharedMainThreadStaticData
.
if (LIKELY(applicationData)) | ||
return *static_cast<ThreadGlobalData*>(applicationData); | ||
|
||
auto data = adoptRef(*new ThreadGlobalData()); |
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.
Dropped.
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.
TESTING (Oops, I pushed while testing some GitHub UI).
Commit message contains (OOPS!), blocking PR #521 |
587be86
to
04f2a2b
Compare
Committed r294213 (250571@main): https://commits.webkit.org/250571@main Reviewed commits have been landed. Closing PR #521 and removing active labels. |
04f2a2b