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

Side by Side Diff: vm/raw_object.cc

Issue 8898034: - Implement the old sweeper. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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 | « vm/raw_object.h ('k') | vm/verifier.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/raw_object.h" 5 #include "vm/raw_object.h"
6 6
7 #include "vm/freelist.h"
7 #include "vm/isolate.h" 8 #include "vm/isolate.h"
8 #include "vm/object.h" 9 #include "vm/object.h"
9 #include "vm/visitor.h" 10 #include "vm/visitor.h"
10 11
11 12
12 namespace dart { 13 namespace dart {
13 14
14 void RawObject::Validate() const { 15 void RawObject::Validate() const {
15 // All Smi values are valid. 16 // All Smi values are valid.
16 if (!IsHeapObject()) { 17 if (!IsHeapObject()) {
17 return; 18 return;
18 } 19 }
19 // Validate that the class_ field is sensible. 20 // Validate that the class_ field is sensible.
20 RawClass* raw_class = ptr()->class_; 21 RawClass* raw_class = ptr()->class_;
21 ASSERT(raw_class->IsHeapObject()); 22 ASSERT(raw_class->IsHeapObject());
22 RawClass* raw_class_class = raw_class->ptr()->class_; 23 RawClass* raw_class_class = raw_class->ptr()->class_;
23 ASSERT(raw_class_class->IsHeapObject()); 24 ASSERT(raw_class_class->IsHeapObject());
24 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass); 25 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass);
25 } 26 }
26 27
27 28
28 intptr_t RawObject::Size() const { 29 intptr_t RawObject::Size() const {
29 NoHandleScope no_handles(Isolate::Current()); 30 NoHandleScope no_handles(Isolate::Current());
30 31
31 // Only reasonable to be called on heap objects. 32 // Only reasonable to be called on heap objects.
32 ASSERT(IsHeapObject()); 33 ASSERT(IsHeapObject());
33 34
34 RawClass* raw_class = ptr()->class_; 35 RawClass* raw_class = ptr()->class_;
36 if (IsMarked()) {
37 // If the object is marked we need to remove the marking bits from the
38 // raw_class which we loaded above.
39 uword header_bits = reinterpret_cast<uword>(raw_class);
40 header_bits = (header_bits & ~kMarkingMask) | kNotMarked;
41 raw_class = reinterpret_cast<RawClass*>(header_bits);
42 }
35 intptr_t instance_size = raw_class->ptr()->instance_size_; 43 intptr_t instance_size = raw_class->ptr()->instance_size_;
44 ObjectKind instance_kind = raw_class->ptr()->instance_kind_;
45
36 if (instance_size == 0) { 46 if (instance_size == 0) {
37 switch (raw_class->ptr()->instance_kind_) { 47 switch (instance_kind) {
38 case kTokenStream: { 48 case kTokenStream: {
39 const RawTokenStream* raw_tokens = 49 const RawTokenStream* raw_tokens =
40 reinterpret_cast<const RawTokenStream*>(this); 50 reinterpret_cast<const RawTokenStream*>(this);
41 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); 51 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_);
42 instance_size = TokenStream::InstanceSize(tokens_length); 52 instance_size = TokenStream::InstanceSize(tokens_length);
43 break; 53 break;
44 } 54 }
45 case kCode: { 55 case kCode: {
46 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this); 56 const RawCode* raw_code = reinterpret_cast<const RawCode*>(this);
47 intptr_t pointer_offsets_length = 57 intptr_t pointer_offsets_length =
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 177
168 switch (kind) { 178 switch (kind) {
169 #define RAW_VISITPOINTERS(clazz) \ 179 #define RAW_VISITPOINTERS(clazz) \
170 case clazz::kInstanceKind: { \ 180 case clazz::kInstanceKind: { \
171 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ 181 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \
172 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ 182 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \
173 break; \ 183 break; \
174 } 184 }
175 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) 185 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS)
176 #undef RAW_VISITPOINTERS 186 #undef RAW_VISITPOINTERS
187 case kFreeListElement: {
188 // Nothing to visit for free list elements.
189 uword addr = RawObject::ToAddr(this);
190 FreeListElement* element = reinterpret_cast<FreeListElement*>(addr);
191 size = element->Size();
192 break;
193 }
177 default: 194 default:
178 OS::Print("Kind: %d\n", kind); 195 OS::Print("Kind: %d\n", kind);
179 UNREACHABLE(); 196 UNREACHABLE();
180 break; 197 break;
181 } 198 }
182 199
183 ASSERT(size != 0); 200 ASSERT(size != 0);
184 return size; 201 return size;
185 } 202 }
186 203
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 562 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
546 ObjectPointerVisitor* visitor) { 563 ObjectPointerVisitor* visitor) {
547 // Make sure that we got here with the tagged pointer as this. 564 // Make sure that we got here with the tagged pointer as this.
548 ASSERT(raw_obj->IsHeapObject()); 565 ASSERT(raw_obj->IsHeapObject());
549 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 566 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
550 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 567 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
551 return JSRegExp::InstanceSize(length); 568 return JSRegExp::InstanceSize(length);
552 } 569 }
553 570
554 } // namespace dart 571 } // namespace dart
OLDNEW
« no previous file with comments | « vm/raw_object.h ('k') | vm/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698