Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: src/snapshot-source-sink.h

Issue 781943002: Reland "Encode reservation meta data in the snapshot blob." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot-external.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 FINAL { 20 class SnapshotByteSource FINAL {
21 public: 21 public:
22 SnapshotByteSource(const byte* array, int length); 22 SnapshotByteSource(const byte* data, int length)
23 ~SnapshotByteSource(); 23 : data_(data), length_(length), position_(0) {}
24
25 explicit SnapshotByteSource(Vector<const byte> payload)
26 : data_(payload.start()), length_(payload.length()), position_(0) {}
27
28 ~SnapshotByteSource() {}
24 29
25 bool HasMore() { return position_ < length_; } 30 bool HasMore() { return position_ < length_; }
26 31
27 byte Get() { 32 byte Get() {
28 DCHECK(position_ < length_); 33 DCHECK(position_ < length_);
29 return data_[position_++]; 34 return data_[position_++];
30 } 35 }
31 36
32 int32_t GetUnalignedInt(); 37 int32_t GetUnalignedInt();
33 38
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ~SnapshotByteSink() {} 81 ~SnapshotByteSink() {}
77 82
78 void Put(byte b, const char* description) { data_.Add(b); } 83 void Put(byte b, const char* description) { data_.Add(b); }
79 84
80 void PutSection(int b, const char* description) { 85 void PutSection(int b, const char* description) {
81 DCHECK_LE(b, kMaxUInt8); 86 DCHECK_LE(b, kMaxUInt8);
82 Put(static_cast<byte>(b), description); 87 Put(static_cast<byte>(b), description);
83 } 88 }
84 89
85 void PutInt(uintptr_t integer, const char* description); 90 void PutInt(uintptr_t integer, const char* description);
86 void PutRaw(byte* data, int number_of_bytes, const char* description); 91 void PutRaw(const byte* data, int number_of_bytes, const char* description);
87 void PutBlob(byte* data, int number_of_bytes, const char* description); 92 void PutBlob(Vector<const byte> blob, const char* description);
88 int Position() { return data_.length(); } 93 int Position() { return data_.length(); }
89 94
90 const List<byte>& data() const { return data_; } 95 const List<byte>& data() const { return data_; }
91 96
92 private: 97 private:
93 List<byte> data_; 98 List<byte> data_;
94 }; 99 };
95 100
96 } // namespace v8::internal 101 } // namespace v8::internal
97 } // namespace v8 102 } // namespace v8
98 103
99 #endif // V8_SNAPSHOT_SOURCE_SINK_H_ 104 #endif // V8_SNAPSHOT_SOURCE_SINK_H_
OLDNEW
« no previous file with comments | « src/snapshot-external.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698