| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return size; | 125 return size; |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) { | 129 HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) { |
| 130 uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_); | 130 uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_); |
| 131 return names_.Lookup(const_cast<char*>(str), hash, true); | 131 return names_.Lookup(const_cast<char*>(str), hash, true); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 JITLineInfoTable::JITLineInfoTable() {} | |
| 136 | |
| 137 | |
| 138 JITLineInfoTable::~JITLineInfoTable() {} | |
| 139 | |
| 140 | |
| 141 void JITLineInfoTable::SetPosition(int pc_offset, int line) { | |
| 142 DCHECK(pc_offset >= 0); | |
| 143 DCHECK(line > 0); // The 1-based number of the source line. | |
| 144 if (GetSourceLineNumber(pc_offset) != line) { | |
| 145 pc_offset_map_.insert(std::make_pair(pc_offset, line)); | |
| 146 } | |
| 147 } | |
| 148 | |
| 149 int JITLineInfoTable::GetSourceLineNumber(int pc_offset) const { | |
| 150 PcOffsetMap::const_iterator it = pc_offset_map_.lower_bound(pc_offset); | |
| 151 if (it == pc_offset_map_.end()) { | |
| 152 if (pc_offset_map_.empty()) return v8::CpuProfileNode::kNoLineNumberInfo; | |
| 153 return (--pc_offset_map_.end())->second; | |
| 154 } | |
| 155 return it->second; | |
| 156 } | |
| 157 | |
| 158 | |
| 159 const char* const CodeEntry::kEmptyNamePrefix = ""; | 135 const char* const CodeEntry::kEmptyNamePrefix = ""; |
| 160 const char* const CodeEntry::kEmptyResourceName = ""; | 136 const char* const CodeEntry::kEmptyResourceName = ""; |
| 161 const char* const CodeEntry::kEmptyBailoutReason = ""; | 137 const char* const CodeEntry::kEmptyBailoutReason = ""; |
| 162 | 138 |
| 163 | 139 |
| 164 CodeEntry::~CodeEntry() { | 140 CodeEntry::~CodeEntry() { |
| 165 delete no_frame_ranges_; | 141 delete no_frame_ranges_; |
| 166 delete line_info_; | |
| 167 } | 142 } |
| 168 | 143 |
| 169 | 144 |
| 170 uint32_t CodeEntry::GetCallUid() const { | 145 uint32_t CodeEntry::GetCallUid() const { |
| 171 uint32_t hash = ComputeIntegerHash(tag_, v8::internal::kZeroHashSeed); | 146 uint32_t hash = ComputeIntegerHash(tag_, v8::internal::kZeroHashSeed); |
| 172 if (shared_id_ != 0) { | 147 if (shared_id_ != 0) { |
| 173 hash ^= ComputeIntegerHash(static_cast<uint32_t>(shared_id_), | 148 hash ^= ComputeIntegerHash(static_cast<uint32_t>(shared_id_), |
| 174 v8::internal::kZeroHashSeed); | 149 v8::internal::kZeroHashSeed); |
| 175 } else { | 150 } else { |
| 176 hash ^= ComputeIntegerHash( | 151 hash ^= ComputeIntegerHash( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 199 && line_number_ == entry->line_number_))); | 174 && line_number_ == entry->line_number_))); |
| 200 } | 175 } |
| 201 | 176 |
| 202 | 177 |
| 203 void CodeEntry::SetBuiltinId(Builtins::Name id) { | 178 void CodeEntry::SetBuiltinId(Builtins::Name id) { |
| 204 tag_ = Logger::BUILTIN_TAG; | 179 tag_ = Logger::BUILTIN_TAG; |
| 205 builtin_id_ = id; | 180 builtin_id_ = id; |
| 206 } | 181 } |
| 207 | 182 |
| 208 | 183 |
| 209 int CodeEntry::GetSourceLine(int pc_offset) const { | |
| 210 if (line_info_ && !line_info_->empty()) { | |
| 211 return line_info_->GetSourceLineNumber(pc_offset); | |
| 212 } | |
| 213 return v8::CpuProfileNode::kNoLineNumberInfo; | |
| 214 } | |
| 215 | |
| 216 | |
| 217 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { | 184 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { |
| 218 HashMap::Entry* map_entry = | 185 HashMap::Entry* map_entry = |
| 219 children_.Lookup(entry, CodeEntryHash(entry), false); | 186 children_.Lookup(entry, CodeEntryHash(entry), false); |
| 220 return map_entry != NULL ? | 187 return map_entry != NULL ? |
| 221 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; | 188 reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; |
| 222 } | 189 } |
| 223 | 190 |
| 224 | 191 |
| 225 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { | 192 ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { |
| 226 HashMap::Entry* map_entry = | 193 HashMap::Entry* map_entry = |
| 227 children_.Lookup(entry, CodeEntryHash(entry), true); | 194 children_.Lookup(entry, CodeEntryHash(entry), true); |
| 228 if (map_entry->value == NULL) { | 195 if (map_entry->value == NULL) { |
| 229 // New node added. | 196 // New node added. |
| 230 ProfileNode* new_node = new ProfileNode(tree_, entry); | 197 ProfileNode* new_node = new ProfileNode(tree_, entry); |
| 231 map_entry->value = new_node; | 198 map_entry->value = new_node; |
| 232 children_list_.Add(new_node); | 199 children_list_.Add(new_node); |
| 233 } | 200 } |
| 234 return reinterpret_cast<ProfileNode*>(map_entry->value); | 201 return reinterpret_cast<ProfileNode*>(map_entry->value); |
| 235 } | 202 } |
| 236 | 203 |
| 237 | 204 |
| 238 void ProfileNode::IncrementLineTicks(int src_line) { | |
| 239 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) return; | |
| 240 // Increment a hit counter of a certain source line. | |
| 241 // Add a new source line if not found. | |
| 242 HashMap::Entry* e = | |
| 243 line_ticks_.Lookup(reinterpret_cast<void*>(src_line), src_line, true); | |
| 244 DCHECK(e); | |
| 245 e->value = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(e->value) + 1); | |
| 246 } | |
| 247 | |
| 248 | |
| 249 bool ProfileNode::GetLineTicks(v8::CpuProfileNode::LineTick* entries, | |
| 250 unsigned int length) const { | |
| 251 if (entries == NULL || length == 0) return false; | |
| 252 | |
| 253 unsigned line_count = line_ticks_.occupancy(); | |
| 254 | |
| 255 if (line_count == 0) return true; | |
| 256 if (length < line_count) return false; | |
| 257 | |
| 258 v8::CpuProfileNode::LineTick* entry = entries; | |
| 259 | |
| 260 for (HashMap::Entry* p = line_ticks_.Start(); p != NULL; | |
| 261 p = line_ticks_.Next(p), entry++) { | |
| 262 entry->line = | |
| 263 static_cast<unsigned int>(reinterpret_cast<uintptr_t>(p->key)); | |
| 264 entry->hit_count = | |
| 265 static_cast<unsigned int>(reinterpret_cast<uintptr_t>(p->value)); | |
| 266 } | |
| 267 | |
| 268 return true; | |
| 269 } | |
| 270 | |
| 271 | |
| 272 void ProfileNode::Print(int indent) { | 205 void ProfileNode::Print(int indent) { |
| 273 base::OS::Print("%5u %*s %s%s %d #%d %s", self_ticks_, indent, "", | 206 base::OS::Print("%5u %*s %s%s %d #%d %s", self_ticks_, indent, "", |
| 274 entry_->name_prefix(), entry_->name(), entry_->script_id(), | 207 entry_->name_prefix(), entry_->name(), entry_->script_id(), |
| 275 id(), entry_->bailout_reason()); | 208 id(), entry_->bailout_reason()); |
| 276 if (entry_->resource_name()[0] != '\0') | 209 if (entry_->resource_name()[0] != '\0') |
| 277 base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); | 210 base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); |
| 278 base::OS::Print("\n"); | 211 base::OS::Print("\n"); |
| 279 for (HashMap::Entry* p = children_.Start(); | 212 for (HashMap::Entry* p = children_.Start(); |
| 280 p != NULL; | 213 p != NULL; |
| 281 p = children_.Next(p)) { | 214 p = children_.Next(p)) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 302 root_(new ProfileNode(this, &root_entry_)) { | 235 root_(new ProfileNode(this, &root_entry_)) { |
| 303 } | 236 } |
| 304 | 237 |
| 305 | 238 |
| 306 ProfileTree::~ProfileTree() { | 239 ProfileTree::~ProfileTree() { |
| 307 DeleteNodesCallback cb; | 240 DeleteNodesCallback cb; |
| 308 TraverseDepthFirst(&cb); | 241 TraverseDepthFirst(&cb); |
| 309 } | 242 } |
| 310 | 243 |
| 311 | 244 |
| 312 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path, | 245 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) { |
| 313 int src_line) { | |
| 314 ProfileNode* node = root_; | 246 ProfileNode* node = root_; |
| 315 for (CodeEntry** entry = path.start() + path.length() - 1; | 247 for (CodeEntry** entry = path.start() + path.length() - 1; |
| 316 entry != path.start() - 1; | 248 entry != path.start() - 1; |
| 317 --entry) { | 249 --entry) { |
| 318 if (*entry != NULL) { | 250 if (*entry != NULL) { |
| 319 node = node->FindOrAddChild(*entry); | 251 node = node->FindOrAddChild(*entry); |
| 320 } | 252 } |
| 321 } | 253 } |
| 322 node->IncrementSelfTicks(); | 254 node->IncrementSelfTicks(); |
| 323 if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) { | |
| 324 node->IncrementLineTicks(src_line); | |
| 325 } | |
| 326 return node; | 255 return node; |
| 327 } | 256 } |
| 328 | 257 |
| 329 | 258 |
| 330 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path, | 259 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) { |
| 331 int src_line) { | |
| 332 ProfileNode* node = root_; | 260 ProfileNode* node = root_; |
| 333 for (CodeEntry** entry = path.start(); | 261 for (CodeEntry** entry = path.start(); |
| 334 entry != path.start() + path.length(); | 262 entry != path.start() + path.length(); |
| 335 ++entry) { | 263 ++entry) { |
| 336 if (*entry != NULL) { | 264 if (*entry != NULL) { |
| 337 node = node->FindOrAddChild(*entry); | 265 node = node->FindOrAddChild(*entry); |
| 338 } | 266 } |
| 339 } | 267 } |
| 340 node->IncrementSelfTicks(); | 268 node->IncrementSelfTicks(); |
| 341 if (src_line != v8::CpuProfileNode::kNoLineNumberInfo) { | |
| 342 node->IncrementLineTicks(src_line); | |
| 343 } | |
| 344 } | 269 } |
| 345 | 270 |
| 346 | 271 |
| 347 struct NodesPair { | 272 struct NodesPair { |
| 348 NodesPair(ProfileNode* src, ProfileNode* dst) | 273 NodesPair(ProfileNode* src, ProfileNode* dst) |
| 349 : src(src), dst(dst) { } | 274 : src(src), dst(dst) { } |
| 350 ProfileNode* src; | 275 ProfileNode* src; |
| 351 ProfileNode* dst; | 276 ProfileNode* dst; |
| 352 }; | 277 }; |
| 353 | 278 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 320 |
| 396 | 321 |
| 397 CpuProfile::CpuProfile(const char* title, bool record_samples) | 322 CpuProfile::CpuProfile(const char* title, bool record_samples) |
| 398 : title_(title), | 323 : title_(title), |
| 399 record_samples_(record_samples), | 324 record_samples_(record_samples), |
| 400 start_time_(base::TimeTicks::HighResolutionNow()) { | 325 start_time_(base::TimeTicks::HighResolutionNow()) { |
| 401 } | 326 } |
| 402 | 327 |
| 403 | 328 |
| 404 void CpuProfile::AddPath(base::TimeTicks timestamp, | 329 void CpuProfile::AddPath(base::TimeTicks timestamp, |
| 405 const Vector<CodeEntry*>& path, int src_line) { | 330 const Vector<CodeEntry*>& path) { |
| 406 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path, src_line); | 331 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); |
| 407 if (record_samples_) { | 332 if (record_samples_) { |
| 408 timestamps_.Add(timestamp); | 333 timestamps_.Add(timestamp); |
| 409 samples_.Add(top_frame_node); | 334 samples_.Add(top_frame_node); |
| 410 } | 335 } |
| 411 } | 336 } |
| 412 | 337 |
| 413 | 338 |
| 414 void CpuProfile::CalculateTotalTicksAndSamplingRate() { | 339 void CpuProfile::CalculateTotalTicksAndSamplingRate() { |
| 415 end_time_ = base::TimeTicks::HighResolutionNow(); | 340 end_time_ = base::TimeTicks::HighResolutionNow(); |
| 416 } | 341 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 if (profile == finished_profiles_[i]) { | 510 if (profile == finished_profiles_[i]) { |
| 586 finished_profiles_.Remove(i); | 511 finished_profiles_.Remove(i); |
| 587 return; | 512 return; |
| 588 } | 513 } |
| 589 } | 514 } |
| 590 UNREACHABLE(); | 515 UNREACHABLE(); |
| 591 } | 516 } |
| 592 | 517 |
| 593 | 518 |
| 594 void CpuProfilesCollection::AddPathToCurrentProfiles( | 519 void CpuProfilesCollection::AddPathToCurrentProfiles( |
| 595 base::TimeTicks timestamp, const Vector<CodeEntry*>& path, int src_line) { | 520 base::TimeTicks timestamp, const Vector<CodeEntry*>& path) { |
| 596 // As starting / stopping profiles is rare relatively to this | 521 // As starting / stopping profiles is rare relatively to this |
| 597 // method, we don't bother minimizing the duration of lock holding, | 522 // method, we don't bother minimizing the duration of lock holding, |
| 598 // e.g. copying contents of the list to a local vector. | 523 // e.g. copying contents of the list to a local vector. |
| 599 current_profiles_semaphore_.Wait(); | 524 current_profiles_semaphore_.Wait(); |
| 600 for (int i = 0; i < current_profiles_.length(); ++i) { | 525 for (int i = 0; i < current_profiles_.length(); ++i) { |
| 601 current_profiles_[i]->AddPath(timestamp, path, src_line); | 526 current_profiles_[i]->AddPath(timestamp, path); |
| 602 } | 527 } |
| 603 current_profiles_semaphore_.Signal(); | 528 current_profiles_semaphore_.Signal(); |
| 604 } | 529 } |
| 605 | 530 |
| 606 | 531 |
| 607 CodeEntry* CpuProfilesCollection::NewCodeEntry( | 532 CodeEntry* CpuProfilesCollection::NewCodeEntry( |
| 608 Logger::LogEventsAndTags tag, const char* name, const char* name_prefix, | 533 Logger::LogEventsAndTags tag, |
| 609 const char* resource_name, int line_number, int column_number, | 534 const char* name, |
| 610 JITLineInfoTable* line_info, Address instruction_start) { | 535 const char* name_prefix, |
| 611 CodeEntry* code_entry = | 536 const char* resource_name, |
| 612 new CodeEntry(tag, name, name_prefix, resource_name, line_number, | 537 int line_number, |
| 613 column_number, line_info, instruction_start); | 538 int column_number) { |
| 539 CodeEntry* code_entry = new CodeEntry(tag, |
| 540 name, |
| 541 name_prefix, |
| 542 resource_name, |
| 543 line_number, |
| 544 column_number); |
| 614 code_entries_.Add(code_entry); | 545 code_entries_.Add(code_entry); |
| 615 return code_entry; | 546 return code_entry; |
| 616 } | 547 } |
| 617 | 548 |
| 618 | 549 |
| 619 const char* const ProfileGenerator::kProgramEntryName = | 550 const char* const ProfileGenerator::kProgramEntryName = |
| 620 "(program)"; | 551 "(program)"; |
| 621 const char* const ProfileGenerator::kIdleEntryName = | 552 const char* const ProfileGenerator::kIdleEntryName = |
| 622 "(idle)"; | 553 "(idle)"; |
| 623 const char* const ProfileGenerator::kGarbageCollectorEntryName = | 554 const char* const ProfileGenerator::kGarbageCollectorEntryName = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 641 } | 572 } |
| 642 | 573 |
| 643 | 574 |
| 644 void ProfileGenerator::RecordTickSample(const TickSample& sample) { | 575 void ProfileGenerator::RecordTickSample(const TickSample& sample) { |
| 645 // Allocate space for stack frames + pc + function + vm-state. | 576 // Allocate space for stack frames + pc + function + vm-state. |
| 646 ScopedVector<CodeEntry*> entries(sample.frames_count + 3); | 577 ScopedVector<CodeEntry*> entries(sample.frames_count + 3); |
| 647 // As actual number of decoded code entries may vary, initialize | 578 // As actual number of decoded code entries may vary, initialize |
| 648 // entries vector with NULL values. | 579 // entries vector with NULL values. |
| 649 CodeEntry** entry = entries.start(); | 580 CodeEntry** entry = entries.start(); |
| 650 memset(entry, 0, entries.length() * sizeof(*entry)); | 581 memset(entry, 0, entries.length() * sizeof(*entry)); |
| 651 | |
| 652 // The ProfileNode knows nothing about all versions of generated code for | |
| 653 // the same JS function. The line number information associated with | |
| 654 // the latest version of generated code is used to find a source line number | |
| 655 // for a JS function. Then, the detected source line is passed to | |
| 656 // ProfileNode to increase the tick count for this source line. | |
| 657 int src_line = v8::CpuProfileNode::kNoLineNumberInfo; | |
| 658 bool src_line_not_found = true; | |
| 659 | |
| 660 if (sample.pc != NULL) { | 582 if (sample.pc != NULL) { |
| 661 if (sample.has_external_callback && sample.state == EXTERNAL && | 583 if (sample.has_external_callback && sample.state == EXTERNAL && |
| 662 sample.top_frame_type == StackFrame::EXIT) { | 584 sample.top_frame_type == StackFrame::EXIT) { |
| 663 // Don't use PC when in external callback code, as it can point | 585 // Don't use PC when in external callback code, as it can point |
| 664 // inside callback's code, and we will erroneously report | 586 // inside callback's code, and we will erroneously report |
| 665 // that a callback calls itself. | 587 // that a callback calls itself. |
| 666 *entry++ = code_map_.FindEntry(sample.external_callback); | 588 *entry++ = code_map_.FindEntry(sample.external_callback); |
| 667 } else { | 589 } else { |
| 668 Address start; | 590 Address start; |
| 669 CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start); | 591 CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start); |
| 670 // If pc is in the function code before it set up stack frame or after the | 592 // If pc is in the function code before it set up stack frame or after the |
| 671 // frame was destroyed SafeStackFrameIterator incorrectly thinks that | 593 // frame was destroyed SafeStackFrameIterator incorrectly thinks that |
| 672 // ebp contains return address of the current function and skips caller's | 594 // ebp contains return address of the current function and skips caller's |
| 673 // frame. Check for this case and just skip such samples. | 595 // frame. Check for this case and just skip such samples. |
| 674 if (pc_entry) { | 596 if (pc_entry) { |
| 675 List<OffsetRange>* ranges = pc_entry->no_frame_ranges(); | 597 List<OffsetRange>* ranges = pc_entry->no_frame_ranges(); |
| 676 int pc_offset = | |
| 677 static_cast<int>(sample.pc - pc_entry->instruction_start()); | |
| 678 if (ranges) { | 598 if (ranges) { |
| 599 Code* code = Code::cast(HeapObject::FromAddress(start)); |
| 600 int pc_offset = static_cast<int>( |
| 601 sample.pc - code->instruction_start()); |
| 679 for (int i = 0; i < ranges->length(); i++) { | 602 for (int i = 0; i < ranges->length(); i++) { |
| 680 OffsetRange& range = ranges->at(i); | 603 OffsetRange& range = ranges->at(i); |
| 681 if (range.from <= pc_offset && pc_offset < range.to) { | 604 if (range.from <= pc_offset && pc_offset < range.to) { |
| 682 return; | 605 return; |
| 683 } | 606 } |
| 684 } | 607 } |
| 685 } | 608 } |
| 686 src_line = pc_entry->GetSourceLine(pc_offset); | |
| 687 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) { | |
| 688 src_line = pc_entry->line_number(); | |
| 689 } | |
| 690 src_line_not_found = false; | |
| 691 *entry++ = pc_entry; | 609 *entry++ = pc_entry; |
| 692 | 610 |
| 693 if (pc_entry->builtin_id() == Builtins::kFunctionCall || | 611 if (pc_entry->builtin_id() == Builtins::kFunctionCall || |
| 694 pc_entry->builtin_id() == Builtins::kFunctionApply) { | 612 pc_entry->builtin_id() == Builtins::kFunctionApply) { |
| 695 // When current function is FunctionCall or FunctionApply builtin the | 613 // When current function is FunctionCall or FunctionApply builtin the |
| 696 // top frame is either frame of the calling JS function or internal | 614 // top frame is either frame of the calling JS function or internal |
| 697 // frame. In the latter case we know the caller for sure but in the | 615 // frame. In the latter case we know the caller for sure but in the |
| 698 // former case we don't so we simply replace the frame with | 616 // former case we don't so we simply replace the frame with |
| 699 // 'unresolved' entry. | 617 // 'unresolved' entry. |
| 700 if (sample.top_frame_type == StackFrame::JAVA_SCRIPT) { | 618 if (sample.top_frame_type == StackFrame::JAVA_SCRIPT) { |
| 701 *entry++ = unresolved_entry_; | 619 *entry++ = unresolved_entry_; |
| 702 } | 620 } |
| 703 } | 621 } |
| 704 } | 622 } |
| 705 } | 623 } |
| 706 | 624 |
| 707 for (const Address* stack_pos = sample.stack, | 625 for (const Address* stack_pos = sample.stack, |
| 708 *stack_end = stack_pos + sample.frames_count; | 626 *stack_end = stack_pos + sample.frames_count; |
| 709 stack_pos != stack_end; | 627 stack_pos != stack_end; |
| 710 ++stack_pos) { | 628 ++stack_pos) { |
| 711 Address start = NULL; | 629 *entry++ = code_map_.FindEntry(*stack_pos); |
| 712 *entry = code_map_.FindEntry(*stack_pos, &start); | |
| 713 | |
| 714 // Skip unresolved frames (e.g. internal frame) and get source line of | |
| 715 // the first JS caller. | |
| 716 if (src_line_not_found && *entry) { | |
| 717 int pc_offset = | |
| 718 static_cast<int>(*stack_pos - (*entry)->instruction_start()); | |
| 719 src_line = (*entry)->GetSourceLine(pc_offset); | |
| 720 if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) { | |
| 721 src_line = (*entry)->line_number(); | |
| 722 } | |
| 723 src_line_not_found = false; | |
| 724 } | |
| 725 | |
| 726 entry++; | |
| 727 } | 630 } |
| 728 } | 631 } |
| 729 | 632 |
| 730 if (FLAG_prof_browser_mode) { | 633 if (FLAG_prof_browser_mode) { |
| 731 bool no_symbolized_entries = true; | 634 bool no_symbolized_entries = true; |
| 732 for (CodeEntry** e = entries.start(); e != entry; ++e) { | 635 for (CodeEntry** e = entries.start(); e != entry; ++e) { |
| 733 if (*e != NULL) { | 636 if (*e != NULL) { |
| 734 no_symbolized_entries = false; | 637 no_symbolized_entries = false; |
| 735 break; | 638 break; |
| 736 } | 639 } |
| 737 } | 640 } |
| 738 // If no frames were symbolized, put the VM state entry in. | 641 // If no frames were symbolized, put the VM state entry in. |
| 739 if (no_symbolized_entries) { | 642 if (no_symbolized_entries) { |
| 740 *entry++ = EntryForVMState(sample.state); | 643 *entry++ = EntryForVMState(sample.state); |
| 741 } | 644 } |
| 742 } | 645 } |
| 743 | 646 |
| 744 profiles_->AddPathToCurrentProfiles(sample.timestamp, entries, src_line); | 647 profiles_->AddPathToCurrentProfiles(sample.timestamp, entries); |
| 745 } | 648 } |
| 746 | 649 |
| 747 | 650 |
| 748 CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { | 651 CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { |
| 749 switch (tag) { | 652 switch (tag) { |
| 750 case GC: | 653 case GC: |
| 751 return gc_entry_; | 654 return gc_entry_; |
| 752 case JS: | 655 case JS: |
| 753 case COMPILER: | 656 case COMPILER: |
| 754 // DOM events handlers are reported as OTHER / EXTERNAL entries. | 657 // DOM events handlers are reported as OTHER / EXTERNAL entries. |
| 755 // To avoid confusing people, let's put all these entries into | 658 // To avoid confusing people, let's put all these entries into |
| 756 // one bucket. | 659 // one bucket. |
| 757 case OTHER: | 660 case OTHER: |
| 758 case EXTERNAL: | 661 case EXTERNAL: |
| 759 return program_entry_; | 662 return program_entry_; |
| 760 case IDLE: | 663 case IDLE: |
| 761 return idle_entry_; | 664 return idle_entry_; |
| 762 default: return NULL; | 665 default: return NULL; |
| 763 } | 666 } |
| 764 } | 667 } |
| 765 | 668 |
| 766 } } // namespace v8::internal | 669 } } // namespace v8::internal |
| OLD | NEW |