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 #ifndef VM_SNAPSHOT_H_ | 5 #ifndef VM_SNAPSHOT_H_ |
6 #define VM_SNAPSHOT_H_ | 6 #define VM_SNAPSHOT_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 void ReadBytes(uint8_t* addr, intptr_t len) { | 189 void ReadBytes(uint8_t* addr, intptr_t len) { |
190 stream_.ReadBytes(addr, len); | 190 stream_.ReadBytes(addr, len); |
191 } | 191 } |
192 | 192 |
193 double ReadDouble() { | 193 double ReadDouble() { |
194 double result; | 194 double result; |
195 stream_.ReadBytes(reinterpret_cast<uint8_t*>(&result), sizeof(result)); | 195 stream_.ReadBytes(reinterpret_cast<uint8_t*>(&result), sizeof(result)); |
196 return result; | 196 return result; |
197 } | 197 } |
198 | 198 |
| 199 intptr_t ReadTags() { |
| 200 const intptr_t tags = static_cast<intptr_t>(Read<int8_t>()) & 0xff; |
| 201 ASSERT(SerializedHeaderTag::decode(tags) != kObjectId); |
| 202 return tags; |
| 203 } |
199 | 204 |
200 const uint8_t* CurrentBufferAddress() const { | 205 const uint8_t* CurrentBufferAddress() const { |
201 return stream_.AddressOfCurrentPosition(); | 206 return stream_.AddressOfCurrentPosition(); |
202 } | 207 } |
203 | 208 |
204 void Advance(intptr_t value) { | 209 void Advance(intptr_t value) { |
205 stream_.Advance(value); | 210 stream_.Advance(value); |
206 } | 211 } |
207 | 212 |
208 RawSmi* ReadAsSmi(); | 213 RawSmi* ReadAsSmi(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 | 438 |
434 // Write serialization header information for an object. | 439 // Write serialization header information for an object. |
435 void WriteInlinedObjectHeader(intptr_t id) { | 440 void WriteInlinedObjectHeader(intptr_t id) { |
436 ASSERT(id <= kMaxObjectId); | 441 ASSERT(id <= kMaxObjectId); |
437 intptr_t value = 0; | 442 intptr_t value = 0; |
438 value = SerializedHeaderTag::update(kInlined, value); | 443 value = SerializedHeaderTag::update(kInlined, value); |
439 value = SerializedHeaderData::update(id, value); | 444 value = SerializedHeaderData::update(id, value); |
440 WriteIntptrValue(value); | 445 WriteIntptrValue(value); |
441 } | 446 } |
442 | 447 |
| 448 void WriteTags(intptr_t tags) { |
| 449 ASSERT(SerializedHeaderTag::decode(tags) != kObjectId); |
| 450 const intptr_t flags = tags & 0xff; |
| 451 Write<int8_t>(static_cast<int8_t>(flags)); |
| 452 } |
| 453 |
443 // Write out a buffer of bytes. | 454 // Write out a buffer of bytes. |
444 void WriteBytes(const uint8_t* addr, intptr_t len) { | 455 void WriteBytes(const uint8_t* addr, intptr_t len) { |
445 stream_.WriteBytes(addr, len); | 456 stream_.WriteBytes(addr, len); |
446 } | 457 } |
447 | 458 |
448 void WriteDouble(double value) { | 459 void WriteDouble(double value) { |
449 stream_.WriteBytes(reinterpret_cast<const uint8_t*>(&value), sizeof(value)); | 460 stream_.WriteBytes(reinterpret_cast<const uint8_t*>(&value), sizeof(value)); |
450 } | 461 } |
451 | 462 |
452 protected: | 463 protected: |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 private: | 660 private: |
650 SnapshotWriter* writer_; | 661 SnapshotWriter* writer_; |
651 bool as_references_; | 662 bool as_references_; |
652 | 663 |
653 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 664 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
654 }; | 665 }; |
655 | 666 |
656 } // namespace dart | 667 } // namespace dart |
657 | 668 |
658 #endif // VM_SNAPSHOT_H_ | 669 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |