blob: 75e594ee30420da5008b639089e3c956f4fee2a8 [file] [log] [blame]
whesse@chromium.orgcec079d2010-03-22 14:44:04 +00001// Copyright 2010 the V8 project authors. All rights reserved.
ulan@chromium.org750145a2013-03-07 15:14:13 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000027//
28// Tests of profiles generator and utilities.
29
30#include "v8.h"
31#include "cpu-profiler-inl.h"
32#include "cctest.h"
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +000033#include "../include/v8-profiler.h"
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000034
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000035using i::CodeEntry;
lrn@chromium.org25156de2010-04-06 13:10:27 +000036using i::CpuProfile;
vegorov@chromium.org26c16f82010-08-11 13:41:03 +000037using i::CpuProfiler;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000038using i::CpuProfilesCollection;
39using i::ProfileGenerator;
40using i::ProfileNode;
41using i::ProfilerEventsProcessor;
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000042using i::TokenEnumerator;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000043
44
45TEST(StartStop) {
46 CpuProfilesCollection profiles;
47 ProfileGenerator generator(&profiles);
ulan@chromium.org750145a2013-03-07 15:14:13 +000048 ProfilerEventsProcessor processor(&generator);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000049 processor.Start();
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000050 processor.Stop();
51 processor.Join();
52}
53
54static v8::Persistent<v8::Context> env;
55
56static void InitializeVM() {
57 if (env.IsEmpty()) env = v8::Context::New();
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +000058 v8::HandleScope scope(env->GetIsolate());
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000059 env->Enter();
60}
61
62static inline i::Address ToAddress(int n) {
63 return reinterpret_cast<i::Address>(n);
64}
65
mmassi@chromium.org49a44672012-12-04 13:52:03 +000066static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
67 i::Address frame1,
68 i::Address frame2 = NULL,
69 i::Address frame3 = NULL) {
70 i::TickSample* sample = proc->TickSampleEvent();
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000071 sample->pc = frame1;
fschneider@chromium.org3a5fd782011-02-24 10:10:44 +000072 sample->tos = frame1;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000073 sample->frames_count = 0;
74 if (frame2 != NULL) {
75 sample->stack[0] = frame2;
76 sample->frames_count = 1;
77 }
78 if (frame3 != NULL) {
79 sample->stack[1] = frame3;
80 sample->frames_count = 2;
81 }
82}
83
ager@chromium.org357bf652010-04-12 11:30:10 +000084namespace {
85
86class TestSetup {
87 public:
88 TestSetup()
89 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) {
90 i::FLAG_prof_browser_mode = false;
91 }
92
93 ~TestSetup() {
94 i::FLAG_prof_browser_mode = old_flag_prof_browser_mode_;
95 }
96
97 private:
98 bool old_flag_prof_browser_mode_;
99};
100
101} // namespace
102
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000103TEST(CodeEvents) {
104 InitializeVM();
yangguo@chromium.orgc03a1922013-02-19 13:55:47 +0000105 i::Isolate* isolate = i::Isolate::Current();
106 i::Heap* heap = isolate->heap();
107 i::Factory* factory = isolate->factory();
ager@chromium.org357bf652010-04-12 11:30:10 +0000108 TestSetup test_setup;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000109 CpuProfilesCollection profiles;
lrn@chromium.org25156de2010-04-06 13:10:27 +0000110 profiles.StartProfiling("", 1);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000111 ProfileGenerator generator(&profiles);
ulan@chromium.org750145a2013-03-07 15:14:13 +0000112 ProfilerEventsProcessor processor(&generator);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000113 processor.Start();
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000114
115 // Enqueue code creation events.
yangguo@chromium.orgc03a1922013-02-19 13:55:47 +0000116 i::HandleScope scope(isolate);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000117 const char* aaa_str = "aaa";
yangguo@chromium.orgc03a1922013-02-19 13:55:47 +0000118 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
whesse@chromium.orgb6e43bb2010-04-14 09:36:28 +0000119 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000120 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG,
121 *aaa_name,
yangguo@chromium.orgc03a1922013-02-19 13:55:47 +0000122 heap->empty_string(),
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000123 0,
124 ToAddress(0x1000),
fschneider@chromium.org3a5fd782011-02-24 10:10:44 +0000125 0x100,
126 ToAddress(0x10000));
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000127 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
128 "bbb",
129 ToAddress(0x1200),
130 0x80);
131 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
132 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
133 "ddd",
134 ToAddress(0x1400),
135 0x80);
136 processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500));
137 processor.CodeCreateEvent(i::Logger::STUB_TAG, 3, ToAddress(0x1600), 0x10);
lrn@chromium.org34e60782011-09-15 07:25:40 +0000138 processor.CodeCreateEvent(i::Logger::STUB_TAG, 4, ToAddress(0x1605), 0x10);
mmassi@chromium.org49a44672012-12-04 13:52:03 +0000139 // Enqueue a tick event to enable code events processing.
140 EnqueueTickSampleEvent(&processor, ToAddress(0x1000));
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000141
142 processor.Stop();
143 processor.Join();
144
145 // Check the state of profile generator.
146 CodeEntry* entry1 = generator.code_map()->FindEntry(ToAddress(0x1000));
147 CHECK_NE(NULL, entry1);
148 CHECK_EQ(aaa_str, entry1->name());
149 CodeEntry* entry2 = generator.code_map()->FindEntry(ToAddress(0x1200));
150 CHECK_NE(NULL, entry2);
151 CHECK_EQ("bbb", entry2->name());
152 CodeEntry* entry3 = generator.code_map()->FindEntry(ToAddress(0x1300));
153 CHECK_NE(NULL, entry3);
lrn@chromium.org25156de2010-04-06 13:10:27 +0000154 CHECK_EQ("5", entry3->name());
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000155 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1400)));
156 CodeEntry* entry4 = generator.code_map()->FindEntry(ToAddress(0x1500));
157 CHECK_NE(NULL, entry4);
158 CHECK_EQ("ddd", entry4->name());
159 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1600)));
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000160}
161
162
163template<typename T>
164static int CompareProfileNodes(const T* p1, const T* p2) {
165 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
166}
167
168TEST(TickEvents) {
ager@chromium.org357bf652010-04-12 11:30:10 +0000169 TestSetup test_setup;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000170 CpuProfilesCollection profiles;
lrn@chromium.org25156de2010-04-06 13:10:27 +0000171 profiles.StartProfiling("", 1);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000172 ProfileGenerator generator(&profiles);
ulan@chromium.org750145a2013-03-07 15:14:13 +0000173 ProfilerEventsProcessor processor(&generator);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000174 processor.Start();
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000175
176 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
177 "bbb",
178 ToAddress(0x1200),
179 0x80);
180 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
181 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
182 "ddd",
183 ToAddress(0x1400),
184 0x80);
mmassi@chromium.org49a44672012-12-04 13:52:03 +0000185 EnqueueTickSampleEvent(&processor, ToAddress(0x1210));
186 EnqueueTickSampleEvent(&processor, ToAddress(0x1305), ToAddress(0x1220));
187 EnqueueTickSampleEvent(&processor,
188 ToAddress(0x1404),
189 ToAddress(0x1305),
190 ToAddress(0x1230));
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000191
192 processor.Stop();
193 processor.Join();
erik.corry@gmail.com9dfbea42010-05-21 12:58:28 +0000194 CpuProfile* profile =
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +0000195 profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
lrn@chromium.org25156de2010-04-06 13:10:27 +0000196 CHECK_NE(NULL, profile);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000197
198 // Check call trees.
lrn@chromium.org25156de2010-04-06 13:10:27 +0000199 const i::List<ProfileNode*>* top_down_root_children =
200 profile->top_down()->root()->children();
201 CHECK_EQ(1, top_down_root_children->length());
202 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name());
203 const i::List<ProfileNode*>* top_down_bbb_children =
204 top_down_root_children->last()->children();
205 CHECK_EQ(1, top_down_bbb_children->length());
206 CHECK_EQ("5", top_down_bbb_children->last()->entry()->name());
207 const i::List<ProfileNode*>* top_down_stub_children =
208 top_down_bbb_children->last()->children();
209 CHECK_EQ(1, top_down_stub_children->length());
210 CHECK_EQ("ddd", top_down_stub_children->last()->entry()->name());
211 const i::List<ProfileNode*>* top_down_ddd_children =
212 top_down_stub_children->last()->children();
213 CHECK_EQ(0, top_down_ddd_children->length());
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000214}
lrn@chromium.org25156de2010-04-06 13:10:27 +0000215
vegorov@chromium.org26c16f82010-08-11 13:41:03 +0000216
217// http://crbug/51594
218// This test must not crash.
219TEST(CrashIfStoppingLastNonExistentProfile) {
220 InitializeVM();
221 TestSetup test_setup;
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000222 CpuProfiler::SetUp();
vegorov@chromium.org26c16f82010-08-11 13:41:03 +0000223 CpuProfiler::StartProfiling("1");
224 CpuProfiler::StopProfiling("2");
225 CpuProfiler::StartProfiling("1");
226 CpuProfiler::StopProfiling("");
227 CpuProfiler::TearDown();
228}
229
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000230
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000231// http://code.google.com/p/v8/issues/detail?id=1398
232// Long stacks (exceeding max frames limit) must not be erased.
233TEST(Issue1398) {
234 TestSetup test_setup;
235 CpuProfilesCollection profiles;
236 profiles.StartProfiling("", 1);
237 ProfileGenerator generator(&profiles);
ulan@chromium.org750145a2013-03-07 15:14:13 +0000238 ProfilerEventsProcessor processor(&generator);
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000239 processor.Start();
240
241 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
242 "bbb",
243 ToAddress(0x1200),
244 0x80);
245
mmassi@chromium.org49a44672012-12-04 13:52:03 +0000246 i::TickSample* sample = processor.TickSampleEvent();
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000247 sample->pc = ToAddress(0x1200);
248 sample->tos = 0;
249 sample->frames_count = i::TickSample::kMaxFramesCount;
250 for (int i = 0; i < sample->frames_count; ++i) {
251 sample->stack[i] = ToAddress(0x1200);
252 }
253
254 processor.Stop();
255 processor.Join();
256 CpuProfile* profile =
257 profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
258 CHECK_NE(NULL, profile);
259
260 int actual_depth = 0;
261 const ProfileNode* node = profile->top_down()->root();
262 while (node->children()->length() > 0) {
263 node = node->children()->last();
264 ++actual_depth;
265 }
266
267 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
268}
269
270
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000271TEST(DeleteAllCpuProfiles) {
272 InitializeVM();
273 TestSetup test_setup;
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +0000274 CpuProfiler::SetUp();
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000275 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
276 CpuProfiler::DeleteAllProfiles();
277 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
278
279 CpuProfiler::StartProfiling("1");
280 CpuProfiler::StopProfiling("1");
281 CHECK_EQ(1, CpuProfiler::GetProfilesCount());
282 CpuProfiler::DeleteAllProfiles();
283 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
284 CpuProfiler::StartProfiling("1");
285 CpuProfiler::StartProfiling("2");
286 CpuProfiler::StopProfiling("2");
287 CpuProfiler::StopProfiling("1");
288 CHECK_EQ(2, CpuProfiler::GetProfilesCount());
289 CpuProfiler::DeleteAllProfiles();
290 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
291
292 // Test profiling cancellation by the 'delete' command.
293 CpuProfiler::StartProfiling("1");
294 CpuProfiler::StartProfiling("2");
295 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
296 CpuProfiler::DeleteAllProfiles();
297 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
298
299 CpuProfiler::TearDown();
300}
301
302
303TEST(DeleteCpuProfile) {
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000304 LocalContext env;
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +0000305 v8::HandleScope scope(env->GetIsolate());
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000306
307 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
308 v8::Local<v8::String> name1 = v8::String::New("1");
309 v8::CpuProfiler::StartProfiling(name1);
310 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
311 CHECK_NE(NULL, p1);
312 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
313 unsigned uid1 = p1->GetUid();
314 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
315 const_cast<v8::CpuProfile*>(p1)->Delete();
316 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
317 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
318
319 v8::Local<v8::String> name2 = v8::String::New("2");
320 v8::CpuProfiler::StartProfiling(name2);
321 const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2);
322 CHECK_NE(NULL, p2);
323 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
324 unsigned uid2 = p2->GetUid();
325 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
326 CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2));
327 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
328 v8::Local<v8::String> name3 = v8::String::New("3");
329 v8::CpuProfiler::StartProfiling(name3);
330 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
331 CHECK_NE(NULL, p3);
332 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
333 unsigned uid3 = p3->GetUid();
334 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
335 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
336 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
337 const_cast<v8::CpuProfile*>(p2)->Delete();
338 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
339 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
340 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
341 const_cast<v8::CpuProfile*>(p3)->Delete();
342 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
343 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
344 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
345 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
346}
347
348
349TEST(DeleteCpuProfileDifferentTokens) {
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000350 LocalContext env;
svenpanne@chromium.org2bda5432013-03-15 12:39:50 +0000351 v8::HandleScope scope(env->GetIsolate());
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000352
353 CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
354 v8::Local<v8::String> name1 = v8::String::New("1");
355 v8::CpuProfiler::StartProfiling(name1);
356 const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1);
357 CHECK_NE(NULL, p1);
358 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
359 unsigned uid1 = p1->GetUid();
360 CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
361 v8::Local<v8::String> token1 = v8::String::New("token1");
362 const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1);
363 CHECK_NE(NULL, p1_t1);
364 CHECK_NE(p1, p1_t1);
365 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
366 const_cast<v8::CpuProfile*>(p1)->Delete();
367 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
368 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
369 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
370 const_cast<v8::CpuProfile*>(p1_t1)->Delete();
371 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
372
373 v8::Local<v8::String> name2 = v8::String::New("2");
374 v8::CpuProfiler::StartProfiling(name2);
375 v8::Local<v8::String> token2 = v8::String::New("token2");
376 const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2);
377 CHECK_NE(NULL, p2_t2);
378 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
379 unsigned uid2 = p2_t2->GetUid();
380 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
381 const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2);
382 CHECK_NE(p2_t2, p2);
383 v8::Local<v8::String> name3 = v8::String::New("3");
384 v8::CpuProfiler::StartProfiling(name3);
385 const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3);
386 CHECK_NE(NULL, p3);
387 CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount());
388 unsigned uid3 = p3->GetUid();
389 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
390 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
391 const_cast<v8::CpuProfile*>(p2_t2)->Delete();
392 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
393 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
394 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
395 const_cast<v8::CpuProfile*>(p2)->Delete();
396 CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
397 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
398 CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
399 const_cast<v8::CpuProfile*>(p3)->Delete();
400 CHECK_EQ(0, CpuProfiler::GetProfilesCount());
401 CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
402}