Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: src/profiler/sampler.h

Issue 1926863003: Make Isolate::GetStackSample API support simulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/profiler/sampler.h
diff --git a/src/profiler/sampler.h b/src/profiler/sampler.h
index f6804f8e25f7aa0a328a64b746cd8251115cad90..03aa7c77c8db8cea117faa879adb2b9cb9d1eed1 100644
--- a/src/profiler/sampler.h
+++ b/src/profiler/sampler.h
@@ -11,6 +11,7 @@
#include "src/base/platform/time.h"
#include "src/frames.h"
#include "src/globals.h"
+#include "src/simulator.h"
namespace v8 {
namespace internal {
@@ -141,6 +142,70 @@ class Sampler {
};
+#if defined(USE_SIMULATOR)
+class SimulatorHelper : AllStatic {
+ public:
+ 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.
+ Simulator *simulator = isolate->thread_local_top()->simulator_;
+ // Check if there is active simulator.
+ if (simulator == NULL) return false;
+#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 true;
+ }
+ 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
+ return true;
+ }
+};
+#endif // USE_SIMULATOR
+
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698