Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1217813013: Fix CodeFlusher::ProcessOptimizedCodeMaps stale fields. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_opt-code-map-6
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.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 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 while (holder != NULL) { 943 while (holder != NULL) {
944 next_holder = GetNextCodeMap(holder); 944 next_holder = GetNextCodeMap(holder);
945 ClearNextCodeMap(holder); 945 ClearNextCodeMap(holder);
946 946
947 // Process context-dependent entries in the optimized code map. 947 // Process context-dependent entries in the optimized code map.
948 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map()); 948 FixedArray* code_map = FixedArray::cast(holder->optimized_code_map());
949 int new_length = SharedFunctionInfo::kEntriesStart; 949 int new_length = SharedFunctionInfo::kEntriesStart;
950 int old_length = code_map->length(); 950 int old_length = code_map->length();
951 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length; 951 for (int i = SharedFunctionInfo::kEntriesStart; i < old_length;
952 i += SharedFunctionInfo::kEntryLength) { 952 i += SharedFunctionInfo::kEntryLength) {
953 // Each entry contains [ context, code, literals, ast-id ] as fields.
954 STATIC_ASSERT(SharedFunctionInfo::kEntryLength == 4);
953 Code* code = 955 Code* code =
954 Code::cast(code_map->get(i + SharedFunctionInfo::kCachedCodeOffset)); 956 Code::cast(code_map->get(i + SharedFunctionInfo::kCachedCodeOffset));
957 Context* context =
958 Context::cast(code_map->get(i + SharedFunctionInfo::kContextOffset));
Hannes Payer (out of office) 2015/07/01 12:51:38 move context before code to correspond to the comm
Michael Starzinger 2015/07/01 12:59:16 Done.
959 FixedArray* literals = FixedArray::cast(
960 code_map->get(i + SharedFunctionInfo::kLiteralsOffset));
961 Smi* ast_id =
962 Smi::cast(code_map->get(i + SharedFunctionInfo::kOsrAstIdOffset));
955 if (Marking::IsWhite(Marking::MarkBitFrom(code))) continue; 963 if (Marking::IsWhite(Marking::MarkBitFrom(code))) continue;
956 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(code))); 964 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(code)));
957 // Move every slot in the entry. 965 if (Marking::IsWhite(Marking::MarkBitFrom(context))) continue;
958 for (int j = 0; j < SharedFunctionInfo::kEntryLength; j++) { 966 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(context)));
959 int dst_index = new_length++; 967 if (Marking::IsWhite(Marking::MarkBitFrom(literals))) continue;
960 Object** slot = code_map->RawFieldOfElementAt(dst_index); 968 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(literals)));
961 Object* object = code_map->get(i + j); 969 // Move every slot in the entry and record slots when needed.
962 code_map->set(dst_index, object); 970 code_map->set(new_length + SharedFunctionInfo::kCachedCodeOffset, code);
963 if (j == SharedFunctionInfo::kOsrAstIdOffset) { 971 code_map->set(new_length + SharedFunctionInfo::kContextOffset, context);
964 DCHECK(object->IsSmi()); 972 code_map->set(new_length + SharedFunctionInfo::kLiteralsOffset, literals);
965 } else { 973 code_map->set(new_length + SharedFunctionInfo::kOsrAstIdOffset, ast_id);
966 DCHECK( 974 Object** code_slot = code_map->RawFieldOfElementAt(
967 Marking::IsBlack(Marking::MarkBitFrom(HeapObject::cast(*slot)))); 975 new_length + SharedFunctionInfo::kCachedCodeOffset);
968 isolate_->heap()->mark_compact_collector()->RecordSlot(slot, slot, 976 isolate_->heap()->mark_compact_collector()->RecordSlot(
969 *slot); 977 code_slot, code_slot, *code_slot);
970 } 978 Object** context_slot = code_map->RawFieldOfElementAt(
971 } 979 new_length + SharedFunctionInfo::kContextOffset);
980 isolate_->heap()->mark_compact_collector()->RecordSlot(
981 context_slot, context_slot, *context_slot);
982 Object** literals_slot = code_map->RawFieldOfElementAt(
983 new_length + SharedFunctionInfo::kLiteralsOffset);
984 isolate_->heap()->mark_compact_collector()->RecordSlot(
985 literals_slot, literals_slot, *literals_slot);
986 new_length += SharedFunctionInfo::kEntryLength;
972 } 987 }
973 988
974 // Process context-independent entry in the optimized code map. 989 // Process context-independent entry in the optimized code map.
975 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); 990 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex);
976 if (shared_object->IsCode()) { 991 if (shared_object->IsCode()) {
977 Code* shared_code = Code::cast(shared_object); 992 Code* shared_code = Code::cast(shared_object);
978 if (Marking::IsWhite(Marking::MarkBitFrom(shared_code))) { 993 if (Marking::IsWhite(Marking::MarkBitFrom(shared_code))) {
979 code_map->set_undefined(SharedFunctionInfo::kSharedCodeIndex); 994 code_map->set_undefined(SharedFunctionInfo::kSharedCodeIndex);
980 } else { 995 } else {
981 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(shared_code))); 996 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(shared_code)));
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4638 SlotsBuffer* buffer = *buffer_address; 4653 SlotsBuffer* buffer = *buffer_address;
4639 while (buffer != NULL) { 4654 while (buffer != NULL) {
4640 SlotsBuffer* next_buffer = buffer->next(); 4655 SlotsBuffer* next_buffer = buffer->next();
4641 DeallocateBuffer(buffer); 4656 DeallocateBuffer(buffer);
4642 buffer = next_buffer; 4657 buffer = next_buffer;
4643 } 4658 }
4644 *buffer_address = NULL; 4659 *buffer_address = NULL;
4645 } 4660 }
4646 } // namespace internal 4661 } // namespace internal
4647 } // namespace v8 4662 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698