зеркало из https://github.com/mozilla/gecko-dev.git
Bug 557991 - nanojit: remove dead code from CodeAlloc. r=edwsmith.
--HG-- extra : convert_revision : 335ca0fff2a7ac451d0fa1c11594f6dbacada648
This commit is contained in:
Родитель
aa8c8d3faf
Коммит
a034e2854e
|
@ -303,7 +303,7 @@ namespace nanojit
|
|||
{
|
||||
if (error()) return;
|
||||
// This may be a normal code chunk or an exit code chunk.
|
||||
NanoAssertMsg(containsPtr(codeStart, codeEnd, _nIns),
|
||||
NanoAssertMsg(codeStart <= _nIns && _nIns <= codeEnd,
|
||||
"Native instruction pointer overstep paging bounds; check overrideProtect for last instruction");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -210,41 +210,6 @@ namespace nanojit
|
|||
debug_only(sanity_check();)
|
||||
}
|
||||
|
||||
void CodeAlloc::sweep() {
|
||||
debug_only(sanity_check();)
|
||||
|
||||
// Pass #1: remove fully-coalesced blocks from availblocks.
|
||||
CodeList** prev = &availblocks;
|
||||
for (CodeList* ab = availblocks; ab != 0; ab = *prev) {
|
||||
NanoAssert(ab->higher != 0);
|
||||
NanoAssert(ab->isFree);
|
||||
if (!ab->higher->higher && !ab->lower) {
|
||||
*prev = ab->next;
|
||||
debug_only(ab->next = 0;)
|
||||
} else {
|
||||
prev = &ab->next;
|
||||
}
|
||||
}
|
||||
|
||||
// Pass #2: remove same blocks from heapblocks, and free them.
|
||||
prev = &heapblocks;
|
||||
for (CodeList* hb = heapblocks; hb != 0; hb = *prev) {
|
||||
NanoAssert(hb->lower != 0);
|
||||
if (!hb->lower->lower && hb->lower->isFree) {
|
||||
NanoAssert(!hb->lower->next);
|
||||
// whole page is unused
|
||||
void* mem = hb->lower;
|
||||
*prev = hb->next;
|
||||
_nvprof("free page",1);
|
||||
markBlockWrite(firstBlock(hb));
|
||||
freeCodeChunk(mem, bytesPerAlloc);
|
||||
totalAllocated -= bytesPerAlloc;
|
||||
} else {
|
||||
prev = &hb->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CodeAlloc::freeAll(CodeList* &code) {
|
||||
while (code) {
|
||||
CodeList *b = removeBlock(code);
|
||||
|
@ -463,52 +428,10 @@ extern "C" void sync_instruction_memory(caddr_t v, u_int len);
|
|||
}
|
||||
}
|
||||
|
||||
size_t CodeAlloc::size(const CodeList* blocks) {
|
||||
size_t size = 0;
|
||||
for (const CodeList* b = blocks; b != 0; b = b->next)
|
||||
size += int((uintptr_t)b->end - (uintptr_t)b);
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t CodeAlloc::size() {
|
||||
return totalAllocated;
|
||||
}
|
||||
|
||||
bool CodeAlloc::contains(const CodeList* blocks, NIns* p) {
|
||||
for (const CodeList *b = blocks; b != 0; b = b->next) {
|
||||
_nvprof("block contains",1);
|
||||
if (b->contains(p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CodeAlloc::moveAll(CodeList* &blocks, CodeList* &other) {
|
||||
if (other) {
|
||||
CodeList* last = other;
|
||||
while (last->next)
|
||||
last = last->next;
|
||||
last->next = blocks;
|
||||
blocks = other;
|
||||
other = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// figure out whether this is a pointer into allocated/free code,
|
||||
// or something we don't manage.
|
||||
CodeAlloc::CodePointerKind CodeAlloc::classifyPtr(NIns *p) {
|
||||
for (CodeList* hb = heapblocks; hb != 0; hb = hb->next) {
|
||||
CodeList* b = firstBlock(hb);
|
||||
if (!containsPtr((NIns*)b, (NIns*)((uintptr_t)b + bytesPerAlloc), p))
|
||||
continue;
|
||||
do {
|
||||
if (b->contains(p))
|
||||
return b->isFree ? kFree : kUsed;
|
||||
} while ((b = b->higher) != 0);
|
||||
}
|
||||
return kUnknown;
|
||||
}
|
||||
|
||||
// check that all block neighbors are correct
|
||||
#ifdef _DEBUG
|
||||
void CodeAlloc::sanity_check() {
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
|
||||
namespace nanojit
|
||||
{
|
||||
/** return true if ptr is in the range [start, end] */
|
||||
inline bool containsPtr(const NIns* start, const NIns* end, const NIns* ptr) {
|
||||
return ptr >= start && ptr <= end;
|
||||
}
|
||||
|
||||
/**
|
||||
* CodeList is a linked list of non-contigous blocks of code. Clients use CodeList*
|
||||
* to point to a list, and each CodeList instance tracks a single contiguous
|
||||
|
@ -93,9 +88,6 @@ namespace nanojit
|
|||
|
||||
/** return the whole size of this block including overhead */
|
||||
size_t blockSize() const { return uintptr_t(end) - uintptr_t(this); }
|
||||
|
||||
/** return true if just this block contains p */
|
||||
bool contains(NIns* p) const { return containsPtr(&code[0], end, p); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -196,31 +188,12 @@ namespace nanojit
|
|||
/** add a block previously returned by alloc(), to code */
|
||||
static void add(CodeList* &code, NIns* start, NIns* end);
|
||||
|
||||
/** move all the code in list "from" to list "to", and leave from empty. */
|
||||
static void moveAll(CodeList* &to, CodeList* &from);
|
||||
|
||||
/** return true if any block in list "code" contains the code pointer p */
|
||||
static bool contains(const CodeList* code, NIns* p);
|
||||
|
||||
/** return the number of bytes in all the code blocks in "code", including block overhead */
|
||||
static size_t size(const CodeList* code);
|
||||
|
||||
/** return the total number of bytes held by this CodeAlloc. */
|
||||
size_t size();
|
||||
|
||||
/** print out stats about heap usage */
|
||||
void logStats();
|
||||
|
||||
enum CodePointerKind {
|
||||
kUnknown, kFree, kUsed
|
||||
};
|
||||
|
||||
/** determine whether the given address is not code, or is allocated or free */
|
||||
CodePointerKind classifyPtr(NIns *p);
|
||||
|
||||
/** return any completely empty pages */
|
||||
void sweep();
|
||||
|
||||
/** protect all code in this code alloc */
|
||||
void markAllExec();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче