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

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

Issue 13866012: Fix issue with serializing typed array views (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 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
« no previous file with comments | « no previous file | 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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 WriteInlinedObjectHeader(object_id); 973 WriteInlinedObjectHeader(object_id);
974 974
975 // Write out the class information. 975 // Write out the class information.
976 WriteIndexedObject(kImmutableArrayCid); 976 WriteIndexedObject(kImmutableArrayCid);
977 977
978 // Write out the length field. 978 // Write out the length field.
979 Write<RawObject*>(rawarray->ptr()->length_); 979 Write<RawObject*>(rawarray->ptr()->length_);
980 980
981 return; 981 return;
982 } 982 }
983 if (RawObject::IsTypedDataViewClassId(class_id)) {
984 WriteInstanceRef(raw, cls);
985 return;
986 }
983 // Object is being referenced, add it to the forward ref list and mark 987 // Object is being referenced, add it to the forward ref list and mark
984 // it so that future references to this object in the snapshot will use 988 // it so that future references to this object in the snapshot will use
985 // this object id. Mark it as not having been serialized yet so that we 989 // this object id. Mark it as not having been serialized yet so that we
986 // will serialize the object when we go through the forward list. 990 // will serialize the object when we go through the forward list.
987 intptr_t object_id = MarkObject(raw, kIsSerialized); 991 intptr_t object_id = MarkObject(raw, kIsSerialized);
988 switch (class_id) { 992 switch (class_id) {
989 #define SNAPSHOT_WRITE(clazz) \ 993 #define SNAPSHOT_WRITE(clazz) \
990 case clazz::kClassId: { \ 994 case clazz::kClassId: { \
991 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ 995 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \
992 raw_obj->WriteTo(this, object_id, kind_); \ 996 raw_obj->WriteTo(this, object_id, kind_); \
(...skipping 14 matching lines...) Expand all
1007 #define SNAPSHOT_WRITE(clazz) \ 1011 #define SNAPSHOT_WRITE(clazz) \
1008 case kExternalTypedData##clazz##Cid: \ 1012 case kExternalTypedData##clazz##Cid: \
1009 1013
1010 CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE) { 1014 CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE) {
1011 RawExternalTypedData* raw_obj = 1015 RawExternalTypedData* raw_obj =
1012 reinterpret_cast<RawExternalTypedData*>(raw); 1016 reinterpret_cast<RawExternalTypedData*>(raw);
1013 raw_obj->WriteTo(this, object_id, kind_); 1017 raw_obj->WriteTo(this, object_id, kind_);
1014 return; 1018 return;
1015 } 1019 }
1016 #undef SNAPSHOT_WRITE 1020 #undef SNAPSHOT_WRITE
1017 #define SNAPSHOT_WRITE(clazz) \
1018 case kTypedData##clazz##ViewCid: \
1019
1020 CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE)
1021 case kByteDataViewCid: {
1022 WriteInstanceRef(raw, cls);
1023 return;
1024 }
1025 #undef SNAPSHOT_WRITE
1026 default: break; 1021 default: break;
1027 } 1022 }
1028 UNREACHABLE(); 1023 UNREACHABLE();
1029 } 1024 }
1030 1025
1031 1026
1032 void FullSnapshotWriter::WriteFullSnapshot() { 1027 void FullSnapshotWriter::WriteFullSnapshot() {
1033 Isolate* isolate = Isolate::Current(); 1028 Isolate* isolate = Isolate::Current();
1034 ASSERT(isolate != NULL); 1029 ASSERT(isolate != NULL);
1035 ObjectStore* object_store = isolate->object_store(); 1030 ObjectStore* object_store = isolate->object_store();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1076
1082 1077
1083 intptr_t SnapshotWriter::MarkObject(RawObject* raw, SerializeState state) { 1078 intptr_t SnapshotWriter::MarkObject(RawObject* raw, SerializeState state) {
1084 NoGCScope no_gc; 1079 NoGCScope no_gc;
1085 intptr_t object_id = forward_list_.length() + kMaxPredefinedObjectIds; 1080 intptr_t object_id = forward_list_.length() + kMaxPredefinedObjectIds;
1086 ASSERT(object_id <= kMaxObjectId); 1081 ASSERT(object_id <= kMaxObjectId);
1087 uword value = 0; 1082 uword value = 0;
1088 value = SerializedHeaderTag::update(kObjectId, value); 1083 value = SerializedHeaderTag::update(kObjectId, value);
1089 value = SerializedHeaderData::update(object_id, value); 1084 value = SerializedHeaderData::update(object_id, value);
1090 uword tags = raw->ptr()->tags_; 1085 uword tags = raw->ptr()->tags_;
1086 ASSERT(SerializedHeaderTag::decode(tags) != kObjectId);
1091 raw->ptr()->tags_ = value; 1087 raw->ptr()->tags_ = value;
1092 ForwardObjectNode* node = new ForwardObjectNode(raw, tags, state); 1088 ForwardObjectNode* node = new ForwardObjectNode(raw, tags, state);
1093 ASSERT(node != NULL); 1089 ASSERT(node != NULL);
1094 forward_list_.Add(node); 1090 forward_list_.Add(node);
1095 return object_id; 1091 return object_id;
1096 } 1092 }
1097 1093
1098 1094
1099 void SnapshotWriter::UnmarkAll() { 1095 void SnapshotWriter::UnmarkAll() {
1100 NoGCScope no_gc; 1096 NoGCScope no_gc;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 UnmarkAll(); 1462 UnmarkAll();
1467 isolate->set_long_jump_base(base); 1463 isolate->set_long_jump_base(base);
1468 } else { 1464 } else {
1469 isolate->set_long_jump_base(base); 1465 isolate->set_long_jump_base(base);
1470 ThrowException(exception_type(), exception_msg()); 1466 ThrowException(exception_type(), exception_msg());
1471 } 1467 }
1472 } 1468 }
1473 1469
1474 1470
1475 } // namespace dart 1471 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698