| OLD | NEW |
| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 AllocationSpace space = SelectSpace(size, TENURED); |
| 127 | 127 |
| 128 // Allocate string. | 128 // Allocate string. |
| 129 HeapObject* result; | 129 HeapObject* result = nullptr; |
| 130 { | 130 { |
| 131 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 131 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| 132 if (!allocation.To(&result)) return allocation; | 132 if (!allocation.To(&result)) return allocation; |
| 133 } | 133 } |
| 134 | 134 |
| 135 // String maps are all immortal immovable objects. | 135 // String maps are all immortal immovable objects. |
| 136 result->set_map_no_write_barrier(map); | 136 result->set_map_no_write_barrier(map); |
| 137 // Set length and hash fields of the allocated string. | 137 // Set length and hash fields of the allocated string. |
| 138 String* answer = String::cast(result); | 138 String* answer = String::cast(result); |
| 139 answer->set_length(str.length()); | 139 answer->set_length(str.length()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 151 | 151 |
| 152 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, | 152 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, |
| 153 uint32_t hash_field) { | 153 uint32_t hash_field) { |
| 154 CHECK_GE(String::kMaxLength, str.length()); | 154 CHECK_GE(String::kMaxLength, str.length()); |
| 155 // Compute map and object size. | 155 // Compute map and object size. |
| 156 Map* map = internalized_string_map(); | 156 Map* map = internalized_string_map(); |
| 157 int size = SeqTwoByteString::SizeFor(str.length()); | 157 int size = SeqTwoByteString::SizeFor(str.length()); |
| 158 AllocationSpace space = SelectSpace(size, TENURED); | 158 AllocationSpace space = SelectSpace(size, TENURED); |
| 159 | 159 |
| 160 // Allocate string. | 160 // Allocate string. |
| 161 HeapObject* result; | 161 HeapObject* result = nullptr; |
| 162 { | 162 { |
| 163 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 163 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
| 164 if (!allocation.To(&result)) return allocation; | 164 if (!allocation.To(&result)) return allocation; |
| 165 } | 165 } |
| 166 | 166 |
| 167 result->set_map(map); | 167 result->set_map(map); |
| 168 // Set length and hash fields of the allocated string. | 168 // Set length and hash fields of the allocated string. |
| 169 String* answer = String::cast(result); | 169 String* answer = String::cast(result); |
| 170 answer->set_length(str.length()); | 170 answer->set_length(str.length()); |
| 171 answer->set_hash_field(hash_field); | 171 answer->set_hash_field(hash_field); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 199 DCHECK(gc_state_ == NOT_IN_GC); | 199 DCHECK(gc_state_ == NOT_IN_GC); |
| 200 #ifdef DEBUG | 200 #ifdef DEBUG |
| 201 if (FLAG_gc_interval >= 0 && AllowAllocationFailure::IsAllowed(isolate_) && | 201 if (FLAG_gc_interval >= 0 && AllowAllocationFailure::IsAllowed(isolate_) && |
| 202 Heap::allocation_timeout_-- <= 0) { | 202 Heap::allocation_timeout_-- <= 0) { |
| 203 return AllocationResult::Retry(space); | 203 return AllocationResult::Retry(space); |
| 204 } | 204 } |
| 205 isolate_->counters()->objs_since_last_full()->Increment(); | 205 isolate_->counters()->objs_since_last_full()->Increment(); |
| 206 isolate_->counters()->objs_since_last_young()->Increment(); | 206 isolate_->counters()->objs_since_last_young()->Increment(); |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 HeapObject* object; | 209 HeapObject* object = nullptr; |
| 210 AllocationResult allocation; | 210 AllocationResult allocation; |
| 211 if (NEW_SPACE == space) { | 211 if (NEW_SPACE == space) { |
| 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() && retry_space != NEW_SPACE) { |
| 214 space = retry_space; | 214 space = retry_space; |
| 215 } else { | 215 } else { |
| 216 if (allocation.To(&object)) { | 216 if (allocation.To(&object)) { |
| 217 OnAllocationEvent(object, size_in_bytes); | 217 OnAllocationEvent(object, size_in_bytes); |
| 218 } | 218 } |
| 219 return allocation; | 219 return allocation; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 784 |
| 785 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 785 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |
| 786 for (Object** current = start; current < end; current++) { | 786 for (Object** current = start; current < end; current++) { |
| 787 CHECK((*current)->IsSmi()); | 787 CHECK((*current)->IsSmi()); |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 } | 790 } |
| 791 } // namespace v8::internal | 791 } // namespace v8::internal |
| 792 | 792 |
| 793 #endif // V8_HEAP_HEAP_INL_H_ | 793 #endif // V8_HEAP_HEAP_INL_H_ |
| OLD | NEW |