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

Unified Diff: runtime/vm/profiler.cc

Issue 2680123004: VM: Teach GetAndValidateIsolateStackBounds(...) to fallback to OS thread stack bounds. (Closed)
Patch Set: Done Created 3 years, 10 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
« no previous file with comments | « runtime/vm/os_thread_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 2e99b34d7ee646d2eb9d364f4c66f09feb469a78..55437a90908a428d716eb519a3bb9864dc1655e7 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -797,51 +797,53 @@ static void CollectSample(Isolate* isolate,
// Get |isolate|'s stack boundary and verify that |sp| and |fp| are within
-// it. Return |false| if anything looks suspicious.
-static bool GetAndValidateIsolateStackBounds(Thread* thread,
- uintptr_t fp,
- uintptr_t sp,
- uword* stack_lower,
- uword* stack_upper) {
+// it. If |get_os_thread_bounds| is true then if |isolate| stackbounds are
+// not available we fallback to using underlying OS thread bounds. This only
+// works for the current thread.
+// Return |false| if anything looks suspicious.
+static bool GetAndValidateIsolateStackBounds(
Cutch 2017/02/09 16:45:24 While you're here, this could be renamed to GetAnd
Vyacheslav Egorov (Google) 2017/02/09 17:19:20 Done.
+ Thread* thread,
+ uintptr_t fp,
+ uintptr_t sp,
+ uword* stack_lower,
+ uword* stack_upper,
+ bool get_os_thread_bounds = false) {
ASSERT(thread != NULL);
OSThread* os_thread = thread->os_thread();
ASSERT(os_thread != NULL);
ASSERT(stack_lower != NULL);
ASSERT(stack_upper != NULL);
+ ASSERT(!get_os_thread_bounds || (Thread::Current() == thread));
+
#if defined(USING_SIMULATOR)
- const bool in_dart_code = thread->IsExecutingDartCode();
- if (in_dart_code) {
+ const bool use_simulator_stack_bounds = thread->IsExecutingDartCode();
+ if (use_simulator_stack_bounds) {
Isolate* isolate = thread->isolate();
ASSERT(isolate != NULL);
Simulator* simulator = isolate->simulator();
*stack_lower = simulator->StackBase();
*stack_upper = simulator->StackTop();
- } else if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) {
- // Could not get stack boundary.
- return false;
- }
- if ((*stack_lower == 0) || (*stack_upper == 0)) {
- return false;
}
#else
- if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper) ||
- (*stack_lower == 0) || (*stack_upper == 0)) {
+ const bool use_simulator_stack_bounds = false;
+#endif
+
+ if (!use_simulator_stack_bounds &&
+ !os_thread->GetProfilerStackBounds(stack_lower, stack_upper) &&
+ !(get_os_thread_bounds &&
+ OSThread::GetCurrentStackBounds(stack_lower, stack_upper))) {
// Could not get stack boundary.
return false;
}
-#endif
-#if defined(TARGET_ARCH_DBC)
- if (!in_dart_code && (sp > *stack_lower)) {
- // The stack pointer gives us a tighter lower bound.
- *stack_lower = sp;
+ if ((*stack_lower == 0) || (*stack_upper == 0)) {
+ return false;
}
-#else
- if (sp > *stack_lower) {
+
+ if (!use_simulator_stack_bounds && (sp > *stack_lower)) {
// The stack pointer gives us a tighter lower bound.
*stack_lower = sp;
}
-#endif
if (*stack_lower >= *stack_upper) {
// Stack boundary is invalid.
@@ -983,7 +985,8 @@ void Profiler::DumpStackTrace(uword sp, uword fp, uword pc) {
}
if (!GetAndValidateIsolateStackBounds(thread, fp, sp, &stack_lower,
- &stack_upper)) {
+ &stack_upper,
+ /*get_os_thread_bounds=*/true)) {
Cutch 2017/02/09 16:45:24 I wonder why this isn't the default now?
Vyacheslav Egorov (Google) 2017/02/09 17:19:20 Because it only works if thread == Thread::Current
OS::PrintErr(
"Stack dump aborted because GetAndValidateIsolateStackBounds.\n");
return;
« no previous file with comments | « runtime/vm/os_thread_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698