Index: src/profile-generator.cc |
diff --git a/src/profile-generator.cc b/src/profile-generator.cc |
index 74dfbf445c219d9cc947aac77140b31cc49cc0c0..a7384a62aa5afa124df4c334ac0f6c1a581680a8 100644 |
--- a/src/profile-generator.cc |
+++ b/src/profile-generator.cc |
@@ -492,6 +492,28 @@ const CodeMap::CodeTreeConfig::Value CodeMap::CodeTreeConfig::kNoValue = |
CodeMap::CodeEntryInfo(NULL, 0); |
+void CodeMap::AddCode(Address addr, CodeEntry* entry, unsigned size) { |
+ DeleteAllCoveredCode(addr, addr + size); |
+ CodeTree::Locator locator; |
+ tree_.Insert(addr, &locator); |
+ locator.set_value(CodeEntryInfo(entry, size)); |
+} |
+ |
+ |
+void CodeMap::DeleteAllCoveredCode(Address start, Address end) { |
+ List<Address> to_delete; |
+ Address addr = end - 1; |
+ while (addr >= start) { |
+ CodeTree::Locator locator; |
+ if (!tree_.FindGreatestLessThan(addr, &locator)) break; |
+ Address start2 = locator.key(), end2 = start2 + locator.value().size; |
+ if (start2 < end && start < end2) to_delete.Add(start2); |
+ addr = start2 - 1; |
+ } |
+ for (int i = 0; i < to_delete.length(); ++i) tree_.Remove(to_delete[i]); |
+} |
+ |
+ |
CodeEntry* CodeMap::FindEntry(Address addr) { |
CodeTree::Locator locator; |
if (tree_.FindGreatestLessThan(addr, &locator)) { |
@@ -520,6 +542,16 @@ int CodeMap::GetSharedId(Address addr) { |
} |
+void CodeMap::MoveCode(Address from, Address to) { |
+ if (from == to) return; |
+ CodeTree::Locator locator; |
+ if (!tree_.Find(from, &locator)) return; |
+ CodeEntryInfo entry = locator.value(); |
+ tree_.Remove(from); |
+ AddCode(to, entry.entry, entry.size); |
+} |
+ |
+ |
void CodeMap::CodeTreePrinter::Call( |
const Address& key, const CodeMap::CodeEntryInfo& value) { |
OS::Print("%p %5d %s\n", key, value.size, value.entry->name()); |