Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/object.h" | 6 #include "vm/object.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
| 9 #include "vm/visitor.h" | 9 #include "vm/visitor.h" |
| 10 | 10 |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 | 992 |
| 993 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, | 993 RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader, |
| 994 intptr_t object_id, | 994 intptr_t object_id, |
| 995 bool classes_serialized) { | 995 bool classes_serialized) { |
| 996 ASSERT(reader != NULL); | 996 ASSERT(reader != NULL); |
| 997 // Read the length so that we can determine instance size to allocate. | 997 // Read the length so that we can determine instance size to allocate. |
| 998 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 998 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); |
| 999 intptr_t len = Smi::Value(smi_len); | 999 intptr_t len = Smi::Value(smi_len); |
| 1000 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); | 1000 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); |
| 1001 | 1001 |
| 1002 // Allocate a one byte character area. | 1002 // Set up the one byte string object. |
| 1003 uint8_t* chars = new uint8_t[len]; | 1003 OneByteString& str_obj = OneByteString::ZoneHandle( |
| 1004 for (int i = 0; i < len; i++) { | 1004 OneByteString::New(len, classes_serialized ? Heap::kOld : Heap::kNew)); |
| 1005 chars[i] = reader->Read<uint8_t>(); | 1005 for (intptr_t i = 0; i < len; i++) { |
| 1006 *str_obj.CharAddr(i) = reader->Read<uint8_t>(); | |
|
siva
2011/10/21 20:40:55
*(str_obj.CharAddr(i)) = reader->Read<uint8_t>();
| |
| 1006 } | 1007 } |
| 1007 | 1008 |
| 1008 // Set up the one byte string object. | |
| 1009 OneByteString& str_obj = OneByteString::ZoneHandle( | |
| 1010 OneByteString::New(chars, | |
| 1011 len, | |
| 1012 classes_serialized ? Heap::kOld : Heap::kNew)); | |
| 1013 delete[] chars; | |
| 1014 reader->AddBackwardReference(object_id, &str_obj); | 1009 reader->AddBackwardReference(object_id, &str_obj); |
| 1015 RawOneByteString* raw_str = str_obj.raw(); | 1010 RawOneByteString* raw_str = str_obj.raw(); |
| 1016 raw_str->ptr()->hash_ = smi_hash; | 1011 raw_str->ptr()->hash_ = smi_hash; |
| 1017 return str_obj.raw(); | 1012 return str_obj.raw(); |
| 1018 } | 1013 } |
| 1019 | 1014 |
| 1020 | 1015 |
| 1021 void RawOneByteString::WriteTo(SnapshotWriter* writer, | 1016 void RawOneByteString::WriteTo(SnapshotWriter* writer, |
| 1022 intptr_t object_id, | 1017 intptr_t object_id, |
| 1023 bool serialize_classes) { | 1018 bool serialize_classes) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1045 | 1040 |
| 1046 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, | 1041 RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader, |
| 1047 intptr_t object_id, | 1042 intptr_t object_id, |
| 1048 bool classes_serialized) { | 1043 bool classes_serialized) { |
| 1049 ASSERT(reader != NULL); | 1044 ASSERT(reader != NULL); |
| 1050 // Read the length so that we can determine instance size to allocate. | 1045 // Read the length so that we can determine instance size to allocate. |
| 1051 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1046 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); |
| 1052 intptr_t len = Smi::Value(smi_len); | 1047 intptr_t len = Smi::Value(smi_len); |
| 1053 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); | 1048 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); |
| 1054 | 1049 |
| 1055 // Allocate a two byte character area. | 1050 // Set up the two byte string object. |
| 1056 uint16_t* chars = new uint16_t[len]; | 1051 TwoByteString& str_obj = TwoByteString::ZoneHandle( |
| 1052 TwoByteString::New(len, classes_serialized ? Heap::kOld : Heap::kNew)); | |
| 1057 for (int i = 0; i < len; i++) { | 1053 for (int i = 0; i < len; i++) { |
|
siva
2011/10/21 20:40:55
int => intptr_t like above?
| |
| 1058 chars[i] = reader->Read<uint16_t>(); | 1054 *str_obj.CharAddr(i) = reader->Read<uint16_t>(); |
|
siva
2011/10/21 20:40:55
ditto.
| |
| 1059 } | 1055 } |
| 1060 | 1056 |
| 1061 // Set up the two byte string object. | |
| 1062 TwoByteString& str_obj = TwoByteString::ZoneHandle( | |
| 1063 TwoByteString::New(chars, | |
| 1064 len, | |
| 1065 classes_serialized ? Heap::kOld : Heap::kNew)); | |
| 1066 delete[] chars; | |
| 1067 reader->AddBackwardReference(object_id, &str_obj); | 1057 reader->AddBackwardReference(object_id, &str_obj); |
| 1068 RawTwoByteString* raw_str = str_obj.raw(); | 1058 RawTwoByteString* raw_str = str_obj.raw(); |
| 1069 raw_str->ptr()->hash_ = smi_hash; | 1059 raw_str->ptr()->hash_ = smi_hash; |
| 1070 return str_obj.raw(); | 1060 return str_obj.raw(); |
| 1071 } | 1061 } |
| 1072 | 1062 |
| 1073 | 1063 |
| 1074 void RawTwoByteString::WriteTo(SnapshotWriter* writer, | 1064 void RawTwoByteString::WriteTo(SnapshotWriter* writer, |
| 1075 intptr_t object_id, | 1065 intptr_t object_id, |
| 1076 bool serialize_classes) { | 1066 bool serialize_classes) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1098 | 1088 |
| 1099 RawFourByteString* FourByteString::ReadFrom(SnapshotReader* reader, | 1089 RawFourByteString* FourByteString::ReadFrom(SnapshotReader* reader, |
| 1100 intptr_t object_id, | 1090 intptr_t object_id, |
| 1101 bool classes_serialized) { | 1091 bool classes_serialized) { |
| 1102 ASSERT(reader != NULL); | 1092 ASSERT(reader != NULL); |
| 1103 // Read the length so that we can determine instance size to allocate. | 1093 // Read the length so that we can determine instance size to allocate. |
| 1104 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); | 1094 RawSmi* smi_len = GetSmi(reader->Read<intptr_t>()); |
| 1105 intptr_t len = Smi::Value(smi_len); | 1095 intptr_t len = Smi::Value(smi_len); |
| 1106 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); | 1096 RawSmi* smi_hash = GetSmi(reader->Read<intptr_t>()); |
| 1107 | 1097 |
| 1108 // Allocate a four byte character area. | 1098 // Set up the four byte string object. |
| 1109 uint32_t* chars = new uint32_t[len]; | 1099 FourByteString& str_obj = FourByteString::ZoneHandle( |
| 1110 for (int i = 0; i < len; i++) { | 1100 FourByteString::New(len, classes_serialized ? Heap::kOld : Heap::kNew)); |
| 1111 chars[i] = reader->Read<uint32_t>(); | 1101 for (intptr_t i = 0; i < len; i++) { |
| 1102 *str_obj.CharAddr(i) = reader->Read<uint32_t>(); | |
|
siva
2011/10/21 20:40:55
ditto.
| |
| 1112 } | 1103 } |
| 1113 | 1104 |
| 1114 // Set up the four byte string object. | |
| 1115 FourByteString& str_obj = FourByteString::ZoneHandle( | |
| 1116 FourByteString::New(chars, | |
| 1117 len, | |
| 1118 classes_serialized ? Heap::kOld : Heap::kNew)); | |
| 1119 delete[] chars; | |
| 1120 reader->AddBackwardReference(object_id, &str_obj); | 1105 reader->AddBackwardReference(object_id, &str_obj); |
| 1121 RawFourByteString* raw_str = str_obj.raw(); | 1106 RawFourByteString* raw_str = str_obj.raw(); |
| 1122 raw_str->ptr()->hash_ = smi_hash; | 1107 raw_str->ptr()->hash_ = smi_hash; |
| 1123 return str_obj.raw(); | 1108 return str_obj.raw(); |
| 1124 } | 1109 } |
| 1125 | 1110 |
| 1126 | 1111 |
| 1127 void RawFourByteString::WriteTo(SnapshotWriter* writer, | 1112 void RawFourByteString::WriteTo(SnapshotWriter* writer, |
| 1128 intptr_t object_id, | 1113 intptr_t object_id, |
| 1129 bool serialize_classes) { | 1114 bool serialize_classes) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 // Write out all the other fields. | 1322 // Write out all the other fields. |
| 1338 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1323 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 1339 writer->WriteObject(ptr()->pattern_); | 1324 writer->WriteObject(ptr()->pattern_); |
| 1340 writer->Write<intptr_t>(ptr()->type_); | 1325 writer->Write<intptr_t>(ptr()->type_); |
| 1341 writer->Write<intptr_t>(ptr()->flags_); | 1326 writer->Write<intptr_t>(ptr()->flags_); |
| 1342 | 1327 |
| 1343 // Do not write out the data part which is native. | 1328 // Do not write out the data part which is native. |
| 1344 } | 1329 } |
| 1345 | 1330 |
| 1346 } // namespace dart | 1331 } // namespace dart |
| OLD | NEW |