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

Unified Diff: src/api.cc

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
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 47fc1ce1b2f62ba22dd739aeba225c14da1b9230..15e5b6934af400b996bc4d8db528194693042edf 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7527,6 +7527,71 @@ void Isolate::GetStackSample(const RegisterState& state, void** frames,
}
+void Isolate::GetStackSample(RegisterState* state, void** frames,
alph 2016/04/27 22:29:20 v8 usually do not put that much implementation spe
+ size_t frames_limit, SampleInfo* sample_info) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+#if defined(USE_SIMULATOR)
+ i::Simulator *simulator = isolate->thread_local_top()->simulator_;
+ if (simulator != NULL) {
+#if V8_TARGET_ARCH_ARM
+ if (!simulator->has_bad_pc()) {
+ state->pc = reinterpret_cast<void*>(simulator->get_pc());
+ }
+ state->sp = reinterpret_cast<void*>(simulator->get_register(
+ i::Simulator::sp));
+ state->fp = reinterpret_cast<void*>(simulator->get_register(
+ i::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<void*>(simulator->pc());
+ state->sp = reinterpret_cast<void*>(simulator->sp());
+ state->fp = reinterpret_cast<void*>(simulator->fp());
+#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
+ if (!simulator->has_bad_pc()) {
+ state->pc = reinterpret_cast<void*>(simulator->get_pc());
+ }
+ state->sp = reinterpret_cast<void*>(simulator->get_register(
+ i::Simulator::sp));
+ state->fp = reinterpret_cast<void*>(simulator->get_register(
+ i::Simulator::fp));
+#elif V8_TARGET_ARCH_PPC
+ if (!simulator->has_bad_pc()) {
+ state->pc = reinterpret_cast<void*>(simulator->get_pc());
+ }
+ state->sp =
+ reinterpret_cast<void*>(simulator->get_register(i::Simulator::sp));
+ state->fp =
+ reinterpret_cast<void*>(simulator->get_register(i::Simulator::fp));
+#elif V8_TARGET_ARCH_S390
+ if (!simulator->has_bad_pc()) {
+ state->pc = reinterpret_cast<void*>(simulator->get_pc());
+ }
+ state->sp =
+ reinterpret_cast<void*>(simulator->get_register(i::Simulator::sp));
+ state->fp =
+ reinterpret_cast<void*>(simulator->get_register(i::Simulator::fp));
+#endif
+ }
+#endif // USE_SIMULATOR
+ i::TickSample::GetStackSample(isolate, *state,
+ i::TickSample::kSkipCEntryFrame,
+ frames, frames_limit, sample_info);
+}
+
+
void Isolate::SetEventLogger(LogEventCallback that) {
// Do not overwrite the event logger if we want to log explicitly.
if (i::FLAG_log_internal_timer_events) return;
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698