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