diff options
Diffstat (limited to 'js/src/vm')
-rw-r--r-- | js/src/vm/ArrayBufferObject.cpp | 20 | ||||
-rw-r--r-- | js/src/vm/ArrayBufferObject.h | 6 | ||||
-rw-r--r-- | js/src/vm/CommonPropertyNames.h | 53 | ||||
-rw-r--r-- | js/src/vm/GlobalObject.cpp | 11 | ||||
-rw-r--r-- | js/src/vm/Runtime.cpp | 6 | ||||
-rw-r--r-- | js/src/vm/Runtime.h | 7 | ||||
-rw-r--r-- | js/src/vm/SelfHosting.cpp | 22 | ||||
-rw-r--r-- | js/src/vm/SharedArrayObject.cpp | 9 | ||||
-rw-r--r-- | js/src/vm/SharedArrayObject.h | 6 |
9 files changed, 117 insertions, 23 deletions
diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index db1d7c798f..6ace034adb 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -1255,15 +1255,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 @@ -1890,6 +1891,17 @@ JS_GetArrayBufferViewByteLength(JSObject* obj) : obj->as<TypedArrayObject>().byteLength(); } +JS_FRIEND_API(uint32_t) +JS_GetArrayBufferViewByteOffset(JSObject* obj) +{ + obj = CheckedUnwrap(obj); + if (!obj) + return 0; + return obj->is<DataViewObject>() + ? obj->as<DataViewObject>().byteOffset() + : obj->as<TypedArrayObject>().byteOffset(); +} + JS_FRIEND_API(JSObject*) JS_GetObjectAsArrayBufferView(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data) { diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 4ff7962cfb..f4010c6c77 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -261,9 +261,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); diff --git a/js/src/vm/CommonPropertyNames.h b/js/src/vm/CommonPropertyNames.h index f05a4db9be..ebfad89fa0 100644 --- a/js/src/vm/CommonPropertyNames.h +++ b/js/src/vm/CommonPropertyNames.h @@ -18,6 +18,8 @@ macro(apply, apply, "apply") \ macro(args, args, "args") \ macro(arguments, arguments, "arguments") \ + macro(AcquireReadableStreamBYOBReader, AcquireReadableStreamBYOBReader, "AcquireReadableStreamBYOBReader") \ + macro(AcquireReadableStreamDefaultReader, AcquireReadableStreamDefaultReader, "AcquireReadableStreamDefaultReader") \ macro(ArrayBufferSpecies, ArrayBufferSpecies, "ArrayBufferSpecies") \ macro(ArrayIterator, ArrayIterator, "Array Iterator") \ macro(ArrayIteratorNext, ArrayIteratorNext, "ArrayIteratorNext") \ @@ -35,6 +37,7 @@ macro(AsyncGeneratorFunction, AsyncGeneratorFunction, "AsyncGeneratorFunction") \ macro(AsyncWrapped, AsyncWrapped, "AsyncWrapped") \ macro(async, async, "async") \ + macro(autoAllocateChunkSize, autoAllocateChunkSize, "autoAllocateChunkSize") \ macro(await, await, "await") \ macro(bigint64, bigint64, "bigint64") \ macro(biguint64, biguint64, "biguint64") \ @@ -48,6 +51,7 @@ macro(buffer, buffer, "buffer") \ macro(builder, builder, "builder") \ macro(by, by, "by") \ + macro(byob, byob, "byob") \ macro(byteAlignment, byteAlignment, "byteAlignment") \ macro(byteLength, byteLength, "byteLength") \ macro(byteOffset, byteOffset, "byteOffset") \ @@ -59,6 +63,7 @@ macro(callee, callee, "callee") \ macro(caller, caller, "caller") \ macro(callFunction, callFunction, "callFunction") \ + macro(cancel, cancel, "cancel") \ macro(case, case_, "case") \ macro(caseFirst, caseFirst, "caseFirst") \ macro(catch, catch_, "catch") \ @@ -180,6 +185,7 @@ macro(has, has, "has") \ macro(hasOwn, hasOwn, "hasOwn") \ macro(hasOwnProperty, hasOwnProperty, "hasOwnProperty") \ + macro(highWaterMark, highWaterMark, "highWaterMark") \ macro(hour, hour, "hour") \ macro(hourCycle, hourCycle, "hourCycle") \ macro(if, if_, "if") \ @@ -250,6 +256,7 @@ macro(minusSign, minusSign, "minusSign") \ macro(minute, minute, "minute") \ macro(missingArguments, missingArguments, "missingArguments") \ + macro(mode, mode, "mode") \ macro(module, module, "module") \ macro(Module, Module, "Module") \ macro(ModuleInstantiate, ModuleInstantiate, "ModuleInstantiate") \ @@ -312,7 +319,52 @@ macro(prototype, prototype, "prototype") \ macro(proxy, proxy, "proxy") \ macro(public, public_, "public") \ + macro(pull, pull, "pull") \ macro(raw, raw, "raw") \ + macro(ReadableByteStreamControllerGetDesiredSize, \ + ReadableByteStreamControllerGetDesiredSize, \ + "ReadableByteStreamControllerGetDesiredSize") \ + macro(ReadableByteStreamController_close, \ + ReadableByteStreamController_close, \ + "ReadableByteStreamController_close") \ + macro(ReadableByteStreamController_enqueue, \ + ReadableByteStreamController_enqueue, \ + "ReadableByteStreamController_enqueue") \ + macro(ReadableByteStreamController_error, \ + ReadableByteStreamController_error, \ + "ReadableByteStreamController_error") \ + macro(ReadableStreamBYOBReader_cancel, \ + ReadableStreamBYOBReader_cancel, \ + "ReadableStreamBYOBReader_cancel") \ + macro(ReadableStreamBYOBReader_read, \ + ReadableStreamBYOBReader_read, \ + "ReadableStreamBYOBReader_read") \ + macro(ReadableStreamBYOBReader_releaseLock, \ + ReadableStreamBYOBReader_releaseLock, \ + "ReadableStreamBYOBReader_releaseLock") \ + macro(ReadableStream_cancel, ReadableStream_cancel, "ReadableStream_cancel") \ + macro(ReadableStreamDefaultControllerGetDesiredSize, \ + ReadableStreamDefaultControllerGetDesiredSize, \ + "ReadableStreamDefaultControllerGetDesiredSize") \ + macro(ReadableStreamDefaultController_close, \ + ReadableStreamDefaultController_close, \ + "ReadableStreamDefaultController_close") \ + macro(ReadableStreamDefaultController_enqueue, \ + ReadableStreamDefaultController_enqueue, \ + "ReadableStreamDefaultController_enqueue") \ + macro(ReadableStreamDefaultController_error, \ + ReadableStreamDefaultController_error, \ + "ReadableStreamDefaultController_error") \ + macro(ReadableStreamDefaultReader_cancel, \ + ReadableStreamDefaultReader_cancel, \ + "ReadableStreamDefaultReader_cancel") \ + macro(ReadableStreamDefaultReader_read, \ + ReadableStreamDefaultReader_read, \ + "ReadableStreamDefaultReader_read") \ + macro(ReadableStreamDefaultReader_releaseLock, \ + ReadableStreamDefaultReader_releaseLock, \ + "ReadableStreamDefaultReader_releaseLock") \ + macro(ReadableStreamTee, ReadableStreamTee, "ReadableStreamTee") \ macro(reason, reason, "reason") \ macro(RegExpFlagsGetter, RegExpFlagsGetter, "RegExpFlagsGetter") \ macro(RegExpStringIterator, RegExpStringIterator, "RegExp String Iterator") \ @@ -347,6 +399,7 @@ macro(StarGeneratorNext, StarGeneratorNext, "StarGeneratorNext") \ macro(StarGeneratorReturn, StarGeneratorReturn, "StarGeneratorReturn") \ macro(StarGeneratorThrow, StarGeneratorThrow, "StarGeneratorThrow") \ + macro(start, start, "start") \ macro(startTimestamp, startTimestamp, "startTimestamp") \ macro(state, state, "state") \ macro(static, static_, "static") \ diff --git a/js/src/vm/GlobalObject.cpp b/js/src/vm/GlobalObject.cpp index b7d3344b3e..1321be9e9b 100644 --- a/js/src/vm/GlobalObject.cpp +++ b/js/src/vm/GlobalObject.cpp @@ -23,6 +23,7 @@ #include "builtin/Promise.h" #include "builtin/RegExp.h" #include "builtin/SelfHostingDefines.h" +#include "builtin/Stream.h" #include "builtin/SymbolObject.h" #include "builtin/TypedObject.h" #include "builtin/WeakMapObject.h" @@ -98,6 +99,16 @@ GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key) case JSProto_WebAssembly: return !wasm::HasSupport(cx); + case JSProto_ReadableStream: + case JSProto_ReadableStreamDefaultReader: + case JSProto_ReadableStreamBYOBReader: + case JSProto_ReadableStreamDefaultController: + case JSProto_ReadableByteStreamController: + case JSProto_ReadableStreamBYOBRequest: + case JSProto_ByteLengthQueuingStrategy: + case JSProto_CountQueuingStrategy: + return !cx->options().streams(); + #ifdef ENABLE_SHARED_ARRAY_BUFFER case JSProto_Atomics: case JSProto_SharedArrayBuffer: diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 053b7c44b0..c5deff940c 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -156,6 +156,12 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime) startAsyncTaskCallback(nullptr), finishAsyncTaskCallback(nullptr), promiseTasksToDestroy(mutexid::PromiseTaskPtrVector), + readableStreamDataRequestCallback(nullptr), + readableStreamWriteIntoReadRequestCallback(nullptr), + readableStreamCancelCallback(nullptr), + readableStreamClosedCallback(nullptr), + readableStreamErroredCallback(nullptr), + readableStreamFinalizeCallback(nullptr), exclusiveAccessLock(mutexid::RuntimeExclusiveAccess), #ifdef DEBUG mainThreadHasExclusiveAccess(false), diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 962f0e1a1e..13523844c1 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -655,6 +655,13 @@ struct JSRuntime : public JS::shadow::Runtime, JS::FinishAsyncTaskCallback finishAsyncTaskCallback; js::ExclusiveData<js::PromiseTaskPtrVector> promiseTasksToDestroy; + JS::RequestReadableStreamDataCallback readableStreamDataRequestCallback; + JS::WriteIntoReadRequestBufferCallback readableStreamWriteIntoReadRequestCallback; + JS::CancelReadableStreamCallback readableStreamCancelCallback; + JS::ReadableStreamClosedCallback readableStreamClosedCallback; + JS::ReadableStreamErroredCallback readableStreamErroredCallback; + JS::ReadableStreamFinalizeCallback readableStreamFinalizeCallback; + private: /* * Lock taken when using per-runtime or per-zone data that could otherwise diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index e9c72d1bf1..e006846752 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -36,6 +36,7 @@ #include "builtin/Promise.h" #include "builtin/Reflect.h" #include "builtin/SelfHostingDefines.h" +#include "builtin/Stream.h" #include "builtin/TypedObject.h" #include "builtin/WeakSetObject.h" #include "gc/Marking.h" @@ -71,7 +72,6 @@ using JS::AutoCheckCannotGC; using mozilla::IsInRange; using mozilla::Maybe; using mozilla::PodMove; -using mozilla::Maybe; static void selfHosting_WarningReporter(JSContext* cx, JSErrorReport* report) @@ -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), @@ -2489,6 +2490,9 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("CallWeakSetMethodIfWrapped", CallNonGenericSelfhostedMethod<Is<WeakSetObject>>, 2, 0), + JS_FN("IsReadableStreamBYOBRequest", + intrinsic_IsInstanceOfBuiltin<ReadableStreamBYOBRequest>, 1, 0), + // See builtin/TypedObject.h for descriptors of the typedobj functions. JS_FN("NewOpaqueTypedObject", js::NewOpaqueTypedObject, 1, 0), JS_FN("NewDerivedTypedObject", js::NewDerivedTypedObject, 3, 0), diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp index 8e55001d13..44fe3b790d 100644 --- a/js/src/vm/SharedArrayObject.cpp +++ b/js/src/vm/SharedArrayObject.cpp @@ -331,15 +331,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); } diff --git a/js/src/vm/SharedArrayObject.h b/js/src/vm/SharedArrayObject.h index 05db688184..19048336cb 100644 --- a/js/src/vm/SharedArrayObject.h +++ b/js/src/vm/SharedArrayObject.h @@ -146,9 +146,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; |