OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 object, | 959 object, |
960 JSWeakMap::BodyDescriptor::kStartOffset, | 960 JSWeakMap::BodyDescriptor::kStartOffset, |
961 JSWeakMap::kTableOffset); | 961 JSWeakMap::kTableOffset); |
962 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers( | 962 BodyVisitorBase<StaticMarkingVisitor>::IteratePointers( |
963 map->GetHeap(), | 963 map->GetHeap(), |
964 object, | 964 object, |
965 JSWeakMap::kTableOffset + kPointerSize, | 965 JSWeakMap::kTableOffset + kPointerSize, |
966 object_size); | 966 object_size); |
967 | 967 |
968 // Mark the backing hash table without pushing it on the marking stack. | 968 // Mark the backing hash table without pushing it on the marking stack. |
969 ASSERT(!MarkCompactCollector::IsMarked(weak_map->unchecked_table())); | 969 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); |
970 ASSERT(MarkCompactCollector::IsMarked(weak_map->unchecked_table()->map())); | 970 ASSERT(!MarkCompactCollector::IsMarked(table)); |
971 | 971 collector->SetMark(table, Marking::MarkBitFrom(table)); |
972 HeapObject* unchecked_table = weak_map->unchecked_table(); | 972 collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map())); |
973 MarkBit mark_bit = Marking::MarkBitFrom(unchecked_table); | 973 ASSERT(MarkCompactCollector::IsMarked(table->map())); |
974 collector->SetMark(unchecked_table, mark_bit); | |
975 } | 974 } |
976 | 975 |
977 static void VisitCode(Map* map, HeapObject* object) { | 976 static void VisitCode(Map* map, HeapObject* object) { |
978 reinterpret_cast<Code*>(object)->CodeIterateBody<StaticMarkingVisitor>( | 977 reinterpret_cast<Code*>(object)->CodeIterateBody<StaticMarkingVisitor>( |
979 map->GetHeap()); | 978 map->GetHeap()); |
980 } | 979 } |
981 | 980 |
982 // Code flushing support. | 981 // Code flushing support. |
983 | 982 |
984 // How many collections newly compiled code object will survive before being | 983 // How many collections newly compiled code object will survive before being |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2290 } | 2289 } |
2291 } | 2290 } |
2292 } | 2291 } |
2293 | 2292 |
2294 | 2293 |
2295 void MarkCompactCollector::ProcessWeakMaps() { | 2294 void MarkCompactCollector::ProcessWeakMaps() { |
2296 Object* weak_map_obj = encountered_weak_maps(); | 2295 Object* weak_map_obj = encountered_weak_maps(); |
2297 while (weak_map_obj != Smi::FromInt(0)) { | 2296 while (weak_map_obj != Smi::FromInt(0)) { |
2298 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2297 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
2299 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2298 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
2300 ObjectHashTable* table = weak_map->unchecked_table(); | 2299 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); |
2301 for (int i = 0; i < table->Capacity(); i++) { | 2300 for (int i = 0; i < table->Capacity(); i++) { |
2302 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2301 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
2303 Object* value = table->get(table->EntryToValueIndex(i)); | 2302 Object* value = table->get(table->EntryToValueIndex(i)); |
2304 StaticMarkingVisitor::VisitPointer(heap(), &value); | 2303 StaticMarkingVisitor::VisitPointer(heap(), &value); |
2305 table->set_unchecked(heap(), | 2304 table->set_unchecked(heap(), |
2306 table->EntryToValueIndex(i), | 2305 table->EntryToValueIndex(i), |
2307 value, | 2306 value, |
2308 UPDATE_WRITE_BARRIER); | 2307 UPDATE_WRITE_BARRIER); |
2309 } | 2308 } |
2310 } | 2309 } |
2311 weak_map_obj = weak_map->next(); | 2310 weak_map_obj = weak_map->next(); |
2312 } | 2311 } |
2313 } | 2312 } |
2314 | 2313 |
2315 | 2314 |
2316 void MarkCompactCollector::ClearWeakMaps() { | 2315 void MarkCompactCollector::ClearWeakMaps() { |
2317 Object* weak_map_obj = encountered_weak_maps(); | 2316 Object* weak_map_obj = encountered_weak_maps(); |
2318 while (weak_map_obj != Smi::FromInt(0)) { | 2317 while (weak_map_obj != Smi::FromInt(0)) { |
2319 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2318 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
2320 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2319 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
2321 ObjectHashTable* table = weak_map->unchecked_table(); | 2320 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); |
2322 for (int i = 0; i < table->Capacity(); i++) { | 2321 for (int i = 0; i < table->Capacity(); i++) { |
2323 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2322 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
2324 table->RemoveEntry(i); | 2323 table->RemoveEntry(i); |
2325 } | 2324 } |
2326 } | 2325 } |
2327 weak_map_obj = weak_map->next(); | 2326 weak_map_obj = weak_map->next(); |
2328 weak_map->set_next(Smi::FromInt(0)); | 2327 weak_map->set_next(Smi::FromInt(0)); |
2329 } | 2328 } |
2330 set_encountered_weak_maps(Smi::FromInt(0)); | 2329 set_encountered_weak_maps(Smi::FromInt(0)); |
2331 } | 2330 } |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3775 while (buffer != NULL) { | 3774 while (buffer != NULL) { |
3776 SlotsBuffer* next_buffer = buffer->next(); | 3775 SlotsBuffer* next_buffer = buffer->next(); |
3777 DeallocateBuffer(buffer); | 3776 DeallocateBuffer(buffer); |
3778 buffer = next_buffer; | 3777 buffer = next_buffer; |
3779 } | 3778 } |
3780 *buffer_address = NULL; | 3779 *buffer_address = NULL; |
3781 } | 3780 } |
3782 | 3781 |
3783 | 3782 |
3784 } } // namespace v8::internal | 3783 } } // namespace v8::internal |
OLD | NEW |