зеркало из https://github.com/mozilla/gecko-dev.git
Bug 770421 - tidy CallObject::getCalleeFunction() (r=njn)
This commit is contained in:
Родитель
0a825398c9
Коммит
44034475aa
|
@ -3229,7 +3229,7 @@ ScriptAnalysis::resolveNameAccess(JSContext *cx, jsid id, bool addDependency)
|
|||
* don't resolve name accesses on lambdas in DeclEnv objects on the
|
||||
* scope chain.
|
||||
*/
|
||||
if (atom == CallObjectLambdaName(script->function()))
|
||||
if (atom == CallObjectLambdaName(*script->function()))
|
||||
return access;
|
||||
|
||||
if (!script->nesting()->parent)
|
||||
|
@ -5022,7 +5022,7 @@ TypeScript::SetScope(JSContext *cx, JSScript *script_, JSObject *scope_)
|
|||
* object has been created in the heavyweight case.
|
||||
*/
|
||||
JS_ASSERT_IF(scope && scope->isCall() && !scope->asCall().isForEval(),
|
||||
scope->asCall().getCalleeFunction() != fun);
|
||||
&scope->asCall().callee() != fun);
|
||||
|
||||
if (!script->compileAndGo) {
|
||||
script->types->global = NULL;
|
||||
|
@ -5069,7 +5069,7 @@ TypeScript::SetScope(JSContext *cx, JSScript *script_, JSObject *scope_)
|
|||
JS_ASSERT(!call.isForEval());
|
||||
|
||||
/* Don't track non-heavyweight parents, NAME ops won't reach into them. */
|
||||
JSFunction *parentFun = call.getCalleeFunction();
|
||||
JSFunction *parentFun = &call.callee();
|
||||
if (!parentFun || !parentFun->isHeavyweight())
|
||||
return true;
|
||||
JSScript *parent = parentFun->script();
|
||||
|
@ -5188,7 +5188,7 @@ CheckNestingParent(JSContext *cx, JSObject *scope, JSScript *script)
|
|||
JSScript *parent = script->nesting()->parent;
|
||||
JS_ASSERT(parent);
|
||||
|
||||
while (!scope->isCall() || scope->asCall().getCalleeFunction()->script() != parent)
|
||||
while (!scope->isCall() || scope->asCall().callee().script() != parent)
|
||||
scope = &scope->asScope().enclosingScope();
|
||||
|
||||
if (scope != parent->nesting()->activeCall) {
|
||||
|
|
|
@ -540,9 +540,9 @@ namespace js {
|
|||
* scope chain above call objects for fun.
|
||||
*/
|
||||
static inline JSAtom *
|
||||
CallObjectLambdaName(JSFunction *fun)
|
||||
CallObjectLambdaName(JSFunction &fun)
|
||||
{
|
||||
return (fun->flags & JSFUN_LAMBDA) ? fun->atom.get() : NULL;
|
||||
return (fun.flags & JSFUN_LAMBDA) ? fun.atom.get() : NULL;
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
|
|
@ -235,9 +235,6 @@ class Bindings
|
|||
|
||||
} /* namespace js */
|
||||
|
||||
#define JS_OBJECT_ARRAY_SIZE(length) \
|
||||
(offsetof(ObjectArray, vector) + sizeof(JSObject *) * (length))
|
||||
|
||||
#ifdef JS_METHODJIT
|
||||
namespace JSC {
|
||||
class ExecutablePool;
|
||||
|
|
|
@ -349,10 +349,10 @@ class SetPropCompiler : public PICStubCompiler
|
|||
// \\ V and getters, and
|
||||
// \===/ 2. arguments and locals have different getters
|
||||
// then we can rely on fun->nargs remaining invariant.
|
||||
JSFunction *fun = obj->asCall().getCalleeFunction();
|
||||
JSFunction &fun = obj->asCall().callee();
|
||||
uint16_t slot = uint16_t(shape->shortid());
|
||||
if (shape->setterOp() == CallObject::setVarOp)
|
||||
slot += fun->nargs;
|
||||
slot += fun.nargs;
|
||||
slot += CallObject::RESERVED_SLOTS;
|
||||
Address address = masm.objPropAddress(obj, pic.objReg, slot);
|
||||
masm.storeValue(pic.u.vr, address);
|
||||
|
@ -603,8 +603,8 @@ class SetPropCompiler : public PICStubCompiler
|
|||
* objects may differ due to eval(), DEFFUN, etc.).
|
||||
*/
|
||||
RecompilationMonitor monitor(cx);
|
||||
JSFunction *fun = obj->asCall().getCalleeFunction();
|
||||
JSScript *script = fun->script();
|
||||
JSFunction &fun = obj->asCall().callee();
|
||||
JSScript *script = fun.script();
|
||||
uint16_t slot = uint16_t(shape->shortid());
|
||||
if (!script->ensureHasTypes(cx))
|
||||
return error();
|
||||
|
@ -1583,10 +1583,10 @@ class ScopeNameCompiler : public PICStubCompiler
|
|||
Jump finalShape = masm.branchPtr(Assembler::NotEqual, pic.shapeReg,
|
||||
ImmPtr(getprop.holder->lastProperty()));
|
||||
|
||||
JSFunction *fun = getprop.holder->asCall().getCalleeFunction();
|
||||
JSFunction &fun = getprop.holder->asCall().callee();
|
||||
unsigned slot = shape->shortid();
|
||||
if (kind == VAR)
|
||||
slot += fun->nargs;
|
||||
slot += fun.nargs;
|
||||
slot += CallObject::RESERVED_SLOTS;
|
||||
Address address = masm.objPropAddress(obj, pic.objReg, slot);
|
||||
|
||||
|
|
|
@ -4354,11 +4354,11 @@ DebuggerEnv_getCallee(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!scope.isCall())
|
||||
return true;
|
||||
|
||||
JSObject *callee = scope.asCall().getCallee();
|
||||
if (!callee)
|
||||
CallObject &callobj = scope.asCall();
|
||||
if (callobj.isForEval())
|
||||
return true;
|
||||
|
||||
args.rval() = ObjectValue(*callee);
|
||||
args.rval() = ObjectValue(callobj.callee());
|
||||
if (!dbg->wrapDebuggeeValue(cx, &args.rval()))
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
@ -65,70 +65,57 @@ CallObject::isForEval() const
|
|||
return getReservedSlot(CALLEE_SLOT).isNull();
|
||||
}
|
||||
|
||||
inline void
|
||||
CallObject::setCallee(JSObject *callee)
|
||||
inline JSFunction &
|
||||
CallObject::callee() const
|
||||
{
|
||||
JS_ASSERT_IF(callee, callee->isFunction());
|
||||
setFixedSlot(CALLEE_SLOT, ObjectOrNullValue(callee));
|
||||
}
|
||||
|
||||
inline JSObject *
|
||||
CallObject::getCallee() const
|
||||
{
|
||||
return getReservedSlot(CALLEE_SLOT).toObjectOrNull();
|
||||
}
|
||||
|
||||
inline JSFunction *
|
||||
CallObject::getCalleeFunction() const
|
||||
{
|
||||
return getReservedSlot(CALLEE_SLOT).toObject().toFunction();
|
||||
return *getReservedSlot(CALLEE_SLOT).toObject().toFunction();
|
||||
}
|
||||
|
||||
inline const Value &
|
||||
CallObject::arg(unsigned i, MaybeCheckAliasing checkAliasing) const
|
||||
{
|
||||
JS_ASSERT_IF(checkAliasing, getCalleeFunction()->script()->formalLivesInCallObject(i));
|
||||
JS_ASSERT_IF(checkAliasing, callee().script()->formalLivesInCallObject(i));
|
||||
return getSlot(RESERVED_SLOTS + i);
|
||||
}
|
||||
|
||||
inline void
|
||||
CallObject::setArg(unsigned i, const Value &v, MaybeCheckAliasing checkAliasing)
|
||||
{
|
||||
JS_ASSERT_IF(checkAliasing, getCalleeFunction()->script()->formalLivesInCallObject(i));
|
||||
JS_ASSERT_IF(checkAliasing, callee().script()->formalLivesInCallObject(i));
|
||||
setSlot(RESERVED_SLOTS + i, v);
|
||||
}
|
||||
|
||||
inline const Value &
|
||||
CallObject::var(unsigned i, MaybeCheckAliasing checkAliasing) const
|
||||
{
|
||||
JSFunction *fun = getCalleeFunction();
|
||||
JS_ASSERT_IF(checkAliasing, fun->script()->varIsAliased(i));
|
||||
return getSlot(RESERVED_SLOTS + fun->nargs + i);
|
||||
JSFunction &fun = callee();
|
||||
JS_ASSERT_IF(checkAliasing, fun.script()->varIsAliased(i));
|
||||
return getSlot(RESERVED_SLOTS + fun.nargs + i);
|
||||
}
|
||||
|
||||
inline void
|
||||
CallObject::setVar(unsigned i, const Value &v, MaybeCheckAliasing checkAliasing)
|
||||
{
|
||||
JSFunction *fun = getCalleeFunction();
|
||||
JS_ASSERT_IF(checkAliasing, fun->script()->varIsAliased(i));
|
||||
setSlot(RESERVED_SLOTS + fun->nargs + i, v);
|
||||
JSFunction &fun = callee();
|
||||
JS_ASSERT_IF(checkAliasing, fun.script()->varIsAliased(i));
|
||||
setSlot(RESERVED_SLOTS + fun.nargs + i, v);
|
||||
}
|
||||
|
||||
inline HeapSlotArray
|
||||
CallObject::argArray()
|
||||
{
|
||||
DebugOnly<JSFunction*> fun = getCalleeFunction();
|
||||
JS_ASSERT(hasContiguousSlots(RESERVED_SLOTS, fun->nargs));
|
||||
JSFunction &fun = callee();
|
||||
JS_ASSERT(hasContiguousSlots(RESERVED_SLOTS, fun.nargs));
|
||||
return HeapSlotArray(getSlotAddress(RESERVED_SLOTS));
|
||||
}
|
||||
|
||||
inline HeapSlotArray
|
||||
CallObject::varArray()
|
||||
{
|
||||
JSFunction *fun = getCalleeFunction();
|
||||
JS_ASSERT(hasContiguousSlots(RESERVED_SLOTS + fun->nargs,
|
||||
fun->script()->bindings.numVars()));
|
||||
return HeapSlotArray(getSlotAddress(RESERVED_SLOTS + fun->nargs));
|
||||
JSFunction &fun = callee();
|
||||
JS_ASSERT(hasContiguousSlots(RESERVED_SLOTS + fun.nargs,
|
||||
fun.script()->bindings.numVars()));
|
||||
return HeapSlotArray(getSlotAddress(RESERVED_SLOTS + fun.nargs));
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
|
|
|
@ -184,7 +184,7 @@ CallObject::createForFunction(JSContext *cx, StackFrame *fp)
|
|||
void
|
||||
CallObject::copyUnaliasedValues(StackFrame *fp)
|
||||
{
|
||||
JS_ASSERT(fp->script() == getCalleeFunction()->script());
|
||||
JS_ASSERT(fp->script() == callee().script());
|
||||
JSScript *script = fp->script();
|
||||
|
||||
/* If bindings are accessed dynamically, everything is aliased. */
|
||||
|
@ -227,7 +227,7 @@ CallObject::setArgOp(JSContext *cx, HandleObject obj, HandleId id, JSBool strict
|
|||
JS_ASSERT((int16_t) JSID_TO_INT(id) == JSID_TO_INT(id));
|
||||
unsigned i = (uint16_t) JSID_TO_INT(id);
|
||||
|
||||
JSScript *script = callobj.getCalleeFunction()->script();
|
||||
JSScript *script = callobj.callee().script();
|
||||
JS_ASSERT(script->formalLivesInCallObject(i));
|
||||
|
||||
callobj.setArg(i, *vp);
|
||||
|
@ -247,7 +247,7 @@ CallObject::setVarOp(JSContext *cx, HandleObject obj, HandleId id, JSBool strict
|
|||
JS_ASSERT((int16_t) JSID_TO_INT(id) == JSID_TO_INT(id));
|
||||
unsigned i = (uint16_t) JSID_TO_INT(id);
|
||||
|
||||
JSScript *script = callobj.getCalleeFunction()->script();
|
||||
JSScript *script = callobj.callee().script();
|
||||
JS_ASSERT(script->varIsAliased(i));
|
||||
|
||||
callobj.setVar(i, *vp);
|
||||
|
@ -984,7 +984,7 @@ ScopeIter::operator++()
|
|||
case Call:
|
||||
if (hasScopeObject_) {
|
||||
cur_ = &cur_->asCall().enclosingScope();
|
||||
if (CallObjectLambdaName(fp_->fun()))
|
||||
if (CallObjectLambdaName(*fp_->fun()))
|
||||
cur_ = &cur_->asDeclEnv().enclosingScope();
|
||||
}
|
||||
fp_ = NULL;
|
||||
|
@ -1071,7 +1071,7 @@ ScopeIter::settle()
|
|||
CallObject &callobj = cur_->asCall();
|
||||
type_ = callobj.isForEval() ? StrictEvalScope : Call;
|
||||
hasScopeObject_ = true;
|
||||
JS_ASSERT_IF(type_ == Call, callobj.getCalleeFunction()->script() == fp_->script());
|
||||
JS_ASSERT_IF(type_ == Call, callobj.callee().script() == fp_->script());
|
||||
} else {
|
||||
JS_ASSERT(!cur_->isScope());
|
||||
JS_ASSERT(fp_->isGlobalFrame() || fp_->isDebuggerFrame());
|
||||
|
@ -1142,7 +1142,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
|
||||
if (scope.isCall() && !scope.asCall().isForEval()) {
|
||||
CallObject &callobj = scope.asCall();
|
||||
JSScript *script = callobj.getCalleeFunction()->script();
|
||||
JSScript *script = callobj.callee().script();
|
||||
if (!script->ensureHasTypes(cx))
|
||||
return false;
|
||||
|
||||
|
@ -1249,7 +1249,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
static bool isMissingArgumentsBinding(ScopeObject &scope)
|
||||
{
|
||||
return isFunctionScope(scope) &&
|
||||
!scope.asCall().getCalleeFunction()->script()->argumentsHasVarBinding();
|
||||
!scope.asCall().callee().script()->argumentsHasVarBinding();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1266,7 +1266,7 @@ class DebugScopeProxy : public BaseProxyHandler
|
|||
if (!isArguments(cx, id) || !isFunctionScope(scope))
|
||||
return true;
|
||||
|
||||
JSScript *script = scope.asCall().getCalleeFunction()->script();
|
||||
JSScript *script = scope.asCall().callee().script();
|
||||
if (script->needsArgsObj())
|
||||
return true;
|
||||
|
||||
|
@ -1788,7 +1788,7 @@ GetDebugScopeForScope(JSContext *cx, ScopeObject &scope, const ScopeIter &enclos
|
|||
|
||||
JSObject &maybeDecl = scope.enclosingScope();
|
||||
if (maybeDecl.isDeclEnv()) {
|
||||
JS_ASSERT(CallObjectLambdaName(scope.asCall().getCalleeFunction()));
|
||||
JS_ASSERT(CallObjectLambdaName(scope.asCall().callee()));
|
||||
enclosingDebug = DebugScopeObject::create(cx, maybeDecl.asDeclEnv(), enclosingDebug);
|
||||
if (!enclosingDebug)
|
||||
return NULL;
|
||||
|
@ -1830,7 +1830,7 @@ GetDebugScopeForMissing(JSContext *cx, const ScopeIter &si)
|
|||
return NULL;
|
||||
|
||||
if (callobj->enclosingScope().isDeclEnv()) {
|
||||
JS_ASSERT(CallObjectLambdaName(callobj->getCalleeFunction()));
|
||||
JS_ASSERT(CallObjectLambdaName(callobj->callee()));
|
||||
DeclEnvObject &declenv = callobj->enclosingScope().asDeclEnv();
|
||||
enclosingDebug = DebugScopeObject::create(cx, declenv, enclosingDebug);
|
||||
if (!enclosingDebug)
|
||||
|
|
|
@ -135,16 +135,14 @@ class CallObject : public ScopeObject
|
|||
static CallObject *createForFunction(JSContext *cx, StackFrame *fp);
|
||||
static CallObject *createForStrictEval(JSContext *cx, StackFrame *fp);
|
||||
|
||||
/* True if this is for a strict mode eval frame or for a function call. */
|
||||
/* True if this is for a strict mode eval frame. */
|
||||
inline bool isForEval() const;
|
||||
|
||||
/*
|
||||
* The callee function if this CallObject was created for a function
|
||||
* invocation, or null if it was created for a strict mode eval frame.
|
||||
* Returns the function for which this CallObject was created. (This may
|
||||
* only be called if !isForEval.)
|
||||
*/
|
||||
inline JSObject *getCallee() const;
|
||||
inline JSFunction *getCalleeFunction() const;
|
||||
inline void setCallee(JSObject *callee);
|
||||
inline JSFunction &callee() const;
|
||||
|
||||
/* Returns the formal argument at the given index. */
|
||||
inline const Value &arg(unsigned i, MaybeCheckAliasing = CHECK_ALIASING) const;
|
||||
|
|
|
@ -300,11 +300,10 @@ StackFrame::epilogue(JSContext *cx)
|
|||
|
||||
JS_ASSERT(isNonEvalFunctionFrame());
|
||||
if (fun()->isHeavyweight()) {
|
||||
JS_ASSERT_IF(hasCallObj(),
|
||||
scopeChain()->asCall().getCalleeFunction()->script() == script());
|
||||
JS_ASSERT_IF(hasCallObj(), scopeChain()->asCall().callee().script() == script());
|
||||
} else {
|
||||
JS_ASSERT(!scopeChain()->isCall() || scopeChain()->asCall().isForEval() ||
|
||||
scopeChain()->asCall().getCalleeFunction()->script() != script());
|
||||
scopeChain()->asCall().callee().script() != script());
|
||||
}
|
||||
|
||||
if (cx->compartment->debugMode())
|
||||
|
|
Загрузка…
Ссылка в новой задаче