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

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

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