Add interface for JSStackFrame.fun/script/thisv/rval, bug 586533. r=lw

This commit is contained in:
Brian Hackett 2010-08-15 08:44:51 -04:00
parent 7c4464a4e9
commit 7cbcc50fa8
27 changed files with 503 additions and 388 deletions

View File

@ -5386,7 +5386,7 @@ nsContentUtils::CanAccessNativeAnon()
// Some code is running, we can't make the assumption, as above, but we
// can't use a native frame, so clear fp.
fp = nsnull;
} else if (!fp->script) {
} else if (!fp->hasScript()) {
fp = nsnull;
}
@ -5401,8 +5401,8 @@ nsContentUtils::CanAccessNativeAnon()
// if they've been cloned into less privileged contexts.
static const char prefix[] = "chrome://global/";
const char *filename;
if (fp && fp->script &&
(filename = fp->script->filename) &&
if (fp && fp->hasScript() &&
(filename = fp->getScript()->filename) &&
!strncmp(filename, prefix, NS_ARRAY_LENGTH(prefix) - 1)) {
return PR_TRUE;
}

View File

@ -1222,7 +1222,7 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
cx->debugHooks->
debuggerHandlerData)) {
case JSTRAP_RETURN:
fp->rval = js::Valueify(rval);
fp->setReturnValue(js::Valueify(rval));
return JS_TRUE;
case JSTRAP_ERROR:
cx->throwing = JS_FALSE;

View File

@ -4303,7 +4303,7 @@ js_generic_native_method_dispatcher(JSContext *cx, JSObject *obj,
*/
if (!ComputeThisFromArgv(cx, argv))
return JS_FALSE;
js_GetTopStackFrame(cx)->thisv = argv[-1];
js_GetTopStackFrame(cx)->setThisValue(argv[-1]);
JS_ASSERT(cx->fp->argv == argv);
/* Clear the last parameter in case too few arguments were passed. */

View File

@ -345,7 +345,7 @@ JS_REQUIRES_STACK void
StackSpace::pushSynthesizedSlowNativeFrame(JSContext *cx, StackSegment *seg, JSStackFrame *fp,
JSFrameRegs &regs)
{
JS_ASSERT(!fp->script && FUN_SLOW_NATIVE(fp->fun));
JS_ASSERT(!fp->hasScript() && FUN_SLOW_NATIVE(fp->getFunction()));
fp->down = cx->fp;
seg->setPreviousInMemory(currentSegment);
currentSegment = seg;
@ -359,7 +359,7 @@ StackSpace::popSynthesizedSlowNativeFrame(JSContext *cx)
JS_ASSERT(isCurrentAndActive(cx));
JS_ASSERT(cx->hasActiveSegment());
JS_ASSERT(currentSegment->getInitialFrame() == cx->fp);
JS_ASSERT(!cx->fp->script && FUN_SLOW_NATIVE(cx->fp->fun));
JS_ASSERT(!cx->fp->hasScript() && FUN_SLOW_NATIVE(cx->fp->getFunction()));
cx->popSegmentAndFrame();
currentSegment = currentSegment->getPreviousInMemory();
}
@ -1312,7 +1312,7 @@ PopulateReportBlame(JSContext *cx, JSErrorReport *report)
*/
for (JSStackFrame *fp = js_GetTopStackFrame(cx); fp; fp = fp->down) {
if (fp->pc(cx)) {
report->filename = fp->script->filename;
report->filename = fp->getScript()->filename;
report->lineno = js_FramePCToLineNumber(cx, fp);
break;
}
@ -1406,7 +1406,7 @@ checkReportFlags(JSContext *cx, uintN *flags)
* the nearest scripted frame is strict, see bug 536306.
*/
JSStackFrame *fp = js_GetScriptedCaller(cx, NULL);
if (fp && fp->script->strictModeCode)
if (fp && fp->getScript()->strictModeCode)
*flags &= ~JSREPORT_WARNING;
else if (JS_HAS_STRICT_OPTION(cx))
*flags |= JSREPORT_WARNING;
@ -1870,7 +1870,7 @@ js_GetScriptedCaller(JSContext *cx, JSStackFrame *fp)
if (!fp)
fp = js_GetTopStackFrame(cx);
while (fp) {
if (fp->script)
if (fp->hasScript())
return fp;
fp = fp->down;
}

View File

@ -2014,8 +2014,8 @@ struct JSContext
JSStackFrame *findFrameAtLevel(uintN targetLevel) {
JSStackFrame *fp = this->fp;
while (true) {
JS_ASSERT(fp && fp->script);
if (fp->script->staticLevel == targetLevel)
JS_ASSERT(fp && fp->hasScript());
if (fp->getScript()->staticLevel == targetLevel)
break;
fp = fp->down;
}
@ -2299,14 +2299,14 @@ JS_ALWAYS_INLINE JSObject *
JSStackFrame::varobj(js::StackSegment *seg) const
{
JS_ASSERT(seg->contains(this));
return fun ? maybeCallObj() : seg->getInitialVarObj();
return hasFunction() ? maybeCallObj() : seg->getInitialVarObj();
}
JS_ALWAYS_INLINE JSObject *
JSStackFrame::varobj(JSContext *cx) const
{
JS_ASSERT(cx->activeSegment()->contains(this));
return fun ? maybeCallObj() : cx->activeSegment()->getInitialVarObj();
return hasFunction() ? maybeCallObj() : cx->activeSegment()->getInitialVarObj();
}
JS_ALWAYS_INLINE jsbytecode *
@ -2348,7 +2348,8 @@ class AutoCheckRequestDepth {
static inline uintN
FramePCOffset(JSContext *cx, JSStackFrame* fp)
{
return uintN((fp->hasIMacroPC() ? fp->getIMacroPC() : fp->pc(cx)) - fp->script->code);
jsbytecode *pc = fp->hasIMacroPC() ? fp->getIMacroPC() : fp->pc(cx);
return uintN(pc - fp->getScript()->code);
}
static inline JSAtom **
@ -2356,7 +2357,7 @@ FrameAtomBase(JSContext *cx, JSStackFrame *fp)
{
return fp->hasIMacroPC()
? COMMON_ATOMS_START(&cx->runtime->atomState)
: fp->script->atomMap.vector;
: fp->getScript()->atomMap.vector;
}
namespace js {

View File

@ -343,9 +343,9 @@ FrameRegsIter::contiguousDownFrameSP(JSStackFrame *up)
Value *sp = up->argv + up->argc;
#ifdef DEBUG
JS_ASSERT(sp <= up->argEnd());
JS_ASSERT(sp >= (up->down->script ? up->down->base() : up->down->slots()));
if (up->fun) {
uint16 nargs = up->fun->nargs;
JS_ASSERT(sp >= (up->down->hasScript() ? up->down->base() : up->down->slots()));
if (up->hasFunction()) {
uint16 nargs = up->getFunction()->nargs;
uintN argc = up->argc;
uintN missing = argc < nargs ? nargs - argc : 0;
JS_ASSERT(sp == up->argEnd() - missing);

View File

@ -682,8 +682,8 @@ js_watch_set(JSContext *cx, JSObject *obj, jsid id, Value *vp)
JSStackFrame *fp = frame.getFrame();
PodZero(fp);
MakeValueRangeGCSafe(fp->slots(), nfixed);
fp->script = script;
fp->fun = fun;
fp->setScript(script);
fp->setFunction(fun);
fp->argv = vp + 2;
fp->setScopeChain(closure->getParent());
fp->setArgsObj(NULL);
@ -1100,7 +1100,7 @@ JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp)
JS_PUBLIC_API(JSScript *)
JS_GetFrameScript(JSContext *cx, JSStackFrame *fp)
{
return fp->script;
return fp->maybeScript();
}
JS_PUBLIC_API(jsbytecode *)
@ -1120,16 +1120,16 @@ JS_StackFramePrincipals(JSContext *cx, JSStackFrame *fp)
{
JSSecurityCallbacks *callbacks;
if (fp->fun) {
if (fp->hasFunction()) {
callbacks = JS_GetSecurityCallbacks(cx);
if (callbacks && callbacks->findObjectPrincipals) {
if (FUN_OBJECT(fp->fun) != fp->callee())
if (FUN_OBJECT(fp->getFunction()) != fp->callee())
return callbacks->findObjectPrincipals(cx, fp->callee());
/* FALL THROUGH */
}
}
if (fp->script)
return fp->script->principals;
if (fp->hasScript())
return fp->getScript()->principals;
return NULL;
}
@ -1162,7 +1162,7 @@ JS_EvalFramePrincipals(JSContext *cx, JSStackFrame *fp, JSStackFrame *caller)
JS_PUBLIC_API(void *)
JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp)
{
if (fp->hasAnnotation() && fp->script) {
if (fp->hasAnnotation() && fp->hasScript()) {
JSPrincipals *principals = JS_StackFramePrincipals(cx, fp);
if (principals && principals->globalPrivilegesEnabled(cx, principals)) {
@ -1197,7 +1197,7 @@ JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp)
JS_PUBLIC_API(JSBool)
JS_IsNativeFrame(JSContext *cx, JSStackFrame *fp)
{
return !fp->script;
return !fp->hasScript();
}
/* this is deprecated, use JS_GetFrameScopeChain instead */
@ -1222,7 +1222,7 @@ JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp)
{
JS_ASSERT(cx->stack().contains(fp));
if (! fp->fun)
if (!fp->hasFunction())
return NULL;
/* Force creation of argument object if not yet created */
@ -1247,17 +1247,17 @@ JS_GetFrameThis(JSContext *cx, JSStackFrame *fp)
JS_PUBLIC_API(JSFunction *)
JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp)
{
return fp->fun;
return fp->maybeFunction();
}
JS_PUBLIC_API(JSObject *)
JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp)
{
if (!fp->fun)
if (!fp->hasFunction())
return NULL;
JS_ASSERT(fp->callee()->isFunction());
JS_ASSERT(fp->callee()->getPrivate() == fp->fun);
JS_ASSERT(fp->callee()->getPrivate() == fp->getFunction());
return fp->callee();
}
@ -1293,13 +1293,13 @@ JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp)
JS_PUBLIC_API(jsval)
JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp)
{
return Jsvalify(fp->rval);
return Jsvalify(fp->getReturnValue());
}
JS_PUBLIC_API(void)
JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval)
{
fp->rval = Valueify(rval);
fp->setReturnValue(Valueify(rval));
}
/************************************************************************/
@ -1562,7 +1562,7 @@ SetupFakeFrame(JSContext *cx, ExecuteFrameGuard &frame, JSFrameRegs &regs, JSObj
JSStackFrame *fp = frame.getFrame();
PodZero(fp);
fp->fun = fun;
fp->setFunction(fun);
fp->argv = vp + 2;
fp->setScopeChain(scopeobj->getGlobal());
@ -1796,8 +1796,8 @@ JS_GetTopScriptFilenameFlags(JSContext *cx, JSStackFrame *fp)
if (!fp)
fp = js_GetTopStackFrame(cx);
while (fp) {
if (fp->script)
return JS_GetScriptFilenameFlags(fp->script);
if (fp->hasScript())
return JS_GetScriptFilenameFlags(fp->getScript());
fp = fp->down;
}
return 0;

View File

@ -1874,7 +1874,7 @@ static bool
MakeUpvarForEval(JSParseNode *pn, JSCodeGenerator *cg)
{
JSContext *cx = cg->parser->context;
JSFunction *fun = cg->parser->callerFrame->fun;
JSFunction *fun = cg->parser->callerFrame->getFunction();
uintN upvarLevel = fun->u.i.script->staticLevel;
JSFunctionBox *funbox = cg->funbox;
@ -2059,8 +2059,8 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (cg->flags & TCF_IN_FOR_INIT)
return JS_TRUE;
JS_ASSERT(caller->script);
if (!caller->fun)
JS_ASSERT(caller->hasScript());
if (!caller->hasFunction())
return JS_TRUE;
/*
@ -2089,7 +2089,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
* defeats the display optimization to static link searching used
* by JSOP_{GET,CALL}UPVAR.
*/
JSFunction *fun = cg->parser->callerFrame->fun;
JSFunction *fun = cg->parser->callerFrame->getFunction();
JS_ASSERT(cg->staticLevel >= fun->u.i.script->staticLevel);
unsigned skip = cg->staticLevel - fun->u.i.script->staticLevel;
if (cg->skipSpansGenerator(skip))
@ -2159,7 +2159,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JSStackFrame *caller = cg->parser->callerFrame;
#endif
JS_ASSERT(caller);
JS_ASSERT(caller->script);
JS_ASSERT(caller->hasScript());
JSTreeContext *tc = cg;
while (tc->staticLevel != level)
@ -2168,7 +2168,7 @@ BindNameToSlot(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JSCodeGenerator *evalcg = (JSCodeGenerator *) tc;
JS_ASSERT(evalcg->compileAndGo());
JS_ASSERT(caller->fun && cg->parser->callerVarObj == evalcg->scopeChain);
JS_ASSERT(caller->hasFunction() && cg->parser->callerVarObj == evalcg->scopeChain);
/*
* Don't generate upvars on the left side of a for loop. See

View File

@ -293,7 +293,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
stackDepth = 0;
valueCount = 0;
for (fp = js_GetTopStackFrame(cx); fp; fp = fp->down) {
if (fp->fun && fp->argv) {
if (fp->hasFunction() && fp->argv) {
Value v = NullValue();
if (checkAccess &&
!checkAccess(cx, fp->callee(), callerid, JSACC_READ, &v)) {
@ -334,12 +334,12 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
values = GetStackTraceValueBuffer(priv);
elem = priv->stackElems;
for (fp = js_GetTopStackFrame(cx); fp != fpstop; fp = fp->down) {
if (!fp->fun) {
if (!fp->hasFunction()) {
elem->funName = NULL;
elem->argc = 0;
} else {
elem->funName = fp->fun->atom
? ATOM_TO_STRING(fp->fun->atom)
elem->funName = fp->getFunction()->atom
? ATOM_TO_STRING(fp->getFunction()->atom)
: cx->runtime->emptyString;
elem->argc = fp->argc;
memcpy(values, fp->argv, fp->argc * sizeof(jsval));
@ -347,8 +347,8 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
}
elem->ulineno = 0;
elem->filename = NULL;
if (fp->script) {
elem->filename = fp->script->filename;
if (fp->hasScript()) {
elem->filename = fp->getScript()->filename;
if (fp->pc(cx))
elem->ulineno = js_FramePCToLineNumber(cx, fp);
}
@ -749,7 +749,7 @@ Exception(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *rval)
} else {
fp = js_GetScriptedCaller(cx, NULL);
if (fp) {
filename = FilenameToString(cx, fp->script->filename);
filename = FilenameToString(cx, fp->getScript()->filename);
if (!filename)
return JS_FALSE;
} else {

View File

@ -202,8 +202,8 @@ js_GetArgsObject(JSContext *cx, JSStackFrame *fp)
* We must be in a function activation; the function must be lightweight
* or else fp must have a variable object.
*/
JS_ASSERT(fp->fun);
JS_ASSERT_IF(fp->fun->flags & JSFUN_HEAVYWEIGHT,
JS_ASSERT(fp->hasFunction());
JS_ASSERT_IF(fp->getFunction()->flags & JSFUN_HEAVYWEIGHT,
fp->varobj(cx->containingSegment(fp)));
/* Skip eval and debugger frames. */
@ -772,7 +772,7 @@ JSObject *
js_GetCallObject(JSContext *cx, JSStackFrame *fp)
{
/* Create a call object for fp only if it lacks one. */
JS_ASSERT(fp->fun);
JS_ASSERT(fp->hasFunction());
if (fp->hasCallObj())
return fp->getCallObj();
@ -791,7 +791,8 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp)
* expression Call's parent points to an environment object holding
* function's name.
*/
JSAtom *lambdaName = (fp->fun->flags & JSFUN_LAMBDA) ? fp->fun->atom : NULL;
JSAtom *lambdaName =
(fp->getFunction()->flags & JSFUN_LAMBDA) ? fp->getFunction()->atom : NULL;
if (lambdaName) {
JSObject *envobj = NewDeclEnvObject(cx, fp);
if (!envobj)
@ -809,13 +810,13 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp)
}
}
JSObject *callobj = NewCallObject(cx, fp->fun, fp->getScopeChain());
JSObject *callobj = NewCallObject(cx, fp->getFunction(), fp->getScopeChain());
if (!callobj)
return NULL;
callobj->setPrivate(fp);
JS_ASSERT(fp->argv);
JS_ASSERT(fp->fun == GET_FUNCTION_PRIVATE(cx, fp->callee()));
JS_ASSERT(fp->getFunction() == GET_FUNCTION_PRIVATE(cx, fp->callee()));
callobj->setSlot(JSSLOT_CALLEE, fp->calleeValue());
fp->setCallObj(callobj);
@ -873,7 +874,7 @@ js_PutCallObject(JSContext *cx, JSStackFrame *fp)
js_PutArgsObject(cx, fp);
}
JSFunction *fun = fp->fun;
JSFunction *fun = fp->getFunction();
JS_ASSERT(fun == js_GetCallObjectFunction(callobj));
uintN n = fun->countArgsAndVars();
@ -1265,11 +1266,13 @@ JS_PUBLIC_DATA(Class) js_CallClass = {
bool
JSStackFrame::getValidCalleeObject(JSContext *cx, Value *vp)
{
if (!fun) {
if (!hasFunction()) {
*vp = argv ? argv[-2] : UndefinedValue();
return true;
}
JSFunction *fun = getFunction();
/*
* See the equivalent condition in args_getProperty for ARGS_CALLEE, but
* note that here we do not want to throw, since this escape can happen via
@ -1292,11 +1295,11 @@ JSStackFrame::getValidCalleeObject(JSContext *cx, Value *vp)
* through the frame's |this| object's method read barrier for the method
* atom by which it was uniquely associated with a property.
*/
if (thisv.isObject()) {
if (getThisValue().isObject()) {
JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun);
if (fun == funobj && fun->methodAtom()) {
JSObject *thisp = &thisv.toObject();
JSObject *thisp = &getThisValue().toObject();
JS_ASSERT(thisp->canHaveMethodBarrier());
JSScope *scope = thisp->scope();
@ -1408,7 +1411,7 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
/* Find fun's top-most activation record. */
JSStackFrame *fp;
for (fp = js_GetTopStackFrame(cx);
fp && (fp->fun != fun || (fp->flags & JSFRAME_SPECIAL));
fp && (fp->maybeFunction() != fun || (fp->flags & JSFRAME_SPECIAL));
fp = fp->down) {
continue;
}
@ -1455,7 +1458,7 @@ fun_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
default:
/* XXX fun[0] and fun.arguments[0] are equivalent. */
if (fp && fp->fun && (uintN)slot < fp->fun->nargs)
if (fp && fp->hasFunction() && (uintN)slot < fp->getFunction()->nargs)
*vp = fp->argv[slot];
break;
}
@ -2210,7 +2213,8 @@ Function(JSContext *cx, JSObject *obj, uintN argc, Value *argv, Value *rval)
* Function indirectly from a script.
*/
fp = js_GetTopStackFrame(cx);
JS_ASSERT(!fp->script && fp->fun && fp->fun->u.n.native == Function);
JS_ASSERT(!fp->hasScript() && fp->hasFunction() &&
fp->getFunction()->u.n.native == Function);
caller = js_GetScriptedCaller(cx, fp);
if (caller) {
principals = JS_EvalFramePrincipals(cx, fp, caller);
@ -2544,8 +2548,8 @@ js_NewFlatClosure(JSContext *cx, JSFunction *fun)
JSObject *
js_NewDebuggableFlatClosure(JSContext *cx, JSFunction *fun)
{
JS_ASSERT(cx->fp->fun->flags & JSFUN_HEAVYWEIGHT);
JS_ASSERT(!cx->fp->fun->optimizedClosure());
JS_ASSERT(cx->fp->getFunction()->flags & JSFUN_HEAVYWEIGHT);
JS_ASSERT(!cx->fp->getFunction()->optimizedClosure());
JS_ASSERT(FUN_FLAT_CLOSURE(fun));
return WrapEscapingClosure(cx, cx->fp, fun);
@ -2665,7 +2669,7 @@ js_ReportIsNotFunction(JSContext *cx, const Value *vp, uintN flags)
++i;
if (!i.done()) {
uintN depth = js_ReconstructStackDepth(cx, i.fp()->script, i.pc());
uintN depth = js_ReconstructStackDepth(cx, i.fp()->getScript(), i.pc());
Value *simsp = i.fp()->base() + depth;
JS_ASSERT(simsp <= i.sp());
if (i.fp()->base() <= vp && vp < simsp)

View File

@ -2254,12 +2254,12 @@ js_TraceStackFrame(JSTracer *trc, JSStackFrame *fp)
JS_CALL_OBJECT_TRACER(trc, fp->getCallObj(), "call");
if (fp->hasArgsObj())
JS_CALL_OBJECT_TRACER(trc, fp->getArgsObj(), "arguments");
if (fp->script)
js_TraceScript(trc, fp->script);
if (fp->hasScript())
js_TraceScript(trc, fp->getScript());
/* Allow for primitive this parameter due to JSFUN_THISP_* flags. */
MarkValue(trc, fp->thisv, "this");
MarkValue(trc, fp->rval, "rval");
MarkValue(trc, fp->getThisValue(), "this");
MarkValue(trc, fp->getReturnValue(), "rval");
if (fp->hasScopeChain())
JS_CALL_OBJECT_TRACER(trc, fp->getScopeChain(), "scope chain");
}

View File

@ -110,8 +110,8 @@ js_GetScopeChain(JSContext *cx, JSStackFrame *fp)
* Don't force a call object for a lightweight function call, but do
* insist that there is a call object for a heavyweight function call.
*/
JS_ASSERT(!fp->fun ||
!(fp->fun->flags & JSFUN_HEAVYWEIGHT) ||
JS_ASSERT(!fp->hasFunction() ||
!(fp->getFunction()->flags & JSFUN_HEAVYWEIGHT) ||
fp->hasCallObj());
JS_ASSERT(fp->hasScopeChain());
return fp->getScopeChain();
@ -128,7 +128,7 @@ js_GetScopeChain(JSContext *cx, JSStackFrame *fp)
* Also, identify the innermost compiler-allocated block we needn't clone.
*/
JSObject *limitBlock, *limitClone;
if (fp->fun && !fp->hasCallObj()) {
if (fp->hasFunction() && !fp->hasCallObj()) {
JS_ASSERT_IF(fp->getScopeChain()->getClass() == &js_BlockClass,
fp->getScopeChain()->getPrivate() != js_FloatingFrameIfGenerator(cx, fp));
if (!js_GetCallObject(cx, fp))
@ -498,20 +498,24 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native,
SetValueRangeToUndefined(fp->slots(), nvars);
/* Initialize frame. */
fp->thisv = args.thisv();
fp->setThisValue(args.thisv());
fp->setCallObj(NULL);
fp->setArgsObj(NULL);
fp->script = script;
fp->fun = fun;
fp->setScript(script);
fp->setFunction(fun);
fp->argc = args.argc();
fp->argv = args.argv();
fp->rval = (flags & JSINVOKE_CONSTRUCT) ? fp->thisv : UndefinedValue();
fp->setAnnotation(NULL);
fp->setScopeChain(NULL);
fp->setBlockChain(NULL);
fp->flags = flags;
JS_ASSERT(!fp->hasIMacroPC());
if (flags & JSINVOKE_CONSTRUCT)
fp->setReturnValue(fp->getThisValue());
else
fp->clearReturnValue();
/* Initialize regs. */
JSFrameRegs &regs = frame.getRegs();
if (script) {
@ -557,8 +561,9 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native,
JSBool alreadyThrowing = cx->throwing;
#endif
JSObject *thisp = fp->thisv.toObjectOrNull();
ok = callJSNative(cx, native, thisp, fp->argc, fp->argv, &fp->rval);
JSObject *thisp = fp->getThisValue().toObjectOrNull();
ok = callJSNative(cx, native, thisp, fp->argc, fp->argv,
fp->addressReturnValue());
JS_ASSERT(cx->fp == fp);
JS_RUNTIME_METER(cx->runtime, nativeCalls);
@ -572,7 +577,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native,
ok = Interpret(cx);
}
DTrace::exitJSFun(cx, fp, fun, fp->rval);
DTrace::exitJSFun(cx, fp, fun, fp->getReturnValue());
if (hookData) {
hook = cx->debugHooks->callHook;
@ -581,7 +586,7 @@ InvokeCommon(JSContext *cx, JSFunction *fun, JSScript *script, T native,
}
fp->putActivationObjects(cx);
args.rval() = fp->rval;
args.rval() = fp->getReturnValue();
return ok;
}
@ -604,7 +609,7 @@ DoSlowCall(JSContext *cx, uintN argc, Value *vp)
JSObject *obj = fp->getThisObject(cx);
if (!obj)
return false;
JS_ASSERT(ObjectValue(*obj) == fp->thisv);
JS_ASSERT(ObjectValue(*obj) == fp->getThisValue());
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
Class *clasp = callee->getClass();
@ -796,11 +801,11 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
if (script->hasSharps) {
JS_ASSERT(script->nfixed >= SHARP_NSLOTS);
Value *sharps = &fp->slots()[script->nfixed - SHARP_NSLOTS];
if (down && down->script && down->script->hasSharps) {
JS_ASSERT(down->script->nfixed >= SHARP_NSLOTS);
int base = (down->fun && !(down->flags & JSFRAME_SPECIAL))
? down->fun->sharpSlotBase(cx)
: down->script->nfixed - SHARP_NSLOTS;
if (down && down->hasScript() && down->getScript()->hasSharps) {
JS_ASSERT(down->getFixedCount() >= SHARP_NSLOTS);
int base = (down->getFunction() && !(down->flags & JSFRAME_SPECIAL))
? down->getFunction()->sharpSlotBase(cx)
: down->getFixedCount() - SHARP_NSLOTS;
if (base < 0)
return false;
sharps[0] = down->slots()[base];
@ -818,8 +823,8 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
/* Propagate arg state for eval and the debugger API. */
fp->setCallObj(down->maybeCallObj());
fp->setArgsObj(NULL);
fp->fun = (script->staticLevel > 0) ? down->fun : NULL;
fp->thisv = down->thisv;
fp->setFunction((script->staticLevel > 0) ? down->maybeFunction() : NULL);
fp->setThisValue(down->getThisValue());
fp->flags = flags | (down->flags & JSFRAME_COMPUTED_THIS);
fp->argc = down->argc;
fp->argv = down->argv;
@ -839,8 +844,8 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
} else {
fp->setCallObj(NULL);
fp->setArgsObj(NULL);
fp->fun = NULL;
fp->thisv.setUndefined(); /* Make GC-safe until initialized below. */
fp->setFunction(NULL);
fp->setThisValue(UndefinedValue()); /* Make GC-safe until initialized below. */
fp->flags = flags | JSFRAME_COMPUTED_THIS;
fp->argc = 0;
fp->argv = NULL;
@ -859,8 +864,8 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
JS_ASSERT(!initialVarObj->getOps()->defineProperty);
JS_ASSERT(!fp->hasIMacroPC());
fp->script = script;
fp->rval.setUndefined();
fp->setScript(script);
fp->clearReturnValue();
fp->setBlockChain(NULL);
/* Initialize regs. */
@ -875,7 +880,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
JSObject *thisp = chain->thisObject(cx);
if (!thisp)
return false;
fp->thisv.setObject(*thisp);
fp->setThisValue(ObjectValue(*thisp));
}
void *hookData = NULL;
@ -885,7 +890,7 @@ Execute(JSContext *cx, JSObject *chain, JSScript *script,
AutoPreserveEnumerators preserve(cx);
JSBool ok = Interpret(cx);
if (result)
*result = fp->rval;
*result = fp->getReturnValue();
if (hookData) {
if (JSInterpreterHook hook = cx->debugHooks->executeHook)
@ -1347,16 +1352,16 @@ js::GetUpvar(JSContext *cx, uintN closureLevel, UpvarCookie cookie)
uintN slot = cookie.slot();
Value *vp;
if (!fp->fun || (fp->flags & JSFRAME_EVAL)) {
vp = fp->slots() + fp->script->nfixed;
} else if (slot < fp->fun->nargs) {
if (!fp->hasFunction() || (fp->flags & JSFRAME_EVAL)) {
vp = fp->slots() + fp->getFixedCount();
} else if (slot < fp->getArgumentCount()) {
vp = fp->argv;
} else if (slot == UpvarCookie::CALLEE_SLOT) {
vp = &fp->argv[-2];
slot = 0;
} else {
slot -= fp->fun->nargs;
JS_ASSERT(slot < fp->script->nslots);
slot -= fp->getArgumentCount();
JS_ASSERT(slot < fp->getSlotCount());
vp = fp->slots();
}
@ -1384,10 +1389,10 @@ js_TraceOpcode(JSContext *cx)
* Operations in prologues don't produce interesting values, and
* js_DecompileValueGenerator isn't set up to handle them anyway.
*/
if (cx->tracePrevPc && regs->pc >= fp->script->main) {
if (cx->tracePrevPc && regs->pc >= fp->getScript()->main) {
JSOp tracePrevOp = JSOp(*cx->tracePrevPc);
ndefs = js_GetStackDefs(cx, &js_CodeSpec[tracePrevOp], tracePrevOp,
fp->script, cx->tracePrevPc);
fp->getScript(), cx->tracePrevPc);
/*
* If there aren't that many elements on the stack, then we have
@ -1424,9 +1429,10 @@ js_TraceOpcode(JSContext *cx)
}
fprintf(tracefp, "%4u: ",
js_PCToLineNumber(cx, fp->script, fp->hasIMacroPC() ? fp->getIMacroPC() : regs->pc));
js_Disassemble1(cx, fp->script, regs->pc,
regs->pc - fp->script->code,
js_PCToLineNumber(cx, fp->getScript(),
fp->hasIMacroPC() ? fp->getIMacroPC() : regs->pc));
js_Disassemble1(cx, fp->getScript(), regs->pc,
regs->pc - fp->getScript()->code,
JS_FALSE, tracefp);
op = (JSOp) *regs->pc;
nuses = js_GetStackUses(&js_CodeSpec[op], op, regs->pc);
@ -1767,6 +1773,7 @@ namespace reprmeter {
#define PUSH_OBJECT_OR_NULL(obj) regs.sp++->setObject(obj)
#define PUSH_HOLE() regs.sp++->setMagic(JS_ARRAY_HOLE)
#define POP_COPY_TO(v) v = *--regs.sp
#define POP_RETURN_VALUE() fp->setReturnValue(*--regs.sp)
#define POP_BOOLEAN(cx, vp, b) \
JS_BEGIN_MACRO \
@ -2180,7 +2187,7 @@ Interpret(JSContext *cx)
/* Set registerized frame pointer and derived script pointer. */
JSStackFrame *fp = cx->fp;
JSScript *script = fp->script;
JSScript *script = fp->getScript();
JS_ASSERT(!script->isEmpty());
JS_ASSERT(script->length > 1);
@ -2241,7 +2248,7 @@ Interpret(JSContext *cx)
#define RESTORE_INTERP_VARS() \
JS_BEGIN_MACRO \
fp = cx->fp; \
script = fp->script; \
script = fp->getScript(); \
atoms = FrameAtomBase(cx, fp); \
currentVersion = (JSVersion) script->version; \
JS_ASSERT(cx->regs == &regs); \
@ -2442,7 +2449,7 @@ Interpret(JSContext *cx)
case JSTRAP_CONTINUE:
break;
case JSTRAP_RETURN:
fp->rval = rval;
fp->setReturnValue(rval);
interpReturnOK = JS_TRUE;
goto forced_return;
case JSTRAP_THROW:
@ -2548,7 +2555,7 @@ END_CASE(JSOP_POPN)
BEGIN_CASE(JSOP_SETRVAL)
BEGIN_CASE(JSOP_POPV)
ASSERT_NOT_THROWING(cx);
POP_COPY_TO(fp->rval);
POP_RETURN_VALUE();
END_CASE(JSOP_POPV)
BEGIN_CASE(JSOP_ENTERWITH)
@ -2574,10 +2581,10 @@ BEGIN_CASE(JSOP_LEAVEWITH)
END_CASE(JSOP_LEAVEWITH)
BEGIN_CASE(JSOP_RETURN)
POP_COPY_TO(fp->rval);
POP_RETURN_VALUE();
/* FALL THROUGH */
BEGIN_CASE(JSOP_RETRVAL) /* fp->rval already set */
BEGIN_CASE(JSOP_RETRVAL) /* fp return value already set */
BEGIN_CASE(JSOP_STOP)
{
/*
@ -2603,8 +2610,8 @@ BEGIN_CASE(JSOP_STOP)
}
JS_ASSERT(regs.sp == fp->base());
if ((fp->flags & JSFRAME_CONSTRUCTING) && fp->rval.isPrimitive())
fp->rval = fp->thisv;
if ((fp->flags & JSFRAME_CONSTRUCTING) && fp->getReturnValue().isPrimitive())
fp->setReturnValue(fp->getThisValue());
interpReturnOK = true;
if (inlineCallCount)
@ -2628,7 +2635,7 @@ BEGIN_CASE(JSOP_STOP)
*/
fp->putActivationObjects(cx);
DTrace::exitJSFun(cx, fp, fp->fun, fp->rval);
DTrace::exitJSFun(cx, fp, fp->getFunction(), fp->getReturnValue());
/* Restore context version only if callee hasn't set version. */
if (JS_LIKELY(cx->version == currentVersion)) {
@ -2642,13 +2649,13 @@ BEGIN_CASE(JSOP_STOP)
* passed in via |this|, and instrument this constructor invocation.
*/
if (fp->flags & JSFRAME_CONSTRUCTING) {
if (fp->rval.isPrimitive())
fp->rval = fp->thisv;
if (fp->getReturnValue().isPrimitive())
fp->setReturnValue(fp->getThisValue());
JS_RUNTIME_METER(cx->runtime, constructs);
}
JSStackFrame *down = fp->down;
bool recursive = fp->script == down->script;
bool recursive = fp->getScript() == down->getScript();
Value *newsp = fp->argv - 1;
/* Pop the frame. */
@ -2656,11 +2663,11 @@ BEGIN_CASE(JSOP_STOP)
/* Propagate return value before fp is lost. */
regs.sp = newsp;
regs.sp[-1] = fp->rval;
regs.sp[-1] = fp->getReturnValue();
/* Sync interpreter registers. */
fp = cx->fp;
script = fp->script;
script = fp->getScript();
atoms = FrameAtomBase(cx, fp);
/* Resume execution in the calling frame. */
@ -2910,7 +2917,7 @@ BEGIN_CASE(JSOP_FORARG)
{
JS_ASSERT(regs.sp - 1 >= fp->base());
uintN slot = GET_ARGNO(regs.pc);
JS_ASSERT(slot < fp->fun->nargs);
JS_ASSERT(slot < fp->getArgumentCount());
JS_ASSERT(regs.sp[-1].isObject());
if (!IteratorNext(cx, &regs.sp[-1].toObject(), &fp->argv[slot]))
goto error;
@ -2921,7 +2928,7 @@ BEGIN_CASE(JSOP_FORLOCAL)
{
JS_ASSERT(regs.sp - 1 >= fp->base());
uintN slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < fp->script->nslots);
JS_ASSERT(slot < fp->getSlotCount());
JS_ASSERT(regs.sp[-1].isObject());
if (!IteratorNext(cx, &regs.sp[-1].toObject(), &fp->slots()[slot]))
goto error;
@ -3815,7 +3822,7 @@ BEGIN_CASE(JSOP_ARGINC)
// If we initialize in the declaration, MSVC complains that the labels skip init.
uint32 slot;
slot = GET_ARGNO(regs.pc);
JS_ASSERT(slot < fp->fun->nargs);
JS_ASSERT(slot < fp->getArgumentCount());
METER_SLOT_OP(op, slot);
vp = fp->argv + slot;
goto do_int_fast_incop;
@ -3836,7 +3843,7 @@ BEGIN_CASE(JSOP_LOCALINC)
*/
do_local_incop:
slot = GET_SLOTNO(regs.pc);
JS_ASSERT(slot < fp->script->nslots);
JS_ASSERT(slot < fp->getSlotCount());
vp = fp->slots() + slot;
METER_SLOT_OP(op, slot);
vp = fp->slots() + slot;
@ -3917,7 +3924,7 @@ BEGIN_CASE(JSOP_GVARINC)
BEGIN_CASE(JSOP_THIS)
if (!fp->getThisObject(cx))
goto error;
PUSH_COPY(fp->thisv);
PUSH_COPY(fp->getThisValue());
END_CASE(JSOP_THIS)
BEGIN_CASE(JSOP_UNBRANDTHIS)
@ -3947,7 +3954,7 @@ BEGIN_CASE(JSOP_GETARGPROP)
{
i = ARGNO_LEN;
uint32 slot = GET_ARGNO(regs.pc);
JS_ASSERT(slot < fp->fun->nargs);
JS_ASSERT(slot < fp->getArgumentCount());
PUSH_COPY(fp->argv[slot]);
goto do_getprop_body;
}
@ -4611,17 +4618,17 @@ BEGIN_CASE(JSOP_APPLY)
/* Initialize stack frame. */
newfp->setCallObj(NULL);
newfp->setArgsObj(NULL);
newfp->script = newscript;
newfp->fun = fun;
newfp->setScript(newscript);
newfp->setFunction(fun);
newfp->argc = argc;
newfp->argv = vp + 2;
newfp->rval.setUndefined();
newfp->clearReturnValue();
newfp->setAnnotation(NULL);
newfp->setScopeChain(obj->getParent());
newfp->flags = flags;
newfp->setBlockChain(NULL);
JS_ASSERT(!JSFUN_BOUND_METHOD_TEST(fun->flags));
newfp->thisv = vp[1];
newfp->setThisValue(vp[1]);
JS_ASSERT(!newfp->hasIMacroPC());
/* Push void to initialize local variables. */
@ -4679,7 +4686,7 @@ BEGIN_CASE(JSOP_APPLY)
if (status == ARECORD_ERROR)
goto error;
}
} else if (fp->script == fp->down->script &&
} else if (fp->getScript() == fp->down->getScript() &&
*fp->down->savedPC == JSOP_CALL &&
*regs.pc == JSOP_TRACE) {
MONITOR_BRANCH(Record_EnterFrame);
@ -5062,7 +5069,7 @@ BEGIN_CASE(JSOP_TRAP)
case JSTRAP_ERROR:
goto error;
case JSTRAP_RETURN:
fp->rval = rval;
fp->setReturnValue(rval);
interpReturnOK = JS_TRUE;
goto forced_return;
case JSTRAP_THROW:
@ -5113,7 +5120,7 @@ BEGIN_CASE(JSOP_GETARG)
BEGIN_CASE(JSOP_CALLARG)
{
uint32 slot = GET_ARGNO(regs.pc);
JS_ASSERT(slot < fp->fun->nargs);
JS_ASSERT(slot < fp->getArgumentCount());
METER_SLOT_OP(op, slot);
PUSH_COPY(fp->argv[slot]);
if (op == JSOP_CALLARG)
@ -5124,7 +5131,7 @@ END_CASE(JSOP_GETARG)
BEGIN_CASE(JSOP_SETARG)
{
uint32 slot = GET_ARGNO(regs.pc);
JS_ASSERT(slot < fp->fun->nargs);
JS_ASSERT(slot < fp->getArgumentCount());
METER_SLOT_OP(op, slot);
fp->argv[slot] = regs.sp[-1];
}
@ -5174,7 +5181,7 @@ END_CASE(JSOP_GETUPVAR)
BEGIN_CASE(JSOP_GETUPVAR_DBG)
BEGIN_CASE(JSOP_CALLUPVAR_DBG)
{
JSFunction *fun = fp->fun;
JSFunction *fun = fp->getFunction();
JS_ASSERT(FUN_KIND(fun) == JSFUN_INTERPRETED);
JS_ASSERT(fun->u.i.wrapper);
@ -5351,7 +5358,7 @@ BEGIN_CASE(JSOP_DEFVAR)
* and has stub getter and setter, into a "fast global" accessed
* by the JSOP_*GVAR opcodes.
*/
if (!fp->fun &&
if (!fp->hasFunction() &&
index < GlobalVarCount(fp) &&
obj2 == obj &&
obj->isNative()) {
@ -6090,7 +6097,7 @@ END_CASE(JSOP_INITELEM)
BEGIN_CASE(JSOP_DEFSHARP)
{
uint32 slot = GET_UINT16(regs.pc);
JS_ASSERT(slot + 1 < fp->script->nfixed);
JS_ASSERT(slot + 1 < fp->getFixedCount());
const Value &lref = fp->slots()[slot];
JSObject *obj;
if (lref.isObject()) {
@ -6120,7 +6127,7 @@ END_CASE(JSOP_DEFSHARP)
BEGIN_CASE(JSOP_USESHARP)
{
uint32 slot = GET_UINT16(regs.pc);
JS_ASSERT(slot + 1 < fp->script->nfixed);
JS_ASSERT(slot + 1 < fp->getFixedCount());
const Value &lref = fp->slots()[slot];
jsint i = (jsint) GET_UINT16(regs.pc + UINT16_LEN);
Value rval;
@ -6147,7 +6154,7 @@ END_CASE(JSOP_USESHARP)
BEGIN_CASE(JSOP_SHARPINIT)
{
uint32 slot = GET_UINT16(regs.pc);
JS_ASSERT(slot + 1 < fp->script->nfixed);
JS_ASSERT(slot + 1 < fp->getFixedCount());
Value *vp = &fp->slots()[slot];
Value rval = vp[1];
@ -6309,7 +6316,7 @@ BEGIN_CASE(JSOP_DEBUGGER)
case JSTRAP_CONTINUE:
break;
case JSTRAP_RETURN:
fp->rval = rval;
fp->setReturnValue(rval);
interpReturnOK = JS_TRUE;
goto forced_return;
case JSTRAP_THROW:
@ -6699,7 +6706,7 @@ BEGIN_CASE(JSOP_GENERATOR)
if (!obj)
goto error;
JS_ASSERT(!fp->hasCallObj() && !fp->hasArgsObj());
fp->rval.setObject(*obj);
fp->setReturnValue(ObjectValue(*obj));
interpReturnOK = true;
if (inlineCallCount != 0)
goto inline_return;
@ -6713,7 +6720,7 @@ BEGIN_CASE(JSOP_YIELD)
JSDVG_SEARCH_STACK, fp->argv[-2], NULL);
goto error;
}
fp->rval = regs.sp[-1];
fp->setReturnValue(regs.sp[-1]);
fp->flags |= JSFRAME_YIELDING;
regs.pc += JSOP_YIELD_LENGTH;
interpReturnOK = JS_TRUE;
@ -6845,7 +6852,7 @@ END_CASE(JSOP_ARRAYPUSH)
goto error;
case JSTRAP_RETURN:
cx->throwing = JS_FALSE;
fp->rval = rval;
fp->setReturnValue(rval);
interpReturnOK = JS_TRUE;
goto forced_return;
case JSTRAP_THROW:
@ -6910,7 +6917,7 @@ END_CASE(JSOP_ARRAYPUSH)
switch (tn->kind) {
case JSTRY_CATCH:
JS_ASSERT(js_GetOpcode(cx, fp->script, regs.pc) == JSOP_ENTERBLOCK);
JS_ASSERT(js_GetOpcode(cx, fp->getScript(), regs.pc) == JSOP_ENTERBLOCK);
#if JS_HAS_GENERATORS
/* Catch cannot intercept the closing of a generator. */
@ -6939,7 +6946,7 @@ END_CASE(JSOP_ARRAYPUSH)
case JSTRY_ITER: {
/* This is similar to JSOP_ENDITER in the interpreter loop. */
JS_ASSERT(js_GetOpcode(cx, fp->script, regs.pc) == JSOP_ENDITER);
JS_ASSERT(js_GetOpcode(cx, fp->getScript(), regs.pc) == JSOP_ENDITER);
AutoValueRooter tvr(cx, cx->exception);
cx->throwing = false;
ok = js_CloseIterator(cx, &regs.sp[-1].toObject());
@ -6963,7 +6970,7 @@ END_CASE(JSOP_ARRAYPUSH)
cx->exception.isMagic(JS_GENERATOR_CLOSING))) {
cx->throwing = JS_FALSE;
interpReturnOK = JS_TRUE;
fp->rval.setUndefined();
fp->clearReturnValue();
}
#endif
}

View File

@ -89,19 +89,19 @@ struct JSStackFrame
JSObject *argsobj; /* lazily created arguments object */
JSObject *scopeChain; /* current scope chain */
JSObject *blockChain; /* current static block */
jsbytecode *imacpc; /* null or interpreter macro call pc */
void *annotation; /* used by Java security */
void *hookData; /* debugger call hook data */
JSVersion callerVersion; /* dynamic version of calling script */
jsbytecode *imacpc; /* null or interpreter macro call pc */
public:
JSScript *script; /* script being interpreted */
JSFunction *fun; /* function being called or null */
uintN argc; /* actual argument count */
js::Value *argv; /* base of argument stack slots */
js::Value thisv; /* "this" pointer if in method */
js::Value rval; /* function return value */
public:
uintN argc; /* actual argument count */
js::Value *argv; /* base of argument stack slots */
/* Maintained by StackSpace operations */
JSStackFrame *down; /* previous frame, part of
stack layout invariant */
@ -110,9 +110,9 @@ struct JSStackFrame
static jsbytecode *const sInvalidPC;
#endif
uint32 flags; /* frame flags -- see below */
uint32 flags; /* frame flags -- see below */
void *padding;
void *padding;
/* Get the frame's current bytecode, assuming |this| is in |cx|. */
jsbytecode *pc(JSContext *cx) const;
@ -126,7 +126,7 @@ struct JSStackFrame
}
js::Value *base() const {
return slots() + script->nfixed;
return slots() + getScript()->nfixed;
}
/* Call object accessors */
@ -262,6 +262,33 @@ struct JSStackFrame
blockChain = obj;
}
/* IMacroPC accessors. */
bool hasIMacroPC() const { return flags & JSFRAME_IN_IMACRO; }
/*
* @pre hasIMacroPC
* @return The PC at which an imacro started executing (guaranteed non-null. The PC of the
* executing imacro must be in regs.pc, so the displaced
* original value is stored here.
*/
jsbytecode *getIMacroPC() const {
JS_ASSERT(flags & JSFRAME_IN_IMACRO);
return imacpc;
}
/* @return The imacro pc if hasIMacroPC; otherwise, NULL. */
jsbytecode *maybeIMacroPC() const { return hasIMacroPC() ? getIMacroPC() : NULL; }
void clearIMacroPC() { flags &= ~JSFRAME_IN_IMACRO; }
void setIMacroPC(jsbytecode *newIMacPC) {
JS_ASSERT(newIMacPC);
JS_ASSERT(!(flags & JSFRAME_IN_IMACRO));
imacpc = newIMacPC;
flags |= JSFRAME_IN_IMACRO;
}
/* Annotation accessors */
bool hasAnnotation() const {
@ -310,31 +337,90 @@ struct JSStackFrame
callerVersion = version;
}
/* IMacroPC accessors. */
/* Script accessors */
bool hasIMacroPC() const { return flags & JSFRAME_IN_IMACRO; }
/*
* @pre hasIMacroPC
* @return The PC at which an imacro started executing (guaranteed non-null. The PC of the
* executing imacro must be in regs.pc, so the displaced
* original value is stored here.
*/
jsbytecode *getIMacroPC() const {
JS_ASSERT(flags & JSFRAME_IN_IMACRO);
return imacpc;
bool hasScript() const {
return script != NULL;
}
/* @return The imacro pc if hasIMacroPC; otherwise, NULL. */
jsbytecode *maybeIMacroPC() const { return hasIMacroPC() ? getIMacroPC() : NULL; }
JSScript* getScript() const {
JS_ASSERT(hasScript());
return script;
}
void clearIMacroPC() { flags &= ~JSFRAME_IN_IMACRO; }
JSScript* maybeScript() const {
return script;
}
void setIMacroPC(jsbytecode *newIMacPC) {
JS_ASSERT(newIMacPC);
JS_ASSERT(!(flags & JSFRAME_IN_IMACRO));
imacpc = newIMacPC;
flags |= JSFRAME_IN_IMACRO;
size_t getFixedCount() const {
return getScript()->nfixed;
}
size_t getSlotCount() const {
return getScript()->nslots;
}
void setScript(JSScript *s) {
script = s;
}
static size_t offsetScript() {
return offsetof(JSStackFrame, script);
}
/* Function accessors */
bool hasFunction() const {
return fun != NULL;
}
JSFunction* getFunction() const {
JS_ASSERT(hasFunction());
return fun;
}
JSFunction* maybeFunction() const {
return fun;
}
size_t getArgumentCount() const {
return getFunction()->nargs;
}
void setFunction(JSFunction *f) {
fun = f;
}
/* This-value accessors */
const js::Value& getThisValue() {
return thisv;
}
void setThisValue(const js::Value &v) {
thisv = v;
}
/* Return-value accessors */
const js::Value& getReturnValue() {
return rval;
}
void setReturnValue(const js::Value &v) {
rval = v;
}
void clearReturnValue() {
rval.setUndefined();
}
js::Value* addressReturnValue() {
return &rval;
}
static size_t offsetReturnValue() {
return offsetof(JSStackFrame, rval);
}
/* Other accessors */
@ -399,6 +485,9 @@ struct JSStackFrame
}
bool isDummyFrame() const { return !!(flags & JSFRAME_DUMMY); }
/* Contains static assertions for member alignment, don't call. */
inline void staticAsserts();
};
namespace js {
@ -406,16 +495,20 @@ namespace js {
JS_STATIC_ASSERT(sizeof(JSStackFrame) % sizeof(Value) == 0);
static const size_t VALUES_PER_STACK_FRAME = sizeof(JSStackFrame) / sizeof(Value);
JS_STATIC_ASSERT(offsetof(JSStackFrame, rval) % sizeof(Value) == 0);
JS_STATIC_ASSERT(offsetof(JSStackFrame, thisv) % sizeof(Value) == 0);
} /* namespace js */
inline void
JSStackFrame::staticAsserts()
{
JS_STATIC_ASSERT(offsetof(JSStackFrame, rval) % sizeof(js::Value) == 0);
JS_STATIC_ASSERT(offsetof(JSStackFrame, thisv) % sizeof(js::Value) == 0);
}
static JS_INLINE uintN
GlobalVarCount(JSStackFrame *fp)
{
JS_ASSERT(!fp->fun);
return fp->script->nfixed;
JS_ASSERT(!fp->hasFunction());
return fp->getScript()->nfixed;
}
/*
@ -691,7 +784,7 @@ JSStackFrame::getThisObject(JSContext *cx)
return &thisv.toObject();
if (!js::ComputeThisFromArgv(cx, argv))
return NULL;
thisv = argv[-1];
setThisValue(argv[-1]);
flags |= JSFRAME_COMPUTED_THIS;
return &thisv.toObject();
}

View File

@ -1096,7 +1096,7 @@ js_NewGenerator(JSContext *cx)
/* Load and compute stack slot counts. */
JSStackFrame *fp = cx->fp;
uintN argc = fp->argc;
uintN nargs = JS_MAX(argc, fp->fun->nargs);
uintN nargs = JS_MAX(argc, fp->getArgumentCount());
uintN vplen = 2 + nargs;
/* Compute JSGenerator size. */
@ -1104,7 +1104,7 @@ js_NewGenerator(JSContext *cx)
(-1 + /* one Value included in JSGenerator */
vplen +
VALUES_PER_STACK_FRAME +
fp->script->nslots) * sizeof(Value);
fp->getSlotCount()) * sizeof(Value);
JSGenerator *gen = (JSGenerator *) cx->malloc(nbytes);
if (!gen)
@ -1119,8 +1119,8 @@ js_NewGenerator(JSContext *cx)
gen->obj = obj;
gen->state = JSGEN_NEWBORN;
gen->savedRegs.pc = cx->regs->pc;
JS_ASSERT(cx->regs->sp == fp->slots() + fp->script->nfixed);
gen->savedRegs.sp = slots + fp->script->nfixed;
JS_ASSERT(cx->regs->sp == fp->slots() + fp->getFixedCount());
gen->savedRegs.sp = slots + fp->getFixedCount();
gen->vplen = vplen;
gen->enumerators = NULL;
gen->liveFrame = newfp;
@ -1136,12 +1136,12 @@ js_NewGenerator(JSContext *cx)
fp->getArgsObj()->setPrivate(newfp);
fp->setArgsObj(NULL);
}
newfp->script = fp->script;
newfp->fun = fp->fun;
newfp->thisv = fp->thisv;
newfp->setScript(fp->getScript());
newfp->setFunction(fp->getFunction());
newfp->setThisValue(fp->getThisValue());
newfp->argc = fp->argc;
newfp->argv = vp + 2;
newfp->rval = fp->rval;
newfp->setReturnValue(fp->getReturnValue());
newfp->setAnnotation(NULL);
newfp->setScopeChain(fp->maybeScopeChain());
JS_ASSERT(!fp->hasBlockChain());
@ -1151,7 +1151,7 @@ js_NewGenerator(JSContext *cx)
/* Copy in arguments and slots. */
memcpy(vp, fp->argv - 2, vplen * sizeof(Value));
memcpy(slots, fp->slots(), fp->script->nfixed * sizeof(Value));
memcpy(slots, fp->slots(), fp->getFixedCount() * sizeof(Value));
obj->setPrivate(gen);
return obj;
@ -1184,7 +1184,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
if (gen->state == JSGEN_RUNNING || gen->state == JSGEN_CLOSING) {
js_ReportValueError(cx, JSMSG_NESTING_GENERATOR,
JSDVG_SEARCH_STACK, ObjectOrNullValue(obj),
JS_GetFunctionId(gen->getFloatingFrame()->fun));
JS_GetFunctionId(gen->getFloatingFrame()->getFunction()));
return JS_FALSE;
}
@ -1223,7 +1223,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
{
Value *genVp = gen->floatingStack;
uintN vplen = gen->vplen;
uintN nfixed = genfp->script->nslots;
uintN nfixed = genfp->getSlotCount();
/*
* Get a pointer to new frame/slots. This memory is not "claimed", so
@ -1247,7 +1247,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
fp->flags &= ~JSFRAME_FLOATING_GENERATOR;
fp->argv = vp + 2;
gen->savedRegs.sp = fp->slots() + (gen->savedRegs.sp - genfp->slots());
JS_ASSERT(uintN(gen->savedRegs.sp - fp->slots()) <= fp->script->nslots);
JS_ASSERT(uintN(gen->savedRegs.sp - fp->slots()) <= fp->getSlotCount());
#ifdef DEBUG
JSObject *callobjBefore = fp->maybeCallObj();
@ -1292,13 +1292,13 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
JS_ASSERT_IF(callobjBefore, callobjBefore == fp->maybeCallObj());
/* Copy and rebase stack frame/args/slots. Restore "floating" flag. */
JS_ASSERT(uintN(gen->savedRegs.sp - fp->slots()) <= fp->script->nslots);
JS_ASSERT(uintN(gen->savedRegs.sp - fp->slots()) <= fp->getSlotCount());
uintN usedAfter = gen->savedRegs.sp - vp;
memcpy(genVp, vp, usedAfter * sizeof(Value));
genfp->flags |= JSFRAME_FLOATING_GENERATOR;
genfp->argv = genVp + 2;
gen->savedRegs.sp = genfp->slots() + (gen->savedRegs.sp - fp->slots());
JS_ASSERT(uintN(gen->savedRegs.sp - genfp->slots()) <= genfp->script->nslots);
JS_ASSERT(uintN(gen->savedRegs.sp - genfp->slots()) <= genfp->getSlotCount());
}
if (gen->getFloatingFrame()->flags & JSFRAME_YIELDING) {
@ -1312,7 +1312,7 @@ SendToGenerator(JSContext *cx, JSGeneratorOp op, JSObject *obj,
return JS_TRUE;
}
genfp->rval.setUndefined();
genfp->clearReturnValue();
gen->state = JSGEN_CLOSED;
if (ok) {
/* Returned, explicitly or by falling off the end. */
@ -1401,7 +1401,7 @@ generator_op(JSContext *cx, JSGeneratorOp op, Value *vp, uintN argc)
bool undef = ((op == JSGENOP_SEND || op == JSGENOP_THROW) && argc != 0);
if (!SendToGenerator(cx, op, obj, gen, undef ? vp[2] : UndefinedValue()))
return JS_FALSE;
*vp = gen->getFloatingFrame()->rval;
*vp = gen->getFloatingFrame()->getReturnValue();
return JS_TRUE;
}

View File

@ -951,7 +951,7 @@ js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
#endif
JS_ASSERT(principals || !(callbacks && callbacks->findObjectPrincipals));
flags = JS_GetScriptFilenameFlags(caller->script);
flags = JS_GetScriptFilenameFlags(caller->getScript());
if ((flags & JSFILENAME_PROTECTED) &&
principals &&
strcmp(principals->codebase, "[System Principal]")) {
@ -960,13 +960,13 @@ js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
}
jsbytecode *pc = caller->pc(cx);
if (pc && js_GetOpcode(cx, caller->script, pc) == JSOP_EVAL) {
JS_ASSERT(js_GetOpcode(cx, caller->script, pc + JSOP_EVAL_LENGTH) == JSOP_LINENO);
if (pc && js_GetOpcode(cx, caller->getScript(), pc) == JSOP_EVAL) {
JS_ASSERT(js_GetOpcode(cx, caller->getScript(), pc + JSOP_EVAL_LENGTH) == JSOP_LINENO);
*linenop = GET_UINT16(pc + JSOP_EVAL_LENGTH);
} else {
*linenop = js_FramePCToLineNumber(cx, caller);
}
return caller->script->filename;
return caller->getScript()->filename;
}
#ifndef EVAL_CACHE_CHAIN_LIMIT
@ -1053,18 +1053,18 @@ obj_eval(JSContext *cx, uintN argc, Value *vp)
* when evaluating the code string. Warn when such uses are seen so that
* authors will know that support for eval(s, o) has been removed.
*/
if (argc > 1 && !caller->script->warnedAboutTwoArgumentEval) {
if (argc > 1 && !caller->getScript()->warnedAboutTwoArgumentEval) {
static const char TWO_ARGUMENT_WARNING[] =
"Support for eval(code, scopeObject) has been removed. "
"Use |with (scopeObject) eval(code);| instead.";
if (!JS_ReportWarning(cx, TWO_ARGUMENT_WARNING))
return JS_FALSE;
caller->script->warnedAboutTwoArgumentEval = true;
caller->getScript()->warnedAboutTwoArgumentEval = true;
}
/* From here on, control must exit through label out with ok set. */
MUST_FLOW_THROUGH("out");
uintN staticLevel = caller->script->staticLevel + 1;
uintN staticLevel = caller->getScript()->staticLevel + 1;
/*
* Bring fp->scopeChain up to date. We're either going to use
@ -1141,7 +1141,7 @@ obj_eval(JSContext *cx, uintN argc, Value *vp)
* calls to eval from global code are not cached.
*/
JSScript **bucket = EvalCacheHash(cx, str);
if (!indirectCall && caller->fun) {
if (!indirectCall && caller->hasFunction()) {
uintN count = 0;
JSScript **scriptp = bucket;
@ -1159,7 +1159,7 @@ obj_eval(JSContext *cx, uintN argc, Value *vp)
*/
JSFunction *fun = script->getFunction(0);
if (fun == caller->fun) {
if (fun == caller->getFunction()) {
/*
* Get the source string passed for safekeeping in the
* atom map by the prior eval to Compiler::compileScript.
@ -2694,7 +2694,7 @@ Detecting(JSContext *cx, jsbytecode *pc)
JSOp op;
JSAtom *atom;
script = cx->fp->script;
script = cx->fp->getScript();
endpc = script->code + script->length;
for (;; pc += js_CodeSpec[op].length) {
JS_ASSERT_IF(!cx->fp->hasIMacroPC(), script->code <= pc && pc < endpc);
@ -2767,7 +2767,7 @@ js_InferFlags(JSContext *cx, uintN defaultFlags)
JSStackFrame *const fp = js_GetTopStackFrame(cx);
if (!fp || !(pc = cx->regs->pc))
return defaultFlags;
cs = &js_CodeSpec[js_GetOpcode(cx, fp->script, pc)];
cs = &js_CodeSpec[js_GetOpcode(cx, fp->getScript(), pc)];
format = cs->format;
if (JOF_MODE(format) != JOF_NAME)
flags |= JSRESOLVE_QUALIFIED;
@ -2776,7 +2776,7 @@ js_InferFlags(JSContext *cx, uintN defaultFlags)
flags |= JSRESOLVE_ASSIGNING;
} else if (cs->length >= 0) {
pc += cs->length;
if (pc < cx->fp->script->code + cx->fp->script->length && Detecting(cx, pc))
if (pc < cx->fp->getScript()->code + cx->fp->getScript()->length && Detecting(cx, pc))
flags |= JSRESOLVE_DETECTING;
}
if (format & JOF_DECLARING)
@ -2978,7 +2978,7 @@ js_PutBlockObject(JSContext *cx, JSBool normalUnwind)
/* See comments in CheckDestructuring from jsparse.cpp. */
JS_ASSERT(count >= 1);
depth += fp->script->nfixed;
depth += fp->getFixedCount();
obj->fslots[JSSLOT_BLOCK_DEPTH + 1] = fp->slots()[depth];
if (normalUnwind && count > 1) {
--count;
@ -3007,8 +3007,8 @@ block_getProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
JSStackFrame *fp = (JSStackFrame *) obj->getPrivate();
if (fp) {
fp = js_LiveFrameIfGenerator(fp);
index += fp->script->nfixed + OBJ_BLOCK_DEPTH(cx, obj);
JS_ASSERT(index < fp->script->nslots);
index += fp->getFixedCount() + OBJ_BLOCK_DEPTH(cx, obj);
JS_ASSERT(index < fp->getSlotCount());
*vp = fp->slots()[index];
return true;
}
@ -3033,8 +3033,8 @@ block_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
JSStackFrame *fp = (JSStackFrame *) obj->getPrivate();
if (fp) {
fp = js_LiveFrameIfGenerator(fp);
index += fp->script->nfixed + OBJ_BLOCK_DEPTH(cx, obj);
JS_ASSERT(index < fp->script->nslots);
index += fp->getFixedCount() + OBJ_BLOCK_DEPTH(cx, obj);
JS_ASSERT(index < fp->getSlotCount());
fp->slots()[index] = *vp;
return true;
}
@ -4776,7 +4776,7 @@ js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN getHow,
op = (JSOp) *pc;
if (op == JSOP_TRAP) {
JS_ASSERT_NOT_ON_TRACE(cx);
op = JS_GetTrapOpcode(cx, cx->fp->script, pc);
op = JS_GetTrapOpcode(cx, cx->fp->getScript(), pc);
}
if (op == JSOP_GETXPROP) {
flags = JSREPORT_ERROR;
@ -4868,7 +4868,7 @@ js_CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname)
return true;
/* If neither cx nor the code is strict, then no check is needed. */
if (!(fp->script && fp->script->strictModeCode) &&
if (!(fp->hasScript() && fp->getScript()->strictModeCode) &&
!JS_HAS_STRICT_OPTION(cx)) {
return true;
}
@ -5265,8 +5265,8 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval)
if (fun != funobj) {
for (JSStackFrame *fp = cx->fp; fp; fp = fp->down) {
if (fp->callee() == fun &&
fp->thisv.isObject() &&
&fp->thisv.toObject() == obj) {
fp->getThisValue().isObject() &&
&fp->getThisValue().toObject() == obj) {
fp->setCalleeObject(*funobj);
}
}
@ -6370,11 +6370,13 @@ js_DumpStackFrame(JSContext *cx, JSStackFrame *start)
}
fputc('\n', stderr);
if (fp->script)
fprintf(stderr, "file %s line %u\n", fp->script->filename, (unsigned) fp->script->lineno);
if (fp->hasScript()) {
fprintf(stderr, "file %s line %u\n",
fp->getScript()->filename, (unsigned) fp->getScript()->lineno);
}
if (jsbytecode *pc = i.pc()) {
if (!fp->script) {
if (!fp->hasScript()) {
fprintf(stderr, "*** pc && !script, skipping frame\n\n");
continue;
}
@ -6400,9 +6402,9 @@ js_DumpStackFrame(JSContext *cx, JSStackFrame *start)
fprintf(stderr, " argv: %p (argc: %u)\n", (void *) fp->argv, (unsigned) fp->argc);
MaybeDumpObject("callobj", fp->maybeCallObj());
MaybeDumpObject("argsobj", fp->maybeArgsObj());
MaybeDumpValue("this", fp->thisv);
MaybeDumpValue("this", fp->getThisValue());
fprintf(stderr, " rval: ");
dumpValue(fp->rval);
dumpValue(fp->getReturnValue());
fputc('\n', stderr);
fprintf(stderr, " flags:");

View File

@ -279,7 +279,7 @@ js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp)
JS_FRIEND_API(JSBool)
js_DumpPC(JSContext *cx)
{
return js_DisassembleAtPC(cx, cx->fp->script, true, stdout, cx->regs->pc);
return js_DisassembleAtPC(cx, cx->fp->getScript(), true, stdout, cx->regs->pc);
}
JSBool
@ -2873,8 +2873,8 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
if (fp) {
while (!(fp->flags & JSFRAME_EVAL))
fp = fp->down;
JS_ASSERT(fp->script == jp->script);
JS_ASSERT(fp->down->fun == jp->fun);
JS_ASSERT(fp->getScript() == jp->script);
JS_ASSERT(fp->down->getFunction() == jp->fun);
JS_ASSERT(FUN_INTERPRETED(jp->fun));
JS_ASSERT(jp->script != jp->fun->u.i.script);
JS_ASSERT(jp->script->upvarsOffset != 0);
@ -5082,14 +5082,14 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v_in,
/* Get scripted caller */
FrameRegsIter i(cx);
while (!i.done() && !i.fp()->script)
while (!i.done() && !i.fp()->hasScript())
++i;
if (i.done() || !i.pc() || i.fp()->script->nslots == 0)
if (i.done() || !i.pc() || i.fp()->getSlotCount() == 0)
goto do_fallback;
fp = i.fp();
script = fp->script;
script = fp->getScript();
pc = fp->hasIMacroPC() ? fp->getIMacroPC() : i.pc();
JS_ASSERT(pc >= script->main && pc < script->code + script->length);
@ -5170,7 +5170,7 @@ js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v_in,
if (savedIMacroPC && size_t(pc - script->code) >= script->length)
name = FAILED_EXPRESSION_DECOMPILER;
else
name = DecompileExpression(cx, script, fp->fun, pc);
name = DecompileExpression(cx, script, fp->maybeFunction(), pc);
if (savedIMacroPC) {
if (fp == cx->fp)

View File

@ -771,8 +771,8 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *calle
/* If this is a direct call to eval, inherit the caller's strictness. */
if (callerFrame &&
callerFrame->script &&
callerFrame->script->strictModeCode) {
callerFrame->hasScript() &&
callerFrame->getScript()->strictModeCode) {
cg.flags |= TCF_STRICT_MODE_CODE;
tokenStream.setStrictMode();
}
@ -795,13 +795,13 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *calle
goto out;
}
if (callerFrame && callerFrame->fun) {
if (callerFrame && callerFrame->hasFunction()) {
/*
* An eval script in a caller frame needs to have its enclosing
* function captured in case it refers to an upvar, and someone
* wishes to decompile it while it's running.
*/
funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun));
funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->getFunction()));
if (!funbox)
goto out;
funbox->emitLink = cg.objectList.lastbox;

View File

@ -939,7 +939,7 @@ struct Parser : private js::AutoGCRooter
{
js::PodArrayZero(tempFreeList);
setPrincipals(prin);
JS_ASSERT_IF(cfp, cfp->script);
JS_ASSERT_IF(cfp, cfp->hasScript());
}
~Parser();

View File

@ -128,7 +128,7 @@ PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, uintN protoI
* opcode format flags.
*/
pc = cx->regs->pc;
op = js_GetOpcode(cx, cx->fp->script, pc);
op = js_GetOpcode(cx, cx->fp->getScript(), pc);
cs = &js_CodeSpec[op];
kshape = 0;
@ -317,7 +317,7 @@ GetAtomFromBytecode(JSContext *cx, jsbytecode *pc, JSOp op, const JSCodeSpec &cs
ptrdiff_t pcoff = (JOF_TYPE(cs.format) == JOF_SLOTATOM) ? SLOTNO_LEN : 0;
JSAtom *atom;
GET_ATOM_FROM_BYTECODE(cx->fp->script, pc, pcoff, atom);
GET_ATOM_FROM_BYTECODE(cx->fp->getScript(), pc, pcoff, atom);
return atom;
}
@ -329,10 +329,11 @@ PropertyCache::fullTest(JSContext *cx, jsbytecode *pc, JSObject **objp, JSObject
uint32 vcap;
JS_ASSERT(this == &JS_PROPERTY_CACHE(cx));
JS_ASSERT(uintN((cx->fp->hasIMacroPC() ? cx->fp->getIMacroPC() : pc) - cx->fp->script->code)
< cx->fp->script->length);
JS_ASSERT(
uintN((cx->fp->hasIMacroPC() ? cx->fp->getIMacroPC() : pc) - cx->fp->getScript()->code)
< cx->fp->getScript()->length);
JSOp op = js_GetOpcode(cx, cx->fp->script, pc);
JSOp op = js_GetOpcode(cx, cx->fp->getScript(), pc);
const JSCodeSpec &cs = js_CodeSpec[op];
obj = *objp;

View File

@ -213,7 +213,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::upRecursion()
{
JS_ASSERT((JSOp)*cx->fp->down->savedPC == JSOP_CALL);
JS_ASSERT(js_CodeSpec[js_GetOpcode(cx, cx->fp->down->script,
JS_ASSERT(js_CodeSpec[js_GetOpcode(cx, cx->fp->down->getScript(),
cx->fp->down->savedPC)].length == JSOP_CALL_LENGTH);
JS_ASSERT(callDepth == 0);
@ -390,7 +390,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
{
/* Missing - no go */
if (cx->fp->argc != cx->fp->fun->nargs)
if (cx->fp->argc != cx->fp->getArgumentCount())
RETURN_STOP_A("argc != nargs");
LIns* argv_ins;
@ -432,9 +432,9 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
guard(true,
lir->ins2(LIR_eqp,
addName(lir->insLoad(LIR_ldp, fp_ins,
offsetof(JSStackFrame, script), ACCSET_OTHER),
JSStackFrame::offsetScript(), ACCSET_OTHER),
"script"),
INS_CONSTPTR(cx->fp->down->script)),
INS_CONSTPTR(cx->fp->down->getScript())),
RECURSIVE_LOOP_EXIT);
}
@ -591,7 +591,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
/* this */
slurpSlot(argv_ins, -1 * ptrdiff_t(sizeof(Value)), &fp->argv[-1], &info);
/* args[0..n] */
for (unsigned i = 0; i < JS_MAX(fp->argc, fp->fun->nargs); i++)
for (unsigned i = 0; i < JS_MAX(fp->argc, fp->getArgumentCount()); i++)
slurpSlot(argv_ins, i * sizeof(Value), &fp->argv[i], &info);
/* argsobj */
slurpFrameObjPtrSlot(fp_ins, JSStackFrame::offsetArgsObj(), fp->addressArgsObj(), &info);
@ -600,10 +600,10 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
/* vars */
LIns* slots_ins = addName(lir->ins2(LIR_addp, fp_ins, INS_CONSTWORD(sizeof(JSStackFrame))),
"slots");
for (unsigned i = 0; i < fp->script->nfixed; i++)
for (unsigned i = 0; i < fp->getFixedCount(); i++)
slurpSlot(slots_ins, i * sizeof(Value), &fp->slots()[i], &info);
/* stack vals */
unsigned nfixed = fp->script->nfixed;
unsigned nfixed = fp->getFixedCount();
Value* stack = fp->base();
LIns* stack_ins = addName(lir->ins2(LIR_addp,
slots_ins,
@ -614,7 +614,7 @@ TraceRecorder::slurpDownFrames(jsbytecode* return_pc)
if (anchor && anchor->exitType == RECURSIVE_SLURP_FAIL_EXIT)
limit--;
else
limit -= fp->fun->nargs + 2;
limit -= fp->getArgumentCount() + 2;
for (size_t i = 0; i < limit; i++)
slurpSlot(stack_ins, i * sizeof(Value), &stack[i], &info);
@ -673,14 +673,15 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::downRecursion()
{
JSStackFrame* fp = cx->fp;
if ((jsbytecode*)fragment->ip < fp->script->code ||
(jsbytecode*)fragment->ip >= fp->script->code + fp->script->length) {
JSScript *script = fp->getScript();
if ((jsbytecode*)fragment->ip < script->code ||
(jsbytecode*)fragment->ip >= script->code + script->length) {
RETURN_STOP_A("inner recursive call must compile first");
}
/* Adjust the stack by the budget the down-frame needs. */
int slots = NativeStackSlots(cx, 1) - NativeStackSlots(cx, 0);
JS_ASSERT(unsigned(slots) == NativeStackSlots(cx, 1) - fp->argc - 2 - fp->script->nfixed - 2);
JS_ASSERT(unsigned(slots) == NativeStackSlots(cx, 1) - fp->argc - 2 - fp->getFixedCount() - 2);
/* Guard that there is enough stack space. */
JS_ASSERT(tree->maxNativeStackSlots >= tree->nativeStackBase / sizeof(double));
@ -722,11 +723,11 @@ TraceRecorder::downRecursion()
* tree pc.
*/
VMSideExit* exit;
if ((jsbytecode*)fragment->root->ip == fp->script->code)
if ((jsbytecode*)fragment->root->ip == script->code)
exit = snapshot(UNSTABLE_LOOP_EXIT);
else
exit = snapshot(RECURSIVE_UNLINKED_EXIT);
exit->recursive_pc = fp->script->code;
exit->recursive_pc = script->code;
debug_only_print0(LC_TMTracer, "Compiling down-recursive function call.\n");
JS_ASSERT(tree->recursion != Recursion_Disallowed);
tree->recursion = Recursion_Detected;

View File

@ -1356,7 +1356,8 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
uintN
js_FramePCToLineNumber(JSContext *cx, JSStackFrame *fp)
{
return js_PCToLineNumber(cx, fp->script, fp->hasIMacroPC() ? fp->getIMacroPC() : fp->pc(cx));
return js_PCToLineNumber(cx, fp->getScript(),
fp->hasIMacroPC() ? fp->getIMacroPC() : fp->pc(cx));
}
uintN

View File

@ -1091,7 +1091,7 @@ Tracker::set(const void* v, LIns* i)
static inline jsuint
argSlots(JSStackFrame* fp)
{
return JS_MAX(fp->argc, fp->fun->nargs);
return JS_MAX(fp->argc, fp->getArgumentCount());
}
static inline bool
@ -1185,7 +1185,7 @@ static JS_REQUIRES_STACK inline int
StackSlotHash(JSContext* cx, unsigned slot, const void* pc)
{
uintptr_t h = HASH_SEED;
HashAccum(h, uintptr_t(cx->fp->script), ORACLE_MASK);
HashAccum(h, uintptr_t(cx->fp->getScript()), ORACLE_MASK);
HashAccum(h, uintptr_t(pc), ORACLE_MASK);
HashAccum(h, uintptr_t(slot), ORACLE_MASK);
return int(h);
@ -1200,7 +1200,7 @@ GlobalSlotHash(JSContext* cx, unsigned slot)
while (fp->down)
fp = fp->down;
HashAccum(h, uintptr_t(fp->script), ORACLE_MASK);
HashAccum(h, uintptr_t(fp->maybeScript()), ORACLE_MASK);
HashAccum(h, uintptr_t(fp->getScopeChain()->getGlobal()->shape()), ORACLE_MASK);
HashAccum(h, uintptr_t(slot), ORACLE_MASK);
return int(h);
@ -1532,11 +1532,11 @@ TreeFragment::initialize(JSContext* cx, SlotList *globalSlots, bool speculate)
this->spOffsetAtEntry = cx->regs->sp - cx->fp->base();
#ifdef DEBUG
this->treeFileName = cx->fp->script->filename;
this->treeFileName = cx->fp->getScript()->filename;
this->treeLineNumber = js_FramePCToLineNumber(cx, cx->fp);
this->treePCOffset = FramePCOffset(cx, cx->fp);
#endif
this->script = cx->fp->script;
this->script = cx->fp->getScript();
this->recursion = Recursion_None;
this->gcthings.clear();
this->sprops.clear();
@ -1824,17 +1824,17 @@ VisitFrameSlots(Visitor &visitor, JSContext *cx, unsigned depth,
if (!visitor.visitFrameObjPtr(fp->addressScopeChain(), fp))
return false;
visitor.setStackSlotKind("var");
if (!visitor.visitStackSlots(fp->slots(), fp->script->nfixed, fp))
if (!visitor.visitStackSlots(fp->slots(), fp->getFixedCount(), fp))
return false;
}
visitor.setStackSlotKind("stack");
Value *base = fp->base();
JS_ASSERT(sp >= base && sp <= fp->slots() + fp->script->nslots);
JS_ASSERT(sp >= base && sp <= fp->slots() + fp->getSlotCount());
if (!visitor.visitStackSlots(base, size_t(sp - base), fp))
return false;
if (up) {
int missing = up->fun->nargs - up->argc;
int missing = up->getArgumentCount() - up->argc;
if (missing > 0) {
visitor.setStackSlotKind("missing");
if (!visitor.visitStackSlots(sp, size_t(missing), fp))
@ -1996,7 +1996,7 @@ NativeStackSlots(JSContext *cx, unsigned callDepth)
JSStackFrame *const fp = i.fp();
slots += i.sp() - fp->base();
if (fp->argv)
slots += fp->script->nfixed + SPECIAL_FRAME_SLOTS;
slots += fp->getFixedCount() + SPECIAL_FRAME_SLOTS;
if (depth-- == 0) {
if (fp->argv)
slots += 2/*callee,this*/ + argSlots(fp);
@ -2007,7 +2007,7 @@ NativeStackSlots(JSContext *cx, unsigned callDepth)
#endif
return slots;
}
int missing = fp->fun->nargs - fp->argc;
int missing = fp->getArgumentCount() - fp->argc;
if (missing > 0)
slots += missing;
}
@ -2240,7 +2240,7 @@ TraceRecorder::TraceRecorder(JSContext* cx, VMSideExit* anchor, VMFragment* frag
global_dslots(NULL),
callDepth(anchor ? anchor->calldepth : 0),
atoms(FrameAtomBase(cx, cx->fp)),
consts(cx->fp->script->constOffset ? cx->fp->script->consts()->vector : NULL),
consts(cx->fp->getScript()->constOffset ? cx->fp->getScript()->consts()->vector : NULL),
cfgMerges(&tempAlloc()),
trashSelf(false),
whichTreesToTrash(&tempAlloc()),
@ -2485,7 +2485,7 @@ TraceRecorder::finishAbort(const char* reason)
tree->treeFileName,
tree->treeLineNumber,
tree->treePCOffset,
cx->fp->script->filename,
cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp),
FramePCOffset(cx, cx->fp),
reason);
@ -2630,7 +2630,7 @@ TraceRecorder::nativeStackOffsetImpl(const void* p) const
*/
if (!visitor.stopped()) {
const Value *vp = (const Value *)p;
JS_ASSERT(size_t(vp - cx->fp->slots()) < cx->fp->script->nslots);
JS_ASSERT(size_t(vp - cx->fp->slots()) < cx->fp->getSlotCount());
offset += size_t(vp - cx->regs->sp) * sizeof(double);
}
return offset;
@ -3231,13 +3231,13 @@ GetUpvarVarOnTrace(JSContext* cx, uint32 upvarLevel, int32 slot, uint32 callDept
*/
struct UpvarStackTraits {
static Value interp_get(JSStackFrame* fp, int32 slot) {
return fp->slots()[slot + fp->script->nfixed];
return fp->slots()[slot + fp->getFixedCount()];
}
static uint32 native_slot(uint32 argc, int32 slot) {
/*
* Locals are not imported by the tracer when the frame has no
* function, so we do not add fp->script->nfixed.
* function, so we do not add fp->getFixedCount().
*/
JS_ASSERT(argc == 0);
return slot;
@ -3454,10 +3454,10 @@ FlushNativeStackFrame(JSContext* cx, unsigned callDepth, const JSValueType* mp,
JS_ASSERT(fp->argv[-1].isObjectOrNull());
JS_ASSERT(fp->callee()->isFunction());
JS_ASSERT(GET_FUNCTION_PRIVATE(cx, fp->callee()) == fp->fun);
JS_ASSERT(GET_FUNCTION_PRIVATE(cx, fp->callee()) == fp->getFunction());
if (FUN_INTERPRETED(fp->fun) &&
(fp->fun->flags & JSFUN_HEAVYWEIGHT)) {
if (FUN_INTERPRETED(fp->getFunction()) &&
(fp->getFunction()->flags & JSFUN_HEAVYWEIGHT)) {
// Iff these fields are NULL, then |fp| was synthesized on trace exit, so
// we need to update the frame fields.
if (!fp->hasCallObj())
@ -3471,7 +3471,7 @@ FlushNativeStackFrame(JSContext* cx, unsigned callDepth, const JSValueType* mp,
if (!fp->getScopeChain()->getPrivate())
fp->getScopeChain()->setPrivate(fp);
}
fp->thisv = fp->argv[-1];
fp->setThisValue(fp->argv[-1]);
if (fp->flags & JSFRAME_CONSTRUCTING) // constructors always compute 'this'
fp->flags |= JSFRAME_COMPUTED_THIS;
}
@ -3525,19 +3525,21 @@ TraceRecorder::importImpl(LIns* base, ptrdiff_t offset, const void* p, JSValueTy
const char* funName = NULL;
if (*prefix == 'a' || *prefix == 'v') {
mark = JS_ARENA_MARK(&cx->tempPool);
if (fp->fun->hasLocalNames())
localNames = js_GetLocalNameArray(cx, fp->fun, &cx->tempPool);
funName = fp->fun->atom ? js_AtomToPrintableString(cx, fp->fun->atom) : "<anonymous>";
if (fp->getFunction()->hasLocalNames())
localNames = js_GetLocalNameArray(cx, fp->getFunction(), &cx->tempPool);
funName = fp->getFunction()->atom
? js_AtomToPrintableString(cx, fp->getFunction()->atom)
: "<anonymous>";
}
if (!strcmp(prefix, "argv")) {
if (index < fp->fun->nargs) {
if (index < fp->getArgumentCount()) {
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[index]);
JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom));
} else {
JS_snprintf(name, sizeof name, "$%s.<arg%d>", funName, index);
}
} else if (!strcmp(prefix, "vars")) {
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[fp->fun->nargs + index]);
JSAtom *atom = JS_LOCAL_NAME_TO_ATOM(localNames[fp->getArgumentCount() + index]);
JS_snprintf(name, sizeof name, "$%s.%s", funName, js_AtomToPrintableString(cx, atom));
} else {
JS_snprintf(name, sizeof name, "$%s%d", prefix, index);
@ -3811,7 +3813,7 @@ TraceRecorder::attemptImport(const Value* p)
CountSlotsVisitor countVisitor(p);
VisitStackSlots(countVisitor, cx, callDepth);
if (countVisitor.stopped() || size_t(p - cx->fp->slots()) < cx->fp->script->nslots)
if (countVisitor.stopped() || size_t(p - cx->fp->slots()) < cx->fp->getSlotCount())
return get(p);
return NULL;
@ -4129,7 +4131,7 @@ TreevisLogExit(JSContext* cx, VMSideExit* exit)
{
debug_only_printf(LC_TMTreeVis, "TREEVIS ADDEXIT EXIT=%p TYPE=%s FRAG=%p PC=%p FILE=\"%s\""
" LINE=%d OFFS=%d", (void*)exit, getExitName(exit->exitType),
(void*)exit->from, (void*)cx->regs->pc, cx->fp->script->filename,
(void*)exit->from, (void*)cx->regs->pc, cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp), FramePCOffset(cx, cx->fp));
debug_only_print0(LC_TMTreeVis, " STACK=\"");
for (unsigned i = 0; i < exit->numStackSlots; i++)
@ -4484,7 +4486,7 @@ TraceRecorder::compile()
/* :TODO: windows support */
#if defined DEBUG && !defined WIN32
/* Associate a filename and line number with the fragment. */
const char* filename = cx->fp->script->filename;
const char* filename = cx->fp->getScript()->filename;
char* label = (char*)js_malloc((filename ? strlen(filename) : 7) + 16);
sprintf(label, "%s:%u", filename ? filename : "<stdin>",
js_FramePCToLineNumber(cx, cx->fp));
@ -4996,7 +4998,7 @@ TraceRecorder::closeLoop(SlotMap& slotMap, VMSideExit* exit)
#ifdef JS_JIT_SPEW
debug_only_printf(LC_TMMinimal,
"Recording completed at %s:%u@%u via closeLoop (FragID=%06u)\n",
cx->fp->script->filename,
cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp),
FramePCOffset(cx, cx->fp),
fragment->profFragID);
@ -5170,7 +5172,7 @@ TraceRecorder::endLoop(VMSideExit* exit)
#ifdef JS_JIT_SPEW
debug_only_printf(LC_TMMinimal,
"Recording completed at %s:%u@%u via endLoop (FragID=%06u)\n",
cx->fp->script->filename,
cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp),
FramePCOffset(cx, cx->fp),
fragment->profFragID);
@ -5409,7 +5411,7 @@ TraceRecorder::trackCfgMerges(jsbytecode* pc)
{
/* If we hit the beginning of an if/if-else, then keep track of the merge point after it. */
JS_ASSERT((*pc == JSOP_IFEQ) || (*pc == JSOP_IFEQX));
jssrcnote* sn = js_GetSrcNote(cx->fp->script, pc);
jssrcnote* sn = js_GetSrcNote(cx->fp->getScript(), pc);
if (sn != NULL) {
if (SN_TYPE(sn) == SRC_IF) {
cfgMerges.add((*pc == JSOP_IFEQ)
@ -5658,8 +5660,8 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee)
/* Assert that we have a correct sp distance from cx->fp->slots in fi. */
JSStackFrame* const fp = cx->fp;
JS_ASSERT_IF(!fi.imacpc,
js_ReconstructStackDepth(cx, fp->script, fi.pc) ==
uintN(fi.spdist - fp->script->nfixed));
js_ReconstructStackDepth(cx, fp->getScript(), fi.pc) ==
uintN(fi.spdist - fp->getFixedCount()));
/* Simulate js_Interpret locals for when |cx->fp == fp|. */
JSScript* newscript = fun->u.i.script;
@ -5699,8 +5701,8 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee)
/* Initialize the new stack frame. */
newfp->setCallObj(NULL);
newfp->setArgsObj(NULL);
newfp->script = newscript;
newfp->fun = fun;
newfp->setScript(newscript);
newfp->setFunction(fun);
newfp->argc = argc;
newfp->argv = argv;
#ifdef DEBUG
@ -5708,19 +5710,19 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee)
// someone forgets to initialize it later.
newfp->argv[-1].setMagic(JS_THIS_POISON);
#endif
newfp->rval = UndefinedValue();
newfp->clearReturnValue();
newfp->setAnnotation(NULL);
newfp->setScopeChain(NULL); // will be updated in FlushNativeStackFrame
newfp->flags = fi.is_constructing() ? JSFRAME_CONSTRUCTING : 0;
newfp->setBlockChain(NULL);
newfp->thisv.setNull(); // will be updated in FlushNativeStackFrame
newfp->setThisValue(NullValue()); // will be updated in FlushNativeStackFrame
JS_ASSERT(!newfp->hasIMacroPC());
/*
* Note that fp->script is still the caller's script; set the callee
* inline frame's idea of caller version from its version.
*/
newfp->setCallerVersion((JSVersion) fp->script->version);
newfp->setCallerVersion((JSVersion) fp->getScript()->version);
/* Push inline frame. (Copied from js_Interpret.) */
stack.pushInlineFrame(cx, fp, fi.pc, newfp);
@ -5748,7 +5750,7 @@ SynthesizeFrame(JSContext* cx, const FrameInfo& fi, JSObject* callee)
* everything down to the caller's fp->slots (where vars start) and avoid
* some of the complexity?
*/
return (fi.spdist - newfp->down->script->nfixed) +
return (fi.spdist - newfp->down->getFixedCount()) +
((fun->nargs > newfp->argc) ? fun->nargs - newfp->argc : 0) +
newscript->nfixed + SPECIAL_FRAME_SLOTS;
}
@ -5774,12 +5776,12 @@ SynthesizeSlowNativeFrame(TracerState& state, JSContext *cx, VMSideExit *exit)
fp->setCallObj(NULL);
fp->setArgsObj(NULL);
fp->script = NULL;
fp->thisv = state.nativeVp[1];
fp->setScript(NULL);
fp->setThisValue(state.nativeVp[1]);
fp->argc = state.nativeVpLen - 2;
fp->argv = state.nativeVp + 2;
fp->fun = GET_FUNCTION_PRIVATE(cx, fp->callee());
fp->rval = UndefinedValue();
fp->setFunction(GET_FUNCTION_PRIVATE(cx, fp->callee()));
fp->clearReturnValue();
fp->setAnnotation(NULL);
fp->setScopeChain(cx->fp->getScopeChain());
fp->setBlockChain(NULL);
@ -5997,7 +5999,7 @@ CreateBranchFragment(JSContext* cx, TreeFragment* root, VMSideExit* anchor)
debug_only_printf(LC_TMTreeVis, "TREEVIS CREATEBRANCH ROOT=%p FRAG=%p PC=%p FILE=\"%s\""
" LINE=%d ANCHOR=%p OFFS=%d\n",
(void*)root, (void*)f, (void*)cx->regs->pc, cx->fp->script->filename,
(void*)root, (void*)f, (void*)cx->regs->pc, cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp), (void*)anchor,
FramePCOffset(cx, cx->fp));
verbose_only( tm->branches = new (*tm->dataAlloc) Seq<Fragment*>(f, tm->branches); )
@ -6160,7 +6162,7 @@ TraceRecorder::recordLoopEdge(JSContext* cx, TraceRecorder* r, uintN& inlineCall
debug_only_printf(LC_TMTracer,
"Looking for type-compatible peer (%s:%d@%d)\n",
cx->fp->script->filename,
cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp),
FramePCOffset(cx, cx->fp));
@ -6203,9 +6205,9 @@ TraceRecorder::attemptTreeCall(TreeFragment* f, uintN& inlineCallCount)
* In the interim, just do tree calls knowing that they won't go into
* recursive trees that can pop parent frames.
*/
if (f->script == cx->fp->script) {
if (f->script == cx->fp->getScript()) {
if (f->recursion >= Recursion_Unwinds) {
Blacklist(cx->fp->script->code);
Blacklist(cx->fp->getScript()->code);
AbortRecording(cx, "Inner tree is an unsupported type of recursion");
return ARECORD_ABORTED;
}
@ -6734,7 +6736,7 @@ ExecuteTree(JSContext* cx, TreeFragment* f, uintN& inlineCallCount,
AUDIT(traceTriggered);
debug_only_printf(LC_TMTracer,
"entering trace at %s:%u@%u, native stack slots: %u code: %p\n",
cx->fp->script->filename,
cx->fp->getScript()->filename,
js_FramePCToLineNumber(cx, cx->fp),
FramePCOffset(cx, cx->fp),
f->maxNativeStackSlots,
@ -6853,11 +6855,11 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
*
* First, if we just returned from a slow native, pop its stack frame.
*/
if (!cx->fp->script) {
if (!cx->fp->hasScript()) {
JS_ASSERT(cx->regs == &state.bailedSlowNativeRegs);
cx->stack().popSynthesizedSlowNativeFrame(cx);
}
JS_ASSERT(cx->fp->script);
JS_ASSERT(cx->fp->hasScript());
if (!(bs & BUILTIN_ERROR)) {
/*
@ -6903,8 +6905,8 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
regs->sp += cs.ndefs;
regs->pc += cs.length;
JS_ASSERT_IF(!cx->fp->hasIMacroPC(),
cx->fp->slots() + cx->fp->script->nfixed +
js_ReconstructStackDepth(cx, cx->fp->script, regs->pc) ==
cx->fp->slots() + cx->fp->getFixedCount() +
js_ReconstructStackDepth(cx, cx->fp->getScript(), regs->pc) ==
regs->sp);
/*
@ -6963,7 +6965,7 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
JSStackFrame* fp = cx->fp;
debug_only_printf(LC_TMTracer,
"synthesized deep frame for %s:%u@%u, slots=%d, fi=%p\n",
fp->script->filename,
fp->getScript()->filename,
js_FramePCToLineNumber(cx, fp),
FramePCOffset(cx, fp),
slots,
@ -6999,7 +7001,7 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
JSStackFrame* fp = cx->fp;
debug_only_printf(LC_TMTracer,
"synthesized shallow frame for %s:%u@%u\n",
fp->script->filename, js_FramePCToLineNumber(cx, fp),
fp->getScript()->filename, js_FramePCToLineNumber(cx, fp),
FramePCOffset(cx, fp));
#endif
}
@ -7026,8 +7028,8 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
fp->clearIMacroPC();
cx->regs->sp = fp->base() + (innermost->sp_adj / sizeof(double)) - calldepth_slots;
JS_ASSERT_IF(!fp->hasIMacroPC(),
fp->slots() + fp->script->nfixed +
js_ReconstructStackDepth(cx, fp->script, cx->regs->pc) == cx->regs->sp);
fp->slots() + fp->getFixedCount() +
js_ReconstructStackDepth(cx, fp->getScript(), cx->regs->pc) == cx->regs->sp);
#ifdef EXECUTE_TREE_TIMER
uint64 cycles = rdtsc() - state.startTime;
@ -7038,7 +7040,7 @@ LeaveTree(TraceMonitor *tm, TracerState& state, VMSideExit* lr)
debug_only_printf(LC_TMTracer,
"leaving trace at %s:%u@%u, op=%s, lr=%p, exitType=%s, sp=%lld, "
"calldepth=%d, cycles=%llu\n",
fp->script->filename,
fp->getScript()->filename,
js_FramePCToLineNumber(cx, fp),
FramePCOffset(cx, fp),
js_CodeName[fp->hasIMacroPC() ? *fp->getIMacroPC() : *cx->regs->pc],
@ -7385,9 +7387,9 @@ TraceRecorder::monitorRecording(JSOp op)
debug_only_stmt(
if (LogController.lcbits & LC_TMRecorder) {
js_Disassemble1(cx, cx->fp->script, cx->regs->pc,
js_Disassemble1(cx, cx->fp->getScript(), cx->regs->pc,
cx->fp->hasIMacroPC()
? 0 : cx->regs->pc - cx->fp->script->code,
? 0 : cx->regs->pc - cx->fp->getScript()->code,
!cx->fp->hasIMacroPC(), stdout);
}
)
@ -8042,14 +8044,14 @@ DeepBail(JSContext *cx)
JS_REQUIRES_STACK Value&
TraceRecorder::argval(unsigned n) const
{
JS_ASSERT(n < cx->fp->fun->nargs);
JS_ASSERT(n < cx->fp->getArgumentCount());
return cx->fp->argv[n];
}
JS_REQUIRES_STACK Value&
TraceRecorder::varval(unsigned n) const
{
JS_ASSERT(n < cx->fp->script->nslots);
JS_ASSERT(n < cx->fp->getSlotCount());
return cx->fp->slots()[n];
}
@ -8063,9 +8065,9 @@ JS_REQUIRES_STACK void
TraceRecorder::updateAtoms()
{
atoms = FrameAtomBase(cx, cx->fp);
consts = cx->fp->hasIMacroPC() || cx->fp->script->constOffset == 0
consts = cx->fp->hasIMacroPC() || cx->fp->getScript()->constOffset == 0
? 0
: cx->fp->script->consts()->vector;
: cx->fp->getScript()->consts()->vector;
}
JS_REQUIRES_STACK void
@ -8227,15 +8229,15 @@ TraceRecorder::callProp(JSObject* obj, JSProperty* prop, jsid id, Value*& vp,
JSStackFrame* cfp = (JSStackFrame*) obj->getPrivate();
if (cfp) {
if (sprop->getterOp() == js_GetCallArg) {
JS_ASSERT(slot < cfp->fun->nargs);
JS_ASSERT(slot < cfp->getArgumentCount());
vp = &cfp->argv[slot];
upvar_slot = slot;
nr.v = *vp;
} else if (sprop->getterOp() == js_GetCallVar ||
sprop->getterOp() == js_GetCallVarChecked) {
JS_ASSERT(slot < cfp->script->nslots);
JS_ASSERT(slot < cfp->getSlotCount());
vp = &cfp->slots()[slot];
upvar_slot = cx->fp->fun->nargs + slot;
upvar_slot = cx->fp->getArgumentCount() + slot;
nr.v = *vp;
} else {
RETURN_STOP("dynamic property of Call object");
@ -9537,7 +9539,7 @@ TraceRecorder::guardPropertyCacheHit(LIns* obj_ins,
if (entry->adding())
RETURN_STOP("adding a property to the global object");
JSOp op = js_GetOpcode(cx, cx->fp->script, cx->regs->pc);
JSOp op = js_GetOpcode(cx, cx->fp->getScript(), cx->regs->pc);
if (JOF_OPMODE(op) != JOF_NAME) {
guard(true,
addName(lir->ins2(LIR_eqp, obj_ins, INS_CONSTOBJ(globalObj)), "guard_global"),
@ -10260,14 +10262,14 @@ TraceRecorder::clearEntryFrameSlotsFromTracker(Tracker& which)
JSStackFrame *fp = entryFrame();
// Clear only slots that are not also used by the next frame up.
clearFrameSlotsFromTracker(which, fp, fp->script->nfixed);
clearFrameSlotsFromTracker(which, fp, fp->getFixedCount());
}
JS_REQUIRES_STACK void
TraceRecorder::clearCurrentFrameSlotsFromTracker(Tracker& which)
{
// Clear out all local slots.
clearFrameSlotsFromTracker(which, cx->fp, cx->fp->script->nslots);
clearFrameSlotsFromTracker(which, cx->fp, cx->fp->getSlotCount());
}
/*
@ -10279,12 +10281,14 @@ JS_REQUIRES_STACK void
TraceRecorder::putActivationObjects()
{
bool have_args = cx->fp->hasArgsObj() && cx->fp->argc;
bool have_call = cx->fp->fun && JSFUN_HEAVYWEIGHT_TEST(cx->fp->fun->flags) && cx->fp->fun->countArgsAndVars();
bool have_call = cx->fp->hasFunction() &&
JSFUN_HEAVYWEIGHT_TEST(cx->fp->getFunction()->flags) &&
cx->fp->getFunction()->countArgsAndVars();
if (!have_args && !have_call)
return;
int nargs = have_args ? argSlots(cx->fp) : cx->fp->fun->nargs;
int nargs = have_args ? argSlots(cx->fp) : cx->fp->getArgumentCount();
LIns* args_ins;
if (nargs) {
@ -10304,7 +10308,7 @@ TraceRecorder::putActivationObjects()
}
if (have_call) {
int nslots = cx->fp->fun->countVars();
int nslots = cx->fp->getFunction()->countVars();
LIns* slots_ins;
if (nslots) {
slots_ins = lir->insAlloc(sizeof(Value) * nslots);
@ -10318,7 +10322,7 @@ TraceRecorder::putActivationObjects()
LIns* scopeChain_ins = getFrameObjPtr(cx->fp->addressScopeChain());
LIns* args[] = { slots_ins, INS_CONST(nslots), args_ins,
INS_CONST(cx->fp->fun->nargs), scopeChain_ins, cx_ins };
INS_CONST(cx->fp->getArgumentCount()), scopeChain_ins, cx_ins };
lir->insCall(&js_PutCallObjectOnTrace_ci, args);
}
}
@ -10330,11 +10334,11 @@ IsTraceableRecursion(JSContext *cx)
JSStackFrame *down = cx->fp->down;
if (!down)
return false;
if (down->script != fp->script)
if (down->maybeScript() != fp->maybeScript())
return false;
if (down->argc != fp->argc)
return false;
if (fp->argc != fp->fun->nargs)
if (fp->argc != fp->getArgumentCount())
return false;
if (fp->hasIMacroPC() || down->hasIMacroPC())
return false;
@ -10342,7 +10346,7 @@ IsTraceableRecursion(JSContext *cx)
return false;
if (fp->hasBlockChain() || down->hasBlockChain())
return false;
if (*fp->script->code != JSOP_TRACE)
if (*fp->getScript()->code != JSOP_TRACE)
return false;
return true;
}
@ -10356,11 +10360,11 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount)
RETURN_STOP_A("exceeded maximum call depth");
debug_only_printf(LC_TMTracer, "EnterFrame %s, callDepth=%d\n",
js_AtomToPrintableString(cx, cx->fp->fun->atom),
js_AtomToPrintableString(cx, cx->fp->getFunction()->atom),
callDepth);
debug_only_stmt(
if (LogController.lcbits & LC_TMRecorder) {
js_Disassemble(cx, cx->fp->script, JS_TRUE, stdout);
js_Disassemble(cx, cx->fp->getScript(), JS_TRUE, stdout);
debug_only_print0(LC_TMTracer, "----\n");
}
)
@ -10380,7 +10384,7 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount)
// slots defined as imported by VisitFrameSlots.
Value* vp = &fp->argv[fp->argc];
Value* vpstop = vp + ptrdiff_t(fp->fun->nargs) - ptrdiff_t(fp->argc);
Value* vpstop = vp + ptrdiff_t(fp->getArgumentCount()) - ptrdiff_t(fp->argc);
for (; vp < vpstop; ++vp) {
nativeFrameTracker.set(vp, NULL);
set(vp, void_ins);
@ -10391,29 +10395,29 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount)
nativeFrameTracker.set(fp->addressScopeChain(), NULL);
vp = fp->slots();
vpstop = vp + fp->script->nfixed;
vpstop = vp + fp->getFixedCount();
for (; vp < vpstop; ++vp) {
nativeFrameTracker.set(vp, NULL);
set(vp, void_ins);
}
vp = vpstop;
vpstop = vp + (fp->script->nslots - fp->script->nfixed);
vpstop = vp + (fp->getSlotCount() - fp->getFixedCount());
for (; vp < vpstop; ++vp)
nativeFrameTracker.set(vp, NULL);
LIns* callee_ins = get(&cx->fp->argv[-2]);
LIns* scopeChain_ins = stobj_get_parent(callee_ins);
if (cx->fp->fun && JSFUN_HEAVYWEIGHT_TEST(cx->fp->fun->flags)) {
if (cx->fp->hasFunction() && JSFUN_HEAVYWEIGHT_TEST(cx->fp->getFunction()->flags)) {
// We need to make sure every part of the frame is known to the tracker
// before taking a snapshot.
setFrameObjPtr(fp->addressScopeChain(), INS_NULL());
if (js_IsNamedLambda(cx->fp->fun))
if (js_IsNamedLambda(cx->fp->getFunction()))
RETURN_STOP_A("can't call named lambda heavyweight on trace");
LIns* fun_ins = INS_CONSTPTR(cx->fp->fun);
LIns* fun_ins = INS_CONSTPTR(cx->fp->getFunction());
LIns* args[] = { scopeChain_ins, callee_ins, fun_ins, cx_ins };
LIns* call_ins = lir->insCall(&js_CreateCallObjectOnTrace_ci, args);
@ -10431,17 +10435,17 @@ TraceRecorder::record_EnterFrame(uintN& inlineCallCount)
* concerned about. That should pass through below to not regress pre-recursion
* functionality.
*/
if (IsTraceableRecursion(cx) && tree->script == cx->fp->script) {
if (IsTraceableRecursion(cx) && tree->script == cx->fp->getScript()) {
if (tree->recursion == Recursion_Disallowed)
RETURN_STOP_A("recursion not allowed in this tree");
if (tree->script != cx->fp->script)
if (tree->script != cx->fp->getScript())
RETURN_STOP_A("recursion does not match original tree");
return InjectStatus(downRecursion());
}
/* Try inlining one level in case this recursion doesn't go too deep. */
if (fp->script == fp->down->script &&
fp->down->down && fp->down->down->script == fp->script) {
if (fp->getScript() == fp->down->getScript() &&
fp->down->down && fp->down->down->getScript() == fp->getScript()) {
RETURN_STOP_A("recursion started inlining");
}
@ -10492,14 +10496,14 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_LeaveFrame()
{
debug_only_stmt(
if (cx->fp->fun)
if (cx->fp->hasFunction())
debug_only_printf(LC_TMTracer,
"LeaveFrame (back to %s), callDepth=%d\n",
js_AtomToPrintableString(cx, cx->fp->fun->atom),
js_AtomToPrintableString(cx, cx->fp->getFunction()->atom),
callDepth);
);
JS_ASSERT(js_CodeSpec[js_GetOpcode(cx, cx->fp->script,
JS_ASSERT(js_CodeSpec[js_GetOpcode(cx, cx->fp->getScript(),
cx->regs->pc)].length == JSOP_CALL_LENGTH);
if (callDepth-- <= 0)
@ -10528,7 +10532,7 @@ TraceRecorder::record_JSOP_POPV()
// frame because POPV appears only in global and eval code and we don't
// trace JSOP_EVAL or leaving the frame where tracing started.
LIns *fp_ins = lir->insLoad(LIR_ldp, cx_ins, offsetof(JSContext, fp), ACCSET_OTHER);
box_value_into(rval, get(&rval), fp_ins, offsetof(JSStackFrame, rval), ACCSET_OTHER);
box_value_into(rval, get(&rval), fp_ins, JSStackFrame::offsetReturnValue(), ACCSET_OTHER);
return ARECORD_CONTINUE;
}
@ -10566,7 +10570,7 @@ TraceRecorder::record_JSOP_RETURN()
/* A return from callDepth 0 terminates the current loop, except for recursion. */
if (callDepth == 0) {
if (IsTraceableRecursion(cx) && tree->recursion != Recursion_Disallowed &&
tree->script == cx->fp->script) {
tree->script == cx->fp->getScript()) {
return InjectStatus(upRecursion());
} else {
AUDIT(returnLoopExits);
@ -10578,7 +10582,7 @@ TraceRecorder::record_JSOP_RETURN()
#ifdef MOZ_TRACE_JSCALLS
if (cx->functionCallback) {
LIns* args[] = { INS_CONST(0), INS_CONSTPTR(cx->fp->fun), cx_ins };
LIns* args[] = { INS_CONST(0), INS_CONSTPTR(cx->fp->getFunction()), cx_ins };
LIns* call_ins = lir->insCall(&functionProbe_ci, args);
guard(false, lir->insEqI_0(call_ins), MISMATCH_EXIT);
}
@ -10588,14 +10592,14 @@ TraceRecorder::record_JSOP_RETURN()
Value& rval = stackval(-1);
JSStackFrame *fp = cx->fp;
if ((cx->fp->flags & JSFRAME_CONSTRUCTING) && rval.isPrimitive()) {
JS_ASSERT(fp->thisv == fp->argv[-1]);
JS_ASSERT(fp->getThisValue() == fp->argv[-1]);
rval_ins = get(&fp->argv[-1]);
} else {
rval_ins = get(&rval);
}
debug_only_printf(LC_TMTracer,
"returning from %s\n",
js_AtomToPrintableString(cx, cx->fp->fun->atom));
js_AtomToPrintableString(cx, cx->fp->getFunction()->atom));
clearCurrentFrameSlotsFromTracker(nativeFrameTracker);
return ARECORD_CONTINUE;
@ -10609,7 +10613,7 @@ TraceRecorder::record_JSOP_GOTO()
* generate an always-taken loop exit guard. For other downward gotos
* (like if/else) continue recording.
*/
jssrcnote* sn = js_GetSrcNote(cx->fp->script, cx->regs->pc);
jssrcnote* sn = js_GetSrcNote(cx->fp->getScript(), cx->regs->pc);
if (sn && (SN_TYPE(sn) == SRC_BREAK || SN_TYPE(sn) == SRC_CONT2LABEL)) {
AUDIT(breakLoopExits);
@ -13141,10 +13145,10 @@ TraceRecorder::upvar(JSScript* script, JSUpvarArray* uva, uintN index, Value& v)
JSStackFrame* fp = cx->findFrameAtLevel(level);
const CallInfo* ci;
int32 slot;
if (!fp->fun || (fp->flags & JSFRAME_EVAL)) {
if (!fp->hasFunction() || (fp->flags & JSFRAME_EVAL)) {
ci = &GetUpvarStackOnTrace_ci;
slot = cookieSlot;
} else if (cookieSlot < fp->fun->nargs) {
} else if (cookieSlot < fp->getArgumentCount()) {
ci = &GetUpvarArgOnTrace_ci;
slot = cookieSlot;
} else if (cookieSlot == UpvarCookie::CALLEE_SLOT) {
@ -13152,7 +13156,7 @@ TraceRecorder::upvar(JSScript* script, JSUpvarArray* uva, uintN index, Value& v)
slot = -2;
} else {
ci = &GetUpvarVarOnTrace_ci;
slot = cookieSlot - fp->fun->nargs;
slot = cookieSlot - fp->getArgumentCount();
}
LIns* outp = lir->insAlloc(sizeof(double));
@ -13212,7 +13216,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_GETUPVAR()
{
uintN index = GET_UINT16(cx->regs->pc);
JSScript *script = cx->fp->script;
JSScript *script = cx->fp->getScript();
JSUpvarArray* uva = script->upvars();
JS_ASSERT(index < uva->length);
@ -14147,7 +14151,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_OBJECT()
{
JSStackFrame* const fp = cx->fp;
JSScript* script = fp->script;
JSScript* script = fp->getScript();
unsigned index = atoms - script->atomMap.vector + GET_INDEX(cx->regs->pc);
JSObject* obj;
@ -14721,7 +14725,7 @@ TraceRecorder::record_JSOP_BINDNAME()
JSStackFrame* const fp = cx->fp;
JSObject *obj;
if (!fp->fun) {
if (!fp->hasFunction()) {
obj = fp->getScopeChain();
#ifdef DEBUG
@ -14733,7 +14737,7 @@ TraceRecorder::record_JSOP_BINDNAME()
while (obj->getClass() == &js_BlockClass) {
// The block's values are still on the stack.
#ifdef DEBUG
// NB: fp2 can't be a generator frame, because !fp->fun.
// NB: fp2 can't be a generator frame, because !fp->hasFunction.
while (obj->getPrivate() != fp2) {
JS_ASSERT(fp2->flags & JSFRAME_SPECIAL);
fp2 = fp2->down;
@ -14765,7 +14769,7 @@ TraceRecorder::record_JSOP_BINDNAME()
// We can't trace BINDNAME in functions that contain direct calls to eval,
// as they might add bindings which previously-traced references would have
// to see.
if (JSFUN_HEAVYWEIGHT_TEST(fp->fun->flags))
if (JSFUN_HEAVYWEIGHT_TEST(fp->getFunction()->flags))
RETURN_STOP_A("BINDNAME in heavyweight function.");
// We don't have the scope chain on trace, so instead we get a start object
@ -15021,7 +15025,7 @@ jsatomid
TraceRecorder::getFullIndex(ptrdiff_t pcoff)
{
jsatomid index = GET_INDEX(cx->regs->pc + pcoff);
index += atoms - cx->fp->script->atomMap.vector;
index += atoms - cx->fp->getScript()->atomMap.vector;
return index;
}
@ -15029,7 +15033,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_LAMBDA()
{
JSFunction* fun;
fun = cx->fp->script->getFunction(getFullIndex());
fun = cx->fp->getScript()->getFunction(getFullIndex());
/*
* Emit code to clone a null closure parented by this recorder's global
@ -15128,7 +15132,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_LAMBDA_FC()
{
JSFunction* fun;
fun = cx->fp->script->getFunction(getFullIndex());
fun = cx->fp->getScript()->getFunction(getFullIndex());
if (FUN_OBJECT(fun)->getParent() != globalObj)
return ARECORD_STOP;
@ -15212,7 +15216,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_ARGSUB()
{
JSStackFrame* const fp = cx->fp;
if (!(fp->fun->flags & JSFUN_HEAVYWEIGHT)) {
if (!(fp->getFunction()->flags & JSFUN_HEAVYWEIGHT)) {
uintN slot = GET_ARGNO(cx->regs->pc);
if (slot >= fp->argc)
RETURN_STOP_A("can't trace out-of-range arguments");
@ -15236,7 +15240,7 @@ TraceRecorder::guardArgsLengthNotAssigned(LIns* argsobj_ins)
JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_ARGCNT()
{
if (cx->fp->fun->flags & JSFUN_HEAVYWEIGHT)
if (cx->fp->getFunction()->flags & JSFUN_HEAVYWEIGHT)
RETURN_STOP_A("can't trace heavyweight JSOP_ARGCNT");
// argc is fixed on trace, so ideally we would simply generate LIR for
@ -15480,7 +15484,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_REGEXP()
{
JSStackFrame* const fp = cx->fp;
JSScript* script = fp->script;
JSScript* script = fp->getScript();
unsigned index = atoms - script->atomMap.vector + GET_INDEX(cx->regs->pc);
LIns* proto_ins;
@ -15764,7 +15768,7 @@ TraceRecorder::record_JSOP_STOP()
{
if (callDepth == 0 && IsTraceableRecursion(cx) &&
tree->recursion != Recursion_Disallowed &&
tree->script == cx->fp->script) {
tree->script == cx->fp->getScript()) {
return InjectStatus(upRecursion());
}
JSStackFrame *fp = cx->fp;
@ -15775,7 +15779,7 @@ TraceRecorder::record_JSOP_STOP()
* interpreter's JSOP_STOP case will return from the imacro, back to
* the pc after the calling op, still in the same JSStackFrame.
*/
updateAtoms(fp->script);
updateAtoms(fp->getScript());
return ARECORD_CONTINUE;
}
@ -15783,7 +15787,7 @@ TraceRecorder::record_JSOP_STOP()
#ifdef MOZ_TRACE_JSCALLS
if (cx->functionCallback) {
LIns* args[] = { INS_CONST(0), INS_CONSTPTR(cx->fp->fun), cx_ins };
LIns* args[] = { INS_CONST(0), INS_CONSTPTR(cx->fp->getFunction()), cx_ins };
LIns* call_ins = lir->insCall(&functionProbe_ci, args);
guard(false, lir->insEqI_0(call_ins), MISMATCH_EXIT);
}
@ -15798,7 +15802,7 @@ TraceRecorder::record_JSOP_STOP()
* of the last expression-statement, debugger API calls).
*/
if (fp->flags & JSFRAME_CONSTRUCTING) {
JS_ASSERT(fp->thisv == fp->argv[-1]);
JS_ASSERT(fp->getThisValue() == fp->argv[-1]);
rval_ins = get(&fp->argv[-1]);
} else {
rval_ins = INS_UNDEFINED();
@ -15838,7 +15842,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_ENTERBLOCK()
{
JSObject* obj;
obj = cx->fp->script->getObject(getFullIndex(0));
obj = cx->fp->getScript()->getObject(getFullIndex(0));
LIns* void_ins = INS_UNDEFINED();
for (int i = 0, n = OBJ_BLOCK_COUNT(cx, obj); i < n; i++)
@ -15871,7 +15875,7 @@ JS_REQUIRES_STACK AbortableRecordingStatus
TraceRecorder::record_JSOP_ARRAYPUSH()
{
uint32_t slot = GET_UINT16(cx->regs->pc);
JS_ASSERT(cx->fp->script->nfixed <= slot);
JS_ASSERT(cx->fp->getFixedCount() <= slot);
JS_ASSERT(cx->fp->slots() + slot < cx->regs->sp - 1);
Value &arrayval = cx->fp->slots()[slot];
JS_ASSERT(arrayval.isObject());
@ -15913,7 +15917,7 @@ TraceRecorder::record_JSOP_GETTHISPROP()
* ARECORD_STOP if thisv is not available.
*/
JS_ASSERT(cx->fp->flags & JSFRAME_COMPUTED_THIS);
CHECK_STATUS_A(getProp(&cx->fp->thisv.toObject(), this_ins));
CHECK_STATUS_A(getProp(&cx->fp->getThisValue().toObject(), this_ins));
return ARECORD_CONTINUE;
}

View File

@ -1716,14 +1716,14 @@ ParseXMLSource(JSContext *cx, JSString *src)
xml = NULL;
FrameRegsIter i(cx);
for (; !i.done() && !i.pc(); ++i)
JS_ASSERT(!i.fp()->script);
JS_ASSERT(!i.fp()->hasScript());
filename = NULL;
lineno = 1;
if (!i.done()) {
JSStackFrame *fp = i.fp();
op = (JSOp) *i.pc();
if (op == JSOP_TOXML || op == JSOP_TOXMLLIST) {
filename = fp->script->filename;
filename = fp->getScript()->filename;
lineno = js_FramePCToLineNumber(cx, fp);
for (endp = srcp + srclen; srcp < endp; srcp++) {
if (*srcp == '\n')

View File

@ -1428,7 +1428,7 @@ ValueToScript(JSContext *cx, jsval v)
script = (JSScript *) JS_GetPrivate(cx, obj);
} else if (clasp == Jsvalify(&js_GeneratorClass)) {
JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj);
fun = gen->getFloatingFrame()->fun;
fun = gen->getFloatingFrame()->getFunction();
script = FUN_SCRIPT(fun);
}
}
@ -1455,7 +1455,7 @@ GetTrapArgs(JSContext *cx, uintN argc, jsval *argv, JSScript **scriptp,
uintN intarg;
JSScript *script;
*scriptp = JS_GetScriptedCaller(cx, NULL)->script;
*scriptp = JS_GetScriptedCaller(cx, NULL)->getScript();
*ip = 0;
if (argc != 0) {
v = argv[0];
@ -1485,7 +1485,8 @@ TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
JSStackFrame *caller = JS_GetScriptedCaller(cx, NULL);
if (!JS_EvaluateUCInStackFrame(cx, caller,
JS_GetStringChars(str), JS_GetStringLength(str),
caller->script->filename, caller->script->lineno,
caller->getScript()->filename,
caller->getScript()->lineno,
rval)) {
return JSTRAP_ERROR;
}
@ -1539,7 +1540,7 @@ LineToPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL, JSSMSG_LINE2PC_USAGE);
return JS_FALSE;
}
script = JS_GetScriptedCaller(cx, NULL)->script;
script = JS_GetScriptedCaller(cx, NULL)->getScript();
if (!GetTrapArgs(cx, argc, argv, &script, &i))
return JS_FALSE;
lineno = (i == 0) ? script->lineno : (uintN)i;
@ -3067,8 +3068,8 @@ EvalInContext(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return false;
}
if (!JS_EvaluateUCScript(cx, sobj, src, srclen,
fp->script->filename,
JS_PCToLineNumber(cx, fp->script, fp->pc(cx)),
fp->getScript()->filename,
JS_PCToLineNumber(cx, fp->getScript(), fp->pc(cx)),
rval)) {
return false;
}
@ -3103,7 +3104,7 @@ EvalInFrame(JSContext *cx, uintN argc, jsval *vp)
}
JSStackFrame *const fp = fi.fp();
if (!fp->script) {
if (!fp->hasScript()) {
JS_ReportError(cx, "cannot eval in non-script frame");
return JS_FALSE;
}
@ -3113,8 +3114,8 @@ EvalInFrame(JSContext *cx, uintN argc, jsval *vp)
oldfp = JS_SaveFrameChain(cx);
JSBool ok = JS_EvaluateUCInStackFrame(cx, fp, str->chars(), str->length(),
fp->script->filename,
JS_PCToLineNumber(cx, fp->script,
fp->getScript()->filename,
JS_PCToLineNumber(cx, fp->getScript(),
fi.pc()),
vp);
@ -3836,9 +3837,9 @@ Snarf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
/* Get the currently executing script's name. */
fp = JS_GetScriptedCaller(cx, NULL);
JS_ASSERT(fp && fp->script->filename);
JS_ASSERT(fp && fp->getScript()->filename);
#ifdef XP_UNIX
pathname = MakeAbsolutePathname(cx, fp->script->filename, filename);
pathname = MakeAbsolutePathname(cx, fp->getScript()->filename, filename);
if (!pathname)
return JS_FALSE;
#else

View File

@ -200,7 +200,7 @@ AllowedToAct(JSContext *cx, jsid id)
// Some code is running, we can't make the assumption, as above, but we
// can't use a native frame, so clear fp.
fp = nsnull;
} else if (!fp->script) {
} else if (!fp->hasScript()) {
fp = nsnull;
}
@ -215,7 +215,7 @@ AllowedToAct(JSContext *cx, jsid id)
// if they've been cloned into less privileged contexts.
const char *filename;
if (fp &&
(filename = fp->script->filename) &&
(filename = fp->getScript()->filename) &&
!strncmp(filename, prefix, NS_ARRAY_LENGTH(prefix) - 1)) {
return JS_TRUE;
}
@ -246,7 +246,7 @@ CheckFilename(JSContext *cx, jsid id, JSStackFrame *fp)
{
const char *filename;
if (fp &&
(filename = fp->script->filename) &&
(filename = fp->getScript()->filename) &&
!strncmp(filename, prefix, NS_ARRAY_LENGTH(prefix) - 1)) {
return JS_TRUE;
}

View File

@ -1309,7 +1309,7 @@ XPCConvert::NativeInterface2JSObject(XPCLazyCallContext& lccx,
JSStackFrame* fp = JS_GetScriptedCaller(cx, NULL);
if(fp)
{
script = fp->script;
script = fp->maybeScript();
callee = fp->callee();
}
}

View File

@ -207,7 +207,7 @@ AccessCheck::isSystemOnlyAccessPermitted(JSContext *cx)
// Some code is running, we can't make the assumption, as above, but we
// can't use a native frame, so clear fp.
fp = NULL;
} else if (!fp->script) {
} else if (!fp->hasScript()) {
fp = NULL;
}
@ -222,7 +222,7 @@ AccessCheck::isSystemOnlyAccessPermitted(JSContext *cx)
static const char prefix[] = "chrome://global/";
const char *filename;
if (fp &&
(filename = fp->script->filename) &&
(filename = fp->getScript()->filename) &&
!strncmp(filename, prefix, NS_ARRAY_LENGTH(prefix) - 1)) {
return true;
}