Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: src/heap.cc

Issue 18173013: AllocationSite objects weakly linked for traversal (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed final nits Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (max_virtual > 0) { 175 if (max_virtual > 0) {
176 if (code_range_size_ > 0) { 176 if (code_range_size_ > 0) {
177 // Reserve no more than 1/8 of the memory for the code range. 177 // Reserve no more than 1/8 of the memory for the code range.
178 code_range_size_ = Min(code_range_size_, max_virtual >> 3); 178 code_range_size_ = Min(code_range_size_, max_virtual >> 3);
179 } 179 }
180 } 180 }
181 181
182 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); 182 memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
183 native_contexts_list_ = NULL; 183 native_contexts_list_ = NULL;
184 array_buffers_list_ = Smi::FromInt(0); 184 array_buffers_list_ = Smi::FromInt(0);
185 allocation_sites_list_ = Smi::FromInt(0);
185 mark_compact_collector_.heap_ = this; 186 mark_compact_collector_.heap_ = this;
186 external_string_table_.heap_ = this; 187 external_string_table_.heap_ = this;
187 // Put a dummy entry in the remembered pages so we can find the list the 188 // Put a dummy entry in the remembered pages so we can find the list the
188 // minidump even if there are no real unmapped pages. 189 // minidump even if there are no real unmapped pages.
189 RememberUnmappedPage(NULL, false); 190 RememberUnmappedPage(NULL, false);
190 191
191 ClearObjectStats(true); 192 ClearObjectStats(true);
192 } 193 }
193 194
194 195
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { 1658 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) {
1658 // We don't record weak slots during marking or scavenges. 1659 // We don't record weak slots during marking or scavenges.
1659 // Instead we do it once when we complete mark-compact cycle. 1660 // Instead we do it once when we complete mark-compact cycle.
1660 // Note that write barrier has no effect if we are already in the middle of 1661 // Note that write barrier has no effect if we are already in the middle of
1661 // compacting mark-sweep cycle and we have to record slots manually. 1662 // compacting mark-sweep cycle and we have to record slots manually.
1662 bool record_slots = 1663 bool record_slots =
1663 gc_state() == MARK_COMPACT && 1664 gc_state() == MARK_COMPACT &&
1664 mark_compact_collector()->is_compacting(); 1665 mark_compact_collector()->is_compacting();
1665 ProcessArrayBuffers(retainer, record_slots); 1666 ProcessArrayBuffers(retainer, record_slots);
1666 ProcessNativeContexts(retainer, record_slots); 1667 ProcessNativeContexts(retainer, record_slots);
1668 ProcessAllocationSites(retainer, record_slots);
1667 } 1669 }
1668 1670
1669 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer, 1671 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer,
1670 bool record_slots) { 1672 bool record_slots) {
1671 Object* head = 1673 Object* head =
1672 VisitWeakList<Context>( 1674 VisitWeakList<Context>(
1673 this, native_contexts_list(), retainer, record_slots); 1675 this, native_contexts_list(), retainer, record_slots);
1674 // Update the head of the list of contexts. 1676 // Update the head of the list of contexts.
1675 native_contexts_list_ = head; 1677 native_contexts_list_ = head;
1676 } 1678 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 Object* undefined = undefined_value(); 1752 Object* undefined = undefined_value();
1751 for (Object* o = array_buffers_list(); o != undefined;) { 1753 for (Object* o = array_buffers_list(); o != undefined;) {
1752 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); 1754 JSArrayBuffer* buffer = JSArrayBuffer::cast(o);
1753 Runtime::FreeArrayBuffer(isolate(), buffer); 1755 Runtime::FreeArrayBuffer(isolate(), buffer);
1754 o = buffer->weak_next(); 1756 o = buffer->weak_next();
1755 } 1757 }
1756 array_buffers_list_ = undefined; 1758 array_buffers_list_ = undefined;
1757 } 1759 }
1758 1760
1759 1761
1762 template<>
1763 struct WeakListVisitor<AllocationSite> {
1764 static void SetWeakNext(AllocationSite* obj, Object* next) {
1765 obj->set_weak_next(next);
1766 }
1767
1768 static Object* WeakNext(AllocationSite* obj) {
1769 return obj->weak_next();
1770 }
1771
1772 static void VisitLiveObject(Heap* heap,
1773 AllocationSite* array_buffer,
1774 WeakObjectRetainer* retainer,
1775 bool record_slots) {}
1776
1777 static void VisitPhantomObject(Heap* heap, AllocationSite* phantom) {}
1778
1779 static int WeakNextOffset() {
1780 return AllocationSite::kWeakNextOffset;
1781 }
1782 };
1783
1784
1785 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer,
1786 bool record_slots) {
1787 Object* allocation_site_obj =
1788 VisitWeakList<AllocationSite>(this,
1789 allocation_sites_list(),
1790 retainer, record_slots);
1791 set_allocation_sites_list(allocation_site_obj);
1792 }
1793
1794
1760 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { 1795 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) {
1761 DisallowHeapAllocation no_allocation; 1796 DisallowHeapAllocation no_allocation;
1762 1797
1763 // Both the external string table and the string table may contain 1798 // Both the external string table and the string table may contain
1764 // external strings, but neither lists them exhaustively, nor is the 1799 // external strings, but neither lists them exhaustively, nor is the
1765 // intersection set empty. Therefore we iterate over the external string 1800 // intersection set empty. Therefore we iterate over the external string
1766 // table first, ignoring internalized strings, and then over the 1801 // table first, ignoring internalized strings, and then over the
1767 // internalized string table. 1802 // internalized string table.
1768 1803
1769 class ExternalStringTableVisitorAdapter : public ObjectVisitor { 1804 class ExternalStringTableVisitorAdapter : public ObjectVisitor {
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 result->set_value(value); 2915 result->set_value(value);
2881 return result; 2916 return result;
2882 } 2917 }
2883 2918
2884 2919
2885 MaybeObject* Heap::AllocateAllocationSite() { 2920 MaybeObject* Heap::AllocateAllocationSite() {
2886 Object* result; 2921 Object* result;
2887 MaybeObject* maybe_result = Allocate(allocation_site_map(), 2922 MaybeObject* maybe_result = Allocate(allocation_site_map(),
2888 OLD_POINTER_SPACE); 2923 OLD_POINTER_SPACE);
2889 if (!maybe_result->ToObject(&result)) return maybe_result; 2924 if (!maybe_result->ToObject(&result)) return maybe_result;
2890 AllocationSite::cast(result)->Initialize(); 2925 AllocationSite* site = AllocationSite::cast(result);
2926 site->Initialize();
2927
2928 // Link the site
2929 site->set_weak_next(allocation_sites_list());
2930 set_allocation_sites_list(site);
2891 return result; 2931 return result;
2892 } 2932 }
2893 2933
2894 2934
2895 MaybeObject* Heap::CreateOddball(const char* to_string, 2935 MaybeObject* Heap::CreateOddball(const char* to_string,
2896 Object* to_number, 2936 Object* to_number,
2897 byte kind) { 2937 byte kind) {
2898 Object* result; 2938 Object* result;
2899 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); 2939 { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE);
2900 if (!maybe_result->ToObject(&result)) return maybe_result; 2940 if (!maybe_result->ToObject(&result)) return maybe_result;
(...skipping 3981 matching lines...) Expand 10 before | Expand all | Expand 10 after
6882 bool Heap::CreateHeapObjects() { 6922 bool Heap::CreateHeapObjects() {
6883 // Create initial maps. 6923 // Create initial maps.
6884 if (!CreateInitialMaps()) return false; 6924 if (!CreateInitialMaps()) return false;
6885 if (!CreateApiObjects()) return false; 6925 if (!CreateApiObjects()) return false;
6886 6926
6887 // Create initial objects 6927 // Create initial objects
6888 if (!CreateInitialObjects()) return false; 6928 if (!CreateInitialObjects()) return false;
6889 6929
6890 native_contexts_list_ = undefined_value(); 6930 native_contexts_list_ = undefined_value();
6891 array_buffers_list_ = undefined_value(); 6931 array_buffers_list_ = undefined_value();
6932 allocation_sites_list_ = undefined_value();
6892 return true; 6933 return true;
6893 } 6934 }
6894 6935
6895 6936
6896 void Heap::SetStackLimits() { 6937 void Heap::SetStackLimits() {
6897 ASSERT(isolate_ != NULL); 6938 ASSERT(isolate_ != NULL);
6898 ASSERT(isolate_ == isolate()); 6939 ASSERT(isolate_ == isolate());
6899 // On 64 bit machines, pointers are generally out of range of Smis. We write 6940 // On 64 bit machines, pointers are generally out of range of Smis. We write
6900 // something that looks like an out of range Smi to the GC. 6941 // something that looks like an out of range Smi to the GC.
6901 6942
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
8135 if (FLAG_parallel_recompilation) { 8176 if (FLAG_parallel_recompilation) {
8136 heap_->relocation_mutex_->Lock(); 8177 heap_->relocation_mutex_->Lock();
8137 #ifdef DEBUG 8178 #ifdef DEBUG
8138 heap_->relocation_mutex_locked_by_optimizer_thread_ = 8179 heap_->relocation_mutex_locked_by_optimizer_thread_ =
8139 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 8180 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
8140 #endif // DEBUG 8181 #endif // DEBUG
8141 } 8182 }
8142 } 8183 }
8143 8184
8144 } } // namespace v8::internal 8185 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698