Bug 889727 (part 2) - Slim down jsobjinlines.h some more. r=terrence.

--HG--
extra : rebase_source : a03d7da43acfb0eb0012778dd2366ce9a4bc2208
This commit is contained in:
Nicholas Nethercote 2013-07-02 22:14:20 -07:00
Родитель b7c86690d8
Коммит 8c4e0cb8fb
4 изменённых файлов: 81 добавлений и 144 удалений

Просмотреть файл

@ -1448,9 +1448,13 @@ js::NewObjectWithClassProtoCommon(JSContext *cx, js::Class *clasp, JSObject *pro
return obj;
}
JSObject *
js::NewObjectWithType(JSContext *cx, HandleTypeObject type, JSObject *parent, gc::AllocKind allocKind,
NewObjectKind newKind /* = GenericObject */)
/*
* Create a plain object with the specified type. This bypasses getNewType to
* avoid losing creation site information for objects made by scripted 'new'.
*/
static JSObject *
NewObjectWithType(JSContext *cx, HandleTypeObject type, JSObject *parent, gc::AllocKind allocKind,
NewObjectKind newKind = GenericObject)
{
JS_ASSERT(type->proto->hasNewType(&ObjectClass, type));
JS_ASSERT(parent);
@ -3236,8 +3240,8 @@ PurgeProtoChain(JSContext *cx, JSObject *objArg, HandleId id)
return true;
}
bool
js_PurgeScopeChainHelper(JSContext *cx, HandleObject objArg, HandleId id)
static bool
PurgeScopeChainHelper(JSContext *cx, HandleObject objArg, HandleId id)
{
/* Re-root locally so we can re-assign. */
RootedObject obj(cx, objArg);
@ -3267,6 +3271,21 @@ js_PurgeScopeChainHelper(JSContext *cx, HandleObject objArg, HandleId id)
return true;
}
/*
* PurgeScopeChain does nothing if obj is not itself a prototype or parent
* scope, else it reshapes the scope and prototype chains it links. It calls
* PurgeScopeChainHelper, which asserts that obj is flagged as a delegate
* (i.e., obj has ever been on a prototype or parent chain).
*/
static inline bool
PurgeScopeChain(JSContext *cx, JS::HandleObject obj, JS::HandleId id)
{
if (obj->isDelegate())
return PurgeScopeChainHelper(cx, obj, id);
return true;
}
Shape *
js_AddNativeProperty(JSContext *cx, HandleObject obj, HandleId id,
PropertyOp getter, StrictPropertyOp setter, uint32_t slot,
@ -3277,7 +3296,7 @@ js_AddNativeProperty(JSContext *cx, HandleObject obj, HandleId id,
* this optimistically (assuming no failure below) before locking obj, so
* we can lock the shadowed scope.
*/
if (!js_PurgeScopeChain(cx, obj, id))
if (!PurgeScopeChain(cx, obj, id))
return NULL;
Shape *shape =
@ -3512,7 +3531,7 @@ js::DefineNativeProperty(JSContext *cx, HandleObject obj, HandleId id, HandleVal
* is not possible.
*/
if (!(defineHow & DNP_DONT_PURGE)) {
if (!js_PurgeScopeChain(cx, obj, id))
if (!PurgeScopeChain(cx, obj, id))
return false;
}
@ -4478,7 +4497,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
}
/* Purge the property cache of now-shadowed id in obj's scope chain. */
if (!js_PurgeScopeChain(cx, obj, id))
if (!PurgeScopeChain(cx, obj, id))
return false;
if (getter == JS_PropertyStub)

Просмотреть файл

@ -288,18 +288,28 @@ class JSObject : public js::ObjectImpl
static const uint32_t NELEMENTS_LIMIT = JS_BIT(28);
public:
inline bool setDelegate(JSContext *cx);
bool setDelegate(JSContext *cx) {
return setFlag(cx, js::BaseShape::DELEGATE, GENERATE_SHAPE);
}
inline bool isBoundFunction() const;
bool isBoundFunction() const {
return lastProperty()->hasObjectFlag(js::BaseShape::BOUND_FUNCTION);
}
inline bool hasSpecialEquality() const;
inline bool watched() const;
inline bool setWatched(JSContext *cx);
bool watched() const {
return lastProperty()->hasObjectFlag(js::BaseShape::WATCHED);
}
bool setWatched(JSContext *cx) {
return setFlag(cx, js::BaseShape::WATCHED, GENERATE_SHAPE);
}
/* See StackFrame::varObj. */
inline bool isVarObj();
inline bool setVarObj(JSContext *cx);
bool setVarObj(JSContext *cx) {
return setFlag(cx, js::BaseShape::VAROBJ);
}
/*
* Objects with an uncacheable proto can have their prototype mutated
@ -307,18 +317,28 @@ class JSObject : public js::ObjectImpl
* and JIT inline caches should not be filled for lookups across prototype
* lookups on the object.
*/
inline bool hasUncacheableProto() const;
inline bool setUncacheableProto(JSContext *cx);
bool hasUncacheableProto() const {
return lastProperty()->hasObjectFlag(js::BaseShape::UNCACHEABLE_PROTO);
}
bool setUncacheableProto(JSContext *cx) {
return setFlag(cx, js::BaseShape::UNCACHEABLE_PROTO, GENERATE_SHAPE);
}
/*
* Whether SETLELEM was used to access this object. See also the comment near
* PropertyTree::MAX_HEIGHT.
*/
inline bool hadElementsAccess() const;
inline bool setHadElementsAccess(JSContext *cx);
bool hadElementsAccess() const {
return lastProperty()->hasObjectFlag(js::BaseShape::HAD_ELEMENTS_ACCESS);
}
bool setHadElementsAccess(JSContext *cx) {
return setFlag(cx, js::BaseShape::HAD_ELEMENTS_ACCESS);
}
public:
inline bool nativeEmpty() const;
bool nativeEmpty() const {
return lastProperty()->isEmptyShape();
}
bool shadowingShapeChange(JSContext *cx, const js::Shape &shape);
@ -326,11 +346,17 @@ class JSObject : public js::ObjectImpl
* Whether there may be indexed properties on this object, excluding any in
* the object's elements.
*/
inline bool isIndexed() const;
bool isIndexed() const {
return lastProperty()->hasObjectFlag(js::BaseShape::INDEXED);
}
inline uint32_t propertyCount() const;
uint32_t propertyCount() const {
return lastProperty()->entryCount();
}
inline bool hasShapeTable() const;
bool hasShapeTable() const {
return lastProperty()->hasTable();
}
void sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::ObjectsExtraSizes *sizes);
@ -446,7 +472,9 @@ class JSObject : public js::ObjectImpl
* to recover this information in the object's type information after it
* is purged on GC.
*/
inline bool setIteratedSingleton(JSContext *cx);
bool setIteratedSingleton(JSContext *cx) {
return setFlag(cx, js::BaseShape::ITERATED_SINGLETON);
}
/*
* Mark an object as requiring its default 'new' type to have unknown
@ -490,7 +518,9 @@ class JSObject : public js::ObjectImpl
*/
/* Access the parent link of an object. */
inline JSObject *getParent() const;
JSObject *getParent() const {
return lastProperty()->getObjectParent();
}
static bool setParent(JSContext *cx, js::HandleObject obj, js::HandleObject newParent);
/*
@ -501,7 +531,9 @@ class JSObject : public js::ObjectImpl
inline JSObject *enclosingScope();
/* Access the metadata on an object. */
inline JSObject *getMetadata() const;
inline JSObject *getMetadata() const {
return lastProperty()->getObjectMetadata();
}
static bool setMetadata(JSContext *cx, js::HandleObject obj, js::HandleObject newMetadata);
inline js::GlobalObject &global() const;
@ -546,7 +578,7 @@ class JSObject : public js::ObjectImpl
static const char *className(JSContext *cx, js::HandleObject obj);
/* Accessors for elements. */
inline bool ensureElements(JSContext *cx, uint32_t cap);
inline bool ensureElements(JSContext *cx, uint32_t capacity);
bool growElements(js::ThreadSafeContext *tcx, uint32_t newcap);
void shrinkElements(JSContext *cx, uint32_t cap);
void setDynamicElements(js::ObjectElements *header) {

Просмотреть файл

@ -118,18 +118,6 @@ JSObject::finalize(js::FreeOp *fop)
finish(fop);
}
inline JSObject *
JSObject::getParent() const
{
return lastProperty()->getObjectParent();
}
inline JSObject *
JSObject::getMetadata() const
{
return lastProperty()->getObjectMetadata();
}
inline void
JSObject::setLastPropertyInfallible(js::Shape *shape)
{
@ -555,16 +543,6 @@ JSObject::getProto(JSContext *cx, js::HandleObject obj, js::MutableHandleObject
}
}
inline bool JSObject::setIteratedSingleton(JSContext *cx)
{
return setFlag(cx, js::BaseShape::ITERATED_SINGLETON);
}
inline bool JSObject::setDelegate(JSContext *cx)
{
return setFlag(cx, js::BaseShape::DELEGATE, GENERATE_SHAPE);
}
inline bool JSObject::isVarObj()
{
if (is<js::DebugScopeObject>())
@ -572,51 +550,6 @@ inline bool JSObject::isVarObj()
return lastProperty()->hasObjectFlag(js::BaseShape::VAROBJ);
}
inline bool JSObject::setVarObj(JSContext *cx)
{
return setFlag(cx, js::BaseShape::VAROBJ);
}
inline bool JSObject::setWatched(JSContext *cx)
{
return setFlag(cx, js::BaseShape::WATCHED, GENERATE_SHAPE);
}
inline bool JSObject::hasUncacheableProto() const
{
return lastProperty()->hasObjectFlag(js::BaseShape::UNCACHEABLE_PROTO);
}
inline bool JSObject::setUncacheableProto(JSContext *cx)
{
return setFlag(cx, js::BaseShape::UNCACHEABLE_PROTO, GENERATE_SHAPE);
}
inline bool JSObject::hadElementsAccess() const
{
return lastProperty()->hasObjectFlag(js::BaseShape::HAD_ELEMENTS_ACCESS);
}
inline bool JSObject::setHadElementsAccess(JSContext *cx)
{
return setFlag(cx, js::BaseShape::HAD_ELEMENTS_ACCESS);
}
inline bool JSObject::isBoundFunction() const
{
return lastProperty()->hasObjectFlag(js::BaseShape::BOUND_FUNCTION);
}
inline bool JSObject::isIndexed() const
{
return lastProperty()->hasObjectFlag(js::BaseShape::INDEXED);
}
inline bool JSObject::watched() const
{
return lastProperty()->hasObjectFlag(js::BaseShape::WATCHED);
}
/* static */ inline JSObject *
JSObject::create(JSContext *cx, js::gc::AllocKind kind, js::gc::InitialHeap heap,
js::HandleShape shape, js::HandleTypeObject type,
@ -757,24 +690,6 @@ JSObject::nativeSetSlotWithType(JSContext *cx, js::HandleObject obj, js::Shape *
js::types::AddTypePropertyId(cx, obj, shape->propid(), value);
}
inline bool
JSObject::nativeEmpty() const
{
return lastProperty()->isEmptyShape();
}
inline uint32_t
JSObject::propertyCount() const
{
return lastProperty()->entryCount();
}
inline bool
JSObject::hasShapeTable() const
{
return lastProperty()->hasTable();
}
/* static */ inline JSBool
JSObject::getElement(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
uint32_t index, js::MutableHandleValue vp)
@ -1156,18 +1071,6 @@ NewBuiltinClassInstance(JSContext *cx, Class *clasp, NewObjectKind newKind = Gen
return NewBuiltinClassInstance(cx, clasp, allocKind, newKind);
}
bool
FindClassPrototype(JSContext *cx, HandleObject scope, JSProtoKey protoKey,
MutableHandleObject protop, Class *clasp);
/*
* Create a plain object with the specified type. This bypasses getNewType to
* avoid losing creation site information for objects made by scripted 'new'.
*/
JSObject *
NewObjectWithType(JSContext *cx, HandleTypeObject type, JSObject *parent, gc::AllocKind allocKind,
NewObjectKind newKind = GenericObject);
// Used to optimize calls to (new Object())
bool
NewObjectScriptedCall(JSContext *cx, MutableHandleObject obj);
@ -1323,21 +1226,4 @@ js_InitClass(JSContext *cx, js::HandleObject obj, JSObject *parent_proto,
JSObject **ctorp = NULL,
js::gc::AllocKind ctorKind = JSFunction::FinalizeKind);
/*
* js_PurgeScopeChain does nothing if obj is not itself a prototype or parent
* scope, else it reshapes the scope and prototype chains it links. It calls
* js_PurgeScopeChainHelper, which asserts that obj is flagged as a delegate
* (i.e., obj has ever been on a prototype or parent chain).
*/
extern bool
js_PurgeScopeChainHelper(JSContext *cx, JS::HandleObject obj, JS::HandleId id);
inline bool
js_PurgeScopeChain(JSContext *cx, JS::HandleObject obj, JS::HandleId id)
{
if (obj->isDelegate())
return js_PurgeScopeChainHelper(cx, obj, id);
return true;
}
#endif /* jsobjinlines_h */

Просмотреть файл

@ -51,11 +51,11 @@ class Debugger;
* whether eval is allowed (per the global's Content Security Policy).
*
* The first two ranges are necessary to implement js::FindClassObject,
* FindClassPrototype, and spec language speaking in terms of "the original
* Array prototype object", or "as if by the expression new Array()" referring
* to the original Array constructor. The third range stores the (writable and
* even deletable) Object, Array, &c. properties (although a slot won't be used
* again if its property is deleted and readded).
* and spec language speaking in terms of "the original Array prototype
* object", or "as if by the expression new Array()" referring to the original
* Array constructor. The third range stores the (writable and even deletable)
* Object, Array, &c. properties (although a slot won't be used again if its
* property is deleted and readded).
*/
class GlobalObject : public JSObject
{