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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; | 180 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; |
181 void ConsumeTag(SerializationTag peeked_tag); | 181 void ConsumeTag(SerializationTag peeked_tag); |
182 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; | 182 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; |
183 template <typename T> | 183 template <typename T> |
184 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; | 184 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; |
185 template <typename T> | 185 template <typename T> |
186 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; | 186 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; |
187 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; | 187 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; |
188 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; | 188 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; |
189 | 189 |
| 190 // Reads a string if it matches the one provided. |
| 191 // Returns true if this was the case. Otherwise, nothing is consumed. |
| 192 bool ReadExpectedString(Handle<String> expected) WARN_UNUSED_RESULT; |
| 193 |
190 // Like ReadObject, but skips logic for special cases in simulating the | 194 // Like ReadObject, but skips logic for special cases in simulating the |
191 // "stack machine". | 195 // "stack machine". |
192 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; | 196 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; |
193 | 197 |
194 // Reading V8 objects of specific kinds. | 198 // Reading V8 objects of specific kinds. |
195 // The tag is assumed to have already been read. | 199 // The tag is assumed to have already been read. |
196 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; | 200 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; |
197 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; | 201 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; |
198 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; | 202 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; |
199 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; | 203 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; |
200 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; | 204 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; |
201 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; | 205 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; |
202 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; | 206 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; |
203 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; | 207 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; |
204 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; | 208 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; |
205 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; | 209 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; |
206 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT; | 210 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT; |
207 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared) | 211 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared) |
208 WARN_UNUSED_RESULT; | 212 WARN_UNUSED_RESULT; |
209 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( | 213 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( |
210 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; | 214 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; |
211 | 215 |
212 /* | 216 /* |
213 * Reads key-value pairs into the object until the specified end tag is | 217 * Reads key-value pairs into the object until the specified end tag is |
214 * encountered. If successful, returns the number of properties read. | 218 * encountered. If successful, returns the number of properties read. |
215 */ | 219 */ |
216 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, | 220 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, |
217 SerializationTag end_tag); | 221 SerializationTag end_tag, |
| 222 bool can_use_transitions); |
218 | 223 |
219 // Manipulating the map from IDs to reified objects. | 224 // Manipulating the map from IDs to reified objects. |
220 bool HasObjectWithID(uint32_t id); | 225 bool HasObjectWithID(uint32_t id); |
221 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); | 226 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); |
222 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); | 227 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); |
223 | 228 |
224 Isolate* const isolate_; | 229 Isolate* const isolate_; |
225 const uint8_t* position_; | 230 const uint8_t* position_; |
226 const uint8_t* const end_; | 231 const uint8_t* const end_; |
227 uint32_t version_ = 0; | 232 uint32_t version_ = 0; |
228 uint32_t next_id_ = 0; | 233 uint32_t next_id_ = 0; |
229 | 234 |
230 // Always global handles. | 235 // Always global handles. |
231 Handle<SeededNumberDictionary> id_map_; | 236 Handle<SeededNumberDictionary> id_map_; |
232 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; | 237 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; |
233 | 238 |
234 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 239 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
235 }; | 240 }; |
236 | 241 |
237 } // namespace internal | 242 } // namespace internal |
238 } // namespace v8 | 243 } // namespace v8 |
239 | 244 |
240 #endif // V8_VALUE_SERIALIZER_H_ | 245 #endif // V8_VALUE_SERIALIZER_H_ |
OLD | NEW |