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

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

Issue 792163003: Deletion barrier preparation: validate overwritten references. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/object.cc » ('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 <map> 7 #include <map>
8 8
9 #include "vm/bit_set.h" 9 #include "vm/bit_set.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
11 #include "vm/object.h" 11 #include "vm/object.h"
12 #include "vm/raw_object.h" 12 #include "vm/raw_object.h"
13 #include "vm/thread.h" 13 #include "vm/thread.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 17
18 FreeListElement* FreeListElement::AsElement(uword addr, intptr_t size) { 18 FreeListElement* FreeListElement::AsElement(uword addr, intptr_t size) {
19 // Precondition: the (page containing the) header of the element is 19 // Precondition: the (page containing the) header of the element is
20 // writable. 20 // writable.
21 ASSERT(size >= kObjectAlignment); 21 ASSERT(size >= kObjectAlignment);
22 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 22 ASSERT(Utils::IsAligned(size, kObjectAlignment));
23 23
24 FreeListElement* result = reinterpret_cast<FreeListElement*>(addr); 24 FreeListElement* result = reinterpret_cast<FreeListElement*>(addr);
25 25
26 uword tags = 0; 26 uword tags = 0;
27 tags = RawObject::SizeTag::update(size, tags); 27 tags = RawObject::SizeTag::update(size, tags);
28 tags = RawObject::ClassIdTag::update(kFreeListElement, tags); 28 tags = RawObject::ClassIdTag::update(kFreeListElement, tags);
29 // All words in a freelist element header must look like smis; see
30 // TryAllocateSmiInitializedLocked.
31 ASSERT(!reinterpret_cast<RawObject*>(tags)->IsHeapObject());
29 32
30 result->tags_ = tags; 33 result->tags_ = tags;
31 if (size > RawObject::SizeTag::kMaxSizeTag) { 34 if (size > RawObject::SizeTag::kMaxSizeTag) {
32 *result->SizeAddress() = size; 35 *result->SizeAddress() = size;
33 } 36 }
34 result->set_next(NULL); 37 result->set_next(NULL);
35 return result; 38 return result;
36 // Postcondition: the (page containing the) header of the element is 39 // Postcondition: the (page containing the) header of the element is
37 // writable. 40 // writable.
38 } 41 }
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 if (next_index != -1) { 397 if (next_index != -1) {
395 FreeListElement* element = DequeueElement(next_index); 398 FreeListElement* element = DequeueElement(next_index);
396 SplitElementAfterAndEnqueue(element, size, false); 399 SplitElementAfterAndEnqueue(element, size, false);
397 return reinterpret_cast<uword>(element); 400 return reinterpret_cast<uword>(element);
398 } 401 }
399 } 402 }
400 return 0; 403 return 0;
401 } 404 }
402 405
403 } // namespace dart 406 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698