| 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/raw_object.h" | 5 #include "vm/raw_object.h" |
| 6 | 6 |
| 7 #include "vm/class_table.h" | 7 #include "vm/class_table.h" |
| 8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
| 9 #include "vm/freelist.h" | 9 #include "vm/freelist.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 359 } |
| 360 | 360 |
| 361 | 361 |
| 362 intptr_t RawRedirectionData::VisitRedirectionDataPointers( | 362 intptr_t RawRedirectionData::VisitRedirectionDataPointers( |
| 363 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { | 363 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { |
| 364 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 364 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 365 return RedirectionData::InstanceSize(); | 365 return RedirectionData::InstanceSize(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 | 368 |
| 369 bool RawFunction::SkipCode(RawFunction* raw_fun) { |
| 370 // NOTE: This code runs while GC is in progress and runs within |
| 371 // a NoHandleScope block. Hence it is not okay to use regular Zone or |
| 372 // Scope handles. We use direct stack handles, and so the raw pointers in |
| 373 // these handles are not traversed. The use of handles is mainly to |
| 374 // be able to reuse the handle based code and avoid having to add |
| 375 // helper functions to the raw object interface. |
| 376 Function fn; |
| 377 fn = raw_fun; |
| 378 |
| 379 Code code; |
| 380 code = fn.CurrentCode(); |
| 381 |
| 382 if (!code.IsNull() && // The function may not have code. |
| 383 !code.is_optimized() && |
| 384 (fn.CurrentCode() == fn.unoptimized_code()) && |
| 385 !fn.HasBreakpoint() && |
| 386 (fn.usage_counter() >= 0)) { |
| 387 fn.set_usage_counter(fn.usage_counter() / 2); |
| 388 if (FLAG_always_drop_code || (fn.usage_counter() == 0)) { |
| 389 return true; |
| 390 } |
| 391 } |
| 392 return false; |
| 393 } |
| 394 |
| 395 |
| 369 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, | 396 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, |
| 370 ObjectPointerVisitor* visitor) { | 397 ObjectPointerVisitor* visitor) { |
| 371 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 398 if (visitor->visit_function_code() || |
| 399 !RawFunction::SkipCode(raw_obj)) { |
| 400 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 401 } else { |
| 402 GrowableArray<RawFunction*>* sfga = visitor->skipped_code_functions(); |
| 403 ASSERT(sfga != NULL); |
| 404 sfga->Add(raw_obj); |
| 405 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); |
| 406 } |
| 372 return Function::InstanceSize(); | 407 return Function::InstanceSize(); |
| 373 } | 408 } |
| 374 | 409 |
| 375 | 410 |
| 376 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, | 411 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, |
| 377 ObjectPointerVisitor* visitor) { | 412 ObjectPointerVisitor* visitor) { |
| 378 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 413 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 379 return Field::InstanceSize(); | 414 return Field::InstanceSize(); |
| 380 } | 415 } |
| 381 | 416 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 | 836 |
| 802 intptr_t RawMirrorReference::VisitMirrorReferencePointers( | 837 intptr_t RawMirrorReference::VisitMirrorReferencePointers( |
| 803 RawMirrorReference* raw_obj, ObjectPointerVisitor* visitor) { | 838 RawMirrorReference* raw_obj, ObjectPointerVisitor* visitor) { |
| 804 // Make sure that we got here with the tagged pointer as this. | 839 // Make sure that we got here with the tagged pointer as this. |
| 805 ASSERT(raw_obj->IsHeapObject()); | 840 ASSERT(raw_obj->IsHeapObject()); |
| 806 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 841 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 807 return MirrorReference::InstanceSize(); | 842 return MirrorReference::InstanceSize(); |
| 808 } | 843 } |
| 809 | 844 |
| 810 } // namespace dart | 845 } // namespace dart |
| OLD | NEW |