Chromium Code Reviews| 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 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2244 } | 2244 } |
| 2245 } | 2245 } |
| 2246 } | 2246 } |
| 2247 { | 2247 { |
| 2248 HeapObjectIterator js_global_property_cell_iterator( | 2248 HeapObjectIterator js_global_property_cell_iterator( |
| 2249 heap()->property_cell_space()); | 2249 heap()->property_cell_space()); |
| 2250 HeapObject* cell; | 2250 HeapObject* cell; |
| 2251 while ((cell = js_global_property_cell_iterator.Next()) != NULL) { | 2251 while ((cell = js_global_property_cell_iterator.Next()) != NULL) { |
| 2252 ASSERT(cell->IsPropertyCell()); | 2252 ASSERT(cell->IsPropertyCell()); |
| 2253 if (IsMarked(cell)) { | 2253 if (IsMarked(cell)) { |
| 2254 int offset = PropertyCell::kValueOffset; | 2254 MarkCompactMarkingVisitor::VisitPropertyCell(cell->map(), cell); |
| 2255 MarkCompactMarkingVisitor::VisitPointer( | |
| 2256 heap(), | |
| 2257 reinterpret_cast<Object**>(cell->address() + offset)); | |
| 2258 offset = PropertyCell::kTypeOffset; | |
| 2259 MarkCompactMarkingVisitor::VisitPointer( | |
| 2260 heap(), | |
| 2261 reinterpret_cast<Object**>(cell->address() + offset)); | |
| 2262 } | 2255 } |
| 2263 } | 2256 } |
| 2264 } | 2257 } |
| 2265 } | 2258 } |
| 2266 | 2259 |
| 2267 RootMarkingVisitor root_visitor(heap()); | 2260 RootMarkingVisitor root_visitor(heap()); |
| 2268 MarkRoots(&root_visitor); | 2261 MarkRoots(&root_visitor); |
| 2269 | 2262 |
| 2270 // The objects reachable from the roots are marked, yet unreachable | 2263 // The objects reachable from the roots are marked, yet unreachable |
| 2271 // objects are unmarked. Mark objects reachable due to host | 2264 // objects are unmarked. Mark objects reachable due to host |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2430 // This map is used for inobject slack tracking and has been detached | 2423 // This map is used for inobject slack tracking and has been detached |
| 2431 // from SharedFunctionInfo during the mark phase. | 2424 // from SharedFunctionInfo during the mark phase. |
| 2432 // Since it survived the GC, reattach it now. | 2425 // Since it survived the GC, reattach it now. |
| 2433 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); | 2426 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); |
| 2434 } | 2427 } |
| 2435 | 2428 |
| 2436 ClearNonLivePrototypeTransitions(map); | 2429 ClearNonLivePrototypeTransitions(map); |
| 2437 ClearNonLiveMapTransitions(map, map_mark); | 2430 ClearNonLiveMapTransitions(map, map_mark); |
| 2438 | 2431 |
| 2439 if (map_mark.Get()) { | 2432 if (map_mark.Get()) { |
| 2440 ClearNonLiveDependentCode(map); | 2433 ClearNonLiveDependentCode(map->dependent_code()); |
| 2441 } else { | 2434 } else { |
| 2442 ClearAndDeoptimizeDependentCode(map); | 2435 ClearAndDeoptimizeDependentCode(map); |
| 2443 } | 2436 } |
| 2444 } | 2437 } |
| 2438 | |
| 2439 // Iterate over property cell space, removing dependent code that is not | |
| 2440 // otherwise kept alive by strong references. | |
| 2441 HeapObjectIterator cell_iterator(heap_->property_cell_space()); | |
| 2442 for (HeapObject* cell = cell_iterator.Next(); | |
| 2443 cell != NULL; | |
| 2444 cell = cell_iterator.Next()) { | |
| 2445 ClearNonLiveDependentCode(PropertyCell::cast(cell)->dependent_code()); | |
|
Michael Starzinger
2013/06/26 15:23:31
This iteration should only concern itself with mar
danno
2013/06/26 15:42:40
Done.
| |
| 2446 } | |
| 2445 } | 2447 } |
| 2446 | 2448 |
| 2447 | 2449 |
| 2448 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { | 2450 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { |
| 2449 int number_of_transitions = map->NumberOfProtoTransitions(); | 2451 int number_of_transitions = map->NumberOfProtoTransitions(); |
| 2450 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); | 2452 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); |
| 2451 | 2453 |
| 2452 int new_number_of_transitions = 0; | 2454 int new_number_of_transitions = 0; |
| 2453 const int header = Map::kProtoTransitionHeaderSize; | 2455 const int header = Map::kProtoTransitionHeaderSize; |
| 2454 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; | 2456 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2520 Code* code = entries->code_at(i); | 2522 Code* code = entries->code_at(i); |
| 2521 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2523 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| 2522 code->set_marked_for_deoptimization(true); | 2524 code->set_marked_for_deoptimization(true); |
| 2523 } | 2525 } |
| 2524 entries->clear_at(i); | 2526 entries->clear_at(i); |
| 2525 } | 2527 } |
| 2526 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2528 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
| 2527 } | 2529 } |
| 2528 | 2530 |
| 2529 | 2531 |
| 2530 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { | 2532 void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) { |
| 2531 DisallowHeapAllocation no_allocation; | 2533 DisallowHeapAllocation no_allocation; |
| 2532 DependentCode* entries = map->dependent_code(); | |
| 2533 DependentCode::GroupStartIndexes starts(entries); | 2534 DependentCode::GroupStartIndexes starts(entries); |
| 2534 int number_of_entries = starts.number_of_entries(); | 2535 int number_of_entries = starts.number_of_entries(); |
| 2535 if (number_of_entries == 0) return; | 2536 if (number_of_entries == 0) return; |
| 2536 int new_number_of_entries = 0; | 2537 int new_number_of_entries = 0; |
| 2537 // Go through all groups, remove dead codes and compact. | 2538 // Go through all groups, remove dead codes and compact. |
| 2538 for (int g = 0; g < DependentCode::kGroupCount; g++) { | 2539 for (int g = 0; g < DependentCode::kGroupCount; g++) { |
| 2539 int group_number_of_entries = 0; | 2540 int group_number_of_entries = 0; |
| 2540 for (int i = starts.at(g); i < starts.at(g + 1); i++) { | 2541 for (int i = starts.at(g); i < starts.at(g + 1); i++) { |
| 2541 Object* obj = entries->object_at(i); | 2542 Object* obj = entries->object_at(i); |
| 2542 ASSERT(obj->IsCode() || IsMarked(obj)); | 2543 ASSERT(obj->IsCode() || IsMarked(obj)); |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3391 } | 3392 } |
| 3392 | 3393 |
| 3393 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); | 3394 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); |
| 3394 | 3395 |
| 3395 // Update pointers from cells. | 3396 // Update pointers from cells. |
| 3396 HeapObjectIterator cell_iterator(heap_->cell_space()); | 3397 HeapObjectIterator cell_iterator(heap_->cell_space()); |
| 3397 for (HeapObject* cell = cell_iterator.Next(); | 3398 for (HeapObject* cell = cell_iterator.Next(); |
| 3398 cell != NULL; | 3399 cell != NULL; |
| 3399 cell = cell_iterator.Next()) { | 3400 cell = cell_iterator.Next()) { |
| 3400 if (cell->IsCell()) { | 3401 if (cell->IsCell()) { |
| 3401 Address value_address = reinterpret_cast<Address>(cell) + | 3402 Cell::BodyDescriptor::IterateBody(cell, &updating_visitor); |
| 3402 (Cell::kValueOffset - kHeapObjectTag); | |
| 3403 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
| 3404 } | 3403 } |
| 3405 } | 3404 } |
| 3406 | 3405 |
| 3407 HeapObjectIterator js_global_property_cell_iterator( | 3406 HeapObjectIterator js_global_property_cell_iterator( |
| 3408 heap_->property_cell_space()); | 3407 heap_->property_cell_space()); |
| 3409 for (HeapObject* cell = js_global_property_cell_iterator.Next(); | 3408 for (HeapObject* cell = js_global_property_cell_iterator.Next(); |
| 3410 cell != NULL; | 3409 cell != NULL; |
| 3411 cell = js_global_property_cell_iterator.Next()) { | 3410 cell = js_global_property_cell_iterator.Next()) { |
| 3412 if (cell->IsPropertyCell()) { | 3411 if (cell->IsPropertyCell()) { |
| 3413 Address value_address = | 3412 PropertyCell::BodyDescriptor::IterateBody(cell, &updating_visitor); |
| 3414 reinterpret_cast<Address>(cell) + | |
| 3415 (PropertyCell::kValueOffset - kHeapObjectTag); | |
| 3416 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
| 3417 Address type_address = | |
| 3418 reinterpret_cast<Address>(cell) + | |
| 3419 (PropertyCell::kTypeOffset - kHeapObjectTag); | |
| 3420 updating_visitor.VisitPointer(reinterpret_cast<Object**>(type_address)); | |
| 3421 } | 3413 } |
| 3422 } | 3414 } |
| 3423 | 3415 |
| 3424 // Update pointer from the native contexts list. | 3416 // Update pointer from the native contexts list. |
| 3425 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); | 3417 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); |
| 3426 | 3418 |
| 3427 heap_->string_table()->Iterate(&updating_visitor); | 3419 heap_->string_table()->Iterate(&updating_visitor); |
| 3428 | 3420 |
| 3429 // Update pointers from external string table. | 3421 // Update pointers from external string table. |
| 3430 heap_->UpdateReferencesInExternalStringTable( | 3422 heap_->UpdateReferencesInExternalStringTable( |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4295 while (buffer != NULL) { | 4287 while (buffer != NULL) { |
| 4296 SlotsBuffer* next_buffer = buffer->next(); | 4288 SlotsBuffer* next_buffer = buffer->next(); |
| 4297 DeallocateBuffer(buffer); | 4289 DeallocateBuffer(buffer); |
| 4298 buffer = next_buffer; | 4290 buffer = next_buffer; |
| 4299 } | 4291 } |
| 4300 *buffer_address = NULL; | 4292 *buffer_address = NULL; |
| 4301 } | 4293 } |
| 4302 | 4294 |
| 4303 | 4295 |
| 4304 } } // namespace v8::internal | 4296 } } // namespace v8::internal |
| OLD | NEW |