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

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

Issue 10521004: Eliminate RawObject::class_ field entirely. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/stack_frame.h" 11 #include "vm/stack_frame.h"
12 #include "vm/verifier.h" 12 #include "vm/verifier.h"
13 #include "vm/visitor.h" 13 #include "vm/visitor.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 // Scavenger uses RawObject::kFreeBit to distinguish forwaded and non-forwarded
18 // objects because scavenger can never encounter free list element during
19 // evacuation and thus all objects scavenger encounters have
20 // kFreeBit cleared.
17 enum { 21 enum {
18 kForwardingMask = 3, 22 kForwardingMask = 1,
19 kNotForwarded = 1, // Tagged pointer. 23 kNotForwarded = 0,
20 kForwarded = 3, // Tagged pointer and forwarding bit set. 24 kForwarded = 1,
21 }; 25 };
22 26
23 27
24 static inline bool IsForwarding(uword header) { 28 static inline bool IsForwarding(uword header) {
25 uword bits = header & kForwardingMask; 29 uword bits = header & kForwardingMask;
26 ASSERT((bits == kNotForwarded) || (bits == kForwarded)); 30 ASSERT((bits == kNotForwarded) || (bits == kForwarded));
27 return bits == kForwarded; 31 return bits == kForwarded;
28 } 32 }
29 33
30 34
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 154
151 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor); 155 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor);
152 }; 156 };
153 157
154 158
155 Scavenger::Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment) 159 Scavenger::Scavenger(Heap* heap, intptr_t max_capacity, uword object_alignment)
156 : heap_(heap), 160 : heap_(heap),
157 object_alignment_(object_alignment), 161 object_alignment_(object_alignment),
158 count_(0), 162 count_(0),
159 scavenging_(false) { 163 scavenging_(false) {
164 // Verify assumptions about the first word in objects that scavenger is going
Ivan Posva 2012/06/06 13:42:11 objects which the scavenger
165 // to use for forwarding pointers.
166 ASSERT(Object::tags_offset() == 0);
167 ASSERT(kForwardingMask == (1 << RawObject::kFreeBit));
168
160 // Allocate the virtual memory for this scavenge heap. 169 // Allocate the virtual memory for this scavenge heap.
161 space_ = VirtualMemory::Reserve(max_capacity); 170 space_ = VirtualMemory::Reserve(max_capacity);
162 ASSERT(space_ != NULL); 171 ASSERT(space_ != NULL);
163 172
164 // Allocate the entire space at the beginning. 173 // Allocate the entire space at the beginning.
165 space_->Commit(false); 174 space_->Commit(false);
166 175
167 // Setup the semi spaces. 176 // Setup the semi spaces.
168 uword semi_space_size = space_->size() / 2; 177 uword semi_space_size = space_->size() / 2;
169 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0); 178 ASSERT((semi_space_size & (VirtualMemory::PageSize() - 1)) == 0);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 OS::PrintErr(" done.\n"); 396 OS::PrintErr(" done.\n");
388 } 397 }
389 398
390 count_++; 399 count_++;
391 // Done scavenging. Reset the marker. 400 // Done scavenging. Reset the marker.
392 ASSERT(scavenging_); 401 ASSERT(scavenging_);
393 scavenging_ = false; 402 scavenging_ = false;
394 } 403 }
395 404
396 } // namespace dart 405 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698