| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 #include "cpu-profiler-inl.h" | 8 #include "cpu-profiler-inl.h" |
| 9 #include "cctest.h" | 9 #include "cctest.h" |
| 10 | 10 |
| 11 namespace i = v8::internal; | 11 namespace i = v8::internal; |
| 12 | 12 |
| 13 using i::CodeEntry; | 13 using i::CodeEntry; |
| 14 using i::CpuProfile; | 14 using i::CpuProfile; |
| 15 using i::CpuProfilesCollection; | 15 using i::CpuProfilesCollection; |
| 16 using i::ProfileGenerator; | 16 using i::ProfileGenerator; |
| 17 using i::ProfileNode; | 17 using i::ProfileNode; |
| 18 using i::ProfilerEventsProcessor; | 18 using i::ProfilerEventsProcessor; |
| 19 using i::TokenEnumerator; |
| 19 | 20 |
| 20 | 21 |
| 21 TEST(StartStop) { | 22 TEST(StartStop) { |
| 22 CpuProfilesCollection profiles; | 23 CpuProfilesCollection profiles; |
| 23 ProfileGenerator generator(&profiles); | 24 ProfileGenerator generator(&profiles); |
| 24 ProfilerEventsProcessor processor(&generator); | 25 ProfilerEventsProcessor processor(&generator); |
| 25 processor.Start(); | 26 processor.Start(); |
| 26 while (!processor.running()) { | 27 while (!processor.running()) { |
| 27 i::Thread::YieldCPU(); | 28 i::Thread::YieldCPU(); |
| 28 } | 29 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 0x80); | 109 0x80); |
| 109 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); | 110 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); |
| 110 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, | 111 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, |
| 111 "ddd", | 112 "ddd", |
| 112 ToAddress(0x1400), | 113 ToAddress(0x1400), |
| 113 0x80); | 114 0x80); |
| 114 processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500)); | 115 processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500)); |
| 115 processor.CodeCreateEvent(i::Logger::STUB_TAG, 3, ToAddress(0x1600), 0x10); | 116 processor.CodeCreateEvent(i::Logger::STUB_TAG, 3, ToAddress(0x1600), 0x10); |
| 116 processor.CodeDeleteEvent(ToAddress(0x1600)); | 117 processor.CodeDeleteEvent(ToAddress(0x1600)); |
| 117 processor.FunctionCreateEvent(ToAddress(0x1700), ToAddress(0x1000), | 118 processor.FunctionCreateEvent(ToAddress(0x1700), ToAddress(0x1000), |
| 118 CodeEntry::kNoSecurityToken); | 119 TokenEnumerator::kNoSecurityToken); |
| 119 // Enqueue a tick event to enable code events processing. | 120 // Enqueue a tick event to enable code events processing. |
| 120 EnqueueTickSampleEvent(&processor, ToAddress(0x1000)); | 121 EnqueueTickSampleEvent(&processor, ToAddress(0x1000)); |
| 121 | 122 |
| 122 processor.Stop(); | 123 processor.Stop(); |
| 123 processor.Join(); | 124 processor.Join(); |
| 124 | 125 |
| 125 // Check the state of profile generator. | 126 // Check the state of profile generator. |
| 126 CodeEntry* entry1 = generator.code_map()->FindEntry(ToAddress(0x1000)); | 127 CodeEntry* entry1 = generator.code_map()->FindEntry(ToAddress(0x1000)); |
| 127 CHECK_NE(NULL, entry1); | 128 CHECK_NE(NULL, entry1); |
| 128 CHECK_EQ(aaa_str, entry1->name()); | 129 CHECK_EQ(aaa_str, entry1->name()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 EnqueueTickSampleEvent(&processor, ToAddress(0x1210)); | 172 EnqueueTickSampleEvent(&processor, ToAddress(0x1210)); |
| 172 EnqueueTickSampleEvent(&processor, ToAddress(0x1305), ToAddress(0x1220)); | 173 EnqueueTickSampleEvent(&processor, ToAddress(0x1305), ToAddress(0x1220)); |
| 173 EnqueueTickSampleEvent(&processor, | 174 EnqueueTickSampleEvent(&processor, |
| 174 ToAddress(0x1404), | 175 ToAddress(0x1404), |
| 175 ToAddress(0x1305), | 176 ToAddress(0x1305), |
| 176 ToAddress(0x1230)); | 177 ToAddress(0x1230)); |
| 177 | 178 |
| 178 processor.Stop(); | 179 processor.Stop(); |
| 179 processor.Join(); | 180 processor.Join(); |
| 180 CpuProfile* profile = | 181 CpuProfile* profile = |
| 181 profiles.StopProfiling(CodeEntry::kNoSecurityToken, "", 1); | 182 profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1); |
| 182 CHECK_NE(NULL, profile); | 183 CHECK_NE(NULL, profile); |
| 183 | 184 |
| 184 // Check call trees. | 185 // Check call trees. |
| 185 const i::List<ProfileNode*>* top_down_root_children = | 186 const i::List<ProfileNode*>* top_down_root_children = |
| 186 profile->top_down()->root()->children(); | 187 profile->top_down()->root()->children(); |
| 187 CHECK_EQ(1, top_down_root_children->length()); | 188 CHECK_EQ(1, top_down_root_children->length()); |
| 188 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); | 189 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); |
| 189 const i::List<ProfileNode*>* top_down_bbb_children = | 190 const i::List<ProfileNode*>* top_down_bbb_children = |
| 190 top_down_root_children->last()->children(); | 191 top_down_root_children->last()->children(); |
| 191 CHECK_EQ(1, top_down_bbb_children->length()); | 192 CHECK_EQ(1, top_down_bbb_children->length()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 218 bottom_up_root_children[2]->children(); | 219 bottom_up_root_children[2]->children(); |
| 219 CHECK_EQ(1, bottom_up_ddd_children->length()); | 220 CHECK_EQ(1, bottom_up_ddd_children->length()); |
| 220 CHECK_EQ("5", bottom_up_ddd_children->last()->entry()->name()); | 221 CHECK_EQ("5", bottom_up_ddd_children->last()->entry()->name()); |
| 221 const i::List<ProfileNode*>* bottom_up_ddd_stub_children = | 222 const i::List<ProfileNode*>* bottom_up_ddd_stub_children = |
| 222 bottom_up_ddd_children->last()->children(); | 223 bottom_up_ddd_children->last()->children(); |
| 223 CHECK_EQ(1, bottom_up_ddd_stub_children->length()); | 224 CHECK_EQ(1, bottom_up_ddd_stub_children->length()); |
| 224 CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name()); | 225 CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name()); |
| 225 } | 226 } |
| 226 | 227 |
| 227 #endif // ENABLE_LOGGING_AND_PROFILING | 228 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |