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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 char* p = object->value.as_string; | 388 char* p = object->value.as_string; |
389 memmove(p, str->ptr()->data_, len); | 389 memmove(p, str->ptr()->data_, len); |
390 p[len] = '\0'; | 390 p[len] = '\0'; |
391 ASSERT(vm_symbol_references_[symbol_id] == NULL); | 391 ASSERT(vm_symbol_references_[symbol_id] == NULL); |
392 vm_symbol_references_[symbol_id] = object; | 392 vm_symbol_references_[symbol_id] = object; |
393 return object; | 393 return object; |
394 } | 394 } |
395 | 395 |
396 | 396 |
397 Dart_CObject* ApiMessageReader::ReadObjectRef() { | 397 Dart_CObject* ApiMessageReader::ReadObjectRef() { |
398 int64_t value = Read<int64_t>(); | 398 int64_t value64 = Read<int64_t>(); |
399 if ((value & kSmiTagMask) == 0) { | 399 if ((value64 & kSmiTagMask) == 0) { |
400 int64_t untagged_value = value >> kSmiTagShift; | 400 int64_t untagged_value = value64 >> kSmiTagShift; |
401 if (kMinInt32 <= untagged_value && untagged_value <= kMaxInt32) { | 401 if ((kMinInt32 <= untagged_value) && (untagged_value <= kMaxInt32)) { |
402 return AllocateDartCObjectInt32(untagged_value); | 402 return AllocateDartCObjectInt32(static_cast<int32_t>(untagged_value)); |
403 } else { | 403 } else { |
404 return AllocateDartCObjectInt64(untagged_value); | 404 return AllocateDartCObjectInt64(untagged_value); |
405 } | 405 } |
406 } | 406 } |
407 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); | 407 ASSERT((value64 <= kIntptrMax) && (value64 >= kIntptrMin)); |
| 408 intptr_t value = static_cast<intptr_t>(value64); |
408 if (IsVMIsolateObject(value)) { | 409 if (IsVMIsolateObject(value)) { |
409 return ReadVMIsolateObject(value); | 410 return ReadVMIsolateObject(value); |
410 } | 411 } |
411 if (SerializedHeaderTag::decode(value) == kObjectId) { | 412 if (SerializedHeaderTag::decode(value) == kObjectId) { |
412 return ReadIndexedObject(SerializedHeaderData::decode(value)); | 413 return ReadIndexedObject(SerializedHeaderData::decode(value)); |
413 } | 414 } |
414 ASSERT(SerializedHeaderTag::decode(value) == kInlined); | 415 ASSERT(SerializedHeaderTag::decode(value) == kInlined); |
415 // Read the class header information and lookup the class. | 416 // Read the class header information and lookup the class. |
416 intptr_t class_header = ReadIntptrValue(); | 417 intptr_t class_header = ReadIntptrValue(); |
417 | 418 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 int8_t type_state = Read<int8_t>(); | 506 int8_t type_state = Read<int8_t>(); |
506 USE(type_state); | 507 USE(type_state); |
507 Dart_CObject* parameterized_class = ReadObjectImpl(); | 508 Dart_CObject* parameterized_class = ReadObjectImpl(); |
508 // The type parameter is finalized, therefore parameterized_class is null. | 509 // The type parameter is finalized, therefore parameterized_class is null. |
509 ASSERT(parameterized_class->type == Dart_CObject_kNull); | 510 ASSERT(parameterized_class->type == Dart_CObject_kNull); |
510 Dart_CObject* name = ReadObjectImpl(); | 511 Dart_CObject* name = ReadObjectImpl(); |
511 ASSERT(name->type == Dart_CObject_kString); | 512 ASSERT(name->type == Dart_CObject_kString); |
512 return value; | 513 return value; |
513 } | 514 } |
514 case kMintCid: { | 515 case kMintCid: { |
515 int64_t value = Read<int64_t>(); | 516 int64_t value64 = Read<int64_t>(); |
516 Dart_CObject* object; | 517 Dart_CObject* object; |
517 if (kMinInt32 <= value && value <= kMaxInt32) { | 518 if ((kMinInt32 <= value64) && (value64 <= kMaxInt32)) { |
518 object = AllocateDartCObjectInt32(value); | 519 object = AllocateDartCObjectInt32(static_cast<int32_t>(value64)); |
519 } else { | 520 } else { |
520 object = AllocateDartCObjectInt64(value); | 521 object = AllocateDartCObjectInt64(value64); |
521 } | 522 } |
522 AddBackRef(object_id, object, kIsDeserialized); | 523 AddBackRef(object_id, object, kIsDeserialized); |
523 return object; | 524 return object; |
524 } | 525 } |
525 case kBigintCid: { | 526 case kBigintCid: { |
526 // Read in the hex string representation of the bigint. | 527 // Read in the hex string representation of the bigint. |
527 intptr_t len = ReadIntptrValue(); | 528 intptr_t len = ReadIntptrValue(); |
528 Dart_CObject* object = AllocateDartCObjectBigint(len); | 529 Dart_CObject* object = AllocateDartCObjectBigint(len); |
529 AddBackRef(object_id, object, kIsDeserialized); | 530 AddBackRef(object_id, object, kIsDeserialized); |
530 char* p = object->value.as_bigint; | 531 char* p = object->value.as_bigint; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 if (!backward_references_[i]->is_deserialized()) { | 712 if (!backward_references_[i]->is_deserialized()) { |
712 ReadObjectImpl(); | 713 ReadObjectImpl(); |
713 backward_references_[i]->set_state(kIsDeserialized); | 714 backward_references_[i]->set_state(kIsDeserialized); |
714 } | 715 } |
715 } | 716 } |
716 return value; | 717 return value; |
717 } | 718 } |
718 | 719 |
719 | 720 |
720 Dart_CObject* ApiMessageReader::ReadObjectImpl() { | 721 Dart_CObject* ApiMessageReader::ReadObjectImpl() { |
721 int64_t value = Read<int64_t>(); | 722 int64_t value64 = Read<int64_t>(); |
722 if ((value & kSmiTagMask) == 0) { | 723 if ((value64 & kSmiTagMask) == 0) { |
723 int64_t untagged_value = value >> kSmiTagShift; | 724 int64_t untagged_value = value64 >> kSmiTagShift; |
724 if (kMinInt32 <= untagged_value && untagged_value <= kMaxInt32) { | 725 if ((kMinInt32 <= untagged_value) && (untagged_value <= kMaxInt32)) { |
725 return AllocateDartCObjectInt32(untagged_value); | 726 return AllocateDartCObjectInt32(static_cast<int32_t>(untagged_value)); |
726 } else { | 727 } else { |
727 return AllocateDartCObjectInt64(untagged_value); | 728 return AllocateDartCObjectInt64(untagged_value); |
728 } | 729 } |
729 } | 730 } |
730 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); | 731 ASSERT((value64 <= kIntptrMax) && (value64 >= kIntptrMin)); |
| 732 intptr_t value = static_cast<intptr_t>(value64); |
731 if (IsVMIsolateObject(value)) { | 733 if (IsVMIsolateObject(value)) { |
732 return ReadVMIsolateObject(value); | 734 return ReadVMIsolateObject(value); |
733 } | 735 } |
734 if (SerializedHeaderTag::decode(value) == kObjectId) { | 736 if (SerializedHeaderTag::decode(value) == kObjectId) { |
735 return ReadIndexedObject(SerializedHeaderData::decode(value)); | 737 return ReadIndexedObject(SerializedHeaderData::decode(value)); |
736 } | 738 } |
737 ASSERT(SerializedHeaderTag::decode(value) == kInlined); | 739 ASSERT(SerializedHeaderTag::decode(value) == kInlined); |
738 return ReadInlinedObject(SerializedHeaderData::decode(value)); | 740 return ReadInlinedObject(SerializedHeaderData::decode(value)); |
739 } | 741 } |
740 | 742 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 ASSERT(new_list != NULL); | 842 ASSERT(new_list != NULL); |
841 forward_list_ = reinterpret_cast<Dart_CObject**>(new_list); | 843 forward_list_ = reinterpret_cast<Dart_CObject**>(new_list); |
842 } | 844 } |
843 forward_list_[forward_id_] = object; | 845 forward_list_[forward_id_] = object; |
844 forward_id_ += 1; | 846 forward_id_ += 1; |
845 } | 847 } |
846 | 848 |
847 | 849 |
848 void ApiMessageWriter::WriteSmi(int64_t value) { | 850 void ApiMessageWriter::WriteSmi(int64_t value) { |
849 ASSERT(Smi::IsValid64(value)); | 851 ASSERT(Smi::IsValid64(value)); |
850 Write<RawObject*>(Smi::New(value)); | 852 Write<RawObject*>(Smi::New(static_cast<intptr_t>(value))); |
851 } | 853 } |
852 | 854 |
853 | 855 |
854 void ApiMessageWriter::WriteNullObject() { | 856 void ApiMessageWriter::WriteNullObject() { |
855 WriteVMIsolateObject(kNullObject); | 857 WriteVMIsolateObject(kNullObject); |
856 } | 858 } |
857 | 859 |
858 | 860 |
859 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { | 861 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { |
860 ASSERT(!Smi::IsValid64(value)); | 862 ASSERT(!Smi::IsValid64(value)); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 if (!success) { | 1172 if (!success) { |
1171 UnmarkAllCObjects(object); | 1173 UnmarkAllCObjects(object); |
1172 return false; | 1174 return false; |
1173 } | 1175 } |
1174 } | 1176 } |
1175 UnmarkAllCObjects(object); | 1177 UnmarkAllCObjects(object); |
1176 return true; | 1178 return true; |
1177 } | 1179 } |
1178 | 1180 |
1179 } // namespace dart | 1181 } // namespace dart |
OLD | NEW |