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

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

Issue 349293002: Omits size bits when writing RawObject tags to a snapshot. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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/snapshot.h ('k') | tests/standalone/issue14236_test.dart » ('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/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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 Array& array = Array::ZoneHandle( 295 Array& array = Array::ZoneHandle(
296 isolate(), 296 isolate(),
297 (kind_ == Snapshot::kFull) ? 297 (kind_ == Snapshot::kFull) ?
298 NewImmutableArray(len) : ImmutableArray::New(len, HEAP_SPACE(kind_))); 298 NewImmutableArray(len) : ImmutableArray::New(len, HEAP_SPACE(kind_)));
299 AddBackRef(object_id, &array, kIsNotDeserialized); 299 AddBackRef(object_id, &array, kIsNotDeserialized);
300 300
301 return array.raw(); 301 return array.raw();
302 } 302 }
303 303
304 // For all other internal VM classes we read the object inline. 304 // For all other internal VM classes we read the object inline.
305 intptr_t tags = ReadIntptrValue(); 305 intptr_t tags = ReadTags();
306 switch (class_id) { 306 switch (class_id) {
307 #define SNAPSHOT_READ(clazz) \ 307 #define SNAPSHOT_READ(clazz) \
308 case clazz::kClassId: { \ 308 case clazz::kClassId: { \
309 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 309 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
310 break; \ 310 break; \
311 } 311 }
312 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 312 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
313 #undef SNAPSHOT_READ 313 #undef SNAPSHOT_READ
314 #define SNAPSHOT_READ(clazz) \ 314 #define SNAPSHOT_READ(clazz) \
315 case kTypedData##clazz##Cid: \ 315 case kTypedData##clazz##Cid: \
316 316
317 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 317 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
318 tags = RawObject::ClassIdTag::update(class_id, tags);
318 obj_ = TypedData::ReadFrom(this, object_id, tags, kind_); 319 obj_ = TypedData::ReadFrom(this, object_id, tags, kind_);
319 break; 320 break;
320 } 321 }
321 #undef SNAPSHOT_READ 322 #undef SNAPSHOT_READ
322 #define SNAPSHOT_READ(clazz) \ 323 #define SNAPSHOT_READ(clazz) \
323 case kExternalTypedData##clazz##Cid: \ 324 case kExternalTypedData##clazz##Cid: \
324 325
325 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 326 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
327 tags = RawObject::ClassIdTag::update(class_id, tags);
326 obj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); 328 obj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_);
327 break; 329 break;
328 } 330 }
329 #undef SNAPSHOT_READ 331 #undef SNAPSHOT_READ
330 default: UNREACHABLE(); break; 332 default: UNREACHABLE(); break;
331 } 333 }
332 if (kind_ == Snapshot::kFull) { 334 if (kind_ == Snapshot::kFull) {
333 obj_.SetCreatedFromSnapshot(); 335 obj_.SetCreatedFromSnapshot();
334 } 336 }
335 return obj_.raw(); 337 return obj_.raw();
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 } 807 }
806 } 808 }
807 Object* object = GetBackRef(object_id); 809 Object* object = GetBackRef(object_id);
808 return object->raw(); 810 return object->raw();
809 } 811 }
810 812
811 813
812 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) { 814 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id) {
813 // Read the class header information and lookup the class. 815 // Read the class header information and lookup the class.
814 intptr_t class_header = ReadIntptrValue(); 816 intptr_t class_header = ReadIntptrValue();
815 intptr_t tags = ReadIntptrValue(); 817 intptr_t tags = ReadTags();
816 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { 818 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) {
817 // Object is regular dart instance. 819 // Object is regular dart instance.
818 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id)); 820 Instance* result = reinterpret_cast<Instance*>(GetBackRef(object_id));
819 intptr_t instance_size = 0; 821 intptr_t instance_size = 0;
820 if (result == NULL) { 822 if (result == NULL) {
821 result = &(Instance::ZoneHandle(isolate(), Instance::null())); 823 result = &(Instance::ZoneHandle(isolate(), Instance::null()));
822 AddBackRef(object_id, result, kIsDeserialized); 824 AddBackRef(object_id, result, kIsDeserialized);
823 cls_ ^= ReadObjectImpl(); 825 cls_ ^= ReadObjectImpl();
824 ASSERT(!cls_.IsNull()); 826 ASSERT(!cls_.IsNull());
825 instance_size = cls_.instance_size(); 827 instance_size = cls_.instance_size();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 case clazz::kClassId: { \ 887 case clazz::kClassId: { \
886 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 888 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
887 break; \ 889 break; \
888 } 890 }
889 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 891 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
890 #undef SNAPSHOT_READ 892 #undef SNAPSHOT_READ
891 #define SNAPSHOT_READ(clazz) \ 893 #define SNAPSHOT_READ(clazz) \
892 case kTypedData##clazz##Cid: \ 894 case kTypedData##clazz##Cid: \
893 895
894 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 896 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
897 tags = RawObject::ClassIdTag::update(cls_.id(), tags);
895 obj_ = TypedData::ReadFrom(this, object_id, tags, kind_); 898 obj_ = TypedData::ReadFrom(this, object_id, tags, kind_);
896 break; 899 break;
897 } 900 }
898 #undef SNAPSHOT_READ 901 #undef SNAPSHOT_READ
899 #define SNAPSHOT_READ(clazz) \ 902 #define SNAPSHOT_READ(clazz) \
900 case kExternalTypedData##clazz##Cid: \ 903 case kExternalTypedData##clazz##Cid: \
901 904
902 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 905 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
906 tags = RawObject::ClassIdTag::update(cls_.id(), tags);
903 obj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); 907 obj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_);
904 break; 908 break;
905 } 909 }
906 #undef SNAPSHOT_READ 910 #undef SNAPSHOT_READ
907 default: UNREACHABLE(); break; 911 default: UNREACHABLE(); break;
908 } 912 }
909 if (kind_ == Snapshot::kFull) { 913 if (kind_ == Snapshot::kFull) {
910 obj_.SetCreatedFromSnapshot(); 914 obj_.SetCreatedFromSnapshot();
911 } 915 }
912 return obj_.raw(); 916 return obj_.raw();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1385
1382 1386
1383 void SnapshotWriter::WriteClassId(RawClass* cls) { 1387 void SnapshotWriter::WriteClassId(RawClass* cls) {
1384 ASSERT(kind_ != Snapshot::kFull); 1388 ASSERT(kind_ != Snapshot::kFull);
1385 int class_id = cls->ptr()->id_; 1389 int class_id = cls->ptr()->id_;
1386 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id)); 1390 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id));
1387 // TODO(5411462): Should restrict this to only core-lib classes in this 1391 // TODO(5411462): Should restrict this to only core-lib classes in this
1388 // case. 1392 // case.
1389 // Write out the class and tags information. 1393 // Write out the class and tags information.
1390 WriteVMIsolateObject(kClassCid); 1394 WriteVMIsolateObject(kClassCid);
1391 WriteIntptrValue(GetObjectTags(cls)); 1395 WriteTags(GetObjectTags(cls));
1392 1396
1393 // Write out the library url and class name. 1397 // Write out the library url and class name.
1394 RawLibrary* library = cls->ptr()->library_; 1398 RawLibrary* library = cls->ptr()->library_;
1395 ASSERT(library != Library::null()); 1399 ASSERT(library != Library::null());
1396 WriteObjectImpl(library->ptr()->url_); 1400 WriteObjectImpl(library->ptr()->url_);
1397 WriteObjectImpl(cls->ptr()->name_); 1401 WriteObjectImpl(cls->ptr()->name_);
1398 } 1402 }
1399 1403
1400 1404
1401 void SnapshotWriter::ArrayWriteTo(intptr_t object_id, 1405 void SnapshotWriter::ArrayWriteTo(intptr_t object_id,
1402 intptr_t array_kind, 1406 intptr_t array_kind,
1403 intptr_t tags, 1407 intptr_t tags,
1404 RawSmi* length, 1408 RawSmi* length,
1405 RawTypeArguments* type_arguments, 1409 RawTypeArguments* type_arguments,
1406 RawObject* data[]) { 1410 RawObject* data[]) {
1407 intptr_t len = Smi::Value(length); 1411 intptr_t len = Smi::Value(length);
1408 1412
1409 // Write out the serialization header value for this object. 1413 // Write out the serialization header value for this object.
1410 WriteInlinedObjectHeader(object_id); 1414 WriteInlinedObjectHeader(object_id);
1411 1415
1412 // Write out the class and tags information. 1416 // Write out the class and tags information.
1413 WriteIndexedObject(array_kind); 1417 WriteIndexedObject(array_kind);
1414 WriteIntptrValue(tags); 1418 WriteTags(tags);
1415 1419
1416 // Write out the length field. 1420 // Write out the length field.
1417 Write<RawObject*>(length); 1421 Write<RawObject*>(length);
1418 1422
1419 // Write out the type arguments. 1423 // Write out the type arguments.
1420 WriteObjectImpl(type_arguments); 1424 WriteObjectImpl(type_arguments);
1421 1425
1422 // Write out the individual object ids. 1426 // Write out the individual object ids.
1423 for (intptr_t i = 0; i < len; i++) { 1427 for (intptr_t i = 0; i < len; i++) {
1424 WriteObjectRef(data[i]); 1428 WriteObjectRef(data[i]);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 cls->ptr()->next_field_offset_in_words_ << kWordSizeLog2; 1468 cls->ptr()->next_field_offset_in_words_ << kWordSizeLog2;
1465 ASSERT(next_field_offset > 0); 1469 ASSERT(next_field_offset > 0);
1466 1470
1467 // Write out the serialization header value for this object. 1471 // Write out the serialization header value for this object.
1468 WriteInlinedObjectHeader(object_id); 1472 WriteInlinedObjectHeader(object_id);
1469 1473
1470 // Indicate this is an instance object. 1474 // Indicate this is an instance object.
1471 WriteIntptrValue(SerializedHeaderData::encode(kInstanceObjectId)); 1475 WriteIntptrValue(SerializedHeaderData::encode(kInstanceObjectId));
1472 1476
1473 // Write out the tags. 1477 // Write out the tags.
1474 WriteIntptrValue(tags); 1478 WriteTags(tags);
1475 1479
1476 // Write out the class information for this object. 1480 // Write out the class information for this object.
1477 WriteObjectImpl(cls); 1481 WriteObjectImpl(cls);
1478 1482
1479 // Write out all the fields for the object. 1483 // Write out all the fields for the object.
1480 // Instance::NextFieldOffset() returns the offset of the first field in 1484 // Instance::NextFieldOffset() returns the offset of the first field in
1481 // a Dart object. 1485 // a Dart object.
1482 intptr_t offset = Instance::NextFieldOffset(); 1486 intptr_t offset = Instance::NextFieldOffset();
1483 while (offset < next_field_offset) { 1487 while (offset < next_field_offset) {
1484 WriteObjectRef(*reinterpret_cast<RawObject**>( 1488 WriteObjectRef(*reinterpret_cast<RawObject**>(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 NoGCScope no_gc; 1576 NoGCScope no_gc;
1573 WriteObject(obj.raw()); 1577 WriteObject(obj.raw());
1574 UnmarkAll(); 1578 UnmarkAll();
1575 } else { 1579 } else {
1576 ThrowException(exception_type(), exception_msg()); 1580 ThrowException(exception_type(), exception_msg());
1577 } 1581 }
1578 } 1582 }
1579 1583
1580 1584
1581 } // namespace dart 1585 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | tests/standalone/issue14236_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698