mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 886205 (part 4) - Move some function definitions from jsfuninlines.h to jsfun.h. r=terrence.
--HG-- extra : rebase_source : 1bd4bf6c2c4db1392d43908a438df3fde48e29b2
This commit is contained in:
parent
2cad2097bc
commit
1c0e8900ee
@ -469,7 +469,7 @@ js::PrincipalsForCompiledCode(const CallReceiver &call, JSContext *cx)
|
|||||||
{
|
{
|
||||||
JSObject &callee = call.callee();
|
JSObject &callee = call.callee();
|
||||||
JS_ASSERT(IsAnyBuiltinEval(&callee.as<JSFunction>()) ||
|
JS_ASSERT(IsAnyBuiltinEval(&callee.as<JSFunction>()) ||
|
||||||
IsBuiltinFunctionConstructor(&callee.as<JSFunction>()));
|
callee.as<JSFunction>().isBuiltinFunctionConstructor());
|
||||||
|
|
||||||
// To compute the principals of the compiled eval/Function code, we simply
|
// To compute the principals of the compiled eval/Function code, we simply
|
||||||
// use the callee's principals. To see why the caller's principals are
|
// use the callee's principals. To see why the caller's principals are
|
||||||
|
@ -662,7 +662,7 @@ JS_IsBuiltinEvalFunction(JSFunction *fun)
|
|||||||
JS_PUBLIC_API(JSBool)
|
JS_PUBLIC_API(JSBool)
|
||||||
JS_IsBuiltinFunctionConstructor(JSFunction *fun)
|
JS_IsBuiltinFunctionConstructor(JSFunction *fun)
|
||||||
{
|
{
|
||||||
return IsBuiltinFunctionConstructor(fun);
|
return fun->isBuiltinFunctionConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -1524,9 +1524,9 @@ js::Function(JSContext *cx, unsigned argc, Value *vp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
js::IsBuiltinFunctionConstructor(JSFunction *fun)
|
JSFunction::isBuiltinFunctionConstructor()
|
||||||
{
|
{
|
||||||
return fun->maybeNative() == Function;
|
return maybeNative() == Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSFunction *
|
JSFunction *
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "jsprvtd.h"
|
#include "jsprvtd.h"
|
||||||
#include "jsobj.h"
|
#include "jsobj.h"
|
||||||
|
#include "jsscript.h"
|
||||||
|
|
||||||
#include "gc/Barrier.h"
|
#include "gc/Barrier.h"
|
||||||
|
|
||||||
@ -82,7 +83,17 @@ class JSFunction : public JSObject
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/* Call objects must be created for each invocation of a heavyweight function. */
|
/* Call objects must be created for each invocation of a heavyweight function. */
|
||||||
inline bool isHeavyweight() const;
|
bool isHeavyweight() const {
|
||||||
|
JS_ASSERT(!isInterpretedLazy());
|
||||||
|
|
||||||
|
if (isNative())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Note: this should be kept in sync with FunctionBox::isHeavyweight().
|
||||||
|
return nonLazyScript()->bindings.hasAnyAliasedBindings() ||
|
||||||
|
nonLazyScript()->funHasExtensibleScope ||
|
||||||
|
nonLazyScript()->funNeedsDeclEnvObject;
|
||||||
|
}
|
||||||
|
|
||||||
/* A function can be classified as either native (C++) or interpreted (JS): */
|
/* A function can be classified as either native (C++) or interpreted (JS): */
|
||||||
bool isInterpreted() const { return flags & (INTERPRETED | INTERPRETED_LAZY); }
|
bool isInterpreted() const { return flags & (INTERPRETED | INTERPRETED_LAZY); }
|
||||||
@ -128,12 +139,16 @@ class JSFunction : public JSObject
|
|||||||
return isInterpreted() && !isFunctionPrototype() &&
|
return isInterpreted() && !isFunctionPrototype() &&
|
||||||
(!isSelfHostedBuiltin() || isSelfHostedConstructor());
|
(!isSelfHostedBuiltin() || isSelfHostedConstructor());
|
||||||
}
|
}
|
||||||
bool isNamedLambda() const {
|
bool isNamedLambda() const {
|
||||||
return isLambda() && atom_ && !hasGuessedAtom();
|
return isLambda() && atom_ && !hasGuessedAtom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBuiltinFunctionConstructor();
|
||||||
|
|
||||||
/* Returns the strictness of this function, which must be interpreted. */
|
/* Returns the strictness of this function, which must be interpreted. */
|
||||||
inline bool strict() const;
|
bool strict() const {
|
||||||
|
return nonLazyScript()->strict;
|
||||||
|
}
|
||||||
|
|
||||||
// Can be called multiple times by the parser.
|
// Can be called multiple times by the parser.
|
||||||
void setArgCount(uint16_t nargs) {
|
void setArgCount(uint16_t nargs) {
|
||||||
@ -190,7 +205,10 @@ class JSFunction : public JSObject
|
|||||||
* For an interpreted function, accessors for the initial scope object of
|
* For an interpreted function, accessors for the initial scope object of
|
||||||
* activations (stack frames) of the function.
|
* activations (stack frames) of the function.
|
||||||
*/
|
*/
|
||||||
inline JSObject *environment() const;
|
JSObject *environment() const {
|
||||||
|
JS_ASSERT(isInterpreted());
|
||||||
|
return u.i.env_;
|
||||||
|
}
|
||||||
inline void setEnvironment(JSObject *obj);
|
inline void setEnvironment(JSObject *obj);
|
||||||
inline void initEnvironment(JSObject *obj);
|
inline void initEnvironment(JSObject *obj);
|
||||||
|
|
||||||
@ -258,7 +276,12 @@ class JSFunction : public JSObject
|
|||||||
|
|
||||||
inline void setScript(JSScript *script_);
|
inline void setScript(JSScript *script_);
|
||||||
inline void initScript(JSScript *script_);
|
inline void initScript(JSScript *script_);
|
||||||
inline void initLazyScript(js::LazyScript *script);
|
void initLazyScript(js::LazyScript *lazy) {
|
||||||
|
JS_ASSERT(isInterpreted());
|
||||||
|
flags &= ~INTERPRETED;
|
||||||
|
flags |= INTERPRETED_LAZY;
|
||||||
|
u.i.s.lazy_ = lazy;
|
||||||
|
}
|
||||||
|
|
||||||
JSNative native() const {
|
JSNative native() const {
|
||||||
JS_ASSERT(isNative());
|
JS_ASSERT(isNative());
|
||||||
@ -269,9 +292,21 @@ class JSFunction : public JSObject
|
|||||||
return isInterpreted() ? NULL : native();
|
return isInterpreted() ? NULL : native();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void initNative(js::Native native, const JSJitInfo *jitinfo);
|
void initNative(js::Native native, const JSJitInfo *jitinfo) {
|
||||||
inline const JSJitInfo *jitInfo() const;
|
JS_ASSERT(native);
|
||||||
inline void setJitInfo(const JSJitInfo *data);
|
u.n.native = native;
|
||||||
|
u.n.jitinfo = jitinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
const JSJitInfo *jitInfo() const {
|
||||||
|
JS_ASSERT(isNative());
|
||||||
|
return u.n.jitinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setJitInfo(const JSJitInfo *data) {
|
||||||
|
JS_ASSERT(isNative());
|
||||||
|
u.n.jitinfo = data;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned offsetOfNativeOrScript() {
|
static unsigned offsetOfNativeOrScript() {
|
||||||
JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, i.s.script_));
|
JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, i.s.script_));
|
||||||
@ -347,6 +382,31 @@ JSAPIToJSFunctionFlags(unsigned flags)
|
|||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
|
/* Valueified JS_IsConstructing. */
|
||||||
|
static JS_ALWAYS_INLINE bool
|
||||||
|
IsConstructing(const Value *vp)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
|
||||||
|
if (callee->is<JSFunction>()) {
|
||||||
|
JSFunction *fun = &callee->as<JSFunction>();
|
||||||
|
JS_ASSERT(fun->isNativeConstructor());
|
||||||
|
} else {
|
||||||
|
JS_ASSERT(callee->getClass()->construct != NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return vp[1].isMagic();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
IsConstructing(CallReceiver call)
|
||||||
|
{
|
||||||
|
return IsConstructing(call.base());
|
||||||
|
}
|
||||||
|
|
||||||
|
extern JSBool
|
||||||
|
Function(JSContext *cx, unsigned argc, Value *vp);
|
||||||
|
|
||||||
extern JSFunction *
|
extern JSFunction *
|
||||||
NewFunction(JSContext *cx, HandleObject funobj, JSNative native, unsigned nargs,
|
NewFunction(JSContext *cx, HandleObject funobj, JSNative native, unsigned nargs,
|
||||||
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
|
JSFunction::Flags flags, HandleObject parent, HandleAtom atom,
|
||||||
@ -397,6 +457,13 @@ JSFunction::toExtended() const
|
|||||||
return static_cast<const js::FunctionExtended *>(this);
|
return static_cast<const js::FunctionExtended *>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const js::Value &
|
||||||
|
JSFunction::getExtendedSlot(size_t which) const
|
||||||
|
{
|
||||||
|
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
|
||||||
|
return toExtended()->extendedSlots[which];
|
||||||
|
}
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
JSString *FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lambdaParen);
|
JSString *FunctionToString(JSContext *cx, HandleFunction fun, bool bodyOnly, bool lambdaParen);
|
||||||
|
@ -16,12 +16,6 @@
|
|||||||
#include "vm/ScopeObject-inl.h"
|
#include "vm/ScopeObject-inl.h"
|
||||||
#include "vm/String-inl.h"
|
#include "vm/String-inl.h"
|
||||||
|
|
||||||
inline bool
|
|
||||||
JSFunction::strict() const
|
|
||||||
{
|
|
||||||
return nonLazyScript()->strict;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
JSFunction::initAtom(JSAtom *atom)
|
JSFunction::initAtom(JSAtom *atom)
|
||||||
{
|
{
|
||||||
@ -38,13 +32,6 @@ JSFunction::setGuessedAtom(JSAtom *atom)
|
|||||||
flags |= HAS_GUESSED_ATOM;
|
flags |= HAS_GUESSED_ATOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline JSObject *
|
|
||||||
JSFunction::environment() const
|
|
||||||
{
|
|
||||||
JS_ASSERT(isInterpreted());
|
|
||||||
return u.i.env_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
JSFunction::setEnvironment(JSObject *obj)
|
JSFunction::setEnvironment(JSObject *obj)
|
||||||
{
|
{
|
||||||
@ -59,28 +46,6 @@ JSFunction::initEnvironment(JSObject *obj)
|
|||||||
((js::HeapPtrObject *)&u.i.env_)->init(obj);
|
((js::HeapPtrObject *)&u.i.env_)->init(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
JSFunction::initNative(js::Native native, const JSJitInfo *data)
|
|
||||||
{
|
|
||||||
JS_ASSERT(native);
|
|
||||||
u.n.native = native;
|
|
||||||
u.n.jitinfo = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const JSJitInfo *
|
|
||||||
JSFunction::jitInfo() const
|
|
||||||
{
|
|
||||||
JS_ASSERT(isNative());
|
|
||||||
return u.n.jitinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
JSFunction::setJitInfo(const JSJitInfo *data)
|
|
||||||
{
|
|
||||||
JS_ASSERT(isNative());
|
|
||||||
u.n.jitinfo = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
JSFunction::initializeExtended()
|
JSFunction::initializeExtended()
|
||||||
{
|
{
|
||||||
@ -105,45 +70,8 @@ JSFunction::setExtendedSlot(size_t which, const js::Value &val)
|
|||||||
toExtended()->extendedSlots[which] = val;
|
toExtended()->extendedSlots[which] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const js::Value &
|
|
||||||
JSFunction::getExtendedSlot(size_t which) const
|
|
||||||
{
|
|
||||||
JS_ASSERT(which < mozilla::ArrayLength(toExtended()->extendedSlots));
|
|
||||||
return toExtended()->extendedSlots[which];
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
extern JS_ALWAYS_INLINE bool
|
|
||||||
SameTraceType(const Value &lhs, const Value &rhs)
|
|
||||||
{
|
|
||||||
return SameType(lhs, rhs) &&
|
|
||||||
(lhs.isPrimitive() ||
|
|
||||||
lhs.toObject().is<JSFunction>() == rhs.toObject().is<JSFunction>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Valueified JS_IsConstructing. */
|
|
||||||
static JS_ALWAYS_INLINE bool
|
|
||||||
IsConstructing(const Value *vp)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
JSObject *callee = &JS_CALLEE(cx, vp).toObject();
|
|
||||||
if (callee->is<JSFunction>()) {
|
|
||||||
JSFunction *fun = &callee->as<JSFunction>();
|
|
||||||
JS_ASSERT(fun->isNativeConstructor());
|
|
||||||
} else {
|
|
||||||
JS_ASSERT(callee->getClass()->construct != NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return vp[1].isMagic();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
IsConstructing(CallReceiver call)
|
|
||||||
{
|
|
||||||
return IsConstructing(call.base());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *
|
inline const char *
|
||||||
GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
||||||
{
|
{
|
||||||
@ -153,12 +81,6 @@ GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
|
|||||||
return js_anonymous_str;
|
return js_anonymous_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern JSBool
|
|
||||||
Function(JSContext *cx, unsigned argc, Value *vp);
|
|
||||||
|
|
||||||
extern bool
|
|
||||||
IsBuiltinFunctionConstructor(JSFunction *fun);
|
|
||||||
|
|
||||||
static inline JSObject *
|
static inline JSObject *
|
||||||
SkipScopeParent(JSObject *parent)
|
SkipScopeParent(JSObject *parent)
|
||||||
{
|
{
|
||||||
@ -224,20 +146,6 @@ CloneFunctionObjectIfNotSingleton(JSContext *cx, HandleFunction fun, HandleObjec
|
|||||||
|
|
||||||
} /* namespace js */
|
} /* namespace js */
|
||||||
|
|
||||||
inline bool
|
|
||||||
JSFunction::isHeavyweight() const
|
|
||||||
{
|
|
||||||
JS_ASSERT(!isInterpretedLazy());
|
|
||||||
|
|
||||||
if (isNative())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Note: this should be kept in sync with FunctionBox::isHeavyweight().
|
|
||||||
return nonLazyScript()->bindings.hasAnyAliasedBindings() ||
|
|
||||||
nonLazyScript()->funHasExtensibleScope ||
|
|
||||||
nonLazyScript()->funNeedsDeclEnvObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline JSScript *
|
inline JSScript *
|
||||||
JSFunction::existingScript()
|
JSFunction::existingScript()
|
||||||
{
|
{
|
||||||
@ -272,17 +180,6 @@ JSFunction::initScript(JSScript *script_)
|
|||||||
mutableScript().init(script_);
|
mutableScript().init(script_);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
JSFunction::initLazyScript(js::LazyScript *lazy)
|
|
||||||
{
|
|
||||||
JS_ASSERT(isInterpreted());
|
|
||||||
|
|
||||||
flags &= ~INTERPRETED;
|
|
||||||
flags |= INTERPRETED_LAZY;
|
|
||||||
|
|
||||||
u.i.s.lazy_ = lazy;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline JSObject *
|
inline JSObject *
|
||||||
JSFunction::getBoundFunctionTarget() const
|
JSFunction::getBoundFunctionTarget() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user