Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 CodeTree::Locator locator; | 524 CodeTree::Locator locator; |
| 525 if (!tree_.FindGreatestLessThan(addr, &locator)) break; | 525 if (!tree_.FindGreatestLessThan(addr, &locator)) break; |
| 526 Address start2 = locator.key(), end2 = start2 + locator.value().size; | 526 Address start2 = locator.key(), end2 = start2 + locator.value().size; |
| 527 if (start2 < end && start < end2) to_delete.Add(start2); | 527 if (start2 < end && start < end2) to_delete.Add(start2); |
| 528 addr = start2 - 1; | 528 addr = start2 - 1; |
| 529 } | 529 } |
| 530 for (int i = 0; i < to_delete.length(); ++i) tree_.Remove(to_delete[i]); | 530 for (int i = 0; i < to_delete.length(); ++i) tree_.Remove(to_delete[i]); |
| 531 } | 531 } |
| 532 | 532 |
| 533 | 533 |
| 534 CodeEntry* CodeMap::FindEntry(Address addr) { | 534 CodeEntry* CodeMap::FindEntry(Address addr, Address* start) { |
| 535 CodeTree::Locator locator; | 535 CodeTree::Locator locator; |
| 536 if (tree_.FindGreatestLessThan(addr, &locator)) { | 536 if (tree_.FindGreatestLessThan(addr, &locator)) { |
| 537 // locator.key() <= addr. Need to check that addr is within entry. | 537 // locator.key() <= addr. Need to check that addr is within entry. |
| 538 const CodeEntryInfo& entry = locator.value(); | 538 const CodeEntryInfo& entry = locator.value(); |
| 539 if (addr < (locator.key() + entry.size)) | 539 if (addr < (locator.key() + entry.size)) { |
| 540 if (start) | |
| 541 *start = locator.key(); | |
| 540 return entry.entry; | 542 return entry.entry; |
| 543 } | |
| 541 } | 544 } |
| 542 return NULL; | 545 return NULL; |
| 543 } | 546 } |
| 544 | 547 |
| 545 | 548 |
| 546 int CodeMap::GetSharedId(Address addr) { | 549 int CodeMap::GetSharedId(Address addr) { |
| 547 CodeTree::Locator locator; | 550 CodeTree::Locator locator; |
| 548 // For shared function entries, 'size' field is used to store their IDs. | 551 // For shared function entries, 'size' field is used to store their IDs. |
| 549 if (tree_.Find(addr, &locator)) { | 552 if (tree_.Find(addr, &locator)) { |
| 550 const CodeEntryInfo& entry = locator.value(); | 553 const CodeEntryInfo& entry = locator.value(); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 | 894 |
| 892 | 895 |
| 893 void ProfileGenerator::RecordTickSample(const TickSample& sample) { | 896 void ProfileGenerator::RecordTickSample(const TickSample& sample) { |
| 894 // Allocate space for stack frames + pc + function + vm-state. | 897 // Allocate space for stack frames + pc + function + vm-state. |
| 895 ScopedVector<CodeEntry*> entries(sample.frames_count + 3); | 898 ScopedVector<CodeEntry*> entries(sample.frames_count + 3); |
| 896 // As actual number of decoded code entries may vary, initialize | 899 // As actual number of decoded code entries may vary, initialize |
| 897 // entries vector with NULL values. | 900 // entries vector with NULL values. |
| 898 CodeEntry** entry = entries.start(); | 901 CodeEntry** entry = entries.start(); |
| 899 memset(entry, 0, entries.length() * sizeof(*entry)); | 902 memset(entry, 0, entries.length() * sizeof(*entry)); |
| 900 if (sample.pc != NULL) { | 903 if (sample.pc != NULL) { |
| 901 *entry++ = code_map_.FindEntry(sample.pc); | 904 Address start; |
| 905 CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start); | |
| 906 // If pc is in the function code before it setup stack frame or after the | |
| 907 // frame was destroyed SafeStackTraceFrameIterator incorrectly thinks that | |
| 908 // ebp cotains return address of the current function and skips caller's | |
| 909 // frame. Check for this case and just skip such samples. | |
| 910 if (pc_entry && pc_entry->frame_setup_offset() != -1) { | |
| 911 Code* code = Code::cast(HeapObject::FromAddress(start)); | |
| 912 Address instruction_start = code->instruction_start(); | |
| 913 // Frame setup code is at least 4 bytes. | |
| 914 if (sample.pc < instruction_start + pc_entry->frame_setup_offset() + 4) | |
| 915 return; | |
|
loislo
2013/04/26 13:36:56
looks like you are skipping the other stack traces
yurys
2013/04/26 13:43:51
Yes, this is intentional, the comment above descri
| |
| 916 Address frame_destroy = instruction_start + | |
| 917 pc_entry->frame_destroy_offset(); | |
| 918 if (frame_destroy < sample.pc && sample.pc < frame_destroy + 4) | |
| 919 return; | |
|
loislo
2013/04/26 13:36:56
ditto
yurys
2013/04/26 13:43:51
See above.
| |
| 920 } | |
| 921 *entry++ = pc_entry; | |
|
loislo
2013/04/26 13:36:56
sounds like you are adding zero entry if the mappi
yurys
2013/04/26 13:43:51
This part didn't change, it is normal case - pc co
| |
| 902 | 922 |
| 903 if (sample.has_external_callback) { | 923 if (sample.has_external_callback) { |
| 904 // Don't use PC when in external callback code, as it can point | 924 // Don't use PC when in external callback code, as it can point |
| 905 // inside callback's code, and we will erroneously report | 925 // inside callback's code, and we will erroneously report |
| 906 // that a callback calls itself. | 926 // that a callback calls itself. |
| 907 *(entries.start()) = NULL; | 927 *(entries.start()) = NULL; |
| 908 *entry++ = code_map_.FindEntry(sample.external_callback); | 928 *entry++ = code_map_.FindEntry(sample.external_callback); |
| 909 } | 929 } |
| 910 | 930 |
| 911 for (const Address* stack_pos = sample.stack, | 931 for (const Address* stack_pos = sample.stack, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 928 if (no_symbolized_entries) { | 948 if (no_symbolized_entries) { |
| 929 *entry++ = EntryForVMState(sample.state); | 949 *entry++ = EntryForVMState(sample.state); |
| 930 } | 950 } |
| 931 } | 951 } |
| 932 | 952 |
| 933 profiles_->AddPathToCurrentProfiles(entries); | 953 profiles_->AddPathToCurrentProfiles(entries); |
| 934 } | 954 } |
| 935 | 955 |
| 936 | 956 |
| 937 } } // namespace v8::internal | 957 } } // namespace v8::internal |
| OLD | NEW |