mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-18 10:23:08 +09:00
Convert CopyBoxedOrUnboxedDenseElements to something that doesn't crash.
This commit is contained in:
parent
a7d7332c7b
commit
ec0e78d127
3 changed files with 33 additions and 23 deletions
|
|
@ -2361,6 +2361,22 @@ CanOptimizeForDenseStorage(HandleObject arr, uint32_t startingIndex, uint32_t co
|
|||
startingIndex + count <= arr->as<NativeObject>().getDenseInitializedLength();
|
||||
}
|
||||
|
||||
static inline DenseElementResult
|
||||
CopyDenseElements(JSContext* cx, NativeObject* dst, NativeObject* src,
|
||||
uint32_t dstStart, uint32_t srcStart, uint32_t length)
|
||||
{
|
||||
MOZ_ASSERT(dst->getDenseInitializedLength() == dstStart);
|
||||
MOZ_ASSERT(src->getDenseInitializedLength() >= srcStart + length);
|
||||
MOZ_ASSERT(dst->getDenseCapacity() >= dstStart + length);
|
||||
|
||||
dst->setDenseInitializedLength(dstStart + length);
|
||||
|
||||
const Value* vp = src->getDenseElements() + srcStart;
|
||||
dst->initDenseElements(dstStart, vp, length);
|
||||
|
||||
return DenseElementResult::Success;
|
||||
}
|
||||
|
||||
/* ES 2016 draft Mar 25, 2016 22.1.3.26. */
|
||||
bool
|
||||
js::array_splice(JSContext* cx, unsigned argc, Value* vp)
|
||||
|
|
@ -2459,7 +2475,9 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI
|
|||
|
||||
/* Steps 10-11. */
|
||||
DebugOnly<DenseElementResult> result =
|
||||
CopyBoxedOrUnboxedDenseElements(cx, arr, obj, 0, actualStart, actualDeleteCount);
|
||||
CopyDenseElements(cx, &arr->as<NativeObject>(),
|
||||
&obj->as<NativeObject>(), 0,
|
||||
actualStart, actualDeleteCount);
|
||||
MOZ_ASSERT(result.value == DenseElementResult::Success);
|
||||
|
||||
/* Step 12 (implicit). */
|
||||
|
|
@ -2827,7 +2845,7 @@ ArraySliceOrdinary(JSContext* cx, HandleObject obj, uint32_t length, uint32_t be
|
|||
|
||||
if (count) {
|
||||
DebugOnly<DenseElementResult> result =
|
||||
CopyBoxedOrUnboxedDenseElements(cx, narr, obj, 0, begin, count);
|
||||
CopyDenseElements(cx, &narr->as<NativeObject>(), &obj->as<NativeObject>(), 0, begin, count);
|
||||
MOZ_ASSERT(result.value == DenseElementResult::Success);
|
||||
}
|
||||
arr.set(narr);
|
||||
|
|
@ -2968,7 +2986,7 @@ ArraySliceDenseKernel(JSContext* cx, ArrayObject* arr, int32_t beginArg, int32_t
|
|||
if (count) {
|
||||
if (!result->ensureElements(cx, count))
|
||||
return false;
|
||||
CopyBoxedOrUnboxedDenseElements(cx, result, arr, 0, begin, count);
|
||||
CopyDenseElements(cx, &result->as<NativeObject>(), &arr->as<NativeObject>(), 0, begin, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue