mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
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:
parent
2ca5715149
commit
90ca1f569a
7 changed files with 28 additions and 26 deletions
|
|
@ -2,8 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "TypedObjectConstants.h"
|
|
||||||
|
|
||||||
function ViewedArrayBufferIfReified(tarray) {
|
function ViewedArrayBufferIfReified(tarray) {
|
||||||
assert(IsTypedArray(tarray), "non-typed array asked for its buffer");
|
assert(IsTypedArray(tarray), "non-typed array asked for its buffer");
|
||||||
|
|
||||||
|
|
@ -1781,7 +1779,7 @@ function ArrayBufferSlice(start, end) {
|
||||||
ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED);
|
ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED);
|
||||||
|
|
||||||
// Steps 19-21.
|
// Steps 19-21.
|
||||||
ArrayBufferCopyData(new_, O, first | 0, newLen | 0, isWrapped);
|
ArrayBufferCopyData(new_, 0, O, first | 0, newLen | 0, isWrapped);
|
||||||
|
|
||||||
// Step 22.
|
// Step 22.
|
||||||
return new_;
|
return new_;
|
||||||
|
|
@ -1863,7 +1861,7 @@ function SharedArrayBufferSlice(start, end) {
|
||||||
ThrowTypeError(JSMSG_SHORT_SHARED_ARRAY_BUFFER_RETURNED, newLen, actualLen);
|
ThrowTypeError(JSMSG_SHORT_SHARED_ARRAY_BUFFER_RETURNED, newLen, actualLen);
|
||||||
|
|
||||||
// Steps 16-18.
|
// Steps 16-18.
|
||||||
SharedArrayBufferCopyData(new_, O, first | 0, newLen | 0, isWrapped);
|
SharedArrayBufferCopyData(new_, 0, O, first | 0, newLen | 0, isWrapped);
|
||||||
|
|
||||||
// Step 19.
|
// Step 19.
|
||||||
return new_;
|
return new_;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SelfHostingDefines.h"
|
#include "SelfHostingDefines.h"
|
||||||
|
#include "TypedObjectConstants.h"
|
||||||
|
|
||||||
// Assertions and debug printing, defined here instead of in the header above
|
// Assertions and debug printing, defined here instead of in the header above
|
||||||
// to make `assert` invisible to C++.
|
// to make `assert` invisible to C++.
|
||||||
|
|
|
||||||
|
|
@ -1255,15 +1255,16 @@ ArrayBufferObject::finalize(FreeOp* fop, JSObject* obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
ArrayBufferObject::copyData(Handle<ArrayBufferObject*> toBuffer,
|
ArrayBufferObject::copyData(Handle<ArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||||
Handle<ArrayBufferObject*> fromBuffer,
|
Handle<ArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||||
uint32_t fromIndex, uint32_t count)
|
uint32_t count)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
||||||
|
MOZ_ASSERT(toBuffer->byteLength() >= toIndex + count);
|
||||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
||||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
||||||
|
|
||||||
memcpy(toBuffer->dataPointer(), fromBuffer->dataPointer() + fromIndex, count);
|
memcpy(toBuffer->dataPointer() + toIndex, fromBuffer->dataPointer() + fromIndex, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
|
|
|
||||||
|
|
@ -261,9 +261,9 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool createTypedArrayFromBuffer(JSContext* cx, unsigned argc, Value* vp);
|
static bool createTypedArrayFromBuffer(JSContext* cx, unsigned argc, Value* vp);
|
||||||
|
|
||||||
static void copyData(Handle<ArrayBufferObject*> toBuffer,
|
static void copyData(Handle<ArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||||
Handle<ArrayBufferObject*> fromBuffer,
|
Handle<ArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||||
uint32_t fromIndex, uint32_t count);
|
uint32_t count);
|
||||||
|
|
||||||
static void trace(JSTracer* trc, JSObject* obj);
|
static void trace(JSTracer* trc, JSObject* obj);
|
||||||
static void objectMoved(JSObject* obj, const JSObject* old);
|
static void objectMoved(JSObject* obj, const JSObject* old);
|
||||||
|
|
|
||||||
|
|
@ -1098,9 +1098,9 @@ static bool
|
||||||
intrinsic_ArrayBufferCopyData(JSContext* cx, unsigned argc, Value* vp)
|
intrinsic_ArrayBufferCopyData(JSContext* cx, unsigned argc, Value* vp)
|
||||||
{
|
{
|
||||||
CallArgs args = CallArgsFromVp(argc, 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);
|
Rooted<T*> toBuffer(cx);
|
||||||
if (!isWrapped) {
|
if (!isWrapped) {
|
||||||
toBuffer = &args[0].toObject().as<T>();
|
toBuffer = &args[0].toObject().as<T>();
|
||||||
|
|
@ -1114,11 +1114,12 @@ intrinsic_ArrayBufferCopyData(JSContext* cx, unsigned argc, Value* vp)
|
||||||
}
|
}
|
||||||
toBuffer = toBufferObj.as<T>();
|
toBuffer = toBufferObj.as<T>();
|
||||||
}
|
}
|
||||||
Rooted<T*> fromBuffer(cx, &args[1].toObject().as<T>());
|
uint32_t toIndex = uint32_t(args[1].toInt32());
|
||||||
uint32_t fromIndex = uint32_t(args[2].toInt32());
|
Rooted<T*> fromBuffer(cx, &args[2].toObject().as<T>());
|
||||||
uint32_t count = uint32_t(args[3].toInt32());
|
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();
|
args.rval().setUndefined();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2426,14 +2427,14 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||||
intrinsic_PossiblyWrappedArrayBufferByteLength<ArrayBufferObject>, 1,0,
|
intrinsic_PossiblyWrappedArrayBufferByteLength<ArrayBufferObject>, 1,0,
|
||||||
IntrinsicPossiblyWrappedArrayBufferByteLength),
|
IntrinsicPossiblyWrappedArrayBufferByteLength),
|
||||||
JS_FN("ArrayBufferCopyData",
|
JS_FN("ArrayBufferCopyData",
|
||||||
intrinsic_ArrayBufferCopyData<ArrayBufferObject>, 5,0),
|
intrinsic_ArrayBufferCopyData<ArrayBufferObject>, 6,0),
|
||||||
|
|
||||||
JS_FN("SharedArrayBufferByteLength",
|
JS_FN("SharedArrayBufferByteLength",
|
||||||
intrinsic_ArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
|
intrinsic_ArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
|
||||||
JS_FN("PossiblyWrappedSharedArrayBufferByteLength",
|
JS_FN("PossiblyWrappedSharedArrayBufferByteLength",
|
||||||
intrinsic_PossiblyWrappedArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
|
intrinsic_PossiblyWrappedArrayBufferByteLength<SharedArrayBufferObject>, 1,0),
|
||||||
JS_FN("SharedArrayBufferCopyData",
|
JS_FN("SharedArrayBufferCopyData",
|
||||||
intrinsic_ArrayBufferCopyData<SharedArrayBufferObject>, 5,0),
|
intrinsic_ArrayBufferCopyData<SharedArrayBufferObject>, 6,0),
|
||||||
|
|
||||||
JS_FN("IsUint8TypedArray", intrinsic_IsUint8TypedArray, 1,0),
|
JS_FN("IsUint8TypedArray", intrinsic_IsUint8TypedArray, 1,0),
|
||||||
JS_FN("IsInt8TypedArray", intrinsic_IsInt8TypedArray, 1,0),
|
JS_FN("IsInt8TypedArray", intrinsic_IsInt8TypedArray, 1,0),
|
||||||
|
|
|
||||||
|
|
@ -331,15 +331,16 @@ SharedArrayBufferObject::addSizeOfExcludingThis(JSObject* obj, mozilla::MallocSi
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void
|
/* static */ void
|
||||||
SharedArrayBufferObject::copyData(Handle<SharedArrayBufferObject*> toBuffer,
|
SharedArrayBufferObject::copyData(Handle<SharedArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||||
Handle<SharedArrayBufferObject*> fromBuffer,
|
Handle<SharedArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||||
uint32_t fromIndex, uint32_t count)
|
uint32_t count)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
||||||
|
MOZ_ASSERT(toBuffer->byteLength() >= toIndex + count);
|
||||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
||||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
||||||
|
|
||||||
jit::AtomicOperations::memcpySafeWhenRacy(toBuffer->dataPointerShared(),
|
jit::AtomicOperations::memcpySafeWhenRacy(toBuffer->dataPointerShared() + toIndex,
|
||||||
fromBuffer->dataPointerShared() + fromIndex,
|
fromBuffer->dataPointerShared() + fromIndex,
|
||||||
count);
|
count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,9 +146,9 @@ class SharedArrayBufferObject : public ArrayBufferObjectMaybeShared
|
||||||
static void addSizeOfExcludingThis(JSObject* obj, mozilla::MallocSizeOf mallocSizeOf,
|
static void addSizeOfExcludingThis(JSObject* obj, mozilla::MallocSizeOf mallocSizeOf,
|
||||||
JS::ClassInfo* info);
|
JS::ClassInfo* info);
|
||||||
|
|
||||||
static void copyData(Handle<SharedArrayBufferObject*> toBuffer,
|
static void copyData(Handle<SharedArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||||
Handle<SharedArrayBufferObject*> fromBuffer,
|
Handle<SharedArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||||
uint32_t fromIndex, uint32_t count);
|
uint32_t count);
|
||||||
|
|
||||||
SharedArrayRawBuffer* rawBufferObject() const;
|
SharedArrayRawBuffer* rawBufferObject() const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue