Fix bug 602574 - Assertion failure: constOffset != 0 in JSScript::NewScript() on 64-bit platforms. r=gal@uci.edu

This commit is contained in:
David Anderson 2010-10-10 15:47:09 -07:00
parent 15dee18d2a
commit c190047dbc
4 changed files with 31 additions and 37 deletions

View File

@ -296,44 +296,14 @@ struct JSScript {
js::mjit::JITScript *jitNormal; /* Extra JIT info for normal scripts */ js::mjit::JITScript *jitNormal; /* Extra JIT info for normal scripts */
js::mjit::JITScript *jitCtor; /* Extra JIT info for constructors */ js::mjit::JITScript *jitCtor; /* Extra JIT info for constructors */
void **nmapNormal;
void **nmapCtor;
bool hasJITCode() { bool hasJITCode() {
return jitNormal || jitCtor; return jitNormal || jitCtor;
} }
void setNativeMap(bool constructing, void **map) { // These methods are implemented in MethodJIT.h.
if (constructing) inline void **nativeMap(bool constructing);
nmapCtor = map; inline void *maybeNativeCodeForPC(bool constructing, jsbytecode *pc);
else inline void *nativeCodeForPC(bool constructing, jsbytecode *pc);
nmapNormal = map;
}
void **maybeNativeMap(bool constructing) {
return constructing ? nmapCtor : nmapNormal;
}
void **nativeMap(bool constructing) {
void **nmap = maybeNativeMap(constructing);
JS_ASSERT(nmap);
return nmap;
}
void *maybeNativeCodeForPC(bool constructing, jsbytecode *pc) {
void **nmap = maybeNativeMap(constructing);
if (!nmap)
return NULL;
JS_ASSERT(pc >= code && pc < code + length);
return nmap[pc - code];
}
void *nativeCodeForPC(bool constructing, jsbytecode *pc) {
void **nmap = nativeMap(constructing);
JS_ASSERT(pc >= code && pc < code + length);
JS_ASSERT(nmap[pc - code]);
return nmap[pc - code];
}
js::mjit::JITScript *getJIT(bool constructing) { js::mjit::JITScript *getJIT(bool constructing) {
return constructing ? jitCtor : jitNormal; return constructing ? jitCtor : jitNormal;

View File

@ -590,7 +590,7 @@ mjit::Compiler::finishThisUp(JITScript **jitp)
JS_ASSERT(size_t(cursor - (uint8*)jit) == totalBytes); JS_ASSERT(size_t(cursor - (uint8*)jit) == totalBytes);
script->setNativeMap(isConstructing, nmap); jit->nmap = nmap;
*jitp = jit; *jitp = jit;
return Compile_Okay; return Compile_Okay;

View File

@ -835,7 +835,6 @@ mjit::ReleaseScriptCode(JSContext *cx, JSScript *script)
script->jitArityCheckNormal = NULL; script->jitArityCheckNormal = NULL;
cx->free(script->jitNormal); cx->free(script->jitNormal);
script->jitNormal = NULL; script->jitNormal = NULL;
script->nmapNormal = NULL;
} }
if (script->jitCtor) { if (script->jitCtor) {
@ -843,7 +842,6 @@ mjit::ReleaseScriptCode(JSContext *cx, JSScript *script)
script->jitArityCheckCtor = NULL; script->jitArityCheckCtor = NULL;
cx->free(script->jitCtor); cx->free(script->jitCtor);
script->jitCtor = NULL; script->jitCtor = NULL;
script->nmapCtor = NULL;
} }
} }

View File

@ -187,6 +187,7 @@ struct CallSite;
struct JITScript { struct JITScript {
typedef JSC::MacroAssemblerCodeRef CodeRef; typedef JSC::MacroAssemblerCodeRef CodeRef;
CodeRef code; /* pool & code addresses */ CodeRef code; /* pool & code addresses */
void **nmap; /* pc -> JIT code map, sparse */
js::mjit::CallSite *callSites; js::mjit::CallSite *callSites;
uint32 nCallSites; uint32 nCallSites;
@ -268,6 +269,31 @@ struct CallSite
} /* namespace js */ } /* namespace js */
inline void *
JSScript::maybeNativeCodeForPC(bool constructing, jsbytecode *pc)
{
js::mjit::JITScript *jit = getJIT(constructing);
if (!jit)
return NULL;
JS_ASSERT(pc >= code && pc < code + length);
return jit->nmap[pc - code];
}
inline void **
JSScript::nativeMap(bool constructing)
{
return getJIT(constructing)->nmap;
}
inline void *
JSScript::nativeCodeForPC(bool constructing, jsbytecode *pc)
{
void **nmap = nativeMap(constructing);
JS_ASSERT(pc >= code && pc < code + length);
JS_ASSERT(nmap[pc - code]);
return nmap[pc - code];
}
#ifdef _MSC_VER #ifdef _MSC_VER
extern "C" void *JaegerThrowpoline(js::VMFrame *vmFrame); extern "C" void *JaegerThrowpoline(js::VMFrame *vmFrame);
#else #else