5 #ifndef V8_VALUE_SERIALIZER_H_ 6 #define V8_VALUE_SERIALIZER_H_ 11 #include "include/v8.h" 12 #include "src/base/compiler-specific.h" 13 #include "src/base/macros.h" 14 #include "src/identity-map.h" 15 #include "src/maybe-handles.h" 16 #include "src/message-template.h" 17 #include "src/vector.h" 18 #include "src/zone/zone.h" 27 class JSArrayBufferView;
33 class MutableHeapNumber;
37 class WasmMemoryObject;
38 class WasmModuleObject;
40 enum class SerializationTag : uint8_t;
67 std::vector<uint8_t> ReleaseBuffer();
73 std::pair<uint8_t*, size_t> Release();
80 void TransferArrayBuffer(
uint32_t transfer_id,
88 void WriteUint64(uint64_t value);
89 void WriteRawBytes(
const void* source,
size_t length);
90 void WriteDouble(
double value);
99 void SetTreatArrayBufferViewsAsHostObjects(
bool mode);
103 Maybe<bool> ExpandBuffer(
size_t required_capacity);
106 void WriteTag(SerializationTag tag);
107 template <
typename T>
108 void WriteVarint(
T value);
109 template <
typename T>
110 void WriteZigZag(
T value);
113 void WriteBigIntContents(
BigInt* bigint);
117 void WriteOddball(
Oddball* oddball);
118 void WriteSmi(
Smi smi);
121 void WriteBigInt(
BigInt* bigint);
124 V8_WARN_UNUSED_RESULT;
128 void WriteJSDate(
JSDate* date);
130 void WriteJSRegExp(
JSRegExp* regexp);
134 V8_WARN_UNUSED_RESULT;
137 V8_WARN_UNUSED_RESULT;
139 V8_WARN_UNUSED_RESULT;
154 void ThrowDataCloneError(MessageTemplate template_index);
155 V8_NOINLINE
void ThrowDataCloneError(MessageTemplate template_index,
162 uint8_t* buffer_ =
nullptr;
163 size_t buffer_size_ = 0;
164 size_t buffer_capacity_ = 0;
165 bool treat_array_buffer_views_as_host_objects_ =
false;
166 bool out_of_memory_ =
false;
201 uint32_t GetWireFormatVersion()
const {
return version_; }
216 V8_WARN_UNUSED_RESULT;
222 void TransferArrayBuffer(
uint32_t transfer_id,
229 bool ReadUint32(
uint32_t* value) V8_WARN_UNUSED_RESULT;
230 bool ReadUint64(uint64_t* value) V8_WARN_UNUSED_RESULT;
231 bool ReadDouble(
double* value) V8_WARN_UNUSED_RESULT;
232 bool ReadRawBytes(
size_t length,
const void** data) V8_WARN_UNUSED_RESULT;
233 void set_expect_inline_wasm(
bool expect_inline_wasm) {
234 expect_inline_wasm_ = expect_inline_wasm;
240 void ConsumeTag(SerializationTag peeked_tag);
242 template <
typename T>
243 Maybe<T> ReadVarint() V8_WARN_UNUSED_RESULT;
244 template <
typename T>
245 Maybe<T> ReadZigZag() V8_WARN_UNUSED_RESULT;
248 bool expect_inline_wasm()
const {
return expect_inline_wasm_; }
252 bool ReadExpectedString(
Handle<String> expected) V8_WARN_UNUSED_RESULT;
278 V8_WARN_UNUSED_RESULT;
280 V8_WARN_UNUSED_RESULT;
293 SerializationTag end_tag,
294 bool can_use_transitions);
303 const uint8_t* position_;
304 const uint8_t*
const end_;
305 PretenureFlag pretenure_;
308 bool expect_inline_wasm_ =
false;
320 #endif // V8_VALUE_SERIALIZER_H_