Skip to content

Commit c8e15cd

Browse files
committed
deps: V8: cherry-pick 821fb3883a8e
Original commit message: [serializer] avoid deferring objects with embedder fields JS objects with embedder fields cannot be deferred because the serialize/deserialize callbacks need the back reference immediately to identify the object. Refs: nodejs/node-v8#175 Bug: v8:11146 Change-Id: I4292f2ab0041f7b0779620437ed26905c194cd9b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2531195 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Joyee Cheung <joyee@igalia.com> Cr-Commit-Position: refs/heads/master@{#71134} Refs: v8/v8@821fb38 PR-URL: #35700 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
1 parent b0d6742 commit c8e15cd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.9',
39+
'v8_embedder_string': '-node.10',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/snapshot/serializer-deserializer.cc

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ void SerializerDeserializer::Iterate(Isolate* isolate, RootVisitor* visitor) {
3030
}
3131

3232
bool SerializerDeserializer::CanBeDeferred(HeapObject o) {
33-
// Maps cannot be deferred as objects are expected to have a valid map
34-
// immediately. Internalized strings cannot be deferred as they might be
33+
// 1. Maps cannot be deferred as objects are expected to have a valid map
34+
// immediately.
35+
// 2. Internalized strings cannot be deferred as they might be
3536
// converted to thin strings during post processing, at which point forward
3637
// references to the now-thin string will already have been written.
38+
// 3. JS objects with embedder fields cannot be deferred because the
39+
// serialize/deserialize callbacks need the back reference immediately to
40+
// identify the object.
3741
// TODO(leszeks): Could we defer string serialization if forward references
3842
// were resolved after object post processing?
39-
return !o.IsMap() && !o.IsInternalizedString();
43+
return !o.IsMap() && !o.IsInternalizedString() &&
44+
!(o.IsJSObject() && JSObject::cast(o).GetEmbedderFieldCount() > 0);
4045
}
4146

4247
void SerializerDeserializer::RestoreExternalReferenceRedirector(

0 commit comments

Comments
 (0)