| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ | 5 #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ |
| 6 #define V8_SNAPSHOT_SOURCE_SINK_H_ | 6 #define V8_SNAPSHOT_SOURCE_SINK_H_ |
| 7 | 7 |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/utils.h" | 9 #include "src/utils.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Source to read snapshot and builtins files from. | 16 * Source to read snapshot and builtins files from. |
| 17 * | 17 * |
| 18 * Note: Memory ownership remains with callee. | 18 * Note: Memory ownership remains with callee. |
| 19 */ | 19 */ |
| 20 class SnapshotByteSource V8_FINAL { | 20 class SnapshotByteSource V8_FINAL { |
| 21 public: | 21 public: |
| 22 SnapshotByteSource(const byte* array, int length); | 22 SnapshotByteSource(const byte* array, int length); |
| 23 ~SnapshotByteSource(); | 23 ~SnapshotByteSource(); |
| 24 | 24 |
| 25 bool HasMore() { return position_ < length_; } | 25 bool HasMore() { return position_ < length_; } |
| 26 | 26 |
| 27 int Get() { | 27 int Get() { |
| 28 ASSERT(position_ < length_); | 28 DCHECK(position_ < length_); |
| 29 return data_[position_++]; | 29 return data_[position_++]; |
| 30 } | 30 } |
| 31 | 31 |
| 32 int32_t GetUnalignedInt(); | 32 int32_t GetUnalignedInt(); |
| 33 | 33 |
| 34 void Advance(int by) { position_ += by; } | 34 void Advance(int by) { position_ += by; } |
| 35 | 35 |
| 36 void CopyRaw(byte* to, int number_of_bytes); | 36 void CopyRaw(byte* to, int number_of_bytes); |
| 37 | 37 |
| 38 inline int GetInt() { | 38 inline int GetInt() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 66 /** | 66 /** |
| 67 * Sink to write snapshot files to. | 67 * Sink to write snapshot files to. |
| 68 * | 68 * |
| 69 * Subclasses must implement actual storage or i/o. | 69 * Subclasses must implement actual storage or i/o. |
| 70 */ | 70 */ |
| 71 class SnapshotByteSink { | 71 class SnapshotByteSink { |
| 72 public: | 72 public: |
| 73 virtual ~SnapshotByteSink() { } | 73 virtual ~SnapshotByteSink() { } |
| 74 virtual void Put(byte b, const char* description) = 0; | 74 virtual void Put(byte b, const char* description) = 0; |
| 75 virtual void PutSection(int b, const char* description) { | 75 virtual void PutSection(int b, const char* description) { |
| 76 ASSERT_LE(b, kMaxUInt8); | 76 DCHECK_LE(b, kMaxUInt8); |
| 77 Put(static_cast<byte>(b), description); | 77 Put(static_cast<byte>(b), description); |
| 78 } | 78 } |
| 79 void PutInt(uintptr_t integer, const char* description); | 79 void PutInt(uintptr_t integer, const char* description); |
| 80 void PutRaw(byte* data, int number_of_bytes, const char* description); | 80 void PutRaw(byte* data, int number_of_bytes, const char* description); |
| 81 void PutBlob(byte* data, int number_of_bytes, const char* description); | 81 void PutBlob(byte* data, int number_of_bytes, const char* description); |
| 82 virtual int Position() = 0; | 82 virtual int Position() = 0; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 | 85 |
| 86 class DummySnapshotSink : public SnapshotByteSink { | 86 class DummySnapshotSink : public SnapshotByteSink { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 116 virtual int Position() V8_OVERRIDE { return data_->length(); } | 116 virtual int Position() V8_OVERRIDE { return data_->length(); } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 i::List<byte>* data_; | 119 i::List<byte>* data_; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace v8::internal | 122 } // namespace v8::internal |
| 123 } // namespace v8 | 123 } // namespace v8 |
| 124 | 124 |
| 125 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ | 125 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ |
| OLD | NEW |