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/objects-visiting.h" | 8 #include "src/heap/objects-visiting.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 !shared->optimized_code_map()->IsSmi()) { | 412 !shared->optimized_code_map()->IsSmi()) { |
413 // Always flush the optimized code map if requested by flag. | 413 // Always flush the optimized code map if requested by flag. |
414 shared->ClearOptimizedCodeMap(); | 414 shared->ClearOptimizedCodeMap(); |
415 } | 415 } |
416 MarkCompactCollector* collector = heap->mark_compact_collector(); | 416 MarkCompactCollector* collector = heap->mark_compact_collector(); |
417 if (collector->is_code_flushing_enabled()) { | 417 if (collector->is_code_flushing_enabled()) { |
418 if (!shared->optimized_code_map()->IsSmi()) { | 418 if (!shared->optimized_code_map()->IsSmi()) { |
419 // Add the shared function info holding an optimized code map to | 419 // Add the shared function info holding an optimized code map to |
420 // the code flusher for processing of code maps after marking. | 420 // the code flusher for processing of code maps after marking. |
421 collector->code_flusher()->AddOptimizedCodeMap(shared); | 421 collector->code_flusher()->AddOptimizedCodeMap(shared); |
422 // Treat all references within the code map weakly by marking the | 422 // Treat some references within the code map weakly by marking the |
423 // code map itself but not pushing it onto the marking deque. | 423 // code map itself but not pushing it onto the marking deque. |
424 FixedArray* code_map = FixedArray::cast(shared->optimized_code_map()); | 424 FixedArray* code_map = FixedArray::cast(shared->optimized_code_map()); |
425 StaticVisitor::MarkObjectWithoutPush(heap, code_map); | 425 MarkOptimizedCodeMap(heap, code_map); |
426 } | 426 } |
427 if (IsFlushable(heap, shared)) { | 427 if (IsFlushable(heap, shared)) { |
428 // This function's code looks flushable. But we have to postpone | 428 // This function's code looks flushable. But we have to postpone |
429 // the decision until we see all functions that point to the same | 429 // the decision until we see all functions that point to the same |
430 // SharedFunctionInfo because some of them might be optimized. | 430 // SharedFunctionInfo because some of them might be optimized. |
431 // That would also make the non-optimized version of the code | 431 // That would also make the non-optimized version of the code |
432 // non-flushable, because it is required for bailing out from | 432 // non-flushable, because it is required for bailing out from |
433 // optimized code. | 433 // optimized code. |
434 collector->code_flusher()->AddCandidate(shared); | 434 collector->code_flusher()->AddCandidate(shared); |
435 // Treat the reference to the code object weakly. | 435 // Treat the reference to the code object weakly. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 | 583 |
584 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 584 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
585 for (int i = 0; i < num_transitions; ++i) { | 585 for (int i = 0; i < num_transitions; ++i) { |
586 StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i)); | 586 StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i)); |
587 } | 587 } |
588 } | 588 } |
589 | 589 |
590 | 590 |
591 template <typename StaticVisitor> | 591 template <typename StaticVisitor> |
| 592 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( |
| 593 Heap* heap, FixedArray* code_map) { |
| 594 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; |
| 595 |
| 596 // Mark the context-independent entry in the optimized code map. Depending on |
| 597 // the age of the code object, we treat it as a strong or a weak reference. |
| 598 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); |
| 599 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && |
| 600 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { |
| 601 StaticVisitor::VisitPointer( |
| 602 heap, |
| 603 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); |
| 604 } |
| 605 } |
| 606 |
| 607 |
| 608 template <typename StaticVisitor> |
592 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, | 609 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, |
593 Code* code) { | 610 Code* code) { |
594 // For optimized functions we should retain both non-optimized version | 611 // For optimized functions we should retain both non-optimized version |
595 // of its code and non-optimized version of all inlined functions. | 612 // of its code and non-optimized version of all inlined functions. |
596 // This is required to support bailing out from inlined code. | 613 // This is required to support bailing out from inlined code. |
597 DeoptimizationInputData* const data = | 614 DeoptimizationInputData* const data = |
598 DeoptimizationInputData::cast(code->deoptimization_data()); | 615 DeoptimizationInputData::cast(code->deoptimization_data()); |
599 FixedArray* const literals = data->LiteralArray(); | 616 FixedArray* const literals = data->LiteralArray(); |
600 int const inlined_count = data->InlinedFunctionCount()->value(); | 617 int const inlined_count = data->InlinedFunctionCount()->value(); |
601 for (int i = 0; i < inlined_count; ++i) { | 618 for (int i = 0; i < inlined_count; ++i) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 852 |
836 RelocIterator it(this, mode_mask); | 853 RelocIterator it(this, mode_mask); |
837 for (; !it.done(); it.next()) { | 854 for (; !it.done(); it.next()) { |
838 it.rinfo()->template Visit<StaticVisitor>(heap); | 855 it.rinfo()->template Visit<StaticVisitor>(heap); |
839 } | 856 } |
840 } | 857 } |
841 } | 858 } |
842 } // namespace v8::internal | 859 } // namespace v8::internal |
843 | 860 |
844 #endif // V8_OBJECTS_VISITING_INL_H_ | 861 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |