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 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 | 912 |
913 Code* code = shared->code(); | 913 Code* code = shared->code(); |
914 MarkBit code_mark = Marking::MarkBitFrom(code); | 914 MarkBit code_mark = Marking::MarkBitFrom(code); |
915 if (Marking::IsWhite(code_mark)) { | 915 if (Marking::IsWhite(code_mark)) { |
916 if (FLAG_trace_code_flushing && shared->is_compiled()) { | 916 if (FLAG_trace_code_flushing && shared->is_compiled()) { |
917 PrintF("[code-flushing clears: "); | 917 PrintF("[code-flushing clears: "); |
918 shared->ShortPrint(); | 918 shared->ShortPrint(); |
919 PrintF(" - age: %d]\n", code->GetAge()); | 919 PrintF(" - age: %d]\n", code->GetAge()); |
920 } | 920 } |
921 // Always flush the optimized code map if there is one. | 921 // Always flush the optimized code map if there is one. |
922 if (!shared->optimized_code_map()->IsSmi()) { | 922 if (!shared->OptimizedCodeMapIsCleared()) { |
923 shared->ClearOptimizedCodeMap(); | 923 shared->ClearOptimizedCodeMap(); |
924 } | 924 } |
925 shared->set_code(lazy_compile); | 925 shared->set_code(lazy_compile); |
926 candidate->set_code(lazy_compile); | 926 candidate->set_code(lazy_compile); |
927 } else { | 927 } else { |
928 DCHECK(Marking::IsBlack(code_mark)); | 928 DCHECK(Marking::IsBlack(code_mark)); |
929 candidate->set_code(code); | 929 candidate->set_code(code); |
930 } | 930 } |
931 | 931 |
932 // We are in the middle of a GC cycle so the write barrier in the code | 932 // We are in the middle of a GC cycle so the write barrier in the code |
(...skipping 26 matching lines...) Expand all Loading... |
959 | 959 |
960 Code* code = candidate->code(); | 960 Code* code = candidate->code(); |
961 MarkBit code_mark = Marking::MarkBitFrom(code); | 961 MarkBit code_mark = Marking::MarkBitFrom(code); |
962 if (Marking::IsWhite(code_mark)) { | 962 if (Marking::IsWhite(code_mark)) { |
963 if (FLAG_trace_code_flushing && candidate->is_compiled()) { | 963 if (FLAG_trace_code_flushing && candidate->is_compiled()) { |
964 PrintF("[code-flushing clears: "); | 964 PrintF("[code-flushing clears: "); |
965 candidate->ShortPrint(); | 965 candidate->ShortPrint(); |
966 PrintF(" - age: %d]\n", code->GetAge()); | 966 PrintF(" - age: %d]\n", code->GetAge()); |
967 } | 967 } |
968 // Always flush the optimized code map if there is one. | 968 // Always flush the optimized code map if there is one. |
969 if (!candidate->optimized_code_map()->IsSmi()) { | 969 if (!candidate->OptimizedCodeMapIsCleared()) { |
970 candidate->ClearOptimizedCodeMap(); | 970 candidate->ClearOptimizedCodeMap(); |
971 } | 971 } |
972 candidate->set_code(lazy_compile); | 972 candidate->set_code(lazy_compile); |
973 } | 973 } |
974 | 974 |
975 Object** code_slot = | 975 Object** code_slot = |
976 HeapObject::RawField(candidate, SharedFunctionInfo::kCodeOffset); | 976 HeapObject::RawField(candidate, SharedFunctionInfo::kCodeOffset); |
977 isolate_->heap()->mark_compact_collector()->RecordSlot(candidate, code_slot, | 977 isolate_->heap()->mark_compact_collector()->RecordSlot(candidate, code_slot, |
978 *code_slot); | 978 *code_slot); |
979 | 979 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 heap()->object_stats_->TraceObjectStats(); | 2118 heap()->object_stats_->TraceObjectStats(); |
2119 } | 2119 } |
2120 heap()->object_stats_->CheckpointObjectStats(); | 2120 heap()->object_stats_->CheckpointObjectStats(); |
2121 } | 2121 } |
2122 } | 2122 } |
2123 | 2123 |
2124 | 2124 |
2125 void MarkCompactCollector::ProcessAndClearOptimizedCodeMaps() { | 2125 void MarkCompactCollector::ProcessAndClearOptimizedCodeMaps() { |
2126 SharedFunctionInfo::Iterator iterator(isolate()); | 2126 SharedFunctionInfo::Iterator iterator(isolate()); |
2127 while (SharedFunctionInfo* shared = iterator.Next()) { | 2127 while (SharedFunctionInfo* shared = iterator.Next()) { |
2128 if (shared->optimized_code_map()->IsSmi()) continue; | 2128 if (shared->OptimizedCodeMapIsCleared()) continue; |
2129 | 2129 |
2130 // Process context-dependent entries in the optimized code map. | 2130 // Process context-dependent entries in the optimized code map. |
2131 FixedArray* code_map = FixedArray::cast(shared->optimized_code_map()); | 2131 FixedArray* code_map = shared->optimized_code_map(); |
2132 int new_length = SharedFunctionInfo::kEntriesStart; | 2132 int new_length = SharedFunctionInfo::kEntriesStart; |
2133 int old_length = code_map->length(); | 2133 int old_length = code_map->length(); |
2134 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length; | 2134 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length; |
2135 i += SharedFunctionInfo::kEntryLength) { | 2135 i += SharedFunctionInfo::kEntryLength) { |
2136 // Each entry contains [ context, code, literals, ast-id ] as fields. | 2136 // Each entry contains [ context, code, literals, ast-id ] as fields. |
2137 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4); | 2137 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4); |
2138 Context* context = | 2138 Context* context = |
2139 Context::cast(code_map->get(i + SharedFunctionInfo::kContextOffset)); | 2139 Context::cast(code_map->get(i + SharedFunctionInfo::kContextOffset)); |
2140 HeapObject* code = HeapObject::cast( | 2140 HeapObject* code = HeapObject::cast( |
2141 code_map->get(i + SharedFunctionInfo::kCachedCodeOffset)); | 2141 code_map->get(i + SharedFunctionInfo::kCachedCodeOffset)); |
(...skipping 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4575 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4575 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4576 if (Marking::IsBlack(mark_bit)) { | 4576 if (Marking::IsBlack(mark_bit)) { |
4577 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4577 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4578 RecordRelocSlot(&rinfo, target); | 4578 RecordRelocSlot(&rinfo, target); |
4579 } | 4579 } |
4580 } | 4580 } |
4581 } | 4581 } |
4582 | 4582 |
4583 } // namespace internal | 4583 } // namespace internal |
4584 } // namespace v8 | 4584 } // namespace v8 |
OLD | NEW |