Closed Bug 1351405 Opened 7 years ago Closed 7 years ago

Simplify the GC sweep phase implementation

Categories

(Core :: JavaScript: GC, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: jonco, Assigned: jonco)

Details

Attachments

(1 file)

At the moment GCRuntime::sweepPhase is very complicated and mixes up sweeping code with code that handles yielding to the mutator and resuming later on.

We can clean this up making it more data driven.  If we have a list of sweep actions we can split the driver code which handles yielding and resuming from the code that actually does the sweeping.
As discussed, make incremental sweeping data driven.
Attachment #8852416 - Flags: review?(sphink)
Comment on attachment 8852416 [details] [diff] [review]
bug1351405-simplify-sweep-phase

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

Wow, that came out really nice. My initial reaction was that you could set all this up with a static initializer, but with the looping over AllocKinds and things, I agree with the way you have it here.

::: js/src/gc/GCRuntime.h
@@ +1216,5 @@
>       * Incremental sweep state.
>       */
>      ActiveThreadData<JS::Zone*> sweepGroups;
>      ActiveThreadOrGCTaskData<JS::Zone*> currentSweepGroup;
> +    ActiveThreadData<size_t> sweepPhase;

Having this be a size_t seemed weird to me until I realized that it's an index. I know it's long, but how about sweepPhaseIndex and sweepActionIndex?

Or go all out and do

  struct { phaseIndex, actionIndex } incrementalSweepState; // incrementalSweepProgress?

::: js/src/jsgc.cpp
@@ +393,5 @@
>          }
>      }
>  };
>  
> +// Incremental sweeping is controlled by a list of actions that descibe what

*describe

@@ +396,5 @@
>  
> +// Incremental sweeping is controlled by a list of actions that descibe what
> +// happens and in what order. Due to the incremental nature of sweeping an
> +// action does not necessarily run to completion so the current state is tracked
> +// in the GCRuntime by sweepPhase() method.

by *the

@@ +421,5 @@
> +
> +using SweepActionVector = Vector<SweepAction, 0, SystemAllocPolicy>;
> +using SweepPhaseVector = Vector<SweepActionVector, 0, SystemAllocPolicy>;
> +
> +SweepPhaseVector SweepPhases;

static

@@ +433,5 @@
> +void
> +js::gc::ShutDownStaticData()
> +{
> +    SweepPhases.clearAndFree();
> +}

Why is the shutdown needed? Won't ~Vector take care of this?
Attachment #8852416 - Flags: review?(sphink) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5df436b84953
Simplify incremental sweeping implementation r=sfink
https://hg.mozilla.org/mozilla-central/rev/5df436b84953
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: