OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "code-stubs.h" | 7 #include "code-stubs.h" |
8 #include "compilation-cache.h" | 8 #include "compilation-cache.h" |
9 #include "cpu-profiler.h" | 9 #include "cpu-profiler.h" |
10 #include "deoptimizer.h" | 10 #include "deoptimizer.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 ClearWeakCollections(); | 410 ClearWeakCollections(); |
411 | 411 |
412 #ifdef VERIFY_HEAP | 412 #ifdef VERIFY_HEAP |
413 if (FLAG_verify_heap) { | 413 if (FLAG_verify_heap) { |
414 VerifyMarking(heap_); | 414 VerifyMarking(heap_); |
415 } | 415 } |
416 #endif | 416 #endif |
417 | 417 |
418 SweepSpaces(); | 418 SweepSpaces(); |
419 | 419 |
| 420 if (!FLAG_collect_maps) ReattachInitialMaps(); |
| 421 |
420 #ifdef DEBUG | 422 #ifdef DEBUG |
421 if (FLAG_verify_native_context_separation) { | 423 if (FLAG_verify_native_context_separation) { |
422 VerifyNativeContextSeparation(heap_); | 424 VerifyNativeContextSeparation(heap_); |
423 } | 425 } |
424 #endif | 426 #endif |
425 | 427 |
426 #ifdef VERIFY_HEAP | 428 #ifdef VERIFY_HEAP |
427 if (heap()->weak_embedded_objects_verification_enabled()) { | 429 if (heap()->weak_embedded_objects_verification_enabled()) { |
428 VerifyWeakEmbeddedObjectsInCode(); | 430 VerifyWeakEmbeddedObjectsInCode(); |
429 } | 431 } |
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 } | 2527 } |
2526 } | 2528 } |
2527 } | 2529 } |
2528 // Move to next element in the list. | 2530 // Move to next element in the list. |
2529 raw_context = context->get(Context::NEXT_CONTEXT_LINK); | 2531 raw_context = context->get(Context::NEXT_CONTEXT_LINK); |
2530 } | 2532 } |
2531 ProcessMarkingDeque(); | 2533 ProcessMarkingDeque(); |
2532 } | 2534 } |
2533 | 2535 |
2534 | 2536 |
| 2537 void MarkCompactCollector::ReattachInitialMaps() { |
| 2538 HeapObjectIterator map_iterator(heap()->map_space()); |
| 2539 for (HeapObject* obj = map_iterator.Next(); |
| 2540 obj != NULL; |
| 2541 obj = map_iterator.Next()) { |
| 2542 Map* map = Map::cast(obj); |
| 2543 |
| 2544 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
| 2545 if (map->instance_type() < FIRST_JS_RECEIVER_TYPE) continue; |
| 2546 |
| 2547 if (map->attached_to_shared_function_info()) { |
| 2548 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); |
| 2549 } |
| 2550 } |
| 2551 } |
| 2552 |
| 2553 |
2535 void MarkCompactCollector::ClearNonLiveReferences() { | 2554 void MarkCompactCollector::ClearNonLiveReferences() { |
2536 // Iterate over the map space, setting map transitions that go from | 2555 // Iterate over the map space, setting map transitions that go from |
2537 // a marked map to an unmarked map to null transitions. This action | 2556 // a marked map to an unmarked map to null transitions. This action |
2538 // is carried out only on maps of JSObjects and related subtypes. | 2557 // is carried out only on maps of JSObjects and related subtypes. |
2539 HeapObjectIterator map_iterator(heap()->map_space()); | 2558 HeapObjectIterator map_iterator(heap()->map_space()); |
2540 for (HeapObject* obj = map_iterator.Next(); | 2559 for (HeapObject* obj = map_iterator.Next(); |
2541 obj != NULL; | 2560 obj != NULL; |
2542 obj = map_iterator.Next()) { | 2561 obj = map_iterator.Next()) { |
2543 Map* map = Map::cast(obj); | 2562 Map* map = Map::cast(obj); |
2544 | 2563 |
2545 if (!map->CanTransition()) continue; | 2564 if (!map->CanTransition()) continue; |
2546 | 2565 |
2547 MarkBit map_mark = Marking::MarkBitFrom(map); | 2566 MarkBit map_mark = Marking::MarkBitFrom(map); |
| 2567 if (map_mark.Get() && map->attached_to_shared_function_info()) { |
| 2568 // This map is used for inobject slack tracking and has been detached |
| 2569 // from SharedFunctionInfo during the mark phase. |
| 2570 // Since it survived the GC, reattach it now. |
| 2571 JSFunction::cast(map->constructor())->shared()->AttachInitialMap(map); |
| 2572 } |
| 2573 |
2548 ClearNonLivePrototypeTransitions(map); | 2574 ClearNonLivePrototypeTransitions(map); |
2549 ClearNonLiveMapTransitions(map, map_mark); | 2575 ClearNonLiveMapTransitions(map, map_mark); |
2550 | 2576 |
2551 if (map_mark.Get()) { | 2577 if (map_mark.Get()) { |
2552 ClearNonLiveDependentCode(map->dependent_code()); | 2578 ClearNonLiveDependentCode(map->dependent_code()); |
2553 } else { | 2579 } else { |
2554 ClearDependentCode(map->dependent_code()); | 2580 ClearDependentCode(map->dependent_code()); |
2555 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2581 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
2556 } | 2582 } |
2557 } | 2583 } |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4506 while (buffer != NULL) { | 4532 while (buffer != NULL) { |
4507 SlotsBuffer* next_buffer = buffer->next(); | 4533 SlotsBuffer* next_buffer = buffer->next(); |
4508 DeallocateBuffer(buffer); | 4534 DeallocateBuffer(buffer); |
4509 buffer = next_buffer; | 4535 buffer = next_buffer; |
4510 } | 4536 } |
4511 *buffer_address = NULL; | 4537 *buffer_address = NULL; |
4512 } | 4538 } |
4513 | 4539 |
4514 | 4540 |
4515 } } // namespace v8::internal | 4541 } } // namespace v8::internal |
OLD | NEW |