Closed
Bug 1020290
Opened 10 years ago
Closed 10 years ago
Introduce templates to clean up code shared between Nursery and ForkJoinNursery
Categories
(Core :: JavaScript: GC, defect)
Tracking
()
RESOLVED
FIXED
mozilla33
People
(Reporter: lth, Assigned: lth)
Details
Attachments
(5 files)
7.44 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
1.42 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
15.86 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
2.78 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
5.74 KB,
patch
|
jonco
:
review+
|
Details | Diff | Splinter Review |
This is clean-up after 933313 that was deferred so as not to impede landing that patch. A number of functions are shared between the Nursery and ForkJoinNursery but have awkward ifdefs, conditions, or duplication. This bug tracks the work of cleaning that up. - UpdateIonJSFrameForMinorGC should be templatized on the nursery type, and the awkward conditional in its middle should make use of the template type to call the correct forwardBufferPointer. - UpdateJitActivationsForMinorGC will then need to be templatized on the nursery type. The version that takes a runtime can be removed, it need take only a PerThreadData. (More will come)
Assignee | ||
Comment 1•10 years ago
|
||
In some cases there are templates to remove: A template was introduced for MarkExactStackRoots in gc/RootMarking.cpp to work around what is an awkwardly structured doubly nested loop. The outer loop loops over types of objects, the inner loop loops over contexts / per-thread-data objects. However, the regular marker and the PJS marker have different needs for the inner loop. By inverting the loop we might be able to get cleaner code, and we might be able to get rid of the template. Reasonably, the outer loop would loop over contexts and per-thread-data objects (and would be trivial for PJS), the inner loop would then loop over types for each per-thread-data object.
Assignee | ||
Comment 2•10 years ago
|
||
There is some renaming to do: Right now, there is a notion of "the nursery" which means the GGC nursery; this shows up in method names such as "hasNursery", "nursery" (to get it from the ThreadSafeContext), and "isInsideNursery". When talking about the ForkJoin nursery we have to use different names, eg, "fjNursery()" gets the ForkJoinNursery from a ThreadSafeContext. Since there are now two kinds of nurseries it may be that we should rearrange a bit. Methods for the normal nursery should be moved to ExclusiveContext; methods for the ForkJoin nursery should be moved to the ForkJoinContext. Methods that use one kind but not the other kind may be templatized on the type of context, or they may have run-time guards (which they have anyway). Methods for the normal nursery should have less generic names. (Reference: Shu's remarks on https://bugzilla.mozilla.org/show_bug.cgi?id=933313#c71)
Assignee | ||
Comment 3•10 years ago
|
||
TryNewNurseryObject / TryNewFJNurseryObject should be refactored, see https://bugzilla.mozilla.org/show_bug.cgi?id=933313#c86 ff.
Assignee | ||
Comment 4•10 years ago
|
||
Regarding comment 2, there's also Terrence's reply: https://bugzilla.mozilla.org/show_bug.cgi?id=933313#c98.
Assignee | ||
Comment 5•10 years ago
|
||
Scalpel left in patient: There's a little bit of code left for TypedArrayObject in the GC (in copyObjectToTospace), but this should probably be removed because TypedArrayObjects are not nursery-allocated, cf https://bugzilla.mozilla.org/show_bug.cgi?id=933313#c128.
Assignee | ||
Comment 6•10 years ago
|
||
Bug 1024567 makes the point that there's some ad-hoc testing for inside-this-nursery or inside-that-nursery that would be conceptually cleaner if it was abstracted and named for its purpose, not its mechanism.
Assignee | ||
Comment 7•10 years ago
|
||
Addresses the issue in comment #1.
Attachment #8445863 -
Flags: review?(shu)
Assignee | ||
Comment 8•10 years ago
|
||
(In reply to Lars T Hansen [:lth] from comment #7) > Addresses the issue in comment #1. Foo. Addresses the issue in the bug description.
Assignee | ||
Comment 9•10 years ago
|
||
Addresses the issue in comment #5.
Attachment #8445864 -
Flags: review?(shu)
Assignee | ||
Comment 10•10 years ago
|
||
Addresses the issue in comment #2.
Attachment #8445865 -
Flags: review?(shu)
Assignee | ||
Comment 11•10 years ago
|
||
Addresses the issue in comment #3.
Attachment #8445868 -
Flags: review?(shu)
Assignee | ||
Comment 12•10 years ago
|
||
Try run with the four patches applied in order: https://tbpl.mozilla.org/?tree=Try&rev=3aabdce9409e
Assignee | ||
Comment 13•10 years ago
|
||
This pertains to comment #1. Jon, you may recall we discussed this. What I have here is /maybe/ marginally cleaner because there is no use of a template at the interface to MarkExactStackRoots, but I'm not sure how much difference it really makes. Your call.
Attachment #8446051 -
Flags: feedback?(jcoppeard)
Comment 14•10 years ago
|
||
Comment on attachment 8445863 [details] [diff] [review] Factor UpdateJitActivationsForMinorGC Review of attachment 8445863 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/gc/Nursery.cpp @@ +447,5 @@ > +/*static*/ void > +js::Nursery::forwardBufferPointer(JSTracer* trc, HeapSlot **pSlotElems) > +{ > + trc->runtime()->gc.nursery.forwardBufferPointer(pSlotElems); > +} Given how this isn't doing the actual work (as opposed to ForkJoinNursery::forwardBufferPointer), perhaps it should be made static inline? I'm not sure how much performance matters here. ::: js/src/jit/IonFrames.cpp @@ +970,5 @@ > uintptr_t *spill = frame.spillBase(); > for (GeneralRegisterBackwardIterator iter(safepoint.allGprSpills()); iter.more(); iter++) { > --spill; > + if (slotsRegs.has(*iter)) > + T::forwardBufferPointer(trc, reinterpret_cast<HeapSlot **>(spill)); Very nice. @@ +1270,5 @@ > return nullptr; > } > > #ifdef JSGC_GENERATIONAL > +template<typename T> Style nit: template <typename T> @@ +1277,5 @@ > #ifdef JSGC_FJGENERATIONAL > JS_ASSERT(trc->runtime()->isHeapMinorCollecting() || trc->runtime()->isFJMinorCollecting()); > #else > JS_ASSERT(trc->runtime()->isHeapMinorCollecting()); > #endif Perhaps refactor this as well to T::isHeapMinorCollecting? ::: js/src/jit/IonFrames.h @@ +270,5 @@ > JSCompartment * > TopmostIonActivationCompartment(JSRuntime *rt); > > #ifdef JSGC_GENERATIONAL > +template<typename T> Style nit: template <typename T>
Attachment #8445863 -
Flags: review?(shu) → review+
Updated•10 years ago
|
Attachment #8445864 -
Flags: review?(shu) → review+
Comment 15•10 years ago
|
||
Comment on attachment 8445865 [details] [diff] [review] Move notions of 'nursery' out of ThreadSafeContext, rename 'fjNursery' Review of attachment 8445865 [details] [diff] [review]: ----------------------------------------------------------------- Nice. ::: js/src/jsobj.cpp @@ +2862,1 @@ > oldCount, newCount); Style nit: indentation @@ +3191,1 @@ > oldCount, newCount); Style nit: indentation
Attachment #8445865 -
Flags: review?(shu) → review+
Updated•10 years ago
|
Attachment #8445868 -
Flags: review?(shu) → review+
Assignee | ||
Comment 16•10 years ago
|
||
(In reply to Shu-yu Guo [:shu] from comment #14) > Comment on attachment 8445863 [details] [diff] [review] > Factor UpdateJitActivationsForMinorGC > > @@ +1277,5 @@ > > #ifdef JSGC_FJGENERATIONAL > > JS_ASSERT(trc->runtime()->isHeapMinorCollecting() || trc->runtime()->isFJMinorCollecting()); > > #else > > JS_ASSERT(trc->runtime()->isHeapMinorCollecting()); > > #endif > > Perhaps refactor this as well to T::isHeapMinorCollecting? I'm sympathetic. However, since JSGC_FJGENERATIONAL is going away (bug 1019871) I've decided to leave it for now.
Assignee | ||
Comment 17•10 years ago
|
||
First four patches: https://hg.mozilla.org/integration/mozilla-inbound/rev/173fd059805a https://hg.mozilla.org/integration/mozilla-inbound/rev/fdf4539783a3 https://hg.mozilla.org/integration/mozilla-inbound/rev/6f8cc863fe30 https://hg.mozilla.org/integration/mozilla-inbound/rev/dca83d9c4132
Assignee | ||
Updated•10 years ago
|
Keywords: leave-open
Comment 18•10 years ago
|
||
Comment on attachment 8446051 [details] [diff] [review] Invert the MarkExactStackRoots loop to get rid of a template Review of attachment 8446051 [details] [diff] [review]: ----------------------------------------------------------------- This is cleaner, so I say go for it.
Attachment #8446051 -
Flags: feedback?(jcoppeard) → review+
Comment 19•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/173fd059805a https://hg.mozilla.org/mozilla-central/rev/fdf4539783a3 https://hg.mozilla.org/mozilla-central/rev/6f8cc863fe30 https://hg.mozilla.org/mozilla-central/rev/dca83d9c4132 https://hg.mozilla.org/mozilla-central/rev/248b27831f24 https://hg.mozilla.org/mozilla-central/rev/c3d4833a1735
Assignee | ||
Comment 20•10 years ago
|
||
Patch "Invert the MarkStackExactRoots loop ..." https://hg.mozilla.org/integration/mozilla-inbound/rev/955a638544a0
Keywords: leave-open
Assignee | ||
Comment 21•10 years ago
|
||
(In reply to Lars T Hansen [:lth] from comment #20) > Patch "Invert the MarkStackExactRoots loop ..." > https://hg.mozilla.org/integration/mozilla-inbound/rev/955a638544a0 Previous try run: https://tbpl.mozilla.org/?tree=Try&rev=20770b737de6
https://hg.mozilla.org/mozilla-central/rev/955a638544a0
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
You need to log in
before you can comment on or make changes to this bug.
Description
•