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 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 bool parent_is_alive = Marking::MarkBitFrom(parent).Get(); | 2362 bool parent_is_alive = Marking::MarkBitFrom(parent).Get(); |
2363 if (!current_is_alive && parent_is_alive) { | 2363 if (!current_is_alive && parent_is_alive) { |
2364 parent->ClearNonLiveTransitions(heap()); | 2364 parent->ClearNonLiveTransitions(heap()); |
2365 } | 2365 } |
2366 } | 2366 } |
2367 | 2367 |
2368 | 2368 |
2369 void MarkCompactCollector::ClearAndDeoptimizeDependentCodes(Map* map) { | 2369 void MarkCompactCollector::ClearAndDeoptimizeDependentCodes(Map* map) { |
2370 AssertNoAllocation no_allocation_scope; | 2370 AssertNoAllocation no_allocation_scope; |
2371 DependentCodes* codes = map->dependent_codes(); | 2371 DependentCodes* codes = map->dependent_codes(); |
2372 int number_of_codes = codes->number_of_codes(); | 2372 DependentCodes::GroupStartIndexes starts; |
| 2373 codes->ComputeGroupStartIndexes(starts); |
| 2374 int number_of_codes = starts[DependentCodes::kGroupCount]; |
2373 if (number_of_codes == 0) return; | 2375 if (number_of_codes == 0) return; |
2374 for (int i = 0; i < number_of_codes; i++) { | 2376 for (int i = 0; i < number_of_codes; i++) { |
2375 Code* code = codes->code_at(i); | 2377 Code* code = codes->code_at(i); |
2376 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2378 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
2377 code->set_marked_for_deoptimization(true); | 2379 code->set_marked_for_deoptimization(true); |
2378 } | 2380 } |
2379 codes->clear_code_at(i); | 2381 codes->clear_code_at(i); |
2380 } | 2382 } |
2381 map->set_dependent_codes(DependentCodes::cast(heap()->empty_fixed_array())); | 2383 map->set_dependent_codes(DependentCodes::cast(heap()->empty_fixed_array())); |
2382 } | 2384 } |
2383 | 2385 |
2384 | 2386 |
2385 void MarkCompactCollector::ClearNonLiveDependentCodes(Map* map) { | 2387 void MarkCompactCollector::ClearNonLiveDependentCodes(Map* map) { |
2386 AssertNoAllocation no_allocation_scope; | 2388 AssertNoAllocation no_allocation_scope; |
2387 DependentCodes* codes = map->dependent_codes(); | 2389 DependentCodes* codes = map->dependent_codes(); |
2388 int number_of_codes = codes->number_of_codes(); | 2390 DependentCodes::GroupStartIndexes starts; |
| 2391 codes->ComputeGroupStartIndexes(starts); |
| 2392 int number_of_codes = starts[DependentCodes::kGroupCount]; |
2389 if (number_of_codes == 0) return; | 2393 if (number_of_codes == 0) return; |
2390 int new_number_of_codes = 0; | 2394 int new_number_of_codes = 0; |
2391 for (int i = 0; i < number_of_codes; i++) { | 2395 // Go through all groups, remove dead codes and compact. |
2392 Code* code = codes->code_at(i); | 2396 for (int g = 0; g < DependentCodes::kGroupCount; g++) { |
2393 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2397 int group_number_of_codes = 0; |
2394 if (new_number_of_codes != i) { | 2398 for (int i = starts[g]; i < starts[g + 1]; i++) { |
2395 codes->set_code_at(new_number_of_codes, code); | 2399 Code* code = codes->code_at(i); |
| 2400 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| 2401 if (new_number_of_codes + group_number_of_codes != i) { |
| 2402 codes->set_code_at(new_number_of_codes + group_number_of_codes, code); |
| 2403 } |
| 2404 Object** slot = codes->code_slot_at(new_number_of_codes + |
| 2405 group_number_of_codes); |
| 2406 RecordSlot(slot, slot, code); |
| 2407 group_number_of_codes++; |
2396 } | 2408 } |
2397 Object** slot = codes->code_slot_at(new_number_of_codes); | |
2398 RecordSlot(slot, slot, code); | |
2399 new_number_of_codes++; | |
2400 } | 2409 } |
| 2410 codes->set_number_of_codes(static_cast<DependentCodes::DependencyGroup>(g), |
| 2411 group_number_of_codes); |
| 2412 new_number_of_codes += group_number_of_codes; |
2401 } | 2413 } |
2402 for (int i = new_number_of_codes; i < number_of_codes; i++) { | 2414 for (int i = new_number_of_codes; i < number_of_codes; i++) { |
2403 codes->clear_code_at(i); | 2415 codes->clear_code_at(i); |
2404 } | 2416 } |
2405 codes->set_number_of_codes(new_number_of_codes); | |
2406 } | 2417 } |
2407 | 2418 |
2408 | 2419 |
2409 void MarkCompactCollector::ProcessWeakMaps() { | 2420 void MarkCompactCollector::ProcessWeakMaps() { |
2410 Object* weak_map_obj = encountered_weak_maps(); | 2421 Object* weak_map_obj = encountered_weak_maps(); |
2411 while (weak_map_obj != Smi::FromInt(0)) { | 2422 while (weak_map_obj != Smi::FromInt(0)) { |
2412 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2423 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
2413 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2424 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
2414 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); | 2425 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); |
2415 Object** anchor = reinterpret_cast<Object**>(table->address()); | 2426 Object** anchor = reinterpret_cast<Object**>(table->address()); |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4072 while (buffer != NULL) { | 4083 while (buffer != NULL) { |
4073 SlotsBuffer* next_buffer = buffer->next(); | 4084 SlotsBuffer* next_buffer = buffer->next(); |
4074 DeallocateBuffer(buffer); | 4085 DeallocateBuffer(buffer); |
4075 buffer = next_buffer; | 4086 buffer = next_buffer; |
4076 } | 4087 } |
4077 *buffer_address = NULL; | 4088 *buffer_address = NULL; |
4078 } | 4089 } |
4079 | 4090 |
4080 | 4091 |
4081 } } // namespace v8::internal | 4092 } } // namespace v8::internal |
OLD | NEW |