This commit is contained in:
David Anderson 2009-10-21 20:01:40 -07:00
commit 54edcd9d12
5 changed files with 12 additions and 16 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) + \
@ -8332,11 +8335,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

@ -310,12 +310,12 @@ extern "C" void sync_instruction_memory(caddr_t v, u_int len);
#elif defined AVMPLUS_UNIX
#ifdef ANDROID
void CodeAlloc::flushICache(void *start, size_t len) {
cacheflush((int)start, (int)(start + len), 0);
cacheflush((int)start, (int)start + len, 0);
}
#else
// fixme: __clear_cache is a libgcc feature, test for libgcc or gcc
void CodeAlloc::flushICache(void *start, size_t len) {
__clear_cache((char*)start, (char*)(start + len));
__clear_cache((char*)start, (char*)start + len);
}
#endif
#endif // AVMPLUS_MAC && NANOJIT_PPC

View File

@ -384,7 +384,7 @@ namespace nanojit
typedef uint8_t NIns;
// Bytes of icache to flush after Assembler::patch
const size_t LARGEST_BRANCH_PATCH = 16 * sizeof(Nins);
const size_t LARGEST_BRANCH_PATCH = 16 * sizeof(NIns);
inline Register nextreg(Register r) {
return Register(r+1);

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;