summaryrefslogtreecommitdiffstats
path: root/js/src/vm
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/vm')
-rw-r--r--js/src/vm/UnboxedObject-inl.h138
1 files changed, 9 insertions, 129 deletions
diff --git a/js/src/vm/UnboxedObject-inl.h b/js/src/vm/UnboxedObject-inl.h
index 499f3604b..b308464fe 100644
--- a/js/src/vm/UnboxedObject-inl.h
+++ b/js/src/vm/UnboxedObject-inl.h
@@ -173,129 +173,9 @@ UnboxedPlainObject::layout() const
}
/////////////////////////////////////////////////////////////////////
-// Combined methods for NativeObject and UnboxedArrayObject accesses.
-/////////////////////////////////////////////////////////////////////
-
-static inline bool
-HasAnyBoxedOrUnboxedDenseElements(JSObject* obj)
-{
- return obj->isNative();
-}
-
-static inline size_t
-GetAnyBoxedOrUnboxedInitializedLength(JSObject* obj)
-{
- if (obj->isNative())
- return obj->as<NativeObject>().getDenseInitializedLength();
- return 0;
-}
-
-static inline size_t
-GetAnyBoxedOrUnboxedCapacity(JSObject* obj)
-{
- if (obj->isNative())
- return obj->as<NativeObject>().getDenseCapacity();
- return 0;
-}
-
-static inline Value
-GetAnyBoxedOrUnboxedDenseElement(JSObject* obj, size_t index)
-{
- return obj->as<NativeObject>().getDenseElement(index);
-}
-
-static inline size_t
-GetAnyBoxedOrUnboxedArrayLength(JSObject* obj)
-{
- return obj->as<ArrayObject>().length();
-}
-
-static inline void
-SetAnyBoxedOrUnboxedArrayLength(JSContext* cx, JSObject* obj, size_t length)
-{
- MOZ_ASSERT(length >= obj->as<ArrayObject>().length());
- obj->as<ArrayObject>().setLength(cx, length);
-}
-
-static inline bool
-SetAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value)
-{
- obj->as<NativeObject>().setDenseElementWithType(cx, index, value);
- return true;
-}
-
-static inline bool
-InitAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value)
-{
- obj->as<NativeObject>().initDenseElementWithType(cx, index, value);
- return true;
-}
-
-/////////////////////////////////////////////////////////////////////
// Template methods for NativeObject and UnboxedArrayObject accesses.
/////////////////////////////////////////////////////////////////////
-static inline JSValueType
-GetBoxedOrUnboxedType(JSObject* obj)
-{
- return JSVAL_TYPE_MAGIC;
-}
-
-static inline bool
-HasBoxedOrUnboxedDenseElements(JSObject* obj)
-{
- return obj->isNative();
-}
-
-static inline size_t
-GetBoxedOrUnboxedInitializedLength(JSObject* obj)
-{
- return obj->as<NativeObject>().getDenseInitializedLength();
-}
-
-static inline DenseElementResult
-SetBoxedOrUnboxedInitializedLength(JSContext* cx, JSObject* obj, size_t initlen)
-{
- size_t oldInitlen = GetBoxedOrUnboxedInitializedLength(obj);
- obj->as<NativeObject>().setDenseInitializedLength(initlen);
- if (initlen < oldInitlen)
- obj->as<NativeObject>().shrinkElements(cx, initlen);
- return DenseElementResult::Success;
-}
-
-static inline size_t
-GetBoxedOrUnboxedCapacity(JSObject* obj)
-{
- return obj->as<NativeObject>().getDenseCapacity();
-}
-
-static inline Value
-GetBoxedOrUnboxedDenseElement(JSObject* obj, size_t index)
-{
- return obj->as<NativeObject>().getDenseElement(index);
-}
-
-static inline void
-SetBoxedOrUnboxedDenseElementNoTypeChange(JSObject* obj, size_t index, const Value& value)
-{
- obj->as<NativeObject>().setDenseElement(index, value);
-}
-
-static inline bool
-SetBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value)
-{
- obj->as<NativeObject>().setDenseElementWithType(cx, index, value);
- return true;
-}
-
-static inline DenseElementResult
-EnsureBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, size_t count)
-{
- if (!obj->as<ArrayObject>().ensureElements(cx, count))
- return DenseElementResult::Failure;
- return DenseElementResult::Success;
-}
-
static inline DenseElementResult
SetOrExtendBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj,
uint32_t start, const Value* vp, uint32_t count,
@@ -334,7 +214,7 @@ static inline DenseElementResult
MoveBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, uint32_t dstStart, uint32_t srcStart,
uint32_t length)
{
- MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj));
+ MOZ_ASSERT(obj->isNative());
if (obj->as<NativeObject>().denseElementsAreFrozen())
return DenseElementResult::Incomplete;
@@ -350,13 +230,13 @@ static inline DenseElementResult
CopyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* dst, JSObject* src,
uint32_t dstStart, uint32_t srcStart, uint32_t length)
{
- MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(src));
- MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(dst));
- MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(dst) == dstStart);
- MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(src) >= srcStart + length);
- MOZ_ASSERT(GetBoxedOrUnboxedCapacity(dst) >= dstStart + length);
+ MOZ_ASSERT(src->isNative());
+ MOZ_ASSERT(dst->isNative());
+ MOZ_ASSERT(dst->as<NativeObject>().getDenseInitializedLength() == dstStart);
+ MOZ_ASSERT(src->as<NativeObject>().getDenseInitializedLength() >= srcStart + length);
+ MOZ_ASSERT(dst->as<NativeObject>().getDenseCapacity() >= dstStart + length);
- SetBoxedOrUnboxedInitializedLength(cx, dst, dstStart + length);
+ dst->as<NativeObject>().setDenseInitializedLength(dstStart + length);
const Value* vp = src->as<NativeObject>().getDenseElements() + srcStart;
dst->as<NativeObject>().initDenseElements(dstStart, vp, length);
@@ -383,7 +263,7 @@ template <typename F>
DenseElementResult
CallBoxedOrUnboxedSpecialization(F f, JSObject* obj)
{
- if (!HasAnyBoxedOrUnboxedDenseElements(obj))
+ if (!obj->isNative())
return DenseElementResult::Incomplete;
return f. DEPENDENT_TEMPLATE_HINT operator()<JSVAL_TYPE_MAGIC>();
}
@@ -393,7 +273,7 @@ template <typename F>
DenseElementResult
CallBoxedOrUnboxedSpecialization(F f, JSObject* obj1, JSObject* obj2)
{
- if (!HasAnyBoxedOrUnboxedDenseElements(obj1) || !HasAnyBoxedOrUnboxedDenseElements(obj2))
+ if (!obj1->isNative() || !obj2->isNative())
return DenseElementResult::Incomplete;
return f. DEPENDENT_TEMPLATE_HINT operator()<JSVAL_TYPE_MAGIC, JSVAL_TYPE_MAGIC>();