Bug 856368 - Inline the AllocateBy* and FreeBy* methods into the header. r=roc

This commit is contained in:
Mats Palmgren 2013-04-15 22:00:06 +02:00
Родитель 11a4e4ae9f
Коммит d7cb6e0ea4
2 изменённых файлов: 33 добавлений и 51 удалений

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

@ -250,7 +250,7 @@ nsPresArena::~nsPresArena()
PL_FinishArenaPool(&mPool);
}
void*
NS_HIDDEN_(void*)
nsPresArena::Allocate(uint32_t aCode, size_t aSize)
{
NS_ABORT_IF_FALSE(aSize > 0, "PresArena cannot allocate zero bytes");
@ -308,7 +308,7 @@ nsPresArena::Allocate(uint32_t aCode, size_t aSize)
return result;
}
void
NS_HIDDEN_(void)
nsPresArena::Free(uint32_t aCode, void* aPtr)
{
// Try to recycle this entry.
@ -414,42 +414,6 @@ nsPresArena::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf,
aArenaStats->mOther = mallocSize - data.total;
}
void*
nsPresArena::AllocateBySize(size_t aSize)
{
return Allocate(uint32_t(aSize) | uint32_t(NON_OBJECT_MARKER), aSize);
}
void
nsPresArena::FreeBySize(size_t aSize, void* aPtr)
{
Free(uint32_t(aSize) | uint32_t(NON_OBJECT_MARKER), aPtr);
}
void*
nsPresArena::AllocateByFrameID(nsQueryFrame::FrameIID aID, size_t aSize)
{
return Allocate(aID, aSize);
}
void
nsPresArena::FreeByFrameID(nsQueryFrame::FrameIID aID, void* aPtr)
{
Free(aID, aPtr);
}
void*
nsPresArena::AllocateByObjectID(ObjectID aID, size_t aSize)
{
return Allocate(aID, aSize);
}
void
nsPresArena::FreeByObjectID(ObjectID aID, void* aPtr)
{
Free(aID, aPtr);
}
/* static */ uintptr_t
nsPresArena::GetPoisonValue()
{

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

@ -23,15 +23,6 @@ public:
nsPresArena();
~nsPresArena();
// Pool allocation with recycler lists indexed by object size, aSize.
NS_HIDDEN_(void*) AllocateBySize(size_t aSize);
NS_HIDDEN_(void) FreeBySize(size_t aSize, void* aPtr);
// Pool allocation with recycler lists indexed by frame-type ID.
// Every aID must always be used with the same object size, aSize.
NS_HIDDEN_(void*) AllocateByFrameID(nsQueryFrame::FrameIID aID, size_t aSize);
NS_HIDDEN_(void) FreeByFrameID(nsQueryFrame::FrameIID aID, void* aPtr);
enum ObjectID {
nsLineBox_id = nsQueryFrame::NON_FRAME_MARKER,
nsRuleNode_id,
@ -47,10 +38,37 @@ public:
NON_OBJECT_MARKER = 0x40000000
};
// Pool allocation with recycler lists indexed by object size, aSize.
NS_HIDDEN_(void*) AllocateBySize(size_t aSize)
{
return Allocate(uint32_t(aSize) | uint32_t(NON_OBJECT_MARKER), aSize);
}
NS_HIDDEN_(void) FreeBySize(size_t aSize, void* aPtr)
{
Free(uint32_t(aSize) | uint32_t(NON_OBJECT_MARKER), aPtr);
}
// Pool allocation with recycler lists indexed by frame-type ID.
// Every aID must always be used with the same object size, aSize.
NS_HIDDEN_(void*) AllocateByFrameID(nsQueryFrame::FrameIID aID, size_t aSize)
{
return Allocate(aID, aSize);
}
NS_HIDDEN_(void) FreeByFrameID(nsQueryFrame::FrameIID aID, void* aPtr)
{
Free(aID, aPtr);
}
// Pool allocation with recycler lists indexed by object-type ID (see above).
// Every aID must always be used with the same object size, aSize.
NS_HIDDEN_(void*) AllocateByObjectID(ObjectID aID, size_t aSize);
NS_HIDDEN_(void) FreeByObjectID(ObjectID aID, void* aPtr);
NS_HIDDEN_(void*) AllocateByObjectID(ObjectID aID, size_t aSize)
{
return Allocate(aID, aSize);
}
NS_HIDDEN_(void) FreeByObjectID(ObjectID aID, void* aPtr)
{
Free(aID, aPtr);
}
/**
* Fill aArenaStats with sizes of interesting objects allocated in
@ -69,8 +87,8 @@ public:
static uintptr_t GetPoisonValue();
private:
void* Allocate(uint32_t aCode, size_t aSize);
void Free(uint32_t aCode, void* aPtr);
NS_HIDDEN_(void*) Allocate(uint32_t aCode, size_t aSize);
NS_HIDDEN_(void) Free(uint32_t aCode, void* aPtr);
// All keys to this hash table fit in 32 bits (see below) so we do not
// bother actually hashing them.