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

Side by Side Diff: src/heap/heap.cc

Issue 904633003: Just visit young array buffers during scavenge. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
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/v8.h" 5 #include "src/v8.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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 gcs_since_last_deopt_(0), 137 gcs_since_last_deopt_(0),
138 #ifdef VERIFY_HEAP 138 #ifdef VERIFY_HEAP
139 no_weak_object_verification_scope_depth_(0), 139 no_weak_object_verification_scope_depth_(0),
140 #endif 140 #endif
141 allocation_sites_scratchpad_length_(0), 141 allocation_sites_scratchpad_length_(0),
142 promotion_queue_(this), 142 promotion_queue_(this),
143 configured_(false), 143 configured_(false),
144 external_string_table_(this), 144 external_string_table_(this),
145 chunks_queued_for_free_(NULL), 145 chunks_queued_for_free_(NULL),
146 gc_callbacks_depth_(0), 146 gc_callbacks_depth_(0),
147 deserialization_complete_(false) { 147 deserialization_complete_(false),
148 promotion_failure_(false) {
148 // Allow build-time customization of the max semispace size. Building 149 // Allow build-time customization of the max semispace size. Building
149 // V8 with snapshots and a non-default max semispace size is much 150 // V8 with snapshots and a non-default max semispace size is much
150 // easier if you can define it as part of the build environment. 151 // easier if you can define it as part of the build environment.
151 #if defined(V8_MAX_SEMISPACE_SIZE) 152 #if defined(V8_MAX_SEMISPACE_SIZE)
152 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; 153 max_semi_space_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE;
153 #endif 154 #endif
154 155
155 // Ensure old_generation_size_ is a multiple of kPageSize. 156 // Ensure old_generation_size_ is a multiple of kPageSize.
156 DCHECK(MB >= Page::kPageSize); 157 DCHECK(MB >= Page::kPageSize);
157 158
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 #undef UPDATE_FRAGMENTATION_FOR_SPACE 725 #undef UPDATE_FRAGMENTATION_FOR_SPACE
725 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE 726 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE
726 727
727 #ifdef DEBUG 728 #ifdef DEBUG
728 ReportStatisticsAfterGC(); 729 ReportStatisticsAfterGC();
729 #endif // DEBUG 730 #endif // DEBUG
730 731
731 // Remember the last top pointer so that we can later find out 732 // Remember the last top pointer so that we can later find out
732 // whether we allocated in new space since the last GC. 733 // whether we allocated in new space since the last GC.
733 new_space_top_after_last_gc_ = new_space()->top(); 734 new_space_top_after_last_gc_ = new_space()->top();
735 set_promotion_failure(false);
734 } 736 }
735 737
736 738
737 void Heap::CollectAllGarbage(int flags, const char* gc_reason, 739 void Heap::CollectAllGarbage(int flags, const char* gc_reason,
738 const v8::GCCallbackFlags gc_callback_flags) { 740 const v8::GCCallbackFlags gc_callback_flags) {
739 // Since we are ignoring the return value, the exact choice of space does 741 // Since we are ignoring the return value, the exact choice of space does
740 // not matter, so long as we do not specify NEW_SPACE, which would not 742 // not matter, so long as we do not specify NEW_SPACE, which would not
741 // cause a full GC. 743 // cause a full GC.
742 mark_compact_collector_.SetFlags(flags); 744 mark_compact_collector_.SetFlags(flags);
743 CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags); 745 CollectGarbage(OLD_POINTER_SPACE, gc_reason, gc_callback_flags);
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 Object** start = &external_string_table_.old_space_strings_[0]; 1684 Object** start = &external_string_table_.old_space_strings_[0];
1683 Object** end = start + external_string_table_.old_space_strings_.length(); 1685 Object** end = start + external_string_table_.old_space_strings_.length();
1684 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); 1686 for (Object** p = start; p < end; ++p) *p = updater_func(this, p);
1685 } 1687 }
1686 1688
1687 UpdateNewSpaceReferencesInExternalStringTable(updater_func); 1689 UpdateNewSpaceReferencesInExternalStringTable(updater_func);
1688 } 1690 }
1689 1691
1690 1692
1691 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) { 1693 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) {
1692 ProcessArrayBuffers(retainer); 1694 ProcessArrayBuffers(retainer, false);
1695 ProcessNewArrayBufferViews(retainer);
1693 ProcessNativeContexts(retainer); 1696 ProcessNativeContexts(retainer);
1694 ProcessAllocationSites(retainer); 1697 ProcessAllocationSites(retainer);
1695 } 1698 }
1696 1699
1697 1700
1698 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { 1701 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) {
1699 ProcessArrayBuffers(retainer); 1702 ProcessArrayBuffers(retainer, true);
1703 ProcessNewArrayBufferViews(retainer);
1700 ProcessNativeContexts(retainer); 1704 ProcessNativeContexts(retainer);
1701 } 1705 }
1702 1706
1703 1707
1704 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { 1708 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) {
1705 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer); 1709 Object* head =
1710 VisitWeakList<Context>(this, native_contexts_list(), retainer, false);
1706 // Update the head of the list of contexts. 1711 // Update the head of the list of contexts.
1707 set_native_contexts_list(head); 1712 set_native_contexts_list(head);
1708 } 1713 }
1709 1714
1710 1715
1711 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer) { 1716 void Heap::ProcessArrayBuffers(WeakObjectRetainer* retainer,
1712 Object* array_buffer_obj = 1717 bool stop_after_young) {
1713 VisitWeakList<JSArrayBuffer>(this, array_buffers_list(), retainer); 1718 Object* array_buffer_obj = VisitWeakList<JSArrayBuffer>(
1719 this, array_buffers_list(), retainer, stop_after_young);
1714 set_array_buffers_list(array_buffer_obj); 1720 set_array_buffers_list(array_buffer_obj);
1715 } 1721 }
1716 1722
1717 1723
1724 void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) {
1725 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>(
1726 this, new_array_buffers_view_list_, retainer, false);
1727 set_new_array_buffers_view_list(typed_array_obj);
1728 }
1729
1730
1718 void Heap::TearDownArrayBuffers() { 1731 void Heap::TearDownArrayBuffers() {
1719 Object* undefined = undefined_value(); 1732 Object* undefined = undefined_value();
1720 for (Object* o = array_buffers_list(); o != undefined;) { 1733 for (Object* o = array_buffers_list(); o != undefined;) {
1721 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); 1734 JSArrayBuffer* buffer = JSArrayBuffer::cast(o);
1722 Runtime::FreeArrayBuffer(isolate(), buffer); 1735 Runtime::FreeArrayBuffer(isolate(), buffer);
1723 o = buffer->weak_next(); 1736 o = buffer->weak_next();
1724 } 1737 }
1725 set_array_buffers_list(undefined); 1738 set_array_buffers_list(undefined);
1726 } 1739 }
1727 1740
1728 1741
1729 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) { 1742 void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer) {
1730 Object* allocation_site_obj = 1743 Object* allocation_site_obj = VisitWeakList<AllocationSite>(
1731 VisitWeakList<AllocationSite>(this, allocation_sites_list(), retainer); 1744 this, allocation_sites_list(), retainer, false);
1732 set_allocation_sites_list(allocation_site_obj); 1745 set_allocation_sites_list(allocation_site_obj);
1733 } 1746 }
1734 1747
1735 1748
1736 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { 1749 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) {
1737 DisallowHeapAllocation no_allocation_scope; 1750 DisallowHeapAllocation no_allocation_scope;
1738 Object* cur = allocation_sites_list(); 1751 Object* cur = allocation_sites_list();
1739 bool marked = false; 1752 bool marked = false;
1740 while (cur->IsAllocationSite()) { 1753 while (cur->IsAllocationSite()) {
1741 AllocationSite* casted = AllocationSite::cast(cur); 1754 AllocationSite* casted = AllocationSite::cast(cur);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) { 2167 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) {
2155 return; 2168 return;
2156 } 2169 }
2157 } 2170 }
2158 2171
2159 if (PromoteObject<object_contents, alignment>(map, slot, object, 2172 if (PromoteObject<object_contents, alignment>(map, slot, object,
2160 object_size)) { 2173 object_size)) {
2161 return; 2174 return;
2162 } 2175 }
2163 2176
2177 heap->set_promotion_failure(true);
2164 // If promotion failed, we try to copy the object to the other semi-space 2178 // If promotion failed, we try to copy the object to the other semi-space
2165 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return; 2179 if (SemiSpaceCopyObject<alignment>(map, slot, object, object_size)) return;
2166 2180
2167 UNREACHABLE(); 2181 UNREACHABLE();
2168 } 2182 }
2169 2183
2170 2184
2171 static inline void EvacuateJSFunction(Map* map, HeapObject** slot, 2185 static inline void EvacuateJSFunction(Map* map, HeapObject** slot,
2172 HeapObject* object) { 2186 HeapObject* object) {
2173 ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized< 2187 ObjectEvacuationStrategy<POINTER_OBJECT>::template VisitSpecialized<
(...skipping 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after
5493 // Create initial maps. 5507 // Create initial maps.
5494 if (!CreateInitialMaps()) return false; 5508 if (!CreateInitialMaps()) return false;
5495 CreateApiObjects(); 5509 CreateApiObjects();
5496 5510
5497 // Create initial objects 5511 // Create initial objects
5498 CreateInitialObjects(); 5512 CreateInitialObjects();
5499 CHECK_EQ(0u, gc_count_); 5513 CHECK_EQ(0u, gc_count_);
5500 5514
5501 set_native_contexts_list(undefined_value()); 5515 set_native_contexts_list(undefined_value());
5502 set_array_buffers_list(undefined_value()); 5516 set_array_buffers_list(undefined_value());
5517 set_new_array_buffers_view_list(undefined_value());
5503 set_allocation_sites_list(undefined_value()); 5518 set_allocation_sites_list(undefined_value());
5504 weak_object_to_code_table_ = undefined_value(); 5519 weak_object_to_code_table_ = undefined_value();
5505 return true; 5520 return true;
5506 } 5521 }
5507 5522
5508 5523
5509 void Heap::SetStackLimits() { 5524 void Heap::SetStackLimits() {
5510 DCHECK(isolate_ != NULL); 5525 DCHECK(isolate_ != NULL);
5511 DCHECK(isolate_ == isolate()); 5526 DCHECK(isolate_ == isolate());
5512 // On 64 bit machines, pointers are generally out of range of Smis. We write 5527 // On 64 bit machines, pointers are generally out of range of Smis. We write
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
6488 static_cast<int>(object_sizes_last_time_[index])); 6503 static_cast<int>(object_sizes_last_time_[index]));
6489 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 6504 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
6490 #undef ADJUST_LAST_TIME_OBJECT_COUNT 6505 #undef ADJUST_LAST_TIME_OBJECT_COUNT
6491 6506
6492 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 6507 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
6493 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 6508 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
6494 ClearObjectStats(); 6509 ClearObjectStats();
6495 } 6510 }
6496 } 6511 }
6497 } // namespace v8::internal 6512 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/mark-compact.cc » ('j') | src/runtime/runtime-typedarray.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698