зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1272697 - Part 1: Change ArrayBufferCopyData self-hosting intrinsic to take a start offset for the destination. r=lth
MozReview-Commit-ID: LroQFwbeAhi
This commit is contained in:
Родитель
c381e3ad69
Коммит
50b408fb96
|
@ -2,8 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
#include "TypedObjectConstants.h"
|
||||
|
||||
function ViewedArrayBufferIfReified(tarray) {
|
||||
assert(IsTypedArray(tarray), "non-typed array asked for its buffer");
|
||||
|
||||
|
@ -1650,7 +1648,7 @@ function ArrayBufferSlice(start, end) {
|
|||
ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED);
|
||||
|
||||
// Steps 19-21.
|
||||
ArrayBufferCopyData(new_, O, first | 0, newLen | 0, isWrapped);
|
||||
ArrayBufferCopyData(new_, 0, O, first | 0, newLen | 0, isWrapped);
|
||||
|
||||
// Step 22.
|
||||
return new_;
|
||||
|
@ -1736,7 +1734,7 @@ function SharedArrayBufferSlice(start, end) {
|
|||
ThrowTypeError(JSMSG_SHORT_SHARED_ARRAY_BUFFER_RETURNED, newLen, actualLen);
|
||||
|
||||
// Steps 16-18.
|
||||
SharedArrayBufferCopyData(new_, O, first | 0, newLen | 0, isWrapped);
|
||||
SharedArrayBufferCopyData(new_, 0, O, first | 0, newLen | 0, isWrapped);
|
||||
|
||||
// Step 19.
|
||||
return new_;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "SelfHostingDefines.h"
|
||||
#include "TypedObjectConstants.h"
|
||||
|
||||
// Assertions and debug printing, defined here instead of in the header above
|
||||
// to make `assert` invisible to C++.
|
||||
|
|
|
@ -1225,15 +1225,16 @@ ArrayBufferObject::finalize(FreeOp* fop, JSObject* obj)
|
|||
}
|
||||
|
||||
/* static */ void
|
||||
ArrayBufferObject::copyData(Handle<ArrayBufferObject*> toBuffer,
|
||||
Handle<ArrayBufferObject*> fromBuffer,
|
||||
uint32_t fromIndex, uint32_t count)
|
||||
ArrayBufferObject::copyData(Handle<ArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||
Handle<ArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||
uint32_t count)
|
||||
{
|
||||
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
||||
MOZ_ASSERT(toBuffer->byteLength() >= toIndex + count);
|
||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
||||
|
||||
memcpy(toBuffer->dataPointer(), fromBuffer->dataPointer() + fromIndex, count);
|
||||
memcpy(toBuffer->dataPointer() + toIndex, fromBuffer->dataPointer() + fromIndex, count);
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
|
|
|
@ -259,9 +259,9 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared
|
|||
template<typename T>
|
||||
static bool createTypedArrayFromBuffer(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
static void copyData(Handle<ArrayBufferObject*> toBuffer,
|
||||
Handle<ArrayBufferObject*> fromBuffer,
|
||||
uint32_t fromIndex, uint32_t count);
|
||||
static void copyData(Handle<ArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||
Handle<ArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||
uint32_t count);
|
||||
|
||||
static void trace(JSTracer* trc, JSObject* obj);
|
||||
static void objectMoved(JSObject* obj, const JSObject* old);
|
||||
|
|
|
@ -1011,9 +1011,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>();
|
||||
|
@ -1027,11 +1027,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;
|
||||
|
@ -2499,14 +2500,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("SharedArrayBuffersMemorySame",
|
||||
intrinsic_SharedArrayBuffersMemorySame, 2,0),
|
||||
|
||||
|
|
|
@ -328,15 +328,16 @@ SharedArrayBufferObject::addSizeOfExcludingThis(JSObject* obj, mozilla::MallocSi
|
|||
}
|
||||
|
||||
/* static */ void
|
||||
SharedArrayBufferObject::copyData(Handle<SharedArrayBufferObject*> toBuffer,
|
||||
Handle<SharedArrayBufferObject*> fromBuffer,
|
||||
uint32_t fromIndex, uint32_t count)
|
||||
SharedArrayBufferObject::copyData(Handle<SharedArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||
Handle<SharedArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||
uint32_t count)
|
||||
{
|
||||
MOZ_ASSERT(toBuffer->byteLength() >= count);
|
||||
MOZ_ASSERT(toBuffer->byteLength() >= toIndex + count);
|
||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex);
|
||||
MOZ_ASSERT(fromBuffer->byteLength() >= fromIndex + count);
|
||||
|
||||
jit::AtomicOperations::memcpySafeWhenRacy(toBuffer->dataPointerShared(),
|
||||
jit::AtomicOperations::memcpySafeWhenRacy(toBuffer->dataPointerShared() + toIndex,
|
||||
fromBuffer->dataPointerShared() + fromIndex,
|
||||
count);
|
||||
}
|
||||
|
|
|
@ -148,9 +148,9 @@ class SharedArrayBufferObject : public ArrayBufferObjectMaybeShared
|
|||
static void addSizeOfExcludingThis(JSObject* obj, mozilla::MallocSizeOf mallocSizeOf,
|
||||
JS::ClassInfo* info);
|
||||
|
||||
static void copyData(Handle<SharedArrayBufferObject*> toBuffer,
|
||||
Handle<SharedArrayBufferObject*> fromBuffer,
|
||||
uint32_t fromIndex, uint32_t count);
|
||||
static void copyData(Handle<SharedArrayBufferObject*> toBuffer, uint32_t toIndex,
|
||||
Handle<SharedArrayBufferObject*> fromBuffer, uint32_t fromIndex,
|
||||
uint32_t count);
|
||||
|
||||
SharedArrayRawBuffer* rawBufferObject() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче