| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 using i::ScopedVector; | 46 using i::ScopedVector; |
| 47 using i::TokenEnumerator; | 47 using i::TokenEnumerator; |
| 48 using i::Vector; | 48 using i::Vector; |
| 49 | 49 |
| 50 | 50 |
| 51 TEST(StartStop) { | 51 TEST(StartStop) { |
| 52 CpuProfilesCollection profiles; | 52 CpuProfilesCollection profiles; |
| 53 ProfileGenerator generator(&profiles); | 53 ProfileGenerator generator(&profiles); |
| 54 ProfilerEventsProcessor processor(&generator); | 54 ProfilerEventsProcessor processor(&generator); |
| 55 processor.Start(); | 55 processor.Start(); |
| 56 processor.Stop(); | 56 processor.StopSynchronously(); |
| 57 processor.Join(); | 57 processor.Join(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 static inline i::Address ToAddress(int n) { | 61 static inline i::Address ToAddress(int n) { |
| 62 return reinterpret_cast<i::Address>(n); | 62 return reinterpret_cast<i::Address>(n); |
| 63 } | 63 } |
| 64 | 64 |
| 65 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, | 65 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, |
| 66 i::Address frame1, | 66 i::Address frame1, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); | 154 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); |
| 155 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); | 155 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); |
| 156 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); | 156 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); |
| 157 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); | 157 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); |
| 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); | 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); |
| 159 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); | 159 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); |
| 160 | 160 |
| 161 // Enqueue a tick event to enable code events processing. | 161 // Enqueue a tick event to enable code events processing. |
| 162 EnqueueTickSampleEvent(&processor, aaa_code->address()); | 162 EnqueueTickSampleEvent(&processor, aaa_code->address()); |
| 163 | 163 |
| 164 processor.Stop(); | 164 processor.StopSynchronously(); |
| 165 processor.Join(); | 165 processor.Join(); |
| 166 | 166 |
| 167 // Check the state of profile generator. | 167 // Check the state of profile generator. |
| 168 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); | 168 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); |
| 169 CHECK_NE(NULL, aaa); | 169 CHECK_NE(NULL, aaa); |
| 170 CHECK_EQ(aaa_str, aaa->name()); | 170 CHECK_EQ(aaa_str, aaa->name()); |
| 171 | 171 |
| 172 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); | 172 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); |
| 173 CHECK_NE(NULL, comment); | 173 CHECK_NE(NULL, comment); |
| 174 CHECK_EQ("comment", comment->name()); | 174 CHECK_EQ("comment", comment->name()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 EnqueueTickSampleEvent( | 216 EnqueueTickSampleEvent( |
| 217 &processor, | 217 &processor, |
| 218 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, | 218 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, |
| 219 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); | 219 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); |
| 220 EnqueueTickSampleEvent( | 220 EnqueueTickSampleEvent( |
| 221 &processor, | 221 &processor, |
| 222 frame3_code->instruction_end() - 1, | 222 frame3_code->instruction_end() - 1, |
| 223 frame2_code->instruction_end() - 1, | 223 frame2_code->instruction_end() - 1, |
| 224 frame1_code->instruction_end() - 1); | 224 frame1_code->instruction_end() - 1); |
| 225 | 225 |
| 226 processor.Stop(); | 226 processor.StopSynchronously(); |
| 227 processor.Join(); | 227 processor.Join(); |
| 228 CpuProfile* profile = | 228 CpuProfile* profile = |
| 229 profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); | 229 profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 230 CHECK_NE(NULL, profile); | 230 CHECK_NE(NULL, profile); |
| 231 | 231 |
| 232 // Check call trees. | 232 // Check call trees. |
| 233 const i::List<ProfileNode*>* top_down_root_children = | 233 const i::List<ProfileNode*>* top_down_root_children = |
| 234 profile->top_down()->root()->children(); | 234 profile->top_down()->root()->children(); |
| 235 CHECK_EQ(1, top_down_root_children->length()); | 235 CHECK_EQ(1, top_down_root_children->length()); |
| 236 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); | 236 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); | 281 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); |
| 282 | 282 |
| 283 i::TickSample* sample = processor.TickSampleEvent(); | 283 i::TickSample* sample = processor.TickSampleEvent(); |
| 284 sample->pc = code->address(); | 284 sample->pc = code->address(); |
| 285 sample->tos = 0; | 285 sample->tos = 0; |
| 286 sample->frames_count = i::TickSample::kMaxFramesCount; | 286 sample->frames_count = i::TickSample::kMaxFramesCount; |
| 287 for (int i = 0; i < sample->frames_count; ++i) { | 287 for (int i = 0; i < sample->frames_count; ++i) { |
| 288 sample->stack[i] = code->address(); | 288 sample->stack[i] = code->address(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 processor.Stop(); | 291 processor.StopSynchronously(); |
| 292 processor.Join(); | 292 processor.Join(); |
| 293 CpuProfile* profile = | 293 CpuProfile* profile = |
| 294 profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); | 294 profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 295 CHECK_NE(NULL, profile); | 295 CHECK_NE(NULL, profile); |
| 296 | 296 |
| 297 int actual_depth = 0; | 297 int actual_depth = 0; |
| 298 const ProfileNode* node = profile->top_down()->root(); | 298 const ProfileNode* node = profile->top_down()->root(); |
| 299 while (node->children()->length() > 0) { | 299 while (node->children()->length() > 0) { |
| 300 node = node->children()->last(); | 300 node = node->children()->last(); |
| 301 ++actual_depth; | 301 ++actual_depth; |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 FindChild(startNode, ProfileGenerator::kUnresolvedFunctionName)) { | 1197 FindChild(startNode, ProfileGenerator::kUnresolvedFunctionName)) { |
| 1198 ScopedVector<v8::Handle<v8::String> > names(1); | 1198 ScopedVector<v8::Handle<v8::String> > names(1); |
| 1199 names[0] = v8::String::New("apply"); | 1199 names[0] = v8::String::New("apply"); |
| 1200 CheckChildrenNames(unresolvedNode, names); | 1200 CheckChildrenNames(unresolvedNode, names); |
| 1201 GetChild(unresolvedNode, "apply"); | 1201 GetChild(unresolvedNode, "apply"); |
| 1202 } | 1202 } |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 cpu_profiler->DeleteAllCpuProfiles(); | 1205 cpu_profiler->DeleteAllCpuProfiles(); |
| 1206 } | 1206 } |
| OLD | NEW |