mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 679879 - Change JSFunction macros to methods. Part 2, js/src changes. r=Waldo.
This commit is contained in:
parent
eea79c5c02
commit
4235dced5c
@ -26,7 +26,7 @@ BEGIN_TEST(testLookup_bug522590)
|
||||
JSObject *funobj = JSVAL_TO_OBJECT(r);
|
||||
CHECK(funobj->isFunction());
|
||||
CHECK(!js::IsInternalFunctionObject(funobj));
|
||||
CHECK(GET_FUNCTION_PRIVATE(cx, funobj) != (JSFunction *) funobj);
|
||||
CHECK(funobj->getFunctionPrivate() != (JSFunction *) funobj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv, const char *format
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
*sp = OBJECT_TO_JSVAL(obj);
|
||||
*va_arg(ap, JSFunction **) = GET_FUNCTION_PRIVATE(cx, obj);
|
||||
*va_arg(ap, JSFunction **) = obj->getFunctionPrivate();
|
||||
break;
|
||||
case 'v':
|
||||
*va_arg(ap, jsval *) = *sp;
|
||||
@ -2270,10 +2270,10 @@ JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, ui
|
||||
JSObject *obj = (JSObject *)thing;
|
||||
Class *clasp = obj->getClass();
|
||||
if (clasp == &js_FunctionClass) {
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(trc->context, obj);
|
||||
JSFunction *fun = obj->getFunctionPrivate();
|
||||
if (!fun) {
|
||||
JS_snprintf(buf, bufsize, "<newborn>");
|
||||
} else if (FUN_OBJECT(fun) != obj) {
|
||||
} else if (fun != obj) {
|
||||
JS_snprintf(buf, bufsize, "%p", fun);
|
||||
} else {
|
||||
if (fun->atom)
|
||||
@ -4208,8 +4208,8 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
if (!FUN_FLAT_CLOSURE(fun))
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
if (!fun->isFlatClosure())
|
||||
return CloneFunctionObject(cx, fun, parent);
|
||||
|
||||
/*
|
||||
@ -4254,7 +4254,7 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetFunctionObject(JSFunction *fun)
|
||||
{
|
||||
return FUN_OBJECT(fun);
|
||||
return fun;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSString *)
|
||||
@ -4357,7 +4357,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
|
||||
* as fun->object lives.
|
||||
*/
|
||||
Value priv = PrivateValue(fs);
|
||||
if (!js_SetReservedSlot(cx, FUN_OBJECT(fun), 0, priv))
|
||||
if (!js_SetReservedSlot(cx, fun, 0, priv))
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@ -4712,24 +4712,21 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj,
|
||||
funAtom = js_Atomize(cx, name, strlen(name));
|
||||
if (!funAtom) {
|
||||
fun = NULL;
|
||||
goto out2;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, obj, funAtom);
|
||||
if (!fun)
|
||||
goto out2;
|
||||
goto out;
|
||||
|
||||
{
|
||||
EmptyShape *emptyCallShape = EmptyShape::getEmptyCallShape(cx);
|
||||
if (!emptyCallShape) {
|
||||
if (!emptyCallShape)
|
||||
fun = NULL;
|
||||
goto out2;
|
||||
}
|
||||
AutoShapeRooter shapeRoot(cx, emptyCallShape);
|
||||
|
||||
AutoObjectRooter tvr(cx, FUN_OBJECT(fun));
|
||||
MUST_FLOW_THROUGH("out");
|
||||
AutoObjectRooter tvr(cx, fun);
|
||||
|
||||
Bindings bindings(cx, emptyCallShape);
|
||||
AutoBindingsRooter root(cx, bindings);
|
||||
@ -4737,20 +4734,20 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj,
|
||||
argAtom = js_Atomize(cx, argnames[i], strlen(argnames[i]));
|
||||
if (!argAtom) {
|
||||
fun = NULL;
|
||||
goto out2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
uint16 dummy;
|
||||
if (!bindings.addArgument(cx, argAtom, &dummy)) {
|
||||
fun = NULL;
|
||||
goto out2;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Compiler::compileFunctionBody(cx, fun, principals, &bindings,
|
||||
chars, length, filename, lineno, version)) {
|
||||
fun = NULL;
|
||||
goto out2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (obj && funAtom &&
|
||||
@ -4760,10 +4757,11 @@ CompileUCFunctionForPrincipalsCommon(JSContext *cx, JSObject *obj,
|
||||
}
|
||||
}
|
||||
|
||||
out2:
|
||||
out:
|
||||
LAST_FRAME_CHECKS(cx, fun);
|
||||
return fun;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSFunction *)
|
||||
JS_CompileUCFunctionForPrincipalsVersion(JSContext *cx, JSObject *obj,
|
||||
JSPrincipals *principals, const char *name,
|
||||
|
@ -310,7 +310,7 @@ js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* pa
|
||||
JS_ASSERT(JS_ON_TRACE(cx));
|
||||
|
||||
JSFunction *fun = (JSFunction*) funobj;
|
||||
JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun);
|
||||
JS_ASSERT(funobj->getFunctionPrivate() == fun);
|
||||
|
||||
JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2);
|
||||
if (!closure)
|
||||
|
@ -1083,7 +1083,7 @@ js_ReportMissingArg(JSContext *cx, const Value &v, uintN arg)
|
||||
JS_snprintf(argbuf, sizeof argbuf, "%u", arg);
|
||||
bytes = NULL;
|
||||
if (IsFunctionObject(v)) {
|
||||
atom = GET_FUNCTION_PRIVATE(cx, &v.toObject())->atom;
|
||||
atom = v.toObject().getFunctionPrivate()->atom;
|
||||
bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK,
|
||||
v, atom);
|
||||
if (!bytes)
|
||||
|
@ -548,7 +548,7 @@ JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark)
|
||||
JS_PUBLIC_API(JSScript *)
|
||||
JS_GetFunctionScript(JSContext *cx, JSFunction *fun)
|
||||
{
|
||||
return FUN_SCRIPT(fun);
|
||||
return fun->maybeScript();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSNative)
|
||||
@ -1095,8 +1095,8 @@ JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun)
|
||||
size_t nbytes;
|
||||
|
||||
nbytes = sizeof *fun;
|
||||
nbytes += JS_GetObjectTotalSize(cx, FUN_OBJECT(fun));
|
||||
if (FUN_INTERPRETED(fun))
|
||||
nbytes += JS_GetObjectTotalSize(cx, fun);
|
||||
if (fun->isInterpreted())
|
||||
nbytes += JS_GetScriptTotalSize(cx, fun->script());
|
||||
if (fun->atom)
|
||||
nbytes += GetAtomTotalSize(cx, fun->atom);
|
||||
|
@ -4815,7 +4815,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
#endif
|
||||
|
||||
fun = pn->pn_funbox->function();
|
||||
JS_ASSERT(FUN_INTERPRETED(fun));
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
if (fun->script()) {
|
||||
/*
|
||||
* This second pass is needed to emit JSOP_NOP with a source note
|
||||
@ -4830,7 +4830,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
}
|
||||
|
||||
JS_ASSERT_IF(pn->pn_funbox->tcflags & TCF_FUN_HEAVYWEIGHT,
|
||||
FUN_KIND(fun) == JSFUN_INTERPRETED);
|
||||
fun->kind() == JSFUN_INTERPRETED);
|
||||
|
||||
/* Generate code for the function's body. */
|
||||
void *cg2mark = JS_ARENA_MARK(cg->codePool);
|
||||
@ -4913,7 +4913,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
return false;
|
||||
if (pn->pn_cookie.isFree()) {
|
||||
CG_SWITCH_TO_PROLOG(cg);
|
||||
op = FUN_FLAT_CLOSURE(fun) ? JSOP_DEFFUN_FC : JSOP_DEFFUN;
|
||||
op = fun->isFlatClosure() ? JSOP_DEFFUN_FC : JSOP_DEFFUN;
|
||||
EMIT_INDEX_OP(op, index);
|
||||
|
||||
/* Make blockChain determination quicker. */
|
||||
|
@ -528,24 +528,25 @@ js_ErrorFromException(JSContext *cx, jsval exn)
|
||||
}
|
||||
|
||||
static JSString *
|
||||
ValueToShortSource(JSContext *cx, jsval v)
|
||||
ValueToShortSource(JSContext *cx, const Value &v)
|
||||
{
|
||||
JSString *str;
|
||||
|
||||
/* Avoid toSource bloat and fallibility for object types. */
|
||||
if (JSVAL_IS_PRIMITIVE(v))
|
||||
return js_ValueToSource(cx, Valueify(v));
|
||||
if (!v.isObject())
|
||||
return js_ValueToSource(cx, v);
|
||||
|
||||
AutoCompartment ac(cx, JSVAL_TO_OBJECT(v));
|
||||
JSObject *obj = &v.toObject();
|
||||
AutoCompartment ac(cx, obj);
|
||||
if (!ac.enter())
|
||||
return NULL;
|
||||
|
||||
if (VALUE_IS_FUNCTION(cx, v)) {
|
||||
if (obj->isFunction()) {
|
||||
/*
|
||||
* XXX Avoid function decompilation bloat for now.
|
||||
*/
|
||||
str = JS_GetFunctionId(JS_ValueToFunction(cx, v));
|
||||
if (!str && !(str = js_ValueToSource(cx, Valueify(v)))) {
|
||||
str = JS_GetFunctionId(obj->getFunctionPrivate());
|
||||
if (!str && !(str = js_ValueToSource(cx, v))) {
|
||||
/*
|
||||
* Continue to soldier on if the function couldn't be
|
||||
* converted into a string.
|
||||
@ -559,8 +560,7 @@ ValueToShortSource(JSContext *cx, jsval v)
|
||||
* memory, for too many classes (see Mozilla bug 166743).
|
||||
*/
|
||||
char buf[100];
|
||||
JS_snprintf(buf, sizeof buf, "[object %s]",
|
||||
JSVAL_TO_OBJECT(v)->getClass()->name);
|
||||
JS_snprintf(buf, sizeof buf, "[object %s]", obj->getClass()->name);
|
||||
str = JS_NewStringCopyZ(cx, buf);
|
||||
}
|
||||
|
||||
@ -638,7 +638,7 @@ StackTraceToString(JSContext *cx, JSExnPrivate *priv)
|
||||
for (i = 0; i != elem->argc; i++, values++) {
|
||||
if (i > 0)
|
||||
APPEND_CHAR_TO_STACK(',');
|
||||
str = ValueToShortSource(cx, *values);
|
||||
str = ValueToShortSource(cx, Valueify(*values));
|
||||
if (!str)
|
||||
goto bad;
|
||||
APPEND_STRING_TO_STACK(str);
|
||||
|
@ -1251,8 +1251,9 @@ StackFrame::getValidCalleeObject(JSContext *cx, Value *vp)
|
||||
JSObject *clone;
|
||||
|
||||
if (IsFunctionObject(v, &clone) &&
|
||||
GET_FUNCTION_PRIVATE(cx, clone) == fun &&
|
||||
clone->hasMethodObj(*thisp)) {
|
||||
clone->getFunctionPrivate() == fun &&
|
||||
clone->hasMethodObj(*thisp))
|
||||
{
|
||||
JS_ASSERT(clone != &funobj);
|
||||
*vp = v;
|
||||
overwriteCallee(*clone);
|
||||
@ -1544,8 +1545,8 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
|
||||
|
||||
cx = xdr->cx;
|
||||
if (xdr->mode == JSXDR_ENCODE) {
|
||||
fun = GET_FUNCTION_PRIVATE(cx, *objp);
|
||||
if (!FUN_INTERPRETED(fun)) {
|
||||
fun = (*objp)->getFunctionPrivate();
|
||||
if (!fun->isInterpreted()) {
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_SCRIPTED_FUNCTION,
|
||||
@ -1566,11 +1567,11 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
|
||||
fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, NULL, NULL);
|
||||
if (!fun)
|
||||
return false;
|
||||
FUN_OBJECT(fun)->clearParent();
|
||||
FUN_OBJECT(fun)->clearProto();
|
||||
fun->clearParent();
|
||||
fun->clearProto();
|
||||
}
|
||||
|
||||
AutoObjectRooter tvr(cx, FUN_OBJECT(fun));
|
||||
AutoObjectRooter tvr(cx, fun);
|
||||
|
||||
if (!JS_XDRUint32(xdr, &firstword))
|
||||
return false;
|
||||
@ -1597,7 +1598,7 @@ js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp)
|
||||
fun->u.i.script = script;
|
||||
|
||||
if (xdr->mode == JSXDR_DECODE) {
|
||||
*objp = FUN_OBJECT(fun);
|
||||
*objp = fun;
|
||||
fun->u.i.script->setOwnerObject(fun);
|
||||
#ifdef CHECK_SCRIPT_OWNER
|
||||
fun->script()->owner = NULL;
|
||||
@ -1736,7 +1737,7 @@ fun_toStringHelper(JSContext *cx, JSObject *obj, uintN indent)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
|
||||
JSFunction *fun = obj->getFunctionPrivate();
|
||||
if (!fun)
|
||||
return NULL;
|
||||
|
||||
@ -2029,7 +2030,7 @@ fun_isGenerator(JSContext *cx, uintN argc, Value *vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
|
||||
bool result = false;
|
||||
if (fun->isInterpreted()) {
|
||||
@ -2439,7 +2440,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs,
|
||||
fun->atom = atom;
|
||||
|
||||
/* Set private to self to indicate non-cloned fully initialized function. */
|
||||
FUN_OBJECT(fun)->setPrivate(fun);
|
||||
fun->setPrivate(fun);
|
||||
return fun;
|
||||
}
|
||||
|
||||
@ -2653,7 +2654,7 @@ js_ValueToFunction(JSContext *cx, const Value *vp, uintN flags)
|
||||
js_ReportIsNotFunction(cx, vp, flags);
|
||||
return NULL;
|
||||
}
|
||||
return GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
return funobj->getFunctionPrivate();
|
||||
}
|
||||
|
||||
JSObject *
|
||||
|
@ -60,14 +60,14 @@
|
||||
* 10 interpreted, flat closure
|
||||
* 11 interpreted, null closure
|
||||
*
|
||||
* FUN_FLAT_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset != 0.
|
||||
* FUN_NULL_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset == 0.
|
||||
* isFlatClosure() implies isInterpreted() and u.i.script->upvarsOffset != 0.
|
||||
* isNullClosure() implies isInterpreted() and u.i.script->upvarsOffset == 0.
|
||||
*
|
||||
* FUN_INTERPRETED but not FUN_FLAT_CLOSURE and u.i.script->upvarsOffset != 0
|
||||
* isInterpreted() but not isFlatClosure() and u.i.script->upvarsOffset != 0
|
||||
* is an Algol-like function expression or nested function, i.e., a function
|
||||
* that never escapes upward or downward (heapward), and is only ever called.
|
||||
*
|
||||
* Finally, FUN_INTERPRETED and u.i.script->upvarsOffset == 0 could be either
|
||||
* Finally, isInterpreted() and u.i.script->upvarsOffset == 0 could be either
|
||||
* a non-closure (a global function definition, or any function that uses no
|
||||
* outer names), or a closure of an escaping function that uses outer names
|
||||
* whose values can't be snapshot (because the outer names could be reassigned
|
||||
@ -80,8 +80,8 @@
|
||||
* NB: JSFUN_EXPR_CLOSURE reuses JSFUN_STUB_GSOPS, which is an API request flag
|
||||
* bit only, never stored in fun->flags.
|
||||
*
|
||||
* If we need more bits in the future, all flags for FUN_INTERPRETED functions
|
||||
* can move to u.i.script->flags. For now we use function flag bits to minimize
|
||||
* If we need more bits in the future, all flags for interpreted functions can
|
||||
* move to u.i.script->flags. For now we use function flag bits to minimize
|
||||
* pointer-chasing.
|
||||
*/
|
||||
#define JSFUN_JOINABLE 0x0001 /* function is null closure that does not
|
||||
@ -101,19 +101,6 @@
|
||||
#define JSFUN_KINDMASK 0xc000 /* encode interp vs. native and closure
|
||||
optimization level -- see above */
|
||||
|
||||
#define FUN_OBJECT(fun) (static_cast<JSObject *>(fun))
|
||||
#define FUN_KIND(fun) ((fun)->flags & JSFUN_KINDMASK)
|
||||
#define FUN_SET_KIND(fun,k) ((fun)->flags = ((fun)->flags & ~JSFUN_KINDMASK) | (k))
|
||||
#define FUN_INTERPRETED(fun) (FUN_KIND(fun) >= JSFUN_INTERPRETED)
|
||||
#define FUN_FLAT_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_FLAT_CLOSURE)
|
||||
#define FUN_NULL_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_NULL_CLOSURE)
|
||||
#define FUN_SCRIPT(fun) (FUN_INTERPRETED(fun) ? (fun)->script() : NULL)
|
||||
#define FUN_CLASP(fun) (JS_ASSERT(!FUN_INTERPRETED(fun)), \
|
||||
fun->u.n.clasp)
|
||||
#define FUN_TRCINFO(fun) (JS_ASSERT(!FUN_INTERPRETED(fun)), \
|
||||
JS_ASSERT((fun)->flags & JSFUN_TRCINFO), \
|
||||
fun->u.n.trcinfo)
|
||||
|
||||
struct JSFunction : public JSObject_Slots2
|
||||
{
|
||||
/* Functions always have two fixed slots (FUN_CLASS_RESERVED_SLOTS). */
|
||||
@ -145,16 +132,25 @@ struct JSFunction : public JSObject_Slots2
|
||||
} u;
|
||||
JSAtom *atom; /* name for diagnostics and decompiling */
|
||||
|
||||
bool optimizedClosure() const { return FUN_KIND(this) > JSFUN_INTERPRETED; }
|
||||
bool isInterpreted() const { return FUN_INTERPRETED(this); }
|
||||
bool isNative() const { return !FUN_INTERPRETED(this); }
|
||||
bool optimizedClosure() const { return kind() > JSFUN_INTERPRETED; }
|
||||
bool isInterpreted() const { return kind() >= JSFUN_INTERPRETED; }
|
||||
bool isNative() const { return !isInterpreted(); }
|
||||
bool isConstructor() const { return flags & JSFUN_CONSTRUCTOR; }
|
||||
bool isHeavyweight() const { return JSFUN_HEAVYWEIGHT_TEST(flags); }
|
||||
bool isFlatClosure() const { return FUN_KIND(this) == JSFUN_FLAT_CLOSURE; }
|
||||
bool isNullClosure() const { return kind() == JSFUN_NULL_CLOSURE; }
|
||||
bool isFlatClosure() const { return kind() == JSFUN_FLAT_CLOSURE; }
|
||||
bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; }
|
||||
bool isInterpretedConstructor() const { return isInterpreted() && !isFunctionPrototype(); }
|
||||
|
||||
uint16 kind() const { return flags & JSFUN_KINDMASK; }
|
||||
void setKind(uint16 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;
|
||||
|
||||
void setArgCount(uint16 nargs) {
|
||||
JS_ASSERT(this->nargs == 0);
|
||||
this->nargs = nargs;
|
||||
@ -210,6 +206,10 @@ struct JSFunction : public JSObject_Slots2
|
||||
return u.i.script;
|
||||
}
|
||||
|
||||
JSScript * maybeScript() const {
|
||||
return isInterpreted() ? script() : NULL;
|
||||
}
|
||||
|
||||
js::Native native() const {
|
||||
JS_ASSERT(isNative());
|
||||
return u.n.native;
|
||||
@ -227,6 +227,23 @@ struct JSFunction : public JSObject_Slots2
|
||||
|
||||
/* Number of extra fixed function object slots. */
|
||||
static const uint32 CLASS_RESERVED_SLOTS = JSObject::FUN_CLASS_RESERVED_SLOTS;
|
||||
|
||||
|
||||
js::Class *getConstructorClass() const {
|
||||
JS_ASSERT(isNative());
|
||||
return u.n.clasp;
|
||||
}
|
||||
|
||||
void setConstructorClass(js::Class *clasp) {
|
||||
JS_ASSERT(isNative());
|
||||
u.n.clasp = clasp;
|
||||
}
|
||||
|
||||
JSNativeTraceInfo *getTraceInfo() const {
|
||||
JS_ASSERT(isNative());
|
||||
JS_ASSERT(flags & JSFUN_TRCINFO);
|
||||
return u.n.trcinfo;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
@ -269,12 +286,6 @@ JSObject::getFunctionPrivate() const
|
||||
|
||||
namespace js {
|
||||
|
||||
/*
|
||||
* NB: jsapi.h and jsobj.h must be included before any call to this macro.
|
||||
*/
|
||||
#define VALUE_IS_FUNCTION(cx, v) \
|
||||
(!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction())
|
||||
|
||||
static JS_ALWAYS_INLINE bool
|
||||
IsFunctionObject(const js::Value &v)
|
||||
{
|
||||
@ -354,14 +365,6 @@ SameTraceType(const Value &lhs, const Value &rhs)
|
||||
lhs.toObject().isFunction() == rhs.toObject().isFunction());
|
||||
}
|
||||
|
||||
/*
|
||||
* Macro to access the private slot of the function object after the slot is
|
||||
* initialized.
|
||||
*/
|
||||
#define GET_FUNCTION_PRIVATE(cx, funobj) \
|
||||
(JS_ASSERT((funobj)->isFunction()), \
|
||||
(JSFunction *) (funobj)->getPrivate())
|
||||
|
||||
/*
|
||||
* Return true if this is a compiler-created internal function accessed by
|
||||
* its own object. Such a function object must not be accessible to script
|
||||
|
@ -52,7 +52,7 @@ JSFunction::inStrictMode() const
|
||||
inline void
|
||||
JSFunction::setJoinable()
|
||||
{
|
||||
JS_ASSERT(FUN_INTERPRETED(this));
|
||||
JS_ASSERT(isInterpreted());
|
||||
setSlot(METHOD_ATOM_SLOT, js::NullValue());
|
||||
flags |= JSFUN_JOINABLE;
|
||||
}
|
||||
|
@ -4590,10 +4590,10 @@ BEGIN_CASE(JSOP_DEFFUN)
|
||||
*/
|
||||
JSFunction *fun;
|
||||
LOAD_FUNCTION(0);
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JSObject *obj = fun;
|
||||
|
||||
JSObject *obj2;
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
/*
|
||||
* Even a null closure needs a parent for principals finding.
|
||||
* FIXME: bug 476950, although debugger users may also demand some kind
|
||||
@ -4730,10 +4730,10 @@ BEGIN_CASE(JSOP_DEFLOCALFUN)
|
||||
JSFunction *fun;
|
||||
LOAD_FUNCTION(SLOTNO_LEN);
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
JS_ASSERT(!FUN_FLAT_CLOSURE(fun));
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JS_ASSERT(!fun->isFlatClosure());
|
||||
JSObject *obj = fun;
|
||||
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
obj = CloneFunctionObject(cx, fun, ®s.fp()->scopeChain());
|
||||
if (!obj)
|
||||
goto error;
|
||||
@ -4782,12 +4782,12 @@ BEGIN_CASE(JSOP_LAMBDA)
|
||||
/* Load the specified function object literal. */
|
||||
JSFunction *fun;
|
||||
LOAD_FUNCTION(0);
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JSObject *obj = fun;
|
||||
|
||||
/* do-while(0) so we can break instead of using a goto. */
|
||||
do {
|
||||
JSObject *parent;
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
parent = ®s.fp()->scopeChain();
|
||||
|
||||
if (obj->getParent() == parent) {
|
||||
@ -4845,7 +4845,7 @@ BEGIN_CASE(JSOP_LAMBDA)
|
||||
JSObject *callee;
|
||||
|
||||
if (IsFunctionObject(cref, &callee)) {
|
||||
JSFunction *calleeFun = GET_FUNCTION_PRIVATE(cx, callee);
|
||||
JSFunction *calleeFun = callee->getFunctionPrivate();
|
||||
if (Native native = calleeFun->maybeNative()) {
|
||||
if ((iargc == 1 && native == array_sort) ||
|
||||
(iargc == 2 && native == str_replace)) {
|
||||
|
@ -3919,7 +3919,7 @@ DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAt
|
||||
js_NewFunction(cx, NULL, constructor, nargs, JSFUN_CONSTRUCTOR, obj, atom);
|
||||
if (!fun)
|
||||
goto bad;
|
||||
FUN_CLASP(fun) = clasp;
|
||||
fun->setConstructorClass(clasp);
|
||||
|
||||
AutoValueRooter tvr2(cx, ObjectValue(*fun));
|
||||
if (!DefineStandardSlot(cx, obj, key, atom, tvr2.value(), 0, named))
|
||||
@ -3931,7 +3931,7 @@ DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAt
|
||||
* different object, as is done for operator new -- and as at least
|
||||
* XML support requires.
|
||||
*/
|
||||
ctor = FUN_OBJECT(fun);
|
||||
ctor = fun;
|
||||
if (clasp->flags & JSCLASS_CONSTRUCT_PROTOTYPE) {
|
||||
Value rval;
|
||||
if (!InvokeConstructorWithGivenThis(cx, proto, ObjectOrNullValue(ctor),
|
||||
@ -4709,7 +4709,7 @@ DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const Value &value,
|
||||
JS_ASSERT(!getter && !setter);
|
||||
|
||||
JSObject *funobj = &value.toObject();
|
||||
if (FUN_OBJECT(GET_FUNCTION_PRIVATE(cx, funobj)) == funobj) {
|
||||
if (funobj->getFunctionPrivate() == funobj) {
|
||||
flags |= Shape::METHOD;
|
||||
getter = CastAsPropertyOp(funobj);
|
||||
}
|
||||
@ -5662,7 +5662,7 @@ js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
|
||||
JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
|
||||
JSObject *funobj = &vp->toObject();
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
if (fun == funobj) {
|
||||
flags |= Shape::METHOD;
|
||||
getter = CastAsPropertyOp(funobj);
|
||||
@ -5797,7 +5797,7 @@ js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool str
|
||||
JSObject *funobj;
|
||||
|
||||
if (IsFunctionObject(v, &funobj)) {
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
|
||||
if (fun != funobj) {
|
||||
for (StackFrame *fp = cx->maybefp(); fp; fp = fp->prev()) {
|
||||
@ -6492,7 +6492,7 @@ dumpValue(const Value &v)
|
||||
dumpString(v.toString());
|
||||
else if (v.isObject() && v.toObject().isFunction()) {
|
||||
JSObject *funobj = &v.toObject();
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
if (fun->atom) {
|
||||
fputs("<function ", stderr);
|
||||
FileEscapedString(stderr, fun->atom, 0);
|
||||
|
@ -218,7 +218,7 @@ JSObject::methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp
|
||||
JSObject *funobj = &vp->toObject();
|
||||
JSFunction *fun = funobj->getFunctionPrivate();
|
||||
JS_ASSERT(fun == funobj);
|
||||
JS_ASSERT(FUN_NULL_CLOSURE(fun));
|
||||
JS_ASSERT(fun->isNullClosure());
|
||||
|
||||
funobj = CloneFunctionObject(cx, fun, funobj->getParent());
|
||||
if (!funobj)
|
||||
@ -550,7 +550,7 @@ inline void
|
||||
JSObject::setFlatClosureUpvars(js::Value *upvars)
|
||||
{
|
||||
JS_ASSERT(isFunction());
|
||||
JS_ASSERT(FUN_FLAT_CLOSURE(getFunctionPrivate()));
|
||||
JS_ASSERT(getFunctionPrivate()->isFlatClosure());
|
||||
setSlot(JSSLOT_FLAT_CLOSURE_UPVARS, PrivateValue(upvars));
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ ToDisassemblySource(JSContext *cx, jsval v, JSAutoByteString *bytes)
|
||||
}
|
||||
|
||||
if (clasp == &js_FunctionClass) {
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
|
||||
JSFunction *fun = obj->getFunctionPrivate();
|
||||
JSString *str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT);
|
||||
if (!str)
|
||||
return false;
|
||||
@ -4972,7 +4972,7 @@ js_DecompileFunctionBody(JSPrinter *jp)
|
||||
|
||||
JS_ASSERT(jp->fun);
|
||||
JS_ASSERT(!jp->script);
|
||||
if (!FUN_INTERPRETED(jp->fun)) {
|
||||
if (!jp->fun->isInterpreted()) {
|
||||
js_printf(jp, native_code_str);
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -5011,7 +5011,7 @@ js_DecompileFunction(JSPrinter *jp)
|
||||
return JS_FALSE;
|
||||
js_puts(jp, "(");
|
||||
|
||||
if (!FUN_INTERPRETED(fun)) {
|
||||
if (!fun->isInterpreted()) {
|
||||
js_printf(jp, ") {\n");
|
||||
jp->indent += 4;
|
||||
js_printf(jp, native_code_str);
|
||||
|
@ -313,7 +313,7 @@ Parser::newFunctionBox(JSObject *obj, JSParseNode *fn, JSTreeContext *tc)
|
||||
bool
|
||||
JSFunctionBox::joinable() const
|
||||
{
|
||||
return FUN_NULL_CLOSURE(function()) &&
|
||||
return function()->isNullClosure() &&
|
||||
!(tcflags & (TCF_FUN_USES_ARGUMENTS | TCF_FUN_USES_OWN_NAME));
|
||||
}
|
||||
|
||||
@ -990,7 +990,7 @@ Compiler::compileScript(JSContext *cx, JSObject *scopeChain, StackFrame *callerF
|
||||
* function captured in case it refers to an upvar, and someone
|
||||
* wishes to decompile it while it's running.
|
||||
*/
|
||||
JSObjectBox *funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun()));
|
||||
JSObjectBox *funbox = parser.newObjectBox(callerFrame->fun());
|
||||
if (!funbox)
|
||||
goto out;
|
||||
funbox->emitLink = cg.objectList.lastbox;
|
||||
@ -1978,8 +1978,8 @@ Parser::newFunction(JSTreeContext *tc, JSAtom *atom, FunctionSyntaxKind kind)
|
||||
JSFUN_INTERPRETED | (kind == Expression ? JSFUN_LAMBDA : 0),
|
||||
parent, atom);
|
||||
if (fun && !tc->compileAndGo()) {
|
||||
FUN_OBJECT(fun)->clearParent();
|
||||
FUN_OBJECT(fun)->clearProto();
|
||||
fun->clearParent();
|
||||
fun->clearProto();
|
||||
}
|
||||
return fun;
|
||||
}
|
||||
@ -2461,12 +2461,12 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags)
|
||||
|
||||
JSFunction *fun = funbox->function();
|
||||
|
||||
JS_ASSERT(FUN_KIND(fun) == JSFUN_INTERPRETED);
|
||||
JS_ASSERT(fun->kind() == JSFUN_INTERPRETED);
|
||||
|
||||
if (funbox->tcflags & TCF_FUN_HEAVYWEIGHT) {
|
||||
/* nothing to do */
|
||||
} else if (funbox->inAnyDynamicScope()) {
|
||||
JS_ASSERT(!FUN_NULL_CLOSURE(fun));
|
||||
JS_ASSERT(!fun->isNullClosure());
|
||||
} else if (pn->pn_type != TOK_UPVARS) {
|
||||
/*
|
||||
* No lexical dependencies => null closure, for best performance.
|
||||
@ -2484,7 +2484,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags)
|
||||
*
|
||||
* FIXME: bug 476950.
|
||||
*/
|
||||
FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
|
||||
fun->setKind(JSFUN_NULL_CLOSURE);
|
||||
} else {
|
||||
AtomDefnMapPtr upvars = pn->pn_names;
|
||||
JS_ASSERT(!upvars->empty());
|
||||
@ -2512,7 +2512,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags)
|
||||
}
|
||||
|
||||
if (r.empty())
|
||||
FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
|
||||
fun->setKind(JSFUN_NULL_CLOSURE);
|
||||
} else {
|
||||
uintN nupvars = 0, nflattened = 0;
|
||||
|
||||
@ -2550,13 +2550,13 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags)
|
||||
}
|
||||
|
||||
if (nupvars == 0) {
|
||||
FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
|
||||
fun->setKind(JSFUN_NULL_CLOSURE);
|
||||
} else if (nflattened == nupvars) {
|
||||
/*
|
||||
* We made it all the way through the upvar loop, so it's
|
||||
* safe to optimize to a flat closure.
|
||||
*/
|
||||
FUN_SET_KIND(fun, JSFUN_FLAT_CLOSURE);
|
||||
fun->setKind(JSFUN_FLAT_CLOSURE);
|
||||
switch (PN_OP(fn)) {
|
||||
case JSOP_DEFFUN:
|
||||
fn->pn_op = JSOP_DEFFUN_FC;
|
||||
@ -2575,7 +2575,7 @@ Parser::setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags)
|
||||
}
|
||||
}
|
||||
|
||||
if (FUN_KIND(fun) == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) {
|
||||
if (fun->kind() == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) {
|
||||
/*
|
||||
* One or more upvars cannot be safely snapshot into a flat
|
||||
* closure's non-reserved slot (see JSOP_GETFCSLOT), so we loop
|
||||
@ -2621,7 +2621,7 @@ Parser::markExtensibleScopeDescendants(JSFunctionBox *funbox, bool hasExtensible
|
||||
{
|
||||
for (; funbox; funbox = funbox->siblings) {
|
||||
/*
|
||||
* It would be nice to use FUN_KIND(fun) here to recognize functions
|
||||
* It would be nice to use fun->kind() here to recognize functions
|
||||
* that will never consult their parent chains, and thus don't need
|
||||
* their 'extensible parents' flag set. Filed as bug 619750.
|
||||
*/
|
||||
@ -2663,7 +2663,7 @@ EnterFunction(JSParseNode *fn, JSTreeContext *funtc, JSAtom *funAtom = NULL,
|
||||
return NULL;
|
||||
|
||||
/* Create box for fun->object early to protect against last-ditch GC. */
|
||||
JSFunctionBox *funbox = tc->parser->newFunctionBox(FUN_OBJECT(fun), fn, tc);
|
||||
JSFunctionBox *funbox = tc->parser->newFunctionBox(fun, fn, tc);
|
||||
if (!funbox)
|
||||
return NULL;
|
||||
|
||||
|
@ -90,10 +90,10 @@ FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString* bytes)
|
||||
static const char *
|
||||
FunctionClassname(const JSFunction *fun)
|
||||
{
|
||||
if (!fun || FUN_INTERPRETED(fun))
|
||||
if (!fun || fun->isInterpreted())
|
||||
return Probes::nullName;
|
||||
if (!(fun->flags & JSFUN_TRCINFO) && FUN_CLASP(fun))
|
||||
return (char *)FUN_CLASP(fun)->name;
|
||||
if (!(fun->flags & JSFUN_TRCINFO) && fun->getConstructorClass())
|
||||
return fun->getConstructorClass()->name;
|
||||
return Probes::nullName;
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ PropertyCache::fill(JSContext *cx, JSObject *obj, uintN scopeIndex, JSObject *po
|
||||
if (!pobj->branded()) {
|
||||
PCMETER(brandfills++);
|
||||
#ifdef DEBUG_notme
|
||||
JSFunction *fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(v));
|
||||
JSFunction *fun = JSVAL_TO_OBJECT(v)->getFunctionPrivate();
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
fprintf(stderr,
|
||||
|
@ -1234,7 +1234,7 @@ JSScript::NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
||||
if (cg->inFunction()) {
|
||||
/*
|
||||
* We initialize fun->u.i.script to be the script constructed above
|
||||
* so that the debugger has a valid FUN_SCRIPT(fun).
|
||||
* so that the debugger has a valid fun->script().
|
||||
*/
|
||||
fun = cg->fun();
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
|
@ -120,7 +120,7 @@ JSScript::getFunction(size_t index)
|
||||
JS_ASSERT(funobj->isFunction());
|
||||
JS_ASSERT(funobj == (JSObject *) funobj->getPrivate());
|
||||
JSFunction *fun = (JSFunction *) funobj;
|
||||
JS_ASSERT(FUN_INTERPRETED(fun));
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
@ -2810,7 +2810,7 @@ ValueToNative(const Value &v, JSValueType type, double* slot)
|
||||
|
||||
case JSVAL_TYPE_FUNOBJ: {
|
||||
JS_ASSERT(IsFunctionObject(v));
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject());
|
||||
JSFunction* fun = v.toObject().getFunctionPrivate();
|
||||
#if defined JS_JIT_SPEW
|
||||
if (LogController.lcbits & LC_TMTracer) {
|
||||
char funName[40];
|
||||
@ -3109,7 +3109,7 @@ NativeToValue(JSContext* cx, Value& v, JSValueType type, double* slot)
|
||||
JS_ASSERT(IsFunctionObject(v));
|
||||
#if defined JS_JIT_SPEW
|
||||
if (LogController.lcbits & LC_TMTracer) {
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject());
|
||||
JSFunction* fun = v.toObject().getFunctionPrivate();
|
||||
char funName[40];
|
||||
if (fun->atom)
|
||||
JS_PutEscapedFlatString(funName, sizeof funName, fun->atom, 0);
|
||||
@ -3385,7 +3385,7 @@ GetUpvarOnTrace(JSContext* cx, uint32 upvarLevel, int32 slot, uint32 callDepth,
|
||||
*/
|
||||
stackOffset -= fi->callerHeight;
|
||||
JSObject* callee = *(JSObject**)(&state->stackBase[stackOffset]);
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, callee);
|
||||
JSFunction* fun = callee->getFunctionPrivate();
|
||||
uintN calleeLevel = fun->script()->staticLevel;
|
||||
if (calleeLevel == upvarLevel) {
|
||||
/*
|
||||
@ -10541,7 +10541,7 @@ static JSBool JS_FASTCALL
|
||||
functionProbe(JSContext *cx, JSFunction *fun, int enter)
|
||||
{
|
||||
#ifdef MOZ_TRACE_JSCALLS
|
||||
JSScript *script = fun ? FUN_SCRIPT(fun) : NULL;
|
||||
JSScript *script = fun ? fun->maybeScript() : NULL;
|
||||
if (enter > 0)
|
||||
Probes::enterJSFun(cx, fun, script, enter);
|
||||
else
|
||||
@ -11011,7 +11011,7 @@ TraceRecorder::getClassPrototype(JSObject* ctor, LIns*& proto_ins)
|
||||
{
|
||||
// ctor must be a function created via js_InitClass.
|
||||
#ifdef DEBUG
|
||||
Class *clasp = FUN_CLASP(GET_FUNCTION_PRIVATE(cx, ctor));
|
||||
Class *clasp = ctor->getFunctionPrivate()->getConstructorClass();
|
||||
JS_ASSERT(clasp);
|
||||
|
||||
TraceMonitor &localtm = *traceMonitor;
|
||||
@ -11553,7 +11553,7 @@ TraceRecorder::callNative(uintN argc, JSOp mode)
|
||||
}
|
||||
|
||||
if (fun->flags & JSFUN_TRCINFO) {
|
||||
JSNativeTraceInfo *trcinfo = FUN_TRCINFO(fun);
|
||||
JSNativeTraceInfo *trcinfo = fun->getTraceInfo();
|
||||
JS_ASSERT(trcinfo && fun->u.n.native == trcinfo->native);
|
||||
|
||||
/* Try to call a type specialized version of the native. */
|
||||
@ -11708,10 +11708,10 @@ TraceRecorder::functionCall(uintN argc, JSOp mode)
|
||||
* Bytecode sequences that push shapeless callees must guard on the callee
|
||||
* class being Function and the function being interpreted.
|
||||
*/
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &fval.toObject());
|
||||
JSFunction* fun = fval.toObject().getFunctionPrivate();
|
||||
|
||||
if (Probes::callTrackingActive(cx)) {
|
||||
JSScript *script = FUN_SCRIPT(fun);
|
||||
JSScript *script = fun->maybeScript();
|
||||
if (!script || !script->isEmpty()) {
|
||||
LIns* args[] = { w.immi(1), w.nameImmpNonGC(fun), cx_ins };
|
||||
LIns* call_ins = w.call(&functionProbe_ci, args);
|
||||
@ -11719,7 +11719,7 @@ TraceRecorder::functionCall(uintN argc, JSOp mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (FUN_INTERPRETED(fun))
|
||||
if (fun->isInterpreted())
|
||||
return interpretedFunctionCall(fval, fun, argc, mode == JSOP_NEW);
|
||||
|
||||
Native native = fun->maybeNative();
|
||||
@ -13617,7 +13617,8 @@ TraceRecorder::guardCallee(Value& callee)
|
||||
* private data) case as noted above.
|
||||
*/
|
||||
if (callee_fun->isInterpreted() &&
|
||||
(!FUN_NULL_CLOSURE(callee_fun) || callee_fun->script()->bindings.hasUpvars())) {
|
||||
(!callee_fun->isNullClosure() || callee_fun->script()->bindings.hasUpvars()))
|
||||
{
|
||||
JSObject* parent = callee_obj.getParent();
|
||||
|
||||
if (parent != globalObj) {
|
||||
@ -13819,8 +13820,8 @@ TraceRecorder::record_JSOP_FUNAPPLY()
|
||||
RETURN_IF_XML_A(vp[0]);
|
||||
|
||||
JSObject* obj = &vp[0].toObject();
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj);
|
||||
if (FUN_INTERPRETED(fun))
|
||||
JSFunction* fun = obj->getFunctionPrivate();
|
||||
if (fun->isInterpreted())
|
||||
return record_JSOP_CALL();
|
||||
|
||||
bool apply = fun->u.n.native == js_fun_apply;
|
||||
@ -15422,7 +15423,7 @@ TraceRecorder::record_JSOP_LAMBDA()
|
||||
JSFunction* fun;
|
||||
fun = cx->fp()->script()->getFunction(getFullIndex());
|
||||
|
||||
if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() != globalObj)
|
||||
if (fun->isNullClosure() && fun->getParent() != globalObj)
|
||||
RETURN_STOP_A("Null closure function object parent must be global object");
|
||||
|
||||
/*
|
||||
@ -15436,12 +15437,12 @@ TraceRecorder::record_JSOP_LAMBDA()
|
||||
* JSOP_INITMETHOD logic governing the early ARECORD_CONTINUE returns below
|
||||
* must agree with the corresponding break-from-do-while(0) logic there.
|
||||
*/
|
||||
if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == &cx->fp()->scopeChain()) {
|
||||
if (fun->isNullClosure() && fun->getParent() == &cx->fp()->scopeChain()) {
|
||||
jsbytecode *pc2 = AdvanceOverBlockchainOp(cx->regs().pc + JSOP_LAMBDA_LENGTH);
|
||||
JSOp op2 = JSOp(*pc2);
|
||||
|
||||
if (op2 == JSOP_INITMETHOD) {
|
||||
stack(0, w.immpObjGC(FUN_OBJECT(fun)));
|
||||
stack(0, w.immpObjGC(fun));
|
||||
return ARECORD_CONTINUE;
|
||||
}
|
||||
|
||||
@ -15449,7 +15450,7 @@ TraceRecorder::record_JSOP_LAMBDA()
|
||||
Value lval = stackval(-1);
|
||||
|
||||
if (!lval.isPrimitive() && lval.toObject().canHaveMethodBarrier()) {
|
||||
stack(0, w.immpObjGC(FUN_OBJECT(fun)));
|
||||
stack(0, w.immpObjGC(fun));
|
||||
return ARECORD_CONTINUE;
|
||||
}
|
||||
} else if (fun->joinable()) {
|
||||
@ -15477,7 +15478,7 @@ TraceRecorder::record_JSOP_LAMBDA()
|
||||
|
||||
if ((iargc == 1 && native == array_sort) ||
|
||||
(iargc == 2 && native == str_replace)) {
|
||||
stack(0, w.immpObjGC(FUN_OBJECT(fun)));
|
||||
stack(0, w.immpObjGC(fun));
|
||||
return ARECORD_CONTINUE;
|
||||
}
|
||||
}
|
||||
@ -15486,7 +15487,7 @@ TraceRecorder::record_JSOP_LAMBDA()
|
||||
op2 = JSOp(*pc2);
|
||||
|
||||
if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) {
|
||||
stack(0, w.immpObjGC(FUN_OBJECT(fun)));
|
||||
stack(0, w.immpObjGC(fun));
|
||||
return ARECORD_CONTINUE;
|
||||
}
|
||||
}
|
||||
@ -15524,7 +15525,7 @@ TraceRecorder::record_JSOP_LAMBDA_FC()
|
||||
JSFunction* fun;
|
||||
fun = cx->fp()->script()->getFunction(getFullIndex());
|
||||
|
||||
if (FUN_OBJECT(fun)->getParent() != globalObj)
|
||||
if (fun->getParent() != globalObj)
|
||||
return ARECORD_STOP;
|
||||
|
||||
if (GetBlockChainFast(cx, cx->fp(), JSOP_LAMBDA_FC, JSOP_LAMBDA_FC_LENGTH))
|
||||
@ -15672,9 +15673,9 @@ TraceRecorder::record_JSOP_ARGCNT()
|
||||
JS_REQUIRES_STACK AbortableRecordingStatus
|
||||
TraceRecorder::record_DefLocalFunSetSlot(uint32 slot, JSObject* obj)
|
||||
{
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj);
|
||||
JSFunction* fun = obj->getFunctionPrivate();
|
||||
|
||||
if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == globalObj) {
|
||||
if (fun->isNullClosure() && fun->getParent() == globalObj) {
|
||||
LIns *proto_ins;
|
||||
CHECK_STATUS_A(getClassPrototype(JSProto_Function, proto_ins));
|
||||
|
||||
@ -16012,7 +16013,7 @@ TraceRecorder::record_JSOP_CALLPROP()
|
||||
|
||||
if (pcval.isFunObj()) {
|
||||
if (l.isPrimitive()) {
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &pcval.toFunObj());
|
||||
JSFunction* fun = pcval.toFunObj().getFunctionPrivate();
|
||||
if (fun->isInterpreted() && !fun->inStrictMode())
|
||||
RETURN_STOP_A("callee does not accept primitive |this|");
|
||||
}
|
||||
|
@ -1643,7 +1643,7 @@ GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
|
||||
|
||||
if (!js_FindClassObject(cx, NULL, JSProto_XML, Valueify(&v)))
|
||||
return JS_FALSE;
|
||||
if (!VALUE_IS_FUNCTION(cx, v)) {
|
||||
if (JSVAL_IS_PRIMITIVE(v) || !JSVAL_TO_OBJECT(v)->isFunction()) {
|
||||
*vp = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
}
|
||||
@ -5153,7 +5153,8 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
|
||||
JSFunction *fun;
|
||||
char numBuf[12];
|
||||
|
||||
JS_ASSERT(VALUE_IS_FUNCTION(cx, *vp));
|
||||
JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
|
||||
JS_ASSERT(JSVAL_TO_OBJECT(*vp)->isFunction());
|
||||
|
||||
*objp = ToObject(cx, Valueify(&vp[1]));
|
||||
if (!*objp)
|
||||
@ -5177,7 +5178,7 @@ StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
|
||||
}
|
||||
}
|
||||
|
||||
fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(*vp));
|
||||
fun = JSVAL_TO_OBJECT(*vp)->getFunctionPrivate();
|
||||
JS_snprintf(numBuf, sizeof numBuf, "%u", xml->xml_kids.length);
|
||||
JSAutoByteString funNameBytes;
|
||||
if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
|
||||
@ -7500,7 +7501,7 @@ GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
for (;;) {
|
||||
if (!js_GetProperty(cx, target, id, Valueify(vp)))
|
||||
return false;
|
||||
if (VALUE_IS_FUNCTION(cx, *vp))
|
||||
if (!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction())
|
||||
return true;
|
||||
target = target->getProto();
|
||||
if (target == NULL || !target->isNative())
|
||||
|
@ -419,7 +419,7 @@ stubs::UncachedCallHelper(VMFrame &f, uint32 argc, UncachedCallResult *ucr)
|
||||
|
||||
if (IsFunctionObject(args.calleev(), &ucr->callee)) {
|
||||
ucr->callee = &args.callee();
|
||||
ucr->fun = GET_FUNCTION_PRIVATE(cx, ucr->callee);
|
||||
ucr->fun = ucr->callee->getFunctionPrivate();
|
||||
|
||||
if (ucr->fun->isInterpreted()) {
|
||||
if (!UncachedInlineCall(f, NO_CONSTRUCT, &ucr->codeAddr, &ucr->unjittable, argc))
|
||||
|
@ -558,7 +558,7 @@ class SetPropCompiler : public PICStubCompiler
|
||||
return disable("can't have method barrier");
|
||||
|
||||
JSObject *funobj = &f.regs.sp[-1].toObject();
|
||||
if (funobj != GET_FUNCTION_PRIVATE(cx, funobj))
|
||||
if (funobj != funobj->getFunctionPrivate())
|
||||
return disable("mismatched function");
|
||||
|
||||
flags |= Shape::METHOD;
|
||||
|
@ -704,9 +704,9 @@ stubs::DefFun(VMFrame &f, JSFunction *fun)
|
||||
* a compound statement (not at the top statement level of global code, or
|
||||
* at the top level of a function body).
|
||||
*/
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JSObject *obj = fun;
|
||||
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
/*
|
||||
* Even a null closure needs a parent for principals finding.
|
||||
* FIXME: bug 476950, although debugger users may also demand some kind
|
||||
@ -1325,10 +1325,10 @@ stubs::DefLocalFun(VMFrame &f, JSFunction *fun)
|
||||
* activation.
|
||||
*/
|
||||
JS_ASSERT(fun->isInterpreted());
|
||||
JS_ASSERT(!FUN_FLAT_CLOSURE(fun));
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JS_ASSERT(!fun->isFlatClosure());
|
||||
JSObject *obj = fun;
|
||||
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
obj = CloneFunctionObject(f.cx, fun, &f.fp()->scopeChain());
|
||||
if (!obj)
|
||||
THROWV(NULL);
|
||||
@ -1381,8 +1381,8 @@ stubs::RegExp(VMFrame &f, JSObject *regex)
|
||||
JSObject * JS_FASTCALL
|
||||
stubs::LambdaForInit(VMFrame &f, JSFunction *fun)
|
||||
{
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
JSObject *obj = fun;
|
||||
if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc)));
|
||||
return obj;
|
||||
}
|
||||
@ -1392,8 +1392,8 @@ stubs::LambdaForInit(VMFrame &f, JSFunction *fun)
|
||||
JSObject * JS_FASTCALL
|
||||
stubs::LambdaForSet(VMFrame &f, JSFunction *fun)
|
||||
{
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
JSObject *obj = fun;
|
||||
if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
const Value &lref = f.regs.sp[-1];
|
||||
if (lref.isObject() && lref.toObject().canHaveMethodBarrier()) {
|
||||
fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc)));
|
||||
@ -1406,8 +1406,8 @@ stubs::LambdaForSet(VMFrame &f, JSFunction *fun)
|
||||
JSObject * JS_FASTCALL
|
||||
stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun)
|
||||
{
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
JSObject *obj = fun;
|
||||
if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
/*
|
||||
* Array.prototype.sort and String.prototype.replace are
|
||||
* optimized as if they are special form. We know that they
|
||||
@ -1443,8 +1443,8 @@ stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun)
|
||||
JSObject * JS_FASTCALL
|
||||
stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun)
|
||||
{
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
JSObject *obj = fun;
|
||||
if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
|
||||
jsbytecode *pc2 = f.regs.pc + JSOP_NULL_LENGTH;
|
||||
JSOp op2 = JSOp(*pc2);
|
||||
|
||||
@ -1457,10 +1457,10 @@ stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun)
|
||||
JSObject * JS_FASTCALL
|
||||
stubs::Lambda(VMFrame &f, JSFunction *fun)
|
||||
{
|
||||
JSObject *obj = FUN_OBJECT(fun);
|
||||
JSObject *obj = fun;
|
||||
|
||||
JSObject *parent;
|
||||
if (FUN_NULL_CLOSURE(fun)) {
|
||||
if (fun->isNullClosure()) {
|
||||
parent = &f.fp()->scopeChain();
|
||||
} else {
|
||||
parent = GetScopeChainFast(f.cx, f.fp(), JSOP_LAMBDA, JSOP_LAMBDA_LENGTH);
|
||||
|
@ -1554,7 +1554,7 @@ ValueToScript(JSContext *cx, jsval v)
|
||||
} else if (clasp == Jsvalify(&js_GeneratorClass)) {
|
||||
JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj);
|
||||
fun = gen->floatingFrame()->fun();
|
||||
script = FUN_SCRIPT(fun);
|
||||
script = fun->script();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1562,7 +1562,7 @@ ValueToScript(JSContext *cx, jsval v)
|
||||
fun = JS_ValueToFunction(cx, v);
|
||||
if (!fun)
|
||||
return NULL;
|
||||
script = FUN_SCRIPT(fun);
|
||||
script = fun->maybeScript();
|
||||
if (!script) {
|
||||
JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL,
|
||||
JSSMSG_SCRIPTS_ONLY);
|
||||
@ -1992,7 +1992,7 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive, Sprinter *s
|
||||
JSScript *script = ValueToScript(cx, v);
|
||||
if (!script)
|
||||
return false;
|
||||
if (VALUE_IS_FUNCTION(cx, v)) {
|
||||
if (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction()) {
|
||||
JSFunction *fun = JS_ValueToFunction(cx, v);
|
||||
if (fun && (fun->flags & ~7U)) {
|
||||
uint16 flags = fun->flags;
|
||||
@ -2007,10 +2007,10 @@ DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive, Sprinter *s
|
||||
|
||||
#undef SHOW_FLAG
|
||||
|
||||
if (FUN_INTERPRETED(fun)) {
|
||||
if (FUN_NULL_CLOSURE(fun))
|
||||
if (fun->isInterpreted()) {
|
||||
if (fun->isNullClosure())
|
||||
Sprint(sp, " NULL_CLOSURE");
|
||||
else if (FUN_FLAT_CLOSURE(fun))
|
||||
else if (fun->isFlatClosure())
|
||||
Sprint(sp, " FLAT_CLOSURE");
|
||||
|
||||
JSScript *script = fun->script();
|
||||
@ -2698,7 +2698,7 @@ Clone(JSContext *cx, uintN argc, jsval *vp)
|
||||
return JS_FALSE;
|
||||
argv[0] = OBJECT_TO_JSVAL(obj);
|
||||
}
|
||||
if (VALUE_IS_FUNCTION(cx, argv[0])) {
|
||||
if (!JSVAL_IS_PRIMITIVE(argv[0]) && JSVAL_TO_OBJECT(argv[0])->isFunction()) {
|
||||
funobj = JSVAL_TO_OBJECT(argv[0]);
|
||||
} else {
|
||||
JSFunction *fun = JS_ValueToFunction(cx, argv[0]);
|
||||
|
@ -214,7 +214,7 @@ GlobalObject::createConstructor(JSContext *cx, Native ctor, Class *clasp, JSAtom
|
||||
* Remember the class this function is a constructor for so that we know to
|
||||
* create an object of this class when we call the constructor.
|
||||
*/
|
||||
FUN_CLASP(fun) = clasp;
|
||||
fun->setConstructorClass(clasp);
|
||||
return fun;
|
||||
}
|
||||
|
||||
|
@ -1576,7 +1576,7 @@ XPC_WN_CallMethod(JSContext *cx, uintN argc, jsval *vp)
|
||||
|
||||
#ifdef DEBUG_slimwrappers
|
||||
{
|
||||
JSFunction* fun = GET_FUNCTION_PRIVATE(cx, funobj);
|
||||
JSFunction* fun = funobj->getFunctionPrivate();
|
||||
JSString *funid = JS_GetFunctionId(fun);
|
||||
JSAutoByteString bytes;
|
||||
const char *funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : "<error>";
|
||||
@ -1615,7 +1615,7 @@ XPC_WN_GetterSetter(JSContext *cx, uintN argc, jsval *vp)
|
||||
JSAutoByteString bytes;
|
||||
if(JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION)
|
||||
{
|
||||
JSString *funid = JS_GetFunctionId(GET_FUNCTION_PRIVATE(cx, funobj));
|
||||
JSString *funid = JS_GetFunctionId(funobj->getFunctionPrivate());
|
||||
funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : "<error>";
|
||||
}
|
||||
SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname);
|
||||
|
Loading…
Reference in New Issue
Block a user