OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Tests the sampling API in include/v8.h | 5 // Tests the sampling API in include/v8.h |
6 | 6 |
7 // TODO(mythria): Remove this define after this flag is turned on globally | 7 // TODO(mythria): Remove this define after this flag is turned on globally |
8 #define V8_IMMINENT_DEPRECATION_WARNINGS | 8 #define V8_IMMINENT_DEPRECATION_WARNINGS |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 public: | 87 public: |
88 struct CodeEventEntry { | 88 struct CodeEventEntry { |
89 std::string name; | 89 std::string name; |
90 const void* code_start; | 90 const void* code_start; |
91 size_t code_len; | 91 size_t code_len; |
92 }; | 92 }; |
93 typedef std::map<const void*, CodeEventEntry> CodeEntries; | 93 typedef std::map<const void*, CodeEventEntry> CodeEntries; |
94 | 94 |
95 explicit SamplingTestHelper(const std::string& test_function) | 95 explicit SamplingTestHelper(const std::string& test_function) |
96 : sample_is_taken_(false), isolate_(CcTest::isolate()) { | 96 : sample_is_taken_(false), isolate_(CcTest::isolate()) { |
97 DCHECK(!instance_); | 97 CHECK(!instance_); |
98 instance_ = this; | 98 instance_ = this; |
99 v8::HandleScope scope(isolate_); | 99 v8::HandleScope scope(isolate_); |
100 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); | 100 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate_); |
101 global->Set(v8_str("CollectSample"), | 101 global->Set(v8_str("CollectSample"), |
102 v8::FunctionTemplate::New(isolate_, CollectSample)); | 102 v8::FunctionTemplate::New(isolate_, CollectSample)); |
103 LocalContext env(isolate_, NULL, global); | 103 LocalContext env(isolate_, NULL, global); |
104 isolate_->SetJitCodeEventHandler(v8::kJitCodeEventDefault, | 104 isolate_->SetJitCodeEventHandler(v8::kJitCodeEventDefault, |
105 JitCodeEventHandler); | 105 JitCodeEventHandler); |
106 CompileRun(v8_str(test_function.c_str())); | 106 CompileRun(v8_str(test_function.c_str())); |
107 } | 107 } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 const SamplingTestHelper::CodeEventEntry* entry; | 246 const SamplingTestHelper::CodeEventEntry* entry; |
247 entry = helper.FindEventEntry(sample.begin()[0]); | 247 entry = helper.FindEventEntry(sample.begin()[0]); |
248 CHECK(entry); | 248 CHECK(entry); |
249 CHECK(std::string::npos != entry->name.find("test_sampler_api_inner")); | 249 CHECK(std::string::npos != entry->name.find("test_sampler_api_inner")); |
250 | 250 |
251 entry = helper.FindEventEntry(sample.begin()[1]); | 251 entry = helper.FindEventEntry(sample.begin()[1]); |
252 CHECK(entry); | 252 CHECK(entry); |
253 CHECK(std::string::npos != entry->name.find("test_sampler_api_outer")); | 253 CHECK(std::string::npos != entry->name.find("test_sampler_api_outer")); |
254 } | 254 } |
OLD | NEW |