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

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

Issue 10916207: Support receiving GrowableObjectArray on native ports (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review commetns Created 8 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
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/snapshot_test.cc » ('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/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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698