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

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

Issue 1360903004: [heap] Move large object space selection into 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') | no next file » | 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return AllocateInternalizedStringImpl<false>(t, chars, hash_field); 116 return AllocateInternalizedStringImpl<false>(t, chars, hash_field);
117 } 117 }
118 118
119 119
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 AllocationSpace space = SelectSpace(size, TENURED);
127 126
128 // Allocate string. 127 // Allocate string.
129 HeapObject* result = nullptr; 128 HeapObject* result = nullptr;
130 { 129 {
131 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 130 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
132 if (!allocation.To(&result)) return allocation; 131 if (!allocation.To(&result)) return allocation;
133 } 132 }
134 133
135 // String maps are all immortal immovable objects. 134 // String maps are all immortal immovable objects.
136 result->set_map_no_write_barrier(map); 135 result->set_map_no_write_barrier(map);
137 // Set length and hash fields of the allocated string. 136 // Set length and hash fields of the allocated string.
138 String* answer = String::cast(result); 137 String* answer = String::cast(result);
139 answer->set_length(str.length()); 138 answer->set_length(str.length());
140 answer->set_hash_field(hash_field); 139 answer->set_hash_field(hash_field);
141 140
142 DCHECK_EQ(size, answer->Size()); 141 DCHECK_EQ(size, answer->Size());
143 142
144 // Fill in the characters. 143 // Fill in the characters.
145 MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(), 144 MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(),
146 str.length()); 145 str.length());
147 146
148 return answer; 147 return answer;
149 } 148 }
150 149
151 150
152 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, 151 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str,
153 uint32_t hash_field) { 152 uint32_t hash_field) {
154 CHECK_GE(String::kMaxLength, str.length()); 153 CHECK_GE(String::kMaxLength, str.length());
155 // Compute map and object size. 154 // Compute map and object size.
156 Map* map = internalized_string_map(); 155 Map* map = internalized_string_map();
157 int size = SeqTwoByteString::SizeFor(str.length()); 156 int size = SeqTwoByteString::SizeFor(str.length());
158 AllocationSpace space = SelectSpace(size, TENURED);
159 157
160 // Allocate string. 158 // Allocate string.
161 HeapObject* result = nullptr; 159 HeapObject* result = nullptr;
162 { 160 {
163 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); 161 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE);
164 if (!allocation.To(&result)) return allocation; 162 if (!allocation.To(&result)) return allocation;
165 } 163 }
166 164
167 result->set_map(map); 165 result->set_map(map);
168 // Set length and hash fields of the allocated string. 166 // Set length and hash fields of the allocated string.
169 String* answer = String::cast(result); 167 String* answer = String::cast(result);
170 answer->set_length(str.length()); 168 answer->set_length(str.length());
171 answer->set_hash_field(hash_field); 169 answer->set_hash_field(hash_field);
172 170
173 DCHECK_EQ(size, answer->Size()); 171 DCHECK_EQ(size, answer->Size());
(...skipping 25 matching lines...) Expand all
199 DCHECK(gc_state_ == NOT_IN_GC); 197 DCHECK(gc_state_ == NOT_IN_GC);
200 #ifdef DEBUG 198 #ifdef DEBUG
201 if (FLAG_gc_interval >= 0 && !always_allocate() && 199 if (FLAG_gc_interval >= 0 && !always_allocate() &&
202 Heap::allocation_timeout_-- <= 0) { 200 Heap::allocation_timeout_-- <= 0) {
203 return AllocationResult::Retry(space); 201 return AllocationResult::Retry(space);
204 } 202 }
205 isolate_->counters()->objs_since_last_full()->Increment(); 203 isolate_->counters()->objs_since_last_full()->Increment();
206 isolate_->counters()->objs_since_last_young()->Increment(); 204 isolate_->counters()->objs_since_last_young()->Increment();
207 #endif 205 #endif
208 206
207 bool large_object = size_in_bytes > Page::kMaxRegularHeapObjectSize;
209 HeapObject* object = nullptr; 208 HeapObject* object = nullptr;
210 AllocationResult allocation; 209 AllocationResult allocation;
211 if (NEW_SPACE == space) { 210 if (NEW_SPACE == space) {
212 allocation = new_space_.AllocateRaw(size_in_bytes, alignment); 211 if (!large_object) {
213 if (always_allocate() && allocation.IsRetry() && retry_space != NEW_SPACE) { 212 allocation = new_space_.AllocateRaw(size_in_bytes, alignment);
214 space = retry_space; 213 if (always_allocate() && allocation.IsRetry() &&
214 retry_space != NEW_SPACE) {
215 space = retry_space;
216 }
215 } else { 217 } else {
216 if (allocation.To(&object)) { 218 space = LO_SPACE;
Hannes Payer (out of office) 2015/09/25 10:19:15 This branch will be taken in the end.
217 OnAllocationEvent(object, size_in_bytes);
218 }
219 return allocation;
220 } 219 }
221 } 220 }
222 221
223 if (OLD_SPACE == space) { 222 if (OLD_SPACE == space) {
224 allocation = old_space_->AllocateRaw(size_in_bytes, alignment); 223 if (!large_object) {
224 allocation = old_space_->AllocateRaw(size_in_bytes, alignment);
225 } else {
226 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
227 }
225 } else if (CODE_SPACE == space) { 228 } else if (CODE_SPACE == space) {
226 if (size_in_bytes <= code_space()->AreaSize()) { 229 if (size_in_bytes <= code_space()->AreaSize()) {
227 allocation = code_space_->AllocateRawUnaligned(size_in_bytes); 230 allocation = code_space_->AllocateRawUnaligned(size_in_bytes);
228 } else { 231 } else {
229 // Large code objects are allocated in large object space.
230 allocation = lo_space_->AllocateRaw(size_in_bytes, EXECUTABLE); 232 allocation = lo_space_->AllocateRaw(size_in_bytes, EXECUTABLE);
231 } 233 }
232 } else if (LO_SPACE == space) { 234 } else if (LO_SPACE == space) {
235 DCHECK(large_object);
233 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); 236 allocation = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE);
234 } else { 237 } else if (MAP_SPACE == space) {
235 DCHECK(MAP_SPACE == space);
236 allocation = map_space_->AllocateRawUnaligned(size_in_bytes); 238 allocation = map_space_->AllocateRawUnaligned(size_in_bytes);
237 } 239 }
238 if (allocation.To(&object)) { 240 if (allocation.To(&object)) {
239 OnAllocationEvent(object, size_in_bytes); 241 OnAllocationEvent(object, size_in_bytes);
240 } else { 242 } else {
241 old_gen_exhausted_ = true; 243 old_gen_exhausted_ = true;
242 } 244 }
243 return allocation; 245 return allocation;
244 } 246 }
245 247
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 743
742 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { 744 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) {
743 for (Object** current = start; current < end; current++) { 745 for (Object** current = start; current < end; current++) {
744 CHECK((*current)->IsSmi()); 746 CHECK((*current)->IsSmi());
745 } 747 }
746 } 748 }
747 } 749 }
748 } // namespace v8::internal 750 } // namespace v8::internal
749 751
750 #endif // V8_HEAP_HEAP_INL_H_ 752 #endif // V8_HEAP_HEAP_INL_H_
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698