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

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

Issue 23534067: bulk replace Isolate::Current in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 // 3 3 (program) #0 2 1314 // 3 3 (program) #0 2
1315 // 3 3 (idle) #0 3 1315 // 3 3 (idle) #0 3
1316 TEST(IdleTime) { 1316 TEST(IdleTime) {
1317 LocalContext env; 1317 LocalContext env;
1318 v8::HandleScope scope(env->GetIsolate()); 1318 v8::HandleScope scope(env->GetIsolate());
1319 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1319 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1320 1320
1321 v8::Local<v8::String> profile_name = v8::String::New("my_profile"); 1321 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
1322 cpu_profiler->StartCpuProfiling(profile_name); 1322 cpu_profiler->StartCpuProfiling(profile_name);
1323 1323
1324 i::Isolate* isolate = i::Isolate::Current(); 1324 i::Isolate* isolate = CcTest::i_isolate();
1325 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor(); 1325 i::ProfilerEventsProcessor* processor = isolate->cpu_profiler()->processor();
1326 processor->AddCurrentStack(isolate); 1326 processor->AddCurrentStack(isolate);
1327 1327
1328 cpu_profiler->SetIdle(true); 1328 cpu_profiler->SetIdle(true);
1329 1329
1330 for (int i = 0; i < 3; i++) { 1330 for (int i = 0; i < 3; i++) {
1331 processor->AddCurrentStack(isolate); 1331 processor->AddCurrentStack(isolate);
1332 } 1332 }
1333 1333
1334 cpu_profiler->SetIdle(false); 1334 cpu_profiler->SetIdle(false);
(...skipping 18 matching lines...) Expand all
1353 CHECK_EQ(0, programNode->GetChildrenCount()); 1353 CHECK_EQ(0, programNode->GetChildrenCount());
1354 CHECK_GE(programNode->GetHitCount(), 3); 1354 CHECK_GE(programNode->GetHitCount(), 3);
1355 1355
1356 const v8::CpuProfileNode* idleNode = 1356 const v8::CpuProfileNode* idleNode =
1357 GetChild(root, ProfileGenerator::kIdleEntryName); 1357 GetChild(root, ProfileGenerator::kIdleEntryName);
1358 CHECK_EQ(0, idleNode->GetChildrenCount()); 1358 CHECK_EQ(0, idleNode->GetChildrenCount());
1359 CHECK_GE(idleNode->GetHitCount(), 3); 1359 CHECK_GE(idleNode->GetHitCount(), 3);
1360 1360
1361 cpu_profiler->DeleteAllCpuProfiles(); 1361 cpu_profiler->DeleteAllCpuProfiles();
1362 } 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