зеркало из 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;
|
||||||
using namespace js::gc;
|
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
|
static void
|
||||||
CopyStackFrameArguments(const StackFrame *fp, HeapValue *dst)
|
CopyStackFrameArguments(const StackFrame *fp, HeapValue *dst)
|
||||||
{
|
{
|
||||||
JS_ASSERT(!fp->beginsIonActivation());
|
JS_ASSERT(!fp->beginsIonActivation());
|
||||||
|
|
||||||
HeapValue *dstBase = dst;
|
|
||||||
unsigned numActuals = fp->numActualArgs();
|
unsigned numActuals = fp->numActualArgs();
|
||||||
unsigned numFormals = fp->callee().nargs;
|
unsigned numFormals = fp->callee().nargs;
|
||||||
|
|
||||||
|
@ -55,7 +43,6 @@ CopyStackFrameArguments(const StackFrame *fp, HeapValue *dst)
|
||||||
while (src != end)
|
while (src != end)
|
||||||
(dst++)->init(*src++);
|
(dst++)->init(*src++);
|
||||||
}
|
}
|
||||||
SetMissingFormalArgsToUndefined(dstBase, numActuals, numFormals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
|
@ -77,10 +64,6 @@ struct CopyStackFrameArgs
|
||||||
: fp_(fp)
|
: 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 {
|
void copyArgs(HeapValue *dst) const {
|
||||||
CopyStackFrameArguments(fp_, dst);
|
CopyStackFrameArguments(fp_, dst);
|
||||||
}
|
}
|
||||||
|
@ -102,21 +85,23 @@ struct CopyStackIterArgs
|
||||||
: iter_(iter)
|
: iter_(iter)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
inline JSScript *script() const { return iter_.script(); }
|
void copyArgs(HeapValue *dstBase) const {
|
||||||
inline JSFunction *callee() const { return iter_.callee(); }
|
|
||||||
unsigned numActualArgs() const { return iter_.numActualArgs(); }
|
|
||||||
|
|
||||||
void copyArgs(HeapValue *dst) const {
|
|
||||||
if (!iter_.isIon()) {
|
if (!iter_.isIon()) {
|
||||||
CopyStackFrameArguments(iter_.fp(), dst);
|
CopyStackFrameArguments(iter_.fp(), dstBase);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy actual arguments. */
|
||||||
|
iter_.ionForEachCanonicalActualArg(CopyToHeap(dstBase));
|
||||||
|
|
||||||
|
/* Define formals which are not part of the actuals. */
|
||||||
unsigned numActuals = iter_.numActualArgs();
|
unsigned numActuals = iter_.numActualArgs();
|
||||||
unsigned numFormals = iter_.callee()->nargs;
|
unsigned numFormals = iter_.callee()->nargs;
|
||||||
|
if (numActuals < numFormals) {
|
||||||
iter_.ionForEachCanonicalActualArg(CopyToHeap(dst));
|
HeapValue *dst = dstBase + numActuals, *dstEnd = dstBase + numFormals;
|
||||||
SetMissingFormalArgsToUndefined(dst, numActuals, numFormals);
|
while (dst != dstEnd)
|
||||||
|
(dst++)->init(UndefinedValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -131,9 +116,10 @@ struct CopyStackIterArgs
|
||||||
|
|
||||||
template <typename CopyArgs>
|
template <typename CopyArgs>
|
||||||
/* static */ ArgumentsObject *
|
/* 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)
|
if (!proto)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -141,7 +127,7 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
||||||
if (!type)
|
if (!type)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
bool strict = copy.callee()->inStrictMode();
|
bool strict = callee->inStrictMode();
|
||||||
Class *clasp = strict ? &StrictArgumentsObjectClass : &NormalArgumentsObjectClass;
|
Class *clasp = strict ? &StrictArgumentsObjectClass : &NormalArgumentsObjectClass;
|
||||||
|
|
||||||
RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, TaggedProto(proto),
|
RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, TaggedProto(proto),
|
||||||
|
@ -150,8 +136,7 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
||||||
if (!shape)
|
if (!shape)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
unsigned numActuals = copy.numActualArgs();
|
unsigned numFormals = callee->nargs;
|
||||||
unsigned numFormals = copy.callee()->nargs;
|
|
||||||
unsigned numDeletedWords = NumWordsForBitArrayOfLength(numActuals);
|
unsigned numDeletedWords = NumWordsForBitArrayOfLength(numActuals);
|
||||||
unsigned numArgs = Max(numActuals, numFormals);
|
unsigned numArgs = Max(numActuals, numFormals);
|
||||||
unsigned numBytes = offsetof(ArgumentsData, args) +
|
unsigned numBytes = offsetof(ArgumentsData, args) +
|
||||||
|
@ -163,8 +148,8 @@ ArgumentsObject::create(JSContext *cx, HandleScript script, HandleFunction calle
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
data->numArgs = numArgs;
|
data->numArgs = numArgs;
|
||||||
data->callee.init(ObjectValue(*copy.callee()));
|
data->callee.init(ObjectValue(*callee.get()));
|
||||||
data->script = copy.script();
|
data->script = script;
|
||||||
|
|
||||||
/* Copy [0, numArgs) into data->slots. */
|
/* Copy [0, numArgs) into data->slots. */
|
||||||
HeapValue *dst = data->args, *dstEnd = data->args + numArgs;
|
HeapValue *dst = data->args, *dstEnd = data->args + numArgs;
|
||||||
|
@ -195,7 +180,7 @@ ArgumentsObject::createExpected(JSContext *cx, StackFrame *fp)
|
||||||
RootedScript script(cx, fp->script());
|
RootedScript script(cx, fp->script());
|
||||||
RootedFunction callee(cx, &fp->callee());
|
RootedFunction callee(cx, &fp->callee());
|
||||||
CopyStackFrameArgs copy(fp);
|
CopyStackFrameArgs copy(fp);
|
||||||
ArgumentsObject *argsobj = create(cx, script, callee, copy);
|
ArgumentsObject *argsobj = create(cx, script, callee, fp->numActualArgs(), copy);
|
||||||
if (!argsobj)
|
if (!argsobj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -209,7 +194,7 @@ ArgumentsObject::createUnexpected(JSContext *cx, StackIter &iter)
|
||||||
RootedScript script(cx, iter.script());
|
RootedScript script(cx, iter.script());
|
||||||
RootedFunction callee(cx, iter.callee());
|
RootedFunction callee(cx, iter.callee());
|
||||||
CopyStackIterArgs copy(iter);
|
CopyStackIterArgs copy(iter);
|
||||||
return create(cx, script, callee, copy);
|
return create(cx, script, callee, iter.numActualArgs(), copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArgumentsObject *
|
ArgumentsObject *
|
||||||
|
@ -218,7 +203,7 @@ ArgumentsObject::createUnexpected(JSContext *cx, StackFrame *fp)
|
||||||
RootedScript script(cx, fp->script());
|
RootedScript script(cx, fp->script());
|
||||||
RootedFunction callee(cx, &fp->callee());
|
RootedFunction callee(cx, &fp->callee());
|
||||||
CopyStackFrameArgs copy(fp);
|
CopyStackFrameArgs copy(fp);
|
||||||
return create(cx, script, callee, copy);
|
return create(cx, script, callee, fp->numActualArgs(), copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSBool
|
static JSBool
|
||||||
|
|
|
@ -104,8 +104,8 @@ class ArgumentsObject : public JSObject
|
||||||
static const uint32_t PACKED_BITS_COUNT = 1;
|
static const uint32_t PACKED_BITS_COUNT = 1;
|
||||||
|
|
||||||
template <typename CopyArgs>
|
template <typename CopyArgs>
|
||||||
static ArgumentsObject *create(JSContext *cx, HandleScript script,
|
static ArgumentsObject *create(JSContext *cx, HandleScript script, HandleFunction callee,
|
||||||
HandleFunction callee, CopyArgs ©);
|
unsigned numActuals, CopyArgs ©);
|
||||||
|
|
||||||
inline ArgumentsData *data() const;
|
inline ArgumentsData *data() const;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче