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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 } | 392 } |
393 | 393 |
394 | 394 |
395 intptr_t RawRedirectionData::VisitRedirectionDataPointers( | 395 intptr_t RawRedirectionData::VisitRedirectionDataPointers( |
396 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { | 396 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { |
397 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 397 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
398 return RedirectionData::InstanceSize(); | 398 return RedirectionData::InstanceSize(); |
399 } | 399 } |
400 | 400 |
401 | 401 |
402 bool RawFunction::SkipCode(RawFunction* raw_fun) { | 402 bool RawFunction::CheckUsageCounter(RawFunction* raw_fun) { |
403 // NOTE: This code runs while GC is in progress and runs within | 403 // NOTE: This code runs while GC is in progress and runs within |
404 // a NoHandleScope block. Hence it is not okay to use regular Zone or | 404 // a NoHandleScope block. Hence it is not okay to use regular Zone or |
405 // Scope handles. We use direct stack handles, and so the raw pointers in | 405 // Scope handles. We use direct stack handles, and so the raw pointers in |
406 // these handles are not traversed. The use of handles is mainly to | 406 // these handles are not traversed. The use of handles is mainly to |
407 // be able to reuse the handle based code and avoid having to add | 407 // be able to reuse the handle based code and avoid having to add |
408 // helper functions to the raw object interface. | 408 // helper functions to the raw object interface. |
409 Function fn; | 409 Function fn; |
410 fn = raw_fun; | 410 fn = raw_fun; |
411 | 411 |
412 // The function may not have code. | |
413 if (!fn.HasCode()) return false; | |
414 // These may not increment the usage counter. | |
415 if (fn.is_intrinsic()) return false; | |
416 | |
417 if (fn.usage_counter() >= 0) { | |
418 fn.set_usage_counter(fn.usage_counter() / 2); | |
419 } | |
420 return FLAG_always_drop_code || (fn.usage_counter() == 0); | |
421 } | |
422 | |
423 | |
424 bool RawFunction::ShouldSkipCode(RawCode* raw_code) { | |
Vyacheslav Egorov (Google)
2015/04/09 15:03:46
I would call it ShouldVisitCode instead and invert
Florian Schneider
2015/04/09 15:07:50
Done.
| |
425 // NOTE: This code runs while GC is in progress and runs within | |
426 // a NoHandleScope block. Hence it is not okay to use regular Zone or | |
427 // Scope handles. We use direct stack handles, and so the raw pointers in | |
428 // these handles are not traversed. The use of handles is mainly to | |
429 // be able to reuse the handle based code and avoid having to add | |
430 // helper functions to the raw object interface. | |
412 Code code; | 431 Code code; |
413 code = fn.CurrentCode(); | 432 code = raw_code; |
414 | 433 if (code.IsNull()) return false; |
415 if (fn.HasCode() && // The function may not have code. | 434 if (code.is_optimized()) return false; |
416 !fn.is_intrinsic() && // These may not increment the usage counter. | 435 if (code.HasBreakpoint()) return false; |
417 !code.is_optimized() && | 436 return true; |
418 (fn.CurrentCode() == fn.unoptimized_code()) && | |
419 !code.HasBreakpoint() && | |
420 (fn.usage_counter() >= 0)) { | |
421 fn.set_usage_counter(fn.usage_counter() / 2); | |
422 if (FLAG_always_drop_code || (fn.usage_counter() == 0)) { | |
423 return true; | |
424 } | |
425 } | |
426 return false; | |
427 } | 437 } |
428 | 438 |
429 | 439 |
430 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, | 440 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, |
431 ObjectPointerVisitor* visitor) { | 441 ObjectPointerVisitor* visitor) { |
432 if (visitor->visit_function_code() || | 442 if (visitor->visit_function_code() || !CheckUsageCounter(raw_obj)) { |
433 !RawFunction::SkipCode(raw_obj)) { | |
434 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 443 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
444 return Function::InstanceSize(); | |
445 } | |
446 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); | |
447 | |
448 if (!ShouldSkipCode(raw_obj->ptr()->instructions_->ptr()->code_)) { | |
449 visitor->VisitPointer( | |
450 reinterpret_cast<RawObject**>(&raw_obj->ptr()->instructions_)); | |
435 } else { | 451 } else { |
436 GrowableArray<RawFunction*>* sfga = visitor->skipped_code_functions(); | 452 visitor->skipped_functions()->Add(raw_obj); |
437 ASSERT(sfga != NULL); | 453 } |
438 sfga->Add(raw_obj); | 454 |
439 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); | 455 if (!ShouldSkipCode(raw_obj->ptr()->unoptimized_code_)) { |
456 visitor->VisitPointer( | |
457 reinterpret_cast<RawObject**>(&raw_obj->ptr()->unoptimized_code_)); | |
458 } else { | |
459 visitor->skipped_functions()->Add(raw_obj); | |
440 } | 460 } |
441 return Function::InstanceSize(); | 461 return Function::InstanceSize(); |
442 } | 462 } |
443 | 463 |
444 | 464 |
445 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, | 465 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, |
446 ObjectPointerVisitor* visitor) { | 466 ObjectPointerVisitor* visitor) { |
447 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 467 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
448 return Field::InstanceSize(); | 468 return Field::InstanceSize(); |
449 } | 469 } |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 intptr_t RawUserTag::VisitUserTagPointers( | 927 intptr_t RawUserTag::VisitUserTagPointers( |
908 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 928 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
909 // Make sure that we got here with the tagged pointer as this. | 929 // Make sure that we got here with the tagged pointer as this. |
910 ASSERT(raw_obj->IsHeapObject()); | 930 ASSERT(raw_obj->IsHeapObject()); |
911 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 931 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
912 return UserTag::InstanceSize(); | 932 return UserTag::InstanceSize(); |
913 } | 933 } |
914 | 934 |
915 | 935 |
916 } // namespace dart | 936 } // namespace dart |
OLD | NEW |