| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 ProfilerEventsProcessor processor(&generator); | 48 ProfilerEventsProcessor processor(&generator); |
| 49 processor.Start(); | 49 processor.Start(); |
| 50 processor.Stop(); | 50 processor.Stop(); |
| 51 processor.Join(); | 51 processor.Join(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 static v8::Persistent<v8::Context> env; | 54 static v8::Persistent<v8::Context> env; |
| 55 | 55 |
| 56 static void InitializeVM() { | 56 static void InitializeVM() { |
| 57 if (env.IsEmpty()) env = v8::Context::New(); | 57 if (env.IsEmpty()) env = v8::Context::New(); |
| 58 v8::HandleScope scope; | 58 v8::HandleScope scope(env->GetIsolate()); |
| 59 env->Enter(); | 59 env->Enter(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 static inline i::Address ToAddress(int n) { | 62 static inline i::Address ToAddress(int n) { |
| 63 return reinterpret_cast<i::Address>(n); | 63 return reinterpret_cast<i::Address>(n); |
| 64 } | 64 } |
| 65 | 65 |
| 66 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, | 66 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, |
| 67 i::Address frame1, | 67 i::Address frame1, |
| 68 i::Address frame2 = NULL, | 68 i::Address frame2 = NULL, |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 CpuProfiler::StartProfiling("2"); | 319 CpuProfiler::StartProfiling("2"); |
| 320 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 320 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); |
| 321 CpuProfiler::DeleteAllProfiles(); | 321 CpuProfiler::DeleteAllProfiles(); |
| 322 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 322 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); |
| 323 | 323 |
| 324 CpuProfiler::TearDown(); | 324 CpuProfiler::TearDown(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 | 327 |
| 328 TEST(DeleteCpuProfile) { | 328 TEST(DeleteCpuProfile) { |
| 329 v8::HandleScope scope; | |
| 330 LocalContext env; | 329 LocalContext env; |
| 330 v8::HandleScope scope(env->GetIsolate()); |
| 331 | 331 |
| 332 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); | 332 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); |
| 333 v8::Local<v8::String> name1 = v8::String::New("1"); | 333 v8::Local<v8::String> name1 = v8::String::New("1"); |
| 334 v8::CpuProfiler::StartProfiling(name1); | 334 v8::CpuProfiler::StartProfiling(name1); |
| 335 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); | 335 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); |
| 336 CHECK_NE(NULL, p1); | 336 CHECK_NE(NULL, p1); |
| 337 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); | 337 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); |
| 338 unsigned uid1 = p1->GetUid(); | 338 unsigned uid1 = p1->GetUid(); |
| 339 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); | 339 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); |
| 340 const_cast<v8::CpuProfile*>(p1)->Delete(); | 340 const_cast<v8::CpuProfile*>(p1)->Delete(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 365 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); | 365 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); |
| 366 const_cast<v8::CpuProfile*>(p3)->Delete(); | 366 const_cast<v8::CpuProfile*>(p3)->Delete(); |
| 367 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 367 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); |
| 368 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); | 368 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); |
| 369 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); | 369 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); |
| 370 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); | 370 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); |
| 371 } | 371 } |
| 372 | 372 |
| 373 | 373 |
| 374 TEST(DeleteCpuProfileDifferentTokens) { | 374 TEST(DeleteCpuProfileDifferentTokens) { |
| 375 v8::HandleScope scope; | |
| 376 LocalContext env; | 375 LocalContext env; |
| 376 v8::HandleScope scope(env->GetIsolate()); |
| 377 | 377 |
| 378 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); | 378 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); |
| 379 v8::Local<v8::String> name1 = v8::String::New("1"); | 379 v8::Local<v8::String> name1 = v8::String::New("1"); |
| 380 v8::CpuProfiler::StartProfiling(name1); | 380 v8::CpuProfiler::StartProfiling(name1); |
| 381 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); | 381 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); |
| 382 CHECK_NE(NULL, p1); | 382 CHECK_NE(NULL, p1); |
| 383 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); | 383 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); |
| 384 unsigned uid1 = p1->GetUid(); | 384 unsigned uid1 = p1->GetUid(); |
| 385 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); | 385 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); |
| 386 v8::Local<v8::String> token1 = v8::String::New("token1"); | 386 v8::Local<v8::String> token1 = v8::String::New("token1"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); | 418 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); |
| 419 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); | 419 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); |
| 420 const_cast<v8::CpuProfile*>(p2)->Delete(); | 420 const_cast<v8::CpuProfile*>(p2)->Delete(); |
| 421 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); | 421 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); |
| 422 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); | 422 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); |
| 423 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); | 423 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); |
| 424 const_cast<v8::CpuProfile*>(p3)->Delete(); | 424 const_cast<v8::CpuProfile*>(p3)->Delete(); |
| 425 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 425 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); |
| 426 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); | 426 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); |
| 427 } | 427 } |
| OLD | NEW |