| Index: src/profiler/profile-generator.cc
|
| diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc
|
| index b6293a8ae8c4889e8119464964a36bb25fff921d..d40cf2ad408524a1409cc5c2db701704503a2c4a 100644
|
| --- a/src/profiler/profile-generator.cc
|
| +++ b/src/profiler/profile-generator.cc
|
| @@ -48,6 +48,41 @@ const char* const CodeEntry::kEmptyResourceName = "";
|
| 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_;
|
| @@ -433,15 +468,10 @@ void CodeMap::Print() {
|
| }
|
|
|
| CpuProfilesCollection::CpuProfilesCollection(Isolate* isolate)
|
| - : function_and_resource_names_(isolate->heap()),
|
| + : 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;
|
| }
|
| @@ -450,7 +480,6 @@ static void DeleteCpuProfile(CpuProfile** profile_ptr) {
|
| CpuProfilesCollection::~CpuProfilesCollection() {
|
| finished_profiles_.Iterate(DeleteCpuProfile);
|
| current_profiles_.Iterate(DeleteCpuProfile);
|
| - code_entries_.Iterate(DeleteCodeEntry);
|
| }
|
|
|
|
|
| @@ -527,37 +556,8 @@ void CpuProfilesCollection::AddPathToCurrentProfiles(
|
| 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),
|
| - 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)) {}
|
| + : profiles_(profiles) {}
|
|
|
| void ProfileGenerator::RecordTickSample(const TickSample& sample) {
|
| std::vector<CodeEntry*> entries;
|
| @@ -610,7 +610,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
|
| // former case we don't so we simply replace the frame with
|
| // 'unresolved' entry.
|
| if (!sample.has_external_callback) {
|
| - entries.push_back(unresolved_entry_);
|
| + entries.push_back(CodeEntry::unresolved_entry());
|
| }
|
| }
|
| }
|
| @@ -667,7 +667,7 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
|
| CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
|
| switch (tag) {
|
| case GC:
|
| - return gc_entry_;
|
| + return CodeEntry::gc_entry();
|
| case JS:
|
| case COMPILER:
|
| // DOM events handlers are reported as OTHER / EXTERNAL entries.
|
| @@ -675,9 +675,9 @@ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
|
| // one bucket.
|
| case OTHER:
|
| case EXTERNAL:
|
| - return program_entry_;
|
| + return CodeEntry::program_entry();
|
| case IDLE:
|
| - return idle_entry_;
|
| + return CodeEntry::idle_entry();
|
| default: return NULL;
|
| }
|
| }
|
|
|