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

Side by Side Diff: src/heap/heap-inl.h

Issue 1379493003: Revert of [heap] Remove retry space from AllocateRaw. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « src/heap/heap.cc ('k') | test/cctest/test-alloc.cc » ('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 // 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 #ifndef V8_HEAP_HEAP_INL_H_ 5 #ifndef V8_HEAP_HEAP_INL_H_
6 #define V8_HEAP_HEAP_INL_H_ 6 #define V8_HEAP_HEAP_INL_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 AllocationResult Heap::AllocateOneByteInternalizedString( 120 AllocationResult Heap::AllocateOneByteInternalizedString(
121 Vector<const uint8_t> str, uint32_t hash_field) { 121 Vector<const uint8_t> str, uint32_t hash_field) {
122 CHECK_GE(String::kMaxLength, str.length()); 122 CHECK_GE(String::kMaxLength, str.length());
123 // Compute map and object size. 123 // Compute map and object size.
124 Map* map = one_byte_internalized_string_map(); 124 Map* map = one_byte_internalized_string_map();
125 int size = SeqOneByteString::SizeFor(str.length()); 125 int size = SeqOneByteString::SizeFor(str.length());
126 126
127 // Allocate string. 127 // Allocate string.
128 HeapObject* result = nullptr; 128 HeapObject* result = nullptr;
129 { 129 {
130 AllocationResult allocation = AllocateRaw(size, OLD_SPACE); 130 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
131 if (!allocation.To(&result)) return allocation; 131 if (!allocation.To(&result)) return allocation;
132 } 132 }
133 133
134 // String maps are all immortal immovable objects. 134 // String maps are all immortal immovable objects.
135 result->set_map_no_write_barrier(map); 135 result->set_map_no_write_barrier(map);
136 // Set length and hash fields of the allocated string. 136 // Set length and hash fields of the allocated string.
137 String* answer = String::cast(result); 137 String* answer = String::cast(result);
138 answer->set_length(str.length()); 138 answer->set_length(str.length());
139 answer->set_hash_field(hash_field); 139 answer->set_hash_field(hash_field);
140 140
(...skipping 10 matching lines...) Expand all
151 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, 151 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
152 uint32_t hash_field) { 152 uint32_t hash_field) {
153 CHECK_GE(String::kMaxLength, str.length()); 153 CHECK_GE(String::kMaxLength, str.length());
154 // Compute map and object size. 154 // Compute map and object size.
155 Map* map = internalized_string_map(); 155 Map* map = internalized_string_map();
156 int size = SeqTwoByteString::SizeFor(str.length()); 156 int size = SeqTwoByteString::SizeFor(str.length());
157 157
158 // Allocate string. 158 // Allocate string.
159 HeapObject* result = nullptr; 159 HeapObject* result = nullptr;
160 { 160 {
161 AllocationResult allocation = AllocateRaw(size, OLD_SPACE); 161 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
162 if (!allocation.To(&result)) return allocation; 162 if (!allocation.To(&result)) return allocation;
163 } 163 }
164 164
165 result->set_map(map); 165 result->set_map(map);
166 // Set length and hash fields of the allocated string. 166 // Set length and hash fields of the allocated string.
167 String* answer = String::cast(result); 167 String* answer = String::cast(result);
168 answer->set_length(str.length()); 168 answer->set_length(str.length());
169 answer->set_hash_field(hash_field); 169 answer->set_hash_field(hash_field);
170 170
171 DCHECK_EQ(size, answer->Size()); 171 DCHECK_EQ(size, answer->Size());
(...skipping 11 matching lines...) Expand all
183 } 183 }
184 184
185 185
186 AllocationResult Heap::CopyFixedDoubleArray(FixedDoubleArray* src) { 186 AllocationResult Heap::CopyFixedDoubleArray(FixedDoubleArray* src) {
187 if (src->length() == 0) return src; 187 if (src->length() == 0) return src;
188 return CopyFixedDoubleArrayWithMap(src, src->map()); 188 return CopyFixedDoubleArrayWithMap(src, src->map());
189 } 189 }
190 190
191 191
192 AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space, 192 AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationSpace space,
193 AllocationSpace retry_space,
193 AllocationAlignment alignment) { 194 AllocationAlignment alignment) {
194 DCHECK(AllowHandleAllocation::IsAllowed()); 195 DCHECK(AllowHandleAllocation::IsAllowed());
195 DCHECK(AllowHeapAllocation::IsAllowed()); 196 DCHECK(AllowHeapAllocation::IsAllowed());
196 DCHECK(gc_state_ == NOT_IN_GC); 197 DCHECK(gc_state_ == NOT_IN_GC);
197 #ifdef DEBUG 198 #ifdef DEBUG
198 if (FLAG_gc_interval >= 0 && !always_allocate() && 199 if (FLAG_gc_interval >= 0 && !always_allocate() &&
199 Heap::allocation_timeout_-- <= 0) { 200 Heap::allocation_timeout_-- <= 0) {
200 return AllocationResult::Retry(space); 201 return AllocationResult::Retry(space);
201 } 202 }
202 isolate_->counters()->objs_since_last_full()->Increment(); 203 isolate_->counters()->objs_since_last_full()->Increment();
203 isolate_->counters()->objs_since_last_young()->Increment(); 204 isolate_->counters()->objs_since_last_young()->Increment();
204 #endif 205 #endif
205 206
206 bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize; 207 bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize;
207 HeapObject* object = nullptr; 208 HeapObject* object = nullptr;
208 AllocationResult allocation; 209 AllocationResult allocation;
209 if (NEW_SPACE == space) { 210 if (NEW_SPACE == space) {
210 if (large_object) { 211 if (!large_object) {
212 allocation = new_space_.AllocateRaw(size_in_bytes, alignment);
213 if (always_allocate() && allocation.IsRetry() &&
214 retry_space != NEW_SPACE) {
215 space = retry_space;
216 } else {
217 if (allocation.To(&object)) {
218 OnAllocationEvent(object, size_in_bytes);
219 }
220 return allocation;
221 }
222 } else {
211 space = LO_SPACE; 223 space = LO_SPACE;
212 } else {
213 allocation = new_space_.AllocateRaw(size_in_bytes, alignment);
214 if (allocation.To(&object)) {
215 OnAllocationEvent(object, size_in_bytes);
216 }
217 return allocation;
218 } 224 }
219 } 225 }
220 226
221 // Here we only allocate in the old generation. 227 // Here we only allocate in the old generation.
222 if (OLD_SPACE == space) { 228 if (OLD_SPACE == space) {
223 if (large_object) { 229 if (large_object) {
224 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); 230 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
225 } else { 231 } else {
226 allocation = old_space_->AllocateRaw(size_in_bytes, alignment); 232 allocation = old_space_->AllocateRaw(size_in_bytes, alignment);
227 } 233 }
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 742
737 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 743 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
738 for (Object** current = start; current < end; current++) { 744 for (Object** current = start; current < end; current++) {
739 CHECK((*current)->IsSmi()); 745 CHECK((*current)->IsSmi());
740 } 746 }
741 } 747 }
742 } 748 }
743 } // namespace v8::internal 749 } // namespace v8::internal
744 750
745 #endif // V8_HEAP_HEAP_INL_H_ 751 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | test/cctest/test-alloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698