From 3b7c95220b7f3bb637d3b2d98dad3d590574e26a Mon Sep 17 00:00:00 2001 From: Michaël Zasso Date: Sat, 20 Jul 2019 13:38:32 +0200 Subject: deps: V8: cherry-pick d2ccc59 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Yang Guo Cr-Commit-Position: refs/heads/master@{#62095} Refs: https://github.com/v8/v8/commit/d2ccc599c7a31838752350ae927e41bc386df414 PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann (רפאל פלחי) Reviewed-By: Rich Trott Reviewed-By: Michael Dawson Reviewed-By: Jiawen Geng --- deps/v8/src/snapshot/serializer.cc | 8 +++++--- deps/v8/src/snapshot/serializer.h | 1 + deps/v8/src/snapshot/startup-serializer.cc | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'deps/v8/src') diff --git a/deps/v8/src/snapshot/serializer.cc b/deps/v8/src/snapshot/serializer.cc index 9eefbe2c48..b2dd6a33e7 100644 --- a/deps/v8/src/snapshot/serializer.cc +++ b/deps/v8/src/snapshot/serializer.cc @@ -115,10 +115,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 diff --git a/deps/v8/src/snapshot/serializer.h b/deps/v8/src/snapshot/serializer.h index c9e7fada80..b70c7fd45a 100644 --- a/deps/v8/src/snapshot/serializer.h +++ b/deps/v8/src/snapshot/serializer.h @@ -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_; } diff --git a/deps/v8/src/snapshot/startup-serializer.cc b/deps/v8/src/snapshot/startup-serializer.cc index 62a786f984..6ad2efc18b 100644 --- a/deps/v8/src/snapshot/startup-serializer.cc +++ b/deps/v8/src/snapshot/startup-serializer.cc @@ -71,7 +71,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; -- cgit v1.2.3