Commit 6d1ce935 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[printing] Improve ScopeInfo printing

Bug: v8:7066
Change-Id: I5aa7e976eee6b197586a656ee2e38b9d429ec07b
Reviewed-on: https://chromium-review.googlesource.com/955587Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51881}
parent f1cf0733
......@@ -866,6 +866,26 @@ enum ScopeType : uint8_t {
WITH_SCOPE // The scope introduced by with.
};
inline std::ostream& operator<<(std::ostream& os, ScopeType type) {
switch (type) {
case ScopeType::EVAL_SCOPE:
return os << "EVAL_SCOPE";
case ScopeType::FUNCTION_SCOPE:
return os << "FUNCTION_SCOPE";
case ScopeType::MODULE_SCOPE:
return os << "MODULE_SCOPE";
case ScopeType::SCRIPT_SCOPE:
return os << "SCRIPT_SCOPE";
case ScopeType::CATCH_SCOPE:
return os << "CATCH_SCOPE";
case ScopeType::BLOCK_SCOPE:
return os << "BLOCK_SCOPE";
case ScopeType::WITH_SCOPE:
return os << "WITH_SCOPE";
}
UNREACHABLE();
}
// AllocationSiteMode controls whether allocations are tracked by an allocation
// site.
enum AllocationSiteMode {
......
......@@ -1169,7 +1169,7 @@ void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT
os << "\n - formal_parameter_count: " << internal_formal_parameter_count();
os << "\n - expected_nof_properties: " << expected_nof_properties();
os << "\n - language_mode: " << language_mode();
os << " - code: " << Brief(code());
os << "\n - code: " << Brief(code());
if (HasBytecodeArray()) {
os << "\n - bytecode_array: " << bytecode_array();
}
......
......@@ -3342,9 +3342,13 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
break;
STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE
case SCOPE_INFO_TYPE:
os << "<ScopeInfo[" << ScopeInfo::cast(this)->length() << "]>";
case SCOPE_INFO_TYPE: {
ScopeInfo* scope = ScopeInfo::cast(this);
os << "<ScopeInfo";
if (scope->length()) os << " " << scope->scope_type() << " ";
os << "[" << scope->length() << "]>";
break;
}
case CODE_TYPE: {
Code* code = Code::cast(this);
os << "<Code " << Code::Kind2String(code->kind());
......
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