| 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 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 } | 2262 } |
| 2263 } | 2263 } |
| 2264 } | 2264 } |
| 2265 { | 2265 { |
| 2266 HeapObjectIterator js_global_property_cell_iterator( | 2266 HeapObjectIterator js_global_property_cell_iterator( |
| 2267 heap()->property_cell_space()); | 2267 heap()->property_cell_space()); |
| 2268 HeapObject* cell; | 2268 HeapObject* cell; |
| 2269 while ((cell = js_global_property_cell_iterator.Next()) != NULL) { | 2269 while ((cell = js_global_property_cell_iterator.Next()) != NULL) { |
| 2270 ASSERT(cell->IsPropertyCell()); | 2270 ASSERT(cell->IsPropertyCell()); |
| 2271 if (IsMarked(cell)) { | 2271 if (IsMarked(cell)) { |
| 2272 int offset = PropertyCell::kValueOffset; | 2272 MarkCompactMarkingVisitor::VisitPropertyCell(cell->map(), cell); |
| 2273 MarkCompactMarkingVisitor::VisitPointer( | |
| 2274 heap(), | |
| 2275 reinterpret_cast<Object**>(cell->address() + offset)); | |
| 2276 offset = PropertyCell::kTypeOffset; | |
| 2277 MarkCompactMarkingVisitor::VisitPointer( | |
| 2278 heap(), | |
| 2279 reinterpret_cast<Object**>(cell->address() + offset)); | |
| 2280 } | 2273 } |
| 2281 } | 2274 } |
| 2282 } | 2275 } |
| 2283 } | 2276 } |
| 2284 | 2277 |
| 2285 RootMarkingVisitor root_visitor(heap()); | 2278 RootMarkingVisitor root_visitor(heap()); |
| 2286 MarkRoots(&root_visitor); | 2279 MarkRoots(&root_visitor); |
| 2287 | 2280 |
| 2288 // The objects reachable from the roots are marked, yet unreachable | 2281 // The objects reachable from the roots are marked, yet unreachable |
| 2289 // objects are unmarked. Mark objects reachable due to host | 2282 // objects are unmarked. Mark objects reachable due to host |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 // This map is used for inobject slack tracking and has been detached | 2441 // This map is used for inobject slack tracking and has been detached |
| 2449 // from SharedFunctionInfo during the mark phase. | 2442 // from SharedFunctionInfo during the mark phase. |
| 2450 // Since it survived the GC, reattach it now. | 2443 // Since it survived the GC, reattach it now. |
| 2451 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); | 2444 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); |
| 2452 } | 2445 } |
| 2453 | 2446 |
| 2454 ClearNonLivePrototypeTransitions(map); | 2447 ClearNonLivePrototypeTransitions(map); |
| 2455 ClearNonLiveMapTransitions(map, map_mark); | 2448 ClearNonLiveMapTransitions(map, map_mark); |
| 2456 | 2449 |
| 2457 if (map_mark.Get()) { | 2450 if (map_mark.Get()) { |
| 2458 ClearNonLiveDependentCode(map); | 2451 ClearNonLiveDependentCode(map->dependent_code()); |
| 2459 } else { | 2452 } else { |
| 2460 ClearAndDeoptimizeDependentCode(map); | 2453 ClearAndDeoptimizeDependentCode(map); |
| 2461 } | 2454 } |
| 2462 } | 2455 } |
| 2456 |
| 2457 // Iterate over property cell space, removing dependent code that is not |
| 2458 // otherwise kept alive by strong references. |
| 2459 HeapObjectIterator cell_iterator(heap_->property_cell_space()); |
| 2460 for (HeapObject* cell = cell_iterator.Next(); |
| 2461 cell != NULL; |
| 2462 cell = cell_iterator.Next()) { |
| 2463 ClearNonLiveDependentCode(PropertyCell::cast(cell)->dependent_code()); |
| 2464 } |
| 2463 } | 2465 } |
| 2464 | 2466 |
| 2465 | 2467 |
| 2466 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { | 2468 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { |
| 2467 int number_of_transitions = map->NumberOfProtoTransitions(); | 2469 int number_of_transitions = map->NumberOfProtoTransitions(); |
| 2468 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); | 2470 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); |
| 2469 | 2471 |
| 2470 int new_number_of_transitions = 0; | 2472 int new_number_of_transitions = 0; |
| 2471 const int header = Map::kProtoTransitionHeaderSize; | 2473 const int header = Map::kProtoTransitionHeaderSize; |
| 2472 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; | 2474 const int proto_offset = header + Map::kProtoTransitionPrototypeOffset; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2538 Code* code = entries->code_at(i); | 2540 Code* code = entries->code_at(i); |
| 2539 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2541 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| 2540 code->set_marked_for_deoptimization(true); | 2542 code->set_marked_for_deoptimization(true); |
| 2541 } | 2543 } |
| 2542 entries->clear_at(i); | 2544 entries->clear_at(i); |
| 2543 } | 2545 } |
| 2544 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2546 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
| 2545 } | 2547 } |
| 2546 | 2548 |
| 2547 | 2549 |
| 2548 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { | 2550 void MarkCompactCollector::ClearNonLiveDependentCode(DependentCode* entries) { |
| 2549 DisallowHeapAllocation no_allocation; | 2551 DisallowHeapAllocation no_allocation; |
| 2550 DependentCode* entries = map->dependent_code(); | |
| 2551 DependentCode::GroupStartIndexes starts(entries); | 2552 DependentCode::GroupStartIndexes starts(entries); |
| 2552 int number_of_entries = starts.number_of_entries(); | 2553 int number_of_entries = starts.number_of_entries(); |
| 2553 if (number_of_entries == 0) return; | 2554 if (number_of_entries == 0) return; |
| 2554 int new_number_of_entries = 0; | 2555 int new_number_of_entries = 0; |
| 2555 // Go through all groups, remove dead codes and compact. | 2556 // Go through all groups, remove dead codes and compact. |
| 2556 for (int g = 0; g < DependentCode::kGroupCount; g++) { | 2557 for (int g = 0; g < DependentCode::kGroupCount; g++) { |
| 2557 int group_number_of_entries = 0; | 2558 int group_number_of_entries = 0; |
| 2558 for (int i = starts.at(g); i < starts.at(g + 1); i++) { | 2559 for (int i = starts.at(g); i < starts.at(g + 1); i++) { |
| 2559 Object* obj = entries->object_at(i); | 2560 Object* obj = entries->object_at(i); |
| 2560 ASSERT(obj->IsCode() || IsMarked(obj)); | 2561 ASSERT(obj->IsCode() || IsMarked(obj)); |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 } | 3412 } |
| 3412 | 3413 |
| 3413 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); | 3414 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_UPDATE_MISC_POINTERS); |
| 3414 | 3415 |
| 3415 // Update pointers from cells. | 3416 // Update pointers from cells. |
| 3416 HeapObjectIterator cell_iterator(heap_->cell_space()); | 3417 HeapObjectIterator cell_iterator(heap_->cell_space()); |
| 3417 for (HeapObject* cell = cell_iterator.Next(); | 3418 for (HeapObject* cell = cell_iterator.Next(); |
| 3418 cell != NULL; | 3419 cell != NULL; |
| 3419 cell = cell_iterator.Next()) { | 3420 cell = cell_iterator.Next()) { |
| 3420 if (cell->IsCell()) { | 3421 if (cell->IsCell()) { |
| 3421 Address value_address = reinterpret_cast<Address>(cell) + | 3422 Cell::BodyDescriptor::IterateBody(cell, &updating_visitor); |
| 3422 (Cell::kValueOffset - kHeapObjectTag); | |
| 3423 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
| 3424 } | 3423 } |
| 3425 } | 3424 } |
| 3426 | 3425 |
| 3427 HeapObjectIterator js_global_property_cell_iterator( | 3426 HeapObjectIterator js_global_property_cell_iterator( |
| 3428 heap_->property_cell_space()); | 3427 heap_->property_cell_space()); |
| 3429 for (HeapObject* cell = js_global_property_cell_iterator.Next(); | 3428 for (HeapObject* cell = js_global_property_cell_iterator.Next(); |
| 3430 cell != NULL; | 3429 cell != NULL; |
| 3431 cell = js_global_property_cell_iterator.Next()) { | 3430 cell = js_global_property_cell_iterator.Next()) { |
| 3432 if (cell->IsPropertyCell()) { | 3431 if (cell->IsPropertyCell()) { |
| 3433 Address value_address = | 3432 PropertyCell::BodyDescriptor::IterateBody(cell, &updating_visitor); |
| 3434 reinterpret_cast<Address>(cell) + | |
| 3435 (PropertyCell::kValueOffset - kHeapObjectTag); | |
| 3436 updating_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | |
| 3437 Address type_address = | |
| 3438 reinterpret_cast<Address>(cell) + | |
| 3439 (PropertyCell::kTypeOffset - kHeapObjectTag); | |
| 3440 updating_visitor.VisitPointer(reinterpret_cast<Object**>(type_address)); | |
| 3441 } | 3433 } |
| 3442 } | 3434 } |
| 3443 | 3435 |
| 3444 // Update pointer from the native contexts list. | 3436 // Update pointer from the native contexts list. |
| 3445 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); | 3437 updating_visitor.VisitPointer(heap_->native_contexts_list_address()); |
| 3446 | 3438 |
| 3447 heap_->string_table()->Iterate(&updating_visitor); | 3439 heap_->string_table()->Iterate(&updating_visitor); |
| 3448 | 3440 |
| 3449 // Update pointers from external string table. | 3441 // Update pointers from external string table. |
| 3450 heap_->UpdateReferencesInExternalStringTable( | 3442 heap_->UpdateReferencesInExternalStringTable( |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4315 while (buffer != NULL) { | 4307 while (buffer != NULL) { |
| 4316 SlotsBuffer* next_buffer = buffer->next(); | 4308 SlotsBuffer* next_buffer = buffer->next(); |
| 4317 DeallocateBuffer(buffer); | 4309 DeallocateBuffer(buffer); |
| 4318 buffer = next_buffer; | 4310 buffer = next_buffer; |
| 4319 } | 4311 } |
| 4320 *buffer_address = NULL; | 4312 *buffer_address = NULL; |
| 4321 } | 4313 } |
| 4322 | 4314 |
| 4323 | 4315 |
| 4324 } } // namespace v8::internal | 4316 } } // namespace v8::internal |
| OLD | NEW |