зеркало из https://github.com/mozilla/gecko-dev.git
Bug 761510 - rm JSFUN_NULL_CLOSURE (r=jimb)
This commit is contained in:
Родитель
fa008b140e
Коммит
7d3af7da1f
|
@ -4852,9 +4852,6 @@ EmitFunc(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn)
|
|||
return EmitFunctionDefNop(cx, bce, pn->pn_index);
|
||||
}
|
||||
|
||||
JS_ASSERT_IF(pn->pn_funbox->funIsHeavyweight(),
|
||||
fun->kind() == JSFUN_INTERPRETED);
|
||||
|
||||
{
|
||||
FunctionBox *funbox = pn->pn_funbox;
|
||||
SharedContext sc(cx, /* scopeChain = */ NULL, fun, funbox, funbox->strictModeState);
|
||||
|
|
|
@ -56,46 +56,8 @@ SetFunctionKinds(FunctionBox *funbox, bool *isHeavyweight, bool topInFunction, b
|
|||
SetFunctionKinds(funbox->kids, isHeavyweight, topInFunction, isDirectEval);
|
||||
|
||||
JSFunction *fun = funbox->function();
|
||||
|
||||
JS_ASSERT(fun->kind() == JSFUN_INTERPRETED);
|
||||
|
||||
if (funbox->funIsHeavyweight()) {
|
||||
/* nothing to do */
|
||||
} else if (isDirectEval || funbox->inAnyDynamicScope()) {
|
||||
/*
|
||||
* Either we are in a with-block or a function scope that is
|
||||
* subject to direct eval; or we are compiling strict direct eval
|
||||
* code.
|
||||
*
|
||||
* In either case, fun may reference names that are not bound but
|
||||
* are not necessarily global either. (In the strict direct eval
|
||||
* case, we could bind them, but currently do not bother; see
|
||||
* the comment about strict mode code in BindTopLevelVar.)
|
||||
*/
|
||||
JS_ASSERT(!fun->isNullClosure());
|
||||
} else {
|
||||
bool hasUpvars = false;
|
||||
|
||||
if (pn->isKind(PNK_UPVARS)) {
|
||||
AtomDefnMapPtr upvars = pn->pn_names;
|
||||
JS_ASSERT(!upvars->empty());
|
||||
|
||||
/* Determine whether the this function contains upvars. */
|
||||
for (AtomDefnRange r = upvars->all(); !r.empty(); r.popFront()) {
|
||||
if (!r.front().value()->resolve()->isFreeVar()) {
|
||||
hasUpvars = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasUpvars) {
|
||||
/* No lexical dependencies => null closure, for best performance. */
|
||||
fun->setKind(JSFUN_NULL_CLOSURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (fun->kind() == JSFUN_INTERPRETED && pn->isKind(PNK_UPVARS)) {
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
if (pn->isKind(PNK_UPVARS)) {
|
||||
/*
|
||||
* We loop again over all upvars, and for each non-free upvar,
|
||||
* ensure that its containing function has been flagged as
|
||||
|
|
|
@ -387,7 +387,6 @@ js::XDRInterpretedFunction(XDRState<mode> *xdr, HandleObject enclosingScope, Han
|
|||
|
||||
if (mode == XDR_DECODE) {
|
||||
fun->nargs = flagsword >> 16;
|
||||
JS_ASSERT((flagsword & JSFUN_KINDMASK) >= JSFUN_INTERPRETED);
|
||||
fun->flags = uint16_t(flagsword);
|
||||
fun->atom.init(atom);
|
||||
fun->initScript(script);
|
||||
|
@ -1219,8 +1218,8 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, unsigned nargs,
|
|||
|
||||
/* Initialize all function members. */
|
||||
fun->nargs = uint16_t(nargs);
|
||||
fun->flags = flags & (JSFUN_FLAGS_MASK | JSFUN_KINDMASK);
|
||||
if ((flags & JSFUN_KINDMASK) >= JSFUN_INTERPRETED) {
|
||||
fun->flags = flags & (JSFUN_FLAGS_MASK | JSFUN_INTERPRETED);
|
||||
if (flags & JSFUN_INTERPRETED) {
|
||||
JS_ASSERT(!native);
|
||||
fun->mutableScript().init(NULL);
|
||||
fun->initEnvironment(parent);
|
||||
|
|
|
@ -40,9 +40,6 @@
|
|||
#define JSFUN_EXPR_CLOSURE 0x1000 /* expression closure: function(x) x*x */
|
||||
#define JSFUN_EXTENDED 0x2000 /* structure is FunctionExtended */
|
||||
#define JSFUN_INTERPRETED 0x4000 /* use u.i if kind >= this value else u.native */
|
||||
#define JSFUN_NULL_CLOSURE 0x8000 /* null closure entrains no scope chain */
|
||||
#define JSFUN_KINDMASK 0xc000 /* encode interp vs. native and closure
|
||||
optimization level -- see above */
|
||||
|
||||
namespace js { class FunctionExtended; }
|
||||
|
||||
|
@ -65,21 +62,14 @@ struct JSFunction : public JSObject
|
|||
|
||||
bool hasDefaults() const { return flags & JSFUN_HAS_DEFAULTS; }
|
||||
bool hasRest() const { return flags & JSFUN_HAS_REST; }
|
||||
bool isInterpreted() const { return kind() >= JSFUN_INTERPRETED; }
|
||||
bool isInterpreted() const { return flags & JSFUN_INTERPRETED; }
|
||||
bool isNative() const { return !isInterpreted(); }
|
||||
bool isNativeConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
|
||||
bool isHeavyweight() const { return JSFUN_HEAVYWEIGHT_TEST(flags); }
|
||||
bool isNullClosure() const { return kind() == JSFUN_NULL_CLOSURE; }
|
||||
bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; }
|
||||
bool isInterpretedConstructor() const { return isInterpreted() && !isFunctionPrototype(); }
|
||||
bool isNamedLambda() const { return (flags & JSFUN_LAMBDA) && atom; }
|
||||
|
||||
uint16_t kind() const { return flags & JSFUN_KINDMASK; }
|
||||
void setKind(uint16_t k) {
|
||||
JS_ASSERT(!(k & ~JSFUN_KINDMASK));
|
||||
flags = (flags & ~JSFUN_KINDMASK) | k;
|
||||
}
|
||||
|
||||
/* Returns the strictness of this function, which must be interpreted. */
|
||||
inline bool inStrictMode() const;
|
||||
|
||||
|
|
|
@ -4243,8 +4243,8 @@ mjit::Compiler::inlineCallHelper(uint32_t argc, bool callingNew, FrameSize &call
|
|||
|
||||
/* Test if the function is scripted. */
|
||||
stubcc.masm.load16(Address(icCalleeData, offsetof(JSFunction, flags)), tmp);
|
||||
stubcc.masm.and32(Imm32(JSFUN_KINDMASK), tmp);
|
||||
Jump isNative = stubcc.masm.branch32(Assembler::Below, tmp, Imm32(JSFUN_INTERPRETED));
|
||||
Jump isNative = stubcc.masm.branchTest32(Assembler::Zero, tmp,
|
||||
Imm32(JSFUN_INTERPRETED));
|
||||
tempRegs.putReg(tmp);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1727,9 +1727,6 @@ DisassembleScript(JSContext *cx, JSScript *script_, JSFunction *fun, bool lines,
|
|||
|
||||
#undef SHOW_FLAG
|
||||
|
||||
if (fun->isNullClosure())
|
||||
Sprint(sp, " NULL_CLOSURE");
|
||||
|
||||
Sprint(sp, "\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace js {
|
|||
* and saved versions. If deserialization fails, the data should be
|
||||
* invalidated if possible.
|
||||
*/
|
||||
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 120);
|
||||
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 121);
|
||||
|
||||
class XDRBuffer {
|
||||
public:
|
||||
|
|
Загрузка…
Ссылка в новой задаче