mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 20:47:44 +00:00
Bug 638199 - Shrink ArenaHeader (r=wmccloskey)
This commit is contained in:
parent
93d1a34c53
commit
d27001da51
@ -170,8 +170,6 @@ Arena<T>::init(JSCompartment *compartment, unsigned thingKind)
|
||||
aheader.compartment = compartment;
|
||||
aheader.thingKind = thingKind;
|
||||
aheader.freeList = &t.things[0].cell;
|
||||
aheader.thingSize = sizeof(T);
|
||||
aheader.isUsed = true;
|
||||
JS_ASSERT(sizeof(T) == sizeof(ThingOrCell<T>));
|
||||
ThingOrCell<T> *thing = &t.things[0];
|
||||
ThingOrCell<T> *last = &t.things[JS_ARRAY_LENGTH(t.things) - 1];
|
||||
@ -181,6 +179,8 @@ Arena<T>::init(JSCompartment *compartment, unsigned thingKind)
|
||||
}
|
||||
last->cell.link = NULL;
|
||||
#ifdef DEBUG
|
||||
aheader.thingSize = sizeof(T);
|
||||
aheader.isUsed = true;
|
||||
aheader.hasFreeThings = true;
|
||||
#endif
|
||||
}
|
||||
@ -211,16 +211,15 @@ template<typename T>
|
||||
inline ConservativeGCTest
|
||||
Arena<T>::mark(T *thing, JSTracer *trc)
|
||||
{
|
||||
JS_ASSERT(sizeof(T) == aheader.thingSize);
|
||||
|
||||
T *alignedThing = getAlignedThing(thing);
|
||||
|
||||
if (alignedThing > &t.things[ThingsPerArena-1].t || alignedThing < &t.things[0].t)
|
||||
return CGCT_NOTARENA;
|
||||
|
||||
if (!aheader.isUsed || inFreeList(alignedThing))
|
||||
if (!aheader.compartment || inFreeList(alignedThing))
|
||||
return CGCT_NOTLIVE;
|
||||
|
||||
JS_ASSERT(sizeof(T) == aheader.thingSize);
|
||||
JS_SET_TRACING_NAME(trc, "machine stack");
|
||||
Mark(trc, alignedThing);
|
||||
|
||||
@ -290,11 +289,17 @@ Chunk::init(JSRuntime *rt)
|
||||
Arena<FreeCell> *last = &arenas[JS_ARRAY_LENGTH(arenas) - 1];
|
||||
while (arena < last) {
|
||||
arena->header()->next = arena + 1;
|
||||
arena->header()->compartment = NULL;
|
||||
#ifdef DEBUG
|
||||
arena->header()->isUsed = false;
|
||||
#endif
|
||||
++arena;
|
||||
}
|
||||
last->header()->next = NULL;
|
||||
last->header()->compartment = NULL;
|
||||
#ifdef DEBUG
|
||||
last->header()->isUsed = false;
|
||||
#endif
|
||||
info.numFree = ArenasPerChunk;
|
||||
}
|
||||
|
||||
@ -353,7 +358,10 @@ Chunk::releaseArena(Arena<T> *arena)
|
||||
rt->gcBytes -= sizeof(Arena<T>);
|
||||
comp->gcBytes -= sizeof(Arena<T>);
|
||||
info.emptyArenaLists.insert((Arena<Cell> *)arena);
|
||||
#ifdef DEBUG
|
||||
arena->header()->isUsed = false;
|
||||
#endif
|
||||
arena->header()->compartment = NULL;
|
||||
++info.numFree;
|
||||
if (unused())
|
||||
info.age = 0;
|
||||
@ -632,9 +640,6 @@ MarkIfGCThingWord(JSTracer *trc, jsuword w, uint32 &thingKind)
|
||||
|
||||
ArenaHeader *aheader = cell->arena()->header();
|
||||
|
||||
if (!aheader->isUsed)
|
||||
return CGCT_FREEARENA;
|
||||
|
||||
ConservativeGCTest test;
|
||||
thingKind = aheader->thingKind;
|
||||
|
||||
|
@ -113,9 +113,9 @@ struct ArenaHeader {
|
||||
Arena<FreeCell> *next;
|
||||
FreeCell *freeList;
|
||||
unsigned thingKind;
|
||||
bool isUsed;
|
||||
size_t thingSize;
|
||||
#ifdef DEBUG
|
||||
size_t thingSize;
|
||||
bool isUsed;
|
||||
bool hasFreeThings;
|
||||
#endif
|
||||
};
|
||||
@ -304,7 +304,9 @@ EmptyArenaLists::getNext(JSCompartment *comp, unsigned thingKind) {
|
||||
if (arena) {
|
||||
JS_ASSERT(arena->header()->isUsed == false);
|
||||
JS_ASSERT(arena->header()->thingSize == sizeof(T));
|
||||
#ifdef DEBUG
|
||||
arena->header()->isUsed = true;
|
||||
#endif
|
||||
arena->header()->thingKind = thingKind;
|
||||
arena->header()->compartment = comp;
|
||||
return arena;
|
||||
@ -433,7 +435,7 @@ Arena<T>::getAlignedThing(void *thing)
|
||||
{
|
||||
jsuword start = reinterpret_cast<jsuword>(&t.things[0]);
|
||||
jsuword offset = reinterpret_cast<jsuword>(thing) - start;
|
||||
offset -= offset % aheader.thingSize;
|
||||
offset -= offset % sizeof(T);
|
||||
return reinterpret_cast<T *>(start + offset);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user