Bug 523766 - move jump tables to allocator, r=gal.

This commit is contained in:
Graydon Hoare 2009-10-21 19:50:35 -07:00
parent 399e52afa4
commit 344543af05
3 changed files with 9 additions and 13 deletions

View File

@ -151,6 +151,9 @@ static const char tagChar[] = "OIDISIBI";
/* Max global object size. */
#define MAX_GLOBAL_SLOTS 4096
/* Max number of slots in a table-switch. */
#define MAX_TABLE_SWITCH 256
/* Max memory needed to rebuild the interpreter stack when falling off trace. */
#define MAX_INTERP_STACK_BYTES \
(MAX_NATIVE_STACK_SLOTS * sizeof(jsval) + \
@ -8324,11 +8327,8 @@ TraceRecorder::tableswitch()
high = GET_JUMPX_OFFSET(pc);
}
/*
* Really large tables won't fit in a page. This is a conservative check.
* If it matters in practice we need to go off-page.
*/
if ((high + 1 - low) * sizeof(intptr_t*) + 128 > (unsigned) LARGEST_UNDERRUN_PROT)
/* Cap maximum table-switch size for modesty. */
if ((high + 1 - low) > MAX_TABLE_SWITCH)
return InjectStatus(switchop());
/* Generate switch LIR. */

View File

@ -1460,13 +1460,9 @@ namespace nanojit
*/
void Assembler::emitJumpTable(SwitchInfo* si, NIns* target)
{
underrunProtect(si->count * sizeof(NIns*) + 20);
_nIns = reinterpret_cast<NIns*>(uintptr_t(_nIns) & ~(sizeof(NIns*) - 1));
for (uint32_t i = 0; i < si->count; ++i) {
_nIns = (NIns*) (((intptr_t) _nIns) - sizeof(NIns*));
*(NIns**) _nIns = target;
}
si->table = (NIns**) _nIns;
si->table = (NIns **) alloc.alloc(si->count * sizeof(NIns*));
for (uint32_t i = 0; i < si->count; ++i)
si->table[i] = target;
}
void Assembler::assignSavedRegs()

View File

@ -101,7 +101,7 @@ namespace nanojit
// then by the C functions it calls).
const int NJ_ALIGN_STACK = 16;
const int32_t LARGEST_UNDERRUN_PROT = 3200; // largest value passed to underrunProtect
const int32_t LARGEST_UNDERRUN_PROT = 32; // largest value passed to underrunProtect
typedef uint8_t NIns;