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

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

Issue 2968003004: Revert "The current growth strategy for growable arrays allocates a backing array of size 2 at (emp… (Closed)
Patch Set: Created 3 years, 5 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/dart_api_impl.cc ('k') | runtime/vm/debugger_api_impl.cc » ('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) 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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 // of the activation's current scope. 1368 // of the activation's current scope.
1369 if (!conflict) { 1369 if (!conflict) {
1370 param_names.Add(name); 1370 param_names.Add(name);
1371 param_values.Add(value); 1371 param_values.Add(value);
1372 } 1372 }
1373 } 1373 }
1374 } 1374 }
1375 1375
1376 if (function().is_static()) { 1376 if (function().is_static()) {
1377 const Class& cls = Class::Handle(function().Owner()); 1377 const Class& cls = Class::Handle(function().Owner());
1378 return cls.Evaluate(expr, 1378 return cls.Evaluate(expr, Array::Handle(Array::MakeArray(param_names)),
1379 Array::Handle(Array::MakeFixedLength(param_names)), 1379 Array::Handle(Array::MakeArray(param_values)));
1380 Array::Handle(Array::MakeFixedLength(param_values)));
1381 } else { 1380 } else {
1382 const Object& receiver = Object::Handle(GetReceiver()); 1381 const Object& receiver = Object::Handle(GetReceiver());
1383 const Class& method_cls = Class::Handle(function().origin()); 1382 const Class& method_cls = Class::Handle(function().origin());
1384 ASSERT(receiver.IsInstance() || receiver.IsNull()); 1383 ASSERT(receiver.IsInstance() || receiver.IsNull());
1385 if (!(receiver.IsInstance() || receiver.IsNull())) { 1384 if (!(receiver.IsInstance() || receiver.IsNull())) {
1386 return Object::null(); 1385 return Object::null();
1387 } 1386 }
1388 const Instance& inst = Instance::Cast(receiver); 1387 const Instance& inst = Instance::Cast(receiver);
1389 return inst.Evaluate(method_cls, expr, 1388 return inst.Evaluate(method_cls, expr,
1390 Array::Handle(Array::MakeFixedLength(param_names)), 1389 Array::Handle(Array::MakeArray(param_names)),
1391 Array::Handle(Array::MakeFixedLength(param_values))); 1390 Array::Handle(Array::MakeArray(param_values)));
1392 } 1391 }
1393 UNREACHABLE(); 1392 UNREACHABLE();
1394 return Object::null(); 1393 return Object::null();
1395 } 1394 }
1396 1395
1397 1396
1398 const char* ActivationFrame::ToCString() { 1397 const char* ActivationFrame::ToCString() {
1399 const String& url = String::Handle(SourceUrl()); 1398 const String& url = String::Handle(SourceUrl());
1400 intptr_t line = LineNumber(); 1399 intptr_t line = LineNumber();
1401 const char* func_name = Debugger::QualifiedFunctionName(function()); 1400 const char* func_name = Debugger::QualifiedFunctionName(function());
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
3169 field ^= fields.At(i); 3168 field ^= fields.At(i);
3170 if (!field.is_static()) { 3169 if (!field.is_static()) {
3171 field_name = field.name(); 3170 field_name = field.name();
3172 field_list.Add(field_name); 3171 field_list.Add(field_name);
3173 field_value = GetInstanceField(cls, field_name, obj); 3172 field_value = GetInstanceField(cls, field_name, obj);
3174 field_list.Add(field_value); 3173 field_list.Add(field_value);
3175 } 3174 }
3176 } 3175 }
3177 cls = cls.SuperClass(); 3176 cls = cls.SuperClass();
3178 } 3177 }
3179 return Array::MakeFixedLength(field_list); 3178 return Array::MakeArray(field_list);
3180 } 3179 }
3181 3180
3182 3181
3183 RawArray* Debugger::GetStaticFields(const Class& cls) { 3182 RawArray* Debugger::GetStaticFields(const Class& cls) {
3184 const GrowableObjectArray& field_list = 3183 const GrowableObjectArray& field_list =
3185 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); 3184 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
3186 Array& fields = Array::Handle(cls.fields()); 3185 Array& fields = Array::Handle(cls.fields());
3187 Field& field = Field::Handle(); 3186 Field& field = Field::Handle();
3188 String& field_name = String::Handle(); 3187 String& field_name = String::Handle();
3189 PassiveObject& field_value = PassiveObject::Handle(); 3188 PassiveObject& field_value = PassiveObject::Handle();
3190 for (intptr_t i = 0; i < fields.Length(); i++) { 3189 for (intptr_t i = 0; i < fields.Length(); i++) {
3191 field ^= fields.At(i); 3190 field ^= fields.At(i);
3192 if (field.is_static()) { 3191 if (field.is_static()) {
3193 field_name = field.name(); 3192 field_name = field.name();
3194 field_value = GetStaticField(cls, field_name); 3193 field_value = GetStaticField(cls, field_name);
3195 field_list.Add(field_name); 3194 field_list.Add(field_name);
3196 field_list.Add(field_value); 3195 field_list.Add(field_value);
3197 } 3196 }
3198 } 3197 }
3199 return Array::MakeFixedLength(field_list); 3198 return Array::MakeArray(field_list);
3200 } 3199 }
3201 3200
3202 3201
3203 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list, 3202 void Debugger::CollectLibraryFields(const GrowableObjectArray& field_list,
3204 const Library& lib, 3203 const Library& lib,
3205 const String& prefix, 3204 const String& prefix,
3206 bool include_private_fields) { 3205 bool include_private_fields) {
3207 DictionaryIterator it(lib); 3206 DictionaryIterator it(lib);
3208 Zone* zone = Thread::Current()->zone(); 3207 Zone* zone = Thread::Current()->zone();
3209 Object& entry = Object::Handle(zone); 3208 Object& entry = Object::Handle(zone);
(...skipping 27 matching lines...) Expand all
3237 } 3236 }
3238 } 3237 }
3239 } 3238 }
3240 3239
3241 3240
3242 RawArray* Debugger::GetLibraryFields(const Library& lib) { 3241 RawArray* Debugger::GetLibraryFields(const Library& lib) {
3243 Zone* zone = Thread::Current()->zone(); 3242 Zone* zone = Thread::Current()->zone();
3244 const GrowableObjectArray& field_list = 3243 const GrowableObjectArray& field_list =
3245 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); 3244 GrowableObjectArray::Handle(GrowableObjectArray::New(8));
3246 CollectLibraryFields(field_list, lib, String::Handle(zone), true); 3245 CollectLibraryFields(field_list, lib, String::Handle(zone), true);
3247 return Array::MakeFixedLength(field_list); 3246 return Array::MakeArray(field_list);
3248 } 3247 }
3249 3248
3250 3249
3251 RawArray* Debugger::GetGlobalFields(const Library& lib) { 3250 RawArray* Debugger::GetGlobalFields(const Library& lib) {
3252 Zone* zone = Thread::Current()->zone(); 3251 Zone* zone = Thread::Current()->zone();
3253 const GrowableObjectArray& field_list = 3252 const GrowableObjectArray& field_list =
3254 GrowableObjectArray::Handle(zone, GrowableObjectArray::New(8)); 3253 GrowableObjectArray::Handle(zone, GrowableObjectArray::New(8));
3255 String& prefix_name = String::Handle(zone); 3254 String& prefix_name = String::Handle(zone);
3256 CollectLibraryFields(field_list, lib, prefix_name, true); 3255 CollectLibraryFields(field_list, lib, prefix_name, true);
3257 Library& imported = Library::Handle(zone); 3256 Library& imported = Library::Handle(zone);
3258 intptr_t num_imports = lib.num_imports(); 3257 intptr_t num_imports = lib.num_imports();
3259 for (intptr_t i = 0; i < num_imports; i++) { 3258 for (intptr_t i = 0; i < num_imports; i++) {
3260 imported = lib.ImportLibraryAt(i); 3259 imported = lib.ImportLibraryAt(i);
3261 ASSERT(!imported.IsNull()); 3260 ASSERT(!imported.IsNull());
3262 CollectLibraryFields(field_list, imported, prefix_name, false); 3261 CollectLibraryFields(field_list, imported, prefix_name, false);
3263 } 3262 }
3264 LibraryPrefix& prefix = LibraryPrefix::Handle(zone); 3263 LibraryPrefix& prefix = LibraryPrefix::Handle(zone);
3265 LibraryPrefixIterator it(lib); 3264 LibraryPrefixIterator it(lib);
3266 while (it.HasNext()) { 3265 while (it.HasNext()) {
3267 prefix = it.GetNext(); 3266 prefix = it.GetNext();
3268 prefix_name = prefix.name(); 3267 prefix_name = prefix.name();
3269 ASSERT(!prefix_name.IsNull()); 3268 ASSERT(!prefix_name.IsNull());
3270 prefix_name = String::Concat(prefix_name, Symbols::Dot()); 3269 prefix_name = String::Concat(prefix_name, Symbols::Dot());
3271 for (int32_t i = 0; i < prefix.num_imports(); i++) { 3270 for (int32_t i = 0; i < prefix.num_imports(); i++) {
3272 imported = prefix.GetLibrary(i); 3271 imported = prefix.GetLibrary(i);
3273 CollectLibraryFields(field_list, imported, prefix_name, false); 3272 CollectLibraryFields(field_list, imported, prefix_name, false);
3274 } 3273 }
3275 } 3274 }
3276 return Array::MakeFixedLength(field_list); 3275 return Array::MakeArray(field_list);
3277 } 3276 }
3278 3277
3279 3278
3280 // static 3279 // static
3281 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { 3280 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) {
3282 ASSERT(visitor != NULL); 3281 ASSERT(visitor != NULL);
3283 BreakpointLocation* bpt = breakpoint_locations_; 3282 BreakpointLocation* bpt = breakpoint_locations_;
3284 while (bpt != NULL) { 3283 while (bpt != NULL) {
3285 bpt->VisitObjectPointers(visitor); 3284 bpt->VisitObjectPointers(visitor);
3286 bpt = bpt->next(); 3285 bpt = bpt->next();
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 4528
4530 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 4529 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
4531 ASSERT(bpt->next() == NULL); 4530 ASSERT(bpt->next() == NULL);
4532 bpt->set_next(code_breakpoints_); 4531 bpt->set_next(code_breakpoints_);
4533 code_breakpoints_ = bpt; 4532 code_breakpoints_ = bpt;
4534 } 4533 }
4535 4534
4536 #endif // !PRODUCT 4535 #endif // !PRODUCT
4537 4536
4538 } // namespace dart 4537 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698