From 2b01466c9383f72fd5b42622d92155fdbbbd90cb Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Wed, 1 Feb 2023 17:53:50 +0100 Subject: [PATCH] [ic] Improve printing of polymorphic feedback ... in particular, for keyed loads that have names in the feedback. Also make InstanceType printing more robust against invalid instance types. Change-Id: Ib4bef4646c3a18643291d0bb517ef3470b7497cf Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4213911 Reviewed-by: Victor Gomes Auto-Submit: Leszek Swirski Commit-Queue: Leszek Swirski Cr-Commit-Position: refs/heads/main@{#85602} --- src/diagnostics/objects-printer.cc | 32 ++++++++++++++++++++++++------ src/objects/objects.cc | 3 ++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/diagnostics/objects-printer.cc b/src/diagnostics/objects-printer.cc index da1a1f20a7..735c3900f7 100644 --- a/src/diagnostics/objects-printer.cc +++ b/src/diagnostics/objects-printer.cc @@ -1307,10 +1307,20 @@ void FeedbackNexus::Print(std::ostream& os) { os << InlineCacheState2String(ic_state()); if (ic_state() == InlineCacheState::MONOMORPHIC) { os << "\n " << Brief(GetFeedback()) << ": "; - LoadHandler::PrintHandler(GetFeedbackExtra().GetHeapObjectOrSmi(), os); + Object handler = GetFeedbackExtra().GetHeapObjectOrSmi(); + if (handler.IsWeakFixedArray()) { + handler = WeakFixedArray::cast(handler).Get(0).GetHeapObjectOrSmi(); + } + LoadHandler::PrintHandler(handler, os); } else if (ic_state() == InlineCacheState::POLYMORPHIC) { - WeakFixedArray array = - WeakFixedArray::cast(GetFeedback().GetHeapObject()); + HeapObject feedback = GetFeedback().GetHeapObject(); + WeakFixedArray array; + if (feedback.IsName()) { + os << " with name " << Brief(feedback); + array = WeakFixedArray::cast(GetFeedbackExtra().GetHeapObject()); + } else { + array = WeakFixedArray::cast(feedback); + } for (int i = 0; i < array.length(); i += 2) { os << "\n " << Brief(array.Get(i)) << ": "; LoadHandler::PrintHandler(array.Get(i + 1).GetHeapObjectOrSmi(), os); @@ -1325,10 +1335,20 @@ void FeedbackNexus::Print(std::ostream& os) { os << InlineCacheState2String(ic_state()); if (ic_state() == InlineCacheState::MONOMORPHIC) { os << "\n " << Brief(GetFeedback()) << ": "; - StoreHandler::PrintHandler(GetFeedbackExtra().GetHeapObjectOrSmi(), os); + Object handler = GetFeedbackExtra().GetHeapObjectOrSmi(); + if (handler.IsWeakFixedArray()) { + handler = WeakFixedArray::cast(handler).Get(0).GetHeapObjectOrSmi(); + } + StoreHandler::PrintHandler(handler, os); } else if (ic_state() == InlineCacheState::POLYMORPHIC) { - WeakFixedArray array = - WeakFixedArray::cast(GetFeedback().GetHeapObject()); + HeapObject feedback = GetFeedback().GetHeapObject(); + WeakFixedArray array; + if (feedback.IsName()) { + os << " with name " << Brief(feedback); + array = WeakFixedArray::cast(GetFeedbackExtra().GetHeapObject()); + } else { + array = WeakFixedArray::cast(feedback); + } for (int i = 0; i < array.length(); i += 2) { os << "\n " << Brief(array.Get(i)) << ": "; StoreHandler::PrintHandler(array.Get(i + 1).GetHeapObjectOrSmi(), os); diff --git a/src/objects/objects.cc b/src/objects/objects.cc index 2611c5abc0..1483f71924 100644 --- a/src/objects/objects.cc +++ b/src/objects/objects.cc @@ -190,7 +190,8 @@ std::ostream& operator<<(std::ostream& os, InstanceType instance_type) { INSTANCE_TYPE_LIST(WRITE_TYPE) #undef WRITE_TYPE } - UNREACHABLE(); + return os << "[unknown instance type " << static_cast(instance_type) + << "]"; } std::ostream& operator<<(std::ostream& os, PropertyCellType type) {