зеркало из https://github.com/mozilla/gecko-dev.git
Address bug 697537 review comments, r=luke.
This commit is contained in:
Родитель
762b6d8315
Коммит
8ef7dce877
|
@ -5460,7 +5460,12 @@ EmitWith(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
|||
static bool
|
||||
SetMethodFunction(JSContext *cx, FunctionBox *funbox, JSAtom *atom)
|
||||
{
|
||||
/* Replace a boxed function with a new one with a method atom. */
|
||||
/*
|
||||
* Replace a boxed function with a new one with a method atom. Methods
|
||||
* require a function with the extended size finalize kind, which normal
|
||||
* functions don't have. We don't eagerly allocate functions with the
|
||||
* expanded size for boxed functions, as most functions are not methods.
|
||||
*/
|
||||
JSFunction *fun = js_NewFunction(cx, NULL, NULL,
|
||||
funbox->function()->nargs,
|
||||
funbox->function()->flags,
|
||||
|
@ -5472,8 +5477,8 @@ SetMethodFunction(JSContext *cx, FunctionBox *funbox, JSAtom *atom)
|
|||
|
||||
JSScript *script = funbox->function()->script();
|
||||
if (script) {
|
||||
fun->setScript(funbox->function()->script());
|
||||
if (!fun->script()->typeSetFunction(cx, fun))
|
||||
fun->setScript(script);
|
||||
if (!script->typeSetFunction(cx, fun))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1604,13 +1604,12 @@ inline void
|
|||
JSFunction::trace(JSTracer *trc)
|
||||
{
|
||||
if (isFlatClosure() && hasFlatClosureUpvars()) {
|
||||
HeapValue *upvars = getFlatClosureUpvars();
|
||||
if (upvars)
|
||||
if (HeapValue *upvars = getFlatClosureUpvars())
|
||||
MarkValueRange(trc, script()->bindings.countUpvars(), upvars, "upvars");
|
||||
}
|
||||
|
||||
if (isExtended()) {
|
||||
MarkValueRange(trc, JS_ARRAY_LENGTH(toExtended()->extendedSlots),
|
||||
MarkValueRange(trc, ArrayLength(toExtended()->extendedSlots),
|
||||
toExtended()->extendedSlots, "nativeReserved");
|
||||
}
|
||||
|
||||
|
@ -2281,6 +2280,10 @@ JSFunction *
|
|||
js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs,
|
||||
uintN flags, JSObject *parent, JSAtom *atom, js::gc::AllocKind kind)
|
||||
{
|
||||
JS_ASSERT(kind == JSFunction::FinalizeKind || kind == JSFunction::ExtendedFinalizeKind);
|
||||
JS_ASSERT(sizeof(JSFunction) <= gc::Arena::thingSize(JSFunction::FinalizeKind));
|
||||
JS_ASSERT(sizeof(FunctionExtended) <= gc::Arena::thingSize(JSFunction::ExtendedFinalizeKind));
|
||||
|
||||
JSFunction *fun;
|
||||
|
||||
if (funobj) {
|
||||
|
|
|
@ -70,7 +70,7 @@ JSFunction::initializeExtended()
|
|||
{
|
||||
JS_ASSERT(isExtended());
|
||||
|
||||
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(toExtended()->extendedSlots) == 2);
|
||||
JS_ASSERT(js::ArrayLength(toExtended()->extendedSlots) == 2);
|
||||
toExtended()->extendedSlots[0].init(js::UndefinedValue());
|
||||
toExtended()->extendedSlots[1].init(js::UndefinedValue());
|
||||
}
|
||||
|
@ -120,14 +120,14 @@ JSFunction::setMethodObj(JSObject& obj)
|
|||
inline void
|
||||
JSFunction::setExtendedSlot(size_t which, const js::Value &val)
|
||||
{
|
||||
JS_ASSERT(which < JS_ARRAY_LENGTH(toExtended()->extendedSlots));
|
||||
JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
|
||||
toExtended()->extendedSlots[which] = val;
|
||||
}
|
||||
|
||||
inline const js::Value &
|
||||
JSFunction::getExtendedSlot(size_t which) const
|
||||
{
|
||||
JS_ASSERT(which < JS_ARRAY_LENGTH(toExtended()->extendedSlots));
|
||||
JS_ASSERT(which < js::ArrayLength(toExtended()->extendedSlots));
|
||||
return toExtended()->extendedSlots[which];
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче