summaryrefslogtreecommitdiff
path: root/js/src/vm/NativeObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm/NativeObject.h')
-rw-r--r--js/src/vm/NativeObject.h74
1 files changed, 34 insertions, 40 deletions
diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h
index d2c06eabc1..9cc6d54366 100644
--- a/js/src/vm/NativeObject.h
+++ b/js/src/vm/NativeObject.h
@@ -339,16 +339,19 @@ IsObjectValueInCompartment(const Value& v, JSCompartment* comp);
#endif
// Operations which change an object's dense elements can either succeed, fail,
-// or be unable to complete. For native objects, the latter is used when the
-// object's elements must become sparse instead. The enum below is used for
-// such operations, and for similar operations on unboxed arrays and methods
-// that work on both kinds of objects.
+// or be unable to complete. The latter is used when the object's elements must
+// become sparse instead. The enum below is used for such operations.
enum class DenseElementResult {
Failure,
Success,
Incomplete
};
+enum class ShouldUpdateTypes {
+ Update,
+ DontUpdate
+};
+
/*
* NativeObject specifies the internal implementation of a native object.
*
@@ -467,11 +470,6 @@ class NativeObject : public ShapedObject
// that are (temporarily) inconsistent.
void setLastPropertyMakeNonNative(Shape* shape);
- // As for setLastProperty(), but changes the class associated with the
- // object to a native one. The object's type has already been changed, and
- // this brings the shape into sync with it.
- void setLastPropertyMakeNative(ExclusiveContext* cx, Shape* shape);
-
// Newly-created TypedArrays that map a SharedArrayBuffer are
// marked as shared by giving them an ObjectElements that has the
// ObjectElements::SHARED_MEMORY flag set.
@@ -493,8 +491,8 @@ class NativeObject : public ShapedObject
void checkShapeConsistency() { }
#endif
- Shape*
- replaceWithNewEquivalentShape(ExclusiveContext* cx,
+ static Shape*
+ replaceWithNewEquivalentShape(ExclusiveContext* cx, HandleNativeObject obj,
Shape* existingShape, Shape* newShape = nullptr,
bool accessorShape = false);
@@ -512,7 +510,7 @@ class NativeObject : public ShapedObject
*/
bool setSlotSpan(ExclusiveContext* cx, uint32_t span);
- bool toDictionaryMode(ExclusiveContext* cx);
+ static MOZ_MUST_USE bool toDictionaryMode(ExclusiveContext* cx, HandleNativeObject obj);
private:
friend class TenuringTracer;
@@ -611,12 +609,15 @@ class NativeObject : public ShapedObject
}
public:
- bool generateOwnShape(ExclusiveContext* cx, Shape* newShape = nullptr) {
- return replaceWithNewEquivalentShape(cx, lastProperty(), newShape);
+ static MOZ_MUST_USE bool generateOwnShape(ExclusiveContext* cx, HandleNativeObject obj,
+ Shape* newShape = nullptr)
+ {
+ return replaceWithNewEquivalentShape(cx, obj, obj->lastProperty(), newShape);
}
- bool shadowingShapeChange(ExclusiveContext* cx, const Shape& shape);
- bool clearFlag(ExclusiveContext* cx, BaseShape::Flag flag);
+ static MOZ_MUST_USE bool shadowingShapeChange(ExclusiveContext* cx, HandleNativeObject obj,
+ const Shape& shape);
+ static bool clearFlag(ExclusiveContext* cx, HandleNativeObject obj, BaseShape::Flag flag);
// The maximum number of slots in an object.
// |MAX_SLOTS_COUNT * sizeof(JS::Value)| shouldn't overflow
@@ -743,10 +744,10 @@ class NativeObject : public ShapedObject
bool allowDictionary = true);
/* Add a data property whose id is not yet in this scope. */
- Shape* addDataProperty(ExclusiveContext* cx,
- jsid id_, uint32_t slot, unsigned attrs);
- Shape* addDataProperty(ExclusiveContext* cx, HandlePropertyName name,
- uint32_t slot, unsigned attrs);
+ static Shape* addDataProperty(ExclusiveContext* cx, HandleNativeObject obj,
+ jsid id_, uint32_t slot, unsigned attrs);
+ static Shape* addDataProperty(ExclusiveContext* cx, HandleNativeObject obj,
+ HandlePropertyName name, uint32_t slot, unsigned attrs);
/* Add or overwrite a property for id in this scope. */
static Shape*
@@ -766,7 +767,7 @@ class NativeObject : public ShapedObject
unsigned attrs, JSGetterOp getter, JSSetterOp setter);
/* Remove the property named by id from this object. */
- bool removeProperty(ExclusiveContext* cx, jsid id);
+ static bool removeProperty(ExclusiveContext* cx, HandleNativeObject obj, jsid id);
/* Clear the scope, making it empty. */
static void clear(ExclusiveContext* cx, HandleNativeObject obj);
@@ -785,7 +786,8 @@ class NativeObject : public ShapedObject
unsigned flags, ShapeTable::Entry* entry, bool allowDictionary,
const AutoKeepShapeTables& keep);
- bool fillInAfterSwap(JSContext* cx, const Vector<Value>& values, void* priv);
+ static MOZ_MUST_USE bool fillInAfterSwap(JSContext* cx, HandleNativeObject obj,
+ const Vector<Value>& values, void* priv);
public:
// Return true if this object has been converted from shared-immutable
@@ -876,7 +878,7 @@ class NativeObject : public ShapedObject
MOZ_ASSERT(end <= getDenseInitializedLength());
MOZ_ASSERT(!denseElementsAreCopyOnWrite());
for (size_t i = start; i < end; i++)
- elements_[i].HeapSlot::~HeapSlot();
+ elements_[i].destroy();
}
/*
@@ -885,7 +887,7 @@ class NativeObject : public ShapedObject
*/
void prepareSlotRangeForOverwrite(size_t start, size_t end) {
for (size_t i = start; i < end; i++)
- getSlotAddressUnchecked(i)->HeapSlot::~HeapSlot();
+ getSlotAddressUnchecked(i)->destroy();
}
public:
@@ -1085,7 +1087,8 @@ class NativeObject : public ShapedObject
for (uint32_t i = 0; i < count; ++i)
elements_[dstStart + i].set(this, HeapSlot::Element, dstStart + i, src[i]);
} else {
- memcpy(&elements_[dstStart], src, count * sizeof(HeapSlot));
+ memcpy(reinterpret_cast<Value*>(&elements_[dstStart]), src,
+ count * sizeof(Value));
elementsRangeWriteBarrierPost(dstStart, count);
}
}
@@ -1094,7 +1097,7 @@ class NativeObject : public ShapedObject
MOZ_ASSERT(dstStart + count <= getDenseCapacity());
MOZ_ASSERT(!denseElementsAreCopyOnWrite());
MOZ_ASSERT(!denseElementsAreFrozen());
- memcpy(&elements_[dstStart], src, count * sizeof(HeapSlot));
+ memcpy(reinterpret_cast<Value*>(&elements_[dstStart]), src, count * sizeof(Value));
elementsRangeWriteBarrierPost(dstStart, count);
}
@@ -1142,10 +1145,14 @@ class NativeObject : public ShapedObject
MOZ_ASSERT(!denseElementsAreCopyOnWrite());
MOZ_ASSERT(!denseElementsAreFrozen());
- memmove(elements_ + dstStart, elements_ + srcStart, count * sizeof(Value));
+ memmove(elements_ + dstStart, elements_ + srcStart, count * sizeof(HeapSlot));
elementsRangeWriteBarrierPost(dstStart, count);
}
+ inline DenseElementResult
+ setOrExtendDenseElements(ExclusiveContext* cx, uint32_t start, const Value* vp, uint32_t count,
+ ShouldUpdateTypes updateTypes = ShouldUpdateTypes::Update);
+
bool shouldConvertDoubleElements() {
return getElementsHeader()->shouldConvertDoubleElements();
}
@@ -1467,19 +1474,6 @@ NativeGetExistingProperty(JSContext* cx, HandleObject receiver, HandleNativeObje
/* * */
-/*
- * If obj has an already-resolved data property for id, return true and
- * store the property value in *vp.
- */
-extern bool
-HasDataProperty(JSContext* cx, NativeObject* obj, jsid id, Value* vp);
-
-inline bool
-HasDataProperty(JSContext* cx, NativeObject* obj, PropertyName* name, Value* vp)
-{
- return HasDataProperty(cx, obj, NameToId(name), vp);
-}
-
extern bool
GetPropertyForNameLookup(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp);