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

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

Issue 2079273003: Revert of Refactor CpuProfiler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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/v8.gyp ('k') | test/cctest/test-profile-generator.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 15 matching lines...) Expand all
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests of profiles generator and utilities. 28 // Tests of profiles generator and utilities.
29 29
30 #include "src/v8.h" 30 #include "src/v8.h"
31 31
32 #include "include/v8-profiler.h" 32 #include "include/v8-profiler.h"
33 #include "src/base/platform/platform.h" 33 #include "src/base/platform/platform.h"
34 #include "src/deoptimizer.h" 34 #include "src/deoptimizer.h"
35 #include "src/profiler/cpu-profiler-inl.h" 35 #include "src/profiler/cpu-profiler-inl.h"
36 #include "src/profiler/profiler-listener.h"
37 #include "src/utils.h" 36 #include "src/utils.h"
38 #include "test/cctest/cctest.h" 37 #include "test/cctest/cctest.h"
39 #include "test/cctest/profiler-extension.h" 38 #include "test/cctest/profiler-extension.h"
40 39
41 using i::CodeEntry; 40 using i::CodeEntry;
42 using i::CpuProfile; 41 using i::CpuProfile;
43 using i::CpuProfiler; 42 using i::CpuProfiler;
44 using i::CpuProfilesCollection; 43 using i::CpuProfilesCollection;
45 using i::Heap; 44 using i::Heap;
46 using i::ProfileGenerator; 45 using i::ProfileGenerator;
47 using i::ProfileNode; 46 using i::ProfileNode;
48 using i::ProfilerEventsProcessor; 47 using i::ProfilerEventsProcessor;
49 using i::ProfilerListener;
50 using i::ScopedVector; 48 using i::ScopedVector;
51 using i::Vector; 49 using i::Vector;
52 50
53 // Helper methods 51 // Helper methods
54 static v8::Local<v8::Function> GetFunction(v8::Local<v8::Context> env, 52 static v8::Local<v8::Function> GetFunction(v8::Local<v8::Context> env,
55 const char* name) { 53 const char* name) {
56 return v8::Local<v8::Function>::Cast( 54 return v8::Local<v8::Function>::Cast(
57 env->Global()->Get(env, v8_str(name)).ToLocalChecked()); 55 env->Global()->Get(env, v8_str(name)).ToLocalChecked());
58 } 56 }
59 57
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 i::AbstractCode* args3_code = CreateCode(&env); 151 i::AbstractCode* args3_code = CreateCode(&env);
154 i::AbstractCode* args4_code = CreateCode(&env); 152 i::AbstractCode* args4_code = CreateCode(&env);
155 153
156 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 154 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
157 ProfileGenerator* generator = new ProfileGenerator(profiles); 155 ProfileGenerator* generator = new ProfileGenerator(profiles);
158 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 156 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
159 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 157 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100));
160 CpuProfiler profiler(isolate, profiles, generator, processor); 158 CpuProfiler profiler(isolate, profiles, generator, processor);
161 profiles->StartProfiling("", false); 159 profiles->StartProfiling("", false);
162 processor->Start(); 160 processor->Start();
163 ProfilerListener profiler_listener(isolate);
164 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
165 profiler_listener.AddObserver(&profiler);
166 161
167 // Enqueue code creation events. 162 // Enqueue code creation events.
168 const char* aaa_str = "aaa"; 163 const char* aaa_str = "aaa";
169 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str); 164 i::Handle<i::String> aaa_name = factory->NewStringFromAsciiChecked(aaa_str);
170 profiler_listener.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, 165 profiler.CodeCreateEvent(i::CodeEventListener::FUNCTION_TAG, aaa_code,
171 *aaa_name); 166 *aaa_name);
172 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, 167 profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, comment_code,
173 "comment"); 168 "comment");
174 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); 169 profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args5_code, 5);
175 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, 170 profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, comment2_code,
176 "comment2"); 171 "comment2");
177 profiler_listener.CodeMoveEvent(comment2_code, moved_code->address()); 172 profiler.CodeMoveEvent(comment2_code, moved_code->address());
178 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); 173 profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args3_code, 3);
179 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); 174 profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, args4_code, 4);
180 175
181 // Enqueue a tick event to enable code events processing. 176 // Enqueue a tick event to enable code events processing.
182 EnqueueTickSampleEvent(processor, aaa_code->address()); 177 EnqueueTickSampleEvent(processor, aaa_code->address());
183 178
184 profiler_listener.RemoveObserver(&profiler);
185 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
186 processor->StopSynchronously(); 179 processor->StopSynchronously();
187 180
188 // Check the state of profile generator. 181 // Check the state of profile generator.
189 CodeEntry* aaa = generator->code_map()->FindEntry(aaa_code->address()); 182 CodeEntry* aaa = generator->code_map()->FindEntry(aaa_code->address());
190 CHECK(aaa); 183 CHECK(aaa);
191 CHECK_EQ(0, strcmp(aaa_str, aaa->name())); 184 CHECK_EQ(0, strcmp(aaa_str, aaa->name()));
192 185
193 CodeEntry* comment = 186 CodeEntry* comment =
194 generator->code_map()->FindEntry(comment_code->address()); 187 generator->code_map()->FindEntry(comment_code->address());
195 CHECK(comment); 188 CHECK(comment);
(...skipping 25 matching lines...) Expand all
221 i::AbstractCode* frame2_code = CreateCode(&env); 214 i::AbstractCode* frame2_code = CreateCode(&env);
222 i::AbstractCode* frame3_code = CreateCode(&env); 215 i::AbstractCode* frame3_code = CreateCode(&env);
223 216
224 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 217 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
225 ProfileGenerator* generator = new ProfileGenerator(profiles); 218 ProfileGenerator* generator = new ProfileGenerator(profiles);
226 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 219 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
227 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 220 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100));
228 CpuProfiler profiler(isolate, profiles, generator, processor); 221 CpuProfiler profiler(isolate, profiles, generator, processor);
229 profiles->StartProfiling("", false); 222 profiles->StartProfiling("", false);
230 processor->Start(); 223 processor->Start();
231 ProfilerListener profiler_listener(isolate);
232 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
233 profiler_listener.AddObserver(&profiler);
234 224
235 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); 225 profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, frame1_code,
236 profiler_listener.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); 226 "bbb");
237 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); 227 profiler.CodeCreateEvent(i::CodeEventListener::STUB_TAG, frame2_code, 5);
228 profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, frame3_code,
229 "ddd");
238 230
239 EnqueueTickSampleEvent(processor, frame1_code->instruction_start()); 231 EnqueueTickSampleEvent(processor, frame1_code->instruction_start());
240 EnqueueTickSampleEvent( 232 EnqueueTickSampleEvent(
241 processor, 233 processor,
242 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, 234 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2,
243 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); 235 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2);
244 EnqueueTickSampleEvent(processor, frame3_code->instruction_end() - 1, 236 EnqueueTickSampleEvent(processor, frame3_code->instruction_end() - 1,
245 frame2_code->instruction_end() - 1, 237 frame2_code->instruction_end() - 1,
246 frame1_code->instruction_end() - 1); 238 frame1_code->instruction_end() - 1);
247 239
248 profiler_listener.RemoveObserver(&profiler);
249 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
250 processor->StopSynchronously(); 240 processor->StopSynchronously();
251 CpuProfile* profile = profiles->StopProfiling(""); 241 CpuProfile* profile = profiles->StopProfiling("");
252 CHECK(profile); 242 CHECK(profile);
253 243
254 // Check call trees. 244 // Check call trees.
255 const i::List<ProfileNode*>* top_down_root_children = 245 const i::List<ProfileNode*>* top_down_root_children =
256 profile->top_down()->root()->children(); 246 profile->top_down()->root()->children();
257 CHECK_EQ(1, top_down_root_children->length()); 247 CHECK_EQ(1, top_down_root_children->length());
258 CHECK_EQ(0, strcmp("bbb", top_down_root_children->last()->entry()->name())); 248 CHECK_EQ(0, strcmp("bbb", top_down_root_children->last()->entry()->name()));
259 const i::List<ProfileNode*>* top_down_bbb_children = 249 const i::List<ProfileNode*>* top_down_bbb_children =
260 top_down_root_children->last()->children(); 250 top_down_root_children->last()->children();
261 CHECK_EQ(1, top_down_bbb_children->length()); 251 CHECK_EQ(1, top_down_bbb_children->length());
262 CHECK_EQ(0, strcmp("5", top_down_bbb_children->last()->entry()->name())); 252 CHECK_EQ(0, strcmp("5", top_down_bbb_children->last()->entry()->name()));
263 const i::List<ProfileNode*>* top_down_stub_children = 253 const i::List<ProfileNode*>* top_down_stub_children =
264 top_down_bbb_children->last()->children(); 254 top_down_bbb_children->last()->children();
265 CHECK_EQ(1, top_down_stub_children->length()); 255 CHECK_EQ(1, top_down_stub_children->length());
266 CHECK_EQ(0, strcmp("ddd", top_down_stub_children->last()->entry()->name())); 256 CHECK_EQ(0, strcmp("ddd", top_down_stub_children->last()->entry()->name()));
267 const i::List<ProfileNode*>* top_down_ddd_children = 257 const i::List<ProfileNode*>* top_down_ddd_children =
268 top_down_stub_children->last()->children(); 258 top_down_stub_children->last()->children();
269 CHECK_EQ(0, top_down_ddd_children->length()); 259 CHECK_EQ(0, top_down_ddd_children->length());
270
271 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
272 } 260 }
273 261
274 // http://crbug/51594 262 // http://crbug/51594
275 // This test must not crash. 263 // This test must not crash.
276 TEST(CrashIfStoppingLastNonExistentProfile) { 264 TEST(CrashIfStoppingLastNonExistentProfile) {
277 CcTest::InitializeVM(); 265 CcTest::InitializeVM();
278 TestSetup test_setup; 266 TestSetup test_setup;
279 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler(); 267 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
280 profiler->StartProfiling("1"); 268 profiler->StartProfiling("1");
281 profiler->StopProfiling("2"); 269 profiler->StopProfiling("2");
(...skipping 11 matching lines...) Expand all
293 281
294 i::AbstractCode* code = CreateCode(&env); 282 i::AbstractCode* code = CreateCode(&env);
295 283
296 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 284 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
297 ProfileGenerator* generator = new ProfileGenerator(profiles); 285 ProfileGenerator* generator = new ProfileGenerator(profiles);
298 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 286 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
299 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 287 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100));
300 CpuProfiler profiler(isolate, profiles, generator, processor); 288 CpuProfiler profiler(isolate, profiles, generator, processor);
301 profiles->StartProfiling("", false); 289 profiles->StartProfiling("", false);
302 processor->Start(); 290 processor->Start();
303 ProfilerListener profiler_listener(isolate);
304 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
305 profiler_listener.AddObserver(&profiler);
306 291
307 profiler_listener.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 292 profiler.CodeCreateEvent(i::CodeEventListener::BUILTIN_TAG, code, "bbb");
308 293
309 i::TickSample* sample = processor->StartTickSample(); 294 i::TickSample* sample = processor->StartTickSample();
310 sample->pc = code->address(); 295 sample->pc = code->address();
311 sample->tos = 0; 296 sample->tos = 0;
312 sample->frames_count = i::TickSample::kMaxFramesCount; 297 sample->frames_count = i::TickSample::kMaxFramesCount;
313 for (unsigned i = 0; i < sample->frames_count; ++i) { 298 for (unsigned i = 0; i < sample->frames_count; ++i) {
314 sample->stack[i] = code->address(); 299 sample->stack[i] = code->address();
315 } 300 }
316 processor->FinishTickSample(); 301 processor->FinishTickSample();
317 302
318 profiler_listener.RemoveObserver(&profiler);
319 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
320 processor->StopSynchronously(); 303 processor->StopSynchronously();
321 CpuProfile* profile = profiles->StopProfiling(""); 304 CpuProfile* profile = profiles->StopProfiling("");
322 CHECK(profile); 305 CHECK(profile);
323 306
324 unsigned actual_depth = 0; 307 unsigned actual_depth = 0;
325 const ProfileNode* node = profile->top_down()->root(); 308 const ProfileNode* node = profile->top_down()->root();
326 while (node->children()->length() > 0) { 309 while (node->children()->length() > 0) {
327 node = node->children()->last(); 310 node = node->children()->last();
328 ++actual_depth; 311 ++actual_depth;
329 } 312 }
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 i::Address code_address = code->instruction_start(); 1019 i::Address code_address = code->instruction_start();
1037 CHECK(code_address); 1020 CHECK(code_address);
1038 1021
1039 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate); 1022 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate);
1040 ProfileGenerator* generator = new ProfileGenerator(profiles); 1023 ProfileGenerator* generator = new ProfileGenerator(profiles);
1041 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 1024 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
1042 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100)); 1025 generator, nullptr, v8::base::TimeDelta::FromMicroseconds(100));
1043 CpuProfiler profiler(isolate, profiles, generator, processor); 1026 CpuProfiler profiler(isolate, profiles, generator, processor);
1044 profiles->StartProfiling("", false); 1027 profiles->StartProfiling("", false);
1045 processor->Start(); 1028 processor->Start();
1046 ProfilerListener profiler_listener(isolate);
1047 isolate->code_event_dispatcher()->AddListener(&profiler_listener);
1048 profiler_listener.AddObserver(&profiler);
1049 1029
1050 // Enqueue code creation events. 1030 // Enqueue code creation events.
1051 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name); 1031 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name);
1052 int line = 1; 1032 int line = 1;
1053 int column = 1; 1033 int column = 1;
1054 profiler_listener.CodeCreateEvent(i::Logger::FUNCTION_TAG, code, 1034 profiler.CodeCreateEvent(i::CodeEventListener::FUNCTION_TAG, code,
1055 func->shared(), *str, line, column); 1035 func->shared(), *str, line, column);
1056 1036
1057 // Enqueue a tick event to enable code events processing. 1037 // Enqueue a tick event to enable code events processing.
1058 EnqueueTickSampleEvent(processor, code_address); 1038 EnqueueTickSampleEvent(processor, code_address);
1059 1039
1060 profiler_listener.RemoveObserver(&profiler);
1061 isolate->code_event_dispatcher()->RemoveListener(&profiler_listener);
1062 processor->StopSynchronously(); 1040 processor->StopSynchronously();
1063 1041
1064 CpuProfile* profile = profiles->StopProfiling(""); 1042 CpuProfile* profile = profiles->StopProfiling("");
1065 CHECK(profile); 1043 CHECK(profile);
1066 1044
1067 // Check the state of profile generator. 1045 // Check the state of profile generator.
1068 CodeEntry* func_entry = generator->code_map()->FindEntry(code_address); 1046 CodeEntry* func_entry = generator->code_map()->FindEntry(code_address);
1069 CHECK(func_entry); 1047 CHECK(func_entry);
1070 CHECK_EQ(0, strcmp(func_name, func_entry->name())); 1048 CHECK_EQ(0, strcmp(func_name, func_entry->name()));
1071 const i::JITLineInfoTable* line_info = func_entry->line_info(); 1049 const i::JITLineInfoTable* line_info = func_entry->line_info();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 int32_t duration_ms = 100; 1122 int32_t duration_ms = 100;
1145 v8::Local<v8::Value> args[] = { 1123 v8::Local<v8::Value> args[] = {
1146 v8::Integer::New(env->GetIsolate(), duration_ms)}; 1124 v8::Integer::New(env->GetIsolate(), duration_ms)};
1147 v8::CpuProfile* profile = 1125 v8::CpuProfile* profile =
1148 RunProfiler(env.local(), function, args, arraysize(args), 1000); 1126 RunProfiler(env.local(), function, args, arraysize(args), 1000);
1149 1127
1150 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1128 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1151 const v8::CpuProfileNode* start_node = GetChild(env.local(), root, "start"); 1129 const v8::CpuProfileNode* start_node = GetChild(env.local(), root, "start");
1152 GetChild(env.local(), start_node, "bar"); 1130 GetChild(env.local(), start_node, "bar");
1153 1131
1154 const v8::CpuProfileNode* unresolved_node = 1132 const v8::CpuProfileNode* unresolved_node = FindChild(
1155 FindChild(env.local(), root, i::CodeEntry::kUnresolvedFunctionName); 1133 env.local(), root, i::ProfileGenerator::kUnresolvedFunctionName);
1156 CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "call")); 1134 CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "call"));
1157 1135
1158 profile->Delete(); 1136 profile->Delete();
1159 } 1137 }
1160 1138
1161 static const char* function_apply_test_source = 1139 static const char* function_apply_test_source =
1162 "%NeverOptimizeFunction(bar);\n" 1140 "%NeverOptimizeFunction(bar);\n"
1163 "%NeverOptimizeFunction(test);\n" 1141 "%NeverOptimizeFunction(test);\n"
1164 "%NeverOptimizeFunction(start);\n" 1142 "%NeverOptimizeFunction(start);\n"
1165 "function bar(n) {\n" 1143 "function bar(n) {\n"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 1178
1201 v8::CpuProfile* profile = 1179 v8::CpuProfile* profile =
1202 RunProfiler(env.local(), function, args, arraysize(args), 1000); 1180 RunProfiler(env.local(), function, args, arraysize(args), 1000);
1203 1181
1204 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1182 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1205 const v8::CpuProfileNode* start_node = GetChild(env.local(), root, "start"); 1183 const v8::CpuProfileNode* start_node = GetChild(env.local(), root, "start");
1206 const v8::CpuProfileNode* test_node = 1184 const v8::CpuProfileNode* test_node =
1207 GetChild(env.local(), start_node, "test"); 1185 GetChild(env.local(), start_node, "test");
1208 GetChild(env.local(), test_node, "bar"); 1186 GetChild(env.local(), test_node, "bar");
1209 1187
1210 const v8::CpuProfileNode* unresolved_node = 1188 const v8::CpuProfileNode* unresolved_node = FindChild(
1211 FindChild(env.local(), start_node, CodeEntry::kUnresolvedFunctionName); 1189 env.local(), start_node, ProfileGenerator::kUnresolvedFunctionName);
1212 CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "apply")); 1190 CHECK(!unresolved_node || GetChild(env.local(), unresolved_node, "apply"));
1213 1191
1214 profile->Delete(); 1192 profile->Delete();
1215 } 1193 }
1216 1194
1217 static const char* cpu_profiler_deep_stack_test_source = 1195 static const char* cpu_profiler_deep_stack_test_source =
1218 "function foo(n) {\n" 1196 "function foo(n) {\n"
1219 " if (n)\n" 1197 " if (n)\n"
1220 " foo(n - 1);\n" 1198 " foo(n - 1);\n"
1221 " else\n" 1199 " else\n"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 cpu_profiler->SetIdle(false); 1586 cpu_profiler->SetIdle(false);
1609 processor->AddCurrentStack(isolate, true); 1587 processor->AddCurrentStack(isolate, true);
1610 1588
1611 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); 1589 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name);
1612 CHECK(profile); 1590 CHECK(profile);
1613 // Dump collected profile to have a better diagnostic in case of failure. 1591 // Dump collected profile to have a better diagnostic in case of failure.
1614 reinterpret_cast<i::CpuProfile*>(profile)->Print(); 1592 reinterpret_cast<i::CpuProfile*>(profile)->Print();
1615 1593
1616 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1594 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1617 const v8::CpuProfileNode* program_node = 1595 const v8::CpuProfileNode* program_node =
1618 GetChild(env.local(), root, CodeEntry::kProgramEntryName); 1596 GetChild(env.local(), root, ProfileGenerator::kProgramEntryName);
1619 CHECK_EQ(0, program_node->GetChildrenCount()); 1597 CHECK_EQ(0, program_node->GetChildrenCount());
1620 CHECK_GE(program_node->GetHitCount(), 2u); 1598 CHECK_GE(program_node->GetHitCount(), 2u);
1621 1599
1622 const v8::CpuProfileNode* idle_node = 1600 const v8::CpuProfileNode* idle_node =
1623 GetChild(env.local(), root, CodeEntry::kIdleEntryName); 1601 GetChild(env.local(), root, ProfileGenerator::kIdleEntryName);
1624 CHECK_EQ(0, idle_node->GetChildrenCount()); 1602 CHECK_EQ(0, idle_node->GetChildrenCount());
1625 CHECK_GE(idle_node->GetHitCount(), 3u); 1603 CHECK_GE(idle_node->GetHitCount(), 3u);
1626 1604
1627 profile->Delete(); 1605 profile->Delete();
1628 } 1606 }
1629 1607
1630 static void CheckFunctionDetails(v8::Isolate* isolate, 1608 static void CheckFunctionDetails(v8::Isolate* isolate,
1631 const v8::CpuProfileNode* node, 1609 const v8::CpuProfileNode* node,
1632 const char* name, const char* script_name, 1610 const char* name, const char* script_name,
1633 int script_id, int line, int column) { 1611 int script_id, int line, int column) {
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 iprofile->Print(); 2021 iprofile->Print();
2044 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 2022 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
2045 2023
2046 const char* branch[] = {"", "test"}; 2024 const char* branch[] = {"", "test"};
2047 const ProfileNode* itest_node = 2025 const ProfileNode* itest_node =
2048 GetSimpleBranch(env, profile, branch, arraysize(branch)); 2026 GetSimpleBranch(env, profile, branch, arraysize(branch));
2049 CHECK_EQ(0U, itest_node->deopt_infos().size()); 2027 CHECK_EQ(0U, itest_node->deopt_infos().size());
2050 2028
2051 iprofiler->DeleteProfile(iprofile); 2029 iprofiler->DeleteProfile(iprofile);
2052 } 2030 }
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698