From 50113c3307086b425191b7328f4c37e6c4cc7fbd Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 16 Feb 2012 19:11:06 -0800 Subject: [PATCH] Bug 728411 - Move more elements bits over to ObjectImpl. r=bhackett --HG-- extra : rebase_source : bcc5f0d8fc44643675e4a9efad84c7419545bb95 --- js/src/jsobj.h | 18 ------------------ js/src/vm/ObjectImpl.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/js/src/jsobj.h b/js/src/jsobj.h index c7b943cf3c6b..0e346eb2d306 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -818,24 +818,6 @@ struct JSObject : public js::ObjectImpl bool growElements(JSContext *cx, uintN cap); void shrinkElements(JSContext *cx, uintN cap); - inline js::HeapValue* fixedElements() const { - JS_STATIC_ASSERT(2 * sizeof(js::Value) == sizeof(js::ObjectElements)); - return &fixedSlots()[2]; - } - - void setFixedElements() { this->elements = fixedElements(); } - - inline bool hasDynamicElements() const { - /* - * Note: for objects with zero fixed slots this could potentially give - * a spurious 'true' result, if the end of this object is exactly - * aligned with the end of its arena and dynamic slots are allocated - * immediately afterwards. Such cases cannot occur for dense arrays - * (which have at least two fixed slots) and can only result in a leak. - */ - return elements != js::emptyObjectElements && elements != fixedElements(); - } - inline js::ElementIteratorObject *asElementIterator(); /* diff --git a/js/src/vm/ObjectImpl.h b/js/src/vm/ObjectImpl.h index a49791ae937a..143f3598f8f5 100644 --- a/js/src/vm/ObjectImpl.h +++ b/js/src/vm/ObjectImpl.h @@ -259,6 +259,26 @@ class ObjectImpl : public gc::Cell return ObjectElements::fromElements(elements); } + inline HeapValue * fixedElements() const { + MOZ_STATIC_ASSERT(2 * sizeof(Value) == sizeof(ObjectElements), + "when elements are stored inline, the first two " + "slots will hold the ObjectElements header"); + return &fixedSlots()[2]; + } + + void setFixedElements() { this->elements = fixedElements(); } + + inline bool hasDynamicElements() const { + /* + * Note: for objects with zero fixed slots this could potentially give + * a spurious 'true' result, if the end of this object is exactly + * aligned with the end of its arena and dynamic slots are allocated + * immediately afterwards. Such cases cannot occur for dense arrays + * (which have at least two fixed slots) and can only result in a leak. + */ + return elements != emptyObjectElements && elements != fixedElements(); + } + /* Write barrier support. */ static inline void readBarrier(ObjectImpl *obj); static inline void writeBarrierPre(ObjectImpl *obj);