[INFER] Recompile target script in InvokeSession as necessary, bug 621292.

This commit is contained in:
Brian Hackett 2011-03-04 15:56:37 -08:00
parent e5852f8376
commit eb12efe47d
2 changed files with 39 additions and 5 deletions

View File

@ -0,0 +1,24 @@
/* Don't crash. */
var count = 0;
function callbackfn(v) {
if (++count == 98)
count = 0x7ffffff0;
return arr[0] + count;
}
function foo() {
arr = [1,2,3,4,5];
for (var i = 0; i < 50; i++)
arr = arr.map(callbackfn);
}
foo();
function f(a,b,c) {
a = 1; b = 'str'; c = 2.1;
return arguments[0];
}
for (var i = 0; i < 20; i++)
assertEq(f(10,'sss',1), 1);

View File

@ -587,14 +587,24 @@ InvokeSessionGuard::invoke(JSContext *cx) const
formals_[-2] = savedCallee_;
formals_[-1] = savedThis_;
#ifdef JS_METHODJIT
void *code;
if (!optimized() || !(code = script_->getJIT(false /* !constructing */)->invokeEntry))
#else
if (!optimized())
#endif
return Invoke(cx, args_, 0);
#ifdef JS_METHODJIT
mjit::JITScript *jit = script_->getJIT(false /* !constructing */);
if (!jit) {
/* Watch in case the code was thrown away due a recompile. */
mjit::CompileStatus status = mjit::TryCompile(cx, frame_.fp());
if (status == mjit::Compile_Error)
return false;
JS_ASSERT(status == mjit::Compile_Okay);
jit = script_->getJIT(false);
}
void *code;
if (!(code = jit->invokeEntry))
return Invoke(cx, args_, 0);
#endif
/* Clear any garbage left from the last Invoke. */
JSStackFrame *fp = frame_.fp();
fp->clearMissingArgs();