[INFER] Don't use shell bindMethod function on non-compileAndGo scripts, bug 654710.

This commit is contained in:
Brian Hackett 2011-05-09 13:03:03 -07:00
parent 4955efb887
commit aae52a8f74
3 changed files with 13 additions and 1 deletions

View File

@ -285,6 +285,9 @@ LoopState::clearLoopRegisters()
bool
LoopState::loopInvariantEntry(uint32 slot)
{
if (slot == UNASSIGNED)
return true;
/* Watch for loop temporaries. :XXX: this is really gross. */
if (slot - analyze::LocalSlot(outerScript, 0) >= outerScript->nslots)
return true;

View File

@ -5177,6 +5177,15 @@ its_bindMethod(JSContext *cx, uintN argc, jsval *vp)
return JS_FALSE;
}
if (method->getFunctionPrivate()->isInterpreted() &&
method->getFunctionPrivate()->script()->compileAndGo) {
/* Can't reparent compileAndGo scripts. */
JSAutoByteString nameBytes(cx, name);
if (!!nameBytes)
JS_ReportError(cx, "can't bind method %s to compileAndGo script", nameBytes.ptr());
return JS_FALSE;
}
jsid id;
if (!JS_ValueToId(cx, STRING_TO_JSVAL(name), &id))
return JS_FALSE;

View File

@ -59,7 +59,7 @@ printStatus(inSection(2));
function getBoundMethod()
{
return it.bindMethod("boundMethod", function () { return this; });
return it.bindMethod("boundMethod", Function("return this"));
}
// it is a js shell only construction