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 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 // This map is used for inobject slack tracking and has been detached | 2285 // This map is used for inobject slack tracking and has been detached |
2286 // from SharedFunctionInfo during the mark phase. | 2286 // from SharedFunctionInfo during the mark phase. |
2287 // Since it survived the GC, reattach it now. | 2287 // Since it survived the GC, reattach it now. |
2288 map->unchecked_constructor()->unchecked_shared()->AttachInitialMap(map); | 2288 map->unchecked_constructor()->unchecked_shared()->AttachInitialMap(map); |
2289 } | 2289 } |
2290 | 2290 |
2291 ClearNonLivePrototypeTransitions(map); | 2291 ClearNonLivePrototypeTransitions(map); |
2292 ClearNonLiveMapTransitions(map, map_mark); | 2292 ClearNonLiveMapTransitions(map, map_mark); |
2293 | 2293 |
2294 if (map_mark.Get()) { | 2294 if (map_mark.Get()) { |
2295 ClearNonLiveDependentCodes(map); | 2295 ClearNonLiveDependentCode(map); |
2296 } else { | 2296 } else { |
2297 ClearAndDeoptimizeDependentCodes(map); | 2297 ClearAndDeoptimizeDependentCode(map); |
2298 } | 2298 } |
2299 } | 2299 } |
2300 } | 2300 } |
2301 | 2301 |
2302 | 2302 |
2303 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { | 2303 void MarkCompactCollector::ClearNonLivePrototypeTransitions(Map* map) { |
2304 int number_of_transitions = map->NumberOfProtoTransitions(); | 2304 int number_of_transitions = map->NumberOfProtoTransitions(); |
2305 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); | 2305 FixedArray* prototype_transitions = map->GetPrototypeTransitions(); |
2306 | 2306 |
2307 int new_number_of_transitions = 0; | 2307 int new_number_of_transitions = 0; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 // Follow back pointer, check whether we are dealing with a map transition | 2357 // Follow back pointer, check whether we are dealing with a map transition |
2358 // from a live map to a dead path and in case clear transitions of parent. | 2358 // from a live map to a dead path and in case clear transitions of parent. |
2359 bool current_is_alive = map_mark.Get(); | 2359 bool current_is_alive = map_mark.Get(); |
2360 bool parent_is_alive = Marking::MarkBitFrom(parent).Get(); | 2360 bool parent_is_alive = Marking::MarkBitFrom(parent).Get(); |
2361 if (!current_is_alive && parent_is_alive) { | 2361 if (!current_is_alive && parent_is_alive) { |
2362 parent->ClearNonLiveTransitions(heap()); | 2362 parent->ClearNonLiveTransitions(heap()); |
2363 } | 2363 } |
2364 } | 2364 } |
2365 | 2365 |
2366 | 2366 |
2367 void MarkCompactCollector::ClearAndDeoptimizeDependentCodes(Map* map) { | 2367 void MarkCompactCollector::ClearAndDeoptimizeDependentCode(Map* map) { |
2368 AssertNoAllocation no_allocation_scope; | 2368 AssertNoAllocation no_allocation_scope; |
2369 DependentCodes* codes = map->dependent_codes(); | 2369 DependentCode* entries = map->dependent_code(); |
2370 int number_of_codes = codes->number_of_codes(); | 2370 DependentCode::GroupStartIndexes starts(entries); |
2371 if (number_of_codes == 0) return; | 2371 int number_of_entries = starts.number_of_entries(); |
2372 for (int i = 0; i < number_of_codes; i++) { | 2372 if (number_of_entries == 0) return; |
2373 Code* code = codes->code_at(i); | 2373 for (int i = 0; i < number_of_entries; i++) { |
| 2374 Code* code = entries->code_at(i); |
2374 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2375 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
2375 code->set_marked_for_deoptimization(true); | 2376 code->set_marked_for_deoptimization(true); |
2376 } | 2377 } |
2377 codes->clear_code_at(i); | 2378 entries->clear_code_at(i); |
2378 } | 2379 } |
2379 map->set_dependent_codes(DependentCodes::cast(heap()->empty_fixed_array())); | 2380 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
2380 } | 2381 } |
2381 | 2382 |
2382 | 2383 |
2383 void MarkCompactCollector::ClearNonLiveDependentCodes(Map* map) { | 2384 void MarkCompactCollector::ClearNonLiveDependentCode(Map* map) { |
2384 AssertNoAllocation no_allocation_scope; | 2385 AssertNoAllocation no_allocation_scope; |
2385 DependentCodes* codes = map->dependent_codes(); | 2386 DependentCode* entries = map->dependent_code(); |
2386 int number_of_codes = codes->number_of_codes(); | 2387 DependentCode::GroupStartIndexes starts(entries); |
2387 if (number_of_codes == 0) return; | 2388 int number_of_entries = starts.number_of_entries(); |
2388 int new_number_of_codes = 0; | 2389 if (number_of_entries == 0) return; |
2389 for (int i = 0; i < number_of_codes; i++) { | 2390 int new_number_of_entries = 0; |
2390 Code* code = codes->code_at(i); | 2391 // Go through all groups, remove dead codes and compact. |
2391 if (IsMarked(code) && !code->marked_for_deoptimization()) { | 2392 for (int g = 0; g < DependentCode::kGroupCount; g++) { |
2392 if (new_number_of_codes != i) { | 2393 int group_number_of_entries = 0; |
2393 codes->set_code_at(new_number_of_codes, code); | 2394 for (int i = starts.at(g); i < starts.at(g + 1); i++) { |
| 2395 Code* code = entries->code_at(i); |
| 2396 if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| 2397 if (new_number_of_entries + group_number_of_entries != i) { |
| 2398 entries->set_code_at(new_number_of_entries + |
| 2399 group_number_of_entries, code); |
| 2400 } |
| 2401 Object** slot = entries->code_slot_at(new_number_of_entries + |
| 2402 group_number_of_entries); |
| 2403 RecordSlot(slot, slot, code); |
| 2404 group_number_of_entries++; |
2394 } | 2405 } |
2395 Object** slot = codes->code_slot_at(new_number_of_codes); | |
2396 RecordSlot(slot, slot, code); | |
2397 new_number_of_codes++; | |
2398 } | 2406 } |
| 2407 entries->set_number_of_entries( |
| 2408 static_cast<DependentCode::DependencyGroup>(g), |
| 2409 group_number_of_entries); |
| 2410 new_number_of_entries += group_number_of_entries; |
2399 } | 2411 } |
2400 for (int i = new_number_of_codes; i < number_of_codes; i++) { | 2412 for (int i = new_number_of_entries; i < number_of_entries; i++) { |
2401 codes->clear_code_at(i); | 2413 entries->clear_code_at(i); |
2402 } | 2414 } |
2403 codes->set_number_of_codes(new_number_of_codes); | |
2404 } | 2415 } |
2405 | 2416 |
2406 | 2417 |
2407 void MarkCompactCollector::ProcessWeakMaps() { | 2418 void MarkCompactCollector::ProcessWeakMaps() { |
2408 Object* weak_map_obj = encountered_weak_maps(); | 2419 Object* weak_map_obj = encountered_weak_maps(); |
2409 while (weak_map_obj != Smi::FromInt(0)) { | 2420 while (weak_map_obj != Smi::FromInt(0)) { |
2410 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); | 2421 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); |
2411 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); | 2422 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); |
2412 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); | 2423 ObjectHashTable* table = ObjectHashTable::cast(weak_map->table()); |
2413 Object** anchor = reinterpret_cast<Object**>(table->address()); | 2424 Object** anchor = reinterpret_cast<Object**>(table->address()); |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4070 while (buffer != NULL) { | 4081 while (buffer != NULL) { |
4071 SlotsBuffer* next_buffer = buffer->next(); | 4082 SlotsBuffer* next_buffer = buffer->next(); |
4072 DeallocateBuffer(buffer); | 4083 DeallocateBuffer(buffer); |
4073 buffer = next_buffer; | 4084 buffer = next_buffer; |
4074 } | 4085 } |
4075 *buffer_address = NULL; | 4086 *buffer_address = NULL; |
4076 } | 4087 } |
4077 | 4088 |
4078 | 4089 |
4079 } } // namespace v8::internal | 4090 } } // namespace v8::internal |
OLD | NEW |