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/bigint_operations.h" | 5 #include "vm/bigint_operations.h" |
6 #include "vm/dart_api_message.h" | 6 #include "vm/dart_api_message.h" |
7 #include "vm/object.h" | 7 #include "vm/object.h" |
8 #include "vm/snapshot_ids.h" | 8 #include "vm/snapshot_ids.h" |
9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/unicode.h" | 10 #include "vm/unicode.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 intptr_t object_id = GetVMIsolateObjectId(value); | 451 intptr_t object_id = GetVMIsolateObjectId(value); |
452 if (object_id == kNullObject) { | 452 if (object_id == kNullObject) { |
453 return AllocateDartCObjectNull(); | 453 return AllocateDartCObjectNull(); |
454 } | 454 } |
455 if (object_id == kTrueValue) { | 455 if (object_id == kTrueValue) { |
456 return AllocateDartCObjectBool(true); | 456 return AllocateDartCObjectBool(true); |
457 } | 457 } |
458 if (object_id == kFalseValue) { | 458 if (object_id == kFalseValue) { |
459 return AllocateDartCObjectBool(false); | 459 return AllocateDartCObjectBool(false); |
460 } | 460 } |
| 461 if (object_id == kDoubleObject) { |
| 462 return AllocateDartCObjectDouble(ReadDouble()); |
| 463 } |
461 if (Symbols::IsVMSymbolId(object_id)) { | 464 if (Symbols::IsVMSymbolId(object_id)) { |
462 return ReadVMSymbol(object_id); | 465 return ReadVMSymbol(object_id); |
463 } | 466 } |
464 // No other VM isolate objects are supported. | 467 // No other VM isolate objects are supported. |
465 return AllocateDartCObjectNull(); | 468 return AllocateDartCObjectNull(); |
466 } | 469 } |
467 | 470 |
468 | 471 |
469 Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, | 472 Dart_CObject* ApiMessageReader::ReadInternalVMObject(intptr_t class_id, |
470 intptr_t object_id) { | 473 intptr_t object_id) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 Dart_CObject* object = AllocateDartCObjectBigint(len); | 533 Dart_CObject* object = AllocateDartCObjectBigint(len); |
531 AddBackRef(object_id, object, kIsDeserialized); | 534 AddBackRef(object_id, object, kIsDeserialized); |
532 char* p = object->value.as_bigint; | 535 char* p = object->value.as_bigint; |
533 for (intptr_t i = 0; i < len; i++) { | 536 for (intptr_t i = 0; i < len; i++) { |
534 p[i] = Read<uint8_t>(); | 537 p[i] = Read<uint8_t>(); |
535 } | 538 } |
536 p[len] = '\0'; | 539 p[len] = '\0'; |
537 return object; | 540 return object; |
538 } | 541 } |
539 case kDoubleCid: { | 542 case kDoubleCid: { |
540 // Read the double value for the object. | 543 // Doubles are handled specially when being sent as part of message |
541 Dart_CObject* object = AllocateDartCObjectDouble(Read<double>()); | 544 // snapshots. |
542 AddBackRef(object_id, object, kIsDeserialized); | 545 UNREACHABLE(); |
543 return object; | |
544 } | 546 } |
545 case kOneByteStringCid: { | 547 case kOneByteStringCid: { |
546 intptr_t len = ReadSmiValue(); | 548 intptr_t len = ReadSmiValue(); |
547 intptr_t hash = ReadSmiValue(); | 549 intptr_t hash = ReadSmiValue(); |
548 USE(hash); | 550 USE(hash); |
549 uint8_t *latin1 = | 551 uint8_t *latin1 = |
550 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); | 552 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); |
551 intptr_t utf8_len = 0; | 553 intptr_t utf8_len = 0; |
552 for (intptr_t i = 0; i < len; i++) { | 554 for (intptr_t i = 0; i < len; i++) { |
553 latin1[i] = Read<uint8_t>(); | 555 latin1[i] = Read<uint8_t>(); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 WriteIntptrValue(0); | 1048 WriteIntptrValue(0); |
1047 // Write hex string length and content | 1049 // Write hex string length and content |
1048 intptr_t len = strlen(hex_string); | 1050 intptr_t len = strlen(hex_string); |
1049 WriteIntptrValue(len); | 1051 WriteIntptrValue(len); |
1050 for (intptr_t i = 0; i < len; i++) { | 1052 for (intptr_t i = 0; i < len; i++) { |
1051 Write<uint8_t>(hex_string[i]); | 1053 Write<uint8_t>(hex_string[i]); |
1052 } | 1054 } |
1053 break; | 1055 break; |
1054 } | 1056 } |
1055 case Dart_CObject_kDouble: | 1057 case Dart_CObject_kDouble: |
1056 // Write out the serialization header value for this object. | 1058 WriteVMIsolateObject(kDoubleObject); |
1057 WriteInlinedHeader(object); | 1059 WriteDouble(object->value.as_double); |
1058 // Write out the class and tags information. | |
1059 WriteIndexedObject(kDoubleCid); | |
1060 WriteIntptrValue(0); | |
1061 // Write double value. | |
1062 Write<double>(object->value.as_double); | |
1063 break; | 1060 break; |
1064 case Dart_CObject_kString: { | 1061 case Dart_CObject_kString: { |
1065 const uint8_t* utf8_str = | 1062 const uint8_t* utf8_str = |
1066 reinterpret_cast<const uint8_t*>(object->value.as_string); | 1063 reinterpret_cast<const uint8_t*>(object->value.as_string); |
1067 intptr_t utf8_len = strlen(object->value.as_string); | 1064 intptr_t utf8_len = strlen(object->value.as_string); |
1068 if (!Utf8::IsValid(utf8_str, utf8_len)) { | 1065 if (!Utf8::IsValid(utf8_str, utf8_len)) { |
1069 return false; | 1066 return false; |
1070 } | 1067 } |
1071 | 1068 |
1072 Utf8::Type type; | 1069 Utf8::Type type; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 if (!success) { | 1188 if (!success) { |
1192 UnmarkAllCObjects(object); | 1189 UnmarkAllCObjects(object); |
1193 return false; | 1190 return false; |
1194 } | 1191 } |
1195 } | 1192 } |
1196 UnmarkAllCObjects(object); | 1193 UnmarkAllCObjects(object); |
1197 return true; | 1194 return true; |
1198 } | 1195 } |
1199 | 1196 |
1200 } // namespace dart | 1197 } // namespace dart |
OLD | NEW |