зеркало из https://github.com/mozilla/gecko-dev.git
Bug 798834 - Remove reset of non-actual arguments for StackFrame. r=luke a=bajaj
This commit is contained in:
Родитель
15a84656c8
Коммит
249a050eab
|
@ -0,0 +1,5 @@
|
|||
(function(start, stop, step) {
|
||||
stop = start;
|
||||
step = arguments[2];
|
||||
assertEq(stop, true);
|
||||
})(true);
|
|
@ -22,23 +22,11 @@
|
|||
using namespace js;
|
||||
using namespace js::gc;
|
||||
|
||||
/* Erase formals which are not part of the actuals. */
|
||||
static void
|
||||
SetMissingFormalArgsToUndefined(HeapValue *dstBase, unsigned numActuals, unsigned numFormals)
|
||||
{
|
||||
if (numActuals < numFormals) {
|
||||
HeapValue *dst = dstBase + numActuals, *dstEnd = dstBase + numFormals;
|
||||
while (dst != dstEnd)
|
||||
(dst++)->init(UndefinedValue());
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
CopyStackFrameArguments(const StackFrame *fp, HeapValue *dst)
|
||||
{
|
||||
JS_ASSERT(!fp->beginsIonActivation());
|
||||
|
||||
HeapValue *dstBase = dst;
|
||||
unsigned numActuals = fp->numActualArgs();
|
||||
unsigned numFormals = fp->callee().nargs;
|
||||
|
||||
|
@ -55,7 +43,6 @@ CopyStackFrameArguments(const StackFrame *fp, HeapValue *dst)
|
|||
while (src != end)
|
||||
(dst++)->init(*src++);
|
||||
}
|
||||
SetMissingFormalArgsToUndefined(dstBase, numActuals, numFormals);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
|
@ -77,10 +64,6 @@ struct CopyStackFrameArgs
|
|||
: fp_(fp)
|
||||
{ }
|
||||
|
||||
inline JSScript *script() const { return fp_->script(); }
|
||||
inline JSFunction *callee() const { return &fp_->callee(); }
|
||||
unsigned numActualArgs() const { return fp_->numActualArgs(); }
|
||||
|
||||
void copyArgs(HeapValue *dst) const {
|
||||
CopyStackFrameArguments(fp_, dst);
|
||||
}
|
||||
|
@ -102,21 +85,23 @@ struct CopyStackIterArgs
|
|||
: iter_(iter)
|
||||
{ }
|
||||
|
||||
inline JSScript *script() const { return iter_.script(); }
|
||||
inline JSFunction *callee() const { return iter_.callee(); }
|
||||
unsigned numActualArgs() const { return iter_.numActualArgs(); }
|
||||
|
||||
void copyArgs(HeapValue *dst) const {
|
||||
void copyArgs(HeapValue *dstBase) const {
|
||||
if (!iter_.isIon()) {
|
||||
CopyStackFrameArguments(iter_.fp(), dst);
|
||||
CopyStackFrameArguments(iter_.fp(), dstBase);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy actual arguments. */
|
||||
iter_.ionForEachCanonicalActualArg(CopyToHeap(dstBase));
|
||||
|
||||
/* Define formals which are not part of the actuals. */
|
||||
unsigned numActuals = iter_.numActualArgs();
|
||||
unsigned numFormals = iter_.callee()->nargs;
|
||||
|
||||
iter_.ionForEachCanonicalActualArg(CopyToHeap(dst));
|
||||
SetMissingFormalArgsToUndefined(dst, numActuals, numFormals);
|
||||
if (numActuals < numFormals) {
|
||||
HeapValue *dst = dstBase + numActuals, *dstEnd = dstBase + numFormals;
|
||||
while (dst != dstEnd)
|
||||
(dst++)->init(UndefinedValue());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -131,9 +116,10 @@ struct CopyStackIterArgs
|
|||
|
||||
template <typename CopyArgs>
|
||||
/* static */ ArgumentsObject *
|
||||
ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction callee, CopyArgs ©)
|
||||
ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction callee, unsigned numActuals,
|
||||
CopyArgs ©)
|
||||
{
|
||||
RootedObject proto(cx, copy.callee()->global().getOrCreateObjectPrototype(cx));
|
||||
RootedObject proto(cx, callee->global().getOrCreateObjectPrototype(cx));
|
||||
if (!proto)
|
||||
return NULL;
|
||||
|
||||
|
@ -141,7 +127,7 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
|||
if (!type)
|
||||
return NULL;
|
||||
|
||||
bool strict = copy.callee()->inStrictMode();
|
||||
bool strict = callee->inStrictMode();
|
||||
Class *clasp = strict ? &StrictArgumentsObjectClass : &NormalArgumentsObjectClass;
|
||||
|
||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, TaggedProto(proto),
|
||||
|
@ -150,8 +136,7 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
|||
if (!shape)
|
||||
return NULL;
|
||||
|
||||
unsigned numActuals = copy.numActualArgs();
|
||||
unsigned numFormals = copy.callee()->nargs;
|
||||
unsigned numFormals = callee->nargs;
|
||||
unsigned numDeletedWords = NumWordsForBitArrayOfLength(numActuals);
|
||||
unsigned numArgs = Max(numActuals, numFormals);
|
||||
unsigned numBytes = offsetof(ArgumentsData, args) +
|
||||
|
@ -163,8 +148,8 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
|||
return NULL;
|
||||
|
||||
data->numArgs = numArgs;
|
||||
data->callee.init(ObjectValue(*copy.callee()));
|
||||
data->script = copy.script();
|
||||
data->callee.init(ObjectValue(*callee.get()));
|
||||
data->script = script;
|
||||
|
||||
/* Copy [0, numArgs) into data->slots. */
|
||||
HeapValue *dst = data->args, *dstEnd = data->args + numArgs;
|
||||
|
@ -195,7 +180,7 @@ ArgumentsObject::createExpected(JSContext *cx, StackFrame *fp)
|
|||
RootedScript script(cx, fp->script());
|
||||
RootedFunction callee(cx, &fp->callee());
|
||||
CopyStackFrameArgs copy(fp);
|
||||
ArgumentsObject *argsobj = create(cx, script, callee, copy);
|
||||
ArgumentsObject *argsobj = create(cx, script, callee, fp->numActualArgs(), copy);
|
||||
if (!argsobj)
|
||||
return NULL;
|
||||
|
||||
|
@ -209,7 +194,7 @@ ArgumentsObject::createUnexpected(JSContext *cx, StackIter &iter)
|
|||
RootedScript script(cx, iter.script());
|
||||
RootedFunction callee(cx, iter.callee());
|
||||
CopyStackIterArgs copy(iter);
|
||||
return create(cx, script, callee, copy);
|
||||
return create(cx, script, callee, iter.numActualArgs(), copy);
|
||||
}
|
||||
|
||||
ArgumentsObject *
|
||||
|
@ -218,7 +203,7 @@ ArgumentsObject::createUnexpected(JSContext *cx, StackFrame *fp)
|
|||
RootedScript script(cx, fp->script());
|
||||
RootedFunction callee(cx, &fp->callee());
|
||||
CopyStackFrameArgs copy(fp);
|
||||
return create(cx, script, callee, copy);
|
||||
return create(cx, script, callee, fp->numActualArgs(), copy);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
|
|
|
@ -104,8 +104,8 @@ class ArgumentsObject : public JSObject
|
|||
static const uint32_t PACKED_BITS_COUNT = 1;
|
||||
|
||||
template <typename CopyArgs>
|
||||
static ArgumentsObject *create(JSContext *cx, HandleScript script,
|
||||
HandleFunction callee, CopyArgs ©);
|
||||
static ArgumentsObject *create(JSContext *cx, HandleScript script, HandleFunction callee,
|
||||
unsigned numActuals, CopyArgs ©);
|
||||
|
||||
inline ArgumentsData *data() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче