| Index: third_party/WebKit/Source/core/streams/ReadableStream.js
|
| diff --git a/third_party/WebKit/Source/core/streams/ReadableStream.js b/third_party/WebKit/Source/core/streams/ReadableStream.js
|
| index 50b377508ab23d4d770dbc6b049f72a2bef276e2..80580c76e90ad7b5de7c6650a4fea08d785c4911 100644
|
| --- a/third_party/WebKit/Source/core/streams/ReadableStream.js
|
| +++ b/third_party/WebKit/Source/core/streams/ReadableStream.js
|
| @@ -400,7 +400,7 @@
|
|
|
| this[_underlyingSource] = underlyingSource;
|
|
|
| - this[_queue] = new Queue();
|
| + this[_queue] = new binding.SimpleQueue();
|
| this[_totalQueuedSize] = 0;
|
|
|
| this[_readableStreamDefaultControllerBits] = 0b0;
|
| @@ -501,7 +501,7 @@
|
| }
|
|
|
| function ReadableStreamDefaultControllerCancel(controller, reason) {
|
| - controller[_queue] = new Queue();
|
| + controller[_queue] = new binding.SimpleQueue();
|
|
|
| const underlyingSource = controller[_underlyingSource];
|
| return PromiseCallOrNoop(underlyingSource, 'cancel', reason, 'underlyingSource.cancel');
|
| @@ -545,7 +545,7 @@
|
|
|
| ReadableStreamReaderGenericInitialize(this, stream);
|
|
|
| - this[_readRequests] = new Queue();
|
| + this[_readRequests] = new binding.SimpleQueue();
|
| }
|
|
|
| get closed() {
|
| @@ -688,7 +688,7 @@
|
| }
|
|
|
| function ReadableStreamDefaultControllerError(controller, e) {
|
| - controller[_queue] = new Queue();
|
| + controller[_queue] = new binding.SimpleQueue();
|
| const stream = controller[_controlledReadableStream];
|
| ReadableStreamError(stream, e);
|
| }
|
| @@ -704,7 +704,7 @@
|
|
|
| if (IsReadableStreamDefaultReader(reader) === true) {
|
| reader[_readRequests].forEach(request => v8.rejectPromise(request, e));
|
| - reader[_readRequests] = new Queue();
|
| + reader[_readRequests] = new binding.SimpleQueue();
|
| }
|
|
|
| v8.rejectPromise(reader[_closedPromise], e);
|
| @@ -722,7 +722,7 @@
|
| if (IsReadableStreamDefaultReader(reader) === true) {
|
| reader[_readRequests].forEach(request =>
|
| v8.resolvePromise(request, CreateIterResultObject(undefined, true)));
|
| - reader[_readRequests] = new Queue();
|
| + reader[_readRequests] = new binding.SimpleQueue();
|
| }
|
|
|
| v8.resolvePromise(reader[_closedPromise], undefined);
|
| @@ -991,78 +991,8 @@
|
|
|
| //
|
| // Queue-with-sizes
|
| - // Modified from taking the queue (as in the spec) to taking the stream, so we
|
| - // can modify the queue size alongside.
|
| //
|
|
|
| - // Simple queue structure. Avoids scalability issues with using
|
| - // InternalPackedArray directly by using multiple arrays
|
| - // in a linked list and keeping the array size bounded.
|
| - const QUEUE_MAX_ARRAY_SIZE = 16384;
|
| - class Queue {
|
| - constructor() {
|
| - this.front = {
|
| - elements: new v8.InternalPackedArray(),
|
| - next: undefined,
|
| - };
|
| - this.back = this.front;
|
| - // The cursor is used to avoid calling InternalPackedArray.shift().
|
| - this.cursor = 0;
|
| - this.size = 0;
|
| - }
|
| -
|
| - get length() {
|
| - return this.size;
|
| - }
|
| -
|
| - push(element) {
|
| - ++this.size;
|
| - if (this.back.elements.length === QUEUE_MAX_ARRAY_SIZE) {
|
| - const oldBack = this.back;
|
| - this.back = {
|
| - elements: new v8.InternalPackedArray(),
|
| - next: undefined,
|
| - };
|
| - oldBack.next = this.back;
|
| - }
|
| - this.back.elements.push(element);
|
| - }
|
| -
|
| - shift() {
|
| - // assert(this.size > 0);
|
| - --this.size;
|
| - if (this.front.elements.length === this.cursor) {
|
| - // assert(this.cursor === QUEUE_MAX_ARRAY_SIZE);
|
| - // assert(this.front.next !== undefined);
|
| - this.front = this.front.next;
|
| - this.cursor = 0;
|
| - }
|
| - const element = this.front.elements[this.cursor];
|
| - // Permit shifted element to be garbage collected.
|
| - this.front.elements[this.cursor] = undefined;
|
| - ++this.cursor;
|
| -
|
| - return element;
|
| - }
|
| -
|
| - forEach(callback) {
|
| - let i = this.cursor;
|
| - let node = this.front;
|
| - let elements = node.elements;
|
| - while (i !== elements.length || node.next !== undefined) {
|
| - if (i === elements.length) {
|
| - // assert(node.next !== undefined);
|
| - // assert(i === QUEUE_MAX_ARRAY_SIZE);
|
| - node = node.next;
|
| - elements = node.elements;
|
| - i = 0;
|
| - }
|
| - callback(elements[i]);
|
| - ++i;
|
| - }
|
| - }
|
| - }
|
| -
|
| function DequeueValue(controller) {
|
| const result = controller[_queue].shift();
|
| controller[_totalQueuedSize] -= result.size;
|
|
|