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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 151163005: A64: Synchronize with r16356. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « test/cctest/test-cpu-ia32.cc ('k') | test/cctest/test-cpu-x64.cc » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests of profiles generator and utilities. 28 // Tests of profiles generator and utilities.
29 29
30 #include "v8.h" 30 #include "v8.h"
31 #include "cpu-profiler-inl.h" 31 #include "cpu-profiler-inl.h"
32 #include "cctest.h" 32 #include "cctest.h"
33 #include "platform.h" 33 #include "platform.h"
34 #include "smart-pointers.h"
34 #include "utils.h" 35 #include "utils.h"
35 #include "../include/v8-profiler.h" 36 #include "../include/v8-profiler.h"
36 using i::CodeEntry; 37 using i::CodeEntry;
37 using i::CpuProfile; 38 using i::CpuProfile;
38 using i::CpuProfiler; 39 using i::CpuProfiler;
39 using i::CpuProfilesCollection; 40 using i::CpuProfilesCollection;
40 using i::Heap; 41 using i::Heap;
41 using i::ProfileGenerator; 42 using i::ProfileGenerator;
42 using i::ProfileNode; 43 using i::ProfileNode;
43 using i::ProfilerEventsProcessor; 44 using i::ProfilerEventsProcessor;
44 using i::ScopedVector; 45 using i::ScopedVector;
46 using i::SmartPointer;
45 using i::Vector; 47 using i::Vector;
46 48
47 49
48 TEST(StartStop) { 50 TEST(StartStop) {
49 CpuProfilesCollection profiles; 51 CpuProfilesCollection profiles;
50 ProfileGenerator generator(&profiles); 52 ProfileGenerator generator(&profiles);
51 ProfilerEventsProcessor processor(&generator); 53 SmartPointer<ProfilerEventsProcessor> processor(
52 processor.Start(); 54 new ProfilerEventsProcessor(&generator, NULL, 100));
53 processor.StopSynchronously(); 55 processor->Start();
54 processor.Join(); 56 processor->StopSynchronously();
55 } 57 }
56 58
57 59
58 static inline i::Address ToAddress(int n) { 60 static inline i::Address ToAddress(int n) {
59 return reinterpret_cast<i::Address>(n); 61 return reinterpret_cast<i::Address>(n);
60 } 62 }
61 63
62 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 64 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
63 i::Address frame1, 65 i::Address frame1,
64 i::Address frame2 = NULL, 66 i::Address frame2 = NULL,
65 i::Address frame3 = NULL) { 67 i::Address frame3 = NULL) {
66 i::TickSample* sample = proc->TickSampleEvent(); 68 i::TickSample* sample = proc->StartTickSample();
67 sample->pc = frame1; 69 sample->pc = frame1;
68 sample->tos = frame1; 70 sample->tos = frame1;
69 sample->frames_count = 0; 71 sample->frames_count = 0;
70 if (frame2 != NULL) { 72 if (frame2 != NULL) {
71 sample->stack[0] = frame2; 73 sample->stack[0] = frame2;
72 sample->frames_count = 1; 74 sample->frames_count = 1;
73 } 75 }
74 if (frame3 != NULL) { 76 if (frame3 != NULL) {
75 sample->stack[1] = frame3; 77 sample->stack[1] = frame3;
76 sample->frames_count = 2; 78 sample->frames_count = 2;
77 } 79 }
80 proc->FinishTickSample();
78 } 81 }
79 82
80 namespace { 83 namespace {
81 84
82 class TestSetup { 85 class TestSetup {
83 public: 86 public:
84 TestSetup() 87 TestSetup()
85 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) { 88 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) {
86 i::FLAG_prof_browser_mode = false; 89 i::FLAG_prof_browser_mode = false;
87 } 90 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 i::Code* comment_code = CreateCode(&env); 135 i::Code* comment_code = CreateCode(&env);
133 i::Code* args5_code = CreateCode(&env); 136 i::Code* args5_code = CreateCode(&env);
134 i::Code* comment2_code = CreateCode(&env); 137 i::Code* comment2_code = CreateCode(&env);
135 i::Code* moved_code = CreateCode(&env); 138 i::Code* moved_code = CreateCode(&env);
136 i::Code* args3_code = CreateCode(&env); 139 i::Code* args3_code = CreateCode(&env);
137 i::Code* args4_code = CreateCode(&env); 140 i::Code* args4_code = CreateCode(&env);
138 141
139 CpuProfilesCollection* profiles = new CpuProfilesCollection; 142 CpuProfilesCollection* profiles = new CpuProfilesCollection;
140 profiles->StartProfiling("", 1, false); 143 profiles->StartProfiling("", 1, false);
141 ProfileGenerator generator(profiles); 144 ProfileGenerator generator(profiles);
142 ProfilerEventsProcessor processor(&generator); 145 SmartPointer<ProfilerEventsProcessor> processor(
143 processor.Start(); 146 new ProfilerEventsProcessor(&generator, NULL, 100));
144 CpuProfiler profiler(isolate, profiles, &generator, &processor); 147 processor->Start();
148 CpuProfiler profiler(isolate, profiles, &generator, *processor);
145 149
146 // Enqueue code creation events. 150 // Enqueue code creation events.
147 const char* aaa_str = "aaa"; 151 const char* aaa_str = "aaa";
148 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( 152 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
149 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 153 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
150 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name); 154 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name);
151 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); 155 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment");
152 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); 156 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5);
153 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); 157 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2");
154 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); 158 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address());
155 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); 159 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3);
156 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); 160 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4);
157 161
158 // Enqueue a tick event to enable code events processing. 162 // Enqueue a tick event to enable code events processing.
159 EnqueueTickSampleEvent(&processor, aaa_code->address()); 163 EnqueueTickSampleEvent(*processor, aaa_code->address());
160 164
161 processor.StopSynchronously(); 165 processor->StopSynchronously();
162 processor.Join();
163 166
164 // Check the state of profile generator. 167 // Check the state of profile generator.
165 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); 168 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address());
166 CHECK_NE(NULL, aaa); 169 CHECK_NE(NULL, aaa);
167 CHECK_EQ(aaa_str, aaa->name()); 170 CHECK_EQ(aaa_str, aaa->name());
168 171
169 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); 172 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address());
170 CHECK_NE(NULL, comment); 173 CHECK_NE(NULL, comment);
171 CHECK_EQ("comment", comment->name()); 174 CHECK_EQ("comment", comment->name());
172 175
(...skipping 21 matching lines...) Expand all
194 i::Isolate* isolate = i::Isolate::Current(); 197 i::Isolate* isolate = i::Isolate::Current();
195 i::HandleScope scope(isolate); 198 i::HandleScope scope(isolate);
196 199
197 i::Code* frame1_code = CreateCode(&env); 200 i::Code* frame1_code = CreateCode(&env);
198 i::Code* frame2_code = CreateCode(&env); 201 i::Code* frame2_code = CreateCode(&env);
199 i::Code* frame3_code = CreateCode(&env); 202 i::Code* frame3_code = CreateCode(&env);
200 203
201 CpuProfilesCollection* profiles = new CpuProfilesCollection; 204 CpuProfilesCollection* profiles = new CpuProfilesCollection;
202 profiles->StartProfiling("", 1, false); 205 profiles->StartProfiling("", 1, false);
203 ProfileGenerator generator(profiles); 206 ProfileGenerator generator(profiles);
204 ProfilerEventsProcessor processor(&generator); 207 SmartPointer<ProfilerEventsProcessor> processor(
205 processor.Start(); 208 new ProfilerEventsProcessor(&generator, NULL, 100));
206 CpuProfiler profiler(isolate, profiles, &generator, &processor); 209 processor->Start();
210 CpuProfiler profiler(isolate, profiles, &generator, *processor);
207 211
208 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); 212 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb");
209 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); 213 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5);
210 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); 214 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd");
211 215
212 EnqueueTickSampleEvent(&processor, frame1_code->instruction_start()); 216 EnqueueTickSampleEvent(*processor, frame1_code->instruction_start());
213 EnqueueTickSampleEvent( 217 EnqueueTickSampleEvent(
214 &processor, 218 *processor,
215 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, 219 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2,
216 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); 220 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2);
217 EnqueueTickSampleEvent( 221 EnqueueTickSampleEvent(
218 &processor, 222 *processor,
219 frame3_code->instruction_end() - 1, 223 frame3_code->instruction_end() - 1,
220 frame2_code->instruction_end() - 1, 224 frame2_code->instruction_end() - 1,
221 frame1_code->instruction_end() - 1); 225 frame1_code->instruction_end() - 1);
222 226
223 processor.StopSynchronously(); 227 processor->StopSynchronously();
224 processor.Join();
225 CpuProfile* profile = profiles->StopProfiling(""); 228 CpuProfile* profile = profiles->StopProfiling("");
226 CHECK_NE(NULL, profile); 229 CHECK_NE(NULL, profile);
227 230
228 // Check call trees. 231 // Check call trees.
229 const i::List<ProfileNode*>* top_down_root_children = 232 const i::List<ProfileNode*>* top_down_root_children =
230 profile->top_down()->root()->children(); 233 profile->top_down()->root()->children();
231 CHECK_EQ(1, top_down_root_children->length()); 234 CHECK_EQ(1, top_down_root_children->length());
232 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); 235 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name());
233 const i::List<ProfileNode*>* top_down_bbb_children = 236 const i::List<ProfileNode*>* top_down_bbb_children =
234 top_down_root_children->last()->children(); 237 top_down_root_children->last()->children();
(...skipping 28 matching lines...) Expand all
263 TestSetup test_setup; 266 TestSetup test_setup;
264 LocalContext env; 267 LocalContext env;
265 i::Isolate* isolate = i::Isolate::Current(); 268 i::Isolate* isolate = i::Isolate::Current();
266 i::HandleScope scope(isolate); 269 i::HandleScope scope(isolate);
267 270
268 i::Code* code = CreateCode(&env); 271 i::Code* code = CreateCode(&env);
269 272
270 CpuProfilesCollection* profiles = new CpuProfilesCollection; 273 CpuProfilesCollection* profiles = new CpuProfilesCollection;
271 profiles->StartProfiling("", 1, false); 274 profiles->StartProfiling("", 1, false);
272 ProfileGenerator generator(profiles); 275 ProfileGenerator generator(profiles);
273 ProfilerEventsProcessor processor(&generator); 276 SmartPointer<ProfilerEventsProcessor> processor(
274 processor.Start(); 277 new ProfilerEventsProcessor(&generator, NULL, 100));
275 CpuProfiler profiler(isolate, profiles, &generator, &processor); 278 processor->Start();
279 CpuProfiler profiler(isolate, profiles, &generator, *processor);
276 280
277 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 281 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
278 282
279 i::TickSample* sample = processor.TickSampleEvent(); 283 i::TickSample* sample = processor->StartTickSample();
280 sample->pc = code->address(); 284 sample->pc = code->address();
281 sample->tos = 0; 285 sample->tos = 0;
282 sample->frames_count = i::TickSample::kMaxFramesCount; 286 sample->frames_count = i::TickSample::kMaxFramesCount;
283 for (int i = 0; i < sample->frames_count; ++i) { 287 for (int i = 0; i < sample->frames_count; ++i) {
284 sample->stack[i] = code->address(); 288 sample->stack[i] = code->address();
285 } 289 }
290 processor->FinishTickSample();
286 291
287 processor.StopSynchronously(); 292 processor->StopSynchronously();
288 processor.Join();
289 CpuProfile* profile = profiles->StopProfiling(""); 293 CpuProfile* profile = profiles->StopProfiling("");
290 CHECK_NE(NULL, profile); 294 CHECK_NE(NULL, profile);
291 295
292 int actual_depth = 0; 296 int actual_depth = 0;
293 const ProfileNode* node = profile->top_down()->root(); 297 const ProfileNode* node = profile->top_down()->root();
294 while (node->children()->length() > 0) { 298 while (node->children()->length() > 0) {
295 node = node->children()->last(); 299 node = node->children()->last();
296 ++actual_depth; 300 ++actual_depth;
297 } 301 }
298 302
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1365 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1362 ScopedVector<v8::Handle<v8::String> > names(3); 1366 ScopedVector<v8::Handle<v8::String> > names(3);
1363 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName); 1367 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
1364 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName); 1368 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
1365 names[2] = v8::String::New(ProfileGenerator::kIdleEntryName); 1369 names[2] = v8::String::New(ProfileGenerator::kIdleEntryName);
1366 CheckChildrenNames(root, names); 1370 CheckChildrenNames(root, names);
1367 1371
1368 const v8::CpuProfileNode* programNode = 1372 const v8::CpuProfileNode* programNode =
1369 GetChild(root, ProfileGenerator::kProgramEntryName); 1373 GetChild(root, ProfileGenerator::kProgramEntryName);
1370 CHECK_EQ(0, programNode->GetChildrenCount()); 1374 CHECK_EQ(0, programNode->GetChildrenCount());
1371 CHECK_GE(programNode->GetSelfSamplesCount(), 3);
1372 CHECK_GE(programNode->GetHitCount(), 3); 1375 CHECK_GE(programNode->GetHitCount(), 3);
1373 1376
1374 const v8::CpuProfileNode* idleNode = 1377 const v8::CpuProfileNode* idleNode =
1375 GetChild(root, ProfileGenerator::kIdleEntryName); 1378 GetChild(root, ProfileGenerator::kIdleEntryName);
1376 CHECK_EQ(0, idleNode->GetChildrenCount()); 1379 CHECK_EQ(0, idleNode->GetChildrenCount());
1377 CHECK_GE(idleNode->GetSelfSamplesCount(), 3);
1378 CHECK_GE(idleNode->GetHitCount(), 3); 1380 CHECK_GE(idleNode->GetHitCount(), 3);
1379 1381
1380 cpu_profiler->DeleteAllCpuProfiles(); 1382 cpu_profiler->DeleteAllCpuProfiles();
1381 } 1383 }
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-ia32.cc ('k') | test/cctest/test-cpu-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698