mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-17 12:34:35 +03:00
Improved asmjit trace - pretty print nodes being removed
This commit is contained in:
@@ -27,11 +27,11 @@ namespace asmjit {
|
||||
Context::Context(Compiler* compiler) :
|
||||
_compiler(compiler),
|
||||
_zoneAllocator(8192 - Zone::kZoneOverhead),
|
||||
_traceNode(nullptr),
|
||||
_varMapToVaListOffset(0) {
|
||||
|
||||
Context::reset();
|
||||
}
|
||||
|
||||
Context::~Context() {}
|
||||
|
||||
// ============================================================================
|
||||
@@ -312,7 +312,9 @@ Error Context::removeUnreachableCode() {
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
ASMJIT_TLOG("[%05d] Removing unreachable node\n", node->getFlowId());
|
||||
ASMJIT_TSEC({
|
||||
this->_traceNode(this, node, "[REMOVED UNREACHABLE] ");
|
||||
});
|
||||
compiler->removeNode(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -816,6 +816,13 @@ struct Context {
|
||||
//! Zone allocator.
|
||||
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
|
||||
//!
|
||||
//! Offset (how many bytes to add) to `VarMap` to get `VarAttr` array. Used
|
||||
|
||||
@@ -156,7 +156,7 @@ static bool X86Context_annotateInstruction(X86Context* self,
|
||||
#endif // !ASMJIT_DISABLE_LOGGER
|
||||
|
||||
#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;
|
||||
|
||||
switch (node_->getType()) {
|
||||
@@ -263,6 +263,10 @@ X86Context::X86Context(X86Compiler* compiler) : Context(compiler) {
|
||||
_memSlot._vmem.type = kMemTypeStackIndex;
|
||||
_memSlot.setGpdBase(compiler->getArch() == kArchX86);
|
||||
|
||||
#if defined(ASMJIT_TRACE)
|
||||
_traceNode = (TraceNodeFunc)X86Context_traceNode;
|
||||
#endif // ASMJIT_TRACE
|
||||
|
||||
#if !defined(ASMJIT_DISABLE_LOGGER)
|
||||
_emitComments = compiler->getAssembler()->hasLogger();
|
||||
#endif // !ASMJIT_DISABLE_LOGGER
|
||||
@@ -2279,7 +2283,7 @@ _NextGroup:
|
||||
node_->setFlowId(flowId);
|
||||
|
||||
ASMJIT_TSEC({
|
||||
X86Context_traceNode(this, node_, "[F] ");
|
||||
this->_traceNode(this, node_, "[F] ");
|
||||
});
|
||||
|
||||
switch (node_->getType()) {
|
||||
@@ -3777,7 +3781,7 @@ ASMJIT_INLINE uint32_t X86VarAlloc::guessAlloc(VarData* vd, uint32_t allocableRe
|
||||
for (;;) {
|
||||
do {
|
||||
ASMJIT_TSEC({
|
||||
X86Context_traceNode(_context, node, " ");
|
||||
_context->_traceNode(_context, node, " ");
|
||||
});
|
||||
|
||||
// Terminate if we have seen this node already.
|
||||
@@ -5449,7 +5453,7 @@ _NextGroup:
|
||||
node_->orFlags(HLNode::kFlagIsTranslated);
|
||||
|
||||
ASMJIT_TSEC({
|
||||
X86Context_traceNode(this, node_, "[T] ");
|
||||
this->_traceNode(this, node_, "[T] ");
|
||||
});
|
||||
|
||||
switch (node_->getType()) {
|
||||
|
||||
Reference in New Issue
Block a user