Commit d2ccc599 authored by Joyee Cheung's avatar Joyee Cheung Committed by Commit Bot

[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/+/1648240Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62095}
parent 081e5070
...@@ -115,10 +115,12 @@ void Serializer::SerializeRootObject(Object object) { ...@@ -115,10 +115,12 @@ void Serializer::SerializeRootObject(Object object) {
} }
#ifdef DEBUG #ifdef DEBUG
void Serializer::PrintStack() { void Serializer::PrintStack() { PrintStack(std::cout); }
void Serializer::PrintStack(std::ostream& out) {
for (const auto o : stack_) { for (const auto o : stack_) {
o.Print(); o.Print(out);
PrintF("\n"); out << "\n";
} }
} }
#endif // DEBUG #endif // DEBUG
......
...@@ -250,6 +250,7 @@ class Serializer : public SerializerDeserializer { ...@@ -250,6 +250,7 @@ class Serializer : public SerializerDeserializer {
void PushStack(HeapObject o) { stack_.push_back(o); } void PushStack(HeapObject o) { stack_.push_back(o); }
void PopStack() { stack_.pop_back(); } void PopStack() { stack_.pop_back(); }
void PrintStack(); void PrintStack();
void PrintStack(std::ostream&);
#endif // DEBUG #endif // DEBUG
SerializerReferenceMap* reference_map() { return &reference_map_; } SerializerReferenceMap* reference_map() { return &reference_map_; }
......
...@@ -71,7 +71,16 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) { ...@@ -71,7 +71,16 @@ bool IsUnexpectedCodeObject(Isolate* isolate, HeapObject obj) {
#endif // DEBUG #endif // DEBUG
void StartupSerializer::SerializeObject(HeapObject obj) { 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)); DCHECK(!IsUnexpectedCodeObject(isolate(), obj));
if (SerializeHotObject(obj)) return; if (SerializeHotObject(obj)) return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment