OLD | NEW |
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/dart_api_message.h" | 5 #include "vm/dart_api_message.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/snapshot_ids.h" | 7 #include "vm/snapshot_ids.h" |
8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // updated (currently type_arguments is leaked). | 199 // updated (currently type_arguments is leaked). |
200 Dart_CObject* type_arguments = ReadObjectImpl(); | 200 Dart_CObject* type_arguments = ReadObjectImpl(); |
201 if (type_arguments != &type_arguments_marker && | 201 if (type_arguments != &type_arguments_marker && |
202 type_arguments->type != Dart_CObject::kNull) { | 202 type_arguments->type != Dart_CObject::kNull) { |
203 return AllocateDartCObjectUnsupported(); | 203 return AllocateDartCObjectUnsupported(); |
204 } | 204 } |
205 for (int i = 0; i < len; i++) { | 205 for (int i = 0; i < len; i++) { |
206 value->value.as_array.values[i] = ReadObjectRef(); | 206 value->value.as_array.values[i] = ReadObjectRef(); |
207 } | 207 } |
208 return value; | 208 return value; |
| 209 } else if (class_id == kGrowableObjectArrayCid) { |
| 210 // A GrowableObjectArray is serialized as its length followed by its backing |
| 211 // store. The backing store is an array with a length which might be longer |
| 212 // than the length of the GrowableObjectArray. |
| 213 intptr_t len = ReadSmiValue(); |
| 214 Dart_CObject* value = GetBackRef(object_id); |
| 215 ASSERT(value == NULL); |
| 216 // Allocate an empty array for the GrowableObjectArray which will be updated |
| 217 // to point to the content when the backing store has been deserialized. |
| 218 value = AllocateDartCObjectArray(0); |
| 219 AddBackRef(object_id, value, kIsDeserialized); |
| 220 // Read the content of the GrowableObjectArray. |
| 221 Dart_CObject* content = ReadObjectImpl(); |
| 222 ASSERT(content->type == Dart_CObject::kArray); |
| 223 // Make the empty array allocated point to the backing store content. |
| 224 value->value.as_array.length = len; |
| 225 value->value.as_array.values = content->value.as_array.values; |
| 226 return value; |
209 } | 227 } |
210 | 228 |
211 return ReadInternalVMObject(class_id, object_id); | 229 return ReadInternalVMObject(class_id, object_id); |
212 } | 230 } |
213 | 231 |
214 | 232 |
215 Dart_CObject* ApiMessageReader::ReadVMSymbol(intptr_t object_id) { | 233 Dart_CObject* ApiMessageReader::ReadVMSymbol(intptr_t object_id) { |
216 if (Symbols::IsVMSymbolId(object_id)) { | 234 if (Symbols::IsVMSymbolId(object_id)) { |
217 RawOneByteString* str = | 235 RawOneByteString* str = |
218 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id)); | 236 reinterpret_cast<RawOneByteString*>(Symbols::GetVMSymbol(object_id)); |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 // Write out all objects that were added to the forward list and have | 794 // Write out all objects that were added to the forward list and have |
777 // not been serialized yet. These would typically be fields of arrays. | 795 // not been serialized yet. These would typically be fields of arrays. |
778 // NOTE: The forward list might grow as we process the list. | 796 // NOTE: The forward list might grow as we process the list. |
779 for (intptr_t i = 0; i < forward_id_; i++) { | 797 for (intptr_t i = 0; i < forward_id_; i++) { |
780 WriteForwardedCObject(forward_list_[i]); | 798 WriteForwardedCObject(forward_list_[i]); |
781 } | 799 } |
782 UnmarkAllCObjects(object); | 800 UnmarkAllCObjects(object); |
783 } | 801 } |
784 | 802 |
785 } // namespace dart | 803 } // namespace dart |
OLD | NEW |