| OLD | NEW |
| 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 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1317 object, | 1317 object, |
| 1318 JSWeakMap::BodyDescriptor::kStartOffset, | 1318 JSWeakMap::BodyDescriptor::kStartOffset, |
| 1319 JSWeakMap::kTableOffset); | 1319 JSWeakMap::kTableOffset); |
| 1320 BodyVisitorBase<MarkCompactMarkingVisitor>::IteratePointers( | 1320 BodyVisitorBase<MarkCompactMarkingVisitor>::IteratePointers( |
| 1321 map->GetHeap(), | 1321 map->GetHeap(), |
| 1322 object, | 1322 object, |
| 1323 JSWeakMap::kTableOffset + kPointerSize, | 1323 JSWeakMap::kTableOffset + kPointerSize, |
| 1324 object_size); | 1324 object_size); |
| 1325 | 1325 |
| 1326 // Mark the backing hash table without pushing it on the marking stack. | 1326 // Mark the backing hash table without pushing it on the marking stack. |
| 1327 Object* table_object = weak_map->table(); | |
| 1328 if (!table_object->IsHashTable()) return; | |
| 1329 ObjectHashTable* table = ObjectHashTable::cast(table_object); | |
| 1330 Object** table_slot = | 1327 Object** table_slot = |
| 1331 HeapObject::RawField(weak_map, JSWeakMap::kTableOffset); | 1328 HeapObject::RawField(weak_map, JSWeakMap::kTableOffset); |
| 1329 if (!(*table_slot)->IsHashTable()) return; |
| 1330 ObjectHashTable* table = ObjectHashTable::cast(*table_slot); |
| 1332 MarkBit table_mark = Marking::MarkBitFrom(table); | 1331 MarkBit table_mark = Marking::MarkBitFrom(table); |
| 1333 collector->RecordSlot(table_slot, table_slot, table); | 1332 collector->RecordSlot(table_slot, table_slot, table); |
| 1334 if (!table_mark.Get()) collector->SetMark(table, table_mark); | 1333 if (!table_mark.Get()) collector->SetMark(table, table_mark); |
| 1335 // Recording the map slot can be skipped, because maps are not compacted. | 1334 // Recording the map slot can be skipped, because maps are not compacted. |
| 1336 collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map())); | 1335 collector->MarkObject(table->map(), Marking::MarkBitFrom(table->map())); |
| 1337 ASSERT(MarkCompactCollector::IsMarked(table->map())); | 1336 ASSERT(MarkCompactCollector::IsMarked(table->map())); |
| 1338 } | 1337 } |
| 1339 | 1338 |
| 1340 private: | 1339 private: |
| 1341 template<int id> | 1340 template<int id> |
| (...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 } | 2403 } |
| 2405 codes->set_number_of_codes(new_number_of_codes); | 2404 codes->set_number_of_codes(new_number_of_codes); |
| 2406 } | 2405 } |
| 2407 | 2406 |
| 2408 | 2407 |
| 2409 void MarkCompactCollector::ProcessWeakMaps() { | 2408 void MarkCompactCollector::ProcessWeakMaps() { |
| 2410 Object* weak_map_obj = encountered_weak_maps(); | 2409 Object* weak_map_obj = encountered_weak_maps(); |
| 2411 while (weak_map_obj != Smi::FromInt(0)) { | 2410 while (weak_map_obj != Smi::FromInt(0)) { |
| 2412 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2411 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
| 2413 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2412 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
| 2414 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); | 2413 ObjectHashTable* table = weak_map->table(); |
| 2415 Object** anchor = reinterpret_cast<Object**>(table->address()); | 2414 Object** anchor = reinterpret_cast<Object**>(table->address()); |
| 2416 for (int i = 0; i < table->Capacity(); i++) { | 2415 for (int i = 0; i < table->Capacity(); i++) { |
| 2417 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2416 if (MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
| 2418 Object** key_slot = | 2417 Object** key_slot = |
| 2419 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( | 2418 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( |
| 2420 ObjectHashTable::EntryToIndex(i))); | 2419 ObjectHashTable::EntryToIndex(i))); |
| 2421 RecordSlot(anchor, key_slot, *key_slot); | 2420 RecordSlot(anchor, key_slot, *key_slot); |
| 2422 Object** value_slot = | 2421 Object** value_slot = |
| 2423 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( | 2422 HeapObject::RawField(table, FixedArray::OffsetOfElementAt( |
| 2424 ObjectHashTable::EntryToValueIndex(i))); | 2423 ObjectHashTable::EntryToValueIndex(i))); |
| 2425 MarkCompactMarkingVisitor::MarkObjectByPointer( | 2424 MarkCompactMarkingVisitor::MarkObjectByPointer( |
| 2426 this, anchor, value_slot); | 2425 this, anchor, value_slot); |
| 2427 } | 2426 } |
| 2428 } | 2427 } |
| 2429 weak_map_obj = weak_map->next(); | 2428 weak_map_obj = weak_map->next(); |
| 2430 } | 2429 } |
| 2431 } | 2430 } |
| 2432 | 2431 |
| 2433 | 2432 |
| 2434 void MarkCompactCollector::ClearWeakMaps() { | 2433 void MarkCompactCollector::ClearWeakMaps() { |
| 2435 Object* weak_map_obj = encountered_weak_maps(); | 2434 Object* weak_map_obj = encountered_weak_maps(); |
| 2436 while (weak_map_obj != Smi::FromInt(0)) { | 2435 while (weak_map_obj != Smi::FromInt(0)) { |
| 2437 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2436 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
| 2438 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2437 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
| 2439 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); | 2438 ObjectHashTable* table = weak_map->table(); |
| 2440 for (int i = 0; i < table->Capacity(); i++) { | 2439 for (int i = 0; i < table->Capacity(); i++) { |
| 2441 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { | 2440 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { |
| 2442 table->RemoveEntry(i); | 2441 table->RemoveEntry(i); |
| 2443 } | 2442 } |
| 2444 } | 2443 } |
| 2445 weak_map_obj = weak_map->next(); | 2444 weak_map_obj = weak_map->next(); |
| 2446 weak_map->set_next(Smi::FromInt(0)); | 2445 weak_map->set_next(Smi::FromInt(0)); |
| 2447 } | 2446 } |
| 2448 set_encountered_weak_maps(Smi::FromInt(0)); | 2447 set_encountered_weak_maps(Smi::FromInt(0)); |
| 2449 } | 2448 } |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4072 while (buffer != NULL) { | 4071 while (buffer != NULL) { |
| 4073 SlotsBuffer* next_buffer = buffer->next(); | 4072 SlotsBuffer* next_buffer = buffer->next(); |
| 4074 DeallocateBuffer(buffer); | 4073 DeallocateBuffer(buffer); |
| 4075 buffer = next_buffer; | 4074 buffer = next_buffer; |
| 4076 } | 4075 } |
| 4077 *buffer_address = NULL; | 4076 *buffer_address = NULL; |
| 4078 } | 4077 } |
| 4079 | 4078 |
| 4080 | 4079 |
| 4081 } } // namespace v8::internal | 4080 } } // namespace v8::internal |
| OLD | NEW |