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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 // Process context-dependent entries in the optimized code map. | 1006 // Process context-dependent entries in the optimized code map. |
1007 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); | 1007 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); |
1008 int new_length = SharedFunctionInfo::kEntriesStart; | 1008 int new_length = SharedFunctionInfo::kEntriesStart; |
1009 int old_length = code_map->length(); | 1009 int old_length = code_map->length(); |
1010 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length; | 1010 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length; |
1011 i += SharedFunctionInfo::kEntryLength) { | 1011 i += SharedFunctionInfo::kEntryLength) { |
1012 // Each entry contains [ context, code, literals, ast-id ] as fields. | 1012 // Each entry contains [ context, code, literals, ast-id ] as fields. |
1013 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4); | 1013 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4); |
1014 Context* context = | 1014 Context* context = |
1015 Context::cast(code_map->get(i + SharedFunctionInfo::kContextOffset)); | 1015 Context::cast(code_map->get(i + SharedFunctionInfo::kContextOffset)); |
1016 Code* code = | 1016 if (Marking::IsWhite(Marking::MarkBitFrom(context))) continue; |
1017 Code::cast(code_map->get(i + SharedFunctionInfo::kCachedCodeOffset)); | 1017 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(context))); |
| 1018 |
1018 FixedArray* literals = FixedArray::cast( | 1019 FixedArray* literals = FixedArray::cast( |
1019 code_map->get(i + SharedFunctionInfo::kLiteralsOffset)); | 1020 code_map->get(i + SharedFunctionInfo::kLiteralsOffset)); |
| 1021 if (Marking::IsWhite(Marking::MarkBitFrom(literals))) continue; |
| 1022 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(literals))); |
| 1023 |
| 1024 Object* code = code_map->get(i + SharedFunctionInfo::kCachedCodeOffset); |
1020 Smi* ast_id = | 1025 Smi* ast_id = |
1021 Smi::cast(code_map->get(i + SharedFunctionInfo::kOsrAstIdOffset)); | 1026 Smi::cast(code_map->get(i + SharedFunctionInfo::kOsrAstIdOffset)); |
1022 if (Marking::IsWhite(Marking::MarkBitFrom(context))) continue; | 1027 if (code != nullptr) { |
1023 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(context))); | 1028 if (Marking::IsWhite(Marking::MarkBitFrom(Code::cast(code)))) { |
1024 if (Marking::IsWhite(Marking::MarkBitFrom(code))) continue; | 1029 BailoutId bailout_id(ast_id->value()); |
1025 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(code))); | 1030 if (!bailout_id.IsNone()) continue; |
1026 if (Marking::IsWhite(Marking::MarkBitFrom(literals))) continue; | 1031 // In case of non-OSR entry just clear the code in order to proceed |
1027 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(literals))); | 1032 // sharing literals. |
| 1033 code = nullptr; |
| 1034 } else { |
| 1035 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(Code::cast(code)))); |
| 1036 } |
| 1037 } |
1028 // Move every slot in the entry and record slots when needed. | 1038 // Move every slot in the entry and record slots when needed. |
1029 code_map->set(new_length + SharedFunctionInfo::kCachedCodeOffset, code); | 1039 code_map->set(new_length + SharedFunctionInfo::kCachedCodeOffset, code); |
1030 code_map->set(new_length + SharedFunctionInfo::kContextOffset, context); | 1040 code_map->set(new_length + SharedFunctionInfo::kContextOffset, context); |
1031 code_map->set(new_length + SharedFunctionInfo::kLiteralsOffset, literals); | 1041 code_map->set(new_length + SharedFunctionInfo::kLiteralsOffset, literals); |
1032 code_map->set(new_length + SharedFunctionInfo::kOsrAstIdOffset, ast_id); | 1042 code_map->set(new_length + SharedFunctionInfo::kOsrAstIdOffset, ast_id); |
1033 Object** code_slot = code_map->RawFieldOfElementAt( | 1043 if (code != nullptr) { |
1034 new_length + SharedFunctionInfo::kCachedCodeOffset); | 1044 Object** code_slot = code_map->RawFieldOfElementAt( |
1035 isolate_->heap()->mark_compact_collector()->RecordSlot( | 1045 new_length + SharedFunctionInfo::kCachedCodeOffset); |
1036 code_map, code_slot, *code_slot); | 1046 isolate_->heap()->mark_compact_collector()->RecordSlot( |
| 1047 code_map, code_slot, *code_slot); |
| 1048 } |
1037 Object** context_slot = code_map->RawFieldOfElementAt( | 1049 Object** context_slot = code_map->RawFieldOfElementAt( |
1038 new_length + SharedFunctionInfo::kContextOffset); | 1050 new_length + SharedFunctionInfo::kContextOffset); |
1039 isolate_->heap()->mark_compact_collector()->RecordSlot( | 1051 isolate_->heap()->mark_compact_collector()->RecordSlot( |
1040 code_map, context_slot, *context_slot); | 1052 code_map, context_slot, *context_slot); |
1041 Object** literals_slot = code_map->RawFieldOfElementAt( | 1053 Object** literals_slot = code_map->RawFieldOfElementAt( |
1042 new_length + SharedFunctionInfo::kLiteralsOffset); | 1054 new_length + SharedFunctionInfo::kLiteralsOffset); |
1043 isolate_->heap()->mark_compact_collector()->RecordSlot( | 1055 isolate_->heap()->mark_compact_collector()->RecordSlot( |
1044 code_map, literals_slot, *literals_slot); | 1056 code_map, literals_slot, *literals_slot); |
1045 new_length += SharedFunctionInfo::kEntryLength; | 1057 new_length += SharedFunctionInfo::kEntryLength; |
1046 } | 1058 } |
(...skipping 3537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4584 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4596 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4585 if (Marking::IsBlack(mark_bit)) { | 4597 if (Marking::IsBlack(mark_bit)) { |
4586 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4598 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4587 RecordRelocSlot(&rinfo, target); | 4599 RecordRelocSlot(&rinfo, target); |
4588 } | 4600 } |
4589 } | 4601 } |
4590 } | 4602 } |
4591 | 4603 |
4592 } // namespace internal | 4604 } // namespace internal |
4593 } // namespace v8 | 4605 } // namespace v8 |
OLD | NEW |