Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: runtime/vm/freelist.cc

Issue 2912863006: Inline instance object hash code into object header on 64 bit. (Closed)
Patch Set: Add assembler tests and other feedback from Ryan Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 uint32_t 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 should look like Smis. 28 // All words in a freelist element header should look like Smis.
29 ASSERT(!reinterpret_cast<RawObject*>(tags)->IsHeapObject()); 29 ASSERT(!reinterpret_cast<RawObject*>(tags)->IsHeapObject());
30 30
31 result->tags_ = tags; 31 result->tags_ = tags;
32 #if defined(HASH_IN_OBJECT_HEADER)
33 // Clearing this is mostly for neatness. The identityHashCode
34 // of free list entries is not used.
35 result->hash_ = 0;
36 #endif
32 if (size > RawObject::SizeTag::kMaxSizeTag) { 37 if (size > RawObject::SizeTag::kMaxSizeTag) {
33 *result->SizeAddress() = size; 38 *result->SizeAddress() = size;
34 } 39 }
35 result->set_next(NULL); 40 result->set_next(NULL);
36 return result; 41 return result;
37 // Postcondition: the (page containing the) header of the element is 42 // Postcondition: the (page containing the) header of the element is
38 // writable. 43 // writable.
39 } 44 }
40 45
41 46
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (next_index != -1) { 443 if (next_index != -1) {
439 FreeListElement* element = DequeueElement(next_index); 444 FreeListElement* element = DequeueElement(next_index);
440 SplitElementAfterAndEnqueue(element, size, false); 445 SplitElementAfterAndEnqueue(element, size, false);
441 return reinterpret_cast<uword>(element); 446 return reinterpret_cast<uword>(element);
442 } 447 }
443 } 448 }
444 return 0; 449 return 0;
445 } 450 }
446 451
447 } // namespace dart 452 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698