Issue #1442 - Part 1: Change ArrayBufferCopyData self-hosting intrinsic to take a start offset for the destination. This will be needed to manage stream chunks. https://bugzilla.mozilla.org/show_bug.cgi?id=1272697

This commit is contained in:
Brian Smith 2023-09-27 09:36:44 -05:00 committed by roytam1
commit 90ca1f569a
7 changed files with 28 additions and 26 deletions

View file

@ -1098,9 +1098,9 @@ static bool
intrinsic_ArrayBufferCopyData(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() == 5);
MOZ_ASSERT(args.length() == 6);
bool isWrapped = args[4].toBoolean();
bool isWrapped = args[5].toBoolean();
Rooted<T*> toBuffer(cx);
if (!isWrapped) {
toBuffer = &args[0].toObject().as<T>();
@ -1114,11 +1114,12 @@ intrinsic_ArrayBufferCopyData(JSContext* cx, unsigned argc, Value* vp)
}
toBuffer = toBufferObj.as<T>();
}
Rooted<T*> fromBuffer(cx, &args[1].toObject().as<T>());
uint32_t fromIndex = uint32_t(args[2].toInt32());
uint32_t count = uint32_t(args[3].toInt32());
uint32_t toIndex = uint32_t(args[1].toInt32());
Rooted<T*> fromBuffer(cx, &args[2].toObject().as<T>());
uint32_t fromIndex = uint32_t(args[3].toInt32());
uint32_t count = uint32_t(args[4].toInt32());
T::copyData(toBuffer, fromBuffer, fromIndex, count);
T::copyData(toBuffer, toIndex, fromBuffer, fromIndex, count);
args.rval().setUndefined();
return true;
@ -2426,14 +2427,14 @@ static const JSFunctionSpec intrinsic_functions[] = {
intrinsic_PossiblyWrappedArrayBufferByteLength<ArrayBufferObject>, 1,0,
IntrinsicPossiblyWrappedArrayBufferByteLength),
JS_FN("ArrayBufferCopyData",
intrinsic_ArrayBufferCopyData<ArrayBufferObject>, 5,0),
intrinsic_ArrayBufferCopyData<ArrayBufferObject>, 6,0),
JS_FN("SharedArrayBufferByteLength",
intrinsic_ArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
JS_FN("PossiblyWrappedSharedArrayBufferByteLength",
intrinsic_PossiblyWrappedArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
JS_FN("SharedArrayBufferCopyData",
intrinsic_ArrayBufferCopyData<SharedArrayBufferObject>, 5,0),
intrinsic_ArrayBufferCopyData<SharedArrayBufferObject>, 6,0),
JS_FN("IsUint8TypedArray", intrinsic_IsUint8TypedArray, 1,0),
JS_FN("IsInt8TypedArray", intrinsic_IsInt8TypedArray, 1,0),