| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "lib/mirrors.h" | 9 #include "lib/mirrors.h" |
| 10 #include "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 ICData* Isolate::GetICDataForDeoptId(intptr_t deopt_id) const { | 425 ICData* Isolate::GetICDataForDeoptId(intptr_t deopt_id) const { |
| 426 if (ic_data_array() == Array::null()) { | 426 if (ic_data_array() == Array::null()) { |
| 427 return &ICData::ZoneHandle(); | 427 return &ICData::ZoneHandle(); |
| 428 } | 428 } |
| 429 const Array& array_handle = Array::Handle(ic_data_array()); | 429 const Array& array_handle = Array::Handle(ic_data_array()); |
| 430 if (deopt_id >= array_handle.Length()) { | 430 if (deopt_id >= array_handle.Length()) { |
| 431 // For computations being added in the optimizing compiler. | 431 // For computations being added in the optimizing compiler. |
| 432 return &ICData::ZoneHandle(); | 432 return &ICData::ZoneHandle(); |
| 433 } | 433 } |
| 434 ICData& ic_data_handle = ICData::ZoneHandle(); | 434 ICData& ic_data_handle = ICData::ZoneHandle(); |
| 435 ic_data_handle |= array_handle.At(deopt_id); | 435 ic_data_handle ^= array_handle.At(deopt_id); |
| 436 return &ic_data_handle; | 436 return &ic_data_handle; |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 static int MostUsedFunctionFirst(const Function* const* a, | 440 static int MostUsedFunctionFirst(const Function* const* a, |
| 441 const Function* const* b) { | 441 const Function* const* b) { |
| 442 if ((*a)->usage_counter() > (*b)->usage_counter()) { | 442 if ((*a)->usage_counter() > (*b)->usage_counter()) { |
| 443 return -1; | 443 return -1; |
| 444 } else if ((*a)->usage_counter() < (*b)->usage_counter()) { | 444 } else if ((*a)->usage_counter() < (*b)->usage_counter()) { |
| 445 return 1; | 445 return 1; |
| 446 } else { | 446 } else { |
| 447 return 0; | 447 return 0; |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 | 450 |
| 451 | 451 |
| 452 static void AddFunctionsFromClass(const Class& cls, | 452 static void AddFunctionsFromClass(const Class& cls, |
| 453 GrowableArray<const Function*>* functions) { | 453 GrowableArray<const Function*>* functions) { |
| 454 const Array& class_functions = Array::Handle(cls.functions()); | 454 const Array& class_functions = Array::Handle(cls.functions()); |
| 455 // Class 'dynamic' is allocated/initialized in a special way, leaving | 455 // Class 'dynamic' is allocated/initialized in a special way, leaving |
| 456 // the functions field NULL instead of empty. | 456 // the functions field NULL instead of empty. |
| 457 const int func_len = class_functions.IsNull() ? 0 : class_functions.Length(); | 457 const int func_len = class_functions.IsNull() ? 0 : class_functions.Length(); |
| 458 for (int j = 0; j < func_len; j++) { | 458 for (int j = 0; j < func_len; j++) { |
| 459 Function& function = Function::Handle(); | 459 Function& function = Function::Handle(); |
| 460 function |= class_functions.At(j); | 460 function ^= class_functions.At(j); |
| 461 if (function.usage_counter() > 0) { | 461 if (function.usage_counter() > 0) { |
| 462 functions->Add(&function); | 462 functions->Add(&function); |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 | 466 |
| 467 | 467 |
| 468 void Isolate::PrintInvokedFunctions() { | 468 void Isolate::PrintInvokedFunctions() { |
| 469 ASSERT(this == Isolate::Current()); | 469 ASSERT(this == Isolate::Current()); |
| 470 StackZone zone(this); | 470 StackZone zone(this); |
| 471 HandleScope handle_scope(this); | 471 HandleScope handle_scope(this); |
| 472 const GrowableObjectArray& libraries = | 472 const GrowableObjectArray& libraries = |
| 473 GrowableObjectArray::Handle(object_store()->libraries()); | 473 GrowableObjectArray::Handle(object_store()->libraries()); |
| 474 Library& library = Library::Handle(); | 474 Library& library = Library::Handle(); |
| 475 GrowableArray<const Function*> invoked_functions; | 475 GrowableArray<const Function*> invoked_functions; |
| 476 for (int i = 0; i < libraries.Length(); i++) { | 476 for (int i = 0; i < libraries.Length(); i++) { |
| 477 library |= libraries.At(i); | 477 library ^= libraries.At(i); |
| 478 Class& cls = Class::Handle(); | 478 Class& cls = Class::Handle(); |
| 479 ClassDictionaryIterator iter(library); | 479 ClassDictionaryIterator iter(library); |
| 480 while (iter.HasNext()) { | 480 while (iter.HasNext()) { |
| 481 cls = iter.GetNextClass(); | 481 cls = iter.GetNextClass(); |
| 482 AddFunctionsFromClass(cls, &invoked_functions); | 482 AddFunctionsFromClass(cls, &invoked_functions); |
| 483 } | 483 } |
| 484 Array& anon_classes = Array::Handle(library.raw_ptr()->anonymous_classes_); | 484 Array& anon_classes = Array::Handle(library.raw_ptr()->anonymous_classes_); |
| 485 for (int i = 0; i < library.raw_ptr()->num_anonymous_; i++) { | 485 for (int i = 0; i < library.raw_ptr()->num_anonymous_; i++) { |
| 486 cls |= anon_classes.At(i); | 486 cls ^= anon_classes.At(i); |
| 487 AddFunctionsFromClass(cls, &invoked_functions); | 487 AddFunctionsFromClass(cls, &invoked_functions); |
| 488 } | 488 } |
| 489 } | 489 } |
| 490 invoked_functions.Sort(MostUsedFunctionFirst); | 490 invoked_functions.Sort(MostUsedFunctionFirst); |
| 491 for (int i = 0; i < invoked_functions.length(); i++) { | 491 for (int i = 0; i < invoked_functions.length(); i++) { |
| 492 OS::Print("%10"Pd" x %s\n", | 492 OS::Print("%10"Pd" x %s\n", |
| 493 invoked_functions[i]->usage_counter(), | 493 invoked_functions[i]->usage_counter(), |
| 494 invoked_functions[i]->ToFullyQualifiedCString()); | 494 invoked_functions[i]->ToFullyQualifiedCString()); |
| 495 } | 495 } |
| 496 } | 496 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 | 616 |
| 617 | 617 |
| 618 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, | 618 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, |
| 619 bool visit_prologue_weak_handles) { | 619 bool visit_prologue_weak_handles) { |
| 620 if (api_state() != NULL) { | 620 if (api_state() != NULL) { |
| 621 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); | 621 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); |
| 622 } | 622 } |
| 623 } | 623 } |
| 624 | 624 |
| 625 } // namespace dart | 625 } // namespace dart |
| OLD | NEW |