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

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

Issue 2586923002: [profiler] fix memory leak for code entries for runtime callstats. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « src/profiler/profile-generator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 642
643 ProfileGenerator::ProfileGenerator(Isolate* isolate, 643 ProfileGenerator::ProfileGenerator(Isolate* isolate,
644 CpuProfilesCollection* profiles) 644 CpuProfilesCollection* profiles)
645 : isolate_(isolate), profiles_(profiles) { 645 : isolate_(isolate), profiles_(profiles) {
646 RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats(); 646 RuntimeCallStats* rcs = isolate_->counters()->runtime_call_stats();
647 for (int i = 0; i < RuntimeCallStats::counters_count; ++i) { 647 for (int i = 0; i < RuntimeCallStats::counters_count; ++i) {
648 RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i])); 648 RuntimeCallCounter* counter = &(rcs->*(RuntimeCallStats::counters[i]));
649 DCHECK(counter->name()); 649 DCHECK(counter->name());
650 auto entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(), 650 auto entry = new CodeEntry(CodeEventListener::FUNCTION_TAG, counter->name(),
651 CodeEntry::kEmptyNamePrefix, "native V8Runtime"); 651 CodeEntry::kEmptyNamePrefix, "native V8Runtime");
652 code_entries_.push_back(entry);
652 code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1); 653 code_map_.AddCode(reinterpret_cast<Address>(counter), entry, 1);
653 } 654 }
654 } 655 }
655 656
657 ProfileGenerator::~ProfileGenerator() {
658 for (auto code_entry : code_entries_) delete code_entry;
659 }
660
656 void ProfileGenerator::RecordTickSample(const TickSample& sample) { 661 void ProfileGenerator::RecordTickSample(const TickSample& sample) {
657 std::vector<CodeEntry*> entries; 662 std::vector<CodeEntry*> entries;
658 // Conservatively reserve space for stack frames + pc + function + vm-state. 663 // Conservatively reserve space for stack frames + pc + function + vm-state.
659 // There could in fact be more of them because of inlined entries. 664 // There could in fact be more of them because of inlined entries.
660 entries.reserve(sample.frames_count + 3); 665 entries.reserve(sample.frames_count + 3);
661 666
662 // The ProfileNode knows nothing about all versions of generated code for 667 // The ProfileNode knows nothing about all versions of generated code for
663 // the same JS function. The line number information associated with 668 // the same JS function. The line number information associated with
664 // the latest version of generated code is used to find a source line number 669 // the latest version of generated code is used to find a source line number
665 // for a JS function. Then, the detected source line is passed to 670 // for a JS function. Then, the detected source line is passed to
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 case EXTERNAL: 777 case EXTERNAL:
773 return CodeEntry::program_entry(); 778 return CodeEntry::program_entry();
774 case IDLE: 779 case IDLE:
775 return CodeEntry::idle_entry(); 780 return CodeEntry::idle_entry();
776 default: return NULL; 781 default: return NULL;
777 } 782 }
778 } 783 }
779 784
780 } // namespace internal 785 } // namespace internal
781 } // namespace v8 786 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/profile-generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698