зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1139552 - Convert js::gc::AllocKind to an enum class and eliminate non-AllocKind indexing. r=terrence
This commit is contained in:
Родитель
d36e9cdd88
Коммит
b84e0849ec
|
@ -1487,7 +1487,8 @@ OutlineTypedObject::createUnattachedWithClass(JSContext *cx,
|
||||||
|
|
||||||
NewObjectKind newKind = (heap == gc::TenuredHeap) ? MaybeSingletonObject : GenericObject;
|
NewObjectKind newKind = (heap == gc::TenuredHeap) ? MaybeSingletonObject : GenericObject;
|
||||||
OutlineTypedObject *obj = NewObjectWithGroup<OutlineTypedObject>(cx, group, cx->global(),
|
OutlineTypedObject *obj = NewObjectWithGroup<OutlineTypedObject>(cx, group, cx->global(),
|
||||||
gc::FINALIZE_OBJECT0, newKind);
|
gc::AllocKind::OBJECT0,
|
||||||
|
newKind);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -108,10 +108,10 @@ CheckAllocatorState(ExclusiveContext *cx, AllocKind kind)
|
||||||
JSRuntime *rt = ncx->runtime();
|
JSRuntime *rt = ncx->runtime();
|
||||||
#if defined(JS_GC_ZEAL) || defined(DEBUG)
|
#if defined(JS_GC_ZEAL) || defined(DEBUG)
|
||||||
MOZ_ASSERT_IF(rt->isAtomsCompartment(ncx->compartment()),
|
MOZ_ASSERT_IF(rt->isAtomsCompartment(ncx->compartment()),
|
||||||
kind == FINALIZE_STRING ||
|
kind == AllocKind::STRING ||
|
||||||
kind == FINALIZE_FAT_INLINE_STRING ||
|
kind == AllocKind::FAT_INLINE_STRING ||
|
||||||
kind == FINALIZE_SYMBOL ||
|
kind == AllocKind::SYMBOL ||
|
||||||
kind == FINALIZE_JITCODE);
|
kind == AllocKind::JITCODE);
|
||||||
MOZ_ASSERT(!rt->isHeapBusy());
|
MOZ_ASSERT(!rt->isHeapBusy());
|
||||||
MOZ_ASSERT(rt->gc.isAllocAllowed());
|
MOZ_ASSERT(rt->gc.isAllocAllowed());
|
||||||
#endif
|
#endif
|
||||||
|
@ -156,7 +156,7 @@ js::Allocate(ExclusiveContext *cx, AllocKind kind, size_t nDynamicSlots, Initial
|
||||||
const Class *clasp)
|
const Class *clasp)
|
||||||
{
|
{
|
||||||
static_assert(mozilla::IsConvertible<T *, JSObject *>::value, "must be JSObject derived");
|
static_assert(mozilla::IsConvertible<T *, JSObject *>::value, "must be JSObject derived");
|
||||||
MOZ_ASSERT(kind >= FINALIZE_OBJECT0 && kind <= FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(kind <= AllocKind::OBJECT_LAST);
|
||||||
size_t thingSize = Arena::thingSize(kind);
|
size_t thingSize = Arena::thingSize(kind);
|
||||||
|
|
||||||
MOZ_ASSERT(thingSize == Arena::thingSize(kind));
|
MOZ_ASSERT(thingSize == Arena::thingSize(kind));
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
using namespace js;
|
using namespace js;
|
||||||
using namespace js::gc;
|
using namespace js::gc;
|
||||||
|
|
||||||
JS_STATIC_ASSERT(AllocKinds == FINALIZE_LIMIT);
|
JS_STATIC_ASSERT(AllocKinds == unsigned(AllocKind::LIMIT));
|
||||||
JS_STATIC_ASSERT(LastObjectAllocKind == FINALIZE_OBJECT_LAST);
|
JS_STATIC_ASSERT(LastObjectAllocKind == unsigned(AllocKind::OBJECT_LAST));
|
||||||
|
|
||||||
static FILE *gcTraceFile = nullptr;
|
static FILE *gcTraceFile = nullptr;
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ js::gc::InitTrace(GCRuntime &gc)
|
||||||
TraceEvent(TraceEventInit, 0, TraceFormatVersion);
|
TraceEvent(TraceEventInit, 0, TraceFormatVersion);
|
||||||
|
|
||||||
/* Trace information about thing sizes. */
|
/* Trace information about thing sizes. */
|
||||||
for (unsigned kind = 0; kind < FINALIZE_LIMIT; ++kind)
|
for (ALL_ALLOC_KINDS(kind))
|
||||||
TraceEvent(TraceEventThingSize, Arena::thingSize((AllocKind)kind));
|
TraceEvent(TraceEventThingSize, Arena::thingSize(kind));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ js::gc::TraceTenuredFinalize(Cell *thing)
|
||||||
{
|
{
|
||||||
if (!gcTraceFile)
|
if (!gcTraceFile)
|
||||||
return;
|
return;
|
||||||
if (thing->tenuredGetAllocKind() == FINALIZE_OBJECT_GROUP)
|
if (thing->tenuredGetAllocKind() == AllocKind::OBJECT_GROUP)
|
||||||
tracedGroups.remove(static_cast<const ObjectGroup *>(thing));
|
tracedGroups.remove(static_cast<const ObjectGroup *>(thing));
|
||||||
TraceEvent(TraceEventTenuredFinalize, uint64_t(thing));
|
TraceEvent(TraceEventTenuredFinalize, uint64_t(thing));
|
||||||
}
|
}
|
||||||
|
|
140
js/src/gc/Heap.h
140
js/src/gc/Heap.h
|
@ -10,6 +10,7 @@
|
||||||
#include "mozilla/ArrayUtils.h"
|
#include "mozilla/ArrayUtils.h"
|
||||||
#include "mozilla/Atomics.h"
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/EnumeratedArray.h"
|
||||||
#include "mozilla/PodOperations.h"
|
#include "mozilla/PodOperations.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -75,76 +76,92 @@ enum InitialHeap {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The GC allocation kinds. */
|
/* The GC allocation kinds. */
|
||||||
enum AllocKind {
|
enum class AllocKind : uint8_t {
|
||||||
FINALIZE_OBJECT0,
|
FIRST,
|
||||||
FINALIZE_OBJECT0_BACKGROUND,
|
OBJECT0 = FIRST,
|
||||||
FINALIZE_OBJECT2,
|
OBJECT0_BACKGROUND,
|
||||||
FINALIZE_OBJECT2_BACKGROUND,
|
OBJECT2,
|
||||||
FINALIZE_OBJECT4,
|
OBJECT2_BACKGROUND,
|
||||||
FINALIZE_OBJECT4_BACKGROUND,
|
OBJECT4,
|
||||||
FINALIZE_OBJECT8,
|
OBJECT4_BACKGROUND,
|
||||||
FINALIZE_OBJECT8_BACKGROUND,
|
OBJECT8,
|
||||||
FINALIZE_OBJECT12,
|
OBJECT8_BACKGROUND,
|
||||||
FINALIZE_OBJECT12_BACKGROUND,
|
OBJECT12,
|
||||||
FINALIZE_OBJECT16,
|
OBJECT12_BACKGROUND,
|
||||||
FINALIZE_OBJECT16_BACKGROUND,
|
OBJECT16,
|
||||||
FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16_BACKGROUND,
|
OBJECT16_BACKGROUND,
|
||||||
FINALIZE_SCRIPT,
|
OBJECT_LIMIT,
|
||||||
FINALIZE_LAZY_SCRIPT,
|
OBJECT_LAST = OBJECT_LIMIT - 1,
|
||||||
FINALIZE_SHAPE,
|
SCRIPT,
|
||||||
FINALIZE_ACCESSOR_SHAPE,
|
LAZY_SCRIPT,
|
||||||
FINALIZE_BASE_SHAPE,
|
SHAPE,
|
||||||
FINALIZE_OBJECT_GROUP,
|
ACCESSOR_SHAPE,
|
||||||
FINALIZE_FAT_INLINE_STRING,
|
BASE_SHAPE,
|
||||||
FINALIZE_STRING,
|
OBJECT_GROUP,
|
||||||
FINALIZE_EXTERNAL_STRING,
|
FAT_INLINE_STRING,
|
||||||
FINALIZE_SYMBOL,
|
STRING,
|
||||||
FINALIZE_JITCODE,
|
EXTERNAL_STRING,
|
||||||
FINALIZE_LAST = FINALIZE_JITCODE
|
SYMBOL,
|
||||||
|
JITCODE,
|
||||||
|
LIMIT,
|
||||||
|
LAST = LIMIT - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned FINALIZE_LIMIT = FINALIZE_LAST + 1;
|
static_assert(uint8_t(AllocKind::OBJECT0) == 0, "Please check AllocKind iterations and comparisons"
|
||||||
static const unsigned FINALIZE_OBJECT_LIMIT = FINALIZE_OBJECT_LAST + 1;
|
" of the form |kind <= AllocKind::OBJECT_LAST| to ensure their range is still valid!");
|
||||||
|
|
||||||
|
#define ALL_ALLOC_KINDS(i) AllocKind i = AllocKind::FIRST;\
|
||||||
|
i < AllocKind::LIMIT; i = AllocKind(uint8_t(i) + 1)
|
||||||
|
|
||||||
|
#define OBJECT_ALLOC_KINDS(i) AllocKind i = AllocKind::OBJECT0;\
|
||||||
|
i < AllocKind::OBJECT_LIMIT; i = AllocKind(uint8_t(i) + 1)
|
||||||
|
|
||||||
|
template<typename ValueType> using AllAllocKindArray =
|
||||||
|
mozilla::EnumeratedArray<AllocKind, AllocKind::LIMIT, ValueType>;
|
||||||
|
|
||||||
|
template<typename ValueType> using ObjectAllocKindArray =
|
||||||
|
mozilla::EnumeratedArray<AllocKind, AllocKind::OBJECT_LIMIT, ValueType>;
|
||||||
|
|
||||||
static inline JSGCTraceKind
|
static inline JSGCTraceKind
|
||||||
MapAllocToTraceKind(AllocKind kind)
|
MapAllocToTraceKind(AllocKind kind)
|
||||||
{
|
{
|
||||||
static const JSGCTraceKind map[] = {
|
static const JSGCTraceKind map[] = {
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT0 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT0 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT0_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT0_BACKGROUND */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT2 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT2 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT2_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT2_BACKGROUND */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT4 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT4 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT4_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT4_BACKGROUND */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT8 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT8 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT8_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT8_BACKGROUND */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT12 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT12 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT12_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT12_BACKGROUND */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT16 */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT16 */
|
||||||
JSTRACE_OBJECT, /* FINALIZE_OBJECT16_BACKGROUND */
|
JSTRACE_OBJECT, /* AllocKind::OBJECT16_BACKGROUND */
|
||||||
JSTRACE_SCRIPT, /* FINALIZE_SCRIPT */
|
JSTRACE_SCRIPT, /* AllocKind::SCRIPT */
|
||||||
JSTRACE_LAZY_SCRIPT, /* FINALIZE_LAZY_SCRIPT */
|
JSTRACE_LAZY_SCRIPT, /* AllocKind::LAZY_SCRIPT */
|
||||||
JSTRACE_SHAPE, /* FINALIZE_SHAPE */
|
JSTRACE_SHAPE, /* AllocKind::SHAPE */
|
||||||
JSTRACE_SHAPE, /* FINALIZE_ACCESSOR_SHAPE */
|
JSTRACE_SHAPE, /* AllocKind::ACCESSOR_SHAPE */
|
||||||
JSTRACE_BASE_SHAPE, /* FINALIZE_BASE_SHAPE */
|
JSTRACE_BASE_SHAPE, /* AllocKind::BASE_SHAPE */
|
||||||
JSTRACE_OBJECT_GROUP, /* FINALIZE_OBJECT_GROUP */
|
JSTRACE_OBJECT_GROUP, /* AllocKind::OBJECT_GROUP */
|
||||||
JSTRACE_STRING, /* FINALIZE_FAT_INLINE_STRING */
|
JSTRACE_STRING, /* AllocKind::FAT_INLINE_STRING */
|
||||||
JSTRACE_STRING, /* FINALIZE_STRING */
|
JSTRACE_STRING, /* AllocKind::STRING */
|
||||||
JSTRACE_STRING, /* FINALIZE_EXTERNAL_STRING */
|
JSTRACE_STRING, /* AllocKind::EXTERNAL_STRING */
|
||||||
JSTRACE_SYMBOL, /* FINALIZE_SYMBOL */
|
JSTRACE_SYMBOL, /* AllocKind::SYMBOL */
|
||||||
JSTRACE_JITCODE, /* FINALIZE_JITCODE */
|
JSTRACE_JITCODE, /* AllocKind::JITCODE */
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(MOZ_ARRAY_LENGTH(map) == FINALIZE_LIMIT,
|
static_assert(MOZ_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT),
|
||||||
"AllocKind-to-TraceKind mapping must be in sync");
|
"AllocKind-to-TraceKind mapping must be in sync");
|
||||||
return map[kind];
|
return map[size_t(kind)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This must be an upper bound, but we do not need the least upper bound, so
|
* This must be an upper bound, but we do not need the least upper bound, so
|
||||||
* we just exclude non-background objects.
|
* we just exclude non-background objects.
|
||||||
*/
|
*/
|
||||||
static const size_t MAX_BACKGROUND_FINALIZE_KINDS = FINALIZE_LIMIT - FINALIZE_OBJECT_LIMIT / 2;
|
static const size_t MAX_BACKGROUND_FINALIZE_KINDS =
|
||||||
|
size_t(AllocKind::LIMIT) - size_t(AllocKind::OBJECT_LIMIT) / 2;
|
||||||
|
|
||||||
class TenuredCell;
|
class TenuredCell;
|
||||||
|
|
||||||
|
@ -526,7 +543,7 @@ struct ArenaHeader
|
||||||
CompactFreeSpan firstFreeSpan;
|
CompactFreeSpan firstFreeSpan;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* One of AllocKind constants or FINALIZE_LIMIT when the arena does not
|
* One of AllocKind constants or AllocKind::LIMIT when the arena does not
|
||||||
* contain any GC things and is on the list of empty arenas in the GC
|
* contain any GC things and is on the list of empty arenas in the GC
|
||||||
* chunk.
|
* chunk.
|
||||||
*
|
*
|
||||||
|
@ -571,8 +588,8 @@ struct ArenaHeader
|
||||||
inline Chunk *chunk() const;
|
inline Chunk *chunk() const;
|
||||||
|
|
||||||
bool allocated() const {
|
bool allocated() const {
|
||||||
MOZ_ASSERT(allocKind <= size_t(FINALIZE_LIMIT));
|
MOZ_ASSERT(allocKind <= size_t(AllocKind::LIMIT));
|
||||||
return allocKind < size_t(FINALIZE_LIMIT);
|
return allocKind < size_t(AllocKind::LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(JS::Zone *zoneArg, AllocKind kind) {
|
void init(JS::Zone *zoneArg, AllocKind kind) {
|
||||||
|
@ -582,7 +599,8 @@ struct ArenaHeader
|
||||||
MOZ_ASSERT(!hasDelayedMarking);
|
MOZ_ASSERT(!hasDelayedMarking);
|
||||||
zone = zoneArg;
|
zone = zoneArg;
|
||||||
|
|
||||||
static_assert(FINALIZE_LIMIT <= 255, "We must be able to fit the allockind into uint8_t.");
|
static_assert(size_t(AllocKind::LIMIT) <= 255,
|
||||||
|
"We must be able to fit the allockind into uint8_t.");
|
||||||
allocKind = size_t(kind);
|
allocKind = size_t(kind);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -593,7 +611,7 @@ struct ArenaHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsNotAllocated() {
|
void setAsNotAllocated() {
|
||||||
allocKind = size_t(FINALIZE_LIMIT);
|
allocKind = size_t(AllocKind::LIMIT);
|
||||||
markOverflow = 0;
|
markOverflow = 0;
|
||||||
allocatedDuringIncremental = 0;
|
allocatedDuringIncremental = 0;
|
||||||
hasDelayedMarking = 0;
|
hasDelayedMarking = 0;
|
||||||
|
@ -673,11 +691,11 @@ struct Arena
|
||||||
static void staticAsserts();
|
static void staticAsserts();
|
||||||
|
|
||||||
static size_t thingSize(AllocKind kind) {
|
static size_t thingSize(AllocKind kind) {
|
||||||
return ThingSizes[kind];
|
return ThingSizes[size_t(kind)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t firstThingOffset(AllocKind kind) {
|
static size_t firstThingOffset(AllocKind kind) {
|
||||||
return FirstThingOffsets[kind];
|
return FirstThingOffsets[size_t(kind)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t thingsPerArena(size_t thingSize) {
|
static size_t thingsPerArena(size_t thingSize) {
|
||||||
|
|
|
@ -38,11 +38,11 @@ IterateCompartmentsArenasCells(JSRuntime *rt, Zone *zone, void *data,
|
||||||
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
|
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
|
||||||
(*compartmentCallback)(rt, data, comp);
|
(*compartmentCallback)(rt, data, comp);
|
||||||
|
|
||||||
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
|
for (ALL_ALLOC_KINDS(thingKind)) {
|
||||||
JSGCTraceKind traceKind = MapAllocToTraceKind(AllocKind(thingKind));
|
JSGCTraceKind traceKind = MapAllocToTraceKind(thingKind);
|
||||||
size_t thingSize = Arena::thingSize(AllocKind(thingKind));
|
size_t thingSize = Arena::thingSize(thingKind);
|
||||||
|
|
||||||
for (ArenaIter aiter(zone, AllocKind(thingKind)); !aiter.done(); aiter.next()) {
|
for (ArenaIter aiter(zone, thingKind); !aiter.done(); aiter.next()) {
|
||||||
ArenaHeader *aheader = aiter.get();
|
ArenaHeader *aheader = aiter.get();
|
||||||
(*arenaCallback)(rt, data, aheader->getArena(), traceKind, thingSize);
|
(*arenaCallback)(rt, data, aheader->getArena(), traceKind, thingSize);
|
||||||
for (ArenaCellIterUnderGC iter(aheader); !iter.done(); iter.next())
|
for (ArenaCellIterUnderGC iter(aheader); !iter.done(); iter.next())
|
||||||
|
@ -98,14 +98,14 @@ js::IterateScripts(JSRuntime *rt, JSCompartment *compartment,
|
||||||
AutoPrepareForTracing prep(rt, SkipAtoms);
|
AutoPrepareForTracing prep(rt, SkipAtoms);
|
||||||
|
|
||||||
if (compartment) {
|
if (compartment) {
|
||||||
for (ZoneCellIterUnderGC i(compartment->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(compartment->zone(), gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (script->compartment() == compartment)
|
if (script->compartment() == compartment)
|
||||||
scriptCallback(rt, data, script);
|
scriptCallback(rt, data, script);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
for (ZoneCellIterUnderGC i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next())
|
for (ZoneCellIterUnderGC i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next())
|
||||||
scriptCallback(rt, data, i.get<JSScript>());
|
scriptCallback(rt, data, i.get<JSScript>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,8 @@ js::IterateGrayObjects(Zone *zone, GCThingCallback cellCallback, void *data)
|
||||||
zone->runtimeFromMainThread()->gc.evictNursery();
|
zone->runtimeFromMainThread()->gc.evictNursery();
|
||||||
AutoPrepareForTracing prep(zone->runtimeFromMainThread(), SkipAtoms);
|
AutoPrepareForTracing prep(zone->runtimeFromMainThread(), SkipAtoms);
|
||||||
|
|
||||||
for (size_t finalizeKind = 0; finalizeKind <= FINALIZE_OBJECT_LAST; finalizeKind++) {
|
for (OBJECT_ALLOC_KINDS(thingKind)) {
|
||||||
for (ZoneCellIterUnderGC i(zone, AllocKind(finalizeKind)); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, thingKind); !i.done(); i.next()) {
|
||||||
JSObject *obj = i.get<JSObject>();
|
JSObject *obj = i.get<JSObject>();
|
||||||
if (obj->asTenured().isMarked(GRAY))
|
if (obj->asTenured().isMarked(GRAY))
|
||||||
cellCallback(data, JS::GCCellPtr(obj));
|
cellCallback(data, JS::GCCellPtr(obj));
|
||||||
|
|
|
@ -419,7 +419,7 @@ GetObjectAllocKindForCopy(const Nursery &nursery, JSObject *obj)
|
||||||
|
|
||||||
/* Use minimal size object if we are just going to copy the pointer. */
|
/* Use minimal size object if we are just going to copy the pointer. */
|
||||||
if (!nursery.isInside(aobj->getElementsHeader()))
|
if (!nursery.isInside(aobj->getElementsHeader()))
|
||||||
return FINALIZE_OBJECT0_BACKGROUND;
|
return AllocKind::OBJECT0_BACKGROUND;
|
||||||
|
|
||||||
size_t nelements = aobj->getDenseCapacity();
|
size_t nelements = aobj->getDenseCapacity();
|
||||||
return GetBackgroundAllocKind(GetGCArrayKind(nelements));
|
return GetBackgroundAllocKind(GetGCArrayKind(nelements));
|
||||||
|
@ -459,7 +459,7 @@ GetObjectAllocKindForCopy(const Nursery &nursery, JSObject *obj)
|
||||||
|
|
||||||
// Outline typed objects use the minimum allocation kind.
|
// Outline typed objects use the minimum allocation kind.
|
||||||
if (obj->is<OutlineTypedObject>())
|
if (obj->is<OutlineTypedObject>())
|
||||||
return FINALIZE_OBJECT0;
|
return AllocKind::OBJECT0;
|
||||||
|
|
||||||
// All nursery allocatable non-native objects are handled above.
|
// All nursery allocatable non-native objects are handled above.
|
||||||
MOZ_ASSERT(obj->isNative());
|
MOZ_ASSERT(obj->isNative());
|
||||||
|
|
|
@ -486,7 +486,7 @@ js::gc::GCRuntime::markRuntime(JSTracer *trc,
|
||||||
|
|
||||||
/* Do not discard scripts with counts while profiling. */
|
/* Do not discard scripts with counts while profiling. */
|
||||||
if (rt->profilingScripts && !isHeapMinorCollecting()) {
|
if (rt->profilingScripts && !isHeapMinorCollecting()) {
|
||||||
for (ZoneCellIterUnderGC i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (script->hasScriptCounts()) {
|
if (script->hasScriptCounts()) {
|
||||||
MarkScriptRoot(trc, &script, "profilingScripts");
|
MarkScriptRoot(trc, &script, "profilingScripts");
|
||||||
|
|
|
@ -501,10 +501,10 @@ js::gc::GCRuntime::endVerifyPostBarriers()
|
||||||
/* Walk the heap to find any edges not the the |edges| set. */
|
/* Walk the heap to find any edges not the the |edges| set. */
|
||||||
trc->setTraceCallback(PostVerifierVisitEdge);
|
trc->setTraceCallback(PostVerifierVisitEdge);
|
||||||
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
|
||||||
for (size_t kind = 0; kind < FINALIZE_LIMIT; ++kind) {
|
for (ALL_ALLOC_KINDS(kind)) {
|
||||||
for (ZoneCellIterUnderGC cells(zone, AllocKind(kind)); !cells.done(); cells.next()) {
|
for (ZoneCellIterUnderGC cells(zone, kind); !cells.done(); cells.next()) {
|
||||||
Cell *src = cells.getCell();
|
Cell *src = cells.getCell();
|
||||||
JS_TraceChildren(trc, src, MapAllocToTraceKind(AllocKind(kind)));
|
JS_TraceChildren(trc, src, MapAllocToTraceKind(kind));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ Zone::sweepBreakpoints(FreeOp *fop)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MOZ_ASSERT(isGCSweepingOrCompacting());
|
MOZ_ASSERT(isGCSweepingOrCompacting());
|
||||||
for (ZoneCellIterUnderGC i(this, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(this, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
MOZ_ASSERT_IF(isGCSweeping(), script->zone()->isGCSweeping());
|
MOZ_ASSERT_IF(isGCSweeping(), script->zone()->isGCSweeping());
|
||||||
if (!script->hasAnyBreakpointsOrStepMode())
|
if (!script->hasAnyBreakpointsOrStepMode())
|
||||||
|
@ -171,7 +171,7 @@ Zone::discardJitCode(FreeOp *fop)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* Assert no baseline scripts are marked as active. */
|
/* Assert no baseline scripts are marked as active. */
|
||||||
for (ZoneCellIterUnderGC i(this, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(this, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
MOZ_ASSERT_IF(script->hasBaselineScript(), !script->baselineScript()->active());
|
MOZ_ASSERT_IF(script->hasBaselineScript(), !script->baselineScript()->active());
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ Zone::discardJitCode(FreeOp *fop)
|
||||||
/* Only mark OSI points if code is being discarded. */
|
/* Only mark OSI points if code is being discarded. */
|
||||||
jit::InvalidateAll(fop, this);
|
jit::InvalidateAll(fop, this);
|
||||||
|
|
||||||
for (ZoneCellIterUnderGC i(this, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(this, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
jit::FinishInvalidation(fop, script);
|
jit::FinishInvalidation(fop, script);
|
||||||
|
|
||||||
|
|
|
@ -1076,7 +1076,7 @@ void
|
||||||
jit::ToggleBaselineProfiling(JSRuntime *runtime, bool enable)
|
jit::ToggleBaselineProfiling(JSRuntime *runtime, bool enable)
|
||||||
{
|
{
|
||||||
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (!script->hasBaselineScript())
|
if (!script->hasBaselineScript())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1090,7 +1090,7 @@ void
|
||||||
jit::ToggleBaselineTraceLoggerScripts(JSRuntime *runtime, bool enable)
|
jit::ToggleBaselineTraceLoggerScripts(JSRuntime *runtime, bool enable)
|
||||||
{
|
{
|
||||||
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (!script->hasBaselineScript())
|
if (!script->hasBaselineScript())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1103,7 +1103,7 @@ void
|
||||||
jit::ToggleBaselineTraceLoggerEngine(JSRuntime *runtime, bool enable)
|
jit::ToggleBaselineTraceLoggerEngine(JSRuntime *runtime, bool enable)
|
||||||
{
|
{
|
||||||
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(runtime, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (!script->hasBaselineScript())
|
if (!script->hasBaselineScript())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -4797,7 +4797,7 @@ CodeGenerator::visitCreateThisWithTemplate(LCreateThisWithTemplate *lir)
|
||||||
Register tempReg = ToRegister(lir->temp());
|
Register tempReg = ToRegister(lir->temp());
|
||||||
|
|
||||||
OutOfLineCode *ool = oolCallVM(NewGCObjectInfo, lir,
|
OutOfLineCode *ool = oolCallVM(NewGCObjectInfo, lir,
|
||||||
(ArgList(), Imm32(allocKind), Imm32(initialHeap),
|
(ArgList(), Imm32(int32_t(allocKind)), Imm32(initialHeap),
|
||||||
Imm32(ndynamic), ImmPtr(clasp)),
|
Imm32(ndynamic), ImmPtr(clasp)),
|
||||||
StoreRegisterTo(objReg));
|
StoreRegisterTo(objReg));
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ JitRuntime::Mark(JSTracer *trc)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!trc->runtime()->isHeapMinorCollecting());
|
MOZ_ASSERT(!trc->runtime()->isHeapMinorCollecting());
|
||||||
Zone *zone = trc->runtime()->atomsCompartment()->zone();
|
Zone *zone = trc->runtime()->atomsCompartment()->zone();
|
||||||
for (gc::ZoneCellIterUnderGC i(zone, gc::FINALIZE_JITCODE); !i.done(); i.next()) {
|
for (gc::ZoneCellIterUnderGC i(zone, gc::AllocKind::JITCODE); !i.done(); i.next()) {
|
||||||
JitCode *code = i.get<JitCode>();
|
JitCode *code = i.get<JitCode>();
|
||||||
MarkJitCodeRoot(trc, &code, "wrapper");
|
MarkJitCodeRoot(trc, &code, "wrapper");
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1136,7 @@ jit::ToggleBarriers(JS::Zone *zone, bool needs)
|
||||||
if (!rt->hasJitRuntime())
|
if (!rt->hasJitRuntime())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (gc::ZoneCellIterUnderGC i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIterUnderGC i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (script->hasIonScript())
|
if (script->hasIonScript())
|
||||||
script->ionScript()->toggleBarriers(needs);
|
script->ionScript()->toggleBarriers(needs);
|
||||||
|
|
|
@ -993,7 +993,7 @@ void
|
||||||
MacroAssembler::allocateObject(Register result, Register temp, gc::AllocKind allocKind,
|
MacroAssembler::allocateObject(Register result, Register temp, gc::AllocKind allocKind,
|
||||||
uint32_t nDynamicSlots, gc::InitialHeap initialHeap, Label *fail)
|
uint32_t nDynamicSlots, gc::InitialHeap initialHeap, Label *fail)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(allocKind >= gc::FINALIZE_OBJECT0 && allocKind <= gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
|
||||||
|
|
||||||
checkAllocatorState(fail);
|
checkAllocatorState(fail);
|
||||||
|
|
||||||
|
@ -1029,7 +1029,7 @@ MacroAssembler::newGCThing(Register result, Register temp, JSObject *templateObj
|
||||||
gc::InitialHeap initialHeap, Label *fail)
|
gc::InitialHeap initialHeap, Label *fail)
|
||||||
{
|
{
|
||||||
gc::AllocKind allocKind = templateObj->asTenured().getAllocKind();
|
gc::AllocKind allocKind = templateObj->asTenured().getAllocKind();
|
||||||
MOZ_ASSERT(allocKind >= gc::FINALIZE_OBJECT0 && allocKind <= gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
|
||||||
|
|
||||||
size_t ndynamic = 0;
|
size_t ndynamic = 0;
|
||||||
if (templateObj->isNative())
|
if (templateObj->isNative())
|
||||||
|
@ -1042,7 +1042,7 @@ MacroAssembler::createGCObject(Register obj, Register temp, JSObject *templateOb
|
||||||
gc::InitialHeap initialHeap, Label *fail, bool initContents)
|
gc::InitialHeap initialHeap, Label *fail, bool initContents)
|
||||||
{
|
{
|
||||||
gc::AllocKind allocKind = templateObj->asTenured().getAllocKind();
|
gc::AllocKind allocKind = templateObj->asTenured().getAllocKind();
|
||||||
MOZ_ASSERT(allocKind >= gc::FINALIZE_OBJECT0 && allocKind <= gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
|
||||||
|
|
||||||
uint32_t nDynamicSlots = 0;
|
uint32_t nDynamicSlots = 0;
|
||||||
if (templateObj->isNative()) {
|
if (templateObj->isNative()) {
|
||||||
|
@ -1052,7 +1052,7 @@ MacroAssembler::createGCObject(Register obj, Register temp, JSObject *templateOb
|
||||||
// elements header. The template object, which owns the original
|
// elements header. The template object, which owns the original
|
||||||
// elements, might have another allocation kind.
|
// elements, might have another allocation kind.
|
||||||
if (templateObj->as<NativeObject>().denseElementsAreCopyOnWrite())
|
if (templateObj->as<NativeObject>().denseElementsAreCopyOnWrite())
|
||||||
allocKind = gc::FINALIZE_OBJECT0_BACKGROUND;
|
allocKind = gc::AllocKind::OBJECT0_BACKGROUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocateObject(obj, temp, allocKind, nDynamicSlots, initialHeap, fail);
|
allocateObject(obj, temp, allocKind, nDynamicSlots, initialHeap, fail);
|
||||||
|
@ -1073,13 +1073,13 @@ MacroAssembler::allocateNonObject(Register result, Register temp, gc::AllocKind
|
||||||
void
|
void
|
||||||
MacroAssembler::newGCString(Register result, Register temp, Label *fail)
|
MacroAssembler::newGCString(Register result, Register temp, Label *fail)
|
||||||
{
|
{
|
||||||
allocateNonObject(result, temp, js::gc::FINALIZE_STRING, fail);
|
allocateNonObject(result, temp, js::gc::AllocKind::STRING, fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MacroAssembler::newGCFatInlineString(Register result, Register temp, Label *fail)
|
MacroAssembler::newGCFatInlineString(Register result, Register temp, Label *fail)
|
||||||
{
|
{
|
||||||
allocateNonObject(result, temp, js::gc::FINALIZE_FAT_INLINE_STRING, fail);
|
allocateNonObject(result, temp, js::gc::AllocKind::FAT_INLINE_STRING, fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1150,7 +1150,7 @@ AssertValidObjectPtr(JSContext *cx, JSObject *obj)
|
||||||
if (obj->isTenured()) {
|
if (obj->isTenured()) {
|
||||||
MOZ_ASSERT(obj->isAligned());
|
MOZ_ASSERT(obj->isAligned());
|
||||||
gc::AllocKind kind = obj->asTenured().getAllocKind();
|
gc::AllocKind kind = obj->asTenured().getAllocKind();
|
||||||
MOZ_ASSERT(kind >= js::gc::FINALIZE_OBJECT0 && kind <= js::gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(kind <= js::gc::AllocKind::OBJECT_LAST);
|
||||||
MOZ_ASSERT(obj->asTenured().zone() == cx->zone());
|
MOZ_ASSERT(obj->asTenured().zone() == cx->zone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1182,13 +1182,13 @@ AssertValidStringPtr(JSContext *cx, JSString *str)
|
||||||
|
|
||||||
gc::AllocKind kind = str->getAllocKind();
|
gc::AllocKind kind = str->getAllocKind();
|
||||||
if (str->isFatInline())
|
if (str->isFatInline())
|
||||||
MOZ_ASSERT(kind == gc::FINALIZE_FAT_INLINE_STRING);
|
MOZ_ASSERT(kind == gc::AllocKind::FAT_INLINE_STRING);
|
||||||
else if (str->isExternal())
|
else if (str->isExternal())
|
||||||
MOZ_ASSERT(kind == gc::FINALIZE_EXTERNAL_STRING);
|
MOZ_ASSERT(kind == gc::AllocKind::EXTERNAL_STRING);
|
||||||
else if (str->isAtom() || str->isFlat())
|
else if (str->isAtom() || str->isFlat())
|
||||||
MOZ_ASSERT(kind == gc::FINALIZE_STRING || kind == gc::FINALIZE_FAT_INLINE_STRING);
|
MOZ_ASSERT(kind == gc::AllocKind::STRING || kind == gc::AllocKind::FAT_INLINE_STRING);
|
||||||
else
|
else
|
||||||
MOZ_ASSERT(kind == gc::FINALIZE_STRING);
|
MOZ_ASSERT(kind == gc::AllocKind::STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1207,7 +1207,7 @@ AssertValidSymbolPtr(JSContext *cx, JS::Symbol *sym)
|
||||||
AssertValidStringPtr(cx, desc);
|
AssertValidStringPtr(cx, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(sym->getAllocKind() == gc::FINALIZE_SYMBOL);
|
MOZ_ASSERT(sym->getAllocKind() == gc::AllocKind::SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -3223,11 +3223,11 @@ CreateArrayPrototype(JSContext *cx, JSProtoKey key)
|
||||||
proto->assertParentIs(cx->global());
|
proto->assertParentIs(cx->global());
|
||||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &ArrayObject::class_, TaggedProto(proto),
|
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &ArrayObject::class_, TaggedProto(proto),
|
||||||
cx->global(), metadata,
|
cx->global(), metadata,
|
||||||
gc::FINALIZE_OBJECT0));
|
gc::AllocKind::OBJECT0));
|
||||||
if (!shape)
|
if (!shape)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
RootedArrayObject arrayProto(cx, ArrayObject::createArray(cx, gc::FINALIZE_OBJECT4,
|
RootedArrayObject arrayProto(cx, ArrayObject::createArray(cx, gc::AllocKind::OBJECT4,
|
||||||
gc::TenuredHeap, shape, group, 0));
|
gc::TenuredHeap, shape, group, 0));
|
||||||
if (!arrayProto ||
|
if (!arrayProto ||
|
||||||
!JSObject::setSingleton(cx, arrayProto) ||
|
!JSObject::setSingleton(cx, arrayProto) ||
|
||||||
|
@ -3352,7 +3352,7 @@ NewArray(ExclusiveContext *cxArg, uint32_t length,
|
||||||
*/
|
*/
|
||||||
RootedShape shape(cxArg, EmptyShape::getInitialShape(cxArg, &ArrayObject::class_,
|
RootedShape shape(cxArg, EmptyShape::getInitialShape(cxArg, &ArrayObject::class_,
|
||||||
TaggedProto(proto), cxArg->global(),
|
TaggedProto(proto), cxArg->global(),
|
||||||
metadata, gc::FINALIZE_OBJECT0));
|
metadata, gc::AllocKind::OBJECT0));
|
||||||
if (!shape)
|
if (!shape)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -731,7 +731,7 @@ CreateLazyScriptsForCompartment(JSContext *cx)
|
||||||
// which do not have an uncompiled enclosing script. The last condition is
|
// which do not have an uncompiled enclosing script. The last condition is
|
||||||
// so that we don't compile lazy scripts whose enclosing scripts failed to
|
// so that we don't compile lazy scripts whose enclosing scripts failed to
|
||||||
// compile, indicating that the lazy script did not escape the script.
|
// compile, indicating that the lazy script did not escape the script.
|
||||||
for (gc::ZoneCellIter i(cx->zone(), gc::FINALIZE_LAZY_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(cx->zone(), gc::AllocKind::LAZY_SCRIPT); !i.done(); i.next()) {
|
||||||
LazyScript *lazy = i.get<LazyScript>();
|
LazyScript *lazy = i.get<LazyScript>();
|
||||||
JSFunction *fun = lazy->functionNonDelazifying();
|
JSFunction *fun = lazy->functionNonDelazifying();
|
||||||
if (fun->compartment() == cx->compartment() &&
|
if (fun->compartment() == cx->compartment() &&
|
||||||
|
@ -810,7 +810,7 @@ JSCompartment::unsetIsDebuggee()
|
||||||
void
|
void
|
||||||
JSCompartment::clearBreakpointsIn(FreeOp *fop, js::Debugger *dbg, HandleObject handler)
|
JSCompartment::clearBreakpointsIn(FreeOp *fop, js::Debugger *dbg, HandleObject handler)
|
||||||
{
|
{
|
||||||
for (gc::ZoneCellIter i(zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone(), gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (script->compartment() == this && script->hasAnyBreakpointsOrStepMode())
|
if (script->compartment() == this && script->hasAnyBreakpointsOrStepMode())
|
||||||
script->clearBreakpointsIn(fop, dbg, handler);
|
script->clearBreakpointsIn(fop, dbg, handler);
|
||||||
|
|
|
@ -431,11 +431,11 @@ class JSFunction : public js::NativeObject
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JS_BITS_PER_WORD == 32
|
#if JS_BITS_PER_WORD == 32
|
||||||
static const js::gc::AllocKind FinalizeKind = js::gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const js::gc::AllocKind FinalizeKind = js::gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::FINALIZE_OBJECT4_BACKGROUND;
|
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::AllocKind::OBJECT4_BACKGROUND;
|
||||||
#else
|
#else
|
||||||
static const js::gc::AllocKind FinalizeKind = js::gc::FINALIZE_OBJECT4_BACKGROUND;
|
static const js::gc::AllocKind FinalizeKind = js::gc::AllocKind::OBJECT4_BACKGROUND;
|
||||||
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::FINALIZE_OBJECT8_BACKGROUND;
|
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::AllocKind::OBJECT8_BACKGROUND;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline void trace(JSTracer *trc);
|
inline void trace(JSTracer *trc);
|
||||||
|
|
376
js/src/jsgc.cpp
376
js/src/jsgc.cpp
|
@ -252,11 +252,11 @@ static const uint64_t GC_IDLE_FULL_SPAN = 20 * 1000 * 1000;
|
||||||
static const int IGC_MARK_SLICE_MULTIPLIER = 2;
|
static const int IGC_MARK_SLICE_MULTIPLIER = 2;
|
||||||
|
|
||||||
const AllocKind gc::slotsToThingKind[] = {
|
const AllocKind gc::slotsToThingKind[] = {
|
||||||
/* 0 */ FINALIZE_OBJECT0, FINALIZE_OBJECT2, FINALIZE_OBJECT2, FINALIZE_OBJECT4,
|
/* 0 */ AllocKind::OBJECT0, AllocKind::OBJECT2, AllocKind::OBJECT2, AllocKind::OBJECT4,
|
||||||
/* 4 */ FINALIZE_OBJECT4, FINALIZE_OBJECT8, FINALIZE_OBJECT8, FINALIZE_OBJECT8,
|
/* 4 */ AllocKind::OBJECT4, AllocKind::OBJECT8, AllocKind::OBJECT8, AllocKind::OBJECT8,
|
||||||
/* 8 */ FINALIZE_OBJECT8, FINALIZE_OBJECT12, FINALIZE_OBJECT12, FINALIZE_OBJECT12,
|
/* 8 */ AllocKind::OBJECT8, AllocKind::OBJECT12, AllocKind::OBJECT12, AllocKind::OBJECT12,
|
||||||
/* 12 */ FINALIZE_OBJECT12, FINALIZE_OBJECT16, FINALIZE_OBJECT16, FINALIZE_OBJECT16,
|
/* 12 */ AllocKind::OBJECT12, AllocKind::OBJECT16, AllocKind::OBJECT16, AllocKind::OBJECT16,
|
||||||
/* 16 */ FINALIZE_OBJECT16
|
/* 16 */ AllocKind::OBJECT16
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(JS_ARRAY_LENGTH(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
|
static_assert(JS_ARRAY_LENGTH(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
|
||||||
|
@ -270,29 +270,29 @@ static_assert(JS_ARRAY_LENGTH(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
|
||||||
MOZ_FOR_EACH(CHECK_MIN_THING_SIZE_INNER, (), (__VA_ARGS__ UINT32_MAX))
|
MOZ_FOR_EACH(CHECK_MIN_THING_SIZE_INNER, (), (__VA_ARGS__ UINT32_MAX))
|
||||||
|
|
||||||
const uint32_t Arena::ThingSizes[] = CHECK_MIN_THING_SIZE(
|
const uint32_t Arena::ThingSizes[] = CHECK_MIN_THING_SIZE(
|
||||||
sizeof(JSObject_Slots0), /* FINALIZE_OBJECT0 */
|
sizeof(JSObject_Slots0), /* AllocKind::OBJECT0 */
|
||||||
sizeof(JSObject_Slots0), /* FINALIZE_OBJECT0_BACKGROUND */
|
sizeof(JSObject_Slots0), /* AllocKind::OBJECT0_BACKGROUND */
|
||||||
sizeof(JSObject_Slots2), /* FINALIZE_OBJECT2 */
|
sizeof(JSObject_Slots2), /* AllocKind::OBJECT2 */
|
||||||
sizeof(JSObject_Slots2), /* FINALIZE_OBJECT2_BACKGROUND */
|
sizeof(JSObject_Slots2), /* AllocKind::OBJECT2_BACKGROUND */
|
||||||
sizeof(JSObject_Slots4), /* FINALIZE_OBJECT4 */
|
sizeof(JSObject_Slots4), /* AllocKind::OBJECT4 */
|
||||||
sizeof(JSObject_Slots4), /* FINALIZE_OBJECT4_BACKGROUND */
|
sizeof(JSObject_Slots4), /* AllocKind::OBJECT4_BACKGROUND */
|
||||||
sizeof(JSObject_Slots8), /* FINALIZE_OBJECT8 */
|
sizeof(JSObject_Slots8), /* AllocKind::OBJECT8 */
|
||||||
sizeof(JSObject_Slots8), /* FINALIZE_OBJECT8_BACKGROUND */
|
sizeof(JSObject_Slots8), /* AllocKind::OBJECT8_BACKGROUND */
|
||||||
sizeof(JSObject_Slots12), /* FINALIZE_OBJECT12 */
|
sizeof(JSObject_Slots12), /* AllocKind::OBJECT12 */
|
||||||
sizeof(JSObject_Slots12), /* FINALIZE_OBJECT12_BACKGROUND */
|
sizeof(JSObject_Slots12), /* AllocKind::OBJECT12_BACKGROUND */
|
||||||
sizeof(JSObject_Slots16), /* FINALIZE_OBJECT16 */
|
sizeof(JSObject_Slots16), /* AllocKind::OBJECT16 */
|
||||||
sizeof(JSObject_Slots16), /* FINALIZE_OBJECT16_BACKGROUND */
|
sizeof(JSObject_Slots16), /* AllocKind::OBJECT16_BACKGROUND */
|
||||||
sizeof(JSScript), /* FINALIZE_SCRIPT */
|
sizeof(JSScript), /* AllocKind::SCRIPT */
|
||||||
sizeof(LazyScript), /* FINALIZE_LAZY_SCRIPT */
|
sizeof(LazyScript), /* AllocKind::LAZY_SCRIPT */
|
||||||
sizeof(Shape), /* FINALIZE_SHAPE */
|
sizeof(Shape), /* AllocKind::SHAPE */
|
||||||
sizeof(AccessorShape), /* FINALIZE_ACCESSOR_SHAPE */
|
sizeof(AccessorShape), /* AllocKind::ACCESSOR_SHAPE */
|
||||||
sizeof(BaseShape), /* FINALIZE_BASE_SHAPE */
|
sizeof(BaseShape), /* AllocKind::BASE_SHAPE */
|
||||||
sizeof(ObjectGroup), /* FINALIZE_OBJECT_GROUP */
|
sizeof(ObjectGroup), /* AllocKind::OBJECT_GROUP */
|
||||||
sizeof(JSFatInlineString), /* FINALIZE_FAT_INLINE_STRING */
|
sizeof(JSFatInlineString), /* AllocKind::FAT_INLINE_STRING */
|
||||||
sizeof(JSString), /* FINALIZE_STRING */
|
sizeof(JSString), /* AllocKind::STRING */
|
||||||
sizeof(JSExternalString), /* FINALIZE_EXTERNAL_STRING */
|
sizeof(JSExternalString), /* AllocKind::EXTERNAL_STRING */
|
||||||
sizeof(JS::Symbol), /* FINALIZE_SYMBOL */
|
sizeof(JS::Symbol), /* AllocKind::SYMBOL */
|
||||||
sizeof(jit::JitCode), /* FINALIZE_JITCODE */
|
sizeof(jit::JitCode), /* AllocKind::JITCODE */
|
||||||
);
|
);
|
||||||
|
|
||||||
#undef CHECK_MIN_THING_SIZE_INNER
|
#undef CHECK_MIN_THING_SIZE_INNER
|
||||||
|
@ -301,29 +301,29 @@ const uint32_t Arena::ThingSizes[] = CHECK_MIN_THING_SIZE(
|
||||||
#define OFFSET(type) uint32_t(sizeof(ArenaHeader) + (ArenaSize - sizeof(ArenaHeader)) % sizeof(type))
|
#define OFFSET(type) uint32_t(sizeof(ArenaHeader) + (ArenaSize - sizeof(ArenaHeader)) % sizeof(type))
|
||||||
|
|
||||||
const uint32_t Arena::FirstThingOffsets[] = {
|
const uint32_t Arena::FirstThingOffsets[] = {
|
||||||
OFFSET(JSObject_Slots0), /* FINALIZE_OBJECT0 */
|
OFFSET(JSObject_Slots0), /* AllocKind::OBJECT0 */
|
||||||
OFFSET(JSObject_Slots0), /* FINALIZE_OBJECT0_BACKGROUND */
|
OFFSET(JSObject_Slots0), /* AllocKind::OBJECT0_BACKGROUND */
|
||||||
OFFSET(JSObject_Slots2), /* FINALIZE_OBJECT2 */
|
OFFSET(JSObject_Slots2), /* AllocKind::OBJECT2 */
|
||||||
OFFSET(JSObject_Slots2), /* FINALIZE_OBJECT2_BACKGROUND */
|
OFFSET(JSObject_Slots2), /* AllocKind::OBJECT2_BACKGROUND */
|
||||||
OFFSET(JSObject_Slots4), /* FINALIZE_OBJECT4 */
|
OFFSET(JSObject_Slots4), /* AllocKind::OBJECT4 */
|
||||||
OFFSET(JSObject_Slots4), /* FINALIZE_OBJECT4_BACKGROUND */
|
OFFSET(JSObject_Slots4), /* AllocKind::OBJECT4_BACKGROUND */
|
||||||
OFFSET(JSObject_Slots8), /* FINALIZE_OBJECT8 */
|
OFFSET(JSObject_Slots8), /* AllocKind::OBJECT8 */
|
||||||
OFFSET(JSObject_Slots8), /* FINALIZE_OBJECT8_BACKGROUND */
|
OFFSET(JSObject_Slots8), /* AllocKind::OBJECT8_BACKGROUND */
|
||||||
OFFSET(JSObject_Slots12), /* FINALIZE_OBJECT12 */
|
OFFSET(JSObject_Slots12), /* AllocKind::OBJECT12 */
|
||||||
OFFSET(JSObject_Slots12), /* FINALIZE_OBJECT12_BACKGROUND */
|
OFFSET(JSObject_Slots12), /* AllocKind::OBJECT12_BACKGROUND */
|
||||||
OFFSET(JSObject_Slots16), /* FINALIZE_OBJECT16 */
|
OFFSET(JSObject_Slots16), /* AllocKind::OBJECT16 */
|
||||||
OFFSET(JSObject_Slots16), /* FINALIZE_OBJECT16_BACKGROUND */
|
OFFSET(JSObject_Slots16), /* AllocKind::OBJECT16_BACKGROUND */
|
||||||
OFFSET(JSScript), /* FINALIZE_SCRIPT */
|
OFFSET(JSScript), /* AllocKind::SCRIPT */
|
||||||
OFFSET(LazyScript), /* FINALIZE_LAZY_SCRIPT */
|
OFFSET(LazyScript), /* AllocKind::LAZY_SCRIPT */
|
||||||
OFFSET(Shape), /* FINALIZE_SHAPE */
|
OFFSET(Shape), /* AllocKind::SHAPE */
|
||||||
OFFSET(AccessorShape), /* FINALIZE_ACCESSOR_SHAPE */
|
OFFSET(AccessorShape), /* AllocKind::ACCESSOR_SHAPE */
|
||||||
OFFSET(BaseShape), /* FINALIZE_BASE_SHAPE */
|
OFFSET(BaseShape), /* AllocKind::BASE_SHAPE */
|
||||||
OFFSET(ObjectGroup), /* FINALIZE_OBJECT_GROUP */
|
OFFSET(ObjectGroup), /* AllocKind::OBJECT_GROUP */
|
||||||
OFFSET(JSFatInlineString), /* FINALIZE_FAT_INLINE_STRING */
|
OFFSET(JSFatInlineString), /* AllocKind::FAT_INLINE_STRING */
|
||||||
OFFSET(JSString), /* FINALIZE_STRING */
|
OFFSET(JSString), /* AllocKind::STRING */
|
||||||
OFFSET(JSExternalString), /* FINALIZE_EXTERNAL_STRING */
|
OFFSET(JSExternalString), /* AllocKind::EXTERNAL_STRING */
|
||||||
OFFSET(JS::Symbol), /* FINALIZE_SYMBOL */
|
OFFSET(JS::Symbol), /* AllocKind::SYMBOL */
|
||||||
OFFSET(jit::JitCode), /* FINALIZE_JITCODE */
|
OFFSET(jit::JitCode), /* AllocKind::JITCODE */
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef OFFSET
|
#undef OFFSET
|
||||||
|
@ -342,16 +342,16 @@ struct js::gc::FinalizePhase
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const AllocKind IncrementalPhaseStrings[] = {
|
static const AllocKind IncrementalPhaseStrings[] = {
|
||||||
FINALIZE_EXTERNAL_STRING
|
AllocKind::EXTERNAL_STRING
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AllocKind IncrementalPhaseScripts[] = {
|
static const AllocKind IncrementalPhaseScripts[] = {
|
||||||
FINALIZE_SCRIPT,
|
AllocKind::SCRIPT,
|
||||||
FINALIZE_LAZY_SCRIPT
|
AllocKind::LAZY_SCRIPT
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AllocKind IncrementalPhaseJitCode[] = {
|
static const AllocKind IncrementalPhaseJitCode[] = {
|
||||||
FINALIZE_JITCODE
|
AllocKind::JITCODE
|
||||||
};
|
};
|
||||||
|
|
||||||
static const FinalizePhase IncrementalFinalizePhases[] = {
|
static const FinalizePhase IncrementalFinalizePhases[] = {
|
||||||
|
@ -365,25 +365,25 @@ static const FinalizePhase IncrementalFinalizePhases[] = {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const AllocKind BackgroundPhaseObjects[] = {
|
static const AllocKind BackgroundPhaseObjects[] = {
|
||||||
FINALIZE_OBJECT0_BACKGROUND,
|
AllocKind::OBJECT0_BACKGROUND,
|
||||||
FINALIZE_OBJECT2_BACKGROUND,
|
AllocKind::OBJECT2_BACKGROUND,
|
||||||
FINALIZE_OBJECT4_BACKGROUND,
|
AllocKind::OBJECT4_BACKGROUND,
|
||||||
FINALIZE_OBJECT8_BACKGROUND,
|
AllocKind::OBJECT8_BACKGROUND,
|
||||||
FINALIZE_OBJECT12_BACKGROUND,
|
AllocKind::OBJECT12_BACKGROUND,
|
||||||
FINALIZE_OBJECT16_BACKGROUND
|
AllocKind::OBJECT16_BACKGROUND
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AllocKind BackgroundPhaseStringsAndSymbols[] = {
|
static const AllocKind BackgroundPhaseStringsAndSymbols[] = {
|
||||||
FINALIZE_FAT_INLINE_STRING,
|
AllocKind::FAT_INLINE_STRING,
|
||||||
FINALIZE_STRING,
|
AllocKind::STRING,
|
||||||
FINALIZE_SYMBOL
|
AllocKind::SYMBOL
|
||||||
};
|
};
|
||||||
|
|
||||||
static const AllocKind BackgroundPhaseShapes[] = {
|
static const AllocKind BackgroundPhaseShapes[] = {
|
||||||
FINALIZE_SHAPE,
|
AllocKind::SHAPE,
|
||||||
FINALIZE_ACCESSOR_SHAPE,
|
AllocKind::ACCESSOR_SHAPE,
|
||||||
FINALIZE_BASE_SHAPE,
|
AllocKind::BASE_SHAPE,
|
||||||
FINALIZE_OBJECT_GROUP
|
AllocKind::OBJECT_GROUP
|
||||||
};
|
};
|
||||||
|
|
||||||
static const FinalizePhase BackgroundFinalizePhases[] = {
|
static const FinalizePhase BackgroundFinalizePhases[] = {
|
||||||
|
@ -445,8 +445,10 @@ ArenaHeader::unmarkAll()
|
||||||
/* static */ void
|
/* static */ void
|
||||||
Arena::staticAsserts()
|
Arena::staticAsserts()
|
||||||
{
|
{
|
||||||
static_assert(JS_ARRAY_LENGTH(ThingSizes) == FINALIZE_LIMIT, "We have defined all thing sizes.");
|
static_assert(JS_ARRAY_LENGTH(ThingSizes) == size_t(AllocKind::LIMIT),
|
||||||
static_assert(JS_ARRAY_LENGTH(FirstThingOffsets) == FINALIZE_LIMIT, "We have defined all offsets.");
|
"We haven't defined all thing sizes.");
|
||||||
|
static_assert(JS_ARRAY_LENGTH(FirstThingOffsets) == size_t(AllocKind::LIMIT),
|
||||||
|
"We haven't defined all offsets.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -586,40 +588,40 @@ FinalizeArenas(FreeOp *fop,
|
||||||
ArenaLists::KeepArenasEnum keepArenas)
|
ArenaLists::KeepArenasEnum keepArenas)
|
||||||
{
|
{
|
||||||
switch (thingKind) {
|
switch (thingKind) {
|
||||||
case FINALIZE_OBJECT0:
|
case AllocKind::OBJECT0:
|
||||||
case FINALIZE_OBJECT0_BACKGROUND:
|
case AllocKind::OBJECT0_BACKGROUND:
|
||||||
case FINALIZE_OBJECT2:
|
case AllocKind::OBJECT2:
|
||||||
case FINALIZE_OBJECT2_BACKGROUND:
|
case AllocKind::OBJECT2_BACKGROUND:
|
||||||
case FINALIZE_OBJECT4:
|
case AllocKind::OBJECT4:
|
||||||
case FINALIZE_OBJECT4_BACKGROUND:
|
case AllocKind::OBJECT4_BACKGROUND:
|
||||||
case FINALIZE_OBJECT8:
|
case AllocKind::OBJECT8:
|
||||||
case FINALIZE_OBJECT8_BACKGROUND:
|
case AllocKind::OBJECT8_BACKGROUND:
|
||||||
case FINALIZE_OBJECT12:
|
case AllocKind::OBJECT12:
|
||||||
case FINALIZE_OBJECT12_BACKGROUND:
|
case AllocKind::OBJECT12_BACKGROUND:
|
||||||
case FINALIZE_OBJECT16:
|
case AllocKind::OBJECT16:
|
||||||
case FINALIZE_OBJECT16_BACKGROUND:
|
case AllocKind::OBJECT16_BACKGROUND:
|
||||||
return FinalizeTypedArenas<JSObject>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JSObject>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_SCRIPT:
|
case AllocKind::SCRIPT:
|
||||||
return FinalizeTypedArenas<JSScript>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JSScript>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_LAZY_SCRIPT:
|
case AllocKind::LAZY_SCRIPT:
|
||||||
return FinalizeTypedArenas<LazyScript>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<LazyScript>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_SHAPE:
|
case AllocKind::SHAPE:
|
||||||
return FinalizeTypedArenas<Shape>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<Shape>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_ACCESSOR_SHAPE:
|
case AllocKind::ACCESSOR_SHAPE:
|
||||||
return FinalizeTypedArenas<AccessorShape>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<AccessorShape>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_BASE_SHAPE:
|
case AllocKind::BASE_SHAPE:
|
||||||
return FinalizeTypedArenas<BaseShape>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<BaseShape>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_OBJECT_GROUP:
|
case AllocKind::OBJECT_GROUP:
|
||||||
return FinalizeTypedArenas<ObjectGroup>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<ObjectGroup>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_STRING:
|
case AllocKind::STRING:
|
||||||
return FinalizeTypedArenas<JSString>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JSString>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_FAT_INLINE_STRING:
|
case AllocKind::FAT_INLINE_STRING:
|
||||||
return FinalizeTypedArenas<JSFatInlineString>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JSFatInlineString>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_EXTERNAL_STRING:
|
case AllocKind::EXTERNAL_STRING:
|
||||||
return FinalizeTypedArenas<JSExternalString>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JSExternalString>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_SYMBOL:
|
case AllocKind::SYMBOL:
|
||||||
return FinalizeTypedArenas<JS::Symbol>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<JS::Symbol>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
case FINALIZE_JITCODE:
|
case AllocKind::JITCODE:
|
||||||
return FinalizeTypedArenas<jit::JitCode>(fop, src, dest, thingKind, budget, keepArenas);
|
return FinalizeTypedArenas<jit::JitCode>(fop, src, dest, thingKind, budget, keepArenas);
|
||||||
default:
|
default:
|
||||||
MOZ_CRASH("Invalid alloc kind");
|
MOZ_CRASH("Invalid alloc kind");
|
||||||
|
@ -1787,7 +1789,7 @@ GCMarker::delayMarkingChildren(const void *thing)
|
||||||
inline void
|
inline void
|
||||||
ArenaLists::prepareForIncrementalGC(JSRuntime *rt)
|
ArenaLists::prepareForIncrementalGC(JSRuntime *rt)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
FreeList *freeList = &freeLists[i];
|
FreeList *freeList = &freeLists[i];
|
||||||
if (!freeList->isEmpty()) {
|
if (!freeList->isEmpty()) {
|
||||||
ArenaHeader *aheader = freeList->arenaHeader();
|
ArenaHeader *aheader = freeList->arenaHeader();
|
||||||
|
@ -1936,7 +1938,7 @@ CanRelocateZone(JSRuntime *rt, Zone *zone)
|
||||||
static bool
|
static bool
|
||||||
CanRelocateAllocKind(AllocKind kind)
|
CanRelocateAllocKind(AllocKind kind)
|
||||||
{
|
{
|
||||||
return kind <= FINALIZE_OBJECT_LAST;
|
return kind <= AllocKind::OBJECT_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ArenaHeader::countFreeCells()
|
size_t ArenaHeader::countFreeCells()
|
||||||
|
@ -2062,7 +2064,7 @@ RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize
|
||||||
// Copy source cell contents to destination.
|
// Copy source cell contents to destination.
|
||||||
memcpy(dst, src, thingSize);
|
memcpy(dst, src, thingSize);
|
||||||
|
|
||||||
if (thingKind <= FINALIZE_OBJECT_LAST) {
|
if (thingKind <= AllocKind::OBJECT_LAST) {
|
||||||
JSObject *srcObj = static_cast<JSObject *>(static_cast<Cell *>(src));
|
JSObject *srcObj = static_cast<JSObject *>(static_cast<Cell *>(src));
|
||||||
JSObject *dstObj = static_cast<JSObject *>(static_cast<Cell *>(dst));
|
JSObject *dstObj = static_cast<JSObject *>(static_cast<Cell *>(dst));
|
||||||
|
|
||||||
|
@ -2180,8 +2182,8 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
|
||||||
checkEmptyFreeLists();
|
checkEmptyFreeLists();
|
||||||
|
|
||||||
if (ShouldRelocateAllArenas(reason)) {
|
if (ShouldRelocateAllArenas(reason)) {
|
||||||
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
if (CanRelocateAllocKind(AllocKind(i))) {
|
if (CanRelocateAllocKind(i)) {
|
||||||
ArenaList &al = arenaLists[i];
|
ArenaList &al = arenaLists[i];
|
||||||
ArenaHeader *allArenas = al.head();
|
ArenaHeader *allArenas = al.head();
|
||||||
al.clear();
|
al.clear();
|
||||||
|
@ -2191,17 +2193,18 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
|
||||||
} else {
|
} else {
|
||||||
size_t arenaCount = 0;
|
size_t arenaCount = 0;
|
||||||
size_t relocCount = 0;
|
size_t relocCount = 0;
|
||||||
ArenaHeader **toRelocate[FINALIZE_LIMIT] = {nullptr};
|
AllAllocKindArray<ArenaHeader **> toRelocate;
|
||||||
|
|
||||||
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
if (CanRelocateAllocKind(AllocKind(i)))
|
toRelocate[i] = nullptr;
|
||||||
|
if (CanRelocateAllocKind(i))
|
||||||
toRelocate[i] = arenaLists[i].pickArenasToRelocate(arenaCount, relocCount);
|
toRelocate[i] = arenaLists[i].pickArenasToRelocate(arenaCount, relocCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ShouldRelocateZone(arenaCount, relocCount, reason))
|
if (!ShouldRelocateZone(arenaCount, relocCount, reason))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
if (toRelocate[i]) {
|
if (toRelocate[i]) {
|
||||||
ArenaList &al = arenaLists[i];
|
ArenaList &al = arenaLists[i];
|
||||||
ArenaHeader *arenas = al.removeRemainingArenas(toRelocate[i]);
|
ArenaHeader *arenas = al.removeRemainingArenas(toRelocate[i]);
|
||||||
|
@ -2264,12 +2267,12 @@ GCRuntime::sweepTypesAfterCompacting(Zone *zone)
|
||||||
|
|
||||||
AutoClearTypeInferenceStateOnOOM oom(zone);
|
AutoClearTypeInferenceStateOnOOM oom(zone);
|
||||||
|
|
||||||
for (ZoneCellIterUnderGC i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
script->maybeSweepTypes(&oom);
|
script->maybeSweepTypes(&oom);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ZoneCellIterUnderGC i(zone, FINALIZE_OBJECT_GROUP); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, AllocKind::OBJECT_GROUP); !i.done(); i.next()) {
|
||||||
ObjectGroup *group = i.get<ObjectGroup>();
|
ObjectGroup *group = i.get<ObjectGroup>();
|
||||||
group->maybeSweep(&oom);
|
group->maybeSweep(&oom);
|
||||||
}
|
}
|
||||||
|
@ -2323,39 +2326,39 @@ UpdateCellPointers(MovingTracer *trc, ArenaHeader *arena)
|
||||||
JSGCTraceKind traceKind = MapAllocToTraceKind(kind);
|
JSGCTraceKind traceKind = MapAllocToTraceKind(kind);
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case FINALIZE_OBJECT0:
|
case AllocKind::OBJECT0:
|
||||||
case FINALIZE_OBJECT0_BACKGROUND:
|
case AllocKind::OBJECT0_BACKGROUND:
|
||||||
case FINALIZE_OBJECT2:
|
case AllocKind::OBJECT2:
|
||||||
case FINALIZE_OBJECT2_BACKGROUND:
|
case AllocKind::OBJECT2_BACKGROUND:
|
||||||
case FINALIZE_OBJECT4:
|
case AllocKind::OBJECT4:
|
||||||
case FINALIZE_OBJECT4_BACKGROUND:
|
case AllocKind::OBJECT4_BACKGROUND:
|
||||||
case FINALIZE_OBJECT8:
|
case AllocKind::OBJECT8:
|
||||||
case FINALIZE_OBJECT8_BACKGROUND:
|
case AllocKind::OBJECT8_BACKGROUND:
|
||||||
case FINALIZE_OBJECT12:
|
case AllocKind::OBJECT12:
|
||||||
case FINALIZE_OBJECT12_BACKGROUND:
|
case AllocKind::OBJECT12_BACKGROUND:
|
||||||
case FINALIZE_OBJECT16:
|
case AllocKind::OBJECT16:
|
||||||
case FINALIZE_OBJECT16_BACKGROUND:
|
case AllocKind::OBJECT16_BACKGROUND:
|
||||||
UpdateCellPointersTyped<JSObject>(trc, arena, traceKind);
|
UpdateCellPointersTyped<JSObject>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_SCRIPT:
|
case AllocKind::SCRIPT:
|
||||||
UpdateCellPointersTyped<JSScript>(trc, arena, traceKind);
|
UpdateCellPointersTyped<JSScript>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_LAZY_SCRIPT:
|
case AllocKind::LAZY_SCRIPT:
|
||||||
UpdateCellPointersTyped<LazyScript>(trc, arena, traceKind);
|
UpdateCellPointersTyped<LazyScript>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_SHAPE:
|
case AllocKind::SHAPE:
|
||||||
UpdateCellPointersTyped<Shape>(trc, arena, traceKind);
|
UpdateCellPointersTyped<Shape>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_ACCESSOR_SHAPE:
|
case AllocKind::ACCESSOR_SHAPE:
|
||||||
UpdateCellPointersTyped<AccessorShape>(trc, arena, traceKind);
|
UpdateCellPointersTyped<AccessorShape>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_BASE_SHAPE:
|
case AllocKind::BASE_SHAPE:
|
||||||
UpdateCellPointersTyped<BaseShape>(trc, arena, traceKind);
|
UpdateCellPointersTyped<BaseShape>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_OBJECT_GROUP:
|
case AllocKind::OBJECT_GROUP:
|
||||||
UpdateCellPointersTyped<ObjectGroup>(trc, arena, traceKind);
|
UpdateCellPointersTyped<ObjectGroup>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
case FINALIZE_JITCODE:
|
case AllocKind::JITCODE:
|
||||||
UpdateCellPointersTyped<jit::JitCode>(trc, arena, traceKind);
|
UpdateCellPointersTyped<jit::JitCode>(trc, arena, traceKind);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -2385,21 +2388,21 @@ struct ArenasToUpdate
|
||||||
unsigned kind; // Current alloc kind to process
|
unsigned kind; // Current alloc kind to process
|
||||||
ArenaHeader *arena; // Next arena to process
|
ArenaHeader *arena; // Next arena to process
|
||||||
|
|
||||||
bool shouldProcessKind(unsigned kind);
|
bool shouldProcessKind(AllocKind kind);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ArenasToUpdate::shouldProcessKind(unsigned kind)
|
bool ArenasToUpdate::shouldProcessKind(AllocKind kind)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(kind < FINALIZE_LIMIT);
|
MOZ_ASSERT(kind < AllocKind::LIMIT);
|
||||||
if (kind == FINALIZE_FAT_INLINE_STRING ||
|
if (kind == AllocKind::FAT_INLINE_STRING ||
|
||||||
kind == FINALIZE_STRING ||
|
kind == AllocKind::STRING ||
|
||||||
kind == FINALIZE_EXTERNAL_STRING ||
|
kind == AllocKind::EXTERNAL_STRING ||
|
||||||
kind == FINALIZE_SYMBOL)
|
kind == AllocKind::SYMBOL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (js::gc::IsBackgroundFinalized(AllocKind(kind)))
|
if (js::gc::IsBackgroundFinalized(kind))
|
||||||
return (kinds & BACKGROUND) != 0;
|
return (kinds & BACKGROUND) != 0;
|
||||||
else
|
else
|
||||||
return (kinds & FOREGROUND) != 0;
|
return (kinds & FOREGROUND) != 0;
|
||||||
|
@ -2425,7 +2428,7 @@ ArenasToUpdate::next(AutoLockHelperThreadState& lock)
|
||||||
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
MOZ_ASSERT(arena);
|
MOZ_ASSERT(arena);
|
||||||
MOZ_ASSERT(shouldProcessKind(kind));
|
MOZ_ASSERT(shouldProcessKind(AllocKind(kind)));
|
||||||
MOZ_ASSERT(!zone.done());
|
MOZ_ASSERT(!zone.done());
|
||||||
goto resumePoint;
|
goto resumePoint;
|
||||||
}
|
}
|
||||||
|
@ -2433,8 +2436,8 @@ ArenasToUpdate::next(AutoLockHelperThreadState& lock)
|
||||||
initialized = true;
|
initialized = true;
|
||||||
for (; !zone.done(); zone.next()) {
|
for (; !zone.done(); zone.next()) {
|
||||||
if (zone->isGCCompacting()) {
|
if (zone->isGCCompacting()) {
|
||||||
for (kind = 0; kind < FINALIZE_LIMIT; ++kind) {
|
for (kind = 0; kind < size_t(AllocKind::LIMIT); ++kind) {
|
||||||
if (shouldProcessKind(kind)) {
|
if (shouldProcessKind(AllocKind(kind))) {
|
||||||
for (arena = zone.get()->arenas.getFirstArena(AllocKind(kind));
|
for (arena = zone.get()->arenas.getFirstArena(AllocKind(kind));
|
||||||
arena;
|
arena;
|
||||||
arena = arena->next)
|
arena = arena->next)
|
||||||
|
@ -2757,7 +2760,7 @@ ArenaLists::~ArenaLists()
|
||||||
{
|
{
|
||||||
AutoLockGC lock(runtime_);
|
AutoLockGC lock(runtime_);
|
||||||
|
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
/*
|
/*
|
||||||
* We can only call this during the shutdown after the last GC when
|
* We can only call this during the shutdown after the last GC when
|
||||||
* the background finalization is disabled.
|
* the background finalization is disabled.
|
||||||
|
@ -2767,7 +2770,7 @@ ArenaLists::~ArenaLists()
|
||||||
}
|
}
|
||||||
ReleaseArenaList(runtime_, incrementalSweptArenas.head(), lock);
|
ReleaseArenaList(runtime_, incrementalSweptArenas.head(), lock);
|
||||||
|
|
||||||
for (size_t i = 0; i < FINALIZE_OBJECT_LIMIT; i++)
|
for (OBJECT_ALLOC_KINDS(i))
|
||||||
ReleaseArenaList(runtime_, savedObjectArenas[i].head(), lock);
|
ReleaseArenaList(runtime_, savedObjectArenas[i].head(), lock);
|
||||||
ReleaseArenaList(runtime_, savedEmptyObjectArenas, lock);
|
ReleaseArenaList(runtime_, savedEmptyObjectArenas, lock);
|
||||||
}
|
}
|
||||||
|
@ -2909,7 +2912,7 @@ ArenaLists::queueForegroundObjectsForSweep(FreeOp *fop)
|
||||||
gcstats::AutoPhase ap(fop->runtime()->gc.stats, gcstats::PHASE_SWEEP_OBJECT);
|
gcstats::AutoPhase ap(fop->runtime()->gc.stats, gcstats::PHASE_SWEEP_OBJECT);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (size_t i = 0; i < FINALIZE_OBJECT_LIMIT; i++)
|
for (OBJECT_ALLOC_KINDS(i))
|
||||||
MOZ_ASSERT(savedObjectArenas[i].isEmpty());
|
MOZ_ASSERT(savedObjectArenas[i].isEmpty());
|
||||||
MOZ_ASSERT(savedEmptyObjectArenas == nullptr);
|
MOZ_ASSERT(savedEmptyObjectArenas == nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2918,22 +2921,22 @@ ArenaLists::queueForegroundObjectsForSweep(FreeOp *fop)
|
||||||
// sweep phase, before control can return to the mutator. Otherwise,
|
// sweep phase, before control can return to the mutator. Otherwise,
|
||||||
// mutator behavior can resurrect certain objects whose references would
|
// mutator behavior can resurrect certain objects whose references would
|
||||||
// otherwise have been erased by the finalizer.
|
// otherwise have been erased by the finalizer.
|
||||||
finalizeNow(fop, FINALIZE_OBJECT0, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT0, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
finalizeNow(fop, FINALIZE_OBJECT2, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT2, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
finalizeNow(fop, FINALIZE_OBJECT4, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT4, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
finalizeNow(fop, FINALIZE_OBJECT8, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT8, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
finalizeNow(fop, FINALIZE_OBJECT12, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT12, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
finalizeNow(fop, FINALIZE_OBJECT16, KEEP_ARENAS, &savedEmptyObjectArenas);
|
finalizeNow(fop, AllocKind::OBJECT16, KEEP_ARENAS, &savedEmptyObjectArenas);
|
||||||
|
|
||||||
// Prevent the arenas from having new objects allocated into them. We need
|
// Prevent the arenas from having new objects allocated into them. We need
|
||||||
// to know which objects are marked while we incrementally sweep dead
|
// to know which objects are marked while we incrementally sweep dead
|
||||||
// references from type information.
|
// references from type information.
|
||||||
savedObjectArenas[FINALIZE_OBJECT0] = arenaLists[FINALIZE_OBJECT0].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT0] = arenaLists[AllocKind::OBJECT0].copyAndClear();
|
||||||
savedObjectArenas[FINALIZE_OBJECT2] = arenaLists[FINALIZE_OBJECT2].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT2] = arenaLists[AllocKind::OBJECT2].copyAndClear();
|
||||||
savedObjectArenas[FINALIZE_OBJECT4] = arenaLists[FINALIZE_OBJECT4].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT4] = arenaLists[AllocKind::OBJECT4].copyAndClear();
|
||||||
savedObjectArenas[FINALIZE_OBJECT8] = arenaLists[FINALIZE_OBJECT8].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT8] = arenaLists[AllocKind::OBJECT8].copyAndClear();
|
||||||
savedObjectArenas[FINALIZE_OBJECT12] = arenaLists[FINALIZE_OBJECT12].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT12] = arenaLists[AllocKind::OBJECT12].copyAndClear();
|
||||||
savedObjectArenas[FINALIZE_OBJECT16] = arenaLists[FINALIZE_OBJECT16].copyAndClear();
|
savedObjectArenas[AllocKind::OBJECT16] = arenaLists[AllocKind::OBJECT16].copyAndClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2943,12 +2946,12 @@ ArenaLists::mergeForegroundSweptObjectArenas()
|
||||||
ReleaseArenaList(runtime_, savedEmptyObjectArenas, lock);
|
ReleaseArenaList(runtime_, savedEmptyObjectArenas, lock);
|
||||||
savedEmptyObjectArenas = nullptr;
|
savedEmptyObjectArenas = nullptr;
|
||||||
|
|
||||||
mergeSweptArenas(FINALIZE_OBJECT0);
|
mergeSweptArenas(AllocKind::OBJECT0);
|
||||||
mergeSweptArenas(FINALIZE_OBJECT2);
|
mergeSweptArenas(AllocKind::OBJECT2);
|
||||||
mergeSweptArenas(FINALIZE_OBJECT4);
|
mergeSweptArenas(AllocKind::OBJECT4);
|
||||||
mergeSweptArenas(FINALIZE_OBJECT8);
|
mergeSweptArenas(AllocKind::OBJECT8);
|
||||||
mergeSweptArenas(FINALIZE_OBJECT12);
|
mergeSweptArenas(AllocKind::OBJECT12);
|
||||||
mergeSweptArenas(FINALIZE_OBJECT16);
|
mergeSweptArenas(AllocKind::OBJECT16);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
@ -2964,10 +2967,10 @@ ArenaLists::mergeSweptArenas(AllocKind thingKind)
|
||||||
void
|
void
|
||||||
ArenaLists::queueForegroundThingsForSweep(FreeOp *fop)
|
ArenaLists::queueForegroundThingsForSweep(FreeOp *fop)
|
||||||
{
|
{
|
||||||
gcShapeArenasToUpdate = arenaListsToSweep[FINALIZE_SHAPE];
|
gcShapeArenasToUpdate = arenaListsToSweep[AllocKind::SHAPE];
|
||||||
gcAccessorShapeArenasToUpdate = arenaListsToSweep[FINALIZE_ACCESSOR_SHAPE];
|
gcAccessorShapeArenasToUpdate = arenaListsToSweep[AllocKind::ACCESSOR_SHAPE];
|
||||||
gcObjectGroupArenasToUpdate = arenaListsToSweep[FINALIZE_OBJECT_GROUP];
|
gcObjectGroupArenasToUpdate = arenaListsToSweep[AllocKind::OBJECT_GROUP];
|
||||||
gcScriptArenasToUpdate = arenaListsToSweep[FINALIZE_SCRIPT];
|
gcScriptArenasToUpdate = arenaListsToSweep[AllocKind::SCRIPT];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void *
|
/* static */ void *
|
||||||
|
@ -3336,7 +3339,7 @@ GCRuntime::decommitArenas(AutoLockGC &lock)
|
||||||
// The arena list is not doubly-linked, so we have to work in the free
|
// The arena list is not doubly-linked, so we have to work in the free
|
||||||
// list order and not in the natural order.
|
// list order and not in the natural order.
|
||||||
while (chunk->info.numArenasFreeCommitted) {
|
while (chunk->info.numArenasFreeCommitted) {
|
||||||
ArenaHeader *aheader = chunk->allocateArena(rt, nullptr, FINALIZE_OBJECT0, lock);
|
ArenaHeader *aheader = chunk->allocateArena(rt, nullptr, AllocKind::OBJECT0, lock);
|
||||||
bool ok;
|
bool ok;
|
||||||
{
|
{
|
||||||
AutoUnlockGC unlock(lock);
|
AutoUnlockGC unlock(lock);
|
||||||
|
@ -3401,9 +3404,9 @@ GCRuntime::assertBackgroundSweepingFinished()
|
||||||
MOZ_ASSERT(backgroundSweepZones.isEmpty());
|
MOZ_ASSERT(backgroundSweepZones.isEmpty());
|
||||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||||
MOZ_ASSERT(!zone->isOnList());
|
MOZ_ASSERT(!zone->isOnList());
|
||||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||||
MOZ_ASSERT(zone->arenas.doneBackgroundFinalize(AllocKind(i)));
|
MOZ_ASSERT(zone->arenas.doneBackgroundFinalize(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0);
|
MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0);
|
||||||
|
@ -3869,10 +3872,10 @@ GCRuntime::checkForCompartmentMismatches()
|
||||||
CompartmentCheckTracer trc(rt, CheckCompartmentCallback);
|
CompartmentCheckTracer trc(rt, CheckCompartmentCallback);
|
||||||
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
trc.zone = zone;
|
trc.zone = zone;
|
||||||
for (size_t thingKind = 0; thingKind < FINALIZE_LAST; thingKind++) {
|
for (ALL_ALLOC_KINDS(thingKind)) {
|
||||||
for (ZoneCellIterUnderGC i(zone, AllocKind(thingKind)); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, thingKind); !i.done(); i.next()) {
|
||||||
trc.src = i.getCell();
|
trc.src = i.getCell();
|
||||||
trc.srcKind = MapAllocToTraceKind(AllocKind(thingKind));
|
trc.srcKind = MapAllocToTraceKind(thingKind);
|
||||||
trc.compartment = CompartmentOfCell(trc.src, trc.srcKind);
|
trc.compartment = CompartmentOfCell(trc.src, trc.srcKind);
|
||||||
JS_TraceChildren(&trc, trc.src, trc.srcKind);
|
JS_TraceChildren(&trc, trc.src, trc.srcKind);
|
||||||
}
|
}
|
||||||
|
@ -3898,7 +3901,7 @@ GCRuntime::beginMarkPhase(JS::gcreason::Reason reason)
|
||||||
/* Assert that zone state is as we expect */
|
/* Assert that zone state is as we expect */
|
||||||
MOZ_ASSERT(!zone->isCollecting());
|
MOZ_ASSERT(!zone->isCollecting());
|
||||||
MOZ_ASSERT(!zone->compartments.empty());
|
MOZ_ASSERT(!zone->compartments.empty());
|
||||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||||
|
|
||||||
/* Set up which zones will be collected. */
|
/* Set up which zones will be collected. */
|
||||||
|
@ -5207,7 +5210,8 @@ ArenaLists::foregroundFinalize(FreeOp *fop, AllocKind thingKind, SliceBudget &sl
|
||||||
|
|
||||||
// Join |arenaLists[thingKind]| and |sweepList| into a single list.
|
// Join |arenaLists[thingKind]| and |sweepList| into a single list.
|
||||||
ArenaList finalized = sweepList.toArenaList();
|
ArenaList finalized = sweepList.toArenaList();
|
||||||
arenaLists[thingKind] = finalized.insertListWithCursorAtEnd(arenaLists[thingKind]);
|
arenaLists[thingKind] =
|
||||||
|
finalized.insertListWithCursorAtEnd(arenaLists[thingKind]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5455,8 +5459,8 @@ GCRuntime::endSweepPhase(bool lastGC)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||||
for (unsigned i = 0 ; i < FINALIZE_LIMIT ; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
MOZ_ASSERT_IF(!IsBackgroundFinalized(AllocKind(i)) ||
|
MOZ_ASSERT_IF(!IsBackgroundFinalized(i) ||
|
||||||
!sweepOnBackgroundThread,
|
!sweepOnBackgroundThread,
|
||||||
!zone->arenas.arenaListsToSweep[i]);
|
!zone->arenas.arenaListsToSweep[i]);
|
||||||
}
|
}
|
||||||
|
@ -5530,9 +5534,9 @@ GCRuntime::compactPhase(JS::gcreason::Reason reason)
|
||||||
|
|
||||||
// Check that we did as much compaction as we should have. There
|
// Check that we did as much compaction as we should have. There
|
||||||
// should always be less than one arena's worth of free cells.
|
// should always be less than one arena's worth of free cells.
|
||||||
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i)));
|
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(i));
|
||||||
if (CanRelocateAllocKind(AllocKind(i))) {
|
if (CanRelocateAllocKind(i)) {
|
||||||
ArenaList &al = zone->arenas.arenaLists[i];
|
ArenaList &al = zone->arenas.arenaLists[i];
|
||||||
size_t freeCells = 0;
|
size_t freeCells = 0;
|
||||||
for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
|
for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
|
||||||
|
@ -5743,7 +5747,7 @@ GCRuntime::resetIncrementalGC(const char *reason)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
|
||||||
MOZ_ASSERT(!zone->needsIncrementalBarrier());
|
MOZ_ASSERT(!zone->needsIncrementalBarrier());
|
||||||
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6594,20 +6598,20 @@ gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
|
||||||
// Fixup compartment pointers in source to refer to target, and make sure
|
// Fixup compartment pointers in source to refer to target, and make sure
|
||||||
// type information generations are in sync.
|
// type information generations are in sync.
|
||||||
|
|
||||||
for (ZoneCellIter iter(source->zone(), FINALIZE_SCRIPT); !iter.done(); iter.next()) {
|
for (ZoneCellIter iter(source->zone(), AllocKind::SCRIPT); !iter.done(); iter.next()) {
|
||||||
JSScript *script = iter.get<JSScript>();
|
JSScript *script = iter.get<JSScript>();
|
||||||
MOZ_ASSERT(script->compartment() == source);
|
MOZ_ASSERT(script->compartment() == source);
|
||||||
script->compartment_ = target;
|
script->compartment_ = target;
|
||||||
script->setTypesGeneration(target->zone()->types.generation);
|
script->setTypesGeneration(target->zone()->types.generation);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ZoneCellIter iter(source->zone(), FINALIZE_BASE_SHAPE); !iter.done(); iter.next()) {
|
for (ZoneCellIter iter(source->zone(), AllocKind::BASE_SHAPE); !iter.done(); iter.next()) {
|
||||||
BaseShape *base = iter.get<BaseShape>();
|
BaseShape *base = iter.get<BaseShape>();
|
||||||
MOZ_ASSERT(base->compartment() == source);
|
MOZ_ASSERT(base->compartment() == source);
|
||||||
base->compartment_ = target;
|
base->compartment_ = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ZoneCellIter iter(source->zone(), FINALIZE_OBJECT_GROUP); !iter.done(); iter.next()) {
|
for (ZoneCellIter iter(source->zone(), AllocKind::OBJECT_GROUP); !iter.done(); iter.next()) {
|
||||||
ObjectGroup *group = iter.get<ObjectGroup>();
|
ObjectGroup *group = iter.get<ObjectGroup>();
|
||||||
group->setGeneration(target->zone()->types.generation);
|
group->setGeneration(target->zone()->types.generation);
|
||||||
group->compartment_ = target;
|
group->compartment_ = target;
|
||||||
|
@ -6615,8 +6619,8 @@ gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
|
||||||
|
|
||||||
// Fixup zone pointers in source's zone to refer to target's zone.
|
// Fixup zone pointers in source's zone to refer to target's zone.
|
||||||
|
|
||||||
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
|
for (ALL_ALLOC_KINDS(thingKind)) {
|
||||||
for (ArenaIter aiter(source->zone(), AllocKind(thingKind)); !aiter.done(); aiter.next()) {
|
for (ArenaIter aiter(source->zone(), thingKind); !aiter.done(); aiter.next()) {
|
||||||
ArenaHeader *aheader = aiter.get();
|
ArenaHeader *aheader = aiter.get();
|
||||||
aheader->zone = target->zone();
|
aheader->zone = target->zone();
|
||||||
}
|
}
|
||||||
|
@ -6753,7 +6757,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* Assert no baseline scripts are marked as active. */
|
/* Assert no baseline scripts are marked as active. */
|
||||||
for (ZoneCellIter i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIter i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
MOZ_ASSERT_IF(script->hasBaselineScript(), !script->baselineScript()->active());
|
MOZ_ASSERT_IF(script->hasBaselineScript(), !script->baselineScript()->active());
|
||||||
}
|
}
|
||||||
|
@ -6764,7 +6768,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
|
||||||
|
|
||||||
jit::InvalidateAll(fop, zone);
|
jit::InvalidateAll(fop, zone);
|
||||||
|
|
||||||
for (ZoneCellIter i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIter i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
jit::FinishInvalidation(fop, script);
|
jit::FinishInvalidation(fop, script);
|
||||||
|
|
||||||
|
@ -6782,7 +6786,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
|
||||||
void
|
void
|
||||||
js::PurgeJITCaches(Zone *zone)
|
js::PurgeJITCaches(Zone *zone)
|
||||||
{
|
{
|
||||||
for (ZoneCellIterUnderGC i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIterUnderGC i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
|
|
||||||
/* Discard Ion caches. */
|
/* Discard Ion caches. */
|
||||||
|
@ -6811,12 +6815,12 @@ ArenaLists::adoptArenas(JSRuntime *rt, ArenaLists *fromArenaLists)
|
||||||
|
|
||||||
fromArenaLists->purge();
|
fromArenaLists->purge();
|
||||||
|
|
||||||
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
|
for (ALL_ALLOC_KINDS(thingKind)) {
|
||||||
// When we enter a parallel section, we join the background
|
// When we enter a parallel section, we join the background
|
||||||
// thread, and we do not run GC while in the parallel section,
|
// thread, and we do not run GC while in the parallel section,
|
||||||
// so no finalizer should be active!
|
// so no finalizer should be active!
|
||||||
normalizeBackgroundFinalizeState(AllocKind(thingKind));
|
normalizeBackgroundFinalizeState(thingKind);
|
||||||
fromArenaLists->normalizeBackgroundFinalizeState(AllocKind(thingKind));
|
fromArenaLists->normalizeBackgroundFinalizeState(thingKind);
|
||||||
|
|
||||||
ArenaList *fromList = &fromArenaLists->arenaLists[thingKind];
|
ArenaList *fromList = &fromArenaLists->arenaLists[thingKind];
|
||||||
ArenaList *toList = &arenaLists[thingKind];
|
ArenaList *toList = &arenaLists[thingKind];
|
||||||
|
@ -6839,8 +6843,8 @@ bool
|
||||||
ArenaLists::containsArena(JSRuntime *rt, ArenaHeader *needle)
|
ArenaLists::containsArena(JSRuntime *rt, ArenaHeader *needle)
|
||||||
{
|
{
|
||||||
AutoLockGC lock(rt);
|
AutoLockGC lock(rt);
|
||||||
size_t allocKind = needle->getAllocKind();
|
ArenaList &list = arenaLists[needle->getAllocKind()];
|
||||||
for (ArenaHeader *aheader = arenaLists[allocKind].head(); aheader; aheader = aheader->next) {
|
for (ArenaHeader *aheader = list.head(); aheader; aheader = aheader->next) {
|
||||||
if (aheader == needle)
|
if (aheader == needle)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
222
js/src/jsgc.h
222
js/src/jsgc.h
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "mozilla/Atomics.h"
|
#include "mozilla/Atomics.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
|
#include "mozilla/EnumeratedArray.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/TypeTraits.h"
|
#include "mozilla/TypeTraits.h"
|
||||||
|
|
||||||
|
@ -63,96 +64,96 @@ enum State {
|
||||||
|
|
||||||
/* Map from C++ type to alloc kind. JSObject does not have a 1:1 mapping, so must use Arena::thingSize. */
|
/* Map from C++ type to alloc kind. JSObject does not have a 1:1 mapping, so must use Arena::thingSize. */
|
||||||
template <typename T> struct MapTypeToFinalizeKind {};
|
template <typename T> struct MapTypeToFinalizeKind {};
|
||||||
template <> struct MapTypeToFinalizeKind<JSScript> { static const AllocKind kind = FINALIZE_SCRIPT; };
|
template <> struct MapTypeToFinalizeKind<JSScript> { static const AllocKind kind = AllocKind::SCRIPT; };
|
||||||
template <> struct MapTypeToFinalizeKind<LazyScript> { static const AllocKind kind = FINALIZE_LAZY_SCRIPT; };
|
template <> struct MapTypeToFinalizeKind<LazyScript> { static const AllocKind kind = AllocKind::LAZY_SCRIPT; };
|
||||||
template <> struct MapTypeToFinalizeKind<Shape> { static const AllocKind kind = FINALIZE_SHAPE; };
|
template <> struct MapTypeToFinalizeKind<Shape> { static const AllocKind kind = AllocKind::SHAPE; };
|
||||||
template <> struct MapTypeToFinalizeKind<AccessorShape> { static const AllocKind kind = FINALIZE_ACCESSOR_SHAPE; };
|
template <> struct MapTypeToFinalizeKind<AccessorShape> { static const AllocKind kind = AllocKind::ACCESSOR_SHAPE; };
|
||||||
template <> struct MapTypeToFinalizeKind<BaseShape> { static const AllocKind kind = FINALIZE_BASE_SHAPE; };
|
template <> struct MapTypeToFinalizeKind<BaseShape> { static const AllocKind kind = AllocKind::BASE_SHAPE; };
|
||||||
template <> struct MapTypeToFinalizeKind<ObjectGroup> { static const AllocKind kind = FINALIZE_OBJECT_GROUP; };
|
template <> struct MapTypeToFinalizeKind<ObjectGroup> { static const AllocKind kind = AllocKind::OBJECT_GROUP; };
|
||||||
template <> struct MapTypeToFinalizeKind<JSFatInlineString> { static const AllocKind kind = FINALIZE_FAT_INLINE_STRING; };
|
template <> struct MapTypeToFinalizeKind<JSFatInlineString> { static const AllocKind kind = AllocKind::FAT_INLINE_STRING; };
|
||||||
template <> struct MapTypeToFinalizeKind<JSString> { static const AllocKind kind = FINALIZE_STRING; };
|
template <> struct MapTypeToFinalizeKind<JSString> { static const AllocKind kind = AllocKind::STRING; };
|
||||||
template <> struct MapTypeToFinalizeKind<JSExternalString> { static const AllocKind kind = FINALIZE_EXTERNAL_STRING; };
|
template <> struct MapTypeToFinalizeKind<JSExternalString> { static const AllocKind kind = AllocKind::EXTERNAL_STRING; };
|
||||||
template <> struct MapTypeToFinalizeKind<JS::Symbol> { static const AllocKind kind = FINALIZE_SYMBOL; };
|
template <> struct MapTypeToFinalizeKind<JS::Symbol> { static const AllocKind kind = AllocKind::SYMBOL; };
|
||||||
template <> struct MapTypeToFinalizeKind<jit::JitCode> { static const AllocKind kind = FINALIZE_JITCODE; };
|
template <> struct MapTypeToFinalizeKind<jit::JitCode> { static const AllocKind kind = AllocKind::JITCODE; };
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
IsNurseryAllocable(AllocKind kind)
|
IsNurseryAllocable(AllocKind kind)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(kind >= 0 && unsigned(kind) < FINALIZE_LIMIT);
|
MOZ_ASSERT(kind < AllocKind::LIMIT);
|
||||||
static const bool map[] = {
|
static const bool map[] = {
|
||||||
false, /* FINALIZE_OBJECT0 */
|
false, /* AllocKind::OBJECT0 */
|
||||||
true, /* FINALIZE_OBJECT0_BACKGROUND */
|
true, /* AllocKind::OBJECT0_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT2 */
|
false, /* AllocKind::OBJECT2 */
|
||||||
true, /* FINALIZE_OBJECT2_BACKGROUND */
|
true, /* AllocKind::OBJECT2_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT4 */
|
false, /* AllocKind::OBJECT4 */
|
||||||
true, /* FINALIZE_OBJECT4_BACKGROUND */
|
true, /* AllocKind::OBJECT4_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT8 */
|
false, /* AllocKind::OBJECT8 */
|
||||||
true, /* FINALIZE_OBJECT8_BACKGROUND */
|
true, /* AllocKind::OBJECT8_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT12 */
|
false, /* AllocKind::OBJECT12 */
|
||||||
true, /* FINALIZE_OBJECT12_BACKGROUND */
|
true, /* AllocKind::OBJECT12_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT16 */
|
false, /* AllocKind::OBJECT16 */
|
||||||
true, /* FINALIZE_OBJECT16_BACKGROUND */
|
true, /* AllocKind::OBJECT16_BACKGROUND */
|
||||||
false, /* FINALIZE_SCRIPT */
|
false, /* AllocKind::SCRIPT */
|
||||||
false, /* FINALIZE_LAZY_SCRIPT */
|
false, /* AllocKind::LAZY_SCRIPT */
|
||||||
false, /* FINALIZE_SHAPE */
|
false, /* AllocKind::SHAPE */
|
||||||
false, /* FINALIZE_ACCESSOR_SHAPE */
|
false, /* AllocKind::ACCESSOR_SHAPE */
|
||||||
false, /* FINALIZE_BASE_SHAPE */
|
false, /* AllocKind::BASE_SHAPE */
|
||||||
false, /* FINALIZE_OBJECT_GROUP */
|
false, /* AllocKind::OBJECT_GROUP */
|
||||||
false, /* FINALIZE_FAT_INLINE_STRING */
|
false, /* AllocKind::FAT_INLINE_STRING */
|
||||||
false, /* FINALIZE_STRING */
|
false, /* AllocKind::STRING */
|
||||||
false, /* FINALIZE_EXTERNAL_STRING */
|
false, /* AllocKind::EXTERNAL_STRING */
|
||||||
false, /* FINALIZE_SYMBOL */
|
false, /* AllocKind::SYMBOL */
|
||||||
false, /* FINALIZE_JITCODE */
|
false, /* AllocKind::JITCODE */
|
||||||
};
|
};
|
||||||
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == FINALIZE_LIMIT);
|
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
|
||||||
return map[kind];
|
return map[size_t(kind)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
IsBackgroundFinalized(AllocKind kind)
|
IsBackgroundFinalized(AllocKind kind)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(kind >= 0 && unsigned(kind) < FINALIZE_LIMIT);
|
MOZ_ASSERT(kind < AllocKind::LIMIT);
|
||||||
static const bool map[] = {
|
static const bool map[] = {
|
||||||
false, /* FINALIZE_OBJECT0 */
|
false, /* AllocKind::OBJECT0 */
|
||||||
true, /* FINALIZE_OBJECT0_BACKGROUND */
|
true, /* AllocKind::OBJECT0_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT2 */
|
false, /* AllocKind::OBJECT2 */
|
||||||
true, /* FINALIZE_OBJECT2_BACKGROUND */
|
true, /* AllocKind::OBJECT2_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT4 */
|
false, /* AllocKind::OBJECT4 */
|
||||||
true, /* FINALIZE_OBJECT4_BACKGROUND */
|
true, /* AllocKind::OBJECT4_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT8 */
|
false, /* AllocKind::OBJECT8 */
|
||||||
true, /* FINALIZE_OBJECT8_BACKGROUND */
|
true, /* AllocKind::OBJECT8_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT12 */
|
false, /* AllocKind::OBJECT12 */
|
||||||
true, /* FINALIZE_OBJECT12_BACKGROUND */
|
true, /* AllocKind::OBJECT12_BACKGROUND */
|
||||||
false, /* FINALIZE_OBJECT16 */
|
false, /* AllocKind::OBJECT16 */
|
||||||
true, /* FINALIZE_OBJECT16_BACKGROUND */
|
true, /* AllocKind::OBJECT16_BACKGROUND */
|
||||||
false, /* FINALIZE_SCRIPT */
|
false, /* AllocKind::SCRIPT */
|
||||||
false, /* FINALIZE_LAZY_SCRIPT */
|
false, /* AllocKind::LAZY_SCRIPT */
|
||||||
true, /* FINALIZE_SHAPE */
|
true, /* AllocKind::SHAPE */
|
||||||
true, /* FINALIZE_ACCESSOR_SHAPE */
|
true, /* AllocKind::ACCESSOR_SHAPE */
|
||||||
true, /* FINALIZE_BASE_SHAPE */
|
true, /* AllocKind::BASE_SHAPE */
|
||||||
true, /* FINALIZE_OBJECT_GROUP */
|
true, /* AllocKind::OBJECT_GROUP */
|
||||||
true, /* FINALIZE_FAT_INLINE_STRING */
|
true, /* AllocKind::FAT_INLINE_STRING */
|
||||||
true, /* FINALIZE_STRING */
|
true, /* AllocKind::STRING */
|
||||||
false, /* FINALIZE_EXTERNAL_STRING */
|
false, /* AllocKind::EXTERNAL_STRING */
|
||||||
true, /* FINALIZE_SYMBOL */
|
true, /* AllocKind::SYMBOL */
|
||||||
false, /* FINALIZE_JITCODE */
|
false, /* AllocKind::JITCODE */
|
||||||
};
|
};
|
||||||
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == FINALIZE_LIMIT);
|
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
|
||||||
return map[kind];
|
return map[size_t(kind)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
CanBeFinalizedInBackground(gc::AllocKind kind, const Class *clasp)
|
CanBeFinalizedInBackground(AllocKind kind, const Class *clasp)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(kind <= gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(kind <= AllocKind::OBJECT_LAST);
|
||||||
/* If the class has no finalizer or a finalizer that is safe to call on
|
/* If the class has no finalizer or a finalizer that is safe to call on
|
||||||
* a different thread, we change the finalize kind. For example,
|
* a different thread, we change the alloc kind. For example,
|
||||||
* FINALIZE_OBJECT0 calls the finalizer on the main thread,
|
* AllocKind::OBJECT0 calls the finalizer on the main thread,
|
||||||
* FINALIZE_OBJECT0_BACKGROUND calls the finalizer on the gcHelperThread.
|
* AllocKind::OBJECT0_BACKGROUND calls the finalizer on the gcHelperThread.
|
||||||
* IsBackgroundFinalized is called to prevent recursively incrementing
|
* IsBackgroundFinalized is called to prevent recursively incrementing
|
||||||
* the finalize kind; kind may already be a background finalize kind.
|
* the alloc kind; kind may already be a background finalize kind.
|
||||||
*/
|
*/
|
||||||
return (!gc::IsBackgroundFinalized(kind) &&
|
return (!IsBackgroundFinalized(kind) &&
|
||||||
(!clasp->finalize || (clasp->flags & JSCLASS_BACKGROUND_FINALIZE)));
|
(!clasp->finalize || (clasp->flags & JSCLASS_BACKGROUND_FINALIZE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ static inline AllocKind
|
||||||
GetGCObjectKind(size_t numSlots)
|
GetGCObjectKind(size_t numSlots)
|
||||||
{
|
{
|
||||||
if (numSlots >= SLOTS_TO_THING_KIND_LIMIT)
|
if (numSlots >= SLOTS_TO_THING_KIND_LIMIT)
|
||||||
return FINALIZE_OBJECT16;
|
return AllocKind::OBJECT16;
|
||||||
return slotsToThingKind[numSlots];
|
return slotsToThingKind[numSlots];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ GetGCArrayKind(size_t numSlots)
|
||||||
*/
|
*/
|
||||||
JS_STATIC_ASSERT(ObjectElements::VALUES_PER_HEADER == 2);
|
JS_STATIC_ASSERT(ObjectElements::VALUES_PER_HEADER == 2);
|
||||||
if (numSlots > NativeObject::NELEMENTS_LIMIT || numSlots + 2 >= SLOTS_TO_THING_KIND_LIMIT)
|
if (numSlots > NativeObject::NELEMENTS_LIMIT || numSlots + 2 >= SLOTS_TO_THING_KIND_LIMIT)
|
||||||
return FINALIZE_OBJECT2;
|
return AllocKind::OBJECT2;
|
||||||
return slotsToThingKind[numSlots + 2];
|
return slotsToThingKind[numSlots + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ GetGCObjectKindForBytes(size_t nbytes)
|
||||||
MOZ_ASSERT(nbytes <= JSObject::MAX_BYTE_SIZE);
|
MOZ_ASSERT(nbytes <= JSObject::MAX_BYTE_SIZE);
|
||||||
|
|
||||||
if (nbytes <= sizeof(NativeObject))
|
if (nbytes <= sizeof(NativeObject))
|
||||||
return FINALIZE_OBJECT0;
|
return AllocKind::OBJECT0;
|
||||||
nbytes -= sizeof(NativeObject);
|
nbytes -= sizeof(NativeObject);
|
||||||
|
|
||||||
size_t dataSlots = AlignBytes(nbytes, sizeof(Value)) / sizeof(Value);
|
size_t dataSlots = AlignBytes(nbytes, sizeof(Value)) / sizeof(Value);
|
||||||
|
@ -216,8 +217,8 @@ static inline AllocKind
|
||||||
GetBackgroundAllocKind(AllocKind kind)
|
GetBackgroundAllocKind(AllocKind kind)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!IsBackgroundFinalized(kind));
|
MOZ_ASSERT(!IsBackgroundFinalized(kind));
|
||||||
MOZ_ASSERT(kind <= FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(kind < AllocKind::OBJECT_LAST);
|
||||||
return (AllocKind) (kind + 1);
|
return AllocKind(size_t(kind) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the number of fixed slots and initial capacity associated with a kind. */
|
/* Get the number of fixed slots and initial capacity associated with a kind. */
|
||||||
|
@ -226,26 +227,26 @@ GetGCKindSlots(AllocKind thingKind)
|
||||||
{
|
{
|
||||||
/* Using a switch in hopes that thingKind will usually be a compile-time constant. */
|
/* Using a switch in hopes that thingKind will usually be a compile-time constant. */
|
||||||
switch (thingKind) {
|
switch (thingKind) {
|
||||||
case FINALIZE_OBJECT0:
|
case AllocKind::OBJECT0:
|
||||||
case FINALIZE_OBJECT0_BACKGROUND:
|
case AllocKind::OBJECT0_BACKGROUND:
|
||||||
return 0;
|
return 0;
|
||||||
case FINALIZE_OBJECT2:
|
case AllocKind::OBJECT2:
|
||||||
case FINALIZE_OBJECT2_BACKGROUND:
|
case AllocKind::OBJECT2_BACKGROUND:
|
||||||
return 2;
|
return 2;
|
||||||
case FINALIZE_OBJECT4:
|
case AllocKind::OBJECT4:
|
||||||
case FINALIZE_OBJECT4_BACKGROUND:
|
case AllocKind::OBJECT4_BACKGROUND:
|
||||||
return 4;
|
return 4;
|
||||||
case FINALIZE_OBJECT8:
|
case AllocKind::OBJECT8:
|
||||||
case FINALIZE_OBJECT8_BACKGROUND:
|
case AllocKind::OBJECT8_BACKGROUND:
|
||||||
return 8;
|
return 8;
|
||||||
case FINALIZE_OBJECT12:
|
case AllocKind::OBJECT12:
|
||||||
case FINALIZE_OBJECT12_BACKGROUND:
|
case AllocKind::OBJECT12_BACKGROUND:
|
||||||
return 12;
|
return 12;
|
||||||
case FINALIZE_OBJECT16:
|
case AllocKind::OBJECT16:
|
||||||
case FINALIZE_OBJECT16_BACKGROUND:
|
case AllocKind::OBJECT16_BACKGROUND:
|
||||||
return 16;
|
return 16;
|
||||||
default:
|
default:
|
||||||
MOZ_CRASH("Bad object finalize kind");
|
MOZ_CRASH("Bad object alloc kind");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +262,7 @@ GetGCKindSlots(AllocKind thingKind, const Class *clasp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions have a larger finalize kind than FINALIZE_OBJECT to reserve
|
* Functions have a larger alloc kind than AllocKind::OBJECT to reserve
|
||||||
* space for the extra fields in JSFunction, but have no fixed slots.
|
* space for the extra fields in JSFunction, but have no fixed slots.
|
||||||
*/
|
*/
|
||||||
if (clasp == FunctionClassPtr)
|
if (clasp == FunctionClassPtr)
|
||||||
|
@ -580,9 +581,9 @@ class ArenaLists
|
||||||
* GC we only move the head of the of the list of spans back to the arena
|
* GC we only move the head of the of the list of spans back to the arena
|
||||||
* only for the arena that was not fully allocated.
|
* only for the arena that was not fully allocated.
|
||||||
*/
|
*/
|
||||||
FreeList freeLists[FINALIZE_LIMIT];
|
AllAllocKindArray<FreeList> freeLists;
|
||||||
|
|
||||||
ArenaList arenaLists[FINALIZE_LIMIT];
|
AllAllocKindArray<ArenaList> arenaLists;
|
||||||
|
|
||||||
enum BackgroundFinalizeStateEnum { BFS_DONE, BFS_RUN };
|
enum BackgroundFinalizeStateEnum { BFS_DONE, BFS_RUN };
|
||||||
|
|
||||||
|
@ -590,14 +591,13 @@ class ArenaLists
|
||||||
BackgroundFinalizeState;
|
BackgroundFinalizeState;
|
||||||
|
|
||||||
/* The current background finalization state, accessed atomically. */
|
/* The current background finalization state, accessed atomically. */
|
||||||
BackgroundFinalizeState backgroundFinalizeState[FINALIZE_LIMIT];
|
AllAllocKindArray<BackgroundFinalizeState> backgroundFinalizeState;
|
||||||
|
|
||||||
public:
|
|
||||||
/* For each arena kind, a list of arenas remaining to be swept. */
|
/* For each arena kind, a list of arenas remaining to be swept. */
|
||||||
ArenaHeader *arenaListsToSweep[FINALIZE_LIMIT];
|
AllAllocKindArray<ArenaHeader *> arenaListsToSweep;
|
||||||
|
|
||||||
/* During incremental sweeping, a list of the arenas already swept. */
|
/* During incremental sweeping, a list of the arenas already swept. */
|
||||||
unsigned incrementalSweptArenaKind;
|
AllocKind incrementalSweptArenaKind;
|
||||||
ArenaList incrementalSweptArenas;
|
ArenaList incrementalSweptArenas;
|
||||||
|
|
||||||
// Arena lists which have yet to be swept, but need additional foreground
|
// Arena lists which have yet to be swept, but need additional foreground
|
||||||
|
@ -611,18 +611,18 @@ class ArenaLists
|
||||||
// objects which have already been finalized in the foreground (which must
|
// objects which have already been finalized in the foreground (which must
|
||||||
// happen at the beginning of the GC), so that type sweeping can determine
|
// happen at the beginning of the GC), so that type sweeping can determine
|
||||||
// which of the object pointers are marked.
|
// which of the object pointers are marked.
|
||||||
ArenaList savedObjectArenas[FINALIZE_OBJECT_LIMIT];
|
ObjectAllocKindArray<ArenaList> savedObjectArenas;
|
||||||
ArenaHeader *savedEmptyObjectArenas;
|
ArenaHeader *savedEmptyObjectArenas;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ArenaLists(JSRuntime *rt) : runtime_(rt) {
|
explicit ArenaLists(JSRuntime *rt) : runtime_(rt) {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
freeLists[i].initAsEmpty();
|
freeLists[i].initAsEmpty();
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
backgroundFinalizeState[i] = BFS_DONE;
|
backgroundFinalizeState[i] = BFS_DONE;
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
arenaListsToSweep[i] = nullptr;
|
arenaListsToSweep[i] = nullptr;
|
||||||
incrementalSweptArenaKind = FINALIZE_LIMIT;
|
incrementalSweptArenaKind = AllocKind::LIMIT;
|
||||||
gcShapeArenasToUpdate = nullptr;
|
gcShapeArenasToUpdate = nullptr;
|
||||||
gcAccessorShapeArenasToUpdate = nullptr;
|
gcAccessorShapeArenasToUpdate = nullptr;
|
||||||
gcScriptArenasToUpdate = nullptr;
|
gcScriptArenasToUpdate = nullptr;
|
||||||
|
@ -634,7 +634,7 @@ class ArenaLists
|
||||||
|
|
||||||
static uintptr_t getFreeListOffset(AllocKind thingKind) {
|
static uintptr_t getFreeListOffset(AllocKind thingKind) {
|
||||||
uintptr_t offset = offsetof(ArenaLists, freeLists);
|
uintptr_t offset = offsetof(ArenaLists, freeLists);
|
||||||
return offset + thingKind * sizeof(FreeList);
|
return offset + size_t(thingKind) * sizeof(FreeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FreeList *getFreeList(AllocKind thingKind) const {
|
const FreeList *getFreeList(AllocKind thingKind) const {
|
||||||
|
@ -660,7 +660,7 @@ class ArenaLists
|
||||||
}
|
}
|
||||||
|
|
||||||
bool arenaListsAreEmpty() const {
|
bool arenaListsAreEmpty() const {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
/*
|
/*
|
||||||
* The arena cannot be empty if the background finalization is not yet
|
* The arena cannot be empty if the background finalization is not yet
|
||||||
* done.
|
* done.
|
||||||
|
@ -674,7 +674,7 @@ class ArenaLists
|
||||||
}
|
}
|
||||||
|
|
||||||
void unmarkAll() {
|
void unmarkAll() {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i) {
|
for (ALL_ALLOC_KINDS(i)) {
|
||||||
/* The background finalization must have stopped at this point. */
|
/* The background finalization must have stopped at this point. */
|
||||||
MOZ_ASSERT(backgroundFinalizeState[i] == BFS_DONE);
|
MOZ_ASSERT(backgroundFinalizeState[i] == BFS_DONE);
|
||||||
for (ArenaHeader *aheader = arenaLists[i].head(); aheader; aheader = aheader->next)
|
for (ArenaHeader *aheader = arenaLists[i].head(); aheader; aheader = aheader->next)
|
||||||
|
@ -695,8 +695,8 @@ class ArenaLists
|
||||||
* run the finalizers over unitialized bytes from free things.
|
* run the finalizers over unitialized bytes from free things.
|
||||||
*/
|
*/
|
||||||
void purge() {
|
void purge() {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
purge(AllocKind(i));
|
purge(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void purge(AllocKind i) {
|
void purge(AllocKind i) {
|
||||||
|
@ -716,8 +716,8 @@ class ArenaLists
|
||||||
* outside the GC.
|
* outside the GC.
|
||||||
*/
|
*/
|
||||||
void copyFreeListsToArenas() {
|
void copyFreeListsToArenas() {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
copyFreeListToArena(AllocKind(i));
|
copyFreeListToArena(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copyFreeListToArena(AllocKind thingKind) {
|
void copyFreeListToArena(AllocKind thingKind) {
|
||||||
|
@ -734,8 +734,8 @@ class ArenaLists
|
||||||
* copyToArenas.
|
* copyToArenas.
|
||||||
*/
|
*/
|
||||||
void clearFreeListsInArenas() {
|
void clearFreeListsInArenas() {
|
||||||
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
clearFreeListInArena(AllocKind(i));
|
clearFreeListInArena(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearFreeListInArena(AllocKind kind) {
|
void clearFreeListInArena(AllocKind kind) {
|
||||||
|
@ -795,8 +795,8 @@ class ArenaLists
|
||||||
|
|
||||||
void checkEmptyFreeLists() {
|
void checkEmptyFreeLists() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (size_t i = 0; i < mozilla::ArrayLength(freeLists); ++i)
|
for (ALL_ALLOC_KINDS(i))
|
||||||
MOZ_ASSERT(freeLists[i].isEmpty());
|
checkEmptyFreeList(i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ using mozilla::PodZero;
|
||||||
|
|
||||||
typedef Rooted<PropertyIteratorObject*> RootedPropertyIteratorObject;
|
typedef Rooted<PropertyIteratorObject*> RootedPropertyIteratorObject;
|
||||||
|
|
||||||
static const gc::AllocKind ITERATOR_FINALIZE_KIND = gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const gc::AllocKind ITERATOR_FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
|
|
||||||
void
|
void
|
||||||
NativeIterator::mark(JSTracer *trc)
|
NativeIterator::mark(JSTracer *trc)
|
||||||
|
|
|
@ -1094,10 +1094,10 @@ static inline gc::AllocKind
|
||||||
NewObjectGCKind(const js::Class *clasp)
|
NewObjectGCKind(const js::Class *clasp)
|
||||||
{
|
{
|
||||||
if (clasp == &ArrayObject::class_)
|
if (clasp == &ArrayObject::class_)
|
||||||
return gc::FINALIZE_OBJECT8;
|
return gc::AllocKind::OBJECT8;
|
||||||
if (clasp == &JSFunction::class_)
|
if (clasp == &JSFunction::class_)
|
||||||
return gc::FINALIZE_OBJECT2;
|
return gc::AllocKind::OBJECT2;
|
||||||
return gc::FINALIZE_OBJECT4;
|
return gc::AllocKind::OBJECT4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline JSObject *
|
static inline JSObject *
|
||||||
|
@ -1407,7 +1407,7 @@ js::NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group, Hand
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(parent);
|
MOZ_ASSERT(parent);
|
||||||
|
|
||||||
MOZ_ASSERT(allocKind <= gc::FINALIZE_OBJECT_LAST);
|
MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
|
||||||
if (CanBeFinalizedInBackground(allocKind, group->clasp()))
|
if (CanBeFinalizedInBackground(allocKind, group->clasp()))
|
||||||
allocKind = GetBackgroundAllocKind(allocKind);
|
allocKind = GetBackgroundAllocKind(allocKind);
|
||||||
|
|
||||||
|
@ -1482,7 +1482,7 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group,
|
||||||
if (TypeNewScript *newScript = group->newScript()) {
|
if (TypeNewScript *newScript = group->newScript()) {
|
||||||
if (newScript->analyzed()) {
|
if (newScript->analyzed()) {
|
||||||
// The definite properties analysis has been performed for this
|
// The definite properties analysis has been performed for this
|
||||||
// group, so get the shape and finalize kind to use from the
|
// group, so get the shape and alloc kind to use from the
|
||||||
// TypeNewScript's template.
|
// TypeNewScript's template.
|
||||||
RootedPlainObject templateObject(cx, newScript->templateObject());
|
RootedPlainObject templateObject(cx, newScript->templateObject());
|
||||||
MOZ_ASSERT(templateObject->group() == group);
|
MOZ_ASSERT(templateObject->group() == group);
|
||||||
|
|
|
@ -755,7 +755,7 @@ GuessObjectGCKind(size_t numSlots)
|
||||||
{
|
{
|
||||||
if (numSlots)
|
if (numSlots)
|
||||||
return gc::GetGCObjectKind(numSlots);
|
return gc::GetGCObjectKind(numSlots);
|
||||||
return gc::FINALIZE_OBJECT4;
|
return gc::AllocKind::OBJECT4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline gc::AllocKind
|
static inline gc::AllocKind
|
||||||
|
@ -763,7 +763,7 @@ GuessArrayGCKind(size_t numSlots)
|
||||||
{
|
{
|
||||||
if (numSlots)
|
if (numSlots)
|
||||||
return gc::GetGCArrayKind(numSlots);
|
return gc::GetGCArrayKind(numSlots);
|
||||||
return gc::FINALIZE_OBJECT8;
|
return gc::AllocKind::OBJECT8;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
|
|
|
@ -281,7 +281,7 @@ js::DumpPCCounts(JSContext *cx, HandleScript script, Sprinter *sp)
|
||||||
void
|
void
|
||||||
js::DumpCompartmentPCCounts(JSContext *cx)
|
js::DumpCompartmentPCCounts(JSContext *cx)
|
||||||
{
|
{
|
||||||
for (ZoneCellIter i(cx->zone(), gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIter i(cx->zone(), gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
RootedScript script(cx, i.get<JSScript>());
|
RootedScript script(cx, i.get<JSScript>());
|
||||||
if (script->compartment() != cx->compartment())
|
if (script->compartment() != cx->compartment())
|
||||||
continue;
|
continue;
|
||||||
|
@ -298,8 +298,8 @@ js::DumpCompartmentPCCounts(JSContext *cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned thingKind = FINALIZE_OBJECT0; thingKind < FINALIZE_OBJECT_LIMIT; thingKind++) {
|
for (OBJECT_ALLOC_KINDS(thingKind)) {
|
||||||
for (ZoneCellIter i(cx->zone(), (AllocKind) thingKind); !i.done(); i.next()) {
|
for (ZoneCellIter i(cx->zone(), thingKind); !i.done(); i.next()) {
|
||||||
JSObject *obj = i.get<JSObject>();
|
JSObject *obj = i.get<JSObject>();
|
||||||
if (obj->compartment() != cx->compartment())
|
if (obj->compartment() != cx->compartment())
|
||||||
continue;
|
continue;
|
||||||
|
@ -2042,7 +2042,7 @@ js::StopPCCountProfiling(JSContext *cx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
|
||||||
for (ZoneCellIter i(zone, FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (ZoneCellIter i(zone, AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
JSScript *script = i.get<JSScript>();
|
JSScript *script = i.get<JSScript>();
|
||||||
if (script->hasScriptCounts() && script->types()) {
|
if (script->hasScriptCounts() && script->types()) {
|
||||||
ScriptAndCounts sac;
|
ScriptAndCounts sac;
|
||||||
|
|
|
@ -240,10 +240,10 @@ Shape::fixupDictionaryShapeAfterMovingGC()
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocKind kind = TenuredCell::fromPointer(cell)->getAllocKind();
|
AllocKind kind = TenuredCell::fromPointer(cell)->getAllocKind();
|
||||||
MOZ_ASSERT(kind == FINALIZE_SHAPE ||
|
MOZ_ASSERT(kind == AllocKind::SHAPE ||
|
||||||
kind == FINALIZE_ACCESSOR_SHAPE ||
|
kind == AllocKind::ACCESSOR_SHAPE ||
|
||||||
kind <= FINALIZE_OBJECT_LAST);
|
kind <= AllocKind::OBJECT_LAST);
|
||||||
if (kind == FINALIZE_SHAPE || kind == FINALIZE_ACCESSOR_SHAPE) {
|
if (kind == AllocKind::SHAPE || kind == AllocKind::ACCESSOR_SHAPE) {
|
||||||
// listp points to the parent field of the next shape.
|
// listp points to the parent field of the next shape.
|
||||||
Shape *next = reinterpret_cast<Shape *>(uintptr_t(listp) -
|
Shape *next = reinterpret_cast<Shape *>(uintptr_t(listp) -
|
||||||
offsetof(Shape, parent));
|
offsetof(Shape, parent));
|
||||||
|
|
|
@ -129,7 +129,7 @@ class ArgumentsObject : public NativeObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const uint32_t RESERVED_SLOTS = 3;
|
static const uint32_t RESERVED_SLOTS = 3;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT4_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;
|
||||||
|
|
||||||
/* Create an arguments object for a frame that is expecting them. */
|
/* Create an arguments object for a frame that is expecting them. */
|
||||||
static ArgumentsObject *createExpected(JSContext *cx, AbstractFramePtr frame);
|
static ArgumentsObject *createExpected(JSContext *cx, AbstractFramePtr frame);
|
||||||
|
|
|
@ -91,7 +91,7 @@ ArrayObject::createArray(ExclusiveContext *cx, gc::InitialHeap heap,
|
||||||
// Use the smallest allocation kind for the array, as it can't have any
|
// Use the smallest allocation kind for the array, as it can't have any
|
||||||
// fixed slots (see the assert in createArrayInternal) and will not be using
|
// fixed slots (see the assert in createArrayInternal) and will not be using
|
||||||
// its fixed elements.
|
// its fixed elements.
|
||||||
gc::AllocKind kind = gc::FINALIZE_OBJECT0_BACKGROUND;
|
gc::AllocKind kind = gc::AllocKind::OBJECT0_BACKGROUND;
|
||||||
|
|
||||||
ArrayObject *obj = createArrayInternal(cx, kind, heap, shape, group);
|
ArrayObject *obj = createArrayInternal(cx, kind, heap, shape, group);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
|
@ -113,7 +113,7 @@ ArrayObject::createCopyOnWriteArray(ExclusiveContext *cx, gc::InitialHeap heap,
|
||||||
// Use the smallest allocation kind for the array, as it can't have any
|
// Use the smallest allocation kind for the array, as it can't have any
|
||||||
// fixed slots (see the assert in createArrayInternal) and will not be using
|
// fixed slots (see the assert in createArrayInternal) and will not be using
|
||||||
// its fixed elements.
|
// its fixed elements.
|
||||||
gc::AllocKind kind = gc::FINALIZE_OBJECT0_BACKGROUND;
|
gc::AllocKind kind = gc::AllocKind::OBJECT0_BACKGROUND;
|
||||||
|
|
||||||
RootedObjectGroup group(cx, sharedElementsOwner->group());
|
RootedObjectGroup group(cx, sharedElementsOwner->group());
|
||||||
ArrayObject *obj = createArrayInternal(cx, kind, heap, shape, group);
|
ArrayObject *obj = createArrayInternal(cx, kind, heap, shape, group);
|
||||||
|
|
|
@ -1930,7 +1930,7 @@ UpdateExecutionObservabilityOfScriptsInZone(JSContext *cx, Zone *zone,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (gc::ZoneCellIter iter(zone, gc::FINALIZE_SCRIPT); !iter.done(); iter.next()) {
|
for (gc::ZoneCellIter iter(zone, gc::AllocKind::SCRIPT); !iter.done(); iter.next()) {
|
||||||
JSScript *script = iter.get<JSScript>();
|
JSScript *script = iter.get<JSScript>();
|
||||||
if (obs.shouldRecompileOrInvalidate(script) &&
|
if (obs.shouldRecompileOrInvalidate(script) &&
|
||||||
!gc::IsScriptAboutToBeFinalized(&script))
|
!gc::IsScriptAboutToBeFinalized(&script))
|
||||||
|
|
|
@ -910,7 +910,7 @@ GlobalHelperThreadState::finishParseTask(JSContext *maybecx, JSRuntime *rt, void
|
||||||
// state, so finish any ongoing GC first and assert that we can't trigger
|
// state, so finish any ongoing GC first and assert that we can't trigger
|
||||||
// another one.
|
// another one.
|
||||||
gc::AutoFinishGC finishGC(rt);
|
gc::AutoFinishGC finishGC(rt);
|
||||||
for (gc::ZoneCellIter iter(parseTask->cx->zone(), gc::FINALIZE_OBJECT_GROUP);
|
for (gc::ZoneCellIter iter(parseTask->cx->zone(), gc::AllocKind::OBJECT_GROUP);
|
||||||
!iter.done();
|
!iter.done();
|
||||||
iter.next())
|
iter.next())
|
||||||
{
|
{
|
||||||
|
|
|
@ -232,7 +232,7 @@ class NewObjectCache
|
||||||
|
|
||||||
static void staticAsserts() {
|
static void staticAsserts() {
|
||||||
JS_STATIC_ASSERT(NewObjectCache::MAX_OBJ_SIZE == sizeof(JSObject_Slots16));
|
JS_STATIC_ASSERT(NewObjectCache::MAX_OBJ_SIZE == sizeof(JSObject_Slots16));
|
||||||
JS_STATIC_ASSERT(gc::FINALIZE_OBJECT_LAST == gc::FINALIZE_OBJECT16_BACKGROUND);
|
JS_STATIC_ASSERT(gc::AllocKind::OBJECT_LAST == gc::AllocKind::OBJECT16_BACKGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Entry
|
struct Entry
|
||||||
|
@ -318,7 +318,7 @@ class NewObjectCache
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EntryIndex makeIndex(const Class *clasp, gc::Cell *key, gc::AllocKind kind) {
|
EntryIndex makeIndex(const Class *clasp, gc::Cell *key, gc::AllocKind kind) {
|
||||||
uintptr_t hash = (uintptr_t(clasp) ^ uintptr_t(key)) + kind;
|
uintptr_t hash = (uintptr_t(clasp) ^ uintptr_t(key)) + size_t(kind);
|
||||||
return hash % mozilla::ArrayLength(entries);
|
return hash % mozilla::ArrayLength(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ class DeclEnvObject : public ScopeObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const uint32_t RESERVED_SLOTS = 2;
|
static const uint32_t RESERVED_SLOTS = 2;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ class StaticEvalObject : public ScopeObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const unsigned RESERVED_SLOTS = 2;
|
static const unsigned RESERVED_SLOTS = 2;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ class StaticWithObject : public NestedScopeObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const unsigned RESERVED_SLOTS = 1;
|
static const unsigned RESERVED_SLOTS = 1;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ class DynamicWithObject : public NestedScopeObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const unsigned RESERVED_SLOTS = 4;
|
static const unsigned RESERVED_SLOTS = 4;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT4_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ class BlockObject : public NestedScopeObject
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const unsigned RESERVED_SLOTS = 2;
|
static const unsigned RESERVED_SLOTS = 2;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT4_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT4_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ class UninitializedLexicalObject : public ScopeObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const unsigned RESERVED_SLOTS = 1;
|
static const unsigned RESERVED_SLOTS = 1;
|
||||||
static const gc::AllocKind FINALIZE_KIND = gc::FINALIZE_OBJECT2_BACKGROUND;
|
static const gc::AllocKind FINALIZE_KIND = gc::AllocKind::OBJECT2_BACKGROUND;
|
||||||
|
|
||||||
static const Class class_;
|
static const Class class_;
|
||||||
|
|
||||||
|
|
|
@ -777,7 +777,7 @@ class Shape : public gc::TenuredCell
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAccessorShape() const {
|
bool isAccessorShape() const {
|
||||||
MOZ_ASSERT_IF(flags & ACCESSOR_SHAPE, getAllocKind() == gc::FINALIZE_ACCESSOR_SHAPE);
|
MOZ_ASSERT_IF(flags & ACCESSOR_SHAPE, getAllocKind() == gc::AllocKind::ACCESSOR_SHAPE);
|
||||||
return flags & ACCESSOR_SHAPE;
|
return flags & ACCESSOR_SHAPE;
|
||||||
}
|
}
|
||||||
AccessorShape &asAccessorShape() const {
|
AccessorShape &asAccessorShape() const {
|
||||||
|
@ -1372,8 +1372,8 @@ Shape::Shape(const StackShape &other, uint32_t nfixed)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gc::AllocKind allocKind = getAllocKind();
|
gc::AllocKind allocKind = getAllocKind();
|
||||||
MOZ_ASSERT_IF(other.isAccessorShape(), allocKind == gc::FINALIZE_ACCESSOR_SHAPE);
|
MOZ_ASSERT_IF(other.isAccessorShape(), allocKind == gc::AllocKind::ACCESSOR_SHAPE);
|
||||||
MOZ_ASSERT_IF(allocKind == gc::FINALIZE_SHAPE, !other.isAccessorShape());
|
MOZ_ASSERT_IF(allocKind == gc::AllocKind::SHAPE, !other.isAccessorShape());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
|
MOZ_ASSERT_IF(attrs & (JSPROP_GETTER | JSPROP_SETTER), attrs & JSPROP_SHARED);
|
||||||
|
@ -1386,7 +1386,7 @@ AccessorShape::AccessorShape(const StackShape &other, uint32_t nfixed)
|
||||||
rawGetter(other.rawGetter),
|
rawGetter(other.rawGetter),
|
||||||
rawSetter(other.rawSetter)
|
rawSetter(other.rawSetter)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(getAllocKind() == gc::FINALIZE_ACCESSOR_SHAPE);
|
MOZ_ASSERT(getAllocKind() == gc::AllocKind::ACCESSOR_SHAPE);
|
||||||
|
|
||||||
if ((attrs & JSPROP_GETTER) && rawGetter)
|
if ((attrs & JSPROP_GETTER) && rawGetter)
|
||||||
GetterSetterWriteBarrierPost(this, &this->getterObj);
|
GetterSetterWriteBarrierPost(this, &this->getterObj);
|
||||||
|
|
|
@ -351,7 +351,7 @@ MOZ_ALWAYS_INLINE void
|
||||||
JSString::finalize(js::FreeOp *fop)
|
JSString::finalize(js::FreeOp *fop)
|
||||||
{
|
{
|
||||||
/* FatInline strings are in a different arena. */
|
/* FatInline strings are in a different arena. */
|
||||||
MOZ_ASSERT(getAllocKind() != js::gc::FINALIZE_FAT_INLINE_STRING);
|
MOZ_ASSERT(getAllocKind() != js::gc::AllocKind::FAT_INLINE_STRING);
|
||||||
|
|
||||||
if (isFlat())
|
if (isFlat())
|
||||||
asFlat().finalize(fop);
|
asFlat().finalize(fop);
|
||||||
|
@ -362,7 +362,7 @@ JSString::finalize(js::FreeOp *fop)
|
||||||
inline void
|
inline void
|
||||||
JSFlatString::finalize(js::FreeOp *fop)
|
JSFlatString::finalize(js::FreeOp *fop)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(getAllocKind() != js::gc::FINALIZE_FAT_INLINE_STRING);
|
MOZ_ASSERT(getAllocKind() != js::gc::AllocKind::FAT_INLINE_STRING);
|
||||||
|
|
||||||
if (!isInline())
|
if (!isInline())
|
||||||
fop->free_(nonInlineCharsRaw());
|
fop->free_(nonInlineCharsRaw());
|
||||||
|
@ -371,7 +371,7 @@ JSFlatString::finalize(js::FreeOp *fop)
|
||||||
inline void
|
inline void
|
||||||
JSFatInlineString::finalize(js::FreeOp *fop)
|
JSFatInlineString::finalize(js::FreeOp *fop)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(getAllocKind() == js::gc::FINALIZE_FAT_INLINE_STRING);
|
MOZ_ASSERT(getAllocKind() == js::gc::AllocKind::FAT_INLINE_STRING);
|
||||||
|
|
||||||
if (!isInline())
|
if (!isInline())
|
||||||
fop->free_(nonInlineCharsRaw());
|
fop->free_(nonInlineCharsRaw());
|
||||||
|
|
|
@ -464,7 +464,7 @@ class JSString : public js::gc::TenuredCell
|
||||||
js::gc::MarkStringUnbarriered(trc, &d.s.u3.base, "base");
|
js::gc::MarkStringUnbarriered(trc, &d.s.u3.base, "base");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only called by the GC for strings with the FINALIZE_STRING kind. */
|
/* Only called by the GC for strings with the AllocKind::STRING kind. */
|
||||||
|
|
||||||
inline void finalize(js::FreeOp *fop);
|
inline void finalize(js::FreeOp *fop);
|
||||||
|
|
||||||
|
@ -876,7 +876,7 @@ class JSFatInlineString : public JSInlineString
|
||||||
template<typename CharT>
|
template<typename CharT>
|
||||||
static bool lengthFits(size_t length);
|
static bool lengthFits(size_t length);
|
||||||
|
|
||||||
/* Only called by the GC for strings with the FINALIZE_FAT_INLINE_STRING kind. */
|
/* Only called by the GC for strings with the AllocKind::FAT_INLINE_STRING kind. */
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE void finalize(js::FreeOp *fop);
|
MOZ_ALWAYS_INLINE void finalize(js::FreeOp *fop);
|
||||||
};
|
};
|
||||||
|
@ -910,7 +910,7 @@ class JSExternalString : public JSFlatString
|
||||||
return rawTwoByteChars();
|
return rawTwoByteChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only called by the GC for strings with the FINALIZE_EXTERNAL_STRING kind. */
|
/* Only called by the GC for strings with the AllocKind::EXTERNAL_STRING kind. */
|
||||||
|
|
||||||
inline void finalize(js::FreeOp *fop);
|
inline void finalize(js::FreeOp *fop);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2476,13 +2476,13 @@ js::PrintTypes(JSContext *cx, JSCompartment *comp, bool force)
|
||||||
if (!force && !InferSpewActive(ISpewResult))
|
if (!force && !InferSpewActive(ISpewResult))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (gc::ZoneCellIter i(zone, gc::FINALIZE_SCRIPT); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone, gc::AllocKind::SCRIPT); !i.done(); i.next()) {
|
||||||
RootedScript script(cx, i.get<JSScript>());
|
RootedScript script(cx, i.get<JSScript>());
|
||||||
if (script->types())
|
if (script->types())
|
||||||
script->types()->printTypes(cx, script);
|
script->types()->printTypes(cx, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (gc::ZoneCellIter i(zone, gc::FINALIZE_OBJECT_GROUP); !i.done(); i.next()) {
|
for (gc::ZoneCellIter i(zone, gc::AllocKind::OBJECT_GROUP); !i.done(); i.next()) {
|
||||||
ObjectGroup *group = i.get<ObjectGroup>();
|
ObjectGroup *group = i.get<ObjectGroup>();
|
||||||
group->print();
|
group->print();
|
||||||
}
|
}
|
||||||
|
@ -4253,7 +4253,7 @@ TypeZone::endSweep(JSRuntime *rt)
|
||||||
void
|
void
|
||||||
TypeZone::clearAllNewScriptsOnOOM()
|
TypeZone::clearAllNewScriptsOnOOM()
|
||||||
{
|
{
|
||||||
for (gc::ZoneCellIterUnderGC iter(zone(), gc::FINALIZE_OBJECT_GROUP);
|
for (gc::ZoneCellIterUnderGC iter(zone(), gc::AllocKind::OBJECT_GROUP);
|
||||||
!iter.done(); iter.next())
|
!iter.done(); iter.next())
|
||||||
{
|
{
|
||||||
ObjectGroup *group = iter.get<ObjectGroup>();
|
ObjectGroup *group = iter.get<ObjectGroup>();
|
||||||
|
|
|
@ -178,7 +178,7 @@ class XDRState {
|
||||||
{
|
{
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
if (mode == XDR_ENCODE)
|
if (mode == XDR_ENCODE)
|
||||||
tmp = *val;
|
tmp = uint32_t(*val);
|
||||||
if (!codeUint32(&tmp))
|
if (!codeUint32(&tmp))
|
||||||
return false;
|
return false;
|
||||||
if (mode == XDR_DECODE)
|
if (mode == XDR_DECODE)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче