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

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

Issue 10693071: Use VM type cast and save handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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/parser.cc ('k') | no next file » | 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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return obj.raw(); 99 return obj.raw();
100 } 100 }
101 101
102 102
103 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { 103 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) {
104 ASSERT(kind_ != Snapshot::kFull); 104 ASSERT(kind_ != Snapshot::kFull);
105 // Read the class header information and lookup the class. 105 // Read the class header information and lookup the class.
106 intptr_t class_header = ReadIntptrValue(); 106 intptr_t class_header = ReadIntptrValue();
107 ASSERT((class_header & kSmiTagMask) != 0); 107 ASSERT((class_header & kSmiTagMask) != 0);
108 Class& cls = Class::ZoneHandle(isolate(), Class::null()); 108 Class& cls = Class::ZoneHandle(isolate(), Class::null());
109 cls ^= LookupInternalClass(class_header); 109 cls = LookupInternalClass(class_header);
110 AddBackRef(object_id, &cls, kIsDeserialized); 110 AddBackRef(object_id, &cls, kIsDeserialized);
111 if (cls.IsNull()) { 111 if (cls.IsNull()) {
112 // Read the library/class information and lookup the class. 112 // Read the library/class information and lookup the class.
113 str_ ^= ReadObjectImpl(class_header); 113 str_ ^= ReadObjectImpl(class_header);
114 library_ = Library::LookupLibrary(str_); 114 library_ = Library::LookupLibrary(str_);
115 ASSERT(!library_.IsNull()); 115 ASSERT(!library_.IsNull());
116 str_ ^= ReadObjectImpl(); 116 str_ ^= ReadObjectImpl();
117 cls ^= library_.LookupClass(str_); 117 cls = library_.LookupClass(str_);
118 } 118 }
119 ASSERT(!cls.IsNull()); 119 ASSERT(!cls.IsNull());
120 return cls.raw(); 120 return cls.raw();
121 } 121 }
122 122
123 123
124 RawObject* SnapshotReader::ReadObjectImpl() { 124 RawObject* SnapshotReader::ReadObjectImpl() {
125 int64_t value = Read<int64_t>(); 125 int64_t value = Read<int64_t>();
126 if ((value & kSmiTagMask) == 0) { 126 if ((value & kSmiTagMask) == 0) {
127 return Integer::New((value >> kSmiTagShift)); 127 return Integer::New((value >> kSmiTagShift));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 intptr_t instance_size = cls_.instance_size(); 174 intptr_t instance_size = cls_.instance_size();
175 ASSERT(instance_size > 0); 175 ASSERT(instance_size > 0);
176 if (kind_ == Snapshot::kFull) { 176 if (kind_ == Snapshot::kFull) {
177 result ^= AllocateUninitialized(cls_, instance_size); 177 result ^= AllocateUninitialized(cls_, instance_size);
178 } else { 178 } else {
179 result ^= Object::Allocate(cls_, instance_size, Heap::kNew); 179 result ^= Object::Allocate(cls_, instance_size, Heap::kNew);
180 } 180 }
181 return result.raw(); 181 return result.raw();
182 } else { 182 } else {
183 ASSERT((class_header & kSmiTagMask) != 0); 183 ASSERT((class_header & kSmiTagMask) != 0);
184 cls_ ^= LookupInternalClass(class_header); 184 cls_ = LookupInternalClass(class_header);
185 ASSERT(!cls_.IsNull()); 185 ASSERT(!cls_.IsNull());
186 } 186 }
187 187
188 // Similarly Array and ImmutableArray objects are also similarly only 188 // Similarly Array and ImmutableArray objects are also similarly only
189 // allocated here, the individual array elements are read later. 189 // allocated here, the individual array elements are read later.
190 ObjectKind obj_kind = cls_.instance_kind(); 190 ObjectKind obj_kind = cls_.instance_kind();
191 if (obj_kind == Array::kInstanceKind) { 191 if (obj_kind == Array::kInstanceKind) {
192 // Read the length and allocate an object based on the len. 192 // Read the length and allocate an object based on the len.
193 intptr_t len = ReadSmiValue(); 193 intptr_t len = ReadSmiValue();
194 Array& array = Array::ZoneHandle( 194 Array& array = Array::ZoneHandle(
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 offset += kWordSize; 569 offset += kWordSize;
570 } 570 }
571 if (kind_ == Snapshot::kFull) { 571 if (kind_ == Snapshot::kFull) {
572 result->SetCreatedFromSnapshot(); 572 result->SetCreatedFromSnapshot();
573 } else if (result->IsCanonical()) { 573 } else if (result->IsCanonical()) {
574 *result = result->Canonicalize(); 574 *result = result->Canonicalize();
575 } 575 }
576 return result->raw(); 576 return result->raw();
577 } else { 577 } else {
578 ASSERT((class_header & kSmiTagMask) != 0); 578 ASSERT((class_header & kSmiTagMask) != 0);
579 cls_ ^= LookupInternalClass(class_header); 579 cls_ = LookupInternalClass(class_header);
580 ASSERT(!cls_.IsNull()); 580 ASSERT(!cls_.IsNull());
581 } 581 }
582 switch (cls_.instance_kind()) { 582 switch (cls_.instance_kind()) {
583 #define SNAPSHOT_READ(clazz) \ 583 #define SNAPSHOT_READ(clazz) \
584 case clazz::kInstanceKind: { \ 584 case clazz::kInstanceKind: { \
585 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 585 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
586 break; \ 586 break; \
587 } 587 }
588 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 588 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
589 #undef SNAPSHOT_READ 589 #undef SNAPSHOT_READ
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 RawObject* raw_obj = *current; 1008 RawObject* raw_obj = *current;
1009 if (as_references_) { 1009 if (as_references_) {
1010 writer_->WriteObjectRef(raw_obj); 1010 writer_->WriteObjectRef(raw_obj);
1011 } else { 1011 } else {
1012 writer_->WriteObjectImpl(raw_obj); 1012 writer_->WriteObjectImpl(raw_obj);
1013 } 1013 }
1014 } 1014 }
1015 } 1015 }
1016 1016
1017 } // namespace dart 1017 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698