Bug 1011355 (part 1) - Remove FreeList::allocateFromNewArena(). r=billm.

--HG--
extra : rebase_source : 0098da34802c9febdd0fe351859ce995ba7e449a
This commit is contained in:
Nicholas Nethercote 2014-05-15 17:27:08 -07:00
parent c8e1e0042a
commit 5b33354245
2 changed files with 12 additions and 22 deletions

View File

@ -379,22 +379,6 @@ class FreeList
JS_EXTRA_POISON(reinterpret_cast<void *>(thing), JS_ALLOCATED_TENURED_PATTERN, thingSize);
return reinterpret_cast<void *>(thing);
}
/*
* Allocate from a newly allocated arena. The arena will have been set up
* as fully used during the initialization so to allocate we simply return
* the first thing in the arena and set the free list to point to the
* second.
*/
MOZ_ALWAYS_INLINE void *allocateFromNewArena(uintptr_t arenaAddr, size_t firstThingOffset,
size_t thingSize) {
JS_ASSERT(isEmpty());
JS_ASSERT(!(arenaAddr & ArenaMask));
uintptr_t thing = arenaAddr + firstThingOffset;
head.initFinal(thing + thingSize, arenaAddr + ArenaSize - thingSize, thingSize);
JS_EXTRA_POISON(reinterpret_cast<void *>(thing), JS_ALLOCATED_TENURED_PATTERN, thingSize);
return reinterpret_cast<void *>(thing);
}
};
/* Every arena has a header. */
@ -479,7 +463,7 @@ struct ArenaHeader : public JS::shadow::ArenaHeader
static_assert(FINALIZE_LIMIT <= 255, "We must be able to fit the allockind into uint8_t.");
allocKind = size_t(kind);
/* See comments in FreeSpan::allocateFromNewArena. */
/* The arena is initially marked as full; see allocateFromArenaInline(). */
firstFreeSpanOffsets = FreeSpan::FullArenaOffsets;
}

View File

@ -1591,12 +1591,18 @@ ArenaLists::allocateFromArenaInline(Zone *zone, AllocKind thingKind)
}
al->insertAtStart(aheader);
/* See comments before allocateFromNewArena about this assert. */
/*
* Allocate from a newly allocated arena. The arena will have been set up
* as fully used during the initialization so we have to re-mark it as
* empty before allocating.
*/
JS_ASSERT(!aheader->hasFreeThings());
uintptr_t arenaAddr = aheader->arenaAddress();
return freeLists[thingKind].allocateFromNewArena(arenaAddr,
Arena::firstThingOffset(thingKind),
Arena::thingSize(thingKind));
Arena *arena = aheader->getArena();
size_t thingSize = Arena::thingSize(thingKind);
FreeSpan fullSpan;
fullSpan.initFinal(arena->thingsStart(thingKind), arena->thingsEnd() - thingSize, thingSize);
freeLists[thingKind].setHead(&fullSpan);
return freeLists[thingKind].allocate(thingSize);
}
void *