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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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) 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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // handle, then signal an error. 140 // handle, then signal an error.
141 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_); 141 int64_t snapshot_length = ReadUnaligned(&snapshot->unaligned_length_);
142 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) { 142 if ((snapshot_length < 0) || (snapshot_length > kIntptrMax)) {
143 return NULL; 143 return NULL;
144 } 144 }
145 return snapshot; 145 return snapshot;
146 } 146 }
147 147
148 148
149 RawSmi* BaseReader::ReadAsSmi() { 149 RawSmi* BaseReader::ReadAsSmi() {
150 intptr_t value = ReadIntptrValue(); 150 intptr_t value = Read<int32_t>();
151 ASSERT((value & kSmiTagMask) == kSmiTag); 151 ASSERT((value & kSmiTagMask) == kSmiTag);
152 return reinterpret_cast<RawSmi*>(value); 152 return reinterpret_cast<RawSmi*>(value);
153 } 153 }
154 154
155 155
156 intptr_t BaseReader::ReadSmiValue() { 156 intptr_t BaseReader::ReadSmiValue() {
157 return Smi::Value(ReadAsSmi()); 157 return Smi::Value(ReadAsSmi());
158 } 158 }
159 159
160 160
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 const Error& err = Error::Handle(isolate()->object_store()->sticky_error()); 202 const Error& err = Error::Handle(isolate()->object_store()->sticky_error());
203 isolate()->object_store()->clear_sticky_error(); 203 isolate()->object_store()->clear_sticky_error();
204 return err.raw(); 204 return err.raw();
205 } 205 }
206 } 206 }
207 207
208 208
209 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) { 209 RawClass* SnapshotReader::ReadClassId(intptr_t object_id) {
210 ASSERT(kind_ != Snapshot::kFull); 210 ASSERT(kind_ != Snapshot::kFull);
211 // Read the class header information and lookup the class. 211 // Read the class header information and lookup the class.
212 intptr_t class_header = ReadIntptrValue(); 212 intptr_t class_header = Read<int32_t>();
213 ASSERT((class_header & kSmiTagMask) != kSmiTag); 213 ASSERT((class_header & kSmiTagMask) != kSmiTag);
214 ASSERT(!IsVMIsolateObject(class_header) || 214 ASSERT(!IsVMIsolateObject(class_header) ||
215 !IsSingletonClassId(GetVMIsolateObjectId(class_header))); 215 !IsSingletonClassId(GetVMIsolateObjectId(class_header)));
216 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) || 216 ASSERT((SerializedHeaderTag::decode(class_header) != kObjectId) ||
217 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header))); 217 !IsObjectStoreClassId(SerializedHeaderData::decode(class_header)));
218 Class& cls = Class::ZoneHandle(isolate(), Class::null()); 218 Class& cls = Class::ZoneHandle(isolate(), Class::null());
219 AddBackRef(object_id, &cls, kIsDeserialized); 219 AddBackRef(object_id, &cls, kIsDeserialized);
220 // Read the library/class information and lookup the class. 220 // Read the library/class information and lookup the class.
221 str_ ^= ReadObjectImpl(class_header); 221 str_ ^= ReadObjectImpl(class_header);
222 library_ = Library::LookupLibrary(str_); 222 library_ = Library::LookupLibrary(str_);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return ReadIndexedObject(SerializedHeaderData::decode(value)); 274 return ReadIndexedObject(SerializedHeaderData::decode(value));
275 } 275 }
276 ASSERT(SerializedHeaderTag::decode(value) == kInlined); 276 ASSERT(SerializedHeaderTag::decode(value) == kInlined);
277 intptr_t object_id = SerializedHeaderData::decode(value); 277 intptr_t object_id = SerializedHeaderData::decode(value);
278 if (object_id == kOmittedObjectId) { 278 if (object_id == kOmittedObjectId) {
279 object_id = NextAvailableObjectId(); 279 object_id = NextAvailableObjectId();
280 } 280 }
281 ASSERT(GetBackRef(object_id) == NULL); 281 ASSERT(GetBackRef(object_id) == NULL);
282 282
283 // Read the class header information and lookup the class. 283 // Read the class header information and lookup the class.
284 intptr_t class_header = ReadIntptrValue(); 284 intptr_t class_header = Read<int32_t>();
285 285
286 // Since we are only reading an object reference, If it is an instance kind 286 // Since we are only reading an object reference, If it is an instance kind
287 // then we only need to figure out the class of the object and allocate an 287 // then we only need to figure out the class of the object and allocate an
288 // instance of it. The individual fields will be read later. 288 // instance of it. The individual fields will be read later.
289 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { 289 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
290 Instance& result = Instance::ZoneHandle(isolate(), Instance::null()); 290 Instance& result = Instance::ZoneHandle(isolate(), Instance::null());
291 AddBackRef(object_id, &result, kIsNotDeserialized); 291 AddBackRef(object_id, &result, kIsNotDeserialized);
292 292
293 cls_ ^= ReadObjectImpl(); // Read class information. 293 cls_ ^= ReadObjectImpl(); // Read class information.
294 ASSERT(!cls_.IsNull()); 294 ASSERT(!cls_.IsNull());
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 return GetType(object_store(), object_id); // return type obj. 847 return GetType(object_store(), object_id); // return type obj.
848 } 848 }
849 } 849 }
850 Object* object = GetBackRef(object_id); 850 Object* object = GetBackRef(object_id);
851 return object->raw(); 851 return object->raw();
852 } 852 }
853 853
854 854
855 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) { 855 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) {
856 // Read the class header information and lookup the class. 856 // Read the class header information and lookup the class.
857 intptr_t class_header = ReadIntptrValue(); 857 intptr_t class_header = Read<int32_t>();
858 intptr_t tags = ReadTags(); 858 intptr_t tags = ReadTags();
859 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { 859 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
860 // Object is regular dart instance. 860 // Object is regular dart instance.
861 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id)); 861 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id));
862 intptr_t instance_size = 0; 862 intptr_t instance_size = 0;
863 if (result == NULL) { 863 if (result == NULL) {
864 result = &(Instance::ZoneHandle(isolate(), Instance::null())); 864 result = &(Instance::ZoneHandle(isolate(), Instance::null()));
865 AddBackRef(object_id, result, kIsDeserialized); 865 AddBackRef(object_id, result, kIsDeserialized);
866 cls_ ^= ReadObjectImpl(); 866 cls_ ^= ReadObjectImpl();
867 ASSERT(!cls_.IsNull()); 867 ASSERT(!cls_.IsNull());
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 1539
1540 // Object is regular dart instance. 1540 // Object is regular dart instance.
1541 intptr_t next_field_offset = 1541 intptr_t next_field_offset =
1542 cls->ptr()->next_field_offset_in_words_ << kWordSizeLog2; 1542 cls->ptr()->next_field_offset_in_words_ << kWordSizeLog2;
1543 ASSERT(next_field_offset > 0); 1543 ASSERT(next_field_offset > 0);
1544 1544
1545 // Write out the serialization header value for this object. 1545 // Write out the serialization header value for this object.
1546 WriteInlinedObjectHeader(object_id); 1546 WriteInlinedObjectHeader(object_id);
1547 1547
1548 // Indicate this is an instance object. 1548 // Indicate this is an instance object.
1549 WriteIntptrValue(SerializedHeaderData::encode(kInstanceObjectId)); 1549 Write<int32_t>(SerializedHeaderData::encode(kInstanceObjectId));
1550 1550
1551 // Write out the tags. 1551 // Write out the tags.
1552 WriteTags(tags); 1552 WriteTags(tags);
1553 1553
1554 // Write out the class information for this object. 1554 // Write out the class information for this object.
1555 WriteObjectImpl(cls); 1555 WriteObjectImpl(cls);
1556 1556
1557 // Write out all the fields for the object. 1557 // Write out all the fields for the object.
1558 // Instance::NextFieldOffset() returns the offset of the first field in 1558 // Instance::NextFieldOffset() returns the offset of the first field in
1559 // a Dart object. 1559 // a Dart object.
(...skipping 14 matching lines...) Expand all
1574 // Object is being referenced, add it to the forward ref list and mark 1574 // Object is being referenced, add it to the forward ref list and mark
1575 // it so that future references to this object in the snapshot will use 1575 // it so that future references to this object in the snapshot will use
1576 // this object id. Mark it as not having been serialized yet so that we 1576 // this object id. Mark it as not having been serialized yet so that we
1577 // will serialize the object when we go through the forward list. 1577 // will serialize the object when we go through the forward list.
1578 forward_list_.MarkAndAddObject(raw, kIsNotSerialized); 1578 forward_list_.MarkAndAddObject(raw, kIsNotSerialized);
1579 1579
1580 // Write out the serialization header value for this object. 1580 // Write out the serialization header value for this object.
1581 WriteInlinedObjectHeader(kOmittedObjectId); 1581 WriteInlinedObjectHeader(kOmittedObjectId);
1582 1582
1583 // Indicate this is an instance object. 1583 // Indicate this is an instance object.
1584 WriteIntptrValue(SerializedHeaderData::encode(kInstanceObjectId)); 1584 Write<int32_t>(SerializedHeaderData::encode(kInstanceObjectId));
1585 1585
1586 // Write out the class information for this object. 1586 // Write out the class information for this object.
1587 WriteObjectImpl(cls); 1587 WriteObjectImpl(cls);
1588 } 1588 }
1589 1589
1590 1590
1591 void SnapshotWriter::ThrowException(Exceptions::ExceptionType type, 1591 void SnapshotWriter::ThrowException(Exceptions::ExceptionType type,
1592 const char* msg) { 1592 const char* msg) {
1593 Isolate::Current()->object_store()->clear_sticky_error(); 1593 Isolate::Current()->object_store()->clear_sticky_error();
1594 UnmarkAll(); 1594 UnmarkAll();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 NoGCScope no_gc; 1650 NoGCScope no_gc;
1651 WriteObject(obj.raw()); 1651 WriteObject(obj.raw());
1652 UnmarkAll(); 1652 UnmarkAll();
1653 } else { 1653 } else {
1654 ThrowException(exception_type(), exception_msg()); 1654 ThrowException(exception_type(), exception_msg());
1655 } 1655 }
1656 } 1656 }
1657 1657
1658 1658
1659 } // namespace dart 1659 } // namespace dart
OLDNEW
« runtime/vm/raw_object.h ('K') | « runtime/vm/snapshot.h ('k') | runtime/vm/stack_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698