Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Side by Side Diff: src/profiler/profile-generator.cc

Issue 2655963003: [profiler] Fix a memory leak of CodeEvent objects (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/profiler/profile-generator.h" 5 #include "src/profiler/profile-generator.h"
6 6
7 #include "src/base/adapters.h" 7 #include "src/base/adapters.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/global-handles.h" 10 #include "src/global-handles.h"
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 // As starting / stopping profiles is rare relatively to this 628 // As starting / stopping profiles is rare relatively to this
629 // method, we don't bother minimizing the duration of lock holding, 629 // method, we don't bother minimizing the duration of lock holding,
630 // e.g. copying contents of the list to a local vector. 630 // e.g. copying contents of the list to a local vector.
631 current_profiles_semaphore_.Wait(); 631 current_profiles_semaphore_.Wait();
632 for (int i = 0; i < current_profiles_.length(); ++i) { 632 for (int i = 0; i < current_profiles_.length(); ++i) {
633 current_profiles_[i]->AddPath(timestamp, path, src_line, update_stats); 633 current_profiles_[i]->AddPath(timestamp, path, src_line, update_stats);
634 } 634 }
635 current_profiles_semaphore_.Signal(); 635 current_profiles_semaphore_.Signal();
636 } 636 }
637 637
638 ProfileGenerator::ProfileGenerator(Isolate* isolate, 638 ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
639 CpuProfilesCollection* profiles) 639 : profiles_(profiles) {}
640 : isolate_(isolate), profiles_(profiles) {
641 RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats();
642 for (int i = 0; i < RuntimeCallStats::counters_count; ++i) {
643 RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i]));
644 DCHECK(counter->name());
645 auto entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),
646 CodeEntry::kEmptyNamePrefix, "native V8Runtime");
647 code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1);
648 }
649 }
650 640
651 void ProfileGenerator::RecordTickSample(const TickSample& sample) { 641 void ProfileGenerator::RecordTickSample(const TickSample& sample) {
652 std::vector<CodeEntry*> entries; 642 std::vector<CodeEntry*> entries;
653 // Conservatively reserve space for stack frames + pc + function + vm-state. 643 // Conservatively reserve space for stack frames + pc + function + vm-state.
654 // There could in fact be more of them because of inlined entries. 644 // There could in fact be more of them because of inlined entries.
655 entries.reserve(sample.frames_count + 3); 645 entries.reserve(sample.frames_count + 3);
656 646
657 // The ProfileNode knows nothing about all versions of generated code for 647 // The ProfileNode knows nothing about all versions of generated code for
658 // the same JS function. The line number information associated with 648 // the same JS function. The line number information associated with
659 // the latest version of generated code is used to find a source line number 649 // the latest version of generated code is used to find a source line number
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 case EXTERNAL: 757 case EXTERNAL:
768 return CodeEntry::program_entry(); 758 return CodeEntry::program_entry();
769 case IDLE: 759 case IDLE:
770 return CodeEntry::idle_entry(); 760 return CodeEntry::idle_entry();
771 default: return NULL; 761 default: return NULL;
772 } 762 }
773 } 763 }
774 764
775 } // namespace internal 765 } // namespace internal
776 } // namespace v8 766 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698