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/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 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 str++; | 1271 str++; |
1272 } | 1272 } |
1273 intptr_t len = strlen(str); | 1273 intptr_t len = strlen(str); |
1274 ASSERT(len > 2 && str[0] == '0' && str[1] == 'x'); | 1274 ASSERT(len > 2 && str[0] == '0' && str[1] == 'x'); |
1275 if (neg) { | 1275 if (neg) { |
1276 writer->WriteIntptrValue(len - 1); // Include '-' in length. | 1276 writer->WriteIntptrValue(len - 1); // Include '-' in length. |
1277 writer->Write<uint8_t>('-'); | 1277 writer->Write<uint8_t>('-'); |
1278 } else { | 1278 } else { |
1279 writer->WriteIntptrValue(len - 2); | 1279 writer->WriteIntptrValue(len - 2); |
1280 } | 1280 } |
1281 for (intptr_t i = 2; i < len; i++) { | 1281 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2)); |
1282 writer->Write<uint8_t>(str[i]); | |
1283 } | |
1284 } | 1282 } |
1285 | 1283 |
1286 | 1284 |
1287 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 1285 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
1288 intptr_t object_id, | 1286 intptr_t object_id, |
1289 intptr_t tags, | 1287 intptr_t tags, |
1290 Snapshot::Kind kind) { | 1288 Snapshot::Kind kind) { |
1291 ASSERT(reader != NULL); | 1289 ASSERT(reader != NULL); |
1292 // Read the double value for the object. | 1290 // Read the double value for the object. |
1293 double value = reader->Read<double>(); | 1291 double value = reader->Read<double>(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 // Write out the class and tags information. | 1479 // Write out the class and tags information. |
1482 writer->WriteObjectHeader(class_id, tags); | 1480 writer->WriteObjectHeader(class_id, tags); |
1483 | 1481 |
1484 // Write out the length field. | 1482 // Write out the length field. |
1485 writer->Write<RawObject*>(length); | 1483 writer->Write<RawObject*>(length); |
1486 | 1484 |
1487 // Write out the hash field. | 1485 // Write out the hash field. |
1488 writer->Write<RawObject*>(hash); | 1486 writer->Write<RawObject*>(hash); |
1489 | 1487 |
1490 // Write out the string. | 1488 // Write out the string. |
1491 for (intptr_t i = 0; i < len; i++) { | 1489 if (len > 0) { |
1492 writer->Write(data[i]); | 1490 if (class_id == ObjectStore::kOneByteStringClass) { |
| 1491 writer->WriteBytes(reinterpret_cast<const uint8_t*>(data), len); |
| 1492 } else { |
| 1493 for (intptr_t i = 0; i < len; i++) { |
| 1494 writer->Write(data[i]); |
| 1495 } |
| 1496 } |
1493 } | 1497 } |
1494 } | 1498 } |
1495 | 1499 |
1496 | 1500 |
1497 void RawOneByteString::WriteTo(SnapshotWriter* writer, | 1501 void RawOneByteString::WriteTo(SnapshotWriter* writer, |
1498 intptr_t object_id, | 1502 intptr_t object_id, |
1499 Snapshot::Kind kind) { | 1503 Snapshot::Kind kind) { |
1500 StringWriteTo(writer, | 1504 StringWriteTo(writer, |
1501 object_id, | 1505 object_id, |
1502 kind, | 1506 kind, |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1973 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
1970 writer->WriteObjectImpl(ptr()->pattern_); | 1974 writer->WriteObjectImpl(ptr()->pattern_); |
1971 writer->WriteIntptrValue(ptr()->type_); | 1975 writer->WriteIntptrValue(ptr()->type_); |
1972 writer->WriteIntptrValue(ptr()->flags_); | 1976 writer->WriteIntptrValue(ptr()->flags_); |
1973 | 1977 |
1974 // Do not write out the data part which is native. | 1978 // Do not write out the data part which is native. |
1975 } | 1979 } |
1976 | 1980 |
1977 | 1981 |
1978 } // namespace dart | 1982 } // namespace dart |
OLD | NEW |