Dramatically speeding up HIR comments.
This commit is contained in:
parent
56a4620cdf
commit
14e1438ec0
|
@ -56,9 +56,9 @@ bool PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
||||||
|
|
||||||
with_debug_info_ = (flags & EMIT_DEBUG_COMMENTS) == EMIT_DEBUG_COMMENTS;
|
with_debug_info_ = (flags & EMIT_DEBUG_COMMENTS) == EMIT_DEBUG_COMMENTS;
|
||||||
if (with_debug_info_) {
|
if (with_debug_info_) {
|
||||||
Comment("%s fn %.8X-%.8X %s", symbol_info->module()->name().c_str(),
|
CommentFormat("%s fn %.8X-%.8X %s", symbol_info->module()->name().c_str(),
|
||||||
symbol_info->address(), symbol_info->end_address(),
|
symbol_info->address(), symbol_info->end_address(),
|
||||||
symbol_info->name().c_str());
|
symbol_info->name().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate offset list.
|
// Allocate offset list.
|
||||||
|
@ -101,8 +101,9 @@ bool PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
||||||
AnnotateLabel(address, label);
|
AnnotateLabel(address, label);
|
||||||
}
|
}
|
||||||
comment_buffer_.Reset();
|
comment_buffer_.Reset();
|
||||||
|
comment_buffer_.AppendFormat("%.8X %.8X ", address, i.code);
|
||||||
DisasmPPC(i, &comment_buffer_);
|
DisasmPPC(i, &comment_buffer_);
|
||||||
Comment("%.8X %.8X %s", address, i.code, comment_buffer_.GetString());
|
Comment(comment_buffer_);
|
||||||
first_instr = last_instr();
|
first_instr = last_instr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
#include "xenia/cpu/symbol_info.h"
|
#include "xenia/cpu/symbol_info.h"
|
||||||
#include "xenia/profiling.h"
|
#include "xenia/profiling.h"
|
||||||
|
|
||||||
|
// Will scribble arena memory to hopefully find use before clears.
|
||||||
|
//#define SCRIBBLE_ARENA_ON_RESET
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace cpu {
|
namespace cpu {
|
||||||
namespace hir {
|
namespace hir {
|
||||||
|
@ -57,7 +60,7 @@ void HIRBuilder::Reset() {
|
||||||
locals_.clear();
|
locals_.clear();
|
||||||
block_head_ = block_tail_ = NULL;
|
block_head_ = block_tail_ = NULL;
|
||||||
current_block_ = NULL;
|
current_block_ = NULL;
|
||||||
#if XE_DEBUG
|
#if SCRIBBLE_ARENA_ON_RESET
|
||||||
arena_->DebugFill();
|
arena_->DebugFill();
|
||||||
#endif
|
#endif
|
||||||
arena_->Reset();
|
arena_->Reset();
|
||||||
|
@ -727,18 +730,38 @@ Value* HIRBuilder::CloneValue(Value* source) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HIRBuilder::Comment(const char* format, ...) {
|
void HIRBuilder::Comment(const char* value) {
|
||||||
char buffer[1024];
|
size_t length = std::strlen(value);
|
||||||
va_list args;
|
if (!length) {
|
||||||
va_start(args, format);
|
|
||||||
vsnprintf(buffer, 1024, format, args);
|
|
||||||
va_end(args);
|
|
||||||
size_t len = strlen(buffer);
|
|
||||||
if (!len) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void* p = arena_->Alloc(len + 1);
|
void* p = arena_->Alloc(length + 1);
|
||||||
memcpy(p, buffer, len + 1);
|
std::memcpy(p, value, length + 1);
|
||||||
|
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);
|
||||||
|
i->src1.offset = (uint64_t)p;
|
||||||
|
i->src2.value = i->src3.value = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HIRBuilder::Comment(const StringBuffer& value) {
|
||||||
|
if (!value.length()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void* p = arena_->Alloc(value.length() + 1);
|
||||||
|
std::memcpy(p, value.GetString(), value.length() + 1);
|
||||||
|
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);
|
||||||
|
i->src1.offset = (uint64_t)p;
|
||||||
|
i->src2.value = i->src3.value = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HIRBuilder::CommentFormat(const char* format, ...) {
|
||||||
|
static const uint32_t kMaxCommentSize = 1024;
|
||||||
|
char* p = reinterpret_cast<char*>(arena_->Alloc(kMaxCommentSize));
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
size_t chars_written = vsnprintf(p, kMaxCommentSize - 1, format, args);
|
||||||
|
va_end(args);
|
||||||
|
size_t rewind = kMaxCommentSize - chars_written;
|
||||||
|
arena_->Rewind(rewind);
|
||||||
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);
|
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);
|
||||||
i->src1.offset = (uint64_t)p;
|
i->src1.offset = (uint64_t)p;
|
||||||
i->src2.value = i->src3.value = NULL;
|
i->src2.value = i->src3.value = NULL;
|
||||||
|
|
|
@ -68,7 +68,9 @@ class HIRBuilder {
|
||||||
// static allocations:
|
// static allocations:
|
||||||
// Value* AllocStatic(size_t length);
|
// Value* AllocStatic(size_t length);
|
||||||
|
|
||||||
void Comment(const char* format, ...);
|
void Comment(const char* value);
|
||||||
|
void Comment(const StringBuffer& value);
|
||||||
|
void CommentFormat(const char* format, ...);
|
||||||
|
|
||||||
void Nop();
|
void Nop();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue