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

Side by Side Diff: vm/raw_object.cc

Issue 10052027: Add fast paths for Smi values in the dart embedding api. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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
« vm/handles.h ('K') | « vm/pages.cc ('k') | vm/scavenger.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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"
(...skipping 18 matching lines...) Expand all
29 ASSERT(raw_class_class->IsHeapObject()); 29 ASSERT(raw_class_class->IsHeapObject());
30 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass); 30 ASSERT(raw_class_class->ptr()->instance_kind_ == kClass);
31 31
32 // Validate that the tags_ field is sensible. 32 // Validate that the tags_ field is sensible.
33 intptr_t tags = ptr()->tags_; 33 intptr_t tags = ptr()->tags_;
34 ASSERT((tags & 0xffff00f0) == 0); 34 ASSERT((tags & 0xffff00f0) == 0);
35 } 35 }
36 36
37 37
38 intptr_t RawObject::SizeFromClass() const { 38 intptr_t RawObject::SizeFromClass() const {
39 NoHandleScope no_handles(Isolate::Current()); 39 NOHANDLESCOPE(Isolate::Current());
40 40
41 // Only reasonable to be called on heap objects. 41 // Only reasonable to be called on heap objects.
42 ASSERT(IsHeapObject()); 42 ASSERT(IsHeapObject());
43 43
44 RawClass* raw_class = ptr()->class_; 44 RawClass* raw_class = ptr()->class_;
45 intptr_t instance_size = raw_class->ptr()->instance_size_; 45 intptr_t instance_size = raw_class->ptr()->instance_size_;
46 ObjectKind instance_kind = raw_class->ptr()->instance_kind_; 46 ObjectKind instance_kind = raw_class->ptr()->instance_kind_;
47 47
48 if (instance_size == 0) { 48 if (instance_size == 0) {
49 switch (instance_kind) { 49 switch (instance_kind) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 intptr_t tags = ptr()->tags_; 180 intptr_t tags = ptr()->tags_;
181 ASSERT((instance_size == SizeTag::decode(tags)) || 181 ASSERT((instance_size == SizeTag::decode(tags)) ||
182 (SizeTag::decode(tags) == 0) || 182 (SizeTag::decode(tags) == 0) ||
183 FreeBit::decode(tags)); 183 FreeBit::decode(tags));
184 return instance_size; 184 return instance_size;
185 } 185 }
186 186
187 187
188 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) { 188 intptr_t RawObject::VisitPointers(ObjectPointerVisitor* visitor) {
189 intptr_t size = 0; 189 intptr_t size = 0;
190 NoHandleScope no_handles(Isolate::Current()); 190 NOHANDLESCOPE(Isolate::Current());
191 191
192 // Only reasonable to be called on heap objects. 192 // Only reasonable to be called on heap objects.
193 ASSERT(IsHeapObject()); 193 ASSERT(IsHeapObject());
194 194
195 // Read the necessary data out of the class before visting the class itself. 195 // Read the necessary data out of the class before visting the class itself.
196 RawClass* raw_class = ptr()->class_; 196 RawClass* raw_class = ptr()->class_;
197 ObjectKind kind = raw_class->ptr()->instance_kind_; 197 ObjectKind kind = raw_class->ptr()->instance_kind_;
198 198
199 // Visit the class before visting the fields. 199 // Visit the class before visting the fields.
200 visitor->VisitPointer(reinterpret_cast<RawObject**>(&ptr()->class_)); 200 visitor->VisitPointer(reinterpret_cast<RawObject**>(&ptr()->class_));
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj, 693 intptr_t RawJSRegExp::VisitJSRegExpPointers(RawJSRegExp* raw_obj,
694 ObjectPointerVisitor* visitor) { 694 ObjectPointerVisitor* visitor) {
695 // Make sure that we got here with the tagged pointer as this. 695 // Make sure that we got here with the tagged pointer as this.
696 ASSERT(raw_obj->IsHeapObject()); 696 ASSERT(raw_obj->IsHeapObject());
697 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_); 697 intptr_t length = Smi::Value(raw_obj->ptr()->data_length_);
698 visitor->VisitPointers(raw_obj->from(), raw_obj->to()); 698 visitor->VisitPointers(raw_obj->from(), raw_obj->to());
699 return JSRegExp::InstanceSize(length); 699 return JSRegExp::InstanceSize(length);
700 } 700 }
701 701
702 } // namespace dart 702 } // namespace dart
OLDNEW
« vm/handles.h ('K') | « vm/pages.cc ('k') | vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698