Commit f76c2ae2 authored by yurys@chromium.org's avatar yurys@chromium.org

Avoid unnecessary indirection when creating CodeEntries

BUG=None

Review URL: https://codereview.chromium.org/14471035

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14446 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 49ce7642
...@@ -44,9 +44,11 @@ static const int kTickSamplesBufferChunksCount = 16; ...@@ -44,9 +44,11 @@ static const int kTickSamplesBufferChunksCount = 16;
static const int kProfilerStackSize = 64 * KB; static const int kProfilerStackSize = 64 * KB;
ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) ProfilerEventsProcessor::ProfilerEventsProcessor(
ProfileGenerator* generator, CpuProfilesCollection* profiles)
: Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
generator_(generator), generator_(generator),
profiles_(profiles),
running_(true), running_(true),
ticks_buffer_(sizeof(TickSampleEventRecord), ticks_buffer_(sizeof(TickSampleEventRecord),
kTickSamplesBufferChunkSize, kTickSamplesBufferChunkSize,
...@@ -65,7 +67,7 @@ void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, ...@@ -65,7 +67,7 @@ void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag,
rec->type = CodeEventRecord::CODE_CREATION; rec->type = CodeEventRecord::CODE_CREATION;
rec->order = ++enqueue_order_; rec->order = ++enqueue_order_;
rec->start = start; rec->start = start;
rec->entry = generator_->NewCodeEntry(tag, prefix, name); rec->entry = profiles_->NewCodeEntry(tag, prefix, name);
rec->size = 1; rec->size = 1;
rec->shared = NULL; rec->shared = NULL;
events_buffer_.Enqueue(evt_rec); events_buffer_.Enqueue(evt_rec);
...@@ -85,7 +87,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -85,7 +87,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
rec->type = CodeEventRecord::CODE_CREATION; rec->type = CodeEventRecord::CODE_CREATION;
rec->order = ++enqueue_order_; rec->order = ++enqueue_order_;
rec->start = start; 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->size = size;
rec->shared = shared; rec->shared = shared;
events_buffer_.Enqueue(evt_rec); events_buffer_.Enqueue(evt_rec);
...@@ -102,7 +104,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -102,7 +104,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
rec->type = CodeEventRecord::CODE_CREATION; rec->type = CodeEventRecord::CODE_CREATION;
rec->order = ++enqueue_order_; rec->order = ++enqueue_order_;
rec->start = start; rec->start = start;
rec->entry = generator_->NewCodeEntry(tag, name); rec->entry = profiles_->NewCodeEntry(tag, name);
rec->size = size; rec->size = size;
rec->shared = NULL; rec->shared = NULL;
events_buffer_.Enqueue(evt_rec); events_buffer_.Enqueue(evt_rec);
...@@ -119,7 +121,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, ...@@ -119,7 +121,7 @@ void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
rec->type = CodeEventRecord::CODE_CREATION; rec->type = CodeEventRecord::CODE_CREATION;
rec->order = ++enqueue_order_; rec->order = ++enqueue_order_;
rec->start = start; rec->start = start;
rec->entry = generator_->NewCodeEntry(tag, args_count); rec->entry = profiles_->NewCodeEntry(tag, args_count);
rec->size = size; rec->size = size;
rec->shared = NULL; rec->shared = NULL;
events_buffer_.Enqueue(evt_rec); events_buffer_.Enqueue(evt_rec);
...@@ -162,7 +164,7 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent( ...@@ -162,7 +164,7 @@ void ProfilerEventsProcessor::RegExpCodeCreateEvent(
rec->type = CodeEventRecord::CODE_CREATION; rec->type = CodeEventRecord::CODE_CREATION;
rec->order = ++enqueue_order_; rec->order = ++enqueue_order_;
rec->start = start; rec->start = start;
rec->entry = generator_->NewCodeEntry(tag, prefix, name); rec->entry = profiles_->NewCodeEntry(tag, prefix, name);
rec->size = size; rec->size = size;
events_buffer_.Enqueue(evt_rec); events_buffer_.Enqueue(evt_rec);
} }
...@@ -443,7 +445,7 @@ void CpuProfiler::StartProcessorIfNotStarted() { ...@@ -443,7 +445,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
saved_logging_nesting_ = isolate_->logger()->logging_nesting_; saved_logging_nesting_ = isolate_->logger()->logging_nesting_;
isolate_->logger()->logging_nesting_ = 0; isolate_->logger()->logging_nesting_ = 0;
generator_ = new ProfileGenerator(profiles_); generator_ = new ProfileGenerator(profiles_);
processor_ = new ProfilerEventsProcessor(generator_); processor_ = new ProfilerEventsProcessor(generator_, profiles_);
is_profiling_ = true; is_profiling_ = true;
processor_->StartSynchronously(); processor_->StartSynchronously();
// Enumerate stuff we already have in the heap. // Enumerate stuff we already have in the heap.
...@@ -458,7 +460,7 @@ void CpuProfiler::StartProcessorIfNotStarted() { ...@@ -458,7 +460,7 @@ void CpuProfiler::StartProcessorIfNotStarted() {
isolate_->logger()->LogAccessorCallbacks(); isolate_->logger()->LogAccessorCallbacks();
} }
// Enable stack sampling. // Enable stack sampling.
Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_); Sampler* sampler = isolate_->logger()->sampler();
sampler->IncreaseProfilingDepth(); sampler->IncreaseProfilingDepth();
if (!sampler->IsActive()) { if (!sampler->IsActive()) {
sampler->Start(); sampler->Start();
......
...@@ -125,7 +125,8 @@ class TickSampleEventRecord { ...@@ -125,7 +125,8 @@ class TickSampleEventRecord {
// methods called by event producers: VM and stack sampler threads. // methods called by event producers: VM and stack sampler threads.
class ProfilerEventsProcessor : public Thread { class ProfilerEventsProcessor : public Thread {
public: public:
explicit ProfilerEventsProcessor(ProfileGenerator* generator); ProfilerEventsProcessor(ProfileGenerator* generator,
CpuProfilesCollection* profiles);
virtual ~ProfilerEventsProcessor() {} virtual ~ProfilerEventsProcessor() {}
// Thread control. // Thread control.
...@@ -178,6 +179,7 @@ class ProfilerEventsProcessor : public Thread { ...@@ -178,6 +179,7 @@ class ProfilerEventsProcessor : public Thread {
INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
ProfileGenerator* generator_; ProfileGenerator* generator_;
CpuProfilesCollection* profiles_;
bool running_; bool running_;
UnboundQueue<CodeEventsContainer> events_buffer_; UnboundQueue<CodeEventsContainer> events_buffer_;
SamplingCircularQueue ticks_buffer_; SamplingCircularQueue ticks_buffer_;
......
...@@ -400,33 +400,6 @@ class ProfileGenerator { ...@@ -400,33 +400,6 @@ class ProfileGenerator {
public: public:
explicit ProfileGenerator(CpuProfilesCollection* profiles); 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); void RecordTickSample(const TickSample& sample);
INLINE(CodeMap* code_map()) { return &code_map_; } INLINE(CodeMap* code_map()) { return &code_map_; }
......
...@@ -48,7 +48,7 @@ using i::Vector; ...@@ -48,7 +48,7 @@ using i::Vector;
TEST(StartStop) { TEST(StartStop) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
ProfilerEventsProcessor processor(&generator); ProfilerEventsProcessor processor(&generator, &profiles);
processor.Start(); processor.Start();
processor.Stop(); processor.Stop();
processor.Join(); processor.Join();
...@@ -104,7 +104,7 @@ TEST(CodeEvents) { ...@@ -104,7 +104,7 @@ TEST(CodeEvents) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
ProfilerEventsProcessor processor(&generator); ProfilerEventsProcessor processor(&generator, &profiles);
processor.Start(); processor.Start();
// Enqueue code creation events. // Enqueue code creation events.
...@@ -165,7 +165,7 @@ TEST(TickEvents) { ...@@ -165,7 +165,7 @@ TEST(TickEvents) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
ProfilerEventsProcessor processor(&generator); ProfilerEventsProcessor processor(&generator, &profiles);
processor.Start(); processor.Start();
processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
...@@ -229,7 +229,7 @@ TEST(Issue1398) { ...@@ -229,7 +229,7 @@ TEST(Issue1398) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
ProfilerEventsProcessor processor(&generator); ProfilerEventsProcessor processor(&generator, &profiles);
processor.Start(); processor.Start();
processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
......
...@@ -611,9 +611,9 @@ TEST(RecordTickSample) { ...@@ -611,9 +611,9 @@ TEST(RecordTickSample) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc");
generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
...@@ -727,9 +727,9 @@ TEST(SampleIds) { ...@@ -727,9 +727,9 @@ TEST(SampleIds) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, true); profiles.StartProfiling("", 1, true);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
CodeEntry* entry1 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
CodeEntry* entry3 = generator.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc"); CodeEntry* entry3 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "ccc");
generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100); generator.code_map()->AddCode(ToAddress(0x1700), entry2, 0x100);
generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50); generator.code_map()->AddCode(ToAddress(0x1900), entry3, 0x50);
...@@ -776,7 +776,7 @@ TEST(NoSamples) { ...@@ -776,7 +776,7 @@ TEST(NoSamples) {
CpuProfilesCollection profiles; CpuProfilesCollection profiles;
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles); 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); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
// We are building the following calls tree: // We are building the following calls tree:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment