Reviewers: Jarin, Benedikt Meurer,
Message:
Re-opening the topic of pretty printers for regalloc data structures at
debug
time.
Description:
When working on the register allocator, I often need to introspect the
various
components of the model - e.g. InstructionSequence, Instruction, LiveRange,
etc.
A pretty printer would help. While we have a suite of operator<< defined for
these types, turns out that using them at debug time is close to impossible
-
gdb has poor (or convoluted) support for instantiating structures (e.g.
OFStream, PrintableInstructionSequence, etc), and calling operator<< with
pass-by-reference semantics.
I explored gdb macros, but hit an issue quite early with instantiating and
initializing an OFStream - "virtual baseclass botch".
Currently, I have a side-file that I include (and then remove before
publishing
CLs), which defines wrappers to the above operator<< APIs, but this is
becoming
quite awkward, and I believe the functionality to be quite useful to anyone
working in this (regalloc) area, so it's worth having something better than
local side-files. The gdb path seems overly-twisted for the problem at
hand, and
I've noticed elsewhere (e.g. Object) the presence of Print APIs - hence this
change.
BUG=
Please review this at https://codereview.chromium.org/1280483002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+57, -0 lines):
M src/compiler/register-allocator.h
M src/compiler/register-allocator.cc
Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc
b/src/compiler/register-allocator.cc
index
5bf858a86cf6e7551ce7a033603cc7c17990cbe2..7836970d84b4d75ce99ddece8c7f8d4d8314b082
100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -1087,6 +1087,57 @@ bool
RegisterAllocationData::IsBlockBoundary(LifetimePosition pos) const {
}
+void RegisterAllocationData::Print(
+ const InstructionSequence* instructionSequence) {
+ OFStream os(stdout);
+ PrintableInstructionSequence wrapper;
+ wrapper.register_configuration_ = config();
+ wrapper.sequence_ = instructionSequence;
+ os << wrapper << std::endl;
+}
+
+
+void RegisterAllocationData::Print(const Instruction* instruction) {
+ OFStream os(stdout);
+ PrintableInstruction wrapper;
+ wrapper.instr_ = instruction;
+ wrapper.register_configuration_ = config();
+ os << wrapper << std::endl;
+}
+
+
+void RegisterAllocationData::Print(const LiveRange* range, bool
with_children) {
+ OFStream os(stdout);
+ PrintableLiveRange wrapper;
+ wrapper.register_configuration_ = config();
+ for (const LiveRange* i = range; i != nullptr; i = i->next()) {
+ wrapper.range_ = i;
+ os << wrapper << std::endl;
+ if (!with_children) break;
+ }
+}
+
+
+void RegisterAllocationData::Print(const InstructionOperand& op) {
+ OFStream os(stdout);
+ PrintableInstructionOperand wrapper;
+ wrapper.register_configuration_ = config();
+ wrapper.op_ = op;
+ os << wrapper << std::endl;
+}
+
+
+void RegisterAllocationData::Print(const MoveOperands* move) {
+ OFStream os(stdout);
+ PrintableInstructionOperand wrapper;
+ wrapper.register_configuration_ = config();
+ wrapper.op_ = move->destination();
+ os << wrapper << " = ";
+ wrapper.op_ = move->source();
+ os << wrapper << std::endl;
+}
+
+
ConstraintBuilder::ConstraintBuilder(RegisterAllocationData* data)
: data_(data) {}
Index: src/compiler/register-allocator.h
diff --git a/src/compiler/register-allocator.h
b/src/compiler/register-allocator.h
index
cd3a5f6ca5b1cb7aff1b38ee9e52917f52be2622..1a4f91b1695102c13562b5d95284324216f34a5c
100644
--- a/src/compiler/register-allocator.h
+++ b/src/compiler/register-allocator.h
@@ -630,6 +630,12 @@ class RegisterAllocationData final : public ZoneObject
{
PhiMapValue* GetPhiMapValueFor(int virtual_register);
bool IsBlockBoundary(LifetimePosition pos) const;
+ void Print(const InstructionSequence* instructionSequence);
+ void Print(const Instruction* instruction);
+ void Print(const LiveRange* range, bool with_children = false);
+ void Print(const InstructionOperand& op);
+ void Print(const MoveOperands* move);
+
private:
Zone* const allocation_zone_;
Frame* const frame_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.