Skip to content

Commit

Permalink
deps: V8: backport d2ccc59
Browse files Browse the repository at this point in the history
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 <yangguo@chromium.org>
    Commit-Queue: Yang Guo <yangguo@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#62095}

Refs: v8/v8@d2ccc59

PR-URL: nodejs#28648
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and Trott committed Jul 16, 2019
1 parent 87d0d8c commit 2a15037
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.14',
'v8_embedder_string': '-node.15',

##### V8 defaults for Node.js #####

Expand Down
8 changes: 5 additions & 3 deletions deps/v8/src/snapshot/serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ void Serializer::SerializeRootObject(Object object) {
}

#ifdef DEBUG
void Serializer::PrintStack() {
void Serializer::PrintStack() { PrintStack(std::cout); }

void Serializer::PrintStack(std::ostream& out) {
for (const auto o : stack_) {
o->Print();
PrintF("\n");
o.Print(out);
out << "\n";
}
}
#endif // DEBUG
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/snapshot/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class Serializer : public SerializerDeserializer {
void PushStack(HeapObject o) { stack_.push_back(o); }
void PopStack() { stack_.pop_back(); }
void PrintStack();
void PrintStack(std::ostream&);
#endif // DEBUG

SerializerReferenceMap* reference_map() { return &reference_map_; }
Expand Down
11 changes: 10 additions & 1 deletion deps/v8/src/snapshot/startup-serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) {
#endif // DEBUG

void StartupSerializer::SerializeObject(HeapObject obj) {
DCHECK(!obj->IsJSFunction());
#ifdef DEBUG
if (obj.IsJSFunction()) {
v8::base::OS::PrintError("Reference stack:\n");
PrintStack(std::cerr);
obj.Print(std::cerr);
FATAL(
"JSFunction should be added through the context snapshot instead of "
"the isolate snapshot");
}
#endif // DEBUG
DCHECK(!IsUnexpectedCodeObject(isolate(), obj));

if (SerializeHotObject(obj)) return;
Expand Down

0 comments on commit 2a15037

Please sign in to comment.