| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { | 148 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { |
| 149 deopt_infos_.push_back(entry->GetDeoptInfo()); | 149 deopt_infos_.push_back(entry->GetDeoptInfo()); |
| 150 entry->clear_deopt_info(); | 150 entry->clear_deopt_info(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { | 154 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { |
| 155 HashMap::Entry* map_entry = | 155 HashMap::Entry* map_entry = children_.Lookup(entry, CodeEntryHash(entry)); |
| 156 children_.Lookup(entry, CodeEntryHash(entry), false); | |
| 157 return map_entry != NULL ? | 156 return map_entry != NULL ? |
| 158 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; | 157 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; |
| 159 } | 158 } |
| 160 | 159 |
| 161 | 160 |
| 162 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { | 161 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { |
| 163 HashMap::Entry* map_entry = | 162 HashMap::Entry* map_entry = |
| 164 children_.Lookup(entry, CodeEntryHash(entry), true); | 163 children_.LookupOrInsert(entry, CodeEntryHash(entry)); |
| 165 ProfileNode* node = reinterpret_cast<ProfileNode*>(map_entry->value); | 164 ProfileNode* node = reinterpret_cast<ProfileNode*>(map_entry->value); |
| 166 if (node == NULL) { | 165 if (node == NULL) { |
| 167 // New node added. | 166 // New node added. |
| 168 node = new ProfileNode(tree_, entry); | 167 node = new ProfileNode(tree_, entry); |
| 169 map_entry->value = node; | 168 map_entry->value = node; |
| 170 children_list_.Add(node); | 169 children_list_.Add(node); |
| 171 } | 170 } |
| 172 return node; | 171 return node; |
| 173 } | 172 } |
| 174 | 173 |
| 175 | 174 |
| 176 void ProfileNode::IncrementLineTicks(int src_line) { | 175 void ProfileNode::IncrementLineTicks(int src_line) { |
| 177 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) return; | 176 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) return; |
| 178 // Increment a hit counter of a certain source line. | 177 // Increment a hit counter of a certain source line. |
| 179 // Add a new source line if not found. | 178 // Add a new source line if not found. |
| 180 HashMap::Entry* e = | 179 HashMap::Entry* e = |
| 181 line_ticks_.Lookup(reinterpret_cast<void*>(src_line), src_line, true); | 180 line_ticks_.LookupOrInsert(reinterpret_cast<void*>(src_line), src_line); |
| 182 DCHECK(e); | 181 DCHECK(e); |
| 183 e->value = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(e->value) + 1); | 182 e->value = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(e->value) + 1); |
| 184 } | 183 } |
| 185 | 184 |
| 186 | 185 |
| 187 bool ProfileNode::GetLineTicks(v8::CpuProfileNode::LineTick* entries, | 186 bool ProfileNode::GetLineTicks(v8::CpuProfileNode::LineTick* entries, |
| 188 unsigned int length) const { | 187 unsigned int length) const { |
| 189 if (entries == NULL || length == 0) return false; | 188 if (entries == NULL || length == 0) return false; |
| 190 | 189 |
| 191 unsigned line_count = line_ticks_.occupancy(); | 190 unsigned line_count = line_ticks_.occupancy(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 261 |
| 263 ProfileTree::~ProfileTree() { | 262 ProfileTree::~ProfileTree() { |
| 264 DeleteNodesCallback cb; | 263 DeleteNodesCallback cb; |
| 265 TraverseDepthFirst(&cb); | 264 TraverseDepthFirst(&cb); |
| 266 } | 265 } |
| 267 | 266 |
| 268 | 267 |
| 269 unsigned ProfileTree::GetFunctionId(const ProfileNode* node) { | 268 unsigned ProfileTree::GetFunctionId(const ProfileNode* node) { |
| 270 CodeEntry* code_entry = node->entry(); | 269 CodeEntry* code_entry = node->entry(); |
| 271 HashMap::Entry* entry = | 270 HashMap::Entry* entry = |
| 272 function_ids_.Lookup(code_entry, code_entry->GetHash(), true); | 271 function_ids_.LookupOrInsert(code_entry, code_entry->GetHash()); |
| 273 if (!entry->value) { | 272 if (!entry->value) { |
| 274 entry->value = reinterpret_cast<void*>(next_function_id_++); | 273 entry->value = reinterpret_cast<void*>(next_function_id_++); |
| 275 } | 274 } |
| 276 return static_cast<unsigned>(reinterpret_cast<uintptr_t>(entry->value)); | 275 return static_cast<unsigned>(reinterpret_cast<uintptr_t>(entry->value)); |
| 277 } | 276 } |
| 278 | 277 |
| 279 | 278 |
| 280 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path, | 279 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path, |
| 281 int src_line) { | 280 int src_line) { |
| 282 ProfileNode* node = root_; | 281 ProfileNode* node = root_; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 case OTHER: | 690 case OTHER: |
| 692 case EXTERNAL: | 691 case EXTERNAL: |
| 693 return program_entry_; | 692 return program_entry_; |
| 694 case IDLE: | 693 case IDLE: |
| 695 return idle_entry_; | 694 return idle_entry_; |
| 696 default: return NULL; | 695 default: return NULL; |
| 697 } | 696 } |
| 698 } | 697 } |
| 699 | 698 |
| 700 } } // namespace v8::internal | 699 } } // namespace v8::internal |
| OLD | NEW |