Closed Bug 1458878 Opened 7 years ago Closed 7 years ago

Assert no GC in IterateScriptCallback

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla62
Tracking Status
firefox61 --- wontfix
firefox62 --- fixed

People

(Reporter: arai, Assigned: arai)

Details

Attachments

(1 file)

IterateScriptCallback is the type of the callback function called by IterateScripts: https://searchfox.org/mozilla-central/rev/ce9ff94ffed34dc17ec0bfa406156d489eaa8ee1/js/src/gc/PublicIterators.cpp#82-102 > void > js::IterateScripts(JSContext* cx, JSCompartment* compartment, > void* data, IterateScriptCallback scriptCallback) > { > ... > scriptCallback(cx->runtime(), data, script); > ... > scriptCallback(cx->runtime(), data, script); IterateScripts is called only from the Debugger, the following line: https://searchfox.org/mozilla-central/rev/ce9ff94ffed34dc17ec0bfa406156d489eaa8ee1/js/src/vm/Debugger.cpp#4416 > class MOZ_STACK_CLASS Debugger::ScriptQuery > { > ... > bool findScripts() { > ... > IterateScripts(cx, singletonComp, this, considerScript); and Debugger::ScriptQuery::considerScript calls Debugger::ScriptQuery::consider, which doesn't GC. https://searchfox.org/mozilla-central/rev/ce9ff94ffed34dc17ec0bfa406156d489eaa8ee1/js/src/vm/Debugger.cpp#4592-4682 > static void considerScript(JSRuntime* rt, void* data, JSScript* script) { > ScriptQuery* self = static_cast<ScriptQuery*>(data); > self->consider(script); > } > > /* > * If |script| matches this query, append it to |vector| or place it in > * |innermostForCompartment|, as appropriate. Set |oom| if an out of memory > * condition occurred. > */ > void consider(JSScript* script) { > ... > } We can assert that IterateScriptCallback doesn't GC, so that we can keep unrooted GCThing across IterateScripts call, which I'm about to do in bug 1434305.
(In reply to Tooru Fujisawa [:arai] from comment #0) > We can assert that IterateScriptCallback doesn't GC, so that we can keep > unrooted GCThing across IterateScripts call this turns out to be false, since those 2 lines can GC... https://searchfox.org/mozilla-central/rev/ce9ff94ffed34dc17ec0bfa406156d489eaa8ee1/js/src/gc/PublicIterators.cpp#87-88 > void > js::IterateScripts(JSContext* cx, JSCompartment* compartment, > void* data, IterateScriptCallback scriptCallback) > { > ... > AutoEmptyNursery empty(cx); > AutoPrepareForTracing prep(cx);
No longer blocks: 1434305
Priority: -- → P3
* Added AutoSuppressGCAnalysis to IterateScripts, after AutoEmptyNursery and AutoPrepareForTracing which will GC * Added AutoRequireNoGC to IterateScriptCallback
Attachment #8974598 - Flags: review?(jcoppeard)
Comment on attachment 8974598 [details] [diff] [review] Assert no GC in IterateScriptCallback. Review of attachment 8974598 [details] [diff] [review]: ----------------------------------------------------------------- Great, thanks.
Attachment #8974598 - Flags: review?(jcoppeard) → review+
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: