[codegen] Factor out safepoint table printing
The logic for printing a safepoint table is currently duplicated for Wasm code and on-heap code, with slight differences. This CL provides a central {SafepointTable::Print} method that is used in both scenarios. The format is slightly changed to explicitly specify which bitmap corresponds to stack slots and which one to registers. R=jkummerow@chromium.org Bug: v8:12401 Change-Id: I67366b1f9a92450a6ebec4210ab4811800a54f34 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306976 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#78159}
This commit is contained in:
parent
1976cbfb36
commit
667187fc08
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "src/codegen/safepoint-table.h"
|
#include "src/codegen/safepoint-table.h"
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "src/codegen/assembler-inl.h"
|
#include "src/codegen/assembler-inl.h"
|
||||||
#include "src/codegen/macro-assembler.h"
|
#include "src/codegen/macro-assembler.h"
|
||||||
#include "src/deoptimizer/deoptimizer.h"
|
#include "src/deoptimizer/deoptimizer.h"
|
||||||
@ -71,11 +73,39 @@ SafepointEntry SafepointTable::FindEntry(Address pc) const {
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SafepointTable::PrintEntry(int index, std::ostream& os) const {
|
void SafepointTable::Print(std::ostream& os) const {
|
||||||
for (uint8_t bits : GetEntry(index).tagged_slots()) {
|
os << "Safepoints (entries = " << length_ << ", byte size = " << byte_size()
|
||||||
for (int bit = 0; bit < kBitsPerByte; ++bit) {
|
<< ")\n";
|
||||||
os << ((bits >> bit) & 1);
|
|
||||||
|
for (int index = 0; index < length_; index++) {
|
||||||
|
SafepointEntry entry = GetEntry(index);
|
||||||
|
os << reinterpret_cast<const void*>(instruction_start_ + entry.pc()) << " "
|
||||||
|
<< std::setw(6) << std::hex << entry.pc();
|
||||||
|
|
||||||
|
if (!entry.tagged_slots().empty()) {
|
||||||
|
os << " slots (sp->fp): ";
|
||||||
|
for (uint8_t bits : entry.tagged_slots()) {
|
||||||
|
for (int bit = 0; bit < kBitsPerByte; ++bit) {
|
||||||
|
os << ((bits >> bit) & 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entry.tagged_register_indexes() != 0) {
|
||||||
|
os << " registers: ";
|
||||||
|
uint32_t register_bits = entry.tagged_register_indexes();
|
||||||
|
int bits = 32 - base::bits::CountLeadingZeros32(register_bits);
|
||||||
|
for (int j = bits - 1; j >= 0; --j) {
|
||||||
|
os << ((register_bits >> j) & 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.has_deoptimization_index()) {
|
||||||
|
os << " deopt " << std::setw(6) << entry.deoptimization_index()
|
||||||
|
<< " trampoline: " << std::setw(6) << std::hex
|
||||||
|
<< entry.trampoline_pc();
|
||||||
|
}
|
||||||
|
os << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class SafepointTable {
|
|||||||
// Returns the entry for the given pc.
|
// Returns the entry for the given pc.
|
||||||
SafepointEntry FindEntry(Address pc) const;
|
SafepointEntry FindEntry(Address pc) const;
|
||||||
|
|
||||||
void PrintEntry(int index, std::ostream& os) const;
|
void Print(std::ostream&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Layout information.
|
// Layout information.
|
||||||
|
@ -585,23 +585,7 @@ void Code::Disassemble(const char* name, std::ostream& os, Isolate* isolate,
|
|||||||
|
|
||||||
if (has_safepoint_info()) {
|
if (has_safepoint_info()) {
|
||||||
SafepointTable table(isolate, current_pc, *this);
|
SafepointTable table(isolate, current_pc, *this);
|
||||||
os << "Safepoints (entries = " << table.length()
|
table.Print(os);
|
||||||
<< ", byte size = " << table.byte_size() << ")\n";
|
|
||||||
for (int i = 0; i < table.length(); i++) {
|
|
||||||
SafepointEntry entry = table.GetEntry(i);
|
|
||||||
os << reinterpret_cast<const void*>(InstructionStart() + entry.pc())
|
|
||||||
<< " " << std::setw(6) << std::hex << entry.pc() << " ";
|
|
||||||
print_pc(os, entry.trampoline_pc());
|
|
||||||
os << std::dec << " ";
|
|
||||||
table.PrintEntry(i, os);
|
|
||||||
os << " (sp -> fp) ";
|
|
||||||
if (entry.has_deoptimization_index()) {
|
|
||||||
os << std::setw(6) << entry.deoptimization_index();
|
|
||||||
} else {
|
|
||||||
os << "<none>";
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
os << "\n";
|
os << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,28 +436,7 @@ void WasmCode::Disassemble(const char* name, std::ostream& os,
|
|||||||
|
|
||||||
if (safepoint_table_offset_ > 0) {
|
if (safepoint_table_offset_ > 0) {
|
||||||
SafepointTable table(this);
|
SafepointTable table(this);
|
||||||
// TODO(clemensb): Unify with printing in code.cc.
|
table.Print(os);
|
||||||
os << "Safepoints (entries = " << table.length()
|
|
||||||
<< ", byte size = " << table.byte_size() << ")\n";
|
|
||||||
for (int i = 0; i < table.length(); i++) {
|
|
||||||
SafepointEntry entry = table.GetEntry(i);
|
|
||||||
os << reinterpret_cast<const void*>(instruction_start() + entry.pc())
|
|
||||||
<< " " << std::setw(6) << std::hex << entry.pc() << " ";
|
|
||||||
table.PrintEntry(i, os);
|
|
||||||
os << " (sp -> fp)";
|
|
||||||
if (entry.trampoline_pc() != SafepointEntry::kNoTrampolinePC) {
|
|
||||||
os << " trampoline: " << std::hex << entry.trampoline_pc() << std::dec;
|
|
||||||
}
|
|
||||||
if (entry.tagged_register_indexes() != 0) {
|
|
||||||
os << " registers: ";
|
|
||||||
uint32_t register_bits = entry.tagged_register_indexes();
|
|
||||||
int bits = 32 - base::bits::CountLeadingZeros32(register_bits);
|
|
||||||
for (int j = bits - 1; j >= 0; --j) {
|
|
||||||
os << ((register_bits >> j) & 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
os << "\n";
|
os << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user