Skip to content

src,lib: make JSTransferables based on private symbols

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:

[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](https://github.com/legendecas/node/issues/87055)}

Refs: https://github.com/v8/v8/commit/cf13b9b46572a9824d2d632abdd48c56161ace02

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:

                                                      confidence improvement accuracy (*)   (**)  (***)
webstreams/creation.js kind='ReadableStream' n=50000         ***    137.35 %       ±1.72% ±2.31% ±3.02%
webstreams/creation.js kind='TransformStream' n=50000        ***     93.73 %       ±0.97% ±1.30% ±1.69%
webstreams/creation.js kind='WritableStream' n=50000         ***    128.99 %       ±1.69% ±2.27% ±2.99%

Be aware that when doing many comparisons the risk of a false-positive result increases.
In this case, there are 3 comparisons, you can thus expect the following amount of false-positive results:
  0.15 false positives, when considering a   5% risk acceptance (*, **, ***),
  0.03 false positives, when considering a   1% risk acceptance (**, ***),
  0.00 false positives, when considering a 0.1% risk acceptance (***)

Refs: https://github.com/nodejs/node/pull/47497#discussion_r1163043458

Merge request reports

Loading