| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  218   if (IsOneByte(t, chars)) { |  218   if (IsOneByte(t, chars)) { | 
|  219     return AllocateInternalizedStringImpl<true>(t, chars, hash_field); |  219     return AllocateInternalizedStringImpl<true>(t, chars, hash_field); | 
|  220   } |  220   } | 
|  221   return AllocateInternalizedStringImpl<false>(t, chars, hash_field); |  221   return AllocateInternalizedStringImpl<false>(t, chars, hash_field); | 
|  222 } |  222 } | 
|  223  |  223  | 
|  224  |  224  | 
|  225 AllocationResult Heap::AllocateOneByteInternalizedString( |  225 AllocationResult Heap::AllocateOneByteInternalizedString( | 
|  226     Vector<const uint8_t> str, uint32_t hash_field) { |  226     Vector<const uint8_t> str, uint32_t hash_field) { | 
|  227   CHECK_GE(String::kMaxLength, str.length()); |  227   CHECK_GE(String::kMaxLength, str.length()); | 
 |  228   // The canonical empty_string is the only zero-length string we allow. | 
 |  229   DCHECK_IMPLIES(str.length() == 0, roots_[kempty_stringRootIndex] == nullptr); | 
|  228   // Compute map and object size. |  230   // Compute map and object size. | 
|  229   Map* map = one_byte_internalized_string_map(); |  231   Map* map = one_byte_internalized_string_map(); | 
|  230   int size = SeqOneByteString::SizeFor(str.length()); |  232   int size = SeqOneByteString::SizeFor(str.length()); | 
|  231  |  233  | 
|  232   // Allocate string. |  234   // Allocate string. | 
|  233   HeapObject* result = nullptr; |  235   HeapObject* result = nullptr; | 
|  234   { |  236   { | 
|  235     AllocationResult allocation = AllocateRaw(size, OLD_SPACE); |  237     AllocationResult allocation = AllocateRaw(size, OLD_SPACE); | 
|  236     if (!allocation.To(&result)) return allocation; |  238     if (!allocation.To(&result)) return allocation; | 
|  237   } |  239   } | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  249   MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(), |  251   MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(), | 
|  250           str.length()); |  252           str.length()); | 
|  251  |  253  | 
|  252   return answer; |  254   return answer; | 
|  253 } |  255 } | 
|  254  |  256  | 
|  255  |  257  | 
|  256 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, |  258 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, | 
|  257                                                          uint32_t hash_field) { |  259                                                          uint32_t hash_field) { | 
|  258   CHECK_GE(String::kMaxLength, str.length()); |  260   CHECK_GE(String::kMaxLength, str.length()); | 
 |  261   DCHECK_NE(0, str.length());  // Use Heap::empty_string() instead. | 
|  259   // Compute map and object size. |  262   // Compute map and object size. | 
|  260   Map* map = internalized_string_map(); |  263   Map* map = internalized_string_map(); | 
|  261   int size = SeqTwoByteString::SizeFor(str.length()); |  264   int size = SeqTwoByteString::SizeFor(str.length()); | 
|  262  |  265  | 
|  263   // Allocate string. |  266   // Allocate string. | 
|  264   HeapObject* result = nullptr; |  267   HeapObject* result = nullptr; | 
|  265   { |  268   { | 
|  266     AllocationResult allocation = AllocateRaw(size, OLD_SPACE); |  269     AllocationResult allocation = AllocateRaw(size, OLD_SPACE); | 
|  267     if (!allocation.To(&result)) return allocation; |  270     if (!allocation.To(&result)) return allocation; | 
|  268   } |  271   } | 
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  859  |  862  | 
|  860 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { |  863 void VerifySmisVisitor::VisitPointers(Object** start, Object** end) { | 
|  861   for (Object** current = start; current < end; current++) { |  864   for (Object** current = start; current < end; current++) { | 
|  862     CHECK((*current)->IsSmi()); |  865     CHECK((*current)->IsSmi()); | 
|  863   } |  866   } | 
|  864 } |  867 } | 
|  865 }  // namespace internal |  868 }  // namespace internal | 
|  866 }  // namespace v8 |  869 }  // namespace v8 | 
|  867  |  870  | 
|  868 #endif  // V8_HEAP_HEAP_INL_H_ |  871 #endif  // V8_HEAP_HEAP_INL_H_ | 
| OLD | NEW |