Closed Bug 865320 Opened 11 years ago Closed 11 years ago

Move logic for deciding when to do a merging cycle collection into the CC itself

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: mccr8, Assigned: mccr8)

References

Details

Attachments

(1 file, 3 obsolete files)

Currently, nsJSEnvironment decides when the CC should do a merging collection, but there's no reason it should be done there.  Moving this into the CC decouples CycleCollectNow and the cycle collector a bit, which is a little nicer for ICC.
Attached patch WIP (obsolete) — Splinter Review
Attachment #742559 - Attachment is patch: true
Attachment #742559 - Attachment is obsolete: true
Try run (for a slightly modified version): https://tbpl.mozilla.org/?tree=Try&rev=88a7945381c3
Comment on attachment 742722 [details] [diff] [review]
decide in the CC when to merge or not

This moves the logic for deciding whether to merge zones or not into XPConnect and the cycle collector.

Instead of CycleCollectNow telling the CC if it should merge or not, it tells the CC if the CC was forced.  Right now, that just means that we shouldn't merge, but with ICC, we can use this information to do things like synchronously finishing off the current CC and running a new one, or things like that.

The bulk of the changes in this patch are passing around the the "type" of the CC, which is either normal, forced, or shutdown.  As above, right now this only affects whether we merge or not, but will be used with ICC to alter the behavior more.  It isn't heavily used, but it seems like a nice general concept to have.  I just pass it around rather than add it as a field because we really only need it at the start of a CC.
Attachment #742722 - Flags: review?(bugs)
Comment on attachment 742722 [details] [diff] [review]
decide in the CC when to merge or not

This is hard to review since it mixes words zone and compartment.
Could you fix comments.
Attachment #742722 - Flags: review?(bugs) → review-
Attachment #742722 - Attachment is obsolete: true
Attachment #743348 - Flags: review?(bugs)
Comment on attachment 743348 [details] [diff] [review]
decide in the CC when to merge or not, fixed comments

>+enum ccType {
>+    NormalCC,
>+    ForcedCC,
>+    ShutdownCC
>+};
Could you call these something like
AllowZoneMergesCC,
NormalCC,
ShutdownCC



>+nsCycleCollector::ShouldMergeZones(ccType aCCType)
>+{
>+    if (!mJSRuntime) {
>+        return false;
>+    }
>+
>+    MOZ_ASSERT(mUnmergedNeeded <= kMinConsecutiveUnmerged);
>+    MOZ_ASSERT(mMergedInARow <= kMaxConsecutiveMerged);
>+
>+    if (mMergedInARow == kMaxConsecutiveMerged) {
>+        MOZ_ASSERT(mUnmergedNeeded == 0);
>+        mUnmergedNeeded = kMinConsecutiveUnmerged;
>+    }
>+
>+    if (mUnmergedNeeded > 0) {
>+        mUnmergedNeeded--;
>+        mMergedInARow = 0;
>+        return false;
>+    }
>+
>+    if (aCCType == NormalCC && mJSRuntime->UsefulToMergeZones()) {
Then s/NormalCC/AllowZoneMergesCC/


>+void nsCycleCollector_collect(bool aForced,
>                               nsCycleCollectorResults *aResults,
>                               nsICycleCollectorListener *aListener);
aForced is really vague. aAllowZoneMergesCC? Need to then change how nsJSEnvironment calls this.
Attachment #743348 - Flags: review?(bugs) → review+
How about changing "aForced" to "aManuallyTriggered"?  Is that clearer?  Then I would change ForcedCC to ManualCC or something.

I could also change NormalCC to TimerCC, say, if you think that's a good idea.
aManuallyTriggered is clearer, yes. And TimerCC sounds good too, or should it be ScheduledCC or some such
- renamed aForced to aManuallyTriggered
- rebased over some changes to the merging logic landed by bholley
- CC types are now ScheduledCC, ManualCC, ShutdownCC, and I added comments describing them.

Try run: https://tbpl.mozilla.org/?tree=Try&rev=fc33865c6a57

Just waiting for inbound to reopen.
Attachment #743348 - Attachment is obsolete: true
Attachment #751054 - Flags: review+
Blocks: 866429
https://hg.mozilla.org/mozilla-central/rev/3a50323631c8
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: