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

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

Issue 146213004: A64: Synchronize with r16849. (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-compiler.cc ('k') | test/cctest/test-dataflow.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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle( 120 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle(
121 *v8::Local<v8::Function>::Cast( 121 *v8::Local<v8::Function>::Cast(
122 (*env)->Global()->Get(v8_str(name_start)))); 122 (*env)->Global()->Get(v8_str(name_start))));
123 return fun->code(); 123 return fun->code();
124 } 124 }
125 125
126 126
127 TEST(CodeEvents) { 127 TEST(CodeEvents) {
128 CcTest::InitializeVM(); 128 CcTest::InitializeVM();
129 LocalContext env; 129 LocalContext env;
130 i::Isolate* isolate = i::Isolate::Current(); 130 i::Isolate* isolate = CcTest::i_isolate();
131 i::Factory* factory = isolate->factory(); 131 i::Factory* factory = isolate->factory();
132 TestSetup test_setup; 132 TestSetup test_setup;
133 133
134 i::HandleScope scope(isolate); 134 i::HandleScope scope(isolate);
135 135
136 i::Code* aaa_code = CreateCode(&env); 136 i::Code* aaa_code = CreateCode(&env);
137 i::Code* comment_code = CreateCode(&env); 137 i::Code* comment_code = CreateCode(&env);
138 i::Code* args5_code = CreateCode(&env); 138 i::Code* args5_code = CreateCode(&env);
139 i::Code* comment2_code = CreateCode(&env); 139 i::Code* comment2_code = CreateCode(&env);
140 i::Code* moved_code = CreateCode(&env); 140 i::Code* moved_code = CreateCode(&env);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 template<typename T> 190 template<typename T>
191 static int CompareProfileNodes(const T* p1, const T* p2) { 191 static int CompareProfileNodes(const T* p1, const T* p2) {
192 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 192 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
193 } 193 }
194 194
195 195
196 TEST(TickEvents) { 196 TEST(TickEvents) {
197 TestSetup test_setup; 197 TestSetup test_setup;
198 LocalContext env; 198 LocalContext env;
199 i::Isolate* isolate = i::Isolate::Current(); 199 i::Isolate* isolate = CcTest::i_isolate();
200 i::HandleScope scope(isolate); 200 i::HandleScope scope(isolate);
201 201
202 i::Code* frame1_code = CreateCode(&env); 202 i::Code* frame1_code = CreateCode(&env);
203 i::Code* frame2_code = CreateCode(&env); 203 i::Code* frame2_code = CreateCode(&env);
204 i::Code* frame3_code = CreateCode(&env); 204 i::Code* frame3_code = CreateCode(&env);
205 205
206 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 206 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
207 profiles->StartProfiling("", 1, false); 207 profiles->StartProfiling("", 1, false);
208 ProfileGenerator generator(profiles); 208 ProfileGenerator generator(profiles);
209 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 209 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 top_down_stub_children->last()->children(); 247 top_down_stub_children->last()->children();
248 CHECK_EQ(0, top_down_ddd_children->length()); 248 CHECK_EQ(0, top_down_ddd_children->length());
249 } 249 }
250 250
251 251
252 // http://crbug/51594 252 // http://crbug/51594
253 // This test must not crash. 253 // This test must not crash.
254 TEST(CrashIfStoppingLastNonExistentProfile) { 254 TEST(CrashIfStoppingLastNonExistentProfile) {
255 CcTest::InitializeVM(); 255 CcTest::InitializeVM();
256 TestSetup test_setup; 256 TestSetup test_setup;
257 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); 257 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
258 profiler->StartProfiling("1"); 258 profiler->StartProfiling("1");
259 profiler->StopProfiling("2"); 259 profiler->StopProfiling("2");
260 profiler->StartProfiling("1"); 260 profiler->StartProfiling("1");
261 profiler->StopProfiling(""); 261 profiler->StopProfiling("");
262 } 262 }
263 263
264 264
265 // http://code.google.com/p/v8/issues/detail?id=1398 265 // http://code.google.com/p/v8/issues/detail?id=1398
266 // Long stacks (exceeding max frames limit) must not be erased. 266 // Long stacks (exceeding max frames limit) must not be erased.
267 TEST(Issue1398) { 267 TEST(Issue1398) {
268 TestSetup test_setup; 268 TestSetup test_setup;
269 LocalContext env; 269 LocalContext env;
270 i::Isolate* isolate = i::Isolate::Current(); 270 i::Isolate* isolate = CcTest::i_isolate();
271 i::HandleScope scope(isolate); 271 i::HandleScope scope(isolate);
272 272
273 i::Code* code = CreateCode(&env); 273 i::Code* code = CreateCode(&env);
274 274
275 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 275 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
276 profiles->StartProfiling("", 1, false); 276 profiles->StartProfiling("", 1, false);
277 ProfileGenerator generator(profiles); 277 ProfileGenerator generator(profiles);
278 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 278 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
279 &generator, NULL, TimeDelta::FromMicroseconds(100))); 279 &generator, NULL, TimeDelta::FromMicroseconds(100)));
280 processor->Start(); 280 processor->Start();
(...skipping 21 matching lines...) Expand all
302 ++actual_depth; 302 ++actual_depth;
303 } 303 }
304 304
305 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. 305 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
306 } 306 }
307 307
308 308
309 TEST(DeleteAllCpuProfiles) { 309 TEST(DeleteAllCpuProfiles) {
310 CcTest::InitializeVM(); 310 CcTest::InitializeVM();
311 TestSetup test_setup; 311 TestSetup test_setup;
312 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); 312 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
313 CHECK_EQ(0, profiler->GetProfilesCount()); 313 CHECK_EQ(0, profiler->GetProfilesCount());
314 profiler->DeleteAllProfiles(); 314 profiler->DeleteAllProfiles();
315 CHECK_EQ(0, profiler->GetProfilesCount()); 315 CHECK_EQ(0, profiler->GetProfilesCount());
316 316
317 profiler->StartProfiling("1"); 317 profiler->StartProfiling("1");
318 profiler->StopProfiling("1"); 318 profiler->StopProfiling("1");
319 CHECK_EQ(1, profiler->GetProfilesCount()); 319 CHECK_EQ(1, profiler->GetProfilesCount());
320 profiler->DeleteAllProfiles(); 320 profiler->DeleteAllProfiles();
321 CHECK_EQ(0, profiler->GetProfilesCount()); 321 CHECK_EQ(0, profiler->GetProfilesCount());
322 profiler->StartProfiling("1"); 322 profiler->StartProfiling("1");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); 389 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
390 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3)); 390 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3));
391 const_cast<v8::CpuProfile*>(p3)->Delete(); 391 const_cast<v8::CpuProfile*>(p3)->Delete();
392 CHECK_EQ(0, cpu_profiler->GetProfileCount()); 392 CHECK_EQ(0, cpu_profiler->GetProfileCount());
393 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3)); 393 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3));
394 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); 394 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2));
395 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); 395 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1));
396 } 396 }
397 397
398 398
399 TEST(GetProfilerWhenIsolateIsNotInitialized) {
400 v8::Isolate* isolate = v8::Isolate::GetCurrent();
401 CHECK(i::Isolate::Current()->IsDefaultIsolate());
402 CHECK(!i::Isolate::Current()->IsInitialized());
403 CHECK_EQ(NULL, isolate->GetCpuProfiler());
404 {
405 v8::Isolate::Scope isolateScope(isolate);
406 LocalContext env;
407 v8::HandleScope scope(isolate);
408 CHECK_NE(NULL, isolate->GetCpuProfiler());
409 isolate->GetCpuProfiler()->StartCpuProfiling(v8::String::New("Test"));
410 isolate->GetCpuProfiler()->StopCpuProfiling(v8::String::New("Test"));
411 }
412 CHECK(i::Isolate::Current()->IsInitialized());
413 CHECK_NE(NULL, isolate->GetCpuProfiler());
414 isolate->Dispose();
415 CHECK_EQ(NULL, isolate->GetCpuProfiler());
416 }
417
418
419 TEST(ProfileStartEndTime) { 399 TEST(ProfileStartEndTime) {
420 LocalContext env; 400 LocalContext env;
421 v8::HandleScope scope(env->GetIsolate()); 401 v8::HandleScope scope(env->GetIsolate());
422 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 402 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
423 403
424 v8::Local<v8::String> profile_name = v8::String::New("test"); 404 v8::Local<v8::String> profile_name = v8::String::New("test");
425 cpu_profiler->StartCpuProfiling(profile_name); 405 cpu_profiler->StartCpuProfiling(profile_name);
426 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name); 406 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
427 CHECK(profile->GetStartTime() <= profile->GetEndTime()); 407 CHECK(profile->GetStartTime() <= profile->GetEndTime());
428 } 408 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 // 5 0 (unresolved function) [-1] #5 946 // 5 0 (unresolved function) [-1] #5
967 // 5 5 call [-1] #6 947 // 5 5 call [-1] #6
968 // 71 70 start [-1] #3 948 // 71 70 start [-1] #3
969 // 1 1 bar [-1] #7 949 // 1 1 bar [-1] #7
970 // 19 19 (program) [-1] #2 950 // 19 19 (program) [-1] #2
971 TEST(FunctionCallSample) { 951 TEST(FunctionCallSample) {
972 LocalContext env; 952 LocalContext env;
973 v8::HandleScope scope(env->GetIsolate()); 953 v8::HandleScope scope(env->GetIsolate());
974 954
975 // Collect garbage that might have be generated while installing extensions. 955 // Collect garbage that might have be generated while installing extensions.
976 HEAP->CollectAllGarbage(Heap::kNoGCFlags); 956 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
977 957
978 v8::Script::Compile(v8::String::New(call_function_test_source))->Run(); 958 v8::Script::Compile(v8::String::New(call_function_test_source))->Run();
979 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 959 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
980 env->Global()->Get(v8::String::New("start"))); 960 env->Global()->Get(v8::String::New("start")));
981 961
982 int32_t duration_ms = 100; 962 int32_t duration_ms = 100;
983 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) }; 963 v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
984 const v8::CpuProfile* profile = 964 const v8::CpuProfile* profile =
985 RunProfiler(env, function, args, ARRAY_SIZE(args), 100); 965 RunProfiler(env, function, args, ARRAY_SIZE(args), 100);
986 966
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 // 3 3 (program) #0 2 1314 // 3 3 (program) #0 2
1335 // 3 3 (idle) #0 3 1315 // 3 3 (idle) #0 3
1336 TEST(IdleTime) { 1316 TEST(IdleTime) {
1337 LocalContext env; 1317 LocalContext env;
1338 v8::HandleScope scope(env->GetIsolate()); 1318 v8::HandleScope scope(env->GetIsolate());
1339 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1319 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1340 1320
1341 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); 1321 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
1342 cpu_profiler->StartCpuProfiling(profile_name); 1322 cpu_profiler->StartCpuProfiling(profile_name);
1343 1323
1344 i::Isolate* isolate = i::Isolate::Current(); 1324 i::Isolate* isolate = CcTest::i_isolate();
1345 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor(); 1325 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor();
1346 processor->AddCurrentStack(isolate); 1326 processor->AddCurrentStack(isolate);
1347 1327
1348 cpu_profiler->SetIdle(true); 1328 cpu_profiler->SetIdle(true);
1349 1329
1350 for (int i = 0; i < 3; i++) { 1330 for (int i = 0; i < 3; i++) {
1351 processor->AddCurrentStack(isolate); 1331 processor->AddCurrentStack(isolate);
1352 } 1332 }
1353 1333
1354 cpu_profiler->SetIdle(false); 1334 cpu_profiler->SetIdle(false);
(...skipping 18 matching lines...) Expand all
1373 CHECK_EQ(0, programNode->GetChildrenCount()); 1353 CHECK_EQ(0, programNode->GetChildrenCount());
1374 CHECK_GE(programNode->GetHitCount(), 3); 1354 CHECK_GE(programNode->GetHitCount(), 3);
1375 1355
1376 const v8::CpuProfileNode* idleNode = 1356 const v8::CpuProfileNode* idleNode =
1377 GetChild(root, ProfileGenerator::kIdleEntryName); 1357 GetChild(root, ProfileGenerator::kIdleEntryName);
1378 CHECK_EQ(0, idleNode->GetChildrenCount()); 1358 CHECK_EQ(0, idleNode->GetChildrenCount());
1379 CHECK_GE(idleNode->GetHitCount(), 3); 1359 CHECK_GE(idleNode->GetHitCount(), 3);
1380 1360
1381 cpu_profiler->DeleteAllCpuProfiles(); 1361 cpu_profiler->DeleteAllCpuProfiles();
1382 } 1362 }
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-dataflow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698