Improved asmjit trace - pretty print nodes being removed

This commit is contained in:
kobalicek
2016-03-29 04:57:56 +02:00
parent 6ef5878eca
commit 446a5f1cb1
3 changed files with 19 additions and 6 deletions

View File

@@ -27,11 +27,11 @@ namespace asmjit {
Context::Context(Compiler* compiler) : Context::Context(Compiler* compiler) :
_compiler(compiler), _compiler(compiler),
_zoneAllocator(8192 - Zone::kZoneOverhead), _zoneAllocator(8192 - Zone::kZoneOverhead),
_traceNode(nullptr),
_varMapToVaListOffset(0) { _varMapToVaListOffset(0) {
Context::reset(); Context::reset();
} }
Context::~Context() {} Context::~Context() {}
// ============================================================================ // ============================================================================
@@ -312,7 +312,9 @@ Error Context::removeUnreachableCode() {
} }
if (remove) { if (remove) {
ASMJIT_TLOG("[%05d] Removing unreachable node\n", node->getFlowId()); ASMJIT_TSEC({
this->_traceNode(this, node, "[REMOVED UNREACHABLE] ");
});
compiler->removeNode(node); compiler->removeNode(node);
} }

View File

@@ -816,6 +816,13 @@ struct Context {
//! Zone allocator. //! Zone allocator.
Zone _zoneAllocator; Zone _zoneAllocator;
//! \internal
typedef void (ASMJIT_CDECL* TraceNodeFunc)(Context* self, HLNode* node_, const char* prefix);
//! \internal
//!
//! Only non-NULL when ASMJIT_TRACE is enabled.
TraceNodeFunc _traceNode;
//! \internal //! \internal
//! //!
//! Offset (how many bytes to add) to `VarMap` to get `VarAttr` array. Used //! Offset (how many bytes to add) to `VarMap` to get `VarAttr` array. Used

View File

@@ -156,7 +156,7 @@ static bool X86Context_annotateInstruction(X86Context* self,
#endif // !ASMJIT_DISABLE_LOGGER #endif // !ASMJIT_DISABLE_LOGGER
#if defined(ASMJIT_TRACE) #if defined(ASMJIT_TRACE)
static void X86Context_traceNode(X86Context* self, HLNode* node_, const char* prefix) { static void ASMJIT_CDECL X86Context_traceNode(X86Context* self, HLNode* node_, const char* prefix) {
StringBuilderTmp<256> sb; StringBuilderTmp<256> sb;
switch (node_->getType()) { switch (node_->getType()) {
@@ -263,6 +263,10 @@ X86Context::X86Context(X86Compiler* compiler) : Context(compiler) {
_memSlot._vmem.type = kMemTypeStackIndex; _memSlot._vmem.type = kMemTypeStackIndex;
_memSlot.setGpdBase(compiler->getArch() == kArchX86); _memSlot.setGpdBase(compiler->getArch() == kArchX86);
#if defined(ASMJIT_TRACE)
_traceNode = (TraceNodeFunc)X86Context_traceNode;
#endif // ASMJIT_TRACE
#if !defined(ASMJIT_DISABLE_LOGGER) #if !defined(ASMJIT_DISABLE_LOGGER)
_emitComments = compiler->getAssembler()->hasLogger(); _emitComments = compiler->getAssembler()->hasLogger();
#endif // !ASMJIT_DISABLE_LOGGER #endif // !ASMJIT_DISABLE_LOGGER
@@ -2279,7 +2283,7 @@ _NextGroup:
node_->setFlowId(flowId); node_->setFlowId(flowId);
ASMJIT_TSEC({ ASMJIT_TSEC({
X86Context_traceNode(this, node_, "[F] "); this->_traceNode(this, node_, "[F] ");
}); });
switch (node_->getType()) { switch (node_->getType()) {
@@ -3777,7 +3781,7 @@ ASMJIT_INLINE uint32_t X86VarAlloc::guessAlloc(VarData* vd, uint32_t allocableRe
for (;;) { for (;;) {
do { do {
ASMJIT_TSEC({ ASMJIT_TSEC({
X86Context_traceNode(_context, node, " "); _context->_traceNode(_context, node, " ");
}); });
// Terminate if we have seen this node already. // Terminate if we have seen this node already.
@@ -5449,7 +5453,7 @@ _NextGroup:
node_->orFlags(HLNode::kFlagIsTranslated); node_->orFlags(HLNode::kFlagIsTranslated);
ASMJIT_TSEC({ ASMJIT_TSEC({
X86Context_traceNode(this, node_, "[T] "); this->_traceNode(this, node_, "[T] ");
}); });
switch (node_->getType()) { switch (node_->getType()) {