The default bug view has changed. See this FAQ.

GC: Compartment creation during incremental GC shouldn't reset the GC

RESOLVED FIXED in mozilla14



JavaScript Engine
5 years ago
5 years ago


(Reporter: billm, Assigned: billm)



Firefox Tracking Flags

(Not tracked)



(1 attachment)



5 years ago
Right now, if a compartment is created during an incremental GC, we reset the current GC and finish with a non-incremental GC. This seems to happen pretty frequently during normal browsing.

In theory, we should be able to carry on with the GC as normal without touching the new compartment (i.e., don't mark it and don't collect any of its objects). In practice, this could be a little difficult since it will be hard to avoid marking into the new compartment. Bug 716142 may simplify the problem: maybe we could switch the GC to a multi-compartment GC of every compartment except the newly-created one.

Comment 1

5 years ago
Created attachment 612375 [details] [diff] [review]

Now that multi-compartment GC has landed, we can make headway on this. Unfortunately, the multi-compartment GC patch preserved a difference between "full" GCs and compartment GCs (even if the compartment GC collected every compartment). This patch removes that distinction.

The main changes in behavior from this patch are:

1. If a compartment is created during an incremental GC, we don't reset the GC or switch to non-incremental GC. In fact, we don't do anything. The new compartment won't be collected.

2. We now collect atoms only if every compartment that existed at the beginning of the GC is being collected.

3. Now any GC can delete a compartment if it has no live objects. Previously only "full" GCs could do this.

Note that most of the time we'll still collect all compartments. It's just that collecting all compartments is no longer a special case.
Attachment #612375 - Flags: review?(igor)

Comment 2

5 years ago
Comment on attachment 612375 [details] [diff] [review]

Review of attachment 612375 [details] [diff] [review]:

nice cleanup!

::: js/src/jsatom.cpp
@@ +241,5 @@
>      return true;
>  }
>  void
> +js::FinishCommonAtoms(JSContext *cx)

As you are changing this, replace the cx argument with the rt here

::: js/src/jsgc.cpp
@@ +2277,5 @@
> +            if (!c->isCollecting())
> +                isFullGC = false;
> +        }
> +    }
> +    MarkAtomState(trc, rt->gcKeepAtoms || !isFullGC);

We need a bug to stop marking atoms when the atom compartment is not under the GC itself.
Attachment #612375 - Flags: review?(igor) → review+

Comment 3

5 years ago
Target Milestone: --- → mozilla14


5 years ago
Duplicate of this bug: 742003
Last Resolved: 5 years ago
Resolution: --- → FIXED


5 years ago
Depends on: 749698
You need to log in before you can comment on or make changes to this bug.