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

Side by Side Diff: runtime/vm/profiler.cc

Issue 451033002: Don't try to read return address from the stack of another thread on Win64. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/utils.h" 5 #include "platform/utils.h"
6 6
7 #include "vm/allocation.h" 7 #include "vm/allocation.h"
8 #include "vm/atomic.h" 8 #include "vm/atomic.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 1669
1670 1670
1671 static void SetPCMarkerIfSafe(Sample* sample) { 1671 static void SetPCMarkerIfSafe(Sample* sample) {
1672 ASSERT(sample != NULL); 1672 ASSERT(sample != NULL);
1673 1673
1674 uword* fp = reinterpret_cast<uword*>(sample->fp()); 1674 uword* fp = reinterpret_cast<uword*>(sample->fp());
1675 uword* sp = reinterpret_cast<uword*>(sample->sp()); 1675 uword* sp = reinterpret_cast<uword*>(sample->sp());
1676 1676
1677 // If FP == SP, the pc marker hasn't been pushed. 1677 // If FP == SP, the pc marker hasn't been pushed.
1678 if (fp > sp) { 1678 if (fp > sp) {
1679 #if defined(TARGET_OS_WINDOWS)
Vyacheslav Egorov (Google) 2014/08/08 12:47:54 I don't think this code was doing anything. Stack
Cutch 2014/08/08 13:24:53 Your analysis is correct, this logic isn't entirel
1680 // If the fp is at the beginning of a page, it may be unsafe to access
1681 // the pc marker, because we are reading it from a different thread on
1682 // Windows. The next page may be a guard page.
1683 const intptr_t kPageMask = VirtualMemory::PageSize() - 1;
1684 if ((sample->fp() & kPageMask) == 0) {
1685 return;
1686 }
1687 #endif
1688 const uword pc_marker = *(fp + kPcMarkerSlotFromFp); 1679 const uword pc_marker = *(fp + kPcMarkerSlotFromFp);
1689 sample->set_pc_marker(pc_marker); 1680 sample->set_pc_marker(pc_marker);
1690 } 1681 }
1691 } 1682 }
1692 1683
1693 1684
1694 // Given an exit frame, walk the Dart stack. 1685 // Given an exit frame, walk the Dart stack.
1695 class ProfilerDartExitStackWalker : public ValueObject { 1686 class ProfilerDartExitStackWalker : public ValueObject {
1696 public: 1687 public:
1697 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample) 1688 ProfilerDartExitStackWalker(Isolate* isolate, Sample* sample)
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 ASSERT(counters != NULL); 2031 ASSERT(counters != NULL);
2041 counters->Increment(isolate->vm_tag()); 2032 counters->Increment(isolate->vm_tag());
2042 2033
2043 // Setup sample. 2034 // Setup sample.
2044 Sample* sample = sample_buffer->ReserveSample(); 2035 Sample* sample = sample_buffer->ReserveSample();
2045 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid); 2036 sample->Init(isolate, OS::GetCurrentTimeMicros(), state.tid);
2046 sample->set_vm_tag(isolate->vm_tag()); 2037 sample->set_vm_tag(isolate->vm_tag());
2047 sample->set_user_tag(isolate->user_tag()); 2038 sample->set_user_tag(isolate->user_tag());
2048 sample->set_sp(state.sp); 2039 sample->set_sp(state.sp);
2049 sample->set_fp(state.fp); 2040 sample->set_fp(state.fp);
2041 #if !(defined(TARGET_OS_WINDOWS) && defined(HOST_ARCH_X64))
2042 // It is never safe to read other thread's stack unless
2043 // other thread is inside Dart code.
2050 SetPCMarkerIfSafe(sample); 2044 SetPCMarkerIfSafe(sample);
Cutch 2014/08/08 13:24:53 This should either be: #if !defined(TARGET_OS_WIN
2045 #endif
2051 2046
2052 // Walk the call stack. 2047 // Walk the call stack.
2053 if (FLAG_profile_vm) { 2048 if (FLAG_profile_vm) {
2054 // Always walk the native stack collecting both native and Dart frames. 2049 // Always walk the native stack collecting both native and Dart frames.
2055 ProfilerNativeStackWalker stackWalker(sample, 2050 ProfilerNativeStackWalker stackWalker(sample,
2056 stack_lower, 2051 stack_lower,
2057 stack_upper, 2052 stack_upper,
2058 state.pc, 2053 state.pc,
2059 state.fp, 2054 state.fp,
2060 state.sp); 2055 state.sp);
(...skipping 26 matching lines...) Expand all
2087 stack_upper, 2082 stack_upper,
2088 state.pc, 2083 state.pc,
2089 state.fp, 2084 state.fp,
2090 state.sp); 2085 state.sp);
2091 stackWalker.walk(); 2086 stackWalker.walk();
2092 } 2087 }
2093 } 2088 }
2094 } 2089 }
2095 2090
2096 } // namespace dart 2091 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698