Commit 0f4004fe authored by Yang Guo's avatar Yang Guo

[serializer] track objects being serialized in debug mode.

This is to make debugging serialization easier by having a way
to inspect the object graph. Serializer::PrintStack() can be
invoked from the debugger to print the current traversal path.

R=jgruber@chromium.org

Change-Id: Ie67408ade7989dc559904821b3f009fdfe3e459f
Reviewed-on: https://chromium-review.googlesource.com/571219Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46662}
parent 387f65d4
......@@ -147,6 +147,13 @@ bool Serializer::BackReferenceIsAlreadyAllocated(
}
}
}
void Serializer::PrintStack() {
for (const auto& o : stack_) {
o->Print();
PrintF("\n");
}
}
#endif // DEBUG
bool Serializer::SerializeHotObject(HeapObject* obj, HowToCode how_to_code,
......
......@@ -186,8 +186,6 @@ class Serializer : public SerializerDeserializer {
}
}
bool BackReferenceIsAlreadyAllocated(SerializerReference back_reference);
// This will return the space for an object.
SerializerReference AllocateLargeObject(int size);
SerializerReference AllocateMap();
......@@ -222,6 +220,14 @@ class Serializer : public SerializerDeserializer {
void OutputStatistics(const char* name);
#ifdef DEBUG
void PushStack(HeapObject* o) { stack_.Add(o); }
void PopStack() { stack_.RemoveLast(); }
void PrintStack();
bool BackReferenceIsAlreadyAllocated(SerializerReference back_reference);
#endif // DEBUG
Isolate* isolate_;
SnapshotByteSink sink_;
......@@ -264,6 +270,10 @@ class Serializer : public SerializerDeserializer {
size_t* instance_type_size_;
#endif // OBJECT_PRINT
#ifdef DEBUG
List<HeapObject*> stack_;
#endif // DEBUG
DISALLOW_COPY_AND_ASSIGN(Serializer);
};
......@@ -277,8 +287,16 @@ class Serializer::ObjectSerializer : public ObjectVisitor {
sink_(sink),
reference_representation_(how_to_code + where_to_point),
bytes_processed_so_far_(0),
code_has_been_output_(false) {}
~ObjectSerializer() override {}
code_has_been_output_(false) {
#ifdef DEBUG
serializer_->PushStack(obj);
#endif // DEBUG
}
~ObjectSerializer() override {
#ifdef DEBUG
serializer_->PopStack();
#endif // DEBUG
}
void Serialize();
void SerializeContent();
void SerializeDeferred();
......
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