Skip to content

Commit 492b7cb

Browse files
committed
deps: V8: cherry-pick d2ccc59
Original commit message: [snapshot] print reference stack for JSFunctions in the isolate snapshot This helps debugging incorrect usage of the SnapshotCreator API in debug mode. Change-Id: Ibd9db76a5f460cdf7ea6d14e865592ebaf69aeef Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648240 Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#62095} Refs: v8/v8@d2ccc59 Backport-PR-URL: #28955 PR-URL: #28016 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann (רפאל פלחי) <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent 945955f commit 492b7cb

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.12',
41+
'v8_embedder_string': '-node.13',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/snapshot/serializer.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ void Serializer::SerializeRootObject(Object object) {
115115
}
116116

117117
#ifdef DEBUG
118-
void Serializer::PrintStack() {
118+
void Serializer::PrintStack() { PrintStack(std::cout); }
119+
120+
void Serializer::PrintStack(std::ostream& out) {
119121
for (const auto o : stack_) {
120-
o.Print();
121-
PrintF("\n");
122+
o.Print(out);
123+
out << "\n";
122124
}
123125
}
124126
#endif // DEBUG

deps/v8/src/snapshot/serializer.h

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class Serializer : public SerializerDeserializer {
250250
void PushStack(HeapObject o) { stack_.push_back(o); }
251251
void PopStack() { stack_.pop_back(); }
252252
void PrintStack();
253+
void PrintStack(std::ostream&);
253254
#endif // DEBUG
254255

255256
SerializerReferenceMap* reference_map() { return &reference_map_; }

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) {
7171
#endif // DEBUG
7272

7373
void StartupSerializer::SerializeObject(HeapObject obj) {
74-
DCHECK(!obj.IsJSFunction());
74+
#ifdef DEBUG
75+
if (obj.IsJSFunction()) {
76+
v8::base::OS::PrintError("Reference stack:\n");
77+
PrintStack(std::cerr);
78+
obj.Print(std::cerr);
79+
FATAL(
80+
"JSFunction should be added through the context snapshot instead of "
81+
"the isolate snapshot");
82+
}
83+
#endif // DEBUG
7584
DCHECK(!IsUnexpectedCodeObject(isolate(), obj));
7685

7786
if (SerializeHotObject(obj)) return;

0 commit comments

Comments
 (0)