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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 TEST(StartStop) { | 45 TEST(StartStop) { |
46 CpuProfilesCollection profiles; | 46 CpuProfilesCollection profiles; |
47 ProfileGenerator generator(&profiles); | 47 ProfileGenerator generator(&profiles); |
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; | |
55 | |
56 static void InitializeVM() { | |
57 if (env.IsEmpty()) env = v8::Context::New(); | |
58 v8::HandleScope scope(env->GetIsolate()); | |
59 env->Enter(); | |
60 } | |
61 | |
62 static inline i::Address ToAddress(int n) { | 54 static inline i::Address ToAddress(int n) { |
63 return reinterpret_cast<i::Address>(n); | 55 return reinterpret_cast<i::Address>(n); |
64 } | 56 } |
65 | 57 |
66 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, | 58 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, |
67 i::Address frame1, | 59 i::Address frame1, |
68 i::Address frame2 = NULL, | 60 i::Address frame2 = NULL, |
69 i::Address frame3 = NULL) { | 61 i::Address frame3 = NULL) { |
70 i::TickSample* sample = proc->TickSampleEvent(); | 62 i::TickSample* sample = proc->TickSampleEvent(); |
71 sample->pc = frame1; | 63 sample->pc = frame1; |
(...skipping 22 matching lines...) Expand all Loading... |
94 i::FLAG_prof_browser_mode = old_flag_prof_browser_mode_; | 86 i::FLAG_prof_browser_mode = old_flag_prof_browser_mode_; |
95 } | 87 } |
96 | 88 |
97 private: | 89 private: |
98 bool old_flag_prof_browser_mode_; | 90 bool old_flag_prof_browser_mode_; |
99 }; | 91 }; |
100 | 92 |
101 } // namespace | 93 } // namespace |
102 | 94 |
103 TEST(CodeEvents) { | 95 TEST(CodeEvents) { |
104 InitializeVM(); | 96 CcTest::InitializeVM(); |
105 i::Isolate* isolate = i::Isolate::Current(); | 97 i::Isolate* isolate = i::Isolate::Current(); |
106 i::Heap* heap = isolate->heap(); | 98 i::Heap* heap = isolate->heap(); |
107 i::Factory* factory = isolate->factory(); | 99 i::Factory* factory = isolate->factory(); |
108 TestSetup test_setup; | 100 TestSetup test_setup; |
109 CpuProfilesCollection profiles; | 101 CpuProfilesCollection profiles; |
110 profiles.StartProfiling("", 1, false); | 102 profiles.StartProfiling("", 1, false); |
111 ProfileGenerator generator(&profiles); | 103 ProfileGenerator generator(&profiles); |
112 ProfilerEventsProcessor processor(&generator); | 104 ProfilerEventsProcessor processor(&generator); |
113 processor.Start(); | 105 processor.Start(); |
114 | 106 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 CHECK_EQ("ddd", top_down_stub_children->last()->entry()->name()); | 202 CHECK_EQ("ddd", top_down_stub_children->last()->entry()->name()); |
211 const i::List<ProfileNode*>* top_down_ddd_children = | 203 const i::List<ProfileNode*>* top_down_ddd_children = |
212 top_down_stub_children->last()->children(); | 204 top_down_stub_children->last()->children(); |
213 CHECK_EQ(0, top_down_ddd_children->length()); | 205 CHECK_EQ(0, top_down_ddd_children->length()); |
214 } | 206 } |
215 | 207 |
216 | 208 |
217 // http://crbug/51594 | 209 // http://crbug/51594 |
218 // This test must not crash. | 210 // This test must not crash. |
219 TEST(CrashIfStoppingLastNonExistentProfile) { | 211 TEST(CrashIfStoppingLastNonExistentProfile) { |
220 InitializeVM(); | 212 CcTest::InitializeVM(); |
221 TestSetup test_setup; | 213 TestSetup test_setup; |
222 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 214 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); |
223 profiler->StartProfiling("1"); | 215 profiler->StartProfiling("1"); |
224 profiler->StopProfiling("2"); | 216 profiler->StopProfiling("2"); |
225 profiler->StartProfiling("1"); | 217 profiler->StartProfiling("1"); |
226 profiler->StopProfiling(""); | 218 profiler->StopProfiling(""); |
227 } | 219 } |
228 | 220 |
229 | 221 |
230 // http://code.google.com/p/v8/issues/detail?id=1398 | 222 // http://code.google.com/p/v8/issues/detail?id=1398 |
(...skipping 30 matching lines...) Expand all Loading... |
261 while (node->children()->length() > 0) { | 253 while (node->children()->length() > 0) { |
262 node = node->children()->last(); | 254 node = node->children()->last(); |
263 ++actual_depth; | 255 ++actual_depth; |
264 } | 256 } |
265 | 257 |
266 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. | 258 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. |
267 } | 259 } |
268 | 260 |
269 | 261 |
270 TEST(DeleteAllCpuProfiles) { | 262 TEST(DeleteAllCpuProfiles) { |
271 InitializeVM(); | 263 CcTest::InitializeVM(); |
272 TestSetup test_setup; | 264 TestSetup test_setup; |
273 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 265 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); |
274 CHECK_EQ(0, profiler->GetProfilesCount()); | 266 CHECK_EQ(0, profiler->GetProfilesCount()); |
275 profiler->DeleteAllProfiles(); | 267 profiler->DeleteAllProfiles(); |
276 CHECK_EQ(0, profiler->GetProfilesCount()); | 268 CHECK_EQ(0, profiler->GetProfilesCount()); |
277 | 269 |
278 profiler->StartProfiling("1"); | 270 profiler->StartProfiling("1"); |
279 profiler->StopProfiling("1"); | 271 profiler->StopProfiling("1"); |
280 CHECK_EQ(1, profiler->GetProfilesCount()); | 272 CHECK_EQ(1, profiler->GetProfilesCount()); |
281 profiler->DeleteAllProfiles(); | 273 profiler->DeleteAllProfiles(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | 384 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
393 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | 385 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
394 const_cast<v8::CpuProfile*>(p2)->Delete(); | 386 const_cast<v8::CpuProfile*>(p2)->Delete(); |
395 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 387 CHECK_EQ(1, cpu_profiler->GetProfileCount()); |
396 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | 388 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); |
397 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | 389 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); |
398 const_cast<v8::CpuProfile*>(p3)->Delete(); | 390 const_cast<v8::CpuProfile*>(p3)->Delete(); |
399 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 391 CHECK_EQ(0, cpu_profiler->GetProfileCount()); |
400 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); | 392 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); |
401 } | 393 } |
OLD | NEW |