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

Side by Side Diff: src/value-serializer.h

Issue 2748473004: [wasm] Transferrable modules (Closed)
Patch Set: compile error Created 3 years, 9 months 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
OLDNEW
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
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 WARN_UNUSED_RESULT; 205 WARN_UNUSED_RESULT;
205 206
206 /* 207 /*
207 * Accepts the array buffer corresponding to the one passed previously to 208 * Accepts the array buffer corresponding to the one passed previously to
208 * ValueSerializer::TransferArrayBuffer. 209 * ValueSerializer::TransferArrayBuffer.
209 */ 210 */
210 void TransferArrayBuffer(uint32_t transfer_id, 211 void TransferArrayBuffer(uint32_t transfer_id,
211 Handle<JSArrayBuffer> array_buffer); 212 Handle<JSArrayBuffer> array_buffer);
212 213
213 /* 214 /*
215 * Accepts the WasmModuleObject corresponding to the one having transfer_id
216 * produced by v8::ValueSerializer::GetWasmCompiledModuleId().
217 * See issue v8:6106.
218 */
219 void TransferWasmModule(uint32_t transfer_id,
220 Handle<WasmModuleObject> module);
221 /*
214 * Publicly exposed wire format writing methods. 222 * Publicly exposed wire format writing methods.
215 * These are intended for use within the delegate's WriteHostObject method. 223 * These are intended for use within the delegate's WriteHostObject method.
216 */ 224 */
217 bool ReadUint32(uint32_t* value) WARN_UNUSED_RESULT; 225 bool ReadUint32(uint32_t* value) WARN_UNUSED_RESULT;
218 bool ReadUint64(uint64_t* value) WARN_UNUSED_RESULT; 226 bool ReadUint64(uint64_t* value) WARN_UNUSED_RESULT;
219 bool ReadDouble(double* value) WARN_UNUSED_RESULT; 227 bool ReadDouble(double* value) WARN_UNUSED_RESULT;
220 bool ReadRawBytes(size_t length, const void** data) WARN_UNUSED_RESULT; 228 bool ReadRawBytes(size_t length, const void** data) WARN_UNUSED_RESULT;
229 void set_allow_inline_wasm(bool allow_inline_wasm) {
230 allow_inline_wasm_ = allow_inline_wasm;
231 }
221 232
222 private: 233 private:
223 // Reading the wire format. 234 // Reading the wire format.
224 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT; 235 Maybe<SerializationTag> PeekTag() const WARN_UNUSED_RESULT;
225 void ConsumeTag(SerializationTag peeked_tag); 236 void ConsumeTag(SerializationTag peeked_tag);
226 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT; 237 Maybe<SerializationTag> ReadTag() WARN_UNUSED_RESULT;
227 template <typename T> 238 template <typename T>
228 Maybe<T> ReadVarint() WARN_UNUSED_RESULT; 239 Maybe<T> ReadVarint() WARN_UNUSED_RESULT;
229 template <typename T> 240 template <typename T>
230 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; 241 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT;
231 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; 242 Maybe<double> ReadDouble() WARN_UNUSED_RESULT;
232 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; 243 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT;
244 bool allow_inline_wasm() const { return allow_inline_wasm_; }
233 245
234 // Reads a string if it matches the one provided. 246 // Reads a string if it matches the one provided.
235 // Returns true if this was the case. Otherwise, nothing is consumed. 247 // Returns true if this was the case. Otherwise, nothing is consumed.
236 bool ReadExpectedString(Handle<String> expected) WARN_UNUSED_RESULT; 248 bool ReadExpectedString(Handle<String> expected) WARN_UNUSED_RESULT;
237 249
238 // Like ReadObject, but skips logic for special cases in simulating the 250 // Like ReadObject, but skips logic for special cases in simulating the
239 // "stack machine". 251 // "stack machine".
240 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; 252 MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT;
241 253
242 // Reads a string intended to be part of a more complicated object. 254 // Reads a string intended to be part of a more complicated object.
(...skipping 13 matching lines...) Expand all
256 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; 268 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT;
257 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; 269 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT;
258 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; 270 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT;
259 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; 271 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT;
260 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT; 272 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT;
261 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared) 273 MaybeHandle<JSArrayBuffer> ReadTransferredJSArrayBuffer(bool is_shared)
262 WARN_UNUSED_RESULT; 274 WARN_UNUSED_RESULT;
263 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( 275 MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView(
264 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; 276 Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT;
265 MaybeHandle<JSObject> ReadWasmModule() WARN_UNUSED_RESULT; 277 MaybeHandle<JSObject> ReadWasmModule() WARN_UNUSED_RESULT;
278 MaybeHandle<JSObject> ReadWasmModuleTransfer() WARN_UNUSED_RESULT;
266 MaybeHandle<JSObject> ReadHostObject() WARN_UNUSED_RESULT; 279 MaybeHandle<JSObject> ReadHostObject() WARN_UNUSED_RESULT;
267 280
268 /* 281 /*
269 * Reads key-value pairs into the object until the specified end tag is 282 * Reads key-value pairs into the object until the specified end tag is
270 * encountered. If successful, returns the number of properties read. 283 * encountered. If successful, returns the number of properties read.
271 */ 284 */
272 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, 285 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object,
273 SerializationTag end_tag, 286 SerializationTag end_tag,
274 bool can_use_transitions); 287 bool can_use_transitions);
275 288
276 // Manipulating the map from IDs to reified objects. 289 // Manipulating the map from IDs to reified objects.
277 bool HasObjectWithID(uint32_t id); 290 bool HasObjectWithID(uint32_t id);
278 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); 291 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id);
279 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); 292 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object);
280 293
281 Isolate* const isolate_; 294 Isolate* const isolate_;
282 v8::ValueDeserializer::Delegate* const delegate_; 295 v8::ValueDeserializer::Delegate* const delegate_;
283 const uint8_t* position_; 296 const uint8_t* position_;
284 const uint8_t* const end_; 297 const uint8_t* const end_;
285 PretenureFlag pretenure_; 298 PretenureFlag pretenure_;
286 uint32_t version_ = 0; 299 uint32_t version_ = 0;
287 uint32_t next_id_ = 0; 300 uint32_t next_id_ = 0;
301 bool allow_inline_wasm_ = false;
288 302
289 // Always global handles. 303 // Always global handles.
290 Handle<FixedArray> id_map_; 304 Handle<FixedArray> id_map_;
291 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; 305 MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_;
306 std::vector<Handle<WasmModuleObject>> transferred_wasm_modules_;
jbroman 2017/03/17 14:44:37 Hmm. This seems to require that the handles remain
Mircea Trofin 2017/03/17 16:55:31 As discussed offline - this alternative appears to
292 307
293 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); 308 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer);
294 }; 309 };
295 310
296 } // namespace internal 311 } // namespace internal
297 } // namespace v8 312 } // namespace v8
298 313
299 #endif // V8_VALUE_SERIALIZER_H_ 314 #endif // V8_VALUE_SERIALIZER_H_
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/value-serializer.cc » ('j') | test/unittests/value-serializer-unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698