Speeding up source map lookup for x64 disasm.

This commit is contained in:
Ben Vanik
2015-06-10 00:29:07 -07:00
parent 14e1438ec0
commit 9c58426231
4 changed files with 25 additions and 19 deletions

View File

@@ -20,10 +20,10 @@ DebugInfo::DebugInfo()
hir_disasm_(nullptr),
machine_code_disasm_(nullptr),
source_map_count_(0),
source_map_(nullptr) {}
source_map_entries_(nullptr) {}
DebugInfo::~DebugInfo() {
free(source_map_);
free(source_map_entries_);
free(source_disasm_);
free(raw_hir_disasm_);
free(hir_disasm_);
@@ -33,7 +33,7 @@ DebugInfo::~DebugInfo() {
void DebugInfo::InitializeSourceMap(size_t source_map_count,
SourceMapEntry* source_map) {
source_map_count_ = source_map_count;
source_map_ = source_map;
source_map_entries_ = source_map;
// TODO(benvanik): ensure sorted in some way? MC offset?
}
@@ -41,7 +41,7 @@ void DebugInfo::InitializeSourceMap(size_t source_map_count,
SourceMapEntry* DebugInfo::LookupSourceOffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t n = 0; n < source_map_count_; n++) {
auto entry = &source_map_[n];
auto entry = &source_map_entries_[n];
if (entry->source_offset == offset) {
return entry;
}
@@ -52,7 +52,7 @@ SourceMapEntry* DebugInfo::LookupSourceOffset(uint32_t offset) {
SourceMapEntry* DebugInfo::LookupHIROffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (size_t n = 0; n < source_map_count_; n++) {
auto entry = &source_map_[n];
auto entry = &source_map_entries_[n];
if (entry->hir_offset >= offset) {
return entry;
}
@@ -63,7 +63,7 @@ SourceMapEntry* DebugInfo::LookupHIROffset(uint32_t offset) {
SourceMapEntry* DebugInfo::LookupCodeOffset(uint32_t offset) {
// TODO(benvanik): binary search? We know the list is sorted by code order.
for (int64_t n = source_map_count_ - 1; n >= 0; n--) {
auto entry = &source_map_[n];
auto entry = &source_map_entries_[n];
if (entry->code_offset <= offset) {
return entry;
}