Bug 1227263 part 1 - Rename frame thisValue methods to thisArgument. r=shu

This commit is contained in:
Jan de Mooij 2015-11-26 12:00:04 +01:00
parent 794a175c80
commit 3f89ce8294
16 changed files with 52 additions and 64 deletions

View File

@ -1720,7 +1720,9 @@ CopyFromRematerializedFrame(JSContext* cx, JitActivation* act, uint8_t* fp, size
MOZ_ASSERT(rematFrame->numActualArgs() == frame->numActualArgs());
frame->setScopeChain(rematFrame->scopeChain());
frame->thisValue() = rematFrame->thisValue();
if (frame->isNonEvalFunctionFrame())
frame->thisArgument() = rematFrame->thisArgument();
for (unsigned i = 0; i < frame->numActualArgs(); i++)
frame->argv()[i] = rematFrame->argv()[i];

View File

@ -32,10 +32,10 @@ BaselineFrame::trace(JSTracer* trc, JitFrameIterator& frameIterator)
{
replaceCalleeToken(MarkCalleeToken(trc, calleeToken()));
TraceRoot(trc, &thisValue(), "baseline-this");
// Mark actual and formal args.
// Mark |this|, actual and formal args.
if (isNonEvalFunctionFrame()) {
TraceRoot(trc, &thisArgument(), "baseline-this");
unsigned numArgs = js::Max(numActualArgs(), numFormalArgs());
TraceRootRange(trc, numArgs + isConstructing(), argv(), "baseline-args");
}

View File

@ -211,7 +211,8 @@ class BaselineFrame
unsigned numFormalArgs() const {
return script()->functionNonDelazifying()->nargs();
}
Value& thisValue() const {
Value& thisArgument() const {
MOZ_ASSERT(isNonEvalFunctionFrame());
return *(Value*)(reinterpret_cast<const uint8_t*>(this) +
BaselineFrame::Size() +
offsetOfThis());

View File

@ -198,7 +198,7 @@ jit::EnterBaselineAtBranch(JSContext* cx, InterpreterFrame* fp, jsbytecode* pc)
data.scopeChain = nullptr;
data.calleeToken = CalleeToToken(&fp->callee(), data.constructing);
} else {
thisv = fp->thisValue();
thisv.setUndefined();
data.constructing = false;
data.numActualArgs = 0;
data.maxArgc = 1;

View File

@ -75,7 +75,8 @@ jit::NewBaselineFrameInspector(TempAllocator* temp, BaselineFrame* frame, Compil
// during compilation could capture nursery pointers, so the values' types
// are recorded instead.
inspector->thisType = TypeSet::GetMaybeUntrackedValueType(frame->thisValue());
if (frame->isNonEvalFunctionFrame())
inspector->thisType = TypeSet::GetMaybeUntrackedValueType(frame->thisArgument());
if (frame->scopeChain()->isSingleton())
inspector->singletonScopeChain = frame->scopeChain();

View File

@ -822,8 +822,7 @@ class InlineFrameIterator
return computeScopeChain(v, fallback);
}
Value thisValue(MaybeReadFallback& fallback) const {
// MOZ_ASSERT(isConstructing(...));
Value thisArgument(MaybeReadFallback& fallback) const {
SnapshotIterator s(si_);
// scopeChain

View File

@ -51,7 +51,7 @@ RematerializedFrame::RematerializedFrame(JSContext* cx, uint8_t* top, unsigned n
CopyValueToRematerializedFrame op(slots_);
iter.readFrameArgsAndLocals(cx, op, op, &scopeChain_, &hasCallObj_, &returnValue_,
&argsObj_, &thisValue_, ReadFrame_Actuals,
&argsObj_, &thisArgument_, ReadFrame_Actuals,
fallback);
}
@ -162,7 +162,7 @@ RematerializedFrame::mark(JSTracer* trc)
if (argsObj_)
TraceRoot(trc, &argsObj_, "remat ion frame argsobj");
TraceRoot(trc, &returnValue_, "remat ion frame return value");
TraceRoot(trc, &thisValue_, "remat ion frame this");
TraceRoot(trc, &thisArgument_, "remat ion frame this");
TraceRootRange(trc, numActualArgs_ + isConstructing_ + script_->nfixed(),
slots_, "remat ion frame stack");
}
@ -207,7 +207,7 @@ RematerializedFrame::dump()
fprintf(stderr, " this: ");
#ifdef DEBUG
DumpValue(thisValue());
DumpValue(thisArgument());
#else
fprintf(stderr, "?\n");
#endif

View File

@ -55,7 +55,7 @@ class RematerializedFrame
ArgumentsObject* argsObj_;
Value returnValue_;
Value thisValue_;
Value thisArgument_;
Value slots_[1];
RematerializedFrame(JSContext* cx, uint8_t* top, unsigned numActualArgs,
@ -169,8 +169,8 @@ class RematerializedFrame
Value calleev() const {
return ObjectValue(*callee());
}
Value& thisValue() {
return thisValue_;
Value& thisArgument() {
return thisArgument_;
}
bool isConstructing() const {

View File

@ -3482,7 +3482,7 @@ js::DumpInterpreterFrame(JSContext* cx, InterpreterFrame* start)
MaybeDumpObject("staticScope", i.script()->getStaticBlockScope(pc));
}
if (i.isNonEvalFunctionFrame())
MaybeDumpValue("this", i.originalFunctionThis(cx));
MaybeDumpValue("this", i.thisArgument(cx));
if (!i.isJit()) {
fprintf(stderr, " rval: ");
dumpValue(i.interpFrame()->returnValue());

View File

@ -48,7 +48,7 @@ GeneratorObject::create(JSContext* cx, AbstractFramePtr frame)
GeneratorObject* genObj = &obj->as<GeneratorObject>();
genObj->setCallee(*frame.callee());
genObj->setThisValue(frame.thisValue());
genObj->setThisValue(frame.thisArgument());
genObj->setNewTarget(frame.newTarget());
genObj->setScopeChain(*frame.scopeChain());
if (frame.script()->needsArgsObj())

View File

@ -141,15 +141,15 @@ js::GetFunctionThis(JSContext* cx, AbstractFramePtr frame, MutableHandleValue re
MOZ_ASSERT(frame.isNonEvalFunctionFrame());
MOZ_ASSERT(!frame.fun()->isArrow());
if (frame.thisValue().isObject() ||
if (frame.thisArgument().isObject() ||
frame.fun()->strict() ||
frame.fun()->isSelfHostedBuiltin())
{
res.set(frame.thisValue());
res.set(frame.thisArgument());
return true;
}
RootedValue thisv(cx, frame.thisValue());
RootedValue thisv(cx, frame.thisArgument());
return BoxNonStrictThis(cx, thisv, res);
}

View File

@ -3111,8 +3111,8 @@ js::GetThisValueForDebuggerMaybeOptimizedOut(JSContext* cx, AbstractFramePtr fra
// If we're still inside `frame`, we can use the this-value passed
// to it, if it does not require boxing.
if (si.withinInitialFrame() && (frame.thisValue().isObject() || script->strict()))
res.set(frame.thisValue());
if (si.withinInitialFrame() && (frame.thisArgument().isObject() || script->strict()))
res.set(frame.thisArgument());
else
res.setMagic(JS_OPTIMIZED_OUT);
return true;

View File

@ -849,13 +849,13 @@ AbstractFramePtr::unsetPrevUpToDate() const
}
inline Value&
AbstractFramePtr::thisValue() const
AbstractFramePtr::thisArgument() const
{
if (isInterpreterFrame())
return asInterpreterFrame()->thisValue();
return asInterpreterFrame()->thisArgument();
if (isBaselineFrame())
return asBaselineFrame()->thisValue();
return asRematerializedFrame()->thisValue();
return asBaselineFrame()->thisArgument();
return asRematerializedFrame()->thisArgument();
}
inline Value

View File

@ -259,15 +259,15 @@ InterpreterFrame::prologue(JSContext* cx)
if (isConstructing()) {
if (script->isDerivedClassConstructor()) {
MOZ_ASSERT(callee().isClassConstructor());
functionThis() = MagicValue(JS_UNINITIALIZED_LEXICAL);
} else if (functionThis().isPrimitive()) {
thisArgument() = MagicValue(JS_UNINITIALIZED_LEXICAL);
} else if (thisArgument().isPrimitive()) {
RootedObject callee(cx, &this->callee());
RootedObject newTarget(cx, &this->newTarget().toObject());
JSObject* obj = CreateThisForFunction(cx, callee, newTarget,
createSingleton() ? SingletonObject : GenericObject);
if (!obj)
return false;
functionThis() = ObjectValue(*obj);
thisArgument() = ObjectValue(*obj);
}
}
@ -316,8 +316,13 @@ InterpreterFrame::epilogue(JSContext* cx)
if (MOZ_UNLIKELY(cx->compartment()->isDebuggee()))
DebugScopes::onPopCall(this, cx);
if (!fun()->isGenerator() && isConstructing() && thisValue().isObject() && returnValue().isPrimitive())
setReturnValue(ObjectValue(constructorThis()));
if (!fun()->isGenerator() &&
isConstructing() &&
thisArgument().isObject() &&
returnValue().isPrimitive())
{
setReturnValue(thisArgument());
}
}
bool
@ -1293,7 +1298,7 @@ FrameIter::argsObj() const
}
Value
FrameIter::originalFunctionThis(JSContext* cx) const
FrameIter::thisArgument(JSContext* cx) const
{
MOZ_ASSERT(isNonEvalFunctionFrame());
@ -1304,11 +1309,11 @@ FrameIter::originalFunctionThis(JSContext* cx) const
case JIT:
if (data_.jitFrames_.isIonScripted()) {
jit::MaybeReadFallback recover(cx, activation()->asJit(), &data_.jitFrames_);
return ionInlineFrames_.thisValue(recover);
return ionInlineFrames_.thisArgument(recover);
}
return data_.jitFrames_.baselineFrame()->thisValue();
return data_.jitFrames_.baselineFrame()->thisArgument();
case INTERP:
return interpFrame()->thisValue();
return interpFrame()->thisArgument();
}
MOZ_CRASH("Unexpected state");
}

View File

@ -216,7 +216,7 @@ class AbstractFramePtr
inline JSFunction* maybeFun() const;
inline JSFunction* callee() const;
inline Value calleev() const;
inline Value& thisValue() const;
inline Value& thisArgument() const;
inline Value newTarget() const;
@ -711,33 +711,13 @@ class InterpreterFrame
}
/*
* This value
*
* Every frame has a this value although, until 'this' is computed, the
* value may not be the semantically-correct 'this' value.
*
* The 'this' value is stored before the formal arguments for function
* frames and directly before the frame for global frames. The *Args
* members assert !isEvalFrame(), so we implement specialized inline
* methods for accessing 'this'. When the caller has static knowledge that
* a frame is a function, 'functionThis' allows more efficient access.
* Return the 'this' argument passed to a non-eval function frame. This is
* not necessarily the frame's this-binding, for instance non-strict
* functions will box primitive 'this' values and thisArgument() will
* return the original, unboxed Value.
*/
Value& functionThis() const {
MOZ_ASSERT(isFunctionFrame());
if (isEvalFrame())
return ((Value*)this)[-1];
return argv()[-1];
}
JSObject& constructorThis() const {
MOZ_ASSERT(hasArgs());
return argv()[-1].toObject();
}
Value& thisValue() const {
if (flags_ & (EVAL | GLOBAL | MODULE))
return ((Value*)this)[-1];
Value& thisArgument() const {
MOZ_ASSERT(isNonEvalFunctionFrame());
return argv()[-1];
}
@ -2006,7 +1986,7 @@ class FrameIter
// actual this-binding (for instance, derived class constructors will
// change their this-value later and non-strict functions will box
// primitives).
Value originalFunctionThis(JSContext* cx) const;
Value thisArgument(JSContext* cx) const;
Value newTarget() const;

View File

@ -3881,7 +3881,7 @@ TypeNewScript::rollbackPartiallyInitializedObjects(JSContext* cx, ObjectGroup* g
// we shouldn't run the definite properties analysis on them.
MOZ_ASSERT(!iter.script()->isDerivedClassConstructor());
Value thisv = iter.originalFunctionThis(cx);
Value thisv = iter.thisArgument(cx);
if (!thisv.isObject() ||
thisv.toObject().hasLazyGroup() ||
thisv.toObject().group() != group)