Commit 39985773 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[printer] Robustify handler printing

Make Load/StoreHandler printing a bit more robust against unexpected
values, which we may have missed in the printing definition (or the
value is corrupt, or the caller of the print is passing the wrong value
in) -- for printing like this it's better to be able to not crash on
invalid state.

Change-Id: Ibf5c2064d6aac3da1ac6c19469fe31d5f761b6dc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3918710
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83436}
parent 3ff531f5
...@@ -426,7 +426,8 @@ void PrintSmiLoadHandler(int raw_handler, std::ostream& os) { ...@@ -426,7 +426,8 @@ void PrintSmiLoadHandler(int raw_handler, std::ostream& os) {
<< LoadHandler::ExportsIndexBits::decode(raw_handler); << LoadHandler::ExportsIndexBits::decode(raw_handler);
break; break;
default: default:
UNREACHABLE(); os << "<invalid value " << static_cast<int>(kind) << ">";
break;
} }
} }
...@@ -518,7 +519,7 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) { ...@@ -518,7 +519,7 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) {
<< Builtins::name(CodeT::cast(handler).builtin_id()) << ")"; << Builtins::name(CodeT::cast(handler).builtin_id()) << ")";
} else if (handler.IsSymbol()) { } else if (handler.IsSymbol()) {
os << "LoadHandler(Symbol)(" << Brief(Symbol::cast(handler)) << ")"; os << "LoadHandler(Symbol)(" << Brief(Symbol::cast(handler)) << ")";
} else { } else if (handler.IsLoadHandler()) {
LoadHandler load_handler = LoadHandler::cast(handler); LoadHandler load_handler = LoadHandler::cast(handler);
int raw_handler = load_handler.smi_handler().ToSmi().value(); int raw_handler = load_handler.smi_handler().ToSmi().value();
os << "LoadHandler(do access check on lookup start object = " os << "LoadHandler(do access check on lookup start object = "
...@@ -526,9 +527,10 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) { ...@@ -526,9 +527,10 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) {
<< ", lookup on lookup start object = " << ", lookup on lookup start object = "
<< LookupOnLookupStartObjectBits::decode(raw_handler) << ", "; << LookupOnLookupStartObjectBits::decode(raw_handler) << ", ";
PrintSmiLoadHandler(raw_handler, os); PrintSmiLoadHandler(raw_handler, os);
DCHECK_GE(load_handler.data_field_count(), 1); if (load_handler.data_field_count() >= 1) {
os << ", data1 = "; os << ", data1 = ";
load_handler.data1().ShortPrint(os); load_handler.data1().ShortPrint(os);
}
if (load_handler.data_field_count() >= 2) { if (load_handler.data_field_count() >= 2) {
os << ", data2 = "; os << ", data2 = ";
load_handler.data2().ShortPrint(os); load_handler.data2().ShortPrint(os);
...@@ -540,6 +542,8 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) { ...@@ -540,6 +542,8 @@ void LoadHandler::PrintHandler(Object handler, std::ostream& os) {
os << ", validity cell = "; os << ", validity cell = ";
load_handler.validity_cell().ShortPrint(os); load_handler.validity_cell().ShortPrint(os);
os << ")"; os << ")";
} else {
os << "LoadHandler(<unexpected>)(" << Brief(handler) << ")";
} }
} }
...@@ -550,7 +554,7 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) { ...@@ -550,7 +554,7 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) {
os << "StoreHandler(Smi)("; os << "StoreHandler(Smi)(";
PrintSmiStoreHandler(raw_handler, os); PrintSmiStoreHandler(raw_handler, os);
os << ")" << std::endl; os << ")" << std::endl;
} else { } else if (handler.IsStoreHandler()) {
os << "StoreHandler("; os << "StoreHandler(";
StoreHandler store_handler = StoreHandler::cast(handler); StoreHandler store_handler = StoreHandler::cast(handler);
if (store_handler.smi_handler().IsCodeT()) { if (store_handler.smi_handler().IsCodeT()) {
...@@ -580,6 +584,8 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) { ...@@ -580,6 +584,8 @@ void StoreHandler::PrintHandler(Object handler, std::ostream& os) {
os << ", validity cell = "; os << ", validity cell = ";
store_handler.validity_cell().ShortPrint(os); store_handler.validity_cell().ShortPrint(os);
os << ")" << std::endl; os << ")" << std::endl;
} else {
os << "StoreHandler(<unexpected>)(" << Brief(handler) << ")";
} }
} }
......
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