| OLD | NEW |
| 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/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
| 6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 791 |
| 792 Sample* sample_; | 792 Sample* sample_; |
| 793 const uword stack_upper_; | 793 const uword stack_upper_; |
| 794 const uword original_pc_; | 794 const uword original_pc_; |
| 795 const uword original_fp_; | 795 const uword original_fp_; |
| 796 const uword original_sp_; | 796 const uword original_sp_; |
| 797 uword lower_bound_; | 797 uword lower_bound_; |
| 798 }; | 798 }; |
| 799 | 799 |
| 800 | 800 |
| 801 static void CopyPCMarkerIfSafe(Sample* sample) { | 801 static void CopyPCMarkerIfSafe(Sample* sample, uword fp_addr, uword sp_addr) { |
| 802 ASSERT(sample != NULL); | 802 ASSERT(sample != NULL); |
| 803 | 803 |
| 804 if (sample->vm_tag() != VMTag::kDartTagId) { | 804 if (sample->vm_tag() != VMTag::kDartTagId) { |
| 805 // We can only trust the stack pointer if we are executing Dart code. | 805 // We can only trust the stack pointer if we are executing Dart code. |
| 806 // See http://dartbug.com/20421 for details. | 806 // See http://dartbug.com/20421 for details. |
| 807 return; | 807 return; |
| 808 } | 808 } |
| 809 uword* fp = reinterpret_cast<uword*>(sample->fp()); | 809 uword* fp = reinterpret_cast<uword*>(fp_addr); |
| 810 uword* sp = reinterpret_cast<uword*>(sample->sp()); | 810 uword* sp = reinterpret_cast<uword*>(sp_addr); |
| 811 | 811 |
| 812 // If FP == SP, the pc marker hasn't been pushed. | 812 // If FP == SP, the pc marker hasn't been pushed. |
| 813 if (fp > sp) { | 813 if (fp > sp) { |
| 814 uword* pc_marker_ptr = fp + kPcMarkerSlotFromFp; | 814 uword* pc_marker_ptr = fp + kPcMarkerSlotFromFp; |
| 815 // MSan/ASan are unaware of frames initialized by generated code. | 815 // MSan/ASan are unaware of frames initialized by generated code. |
| 816 MSAN_UNPOISON(pc_marker_ptr, kWordSize); | 816 MSAN_UNPOISON(pc_marker_ptr, kWordSize); |
| 817 ASAN_UNPOISON(pc_marker_ptr, kWordSize); | 817 ASAN_UNPOISON(pc_marker_ptr, kWordSize); |
| 818 sample->set_pc_marker(*pc_marker_ptr); | 818 sample->set_pc_marker(*pc_marker_ptr); |
| 819 } | 819 } |
| 820 } | 820 } |
| 821 | 821 |
| 822 | 822 |
| 823 static void CopyStackBuffer(Sample* sample) { | 823 static void CopyStackBuffer(Sample* sample, uword sp_addr) { |
| 824 ASSERT(sample != NULL); | 824 ASSERT(sample != NULL); |
| 825 if (sample->vm_tag() != VMTag::kDartTagId) { | 825 if (sample->vm_tag() != VMTag::kDartTagId) { |
| 826 // We can only trust the stack pointer if we are executing Dart code. | 826 // We can only trust the stack pointer if we are executing Dart code. |
| 827 // See http://dartbug.com/20421 for details. | 827 // See http://dartbug.com/20421 for details. |
| 828 return; | 828 return; |
| 829 } | 829 } |
| 830 uword* sp = reinterpret_cast<uword*>(sample->sp()); | 830 uword* sp = reinterpret_cast<uword*>(sp_addr); |
| 831 uword* buffer = sample->GetStackBuffer(); | 831 uword* buffer = sample->GetStackBuffer(); |
| 832 if (sp != NULL) { | 832 if (sp != NULL) { |
| 833 for (intptr_t i = 0; i < Sample::kStackBufferSizeInWords; i++) { | 833 for (intptr_t i = 0; i < Sample::kStackBufferSizeInWords; i++) { |
| 834 MSAN_UNPOISON(sp, kWordSize); | 834 MSAN_UNPOISON(sp, kWordSize); |
| 835 ASAN_UNPOISON(sp, kWordSize); | 835 ASAN_UNPOISON(sp, kWordSize); |
| 836 buffer[i] = *sp; | 836 buffer[i] = *sp; |
| 837 sp++; | 837 sp++; |
| 838 } | 838 } |
| 839 } | 839 } |
| 840 } | 840 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 858 #endif | 858 #endif |
| 859 | 859 |
| 860 // All memory access done to collect the sample is performed in CollectSample. | 860 // All memory access done to collect the sample is performed in CollectSample. |
| 861 static void CollectSample(Isolate* isolate, | 861 static void CollectSample(Isolate* isolate, |
| 862 bool exited_dart_code, | 862 bool exited_dart_code, |
| 863 bool in_dart_code, | 863 bool in_dart_code, |
| 864 Sample* sample, | 864 Sample* sample, |
| 865 ProfilerNativeStackWalker* native_stack_walker, | 865 ProfilerNativeStackWalker* native_stack_walker, |
| 866 ProfilerDartExitStackWalker* dart_exit_stack_walker, | 866 ProfilerDartExitStackWalker* dart_exit_stack_walker, |
| 867 ProfilerDartStackWalker* dart_stack_walker, | 867 ProfilerDartStackWalker* dart_stack_walker, |
| 868 uword pc) { | 868 uword pc, |
| 869 uword fp, |
| 870 uword sp) { |
| 869 #if defined(TARGET_OS_WINDOWS) | 871 #if defined(TARGET_OS_WINDOWS) |
| 870 // Use structured exception handling to trap guard page access on Windows. | 872 // Use structured exception handling to trap guard page access on Windows. |
| 871 __try { | 873 __try { |
| 872 #endif | 874 #endif |
| 873 | 875 |
| 874 CopyStackBuffer(sample); | 876 CopyStackBuffer(sample, sp); |
| 875 CopyPCMarkerIfSafe(sample); | 877 CopyPCMarkerIfSafe(sample, fp, sp); |
| 876 | 878 |
| 877 if (FLAG_profile_vm) { | 879 if (FLAG_profile_vm) { |
| 878 // Always walk the native stack collecting both native and Dart frames. | 880 // Always walk the native stack collecting both native and Dart frames. |
| 879 native_stack_walker->walk(); | 881 native_stack_walker->walk(); |
| 880 } else if (exited_dart_code) { | 882 } else if (exited_dart_code) { |
| 881 // We have a valid exit frame info, use the Dart stack walker. | 883 // We have a valid exit frame info, use the Dart stack walker. |
| 882 dart_exit_stack_walker->walk(); | 884 dart_exit_stack_walker->walk(); |
| 883 } else if (in_dart_code) { | 885 } else if (in_dart_code) { |
| 884 // We are executing Dart code. We have frame pointers. | 886 // We are executing Dart code. We have frame pointers. |
| 885 dart_stack_walker->walk(); | 887 dart_stack_walker->walk(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 if (redirect_vm_tag != 0) { | 1041 if (redirect_vm_tag != 0) { |
| 1040 vm_tag = redirect_vm_tag; | 1042 vm_tag = redirect_vm_tag; |
| 1041 } | 1043 } |
| 1042 #endif | 1044 #endif |
| 1043 // Increment counter for vm tag. | 1045 // Increment counter for vm tag. |
| 1044 VMTagCounters* counters = isolate->vm_tag_counters(); | 1046 VMTagCounters* counters = isolate->vm_tag_counters(); |
| 1045 ASSERT(counters != NULL); | 1047 ASSERT(counters != NULL); |
| 1046 counters->Increment(vm_tag); | 1048 counters->Increment(vm_tag); |
| 1047 sample->set_vm_tag(vm_tag); | 1049 sample->set_vm_tag(vm_tag); |
| 1048 sample->set_user_tag(isolate->user_tag()); | 1050 sample->set_user_tag(isolate->user_tag()); |
| 1049 sample->set_sp(sp); | |
| 1050 sample->set_fp(fp); | |
| 1051 sample->set_lr(lr); | 1051 sample->set_lr(lr); |
| 1052 | 1052 |
| 1053 ProfilerNativeStackWalker native_stack_walker(sample, | 1053 ProfilerNativeStackWalker native_stack_walker(sample, |
| 1054 stack_lower, | 1054 stack_lower, |
| 1055 stack_upper, | 1055 stack_upper, |
| 1056 pc, | 1056 pc, |
| 1057 fp, | 1057 fp, |
| 1058 sp); | 1058 sp); |
| 1059 | 1059 |
| 1060 ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample); | 1060 ProfilerDartExitStackWalker dart_exit_stack_walker(isolate, sample); |
| 1061 | 1061 |
| 1062 ProfilerDartStackWalker dart_stack_walker(isolate, | 1062 ProfilerDartStackWalker dart_stack_walker(isolate, |
| 1063 sample, | 1063 sample, |
| 1064 stack_lower, | 1064 stack_lower, |
| 1065 stack_upper, | 1065 stack_upper, |
| 1066 pc, | 1066 pc, |
| 1067 fp, | 1067 fp, |
| 1068 sp); | 1068 sp); |
| 1069 | 1069 |
| 1070 // All memory access is done inside CollectSample. | 1070 // All memory access is done inside CollectSample. |
| 1071 CollectSample(isolate, | 1071 CollectSample(isolate, |
| 1072 exited_dart_code, | 1072 exited_dart_code, |
| 1073 in_dart_code, | 1073 in_dart_code, |
| 1074 sample, | 1074 sample, |
| 1075 &native_stack_walker, | 1075 &native_stack_walker, |
| 1076 &dart_exit_stack_walker, | 1076 &dart_exit_stack_walker, |
| 1077 &dart_stack_walker, | 1077 &dart_stack_walker, |
| 1078 pc); | 1078 pc, |
| 1079 fp, |
| 1080 sp); |
| 1079 } | 1081 } |
| 1080 | 1082 |
| 1081 } // namespace dart | 1083 } // namespace dart |
| OLD | NEW |