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 "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1444 } | 1444 } |
1445 } | 1445 } |
1446 | 1446 |
1447 | 1447 |
1448 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { | 1448 static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { |
1449 return heap->InNewSpace(*p) && | 1449 return heap->InNewSpace(*p) && |
1450 !HeapObject::cast(*p)->map_word().IsForwardingAddress(); | 1450 !HeapObject::cast(*p)->map_word().IsForwardingAddress(); |
1451 } | 1451 } |
1452 | 1452 |
1453 | 1453 |
1454 static bool IsUnModifiedNewSpaceObject(Object** p) { | |
1455 Object* object = *p; | |
1456 DCHECK(object->IsHeapObject()); | |
1457 HeapObject* heap_object = HeapObject::cast(object); | |
1458 if (!object->IsJSObject()) { | |
1459 return false; | |
1460 } | |
1461 Object* obj_constructor = (JSObject::cast(object))->map()->GetConstructor(); | |
1462 JSFunction* constructor = JSFunction::cast(obj_constructor); | |
1463 if (constructor == NULL) return false; | |
1464 if (constructor->initial_map() == heap_object->map()) return true; | |
1465 return false; | |
1466 } | |
1467 | |
1468 | |
1454 void Heap::ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page, | 1469 void Heap::ScavengeStoreBufferCallback(Heap* heap, MemoryChunk* page, |
1455 StoreBufferEvent event) { | 1470 StoreBufferEvent event) { |
1456 heap->store_buffer_rebuilder_.Callback(page, event); | 1471 heap->store_buffer_rebuilder_.Callback(page, event); |
1457 } | 1472 } |
1458 | 1473 |
1459 | 1474 |
1460 void PromotionQueue::Initialize() { | 1475 void PromotionQueue::Initialize() { |
1461 // The last to-space page may be used for promotion queue. On promotion | 1476 // The last to-space page may be used for promotion queue. On promotion |
1462 // conflict, we use the emergency stack. | 1477 // conflict, we use the emergency stack. |
1463 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == | 1478 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1562 // updated as a side effect of promoting an object. | 1577 // updated as a side effect of promoting an object. |
1563 // | 1578 // |
1564 // There is guaranteed to be enough room at the top of the to space | 1579 // There is guaranteed to be enough room at the top of the to space |
1565 // for the addresses of promoted objects: every object promoted | 1580 // for the addresses of promoted objects: every object promoted |
1566 // frees up its size in bytes from the top of the new space, and | 1581 // frees up its size in bytes from the top of the new space, and |
1567 // objects are at least one pointer in size. | 1582 // objects are at least one pointer in size. |
1568 Address new_space_front = new_space_.ToSpaceStart(); | 1583 Address new_space_front = new_space_.ToSpaceStart(); |
1569 promotion_queue_.Initialize(); | 1584 promotion_queue_.Initialize(); |
1570 | 1585 |
1571 ScavengeVisitor scavenge_visitor(this); | 1586 ScavengeVisitor scavenge_visitor(this); |
1587 | |
1588 if (FLAG_scavenge_remove_unmodified_objects) { | |
1589 isolate()->global_handles()->IdentifyWeakUnmodifiedObjects( | |
mythria
2015/09/25 17:23:51
Before, we process anything we park the unmodified
| |
1590 &IsUnModifiedNewSpaceObject); | |
1591 } | |
1592 | |
1593 | |
1572 { | 1594 { |
1573 // Copy roots. | 1595 // Copy roots. |
1574 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); | 1596 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); |
1575 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); | 1597 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); |
1576 } | 1598 } |
1577 | 1599 |
1578 { | 1600 { |
1579 // Copy objects reachable from the old generation. | 1601 // Copy objects reachable from the old generation. |
1580 GCTracer::Scope gc_scope(tracer(), | 1602 GCTracer::Scope gc_scope(tracer(), |
1581 GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); | 1603 GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); |
(...skipping 18 matching lines...) Expand all Loading... | |
1600 if (collector->is_code_flushing_enabled()) { | 1622 if (collector->is_code_flushing_enabled()) { |
1601 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); | 1623 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); |
1602 } | 1624 } |
1603 } | 1625 } |
1604 | 1626 |
1605 { | 1627 { |
1606 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); | 1628 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_SEMISPACE); |
1607 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1629 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1608 } | 1630 } |
1609 | 1631 |
1610 { | 1632 if (!FLAG_scavenge_remove_unmodified_objects) { |
1611 GCTracer::Scope gc_scope(tracer(), | 1633 GCTracer::Scope gc_scope(tracer(), |
1612 GCTracer::Scope::SCAVENGER_OBJECT_GROUPS); | 1634 GCTracer::Scope::SCAVENGER_OBJECT_GROUPS); |
1613 while (isolate()->global_handles()->IterateObjectGroups( | 1635 while (isolate()->global_handles()->IterateObjectGroups( |
1614 &scavenge_visitor, &IsUnscavengedHeapObject)) { | 1636 &scavenge_visitor, &IsUnscavengedHeapObject)) { |
1615 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); | 1637 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); |
1616 } | 1638 } |
1617 isolate()->global_handles()->RemoveObjectGroups(); | 1639 isolate()->global_handles()->RemoveObjectGroups(); |
1618 isolate()->global_handles()->RemoveImplicitRefGroups(); | 1640 isolate()->global_handles()->RemoveImplicitRefGroups(); |
1619 } | 1641 } |
1620 | 1642 |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2845 allocation_sites_scratchpad()->set(allocation_sites_scratchpad_length_, | 2867 allocation_sites_scratchpad()->set(allocation_sites_scratchpad_length_, |
2846 site, SKIP_WRITE_BARRIER); | 2868 site, SKIP_WRITE_BARRIER); |
2847 Object** slot = allocation_sites_scratchpad()->RawFieldOfElementAt( | 2869 Object** slot = allocation_sites_scratchpad()->RawFieldOfElementAt( |
2848 allocation_sites_scratchpad_length_); | 2870 allocation_sites_scratchpad_length_); |
2849 | 2871 |
2850 if (mode == RECORD_SCRATCHPAD_SLOT) { | 2872 if (mode == RECORD_SCRATCHPAD_SLOT) { |
2851 // We need to allow slots buffer overflow here since the evacuation | 2873 // We need to allow slots buffer overflow here since the evacuation |
2852 // candidates are not part of the global list of old space pages and | 2874 // candidates are not part of the global list of old space pages and |
2853 // releasing an evacuation candidate due to a slots buffer overflow | 2875 // releasing an evacuation candidate due to a slots buffer overflow |
2854 // results in lost pages. | 2876 // results in lost pages. |
2855 mark_compact_collector()->ForceRecordSlot(allocation_sites_scratchpad(), | 2877 mark_compact_collector()->RecordSlot(allocation_sites_scratchpad(), slot, |
2856 slot, *slot); | 2878 *slot); |
2857 } | 2879 } |
2858 allocation_sites_scratchpad_length_++; | 2880 allocation_sites_scratchpad_length_++; |
2859 } | 2881 } |
2860 } | 2882 } |
2861 | 2883 |
2862 | 2884 |
2863 | 2885 |
2864 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { | 2886 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { |
2865 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); | 2887 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); |
2866 } | 2888 } |
(...skipping 3238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6105 } | 6127 } |
6106 | 6128 |
6107 | 6129 |
6108 // static | 6130 // static |
6109 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6131 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6110 return StaticVisitorBase::GetVisitorId(map); | 6132 return StaticVisitorBase::GetVisitorId(map); |
6111 } | 6133 } |
6112 | 6134 |
6113 } // namespace internal | 6135 } // namespace internal |
6114 } // namespace v8 | 6136 } // namespace v8 |
OLD | NEW |