-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib,src: use built-in array buffer detach #50130
Conversation
63d7adb
to
8eaae52
Compare
Note that the v8 flag |
@@ -702,7 +699,7 @@ class ReadableStreamBYOBRequest { | |||
const viewBuffer = ArrayBufferViewGetBuffer(view); | |||
const viewBufferByteLength = ArrayBufferPrototypeGetByteLength(viewBuffer); | |||
|
|||
if (isArrayBufferDetached(viewBuffer)) { | |||
if (viewBuffer.detached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a mutable property, so it must be a primordial
if (viewBuffer.detached) { | |
if (ArrayBufferPrototypeDetached(viewBuffer)) { |
@@ -729,7 +726,7 @@ class ReadableStreamBYOBRequest { | |||
|
|||
validateBuffer(view, 'view'); | |||
|
|||
if (isViewedArrayBufferDetached(view)) { | |||
if (ArrayBufferViewGetBuffer(view).detached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ArrayBufferViewGetBuffer(view).detached) { | |
if (ArrayBufferPrototypeDetached(ArrayBufferViewGetBuffer(view)) { |
@@ -1946,7 +1943,7 @@ function readableByteStreamControllerConvertPullIntoDescriptor(desc) { | |||
if (bytesFilled > byteLength) | |||
throw new ERR_INVALID_STATE.RangeError('The buffer size is invalid'); | |||
assert(!(bytesFilled % elementSize)); | |||
const transferredBuffer = transferArrayBuffer(buffer); | |||
const transferredBuffer = buffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const transferredBuffer = buffer.transfer(); | |
const transferredBuffer = ArrayBufferPrototypeTransfer(buffer); |
@@ -2615,7 +2612,7 @@ function readableByteStreamControllerPullInto( | |||
|
|||
let transferredBuffer; | |||
try { | |||
transferredBuffer = transferArrayBuffer(buffer); | |||
transferredBuffer = buffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transferredBuffer = buffer.transfer(); | |
transferredBuffer = ArrayBufferPrototypeTransfer(buffer); |
@@ -2707,7 +2704,7 @@ function readableByteStreamControllerRespond(controller, bytesWritten) { | |||
throw new ERR_INVALID_ARG_VALUE.RangeError('bytesWritten', bytesWritten); | |||
} | |||
|
|||
desc.buffer = transferArrayBuffer(desc.buffer); | |||
desc.buffer = desc.buffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc.buffer = desc.buffer.transfer(); | |
desc.buffer = ArrayBufferPrototypeTransfer(desc.buffer); |
@@ -2757,22 +2754,20 @@ function readableByteStreamControllerEnqueue(controller, chunk) { | |||
if (closeRequested || stream[kState].state !== 'readable') | |||
return; | |||
|
|||
const transferredBuffer = transferArrayBuffer(buffer); | |||
const transferredBuffer = buffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const transferredBuffer = buffer.transfer(); | |
const transferredBuffer = ArrayBufferPrototypeTransfer(buffer); |
|
||
if (pendingPullIntos.length) { | ||
const firstPendingPullInto = pendingPullIntos[0]; | ||
|
||
if (isArrayBufferDetached(firstPendingPullInto.buffer)) { | ||
if (firstPendingPullInto.buffer.detached) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (firstPendingPullInto.buffer.detached) { | |
if (ArrayBufferPrototypeDetached(firstPendingPullInto.buffer)) { |
firstPendingPullInto.buffer = transferArrayBuffer( | ||
firstPendingPullInto.buffer, | ||
); | ||
firstPendingPullInto.buffer = firstPendingPullInto.buffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstPendingPullInto.buffer = firstPendingPullInto.buffer.transfer(); | |
firstPendingPullInto.buffer = ArrayBufferPrototypeTransfer(firstPendingPullInto.buffer); |
@@ -3067,7 +3062,7 @@ function readableByteStreamControllerRespondWithNewView(controller, view) { | |||
if (bufferByteLength !== viewBufferByteLength) | |||
throw new ERR_INVALID_ARG_VALUE.RangeError('view', view); | |||
|
|||
desc.buffer = transferArrayBuffer(viewBuffer); | |||
desc.buffer = viewBuffer.transfer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desc.buffer = viewBuffer.transfer(); | |
desc.buffer = ArrayBufferPrototypeTransfer(viewBuffer); |
8eaae52
to
9096c77
Compare
@legendecas would you be interested in removing the flag that disables arraybuffer.prototype.detach, from v8? |
Sure, the feature has been released since M111 and I believe it is a good time to remove the flag. |
v8/v8@9ebca66 the flag was removed since V8 12.6. |
I couldn't make the
|
My |
This change requires v8 11.8, therefore can't be backported to v18 and v20