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

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

Issue 2105943002: Expose TickSample and its APIs in v8-profiler.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 5 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
« no previous file with comments | « src/profiler/tick-sample.cc ('k') | test/cctest/test-log-stack-tracer.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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator, 74 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator,
75 v8::base::TimeDelta::FromMicroseconds(100))); 75 v8::base::TimeDelta::FromMicroseconds(100)));
76 processor->Start(); 76 processor->Start();
77 processor->StopSynchronously(); 77 processor->StopSynchronously();
78 } 78 }
79 79
80 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 80 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
81 i::Address frame1, 81 i::Address frame1,
82 i::Address frame2 = NULL, 82 i::Address frame2 = NULL,
83 i::Address frame3 = NULL) { 83 i::Address frame3 = NULL) {
84 i::TickSample* sample = proc->StartTickSample(); 84 v8::TickSample* sample = proc->StartTickSample();
85 sample->pc = frame1; 85 sample->pc = frame1;
86 sample->tos = frame1; 86 sample->tos = frame1;
87 sample->frames_count = 0; 87 sample->frames_count = 0;
88 if (frame2 != NULL) { 88 if (frame2 != NULL) {
89 sample->stack[0] = frame2; 89 sample->stack[0] = frame2;
90 sample->frames_count = 1; 90 sample->frames_count = 1;
91 } 91 }
92 if (frame3 != NULL) { 92 if (frame3 != NULL) {
93 sample->stack[1] = frame3; 93 sample->stack[1] = frame3;
94 sample->frames_count = 2; 94 sample->frames_count = 2;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 v8::base::TimeDelta::FromMicroseconds(100)); 302 v8::base::TimeDelta::FromMicroseconds(100));
303 CpuProfiler profiler(isolate, profiles, generator, processor); 303 CpuProfiler profiler(isolate, profiles, generator, processor);
304 profiles->StartProfiling("", false); 304 profiles->StartProfiling("", false);
305 processor->Start(); 305 processor->Start();
306 ProfilerListener profiler_listener(isolate); 306 ProfilerListener profiler_listener(isolate);
307 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 307 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
308 profiler_listener.AddObserver(&profiler); 308 profiler_listener.AddObserver(&profiler);
309 309
310 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 310 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
311 311
312 i::TickSample* sample = processor->StartTickSample(); 312 v8::TickSample* sample = processor->StartTickSample();
313 sample->pc = code->address(); 313 sample->pc = code->address();
314 sample->tos = 0; 314 sample->tos = 0;
315 sample->frames_count = i::TickSample::kMaxFramesCount; 315 sample->frames_count = v8::TickSample::kMaxFramesCount;
316 for (unsigned i = 0; i < sample->frames_count; ++i) { 316 for (unsigned i = 0; i < sample->frames_count; ++i) {
317 sample->stack[i] = code->address(); 317 sample->stack[i] = code->address();
318 } 318 }
319 processor->FinishTickSample(); 319 processor->FinishTickSample();
320 320
321 profiler_listener.RemoveObserver(&profiler); 321 profiler_listener.RemoveObserver(&profiler);
322 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener); 322 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
323 processor->StopSynchronously(); 323 processor->StopSynchronously();
324 CpuProfile* profile = profiles->StopProfiling(""); 324 CpuProfile* profile = profiles->StopProfiling("");
325 CHECK(profile); 325 CHECK(profile);
326 326
327 unsigned actual_depth = 0; 327 unsigned actual_depth = 0;
328 const ProfileNode* node = profile->top_down()->root(); 328 const ProfileNode* node = profile->top_down()->root();
329 while (node->children()->length() > 0) { 329 while (node->children()->length() > 0) {
330 node = node->children()->last(); 330 node = node->children()->last();
331 ++actual_depth; 331 ++actual_depth;
332 } 332 }
333 333
334 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. 334 CHECK_EQ(1 + v8::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
335 } 335 }
336 336
337 TEST(DeleteAllCpuProfiles) { 337 TEST(DeleteAllCpuProfiles) {
338 CcTest::InitializeVM(); 338 CcTest::InitializeVM();
339 TestSetup test_setup; 339 TestSetup test_setup;
340 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler(); 340 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
341 CHECK_EQ(0, profiler->GetProfilesCount()); 341 CHECK_EQ(0, profiler->GetProfilesCount());
342 profiler->DeleteAllProfiles(); 342 profiler->DeleteAllProfiles();
343 CHECK_EQ(0, profiler->GetProfilesCount()); 343 CHECK_EQ(0, profiler->GetProfilesCount());
344 344
(...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 iprofile->Print(); 2048 iprofile->Print();
2049 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 2049 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
2050 2050
2051 const char* branch[] = {"", "test"}; 2051 const char* branch[] = {"", "test"};
2052 const ProfileNode* itest_node = 2052 const ProfileNode* itest_node =
2053 GetSimpleBranch(env, profile, branch, arraysize(branch)); 2053 GetSimpleBranch(env, profile, branch, arraysize(branch));
2054 CHECK_EQ(0U, itest_node->deopt_infos().size()); 2054 CHECK_EQ(0U, itest_node->deopt_infos().size());
2055 2055
2056 iprofiler->DeleteProfile(iprofile); 2056 iprofiler->DeleteProfile(iprofile);
2057 } 2057 }
OLDNEW
« no previous file with comments | « src/profiler/tick-sample.cc ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698