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

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

Issue 2461003002: [profiler] Emit runtime call stats into sampling profile (Closed)
Patch Set: Created 4 years, 1 month 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const char* it = strstr(src, substring); 64 const char* it = strstr(src, substring);
65 CHECK(it); 65 CHECK(it);
66 return static_cast<size_t>(it - src); 66 return static_cast<size_t>(it - src);
67 } 67 }
68 68
69 static const char* reason(const i::DeoptimizeReason reason) { 69 static const char* reason(const i::DeoptimizeReason reason) {
70 return i::DeoptimizeReasonToString(reason); 70 return i::DeoptimizeReasonToString(reason);
71 } 71 }
72 72
73 TEST(StartStop) { 73 TEST(StartStop) {
74 CpuProfilesCollection profiles(CcTest::i_isolate()); 74 i::Isolate* isolate = CcTest::i_isolate();
75 ProfileGenerator generator(&profiles); 75 CpuProfilesCollection profiles(isolate);
76 ProfileGenerator generator(isolate, &profiles);
76 std::unique_ptr<ProfilerEventsProcessor> processor( 77 std::unique_ptr<ProfilerEventsProcessor> processor(
77 new ProfilerEventsProcessor(CcTest::i_isolate(), &generator, 78 new ProfilerEventsProcessor(isolate, &generator,
78 v8::base::TimeDelta::FromMicroseconds(100))); 79 v8::base::TimeDelta::FromMicroseconds(100)));
79 processor->Start(); 80 processor->Start();
80 processor->StopSynchronously(); 81 processor->StopSynchronously();
81 } 82 }
82 83
83 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 84 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
84 i::Address frame1, 85 i::Address frame1,
85 i::Address frame2 = NULL, 86 i::Address frame2 = NULL,
86 i::Address frame3 = NULL) { 87 i::Address frame3 = NULL) {
87 v8::TickSample* sample = proc->StartTickSample(); 88 v8::TickSample* sample = proc->StartTickSample();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 i::AbstractCode* aaa_code = CreateCode(&env); 152 i::AbstractCode* aaa_code = CreateCode(&env);
152 i::AbstractCode* comment_code = CreateCode(&env); 153 i::AbstractCode* comment_code = CreateCode(&env);
153 i::AbstractCode* args5_code = CreateCode(&env); 154 i::AbstractCode* args5_code = CreateCode(&env);
154 i::AbstractCode* comment2_code = CreateCode(&env); 155 i::AbstractCode* comment2_code = CreateCode(&env);
155 i::AbstractCode* moved_code = CreateCode(&env); 156 i::AbstractCode* moved_code = CreateCode(&env);
156 i::AbstractCode* args3_code = CreateCode(&env); 157 i::AbstractCode* args3_code = CreateCode(&env);
157 i::AbstractCode* args4_code = CreateCode(&env); 158 i::AbstractCode* args4_code = CreateCode(&env);
158 159
159 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 160 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
160 ProfileGenerator* generator = new ProfileGenerator(profiles); 161 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles);
161 ProfilerEventsProcessor* processor = 162 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
162 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, 163 isolate, generator, v8::base::TimeDelta::FromMicroseconds(100));
163 v8::base::TimeDelta::FromMicroseconds(100));
164 CpuProfiler profiler(isolate, profiles, generator, processor); 164 CpuProfiler profiler(isolate, profiles, generator, processor);
165 profiles->StartProfiling("", false); 165 profiles->StartProfiling("", false);
166 processor->Start(); 166 processor->Start();
167 ProfilerListener profiler_listener(isolate); 167 ProfilerListener profiler_listener(isolate);
168 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 168 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
169 profiler_listener.AddObserver(&profiler); 169 profiler_listener.AddObserver(&profiler);
170 170
171 // Enqueue code creation events. 171 // Enqueue code creation events.
172 const char* aaa_str = "aaa"; 172 const char* aaa_str = "aaa";
173 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str); 173 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 TestSetup test_setup; 219 TestSetup test_setup;
220 LocalContext env; 220 LocalContext env;
221 i::Isolate* isolate = CcTest::i_isolate(); 221 i::Isolate* isolate = CcTest::i_isolate();
222 i::HandleScope scope(isolate); 222 i::HandleScope scope(isolate);
223 223
224 i::AbstractCode* frame1_code = CreateCode(&env); 224 i::AbstractCode* frame1_code = CreateCode(&env);
225 i::AbstractCode* frame2_code = CreateCode(&env); 225 i::AbstractCode* frame2_code = CreateCode(&env);
226 i::AbstractCode* frame3_code = CreateCode(&env); 226 i::AbstractCode* frame3_code = CreateCode(&env);
227 227
228 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 228 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
229 ProfileGenerator* generator = new ProfileGenerator(profiles); 229 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles);
230 ProfilerEventsProcessor* processor = 230 ProfilerEventsProcessor* processor =
231 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, 231 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
232 v8::base::TimeDelta::FromMicroseconds(100)); 232 v8::base::TimeDelta::FromMicroseconds(100));
233 CpuProfiler profiler(isolate, profiles, generator, processor); 233 CpuProfiler profiler(isolate, profiles, generator, processor);
234 profiles->StartProfiling("", false); 234 profiles->StartProfiling("", false);
235 processor->Start(); 235 processor->Start();
236 ProfilerListener profiler_listener(isolate); 236 ProfilerListener profiler_listener(isolate);
237 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 237 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
238 profiler_listener.AddObserver(&profiler); 238 profiler_listener.AddObserver(&profiler);
239 239
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Long stacks (exceeding max frames limit) must not be erased. 292 // Long stacks (exceeding max frames limit) must not be erased.
293 TEST(Issue1398) { 293 TEST(Issue1398) {
294 TestSetup test_setup; 294 TestSetup test_setup;
295 LocalContext env; 295 LocalContext env;
296 i::Isolate* isolate = CcTest::i_isolate(); 296 i::Isolate* isolate = CcTest::i_isolate();
297 i::HandleScope scope(isolate); 297 i::HandleScope scope(isolate);
298 298
299 i::AbstractCode* code = CreateCode(&env); 299 i::AbstractCode* code = CreateCode(&env);
300 300
301 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 301 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
302 ProfileGenerator* generator = new ProfileGenerator(profiles); 302 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles);
303 ProfilerEventsProcessor* processor = 303 ProfilerEventsProcessor* processor =
304 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, 304 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
305 v8::base::TimeDelta::FromMicroseconds(100)); 305 v8::base::TimeDelta::FromMicroseconds(100));
306 CpuProfiler profiler(isolate, profiles, generator, processor); 306 CpuProfiler profiler(isolate, profiles, generator, processor);
307 profiles->StartProfiling("", false); 307 profiles->StartProfiling("", false);
308 processor->Start(); 308 processor->Start();
309 ProfilerListener profiler_listener(isolate); 309 ProfilerListener profiler_listener(isolate);
310 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 310 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
311 profiler_listener.AddObserver(&profiler); 311 profiler_listener.AddObserver(&profiler);
312 312
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 CHECK(func->shared()); 1066 CHECK(func->shared());
1067 CHECK(func->shared()->abstract_code()); 1067 CHECK(func->shared()->abstract_code());
1068 CHECK(!optimize || func->IsOptimized() || 1068 CHECK(!optimize || func->IsOptimized() ||
1069 !CcTest::i_isolate()->use_crankshaft()); 1069 !CcTest::i_isolate()->use_crankshaft());
1070 i::AbstractCode* code = func->abstract_code(); 1070 i::AbstractCode* code = func->abstract_code();
1071 CHECK(code); 1071 CHECK(code);
1072 i::Address code_address = code->instruction_start(); 1072 i::Address code_address = code->instruction_start();
1073 CHECK(code_address); 1073 CHECK(code_address);
1074 1074
1075 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 1075 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
1076 ProfileGenerator* generator = new ProfileGenerator(profiles); 1076 ProfileGenerator* generator = new ProfileGenerator(isolate, profiles);
1077 ProfilerEventsProcessor* processor = 1077 ProfilerEventsProcessor* processor =
1078 new ProfilerEventsProcessor(CcTest::i_isolate(), generator, 1078 new ProfilerEventsProcessor(CcTest::i_isolate(), generator,
1079 v8::base::TimeDelta::FromMicroseconds(100)); 1079 v8::base::TimeDelta::FromMicroseconds(100));
1080 CpuProfiler profiler(isolate, profiles, generator, processor); 1080 CpuProfiler profiler(isolate, profiles, generator, processor);
1081 profiles->StartProfiling("", false); 1081 profiles->StartProfiling("", false);
1082 processor->Start(); 1082 processor->Start();
1083 ProfilerListener profiler_listener(isolate); 1083 ProfilerListener profiler_listener(isolate);
1084 isolate->code_event_dispatcher()->AddListener(&profiler_listener); 1084 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
1085 profiler_listener.AddObserver(&profiler); 1085 profiler_listener.AddObserver(&profiler);
1086 1086
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 printf("Profile JSON: %s\n", profile_json.c_str()); 2170 printf("Profile JSON: %s\n", profile_json.c_str());
2171 std::string code = profile_checker + profile_json + ")"; 2171 std::string code = profile_checker + profile_json + ")";
2172 v8::Local<v8::Value> result = 2172 v8::Local<v8::Value> result =
2173 CompileRunChecked(CcTest::isolate(), code.c_str()); 2173 CompileRunChecked(CcTest::isolate(), code.c_str());
2174 v8::String::Utf8Value value(result); 2174 v8::String::Utf8Value value(result);
2175 printf("Check result: %*s\n", value.length(), *value); 2175 printf("Check result: %*s\n", value.length(), *value);
2176 CHECK_EQ(0, value.length()); 2176 CHECK_EQ(0, value.length());
2177 2177
2178 i::V8::SetPlatformForTesting(old_platform); 2178 i::V8::SetPlatformForTesting(old_platform);
2179 } 2179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698