| 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 #include "v8.h" | 5 #include "v8.h" |
| 6 #include "cpu-profiler-inl.h" | 6 #include "cpu-profiler-inl.h" |
| 7 #include "cctest.h" | 7 #include "cctest.h" |
| 8 | 8 |
| 9 namespace i = v8::internal; | 9 namespace i = v8::internal; |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 TEST(CodeEvents) { | 60 TEST(CodeEvents) { |
| 61 InitializeVM(); | 61 InitializeVM(); |
| 62 CpuProfilesCollection profiles; | 62 CpuProfilesCollection profiles; |
| 63 profiles.AddProfile(0); | 63 profiles.AddProfile(0); |
| 64 ProfileGenerator generator(&profiles); | 64 ProfileGenerator generator(&profiles); |
| 65 ProfilerEventsProcessor processor(&generator); | 65 ProfilerEventsProcessor processor(&generator); |
| 66 processor.Start(); | 66 processor.Start(); |
| 67 processor.SetUpSamplesProducer(); | |
| 68 while (!processor.running()) { | 67 while (!processor.running()) { |
| 69 i::Thread::YieldCPU(); | 68 i::Thread::YieldCPU(); |
| 70 } | 69 } |
| 71 | 70 |
| 72 // Enqueue code creation events. | 71 // Enqueue code creation events. |
| 73 i::HandleScope scope; | 72 i::HandleScope scope; |
| 74 const char* aaa_str = "aaa"; | 73 const char* aaa_str = "aaa"; |
| 75 i::Handle<i::String> aaa_name = i::Factory::NewStringFromAscii( | 74 i::Handle<i::String> aaa_name = i::Factory::NewStringFromAscii( |
| 76 i::Vector<const char>(aaa_str, strlen(aaa_str))); | 75 i::Vector<const char>(aaa_str, strlen(aaa_str))); |
| 77 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, | 76 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 CHECK_NE(NULL, entry3); | 109 CHECK_NE(NULL, entry3); |
| 111 CHECK_EQ("args_count: 5", entry3->name()); | 110 CHECK_EQ("args_count: 5", entry3->name()); |
| 112 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1400))); | 111 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1400))); |
| 113 CodeEntry* entry4 = generator.code_map()->FindEntry(ToAddress(0x1500)); | 112 CodeEntry* entry4 = generator.code_map()->FindEntry(ToAddress(0x1500)); |
| 114 CHECK_NE(NULL, entry4); | 113 CHECK_NE(NULL, entry4); |
| 115 CHECK_EQ("ddd", entry4->name()); | 114 CHECK_EQ("ddd", entry4->name()); |
| 116 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1600))); | 115 CHECK_EQ(NULL, generator.code_map()->FindEntry(ToAddress(0x1600))); |
| 117 CodeEntry* entry5 = generator.code_map()->FindEntry(ToAddress(0x1700)); | 116 CodeEntry* entry5 = generator.code_map()->FindEntry(ToAddress(0x1700)); |
| 118 CHECK_NE(NULL, entry5); | 117 CHECK_NE(NULL, entry5); |
| 119 CHECK_EQ(aaa_str, entry5->name()); | 118 CHECK_EQ(aaa_str, entry5->name()); |
| 120 | |
| 121 processor.TearDownSamplesProducer(); | |
| 122 } | 119 } |
| 123 | 120 |
| 124 | 121 |
| 125 template<typename T> | 122 template<typename T> |
| 126 static int CompareProfileNodes(const T* p1, const T* p2) { | 123 static int CompareProfileNodes(const T* p1, const T* p2) { |
| 127 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); | 124 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); |
| 128 } | 125 } |
| 129 | 126 |
| 130 TEST(TickEvents) { | 127 TEST(TickEvents) { |
| 131 CpuProfilesCollection profiles; | 128 CpuProfilesCollection profiles; |
| 132 profiles.AddProfile(0); | 129 profiles.AddProfile(0); |
| 133 ProfileGenerator generator(&profiles); | 130 ProfileGenerator generator(&profiles); |
| 134 ProfilerEventsProcessor processor(&generator); | 131 ProfilerEventsProcessor processor(&generator); |
| 135 processor.Start(); | 132 processor.Start(); |
| 136 processor.SetUpSamplesProducer(); | |
| 137 while (!processor.running()) { | 133 while (!processor.running()) { |
| 138 i::Thread::YieldCPU(); | 134 i::Thread::YieldCPU(); |
| 139 } | 135 } |
| 140 | 136 |
| 141 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, | 137 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, |
| 142 "bbb", | 138 "bbb", |
| 143 ToAddress(0x1200), | 139 ToAddress(0x1200), |
| 144 0x80); | 140 0x80); |
| 145 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); | 141 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); |
| 146 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, | 142 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 bottom_up_root_children[1]->GetChildren(&bottom_up_bbb_children); | 186 bottom_up_root_children[1]->GetChildren(&bottom_up_bbb_children); |
| 191 CHECK_EQ(0, bottom_up_bbb_children.length()); | 187 CHECK_EQ(0, bottom_up_bbb_children.length()); |
| 192 i::List<ProfileNode*> bottom_up_ddd_children; | 188 i::List<ProfileNode*> bottom_up_ddd_children; |
| 193 bottom_up_root_children[2]->GetChildren(&bottom_up_ddd_children); | 189 bottom_up_root_children[2]->GetChildren(&bottom_up_ddd_children); |
| 194 CHECK_EQ(1, bottom_up_ddd_children.length()); | 190 CHECK_EQ(1, bottom_up_ddd_children.length()); |
| 195 CHECK_EQ("args_count: 5", bottom_up_ddd_children.last()->entry()->name()); | 191 CHECK_EQ("args_count: 5", bottom_up_ddd_children.last()->entry()->name()); |
| 196 i::List<ProfileNode*> bottom_up_ddd_stub_children; | 192 i::List<ProfileNode*> bottom_up_ddd_stub_children; |
| 197 bottom_up_ddd_children.last()->GetChildren(&bottom_up_ddd_stub_children); | 193 bottom_up_ddd_children.last()->GetChildren(&bottom_up_ddd_stub_children); |
| 198 CHECK_EQ(1, bottom_up_ddd_stub_children.length()); | 194 CHECK_EQ(1, bottom_up_ddd_stub_children.length()); |
| 199 CHECK_EQ("bbb", bottom_up_ddd_stub_children.last()->entry()->name()); | 195 CHECK_EQ("bbb", bottom_up_ddd_stub_children.last()->entry()->name()); |
| 200 | |
| 201 processor.TearDownSamplesProducer(); | |
| 202 } | 196 } |
| OLD | NEW |