Bug 67385

Summary: Don't use MainThread in JSC
Product: WebKit Reporter: Patrick R. Gansterer <paroga>
Component: Web Template FrameworkAssignee: Patrick R. Gansterer <paroga>
Status: NEW    
Severity: Normal CC: abarth, ap, barraclough, darin, levin, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch eric: review-

Patrick R. Gansterer
Reported 2011-09-01 03:48:58 PDT
Don't use MainThread in JSC
Attachments
Patch (1.53 KB, patch)
2011-09-01 03:53 PDT, Patrick R. Gansterer
eric: review-
Patrick R. Gansterer
Comment 1 2011-09-01 03:53:39 PDT
Darin Adler
Comment 2 2011-09-01 09:53:18 PDT
Gavin, do you think this change is OK?
Alexey Proskuryakov
Comment 3 2011-09-01 10:16:09 PDT
+ JSC has no concept of a MainThread. This is incorrect. JavaScriptCore must be initialized from the main thread before use, see comments in JavaScriptCore/runtime/InitializeThreading.h. What seems wrong here is that WTF exposes a separate initializeMainThread() function in addition to initializeThreading(), which also must be called from main thread.
Patrick R. Gansterer
Comment 4 2011-09-01 12:03:27 PDT
(In reply to comment #3) > + JSC has no concept of a MainThread. > > This is incorrect. JavaScriptCore must be initialized from the main thread before use, see comments in JavaScriptCore/runtime/InitializeThreading.h. Sure? AFAIK it is possible to run (and init) JSC from any thead when embedded into an other application. That's not necessary the MainThread. The only use of the MainThread is the assertion in the patch.
Alexey Proskuryakov
Comment 5 2011-09-01 12:17:10 PDT
There is certainly a comment in the header saying that it is a requirement, yes. Whether we should strive to lift that restriction is a separate question, and there are of course many things that could be improved regardless (like the mysterious separate initializeMainThread () call mentioned above). However, it won't be easy to move MainThread functionality from WTF to WebCore, because this will break nightly builds (Safari uses this functionality through WTF).
Patrick R. Gansterer
Comment 6 2011-09-01 12:38:16 PDT
(In reply to comment #5) > However, it won't be easy to move MainThread functionality from WTF to WebCore, because this will break nightly builds (Safari uses this functionality through WTF). Do you see any chance/way to move it to WebCore? On Linux the MainThread functionality isn't provided by the OS and needs an higher level library like Gtk/Qt/wx for this.
David Levin
Comment 7 2011-09-01 17:53:47 PDT
(In reply to comment #3) > + JSC has no concept of a MainThread. > > This is incorrect. JavaScriptCore must be initialized from the main thread before use, see comments in JavaScriptCore/runtime/InitializeThreading.h. > "This function must be called from the main thread. ... Darwin is an exception to this rule" -- http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/InitializeThreading.h I think this is because JavaScriptCore may be run from any thread. (I hit this issue before that the JavaScript API doesn't require is main thread to be set.) However, I don't think this bug/patch has made the case for why MainThread shouldn't be used anywhere in WTF or why it should be moved out of WTF (but I'll admit that it is a tricky area that I messed up before -- I used isMainThread in a place where I shouldn't have).
Eric Seidel (no email)
Comment 8 2012-02-16 14:36:55 PST
Comment on attachment 105936 [details] Patch My understanding is that you *must* initialize JSC (and all our various hashes) on the main thread. This patch looks wrong.
Note You need to log in before you can comment on or make changes to this bug.