Commit 6a0ff91c authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[in-place weak refs] Add MaybeObject::Print.

BUG=v8:7308

Change-Id: I12a38a6099f0ffd8718dc5cb77433baa75bc0411
Reviewed-on: https://chromium-review.googlesource.com/1059110
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53183}
parent 7631358e
...@@ -1999,6 +1999,29 @@ void InterpreterData::InterpreterDataPrint(std::ostream& os) { // NOLINT ...@@ -1999,6 +1999,29 @@ void InterpreterData::InterpreterDataPrint(std::ostream& os) { // NOLINT
os << "\n"; os << "\n";
} }
void MaybeObject::Print() {
OFStream os(stdout);
this->Print(os);
os << std::flush;
}
void MaybeObject::Print(std::ostream& os) {
Smi* smi;
HeapObject* heap_object;
if (ToSmi(&smi)) {
smi->SmiPrint(os);
} else if (IsClearedWeakHeapObject()) {
os << "[cleared]";
} else if (ToWeakHeapObject(&heap_object)) {
os << "[weak] ";
heap_object->HeapObjectPrint(os);
} else if (ToStrongHeapObject(&heap_object)) {
heap_object->HeapObjectPrint(os);
} else {
UNREACHABLE();
}
}
#endif // OBJECT_PRINT #endif // OBJECT_PRINT
// TODO(cbruni): remove once the new maptracer is in place. // TODO(cbruni): remove once the new maptracer is in place.
...@@ -2228,6 +2251,7 @@ void JSObject::PrintTransitions(std::ostream& os) { // NOLINT ...@@ -2228,6 +2251,7 @@ void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
os << "\n - transitions"; os << "\n - transitions";
ta.PrintTransitions(os); ta.PrintTransitions(os);
} }
#endif // defined(DEBUG) || defined(OBJECT_PRINT) #endif // defined(DEBUG) || defined(OBJECT_PRINT)
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -2448,6 +2448,18 @@ void Object::ShortPrint(StringStream* accumulator) { ...@@ -2448,6 +2448,18 @@ void Object::ShortPrint(StringStream* accumulator) {
void Object::ShortPrint(std::ostream& os) { os << Brief(this); } void Object::ShortPrint(std::ostream& os) { os << Brief(this); }
void MaybeObject::ShortPrint(FILE* out) {
OFStream os(out);
os << MaybeObjectBrief(this);
}
void MaybeObject::ShortPrint(StringStream* accumulator) {
std::ostringstream os;
os << MaybeObjectBrief(this);
accumulator->Add(os.str().c_str());
}
void MaybeObject::ShortPrint(std::ostream& os) { os << MaybeObjectBrief(this); }
std::ostream& operator<<(std::ostream& os, const Brief& v) { std::ostream& operator<<(std::ostream& os, const Brief& v) {
if (v.value->IsSmi()) { if (v.value->IsSmi()) {
......
...@@ -61,6 +61,23 @@ class MaybeObject { ...@@ -61,6 +61,23 @@ class MaybeObject {
static void VerifyMaybeObjectPointer(MaybeObject* p); static void VerifyMaybeObjectPointer(MaybeObject* p);
#endif #endif
// Prints this object without details.
void ShortPrint(FILE* out = stdout);
// Prints this object without details to a message accumulator.
void ShortPrint(StringStream* accumulator);
void ShortPrint(std::ostream& os);
#ifdef OBJECT_PRINT
void Print();
void Print(std::ostream& os);
#else
void Print() { ShortPrint(); }
void Print(std::ostream& os) { ShortPrint(os); }
#endif
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(MaybeObject); DISALLOW_IMPLICIT_CONSTRUCTORS(MaybeObject);
}; };
......
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