1 | /* |
2 | * Copyright (c) 2016 Apple Inc. All rights reserved. |
3 | * Copyright (c) 2016 Canon Inc. All rights reserved. |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
18 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
24 | * THE POSSIBILITY OF SUCH DAMAGE. |
25 | * |
26 | */ |
27 | |
28 | // DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for |
29 | // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py |
30 | |
31 | #include "config.h" |
32 | #include "ReadableByteStreamInternalsBuiltins.h" |
33 | |
34 | #if ENABLE(STREAMS_API) |
35 | |
36 | #include "WebCoreJSClientData.h" |
37 | #include <JavaScriptCore/HeapInlines.h> |
38 | #include <JavaScriptCore/IdentifierInlines.h> |
39 | #include <JavaScriptCore/Intrinsic.h> |
40 | #include <JavaScriptCore/JSCJSValueInlines.h> |
41 | #include <JavaScriptCore/JSCellInlines.h> |
42 | #include <JavaScriptCore/StructureInlines.h> |
43 | #include <JavaScriptCore/VM.h> |
44 | |
45 | namespace WebCore { |
46 | |
47 | const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
48 | const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength = 2333; |
49 | static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; |
50 | const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = |
51 | "(function (stream, underlyingByteSource, highWaterMark)\n" \ |
52 | "{\n" \ |
53 | " \"use strict\";\n" \ |
54 | "\n" \ |
55 | " if (!@isReadableStream(stream))\n" \ |
56 | " @throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");\n" \ |
57 | "\n" \ |
58 | " //\n" \ |
59 | " if (@getByIdDirectPrivate(stream, \"readableStreamController\") !== null)\n" \ |
60 | " @throwTypeError(\"ReadableStream already has a controller\");\n" \ |
61 | "\n" \ |
62 | " @putByIdDirectPrivate(this, \"controlledReadableStream\", stream);\n" \ |
63 | " @putByIdDirectPrivate(this, \"underlyingByteSource\", underlyingByteSource);\n" \ |
64 | " @putByIdDirectPrivate(this, \"pullAgain\", false);\n" \ |
65 | " @putByIdDirectPrivate(this, \"pulling\", false);\n" \ |
66 | " @readableByteStreamControllerClearPendingPullIntos(this);\n" \ |
67 | " @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \ |
68 | " @putByIdDirectPrivate(this, \"started\", false);\n" \ |
69 | " @putByIdDirectPrivate(this, \"closeRequested\", false);\n" \ |
70 | "\n" \ |
71 | " let hwm = @toNumber(highWaterMark);\n" \ |
72 | " if (@isNaN(hwm) || hwm < 0)\n" \ |
73 | " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \ |
74 | " @putByIdDirectPrivate(this, \"strategyHWM\", hwm);\n" \ |
75 | "\n" \ |
76 | " let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;\n" \ |
77 | " if (autoAllocateChunkSize !== @undefined) {\n" \ |
78 | " autoAllocateChunkSize = @toNumber(autoAllocateChunkSize);\n" \ |
79 | " if (autoAllocateChunkSize <= 0 || autoAllocateChunkSize === @Infinity || autoAllocateChunkSize === -@Infinity)\n" \ |
80 | " @throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\");\n" \ |
81 | " }\n" \ |
82 | " @putByIdDirectPrivate(this, \"autoAllocateChunkSize\", autoAllocateChunkSize);\n" \ |
83 | " @putByIdDirectPrivate(this, \"pendingPullIntos\", []);\n" \ |
84 | "\n" \ |
85 | " const controller = this;\n" \ |
86 | " const startResult = @promiseInvokeOrNoopNoCatch(underlyingByteSource, \"start\", [this]).@then(() => {\n" \ |
87 | " @putByIdDirectPrivate(controller, \"started\", true);\n" \ |
88 | " @assert(!@getByIdDirectPrivate(controller, \"pulling\"));\n" \ |
89 | " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \ |
90 | " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \ |
91 | " }, (error) => {\n" \ |
92 | " if (@getByIdDirectPrivate(stream, \"state\") === @streamReadable)\n" \ |
93 | " @readableByteStreamControllerError(controller, error);\n" \ |
94 | " });\n" \ |
95 | "\n" \ |
96 | " @putByIdDirectPrivate(this, \"cancel\", @readableByteStreamControllerCancel);\n" \ |
97 | " @putByIdDirectPrivate(this, \"pull\", @readableByteStreamControllerPull);\n" \ |
98 | "\n" \ |
99 | " return this;\n" \ |
100 | "})\n" \ |
101 | ; |
102 | |
103 | const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
104 | const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength = 187; |
105 | static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; |
106 | const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode = |
107 | "(function (controller, view)\n" \ |
108 | "{\n" \ |
109 | " \"use strict\";\n" \ |
110 | "\n" \ |
111 | " @putByIdDirectPrivate(this, \"associatedReadableByteStreamController\", controller);\n" \ |
112 | " @putByIdDirectPrivate(this, \"view\", view);\n" \ |
113 | "})\n" \ |
114 | ; |
115 | |
116 | const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
117 | const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength = 158; |
118 | static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; |
119 | const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode = |
120 | "(function (controller)\n" \ |
121 | "{\n" \ |
122 | " \"use strict\";\n" \ |
123 | "\n" \ |
124 | " //\n" \ |
125 | " //\n" \ |
126 | " return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"underlyingByteSource\");\n" \ |
127 | "})\n" \ |
128 | ; |
129 | |
130 | const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
131 | const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength = 179; |
132 | static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; |
133 | const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode = |
134 | "(function (byobRequest)\n" \ |
135 | "{\n" \ |
136 | " \"use strict\";\n" \ |
137 | "\n" \ |
138 | " //\n" \ |
139 | " //\n" \ |
140 | " return @isObject(byobRequest) && !!@getByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\");\n" \ |
141 | "})\n" \ |
142 | ; |
143 | |
144 | const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
145 | const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength = 149; |
146 | static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; |
147 | const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode = |
148 | "(function (reader)\n" \ |
149 | "{\n" \ |
150 | " \"use strict\";\n" \ |
151 | "\n" \ |
152 | " //\n" \ |
153 | " //\n" \ |
154 | " //\n" \ |
155 | " return @isObject(reader) && !!@getByIdDirectPrivate(reader, \"readIntoRequests\");\n" \ |
156 | "})\n" \ |
157 | ; |
158 | |
159 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
160 | const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 392; |
161 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; |
162 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = |
163 | "(function (controller, reason)\n" \ |
164 | "{\n" \ |
165 | " \"use strict\";\n" \ |
166 | "\n" \ |
167 | " var pendingPullIntos = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \ |
168 | " if (pendingPullIntos.length > 0)\n" \ |
169 | " pendingPullIntos[0].bytesFilled = 0;\n" \ |
170 | " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \ |
171 | " return @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"cancel\", [reason]);\n" \ |
172 | "})\n" \ |
173 | ; |
174 | |
175 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
176 | const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 399; |
177 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; |
178 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = |
179 | "(function (controller, e)\n" \ |
180 | "{\n" \ |
181 | " \"use strict\";\n" \ |
182 | "\n" \ |
183 | " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \ |
184 | " @readableByteStreamControllerClearPendingPullIntos(controller);\n" \ |
185 | " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \ |
186 | " @readableStreamError(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), e);\n" \ |
187 | "})\n" \ |
188 | ; |
189 | |
190 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
191 | const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 848; |
192 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; |
193 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = |
194 | "(function (controller)\n" \ |
195 | "{\n" \ |
196 | " \"use strict\";\n" \ |
197 | "\n" \ |
198 | " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \ |
199 | " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \ |
200 | "\n" \ |
201 | " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \ |
202 | " @putByIdDirectPrivate(controller, \"closeRequested\", true);\n" \ |
203 | " return;\n" \ |
204 | " }\n" \ |
205 | "\n" \ |
206 | " var pendingPullIntos = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \ |
207 | " if (pendingPullIntos.length > 0) {\n" \ |
208 | " if (pendingPullIntos[0].bytesFilled > 0) {\n" \ |
209 | " const e = @makeTypeError(\"Close requested while there remain pending bytes\");\n" \ |
210 | " @readableByteStreamControllerError(controller, e);\n" \ |
211 | " throw e;\n" \ |
212 | " }\n" \ |
213 | " }\n" \ |
214 | "\n" \ |
215 | " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \ |
216 | "})\n" \ |
217 | ; |
218 | |
219 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
220 | const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength = 178; |
221 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeIntrinsic = JSC::NoIntrinsic; |
222 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode = |
223 | "(function (controller)\n" \ |
224 | "{\n" \ |
225 | " \"use strict\";\n" \ |
226 | "\n" \ |
227 | " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \ |
228 | " @putByIdDirectPrivate(controller, \"pendingPullIntos\", []);\n" \ |
229 | "})\n" \ |
230 | ; |
231 | |
232 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
233 | const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 406; |
234 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; |
235 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = |
236 | "(function (controller)\n" \ |
237 | "{\n" \ |
238 | " \"use strict\";\n" \ |
239 | "\n" \ |
240 | " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
241 | " const state = @getByIdDirectPrivate(stream, \"state\");\n" \ |
242 | "\n" \ |
243 | " if (state === @streamErrored)\n" \ |
244 | " return null;\n" \ |
245 | " if (state === @streamClosed)\n" \ |
246 | " return 0;\n" \ |
247 | "\n" \ |
248 | " return @getByIdDirectPrivate(controller, \"strategyHWM\") - @getByIdDirectPrivate(controller, \"queue\").size;\n" \ |
249 | "})\n" \ |
250 | ; |
251 | |
252 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
253 | const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 176; |
254 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; |
255 | const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = |
256 | "(function (stream)\n" \ |
257 | "{\n" \ |
258 | " \"use strict\";\n" \ |
259 | "\n" \ |
260 | " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \ |
261 | " return reader !== @undefined && @isReadableStreamBYOBReader(reader);\n" \ |
262 | "})\n" \ |
263 | ; |
264 | |
265 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
266 | const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 179; |
267 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; |
268 | const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = |
269 | "(function (stream)\n" \ |
270 | "{\n" \ |
271 | " \"use strict\";\n" \ |
272 | "\n" \ |
273 | " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \ |
274 | " return reader !== @undefined && @isReadableStreamDefaultReader(reader);\n" \ |
275 | "})\n" \ |
276 | ; |
277 | |
278 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
279 | const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength = 458; |
280 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeIntrinsic = JSC::NoIntrinsic; |
281 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode = |
282 | "(function (controller) {\n" \ |
283 | "\n" \ |
284 | " \"use strict\";\n" \ |
285 | "\n" \ |
286 | " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \ |
287 | " if (!@getByIdDirectPrivate(controller, \"queue\").size && @getByIdDirectPrivate(controller, \"closeRequested\"))\n" \ |
288 | " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \ |
289 | " else\n" \ |
290 | " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \ |
291 | "})\n" \ |
292 | ; |
293 | |
294 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
295 | const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1687; |
296 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; |
297 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = |
298 | "(function (controller)\n" \ |
299 | "{\n" \ |
300 | " \"use strict\";\n" \ |
301 | "\n" \ |
302 | " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
303 | " @assert(@readableStreamHasDefaultReader(stream));\n" \ |
304 | "\n" \ |
305 | " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \ |
306 | " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length === 0);\n" \ |
307 | " const entry = @getByIdDirectPrivate(controller, \"queue\").content.@shift();\n" \ |
308 | " @getByIdDirectPrivate(controller, \"queue\").size -= entry.byteLength;\n" \ |
309 | " @readableByteStreamControllerHandleQueueDrain(controller);\n" \ |
310 | " let view;\n" \ |
311 | " try {\n" \ |
312 | " view = new @Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);\n" \ |
313 | " } catch (error) {\n" \ |
314 | " return @Promise.@reject(error);\n" \ |
315 | " }\n" \ |
316 | " return @Promise.@resolve({value: view, done: false});\n" \ |
317 | " }\n" \ |
318 | "\n" \ |
319 | " if (@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\") !== @undefined) {\n" \ |
320 | " let buffer;\n" \ |
321 | " try {\n" \ |
322 | " buffer = new @ArrayBuffer(@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"));\n" \ |
323 | " } catch (error) {\n" \ |
324 | " return @Promise.@reject(error);\n" \ |
325 | " }\n" \ |
326 | " const pullIntoDescriptor = {\n" \ |
327 | " buffer,\n" \ |
328 | " byteOffset: 0,\n" \ |
329 | " byteLength: @getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"),\n" \ |
330 | " bytesFilled: 0,\n" \ |
331 | " elementSize: 1,\n" \ |
332 | " ctor: @Uint8Array,\n" \ |
333 | " readerType: 'default'\n" \ |
334 | " };\n" \ |
335 | " @getByIdDirectPrivate(controller, \"pendingPullIntos\").@push(pullIntoDescriptor);\n" \ |
336 | " }\n" \ |
337 | "\n" \ |
338 | " const promise = @readableStreamAddReadRequest(stream);\n" \ |
339 | " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \ |
340 | " return promise;\n" \ |
341 | "})\n" \ |
342 | ; |
343 | |
344 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
345 | const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 815; |
346 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; |
347 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = |
348 | "(function (controller)\n" \ |
349 | "{\n" \ |
350 | " \"use strict\";\n" \ |
351 | "\n" \ |
352 | " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
353 | "\n" \ |
354 | " if (@getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \ |
355 | " return false;\n" \ |
356 | " if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \ |
357 | " return false;\n" \ |
358 | " if (!@getByIdDirectPrivate(controller, \"started\"))\n" \ |
359 | " return false;\n" \ |
360 | " if (@readableStreamHasDefaultReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length > 0)\n" \ |
361 | " return true;\n" \ |
362 | " if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").length > 0)\n" \ |
363 | " return true;\n" \ |
364 | " if (@readableByteStreamControllerGetDesiredSize(controller) > 0)\n" \ |
365 | " return true;\n" \ |
366 | " return false;\n" \ |
367 | "})\n" \ |
368 | ; |
369 | |
370 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
371 | const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 1002; |
372 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; |
373 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = |
374 | "(function (controller)\n" \ |
375 | "{\n" \ |
376 | " \"use strict\";\n" \ |
377 | "\n" \ |
378 | " if (!@readableByteStreamControllerShouldCallPull(controller))\n" \ |
379 | " return;\n" \ |
380 | "\n" \ |
381 | " if (@getByIdDirectPrivate(controller, \"pulling\")) {\n" \ |
382 | " @putByIdDirectPrivate(controller, \"pullAgain\", true);\n" \ |
383 | " return;\n" \ |
384 | " }\n" \ |
385 | "\n" \ |
386 | " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \ |
387 | " @putByIdDirectPrivate(controller, \"pulling\", true);\n" \ |
388 | " @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"pull\", [controller]).@then(() => {\n" \ |
389 | " @putByIdDirectPrivate(controller, \"pulling\", false);\n" \ |
390 | " if (@getByIdDirectPrivate(controller, \"pullAgain\")) {\n" \ |
391 | " @putByIdDirectPrivate(controller, \"pullAgain\", false);\n" \ |
392 | " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \ |
393 | " }\n" \ |
394 | " }, (error) => {\n" \ |
395 | " if (@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable)\n" \ |
396 | " @readableByteStreamControllerError(controller, error);\n" \ |
397 | " });\n" \ |
398 | "})\n" \ |
399 | ; |
400 | |
401 | const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
402 | const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength = 90; |
403 | static const JSC::Intrinsic s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeIntrinsic = JSC::NoIntrinsic; |
404 | const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode = |
405 | "(function (buffer)\n" \ |
406 | "{\n" \ |
407 | " \"use strict\";\n" \ |
408 | "\n" \ |
409 | " //\n" \ |
410 | " //\n" \ |
411 | " //\n" \ |
412 | " //\n" \ |
413 | " return buffer;\n" \ |
414 | "})\n" \ |
415 | ; |
416 | |
417 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
418 | const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1423; |
419 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; |
420 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = |
421 | "(function (controller, chunk)\n" \ |
422 | "{\n" \ |
423 | " \"use strict\";\n" \ |
424 | "\n" \ |
425 | " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
426 | " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \ |
427 | " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \ |
428 | " const buffer = chunk.buffer;\n" \ |
429 | " const byteOffset = chunk.byteOffset;\n" \ |
430 | " const byteLength = chunk.byteLength;\n" \ |
431 | " const transferredBuffer = @transferBufferToCurrentRealm(buffer);\n" \ |
432 | "\n" \ |
433 | " if (@readableStreamHasDefaultReader(stream)) {\n" \ |
434 | " if (!@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length)\n" \ |
435 | " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \ |
436 | " else {\n" \ |
437 | " @assert(!@getByIdDirectPrivate(controller, \"queue\").content.length);\n" \ |
438 | " let transferredView = new @Uint8Array(transferredBuffer, byteOffset, byteLength);\n" \ |
439 | " @readableStreamFulfillReadRequest(stream, transferredView, false);\n" \ |
440 | " }\n" \ |
441 | " return;\n" \ |
442 | " }\n" \ |
443 | "\n" \ |
444 | " if (@readableStreamHasBYOBReader(stream)) {\n" \ |
445 | " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \ |
446 | " @readableByteStreamControllerProcessPullDescriptors(controller);\n" \ |
447 | " return;\n" \ |
448 | " }\n" \ |
449 | "\n" \ |
450 | " @assert(!@isReadableStreamLocked(stream));\n" \ |
451 | " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \ |
452 | "})\n" \ |
453 | ; |
454 | |
455 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
456 | const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 304; |
457 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; |
458 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = |
459 | "(function (controller, buffer, byteOffset, byteLength)\n" \ |
460 | "{\n" \ |
461 | " \"use strict\";\n" \ |
462 | "\n" \ |
463 | " @getByIdDirectPrivate(controller, \"queue\").content.@push({\n" \ |
464 | " buffer: buffer,\n" \ |
465 | " byteOffset: byteOffset,\n" \ |
466 | " byteLength: byteLength\n" \ |
467 | " });\n" \ |
468 | " @getByIdDirectPrivate(controller, \"queue\").size += byteLength;\n" \ |
469 | "})\n" \ |
470 | ; |
471 | |
472 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
473 | const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 609; |
474 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; |
475 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = |
476 | "(function (controller, view)\n" \ |
477 | "{\n" \ |
478 | " \"use strict\";\n" \ |
479 | "\n" \ |
480 | " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0);\n" \ |
481 | "\n" \ |
482 | " let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \ |
483 | "\n" \ |
484 | " if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)\n" \ |
485 | " @throwRangeError(\"Invalid value for view.byteOffset\");\n" \ |
486 | "\n" \ |
487 | " if (firstDescriptor.byteLength !== view.byteLength)\n" \ |
488 | " @throwRangeError(\"Invalid value for view.byteLength\");\n" \ |
489 | "\n" \ |
490 | " firstDescriptor.buffer = view.buffer;\n" \ |
491 | " @readableByteStreamControllerRespondInternal(controller, view.byteLength);\n" \ |
492 | "})\n" \ |
493 | ; |
494 | |
495 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
496 | const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 409; |
497 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; |
498 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = |
499 | "(function (controller, bytesWritten)\n" \ |
500 | "{\n" \ |
501 | " \"use strict\";\n" \ |
502 | "\n" \ |
503 | " bytesWritten = @toNumber(bytesWritten);\n" \ |
504 | "\n" \ |
505 | " if (@isNaN(bytesWritten) || bytesWritten === @Infinity || bytesWritten < 0 )\n" \ |
506 | " @throwRangeError(\"bytesWritten has an incorrect value\");\n" \ |
507 | "\n" \ |
508 | " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0);\n" \ |
509 | "\n" \ |
510 | " @readableByteStreamControllerRespondInternal(controller, bytesWritten);\n" \ |
511 | "})\n" \ |
512 | ; |
513 | |
514 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
515 | const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 708; |
516 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; |
517 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = |
518 | "(function (controller, bytesWritten)\n" \ |
519 | "{\n" \ |
520 | " \"use strict\";\n" \ |
521 | "\n" \ |
522 | " let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \ |
523 | " let stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
524 | "\n" \ |
525 | " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \ |
526 | " if (bytesWritten !== 0)\n" \ |
527 | " @throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");\n" \ |
528 | " @readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);\n" \ |
529 | " } else {\n" \ |
530 | " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \ |
531 | " @readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);\n" \ |
532 | " }\n" \ |
533 | "})\n" \ |
534 | ; |
535 | |
536 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
537 | const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 1439; |
538 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; |
539 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = |
540 | "(function (controller, bytesWritten, pullIntoDescriptor)\n" \ |
541 | "{\n" \ |
542 | " \"use strict\";\n" \ |
543 | "\n" \ |
544 | " if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength)\n" \ |
545 | " @throwRangeError(\"bytesWritten value is too great\");\n" \ |
546 | "\n" \ |
547 | " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length === 0 || @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0] === pullIntoDescriptor);\n" \ |
548 | " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \ |
549 | " pullIntoDescriptor.bytesFilled += bytesWritten;\n" \ |
550 | "\n" \ |
551 | " if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize)\n" \ |
552 | " return;\n" \ |
553 | "\n" \ |
554 | " @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \ |
555 | " const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;\n" \ |
556 | "\n" \ |
557 | " if (remainderSize > 0) {\n" \ |
558 | " const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \ |
559 | " const remainder = @cloneArrayBuffer(pullIntoDescriptor.buffer, end - remainderSize, remainderSize);\n" \ |
560 | " @readableByteStreamControllerEnqueueChunk(controller, remainder, 0, remainder.byteLength);\n" \ |
561 | " }\n" \ |
562 | "\n" \ |
563 | " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \ |
564 | " pullIntoDescriptor.bytesFilled -= remainderSize;\n" \ |
565 | " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \ |
566 | " @readableByteStreamControllerProcessPullDescriptors(controller);\n" \ |
567 | "})\n" \ |
568 | ; |
569 | |
570 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
571 | const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength = 727; |
572 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeIntrinsic = JSC::NoIntrinsic; |
573 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode = |
574 | "(function (controller, firstDescriptor)\n" \ |
575 | "{\n" \ |
576 | " \"use strict\";\n" \ |
577 | "\n" \ |
578 | " firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);\n" \ |
579 | " @assert(firstDescriptor.bytesFilled === 0);\n" \ |
580 | "\n" \ |
581 | " if (@readableStreamHasBYOBReader(@getByIdDirectPrivate(controller, \"controlledReadableStream\"))) {\n" \ |
582 | " while (@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"reader\"), \"readIntoRequests\").length > 0) {\n" \ |
583 | " let pullIntoDescriptor = @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \ |
584 | " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \ |
585 | " }\n" \ |
586 | " }\n" \ |
587 | "})\n" \ |
588 | ; |
589 | |
590 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
591 | const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 706; |
592 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic; |
593 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = |
594 | "(function (controller)\n" \ |
595 | "{\n" \ |
596 | " \"use strict\";\n" \ |
597 | "\n" \ |
598 | " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \ |
599 | " while (@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0) {\n" \ |
600 | " if (@getByIdDirectPrivate(controller, \"queue\").size === 0)\n" \ |
601 | " return;\n" \ |
602 | " let pullIntoDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \ |
603 | " if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \ |
604 | " @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \ |
605 | " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \ |
606 | " }\n" \ |
607 | " }\n" \ |
608 | "})\n" \ |
609 | ; |
610 | |
611 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
612 | const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 2355; |
613 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic; |
614 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = |
615 | "(function (controller, pullIntoDescriptor)\n" \ |
616 | "{\n" \ |
617 | " \"use strict\";\n" \ |
618 | "\n" \ |
619 | " const currentAlignedBytes = pullIntoDescriptor.bytesFilled - (pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize);\n" \ |
620 | " const maxBytesToCopy = @getByIdDirectPrivate(controller, \"queue\").size < pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled ?\n" \ |
621 | " @getByIdDirectPrivate(controller, \"queue\").size : pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled;\n" \ |
622 | " const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;\n" \ |
623 | " const maxAlignedBytes = maxBytesFilled - (maxBytesFilled % pullIntoDescriptor.elementSize);\n" \ |
624 | " let totalBytesToCopyRemaining = maxBytesToCopy;\n" \ |
625 | " let ready = false;\n" \ |
626 | "\n" \ |
627 | " if (maxAlignedBytes > currentAlignedBytes) {\n" \ |
628 | " totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;\n" \ |
629 | " ready = true;\n" \ |
630 | " }\n" \ |
631 | "\n" \ |
632 | " while (totalBytesToCopyRemaining > 0) {\n" \ |
633 | " let headOfQueue = @getByIdDirectPrivate(controller, \"queue\").content[0];\n" \ |
634 | " const bytesToCopy = totalBytesToCopyRemaining < headOfQueue.byteLength ? totalBytesToCopyRemaining : headOfQueue.byteLength;\n" \ |
635 | " //\n" \ |
636 | " //\n" \ |
637 | " //\n" \ |
638 | " const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \ |
639 | " //\n" \ |
640 | " //\n" \ |
641 | " new @Uint8Array(pullIntoDescriptor.buffer).set(new @Uint8Array(headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), destStart);\n" \ |
642 | "\n" \ |
643 | " if (headOfQueue.byteLength === bytesToCopy)\n" \ |
644 | " @getByIdDirectPrivate(controller, \"queue\").content.@shift();\n" \ |
645 | " else {\n" \ |
646 | " headOfQueue.byteOffset += bytesToCopy;\n" \ |
647 | " headOfQueue.byteLength -= bytesToCopy;\n" \ |
648 | " }\n" \ |
649 | "\n" \ |
650 | " @getByIdDirectPrivate(controller, \"queue\").size -= bytesToCopy;\n" \ |
651 | " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length === 0 || @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0] === pullIntoDescriptor);\n" \ |
652 | " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \ |
653 | " pullIntoDescriptor.bytesFilled += bytesToCopy;\n" \ |
654 | " totalBytesToCopyRemaining -= bytesToCopy;\n" \ |
655 | " }\n" \ |
656 | "\n" \ |
657 | " if (!ready) {\n" \ |
658 | " @assert(@getByIdDirectPrivate(controller, \"queue\").size === 0);\n" \ |
659 | " @assert(pullIntoDescriptor.bytesFilled > 0);\n" \ |
660 | " @assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);\n" \ |
661 | " }\n" \ |
662 | "\n" \ |
663 | " return ready;\n" \ |
664 | "})\n" \ |
665 | ; |
666 | |
667 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
668 | const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength = 223; |
669 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeIntrinsic = JSC::NoIntrinsic; |
670 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode = |
671 | "(function (controller)\n" \ |
672 | "{\n" \ |
673 | " \"use strict\";\n" \ |
674 | "\n" \ |
675 | " let descriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").@shift();\n" \ |
676 | " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \ |
677 | " return descriptor;\n" \ |
678 | "})\n" \ |
679 | ; |
680 | |
681 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
682 | const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength = 430; |
683 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; |
684 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode = |
685 | "(function (controller)\n" \ |
686 | "{\n" \ |
687 | " \"use strict\";\n" \ |
688 | "\n" \ |
689 | " if (@getByIdDirectPrivate(controller, \"byobRequest\") === @undefined)\n" \ |
690 | " return;\n" \ |
691 | " const byobRequest = @getByIdDirectPrivate(controller, \"byobRequest\");\n" \ |
692 | " @putByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\", @undefined);\n" \ |
693 | " @putByIdDirectPrivate(byobRequest, \"view\", @undefined);\n" \ |
694 | " @putByIdDirectPrivate(controller, \"byobRequest\", @undefined);\n" \ |
695 | "})\n" \ |
696 | ; |
697 | |
698 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
699 | const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength = 662; |
700 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeIntrinsic = JSC::NoIntrinsic; |
701 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode = |
702 | "(function (stream, pullIntoDescriptor)\n" \ |
703 | "{\n" \ |
704 | " \"use strict\";\n" \ |
705 | "\n" \ |
706 | " @assert(@getByIdDirectPrivate(stream, \"state\") !== @streamErrored);\n" \ |
707 | " let done = false;\n" \ |
708 | " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \ |
709 | " @assert(!pullIntoDescriptor.bytesFilled);\n" \ |
710 | " done = true;\n" \ |
711 | " }\n" \ |
712 | " let filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \ |
713 | " if (pullIntoDescriptor.readerType === \"default\")\n" \ |
714 | " @readableStreamFulfillReadRequest(stream, filledView, done);\n" \ |
715 | " else {\n" \ |
716 | " @assert(pullIntoDescriptor.readerType === \"byob\");\n" \ |
717 | " @readableStreamFulfillReadIntoRequest(stream, filledView, done);\n" \ |
718 | " }\n" \ |
719 | "})\n" \ |
720 | ; |
721 | |
722 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
723 | const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength = 381; |
724 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeIntrinsic = JSC::NoIntrinsic; |
725 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode = |
726 | "(function (pullIntoDescriptor)\n" \ |
727 | "{\n" \ |
728 | " \"use strict\";\n" \ |
729 | "\n" \ |
730 | " @assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength);\n" \ |
731 | " @assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);\n" \ |
732 | "\n" \ |
733 | " return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);\n" \ |
734 | "})\n" \ |
735 | ; |
736 | |
737 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
738 | const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 208; |
739 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; |
740 | const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = |
741 | "(function (stream, chunk, done)\n" \ |
742 | "{\n" \ |
743 | " \"use strict\";\n" \ |
744 | "\n" \ |
745 | " @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").@shift().@resolve.@call(@undefined, {value: chunk, done: done});\n" \ |
746 | "})\n" \ |
747 | ; |
748 | |
749 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
750 | const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 462; |
751 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; |
752 | const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = |
753 | "(function (reader, view)\n" \ |
754 | "{\n" \ |
755 | " \"use strict\";\n" \ |
756 | "\n" \ |
757 | " const stream = @getByIdDirectPrivate(reader, \"ownerReadableStream\");\n" \ |
758 | " @assert(!!stream);\n" \ |
759 | "\n" \ |
760 | " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \ |
761 | " if (@getByIdDirectPrivate(stream, \"state\") === @streamErrored)\n" \ |
762 | " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \ |
763 | "\n" \ |
764 | " return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(stream, \"readableStreamController\"), view);\n" \ |
765 | "})\n" \ |
766 | ; |
767 | |
768 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
769 | const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 2192; |
770 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; |
771 | const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = |
772 | "(function (controller, view)\n" \ |
773 | "{\n" \ |
774 | " \"use strict\";\n" \ |
775 | "\n" \ |
776 | " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ |
777 | " let elementSize = 1;\n" \ |
778 | " //\n" \ |
779 | " //\n" \ |
780 | " //\n" \ |
781 | " //\n" \ |
782 | " //\n" \ |
783 | " //\n" \ |
784 | " //\n" \ |
785 | " //\n" \ |
786 | " //\n" \ |
787 | " //\n" \ |
788 | " if (view.BYTES_PER_ELEMENT !== @undefined)\n" \ |
789 | " elementSize = view.BYTES_PER_ELEMENT;\n" \ |
790 | "\n" \ |
791 | " //\n" \ |
792 | " //\n" \ |
793 | " //\n" \ |
794 | " //\n" \ |
795 | " //\n" \ |
796 | " //\n" \ |
797 | " const ctor = view.constructor;\n" \ |
798 | "\n" \ |
799 | " const pullIntoDescriptor = {\n" \ |
800 | " buffer: view.buffer,\n" \ |
801 | " byteOffset: view.byteOffset,\n" \ |
802 | " byteLength: view.byteLength,\n" \ |
803 | " bytesFilled: 0,\n" \ |
804 | " elementSize,\n" \ |
805 | " ctor,\n" \ |
806 | " readerType: 'byob'\n" \ |
807 | " };\n" \ |
808 | "\n" \ |
809 | " if (@getByIdDirectPrivate(controller, \"pendingPullIntos\").length) {\n" \ |
810 | " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \ |
811 | " @getByIdDirectPrivate(controller, \"pendingPullIntos\").@push(pullIntoDescriptor);\n" \ |
812 | " return @readableStreamAddReadIntoRequest(stream);\n" \ |
813 | " }\n" \ |
814 | "\n" \ |
815 | " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \ |
816 | " const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);\n" \ |
817 | " return @Promise.@resolve({ value: emptyView, done: true });\n" \ |
818 | " }\n" \ |
819 | "\n" \ |
820 | " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \ |
821 | " if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \ |
822 | " const filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \ |
823 | " @readableByteStreamControllerHandleQueueDrain(controller);\n" \ |
824 | " return @Promise.@resolve({ value: filledView, done: false });\n" \ |
825 | " }\n" \ |
826 | " if (@getByIdDirectPrivate(controller, \"closeRequested\")) {\n" \ |
827 | " const e = @makeTypeError(\"Closing stream has been requested\");\n" \ |
828 | " @readableByteStreamControllerError(controller, e);\n" \ |
829 | " return @Promise.@reject(e);\n" \ |
830 | " }\n" \ |
831 | " }\n" \ |
832 | "\n" \ |
833 | " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \ |
834 | " @getByIdDirectPrivate(controller, \"pendingPullIntos\").@push(pullIntoDescriptor);\n" \ |
835 | " const promise = @readableStreamAddReadIntoRequest(stream);\n" \ |
836 | " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \ |
837 | " return promise;\n" \ |
838 | "})\n" \ |
839 | ; |
840 | |
841 | const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; |
842 | const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength = 458; |
843 | static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; |
844 | const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode = |
845 | "(function (stream)\n" \ |
846 | "{\n" \ |
847 | " \"use strict\";\n" \ |
848 | "\n" \ |
849 | " @assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(stream, \"reader\")));\n" \ |
850 | " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable || @getByIdDirectPrivate(stream, \"state\") === @streamClosed);\n" \ |
851 | "\n" \ |
852 | " const readRequest = @newPromiseCapability(@Promise);\n" \ |
853 | " @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").@push(readRequest);\n" \ |
854 | "\n" \ |
855 | " return readRequest.@promise;\n" \ |
856 | "})\n" \ |
857 | ; |
858 | |
859 | |
860 | #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ |
861 | JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ |
862 | {\ |
863 | JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \ |
864 | return clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Source(), WTF::nullopt, s_##codeName##Intrinsic); \ |
865 | } |
866 | WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) |
867 | #undef DEFINE_BUILTIN_GENERATOR |
868 | |
869 | |
870 | } // namespace WebCore |
871 | |
872 | #endif // ENABLE(STREAMS_API) |
873 | |