Closed Bug 911182 Opened 11 years ago Closed 11 years ago

add test that incremental GC is enabled

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla27

People

(Reporter: luke, Assigned: billm)

Details

Attachments

(1 file, 1 obsolete file)

Bug 910777 is an example of how it is easy to forget to add JSCLASS_IMPLEMENTS_BARRIERS and turn off incremental GC for the whole browser.  Seems like we should add a test for this.

Side question: it seems like generational GC would have the same issue that JSCLASS_IMPLEMENTS_BARRIERS is trying to solve (i.e., binary extensions adding a js::Class that don't implement barriers will cause corruption).  Does the lack of JSCLASS_IMPLEMENTS_BARRIERS also disable ggc?  Seems like, because of moving, the problem is much worse and JSCLASS_IMPLEMENTS_BARRIERS won't help much.
It looks like the BARRIERS kill switch is the only way to disable the |rt->gcIncrementalEnabled| flag, outside of an API function that is never called, so maybe we could just assert on runtime shutdown that the flag is true?  A more precise approach would add a new flag to track when the flag is forcibly disabled, and then assert on that.

I guess you also want to only assert when |rt->gcMode == JSGC_MODE_INCREMENTAL| or something, because you don't care if the kill switch has been tripped in runtimes, like workers, that aren't using IGC anyways.
(In reply to Luke Wagner [:luke] from comment #0)
> Side question: it seems like generational GC would have the same issue that
> JSCLASS_IMPLEMENTS_BARRIERS is trying to solve (i.e., binary extensions
> adding a js::Class that don't implement barriers will cause corruption). 
> Does the lack of JSCLASS_IMPLEMENTS_BARRIERS also disable ggc?  Seems like,
> because of moving, the problem is much worse and JSCLASS_IMPLEMENTS_BARRIERS
> won't help much.

Good point! My understanding is that binary extensions need to be rebuilt against each version of the browser, so should bump into our handlified and typesafe marking APIs. Of course, we do still have a ways to go there for complete coverage, so that isn't a total panacea.

Disabling GGC for non-IMPLEMENTS_BARRIERS classes, at least for the near term, is an excellent idea to make porting easier when we flip the switch.
Would our reasoning about how the typesafe markers should catch GGC binary extension hazards extend to IGC such that we could remove JSCLASS_IMPLEMENTS_BARRIERS?
Yes, I believe so. Currently the JS::Heap<T> type that these markers take only do post-barriering. We will be expanding this to do pre-barriers as well when we incrementalize browser marking. Once this is done, it should be relatively hard to have a live gcthing pointer on the heap that is not wrapped in an automatically barriered type, at least outside SpiderMonkey.
Great.  Do we have typesafe marking now or is that coming soon?
Attached patch test-inc-gc (obsolete) — Splinter Review
Bobby, I'm sticking this in xpconnect for lack of a better place. Is that okay?
Assignee: general → wmccloskey
Status: NEW → ASSIGNED
Attachment #797945 - Flags: review?(bobbyholley+bmo)
Won't this fail to catch the case where we run this test before we an instance of the class with the bad custom trace hook?
"before we an" --> "before we trace an"
Comment on attachment 797945 [details] [diff] [review]
test-inc-gc

Review of attachment 797945 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/xpconnect/tests/chrome/test_incremental_gc.xul
@@ +20,5 @@
> +  <script type="application/javascript"><![CDATA[
> +     const Ci = Components.interfaces;
> +     Components.utils.import("resource://gre/modules/Services.jsm");
> +     let winEnumer = Services.ww.getWindowEnumerator();
> +     let enabled = winEnumer.getNext()

As noted on IRC, please dump the ww junk and just use |window| here.
Attachment #797945 - Flags: review?(bobbyholley+bmo) → review+
(In reply to Luke Wagner [:luke] from comment #5)
> Great.  Do we have typesafe marking now or is that coming soon?

The new interface are the JS_CallHeapFooTracer functions starting here:
http://dxr.allizom.org/mozilla-central/source/js/src/jsapi.h#l2128

The old JS_CallFooTracer functions are still present (just above) at the moment. Our intent is to remove these as we can and when they are all gone, do a bulk rename to remove "Heap" and use the old names with new types.

The other part, of course, is full handlification of the API. This should be quite easy now, just extremely boring and time-consuming.
(In reply to Andrew McCreight [:mccr8] from comment #7)
> Won't this fail to catch the case where we run this test before we an
> instance of the class with the bad custom trace hook?

Sorry, I didn't see comment 1 before. That does sound like a better way to do it. I'll try to put something together for that.
Attached patch test-inc-gcSplinter Review
This is a more direct approach of the sort that Andrew proposed.
Attachment #797945 - Attachment is obsolete: true
Attachment #801867 - Flags: review?(luke)
Ah, good point, failing immediately is much more useful than waiting until shutdown. :)
Comment on attachment 801867 [details] [diff] [review]
test-inc-gc

Nice, thanks!
Attachment #801867 - Flags: review?(luke) → review+
https://hg.mozilla.org/mozilla-central/rev/cf1653866a2e
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: