Tab to spaces newline and other such in js code

master
Fedor 2019-07-08 13:07:47 +03:00
parent ca72ef1006
commit 7a74bbaf96
11 changed files with 117 additions and 123 deletions

View File

@ -64,11 +64,11 @@ IdToObjectMap::find(ObjectId id)
JSObject* JSObject*
IdToObjectMap::findPreserveColor(ObjectId id) IdToObjectMap::findPreserveColor(ObjectId id)
{ {
Table::Ptr p = table_.lookup(id); Table::Ptr p = table_.lookup(id);
if (!p) if (!p)
return nullptr; return nullptr;
return p->value().unbarrieredGet(); return p->value().unbarrieredGet();
} }
bool bool
IdToObjectMap::add(ObjectId id, JSObject* obj) IdToObjectMap::add(ObjectId id, JSObject* obj)
@ -766,4 +766,4 @@ CPOWManager*
mozilla::jsipc::CPOWManagerFor(PJavaScriptChild* aChild) mozilla::jsipc::CPOWManagerFor(PJavaScriptChild* aChild)
{ {
return static_cast<JavaScriptChild*>(aChild); return static_cast<JavaScriptChild*>(aChild);
} }

View File

@ -96,7 +96,7 @@ class IdToObjectMap
bool add(ObjectId id, JSObject* obj); bool add(ObjectId id, JSObject* obj);
JSObject* find(ObjectId id); JSObject* find(ObjectId id);
JSObject* findPreserveColor(ObjectId id); JSObject* findPreserveColor(ObjectId id);
void remove(ObjectId id); void remove(ObjectId id);
void clear(); void clear();
@ -234,4 +234,4 @@ class JavaScriptShared : public CPOWManager
} // namespace jsipc } // namespace jsipc
} // namespace mozilla } // namespace mozilla
#endif #endif

View File

@ -795,4 +795,4 @@ WrapperAnswer::RecvDropObject(const ObjectId& objId)
objects_.remove(objId); objects_.remove(objId);
} }
return true; return true;
} }

View File

@ -3003,4 +3003,4 @@ TypeDescr::finalize(FreeOp* fop, JSObject* obj)
TypeDescr& descr = obj->as<TypeDescr>(); TypeDescr& descr = obj->as<TypeDescr>();
if (descr.hasTraceList()) if (descr.hasTraceList())
js_free(const_cast<int32_t*>(descr.traceList())); js_free(const_cast<int32_t*>(descr.traceList()));
} }

View File

@ -901,7 +901,7 @@ class GCRuntime
void requestMajorGC(JS::gcreason::Reason reason); void requestMajorGC(JS::gcreason::Reason reason);
SliceBudget defaultBudget(JS::gcreason::Reason reason, int64_t millis); SliceBudget defaultBudget(JS::gcreason::Reason reason, int64_t millis);
void budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, void budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget,
AutoLockForExclusiveAccess& lock); AutoLockForExclusiveAccess& lock);
void resetIncrementalGC(AbortReason reason, AutoLockForExclusiveAccess& lock); void resetIncrementalGC(AbortReason reason, AutoLockForExclusiveAccess& lock);
// Assert if the system state is such that we should never // 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; void collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::Reason reason) JS_HAZ_GC_CALL;
MOZ_MUST_USE bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget, MOZ_MUST_USE bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget,
JS::gcreason::Reason reason); JS::gcreason::Reason reason);
bool shouldRepeatForDeadZone(JS::gcreason::Reason reason); bool shouldRepeatForDeadZone(JS::gcreason::Reason reason);
void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason, void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason,
AutoLockForExclusiveAccess& lock); AutoLockForExclusiveAccess& lock);
@ -1350,4 +1350,4 @@ class MOZ_RAII AutoMaybeStartBackgroundAllocation
} /* namespace js */ } /* namespace js */
#endif #endif

View File

@ -478,7 +478,7 @@ js::gc::GCRuntime::bufferGrayRoots()
for (GCZonesIter zone(rt); !zone.done(); zone.next()) for (GCZonesIter zone(rt); !zone.done(); zone.next())
MOZ_ASSERT(zone->gcGrayRoots.empty()); 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); BufferGrayRootsTracer grayBufferer(rt);
if (JSTraceDataOp op = grayRootTracer.op) if (JSTraceDataOp op = grayRootTracer.op)
@ -540,4 +540,4 @@ GCRuntime::resetBufferedGrayRoots() const
"Do not clear the gray buffers unless we are Failed or becoming Unused"); "Do not clear the gray buffers unless we are Failed or becoming Unused");
for (GCZonesIter zone(rt); !zone.done(); zone.next()) for (GCZonesIter zone(rt); !zone.done(); zone.next())
zone->gcGrayRoots.clearAndFree(); zone->gcGrayRoots.clearAndFree();
} }

View File

@ -373,18 +373,18 @@ Zone::fixupAfterMovingGC()
bool bool
Zone::addTypeDescrObject(JSContext* cx, HandleObject obj) Zone::addTypeDescrObject(JSContext* cx, HandleObject obj)
{ {
// Type descriptor objects are always tenured so we don't need post barriers // Type descriptor objects are always tenured so we don't need post barriers
// on the set. // on the set.
MOZ_ASSERT(!IsInsideNursery(obj)); MOZ_ASSERT(!IsInsideNursery(obj));
if (!typeDescrObjects.put(obj)) { if (!typeDescrObjects.put(obj)) {
ReportOutOfMemory(cx); ReportOutOfMemory(cx);
return false; return false;
} }
return true; return true;
} }
ZoneList::ZoneList() ZoneList::ZoneList()
: head(nullptr), tail(nullptr) : head(nullptr), tail(nullptr)
{} {}
@ -483,4 +483,4 @@ JS_PUBLIC_API(void)
JS::shadow::RegisterWeakCache(JS::Zone* zone, WeakCache<void*>* cachep) JS::shadow::RegisterWeakCache(JS::Zone* zone, WeakCache<void*>* cachep)
{ {
zone->registerWeakCache(cachep); zone->registerWeakCache(cachep);
} }

View File

@ -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 // This is used by the GC to trace them all first when compacting, since the
// TypedObject trace hook may access these objects. // TypedObject trace hook may access these objects.
// //
// There are no barriers here - the set contains only tenured objects so no // 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 // post-barrier is required, and these are weak references so no pre-barrier
// is required. // is required.
using TypeDescrObjectSet = js::GCHashSet<JSObject*, using TypeDescrObjectSet = js::GCHashSet<JSObject*,
js::MovableCellHasher<JSObject*>, js::MovableCellHasher<JSObject*>,
js::SystemAllocPolicy>; js::SystemAllocPolicy>;
JS::WeakCache<TypeDescrObjectSet> typeDescrObjects; JS::WeakCache<TypeDescrObjectSet> 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 // Malloc counter to measure memory pressure for GC scheduling. It runs from
@ -741,4 +741,4 @@ class ZoneAllocPolicy
} // namespace js } // namespace js
#endif // gc_Zone_h #endif // gc_Zone_h

View File

@ -1527,8 +1527,9 @@ inline void
ArenaLists::prepareForIncrementalGC() ArenaLists::prepareForIncrementalGC()
{ {
purge(); purge();
for (auto i : AllAllocKinds()) for (auto i : AllAllocKinds()) {
arenaLists[i].moveCursorToEnd(); arenaLists[i].moveCursorToEnd();
}
} }
/* Compacting GC */ /* Compacting GC */
@ -3573,18 +3574,18 @@ RelazifyFunctions(Zone* zone, AllocKind kind)
static bool static bool
ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason) ShouldCollectZone(Zone* zone, JS::gcreason::Reason reason)
{ {
// Normally we collect all scheduled zones. // Normally we collect all scheduled zones.
if (reason != JS::gcreason::COMPARTMENT_REVIVED) if (reason != JS::gcreason::COMPARTMENT_REVIVED)
return zone->isGCScheduled(); 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 contianing those compartments. // been collected, then only collect zones containing those compartments.
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) { for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) {
if (comp->scheduledForDestruction) if (comp->scheduledForDestruction)
return true; return true;
} }
return false; return false;
} }
bool bool
@ -3648,13 +3649,8 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces
* keepAtoms() will only change on the main thread, which we are currently * 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 * on. If the value of keepAtoms() changes between GC slices, then we'll
* cancel the incremental GC. See IsIncrementalGCSafe. * cancel the incremental GC. See IsIncrementalGCSafe.
*/ */
if (isFull && !rt->keepAtoms()) { if (isFull && !rt->keepAtoms()) {
Zone* atomsZone = rt->atomsCompartment(lock)->zone(); Zone* atomsZone = rt->atomsCompartment(lock)->zone();
if (atomsZone->isGCScheduled()) { if (atomsZone->isGCScheduled()) {
@ -3758,11 +3754,11 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAcces
gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS); gcstats::AutoPhase ap2(stats, gcstats::PHASE_MARK_ROOTS);
if (isIncremental) { if (isIncremental) {
bufferGrayRoots(); bufferGrayRoots();
markCompartments(); markCompartments();
} }
return true; return true;
} }
@ -3778,11 +3774,11 @@ GCRuntime::markCompartments()
* (1) the compartment has been entered (set in beginMarkPhase() above) * (1) the compartment has been entered (set in beginMarkPhase() above)
* (2) the compartment is not being collected (set in beginMarkPhase() * (2) the compartment is not being collected (set in beginMarkPhase()
* above) * above)
* (3) an object in the compartment was marked during root marking, either * (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 * as a black root or a gray root (set in RootMarking.cpp), or
* (4) the compartment has incoming cross-compartment edges from another * (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. * If the maybeAlive is false, then we set the scheduledForDestruction flag.
* At the end of the GC, we look for compartments where * At the end of the GC, we look for compartments where
* scheduledForDestruction is true. These are compartments that were somehow * scheduledForDestruction is true. These are compartments that were somehow
@ -3802,35 +3798,35 @@ GCRuntime::markCompartments()
/* Propagate the maybeAlive flag via cross-compartment edges. */ /* Propagate the maybeAlive flag via cross-compartment edges. */
Vector<JSCompartment*, 0, js::SystemAllocPolicy> workList; Vector<JSCompartment*, 0, js::SystemAllocPolicy> workList;
for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) { for (CompartmentsIter comp(rt, SkipAtoms); !comp.done(); comp.next()) {
if (comp->maybeAlive) { if (comp->maybeAlive) {
if (!workList.append(comp)) if (!workList.append(comp))
return; return;
} }
} }
while (!workList.empty()) { while (!workList.empty()) {
JSCompartment* comp = workList.popCopy(); JSCompartment* comp = workList.popCopy();
for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) { for (JSCompartment::WrapperEnum e(comp); !e.empty(); e.popFront()) {
if (e.front().key().is<JSString*>()) if (e.front().key().is<JSString*>())
continue; continue;
JSCompartment* dest = e.front().mutableKey().compartment(); JSCompartment* dest = e.front().mutableKey().compartment();
if (dest && !dest->maybeAlive) { if (dest && !dest->maybeAlive) {
dest->maybeAlive = true; dest->maybeAlive = true;
if (!workList.append(dest)) if (!workList.append(dest))
return; return;
} }
} }
} }
/* Set scheduleForDestruction based on maybeAlive. */ /* Set scheduleForDestruction based on maybeAlive. */
for (GCCompartmentsIter comp(rt); !comp.done(); comp.next()) { for (GCCompartmentsIter comp(rt); !comp.done(); comp.next()) {
MOZ_ASSERT(!comp->scheduledForDestruction); MOZ_ASSERT(!comp->scheduledForDestruction);
if (!comp->maybeAlive && !rt->isAtomsCompartment(comp)) if (!comp->maybeAlive && !rt->isAtomsCompartment(comp))
comp->scheduledForDestruction = true; comp->scheduledForDestruction = true;
} }
} }
@ -5513,8 +5509,8 @@ gc::IsIncrementalGCUnsafe(JSRuntime* rt)
{ {
MOZ_ASSERT(!rt->mainThread.suppressGC); MOZ_ASSERT(!rt->mainThread.suppressGC);
if (rt->keepAtoms()) if (rt->keepAtoms())
return gc::AbortReason::KeepAtomsSet; return gc::AbortReason::KeepAtomsSet;
if (!rt->gc.isIncrementalGCAllowed()) if (!rt->gc.isIncrementalGCAllowed())
return gc::AbortReason::IncrementalDisabled; return gc::AbortReason::IncrementalDisabled;
@ -5524,15 +5520,15 @@ gc::IsIncrementalGCUnsafe(JSRuntime* rt)
void void
GCRuntime::budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget, GCRuntime::budgetIncrementalGC(JS::gcreason::Reason reason, SliceBudget& budget,
AutoLockForExclusiveAccess& lock) AutoLockForExclusiveAccess& lock)
{ {
AbortReason unsafeReason = IsIncrementalGCUnsafe(rt); AbortReason unsafeReason = IsIncrementalGCUnsafe(rt);
if (unsafeReason == AbortReason::None) { if (unsafeReason == AbortReason::None) {
if (reason == JS::gcreason::COMPARTMENT_REVIVED) if (reason == JS::gcreason::COMPARTMENT_REVIVED)
unsafeReason = gc::AbortReason::CompartmentRevived; unsafeReason = gc::AbortReason::CompartmentRevived;
else if (mode != JSGC_MODE_INCREMENTAL) else if (mode != JSGC_MODE_INCREMENTAL)
unsafeReason = gc::AbortReason::ModeChange; unsafeReason = gc::AbortReason::ModeChange;
} }
if (unsafeReason != AbortReason::None) { if (unsafeReason != AbortReason::None) {
resetIncrementalGC(unsafeReason, lock); resetIncrementalGC(unsafeReason, lock);
@ -5688,10 +5684,6 @@ GCRuntime::gcCycle(bool nonincrementalByAPI, SliceBudget& budget, JS::gcreason::
} }
State prevState = incrementalState; State prevState = incrementalState;
if (nonincrementalByAPI) { if (nonincrementalByAPI) {
// Reset any in progress incremental GC if this was triggered via the // Reset any in progress incremental GC if this was triggered via the
@ -5799,17 +5791,17 @@ GCRuntime::checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason)
bool bool
GCRuntime::shouldRepeatForDeadZone(JS::gcreason::Reason reason) GCRuntime::shouldRepeatForDeadZone(JS::gcreason::Reason reason)
{ {
MOZ_ASSERT_IF(reason == JS::gcreason::COMPARTMENT_REVIVED, !isIncremental); MOZ_ASSERT_IF(reason == JS::gcreason::COMPARTMENT_REVIVED, !isIncremental);
if (!isIncremental || isIncrementalGCInProgress()) if (!isIncremental || isIncrementalGCInProgress())
return false; return false;
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) { for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
if (c->scheduledForDestruction) if (c->scheduledForDestruction)
return true; return true;
} }
return false; return false;
} }
void void
@ -5831,21 +5823,21 @@ GCRuntime::collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::R
poked = false; poked = false;
bool wasReset = gcCycle(nonincrementalByAPI, budget, reason); bool wasReset = gcCycle(nonincrementalByAPI, budget, reason);
bool repeatForDeadZone = false; bool repeatForDeadZone = false;
if (poked && cleanUpEverything) { if (poked && cleanUpEverything) {
/* Need to re-schedule all zones for GC. */ /* Need to re-schedule all zones for GC. */
JS::PrepareForFullGC(rt->contextFromMainThread()); JS::PrepareForFullGC(rt->contextFromMainThread());
} else if (shouldRepeatForDeadZone(reason) && !wasReset) { } else if (shouldRepeatForDeadZone(reason) && !wasReset) {
/* /*
* This code makes an extra effort to collect compartments that we * This code makes an extra effort to collect compartments that we
* thought were dead at the start of the GC. See the large comment * thought were dead at the start of the GC. See the large comment
* in beginMarkPhase. * in beginMarkPhase.
*/ */
repeatForDeadZone = true; repeatForDeadZone = true;
reason = JS::gcreason::COMPARTMENT_REVIVED; reason = JS::gcreason::COMPARTMENT_REVIVED;
} }
/* /*
@ -7114,4 +7106,4 @@ js::gc::detail::CellIsMarkedGrayIfKnown(const Cell* cell)
} }
return detail::CellIsMarkedGray(tc); return detail::CellIsMarkedGray(tc);
} }

View File

@ -62,7 +62,7 @@ enum class State {
D(MallocBytesTrigger) \ D(MallocBytesTrigger) \
D(GCBytesTrigger) \ D(GCBytesTrigger) \
D(ZoneChange) \ D(ZoneChange) \
D(CompartmentRevived) D(CompartmentRevived)
enum class AbortReason { enum class AbortReason {
#define MAKE_REASON(name) name, #define MAKE_REASON(name) name,
GC_ABORT_REASONS(MAKE_REASON) GC_ABORT_REASONS(MAKE_REASON)
@ -354,6 +354,7 @@ struct SortedArenaListSegment
* be treated as an invariant, however, as the free lists may be cleared, * be treated as an invariant, however, as the free lists may be cleared,
* leaving arenas previously used for allocation partially full. Sorting order * leaving arenas previously used for allocation partially full. Sorting order
* is restored during sweeping. * is restored during sweeping.
* Arenas following the cursor should not be full. * Arenas following the cursor should not be full.
*/ */
class ArenaList { class ArenaList {
@ -454,10 +455,11 @@ class ArenaList {
return !*cursorp_; return !*cursorp_;
} }
void moveCursorToEnd() { void moveCursorToEnd() {
while (!isCursorAtEnd()) while (!isCursorAtEnd()) {
cursorp_ = &(*cursorp_)->next; cursorp_ = &(*cursorp_)->next;
} }
}
// This can return nullptr. // This can return nullptr.
Arena* arenaAfterCursor() const { Arena* arenaAfterCursor() const {
@ -1509,4 +1511,4 @@ UninlinedIsInsideNursery(const gc::Cell* cell);
} /* namespace js */ } /* namespace js */
#endif /* jsgc_h */ #endif /* jsgc_h */

View File

@ -187,8 +187,8 @@ WatchpointMap::markAll(JSTracer* trc)
Map::Entry& entry = e.front(); Map::Entry& entry = e.front();
JSObject* object = entry.key().object; JSObject* object = entry.key().object;
jsid id = entry.key().id; jsid id = entry.key().id;
JSObject* priorObject = object; JSObject* priorObject = object;
jsid priorId = id; jsid priorId = id;
MOZ_ASSERT(JSID_IS_STRING(priorId) || JSID_IS_INT(priorId) || JSID_IS_SYMBOL(priorId)); MOZ_ASSERT(JSID_IS_STRING(priorId) || JSID_IS_INT(priorId) || JSID_IS_SYMBOL(priorId));
TraceManuallyBarrieredEdge(trc, &object, "held Watchpoint object"); TraceManuallyBarrieredEdge(trc, &object, "held Watchpoint object");
@ -243,4 +243,4 @@ WatchpointMap::trace(WeakMapTracer* trc)
JS::GCCellPtr(entry.key().object.get()), JS::GCCellPtr(entry.key().object.get()),
JS::GCCellPtr(entry.value().closure.get())); JS::GCCellPtr(entry.value().closure.get()));
} }
} }