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

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

Issue 1370123002: [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, OLD_SPACE); 130 AllocationResult allocation = AllocateRaw(size, 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, OLD_SPACE); 161 AllocationResult allocation = AllocateRaw(size, 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,
194 AllocationAlignment alignment) { 193 AllocationAlignment alignment) {
195 DCHECK(AllowHandleAllocation::IsAllowed()); 194 DCHECK(AllowHandleAllocation::IsAllowed());
196 DCHECK(AllowHeapAllocation::IsAllowed()); 195 DCHECK(AllowHeapAllocation::IsAllowed());
197 DCHECK(gc_state_ == NOT_IN_GC); 196 DCHECK(gc_state_ == NOT_IN_GC);
198 #ifdef DEBUG 197 #ifdef DEBUG
199 if (FLAG_gc_interval >= 0 && !always_allocate() && 198 if (FLAG_gc_interval >= 0 && !always_allocate() &&
200 Heap::allocation_timeout_-- <= 0) { 199 Heap::allocation_timeout_-- <= 0) {
201 return AllocationResult::Retry(space); 200 return AllocationResult::Retry(space);
202 } 201 }
203 isolate_->counters()->objs_since_last_full()->Increment(); 202 isolate_->counters()->objs_since_last_full()->Increment();
204 isolate_->counters()->objs_since_last_young()->Increment(); 203 isolate_->counters()->objs_since_last_young()->Increment();
205 #endif 204 #endif
206 205
207 bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize; 206 bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize;
208 HeapObject* object = nullptr; 207 HeapObject* object = nullptr;
209 AllocationResult allocation; 208 AllocationResult allocation;
210 if (NEW_SPACE == space) { 209 if (NEW_SPACE == space) {
211 if (!large_object) { 210 if (large_object) {
211 space = LO_SPACE;
212 } else {
212 allocation = new_space_.AllocateRaw(size_in_bytes, alignment); 213 allocation = new_space_.AllocateRaw(size_in_bytes, alignment);
213 if (always_allocate() && allocation.IsRetry() && 214 if (allocation.To(&object)) {
214 retry_space != NEW_SPACE) { 215 OnAllocationEvent(object, size_in_bytes);
215 space = retry_space;
216 } else {
217 if (allocation.To(&object)) {
218 OnAllocationEvent(object, size_in_bytes);
219 }
220 return allocation;
221 } 216 }
222 } else { 217 return allocation;
223 space = LO_SPACE;
224 } 218 }
225 } 219 }
226 220
227 // Here we only allocate in the old generation. 221 // Here we only allocate in the old generation.
228 if (OLD_SPACE == space) { 222 if (OLD_SPACE == space) {
229 if (large_object) { 223 if (large_object) {
230 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); 224 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
231 } else { 225 } else {
232 allocation = old_space_->AllocateRaw(size_in_bytes, alignment); 226 allocation = old_space_->AllocateRaw(size_in_bytes, alignment);
233 } 227 }
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 736
743 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 737 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
744 for (Object** current = start; current < end; current++) { 738 for (Object** current = start; current < end; current++) {
745 CHECK((*current)->IsSmi()); 739 CHECK((*current)->IsSmi());
746 } 740 }
747 } 741 }
748 } 742 }
749 } // namespace v8::internal 743 } // namespace v8::internal
750 744
751 #endif // V8_HEAP_HEAP_INL_H_ 745 #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