mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-19 21:57:30 +09:00
Clean up and rename MoveBoxedOrUnboxedDenseElements.
This commit is contained in:
parent
ec0e78d127
commit
79dfc644d3
2 changed files with 19 additions and 22 deletions
|
|
@ -2132,6 +2132,20 @@ SetInitializedLength(JSContext* cx, NativeObject* obj, size_t initlen)
|
||||||
obj->shrinkElements(cx, initlen);
|
obj->shrinkElements(cx, initlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DenseElementResult
|
||||||
|
MoveDenseElements(JSContext* cx, NativeObject* obj, uint32_t dstStart, uint32_t srcStart,
|
||||||
|
uint32_t length)
|
||||||
|
{
|
||||||
|
if (obj->denseElementsAreFrozen())
|
||||||
|
return DenseElementResult::Incomplete;
|
||||||
|
|
||||||
|
if (!obj->maybeCopyElementsForWrite(cx))
|
||||||
|
return DenseElementResult::Failure;
|
||||||
|
obj->moveDenseElements(dstStart, srcStart, length);
|
||||||
|
|
||||||
|
return DenseElementResult::Success;
|
||||||
|
}
|
||||||
|
|
||||||
static DenseElementResult
|
static DenseElementResult
|
||||||
ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval)
|
ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval)
|
||||||
{
|
{
|
||||||
|
|
@ -2153,7 +2167,7 @@ ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval)
|
||||||
if (rval.isMagic(JS_ELEMENTS_HOLE))
|
if (rval.isMagic(JS_ELEMENTS_HOLE))
|
||||||
rval.setUndefined();
|
rval.setUndefined();
|
||||||
|
|
||||||
DenseElementResult result = MoveBoxedOrUnboxedDenseElements(cx, obj, 0, 1, initlen - 1);
|
DenseElementResult result = MoveDenseElements(cx, &obj->as<NativeObject>(), 0, 1, initlen - 1);
|
||||||
if (result != DenseElementResult::Success)
|
if (result != DenseElementResult::Success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
@ -2514,8 +2528,7 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI
|
||||||
if (CanOptimizeForDenseStorage(obj, 0, len, cx)) {
|
if (CanOptimizeForDenseStorage(obj, 0, len, cx)) {
|
||||||
/* Steps 15.a-b. */
|
/* Steps 15.a-b. */
|
||||||
DenseElementResult result =
|
DenseElementResult result =
|
||||||
MoveBoxedOrUnboxedDenseElements(cx, obj, targetIndex, sourceIndex,
|
MoveDenseElements(cx, &obj->as<NativeObject>(), targetIndex, sourceIndex, len - sourceIndex);
|
||||||
len - sourceIndex);
|
|
||||||
MOZ_ASSERT(result != DenseElementResult::Incomplete);
|
MOZ_ASSERT(result != DenseElementResult::Incomplete);
|
||||||
if (result == DenseElementResult::Failure)
|
if (result == DenseElementResult::Failure)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2601,9 +2614,9 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI
|
||||||
|
|
||||||
if (CanOptimizeForDenseStorage(obj, len, itemCount - actualDeleteCount, cx)) {
|
if (CanOptimizeForDenseStorage(obj, len, itemCount - actualDeleteCount, cx)) {
|
||||||
DenseElementResult result =
|
DenseElementResult result =
|
||||||
MoveBoxedOrUnboxedDenseElements(cx, obj, actualStart + itemCount,
|
MoveDenseElements(cx, &obj->as<NativeObject>(), actualStart + itemCount,
|
||||||
actualStart + actualDeleteCount,
|
actualStart + actualDeleteCount,
|
||||||
len - (actualStart + actualDeleteCount));
|
len - (actualStart + actualDeleteCount));
|
||||||
MOZ_ASSERT(result != DenseElementResult::Incomplete);
|
MOZ_ASSERT(result != DenseElementResult::Incomplete);
|
||||||
if (result == DenseElementResult::Failure)
|
if (result == DenseElementResult::Failure)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -210,22 +210,6 @@ SetOrExtendBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj,
|
||||||
return DenseElementResult::Success;
|
return DenseElementResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DenseElementResult
|
|
||||||
MoveBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, uint32_t dstStart, uint32_t srcStart,
|
|
||||||
uint32_t length)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(obj->isNative());
|
|
||||||
|
|
||||||
if (obj->as<NativeObject>().denseElementsAreFrozen())
|
|
||||||
return DenseElementResult::Incomplete;
|
|
||||||
|
|
||||||
if (!obj->as<NativeObject>().maybeCopyElementsForWrite(cx))
|
|
||||||
return DenseElementResult::Failure;
|
|
||||||
obj->as<NativeObject>().moveDenseElements(dstStart, srcStart, length);
|
|
||||||
|
|
||||||
return DenseElementResult::Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace js
|
} // namespace js
|
||||||
|
|
||||||
#endif // vm_UnboxedObject_inl_h
|
#endif // vm_UnboxedObject_inl_h
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue