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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1562 } | 1562 } |
1563 // Retained object is new tail. | 1563 // Retained object is new tail. |
1564 ASSERT(!retained->IsUndefined()); | 1564 ASSERT(!retained->IsUndefined()); |
1565 candidate = reinterpret_cast<T*>(retained); | 1565 candidate = reinterpret_cast<T*>(retained); |
1566 tail = candidate; | 1566 tail = candidate; |
1567 | 1567 |
1568 | 1568 |
1569 // tail is a live object, visit it. | 1569 // tail is a live object, visit it. |
1570 WeakListVisitor<T>::VisitLiveObject( | 1570 WeakListVisitor<T>::VisitLiveObject( |
1571 heap, tail, retainer, record_slots); | 1571 heap, tail, retainer, record_slots); |
1572 } else { | |
1573 WeakListVisitor<T>::VisitPhantomObject(heap, candidate); | |
1572 } | 1574 } |
1573 | 1575 |
1574 // Move to next element in the list. | 1576 // Move to next element in the list. |
1575 list = WeakListVisitor<T>::WeakNext(candidate); | 1577 list = WeakListVisitor<T>::WeakNext(candidate); |
1576 } | 1578 } |
1577 | 1579 |
1578 // Terminate the list if there is one or more elements. | 1580 // Terminate the list if there is one or more elements. |
1579 if (tail != NULL) { | 1581 if (tail != NULL) { |
1580 WeakListVisitor<T>::SetWeakNext(tail, undefined); | 1582 WeakListVisitor<T>::SetWeakNext(tail, undefined); |
1581 } | 1583 } |
(...skipping 11 matching lines...) Expand all Loading... | |
1593 return function->next_function_link(); | 1595 return function->next_function_link(); |
1594 } | 1596 } |
1595 | 1597 |
1596 static int WeakNextOffset() { | 1598 static int WeakNextOffset() { |
1597 return JSFunction::kNextFunctionLinkOffset; | 1599 return JSFunction::kNextFunctionLinkOffset; |
1598 } | 1600 } |
1599 | 1601 |
1600 static void VisitLiveObject(Heap*, JSFunction*, | 1602 static void VisitLiveObject(Heap*, JSFunction*, |
1601 WeakObjectRetainer*, bool) { | 1603 WeakObjectRetainer*, bool) { |
1602 } | 1604 } |
1605 | |
1606 static void VisitPhantomObject(Heap*, JSFunction*) { | |
1607 } | |
1603 }; | 1608 }; |
1604 | 1609 |
1605 | 1610 |
1606 template<> | 1611 template<> |
1607 struct WeakListVisitor<Context> { | 1612 struct WeakListVisitor<Context> { |
1608 static void SetWeakNext(Context* context, Object* next) { | 1613 static void SetWeakNext(Context* context, Object* next) { |
1609 context->set(Context::NEXT_CONTEXT_LINK, | 1614 context->set(Context::NEXT_CONTEXT_LINK, |
1610 next, | 1615 next, |
1611 UPDATE_WRITE_BARRIER); | 1616 UPDATE_WRITE_BARRIER); |
1612 } | 1617 } |
(...skipping 18 matching lines...) Expand all Loading... | |
1631 UPDATE_WRITE_BARRIER); | 1636 UPDATE_WRITE_BARRIER); |
1632 if (record_slots) { | 1637 if (record_slots) { |
1633 Object** optimized_functions = | 1638 Object** optimized_functions = |
1634 HeapObject::RawField( | 1639 HeapObject::RawField( |
1635 context, FixedArray::SizeFor(Context::OPTIMIZED_FUNCTIONS_LIST)); | 1640 context, FixedArray::SizeFor(Context::OPTIMIZED_FUNCTIONS_LIST)); |
1636 heap->mark_compact_collector()->RecordSlot( | 1641 heap->mark_compact_collector()->RecordSlot( |
1637 optimized_functions, optimized_functions, function_list_head); | 1642 optimized_functions, optimized_functions, function_list_head); |
1638 } | 1643 } |
1639 } | 1644 } |
1640 | 1645 |
1646 static void VisitPhantomObject(Heap*, Context*) { | |
1647 } | |
1648 | |
1641 static int WeakNextOffset() { | 1649 static int WeakNextOffset() { |
1642 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); | 1650 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); |
1643 } | 1651 } |
1644 }; | 1652 }; |
1645 | 1653 |
1646 | 1654 |
1647 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { | 1655 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { |
1648 // We don't record weak slots during marking or scavenges. | 1656 // We don't record weak slots during marking or scavenges. |
1649 // Instead we do it once when we complete mark-compact cycle. | 1657 // Instead we do it once when we complete mark-compact cycle. |
1650 // Note that write barrier has no effect if we are already in the middle of | 1658 // Note that write barrier has no effect if we are already in the middle of |
(...skipping 23 matching lines...) Expand all Loading... | |
1674 | 1682 |
1675 static Object* WeakNext(JSTypedArray* obj) { | 1683 static Object* WeakNext(JSTypedArray* obj) { |
1676 return obj->weak_next(); | 1684 return obj->weak_next(); |
1677 } | 1685 } |
1678 | 1686 |
1679 static void VisitLiveObject(Heap*, | 1687 static void VisitLiveObject(Heap*, |
1680 JSTypedArray* obj, | 1688 JSTypedArray* obj, |
1681 WeakObjectRetainer* retainer, | 1689 WeakObjectRetainer* retainer, |
1682 bool record_slots) {} | 1690 bool record_slots) {} |
1683 | 1691 |
1692 static void VisitPhantomObject(Heap*, JSTypedArray*) {} | |
1693 | |
1684 static int WeakNextOffset() { | 1694 static int WeakNextOffset() { |
1685 return JSTypedArray::kWeakNextOffset; | 1695 return JSTypedArray::kWeakNextOffset; |
1686 } | 1696 } |
1687 }; | 1697 }; |
1688 | 1698 |
1689 | 1699 |
1690 template<> | 1700 template<> |
1691 struct WeakListVisitor<JSArrayBuffer> { | 1701 struct WeakListVisitor<JSArrayBuffer> { |
1692 static void SetWeakNext(JSArrayBuffer* obj, Object* next) { | 1702 static void SetWeakNext(JSArrayBuffer* obj, Object* next) { |
1693 obj->set_weak_next(next); | 1703 obj->set_weak_next(next); |
(...skipping 13 matching lines...) Expand all Loading... | |
1707 array_buffer->weak_first_array(), | 1717 array_buffer->weak_first_array(), |
1708 retainer, record_slots); | 1718 retainer, record_slots); |
1709 array_buffer->set_weak_first_array(typed_array_obj); | 1719 array_buffer->set_weak_first_array(typed_array_obj); |
1710 if (typed_array_obj != heap->undefined_value() && record_slots) { | 1720 if (typed_array_obj != heap->undefined_value() && record_slots) { |
1711 Object** slot = HeapObject::RawField( | 1721 Object** slot = HeapObject::RawField( |
1712 array_buffer, JSArrayBuffer::kWeakFirstArrayOffset); | 1722 array_buffer, JSArrayBuffer::kWeakFirstArrayOffset); |
1713 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj); | 1723 heap->mark_compact_collector()->RecordSlot(slot, slot, typed_array_obj); |
1714 } | 1724 } |
1715 } | 1725 } |
1716 | 1726 |
1727 static void VisitPhantomObject(Heap* heap, JSArrayBuffer* phantom) { | |
1728 Runtime::FreeArrayBuffer(heap->isolate(), phantom); | |
1729 } | |
1730 | |
1717 static int WeakNextOffset() { | 1731 static int WeakNextOffset() { |
1718 return JSArrayBuffer::kWeakNextOffset; | 1732 return JSArrayBuffer::kWeakNextOffset; |
1719 } | 1733 } |
1720 }; | 1734 }; |
1721 | 1735 |
1722 | 1736 |
1723 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer, | 1737 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer, |
1724 bool record_slots) { | 1738 bool record_slots) { |
1725 Object* array_buffer_obj = | 1739 Object* array_buffer_obj = |
1726 VisitWeakList<JSArrayBuffer>(this, | 1740 VisitWeakList<JSArrayBuffer>(this, |
1727 array_buffers_list(), | 1741 array_buffers_list(), |
1728 retainer, record_slots); | 1742 retainer, record_slots); |
1729 set_array_buffers_list(array_buffer_obj); | 1743 set_array_buffers_list(array_buffer_obj); |
1730 } | 1744 } |
1731 | 1745 |
Michael Starzinger
2013/06/19 11:35:09
nit: Add a second empty newline.
Dmitry Lomov (no reviews)
2013/06/19 11:51:25
Done.
| |
1746 void Heap::TearDownArrayBuffers() { | |
1747 Object* undefined = undefined_value(); | |
1748 for (Object* o = array_buffers_list(); | |
Michael Starzinger
2013/06/19 11:35:09
nit: Should fit into one line.
Dmitry Lomov (no reviews)
2013/06/19 11:51:25
Done.
| |
1749 o != undefined;) { | |
1750 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); | |
1751 Runtime::FreeArrayBuffer(isolate(), buffer); | |
1752 o = buffer->weak_next(); | |
1753 } | |
Michael Starzinger
2013/06/19 11:35:09
Let's play it safe and reset array_buffers_list to
Dmitry Lomov (no reviews)
2013/06/19 11:51:25
Done.
| |
1754 } | |
1755 | |
1732 | 1756 |
1733 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { | 1757 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
1734 DisallowHeapAllocation no_allocation; | 1758 DisallowHeapAllocation no_allocation; |
1735 | 1759 |
1736 // Both the external string table and the string table may contain | 1760 // Both the external string table and the string table may contain |
1737 // external strings, but neither lists them exhaustively, nor is the | 1761 // external strings, but neither lists them exhaustively, nor is the |
1738 // intersection set empty. Therefore we iterate over the external string | 1762 // intersection set empty. Therefore we iterate over the external string |
1739 // table first, ignoring internalized strings, and then over the | 1763 // table first, ignoring internalized strings, and then over the |
1740 // internalized string table. | 1764 // internalized string table. |
1741 | 1765 |
(...skipping 5120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6862 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); | 6886 PrintF("max_gc_pause=%.1f ", get_max_gc_pause()); |
6863 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); | 6887 PrintF("total_gc_time=%.1f ", total_gc_time_ms_); |
6864 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); | 6888 PrintF("min_in_mutator=%.1f ", get_min_in_mutator()); |
6865 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", | 6889 PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", |
6866 get_max_alive_after_gc()); | 6890 get_max_alive_after_gc()); |
6867 PrintF("total_marking_time=%.1f ", marking_time()); | 6891 PrintF("total_marking_time=%.1f ", marking_time()); |
6868 PrintF("total_sweeping_time=%.1f ", sweeping_time()); | 6892 PrintF("total_sweeping_time=%.1f ", sweeping_time()); |
6869 PrintF("\n\n"); | 6893 PrintF("\n\n"); |
6870 } | 6894 } |
6871 | 6895 |
6896 TearDownArrayBuffers(); | |
6897 | |
6872 isolate_->global_handles()->TearDown(); | 6898 isolate_->global_handles()->TearDown(); |
6873 | 6899 |
6874 external_string_table_.TearDown(); | 6900 external_string_table_.TearDown(); |
6875 | 6901 |
6876 error_object_list_.TearDown(); | 6902 error_object_list_.TearDown(); |
6877 | 6903 |
6878 new_space_.TearDown(); | 6904 new_space_.TearDown(); |
6879 | 6905 |
6880 if (old_pointer_space_ != NULL) { | 6906 if (old_pointer_space_ != NULL) { |
6881 old_pointer_space_->TearDown(); | 6907 old_pointer_space_->TearDown(); |
(...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8070 if (FLAG_parallel_recompilation) { | 8096 if (FLAG_parallel_recompilation) { |
8071 heap_->relocation_mutex_->Lock(); | 8097 heap_->relocation_mutex_->Lock(); |
8072 #ifdef DEBUG | 8098 #ifdef DEBUG |
8073 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8099 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8074 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8100 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8075 #endif // DEBUG | 8101 #endif // DEBUG |
8076 } | 8102 } |
8077 } | 8103 } |
8078 | 8104 |
8079 } } // namespace v8::internal | 8105 } } // namespace v8::internal |
OLD | NEW |