| 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 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2497 } | 2497 } |
| 2498 | 2498 |
| 2499 | 2499 |
| 2500 void MarkCompactCollector::ClearAndDeoptimizeDependentCode(Map* map) { | 2500 void MarkCompactCollector::ClearAndDeoptimizeDependentCode(Map* map) { |
| 2501 DisallowHeapAllocation no_allocation; | 2501 DisallowHeapAllocation no_allocation; |
| 2502 DependentCode* entries = map->dependent_code(); | 2502 DependentCode* entries = map->dependent_code(); |
| 2503 DependentCode::GroupStartIndexes starts(entries); | 2503 DependentCode::GroupStartIndexes starts(entries); |
| 2504 int number_of_entries = starts.number_of_entries(); | 2504 int number_of_entries = starts.number_of_entries(); |
| 2505 if (number_of_entries == 0) return; | 2505 if (number_of_entries == 0) return; |
| 2506 for (int i = 0; i < number_of_entries; i++) { | 2506 for (int i = 0; i < number_of_entries; i++) { |
| 2507 // If the entry is compilation info then the map must be alive, |
| 2508 // and ClearAndDeoptimizeDependentCode shouldn't be called. |
| 2509 ASSERT(entries->is_code_at(i)); |
| 2507 Code* code = entries->code_at(i); | 2510 Code* code = entries->code_at(i); |
| 2508 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2511 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| 2509 code->set_marked_for_deoptimization(true); | 2512 code->set_marked_for_deoptimization(true); |
| 2510 } | 2513 } |
| 2511 entries->clear_code_at(i); | 2514 entries->clear_at(i); |
| 2512 } | 2515 } |
| 2513 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2516 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
| 2514 } | 2517 } |
| 2515 | 2518 |
| 2516 | 2519 |
| 2517 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { | 2520 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { |
| 2518 DisallowHeapAllocation no_allocation; | 2521 DisallowHeapAllocation no_allocation; |
| 2519 DependentCode* entries = map->dependent_code(); | 2522 DependentCode* entries = map->dependent_code(); |
| 2520 DependentCode::GroupStartIndexes starts(entries); | 2523 DependentCode::GroupStartIndexes starts(entries); |
| 2521 int number_of_entries = starts.number_of_entries(); | 2524 int number_of_entries = starts.number_of_entries(); |
| 2522 if (number_of_entries == 0) return; | 2525 if (number_of_entries == 0) return; |
| 2523 int new_number_of_entries = 0; | 2526 int new_number_of_entries = 0; |
| 2524 // Go through all groups, remove dead codes and compact. | 2527 // Go through all groups, remove dead codes and compact. |
| 2525 for (int g = 0; g < DependentCode::kGroupCount; g++) { | 2528 for (int g = 0; g < DependentCode::kGroupCount; g++) { |
| 2526 int group_number_of_entries = 0; | 2529 int group_number_of_entries = 0; |
| 2527 for (int i = starts.at(g); i < starts.at(g + 1); i++) { | 2530 for (int i = starts.at(g); i < starts.at(g + 1); i++) { |
| 2528 Code* code = entries->code_at(i); | 2531 Object* obj = entries->object_at(i); |
| 2529 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2532 ASSERT(obj->IsCode() || IsMarked(obj)); |
| 2533 if (IsMarked(obj) && |
| 2534 (!obj->IsCode() || !Code::cast(obj)->marked_for_deoptimization())) { |
| 2530 if (new_number_of_entries + group_number_of_entries != i) { | 2535 if (new_number_of_entries + group_number_of_entries != i) { |
| 2531 entries->set_code_at(new_number_of_entries + | 2536 entries->set_object_at( |
| 2532 group_number_of_entries, code); | 2537 new_number_of_entries + group_number_of_entries, obj); |
| 2533 } | 2538 } |
| 2534 Object** slot = entries->code_slot_at(new_number_of_entries + | 2539 Object** slot = entries->slot_at(new_number_of_entries + |
| 2535 group_number_of_entries); | 2540 group_number_of_entries); |
| 2536 RecordSlot(slot, slot, code); | 2541 RecordSlot(slot, slot, obj); |
| 2537 group_number_of_entries++; | 2542 group_number_of_entries++; |
| 2538 } | 2543 } |
| 2539 } | 2544 } |
| 2540 entries->set_number_of_entries( | 2545 entries->set_number_of_entries( |
| 2541 static_cast<DependentCode::DependencyGroup>(g), | 2546 static_cast<DependentCode::DependencyGroup>(g), |
| 2542 group_number_of_entries); | 2547 group_number_of_entries); |
| 2543 new_number_of_entries += group_number_of_entries; | 2548 new_number_of_entries += group_number_of_entries; |
| 2544 } | 2549 } |
| 2545 for (int i = new_number_of_entries; i < number_of_entries; i++) { | 2550 for (int i = new_number_of_entries; i < number_of_entries; i++) { |
| 2546 entries->clear_code_at(i); | 2551 entries->clear_at(i); |
| 2547 } | 2552 } |
| 2548 } | 2553 } |
| 2549 | 2554 |
| 2550 | 2555 |
| 2551 void MarkCompactCollector::ProcessWeakMaps() { | 2556 void MarkCompactCollector::ProcessWeakMaps() { |
| 2552 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKMAP_PROCESS); | 2557 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKMAP_PROCESS); |
| 2553 Object* weak_map_obj = encountered_weak_maps(); | 2558 Object* weak_map_obj = encountered_weak_maps(); |
| 2554 while (weak_map_obj != Smi::FromInt(0)) { | 2559 while (weak_map_obj != Smi::FromInt(0)) { |
| 2555 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2560 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
| 2556 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2561 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4265 while (buffer != NULL) { | 4270 while (buffer != NULL) { |
| 4266 SlotsBuffer* next_buffer = buffer->next(); | 4271 SlotsBuffer* next_buffer = buffer->next(); |
| 4267 DeallocateBuffer(buffer); | 4272 DeallocateBuffer(buffer); |
| 4268 buffer = next_buffer; | 4273 buffer = next_buffer; |
| 4269 } | 4274 } |
| 4270 *buffer_address = NULL; | 4275 *buffer_address = NULL; |
| 4271 } | 4276 } |
| 4272 | 4277 |
| 4273 | 4278 |
| 4274 } } // namespace v8::internal | 4279 } } // namespace v8::internal |
| OLD | NEW |