Closed Bug 1372207 Opened 8 years ago Closed 8 years ago

JS bytecode cache should use Idle callback to trigger the encoding.

Categories

(Core :: DOM: Core & HTML, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: nbp, Assigned: nbp)

References

Details

Attachments

(1 file, 1 obsolete file)

At the moment, the JSBC uses the next cycle after the load-end event and the last script tag to be executed (in case the load event were to inject a new script tag). Instead of using the next cycle after the load-end event, we should use the next idle-time after the load-end event, such that we any code which is spinning the event loop after the load end can still be captured by the bytecode cache encoding.
This replaces the NS_DispatchToCurrentThread by the document event target for the idle callback. This code seems to be the first code to ever use the TaskCategory::IdleCallback, is that the proper category that I should be using for this task?
Attachment #8876711 - Flags: review?(wmccloskey)
TaskCategory::IdleCallback doesn't mean anything yet. (It is very confusing to have it. ) We need to change idle dispatch to use all this TaskCategory stuff. Also, should we ensure EncodeBytecode is called eventually? If so, http://searchfox.org/mozilla-central/rev/d840ebd5858a61dbc1622487c1fab74ecf235e03/xpcom/threads/nsThreadUtils.cpp#368 is probably the right method to use. (You may want to ask farre too)
(In reply to Olli Pettay [:smaug] from comment #2) > Also, should we ensure EncodeBytecode is called eventually? We do not have to, as the code could be clean-up by the destructor of the ScriptLoader, but the NewRunnableMethod has an Owning reference to the ScriptLoader, so in the current implementation we would have to ensure that it is called such that we can later remove the ScriptLoader instance. > If so, > http://searchfox.org/mozilla-central/rev/ > d840ebd5858a61dbc1622487c1fab74ecf235e03/xpcom/threads/nsThreadUtils.cpp#368 > is probably the right method to use. Ok, I will use that instead.
Attachment #8876711 - Flags: review?(wmccloskey)
Use NS_IdleDispatchToCurrentThread instead of NS_DispatchToCurrentThread.
Attachment #8876711 - Attachment is obsolete: true
Attachment #8877123 - Flags: review?(bugs)
Comment on attachment 8877123 [details] [diff] [review] Schedule JSBC encoding to be executed at the next idle time after the onload event. This makes it more likely that EncodeBytecode never runs during the lifetime of document, but I guess that is fine, since that has been possible before too, in case document lifetime is short.
Attachment #8877123 - Flags: review?(bugs) → review+
Pushed by npierron@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/fccb81aa0a57 Schedule JSBC encoding to be executed at the next idle time after the onload event. r=smaug
Component: JavaScript Engine → DOM
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: