| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
| 6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
| 9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
| 10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 template <typename StaticVisitor> | 408 template <typename StaticVisitor> |
| 409 void StaticMarkingVisitor<StaticVisitor>::VisitCode(Map* map, | 409 void StaticMarkingVisitor<StaticVisitor>::VisitCode(Map* map, |
| 410 HeapObject* object) { | 410 HeapObject* object) { |
| 411 typedef FlexibleBodyVisitor<StaticVisitor, Code::BodyDescriptor, void> | 411 typedef FlexibleBodyVisitor<StaticVisitor, Code::BodyDescriptor, void> |
| 412 CodeBodyVisitor; | 412 CodeBodyVisitor; |
| 413 Heap* heap = map->GetHeap(); | 413 Heap* heap = map->GetHeap(); |
| 414 Code* code = Code::cast(object); | 414 Code* code = Code::cast(object); |
| 415 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) { | 415 if (FLAG_age_code && !heap->isolate()->serializer_enabled()) { |
| 416 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); | 416 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); |
| 417 } | 417 } |
| 418 MarkCompactCollector* collector = heap->mark_compact_collector(); | |
| 419 if (collector->is_code_flushing_enabled()) { | |
| 420 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | |
| 421 // Visit all unoptimized code objects to prevent flushing them. | |
| 422 MarkInlinedFunctionsCode(heap, code); | |
| 423 } | |
| 424 } | |
| 425 CodeBodyVisitor::Visit(map, object); | 418 CodeBodyVisitor::Visit(map, object); |
| 426 } | 419 } |
| 427 | 420 |
| 428 | 421 |
| 429 template <typename StaticVisitor> | 422 template <typename StaticVisitor> |
| 430 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( | 423 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( |
| 431 Map* map, HeapObject* object) { | 424 Map* map, HeapObject* object) { |
| 432 Heap* heap = map->GetHeap(); | 425 Heap* heap = map->GetHeap(); |
| 433 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); | 426 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); |
| 434 if (shared->ic_age() != heap->global_ic_age()) { | 427 if (shared->ic_age() != heap->global_ic_age()) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | 591 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); |
| 599 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | 592 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && |
| 600 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | 593 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { |
| 601 StaticVisitor::VisitPointer( | 594 StaticVisitor::VisitPointer( |
| 602 heap, code_map, | 595 heap, code_map, |
| 603 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); | 596 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); |
| 604 } | 597 } |
| 605 } | 598 } |
| 606 | 599 |
| 607 | 600 |
| 608 template <typename StaticVisitor> | |
| 609 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, | |
| 610 Code* code) { | |
| 611 // For optimized functions we should retain both non-optimized version | |
| 612 // of its code and non-optimized version of all inlined functions. | |
| 613 // This is required to support bailing out from inlined code. | |
| 614 if (code->deoptimization_data() != heap->empty_fixed_array()) { | |
| 615 DeoptimizationInputData* const data = | |
| 616 DeoptimizationInputData::cast(code->deoptimization_data()); | |
| 617 FixedArray* const literals = data->LiteralArray(); | |
| 618 int const inlined_count = data->InlinedFunctionCount()->value(); | |
| 619 for (int i = 0; i < inlined_count; ++i) { | |
| 620 StaticVisitor::MarkObject( | |
| 621 heap, SharedFunctionInfo::cast(literals->get(i))->code()); | |
| 622 } | |
| 623 } | |
| 624 } | |
| 625 | |
| 626 | |
| 627 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { | 601 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { |
| 628 Object* undefined = heap->undefined_value(); | 602 Object* undefined = heap->undefined_value(); |
| 629 return (info->script() != undefined) && | 603 return (info->script() != undefined) && |
| 630 (reinterpret_cast<Script*>(info->script())->source() != undefined); | 604 (reinterpret_cast<Script*>(info->script())->source() != undefined); |
| 631 } | 605 } |
| 632 | 606 |
| 633 | 607 |
| 634 template <typename StaticVisitor> | 608 template <typename StaticVisitor> |
| 635 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, | 609 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, |
| 636 JSFunction* function) { | 610 JSFunction* function) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 747 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
| 774 void> JSFunctionWeakCodeBodyVisitor; | 748 void> JSFunctionWeakCodeBodyVisitor; |
| 775 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 749 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
| 776 } | 750 } |
| 777 | 751 |
| 778 | 752 |
| 779 } // namespace internal | 753 } // namespace internal |
| 780 } // namespace v8 | 754 } // namespace v8 |
| 781 | 755 |
| 782 #endif // V8_OBJECTS_VISITING_INL_H_ | 756 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |