| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 // Tests of sampler functionalities. | 4 // Tests of sampler functionalities. |
| 5 | 5 |
| 6 #include "src/libsampler/sampler.h" | 6 #include "src/libsampler/sampler.h" |
| 7 | 7 |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 private: | 34 private: |
| 35 Sampler* sampler_; | 35 Sampler* sampler_; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 | 38 |
| 39 class TestSampler : public Sampler { | 39 class TestSampler : public Sampler { |
| 40 public: | 40 public: |
| 41 explicit TestSampler(Isolate* isolate) : Sampler(isolate) {} | 41 explicit TestSampler(Isolate* isolate) : Sampler(isolate) {} |
| 42 | 42 |
| 43 void SampleStack(const v8::RegisterState& regs) override { | 43 void SampleStack(const v8::RegisterState& regs) override { |
| 44 void* frames[Sampler::kMaxFramesCount]; | 44 void* frames[kMaxFramesCount]; |
| 45 SampleInfo sample_info; | 45 SampleInfo sample_info; |
| 46 isolate()->GetStackSample(regs, reinterpret_cast<void**>(frames), | 46 isolate()->GetStackSample(regs, frames, kMaxFramesCount, &sample_info); |
| 47 Sampler::kMaxFramesCount, &sample_info); | |
| 48 if (is_counting_samples_) { | 47 if (is_counting_samples_) { |
| 49 if (sample_info.vm_state == JS) ++js_sample_count_; | 48 if (sample_info.vm_state == JS) ++js_sample_count_; |
| 50 if (sample_info.vm_state == EXTERNAL) ++external_sample_count_; | 49 if (sample_info.vm_state == EXTERNAL) ++external_sample_count_; |
| 51 } | 50 } |
| 52 } | 51 } |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 | 54 |
| 56 class TestApiCallbacks { | 55 class TestApiCallbacks { |
| 57 public: | 56 public: |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 CompileRun(sampler_test_source); | 131 CompileRun(sampler_test_source); |
| 133 v8::Local<v8::Function> function = GetFunction(env.local(), "start"); | 132 v8::Local<v8::Function> function = GetFunction(env.local(), "start"); |
| 134 | 133 |
| 135 int32_t repeat_count = 100; | 134 int32_t repeat_count = 100; |
| 136 v8::Local<v8::Value> args[] = {v8::Integer::New(isolate, repeat_count)}; | 135 v8::Local<v8::Value> args[] = {v8::Integer::New(isolate, repeat_count)}; |
| 137 RunSampler(env.local(), function, args, arraysize(args), 100, 100); | 136 RunSampler(env.local(), function, args, arraysize(args), 100, 100); |
| 138 } | 137 } |
| 139 | 138 |
| 140 } // namespace sampler | 139 } // namespace sampler |
| 141 } // namespace v8 | 140 } // namespace v8 |
| OLD | NEW |