Index: src/profiler/sampler.cc |
diff --git a/src/profiler/sampler.cc b/src/profiler/sampler.cc |
index 2d3b1283404562b47fdaa1cc8263fc858fd50b2e..e6b7e2753d15325dee867aafb7a6f1fcb301f16b 100644 |
--- a/src/profiler/sampler.cc |
+++ b/src/profiler/sampler.cc |
@@ -48,7 +48,6 @@ |
#include "src/frames-inl.h" |
#include "src/log.h" |
#include "src/profiler/cpu-profiler-inl.h" |
-#include "src/simulator.h" |
#include "src/v8threads.h" |
#include "src/vm-state-inl.h" |
@@ -331,75 +330,6 @@ class Sampler::PlatformData : public PlatformDataCommon { |
#endif |
-#if defined(USE_SIMULATOR) |
-class SimulatorHelper { |
- public: |
- inline bool Init(Isolate* isolate) { |
- simulator_ = isolate->thread_local_top()->simulator_; |
- // Check if there is active simulator. |
- return simulator_ != NULL; |
- } |
- |
- inline void FillRegisters(v8::RegisterState* state) { |
-#if V8_TARGET_ARCH_ARM |
- if (!simulator_->has_bad_pc()) { |
- state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
- } |
- state->sp = reinterpret_cast<Address>(simulator_->get_register( |
- Simulator::sp)); |
- state->fp = reinterpret_cast<Address>(simulator_->get_register( |
- Simulator::r11)); |
-#elif V8_TARGET_ARCH_ARM64 |
- if (simulator_->sp() == 0 || simulator_->fp() == 0) { |
- // It's possible that the simulator is interrupted while it is updating |
- // the sp or fp register. ARM64 simulator does this in two steps: |
- // first setting it to zero and then setting it to a new value. |
- // Bailout if sp/fp doesn't contain the new value. |
- // |
- // FIXME: The above doesn't really solve the issue. |
- // If a 64-bit target is executed on a 32-bit host even the final |
- // write is non-atomic, so it might obtain a half of the result. |
- // Moreover as long as the register set code uses memcpy (as of now), |
- // it is not guaranteed to be atomic even when both host and target |
- // are of same bitness. |
- return; |
- } |
- state->pc = reinterpret_cast<Address>(simulator_->pc()); |
- state->sp = reinterpret_cast<Address>(simulator_->sp()); |
- state->fp = reinterpret_cast<Address>(simulator_->fp()); |
-#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
- if (!simulator_->has_bad_pc()) { |
- state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
- } |
- state->sp = reinterpret_cast<Address>(simulator_->get_register( |
- Simulator::sp)); |
- state->fp = reinterpret_cast<Address>(simulator_->get_register( |
- Simulator::fp)); |
-#elif V8_TARGET_ARCH_PPC |
- if (!simulator_->has_bad_pc()) { |
- state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
- } |
- state->sp = |
- reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); |
- state->fp = |
- reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); |
-#elif V8_TARGET_ARCH_S390 |
- if (!simulator_->has_bad_pc()) { |
- state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
- } |
- state->sp = |
- reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); |
- state->fp = |
- reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); |
-#endif |
- } |
- |
- private: |
- Simulator* simulator_; |
-}; |
-#endif // USE_SIMULATOR |
- |
- |
#if defined(USE_SIGNALS) |
class SignalHandler : public AllStatic { |
@@ -487,9 +417,7 @@ void SignalHandler::CollectSample(void* context, Sampler* sampler) { |
v8::RegisterState state; |
#if defined(USE_SIMULATOR) |
- SimulatorHelper helper; |
- if (!helper.Init(isolate)) return; |
- helper.FillRegisters(&state); |
+ if (!SimulatorHelper::FillRegisters(isolate, &state)) return; |
// It possible that the simulator is interrupted while it is updating |
// the sp or fp register. ARM64 simulator does this in two steps: |
// first setting it to zero and then setting it to the new value. |
@@ -1023,11 +951,6 @@ void Sampler::DoSample() { |
HANDLE profiled_thread = platform_data()->profiled_thread(); |
if (profiled_thread == NULL) return; |
-#if defined(USE_SIMULATOR) |
- SimulatorHelper helper; |
- if (!helper.Init(isolate())) return; |
-#endif |
- |
const DWORD kSuspendFailed = static_cast<DWORD>(-1); |
if (SuspendThread(profiled_thread) == kSuspendFailed) return; |
@@ -1038,7 +961,7 @@ void Sampler::DoSample() { |
if (GetThreadContext(profiled_thread, &context) != 0) { |
v8::RegisterState state; |
#if defined(USE_SIMULATOR) |
- helper.FillRegisters(&state); |
+ if (!SimulatorHelper::FillRegisters(isolate(), &state)) return; |
#else |
#if V8_HOST_ARCH_X64 |
state.pc = reinterpret_cast<Address>(context.Rip); |