| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "vm/thread.h" | 5 #include "vm/thread.h" |
| 6 | 6 |
| 7 #include "vm/compiler_stats.h" | 7 #include "vm/compiler_stats.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 return Thread::name##_entry_point_offset(); \ | 739 return Thread::name##_entry_point_offset(); \ |
| 740 } | 740 } |
| 741 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) | 741 LEAF_RUNTIME_ENTRY_LIST(COMPUTE_OFFSET) |
| 742 #undef COMPUTE_OFFSET | 742 #undef COMPUTE_OFFSET |
| 743 | 743 |
| 744 UNREACHABLE(); | 744 UNREACHABLE(); |
| 745 return -1; | 745 return -1; |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 bool Thread::IsValidHandle(Dart_Handle object) const { |
| 750 return IsValidLocalHandle(object) || IsValidZoneHandle(object) || |
| 751 IsValidScopedHandle(object); |
| 752 } |
| 753 |
| 754 |
| 749 bool Thread::IsValidLocalHandle(Dart_Handle object) const { | 755 bool Thread::IsValidLocalHandle(Dart_Handle object) const { |
| 750 ApiLocalScope* scope = api_top_scope_; | 756 ApiLocalScope* scope = api_top_scope_; |
| 751 while (scope != NULL) { | 757 while (scope != NULL) { |
| 752 if (scope->local_handles()->IsValidHandle(object)) { | 758 if (scope->local_handles()->IsValidHandle(object)) { |
| 753 return true; | 759 return true; |
| 754 } | 760 } |
| 755 scope = scope->previous(); | 761 scope = scope->previous(); |
| 756 } | 762 } |
| 757 return false; | 763 return false; |
| 758 } | 764 } |
| 759 | 765 |
| 760 | 766 |
| 761 intptr_t Thread::CountLocalHandles() const { | 767 intptr_t Thread::CountLocalHandles() const { |
| 762 intptr_t total = 0; | 768 intptr_t total = 0; |
| 763 ApiLocalScope* scope = api_top_scope_; | 769 ApiLocalScope* scope = api_top_scope_; |
| 764 while (scope != NULL) { | 770 while (scope != NULL) { |
| 765 total += scope->local_handles()->CountHandles(); | 771 total += scope->local_handles()->CountHandles(); |
| 766 scope = scope->previous(); | 772 scope = scope->previous(); |
| 767 } | 773 } |
| 768 return total; | 774 return total; |
| 769 } | 775 } |
| 770 | 776 |
| 771 | 777 |
| 778 bool Thread::IsValidZoneHandle(Dart_Handle object) const { |
| 779 Zone* zone = zone_; |
| 780 while (zone != NULL) { |
| 781 if (zone->handles()->IsValidZoneHandle(reinterpret_cast<uword>(object))) { |
| 782 return true; |
| 783 } |
| 784 zone = zone->previous(); |
| 785 } |
| 786 return false; |
| 787 } |
| 788 |
| 789 |
| 772 intptr_t Thread::CountZoneHandles() const { | 790 intptr_t Thread::CountZoneHandles() const { |
| 773 intptr_t count = 0; | 791 intptr_t count = 0; |
| 774 Zone* zone = zone_; | 792 Zone* zone = zone_; |
| 775 while (zone != NULL) { | 793 while (zone != NULL) { |
| 776 count += zone->handles()->CountZoneHandles(); | 794 count += zone->handles()->CountZoneHandles(); |
| 777 zone = zone->previous(); | 795 zone = zone->previous(); |
| 778 } | 796 } |
| 779 ASSERT(count >= 0); | 797 ASSERT(count >= 0); |
| 780 return count; | 798 return count; |
| 781 } | 799 } |
| 782 | 800 |
| 783 | 801 |
| 802 bool Thread::IsValidScopedHandle(Dart_Handle object) const { |
| 803 Zone* zone = zone_; |
| 804 while (zone != NULL) { |
| 805 if (zone->handles()->IsValidScopedHandle(reinterpret_cast<uword>(object))) { |
| 806 return true; |
| 807 } |
| 808 zone = zone->previous(); |
| 809 } |
| 810 return false; |
| 811 } |
| 812 |
| 813 |
| 784 intptr_t Thread::CountScopedHandles() const { | 814 intptr_t Thread::CountScopedHandles() const { |
| 785 intptr_t count = 0; | 815 intptr_t count = 0; |
| 786 Zone* zone = zone_; | 816 Zone* zone = zone_; |
| 787 while (zone != NULL) { | 817 while (zone != NULL) { |
| 788 count += zone->handles()->CountScopedHandles(); | 818 count += zone->handles()->CountScopedHandles(); |
| 789 zone = zone->previous(); | 819 zone = zone->previous(); |
| 790 } | 820 } |
| 791 ASSERT(count >= 0); | 821 ASSERT(count >= 0); |
| 792 return count; | 822 return count; |
| 793 } | 823 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 874 |
| 845 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { | 875 DisableThreadInterruptsScope::~DisableThreadInterruptsScope() { |
| 846 if (thread() != NULL) { | 876 if (thread() != NULL) { |
| 847 OSThread* os_thread = thread()->os_thread(); | 877 OSThread* os_thread = thread()->os_thread(); |
| 848 ASSERT(os_thread != NULL); | 878 ASSERT(os_thread != NULL); |
| 849 os_thread->EnableThreadInterrupts(); | 879 os_thread->EnableThreadInterrupts(); |
| 850 } | 880 } |
| 851 } | 881 } |
| 852 | 882 |
| 853 } // namespace dart | 883 } // namespace dart |
| OLD | NEW |