| 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_INL_H_ | 5 #ifndef V8_HEAP_INL_H_ |
| 6 #define V8_HEAP_INL_H_ | 6 #define V8_HEAP_INL_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "heap.h" | 10 #include "heap.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // String maps are all immortal immovable objects. | 115 // String maps are all immortal immovable objects. |
| 116 result->set_map_no_write_barrier(map); | 116 result->set_map_no_write_barrier(map); |
| 117 // Set length and hash fields of the allocated string. | 117 // Set length and hash fields of the allocated string. |
| 118 String* answer = String::cast(result); | 118 String* answer = String::cast(result); |
| 119 answer->set_length(str.length()); | 119 answer->set_length(str.length()); |
| 120 answer->set_hash_field(hash_field); | 120 answer->set_hash_field(hash_field); |
| 121 | 121 |
| 122 ASSERT_EQ(size, answer->Size()); | 122 ASSERT_EQ(size, answer->Size()); |
| 123 | 123 |
| 124 // Fill in the characters. | 124 // Fill in the characters. |
| 125 OS::MemCopy(answer->address() + SeqOneByteString::kHeaderSize, | 125 MemCopy(answer->address() + SeqOneByteString::kHeaderSize, str.start(), |
| 126 str.start(), str.length()); | 126 str.length()); |
| 127 | 127 |
| 128 return answer; | 128 return answer; |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, | 132 AllocationResult Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, |
| 133 uint32_t hash_field) { | 133 uint32_t hash_field) { |
| 134 if (str.length() > String::kMaxLength) { | 134 if (str.length() > String::kMaxLength) { |
| 135 return isolate()->ThrowInvalidStringLength(); | 135 return isolate()->ThrowInvalidStringLength(); |
| 136 } | 136 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 147 | 147 |
| 148 result->set_map(map); | 148 result->set_map(map); |
| 149 // Set length and hash fields of the allocated string. | 149 // Set length and hash fields of the allocated string. |
| 150 String* answer = String::cast(result); | 150 String* answer = String::cast(result); |
| 151 answer->set_length(str.length()); | 151 answer->set_length(str.length()); |
| 152 answer->set_hash_field(hash_field); | 152 answer->set_hash_field(hash_field); |
| 153 | 153 |
| 154 ASSERT_EQ(size, answer->Size()); | 154 ASSERT_EQ(size, answer->Size()); |
| 155 | 155 |
| 156 // Fill in the characters. | 156 // Fill in the characters. |
| 157 OS::MemCopy(answer->address() + SeqTwoByteString::kHeaderSize, | 157 MemCopy(answer->address() + SeqTwoByteString::kHeaderSize, str.start(), |
| 158 str.start(), str.length() * kUC16Size); | 158 str.length() * kUC16Size); |
| 159 | 159 |
| 160 return answer; | 160 return answer; |
| 161 } | 161 } |
| 162 | 162 |
| 163 AllocationResult Heap::CopyFixedArray(FixedArray* src) { | 163 AllocationResult Heap::CopyFixedArray(FixedArray* src) { |
| 164 if (src->length() == 0) return src; | 164 if (src->length() == 0) return src; |
| 165 return CopyFixedArrayWithMap(src, src->map()); | 165 return CopyFixedArrayWithMap(src, src->map()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 422 |
| 423 if ((dst < src) || (dst >= (src + byte_size))) { | 423 if ((dst < src) || (dst >= (src + byte_size))) { |
| 424 Object** src_slot = reinterpret_cast<Object**>(src); | 424 Object** src_slot = reinterpret_cast<Object**>(src); |
| 425 Object** dst_slot = reinterpret_cast<Object**>(dst); | 425 Object** dst_slot = reinterpret_cast<Object**>(dst); |
| 426 Object** end_slot = src_slot + size_in_words; | 426 Object** end_slot = src_slot + size_in_words; |
| 427 | 427 |
| 428 while (src_slot != end_slot) { | 428 while (src_slot != end_slot) { |
| 429 *dst_slot++ = *src_slot++; | 429 *dst_slot++ = *src_slot++; |
| 430 } | 430 } |
| 431 } else { | 431 } else { |
| 432 OS::MemMove(dst, src, static_cast<size_t>(byte_size)); | 432 MemMove(dst, src, static_cast<size_t>(byte_size)); |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 | 436 |
| 437 void Heap::ScavengePointer(HeapObject** p) { | 437 void Heap::ScavengePointer(HeapObject** p) { |
| 438 ScavengeObject(p, *p); | 438 ScavengeObject(p, *p); |
| 439 } | 439 } |
| 440 | 440 |
| 441 | 441 |
| 442 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { | 442 AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 767 |
| 768 | 768 |
| 769 double GCTracer::SizeOfHeapObjects() { | 769 double GCTracer::SizeOfHeapObjects() { |
| 770 return (static_cast<double>(heap_->SizeOfObjects())) / MB; | 770 return (static_cast<double>(heap_->SizeOfObjects())) / MB; |
| 771 } | 771 } |
| 772 | 772 |
| 773 | 773 |
| 774 } } // namespace v8::internal | 774 } } // namespace v8::internal |
| 775 | 775 |
| 776 #endif // V8_HEAP_INL_H_ | 776 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |