From ad9ac707426e6d1fc332241e421d56b8a062b331 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 27 Apr 2019 16:24:35 +0200 Subject: [PATCH 01/25] New cycle version bump. --- application/palemoon/config/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/config/version.txt b/application/palemoon/config/version.txt index b5df67405d..bcbf0fd129 100644 --- a/application/palemoon/config/version.txt +++ b/application/palemoon/config/version.txt @@ -1 +1 @@ -28.5.0a2 \ No newline at end of file +28.6.0a1 \ No newline at end of file From 852ce8292dbc29e84833e2dbe49794eb262db9a2 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 26 Apr 2019 19:46:37 -0400 Subject: [PATCH 02/25] Fix failure to print when pages contain zero-sized element. Fixes #1058 --- dom/html/HTMLCanvasElement.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index a01795d9eb..4b5deab187 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -552,17 +552,23 @@ HTMLCanvasElement::CopyInnerTo(Element* aDest) HTMLCanvasElement* dest = static_cast(aDest); dest->mOriginalCanvas = this; - nsCOMPtr cxt; - dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt)); - RefPtr context2d = - static_cast(cxt.get()); - if (context2d && !mPrintCallback) { - CanvasImageSource source; - source.SetAsHTMLCanvasElement() = this; - ErrorResult err; - context2d->DrawImage(source, - 0.0, 0.0, err); - rv = err.StealNSResult(); + // We make sure that the canvas is not zero sized since that would cause + // the DrawImage call below to return an error, which would cause printing + // to fail. + nsIntSize size = GetWidthHeight(); + if (size.height > 0 && size.width > 0) { + nsCOMPtr cxt; + dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt)); + RefPtr context2d = + static_cast(cxt.get()); + if (context2d && !mPrintCallback) { + CanvasImageSource source; + source.SetAsHTMLCanvasElement() = this; + ErrorResult err; + context2d->DrawImage(source, + 0.0, 0.0, err); + rv = err.StealNSResult(); + } } } return rv; From 100fe48e7b91ef9d585dfd74fde7b157470ee4ba Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 29 Apr 2019 08:13:02 +0200 Subject: [PATCH 03/25] [PALEMOON] Prevent overlapping modal prompts and preserve prompt order. --- application/palemoon/base/content/tabbrowser.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml index d9366f488c..6555d30717 100644 --- a/application/palemoon/base/content/tabbrowser.xml +++ b/application/palemoon/base/content/tabbrowser.xml @@ -402,11 +402,18 @@ let promptBox = { appendPrompt : function(args, onCloseCallback) { let newPrompt = document.createElementNS(XUL_NS, "tabmodalprompt"); - stack.appendChild(newPrompt); + // stack.appendChild(newPrompt); + stack.insertBefore(newPrompt, browser.nextSibling); browser.setAttribute("tabmodalPromptShowing", true); newPrompt.clientTop; // style flush to assure binding is attached + let prompts = this.listPrompts(); + if (prompts.length > 1) { + // Let's hide ourself behind the current prompt. + newPrompt.hidden = true; + } + let tab = self._getTabForContentWindow(browser.contentWindow); newPrompt.init(args, tab, onCloseCallback); return newPrompt; @@ -418,6 +425,7 @@ let prompts = this.listPrompts(); if (prompts.length) { let prompt = prompts[prompts.length - 1]; + prompt.hidden = false; prompt.Dialog.setDefaultFocus(); } else { browser.removeAttribute("tabmodalPromptShowing"); From a695e349d89367f0aeef264a2734d2eb6355d2ed Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 11:59:46 +0300 Subject: [PATCH 04/25] Improve dead compartment collection js/src --- js/src/jsgc.cpp | 198 ++++++++++++++++++++++++---------------- js/src/jsgc.h | 13 ++- js/src/jswatchpoint.cpp | 19 ++-- 3 files changed, 140 insertions(+), 90 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 8cee9ec096..1e8e4fc8d0 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1524,20 +1524,11 @@ GCMarker::delayMarkingChildren(const void* thing) } inline void -ArenaLists::prepareForIncrementalGC(JSRuntime* rt) +ArenaLists::prepareForIncrementalGC() { - for (auto i : AllAllocKinds()) { - FreeSpan* span = freeLists[i]; - if (span != &placeholder) { - if (!span->isEmpty()) { - Arena* arena = span->getArena(); - arena->allocatedDuringIncremental = true; - rt->gc.marker.delayMarkingArena(arena); - } else { - freeLists[i] = &placeholder; - } - } - } + purge(); + for (auto i : AllAllocKinds()) + arenaLists[i].moveCursorToEnd(); } /* Compacting GC */ @@ -2251,7 +2242,7 @@ GCRuntime::updateTypeDescrObjects(MovingTracer* trc, Zone* zone) { zone->typeDescrObjects.sweep(); for (auto r = zone->typeDescrObjects.all(); !r.empty(); r.popFront()) - UpdateCellPointers(trc, r.front().get()); + UpdateCellPointers(trc, r.front()); } void @@ -3579,6 +3570,23 @@ RelazifyFunctions(Zone* zone, AllocKind kind) } } +static bool +ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason) +{ + // Normally we collect all scheduled zones. + if (reason != JS::gcreason::COMPARTMENT_REVIVED) + return zone->isGCScheduled(); + + // If we are repeating a GC becuase we noticed dead compartments haven't + // been collected, then only collect zones contianing those compartments. + for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { + if (comp->scheduledForDestruction) + return true; + } + + return false; +} + bool GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock) { @@ -3602,7 +3610,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces #endif /* Set up which zones will be collected. */ - if (zone->isGCScheduled()) { + if (ShouldCollectZone(zone, reason)) { if (!zone->isAtomsZone()) { any = true; zone->setGCState(Zone::Mark); @@ -3621,7 +3629,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces for (CompartmentsIter c(rt, WithAtoms); !c.done(); c.next()) { c->marked = false; c->scheduledForDestruction = false; - c->maybeAlive = false; + c->maybeAlive = c->hasBeenEntered() || !c->zone()->isGCScheduled(); if (shouldPreserveJITCode(c, currentTime, reason, canAllocateMoreCode)) c->zone()->setPreservingCode(true); } @@ -3640,6 +3648,12 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces * keepAtoms() will only change on the main thread, which we are currently * on. If the value of keepAtoms() changes between GC slices, then we'll * cancel the incremental GC. See IsIncrementalGCSafe. + + + + + + */ if (isFull && !rt->keepAtoms()) { Zone* atomsZone = rt->atomsCompartment(lock)->zone(); @@ -3655,15 +3669,12 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces return false; /* - * At the end of each incremental slice, we call prepareForIncrementalGC, - * which marks objects in all arenas that we're currently allocating - * into. This can cause leaks if unreachable objects are in these - * arenas. This purge call ensures that we only mark arenas that have had - * allocations after the incremental GC started. + * Ensure that after the start of a collection we don't allocate into any + * existing arenas, as this can cause unreachable things to be marked. */ if (isIncremental) { for (GCZonesIter zone(rt); !zone.done(); zone.next()) - zone->arenas.purge(); + zone->arenas.prepareForIncrementalGC(); } MemProfiler::MarkTenuredStart(rt); @@ -3747,13 +3758,11 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS); - if (isIncremental) { - gcstats::AutoPhase ap3(stats, gcstats::PHASE_BUFFER_GRAY_ROOTS); - bufferGrayRoots(); - } - - markCompartments(); - + if (isIncremental) { + bufferGrayRoots(); + markCompartments(); + } + return true; } @@ -3766,9 +3775,14 @@ GCRuntime::markCompartments() * This code ensures that if a compartment is "dead", then it will be * collected in this GC. A compartment is considered dead if its maybeAlive * flag is false. The maybeAlive flag is set if: - * (1) the compartment has incoming cross-compartment edges, or - * (2) an object in the compartment was marked during root marking, either - * as a black root or a gray root. + * (1) the compartment has been entered (set in beginMarkPhase() above) + * (2) the compartment is not being collected (set in beginMarkPhase() + * above) + * (3) an object in the compartment was marked during root marking, either + * as a black root or a gray root (set in RootMarking.cpp), or + * (4) the compartment has incoming cross-compartment edges from another + * compartment that has maybeAlive set (set by this method). + * * If the maybeAlive is false, then we set the scheduledForDestruction flag. * At the end of the GC, we look for compartments where * scheduledForDestruction is true. These are compartments that were somehow @@ -3786,26 +3800,37 @@ GCRuntime::markCompartments() * allocation and read barriers during JS_TransplantObject and the like. */ - /* Set the maybeAlive flag based on cross-compartment edges. */ - for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { - for (JSCompartment::WrapperEnum e(c); !e.empty(); e.popFront()) { + /* Propagate the maybeAlive flag via cross-compartment edges. */ + + Vector workList; + + for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) { + if (comp->maybeAlive) { + if (!workList.append(comp)) + return; + } + } + while (!workList.empty()) { + JSCompartment* comp = workList.popCopy(); + for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) { if (e.front().key().is()) continue; JSCompartment* dest = e.front().mutableKey().compartment(); - if (dest) + if (dest && !dest->maybeAlive) { dest->maybeAlive = true; + if (!workList.append(dest)) + return; + } } } - /* - * For black roots, code in gc/Marking.cpp will already have set maybeAlive - * during MarkRuntime. - */ - - /* Propogate maybeAlive to scheduleForDestruction. */ - for (GCCompartmentsIter c(rt); !c.done(); c.next()) { - if (!c->maybeAlive && !rt->isAtomsCompartment(c)) - c->scheduledForDestruction = true; + + /* Set scheduleForDestruction based on maybeAlive. */ + + for (GCCompartmentsIter comp(rt); !comp.done(); comp.next()) { + MOZ_ASSERT(!comp->scheduledForDestruction); + if (!comp->maybeAlive && !rt->isAtomsCompartment(comp)) + comp->scheduledForDestruction = true; } } @@ -5306,7 +5331,7 @@ AutoGCSlice::~AutoGCSlice() for (ZonesIter zone(runtime, WithAtoms); !zone.done(); zone.next()) { if (zone->isGCMarking()) { zone->setNeedsIncrementalBarrier(true, Zone::UpdateJit); - zone->arenas.prepareForIncrementalGC(runtime); + zone->arenas.purge(); } else { zone->setNeedsIncrementalBarrier(false, Zone::UpdateJit); } @@ -5487,9 +5512,9 @@ gc::AbortReason gc::IsIncrementalGCUnsafe(JSRuntime* rt) { MOZ_ASSERT(!rt->mainThread.suppressGC); - - if (rt->keepAtoms()) - return gc::AbortReason::KeepAtomsSet; + + if (rt->keepAtoms()) + return gc::AbortReason::KeepAtomsSet; if (!rt->gc.isIncrementalGCAllowed()) return gc::AbortReason::IncrementalDisabled; @@ -5498,9 +5523,17 @@ gc::IsIncrementalGCUnsafe(JSRuntime* rt) } void -GCRuntime::budgetIncrementalGC(SliceBudget& budget, AutoLockForExclusiveAccess& lock) +GCRuntime::budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, + AutoLockForExclusiveAccess& lock) { AbortReason unsafeReason = IsIncrementalGCUnsafe(rt); + if (unsafeReason == AbortReason::None) { + if (reason == JS::gcreason::COMPARTMENT_REVIVED) + unsafeReason = gc::AbortReason::CompartmentRevived; + else if (mode != JSGC_MODE_INCREMENTAL) + unsafeReason = gc::AbortReason::ModeChange; + } + if (unsafeReason != AbortReason::None) { resetIncrementalGC(unsafeReason, lock); budget.makeUnlimited(); @@ -5508,12 +5541,7 @@ GCRuntime::budgetIncrementalGC(SliceBudget& budget, AutoLockForExclusiveAccess& return; } - if (mode != JSGC_MODE_INCREMENTAL) { - resetIncrementalGC(AbortReason::ModeChange, lock); - budget.makeUnlimited(); - stats.nonincremental(AbortReason::ModeChange); - return; - } + if (isTooMuchMalloc()) { budget.makeUnlimited(); @@ -5660,6 +5688,10 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason:: } State prevState = incrementalState; + + + + if (nonincrementalByAPI) { // Reset any in progress incremental GC if this was triggered via the @@ -5672,7 +5704,7 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason:: stats.nonincremental(gc::AbortReason::NonIncrementalRequested); budget.makeUnlimited(); } else { - budgetIncrementalGC(budget, session.lock); + budgetIncrementalGC(reason, budget, session.lock); } /* The GC was reset, so we need a do-over. */ @@ -5764,6 +5796,22 @@ GCRuntime::checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason) return true; } +bool +GCRuntime::shouldRepeatForDeadZone(JS::gcreason::Reason reason) +{ + MOZ_ASSERT_IF(reason == JS::gcreason::COMPARTMENT_REVIVED, !isIncremental); + + if (!isIncremental || isIncrementalGCInProgress()) + return false; + + for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { + if (c->scheduledForDestruction) + return true; + } + + return false; +} + void GCRuntime::collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::Reason reason) { @@ -5782,27 +5830,23 @@ GCRuntime::collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::R do { poked = false; bool wasReset = gcCycle(nonincrementalByAPI, budget, reason); - - /* Need to re-schedule all zones for GC. */ - if (poked && cleanUpEverything) + + bool repeatForDeadZone = false; + if (poked && cleanUpEverything) { + /* Need to re-schedule all zones for GC. */ JS::PrepareForFullGC(rt->contextFromMainThread()); - /* - * This code makes an extra effort to collect compartments that we - * thought were dead at the start of the GC. See the large comment in - * beginMarkPhase. - */ - bool repeatForDeadZone = false; - if (!nonincrementalByAPI && !isIncrementalGCInProgress()) { - for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { - if (c->scheduledForDestruction) { - nonincrementalByAPI = true; - repeatForDeadZone = true; - reason = JS::gcreason::COMPARTMENT_REVIVED; - c->zone()->scheduleGC(); - } - } - } + + } else if (shouldRepeatForDeadZone(reason) && !wasReset) { + /* + * This code makes an extra effort to collect compartments that we + * thought were dead at the start of the GC. See the large comment + * in beginMarkPhase. + */ + repeatForDeadZone = true; + reason = JS::gcreason::COMPARTMENT_REVIVED; + } + /* * If we reset an existing GC, we need to start a new one. Also, we @@ -7070,4 +7114,4 @@ js::gc::detail::CellIsMarkedGrayIfKnown(const Cell* cell) } return detail::CellIsMarkedGray(tc); -} +} \ No newline at end of file diff --git a/js/src/jsgc.h b/js/src/jsgc.h index d3cf31fe77..aa42d474c2 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -61,7 +61,8 @@ enum class State { D(ModeChange) \ D(MallocBytesTrigger) \ D(GCBytesTrigger) \ - D(ZoneChange) + D(ZoneChange) \ + D(CompartmentRevived) enum class AbortReason { #define MAKE_REASON(name) name, GC_ABORT_REASONS(MAKE_REASON) @@ -353,7 +354,6 @@ struct SortedArenaListSegment * be treated as an invariant, however, as the free lists may be cleared, * leaving arenas previously used for allocation partially full. Sorting order * is restored during sweeping. - * Arenas following the cursor should not be full. */ class ArenaList { @@ -453,6 +453,11 @@ class ArenaList { check(); return !*cursorp_; } + + void moveCursorToEnd() { + while (!isCursorAtEnd()) + cursorp_ = &(*cursorp_)->next; + } // This can return nullptr. Arena* arenaAfterCursor() const { @@ -739,7 +744,7 @@ class ArenaLists freeLists[i] = &placeholder; } - inline void prepareForIncrementalGC(JSRuntime* rt); + inline void prepareForIncrementalGC(); /* Check if this arena is in use. */ bool arenaIsInUse(Arena* arena, AllocKind kind) const { @@ -1504,4 +1509,4 @@ UninlinedIsInsideNursery(const gc::Cell* cell); } /* namespace js */ -#endif /* jsgc_h */ +#endif /* jsgc_h */ \ No newline at end of file diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp index 3cf43e2197..68afa4a595 100644 --- a/js/src/jswatchpoint.cpp +++ b/js/src/jswatchpoint.cpp @@ -185,17 +185,18 @@ WatchpointMap::markAll(JSTracer* trc) { for (Map::Enum e(map); !e.empty(); e.popFront()) { Map::Entry& entry = e.front(); - WatchKey key = entry.key(); - WatchKey prior = key; - MOZ_ASSERT(JSID_IS_STRING(prior.id) || JSID_IS_INT(prior.id) || JSID_IS_SYMBOL(prior.id)); + JSObject* object = entry.key().object; + jsid id = entry.key().id; + JSObject* priorObject = object; + jsid priorId = id; + MOZ_ASSERT(JSID_IS_STRING(priorId) || JSID_IS_INT(priorId) || JSID_IS_SYMBOL(priorId)); - TraceEdge(trc, const_cast(&key.object), - "held Watchpoint object"); - TraceEdge(trc, const_cast(&key.id), "WatchKey::id"); + TraceManuallyBarrieredEdge(trc, &object, "held Watchpoint object"); + TraceManuallyBarrieredEdge(trc, &id, "WatchKey::id"); TraceEdge(trc, &entry.value().closure, "Watchpoint::closure"); - if (prior.object != key.object || prior.id != key.id) - e.rekeyFront(key); + if (priorObject != object || priorId != id) + e.rekeyFront(WatchKey(object, id)); } } @@ -242,4 +243,4 @@ WatchpointMap::trace(WeakMapTracer* trc) JS::GCCellPtr(entry.key().object.get()), JS::GCCellPtr(entry.value().closure.get())); } -} +} \ No newline at end of file From c1b4fc1442d800d36c99786bc871d083f309e0a8 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 12:02:24 +0300 Subject: [PATCH 05/25] Improve dead compartment collection js/src/gc --- js/src/gc/GCRuntime.h | 6 ++++-- js/src/gc/RootMarking.cpp | 4 ++-- js/src/gc/Zone.cpp | 17 ++++++++++++++++- js/src/gc/Zone.h | 13 ++++++++++--- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 5c2576efde..16260a4e3c 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -900,7 +900,8 @@ class GCRuntime void requestMajorGC(JS::gcreason::Reason reason); SliceBudget defaultBudget(JS::gcreason::Reason reason, int64_t millis); - void budgetIncrementalGC(SliceBudget& budget, AutoLockForExclusiveAccess& lock); + void budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, + AutoLockForExclusiveAccess& lock); void resetIncrementalGC(AbortReason reason, AutoLockForExclusiveAccess& lock); // Assert if the system state is such that we should never @@ -915,6 +916,7 @@ class GCRuntime void collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::Reason reason) JS_HAZ_GC_CALL; MOZ_MUST_USE bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason::Reason reason); + bool shouldRepeatForDeadZone(JS::gcreason::Reason reason); void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock); @@ -1348,4 +1350,4 @@ class MOZ_RAII AutoMaybeStartBackgroundAllocation } /* namespace js */ -#endif +#endif \ No newline at end of file diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index 93264084bb..ed7b8fb6ff 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -478,6 +478,7 @@ js::gc::GCRuntime::bufferGrayRoots() for (GCZonesIter zone(rt); !zone.done(); zone.next()) MOZ_ASSERT(zone->gcGrayRoots.empty()); + gcstats::AutoPhase ap(stats, gcstats::PHASE_BUFFER_GRAY_ROOTS); BufferGrayRootsTracer grayBufferer(rt); if (JSTraceDataOp op = grayRootTracer.op) @@ -539,5 +540,4 @@ GCRuntime::resetBufferedGrayRoots() const "Do not clear the gray buffers unless we are Failed or becoming Unused"); for (GCZonesIter zone(rt); !zone.done(); zone.next()) zone->gcGrayRoots.clearAndFree(); -} - +} \ No newline at end of file diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index ed099341c5..ecfb9a38cd 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -370,6 +370,21 @@ Zone::fixupAfterMovingGC() fixupInitialShapeTable(); } +bool +Zone::addTypeDescrObject(JSContext* cx, HandleObject obj) +{ + // Type descriptor objects are always tenured so we don't need post barriers + // on the set. + MOZ_ASSERT(!IsInsideNursery(obj)); + + if (!typeDescrObjects.put(obj)) { + ReportOutOfMemory(cx); + return false; + } + + return true; +} + ZoneList::ZoneList() : head(nullptr), tail(nullptr) {} @@ -468,4 +483,4 @@ JS_PUBLIC_API(void) JS::shadow::RegisterWeakCache(JS::Zone* zone, WeakCache* cachep) { zone->registerWeakCache(cachep); -} +} \ No newline at end of file diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index 50d06319db..24f4648f78 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -349,10 +349,17 @@ struct Zone : public JS::shadow::Zone, // Keep track of all TypeDescr and related objects in this compartment. // This is used by the GC to trace them all first when compacting, since the // TypedObject trace hook may access these objects. - using TypeDescrObjectSet = js::GCHashSet, - js::MovableCellHasher>, + + // + // There are no barriers here - the set contains only tenured objects so no + // post-barrier is required, and these are weak references so no pre-barrier + // is required. + using TypeDescrObjectSet = js::GCHashSet, js::SystemAllocPolicy>; JS::WeakCache typeDescrObjects; + + bool addTypeDescrObject(JSContext* cx, HandleObject obj); // Malloc counter to measure memory pressure for GC scheduling. It runs from @@ -734,4 +741,4 @@ class ZoneAllocPolicy } // namespace js -#endif // gc_Zone_h +#endif // gc_Zone_h \ No newline at end of file From 68a36fe36f7594e2d76fedb8418e5dd0f6943a50 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 12:05:03 +0300 Subject: [PATCH 06/25] Improve dead compartment collection js/src/builtin --- js/src/builtin/TypedObject.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index ae74f01bf6..95704ee460 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -652,7 +652,7 @@ ArrayMetaTypeDescr::create(JSContext* cx, if (!CreateTraceList(cx, obj)) return nullptr; - if (!cx->zone()->typeDescrObjects.put(obj)) { + if (!cx->zone()->addTypeDescrObject(cx, obj)) { ReportOutOfMemory(cx); return nullptr; } @@ -993,8 +993,8 @@ StructMetaTypeDescr::create(JSContext* cx, if (!CreateTraceList(cx, descr)) return nullptr; - if (!cx->zone()->typeDescrObjects.put(descr) || - !cx->zone()->typeDescrObjects.put(fieldTypeVec)) + if (!cx->zone()->addTypeDescrObject(cx, descr) || + !cx->zone()->addTypeDescrObject(cx, fieldTypeVec)) { ReportOutOfMemory(cx); return nullptr; @@ -1165,10 +1165,8 @@ DefineSimpleTypeDescr(JSContext* cx, if (!CreateTraceList(cx, descr)) return false; - if (!cx->zone()->typeDescrObjects.put(descr)) { - ReportOutOfMemory(cx); + if (!cx->zone()->addTypeDescrObject(cx, descr)) return false; - } return true; } @@ -3005,4 +3003,4 @@ TypeDescr::finalize(FreeOp* fop, JSObject* obj) TypeDescr& descr = obj->as(); if (descr.hasTraceList()) js_free(const_cast(descr.traceList())); -} +} \ No newline at end of file From acf2827e3ce0a7ba391d03b37c2d18d204669ac0 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 12:08:50 +0300 Subject: [PATCH 07/25] Improve dead compartment collection js/ipc --- js/ipc/JavaScriptShared.cpp | 11 ++++++++++- js/ipc/JavaScriptShared.h | 3 ++- js/ipc/WrapperAnswer.cpp | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index 9786243f21..aba02252d7 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -61,6 +61,15 @@ IdToObjectMap::find(ObjectId id) return p->value(); } +JSObject* +IdToObjectMap::findPreserveColor(ObjectId id) +{ + Table::Ptr p = table_.lookup(id); + if (!p) + return nullptr; + return p->value().unbarrieredGet(); + } + bool IdToObjectMap::add(ObjectId id, JSObject* obj) { @@ -757,4 +766,4 @@ CPOWManager* mozilla::jsipc::CPOWManagerFor(PJavaScriptChild* aChild) { return static_cast(aChild); -} +} \ No newline at end of file diff --git a/js/ipc/JavaScriptShared.h b/js/ipc/JavaScriptShared.h index 4de1538265..d0cd4615b2 100644 --- a/js/ipc/JavaScriptShared.h +++ b/js/ipc/JavaScriptShared.h @@ -96,6 +96,7 @@ class IdToObjectMap bool add(ObjectId id, JSObject* obj); JSObject* find(ObjectId id); + JSObject* findPreserveColor(ObjectId id); void remove(ObjectId id); void clear(); @@ -233,4 +234,4 @@ class JavaScriptShared : public CPOWManager } // namespace jsipc } // namespace mozilla -#endif +#endif \ No newline at end of file diff --git a/js/ipc/WrapperAnswer.cpp b/js/ipc/WrapperAnswer.cpp index fc342bbb68..6ae68e01f4 100644 --- a/js/ipc/WrapperAnswer.cpp +++ b/js/ipc/WrapperAnswer.cpp @@ -789,10 +789,10 @@ WrapperAnswer::RecvDOMInstanceOf(const ObjectId& objId, const int& prototypeID, bool WrapperAnswer::RecvDropObject(const ObjectId& objId) { - JSObject* obj = objects_.find(objId); + JSObject* obj = objects_.findPreserveColor(objId); if (obj) { objectIdMap(objId.hasXrayWaiver()).remove(obj); objects_.remove(objId); } return true; -} +} \ No newline at end of file From 0e23aedfcddf6f6327c2c7e654e02e6b17534ec0 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 12:32:23 +0300 Subject: [PATCH 08/25] Space to comment. --- js/src/jsgc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/js/src/jsgc.h b/js/src/jsgc.h index aa42d474c2..8626e3e38e 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -354,6 +354,7 @@ struct SortedArenaListSegment * be treated as an invariant, however, as the free lists may be cleared, * leaving arenas previously used for allocation partially full. Sorting order * is restored during sweeping. + * Arenas following the cursor should not be full. */ class ArenaList { From 41693aa70fefa669cf74fe0f277ab91c6c60b544 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 15:31:58 +0300 Subject: [PATCH 09/25] Add newline at end of files js/src --- js/src/jsgc.cpp | 2 +- js/src/jsgc.h | 2 +- js/src/jswatchpoint.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 1e8e4fc8d0..ad3d7093d7 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -7114,4 +7114,4 @@ js::gc::detail::CellIsMarkedGrayIfKnown(const Cell* cell) } return detail::CellIsMarkedGray(tc); -} \ No newline at end of file +} diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 8626e3e38e..5d3c372861 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -1510,4 +1510,4 @@ UninlinedIsInsideNursery(const gc::Cell* cell); } /* namespace js */ -#endif /* jsgc_h */ \ No newline at end of file +#endif /* jsgc_h */ diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp index 68afa4a595..f147a07dc4 100644 --- a/js/src/jswatchpoint.cpp +++ b/js/src/jswatchpoint.cpp @@ -243,4 +243,4 @@ WatchpointMap::trace(WeakMapTracer* trc) JS::GCCellPtr(entry.key().object.get()), JS::GCCellPtr(entry.value().closure.get())); } -} \ No newline at end of file +} From 9051e1dd6a36ef05d0678c8f49590008b4b95dc6 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 15:33:52 +0300 Subject: [PATCH 10/25] add newline at end of files js/src/gc --- js/src/gc/GCRuntime.h | 2 +- js/src/gc/RootMarking.cpp | 2 +- js/src/gc/Zone.cpp | 2 +- js/src/gc/Zone.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 16260a4e3c..72910c6158 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -1350,4 +1350,4 @@ class MOZ_RAII AutoMaybeStartBackgroundAllocation } /* namespace js */ -#endif \ No newline at end of file +#endif diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index ed7b8fb6ff..b09ee6e001 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -540,4 +540,4 @@ GCRuntime::resetBufferedGrayRoots() const "Do not clear the gray buffers unless we are Failed or becoming Unused"); for (GCZonesIter zone(rt); !zone.done(); zone.next()) zone->gcGrayRoots.clearAndFree(); -} \ No newline at end of file +} diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index ecfb9a38cd..7681f15c58 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -483,4 +483,4 @@ JS_PUBLIC_API(void) JS::shadow::RegisterWeakCache(JS::Zone* zone, WeakCache* cachep) { zone->registerWeakCache(cachep); -} \ No newline at end of file +} diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index 24f4648f78..d337fe85cb 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -741,4 +741,4 @@ class ZoneAllocPolicy } // namespace js -#endif // gc_Zone_h \ No newline at end of file +#endif // gc_Zone_h From b8a58dab8750c4bf8382311dd3543017009e0dfa Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 15:36:04 +0300 Subject: [PATCH 11/25] Add newline at end of file js/src/builtin --- js/src/builtin/TypedObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 95704ee460..0dfc1123a2 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -3003,4 +3003,4 @@ TypeDescr::finalize(FreeOp* fop, JSObject* obj) TypeDescr& descr = obj->as(); if (descr.hasTraceList()) js_free(const_cast(descr.traceList())); -} \ No newline at end of file +} From 45680f8610621264d5418b58d81ee7e498bb7bd2 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 29 Apr 2019 15:37:46 +0300 Subject: [PATCH 12/25] Add newline at end of files --- js/ipc/JavaScriptShared.cpp | 2 +- js/ipc/JavaScriptShared.h | 2 +- js/ipc/WrapperAnswer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index aba02252d7..050a728968 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -766,4 +766,4 @@ CPOWManager* mozilla::jsipc::CPOWManagerFor(PJavaScriptChild* aChild) { return static_cast(aChild); -} \ No newline at end of file +} diff --git a/js/ipc/JavaScriptShared.h b/js/ipc/JavaScriptShared.h index d0cd4615b2..5aff470cc0 100644 --- a/js/ipc/JavaScriptShared.h +++ b/js/ipc/JavaScriptShared.h @@ -234,4 +234,4 @@ class JavaScriptShared : public CPOWManager } // namespace jsipc } // namespace mozilla -#endif \ No newline at end of file +#endif diff --git a/js/ipc/WrapperAnswer.cpp b/js/ipc/WrapperAnswer.cpp index 6ae68e01f4..563f8f90d3 100644 --- a/js/ipc/WrapperAnswer.cpp +++ b/js/ipc/WrapperAnswer.cpp @@ -795,4 +795,4 @@ WrapperAnswer::RecvDropObject(const ObjectId& objId) objects_.remove(objId); } return true; -} \ No newline at end of file +} From 4489faedab46f03f798457a9b187b856cff1a5e7 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 02:16:38 +0300 Subject: [PATCH 13/25] tab to spaces js/src --- js/src/jsgc.cpp | 78 ++++++++++++++++++++--------------------- js/src/jsgc.h | 10 +++--- js/src/jswatchpoint.cpp | 4 +-- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index ad3d7093d7..283eb22b09 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1527,7 +1527,7 @@ inline void ArenaLists::prepareForIncrementalGC() { purge(); - for (auto i : AllAllocKinds()) + for (auto i : AllAllocKinds()) arenaLists[i].moveCursorToEnd(); } @@ -3573,18 +3573,18 @@ RelazifyFunctions(Zone* zone, AllocKind kind) static bool ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason) { - // Normally we collect all scheduled zones. - if (reason != JS::gcreason::COMPARTMENT_REVIVED) - return zone->isGCScheduled(); + // Normally we collect all scheduled zones. + if (reason != JS::gcreason::COMPARTMENT_REVIVED) + return zone->isGCScheduled(); - // If we are repeating a GC becuase we noticed dead compartments haven't - // been collected, then only collect zones contianing those compartments. - for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { - if (comp->scheduledForDestruction) - return true; - } - - return false; + // If we are repeating a GC becuase we noticed dead compartments haven't + // been collected, then only collect zones contianing those compartments. + for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { + if (comp->scheduledForDestruction) + return true; + } + + return false; } bool @@ -5527,12 +5527,12 @@ GCRuntime::budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, AutoLockForExclusiveAccess& lock) { AbortReason unsafeReason = IsIncrementalGCUnsafe(rt); - if (unsafeReason == AbortReason::None) { - if (reason == JS::gcreason::COMPARTMENT_REVIVED) - unsafeReason = gc::AbortReason::CompartmentRevived; - else if (mode != JSGC_MODE_INCREMENTAL) - unsafeReason = gc::AbortReason::ModeChange; - } + if (unsafeReason == AbortReason::None) { + if (reason == JS::gcreason::COMPARTMENT_REVIVED) + unsafeReason = gc::AbortReason::CompartmentRevived; + else if (mode != JSGC_MODE_INCREMENTAL) + unsafeReason = gc::AbortReason::ModeChange; + } if (unsafeReason != AbortReason::None) { resetIncrementalGC(unsafeReason, lock); @@ -5799,17 +5799,17 @@ GCRuntime::checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason) bool GCRuntime::shouldRepeatForDeadZone(JS::gcreason::Reason reason) { - MOZ_ASSERT_IF(reason == JS::gcreason::COMPARTMENT_REVIVED, !isIncremental); - - if (!isIncremental || isIncrementalGCInProgress()) - return false; - - for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { - if (c->scheduledForDestruction) - return true; - } - - return false; + MOZ_ASSERT_IF(reason == JS::gcreason::COMPARTMENT_REVIVED, !isIncremental); + + if (!isIncremental || isIncrementalGCInProgress()) + return false; + + for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { + if (c->scheduledForDestruction) + return true; + } + + return false; } void @@ -5831,21 +5831,21 @@ GCRuntime::collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::R poked = false; bool wasReset = gcCycle(nonincrementalByAPI, budget, reason); - bool repeatForDeadZone = false; + bool repeatForDeadZone = false; if (poked && cleanUpEverything) { - /* Need to re-schedule all zones for GC. */ + /* Need to re-schedule all zones for GC. */ JS::PrepareForFullGC(rt->contextFromMainThread()); } else if (shouldRepeatForDeadZone(reason) && !wasReset) { - /* - * This code makes an extra effort to collect compartments that we - * thought were dead at the start of the GC. See the large comment - * in beginMarkPhase. - */ - repeatForDeadZone = true; - reason = JS::gcreason::COMPARTMENT_REVIVED; - } + /* + * This code makes an extra effort to collect compartments that we + * thought were dead at the start of the GC. See the large comment + * in beginMarkPhase. + */ + repeatForDeadZone = true; + reason = JS::gcreason::COMPARTMENT_REVIVED; + } /* diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 5d3c372861..85b9f5f4ac 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -62,7 +62,7 @@ enum class State { D(MallocBytesTrigger) \ D(GCBytesTrigger) \ D(ZoneChange) \ - D(CompartmentRevived) + D(CompartmentRevived) enum class AbortReason { #define MAKE_REASON(name) name, GC_ABORT_REASONS(MAKE_REASON) @@ -455,10 +455,10 @@ class ArenaList { return !*cursorp_; } - void moveCursorToEnd() { - while (!isCursorAtEnd()) - cursorp_ = &(*cursorp_)->next; - } + void moveCursorToEnd() { + while (!isCursorAtEnd()) + cursorp_ = &(*cursorp_)->next; + } // This can return nullptr. Arena* arenaAfterCursor() const { diff --git a/js/src/jswatchpoint.cpp b/js/src/jswatchpoint.cpp index f147a07dc4..e373235553 100644 --- a/js/src/jswatchpoint.cpp +++ b/js/src/jswatchpoint.cpp @@ -187,8 +187,8 @@ WatchpointMap::markAll(JSTracer* trc) Map::Entry& entry = e.front(); JSObject* object = entry.key().object; jsid id = entry.key().id; - JSObject* priorObject = object; - jsid priorId = id; + JSObject* priorObject = object; + jsid priorId = id; MOZ_ASSERT(JSID_IS_STRING(priorId) || JSID_IS_INT(priorId) || JSID_IS_SYMBOL(priorId)); TraceManuallyBarrieredEdge(trc, &object, "held Watchpoint object"); From 965a10e9ce76e11871e7900b63dfe818be472ca5 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 02:20:36 +0300 Subject: [PATCH 14/25] tab to spaces js/src/gc --- js/src/gc/GCRuntime.h | 4 ++-- js/src/gc/RootMarking.cpp | 2 +- js/src/gc/Zone.cpp | 22 +++++++++++----------- js/src/gc/Zone.h | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 72910c6158..f102e9ef03 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -901,7 +901,7 @@ class GCRuntime void requestMajorGC(JS::gcreason::Reason reason); SliceBudget defaultBudget(JS::gcreason::Reason reason, int64_t millis); void budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, - AutoLockForExclusiveAccess& lock); + AutoLockForExclusiveAccess& lock); void resetIncrementalGC(AbortReason reason, AutoLockForExclusiveAccess& lock); // Assert if the system state is such that we should never @@ -916,7 +916,7 @@ class GCRuntime void collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::Reason reason) JS_HAZ_GC_CALL; MOZ_MUST_USE bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason::Reason reason); - bool shouldRepeatForDeadZone(JS::gcreason::Reason reason); + bool shouldRepeatForDeadZone(JS::gcreason::Reason reason); void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock); diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index b09ee6e001..f5969bc1f5 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -478,7 +478,7 @@ js::gc::GCRuntime::bufferGrayRoots() for (GCZonesIter zone(rt); !zone.done(); zone.next()) MOZ_ASSERT(zone->gcGrayRoots.empty()); - gcstats::AutoPhase ap(stats, gcstats::PHASE_BUFFER_GRAY_ROOTS); + gcstats::AutoPhase ap(stats, gcstats::PHASE_BUFFER_GRAY_ROOTS); BufferGrayRootsTracer grayBufferer(rt); if (JSTraceDataOp op = grayRootTracer.op) diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp index 7681f15c58..f0cdde0121 100644 --- a/js/src/gc/Zone.cpp +++ b/js/src/gc/Zone.cpp @@ -373,18 +373,18 @@ Zone::fixupAfterMovingGC() bool Zone::addTypeDescrObject(JSContext* cx, HandleObject obj) { - // Type descriptor objects are always tenured so we don't need post barriers - // on the set. - MOZ_ASSERT(!IsInsideNursery(obj)); - - if (!typeDescrObjects.put(obj)) { - ReportOutOfMemory(cx); - return false; - } - - return true; + // Type descriptor objects are always tenured so we don't need post barriers + // on the set. + MOZ_ASSERT(!IsInsideNursery(obj)); + + if (!typeDescrObjects.put(obj)) { + ReportOutOfMemory(cx); + return false; + } + + return true; } - + ZoneList::ZoneList() : head(nullptr), tail(nullptr) {} diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index d337fe85cb..c8520ed55b 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -350,16 +350,16 @@ struct Zone : public JS::shadow::Zone, // This is used by the GC to trace them all first when compacting, since the // TypedObject trace hook may access these objects. - // - // There are no barriers here - the set contains only tenured objects so no - // post-barrier is required, and these are weak references so no pre-barrier - // is required. - using TypeDescrObjectSet = js::GCHashSet, js::SystemAllocPolicy>; JS::WeakCache typeDescrObjects; - bool addTypeDescrObject(JSContext* cx, HandleObject obj); + bool addTypeDescrObject(JSContext* cx, HandleObject obj); // Malloc counter to measure memory pressure for GC scheduling. It runs from From 60e2d4889fa3bdaf2daf2c5eee653d5a51055d29 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 02:40:55 +0300 Subject: [PATCH 15/25] tab to spaces js/ipc --- js/ipc/JavaScriptShared.cpp | 2 +- js/ipc/JavaScriptShared.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index 050a728968..8c86e6fe8c 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -68,7 +68,7 @@ IdToObjectMap::findPreserveColor(ObjectId id) if (!p) return nullptr; return p->value().unbarrieredGet(); - } +} bool IdToObjectMap::add(ObjectId id, JSObject* obj) diff --git a/js/ipc/JavaScriptShared.h b/js/ipc/JavaScriptShared.h index 5aff470cc0..5ecec74296 100644 --- a/js/ipc/JavaScriptShared.h +++ b/js/ipc/JavaScriptShared.h @@ -96,7 +96,7 @@ class IdToObjectMap bool add(ObjectId id, JSObject* obj); JSObject* find(ObjectId id); - JSObject* findPreserveColor(ObjectId id); + JSObject* findPreserveColor(ObjectId id); void remove(ObjectId id); void clear(); From 862e0cb3ea07adac14cf6c1ba9f4afbeeb73e014 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 02:43:47 +0300 Subject: [PATCH 16/25] remaining tabs to space js/src/jsgc.cpp --- js/src/jsgc.cpp | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 283eb22b09..589e478f48 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3758,11 +3758,11 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS); - if (isIncremental) { + if (isIncremental) { bufferGrayRoots(); - markCompartments(); - } - + markCompartments(); + } + return true; } @@ -3778,11 +3778,11 @@ GCRuntime::markCompartments() * (1) the compartment has been entered (set in beginMarkPhase() above) * (2) the compartment is not being collected (set in beginMarkPhase() * above) - * (3) an object in the compartment was marked during root marking, either - * as a black root or a gray root (set in RootMarking.cpp), or + * (3) an object in the compartment was marked during root marking, either + * as a black root or a gray root (set in RootMarking.cpp), or * (4) the compartment has incoming cross-compartment edges from another - * compartment that has maybeAlive set (set by this method). - * + * compartment that has maybeAlive set (set by this method). + * * If the maybeAlive is false, then we set the scheduledForDestruction flag. * At the end of the GC, we look for compartments where * scheduledForDestruction is true. These are compartments that were somehow @@ -3802,35 +3802,35 @@ GCRuntime::markCompartments() /* Propagate the maybeAlive flag via cross-compartment edges. */ - Vector workList; - - for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) { - if (comp->maybeAlive) { - if (!workList.append(comp)) - return; - } - } - while (!workList.empty()) { - JSCompartment* comp = workList.popCopy(); - for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) { + Vector workList; + + for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) { + if (comp->maybeAlive) { + if (!workList.append(comp)) + return; + } + } + while (!workList.empty()) { + JSCompartment* comp = workList.popCopy(); + for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) { if (e.front().key().is()) continue; JSCompartment* dest = e.front().mutableKey().compartment(); if (dest && !dest->maybeAlive) { dest->maybeAlive = true; - if (!workList.append(dest)) - return; - } + if (!workList.append(dest)) + return; + } } } /* Set scheduleForDestruction based on maybeAlive. */ - for (GCCompartmentsIter comp(rt); !comp.done(); comp.next()) { - MOZ_ASSERT(!comp->scheduledForDestruction); - if (!comp->maybeAlive && !rt->isAtomsCompartment(comp)) - comp->scheduledForDestruction = true; + for (GCCompartmentsIter comp(rt); !comp.done(); comp.next()) { + MOZ_ASSERT(!comp->scheduledForDestruction); + if (!comp->maybeAlive && !rt->isAtomsCompartment(comp)) + comp->scheduledForDestruction = true; } } From 74084e264132dddfaba3efa933317125dbcd209d Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 11:06:55 +0300 Subject: [PATCH 17/25] Remaining tabs to spaces JavaScriptShared.cpp --- js/ipc/JavaScriptShared.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/ipc/JavaScriptShared.cpp b/js/ipc/JavaScriptShared.cpp index 8c86e6fe8c..961a3f9106 100644 --- a/js/ipc/JavaScriptShared.cpp +++ b/js/ipc/JavaScriptShared.cpp @@ -64,10 +64,10 @@ IdToObjectMap::find(ObjectId id) JSObject* IdToObjectMap::findPreserveColor(ObjectId id) { - Table::Ptr p = table_.lookup(id); - if (!p) - return nullptr; - return p->value().unbarrieredGet(); + Table::Ptr p = table_.lookup(id); + if (!p) + return nullptr; + return p->value().unbarrieredGet(); } bool From 1a8e4749c35a6fe8bcf962243907493ad1fc5cfc Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 12:22:51 +0300 Subject: [PATCH 18/25] Remove some empty lines --- js/src/jsgc.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 589e478f48..70d392973c 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3649,10 +3649,6 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces * on. If the value of keepAtoms() changes between GC slices, then we'll * cancel the incremental GC. See IsIncrementalGCSafe. - - - - */ if (isFull && !rt->keepAtoms()) { @@ -5689,9 +5685,6 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason:: State prevState = incrementalState; - - - if (nonincrementalByAPI) { // Reset any in progress incremental GC if this was triggered via the From 297f99b0bf11b41c37014fbbad93cae06dbc2779 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 12:37:16 +0300 Subject: [PATCH 19/25] Remove rest of empty lines. --- js/src/jsgc.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 70d392973c..a1296f0d85 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3648,9 +3648,8 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces * keepAtoms() will only change on the main thread, which we are currently * on. If the value of keepAtoms() changes between GC slices, then we'll * cancel the incremental GC. See IsIncrementalGCSafe. - - */ + if (isFull && !rt->keepAtoms()) { Zone* atomsZone = rt->atomsCompartment(lock)->zone(); if (atomsZone->isGCScheduled()) { @@ -5684,7 +5683,6 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason:: } State prevState = incrementalState; - if (nonincrementalByAPI) { // Reset any in progress incremental GC if this was triggered via the From b584107330bd4feba1da99bfccbd64d3f36d652f Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 13:22:57 +0300 Subject: [PATCH 20/25] Whitespaces, typo, tabs to space Remove whitespaces, correct comment typo, one more tab to space --- js/src/jsgc.cpp | 12 ++++++------ js/src/jsgc.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index a1296f0d85..f528b2d70f 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3578,7 +3578,7 @@ ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason) return zone->isGCScheduled(); // If we are repeating a GC becuase we noticed dead compartments haven't - // been collected, then only collect zones contianing those compartments. + // been collected, then only collect zones containing those compartments. for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { if (comp->scheduledForDestruction) return true; @@ -3753,8 +3753,8 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS); - if (isIncremental) { - bufferGrayRoots(); + if (isIncremental) { + bufferGrayRoots(); markCompartments(); } @@ -5508,8 +5508,8 @@ gc::IsIncrementalGCUnsafe(JSRuntime* rt) { MOZ_ASSERT(!rt->mainThread.suppressGC); - if (rt->keepAtoms()) - return gc::AbortReason::KeepAtomsSet; + if (rt->keepAtoms()) + return gc::AbortReason::KeepAtomsSet; if (!rt->gc.isIncrementalGCAllowed()) return gc::AbortReason::IncrementalDisabled; @@ -5519,7 +5519,7 @@ gc::IsIncrementalGCUnsafe(JSRuntime* rt) void GCRuntime::budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, - AutoLockForExclusiveAccess& lock) + AutoLockForExclusiveAccess& lock) { AbortReason unsafeReason = IsIncrementalGCUnsafe(rt); if (unsafeReason == AbortReason::None) { diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 85b9f5f4ac..d00d2aef6b 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -354,7 +354,7 @@ struct SortedArenaListSegment * be treated as an invariant, however, as the free lists may be cleared, * leaving arenas previously used for allocation partially full. Sorting order * is restored during sweeping. - + * Arenas following the cursor should not be full. */ class ArenaList { From b11e5bc2d30c6e58f452079f03465b782b071ae5 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Tue, 30 Apr 2019 15:07:04 +0300 Subject: [PATCH 21/25] Braces and one more typo fix for comment --- js/src/jsgc.cpp | 5 +++-- js/src/jsgc.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index f528b2d70f..194468c5d7 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1527,8 +1527,9 @@ inline void ArenaLists::prepareForIncrementalGC() { purge(); - for (auto i : AllAllocKinds()) + for (auto i : AllAllocKinds()) { arenaLists[i].moveCursorToEnd(); + } } /* Compacting GC */ @@ -3577,7 +3578,7 @@ ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason) if (reason != JS::gcreason::COMPARTMENT_REVIVED) return zone->isGCScheduled(); - // If we are repeating a GC becuase we noticed dead compartments haven't + // If we are repeating a GC because we noticed dead compartments haven't // been collected, then only collect zones containing those compartments. for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { if (comp->scheduledForDestruction) diff --git a/js/src/jsgc.h b/js/src/jsgc.h index d00d2aef6b..952fd6bae5 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -456,8 +456,9 @@ class ArenaList { } void moveCursorToEnd() { - while (!isCursorAtEnd()) + while (!isCursorAtEnd()) { cursorp_ = &(*cursorp_)->next; + } } // This can return nullptr. From 87dabd668201458bd1fda84ac921cabb43788974 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 2 May 2019 02:55:53 +0200 Subject: [PATCH 22/25] Restore BROWSER_NEW_TAB_URL check in Basilisk. This resolves #1066 --- application/basilisk/base/content/utilityOverlay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/basilisk/base/content/utilityOverlay.js b/application/basilisk/base/content/utilityOverlay.js index f3ebf3b7eb..12a631d0f0 100644 --- a/application/basilisk/base/content/utilityOverlay.js +++ b/application/basilisk/base/content/utilityOverlay.js @@ -34,7 +34,7 @@ var gBidiUI = false; * Determines whether the given url is considered a special URL for new tabs. */ function isBlankPageURL(aURL) { - return aURL == "about:blank" || aURL == "about:newtab" || aURL == "about:logopage"; + return aURL == "about:blank" || aURL == BROWSER_NEW_TAB_URL || aURL == "about:logopage"; } function getBrowserURL() From aaa28cd3d5e482c1c7f4989ecc23fcf5d4e5ff52 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Thu, 2 May 2019 16:47:23 +0300 Subject: [PATCH 23/25] patch to Bug 1363423 --- layout/base/FrameLayerBuilder.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 1832854398..b315c348ac 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -3648,6 +3648,10 @@ PaintedLayerData::AccumulateEventRegions(ContainerState* aState, nsDisplayLayerE if (alreadyHadRegions) { mDispatchToContentHitRegion.OrWith(CombinedTouchActionRegion()); } + + // Avoid quadratic performance as a result of the region growing to include + // and arbitrarily large number of rects, which can happen on some pages. + mMaybeHitRegion.SimplifyOutward(8); // Calculate scaled versions of the bounds of mHitRegion and mMaybeHitRegion // for quick access in FindPaintedLayerFor(). @@ -6368,3 +6372,4 @@ ContainerState::CreateMaskLayer(Layer *aLayer, } } // namespace mozilla + From 314e75d5db7c9d699e459db4d0158358d1882aaa Mon Sep 17 00:00:00 2001 From: win7-7 Date: Thu, 2 May 2019 16:53:08 +0300 Subject: [PATCH 24/25] unnecessary space at the end removed --- layout/base/FrameLayerBuilder.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index b315c348ac..9aaa28fb55 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -6372,4 +6372,3 @@ ContainerState::CreateMaskLayer(Layer *aLayer, } } // namespace mozilla - From ab7ff906f2de006a67e1ec813e333de5958b509e Mon Sep 17 00:00:00 2001 From: win7-7 Date: Thu, 2 May 2019 16:51:25 +0300 Subject: [PATCH 25/25] patch to Bug 1377329 --- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsDisplayList.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index d619576baf..c830891a50 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1096,7 +1096,6 @@ void nsDisplayListBuilder::MarkFramesForDisplayList(nsIFrame* aDirtyFrame, const nsFrameList& aFrames, const nsRect& aDirtyRect) { - mFramesMarkedForDisplay.SetCapacity(mFramesMarkedForDisplay.Length() + aFrames.GetLength()); for (nsIFrame* e : aFrames) { // Skip the AccessibleCaret frame when building no caret. if (!IsBuildingCaret()) { @@ -1108,6 +1107,7 @@ nsDisplayListBuilder::MarkFramesForDisplayList(nsIFrame* aDirtyFrame, } } } + mFramesMarkedForDisplay.AppendElement(e); MarkOutOfFlowFrameForDisplay(aDirtyFrame, e, aDirtyRect); } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index c9f773f5b6..fcdc9e4fc0 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1200,7 +1200,7 @@ private: PLArenaPool mPool; nsCOMPtr mBoundingSelection; AutoTArray mPresShellStates; - AutoTArray mFramesMarkedForDisplay; + AutoTArray mFramesMarkedForDisplay; AutoTArray mThemeGeometries; nsDisplayTableItem* mCurrentTableItem; DisplayListClipState mClipState;