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