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 | |
422 #ifdef DEBUG | 420 #ifdef DEBUG |
423 if (FLAG_verify_native_context_separation) { | 421 if (FLAG_verify_native_context_separation) { |
424 VerifyNativeContextSeparation(heap_); | 422 VerifyNativeContextSeparation(heap_); |
425 } | 423 } |
426 #endif | 424 #endif |
427 | 425 |
428 #ifdef VERIFY_HEAP | 426 #ifdef VERIFY_HEAP |
429 if (heap()->weak_embedded_objects_verification_enabled()) { | 427 if (heap()->weak_embedded_objects_verification_enabled()) { |
430 VerifyWeakEmbeddedObjectsInCode(); | 428 VerifyWeakEmbeddedObjectsInCode(); |
431 } | 429 } |
(...skipping 2095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 } | 2525 } |
2528 } | 2526 } |
2529 } | 2527 } |
2530 // Move to next element in the list. | 2528 // Move to next element in the list. |
2531 raw_context = context->get(Context::NEXT_CONTEXT_LINK); | 2529 raw_context = context->get(Context::NEXT_CONTEXT_LINK); |
2532 } | 2530 } |
2533 ProcessMarkingDeque(); | 2531 ProcessMarkingDeque(); |
2534 } | 2532 } |
2535 | 2533 |
2536 | 2534 |
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 | |
2554 void MarkCompactCollector::ClearNonLiveReferences() { | 2535 void MarkCompactCollector::ClearNonLiveReferences() { |
2555 // Iterate over the map space, setting map transitions that go from | 2536 // Iterate over the map space, setting map transitions that go from |
2556 // a marked map to an unmarked map to null transitions. This action | 2537 // a marked map to an unmarked map to null transitions. This action |
2557 // is carried out only on maps of JSObjects and related subtypes. | 2538 // is carried out only on maps of JSObjects and related subtypes. |
2558 HeapObjectIterator map_iterator(heap()->map_space()); | 2539 HeapObjectIterator map_iterator(heap()->map_space()); |
2559 for (HeapObject* obj = map_iterator.Next(); | 2540 for (HeapObject* obj = map_iterator.Next(); |
2560 obj != NULL; | 2541 obj != NULL; |
2561 obj = map_iterator.Next()) { | 2542 obj = map_iterator.Next()) { |
2562 Map* map = Map::cast(obj); | 2543 Map* map = Map::cast(obj); |
2563 | 2544 |
2564 if (!map->CanTransition()) continue; | 2545 if (!map->CanTransition()) continue; |
2565 | 2546 |
2566 MarkBit map_mark = Marking::MarkBitFrom(map); | 2547 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 | |
2574 ClearNonLivePrototypeTransitions(map); | 2548 ClearNonLivePrototypeTransitions(map); |
2575 ClearNonLiveMapTransitions(map, map_mark); | 2549 ClearNonLiveMapTransitions(map, map_mark); |
2576 | 2550 |
2577 if (map_mark.Get()) { | 2551 if (map_mark.Get()) { |
2578 ClearNonLiveDependentCode(map->dependent_code()); | 2552 ClearNonLiveDependentCode(map->dependent_code()); |
2579 } else { | 2553 } else { |
2580 ClearDependentCode(map->dependent_code()); | 2554 ClearDependentCode(map->dependent_code()); |
2581 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); | 2555 map->set_dependent_code(DependentCode::cast(heap()->empty_fixed_array())); |
2582 } | 2556 } |
2583 } | 2557 } |
(...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4532 while (buffer != NULL) { | 4506 while (buffer != NULL) { |
4533 SlotsBuffer* next_buffer = buffer->next(); | 4507 SlotsBuffer* next_buffer = buffer->next(); |
4534 DeallocateBuffer(buffer); | 4508 DeallocateBuffer(buffer); |
4535 buffer = next_buffer; | 4509 buffer = next_buffer; |
4536 } | 4510 } |
4537 *buffer_address = NULL; | 4511 *buffer_address = NULL; |
4538 } | 4512 } |
4539 | 4513 |
4540 | 4514 |
4541 } } // namespace v8::internal | 4515 } } // namespace v8::internal |
OLD | NEW |