| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/debugger.h" | 5 #include "vm/debugger.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "platform/address_sanitizer.h" | 9 #include "platform/address_sanitizer.h" |
| 10 | 10 |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 innermost_begin_pos = var_info.begin_pos; | 703 innermost_begin_pos = var_info.begin_pos; |
| 704 context_level_ = var_info.index(); | 704 context_level_ = var_info.index(); |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 } | 707 } |
| 708 ASSERT(context_level_ >= 0); | 708 ASSERT(context_level_ >= 0); |
| 709 } | 709 } |
| 710 return context_level_; | 710 return context_level_; |
| 711 } | 711 } |
| 712 | 712 |
| 713 RawObject* ActivationFrame::GetAsyncCompleter() { | 713 |
| 714 RawObject* ActivationFrame::GetAsyncContextVariable(const String& name) { |
| 714 if (!function_.IsAsyncClosure()) { | 715 if (!function_.IsAsyncClosure()) { |
| 715 return Object::null(); | 716 return Object::null(); |
| 716 } | 717 } |
| 717 GetVarDescriptors(); | 718 GetVarDescriptors(); |
| 718 intptr_t var_desc_len = var_descriptors_.Length(); | 719 intptr_t var_desc_len = var_descriptors_.Length(); |
| 719 if (!live_frame_) { | 720 for (intptr_t i = 0; i < var_desc_len; i++) { |
| 720 // Not actually on the stack. Pull it out of the closure's context. | 721 RawLocalVarDescriptors::VarInfo var_info; |
| 721 intptr_t var_desc_len = var_descriptors_.Length(); | 722 var_descriptors_.GetInfo(i, &var_info); |
| 722 for (intptr_t i = 0; i < var_desc_len; i++) { | 723 if (var_descriptors_.GetName(i) == name.raw()) { |
| 723 RawLocalVarDescriptors::VarInfo var_info; | |
| 724 var_descriptors_.GetInfo(i, &var_info); | |
| 725 const int8_t kind = var_info.kind(); | 724 const int8_t kind = var_info.kind(); |
| 726 if (var_descriptors_.GetName(i) == Symbols::AsyncCompleter().raw()) { | 725 if (!live_frame_) { |
| 727 ASSERT(kind == RawLocalVarDescriptors::kContextVar); | 726 ASSERT(kind == RawLocalVarDescriptors::kContextVar); |
| 728 ASSERT(!ctx_.IsNull()); | |
| 729 return ctx_.At(var_info.index()); | |
| 730 } | 727 } |
| 731 } | 728 if (kind == RawLocalVarDescriptors::kStackVar) { |
| 732 } else { | 729 return GetStackVar(var_info.index()); |
| 733 ASSERT(fp() != 0); | 730 } else { |
| 734 // On the stack. | 731 ASSERT(kind == RawLocalVarDescriptors::kContextVar); |
| 735 for (intptr_t i = 0; i < var_desc_len; i++) { | 732 if (!live_frame_) { |
| 736 RawLocalVarDescriptors::VarInfo var_info; | 733 ASSERT(!ctx_.IsNull()); |
| 737 var_descriptors_.GetInfo(i, &var_info); | 734 return ctx_.At(var_info.index()); |
| 738 if (var_descriptors_.GetName(i) == Symbols::AsyncCompleter().raw()) { | |
| 739 const int8_t kind = var_info.kind(); | |
| 740 if (kind == RawLocalVarDescriptors::kStackVar) { | |
| 741 return GetStackVar(var_info.index()); | |
| 742 } else { | |
| 743 ASSERT(kind == RawLocalVarDescriptors::kContextVar); | |
| 744 return GetContextVar(var_info.scope_id, var_info.index()); | |
| 745 } | 735 } |
| 736 return GetContextVar(var_info.scope_id, var_info.index()); |
| 746 } | 737 } |
| 747 } | 738 } |
| 748 } | 739 } |
| 749 return Object::null(); | 740 return Object::null(); |
| 750 } | 741 } |
| 751 | 742 |
| 752 | 743 |
| 744 RawObject* ActivationFrame::GetAsyncCompleter() { |
| 745 return GetAsyncContextVariable(Symbols::AsyncCompleter()); |
| 746 } |
| 747 |
| 748 |
| 753 RawObject* ActivationFrame::GetAsyncCompleterAwaiter(const Object& completer) { | 749 RawObject* ActivationFrame::GetAsyncCompleterAwaiter(const Object& completer) { |
| 754 const Class& sync_completer_cls = Class::Handle(completer.clazz()); | 750 const Class& sync_completer_cls = Class::Handle(completer.clazz()); |
| 755 ASSERT(!sync_completer_cls.IsNull()); | 751 ASSERT(!sync_completer_cls.IsNull()); |
| 756 const Class& completer_cls = Class::Handle(sync_completer_cls.SuperClass()); | 752 const Class& completer_cls = Class::Handle(sync_completer_cls.SuperClass()); |
| 757 const Field& future_field = | 753 const Field& future_field = |
| 758 Field::Handle(completer_cls.LookupInstanceFieldAllowPrivate( | 754 Field::Handle(completer_cls.LookupInstanceFieldAllowPrivate( |
| 759 Symbols::CompleterFuture())); | 755 Symbols::CompleterFuture())); |
| 760 ASSERT(!future_field.IsNull()); | 756 ASSERT(!future_field.IsNull()); |
| 761 Instance& future = Instance::Handle(); | 757 Instance& future = Instance::Handle(); |
| 762 future ^= Instance::Cast(completer).GetField(future_field); | 758 future ^= Instance::Cast(completer).GetField(future_field); |
| 763 ASSERT(!future.IsNull()); | 759 ASSERT(!future.IsNull()); |
| 764 const Class& future_cls = Class::Handle(future.clazz()); | 760 const Class& future_cls = Class::Handle(future.clazz()); |
| 765 ASSERT(!future_cls.IsNull()); | 761 ASSERT(!future_cls.IsNull()); |
| 766 const Field& awaiter_field = Field::Handle( | 762 const Field& awaiter_field = Field::Handle( |
| 767 future_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); | 763 future_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); |
| 768 ASSERT(!awaiter_field.IsNull()); | 764 ASSERT(!awaiter_field.IsNull()); |
| 769 return future.GetField(awaiter_field); | 765 return future.GetField(awaiter_field); |
| 770 } | 766 } |
| 771 | 767 |
| 772 | 768 |
| 773 RawObject* ActivationFrame::GetAsyncStreamControllerStream() { | 769 RawObject* ActivationFrame::GetAsyncStreamControllerStream() { |
| 774 if (!function_.IsAsyncGenClosure()) { | 770 return GetAsyncContextVariable(Symbols::ControllerStream()); |
| 775 return Object::null(); | |
| 776 } | |
| 777 GetVarDescriptors(); | |
| 778 intptr_t var_desc_len = var_descriptors_.Length(); | |
| 779 if (!live_frame_) { | |
| 780 // Not actually on the stack. Pull it out of the closure's context. | |
| 781 intptr_t var_desc_len = var_descriptors_.Length(); | |
| 782 for (intptr_t i = 0; i < var_desc_len; i++) { | |
| 783 RawLocalVarDescriptors::VarInfo var_info; | |
| 784 var_descriptors_.GetInfo(i, &var_info); | |
| 785 const int8_t kind = var_info.kind(); | |
| 786 if (var_descriptors_.GetName(i) == Symbols::ControllerStream().raw()) { | |
| 787 ASSERT(kind == RawLocalVarDescriptors::kContextVar); | |
| 788 ASSERT(!ctx_.IsNull()); | |
| 789 return ctx_.At(var_info.index()); | |
| 790 } | |
| 791 } | |
| 792 } else { | |
| 793 ASSERT(fp() != 0); | |
| 794 // On the stack. | |
| 795 for (intptr_t i = 0; i < var_desc_len; i++) { | |
| 796 RawLocalVarDescriptors::VarInfo var_info; | |
| 797 var_descriptors_.GetInfo(i, &var_info); | |
| 798 if (var_descriptors_.GetName(i) == Symbols::ControllerStream().raw()) { | |
| 799 const int8_t kind = var_info.kind(); | |
| 800 if (kind == RawLocalVarDescriptors::kStackVar) { | |
| 801 return GetStackVar(var_info.index()); | |
| 802 } else { | |
| 803 ASSERT(kind == RawLocalVarDescriptors::kContextVar); | |
| 804 return GetContextVar(var_info.scope_id, var_info.index()); | |
| 805 } | |
| 806 } | |
| 807 } | |
| 808 } | |
| 809 return Object::null(); | |
| 810 } | 771 } |
| 811 | 772 |
| 812 | 773 |
| 813 RawObject* ActivationFrame::GetAsyncStreamControllerStreamAwaiter( | 774 RawObject* ActivationFrame::GetAsyncStreamControllerStreamAwaiter( |
| 814 const Object& stream) { | 775 const Object& stream) { |
| 815 const Class& stream_cls = Class::Handle(stream.clazz()); | 776 const Class& stream_cls = Class::Handle(stream.clazz()); |
| 816 ASSERT(!stream_cls.IsNull()); | 777 ASSERT(!stream_cls.IsNull()); |
| 817 const Class& stream_impl_cls = Class::Handle(stream_cls.SuperClass()); | 778 const Class& stream_impl_cls = Class::Handle(stream_cls.SuperClass()); |
| 818 const Field& awaiter_field = Field::Handle( | 779 const Field& awaiter_field = Field::Handle( |
| 819 stream_impl_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); | 780 stream_impl_cls.LookupInstanceFieldAllowPrivate(Symbols::_Awaiter())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 839 | 800 |
| 840 bool ActivationFrame::HandlesException(const Instance& exc_obj) { | 801 bool ActivationFrame::HandlesException(const Instance& exc_obj) { |
| 841 intptr_t try_index = TryIndex(); | 802 intptr_t try_index = TryIndex(); |
| 842 if (try_index < 0) { | 803 if (try_index < 0) { |
| 843 return false; | 804 return false; |
| 844 } | 805 } |
| 845 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); | 806 ExceptionHandlers& handlers = ExceptionHandlers::Handle(); |
| 846 Array& handled_types = Array::Handle(); | 807 Array& handled_types = Array::Handle(); |
| 847 AbstractType& type = Type::Handle(); | 808 AbstractType& type = Type::Handle(); |
| 848 const TypeArguments& no_instantiator = TypeArguments::Handle(); | 809 const TypeArguments& no_instantiator = TypeArguments::Handle(); |
| 849 const intptr_t try_index_threshold = CatchClauseNode::kImplicitAsyncTryIndex; | |
| 850 const bool is_async = | 810 const bool is_async = |
| 851 function().IsAsyncClosure() || function().IsAsyncGenClosure(); | 811 function().IsAsyncClosure() || function().IsAsyncGenClosure(); |
| 852 handlers = code().exception_handlers(); | 812 handlers = code().exception_handlers(); |
| 853 ASSERT(!handlers.IsNull()); | 813 ASSERT(!handlers.IsNull()); |
| 854 intptr_t num_handlers_checked = 0; | 814 intptr_t num_handlers_checked = 0; |
| 855 while (try_index >= try_index_threshold) { | 815 while (try_index != CatchClauseNode::kInvalidTryIndex) { |
| 856 // Detect circles in the exception handler data. | 816 // Detect circles in the exception handler data. |
| 857 num_handlers_checked++; | 817 num_handlers_checked++; |
| 858 ASSERT(num_handlers_checked <= handlers.num_entries()); | 818 ASSERT(num_handlers_checked <= handlers.num_entries()); |
| 859 // Only consider user written handlers for async methods. | 819 // Only consider user written handlers for async methods. |
| 860 if (!is_async || !handlers.IsGenerated(try_index)) { | 820 if (!is_async || !handlers.IsGenerated(try_index)) { |
| 861 handled_types = handlers.GetHandledTypes(try_index); | 821 handled_types = handlers.GetHandledTypes(try_index); |
| 862 const intptr_t num_types = handled_types.Length(); | 822 const intptr_t num_types = handled_types.Length(); |
| 863 for (intptr_t k = 0; k < num_types; k++) { | 823 for (intptr_t k = 0; k < num_types; k++) { |
| 864 type ^= handled_types.At(k); | 824 type ^= handled_types.At(k); |
| 865 ASSERT(!type.IsNull()); | 825 ASSERT(!type.IsNull()); |
| (...skipping 3289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4155 | 4115 |
| 4156 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { | 4116 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { |
| 4157 ASSERT(bpt->next() == NULL); | 4117 ASSERT(bpt->next() == NULL); |
| 4158 bpt->set_next(code_breakpoints_); | 4118 bpt->set_next(code_breakpoints_); |
| 4159 code_breakpoints_ = bpt; | 4119 code_breakpoints_ = bpt; |
| 4160 } | 4120 } |
| 4161 | 4121 |
| 4162 #endif // !PRODUCT | 4122 #endif // !PRODUCT |
| 4163 | 4123 |
| 4164 } // namespace dart | 4124 } // namespace dart |
| OLD | NEW |