@@ -3348,7 +3348,12 @@ The following abstract operations support the implementation of the
3348
3348
1. Otherwise, if ! [$ReadableStreamHasBYOBReader$] (|stream|) is true,
3349
3349
1. Perform ! [$ReadableByteStreamControllerEnqueueChunkToQueue$] (|controller|,
3350
3350
|transferredBuffer|, |byteOffset|, |byteLength|).
3351
- 1. Perform ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3351
+ 1. Let |filledPullIntos| be the result of performing
3352
+ ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3353
+ 1. [=list/For each=] |filledPullInto| of |filledPullIntos|,
3354
+ 1. Perform !
3355
+ [$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|controller|.[=ReadableByteStreamController/[[stream]]=] ,
3356
+ |filledPullInto|).
3352
3357
1. Otherwise,
3353
3358
1. Assert: ! [$IsReadableStreamLocked$] (|stream|) is false.
3354
3359
1. Perform ! [$ReadableByteStreamControllerEnqueueChunkToQueue$] (|controller|,
@@ -3433,6 +3438,7 @@ The following abstract operations support the implementation of the
3433
3438
|maxBytesToCopy|.
3434
3439
1. Let |totalBytesToCopyRemaining| be |maxBytesToCopy|.
3435
3440
1. Let |ready| be false.
3441
+ 1. Assert: ! [$IsDetachedBuffer$] (|pullIntoDescriptor|'s [=pull-into descriptor/buffer=] ) is false.
3436
3442
1. Assert: |pullIntoDescriptor|'s [=pull-into descriptor/bytes filled=] < |pullIntoDescriptor|' s
3437
3443
[=pull-into descriptor/minimum fill=] .
3438
3444
1. Let |remainderBytes| be the remainder after dividing |maxBytesFilled| by |pullIntoDescriptor|'s
@@ -3452,6 +3458,14 @@ The following abstract operations support the implementation of the
3452
3458
queue entry/byte length=] ).
3453
3459
1. Let |destStart| be |pullIntoDescriptor|'s [=pull-into descriptor/byte offset=] +
3454
3460
|pullIntoDescriptor|'s [=pull-into descriptor/bytes filled=] .
3461
+ 1. Assert: ! [$CanCopyDataBlockBytes$] (|pullIntoDescriptor|'s [=pull-into descriptor/buffer=] ,
3462
+ |destStart|, |headOfQueue|'s [=readable byte stream queue entry/buffer=] ,
3463
+ |headOfQueue|'s [=readable byte stream queue entry/byte offset=] , |bytesToCopy|) is true.
3464
+ <p class="warning"> If this assertion were to fail (due to a bug in this specification or
3465
+ its implementation), then the next step may read from or write to potentially invalid memory.
3466
+ The user agent should always check this assertion, and stop in an [=implementation-defined=]
3467
+ manner if it fails (e.g. by crashing the process, or by
3468
+ <a abstract-op lt="ReadableByteStreamControllerError">erroring the stream</a> ).
3455
3469
1. Perform ! [$CopyDataBlockBytes$] (|pullIntoDescriptor|'s [=pull-into
3456
3470
descriptor/buffer=] .\[[ArrayBufferData]] , |destStart|,
3457
3471
|headOfQueue|'s [=readable byte stream queue entry/buffer=] .\[[ArrayBufferData]] ,
@@ -3561,17 +3575,17 @@ The following abstract operations support the implementation of the
3561
3575
performs the following steps:
3562
3576
3563
3577
1. Assert: |controller|.[=ReadableByteStreamController/[[closeRequested]]=] is false.
3578
+ 1. Let |filledPullIntos| be a new empty [=list=] .
3564
3579
1. [=While=] |controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=] is not
3565
3580
[=list/is empty|empty=] ,
3566
- 1. If |controller|.[=ReadableByteStreamController/[[queueTotalSize]]=] is 0, return .
3581
+ 1. If |controller|.[=ReadableByteStreamController/[[queueTotalSize]]=] is 0, then [=break=] .
3567
3582
1. Let |pullIntoDescriptor| be
3568
3583
|controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=] [0] .
3569
3584
1. If ! [$ReadableByteStreamControllerFillPullIntoDescriptorFromQueue$] (|controller|,
3570
3585
|pullIntoDescriptor|) is true,
3571
3586
1. Perform ! [$ReadableByteStreamControllerShiftPendingPullInto$] (|controller|).
3572
- 1. Perform !
3573
- [$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|controller|.[=ReadableByteStreamController/[[stream]]=] ,
3574
- |pullIntoDescriptor|).
3587
+ 1. [=list/Append=] |pullIntoDescriptor| to |filledPullIntos|.
3588
+ 1. Return |filledPullIntos|.
3575
3589
</div>
3576
3590
3577
3591
<div algorithm>
@@ -3701,11 +3715,16 @@ The following abstract operations support the implementation of the
3701
3715
perform ! [$ReadableByteStreamControllerShiftPendingPullInto$] (|controller|).
3702
3716
1. Let |stream| be |controller|.[=ReadableByteStreamController/[[stream]]=] .
3703
3717
1. If ! [$ReadableStreamHasBYOBReader$] (|stream|) is true,
3704
- 1. [=While=] ! [$ReadableStreamGetNumReadIntoRequests$] (|stream|) > 0,
3718
+ 1. Let |filledPullIntos| be a new empty [=list=] .
3719
+ 1. Let |i| be 0.
3720
+ 1. [=While=] |i| < ! [$ReadableStreamGetNumReadIntoRequests$] (|stream|),
3705
3721
1. Let |pullIntoDescriptor| be !
3706
3722
[$ReadableByteStreamControllerShiftPendingPullInto$] (|controller|).
3723
+ 1. [=list/Append=] |pullIntoDescriptor| to |filledPullIntos|.
3724
+ 1. Set |i| to |i| + 1.
3725
+ 1. [=list/For each=] |filledPullInto| of |filledPullIntos|,
3707
3726
1. Perform ! [$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|stream|,
3708
- |pullIntoDescriptor |).
3727
+ |filledPullInto |).
3709
3728
</div>
3710
3729
3711
3730
<div algorithm>
@@ -3720,7 +3739,12 @@ The following abstract operations support the implementation of the
3720
3739
1. If |pullIntoDescriptor|'s [=pull-into descriptor/reader type=] is "`none`",
3721
3740
1. Perform ? [$ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue$] (|controller|,
3722
3741
|pullIntoDescriptor|).
3723
- 1. Perform ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3742
+ 1. Let |filledPullIntos| be the result of performing
3743
+ ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3744
+ 1. [=list/For each=] |filledPullInto| of |filledPullIntos|,
3745
+ 1. Perform !
3746
+ [$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|controller|.[=ReadableByteStreamController/[[stream]]=] ,
3747
+ |filledPullInto|).
3724
3748
1. Return.
3725
3749
1. If |pullIntoDescriptor|'s [=pull-into descriptor/bytes filled=] < |pullIntoDescriptor|' s
3726
3750
[=pull-into descriptor/minimum fill=] , return.
@@ -3738,10 +3762,15 @@ The following abstract operations support the implementation of the
3738
3762
|remainderSize|).
3739
3763
1. Set |pullIntoDescriptor|'s [=pull-into descriptor/bytes filled=] to |pullIntoDescriptor|' s
3740
3764
[=pull-into descriptor/bytes filled=] − |remainderSize|.
3765
+ 1. Let |filledPullIntos| be the result of performing
3766
+ ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3741
3767
1. Perform !
3742
3768
[$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|controller|.[=ReadableByteStreamController/[[stream]]=] ,
3743
3769
|pullIntoDescriptor|).
3744
- 1. Perform ! [$ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue$] (|controller|).
3770
+ 1. [=list/For each=] |filledPullInto| of |filledPullIntos|,
3771
+ 1. Perform !
3772
+ [$ReadableByteStreamControllerCommitPullIntoDescriptor$] (|controller|.[=ReadableByteStreamController/[[stream]]=] ,
3773
+ |filledPullInto|).
3745
3774
</div>
3746
3775
3747
3776
<div algorithm>
@@ -6848,6 +6877,22 @@ The following abstract operations are a grab-bag of utilities.
6848
6877
1. Return ? [$StructuredDeserialize$] (|serialized|, [=the current Realm=] ).
6849
6878
</div>
6850
6879
6880
+ <div algorithm>
6881
+ <dfn abstract-op lt="CanCopyDataBlockBytes">CanCopyDataBlockBytes(|toBuffer|, |toIndex|,
6882
+ |fromBuffer|, |fromIndex|, |count|)</dfn> performs the following steps:
6883
+
6884
+ 1. Assert: |toBuffer| [=is an Object=] .
6885
+ 1. Assert: |toBuffer| has an \[[ArrayBufferData]] internal slot.
6886
+ 1. Assert: |fromBuffer| [=is an Object=] .
6887
+ 1. Assert: |fromBuffer| has an \[[ArrayBufferData]] internal slot.
6888
+ 1. If |toBuffer| is |fromBuffer|, return false.
6889
+ 1. If ! [$IsDetachedBuffer$] (|toBuffer|) is true, return false.
6890
+ 1. If ! [$IsDetachedBuffer$] (|fromBuffer|) is true, return false.
6891
+ 1. If |toIndex| + |count| > |toBuffer|.\[[ArrayBufferByteLength]] , return false.
6892
+ 1. If |fromIndex| + |count| > |fromBuffer|.\[[ArrayBufferByteLength]] , return false.
6893
+ 1. Return true.
6894
+ </div>
6895
+
6851
6896
<h2 id="other-specs">Using streams in other specifications</h2>
6852
6897
6853
6898
Much of this standard concerns itself with the internal machinery of streams. Other specifications
0 commit comments