diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc index 47c2a94232..51d29423c4 100644 --- a/src/cpu-profiler.cc +++ b/src/cpu-profiler.cc @@ -44,9 +44,11 @@ static const int kTickSamplesBufferChunksCount = 16; static const int kProfilerStackSize = 64 * KB; -ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) +ProfilerEventsProcessor::ProfilerEventsProcessor( + ProfileGenerator* generator, CpuProfilesCollection* profiles) : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), generator_(generator), + profiles_(profiles), running_(true), ticks_buffer_(sizeof(TickSampleEventRecord), kTickSamplesBufferChunkSize, @@ -65,7 +67,7 @@ void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, rec->type = CodeEventRecord::CODE_CREATION; rec->order = ++enqueue_order_; rec->start = start; - rec->entry = generator_->NewCodeEntry(tag, prefix, name); + rec->entry = profiles_->NewCodeEntry(tag, prefix, name); rec->size = 1; rec->shared = NULL; events_buffer_.Enqueue(evt_rec); @@ -85,7 +87,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, rec->type = CodeEventRecord::CODE_CREATION; rec->order = ++enqueue_order_; rec->start = start; - rec->entry = generator_->NewCodeEntry(tag, name, resource_name, line_number); + rec->entry = profiles_->NewCodeEntry(tag, name, resource_name, line_number); rec->size = size; rec->shared = shared; events_buffer_.Enqueue(evt_rec); @@ -102,7 +104,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, rec->type = CodeEventRecord::CODE_CREATION; rec->order = ++enqueue_order_; rec->start = start; - rec->entry = generator_->NewCodeEntry(tag, name); + rec->entry = profiles_->NewCodeEntry(tag, name); rec->size = size; rec->shared = NULL; events_buffer_.Enqueue(evt_rec); @@ -119,7 +121,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, rec->type = CodeEventRecord::CODE_CREATION; rec->order = ++enqueue_order_; rec->start = start; - rec->entry = generator_->NewCodeEntry(tag, args_count); + rec->entry = profiles_->NewCodeEntry(tag, args_count); rec->size = size; rec->shared = NULL; events_buffer_.Enqueue(evt_rec); @@ -162,7 +164,7 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent( rec->type = CodeEventRecord::CODE_CREATION; rec->order = ++enqueue_order_; rec->start = start; - rec->entry = generator_->NewCodeEntry(tag, prefix, name); + rec->entry = profiles_->NewCodeEntry(tag, prefix, name); rec->size = size; events_buffer_.Enqueue(evt_rec); } @@ -443,7 +445,7 @@ void CpuProfiler::StartProcessorIfNotStarted() { saved_logging_nesting_ = isolate_->logger()->logging_nesting_; isolate_->logger()->logging_nesting_ = 0; generator_ = new ProfileGenerator(profiles_); - processor_ = new ProfilerEventsProcessor(generator_); + processor_ = new ProfilerEventsProcessor(generator_, profiles_); is_profiling_ = true; processor_->StartSynchronously(); // Enumerate stuff we already have in the heap. @@ -458,7 +460,7 @@ void CpuProfiler::StartProcessorIfNotStarted() { isolate_->logger()->LogAccessorCallbacks(); } // Enable stack sampling. - Sampler* sampler = reinterpret_cast(isolate_->logger()->ticker_); + Sampler* sampler = isolate_->logger()->sampler(); sampler->IncreaseProfilingDepth(); if (!sampler->IsActive()) { sampler->Start(); diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h index 6e2b0e09cd..da7ea6de24 100644 --- a/src/cpu-profiler.h +++ b/src/cpu-profiler.h @@ -125,7 +125,8 @@ class TickSampleEventRecord { // methods called by event producers: VM and stack sampler threads. class ProfilerEventsProcessor : public Thread { public: - explicit ProfilerEventsProcessor(ProfileGenerator* generator); + ProfilerEventsProcessor(ProfileGenerator* generator, + CpuProfilesCollection* profiles); virtual ~ProfilerEventsProcessor() {} // Thread control. @@ -178,6 +179,7 @@ class ProfilerEventsProcessor : public Thread { INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); ProfileGenerator* generator_; + CpuProfilesCollection* profiles_; bool running_; UnboundQueue events_buffer_; SamplingCircularQueue ticks_buffer_; diff --git a/src/profile-generator.h b/src/profile-generator.h index 0ed5a0c15b..761291e121 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -400,33 +400,6 @@ class ProfileGenerator { public: explicit ProfileGenerator(CpuProfilesCollection* profiles); - INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, - Name* name, - String* resource_name, - int line_number)) { - return profiles_->NewCodeEntry(tag, name, resource_name, line_number); - } - - INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, - const char* name)) { - return profiles_->NewCodeEntry(tag, name); - } - - INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, - const char* name_prefix, - Name* name)) { - return profiles_->NewCodeEntry(tag, name_prefix, name); - } - - INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, - int args_count)) { - return profiles_->NewCodeEntry(tag, args_count); - } - - INLINE(CodeEntry* NewCodeEntry(int security_token_id)) { - return profiles_->NewCodeEntry(security_token_id); - } - void RecordTickSample(const TickSample& sample); INLINE(CodeMap* code_map()) { return &code_map_; } diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 40b5b79125..f5f5d65d60 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -48,7 +48,7 @@ using i::Vector; TEST(StartStop) { CpuProfilesCollection profiles; ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(&generator, &profiles); processor.Start(); processor.Stop(); processor.Join(); @@ -104,7 +104,7 @@ TEST(CodeEvents) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, false); ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(&generator, &profiles); processor.Start(); // Enqueue code creation events. @@ -165,7 +165,7 @@ TEST(TickEvents) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, false); ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(&generator, &profiles); processor.Start(); processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, @@ -229,7 +229,7 @@ TEST(Issue1398) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, false); ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(&generator, &profiles); processor.Start(); processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index 56b1788a85..85adeca5f4 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -611,9 +611,9 @@ TEST(RecordTickSample) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, false); ProfileGenerator generator(&profiles); - CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); - CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); - CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); + CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); + CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); + CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); @@ -727,9 +727,9 @@ TEST(SampleIds) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, true); ProfileGenerator generator(&profiles); - CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); - CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); - CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); + CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); + CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); + CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); @@ -776,7 +776,7 @@ TEST(NoSamples) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1, false); ProfileGenerator generator(&profiles); - CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); + CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); // We are building the following calls tree: