Chromium Code Reviews| 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/object_store.h" | 7 #include "vm/object_store.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 USE(tags); | 184 USE(tags); |
| 185 intptr_t class_id; | 185 intptr_t class_id; |
| 186 | 186 |
| 187 // Reading of regular dart instances is not supported. | 187 // Reading of regular dart instances is not supported. |
| 188 if (SerializedHeaderData::decode(class_header) == kInstanceId) { | 188 if (SerializedHeaderData::decode(class_header) == kInstanceId) { |
| 189 return AllocateDartCObjectUnsupported(); | 189 return AllocateDartCObjectUnsupported(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 ASSERT((class_header & kSmiTagMask) != 0); | 192 ASSERT((class_header & kSmiTagMask) != 0); |
| 193 class_id = LookupInternalClass(class_header); | 193 class_id = LookupInternalClass(class_header); |
| 194 if (class_id == ObjectStore::kArrayClass || | 194 if (class_id == kArray || class_id == kImmutableArray) { |
|
regis
2012/07/24 13:49:25
Not your cl, but parentheses are missing here and
siva
2012/08/13 20:38:25
Done.
| |
| 195 class_id == ObjectStore::kImmutableArrayClass) { | |
| 196 intptr_t len = ReadSmiValue(); | 195 intptr_t len = ReadSmiValue(); |
| 197 Dart_CObject* value = GetBackRef(object_id); | 196 Dart_CObject* value = GetBackRef(object_id); |
| 198 if (value == NULL) { | 197 if (value == NULL) { |
| 199 value = AllocateDartCObjectArray(len); | 198 value = AllocateDartCObjectArray(len); |
| 200 AddBackRef(object_id, value, kIsDeserialized); | 199 AddBackRef(object_id, value, kIsDeserialized); |
| 201 } | 200 } |
| 202 // Skip type arguments. | 201 // Skip type arguments. |
| 203 // TODO(sjesse): Remove this when message serialization format is | 202 // TODO(sjesse): Remove this when message serialization format is |
| 204 // updated (currently type_arguments is leaked). | 203 // updated (currently type_arguments is leaked). |
| 205 Dart_CObject* type_arguments = ReadObjectImpl(); | 204 Dart_CObject* type_arguments = ReadObjectImpl(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 // Read the class header information and lookup the class. | 237 // Read the class header information and lookup the class. |
| 239 intptr_t class_header = ReadIntptrValue(); | 238 intptr_t class_header = ReadIntptrValue(); |
| 240 | 239 |
| 241 // Reading of regular dart instances is not supported. | 240 // Reading of regular dart instances is not supported. |
| 242 if (SerializedHeaderData::decode(class_header) == kInstanceId) { | 241 if (SerializedHeaderData::decode(class_header) == kInstanceId) { |
| 243 return AllocateDartCObjectUnsupported(); | 242 return AllocateDartCObjectUnsupported(); |
| 244 } | 243 } |
| 245 ASSERT((class_header & kSmiTagMask) != 0); | 244 ASSERT((class_header & kSmiTagMask) != 0); |
| 246 intptr_t object_id = header_value; | 245 intptr_t object_id = header_value; |
| 247 intptr_t class_id = LookupInternalClass(class_header); | 246 intptr_t class_id = LookupInternalClass(class_header); |
| 248 if (class_id == ObjectStore::kArrayClass || | 247 if (class_id == kArray || class_id == kImmutableArray) { |
| 249 class_id == ObjectStore::kImmutableArrayClass) { | |
| 250 ASSERT(GetBackRef(object_id) == NULL); | 248 ASSERT(GetBackRef(object_id) == NULL); |
| 251 intptr_t len = ReadSmiValue(); | 249 intptr_t len = ReadSmiValue(); |
| 252 Dart_CObject* value = AllocateDartCObjectArray(len); | 250 Dart_CObject* value = AllocateDartCObjectArray(len); |
| 253 AddBackRef(object_id, value, kIsNotDeserialized); | 251 AddBackRef(object_id, value, kIsNotDeserialized); |
| 254 return value; | 252 return value; |
| 255 } | 253 } |
| 256 intptr_t tags = ReadIntptrValue(); | 254 intptr_t tags = ReadIntptrValue(); |
| 257 USE(tags); | 255 USE(tags); |
| 258 | 256 |
| 259 return ReadInternalVMObject(class_id, object_id); | 257 return ReadInternalVMObject(class_id, object_id); |
| 260 } | 258 } |
| 261 | 259 |
| 262 | 260 |
| 263 Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, | 261 Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, |
| 264 intptr_t object_id) { | 262 intptr_t object_id) { |
| 265 switch (class_id) { | 263 switch (class_id) { |
| 266 case Object::kClassClass: { | 264 case kClass: { |
| 267 return AllocateDartCObjectUnsupported(); | 265 return AllocateDartCObjectUnsupported(); |
| 268 } | 266 } |
| 269 case Object::kTypeArgumentsClass: { | 267 case kTypeArguments: { |
| 270 // TODO(sjesse): Remove this when message serialization format is | 268 // TODO(sjesse): Remove this when message serialization format is |
| 271 // updated (currently length is leaked). | 269 // updated (currently length is leaked). |
| 272 Dart_CObject* value = &type_arguments_marker; | 270 Dart_CObject* value = &type_arguments_marker; |
| 273 AddBackRef(object_id, value, kIsDeserialized); | 271 AddBackRef(object_id, value, kIsDeserialized); |
| 274 Dart_CObject* length = ReadObjectImpl(); | 272 Dart_CObject* length = ReadObjectImpl(); |
| 275 ASSERT(length->type == Dart_CObject::kInt32); | 273 ASSERT(length->type == Dart_CObject::kInt32); |
| 276 for (int i = 0; i < length->value.as_int32; i++) { | 274 for (int i = 0; i < length->value.as_int32; i++) { |
| 277 Dart_CObject* type = ReadObjectImpl(); | 275 Dart_CObject* type = ReadObjectImpl(); |
| 278 if (type != &dynamic_type_marker) { | 276 if (type != &dynamic_type_marker) { |
| 279 return AllocateDartCObjectUnsupported(); | 277 return AllocateDartCObjectUnsupported(); |
| 280 } | 278 } |
| 281 } | 279 } |
| 282 return value; | 280 return value; |
| 283 } | 281 } |
| 284 case Object::kTypeParameterClass: { | 282 case kTypeParameter: { |
| 285 // TODO(sgjesse): Fix this workaround ignoring the type parameter. | 283 // TODO(sgjesse): Fix this workaround ignoring the type parameter. |
| 286 Dart_CObject* value = &dynamic_type_marker; | 284 Dart_CObject* value = &dynamic_type_marker; |
| 287 AddBackRef(object_id, value, kIsDeserialized); | 285 AddBackRef(object_id, value, kIsDeserialized); |
| 288 intptr_t index = ReadIntptrValue(); | 286 intptr_t index = ReadIntptrValue(); |
| 289 USE(index); | 287 USE(index); |
| 290 intptr_t token_index = ReadIntptrValue(); | 288 intptr_t token_index = ReadIntptrValue(); |
| 291 USE(token_index); | 289 USE(token_index); |
| 292 int8_t type_state = Read<int8_t>(); | 290 int8_t type_state = Read<int8_t>(); |
| 293 USE(type_state); | 291 USE(type_state); |
| 294 Dart_CObject* parameterized_class = ReadObjectImpl(); | 292 Dart_CObject* parameterized_class = ReadObjectImpl(); |
| 295 // The type parameter is finalized, therefore parameterized_class is null. | 293 // The type parameter is finalized, therefore parameterized_class is null. |
| 296 ASSERT(parameterized_class->type == Dart_CObject::kNull); | 294 ASSERT(parameterized_class->type == Dart_CObject::kNull); |
| 297 Dart_CObject* name = ReadObjectImpl(); | 295 Dart_CObject* name = ReadObjectImpl(); |
| 298 ASSERT(name->type == Dart_CObject::kString); | 296 ASSERT(name->type == Dart_CObject::kString); |
| 299 return value; | 297 return value; |
| 300 } | 298 } |
| 301 case ObjectStore::kMintClass: { | 299 case kMint: { |
| 302 int64_t value = Read<int64_t>(); | 300 int64_t value = Read<int64_t>(); |
| 303 Dart_CObject* object; | 301 Dart_CObject* object; |
| 304 if (kMinInt32 <= value && value <= kMaxInt32) { | 302 if (kMinInt32 <= value && value <= kMaxInt32) { |
| 305 object = AllocateDartCObjectInt32(value); | 303 object = AllocateDartCObjectInt32(value); |
| 306 } else { | 304 } else { |
| 307 object = AllocateDartCObjectInt64(value); | 305 object = AllocateDartCObjectInt64(value); |
| 308 } | 306 } |
| 309 AddBackRef(object_id, object, kIsDeserialized); | 307 AddBackRef(object_id, object, kIsDeserialized); |
| 310 return object; | 308 return object; |
| 311 } | 309 } |
| 312 case ObjectStore::kBigintClass: { | 310 case kBigint: { |
| 313 // Read in the hex string representation of the bigint. | 311 // Read in the hex string representation of the bigint. |
| 314 intptr_t len = ReadIntptrValue(); | 312 intptr_t len = ReadIntptrValue(); |
| 315 Dart_CObject* object = AllocateDartCObjectBigint(len); | 313 Dart_CObject* object = AllocateDartCObjectBigint(len); |
| 316 AddBackRef(object_id, object, kIsDeserialized); | 314 AddBackRef(object_id, object, kIsDeserialized); |
| 317 char* p = object->value.as_bigint; | 315 char* p = object->value.as_bigint; |
| 318 for (intptr_t i = 0; i < len; i++) { | 316 for (intptr_t i = 0; i < len; i++) { |
| 319 p[i] = Read<uint8_t>(); | 317 p[i] = Read<uint8_t>(); |
| 320 } | 318 } |
| 321 p[len] = '\0'; | 319 p[len] = '\0'; |
| 322 return object; | 320 return object; |
| 323 } | 321 } |
| 324 case ObjectStore::kDoubleClass: { | 322 case kDouble: { |
| 325 // Read the double value for the object. | 323 // Read the double value for the object. |
| 326 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); | 324 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); |
| 327 AddBackRef(object_id, object, kIsDeserialized); | 325 AddBackRef(object_id, object, kIsDeserialized); |
| 328 return object; | 326 return object; |
| 329 } | 327 } |
| 330 case ObjectStore::kOneByteStringClass: { | 328 case kOneByteString: { |
| 331 intptr_t len = ReadSmiValue(); | 329 intptr_t len = ReadSmiValue(); |
| 332 intptr_t hash = ReadSmiValue(); | 330 intptr_t hash = ReadSmiValue(); |
| 333 USE(hash); | 331 USE(hash); |
| 334 Dart_CObject* object = AllocateDartCObjectString(len); | 332 Dart_CObject* object = AllocateDartCObjectString(len); |
| 335 AddBackRef(object_id, object, kIsDeserialized); | 333 AddBackRef(object_id, object, kIsDeserialized); |
| 336 char* p = object->value.as_string; | 334 char* p = object->value.as_string; |
| 337 for (intptr_t i = 0; i < len; i++) { | 335 for (intptr_t i = 0; i < len; i++) { |
| 338 p[i] = Read<uint8_t>(); | 336 p[i] = Read<uint8_t>(); |
| 339 } | 337 } |
| 340 p[len] = '\0'; | 338 p[len] = '\0'; |
| 341 return object; | 339 return object; |
| 342 } | 340 } |
| 343 case ObjectStore::kTwoByteStringClass: | 341 case kTwoByteString: |
| 344 // Two byte strings not supported. | 342 // Two byte strings not supported. |
| 345 return AllocateDartCObjectUnsupported(); | 343 return AllocateDartCObjectUnsupported(); |
| 346 case ObjectStore::kFourByteStringClass: | 344 case kFourByteString: |
| 347 // Four byte strings not supported. | 345 // Four byte strings not supported. |
| 348 return AllocateDartCObjectUnsupported(); | 346 return AllocateDartCObjectUnsupported(); |
| 349 case ObjectStore::kUint8ArrayClass: { | 347 case kUint8Array: { |
| 350 intptr_t len = ReadSmiValue(); | 348 intptr_t len = ReadSmiValue(); |
| 351 Dart_CObject* object = AllocateDartCObjectUint8Array(len); | 349 Dart_CObject* object = AllocateDartCObjectUint8Array(len); |
| 352 AddBackRef(object_id, object, kIsDeserialized); | 350 AddBackRef(object_id, object, kIsDeserialized); |
| 353 if (len > 0) { | 351 if (len > 0) { |
| 354 uint8_t* p = object->value.as_byte_array.values; | 352 uint8_t* p = object->value.as_byte_array.values; |
| 355 for (intptr_t i = 0; i < len; i++) { | 353 for (intptr_t i = 0; i < len; i++) { |
| 356 p[i] = Read<uint8_t>(); | 354 p[i] = Read<uint8_t>(); |
| 357 } | 355 } |
| 358 } | 356 } |
| 359 return object; | 357 return object; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 } | 441 } |
| 444 return NULL; | 442 return NULL; |
| 445 } | 443 } |
| 446 | 444 |
| 447 | 445 |
| 448 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t *data) { | 446 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t *data) { |
| 449 // Write out the serialization header value for this object. | 447 // Write out the serialization header value for this object. |
| 450 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds); | 448 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds); |
| 451 | 449 |
| 452 // Write out the class and tags information. | 450 // Write out the class and tags information. |
| 453 WriteObjectHeader(ObjectStore::kArrayClass, 0); | 451 WriteObjectHeader(kArray, 0); |
| 454 | 452 |
| 455 // Write out the length field. | 453 // Write out the length field. |
| 456 Write<RawObject*>(Smi::New(field_count)); | 454 Write<RawObject*>(Smi::New(field_count)); |
| 457 | 455 |
| 458 // Write out the type arguments. | 456 // Write out the type arguments. |
| 459 WriteIndexedObject(Object::kNullObject); | 457 WriteIndexedObject(Object::kNullObject); |
| 460 | 458 |
| 461 // Write out the individual Smis. | 459 // Write out the individual Smis. |
| 462 for (int i = 0; i < field_count; i++) { | 460 for (int i = 0; i < field_count; i++) { |
| 463 Write<RawObject*>(Integer::New(data[i])); | 461 Write<RawObject*>(Integer::New(data[i])); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 ASSERT(Smi::IsValid64(value)); | 531 ASSERT(Smi::IsValid64(value)); |
| 534 Write<RawObject*>(Smi::New(value)); | 532 Write<RawObject*>(Smi::New(value)); |
| 535 } | 533 } |
| 536 | 534 |
| 537 | 535 |
| 538 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { | 536 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { |
| 539 ASSERT(!Smi::IsValid64(value)); | 537 ASSERT(!Smi::IsValid64(value)); |
| 540 // Write out the serialization header value for mint object. | 538 // Write out the serialization header value for mint object. |
| 541 WriteInlinedHeader(object); | 539 WriteInlinedHeader(object); |
| 542 // Write out the class and tags information. | 540 // Write out the class and tags information. |
| 543 WriteObjectHeader(ObjectStore::kMintClass, 0); | 541 WriteObjectHeader(kMint, 0); |
| 544 // Write the 64-bit value. | 542 // Write the 64-bit value. |
| 545 Write<int64_t>(value); | 543 Write<int64_t>(value); |
| 546 } | 544 } |
| 547 | 545 |
| 548 | 546 |
| 549 void ApiMessageWriter::WriteInt32(Dart_CObject* object) { | 547 void ApiMessageWriter::WriteInt32(Dart_CObject* object) { |
| 550 int64_t value = object->value.as_int32; | 548 int64_t value = object->value.as_int32; |
| 551 if (Smi::IsValid64(value)) { | 549 if (Smi::IsValid64(value)) { |
| 552 WriteSmi(value); | 550 WriteSmi(value); |
| 553 } else { | 551 } else { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 581 intptr_t object_id = GetMarkedCObjectMark(object); | 579 intptr_t object_id = GetMarkedCObjectMark(object); |
| 582 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); | 580 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); |
| 583 return; | 581 return; |
| 584 } | 582 } |
| 585 | 583 |
| 586 Dart_CObject::Type type = object->type; | 584 Dart_CObject::Type type = object->type; |
| 587 if (type == Dart_CObject::kArray) { | 585 if (type == Dart_CObject::kArray) { |
| 588 // Write out the serialization header value for this object. | 586 // Write out the serialization header value for this object. |
| 589 WriteInlinedHeader(object); | 587 WriteInlinedHeader(object); |
| 590 // Write out the class and tags information. | 588 // Write out the class and tags information. |
| 591 WriteObjectHeader(ObjectStore::kArrayClass, 0); | 589 WriteObjectHeader(kArray, 0); |
| 592 WriteSmi(object->value.as_array.length); | 590 WriteSmi(object->value.as_array.length); |
| 593 // Write out the type arguments. | 591 // Write out the type arguments. |
| 594 WriteIndexedObject(Object::kNullObject); | 592 WriteIndexedObject(Object::kNullObject); |
| 595 // Write out array elements. | 593 // Write out array elements. |
| 596 for (int i = 0; i < object->value.as_array.length; i++) { | 594 for (int i = 0; i < object->value.as_array.length; i++) { |
| 597 WriteCObjectRef(object->value.as_array.values[i]); | 595 WriteCObjectRef(object->value.as_array.values[i]); |
| 598 } | 596 } |
| 599 return; | 597 return; |
| 600 } | 598 } |
| 601 return WriteCObjectInlined(object, type); | 599 return WriteCObjectInlined(object, type); |
| 602 } | 600 } |
| 603 | 601 |
| 604 | 602 |
| 605 void ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { | 603 void ApiMessageWriter::WriteCObjectRef(Dart_CObject* object) { |
| 606 if (IsCObjectMarked(object)) { | 604 if (IsCObjectMarked(object)) { |
| 607 intptr_t object_id = GetMarkedCObjectMark(object); | 605 intptr_t object_id = GetMarkedCObjectMark(object); |
| 608 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); | 606 WriteIndexedObject(kMaxPredefinedObjectIds + object_id); |
| 609 return; | 607 return; |
| 610 } | 608 } |
| 611 | 609 |
| 612 Dart_CObject::Type type = object->type; | 610 Dart_CObject::Type type = object->type; |
| 613 if (type == Dart_CObject::kArray) { | 611 if (type == Dart_CObject::kArray) { |
| 614 // Write out the serialization header value for this object. | 612 // Write out the serialization header value for this object. |
| 615 WriteInlinedHeader(object); | 613 WriteInlinedHeader(object); |
| 616 // Write out the class information. | 614 // Write out the class information. |
| 617 WriteIndexedObject(ObjectStore::kArrayClass); | 615 WriteIndexedObject(kArray); |
| 618 // Write out the length information. | 616 // Write out the length information. |
| 619 WriteSmi(object->value.as_array.length); | 617 WriteSmi(object->value.as_array.length); |
| 620 // Add object to forward list so that this object is serialized later. | 618 // Add object to forward list so that this object is serialized later. |
| 621 AddToForwardList(object); | 619 AddToForwardList(object); |
| 622 return; | 620 return; |
| 623 } | 621 } |
| 624 return WriteCObjectInlined(object, type); | 622 return WriteCObjectInlined(object, type); |
| 625 } | 623 } |
| 626 | 624 |
| 627 | 625 |
| 628 void ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { | 626 void ApiMessageWriter::WriteForwardedCObject(Dart_CObject* object) { |
| 629 ASSERT(IsCObjectMarked(object)); | 627 ASSERT(IsCObjectMarked(object)); |
| 630 Dart_CObject::Type type = | 628 Dart_CObject::Type type = |
| 631 static_cast<Dart_CObject::Type>(object->type & kDartCObjectTypeMask); | 629 static_cast<Dart_CObject::Type>(object->type & kDartCObjectTypeMask); |
| 632 ASSERT(type == Dart_CObject::kArray); | 630 ASSERT(type == Dart_CObject::kArray); |
| 633 | 631 |
| 634 // Write out the serialization header value for this object. | 632 // Write out the serialization header value for this object. |
| 635 intptr_t object_id = GetMarkedCObjectMark(object); | 633 intptr_t object_id = GetMarkedCObjectMark(object); |
| 636 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds + object_id); | 634 WriteSerializationMarker(kInlined, kMaxPredefinedObjectIds + object_id); |
| 637 // Write out the class and tags information. | 635 // Write out the class and tags information. |
| 638 WriteObjectHeader(ObjectStore::kArrayClass, 0); | 636 WriteObjectHeader(kArray, 0); |
| 639 WriteSmi(object->value.as_array.length); | 637 WriteSmi(object->value.as_array.length); |
| 640 // Write out the type arguments. | 638 // Write out the type arguments. |
| 641 WriteIndexedObject(Object::kNullObject); | 639 WriteIndexedObject(Object::kNullObject); |
| 642 // Write out array elements. | 640 // Write out array elements. |
| 643 for (int i = 0; i < object->value.as_array.length; i++) { | 641 for (int i = 0; i < object->value.as_array.length; i++) { |
| 644 WriteCObjectRef(object->value.as_array.values[i]); | 642 WriteCObjectRef(object->value.as_array.values[i]); |
| 645 } | 643 } |
| 646 } | 644 } |
| 647 | 645 |
| 648 | 646 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 662 case Dart_CObject::kInt32: | 660 case Dart_CObject::kInt32: |
| 663 WriteInt32(object); | 661 WriteInt32(object); |
| 664 break; | 662 break; |
| 665 case Dart_CObject::kInt64: | 663 case Dart_CObject::kInt64: |
| 666 WriteInt64(object); | 664 WriteInt64(object); |
| 667 break; | 665 break; |
| 668 case Dart_CObject::kBigint: { | 666 case Dart_CObject::kBigint: { |
| 669 // Write out the serialization header value for this object. | 667 // Write out the serialization header value for this object. |
| 670 WriteInlinedHeader(object); | 668 WriteInlinedHeader(object); |
| 671 // Write out the class and tags information. | 669 // Write out the class and tags information. |
| 672 WriteObjectHeader(ObjectStore::kBigintClass, 0); | 670 WriteObjectHeader(kBigint, 0); |
| 673 // Write hex string length and content | 671 // Write hex string length and content |
| 674 char* hex_string = object->value.as_bigint; | 672 char* hex_string = object->value.as_bigint; |
| 675 intptr_t len = strlen(hex_string); | 673 intptr_t len = strlen(hex_string); |
| 676 WriteIntptrValue(len); | 674 WriteIntptrValue(len); |
| 677 for (intptr_t i = 0; i < len; i++) { | 675 for (intptr_t i = 0; i < len; i++) { |
| 678 Write<uint8_t>(hex_string[i]); | 676 Write<uint8_t>(hex_string[i]); |
| 679 } | 677 } |
| 680 break; | 678 break; |
| 681 } | 679 } |
| 682 case Dart_CObject::kDouble: | 680 case Dart_CObject::kDouble: |
| 683 // Write out the serialization header value for this object. | 681 // Write out the serialization header value for this object. |
| 684 WriteInlinedHeader(object); | 682 WriteInlinedHeader(object); |
| 685 // Write out the class and tags information. | 683 // Write out the class and tags information. |
| 686 WriteObjectHeader(ObjectStore::kDoubleClass, 0); | 684 WriteObjectHeader(kDouble, 0); |
| 687 // Write double value. | 685 // Write double value. |
| 688 Write<double>(object->value.as_double); | 686 Write<double>(object->value.as_double); |
| 689 break; | 687 break; |
| 690 case Dart_CObject::kString: { | 688 case Dart_CObject::kString: { |
| 691 // Write out the serialization header value for this object. | 689 // Write out the serialization header value for this object. |
| 692 WriteInlinedHeader(object); | 690 WriteInlinedHeader(object); |
| 693 // Write out the class and tags information. | 691 // Write out the class and tags information. |
| 694 WriteObjectHeader(ObjectStore::kOneByteStringClass, 0); | 692 WriteObjectHeader(kOneByteString, 0); |
| 695 // Write string length, hash and content | 693 // Write string length, hash and content |
| 696 char* str = object->value.as_string; | 694 char* str = object->value.as_string; |
| 697 intptr_t len = strlen(str); | 695 intptr_t len = strlen(str); |
| 698 WriteSmi(len); | 696 WriteSmi(len); |
| 699 WriteSmi(0); // TODO(sgjesse): Hash - not written. | 697 WriteSmi(0); // TODO(sgjesse): Hash - not written. |
| 700 for (intptr_t i = 0; i < len; i++) { | 698 for (intptr_t i = 0; i < len; i++) { |
| 701 Write<uint8_t>(str[i]); | 699 Write<uint8_t>(str[i]); |
| 702 } | 700 } |
| 703 break; | 701 break; |
| 704 } | 702 } |
| 705 case Dart_CObject::kUint8Array: { | 703 case Dart_CObject::kUint8Array: { |
| 706 // Write out the serialization header value for this object. | 704 // Write out the serialization header value for this object. |
| 707 WriteInlinedHeader(object); | 705 WriteInlinedHeader(object); |
| 708 // Write out the class and tags information. | 706 // Write out the class and tags information. |
| 709 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0); | 707 WriteObjectHeader(kUint8Array, 0); |
| 710 uint8_t* bytes = object->value.as_byte_array.values; | 708 uint8_t* bytes = object->value.as_byte_array.values; |
| 711 intptr_t len = object->value.as_byte_array.length; | 709 intptr_t len = object->value.as_byte_array.length; |
| 712 WriteSmi(len); | 710 WriteSmi(len); |
| 713 for (intptr_t i = 0; i < len; i++) { | 711 for (intptr_t i = 0; i < len; i++) { |
| 714 Write<uint8_t>(bytes[i]); | 712 Write<uint8_t>(bytes[i]); |
| 715 } | 713 } |
| 716 break; | 714 break; |
| 717 } | 715 } |
| 718 case Dart_CObject::kExternalUint8Array: { | 716 case Dart_CObject::kExternalUint8Array: { |
| 719 // TODO(ager): we are writing C pointers into the message in | 717 // TODO(ager): we are writing C pointers into the message in |
| 720 // order to post external arrays through ports. We need to make | 718 // order to post external arrays through ports. We need to make |
| 721 // sure that messages containing pointers can never be posted | 719 // sure that messages containing pointers can never be posted |
| 722 // to other processes. | 720 // to other processes. |
| 723 | 721 |
| 724 // Write out serialization header value for this object. | 722 // Write out serialization header value for this object. |
| 725 WriteInlinedHeader(object); | 723 WriteInlinedHeader(object); |
| 726 // Write out the class and tag information. | 724 // Write out the class and tag information. |
| 727 WriteObjectHeader(ObjectStore::kExternalUint8ArrayClass, 0); | 725 WriteObjectHeader(kExternalUint8Array, 0); |
| 728 int length = object->value.as_external_byte_array.length; | 726 int length = object->value.as_external_byte_array.length; |
| 729 uint8_t* data = object->value.as_external_byte_array.data; | 727 uint8_t* data = object->value.as_external_byte_array.data; |
| 730 void* peer = object->value.as_external_byte_array.peer; | 728 void* peer = object->value.as_external_byte_array.peer; |
| 731 Dart_PeerFinalizer callback = | 729 Dart_PeerFinalizer callback = |
| 732 object->value.as_external_byte_array.callback; | 730 object->value.as_external_byte_array.callback; |
| 733 WriteSmi(length); | 731 WriteSmi(length); |
| 734 WriteIntptrValue(reinterpret_cast<intptr_t>(data)); | 732 WriteIntptrValue(reinterpret_cast<intptr_t>(data)); |
| 735 WriteIntptrValue(reinterpret_cast<intptr_t>(peer)); | 733 WriteIntptrValue(reinterpret_cast<intptr_t>(peer)); |
| 736 WriteIntptrValue(reinterpret_cast<intptr_t>(callback)); | 734 WriteIntptrValue(reinterpret_cast<intptr_t>(callback)); |
| 737 break; | 735 break; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 748 // not been serialized yet. These would typically be fields of arrays. | 746 // not been serialized yet. These would typically be fields of arrays. |
| 749 // NOTE: The forward list might grow as we process the list. | 747 // NOTE: The forward list might grow as we process the list. |
| 750 for (intptr_t i = 0; i < forward_id_; i++) { | 748 for (intptr_t i = 0; i < forward_id_; i++) { |
| 751 WriteForwardedCObject(forward_list_[i]); | 749 WriteForwardedCObject(forward_list_[i]); |
| 752 } | 750 } |
| 753 UnmarkAllCObjects(object); | 751 UnmarkAllCObjects(object); |
| 754 FinalizeBuffer(); | 752 FinalizeBuffer(); |
| 755 } | 753 } |
| 756 | 754 |
| 757 } // namespace dart | 755 } // namespace dart |
| OLD | NEW |