Bug 1139552 - Convert js::gc::AllocKind to an enum class and eliminate non-AllocKind indexing. r=terrence

This commit is contained in:
Emanuel Hoogeveen 2015-03-13 02:13:00 +01:00
Родитель d36e9cdd88
Коммит b84e0849ec
35 изменённых файлов: 479 добавлений и 456 удалений

Просмотреть файл

@ -1487,7 +1487,8 @@ OutlineTypedObject::createUnattachedWithClass(JSContext *cx,
NewObjectKind newKind = (heap == gc::TenuredHeap) ? MaybeSingletonObject : GenericObject;
OutlineTypedObject *obj = NewObjectWithGroup<OutlineTypedObject>(cx, group, cx->global(),
gc::FINALIZE_OBJECT0, newKind);
gc::AllocKind::OBJECT0,
newKind);
if (!obj)
return nullptr;

Просмотреть файл

@ -108,10 +108,10 @@ CheckAllocatorState(ExclusiveContext *cx, AllocKind kind)
JSRuntime *rt = ncx->runtime();
#if defined(JS_GC_ZEAL) || defined(DEBUG)
MOZ_ASSERT_IF(rt->isAtomsCompartment(ncx->compartment()),
kind == FINALIZE_STRING ||
kind == FINALIZE_FAT_INLINE_STRING ||
kind == FINALIZE_SYMBOL ||
kind == FINALIZE_JITCODE);
kind == AllocKind::STRING ||
kind == AllocKind::FAT_INLINE_STRING ||
kind == AllocKind::SYMBOL ||
kind == AllocKind::JITCODE);
MOZ_ASSERT(!rt->isHeapBusy());
MOZ_ASSERT(rt->gc.isAllocAllowed());
#endif
@ -156,7 +156,7 @@ js::Allocate(ExclusiveContext *cx, AllocKind kind, size_t nDynamicSlots, Initial
const Class *clasp)
{
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);
MOZ_ASSERT(thingSize == Arena::thingSize(kind));

Просмотреть файл

@ -18,8 +18,8 @@
using namespace js;
using namespace js::gc;
JS_STATIC_ASSERT(AllocKinds == FINALIZE_LIMIT);
JS_STATIC_ASSERT(LastObjectAllocKind == FINALIZE_OBJECT_LAST);
JS_STATIC_ASSERT(AllocKinds == unsigned(AllocKind::LIMIT));
JS_STATIC_ASSERT(LastObjectAllocKind == unsigned(AllocKind::OBJECT_LAST));
static FILE *gcTraceFile = nullptr;
@ -99,8 +99,8 @@ js::gc::InitTrace(GCRuntime &gc)
TraceEvent(TraceEventInit, 0, TraceFormatVersion);
/* Trace information about thing sizes. */
for (unsigned kind = 0; kind < FINALIZE_LIMIT; ++kind)
TraceEvent(TraceEventThingSize, Arena::thingSize((AllocKind)kind));
for (ALL_ALLOC_KINDS(kind))
TraceEvent(TraceEventThingSize, Arena::thingSize(kind));
return true;
}
@ -229,7 +229,7 @@ js::gc::TraceTenuredFinalize(Cell *thing)
{
if (!gcTraceFile)
return;
if (thing->tenuredGetAllocKind() == FINALIZE_OBJECT_GROUP)
if (thing->tenuredGetAllocKind() == AllocKind::OBJECT_GROUP)
tracedGroups.remove(static_cast<const ObjectGroup *>(thing));
TraceEvent(TraceEventTenuredFinalize, uint64_t(thing));
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Atomics.h"
#include "mozilla/Attributes.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/PodOperations.h"
#include <stddef.h>
@ -75,76 +76,92 @@ enum InitialHeap {
};
/* The GC allocation kinds. */
enum AllocKind {
FINALIZE_OBJECT0,
FINALIZE_OBJECT0_BACKGROUND,
FINALIZE_OBJECT2,
FINALIZE_OBJECT2_BACKGROUND,
FINALIZE_OBJECT4,
FINALIZE_OBJECT4_BACKGROUND,
FINALIZE_OBJECT8,
FINALIZE_OBJECT8_BACKGROUND,
FINALIZE_OBJECT12,
FINALIZE_OBJECT12_BACKGROUND,
FINALIZE_OBJECT16,
FINALIZE_OBJECT16_BACKGROUND,
FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16_BACKGROUND,
FINALIZE_SCRIPT,
FINALIZE_LAZY_SCRIPT,
FINALIZE_SHAPE,
FINALIZE_ACCESSOR_SHAPE,
FINALIZE_BASE_SHAPE,
FINALIZE_OBJECT_GROUP,
FINALIZE_FAT_INLINE_STRING,
FINALIZE_STRING,
FINALIZE_EXTERNAL_STRING,
FINALIZE_SYMBOL,
FINALIZE_JITCODE,
FINALIZE_LAST = FINALIZE_JITCODE
enum class AllocKind : uint8_t {
FIRST,
OBJECT0 = FIRST,
OBJECT0_BACKGROUND,
OBJECT2,
OBJECT2_BACKGROUND,
OBJECT4,
OBJECT4_BACKGROUND,
OBJECT8,
OBJECT8_BACKGROUND,
OBJECT12,
OBJECT12_BACKGROUND,
OBJECT16,
OBJECT16_BACKGROUND,
OBJECT_LIMIT,
OBJECT_LAST = OBJECT_LIMIT - 1,
SCRIPT,
LAZY_SCRIPT,
SHAPE,
ACCESSOR_SHAPE,
BASE_SHAPE,
OBJECT_GROUP,
FAT_INLINE_STRING,
STRING,
EXTERNAL_STRING,
SYMBOL,
JITCODE,
LIMIT,
LAST = LIMIT - 1
};
static const unsigned FINALIZE_LIMIT = FINALIZE_LAST + 1;
static const unsigned FINALIZE_OBJECT_LIMIT = FINALIZE_OBJECT_LAST + 1;
static_assert(uint8_t(AllocKind::OBJECT0) == 0, "Please check AllocKind iterations and comparisons"
" 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
MapAllocToTraceKind(AllocKind kind)
{
static const JSGCTraceKind map[] = {
JSTRACE_OBJECT, /* FINALIZE_OBJECT0 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT0_BACKGROUND */
JSTRACE_OBJECT, /* FINALIZE_OBJECT2 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT2_BACKGROUND */
JSTRACE_OBJECT, /* FINALIZE_OBJECT4 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT4_BACKGROUND */
JSTRACE_OBJECT, /* FINALIZE_OBJECT8 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT8_BACKGROUND */
JSTRACE_OBJECT, /* FINALIZE_OBJECT12 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT12_BACKGROUND */
JSTRACE_OBJECT, /* FINALIZE_OBJECT16 */
JSTRACE_OBJECT, /* FINALIZE_OBJECT16_BACKGROUND */
JSTRACE_SCRIPT, /* FINALIZE_SCRIPT */
JSTRACE_LAZY_SCRIPT, /* FINALIZE_LAZY_SCRIPT */
JSTRACE_SHAPE, /* FINALIZE_SHAPE */
JSTRACE_SHAPE, /* FINALIZE_ACCESSOR_SHAPE */
JSTRACE_BASE_SHAPE, /* FINALIZE_BASE_SHAPE */
JSTRACE_OBJECT_GROUP, /* FINALIZE_OBJECT_GROUP */
JSTRACE_STRING, /* FINALIZE_FAT_INLINE_STRING */
JSTRACE_STRING, /* FINALIZE_STRING */
JSTRACE_STRING, /* FINALIZE_EXTERNAL_STRING */
JSTRACE_SYMBOL, /* FINALIZE_SYMBOL */
JSTRACE_JITCODE, /* FINALIZE_JITCODE */
JSTRACE_OBJECT, /* AllocKind::OBJECT0 */
JSTRACE_OBJECT, /* AllocKind::OBJECT0_BACKGROUND */
JSTRACE_OBJECT, /* AllocKind::OBJECT2 */
JSTRACE_OBJECT, /* AllocKind::OBJECT2_BACKGROUND */
JSTRACE_OBJECT, /* AllocKind::OBJECT4 */
JSTRACE_OBJECT, /* AllocKind::OBJECT4_BACKGROUND */
JSTRACE_OBJECT, /* AllocKind::OBJECT8 */
JSTRACE_OBJECT, /* AllocKind::OBJECT8_BACKGROUND */
JSTRACE_OBJECT, /* AllocKind::OBJECT12 */
JSTRACE_OBJECT, /* AllocKind::OBJECT12_BACKGROUND */
JSTRACE_OBJECT, /* AllocKind::OBJECT16 */
JSTRACE_OBJECT, /* AllocKind::OBJECT16_BACKGROUND */
JSTRACE_SCRIPT, /* AllocKind::SCRIPT */
JSTRACE_LAZY_SCRIPT, /* AllocKind::LAZY_SCRIPT */
JSTRACE_SHAPE, /* AllocKind::SHAPE */
JSTRACE_SHAPE, /* AllocKind::ACCESSOR_SHAPE */
JSTRACE_BASE_SHAPE, /* AllocKind::BASE_SHAPE */
JSTRACE_OBJECT_GROUP, /* AllocKind::OBJECT_GROUP */
JSTRACE_STRING, /* AllocKind::FAT_INLINE_STRING */
JSTRACE_STRING, /* AllocKind::STRING */
JSTRACE_STRING, /* AllocKind::EXTERNAL_STRING */
JSTRACE_SYMBOL, /* AllocKind::SYMBOL */
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");
return map[kind];
return map[size_t(kind)];
}
/*
* This must be an upper bound, but we do not need the least upper bound, so
* 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;
@ -526,7 +543,7 @@ struct ArenaHeader
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
* chunk.
*
@ -571,8 +588,8 @@ struct ArenaHeader
inline Chunk *chunk() const;
bool allocated() const {
MOZ_ASSERT(allocKind <= size_t(FINALIZE_LIMIT));
return allocKind < size_t(FINALIZE_LIMIT);
MOZ_ASSERT(allocKind <= size_t(AllocKind::LIMIT));
return allocKind < size_t(AllocKind::LIMIT);
}
void init(JS::Zone *zoneArg, AllocKind kind) {
@ -582,7 +599,8 @@ struct ArenaHeader
MOZ_ASSERT(!hasDelayedMarking);
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);
/*
@ -593,7 +611,7 @@ struct ArenaHeader
}
void setAsNotAllocated() {
allocKind = size_t(FINALIZE_LIMIT);
allocKind = size_t(AllocKind::LIMIT);
markOverflow = 0;
allocatedDuringIncremental = 0;
hasDelayedMarking = 0;
@ -673,11 +691,11 @@ struct Arena
static void staticAsserts();
static size_t thingSize(AllocKind kind) {
return ThingSizes[kind];
return ThingSizes[size_t(kind)];
}
static size_t firstThingOffset(AllocKind kind) {
return FirstThingOffsets[kind];
return FirstThingOffsets[size_t(kind)];
}
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())
(*compartmentCallback)(rt, data, comp);
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
JSGCTraceKind traceKind = MapAllocToTraceKind(AllocKind(thingKind));
size_t thingSize = Arena::thingSize(AllocKind(thingKind));
for (ALL_ALLOC_KINDS(thingKind)) {
JSGCTraceKind traceKind = MapAllocToTraceKind(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();
(*arenaCallback)(rt, data, aheader->getArena(), traceKind, thingSize);
for (ArenaCellIterUnderGC iter(aheader); !iter.done(); iter.next())
@ -98,14 +98,14 @@ js::IterateScripts(JSRuntime *rt, JSCompartment *compartment,
AutoPrepareForTracing prep(rt, SkipAtoms);
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>();
if (script->compartment() == compartment)
scriptCallback(rt, data, script);
}
} else {
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>());
}
}
@ -117,8 +117,8 @@ js::IterateGrayObjects(Zone *zone, GCThingCallback cellCallback, void *data)
zone->runtimeFromMainThread()->gc.evictNursery();
AutoPrepareForTracing prep(zone->runtimeFromMainThread(), SkipAtoms);
for (size_t finalizeKind = 0; finalizeKind <= FINALIZE_OBJECT_LAST; finalizeKind++) {
for (ZoneCellIterUnderGC i(zone, AllocKind(finalizeKind)); !i.done(); i.next()) {
for (OBJECT_ALLOC_KINDS(thingKind)) {
for (ZoneCellIterUnderGC i(zone, thingKind); !i.done(); i.next()) {
JSObject *obj = i.get<JSObject>();
if (obj->asTenured().isMarked(GRAY))
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. */
if (!nursery.isInside(aobj->getElementsHeader()))
return FINALIZE_OBJECT0_BACKGROUND;
return AllocKind::OBJECT0_BACKGROUND;
size_t nelements = aobj->getDenseCapacity();
return GetBackgroundAllocKind(GetGCArrayKind(nelements));
@ -459,7 +459,7 @@ GetObjectAllocKindForCopy(const Nursery &nursery, JSObject *obj)
// Outline typed objects use the minimum allocation kind.
if (obj->is<OutlineTypedObject>())
return FINALIZE_OBJECT0;
return AllocKind::OBJECT0;
// All nursery allocatable non-native objects are handled above.
MOZ_ASSERT(obj->isNative());

Просмотреть файл

@ -486,7 +486,7 @@ js::gc::GCRuntime::markRuntime(JSTracer *trc,
/* Do not discard scripts with counts while profiling. */
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>();
if (script->hasScriptCounts()) {
MarkScriptRoot(trc, &script, "profilingScripts");

Просмотреть файл

@ -501,10 +501,10 @@ js::gc::GCRuntime::endVerifyPostBarriers()
/* Walk the heap to find any edges not the the |edges| set. */
trc->setTraceCallback(PostVerifierVisitEdge);
for (GCZoneGroupIter zone(rt); !zone.done(); zone.next()) {
for (size_t kind = 0; kind < FINALIZE_LIMIT; ++kind) {
for (ZoneCellIterUnderGC cells(zone, AllocKind(kind)); !cells.done(); cells.next()) {
for (ALL_ALLOC_KINDS(kind)) {
for (ZoneCellIterUnderGC cells(zone, kind); !cells.done(); cells.next()) {
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());
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>();
MOZ_ASSERT_IF(isGCSweeping(), script->zone()->isGCSweeping());
if (!script->hasAnyBreakpointsOrStepMode())
@ -171,7 +171,7 @@ Zone::discardJitCode(FreeOp *fop)
#ifdef DEBUG
/* 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>();
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. */
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>();
jit::FinishInvalidation(fop, script);

Просмотреть файл

@ -1076,7 +1076,7 @@ void
jit::ToggleBaselineProfiling(JSRuntime *runtime, bool enable)
{
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>();
if (!script->hasBaselineScript())
continue;
@ -1090,7 +1090,7 @@ void
jit::ToggleBaselineTraceLoggerScripts(JSRuntime *runtime, bool enable)
{
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>();
if (!script->hasBaselineScript())
continue;
@ -1103,7 +1103,7 @@ void
jit::ToggleBaselineTraceLoggerEngine(JSRuntime *runtime, bool enable)
{
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>();
if (!script->hasBaselineScript())
continue;

Просмотреть файл

@ -4797,7 +4797,7 @@ CodeGenerator::visitCreateThisWithTemplate(LCreateThisWithTemplate *lir)
Register tempReg = ToRegister(lir->temp());
OutOfLineCode *ool = oolCallVM(NewGCObjectInfo, lir,
(ArgList(), Imm32(allocKind), Imm32(initialHeap),
(ArgList(), Imm32(int32_t(allocKind)), Imm32(initialHeap),
Imm32(ndynamic), ImmPtr(clasp)),
StoreRegisterTo(objReg));

Просмотреть файл

@ -494,7 +494,7 @@ JitRuntime::Mark(JSTracer *trc)
{
MOZ_ASSERT(!trc->runtime()->isHeapMinorCollecting());
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>();
MarkJitCodeRoot(trc, &code, "wrapper");
}
@ -1136,7 +1136,7 @@ jit::ToggleBarriers(JS::Zone *zone, bool needs)
if (!rt->hasJitRuntime())
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>();
if (script->hasIonScript())
script->ionScript()->toggleBarriers(needs);

Просмотреть файл

@ -993,7 +993,7 @@ void
MacroAssembler::allocateObject(Register result, Register temp, gc::AllocKind allocKind,
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);
@ -1029,7 +1029,7 @@ MacroAssembler::newGCThing(Register result, Register temp, JSObject *templateObj
gc::InitialHeap initialHeap, Label *fail)
{
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;
if (templateObj->isNative())
@ -1042,7 +1042,7 @@ MacroAssembler::createGCObject(Register obj, Register temp, JSObject *templateOb
gc::InitialHeap initialHeap, Label *fail, bool initContents)
{
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;
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, might have another allocation kind.
if (templateObj->as<NativeObject>().denseElementsAreCopyOnWrite())
allocKind = gc::FINALIZE_OBJECT0_BACKGROUND;
allocKind = gc::AllocKind::OBJECT0_BACKGROUND;
}
allocateObject(obj, temp, allocKind, nDynamicSlots, initialHeap, fail);
@ -1073,13 +1073,13 @@ MacroAssembler::allocateNonObject(Register result, Register temp, gc::AllocKind
void
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
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

Просмотреть файл

@ -1150,7 +1150,7 @@ AssertValidObjectPtr(JSContext *cx, JSObject *obj)
if (obj->isTenured()) {
MOZ_ASSERT(obj->isAligned());
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());
}
}
@ -1182,13 +1182,13 @@ AssertValidStringPtr(JSContext *cx, JSString *str)
gc::AllocKind kind = str->getAllocKind();
if (str->isFatInline())
MOZ_ASSERT(kind == gc::FINALIZE_FAT_INLINE_STRING);
MOZ_ASSERT(kind == gc::AllocKind::FAT_INLINE_STRING);
else if (str->isExternal())
MOZ_ASSERT(kind == gc::FINALIZE_EXTERNAL_STRING);
MOZ_ASSERT(kind == gc::AllocKind::EXTERNAL_STRING);
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
MOZ_ASSERT(kind == gc::FINALIZE_STRING);
MOZ_ASSERT(kind == gc::AllocKind::STRING);
}
void
@ -1207,7 +1207,7 @@ AssertValidSymbolPtr(JSContext *cx, JS::Symbol *sym)
AssertValidStringPtr(cx, desc);
}
MOZ_ASSERT(sym->getAllocKind() == gc::FINALIZE_SYMBOL);
MOZ_ASSERT(sym->getAllocKind() == gc::AllocKind::SYMBOL);
}
void

Просмотреть файл

@ -3223,11 +3223,11 @@ CreateArrayPrototype(JSContext *cx, JSProtoKey key)
proto->assertParentIs(cx->global());
RootedShape shape(cx, EmptyShape::getInitialShape(cx, &ArrayObject::class_, TaggedProto(proto),
cx->global(), metadata,
gc::FINALIZE_OBJECT0));
gc::AllocKind::OBJECT0));
if (!shape)
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));
if (!arrayProto ||
!JSObject::setSingleton(cx, arrayProto) ||
@ -3352,7 +3352,7 @@ NewArray(ExclusiveContext *cxArg, uint32_t length,
*/
RootedShape shape(cxArg, EmptyShape::getInitialShape(cxArg, &ArrayObject::class_,
TaggedProto(proto), cxArg->global(),
metadata, gc::FINALIZE_OBJECT0));
metadata, gc::AllocKind::OBJECT0));
if (!shape)
return nullptr;

Просмотреть файл

@ -731,7 +731,7 @@ CreateLazyScriptsForCompartment(JSContext *cx)
// 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
// 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>();
JSFunction *fun = lazy->functionNonDelazifying();
if (fun->compartment() == cx->compartment() &&
@ -810,7 +810,7 @@ JSCompartment::unsetIsDebuggee()
void
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>();
if (script->compartment() == this && script->hasAnyBreakpointsOrStepMode())
script->clearBreakpointsIn(fop, dbg, handler);

Просмотреть файл

@ -431,11 +431,11 @@ class JSFunction : public js::NativeObject
}
#if JS_BITS_PER_WORD == 32
static const js::gc::AllocKind FinalizeKind = js::gc::FINALIZE_OBJECT2_BACKGROUND;
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::FINALIZE_OBJECT4_BACKGROUND;
static const js::gc::AllocKind FinalizeKind = js::gc::AllocKind::OBJECT2_BACKGROUND;
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::AllocKind::OBJECT4_BACKGROUND;
#else
static const js::gc::AllocKind FinalizeKind = js::gc::FINALIZE_OBJECT4_BACKGROUND;
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::FINALIZE_OBJECT8_BACKGROUND;
static const js::gc::AllocKind FinalizeKind = js::gc::AllocKind::OBJECT4_BACKGROUND;
static const js::gc::AllocKind ExtendedFinalizeKind = js::gc::AllocKind::OBJECT8_BACKGROUND;
#endif
inline void trace(JSTracer *trc);

Просмотреть файл

@ -252,11 +252,11 @@ static const uint64_t GC_IDLE_FULL_SPAN = 20 * 1000 * 1000;
static const int IGC_MARK_SLICE_MULTIPLIER = 2;
const AllocKind gc::slotsToThingKind[] = {
/* 0 */ FINALIZE_OBJECT0, FINALIZE_OBJECT2, FINALIZE_OBJECT2, FINALIZE_OBJECT4,
/* 4 */ FINALIZE_OBJECT4, FINALIZE_OBJECT8, FINALIZE_OBJECT8, FINALIZE_OBJECT8,
/* 8 */ FINALIZE_OBJECT8, FINALIZE_OBJECT12, FINALIZE_OBJECT12, FINALIZE_OBJECT12,
/* 12 */ FINALIZE_OBJECT12, FINALIZE_OBJECT16, FINALIZE_OBJECT16, FINALIZE_OBJECT16,
/* 16 */ FINALIZE_OBJECT16
/* 0 */ AllocKind::OBJECT0, AllocKind::OBJECT2, AllocKind::OBJECT2, AllocKind::OBJECT4,
/* 4 */ AllocKind::OBJECT4, AllocKind::OBJECT8, AllocKind::OBJECT8, AllocKind::OBJECT8,
/* 8 */ AllocKind::OBJECT8, AllocKind::OBJECT12, AllocKind::OBJECT12, AllocKind::OBJECT12,
/* 12 */ AllocKind::OBJECT12, AllocKind::OBJECT16, AllocKind::OBJECT16, AllocKind::OBJECT16,
/* 16 */ AllocKind::OBJECT16
};
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))
const uint32_t Arena::ThingSizes[] = CHECK_MIN_THING_SIZE(
sizeof(JSObject_Slots0), /* FINALIZE_OBJECT0 */
sizeof(JSObject_Slots0), /* FINALIZE_OBJECT0_BACKGROUND */
sizeof(JSObject_Slots2), /* FINALIZE_OBJECT2 */
sizeof(JSObject_Slots2), /* FINALIZE_OBJECT2_BACKGROUND */
sizeof(JSObject_Slots4), /* FINALIZE_OBJECT4 */
sizeof(JSObject_Slots4), /* FINALIZE_OBJECT4_BACKGROUND */
sizeof(JSObject_Slots8), /* FINALIZE_OBJECT8 */
sizeof(JSObject_Slots8), /* FINALIZE_OBJECT8_BACKGROUND */
sizeof(JSObject_Slots12), /* FINALIZE_OBJECT12 */
sizeof(JSObject_Slots12), /* FINALIZE_OBJECT12_BACKGROUND */
sizeof(JSObject_Slots16), /* FINALIZE_OBJECT16 */
sizeof(JSObject_Slots16), /* FINALIZE_OBJECT16_BACKGROUND */
sizeof(JSScript), /* FINALIZE_SCRIPT */
sizeof(LazyScript), /* FINALIZE_LAZY_SCRIPT */
sizeof(Shape), /* FINALIZE_SHAPE */
sizeof(AccessorShape), /* FINALIZE_ACCESSOR_SHAPE */
sizeof(BaseShape), /* FINALIZE_BASE_SHAPE */
sizeof(ObjectGroup), /* FINALIZE_OBJECT_GROUP */
sizeof(JSFatInlineString), /* FINALIZE_FAT_INLINE_STRING */
sizeof(JSString), /* FINALIZE_STRING */
sizeof(JSExternalString), /* FINALIZE_EXTERNAL_STRING */
sizeof(JS::Symbol), /* FINALIZE_SYMBOL */
sizeof(jit::JitCode), /* FINALIZE_JITCODE */
sizeof(JSObject_Slots0), /* AllocKind::OBJECT0 */
sizeof(JSObject_Slots0), /* AllocKind::OBJECT0_BACKGROUND */
sizeof(JSObject_Slots2), /* AllocKind::OBJECT2 */
sizeof(JSObject_Slots2), /* AllocKind::OBJECT2_BACKGROUND */
sizeof(JSObject_Slots4), /* AllocKind::OBJECT4 */
sizeof(JSObject_Slots4), /* AllocKind::OBJECT4_BACKGROUND */
sizeof(JSObject_Slots8), /* AllocKind::OBJECT8 */
sizeof(JSObject_Slots8), /* AllocKind::OBJECT8_BACKGROUND */
sizeof(JSObject_Slots12), /* AllocKind::OBJECT12 */
sizeof(JSObject_Slots12), /* AllocKind::OBJECT12_BACKGROUND */
sizeof(JSObject_Slots16), /* AllocKind::OBJECT16 */
sizeof(JSObject_Slots16), /* AllocKind::OBJECT16_BACKGROUND */
sizeof(JSScript), /* AllocKind::SCRIPT */
sizeof(LazyScript), /* AllocKind::LAZY_SCRIPT */
sizeof(Shape), /* AllocKind::SHAPE */
sizeof(AccessorShape), /* AllocKind::ACCESSOR_SHAPE */
sizeof(BaseShape), /* AllocKind::BASE_SHAPE */
sizeof(ObjectGroup), /* AllocKind::OBJECT_GROUP */
sizeof(JSFatInlineString), /* AllocKind::FAT_INLINE_STRING */
sizeof(JSString), /* AllocKind::STRING */
sizeof(JSExternalString), /* AllocKind::EXTERNAL_STRING */
sizeof(JS::Symbol), /* AllocKind::SYMBOL */
sizeof(jit::JitCode), /* AllocKind::JITCODE */
);
#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))
const uint32_t Arena::FirstThingOffsets[] = {
OFFSET(JSObject_Slots0), /* FINALIZE_OBJECT0 */
OFFSET(JSObject_Slots0), /* FINALIZE_OBJECT0_BACKGROUND */
OFFSET(JSObject_Slots2), /* FINALIZE_OBJECT2 */
OFFSET(JSObject_Slots2), /* FINALIZE_OBJECT2_BACKGROUND */
OFFSET(JSObject_Slots4), /* FINALIZE_OBJECT4 */
OFFSET(JSObject_Slots4), /* FINALIZE_OBJECT4_BACKGROUND */
OFFSET(JSObject_Slots8), /* FINALIZE_OBJECT8 */
OFFSET(JSObject_Slots8), /* FINALIZE_OBJECT8_BACKGROUND */
OFFSET(JSObject_Slots12), /* FINALIZE_OBJECT12 */
OFFSET(JSObject_Slots12), /* FINALIZE_OBJECT12_BACKGROUND */
OFFSET(JSObject_Slots16), /* FINALIZE_OBJECT16 */
OFFSET(JSObject_Slots16), /* FINALIZE_OBJECT16_BACKGROUND */
OFFSET(JSScript), /* FINALIZE_SCRIPT */
OFFSET(LazyScript), /* FINALIZE_LAZY_SCRIPT */
OFFSET(Shape), /* FINALIZE_SHAPE */
OFFSET(AccessorShape), /* FINALIZE_ACCESSOR_SHAPE */
OFFSET(BaseShape), /* FINALIZE_BASE_SHAPE */
OFFSET(ObjectGroup), /* FINALIZE_OBJECT_GROUP */
OFFSET(JSFatInlineString), /* FINALIZE_FAT_INLINE_STRING */
OFFSET(JSString), /* FINALIZE_STRING */
OFFSET(JSExternalString), /* FINALIZE_EXTERNAL_STRING */
OFFSET(JS::Symbol), /* FINALIZE_SYMBOL */
OFFSET(jit::JitCode), /* FINALIZE_JITCODE */
OFFSET(JSObject_Slots0), /* AllocKind::OBJECT0 */
OFFSET(JSObject_Slots0), /* AllocKind::OBJECT0_BACKGROUND */
OFFSET(JSObject_Slots2), /* AllocKind::OBJECT2 */
OFFSET(JSObject_Slots2), /* AllocKind::OBJECT2_BACKGROUND */
OFFSET(JSObject_Slots4), /* AllocKind::OBJECT4 */
OFFSET(JSObject_Slots4), /* AllocKind::OBJECT4_BACKGROUND */
OFFSET(JSObject_Slots8), /* AllocKind::OBJECT8 */
OFFSET(JSObject_Slots8), /* AllocKind::OBJECT8_BACKGROUND */
OFFSET(JSObject_Slots12), /* AllocKind::OBJECT12 */
OFFSET(JSObject_Slots12), /* AllocKind::OBJECT12_BACKGROUND */
OFFSET(JSObject_Slots16), /* AllocKind::OBJECT16 */
OFFSET(JSObject_Slots16), /* AllocKind::OBJECT16_BACKGROUND */
OFFSET(JSScript), /* AllocKind::SCRIPT */
OFFSET(LazyScript), /* AllocKind::LAZY_SCRIPT */
OFFSET(Shape), /* AllocKind::SHAPE */
OFFSET(AccessorShape), /* AllocKind::ACCESSOR_SHAPE */
OFFSET(BaseShape), /* AllocKind::BASE_SHAPE */
OFFSET(ObjectGroup), /* AllocKind::OBJECT_GROUP */
OFFSET(JSFatInlineString), /* AllocKind::FAT_INLINE_STRING */
OFFSET(JSString), /* AllocKind::STRING */
OFFSET(JSExternalString), /* AllocKind::EXTERNAL_STRING */
OFFSET(JS::Symbol), /* AllocKind::SYMBOL */
OFFSET(jit::JitCode), /* AllocKind::JITCODE */
};
#undef OFFSET
@ -342,16 +342,16 @@ struct js::gc::FinalizePhase
*/
static const AllocKind IncrementalPhaseStrings[] = {
FINALIZE_EXTERNAL_STRING
AllocKind::EXTERNAL_STRING
};
static const AllocKind IncrementalPhaseScripts[] = {
FINALIZE_SCRIPT,
FINALIZE_LAZY_SCRIPT
AllocKind::SCRIPT,
AllocKind::LAZY_SCRIPT
};
static const AllocKind IncrementalPhaseJitCode[] = {
FINALIZE_JITCODE
AllocKind::JITCODE
};
static const FinalizePhase IncrementalFinalizePhases[] = {
@ -365,25 +365,25 @@ static const FinalizePhase IncrementalFinalizePhases[] = {
*/
static const AllocKind BackgroundPhaseObjects[] = {
FINALIZE_OBJECT0_BACKGROUND,
FINALIZE_OBJECT2_BACKGROUND,
FINALIZE_OBJECT4_BACKGROUND,
FINALIZE_OBJECT8_BACKGROUND,
FINALIZE_OBJECT12_BACKGROUND,
FINALIZE_OBJECT16_BACKGROUND
AllocKind::OBJECT0_BACKGROUND,
AllocKind::OBJECT2_BACKGROUND,
AllocKind::OBJECT4_BACKGROUND,
AllocKind::OBJECT8_BACKGROUND,
AllocKind::OBJECT12_BACKGROUND,
AllocKind::OBJECT16_BACKGROUND
};
static const AllocKind BackgroundPhaseStringsAndSymbols[] = {
FINALIZE_FAT_INLINE_STRING,
FINALIZE_STRING,
FINALIZE_SYMBOL
AllocKind::FAT_INLINE_STRING,
AllocKind::STRING,
AllocKind::SYMBOL
};
static const AllocKind BackgroundPhaseShapes[] = {
FINALIZE_SHAPE,
FINALIZE_ACCESSOR_SHAPE,
FINALIZE_BASE_SHAPE,
FINALIZE_OBJECT_GROUP
AllocKind::SHAPE,
AllocKind::ACCESSOR_SHAPE,
AllocKind::BASE_SHAPE,
AllocKind::OBJECT_GROUP
};
static const FinalizePhase BackgroundFinalizePhases[] = {
@ -445,8 +445,10 @@ ArenaHeader::unmarkAll()
/* static */ void
Arena::staticAsserts()
{
static_assert(JS_ARRAY_LENGTH(ThingSizes) == FINALIZE_LIMIT, "We have defined all thing sizes.");
static_assert(JS_ARRAY_LENGTH(FirstThingOffsets) == FINALIZE_LIMIT, "We have defined all offsets.");
static_assert(JS_ARRAY_LENGTH(ThingSizes) == size_t(AllocKind::LIMIT),
"We haven't defined all thing sizes.");
static_assert(JS_ARRAY_LENGTH(FirstThingOffsets) == size_t(AllocKind::LIMIT),
"We haven't defined all offsets.");
}
void
@ -586,40 +588,40 @@ FinalizeArenas(FreeOp *fop,
ArenaLists::KeepArenasEnum keepArenas)
{
switch (thingKind) {
case FINALIZE_OBJECT0:
case FINALIZE_OBJECT0_BACKGROUND:
case FINALIZE_OBJECT2:
case FINALIZE_OBJECT2_BACKGROUND:
case FINALIZE_OBJECT4:
case FINALIZE_OBJECT4_BACKGROUND:
case FINALIZE_OBJECT8:
case FINALIZE_OBJECT8_BACKGROUND:
case FINALIZE_OBJECT12:
case FINALIZE_OBJECT12_BACKGROUND:
case FINALIZE_OBJECT16:
case FINALIZE_OBJECT16_BACKGROUND:
case AllocKind::OBJECT0:
case AllocKind::OBJECT0_BACKGROUND:
case AllocKind::OBJECT2:
case AllocKind::OBJECT2_BACKGROUND:
case AllocKind::OBJECT4:
case AllocKind::OBJECT4_BACKGROUND:
case AllocKind::OBJECT8:
case AllocKind::OBJECT8_BACKGROUND:
case AllocKind::OBJECT12:
case AllocKind::OBJECT12_BACKGROUND:
case AllocKind::OBJECT16:
case AllocKind::OBJECT16_BACKGROUND:
return FinalizeTypedArenas<JSObject>(fop, src, dest, thingKind, budget, keepArenas);
case FINALIZE_SCRIPT:
case AllocKind::SCRIPT:
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);
case FINALIZE_SHAPE:
case AllocKind::SHAPE:
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);
case FINALIZE_BASE_SHAPE:
case AllocKind::BASE_SHAPE:
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);
case FINALIZE_STRING:
case AllocKind::STRING:
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);
case FINALIZE_EXTERNAL_STRING:
case AllocKind::EXTERNAL_STRING:
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);
case FINALIZE_JITCODE:
case AllocKind::JITCODE:
return FinalizeTypedArenas<jit::JitCode>(fop, src, dest, thingKind, budget, keepArenas);
default:
MOZ_CRASH("Invalid alloc kind");
@ -1787,7 +1789,7 @@ GCMarker::delayMarkingChildren(const void *thing)
inline void
ArenaLists::prepareForIncrementalGC(JSRuntime *rt)
{
for (size_t i = 0; i != FINALIZE_LIMIT; ++i) {
for (ALL_ALLOC_KINDS(i)) {
FreeList *freeList = &freeLists[i];
if (!freeList->isEmpty()) {
ArenaHeader *aheader = freeList->arenaHeader();
@ -1936,7 +1938,7 @@ CanRelocateZone(JSRuntime *rt, Zone *zone)
static bool
CanRelocateAllocKind(AllocKind kind)
{
return kind <= FINALIZE_OBJECT_LAST;
return kind <= AllocKind::OBJECT_LAST;
}
size_t ArenaHeader::countFreeCells()
@ -2062,7 +2064,7 @@ RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize
// Copy source cell contents to destination.
memcpy(dst, src, thingSize);
if (thingKind <= FINALIZE_OBJECT_LAST) {
if (thingKind <= AllocKind::OBJECT_LAST) {
JSObject *srcObj = static_cast<JSObject *>(static_cast<Cell *>(src));
JSObject *dstObj = static_cast<JSObject *>(static_cast<Cell *>(dst));
@ -2180,8 +2182,8 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
checkEmptyFreeLists();
if (ShouldRelocateAllArenas(reason)) {
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
if (CanRelocateAllocKind(AllocKind(i))) {
for (ALL_ALLOC_KINDS(i)) {
if (CanRelocateAllocKind(i)) {
ArenaList &al = arenaLists[i];
ArenaHeader *allArenas = al.head();
al.clear();
@ -2191,17 +2193,18 @@ ArenaLists::relocateArenas(ArenaHeader *&relocatedListOut, JS::gcreason::Reason
} else {
size_t arenaCount = 0;
size_t relocCount = 0;
ArenaHeader **toRelocate[FINALIZE_LIMIT] = {nullptr};
AllAllocKindArray<ArenaHeader **> toRelocate;
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
if (CanRelocateAllocKind(AllocKind(i)))
for (ALL_ALLOC_KINDS(i)) {
toRelocate[i] = nullptr;
if (CanRelocateAllocKind(i))
toRelocate[i] = arenaLists[i].pickArenasToRelocate(arenaCount, relocCount);
}
if (!ShouldRelocateZone(arenaCount, relocCount, reason))
return false;
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
for (ALL_ALLOC_KINDS(i)) {
if (toRelocate[i]) {
ArenaList &al = arenaLists[i];
ArenaHeader *arenas = al.removeRemainingArenas(toRelocate[i]);
@ -2264,12 +2267,12 @@ GCRuntime::sweepTypesAfterCompacting(Zone *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>();
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>();
group->maybeSweep(&oom);
}
@ -2323,39 +2326,39 @@ UpdateCellPointers(MovingTracer *trc, ArenaHeader *arena)
JSGCTraceKind traceKind = MapAllocToTraceKind(kind);
switch (kind) {
case FINALIZE_OBJECT0:
case FINALIZE_OBJECT0_BACKGROUND:
case FINALIZE_OBJECT2:
case FINALIZE_OBJECT2_BACKGROUND:
case FINALIZE_OBJECT4:
case FINALIZE_OBJECT4_BACKGROUND:
case FINALIZE_OBJECT8:
case FINALIZE_OBJECT8_BACKGROUND:
case FINALIZE_OBJECT12:
case FINALIZE_OBJECT12_BACKGROUND:
case FINALIZE_OBJECT16:
case FINALIZE_OBJECT16_BACKGROUND:
case AllocKind::OBJECT0:
case AllocKind::OBJECT0_BACKGROUND:
case AllocKind::OBJECT2:
case AllocKind::OBJECT2_BACKGROUND:
case AllocKind::OBJECT4:
case AllocKind::OBJECT4_BACKGROUND:
case AllocKind::OBJECT8:
case AllocKind::OBJECT8_BACKGROUND:
case AllocKind::OBJECT12:
case AllocKind::OBJECT12_BACKGROUND:
case AllocKind::OBJECT16:
case AllocKind::OBJECT16_BACKGROUND:
UpdateCellPointersTyped<JSObject>(trc, arena, traceKind);
return;
case FINALIZE_SCRIPT:
case AllocKind::SCRIPT:
UpdateCellPointersTyped<JSScript>(trc, arena, traceKind);
return;
case FINALIZE_LAZY_SCRIPT:
case AllocKind::LAZY_SCRIPT:
UpdateCellPointersTyped<LazyScript>(trc, arena, traceKind);
return;
case FINALIZE_SHAPE:
case AllocKind::SHAPE:
UpdateCellPointersTyped<Shape>(trc, arena, traceKind);
return;
case FINALIZE_ACCESSOR_SHAPE:
case AllocKind::ACCESSOR_SHAPE:
UpdateCellPointersTyped<AccessorShape>(trc, arena, traceKind);
return;
case FINALIZE_BASE_SHAPE:
case AllocKind::BASE_SHAPE:
UpdateCellPointersTyped<BaseShape>(trc, arena, traceKind);
return;
case FINALIZE_OBJECT_GROUP:
case AllocKind::OBJECT_GROUP:
UpdateCellPointersTyped<ObjectGroup>(trc, arena, traceKind);
return;
case FINALIZE_JITCODE:
case AllocKind::JITCODE:
UpdateCellPointersTyped<jit::JitCode>(trc, arena, traceKind);
return;
default:
@ -2385,21 +2388,21 @@ struct ArenasToUpdate
unsigned kind; // Current alloc kind 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);
if (kind == FINALIZE_FAT_INLINE_STRING ||
kind == FINALIZE_STRING ||
kind == FINALIZE_EXTERNAL_STRING ||
kind == FINALIZE_SYMBOL)
MOZ_ASSERT(kind < AllocKind::LIMIT);
if (kind == AllocKind::FAT_INLINE_STRING ||
kind == AllocKind::STRING ||
kind == AllocKind::EXTERNAL_STRING ||
kind == AllocKind::SYMBOL)
{
return false;
}
if (js::gc::IsBackgroundFinalized(AllocKind(kind)))
if (js::gc::IsBackgroundFinalized(kind))
return (kinds & BACKGROUND) != 0;
else
return (kinds & FOREGROUND) != 0;
@ -2425,7 +2428,7 @@ ArenasToUpdate::next(AutoLockHelperThreadState& lock)
if (initialized) {
MOZ_ASSERT(arena);
MOZ_ASSERT(shouldProcessKind(kind));
MOZ_ASSERT(shouldProcessKind(AllocKind(kind)));
MOZ_ASSERT(!zone.done());
goto resumePoint;
}
@ -2433,8 +2436,8 @@ ArenasToUpdate::next(AutoLockHelperThreadState& lock)
initialized = true;
for (; !zone.done(); zone.next()) {
if (zone->isGCCompacting()) {
for (kind = 0; kind < FINALIZE_LIMIT; ++kind) {
if (shouldProcessKind(kind)) {
for (kind = 0; kind < size_t(AllocKind::LIMIT); ++kind) {
if (shouldProcessKind(AllocKind(kind))) {
for (arena = zone.get()->arenas.getFirstArena(AllocKind(kind));
arena;
arena = arena->next)
@ -2757,7 +2760,7 @@ ArenaLists::~ArenaLists()
{
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
* the background finalization is disabled.
@ -2767,7 +2770,7 @@ ArenaLists::~ArenaLists()
}
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_, savedEmptyObjectArenas, lock);
}
@ -2909,7 +2912,7 @@ ArenaLists::queueForegroundObjectsForSweep(FreeOp *fop)
gcstats::AutoPhase ap(fop->runtime()->gc.stats, gcstats::PHASE_SWEEP_OBJECT);
#ifdef DEBUG
for (size_t i = 0; i < FINALIZE_OBJECT_LIMIT; i++)
for (OBJECT_ALLOC_KINDS(i))
MOZ_ASSERT(savedObjectArenas[i].isEmpty());
MOZ_ASSERT(savedEmptyObjectArenas == nullptr);
#endif
@ -2918,22 +2921,22 @@ ArenaLists::queueForegroundObjectsForSweep(FreeOp *fop)
// sweep phase, before control can return to the mutator. Otherwise,
// mutator behavior can resurrect certain objects whose references would
// otherwise have been erased by the finalizer.
finalizeNow(fop, FINALIZE_OBJECT0, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, FINALIZE_OBJECT2, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, FINALIZE_OBJECT4, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, FINALIZE_OBJECT8, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, FINALIZE_OBJECT12, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, FINALIZE_OBJECT16, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT0, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT2, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT4, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT8, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT12, KEEP_ARENAS, &savedEmptyObjectArenas);
finalizeNow(fop, AllocKind::OBJECT16, KEEP_ARENAS, &savedEmptyObjectArenas);
// Prevent the arenas from having new objects allocated into them. We need
// to know which objects are marked while we incrementally sweep dead
// references from type information.
savedObjectArenas[FINALIZE_OBJECT0] = arenaLists[FINALIZE_OBJECT0].copyAndClear();
savedObjectArenas[FINALIZE_OBJECT2] = arenaLists[FINALIZE_OBJECT2].copyAndClear();
savedObjectArenas[FINALIZE_OBJECT4] = arenaLists[FINALIZE_OBJECT4].copyAndClear();
savedObjectArenas[FINALIZE_OBJECT8] = arenaLists[FINALIZE_OBJECT8].copyAndClear();
savedObjectArenas[FINALIZE_OBJECT12] = arenaLists[FINALIZE_OBJECT12].copyAndClear();
savedObjectArenas[FINALIZE_OBJECT16] = arenaLists[FINALIZE_OBJECT16].copyAndClear();
savedObjectArenas[AllocKind::OBJECT0] = arenaLists[AllocKind::OBJECT0].copyAndClear();
savedObjectArenas[AllocKind::OBJECT2] = arenaLists[AllocKind::OBJECT2].copyAndClear();
savedObjectArenas[AllocKind::OBJECT4] = arenaLists[AllocKind::OBJECT4].copyAndClear();
savedObjectArenas[AllocKind::OBJECT8] = arenaLists[AllocKind::OBJECT8].copyAndClear();
savedObjectArenas[AllocKind::OBJECT12] = arenaLists[AllocKind::OBJECT12].copyAndClear();
savedObjectArenas[AllocKind::OBJECT16] = arenaLists[AllocKind::OBJECT16].copyAndClear();
}
void
@ -2943,12 +2946,12 @@ ArenaLists::mergeForegroundSweptObjectArenas()
ReleaseArenaList(runtime_, savedEmptyObjectArenas, lock);
savedEmptyObjectArenas = nullptr;
mergeSweptArenas(FINALIZE_OBJECT0);
mergeSweptArenas(FINALIZE_OBJECT2);
mergeSweptArenas(FINALIZE_OBJECT4);
mergeSweptArenas(FINALIZE_OBJECT8);
mergeSweptArenas(FINALIZE_OBJECT12);
mergeSweptArenas(FINALIZE_OBJECT16);
mergeSweptArenas(AllocKind::OBJECT0);
mergeSweptArenas(AllocKind::OBJECT2);
mergeSweptArenas(AllocKind::OBJECT4);
mergeSweptArenas(AllocKind::OBJECT8);
mergeSweptArenas(AllocKind::OBJECT12);
mergeSweptArenas(AllocKind::OBJECT16);
}
inline void
@ -2964,10 +2967,10 @@ ArenaLists::mergeSweptArenas(AllocKind thingKind)
void
ArenaLists::queueForegroundThingsForSweep(FreeOp *fop)
{
gcShapeArenasToUpdate = arenaListsToSweep[FINALIZE_SHAPE];
gcAccessorShapeArenasToUpdate = arenaListsToSweep[FINALIZE_ACCESSOR_SHAPE];
gcObjectGroupArenasToUpdate = arenaListsToSweep[FINALIZE_OBJECT_GROUP];
gcScriptArenasToUpdate = arenaListsToSweep[FINALIZE_SCRIPT];
gcShapeArenasToUpdate = arenaListsToSweep[AllocKind::SHAPE];
gcAccessorShapeArenasToUpdate = arenaListsToSweep[AllocKind::ACCESSOR_SHAPE];
gcObjectGroupArenasToUpdate = arenaListsToSweep[AllocKind::OBJECT_GROUP];
gcScriptArenasToUpdate = arenaListsToSweep[AllocKind::SCRIPT];
}
/* 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
// list order and not in the natural order.
while (chunk->info.numArenasFreeCommitted) {
ArenaHeader *aheader = chunk->allocateArena(rt, nullptr, FINALIZE_OBJECT0, lock);
ArenaHeader *aheader = chunk->allocateArena(rt, nullptr, AllocKind::OBJECT0, lock);
bool ok;
{
AutoUnlockGC unlock(lock);
@ -3401,9 +3404,9 @@ GCRuntime::assertBackgroundSweepingFinished()
MOZ_ASSERT(backgroundSweepZones.isEmpty());
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
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.doneBackgroundFinalize(AllocKind(i)));
MOZ_ASSERT(zone->arenas.doneBackgroundFinalize(i));
}
}
MOZ_ASSERT(freeLifoAlloc.computedSizeOfExcludingThis() == 0);
@ -3869,10 +3872,10 @@ GCRuntime::checkForCompartmentMismatches()
CompartmentCheckTracer trc(rt, CheckCompartmentCallback);
for (ZonesIter zone(rt, SkipAtoms); !zone.done(); zone.next()) {
trc.zone = zone;
for (size_t thingKind = 0; thingKind < FINALIZE_LAST; thingKind++) {
for (ZoneCellIterUnderGC i(zone, AllocKind(thingKind)); !i.done(); i.next()) {
for (ALL_ALLOC_KINDS(thingKind)) {
for (ZoneCellIterUnderGC i(zone, thingKind); !i.done(); i.next()) {
trc.src = i.getCell();
trc.srcKind = MapAllocToTraceKind(AllocKind(thingKind));
trc.srcKind = MapAllocToTraceKind(thingKind);
trc.compartment = CompartmentOfCell(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 */
MOZ_ASSERT(!zone->isCollecting());
MOZ_ASSERT(!zone->compartments.empty());
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
for (ALL_ALLOC_KINDS(i))
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
/* 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.
ArenaList finalized = sweepList.toArenaList();
arenaLists[thingKind] = finalized.insertListWithCursorAtEnd(arenaLists[thingKind]);
arenaLists[thingKind] =
finalized.insertListWithCursorAtEnd(arenaLists[thingKind]);
return true;
}
@ -5455,8 +5459,8 @@ GCRuntime::endSweepPhase(bool lastGC)
#ifdef DEBUG
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
for (unsigned i = 0 ; i < FINALIZE_LIMIT ; ++i) {
MOZ_ASSERT_IF(!IsBackgroundFinalized(AllocKind(i)) ||
for (ALL_ALLOC_KINDS(i)) {
MOZ_ASSERT_IF(!IsBackgroundFinalized(i) ||
!sweepOnBackgroundThread,
!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
// should always be less than one arena's worth of free cells.
for (size_t i = 0; i < FINALIZE_LIMIT; i++) {
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(AllocKind(i)));
if (CanRelocateAllocKind(AllocKind(i))) {
for (ALL_ALLOC_KINDS(i)) {
size_t thingsPerArena = Arena::thingsPerArena(Arena::thingSize(i));
if (CanRelocateAllocKind(i)) {
ArenaList &al = zone->arenas.arenaLists[i];
size_t freeCells = 0;
for (ArenaHeader *arena = al.arenaAfterCursor(); arena; arena = arena->next)
@ -5743,7 +5747,7 @@ GCRuntime::resetIncrementalGC(const char *reason)
#ifdef DEBUG
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
MOZ_ASSERT(!zone->needsIncrementalBarrier());
for (unsigned i = 0; i < FINALIZE_LIMIT; ++i)
for (ALL_ALLOC_KINDS(i))
MOZ_ASSERT(!zone->arenas.arenaListsToSweep[i]);
}
#endif
@ -6594,20 +6598,20 @@ gc::MergeCompartments(JSCompartment *source, JSCompartment *target)
// Fixup compartment pointers in source to refer to target, and make sure
// 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>();
MOZ_ASSERT(script->compartment() == source);
script->compartment_ = target;
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>();
MOZ_ASSERT(base->compartment() == source);
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>();
group->setGeneration(target->zone()->types.generation);
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.
for (size_t thingKind = 0; thingKind != FINALIZE_LIMIT; thingKind++) {
for (ArenaIter aiter(source->zone(), AllocKind(thingKind)); !aiter.done(); aiter.next()) {
for (ALL_ALLOC_KINDS(thingKind)) {
for (ArenaIter aiter(source->zone(), thingKind); !aiter.done(); aiter.next()) {
ArenaHeader *aheader = aiter.get();
aheader->zone = target->zone();
}
@ -6753,7 +6757,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
#ifdef DEBUG
/* 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>();
MOZ_ASSERT_IF(script->hasBaselineScript(), !script->baselineScript()->active());
}
@ -6764,7 +6768,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
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>();
jit::FinishInvalidation(fop, script);
@ -6782,7 +6786,7 @@ js::ReleaseAllJITCode(FreeOp *fop)
void
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>();
/* Discard Ion caches. */
@ -6811,12 +6815,12 @@ ArenaLists::adoptArenas(JSRuntime *rt, ArenaLists *fromArenaLists)
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
// thread, and we do not run GC while in the parallel section,
// so no finalizer should be active!
normalizeBackgroundFinalizeState(AllocKind(thingKind));
fromArenaLists->normalizeBackgroundFinalizeState(AllocKind(thingKind));
normalizeBackgroundFinalizeState(thingKind);
fromArenaLists->normalizeBackgroundFinalizeState(thingKind);
ArenaList *fromList = &fromArenaLists->arenaLists[thingKind];
ArenaList *toList = &arenaLists[thingKind];
@ -6839,8 +6843,8 @@ bool
ArenaLists::containsArena(JSRuntime *rt, ArenaHeader *needle)
{
AutoLockGC lock(rt);
size_t allocKind = needle->getAllocKind();
for (ArenaHeader *aheader = arenaLists[allocKind].head(); aheader; aheader = aheader->next) {
ArenaList &list = arenaLists[needle->getAllocKind()];
for (ArenaHeader *aheader = list.head(); aheader; aheader = aheader->next) {
if (aheader == needle)
return true;
}

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/Atomics.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/MemoryReporting.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. */
template <typename T> struct MapTypeToFinalizeKind {};
template <> struct MapTypeToFinalizeKind<JSScript> { static const AllocKind kind = FINALIZE_SCRIPT; };
template <> struct MapTypeToFinalizeKind<LazyScript> { static const AllocKind kind = FINALIZE_LAZY_SCRIPT; };
template <> struct MapTypeToFinalizeKind<Shape> { static const AllocKind kind = FINALIZE_SHAPE; };
template <> struct MapTypeToFinalizeKind<AccessorShape> { static const AllocKind kind = FINALIZE_ACCESSOR_SHAPE; };
template <> struct MapTypeToFinalizeKind<BaseShape> { static const AllocKind kind = FINALIZE_BASE_SHAPE; };
template <> struct MapTypeToFinalizeKind<ObjectGroup> { static const AllocKind kind = FINALIZE_OBJECT_GROUP; };
template <> struct MapTypeToFinalizeKind<JSFatInlineString> { static const AllocKind kind = FINALIZE_FAT_INLINE_STRING; };
template <> struct MapTypeToFinalizeKind<JSString> { static const AllocKind kind = FINALIZE_STRING; };
template <> struct MapTypeToFinalizeKind<JSExternalString> { static const AllocKind kind = FINALIZE_EXTERNAL_STRING; };
template <> struct MapTypeToFinalizeKind<JS::Symbol> { static const AllocKind kind = FINALIZE_SYMBOL; };
template <> struct MapTypeToFinalizeKind<jit::JitCode> { static const AllocKind kind = FINALIZE_JITCODE; };
template <> struct MapTypeToFinalizeKind<JSScript> { static const AllocKind kind = AllocKind::SCRIPT; };
template <> struct MapTypeToFinalizeKind<LazyScript> { static const AllocKind kind = AllocKind::LAZY_SCRIPT; };
template <> struct MapTypeToFinalizeKind<Shape> { static const AllocKind kind = AllocKind::SHAPE; };
template <> struct MapTypeToFinalizeKind<AccessorShape> { static const AllocKind kind = AllocKind::ACCESSOR_SHAPE; };
template <> struct MapTypeToFinalizeKind<BaseShape> { static const AllocKind kind = AllocKind::BASE_SHAPE; };
template <> struct MapTypeToFinalizeKind<ObjectGroup> { static const AllocKind kind = AllocKind::OBJECT_GROUP; };
template <> struct MapTypeToFinalizeKind<JSFatInlineString> { static const AllocKind kind = AllocKind::FAT_INLINE_STRING; };
template <> struct MapTypeToFinalizeKind<JSString> { static const AllocKind kind = AllocKind::STRING; };
template <> struct MapTypeToFinalizeKind<JSExternalString> { static const AllocKind kind = AllocKind::EXTERNAL_STRING; };
template <> struct MapTypeToFinalizeKind<JS::Symbol> { static const AllocKind kind = AllocKind::SYMBOL; };
template <> struct MapTypeToFinalizeKind<jit::JitCode> { static const AllocKind kind = AllocKind::JITCODE; };
static inline bool
IsNurseryAllocable(AllocKind kind)
{
MOZ_ASSERT(kind >= 0 && unsigned(kind) < FINALIZE_LIMIT);
MOZ_ASSERT(kind < AllocKind::LIMIT);
static const bool map[] = {
false, /* FINALIZE_OBJECT0 */
true, /* FINALIZE_OBJECT0_BACKGROUND */
false, /* FINALIZE_OBJECT2 */
true, /* FINALIZE_OBJECT2_BACKGROUND */
false, /* FINALIZE_OBJECT4 */
true, /* FINALIZE_OBJECT4_BACKGROUND */
false, /* FINALIZE_OBJECT8 */
true, /* FINALIZE_OBJECT8_BACKGROUND */
false, /* FINALIZE_OBJECT12 */
true, /* FINALIZE_OBJECT12_BACKGROUND */
false, /* FINALIZE_OBJECT16 */
true, /* FINALIZE_OBJECT16_BACKGROUND */
false, /* FINALIZE_SCRIPT */
false, /* FINALIZE_LAZY_SCRIPT */
false, /* FINALIZE_SHAPE */
false, /* FINALIZE_ACCESSOR_SHAPE */
false, /* FINALIZE_BASE_SHAPE */
false, /* FINALIZE_OBJECT_GROUP */
false, /* FINALIZE_FAT_INLINE_STRING */
false, /* FINALIZE_STRING */
false, /* FINALIZE_EXTERNAL_STRING */
false, /* FINALIZE_SYMBOL */
false, /* FINALIZE_JITCODE */
false, /* AllocKind::OBJECT0 */
true, /* AllocKind::OBJECT0_BACKGROUND */
false, /* AllocKind::OBJECT2 */
true, /* AllocKind::OBJECT2_BACKGROUND */
false, /* AllocKind::OBJECT4 */
true, /* AllocKind::OBJECT4_BACKGROUND */
false, /* AllocKind::OBJECT8 */
true, /* AllocKind::OBJECT8_BACKGROUND */
false, /* AllocKind::OBJECT12 */
true, /* AllocKind::OBJECT12_BACKGROUND */
false, /* AllocKind::OBJECT16 */
true, /* AllocKind::OBJECT16_BACKGROUND */
false, /* AllocKind::SCRIPT */
false, /* AllocKind::LAZY_SCRIPT */
false, /* AllocKind::SHAPE */
false, /* AllocKind::ACCESSOR_SHAPE */
false, /* AllocKind::BASE_SHAPE */
false, /* AllocKind::OBJECT_GROUP */
false, /* AllocKind::FAT_INLINE_STRING */
false, /* AllocKind::STRING */
false, /* AllocKind::EXTERNAL_STRING */
false, /* AllocKind::SYMBOL */
false, /* AllocKind::JITCODE */
};
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == FINALIZE_LIMIT);
return map[kind];
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
return map[size_t(kind)];
}
static inline bool
IsBackgroundFinalized(AllocKind kind)
{
MOZ_ASSERT(kind >= 0 && unsigned(kind) < FINALIZE_LIMIT);
MOZ_ASSERT(kind < AllocKind::LIMIT);
static const bool map[] = {
false, /* FINALIZE_OBJECT0 */
true, /* FINALIZE_OBJECT0_BACKGROUND */
false, /* FINALIZE_OBJECT2 */
true, /* FINALIZE_OBJECT2_BACKGROUND */
false, /* FINALIZE_OBJECT4 */
true, /* FINALIZE_OBJECT4_BACKGROUND */
false, /* FINALIZE_OBJECT8 */
true, /* FINALIZE_OBJECT8_BACKGROUND */
false, /* FINALIZE_OBJECT12 */
true, /* FINALIZE_OBJECT12_BACKGROUND */
false, /* FINALIZE_OBJECT16 */
true, /* FINALIZE_OBJECT16_BACKGROUND */
false, /* FINALIZE_SCRIPT */
false, /* FINALIZE_LAZY_SCRIPT */
true, /* FINALIZE_SHAPE */
true, /* FINALIZE_ACCESSOR_SHAPE */
true, /* FINALIZE_BASE_SHAPE */
true, /* FINALIZE_OBJECT_GROUP */
true, /* FINALIZE_FAT_INLINE_STRING */
true, /* FINALIZE_STRING */
false, /* FINALIZE_EXTERNAL_STRING */
true, /* FINALIZE_SYMBOL */
false, /* FINALIZE_JITCODE */
false, /* AllocKind::OBJECT0 */
true, /* AllocKind::OBJECT0_BACKGROUND */
false, /* AllocKind::OBJECT2 */
true, /* AllocKind::OBJECT2_BACKGROUND */
false, /* AllocKind::OBJECT4 */
true, /* AllocKind::OBJECT4_BACKGROUND */
false, /* AllocKind::OBJECT8 */
true, /* AllocKind::OBJECT8_BACKGROUND */
false, /* AllocKind::OBJECT12 */
true, /* AllocKind::OBJECT12_BACKGROUND */
false, /* AllocKind::OBJECT16 */
true, /* AllocKind::OBJECT16_BACKGROUND */
false, /* AllocKind::SCRIPT */
false, /* AllocKind::LAZY_SCRIPT */
true, /* AllocKind::SHAPE */
true, /* AllocKind::ACCESSOR_SHAPE */
true, /* AllocKind::BASE_SHAPE */
true, /* AllocKind::OBJECT_GROUP */
true, /* AllocKind::FAT_INLINE_STRING */
true, /* AllocKind::STRING */
false, /* AllocKind::EXTERNAL_STRING */
true, /* AllocKind::SYMBOL */
false, /* AllocKind::JITCODE */
};
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == FINALIZE_LIMIT);
return map[kind];
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
return map[size_t(kind)];
}
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
* a different thread, we change the finalize kind. For example,
* FINALIZE_OBJECT0 calls the finalizer on the main thread,
* FINALIZE_OBJECT0_BACKGROUND calls the finalizer on the gcHelperThread.
* a different thread, we change the alloc kind. For example,
* AllocKind::OBJECT0 calls the finalizer on the main thread,
* AllocKind::OBJECT0_BACKGROUND calls the finalizer on the gcHelperThread.
* 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)));
}
@ -169,7 +170,7 @@ static inline AllocKind
GetGCObjectKind(size_t numSlots)
{
if (numSlots >= SLOTS_TO_THING_KIND_LIMIT)
return FINALIZE_OBJECT16;
return AllocKind::OBJECT16;
return slotsToThingKind[numSlots];
}
@ -185,7 +186,7 @@ GetGCArrayKind(size_t numSlots)
*/
JS_STATIC_ASSERT(ObjectElements::VALUES_PER_HEADER == 2);
if (numSlots > NativeObject::NELEMENTS_LIMIT || numSlots + 2 >= SLOTS_TO_THING_KIND_LIMIT)
return FINALIZE_OBJECT2;
return AllocKind::OBJECT2;
return slotsToThingKind[numSlots + 2];
}
@ -204,7 +205,7 @@ GetGCObjectKindForBytes(size_t nbytes)
MOZ_ASSERT(nbytes <= JSObject::MAX_BYTE_SIZE);
if (nbytes <= sizeof(NativeObject))
return FINALIZE_OBJECT0;
return AllocKind::OBJECT0;
nbytes -= sizeof(NativeObject);
size_t dataSlots = AlignBytes(nbytes, sizeof(Value)) / sizeof(Value);
@ -216,8 +217,8 @@ static inline AllocKind
GetBackgroundAllocKind(AllocKind kind)
{
MOZ_ASSERT(!IsBackgroundFinalized(kind));
MOZ_ASSERT(kind <= FINALIZE_OBJECT_LAST);
return (AllocKind) (kind + 1);
MOZ_ASSERT(kind < AllocKind::OBJECT_LAST);
return AllocKind(size_t(kind) + 1);
}
/* 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. */
switch (thingKind) {
case FINALIZE_OBJECT0:
case FINALIZE_OBJECT0_BACKGROUND:
case AllocKind::OBJECT0:
case AllocKind::OBJECT0_BACKGROUND:
return 0;
case FINALIZE_OBJECT2:
case FINALIZE_OBJECT2_BACKGROUND:
case AllocKind::OBJECT2:
case AllocKind::OBJECT2_BACKGROUND:
return 2;
case FINALIZE_OBJECT4:
case FINALIZE_OBJECT4_BACKGROUND:
case AllocKind::OBJECT4:
case AllocKind::OBJECT4_BACKGROUND:
return 4;
case FINALIZE_OBJECT8:
case FINALIZE_OBJECT8_BACKGROUND:
case AllocKind::OBJECT8:
case AllocKind::OBJECT8_BACKGROUND:
return 8;
case FINALIZE_OBJECT12:
case FINALIZE_OBJECT12_BACKGROUND:
case AllocKind::OBJECT12:
case AllocKind::OBJECT12_BACKGROUND:
return 12;
case FINALIZE_OBJECT16:
case FINALIZE_OBJECT16_BACKGROUND:
case AllocKind::OBJECT16:
case AllocKind::OBJECT16_BACKGROUND:
return 16;
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.
*/
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
* 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 };
@ -590,14 +591,13 @@ class ArenaLists
BackgroundFinalizeState;
/* 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. */
ArenaHeader *arenaListsToSweep[FINALIZE_LIMIT];
AllAllocKindArray<ArenaHeader *> arenaListsToSweep;
/* During incremental sweeping, a list of the arenas already swept. */
unsigned incrementalSweptArenaKind;
AllocKind incrementalSweptArenaKind;
ArenaList incrementalSweptArenas;
// 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
// happen at the beginning of the GC), so that type sweeping can determine
// which of the object pointers are marked.
ArenaList savedObjectArenas[FINALIZE_OBJECT_LIMIT];
ObjectAllocKindArray<ArenaList> savedObjectArenas;
ArenaHeader *savedEmptyObjectArenas;
public:
explicit ArenaLists(JSRuntime *rt) : runtime_(rt) {
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
for (ALL_ALLOC_KINDS(i))
freeLists[i].initAsEmpty();
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
for (ALL_ALLOC_KINDS(i))
backgroundFinalizeState[i] = BFS_DONE;
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
for (ALL_ALLOC_KINDS(i))
arenaListsToSweep[i] = nullptr;
incrementalSweptArenaKind = FINALIZE_LIMIT;
incrementalSweptArenaKind = AllocKind::LIMIT;
gcShapeArenasToUpdate = nullptr;
gcAccessorShapeArenasToUpdate = nullptr;
gcScriptArenasToUpdate = nullptr;
@ -634,7 +634,7 @@ class ArenaLists
static uintptr_t getFreeListOffset(AllocKind thingKind) {
uintptr_t offset = offsetof(ArenaLists, freeLists);
return offset + thingKind * sizeof(FreeList);
return offset + size_t(thingKind) * sizeof(FreeList);
}
const FreeList *getFreeList(AllocKind thingKind) const {
@ -660,7 +660,7 @@ class ArenaLists
}
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
* done.
@ -674,7 +674,7 @@ class ArenaLists
}
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. */
MOZ_ASSERT(backgroundFinalizeState[i] == BFS_DONE);
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.
*/
void purge() {
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
purge(AllocKind(i));
for (ALL_ALLOC_KINDS(i))
purge(i);
}
void purge(AllocKind i) {
@ -716,8 +716,8 @@ class ArenaLists
* outside the GC.
*/
void copyFreeListsToArenas() {
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
copyFreeListToArena(AllocKind(i));
for (ALL_ALLOC_KINDS(i))
copyFreeListToArena(i);
}
void copyFreeListToArena(AllocKind thingKind) {
@ -734,8 +734,8 @@ class ArenaLists
* copyToArenas.
*/
void clearFreeListsInArenas() {
for (size_t i = 0; i != FINALIZE_LIMIT; ++i)
clearFreeListInArena(AllocKind(i));
for (ALL_ALLOC_KINDS(i))
clearFreeListInArena(i);
}
void clearFreeListInArena(AllocKind kind) {
@ -795,8 +795,8 @@ class ArenaLists
void checkEmptyFreeLists() {
#ifdef DEBUG
for (size_t i = 0; i < mozilla::ArrayLength(freeLists); ++i)
MOZ_ASSERT(freeLists[i].isEmpty());
for (ALL_ALLOC_KINDS(i))
checkEmptyFreeList(i);
#endif
}

Просмотреть файл

@ -52,7 +52,7 @@ using mozilla::PodZero;
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
NativeIterator::mark(JSTracer *trc)

Просмотреть файл

@ -1094,10 +1094,10 @@ static inline gc::AllocKind
NewObjectGCKind(const js::Class *clasp)
{
if (clasp == &ArrayObject::class_)
return gc::FINALIZE_OBJECT8;
return gc::AllocKind::OBJECT8;
if (clasp == &JSFunction::class_)
return gc::FINALIZE_OBJECT2;
return gc::FINALIZE_OBJECT4;
return gc::AllocKind::OBJECT2;
return gc::AllocKind::OBJECT4;
}
static inline JSObject *
@ -1407,7 +1407,7 @@ js::NewObjectWithGroupCommon(ExclusiveContext *cx, HandleObjectGroup group, Hand
{
MOZ_ASSERT(parent);
MOZ_ASSERT(allocKind <= gc::FINALIZE_OBJECT_LAST);
MOZ_ASSERT(allocKind <= gc::AllocKind::OBJECT_LAST);
if (CanBeFinalizedInBackground(allocKind, group->clasp()))
allocKind = GetBackgroundAllocKind(allocKind);
@ -1482,7 +1482,7 @@ CreateThisForFunctionWithGroup(JSContext *cx, HandleObjectGroup group,
if (TypeNewScript *newScript = group->newScript()) {
if (newScript->analyzed()) {
// 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.
RootedPlainObject templateObject(cx, newScript->templateObject());
MOZ_ASSERT(templateObject->group() == group);

Просмотреть файл

@ -755,7 +755,7 @@ GuessObjectGCKind(size_t numSlots)
{
if (numSlots)
return gc::GetGCObjectKind(numSlots);
return gc::FINALIZE_OBJECT4;
return gc::AllocKind::OBJECT4;
}
static inline gc::AllocKind
@ -763,7 +763,7 @@ GuessArrayGCKind(size_t numSlots)
{
if (numSlots)
return gc::GetGCArrayKind(numSlots);
return gc::FINALIZE_OBJECT8;
return gc::AllocKind::OBJECT8;
}
inline bool

Просмотреть файл

@ -281,7 +281,7 @@ js::DumpPCCounts(JSContext *cx, HandleScript script, Sprinter *sp)
void
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>());
if (script->compartment() != cx->compartment())
continue;
@ -298,8 +298,8 @@ js::DumpCompartmentPCCounts(JSContext *cx)
}
}
for (unsigned thingKind = FINALIZE_OBJECT0; thingKind < FINALIZE_OBJECT_LIMIT; thingKind++) {
for (ZoneCellIter i(cx->zone(), (AllocKind) thingKind); !i.done(); i.next()) {
for (OBJECT_ALLOC_KINDS(thingKind)) {
for (ZoneCellIter i(cx->zone(), thingKind); !i.done(); i.next()) {
JSObject *obj = i.get<JSObject>();
if (obj->compartment() != cx->compartment())
continue;
@ -2042,7 +2042,7 @@ js::StopPCCountProfiling(JSContext *cx)
return;
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>();
if (script->hasScriptCounts() && script->types()) {
ScriptAndCounts sac;

Просмотреть файл

@ -240,10 +240,10 @@ Shape::fixupDictionaryShapeAfterMovingGC()
}
AllocKind kind = TenuredCell::fromPointer(cell)->getAllocKind();
MOZ_ASSERT(kind == FINALIZE_SHAPE ||
kind == FINALIZE_ACCESSOR_SHAPE ||
kind <= FINALIZE_OBJECT_LAST);
if (kind == FINALIZE_SHAPE || kind == FINALIZE_ACCESSOR_SHAPE) {
MOZ_ASSERT(kind == AllocKind::SHAPE ||
kind == AllocKind::ACCESSOR_SHAPE ||
kind <= AllocKind::OBJECT_LAST);
if (kind == AllocKind::SHAPE || kind == AllocKind::ACCESSOR_SHAPE) {
// listp points to the parent field of the next shape.
Shape *next = reinterpret_cast<Shape *>(uintptr_t(listp) -
offsetof(Shape, parent));

Просмотреть файл

@ -129,7 +129,7 @@ class ArgumentsObject : public NativeObject
public:
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. */
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
// fixed slots (see the assert in createArrayInternal) and will not be using
// 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);
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
// fixed slots (see the assert in createArrayInternal) and will not be using
// its fixed elements.
gc::AllocKind kind = gc::FINALIZE_OBJECT0_BACKGROUND;
gc::AllocKind kind = gc::AllocKind::OBJECT0_BACKGROUND;
RootedObjectGroup group(cx, sharedElementsOwner->group());
ArrayObject *obj = createArrayInternal(cx, kind, heap, shape, group);

Просмотреть файл

@ -1930,7 +1930,7 @@ UpdateExecutionObservabilityOfScriptsInZone(JSContext *cx, Zone *zone,
return false;
}
} 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>();
if (obs.shouldRecompileOrInvalidate(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
// another one.
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.next())
{

Просмотреть файл

@ -232,7 +232,7 @@ class NewObjectCache
static void staticAsserts() {
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
@ -318,7 +318,7 @@ class NewObjectCache
private:
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);
}

Просмотреть файл

@ -339,7 +339,7 @@ class DeclEnvObject : public ScopeObject
public:
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_;
@ -361,7 +361,7 @@ class StaticEvalObject : public ScopeObject
public:
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_;
@ -435,7 +435,7 @@ class StaticWithObject : public NestedScopeObject
{
public:
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_;
@ -451,7 +451,7 @@ class DynamicWithObject : public NestedScopeObject
public:
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_;
@ -504,7 +504,7 @@ class BlockObject : public NestedScopeObject
public:
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_;
@ -690,7 +690,7 @@ class UninitializedLexicalObject : public ScopeObject
{
public:
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_;

Просмотреть файл

@ -777,7 +777,7 @@ class Shape : public gc::TenuredCell
}
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;
}
AccessorShape &asAccessorShape() const {
@ -1372,8 +1372,8 @@ Shape::Shape(const StackShape &other, uint32_t nfixed)
{
#ifdef DEBUG
gc::AllocKind allocKind = getAllocKind();
MOZ_ASSERT_IF(other.isAccessorShape(), allocKind == gc::FINALIZE_ACCESSOR_SHAPE);
MOZ_ASSERT_IF(allocKind == gc::FINALIZE_SHAPE, !other.isAccessorShape());
MOZ_ASSERT_IF(other.isAccessorShape(), allocKind == gc::AllocKind::ACCESSOR_SHAPE);
MOZ_ASSERT_IF(allocKind == gc::AllocKind::SHAPE, !other.isAccessorShape());
#endif
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),
rawSetter(other.rawSetter)
{
MOZ_ASSERT(getAllocKind() == gc::FINALIZE_ACCESSOR_SHAPE);
MOZ_ASSERT(getAllocKind() == gc::AllocKind::ACCESSOR_SHAPE);
if ((attrs & JSPROP_GETTER) && rawGetter)
GetterSetterWriteBarrierPost(this, &this->getterObj);

Просмотреть файл

@ -351,7 +351,7 @@ MOZ_ALWAYS_INLINE void
JSString::finalize(js::FreeOp *fop)
{
/* 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())
asFlat().finalize(fop);
@ -362,7 +362,7 @@ JSString::finalize(js::FreeOp *fop)
inline void
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())
fop->free_(nonInlineCharsRaw());
@ -371,7 +371,7 @@ JSFlatString::finalize(js::FreeOp *fop)
inline void
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())
fop->free_(nonInlineCharsRaw());

Просмотреть файл

@ -464,7 +464,7 @@ class JSString : public js::gc::TenuredCell
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);
@ -876,7 +876,7 @@ class JSFatInlineString : public JSInlineString
template<typename CharT>
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);
};
@ -910,7 +910,7 @@ class JSExternalString : public JSFlatString
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);
};

Просмотреть файл

@ -2476,13 +2476,13 @@ js::PrintTypes(JSContext *cx, JSCompartment *comp, bool force)
if (!force && !InferSpewActive(ISpewResult))
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>());
if (script->types())
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>();
group->print();
}
@ -4253,7 +4253,7 @@ TypeZone::endSweep(JSRuntime *rt)
void
TypeZone::clearAllNewScriptsOnOOM()
{
for (gc::ZoneCellIterUnderGC iter(zone(), gc::FINALIZE_OBJECT_GROUP);
for (gc::ZoneCellIterUnderGC iter(zone(), gc::AllocKind::OBJECT_GROUP);
!iter.done(); iter.next())
{
ObjectGroup *group = iter.get<ObjectGroup>();

Просмотреть файл

@ -178,7 +178,7 @@ class XDRState {
{
uint32_t tmp;
if (mode == XDR_ENCODE)
tmp = *val;
tmp = uint32_t(*val);
if (!codeUint32(&tmp))
return false;
if (mode == XDR_DECODE)