diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 59ab94b33da3..e21c2debef4e 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -113,7 +113,6 @@ struct TypeInferenceSizes; namespace js { class AutoDebugModeInvalidation; -class ArrayBufferObject; class DebugScopes; class WeakMapBase; } diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index a49a1cafebe2..c33824c62161 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3358,9 +3358,10 @@ js::gc::MarkingValidator::nonIncrementalMark() } /* - * Save the lists of live weakmaps and array buffers for the compartments we - * are collecting. + * Temporarily clear the lists of live weakmaps and array buffers for the + * compartments we are collecting. */ + WeakMapVector weakmaps; ArrayBufferVector arrayBuffers; for (GCCompartmentsIter c(runtime); !c.done(); c.next()) { @@ -3377,10 +3378,6 @@ js::gc::MarkingValidator::nonIncrementalMark() */ initialized = true; - /* - * Reset the lists of live weakmaps and array buffers for the compartments we - * are collecting. - */ for (GCCompartmentsIter c(runtime); !c.done(); c.next()) { WeakMapBase::resetCompartmentWeakMapList(c); ArrayBufferObject::resetArrayBufferList(c); @@ -3437,7 +3434,6 @@ js::gc::MarkingValidator::nonIncrementalMark() Swap(*entry, *bitmap); } - /* Restore the weak map and array buffer lists. */ for (GCCompartmentsIter c(runtime); !c.done(); c.next()) { WeakMapBase::resetCompartmentWeakMapList(c); ArrayBufferObject::resetArrayBufferList(c); diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 97fbefa85262..37eba78754b7 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -165,7 +165,6 @@ extern const Class IntlClass; extern const Class JSONClass; extern const Class MathClass; -class ArrayBufferObject; class GlobalObject; class MapObject; class NewObjectCache; diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 490db9c2c08d..611f3f29a1ea 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -545,6 +545,7 @@ ArrayBufferObject::releaseData(FreeOp *fop) void ArrayBufferObject::setDataPointer(void *data, OwnsState ownsData) { + MOZ_ASSERT_IF(!is(), data != nullptr); setSlot(DATA_SLOT, PrivateValue(data)); setOwnsData(ownsData); } diff --git a/js/src/vm/ObjectImpl.cpp b/js/src/vm/ObjectImpl.cpp index 753ab147c966..19fe70494226 100644 --- a/js/src/vm/ObjectImpl.cpp +++ b/js/src/vm/ObjectImpl.cpp @@ -159,9 +159,7 @@ bool ObjectImpl::canHaveNonEmptyElements() { JSObject *obj = static_cast(this); - if (isNative()) - return !obj->is(); - return obj->is() || obj->is(); + return isNative() && !obj->is(); } #endif // DEBUG diff --git a/js/src/vm/ObjectImpl.h b/js/src/vm/ObjectImpl.h index 73c119312f54..c528903ef29d 100644 --- a/js/src/vm/ObjectImpl.h +++ b/js/src/vm/ObjectImpl.h @@ -193,16 +193,9 @@ class ObjectElements * is <= the length. Memory for elements above the initialized length is * uninitialized, but values between the initialized length and the proper * length are conceptually holes. - * - * ArrayBufferObject uses this field to store byteLength. */ uint32_t initializedLength; - /* - * Beware, one or both of the following fields is clobbered by - * ArrayBufferObject. See GetViewList. - */ - /* Number of allocated slots. */ uint32_t capacity; @@ -287,13 +280,15 @@ IsObjectValueInCompartment(js::Value v, JSCompartment *comp); * The |shape_| member stores the shape of the object, which includes the * object's class and the layout of all its properties. * - * The type member stores the type of the object, which contains its prototype - * object and the possible types of its properties. + * The |type_| member stores the type of the object, which contains its + * prototype object and the possible types of its properties. * * The rest of the object stores its named properties and indexed elements. - * These are stored separately from one another. Objects are followed by an + * These are stored separately from one another. Objects are followed by a * variable-sized array of values for inline storage, which may be used by - * either properties of native objects (fixed slots) or by elements. + * either properties of native objects (fixed slots), by elements (fixed + * elements), or by other data for certain kinds of objects, such as + * ArrayBufferObjects. * * Two native objects with the same shape are guaranteed to have the same * number of fixed slots. @@ -315,12 +310,7 @@ IsObjectValueInCompartment(js::Value v, JSCompartment *comp); * slots may be either names or indexes; no indexed property will be in both * the slots and elements. * - * - For non-native objects other than typed arrays, properties and elements - * are both empty. - * - * - For typed array buffers, elements are used and properties are not used. - * The data indexed by the elements do not represent Values, but primitive - * unboxed integers or floating point values. + * - For non-native objects, slots and elements are both empty. * * The members of this class are currently protected; in the long run this will * will change so that some members are private, and only certain methods that