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