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

Side by Side Diff: vm/raw_object.cc

Issue 9027017: - Promote objects from new gen to old space if they survived a scavenge. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 12 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/raw_object.h" 5 #include "vm/raw_object.h"
6 6
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
11 11
12 12
13 namespace dart { 13 namespace dart {
14 14
15 void RawObject::Validate() const { 15 void RawObject::Validate() const {
16 // All Smi values are valid. 16 // All Smi values are valid.
17 if (!IsHeapObject()) { 17 if (!IsHeapObject()) {
18 return; 18 return;
19 } 19 }
20 // Validate that the class_ field is sensible. 20 // Validate that the class_ field is sensible.
21 RawClass* raw_class = ptr()->class_; 21 RawClass* raw_class = ptr()->class_;
22 ASSERT(raw_class->IsHeapObject()); 22 ASSERT(raw_class->IsHeapObject());
23 RawClass* raw_class_class = raw_class->ptr()->class_; 23 RawClass* raw_class_class = raw_class->ptr()->class_;
24 ASSERT(raw_class_class->IsHeapObject()); 24 ASSERT(raw_class_class->IsHeapObject());
25 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass); 25 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass);
26
27 // Validate that the tags_ field is sensible.
28 intptr_t tags = ptr()->tags_;
29 ASSERT((tags & 0xfffffff0) == 0);
26 } 30 }
27 31
28 32
29 intptr_t RawObject::Size() const { 33 intptr_t RawObject::Size() const {
30 NoHandleScope no_handles(Isolate::Current()); 34 NoHandleScope no_handles(Isolate::Current());
31 35
32 // Only reasonable to be called on heap objects. 36 // Only reasonable to be called on heap objects.
33 ASSERT(IsHeapObject()); 37 ASSERT(IsHeapObject());
34 38
35 RawClass* raw_class = ptr()->class_; 39 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 }
43 intptr_t instance_size = raw_class->ptr()->instance_size_; 40 intptr_t instance_size = raw_class->ptr()->instance_size_;
44 ObjectKind instance_kind = raw_class->ptr()->instance_kind_; 41 ObjectKind instance_kind = raw_class->ptr()->instance_kind_;
45 42
46 if (instance_size == 0) { 43 if (instance_size == 0) {
47 switch (instance_kind) { 44 switch (instance_kind) {
48 case kTokenStream: { 45 case kTokenStream: {
49 const RawTokenStream* raw_tokens = 46 const RawTokenStream* raw_tokens =
50 reinterpret_cast<const RawTokenStream*>(this); 47 reinterpret_cast<const RawTokenStream*>(this);
51 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_); 48 intptr_t tokens_length = Smi::Value(raw_tokens->ptr()->length_);
52 instance_size = TokenStream::InstanceSize(tokens_length); 49 instance_size = TokenStream::InstanceSize(tokens_length);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 164
168 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { 165 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) {
169 intptr_t size = 0; 166 intptr_t size = 0;
170 NoHandleScope no_handles(Isolate::Current()); 167 NoHandleScope no_handles(Isolate::Current());
171 168
172 // Only reasonable to be called on heap objects. 169 // Only reasonable to be called on heap objects.
173 ASSERT(IsHeapObject()); 170 ASSERT(IsHeapObject());
174 171
175 // Read the necessary data out of the class before visting the class itself. 172 // Read the necessary data out of the class before visting the class itself.
176 RawClass* raw_class = ptr()->class_; 173 RawClass* raw_class = ptr()->class_;
177 if (IsMarked()) {
178 // If the object is marked we need to remove the marking bits from the
179 // raw_class which we loaded above.
180 uword header_bits = reinterpret_cast<uword>(raw_class);
181 header_bits = (header_bits & ~kMarkingMask) | kNotMarked;
182 raw_class = reinterpret_cast<RawClass*>(header_bits);
183 }
184 ObjectKind kind = raw_class->ptr()->instance_kind_; 174 ObjectKind kind = raw_class->ptr()->instance_kind_;
185 175
186 // Visit the class before visting the fields. 176 // Visit the class before visting the fields.
187 if (!IsMarked()) { 177 visitor->VisitPointer(reinterpret_cast<RawObject**>(&ptr()->class_));
188 visitor->VisitPointer(reinterpret_cast<RawObject**>(&ptr()->class_));
189 }
190 178
191 switch (kind) { 179 switch (kind) {
192 #define RAW_VISITPOINTERS(clazz) \ 180 #define RAW_VISITPOINTERS(clazz) \
193 case clazz::kInstanceKind: { \ 181 case clazz::kInstanceKind: { \
194 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \ 182 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(this); \
195 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \ 183 size = Raw##clazz::Visit##clazz##Pointers(raw_obj, visitor); \
196 break; \ 184 break; \
197 } 185 }
198 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS) 186 CLASS_LIST_NO_OBJECT(RAW_VISITPOINTERS)
199 #undef RAW_VISITPOINTERS 187 #undef RAW_VISITPOINTERS
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 572 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
585 ObjectPointerVisitor* visitor) { 573 ObjectPointerVisitor* visitor) {
586 // Make sure that we got here with the tagged pointer as this. 574 // Make sure that we got here with the tagged pointer as this.
587 ASSERT(raw_obj->IsHeapObject()); 575 ASSERT(raw_obj->IsHeapObject());
588 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 576 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
589 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 577 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
590 return JSRegExp::InstanceSize(length); 578 return JSRegExp::InstanceSize(length);
591 } 579 }
592 580
593 } // namespace dart 581 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698