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 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 } | 2474 } |
2475 | 2475 |
2476 | 2476 |
2477 void MarkCompactCollector::ClearAndDeoptimizeDependentCode(Map* map) { | 2477 void MarkCompactCollector::ClearAndDeoptimizeDependentCode(Map* map) { |
2478 DisallowHeapAllocation no_allocation; | 2478 DisallowHeapAllocation no_allocation; |
2479 DependentCode* entries = map->dependent_code(); | 2479 DependentCode* entries = map->dependent_code(); |
2480 DependentCode::GroupStartIndexes starts(entries); | 2480 DependentCode::GroupStartIndexes starts(entries); |
2481 int number_of_entries = starts.number_of_entries(); | 2481 int number_of_entries = starts.number_of_entries(); |
2482 if (number_of_entries == 0) return; | 2482 if (number_of_entries == 0) return; |
2483 for (int i = 0; i < number_of_entries; i++) { | 2483 for (int i = 0; i < number_of_entries; i++) { |
| 2484 if (!entries->is_code_at(i)) continue; |
2484 Code* code = entries->code_at(i); | 2485 Code* code = entries->code_at(i); |
2485 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2486 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
2486 code->set_marked_for_deoptimization(true); | 2487 code->set_marked_for_deoptimization(true); |
2487 } | 2488 } |
2488 entries->clear_code_at(i); | 2489 entries->clear_at(i); |
2489 } | 2490 } |
2490 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2491 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
2491 } | 2492 } |
2492 | 2493 |
2493 | 2494 |
2494 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { | 2495 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { |
2495 DisallowHeapAllocation no_allocation; | 2496 DisallowHeapAllocation no_allocation; |
2496 DependentCode* entries = map->dependent_code(); | 2497 DependentCode* entries = map->dependent_code(); |
2497 DependentCode::GroupStartIndexes starts(entries); | 2498 DependentCode::GroupStartIndexes starts(entries); |
2498 int number_of_entries = starts.number_of_entries(); | 2499 int number_of_entries = starts.number_of_entries(); |
2499 if (number_of_entries == 0) return; | 2500 if (number_of_entries == 0) return; |
2500 int new_number_of_entries = 0; | 2501 int new_number_of_entries = 0; |
2501 // Go through all groups, remove dead codes and compact. | 2502 // Go through all groups, remove dead codes and compact. |
2502 for (int g = 0; g < DependentCode::kGroupCount; g++) { | 2503 for (int g = 0; g < DependentCode::kGroupCount; g++) { |
2503 int group_number_of_entries = 0; | 2504 int group_number_of_entries = 0; |
2504 for (int i = starts.at(g); i < starts.at(g + 1); i++) { | 2505 for (int i = starts.at(g); i < starts.at(g + 1); i++) { |
| 2506 if (!entries->is_code_at(i)) continue; |
2505 Code* code = entries->code_at(i); | 2507 Code* code = entries->code_at(i); |
2506 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2508 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
2507 if (new_number_of_entries + group_number_of_entries != i) { | 2509 if (new_number_of_entries + group_number_of_entries != i) { |
2508 entries->set_code_at(new_number_of_entries + | 2510 entries->set_object_at( |
2509 group_number_of_entries, code); | 2511 new_number_of_entries + group_number_of_entries, code); |
2510 } | 2512 } |
2511 Object** slot = entries->code_slot_at(new_number_of_entries + | 2513 Object** slot = entries->slot_at(new_number_of_entries + |
2512 group_number_of_entries); | 2514 group_number_of_entries); |
2513 RecordSlot(slot, slot, code); | 2515 RecordSlot(slot, slot, code); |
2514 group_number_of_entries++; | 2516 group_number_of_entries++; |
2515 } | 2517 } |
2516 } | 2518 } |
2517 entries->set_number_of_entries( | 2519 entries->set_number_of_entries( |
2518 static_cast<DependentCode::DependencyGroup>(g), | 2520 static_cast<DependentCode::DependencyGroup>(g), |
2519 group_number_of_entries); | 2521 group_number_of_entries); |
2520 new_number_of_entries += group_number_of_entries; | 2522 new_number_of_entries += group_number_of_entries; |
2521 } | 2523 } |
2522 for (int i = new_number_of_entries; i < number_of_entries; i++) { | 2524 for (int i = new_number_of_entries; i < number_of_entries; i++) { |
2523 entries->clear_code_at(i); | 2525 entries->clear_at(i); |
2524 } | 2526 } |
2525 } | 2527 } |
2526 | 2528 |
2527 | 2529 |
2528 void MarkCompactCollector::ProcessWeakMaps() { | 2530 void MarkCompactCollector::ProcessWeakMaps() { |
2529 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKMAP_PROCESS); | 2531 GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_WEAKMAP_PROCESS); |
2530 Object* weak_map_obj = encountered_weak_maps(); | 2532 Object* weak_map_obj = encountered_weak_maps(); |
2531 while (weak_map_obj != Smi::FromInt(0)) { | 2533 while (weak_map_obj != Smi::FromInt(0)) { |
2532 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2534 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
2533 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2535 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4242 while (buffer != NULL) { | 4244 while (buffer != NULL) { |
4243 SlotsBuffer* next_buffer = buffer->next(); | 4245 SlotsBuffer* next_buffer = buffer->next(); |
4244 DeallocateBuffer(buffer); | 4246 DeallocateBuffer(buffer); |
4245 buffer = next_buffer; | 4247 buffer = next_buffer; |
4246 } | 4248 } |
4247 *buffer_address = NULL; | 4249 *buffer_address = NULL; |
4248 } | 4250 } |
4249 | 4251 |
4250 | 4252 |
4251 } } // namespace v8::internal | 4253 } } // namespace v8::internal |
OLD | NEW |