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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 740 |
741 | 741 |
742 // Get |isolate|'s stack boundary and verify that |sp| and |fp| are within | 742 // Get |isolate|'s stack boundary and verify that |sp| and |fp| are within |
743 // it. Return |false| if anything looks suspicious. | 743 // it. Return |false| if anything looks suspicious. |
744 static bool GetAndValidateIsolateStackBounds(Thread* thread, | 744 static bool GetAndValidateIsolateStackBounds(Thread* thread, |
745 uintptr_t fp, | 745 uintptr_t fp, |
746 uintptr_t sp, | 746 uintptr_t sp, |
747 uword* stack_lower, | 747 uword* stack_lower, |
748 uword* stack_upper) { | 748 uword* stack_upper) { |
749 ASSERT(thread != NULL); | 749 ASSERT(thread != NULL); |
750 Isolate* isolate = thread->isolate(); | 750 OSThread* os_thread = thread->os_thread(); |
751 ASSERT(isolate != NULL); | 751 ASSERT(os_thread != NULL); |
752 ASSERT(stack_lower != NULL); | 752 ASSERT(stack_lower != NULL); |
753 ASSERT(stack_upper != NULL); | 753 ASSERT(stack_upper != NULL); |
754 #if defined(USING_SIMULATOR) | 754 #if defined(USING_SIMULATOR) |
755 const bool in_dart_code = thread->IsExecutingDartCode(); | 755 const bool in_dart_code = thread->IsExecutingDartCode(); |
756 if (in_dart_code) { | 756 if (in_dart_code) { |
| 757 Isolate* isolate = thread->isolate(); |
| 758 ASSERT(isolate != NULL); |
757 Simulator* simulator = isolate->simulator(); | 759 Simulator* simulator = isolate->simulator(); |
758 *stack_lower = simulator->StackBase(); | 760 *stack_lower = simulator->StackBase(); |
759 *stack_upper = simulator->StackTop(); | 761 *stack_upper = simulator->StackTop(); |
760 } else if (!isolate->GetProfilerStackBounds(stack_lower, stack_upper)) { | 762 } else if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) { |
761 // Could not get stack boundary. | 763 // Could not get stack boundary. |
762 return false; | 764 return false; |
763 } | 765 } |
764 if ((*stack_lower == 0) || (*stack_upper == 0)) { | 766 if ((*stack_lower == 0) || (*stack_upper == 0)) { |
765 return false; | 767 return false; |
766 } | 768 } |
767 #else | 769 #else |
768 if (!isolate->GetProfilerStackBounds(stack_lower, stack_upper) || | 770 if (!os_thread->GetProfilerStackBounds(stack_lower, stack_upper) || |
769 (*stack_lower == 0) || (*stack_upper == 0)) { | 771 (*stack_lower == 0) || (*stack_upper == 0)) { |
770 // Could not get stack boundary. | 772 // Could not get stack boundary. |
771 return false; | 773 return false; |
772 } | 774 } |
773 #endif | 775 #endif |
774 if (sp > *stack_lower) { | 776 if (sp > *stack_lower) { |
775 // The stack pointer gives us a tighter lower bound. | 777 // The stack pointer gives us a tighter lower bound. |
776 *stack_lower = sp; | 778 *stack_lower = sp; |
777 } | 779 } |
778 | 780 |
779 if (*stack_lower >= *stack_upper) { | 781 if (*stack_lower >= *stack_upper) { |
780 // Stack boundary is invalid. | 782 // Stack boundary is invalid. |
781 return false; | 783 return false; |
782 } | 784 } |
783 | 785 |
784 if ((sp < *stack_lower) || (sp >= *stack_upper)) { | 786 if ((sp < *stack_lower) || (sp >= *stack_upper)) { |
785 // Stack pointer is outside isolate stack boundary. | 787 // Stack pointer is outside thread's stack boundary. |
786 return false; | 788 return false; |
787 } | 789 } |
788 | 790 |
789 if ((fp < *stack_lower) || (fp >= *stack_upper)) { | 791 if ((fp < *stack_lower) || (fp >= *stack_upper)) { |
790 // Frame pointer is outside isolate stack boundary. | 792 // Frame pointer is outside threads's stack boundary. |
791 return false; | 793 return false; |
792 } | 794 } |
793 | 795 |
794 return true; | 796 return true; |
795 } | 797 } |
796 | 798 |
797 | 799 |
798 // Some simple sanity checking of |pc|, |fp|, and |sp|. | 800 // Some simple sanity checking of |pc|, |fp|, and |sp|. |
799 static bool InitialRegisterCheck(uintptr_t pc, uintptr_t fp, uintptr_t sp) { | 801 static bool InitialRegisterCheck(uintptr_t pc, uintptr_t fp, uintptr_t sp) { |
800 if ((sp == 0) || (fp == 0) || (pc == 0)) { | 802 if ((sp == 0) || (fp == 0) || (pc == 0)) { |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 } | 1367 } |
1366 } | 1368 } |
1367 | 1369 |
1368 | 1370 |
1369 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1371 ProcessedSampleBuffer::ProcessedSampleBuffer() |
1370 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1372 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
1371 ASSERT(code_lookup_table_ != NULL); | 1373 ASSERT(code_lookup_table_ != NULL); |
1372 } | 1374 } |
1373 | 1375 |
1374 } // namespace dart | 1376 } // namespace dart |
OLD | NEW |