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

Unified Diff: src/profiler/profile-generator.cc

Issue 2079273003: Revert of Refactor CpuProfiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/profiler-listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/profile-generator.cc
diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc
index d40cf2ad408524a1409cc5c2db701704503a2c4a..b6293a8ae8c4889e8119464964a36bb25fff921d 100644
--- a/src/profiler/profile-generator.cc
+++ b/src/profiler/profile-generator.cc
@@ -48,41 +48,6 @@
const char* const CodeEntry::kEmptyBailoutReason = "";
const char* const CodeEntry::kNoDeoptReason = "";
-const char* const CodeEntry::kProgramEntryName = "(program)";
-const char* const CodeEntry::kIdleEntryName = "(idle)";
-const char* const CodeEntry::kGarbageCollectorEntryName = "(garbage collector)";
-const char* const CodeEntry::kUnresolvedFunctionName = "(unresolved function)";
-
-base::LazyDynamicInstance<CodeEntry, CodeEntry::ProgramEntryCreateTrait>::type
- CodeEntry::kProgramEntry = LAZY_DYNAMIC_INSTANCE_INITIALIZER;
-
-base::LazyDynamicInstance<CodeEntry, CodeEntry::IdleEntryCreateTrait>::type
- CodeEntry::kIdleEntry = LAZY_DYNAMIC_INSTANCE_INITIALIZER;
-
-base::LazyDynamicInstance<CodeEntry, CodeEntry::GCEntryCreateTrait>::type
- CodeEntry::kGCEntry = LAZY_DYNAMIC_INSTANCE_INITIALIZER;
-
-base::LazyDynamicInstance<CodeEntry,
- CodeEntry::UnresolvedEntryCreateTrait>::type
- CodeEntry::kUnresolvedEntry = LAZY_DYNAMIC_INSTANCE_INITIALIZER;
-
-CodeEntry* CodeEntry::ProgramEntryCreateTrait::Create() {
- return new CodeEntry(Logger::FUNCTION_TAG, CodeEntry::kProgramEntryName);
-}
-
-CodeEntry* CodeEntry::IdleEntryCreateTrait::Create() {
- return new CodeEntry(Logger::FUNCTION_TAG, CodeEntry::kIdleEntryName);
-}
-
-CodeEntry* CodeEntry::GCEntryCreateTrait::Create() {
- return new CodeEntry(Logger::BUILTIN_TAG,
- CodeEntry::kGarbageCollectorEntryName);
-}
-
-CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() {
- return new CodeEntry(Logger::FUNCTION_TAG,
- CodeEntry::kUnresolvedFunctionName);
-}
CodeEntry::~CodeEntry() {
delete line_info_;
@@ -468,9 +433,14 @@
}
CpuProfilesCollection::CpuProfilesCollection(Isolate* isolate)
- : resource_names_(isolate->heap()),
+ : function_and_resource_names_(isolate->heap()),
profiler_(nullptr),
current_profiles_semaphore_(1) {}
+
+static void DeleteCodeEntry(CodeEntry** entry_ptr) {
+ delete *entry_ptr;
+}
+
static void DeleteCpuProfile(CpuProfile** profile_ptr) {
delete *profile_ptr;
@@ -480,6 +450,7 @@
CpuProfilesCollection::~CpuProfilesCollection() {
finished_profiles_.Iterate(DeleteCpuProfile);
current_profiles_.Iterate(DeleteCpuProfile);
+ code_entries_.Iterate(DeleteCodeEntry);
}
@@ -556,8 +527,37 @@
current_profiles_semaphore_.Signal();
}
+CodeEntry* CpuProfilesCollection::NewCodeEntry(
+ CodeEventListener::LogEventsAndTags tag, const char* name,
+ const char* name_prefix, const char* resource_name, int line_number,
+ int column_number, JITLineInfoTable* line_info, Address instruction_start) {
+ CodeEntry* code_entry =
+ new CodeEntry(tag, name, name_prefix, resource_name, line_number,
+ column_number, line_info, instruction_start);
+ code_entries_.Add(code_entry);
+ return code_entry;
+}
+
+
+const char* const ProfileGenerator::kProgramEntryName =
+ "(program)";
+const char* const ProfileGenerator::kIdleEntryName =
+ "(idle)";
+const char* const ProfileGenerator::kGarbageCollectorEntryName =
+ "(garbage collector)";
+const char* const ProfileGenerator::kUnresolvedFunctionName =
+ "(unresolved function)";
+
ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
- : profiles_(profiles) {}
+ : profiles_(profiles),
+ program_entry_(profiles->NewCodeEntry(CodeEventListener::FUNCTION_TAG,
+ kProgramEntryName)),
+ idle_entry_(profiles->NewCodeEntry(CodeEventListener::FUNCTION_TAG,
+ kIdleEntryName)),
+ gc_entry_(profiles->NewCodeEntry(CodeEventListener::BUILTIN_TAG,
+ kGarbageCollectorEntryName)),
+ unresolved_entry_(profiles->NewCodeEntry(CodeEventListener::FUNCTION_TAG,
+ kUnresolvedFunctionName)) {}
void ProfileGenerator::RecordTickSample(const TickSample& sample) {
std::vector<CodeEntry*> entries;
@@ -610,7 +610,7 @@
// former case we don't so we simply replace the frame with
// 'unresolved' entry.
if (!sample.has_external_callback) {
- entries.push_back(CodeEntry::unresolved_entry());
+ entries.push_back(unresolved_entry_);
}
}
}
@@ -667,7 +667,7 @@
CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
switch (tag) {
case GC:
- return CodeEntry::gc_entry();
+ return gc_entry_;
case JS:
case COMPILER:
// DOM events handlers are reported as OTHER / EXTERNAL entries.
@@ -675,9 +675,9 @@
// one bucket.
case OTHER:
case EXTERNAL:
- return CodeEntry::program_entry();
+ return program_entry_;
case IDLE:
- return CodeEntry::idle_entry();
+ return idle_entry_;
default: return NULL;
}
}
« no previous file with comments | « src/profiler/profile-generator.h ('k') | src/profiler/profiler-listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698