Closed
Bug 661927
Opened 13 years ago
Closed 13 years ago
API to force a precise GC (return to event loop, GC with no JS stack, then call a callback)
Categories
(Core :: XPConnect, enhancement)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
mozilla7
People
(Reporter: jruderman, Assigned: jdm)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, Whiteboard: [sg:want])
Attachments
(1 file, 4 obsolete files)
For quitWithLeakCheck (and perhaps other automated tests), I'd like to have a way to cause a GC to happen with no JS on the stack, so I don't have to worry about conservative GC false positives.
Reporter | ||
Updated•13 years ago
|
Whiteboard: [sg:want]
Do we want to run other things on the event loop here, or do we want to just remove what's entrained on the stack from consideration?
Assignee | ||
Comment 2•13 years ago
|
||
Hmm, is the idea that you would just dispatch a runnable that would check if there's JS on the stack and redispatch itself if it couldn't gc yet?
Comment 3•13 years ago
|
||
I'd think that the function would take a JS function as an argument. When run, it would blow away the JS stack, and invoke the function argument, which is being used as a continuation. A JS-exec, if you prefer.
Reporter | ||
Comment 4•13 years ago
|
||
Comment 2 sounds right, given the possibility of nested event loops.
No synchronously "blowing away the stack", please :)
I would think for fuzzing that you'd want to be able to make GC happen "right now", or as close to right now as is possible. That would mean that you wouldn't want to run extra things off the event loop, which comment 2 would do ...
Comment 7•13 years ago
|
||
Clearly Javascript needs a general call-cc mechanism.
Reporter | ||
Comment 8•13 years ago
|
||
I can already make GC happen "right now", and I use that for fuzzing. What I'm asking for here would be used for precise leak checks at the end of fuzzing, so it's ok if it's stuck on the end of the event queue.
Assignee | ||
Comment 9•13 years ago
|
||
Attachment #541852 -
Flags: review?(mrbkap)
Assignee | ||
Updated•13 years ago
|
Attachment #541852 -
Attachment is obsolete: true
Attachment #541852 -
Flags: review?(mrbkap)
Assignee | ||
Comment 10•13 years ago
|
||
Attachment #541856 -
Flags: review?(mrbkap)
Comment 11•13 years ago
|
||
How does the patch guarantee that there is no JS running?
Assignee | ||
Comment 12•13 years ago
|
||
I assumed that simply checking JS_IsRunning on the desired context would be enough. Should I instead acquire the xpconnect JS runtime, then iterate over all its contexts and do the same check?
Comment 13•13 years ago
|
||
My mistake. I missed the JS_IsRunning in the ::Run().
(I don't know what JS_IsRunning does)
Another question, couldn't you have some idl interface to implement the callback?
Assignee | ||
Comment 14•13 years ago
|
||
I could. I don't really see why that's desirable, however.
Comment 15•13 years ago
|
||
That way the callback would automatically support both function() {} and
{ foo: function() {} }. And using JS API is quite error prone.
Comment 16•13 years ago
|
||
Comment on attachment 541856 [details] [diff] [review]
Add Cu.schedulePreciseGC to allow for a GC to run with no JS code running.
I think I agree with smaug here. If you take an XPCOM interface, you won't have to deal with rooting or context pushing or anything else like that. I'm not sure if the JS_IsRunning check is sufficient. It's possible that other JS code could be running on a different context. On the other hand, I'm not sure if we have an easy way of finding that out...
Attachment #541856 -
Flags: review?(mrbkap)
Assignee | ||
Comment 17•13 years ago
|
||
> I'm not sure if the JS_IsRunning check is sufficient. It's possible that other
> JS code could be running on a different context. On the other hand, I'm not
> sure if we have an easy way of finding that out...
It's possible to grab the runtime service, get the JSRuntime and then use a context iterator to check every context therein. Would that be more suitable?
Assignee | ||
Comment 18•13 years ago
|
||
Attachment #542941 -
Flags: review?(mrbkap)
Assignee | ||
Updated•13 years ago
|
Attachment #541856 -
Attachment is obsolete: true
Comment 19•13 years ago
|
||
Comment on attachment 542941 [details] [diff] [review]
Add Cu.schedulePreciseGC to allow for a GC to run with no JS code running.
Yeah, this is much cleaner.
One nit: your test addition to the makefile should use tabs instead of spaces for spacing. r=mrbkap with that.
Attachment #542941 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 20•13 years ago
|
||
Whiteboard: [sg:want] → [sg:want] [inbound]
Assignee | ||
Comment 21•13 years ago
|
||
Backed out in http://hg.mozilla.org/integration/mozilla-inbound/rev/5773d613df94 due to persistent windows build failures.
xpccomponents.obj : error LNK2019: unresolved external symbol "struct JSContext * __cdecl js_ContextIterator(struct JSRuntime *,int,struct JSContext * *)" (?js_ContextIterator@@YAPAUJSContext@@PAUJSRuntime@@HPAPAU1@@Z) referenced in function "public: virtual unsigned int __stdcall PreciseGCRunnable::Run(void)" (?Run@PreciseGCRunnable@@UAGIXZ)
NEXT ERROR xul.dll : fatal error LNK1120: 1 unresolved externals
Whiteboard: [sg:want] [inbound] → [sg:want]
Assignee | ||
Comment 22•13 years ago
|
||
Third time's the charm.
Attachment #543136 -
Flags: review?(mrbkap)
Assignee | ||
Updated•13 years ago
|
Attachment #542941 -
Attachment is obsolete: true
Comment 23•13 years ago
|
||
Comment on attachment 543136 [details] [diff] [review]
Add Cu.schedulePreciseGC to allow for a GC to run with no JS code running.
You don't want the request around the JS_GC call. Otherwise, we'll still scan the stack. Other than that, this looks good.
Attachment #543136 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 24•13 years ago
|
||
Patch for landing.
Assignee | ||
Updated•13 years ago
|
Attachment #543136 -
Attachment is obsolete: true
Assignee | ||
Updated•13 years ago
|
Keywords: checkin-needed
Comment 25•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Keywords: checkin-needed → dev-doc-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla7
Updated•13 years ago
|
Component: DOM → XPConnect
QA Contact: general → xpconnect
Reporter | ||
Updated•13 years ago
|
Blocks: LifetimeTesting
Comment 26•13 years ago
|
||
Documentation added:
https://developer.mozilla.org/en/Components.utils.schedulePreciseGC
Documentation updated:
https://developer.mozilla.org/en/Components.utils.forceGC
https://developer.mozilla.org/en/Components.utils
https://developer.mozilla.org/en/Components_object
Firefox 7 for developers has also been updated.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•