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 13 matching lines...) Expand all Loading... |
24 class JSArrayBuffer; | 24 class JSArrayBuffer; |
25 class JSArrayBufferView; | 25 class JSArrayBufferView; |
26 class JSDate; | 26 class JSDate; |
27 class JSMap; | 27 class JSMap; |
28 class JSRegExp; | 28 class JSRegExp; |
29 class JSSet; | 29 class JSSet; |
30 class JSValue; | 30 class JSValue; |
31 class Object; | 31 class Object; |
32 class Oddball; | 32 class Oddball; |
33 class Smi; | 33 class Smi; |
| 34 class WasmModuleObject; |
34 | 35 |
35 enum class SerializationTag : uint8_t; | 36 enum class SerializationTag : uint8_t; |
36 | 37 |
37 /** | 38 /** |
38 * Writes V8 objects in a binary format that allows the objects to be cloned | 39 * Writes V8 objects in a binary format that allows the objects to be cloned |
39 * according to the HTML structured clone algorithm. | 40 * according to the HTML structured clone algorithm. |
40 * | 41 * |
41 * Format is based on Blink's previous serialization logic. | 42 * Format is based on Blink's previous serialization logic. |
42 */ | 43 */ |
43 class ValueSerializer { | 44 class ValueSerializer { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 Handle<JSArrayBuffer> array_buffer); | 212 Handle<JSArrayBuffer> array_buffer); |
212 | 213 |
213 /* | 214 /* |
214 * Publicly exposed wire format writing methods. | 215 * Publicly exposed wire format writing methods. |
215 * These are intended for use within the delegate's WriteHostObject method. | 216 * These are intended for use within the delegate's WriteHostObject method. |
216 */ | 217 */ |
217 bool ReadUint32(uint32_t* value) WARN_UNUSED_RESULT; | 218 bool ReadUint32(uint32_t* value) WARN_UNUSED_RESULT; |
218 bool ReadUint64(uint64_t* value) WARN_UNUSED_RESULT; | 219 bool ReadUint64(uint64_t* value) WARN_UNUSED_RESULT; |
219 bool ReadDouble(double* value) WARN_UNUSED_RESULT; | 220 bool ReadDouble(double* value) WARN_UNUSED_RESULT; |
220 bool ReadRawBytes(size_t length, const void** data) WARN_UNUSED_RESULT; | 221 bool ReadRawBytes(size_t length, const void** data) WARN_UNUSED_RESULT; |
| 222 void set_expect_inline_wasm(bool expect_inline_wasm) { |
| 223 expect_inline_wasm_ = expect_inline_wasm; |
| 224 } |
221 | 225 |
222 private: | 226 private: |
223 // Reading the wire format. | 227 // Reading the wire format. |
224 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; | 228 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; |
225 void ConsumeTag(SerializationTag peeked_tag); | 229 void ConsumeTag(SerializationTag peeked_tag); |
226 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; | 230 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; |
227 template <typename T> | 231 template <typename T> |
228 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; | 232 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; |
229 template <typename T> | 233 template <typename T> |
230 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; | 234 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; |
231 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; | 235 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; |
232 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; | 236 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; |
| 237 bool expect_inline_wasm() const { return expect_inline_wasm_; } |
233 | 238 |
234 // Reads a string if it matches the one provided. | 239 // Reads a string if it matches the one provided. |
235 // Returns true if this was the case. Otherwise, nothing is consumed. | 240 // Returns true if this was the case. Otherwise, nothing is consumed. |
236 bool ReadExpectedString(Handle<String> expected) WARN_UNUSED_RESULT; | 241 bool ReadExpectedString(Handle<String> expected) WARN_UNUSED_RESULT; |
237 | 242 |
238 // Like ReadObject, but skips logic for special cases in simulating the | 243 // Like ReadObject, but skips logic for special cases in simulating the |
239 // "stack machine". | 244 // "stack machine". |
240 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; | 245 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; |
241 | 246 |
242 // Reads a string intended to be part of a more complicated object. | 247 // Reads a string intended to be part of a more complicated object. |
(...skipping 13 matching lines...) Expand all Loading... |
256 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; | 261 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; |
257 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; | 262 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; |
258 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; | 263 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; |
259 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; | 264 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; |
260 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT; | 265 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT; |
261 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared) | 266 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared) |
262 WARN_UNUSED_RESULT; | 267 WARN_UNUSED_RESULT; |
263 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( | 268 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( |
264 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; | 269 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; |
265 MaybeHandle<JSObject> ReadWasmModule() WARN_UNUSED_RESULT; | 270 MaybeHandle<JSObject> ReadWasmModule() WARN_UNUSED_RESULT; |
| 271 MaybeHandle<JSObject> ReadWasmModuleTransfer() WARN_UNUSED_RESULT; |
266 MaybeHandle<JSObject> ReadHostObject() WARN_UNUSED_RESULT; | 272 MaybeHandle<JSObject> ReadHostObject() WARN_UNUSED_RESULT; |
267 | 273 |
268 /* | 274 /* |
269 * Reads key-value pairs into the object until the specified end tag is | 275 * Reads key-value pairs into the object until the specified end tag is |
270 * encountered. If successful, returns the number of properties read. | 276 * encountered. If successful, returns the number of properties read. |
271 */ | 277 */ |
272 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, | 278 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, |
273 SerializationTag end_tag, | 279 SerializationTag end_tag, |
274 bool can_use_transitions); | 280 bool can_use_transitions); |
275 | 281 |
276 // Manipulating the map from IDs to reified objects. | 282 // Manipulating the map from IDs to reified objects. |
277 bool HasObjectWithID(uint32_t id); | 283 bool HasObjectWithID(uint32_t id); |
278 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); | 284 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); |
279 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); | 285 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); |
280 | 286 |
281 Isolate* const isolate_; | 287 Isolate* const isolate_; |
282 v8::ValueDeserializer::Delegate* const delegate_; | 288 v8::ValueDeserializer::Delegate* const delegate_; |
283 const uint8_t* position_; | 289 const uint8_t* position_; |
284 const uint8_t* const end_; | 290 const uint8_t* const end_; |
285 PretenureFlag pretenure_; | 291 PretenureFlag pretenure_; |
286 uint32_t version_ = 0; | 292 uint32_t version_ = 0; |
287 uint32_t next_id_ = 0; | 293 uint32_t next_id_ = 0; |
| 294 bool expect_inline_wasm_ = false; |
288 | 295 |
289 // Always global handles. | 296 // Always global handles. |
290 Handle<FixedArray> id_map_; | 297 Handle<FixedArray> id_map_; |
291 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; | 298 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; |
292 | 299 |
293 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 300 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
294 }; | 301 }; |
295 | 302 |
296 } // namespace internal | 303 } // namespace internal |
297 } // namespace v8 | 304 } // namespace v8 |
298 | 305 |
299 #endif // V8_VALUE_SERIALIZER_H_ | 306 #endif // V8_VALUE_SERIALIZER_H_ |
OLD | NEW |