[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 <victorgomes@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85602}
This commit is contained in:
Leszek Swirski 2023-02-01 17:53:50 +01:00 committed by V8 LUCI CQ
parent d54ce968c4
commit 2b01466c93
2 changed files with 28 additions and 7 deletions

View File

@ -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);

View File

@ -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<int16_t>(instance_type)
<< "]";
}
std::ostream& operator<<(std::ostream& os, PropertyCellType type) {