OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // String maps are all immortal immovable objects. | 152 // String maps are all immortal immovable objects. |
153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); | 153 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); |
154 // Set length and hash fields of the allocated string. | 154 // Set length and hash fields of the allocated string. |
155 String* answer = String::cast(result); | 155 String* answer = String::cast(result); |
156 answer->set_length(str.length()); | 156 answer->set_length(str.length()); |
157 answer->set_hash_field(hash_field); | 157 answer->set_hash_field(hash_field); |
158 | 158 |
159 ASSERT_EQ(size, answer->Size()); | 159 ASSERT_EQ(size, answer->Size()); |
160 | 160 |
161 // Fill in the characters. | 161 // Fill in the characters. |
162 memcpy(answer->address() + SeqOneByteString::kHeaderSize, | 162 OS::MemCopy(answer->address() + SeqOneByteString::kHeaderSize, |
163 str.start(), str.length()); | 163 str.start(), str.length()); |
164 | 164 |
165 return answer; | 165 return answer; |
166 } | 166 } |
167 | 167 |
168 | 168 |
169 MaybeObject* Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, | 169 MaybeObject* Heap::AllocateTwoByteInternalizedString(Vector<const uc16> str, |
170 uint32_t hash_field) { | 170 uint32_t hash_field) { |
171 if (str.length() > SeqTwoByteString::kMaxLength) { | 171 if (str.length() > SeqTwoByteString::kMaxLength) { |
172 return Failure::OutOfMemoryException(0x3); | 172 return Failure::OutOfMemoryException(0x3); |
173 } | 173 } |
(...skipping 11 matching lines...) Expand all Loading... |
185 | 185 |
186 reinterpret_cast<HeapObject*>(result)->set_map(map); | 186 reinterpret_cast<HeapObject*>(result)->set_map(map); |
187 // Set length and hash fields of the allocated string. | 187 // Set length and hash fields of the allocated string. |
188 String* answer = String::cast(result); | 188 String* answer = String::cast(result); |
189 answer->set_length(str.length()); | 189 answer->set_length(str.length()); |
190 answer->set_hash_field(hash_field); | 190 answer->set_hash_field(hash_field); |
191 | 191 |
192 ASSERT_EQ(size, answer->Size()); | 192 ASSERT_EQ(size, answer->Size()); |
193 | 193 |
194 // Fill in the characters. | 194 // Fill in the characters. |
195 memcpy(answer->address() + SeqTwoByteString::kHeaderSize, | 195 OS::MemCopy(answer->address() + SeqTwoByteString::kHeaderSize, |
196 str.start(), str.length() * kUC16Size); | 196 str.start(), str.length() * kUC16Size); |
197 | 197 |
198 return answer; | 198 return answer; |
199 } | 199 } |
200 | 200 |
201 MaybeObject* Heap::CopyFixedArray(FixedArray* src) { | 201 MaybeObject* Heap::CopyFixedArray(FixedArray* src) { |
202 return CopyFixedArrayWithMap(src, src->map()); | 202 return CopyFixedArrayWithMap(src, src->map()); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 MaybeObject* Heap::CopyFixedDoubleArray(FixedDoubleArray* src) { | 206 MaybeObject* Heap::CopyFixedDoubleArray(FixedDoubleArray* src) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 : OLD_DATA_SPACE; | 410 : OLD_DATA_SPACE; |
411 } else { | 411 } else { |
412 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; | 412 return (type <= LAST_DATA_TYPE) ? OLD_DATA_SPACE : OLD_POINTER_SPACE; |
413 } | 413 } |
414 } | 414 } |
415 | 415 |
416 | 416 |
417 void Heap::CopyBlock(Address dst, Address src, int byte_size) { | 417 void Heap::CopyBlock(Address dst, Address src, int byte_size) { |
418 CopyWords(reinterpret_cast<Object**>(dst), | 418 CopyWords(reinterpret_cast<Object**>(dst), |
419 reinterpret_cast<Object**>(src), | 419 reinterpret_cast<Object**>(src), |
420 byte_size / kPointerSize); | 420 static_cast<size_t>(byte_size / kPointerSize)); |
421 } | 421 } |
422 | 422 |
423 | 423 |
424 void Heap::MoveBlock(Address dst, Address src, int byte_size) { | 424 void Heap::MoveBlock(Address dst, Address src, int byte_size) { |
425 ASSERT(IsAligned(byte_size, kPointerSize)); | 425 ASSERT(IsAligned(byte_size, kPointerSize)); |
426 | 426 |
427 int size_in_words = byte_size / kPointerSize; | 427 int size_in_words = byte_size / kPointerSize; |
428 | 428 |
429 if ((dst < src) || (dst >= (src + byte_size))) { | 429 if ((dst < src) || (dst >= (src + byte_size))) { |
430 Object** src_slot = reinterpret_cast<Object**>(src); | 430 Object** src_slot = reinterpret_cast<Object**>(src); |
431 Object** dst_slot = reinterpret_cast<Object**>(dst); | 431 Object** dst_slot = reinterpret_cast<Object**>(dst); |
432 Object** end_slot = src_slot + size_in_words; | 432 Object** end_slot = src_slot + size_in_words; |
433 | 433 |
434 while (src_slot != end_slot) { | 434 while (src_slot != end_slot) { |
435 *dst_slot++ = *src_slot++; | 435 *dst_slot++ = *src_slot++; |
436 } | 436 } |
437 } else { | 437 } else { |
438 memmove(dst, src, byte_size); | 438 OS::MemMove(dst, src, static_cast<size_t>(byte_size)); |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 void Heap::ScavengePointer(HeapObject** p) { | 443 void Heap::ScavengePointer(HeapObject** p) { |
444 ScavengeObject(p, *p); | 444 ScavengeObject(p, *p); |
445 } | 445 } |
446 | 446 |
447 | 447 |
448 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { | 448 void Heap::ScavengeObject(HeapObject** p, HeapObject* object) { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 AssertNoAllocation::~AssertNoAllocation() { } | 868 AssertNoAllocation::~AssertNoAllocation() { } |
869 DisableAssertNoAllocation::DisableAssertNoAllocation() { } | 869 DisableAssertNoAllocation::DisableAssertNoAllocation() { } |
870 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } | 870 DisableAssertNoAllocation::~DisableAssertNoAllocation() { } |
871 | 871 |
872 #endif | 872 #endif |
873 | 873 |
874 | 874 |
875 } } // namespace v8::internal | 875 } } // namespace v8::internal |
876 | 876 |
877 #endif // V8_HEAP_INL_H_ | 877 #endif // V8_HEAP_INL_H_ |
OLD | NEW |