OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/freelist.h" | 5 #include "vm/freelist.h" |
6 | 6 |
7 #include "vm/bit_set.h" | 7 #include "vm/bit_set.h" |
8 #include "vm/hash_map.h" | 8 #include "vm/hash_map.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 #include "vm/os_thread.h" | 11 #include "vm/os_thread.h" |
12 #include "vm/raw_object.h" | 12 #include "vm/raw_object.h" |
13 | 13 |
14 namespace dart { | 14 namespace dart { |
15 | 15 |
16 | 16 |
17 FreeListElement* FreeListElement::AsElement(uword addr, intptr_t size) { | 17 FreeListElement* FreeListElement::AsElement(uword addr, intptr_t size) { |
18 // Precondition: the (page containing the) header of the element is | 18 // Precondition: the (page containing the) header of the element is |
19 // writable. | 19 // writable. |
20 ASSERT(size >= kObjectAlignment); | 20 ASSERT(size >= kObjectAlignment); |
21 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 21 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
22 | 22 |
23 FreeListElement* result = reinterpret_cast<FreeListElement*>(addr); | 23 FreeListElement* result = reinterpret_cast<FreeListElement*>(addr); |
24 | 24 |
25 uword tags = 0; | 25 uword tags = 0; |
26 tags = RawObject::SizeTag::update(size, tags); | 26 tags = RawObject::SizeTag::update(size, tags); |
27 tags = RawObject::ClassIdTag::update(kFreeListElement, tags); | 27 tags = RawObject::ClassIdTag::update(kFreeListElement, tags); |
28 // All words in a freelist element header must look like smis; see | 28 // All words in a freelist element header should look like Smis. |
29 // TryAllocateSmiInitializedLocked. | |
30 ASSERT(!reinterpret_cast<RawObject*>(tags)->IsHeapObject()); | 29 ASSERT(!reinterpret_cast<RawObject*>(tags)->IsHeapObject()); |
31 | 30 |
32 result->tags_ = tags; | 31 result->tags_ = tags; |
33 if (size > RawObject::SizeTag::kMaxSizeTag) { | 32 if (size > RawObject::SizeTag::kMaxSizeTag) { |
34 *result->SizeAddress() = size; | 33 *result->SizeAddress() = size; |
35 } | 34 } |
36 result->set_next(NULL); | 35 result->set_next(NULL); |
37 return result; | 36 return result; |
38 // Postcondition: the (page containing the) header of the element is | 37 // Postcondition: the (page containing the) header of the element is |
39 // writable. | 38 // writable. |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 if (next_index != -1) { | 422 if (next_index != -1) { |
424 FreeListElement* element = DequeueElement(next_index); | 423 FreeListElement* element = DequeueElement(next_index); |
425 SplitElementAfterAndEnqueue(element, size, false); | 424 SplitElementAfterAndEnqueue(element, size, false); |
426 return reinterpret_cast<uword>(element); | 425 return reinterpret_cast<uword>(element); |
427 } | 426 } |
428 } | 427 } |
429 return 0; | 428 return 0; |
430 } | 429 } |
431 | 430 |
432 } // namespace dart | 431 } // namespace dart |
OLD | NEW |