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