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 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 } | 1768 } |
1769 | 1769 |
1770 // Terminate the list if there is one or more elements. | 1770 // Terminate the list if there is one or more elements. |
1771 if (tail != NULL) { | 1771 if (tail != NULL) { |
1772 WeakListVisitor<T>::SetWeakNext(tail, undefined); | 1772 WeakListVisitor<T>::SetWeakNext(tail, undefined); |
1773 } | 1773 } |
1774 return head; | 1774 return head; |
1775 } | 1775 } |
1776 | 1776 |
1777 | 1777 |
| 1778 template <class T> |
| 1779 static void ClearWeakList(Heap* heap, |
| 1780 Object* list) { |
| 1781 Object* undefined = heap->undefined_value(); |
| 1782 while (list != undefined) { |
| 1783 T* candidate = reinterpret_cast<T*>(list); |
| 1784 list = WeakListVisitor<T>::WeakNext(candidate); |
| 1785 WeakListVisitor<T>::SetWeakNext(candidate, undefined); |
| 1786 } |
| 1787 } |
| 1788 |
| 1789 |
1778 template<> | 1790 template<> |
1779 struct WeakListVisitor<JSFunction> { | 1791 struct WeakListVisitor<JSFunction> { |
1780 static void SetWeakNext(JSFunction* function, Object* next) { | 1792 static void SetWeakNext(JSFunction* function, Object* next) { |
1781 function->set_next_function_link(next); | 1793 function->set_next_function_link(next); |
1782 } | 1794 } |
1783 | 1795 |
1784 static Object* WeakNext(JSFunction* function) { | 1796 static Object* WeakNext(JSFunction* function) { |
1785 return function->next_function_link(); | 1797 return function->next_function_link(); |
1786 } | 1798 } |
1787 | 1799 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 | 1873 |
1862 if (record_slots) { | 1874 if (record_slots) { |
1863 // Record the updated slot if necessary. | 1875 // Record the updated slot if necessary. |
1864 Object** head_slot = HeapObject::RawField( | 1876 Object** head_slot = HeapObject::RawField( |
1865 context, FixedArray::SizeFor(index)); | 1877 context, FixedArray::SizeFor(index)); |
1866 heap->mark_compact_collector()->RecordSlot( | 1878 heap->mark_compact_collector()->RecordSlot( |
1867 head_slot, head_slot, list_head); | 1879 head_slot, head_slot, list_head); |
1868 } | 1880 } |
1869 } | 1881 } |
1870 | 1882 |
1871 static void VisitPhantomObject(Heap*, Context*) { | 1883 static void VisitPhantomObject(Heap* heap, Context* context) { |
| 1884 ClearWeakList<JSFunction>(heap, |
| 1885 context->get(Context::OPTIMIZED_FUNCTIONS_LIST)); |
| 1886 ClearWeakList<Code>(heap, context->get(Context::OPTIMIZED_CODE_LIST)); |
| 1887 ClearWeakList<Code>(heap, context->get(Context::DEOPTIMIZED_CODE_LIST)); |
1872 } | 1888 } |
1873 | 1889 |
1874 static int WeakNextOffset() { | 1890 static int WeakNextOffset() { |
1875 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); | 1891 return FixedArray::SizeFor(Context::NEXT_CONTEXT_LINK); |
1876 } | 1892 } |
1877 }; | 1893 }; |
1878 | 1894 |
1879 | 1895 |
1880 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { | 1896 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { |
1881 // We don't record weak slots during marking or scavenges. | 1897 // We don't record weak slots during marking or scavenges. |
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4119 ASSERT(!isolate_->code_range()->exists() || | 4135 ASSERT(!isolate_->code_range()->exists() || |
4120 isolate_->code_range()->contains(code->address())); | 4136 isolate_->code_range()->contains(code->address())); |
4121 code->set_instruction_size(desc.instr_size); | 4137 code->set_instruction_size(desc.instr_size); |
4122 code->set_relocation_info(reloc_info); | 4138 code->set_relocation_info(reloc_info); |
4123 code->set_flags(flags); | 4139 code->set_flags(flags); |
4124 code->set_raw_kind_specific_flags1(0); | 4140 code->set_raw_kind_specific_flags1(0); |
4125 code->set_raw_kind_specific_flags2(0); | 4141 code->set_raw_kind_specific_flags2(0); |
4126 code->set_is_crankshafted(crankshafted); | 4142 code->set_is_crankshafted(crankshafted); |
4127 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4143 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); |
4128 code->set_raw_type_feedback_info(undefined_value()); | 4144 code->set_raw_type_feedback_info(undefined_value()); |
| 4145 code->set_next_code_link(undefined_value()); |
4129 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4146 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); |
4130 code->set_gc_metadata(Smi::FromInt(0)); | 4147 code->set_gc_metadata(Smi::FromInt(0)); |
4131 code->set_ic_age(global_ic_age_); | 4148 code->set_ic_age(global_ic_age_); |
4132 code->set_prologue_offset(prologue_offset); | 4149 code->set_prologue_offset(prologue_offset); |
4133 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 4150 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
4134 code->set_marked_for_deoptimization(false); | 4151 code->set_marked_for_deoptimization(false); |
4135 } | 4152 } |
4136 | 4153 |
4137 if (FLAG_enable_ool_constant_pool) { | 4154 if (FLAG_enable_ool_constant_pool) { |
4138 desc.origin->PopulateConstantPool(constant_pool); | 4155 desc.origin->PopulateConstantPool(constant_pool); |
(...skipping 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7811 static_cast<int>(object_sizes_last_time_[index])); | 7828 static_cast<int>(object_sizes_last_time_[index])); |
7812 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7829 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
7813 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7830 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7814 | 7831 |
7815 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7832 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7816 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7833 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7817 ClearObjectStats(); | 7834 ClearObjectStats(); |
7818 } | 7835 } |
7819 | 7836 |
7820 } } // namespace v8::internal | 7837 } } // namespace v8::internal |
OLD | NEW |