Chromium Code Reviews| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 intptr_t RawRedirectionData::VisitRedirectionDataPointers( | 409 intptr_t RawRedirectionData::VisitRedirectionDataPointers( |
| 410 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { | 410 RawRedirectionData* raw_obj, ObjectPointerVisitor* visitor) { |
| 411 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 411 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 412 return RedirectionData::InstanceSize(); | 412 return RedirectionData::InstanceSize(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 | 415 |
| 416 bool RawFunction::SkipCode(RawFunction* raw_fun) { | 416 bool RawFunction::SkipCode(RawFunction* raw_fun, bool visit_current_code) { |
|
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
The name is *very* confusing. Rename it do somethi
Florian Schneider
2015/04/09 14:48:38
Done.
| |
| 417 // NOTE: This code runs while GC is in progress and runs within | 417 // NOTE: This code runs while GC is in progress and runs within |
| 418 // a NoHandleScope block. Hence it is not okay to use regular Zone or | 418 // a NoHandleScope block. Hence it is not okay to use regular Zone or |
| 419 // Scope handles. We use direct stack handles, and so the raw pointers in | 419 // Scope handles. We use direct stack handles, and so the raw pointers in |
| 420 // these handles are not traversed. The use of handles is mainly to | 420 // these handles are not traversed. The use of handles is mainly to |
| 421 // be able to reuse the handle based code and avoid having to add | 421 // be able to reuse the handle based code and avoid having to add |
| 422 // helper functions to the raw object interface. | 422 // helper functions to the raw object interface. |
| 423 Function fn; | 423 Function fn; |
| 424 fn = raw_fun; | 424 fn = raw_fun; |
| 425 | 425 |
| 426 Code code; | 426 Code code; |
| 427 code = fn.CurrentCode(); | 427 if (visit_current_code) { |
| 428 code = fn.CurrentCode(); | |
| 429 } else { | |
| 430 code = fn.unoptimized_code(); | |
| 431 } | |
| 428 | 432 |
| 429 if (fn.HasCode() && // The function may not have code. | 433 if (fn.HasCode() && // The function may not have code. |
| 430 !fn.is_intrinsic() && // These may not increment the usage counter. | 434 !fn.is_intrinsic() && // These may not increment the usage counter. |
| 431 !code.is_optimized() && | 435 (!visit_current_code || !code.is_optimized()) && |
| 432 (fn.CurrentCode() == fn.unoptimized_code()) && | |
| 433 !code.HasBreakpoint() && | 436 !code.HasBreakpoint() && |
| 434 (fn.usage_counter() >= 0)) { | 437 (fn.usage_counter() >= 0)) { |
| 435 fn.set_usage_counter(fn.usage_counter() / 2); | 438 fn.set_usage_counter(fn.usage_counter() / 2); |
| 436 if (FLAG_always_drop_code || (fn.usage_counter() == 0)) { | 439 if (FLAG_always_drop_code || (fn.usage_counter() == 0)) { |
|
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
return (FLAG_always_drop_code || ...);
Florian Schneider
2015/04/09 14:48:38
Done.
| |
| 437 return true; | 440 return true; |
| 438 } | 441 } |
| 439 } | 442 } |
| 440 return false; | 443 return false; |
| 441 } | 444 } |
| 442 | 445 |
| 443 | 446 |
| 444 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, | 447 intptr_t RawFunction::VisitFunctionPointers(RawFunction* raw_obj, |
| 445 ObjectPointerVisitor* visitor) { | 448 ObjectPointerVisitor* visitor) { |
| 446 if (visitor->visit_function_code() || | 449 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); |
| 447 !RawFunction::SkipCode(raw_obj)) { | 450 if (visitor->visit_function_code() || !SkipCode(raw_obj, true)) { |
|
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
I think bool parameter is a bit confusing. Maybe p
Florian Schneider
2015/04/09 14:48:38
Done.
| |
| 448 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 451 visitor->VisitPointer( |
| 452 reinterpret_cast<RawObject**>(&raw_obj->ptr()->instructions_)); | |
| 449 } else { | 453 } else { |
| 450 GrowableArray<RawFunction*>* sfga = visitor->skipped_code_functions(); | 454 visitor->skipped_current_code_functions()->Add(raw_obj); |
| 451 ASSERT(sfga != NULL); | 455 } |
| 452 sfga->Add(raw_obj); | 456 |
| 453 visitor->VisitPointers(raw_obj->from(), raw_obj->to_no_code()); | 457 if (visitor->visit_function_code() || !SkipCode(raw_obj, false)) { |
|
Vyacheslav Egorov (Google)
2015/04/09 12:23:08
we decay fn.usage_counter() twice. I think it shou
Florian Schneider
2015/04/09 14:48:38
Done.
| |
| 458 visitor->VisitPointer( | |
| 459 reinterpret_cast<RawObject**>(&raw_obj->ptr()->unoptimized_code_)); | |
| 460 } else { | |
| 461 visitor->skipped_unoptimized_code_functions()->Add(raw_obj); | |
| 454 } | 462 } |
| 455 return Function::InstanceSize(); | 463 return Function::InstanceSize(); |
| 456 } | 464 } |
| 457 | 465 |
| 458 | 466 |
| 459 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, | 467 intptr_t RawField::VisitFieldPointers(RawField* raw_obj, |
| 460 ObjectPointerVisitor* visitor) { | 468 ObjectPointerVisitor* visitor) { |
| 461 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 469 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 462 return Field::InstanceSize(); | 470 return Field::InstanceSize(); |
| 463 } | 471 } |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 intptr_t RawUserTag::VisitUserTagPointers( | 939 intptr_t RawUserTag::VisitUserTagPointers( |
| 932 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { | 940 RawUserTag* raw_obj, ObjectPointerVisitor* visitor) { |
| 933 // Make sure that we got here with the tagged pointer as this. | 941 // Make sure that we got here with the tagged pointer as this. |
| 934 ASSERT(raw_obj->IsHeapObject()); | 942 ASSERT(raw_obj->IsHeapObject()); |
| 935 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); | 943 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); |
| 936 return UserTag::InstanceSize(); | 944 return UserTag::InstanceSize(); |
| 937 } | 945 } |
| 938 | 946 |
| 939 | 947 |
| 940 } // namespace dart | 948 } // namespace dart |
| OLD | NEW |