OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_VALUE_SERIALIZER_H_ | 5 #ifndef V8_VALUE_SERIALIZER_H_ |
6 #define V8_VALUE_SERIALIZER_H_ | 6 #define V8_VALUE_SERIALIZER_H_ |
7 | 7 |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 /* | 106 /* |
107 * Runs version detection logic, which may fail if the format is invalid. | 107 * Runs version detection logic, which may fail if the format is invalid. |
108 */ | 108 */ |
109 Maybe<bool> ReadHeader() WARN_UNUSED_RESULT; | 109 Maybe<bool> ReadHeader() WARN_UNUSED_RESULT; |
110 | 110 |
111 /* | 111 /* |
112 * Deserializes a V8 object from the buffer. | 112 * Deserializes a V8 object from the buffer. |
113 */ | 113 */ |
114 MaybeHandle<Object> ReadObject() WARN_UNUSED_RESULT; | 114 MaybeHandle<Object> ReadObject() WARN_UNUSED_RESULT; |
115 | 115 |
| 116 /* |
| 117 * Reads an object, consuming the entire buffer. |
| 118 * |
| 119 * This is required for the legacy "version 0" format, which did not allow |
| 120 * reference deduplication, and instead relied on a "stack" model for |
| 121 * deserializing, with the contents of objects and arrays provided first. |
| 122 */ |
| 123 MaybeHandle<Object> ReadObjectUsingEntireBufferForLegacyFormat() |
| 124 WARN_UNUSED_RESULT; |
| 125 |
116 private: | 126 private: |
117 // Reading the wire format. | 127 // Reading the wire format. |
118 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; | 128 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; |
| 129 void ConsumeTag(SerializationTag peeked_tag); |
119 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; | 130 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; |
120 template <typename T> | 131 template <typename T> |
121 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; | 132 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; |
122 template <typename T> | 133 template <typename T> |
123 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; | 134 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; |
124 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; | 135 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; |
125 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; | 136 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; |
126 | 137 |
127 // Reading V8 objects of specific kinds. | 138 // Reading V8 objects of specific kinds. |
128 // The tag is assumed to have already been read. | 139 // The tag is assumed to have already been read. |
(...skipping 20 matching lines...) Expand all Loading... |
149 Handle<SeededNumberDictionary> id_map_; // Always a global handle. | 160 Handle<SeededNumberDictionary> id_map_; // Always a global handle. |
150 uint32_t next_id_ = 0; | 161 uint32_t next_id_ = 0; |
151 | 162 |
152 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 163 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
153 }; | 164 }; |
154 | 165 |
155 } // namespace internal | 166 } // namespace internal |
156 } // namespace v8 | 167 } // namespace v8 |
157 | 168 |
158 #endif // V8_VALUE_SERIALIZER_H_ | 169 #endif // V8_VALUE_SERIALIZER_H_ |
OLD | NEW |