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

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

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed comments Created 5 years, 3 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | 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/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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 752 }
753 753
754 const uword stack_upper_; 754 const uword stack_upper_;
755 const uword original_pc_; 755 const uword original_pc_;
756 const uword original_fp_; 756 const uword original_fp_;
757 const uword original_sp_; 757 const uword original_sp_;
758 uword lower_bound_; 758 uword lower_bound_;
759 }; 759 };
760 760
761 761
762 static void CopyPCMarkerIfSafe(Sample* sample, uword fp_addr, uword sp_addr) {
763 ASSERT(sample != NULL);
764
765 if (sample->vm_tag() != VMTag::kDartTagId) {
766 // We can only trust the stack pointer if we are executing Dart code.
767 // See http://dartbug.com/20421 for details.
768 return;
769 }
770 uword* fp = reinterpret_cast<uword*>(fp_addr);
771 uword* sp = reinterpret_cast<uword*>(sp_addr);
772
773 // If FP == SP, the pc marker hasn't been pushed.
774 if (fp > sp) {
775 uword* pc_marker_ptr = fp + kPcMarkerSlotFromFp;
776 // MSan/ASan are unaware of frames initialized by generated code.
777 MSAN_UNPOISON(pc_marker_ptr, kWordSize);
778 ASAN_UNPOISON(pc_marker_ptr, kWordSize);
779 sample->set_pc_marker(*pc_marker_ptr);
780 }
781 }
782
783
784 static void CopyStackBuffer(Sample* sample, uword sp_addr) { 762 static void CopyStackBuffer(Sample* sample, uword sp_addr) {
785 ASSERT(sample != NULL); 763 ASSERT(sample != NULL);
786 if (sample->vm_tag() != VMTag::kDartTagId) {
787 // We can only trust the stack pointer if we are executing Dart code.
788 // See http://dartbug.com/20421 for details.
789 return;
790 }
791 uword* sp = reinterpret_cast<uword*>(sp_addr); 764 uword* sp = reinterpret_cast<uword*>(sp_addr);
792 uword* buffer = sample->GetStackBuffer(); 765 uword* buffer = sample->GetStackBuffer();
793 if (sp != NULL) { 766 if (sp != NULL) {
794 for (intptr_t i = 0; i < Sample::kStackBufferSizeInWords; i++) { 767 for (intptr_t i = 0; i < Sample::kStackBufferSizeInWords; i++) {
795 MSAN_UNPOISON(sp, kWordSize); 768 MSAN_UNPOISON(sp, kWordSize);
796 ASAN_UNPOISON(sp, kWordSize); 769 ASAN_UNPOISON(sp, kWordSize);
797 buffer[i] = *sp; 770 buffer[i] = *sp;
798 sp++; 771 sp++;
799 } 772 }
800 } 773 }
(...skipping 26 matching lines...) Expand all
827 ProfilerDartExitStackWalker* dart_exit_stack_walker, 800 ProfilerDartExitStackWalker* dart_exit_stack_walker,
828 ProfilerDartStackWalker* dart_stack_walker, 801 ProfilerDartStackWalker* dart_stack_walker,
829 uword pc, 802 uword pc,
830 uword fp, 803 uword fp,
831 uword sp) { 804 uword sp) {
832 #if defined(TARGET_OS_WINDOWS) 805 #if defined(TARGET_OS_WINDOWS)
833 // Use structured exception handling to trap guard page access on Windows. 806 // Use structured exception handling to trap guard page access on Windows.
834 __try { 807 __try {
835 #endif 808 #endif
836 809
837 CopyStackBuffer(sample, sp); 810 if (in_dart_code) {
838 CopyPCMarkerIfSafe(sample, fp, sp); 811 // We can only trust the stack pointer if we are executing Dart code.
812 // See http://dartbug.com/20421 for details.
813 CopyStackBuffer(sample, sp);
814 }
839 815
840 if (FLAG_profile_vm) { 816 if (FLAG_profile_vm) {
841 // Always walk the native stack collecting both native and Dart frames. 817 // Always walk the native stack collecting both native and Dart frames.
842 native_stack_walker->walk(); 818 native_stack_walker->walk();
843 } else if (exited_dart_code) { 819 } else if (exited_dart_code) {
844 // We have a valid exit frame info, use the Dart stack walker. 820 // We have a valid exit frame info, use the Dart stack walker.
845 dart_exit_stack_walker->walk(); 821 dart_exit_stack_walker->walk();
846 } else if (in_dart_code) { 822 } else if (in_dart_code) {
847 // We are executing Dart code. We have frame pointers. 823 // We are executing Dart code. We have frame pointers.
848 dart_stack_walker->walk(); 824 dart_stack_walker->walk();
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 uword pc) { 1385 uword pc) {
1410 return vm_isolate->heap()->CodeContains(pc) 1386 return vm_isolate->heap()->CodeContains(pc)
1411 || isolate->heap()->CodeContains(pc); 1387 || isolate->heap()->CodeContains(pc);
1412 } 1388 }
1413 1389
1414 1390
1415 ProcessedSampleBuffer::ProcessedSampleBuffer() { 1391 ProcessedSampleBuffer::ProcessedSampleBuffer() {
1416 } 1392 }
1417 1393
1418 } // namespace dart 1394 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698