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

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

Issue 11367044: Merged String subclasses into String. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 12 matching lines...) Expand all
23 static bool IsSingletonClassId(intptr_t class_id) { 23 static bool IsSingletonClassId(intptr_t class_id) {
24 // Check if this is a singleton object class which is shared by all isolates. 24 // Check if this is a singleton object class which is shared by all isolates.
25 return ((class_id >= kClassCid && class_id <= kUnwindErrorCid) || 25 return ((class_id >= kClassCid && class_id <= kUnwindErrorCid) ||
26 (class_id >= kNullCid && class_id <= kVoidCid)); 26 (class_id >= kNullCid && class_id <= kVoidCid));
27 } 27 }
28 28
29 29
30 static bool IsObjectStoreClassId(intptr_t class_id) { 30 static bool IsObjectStoreClassId(intptr_t class_id) {
31 // Check if this is a class which is stored in the object store. 31 // Check if this is a class which is stored in the object store.
32 return (class_id == kObjectCid || 32 return (class_id == kObjectCid ||
33 (class_id >= kInstanceCid && class_id <= kWeakPropertyCid)); 33 (class_id >= kInstanceCid && class_id <= kWeakPropertyCid) ||
34 RawObject::IsStringClassId(class_id));
34 } 35 }
35 36
36 37
37 static bool IsObjectStoreTypeId(intptr_t index) { 38 static bool IsObjectStoreTypeId(intptr_t index) {
38 // Check if this is a type which is stored in the object store. 39 // Check if this is a type which is stored in the object store.
39 return (index >= kObjectType && index <= kListInterface); 40 return (index >= kObjectType && index <= kListInterface);
40 } 41 }
41 42
42 43
43 static intptr_t ClassIdFromObjectId(intptr_t object_id) { 44 static intptr_t ClassIdFromObjectId(intptr_t object_id) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 286
286 // For all other internal VM classes we read the object inline. 287 // For all other internal VM classes we read the object inline.
287 intptr_t tags = ReadIntptrValue(); 288 intptr_t tags = ReadIntptrValue();
288 switch (class_id) { 289 switch (class_id) {
289 #define SNAPSHOT_READ(clazz) \ 290 #define SNAPSHOT_READ(clazz) \
290 case clazz::kClassId: { \ 291 case clazz::kClassId: { \
291 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 292 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
292 break; \ 293 break; \
293 } 294 }
294 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 295 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
296 CLASS_LIST_STRING_SUBTYPES(SNAPSHOT_READ)
295 #undef SNAPSHOT_READ 297 #undef SNAPSHOT_READ
296 default: UNREACHABLE(); break; 298 default: UNREACHABLE(); break;
297 } 299 }
298 if (kind_ == Snapshot::kFull) { 300 if (kind_ == Snapshot::kFull) {
299 obj_.SetCreatedFromSnapshot(); 301 obj_.SetCreatedFromSnapshot();
300 } 302 }
301 return obj_.raw(); 303 return obj_.raw();
302 } 304 }
303 305
304 306
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 AllocateUninitialized(cls_, Context::InstanceSize(num_variables))); 426 AllocateUninitialized(cls_, Context::InstanceSize(num_variables)));
425 obj->ptr()->num_variables_ = num_variables; 427 obj->ptr()->num_variables_ = num_variables;
426 return obj; 428 return obj;
427 } 429 }
428 430
429 431
430 RawClass* SnapshotReader::NewClass(intptr_t class_id) { 432 RawClass* SnapshotReader::NewClass(intptr_t class_id) {
431 ASSERT(kind_ == Snapshot::kFull); 433 ASSERT(kind_ == Snapshot::kFull);
432 ASSERT(isolate()->no_gc_scope_depth() != 0); 434 ASSERT(isolate()->no_gc_scope_depth() != 0);
433 if (class_id < kNumPredefinedCids) { 435 if (class_id < kNumPredefinedCids) {
434 ASSERT((class_id >= kInstanceCid) && (class_id <= kDartFunctionCid)); 436 ASSERT(((class_id >= kInstanceCid) && (class_id <= kDartFunctionCid)) ||
437 RawObject::IsStringClassId(class_id));
435 return isolate()->class_table()->At(class_id); 438 return isolate()->class_table()->At(class_id);
436 } 439 }
437 cls_ = Object::class_class(); 440 cls_ = Object::class_class();
438 RawClass* obj = reinterpret_cast<RawClass*>( 441 RawClass* obj = reinterpret_cast<RawClass*>(
439 AllocateUninitialized(cls_, Class::InstanceSize())); 442 AllocateUninitialized(cls_, Class::InstanceSize()));
440 Instance fake; 443 Instance fake;
441 obj->ptr()->handle_vtable_ = fake.vtable(); 444 obj->ptr()->handle_vtable_ = fake.vtable();
442 cls_ = obj; 445 cls_ = obj;
443 cls_.set_id(kIllegalCid); 446 cls_.set_id(kIllegalCid);
444 isolate()->class_table()->Register(cls_); 447 isolate()->class_table()->Register(cls_);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 ASSERT((class_header & kSmiTagMask) != 0); 707 ASSERT((class_header & kSmiTagMask) != 0);
705 cls_ = LookupInternalClass(class_header); 708 cls_ = LookupInternalClass(class_header);
706 ASSERT(!cls_.IsNull()); 709 ASSERT(!cls_.IsNull());
707 switch (cls_.id()) { 710 switch (cls_.id()) {
708 #define SNAPSHOT_READ(clazz) \ 711 #define SNAPSHOT_READ(clazz) \
709 case clazz::kClassId: { \ 712 case clazz::kClassId: { \
710 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \ 713 obj_ = clazz::ReadFrom(this, object_id, tags, kind_); \
711 break; \ 714 break; \
712 } 715 }
713 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ) 716 CLASS_LIST_NO_OBJECT(SNAPSHOT_READ)
717 CLASS_LIST_STRING_SUBTYPES(SNAPSHOT_READ)
714 #undef SNAPSHOT_READ 718 #undef SNAPSHOT_READ
715 default: UNREACHABLE(); break; 719 default: UNREACHABLE(); break;
716 } 720 }
717 if (kind_ == Snapshot::kFull) { 721 if (kind_ == Snapshot::kFull) {
718 obj_.SetCreatedFromSnapshot(); 722 obj_.SetCreatedFromSnapshot();
719 } 723 }
720 return obj_.raw(); 724 return obj_.raw();
721 } 725 }
722 726
723 727
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 intptr_t object_id = MarkObject(raw, kIsSerialized); 867 intptr_t object_id = MarkObject(raw, kIsSerialized);
864 switch (class_id) { 868 switch (class_id) {
865 #define SNAPSHOT_WRITE(clazz) \ 869 #define SNAPSHOT_WRITE(clazz) \
866 case clazz::kClassId: { \ 870 case clazz::kClassId: { \
867 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ 871 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \
868 raw_obj->WriteTo(this, object_id, kind_); \ 872 raw_obj->WriteTo(this, object_id, kind_); \
869 return; \ 873 return; \
870 } \ 874 } \
871 875
872 CLASS_LIST_NO_OBJECT(SNAPSHOT_WRITE) 876 CLASS_LIST_NO_OBJECT(SNAPSHOT_WRITE)
877 CLASS_LIST_STRING_SUBTYPES(SNAPSHOT_WRITE)
873 #undef SNAPSHOT_WRITE 878 #undef SNAPSHOT_WRITE
874 default: break; 879 default: break;
875 } 880 }
876 UNREACHABLE(); 881 UNREACHABLE();
877 } 882 }
878 883
879 884
880 void FullSnapshotWriter::WriteFullSnapshot() { 885 void FullSnapshotWriter::WriteFullSnapshot() {
881 Isolate* isolate = Isolate::Current(); 886 Isolate* isolate = Isolate::Current();
882 ASSERT(isolate != NULL); 887 ASSERT(isolate != NULL);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 } 1065 }
1061 switch (class_id) { 1066 switch (class_id) {
1062 #define SNAPSHOT_WRITE(clazz) \ 1067 #define SNAPSHOT_WRITE(clazz) \
1063 case clazz::kClassId: { \ 1068 case clazz::kClassId: { \
1064 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ 1069 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \
1065 raw_obj->WriteTo(this, object_id, kind_); \ 1070 raw_obj->WriteTo(this, object_id, kind_); \
1066 return; \ 1071 return; \
1067 } \ 1072 } \
1068 1073
1069 CLASS_LIST_NO_OBJECT(SNAPSHOT_WRITE) 1074 CLASS_LIST_NO_OBJECT(SNAPSHOT_WRITE)
1075 CLASS_LIST_STRING_SUBTYPES(SNAPSHOT_WRITE)
1070 #undef SNAPSHOT_WRITE 1076 #undef SNAPSHOT_WRITE
1071 default: break; 1077 default: break;
1072 } 1078 }
1073 UNREACHABLE(); 1079 UNREACHABLE();
1074 } 1080 }
1075 1081
1076 1082
1077 void SnapshotWriter::WriteForwardedObjects() { 1083 void SnapshotWriter::WriteForwardedObjects() {
1078 // Write out all objects that were added to the forward list and have 1084 // Write out all objects that were added to the forward list and have
1079 // not been serialized yet. These would typically be fields of instance 1085 // not been serialized yet. These would typically be fields of instance
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1176
1171 1177
1172 void MessageWriter::WriteMessage(const Object& obj) { 1178 void MessageWriter::WriteMessage(const Object& obj) {
1173 ASSERT(kind() == Snapshot::kMessage); 1179 ASSERT(kind() == Snapshot::kMessage);
1174 WriteObject(obj.raw()); 1180 WriteObject(obj.raw());
1175 UnmarkAll(); 1181 UnmarkAll();
1176 } 1182 }
1177 1183
1178 1184
1179 } // namespace dart 1185 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698