OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_PROFILER_SAMPLER_H_ | 5 #ifndef V8_PROFILER_SAMPLER_H_ |
6 #define V8_PROFILER_SAMPLER_H_ | 6 #define V8_PROFILER_SAMPLER_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 | 9 |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
11 #include "src/base/platform/time.h" | 11 #include "src/base/platform/time.h" |
12 #include "src/frames.h" | 12 #include "src/frames.h" |
13 #include "src/globals.h" | 13 #include "src/globals.h" |
14 #include "src/simulator.h" | |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 | 18 |
18 class Isolate; | 19 class Isolate; |
19 | 20 |
20 // ---------------------------------------------------------------------------- | 21 // ---------------------------------------------------------------------------- |
21 // Sampler | 22 // Sampler |
22 // | 23 // |
23 // A sampler periodically samples the state of the VM and optionally | 24 // A sampler periodically samples the state of the VM and optionally |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 base::Atomic32 registered_; | 135 base::Atomic32 registered_; |
135 PlatformData* data_; // Platform specific data. | 136 PlatformData* data_; // Platform specific data. |
136 // Counts stack samples taken in various VM states. | 137 // Counts stack samples taken in various VM states. |
137 bool is_counting_samples_; | 138 bool is_counting_samples_; |
138 unsigned js_sample_count_; | 139 unsigned js_sample_count_; |
139 unsigned external_sample_count_; | 140 unsigned external_sample_count_; |
140 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 141 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
141 }; | 142 }; |
142 | 143 |
143 | 144 |
145 #if defined(USE_SIMULATOR) | |
146 class SimulatorHelper : AllStatic { | |
147 public: | |
148 inline static bool FillRegisters(Isolate* isolate, v8::RegisterState* state) { | |
alph
2016/04/29 18:55:06
Please don't put such a big function definition in
lpy
2016/04/29 19:51:58
Done.
| |
149 Simulator *simulator = isolate->thread_local_top()->simulator_; | |
150 // Check if there is active simulator. | |
151 if (simulator == NULL) return false; | |
152 #if V8_TARGET_ARCH_ARM | |
153 if (!simulator->has_bad_pc()) { | |
154 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | |
155 } | |
156 state->sp = reinterpret_cast<Address>(simulator->get_register( | |
157 Simulator::sp)); | |
158 state->fp = reinterpret_cast<Address>(simulator->get_register( | |
159 Simulator::r11)); | |
160 #elif V8_TARGET_ARCH_ARM64 | |
161 if (simulator->sp() == 0 || simulator->fp() == 0) { | |
162 // It's possible that the simulator is interrupted while it is updating | |
163 // the sp or fp register. ARM64 simulator does this in two steps: | |
164 // first setting it to zero and then setting it to a new value. | |
165 // Bailout if sp/fp doesn't contain the new value. | |
166 // | |
167 // FIXME: The above doesn't really solve the issue. | |
168 // If a 64-bit target is executed on a 32-bit host even the final | |
169 // write is non-atomic, so it might obtain a half of the result. | |
170 // Moreover as long as the register set code uses memcpy (as of now), | |
171 // it is not guaranteed to be atomic even when both host and target | |
172 // are of same bitness. | |
173 return true; | |
174 } | |
175 state->pc = reinterpret_cast<Address>(simulator->pc()); | |
176 state->sp = reinterpret_cast<Address>(simulator->sp()); | |
177 state->fp = reinterpret_cast<Address>(simulator->fp()); | |
178 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | |
179 if (!simulator->has_bad_pc()) { | |
180 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | |
181 } | |
182 state->sp = reinterpret_cast<Address>(simulator->get_register( | |
183 Simulator::sp)); | |
184 state->fp = reinterpret_cast<Address>(simulator->get_register( | |
185 Simulator::fp)); | |
186 #elif V8_TARGET_ARCH_PPC | |
187 if (!simulator->has_bad_pc()) { | |
188 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | |
189 } | |
190 state->sp = | |
191 reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | |
192 state->fp = | |
193 reinterpret_cast<Address>(simulator->get_register(Simulator::fp)); | |
194 #elif V8_TARGET_ARCH_S390 | |
195 if (!simulator->has_bad_pc()) { | |
196 state->pc = reinterpret_cast<Address>(simulator->get_pc()); | |
197 } | |
198 state->sp = | |
199 reinterpret_cast<Address>(simulator->get_register(Simulator::sp)); | |
200 state->fp = | |
201 reinterpret_cast<Address>(simulator->get_register(Simulator::fp)); | |
202 #endif | |
203 return true; | |
204 } | |
205 }; | |
206 #endif // USE_SIMULATOR | |
207 | |
208 | |
144 } // namespace internal | 209 } // namespace internal |
145 } // namespace v8 | 210 } // namespace v8 |
146 | 211 |
147 #endif // V8_PROFILER_SAMPLER_H_ | 212 #endif // V8_PROFILER_SAMPLER_H_ |
OLD | NEW |