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

Side by Side Diff: vm/debugger.cc

Issue 9634002: Use GrowableObjectArray in the debugger instance/static field lists. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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 "vm/code_index_table.h" 7 #include "vm/code_index_table.h"
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return line_number_; 175 return line_number_;
176 } 176 }
177 177
178 178
179 void ActivationFrame::GetDescIndices() { 179 void ActivationFrame::GetDescIndices() {
180 if (var_descriptors_ == NULL) { 180 if (var_descriptors_ == NULL) {
181 ASSERT(!DartFunction().HasOptimizedCode()); 181 ASSERT(!DartFunction().HasOptimizedCode());
182 const Code& code = Code::Handle(DartFunction().unoptimized_code()); 182 const Code& code = Code::Handle(DartFunction().unoptimized_code());
183 var_descriptors_ = 183 var_descriptors_ =
184 &LocalVarDescriptors::ZoneHandle(code.var_descriptors()); 184 &LocalVarDescriptors::ZoneHandle(code.var_descriptors());
185 // TODO(Hausner): Consider replacing this GrowableArray.
185 GrowableArray<String*> var_names(8); 186 GrowableArray<String*> var_names(8);
186 intptr_t activation_token_pos = TokenIndex(); 187 intptr_t activation_token_pos = TokenIndex();
187 intptr_t var_desc_len = var_descriptors_->Length(); 188 intptr_t var_desc_len = var_descriptors_->Length();
188 for (int cur_idx = 0; cur_idx < var_desc_len; cur_idx++) { 189 for (int cur_idx = 0; cur_idx < var_desc_len; cur_idx++) {
189 ASSERT(var_names.length() == desc_indices_.length()); 190 ASSERT(var_names.length() == desc_indices_.length());
190 intptr_t scope_id, begin_pos, end_pos; 191 intptr_t scope_id, begin_pos, end_pos;
191 var_descriptors_->GetScopeInfo(cur_idx, &scope_id, &begin_pos, &end_pos); 192 var_descriptors_->GetScopeInfo(cur_idx, &scope_id, &begin_pos, &end_pos);
192 if ((begin_pos <= activation_token_pos) && 193 if ((begin_pos <= activation_token_pos) &&
193 (activation_token_pos <= end_pos)) { 194 (activation_token_pos <= end_pos)) {
194 // The current variable is textually in scope. Now check whether 195 // The current variable is textually in scope. Now check whether
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 if (verbose) { 653 if (verbose) {
653 OS::Print("No executable code at line %d in '%s'\n", 654 OS::Print("No executable code at line %d in '%s'\n",
654 line_number, script_url.ToCString()); 655 line_number, script_url.ToCString());
655 } 656 }
656 return NULL; 657 return NULL;
657 } 658 }
658 return SetBreakpoint(func, token_index_at_line); 659 return SetBreakpoint(func, token_index_at_line);
659 } 660 }
660 661
661 662
662 static RawArray* MakeNameValueList(const GrowableArray<Object*>& pairs) {
663 int pairs_len = pairs.length();
664 ASSERT(pairs_len % 2 == 0);
665 const Array& list = Array::Handle(Array::New(pairs_len));
666 for (int i = 0; i < pairs_len; i++) {
667 list.SetAt(i, *pairs[i]);
668 }
669 return list.raw();
670 }
671
672
673 // TODO(hausner): Merge some of this functionality with the code in 663 // TODO(hausner): Merge some of this functionality with the code in
674 // dart_api_impl.cc. 664 // dart_api_impl.cc.
675 RawObject* Debugger::GetInstanceField(const Class& cls, 665 RawObject* Debugger::GetInstanceField(const Class& cls,
676 const String& field_name, 666 const String& field_name,
677 const Instance& object) { 667 const Instance& object) {
678 const Function& getter_func = 668 const Function& getter_func =
679 Function::Handle(cls.LookupGetterFunction(field_name)); 669 Function::Handle(cls.LookupGetterFunction(field_name));
680 ASSERT(!getter_func.IsNull()); 670 ASSERT(!getter_func.IsNull());
681 671
682 Object& result = Object::Handle(); 672 Object& result = Object::Handle();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 705 }
716 isolate_->set_long_jump_base(base); 706 isolate_->set_long_jump_base(base);
717 return result.raw(); 707 return result.raw();
718 } 708 }
719 709
720 710
721 RawArray* Debugger::GetInstanceFields(const Instance& obj) { 711 RawArray* Debugger::GetInstanceFields(const Instance& obj) {
722 Class& cls = Class::Handle(obj.clazz()); 712 Class& cls = Class::Handle(obj.clazz());
723 Array& fields = Array::Handle(); 713 Array& fields = Array::Handle();
724 Field& field = Field::Handle(); 714 Field& field = Field::Handle();
725 GrowableArray<Object*> field_list(8); 715 const GrowableObjectArray& field_list =
716 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
717 String& field_name = String::Handle();
718 Object& field_value = Object::Handle();
726 // Iterate over fields in class hierarchy to count all instance fields. 719 // Iterate over fields in class hierarchy to count all instance fields.
727 while (!cls.IsNull()) { 720 while (!cls.IsNull()) {
728 fields = cls.fields(); 721 fields = cls.fields();
729 for (int i = 0; i < fields.Length(); i++) { 722 for (int i = 0; i < fields.Length(); i++) {
730 field ^= fields.At(i); 723 field ^= fields.At(i);
731 if (!field.is_static()) { 724 if (!field.is_static()) {
732 String& field_name = String::Handle(field.name()); 725 field_name = field.name();
733 field_list.Add(&field_name); 726 field_list.Add(field_name);
734 Object& field_value = Object::Handle();
735 field_value = GetInstanceField(cls, field_name, obj); 727 field_value = GetInstanceField(cls, field_name, obj);
736 field_list.Add(&field_value); 728 field_list.Add(field_value);
737 } 729 }
738 } 730 }
739 cls = cls.SuperClass(); 731 cls = cls.SuperClass();
740 } 732 }
741 return MakeNameValueList(field_list); 733 return Array::MakeArray(field_list);
742 } 734 }
743 735
744 736
745 RawArray* Debugger::GetStaticFields(const Class& cls) { 737 RawArray* Debugger::GetStaticFields(const Class& cls) {
746 GrowableArray<Object*> field_list(8); 738 const GrowableObjectArray& field_list =
739 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
747 Array& fields = Array::Handle(cls.fields()); 740 Array& fields = Array::Handle(cls.fields());
748 Field& field = Field::Handle(); 741 Field& field = Field::Handle();
742 String& field_name = String::Handle();
743 Object& field_value = Object::Handle();
749 for (int i = 0; i < fields.Length(); i++) { 744 for (int i = 0; i < fields.Length(); i++) {
750 field ^= fields.At(i); 745 field ^= fields.At(i);
751 if (field.is_static()) { 746 if (field.is_static()) {
752 String& field_name = String::Handle(field.name()); 747 field_name = field.name();
753 Object& field_value = Object::Handle(GetStaticField(cls, field_name)); 748 field_value = GetStaticField(cls, field_name);
754 field_list.Add(&field_name); 749 field_list.Add(field_name);
755 field_list.Add(&field_value); 750 field_list.Add(field_value);
756 } 751 }
757 } 752 }
758 return MakeNameValueList(field_list); 753 return Array::MakeArray(field_list);
759 } 754 }
760 755
761 756
762 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { 757 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) {
763 ASSERT(visitor != NULL); 758 ASSERT(visitor != NULL);
764 SourceBreakpoint* bpt = src_breakpoints_; 759 SourceBreakpoint* bpt = src_breakpoints_;
765 while (bpt != NULL) { 760 while (bpt != NULL) {
766 bpt->VisitObjectPointers(visitor); 761 bpt->VisitObjectPointers(visitor);
767 bpt = bpt->next(); 762 bpt = bpt->next();
768 } 763 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 } 1010 }
1016 1011
1017 1012
1018 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 1013 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
1019 ASSERT(bpt->next() == NULL); 1014 ASSERT(bpt->next() == NULL);
1020 bpt->set_next(code_breakpoints_); 1015 bpt->set_next(code_breakpoints_);
1021 code_breakpoints_ = bpt; 1016 code_breakpoints_ = bpt;
1022 } 1017 }
1023 1018
1024 } // namespace dart 1019 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698