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

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

Issue 9985010: Fix issues when stressing compaction with WeakMaps. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-weakmaps.cc » ('j') | test/cctest/test-weakmaps.cc » ('J')
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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 1145
1146 typedef FlexibleBodyVisitor<StaticMarkingVisitor, 1146 typedef FlexibleBodyVisitor<StaticMarkingVisitor,
1147 StructBodyDescriptor, 1147 StructBodyDescriptor,
1148 void> StructObjectVisitor; 1148 void> StructObjectVisitor;
1149 1149
1150 static void VisitJSWeakMap(Map* map, HeapObject* object) { 1150 static void VisitJSWeakMap(Map* map, HeapObject* object) {
1151 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector(); 1151 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector();
1152 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(object); 1152 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(object);
1153 1153
1154 // Enqueue weak map in linked list of encountered weak maps. 1154 // Enqueue weak map in linked list of encountered weak maps.
1155 ASSERT(weak_map->next() == Smi::FromInt(0)); 1155 if (weak_map->next() == Smi::FromInt(0)) {
1156 weak_map->set_next(collector->encountered_weak_maps()); 1156 weak_map->set_next(collector->encountered_weak_maps());
1157 collector->set_encountered_weak_maps(weak_map); 1157 collector->set_encountered_weak_maps(weak_map);
1158 }
1158 1159
1159 // Skip visiting the backing hash table containing the mappings. 1160 // Skip visiting the backing hash table containing the mappings.
1160 int object_size = JSWeakMap::BodyDescriptor::SizeOf(map, object); 1161 int object_size = JSWeakMap::BodyDescriptor::SizeOf(map, object);
1161 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers( 1162 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers(
1162 map->GetHeap(), 1163 map->GetHeap(),
1163 object, 1164 object,
1164 JSWeakMap::BodyDescriptor::kStartOffset, 1165 JSWeakMap::BodyDescriptor::kStartOffset,
1165 JSWeakMap::kTableOffset); 1166 JSWeakMap::kTableOffset);
1166 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers( 1167 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers(
1167 map->GetHeap(), 1168 map->GetHeap(),
1168 object, 1169 object,
1169 JSWeakMap::kTableOffset + kPointerSize, 1170 JSWeakMap::kTableOffset + kPointerSize,
1170 object_size); 1171 object_size);
1171 1172
1172 // Mark the backing hash table without pushing it on the marking stack. 1173 // Mark the backing hash table without pushing it on the marking stack.
1173 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); 1174 Object* table_object = weak_map->table();
1174 ASSERT(!MarkCompactCollector::IsMarked(table)); 1175 if (!table_object->IsHashTable()) return;
1175 collector->SetMark(table, Marking::MarkBitFrom(table)); 1176 ObjectHashTable* table = ObjectHashTable::cast(table_object);
1177 Object** table_slot =
1178 HeapObject::RawField(weak_map, JSWeakMap::kTableOffset);
1179 MarkBit table_mark = Marking::MarkBitFrom(table);
1180 collector->RecordSlot(table_slot, table_slot, table);
1181 if (!table_mark.Get()) collector->SetMark(table, table_mark);
1182 // Recording the map slot can be skipped, because maps are not compacted.
1176 collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map())); 1183 collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map()));
1177 ASSERT(MarkCompactCollector::IsMarked(table->map())); 1184 ASSERT(MarkCompactCollector::IsMarked(table->map()));
1178 } 1185 }
1179 1186
1180 static void VisitCode(Map* map, HeapObject* object) { 1187 static void VisitCode(Map* map, HeapObject* object) {
1181 Heap* heap = map->GetHeap(); 1188 Heap* heap = map->GetHeap();
1182 Code* code = reinterpret_cast<Code*>(object); 1189 Code* code = reinterpret_cast<Code*>(object);
1183 if (FLAG_cleanup_code_caches_at_gc) { 1190 if (FLAG_cleanup_code_caches_at_gc) {
1184 Object* raw_info = code->type_feedback_info(); 1191 Object* raw_info = code->type_feedback_info();
1185 if (raw_info->IsTypeFeedbackInfo()) { 1192 if (raw_info->IsTypeFeedbackInfo()) {
(...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after
4134 while (buffer != NULL) { 4141 while (buffer != NULL) {
4135 SlotsBuffer* next_buffer = buffer->next(); 4142 SlotsBuffer* next_buffer = buffer->next();
4136 DeallocateBuffer(buffer); 4143 DeallocateBuffer(buffer);
4137 buffer = next_buffer; 4144 buffer = next_buffer;
4138 } 4145 }
4139 *buffer_address = NULL; 4146 *buffer_address = NULL;
4140 } 4147 }
4141 4148
4142 4149
4143 } } // namespace v8::internal 4150 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-weakmaps.cc » ('j') | test/cctest/test-weakmaps.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698