Bug 639743 - JM: clean up Executable{Pool,Allocator} some more, 6/6. r=dvander.

This commit is contained in:
Nicholas Nethercote 2011-03-09 19:13:29 -08:00
parent 0e02674730
commit d08f2f1dfa

View File

@ -95,7 +95,18 @@ public:
// remember whether m_destroy was computed for the currently active GC.
size_t m_gcNumber;
public:
void release(bool willDestroy = false)
{
JS_ASSERT(m_refCount != 0);
JS_ASSERT_IF(willDestroy, m_refCount = 1);
if (--m_refCount == 0) {
/* We can't (easily) use js_delete() here because the destructor is private. */
this->~ExecutablePool();
js_free(this);
}
}
private:
// It should be impossible for us to roll over, because only small
// pools have multiple holders, and they have one holder per chunk
// of generated code, and they only hold 16KB or so of code.
@ -105,13 +116,6 @@ public:
++m_refCount;
}
void release()
{
JS_ASSERT(m_refCount != 0);
if (--m_refCount == 0)
this->destroy();
}
private:
ExecutablePool(Allocation a)
: m_freePtr(a.pages), m_end(m_freePtr + a.size), m_allocation(a), m_refCount(1),
@ -132,13 +136,6 @@ private:
return result;
}
void destroy()
{
/* We can't (easily) use js_delete() here because the destructor is private. */
this->~ExecutablePool();
js_free(this);
}
size_t available() const {
JS_ASSERT(m_end >= m_freePtr);
return m_end - m_freePtr;
@ -174,7 +171,7 @@ public:
~ExecutableAllocator()
{
for (size_t i = 0; i < m_smallAllocationPools.length(); i++)
m_smallAllocationPools[i]->destroy();
m_smallAllocationPools[i]->release(/* willDestroy = */true);
}
// alloc() returns a pointer to some memory, and also (by reference) a