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

Side by Side Diff: src/cpu-profiler.cc

Issue 14471035: Avoid unnecessary indirection when creating CodeEntries (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed nit Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/cpu-profiler.h ('k') | src/profile-generator.h » ('j') | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 #include "../include/v8-profiler.h" 37 #include "../include/v8-profiler.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 static const int kTickSamplesBufferChunkSize = 64 * KB; 42 static const int kTickSamplesBufferChunkSize = 64 * KB;
43 static const int kTickSamplesBufferChunksCount = 16; 43 static const int kTickSamplesBufferChunksCount = 16;
44 static const int kProfilerStackSize = 64 * KB; 44 static const int kProfilerStackSize = 64 * KB;
45 45
46 46
47 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) 47 ProfilerEventsProcessor::ProfilerEventsProcessor(
48 ProfileGenerator* generator, CpuProfilesCollection* profiles)
48 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), 49 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)),
49 generator_(generator), 50 generator_(generator),
51 profiles_(profiles),
50 running_(true), 52 running_(true),
51 ticks_buffer_(sizeof(TickSampleEventRecord), 53 ticks_buffer_(sizeof(TickSampleEventRecord),
52 kTickSamplesBufferChunkSize, 54 kTickSamplesBufferChunkSize,
53 kTickSamplesBufferChunksCount), 55 kTickSamplesBufferChunksCount),
54 enqueue_order_(0) { 56 enqueue_order_(0) {
55 } 57 }
56 58
57 59
58 void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, 60 void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag,
59 const char* prefix, 61 const char* prefix,
60 Name* name, 62 Name* name,
61 Address start) { 63 Address start) {
62 if (FilterOutCodeCreateEvent(tag)) return; 64 if (FilterOutCodeCreateEvent(tag)) return;
63 CodeEventsContainer evt_rec; 65 CodeEventsContainer evt_rec;
64 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 66 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
65 rec->type = CodeEventRecord::CODE_CREATION; 67 rec->type = CodeEventRecord::CODE_CREATION;
66 rec->order = ++enqueue_order_; 68 rec->order = ++enqueue_order_;
67 rec->start = start; 69 rec->start = start;
68 rec->entry = generator_->NewCodeEntry(tag, prefix, name); 70 rec->entry = profiles_->NewCodeEntry(tag, prefix, name);
69 rec->size = 1; 71 rec->size = 1;
70 rec->shared = NULL; 72 rec->shared = NULL;
71 events_buffer_.Enqueue(evt_rec); 73 events_buffer_.Enqueue(evt_rec);
72 } 74 }
73 75
74 76
75 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, 77 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
76 Name* name, 78 Name* name,
77 String* resource_name, 79 String* resource_name,
78 int line_number, 80 int line_number,
79 Address start, 81 Address start,
80 unsigned size, 82 unsigned size,
81 Address shared) { 83 Address shared) {
82 if (FilterOutCodeCreateEvent(tag)) return; 84 if (FilterOutCodeCreateEvent(tag)) return;
83 CodeEventsContainer evt_rec; 85 CodeEventsContainer evt_rec;
84 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 86 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
85 rec->type = CodeEventRecord::CODE_CREATION; 87 rec->type = CodeEventRecord::CODE_CREATION;
86 rec->order = ++enqueue_order_; 88 rec->order = ++enqueue_order_;
87 rec->start = start; 89 rec->start = start;
88 rec->entry = generator_->NewCodeEntry(tag, name, resource_name, line_number); 90 rec->entry = profiles_->NewCodeEntry(tag, name, resource_name, line_number);
89 rec->size = size; 91 rec->size = size;
90 rec->shared = shared; 92 rec->shared = shared;
91 events_buffer_.Enqueue(evt_rec); 93 events_buffer_.Enqueue(evt_rec);
92 } 94 }
93 95
94 96
95 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, 97 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
96 const char* name, 98 const char* name,
97 Address start, 99 Address start,
98 unsigned size) { 100 unsigned size) {
99 if (FilterOutCodeCreateEvent(tag)) return; 101 if (FilterOutCodeCreateEvent(tag)) return;
100 CodeEventsContainer evt_rec; 102 CodeEventsContainer evt_rec;
101 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 103 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
102 rec->type = CodeEventRecord::CODE_CREATION; 104 rec->type = CodeEventRecord::CODE_CREATION;
103 rec->order = ++enqueue_order_; 105 rec->order = ++enqueue_order_;
104 rec->start = start; 106 rec->start = start;
105 rec->entry = generator_->NewCodeEntry(tag, name); 107 rec->entry = profiles_->NewCodeEntry(tag, name);
106 rec->size = size; 108 rec->size = size;
107 rec->shared = NULL; 109 rec->shared = NULL;
108 events_buffer_.Enqueue(evt_rec); 110 events_buffer_.Enqueue(evt_rec);
109 } 111 }
110 112
111 113
112 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, 114 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag,
113 int args_count, 115 int args_count,
114 Address start, 116 Address start,
115 unsigned size) { 117 unsigned size) {
116 if (FilterOutCodeCreateEvent(tag)) return; 118 if (FilterOutCodeCreateEvent(tag)) return;
117 CodeEventsContainer evt_rec; 119 CodeEventsContainer evt_rec;
118 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 120 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
119 rec->type = CodeEventRecord::CODE_CREATION; 121 rec->type = CodeEventRecord::CODE_CREATION;
120 rec->order = ++enqueue_order_; 122 rec->order = ++enqueue_order_;
121 rec->start = start; 123 rec->start = start;
122 rec->entry = generator_->NewCodeEntry(tag, args_count); 124 rec->entry = profiles_->NewCodeEntry(tag, args_count);
123 rec->size = size; 125 rec->size = size;
124 rec->shared = NULL; 126 rec->shared = NULL;
125 events_buffer_.Enqueue(evt_rec); 127 events_buffer_.Enqueue(evt_rec);
126 } 128 }
127 129
128 130
129 void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) { 131 void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) {
130 CodeEventsContainer evt_rec; 132 CodeEventsContainer evt_rec;
131 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; 133 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_;
132 rec->type = CodeEventRecord::CODE_MOVE; 134 rec->type = CodeEventRecord::CODE_MOVE;
(...skipping 22 matching lines...) Expand all
155 const char* prefix, 157 const char* prefix,
156 String* name, 158 String* name,
157 Address start, 159 Address start,
158 unsigned size) { 160 unsigned size) {
159 if (FilterOutCodeCreateEvent(tag)) return; 161 if (FilterOutCodeCreateEvent(tag)) return;
160 CodeEventsContainer evt_rec; 162 CodeEventsContainer evt_rec;
161 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 163 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
162 rec->type = CodeEventRecord::CODE_CREATION; 164 rec->type = CodeEventRecord::CODE_CREATION;
163 rec->order = ++enqueue_order_; 165 rec->order = ++enqueue_order_;
164 rec->start = start; 166 rec->start = start;
165 rec->entry = generator_->NewCodeEntry(tag, prefix, name); 167 rec->entry = profiles_->NewCodeEntry(tag, prefix, name);
166 rec->size = size; 168 rec->size = size;
167 events_buffer_.Enqueue(evt_rec); 169 events_buffer_.Enqueue(evt_rec);
168 } 170 }
169 171
170 172
171 void ProfilerEventsProcessor::AddCurrentStack() { 173 void ProfilerEventsProcessor::AddCurrentStack() {
172 TickSampleEventRecord record(enqueue_order_); 174 TickSampleEventRecord record(enqueue_order_);
173 TickSample* sample = &record.sample; 175 TickSample* sample = &record.sample;
174 Isolate* isolate = Isolate::Current(); 176 Isolate* isolate = Isolate::Current();
175 sample->state = isolate->current_vm_state(); 177 sample->state = isolate->current_vm_state();
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 StartProfiling(profiles_->GetName(title), record_samples); 438 StartProfiling(profiles_->GetName(title), record_samples);
437 } 439 }
438 440
439 441
440 void CpuProfiler::StartProcessorIfNotStarted() { 442 void CpuProfiler::StartProcessorIfNotStarted() {
441 if (processor_ == NULL) { 443 if (processor_ == NULL) {
442 // Disable logging when using the new implementation. 444 // Disable logging when using the new implementation.
443 saved_logging_nesting_ = isolate_->logger()->logging_nesting_; 445 saved_logging_nesting_ = isolate_->logger()->logging_nesting_;
444 isolate_->logger()->logging_nesting_ = 0; 446 isolate_->logger()->logging_nesting_ = 0;
445 generator_ = new ProfileGenerator(profiles_); 447 generator_ = new ProfileGenerator(profiles_);
446 processor_ = new ProfilerEventsProcessor(generator_); 448 processor_ = new ProfilerEventsProcessor(generator_, profiles_);
447 is_profiling_ = true; 449 is_profiling_ = true;
448 processor_->StartSynchronously(); 450 processor_->StartSynchronously();
449 // Enumerate stuff we already have in the heap. 451 // Enumerate stuff we already have in the heap.
450 if (isolate_->heap()->HasBeenSetUp()) { 452 if (isolate_->heap()->HasBeenSetUp()) {
451 if (!FLAG_prof_browser_mode) { 453 if (!FLAG_prof_browser_mode) {
452 bool saved_log_code_flag = FLAG_log_code; 454 bool saved_log_code_flag = FLAG_log_code;
453 FLAG_log_code = true; 455 FLAG_log_code = true;
454 isolate_->logger()->LogCodeObjects(); 456 isolate_->logger()->LogCodeObjects();
455 FLAG_log_code = saved_log_code_flag; 457 FLAG_log_code = saved_log_code_flag;
456 } 458 }
457 isolate_->logger()->LogCompiledFunctions(); 459 isolate_->logger()->LogCompiledFunctions();
458 isolate_->logger()->LogAccessorCallbacks(); 460 isolate_->logger()->LogAccessorCallbacks();
459 } 461 }
460 // Enable stack sampling. 462 // Enable stack sampling.
461 Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_); 463 Sampler* sampler = isolate_->logger()->sampler();
462 sampler->IncreaseProfilingDepth(); 464 sampler->IncreaseProfilingDepth();
463 if (!sampler->IsActive()) { 465 if (!sampler->IsActive()) {
464 sampler->Start(); 466 sampler->Start();
465 need_to_stop_sampler_ = true; 467 need_to_stop_sampler_ = true;
466 } 468 }
467 } 469 }
468 } 470 }
469 471
470 472
471 CpuProfile* CpuProfiler::StopProfiling(const char* title) { 473 CpuProfile* CpuProfiler::StopProfiling(const char* title) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 processor_->Join(); 513 processor_->Join();
512 delete processor_; 514 delete processor_;
513 delete generator_; 515 delete generator_;
514 processor_ = NULL; 516 processor_ = NULL;
515 generator_ = NULL; 517 generator_ = NULL;
516 logger->logging_nesting_ = saved_logging_nesting_; 518 logger->logging_nesting_ = saved_logging_nesting_;
517 } 519 }
518 520
519 521
520 } } // namespace v8::internal 522 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cpu-profiler.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698