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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 intptr_t ReadIntptrValue() { | 175 intptr_t ReadIntptrValue() { |
176 int64_t value = Read<int64_t>(); | 176 int64_t value = Read<int64_t>(); |
177 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); | 177 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); |
178 return static_cast<intptr_t>(value); | 178 return static_cast<intptr_t>(value); |
179 } | 179 } |
180 | 180 |
181 void ReadBytes(uint8_t* addr, intptr_t len) { | 181 void ReadBytes(uint8_t* addr, intptr_t len) { |
182 stream_.ReadBytes(addr, len); | 182 stream_.ReadBytes(addr, len); |
183 } | 183 } |
184 | 184 |
| 185 double ReadDouble() { |
| 186 double result; |
| 187 stream_.ReadBytes(reinterpret_cast<uint8_t*>(&result), sizeof(result)); |
| 188 return result; |
| 189 } |
| 190 |
| 191 |
185 const uint8_t* CurrentBufferAddress() const { | 192 const uint8_t* CurrentBufferAddress() const { |
186 return stream_.AddressOfCurrentPosition(); | 193 return stream_.AddressOfCurrentPosition(); |
187 } | 194 } |
188 | 195 |
189 void Advance(intptr_t value) { | 196 void Advance(intptr_t value) { |
190 stream_.Advance(value); | 197 stream_.Advance(value); |
191 } | 198 } |
192 | 199 |
193 RawSmi* ReadAsSmi(); | 200 RawSmi* ReadAsSmi(); |
194 intptr_t ReadSmiValue(); | 201 intptr_t ReadSmiValue(); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 value = SerializedHeaderTag::update(kInlined, value); | 421 value = SerializedHeaderTag::update(kInlined, value); |
415 value = SerializedHeaderData::update(id, value); | 422 value = SerializedHeaderData::update(id, value); |
416 WriteIntptrValue(value); | 423 WriteIntptrValue(value); |
417 } | 424 } |
418 | 425 |
419 // Write out a buffer of bytes. | 426 // Write out a buffer of bytes. |
420 void WriteBytes(const uint8_t* addr, intptr_t len) { | 427 void WriteBytes(const uint8_t* addr, intptr_t len) { |
421 stream_.WriteBytes(addr, len); | 428 stream_.WriteBytes(addr, len); |
422 } | 429 } |
423 | 430 |
| 431 void WriteDouble(double value) { |
| 432 stream_.WriteBytes(reinterpret_cast<const uint8_t*>(&value), sizeof(value)); |
| 433 } |
| 434 |
424 protected: | 435 protected: |
425 BaseWriter(uint8_t** buffer, | 436 BaseWriter(uint8_t** buffer, |
426 ReAlloc alloc, | 437 ReAlloc alloc, |
427 intptr_t initial_size) : stream_(buffer, alloc, initial_size) { | 438 intptr_t initial_size) : stream_(buffer, alloc, initial_size) { |
428 ASSERT(buffer != NULL); | 439 ASSERT(buffer != NULL); |
429 ASSERT(alloc != NULL); | 440 ASSERT(alloc != NULL); |
430 } | 441 } |
431 ~BaseWriter() { } | 442 ~BaseWriter() { } |
432 | 443 |
433 void ReserveHeader() { | 444 void ReserveHeader() { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 private: | 630 private: |
620 SnapshotWriter* writer_; | 631 SnapshotWriter* writer_; |
621 bool as_references_; | 632 bool as_references_; |
622 | 633 |
623 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 634 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
624 }; | 635 }; |
625 | 636 |
626 } // namespace dart | 637 } // namespace dart |
627 | 638 |
628 #endif // VM_SNAPSHOT_H_ | 639 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |