-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
src,lib: make JSTransferables based on private symbols #47956
src,lib: make JSTransferables based on private symbols #47956
Conversation
Review requested:
|
Since this is a new feature, this PR can wait until the V8 change gets merged with the v8 currency updates, instead of landing the cherry-picked V8 commit. |
src/node_messaging.cc
Outdated
bool has_transfer_mode; | ||
if (!object->HasPrivate(context, env->transfer_mode_private_symbol()) | ||
.To(&has_transfer_mode)) { | ||
return Nothing<bool>(); |
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.
Do we need to handle Nothing as well? Or can we just assume it is not transferable or transferable? This would reduce the complexity of the implementation below
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.
I dug a bit into the private symbol implementation. I believe we can safely assume that accessing the private symbol data properties should not throw and we can remove the maybe handle checks here.
Thanks for the idea.
oooo... yes! thank you for doing this. |
The HTML structured serialize algorithm treats transferable and serializable as two different bits. A web platform interface can be both transferable and serializable. Splits BaseObject::TransferMode to be able to compose the two bits and distinguishes the transferable and cloneable.
Original commit message: [objects] Determine host objects with serializer delegate Enable custom host objects filter with ValueSerializer::Delegate when ValueSerializer::Delegate::HasCustomHostObject returns true. This allows the embedder to serialize JavaScript implemented host objects. Bug: v8:11927 Change-Id: I70e7aa70b10dc1053c113d521479cbe746febc7e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4385565 Commit-Queue: Chengzhong Wu (legendecas) <legendecas@gmail.com> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/main@{#87055} Refs: v8/v8@cf13b9b
Serializes and transfers platform objects implemented as a JS class based on private symbols instead of V8 object internal slots. This avoids the need to alter the prototype chains and mixins to make the JS class to be transferable.
ca73f52
to
b61b4c9
Compare
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.
rubberstamp LGTM
This is amazing, thanks!
Commit Queue failed- Loading data for nodejs/node/pull/47956 ✔ Done loading data for nodejs/node/pull/47956 ----------------------------------- PR info ------------------------------------ Title src,lib: make JSTransferables based on private symbols (#47956) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch legendecas:webidl/jstransferable -> nodejs:main Labels lib / src, needs-ci Commits 5 - src: distinguish HTML transferable and cloneable - deps: V8: cherry-pick cf13b9b46572 - src,lib: make JSTransferables based on private symbols - fixup! src,lib: make JSTransferables based on private symbols - fixup! deps: V8: cherry-pick cf13b9b46572 Committers 1 - Chengzhong Wu PR-URL: https://github.com/nodejs/node/pull/47956 Refs: https://github.com/v8/v8/commit/cf13b9b46572a9824d2d632abdd48c56161ace02 Reviewed-By: Matteo Collina Reviewed-By: Yagiz Nizipli Reviewed-By: Daeyeon Jeong ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/47956 Refs: https://github.com/v8/v8/commit/cf13b9b46572a9824d2d632abdd48c56161ace02 Reviewed-By: Matteo Collina Reviewed-By: Yagiz Nizipli Reviewed-By: Daeyeon Jeong -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 11 May 2023 06:32:01 GMT ✔ Approvals: 3 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/47956#pullrequestreview-1514024315 ✔ - Yagiz Nizipli (@anonrig): https://github.com/nodejs/node/pull/47956#pullrequestreview-1514347888 ✔ - Daeyeon Jeong (@daeyeon): https://github.com/nodejs/node/pull/47956#pullrequestreview-1519291904 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2023-07-07T09:30:00Z: https://ci.nodejs.org/job/node-test-pull-request/52645/ - Querying data for job/node-test-pull-request/52645/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 47956 From https://github.com/nodejs/node * branch refs/pull/47956/merge -> FETCH_HEAD ✔ Fetched commits as 3205b1936a5c..9558dfbc1604 -------------------------------------------------------------------------------- Auto-merging src/node_file.cc [main 1db5272fe6] src: distinguish HTML transferable and cloneable Author: legendecas Date: Mon Apr 10 02:24:06 2023 +0800 10 files changed, 104 insertions(+), 94 deletions(-) [main 7a5bc6c681] deps: V8: cherry-pick cf13b9b46572 Author: Chengzhong Wu Date: Thu Apr 13 15:22:38 2023 +0800 5 files changed, 110 insertions(+), 3 deletions(-) [main 81dabd1439] src,lib: make JSTransferables based on private symbols Author: Chengzhong Wu Date: Sat May 6 17:00:50 2023 +0800 23 files changed, 342 insertions(+), 232 deletions(-) rename test/parallel/{test-messaging-maketransferable.js => test-messaging-marktransfermode.js} (82%) [main d5adc625d1] fixup! src,lib: make JSTransferables based on private symbols Author: Chengzhong Wu Date: Wed Jul 5 17:09:27 2023 +0800 1 file changed, 4 insertions(+), 4 deletions(-) [main 847a70f995] fixup! deps: V8: cherry-pick cf13b9b46572 Author: Chengzhong Wu Date: Thu Jul 6 17:11:22 2023 +0800 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied There are 5 commits in the PR. Attempting autorebase. Rebasing (2/8)https://github.com/nodejs/node/actions/runs/5488694803 |
Landed in 38dee8a |
@anonrig I think it might be better to land PRs that contain V8 cherry-picks as separate commits with
commit-queue-rebase
|
You’re absolutely right. This was an error. Sorry for the trouble caused! |
This depends on #47604 (it needs the |
The HTML structured serialize algorithm treats transferable and serializable as two different bits. A web platform interface can be both transferable and serializable. Splits BaseObject::TransferMode to be able to compose the two bits and distinguishes the transferable and cloneable. PR-URL: nodejs#47956 Refs: v8/v8@cf13b9b Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
The HTML structured serialize algorithm treats transferable and serializable as two different bits. A web platform interface can be both transferable and serializable. Splits BaseObject::TransferMode to be able to compose the two bits and distinguishes the transferable and cloneable. PR-URL: nodejs#47956 Refs: v8/v8@cf13b9b Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
I think this might be valuable to backport to LTS lines. This PR is not marked as
semver-major
@juanarbol @ruyadorno what do you think, may I remove the dont-land-on-x labels? |
src: distinguish HTML transferable and cloneable
The HTML structured serialize algorithm treats transferable and
serializable as two different bits. A web platform interface can be
both transferable and serializable.
Splits BaseObject::TransferMode to be able to compose the two bits
and distinguishes the transferable and cloneable.
deps: V8: cherry-pick cf13b9b46572
Original commit message:
Refs: v8/v8@cf13b9b
src,lib: make JSTransferables based on private symbols
Serializes and transfers platform objects implemented as a JS class
based on private symbols instead of V8 object internal slots. This
avoids the need to alter the prototype chains and mixins to make the
JS class to be transferable.
The performance improvements on the platform object creation (e.g. web streams) can be observable as:
Refs: #47497 (comment)