| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 WriteIntptrValue(0); | 1030 WriteIntptrValue(0); |
| 1029 // Write hex string length and content | 1031 // Write hex string length and content |
| 1030 intptr_t len = strlen(hex_string); | 1032 intptr_t len = strlen(hex_string); |
| 1031 WriteIntptrValue(len); | 1033 WriteIntptrValue(len); |
| 1032 for (intptr_t i = 0; i < len; i++) { | 1034 for (intptr_t i = 0; i < len; i++) { |
| 1033 Write<uint8_t>(hex_string[i]); | 1035 Write<uint8_t>(hex_string[i]); |
| 1034 } | 1036 } |
| 1035 break; | 1037 break; |
| 1036 } | 1038 } |
| 1037 case Dart_CObject_kDouble: | 1039 case Dart_CObject_kDouble: |
| 1038 // Write out the serialization header value for this object. | 1040 WriteVMIsolateObject(kDoubleObject); |
| 1039 WriteInlinedHeader(object); | 1041 WriteDouble(object->value.as_double); |
| 1040 // Write out the class and tags information. | |
| 1041 WriteIndexedObject(kDoubleCid); | |
| 1042 WriteIntptrValue(0); | |
| 1043 // Write double value. | |
| 1044 Write<double>(object->value.as_double); | |
| 1045 break; | 1042 break; |
| 1046 case Dart_CObject_kString: { | 1043 case Dart_CObject_kString: { |
| 1047 const uint8_t* utf8_str = | 1044 const uint8_t* utf8_str = |
| 1048 reinterpret_cast<const uint8_t*>(object->value.as_string); | 1045 reinterpret_cast<const uint8_t*>(object->value.as_string); |
| 1049 intptr_t utf8_len = strlen(object->value.as_string); | 1046 intptr_t utf8_len = strlen(object->value.as_string); |
| 1050 if (!Utf8::IsValid(utf8_str, utf8_len)) { | 1047 if (!Utf8::IsValid(utf8_str, utf8_len)) { |
| 1051 return false; | 1048 return false; |
| 1052 } | 1049 } |
| 1053 | 1050 |
| 1054 Utf8::Type type; | 1051 Utf8::Type type; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 if (!success) { | 1170 if (!success) { |
| 1174 UnmarkAllCObjects(object); | 1171 UnmarkAllCObjects(object); |
| 1175 return false; | 1172 return false; |
| 1176 } | 1173 } |
| 1177 } | 1174 } |
| 1178 UnmarkAllCObjects(object); | 1175 UnmarkAllCObjects(object); |
| 1179 return true; | 1176 return true; |
| 1180 } | 1177 } |
| 1181 | 1178 |
| 1182 } // namespace dart | 1179 } // namespace dart |
| OLD | NEW |