diff options
Diffstat (limited to 'src/value-serializer.h')
-rw-r--r-- | src/value-serializer.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/value-serializer.h b/src/value-serializer.h index 86e21cf8..7961b2ea 100644 --- a/src/value-serializer.h +++ b/src/value-serializer.h @@ -84,9 +84,18 @@ class ValueSerializer { void WriteRawBytes(const void* source, size_t length); void WriteDouble(double value); + /* + * Indicate whether to treat ArrayBufferView objects as host objects, + * i.e. pass them to Delegate::WriteHostObject. This should not be + * called when no Delegate was passed. + * + * The default is not to treat ArrayBufferViews as host objects. + */ + void SetTreatArrayBufferViewsAsHostObjects(bool mode); + private: // Managing allocations of the internal buffer. - void ExpandBuffer(size_t required_capacity); + Maybe<bool> ExpandBuffer(size_t required_capacity); // Writing the wire format. void WriteTag(SerializationTag tag); @@ -96,7 +105,7 @@ class ValueSerializer { void WriteZigZag(T value); void WriteOneByteString(Vector<const uint8_t> chars); void WriteTwoByteString(Vector<const uc16> chars); - uint8_t* ReserveRawBytes(size_t bytes); + Maybe<uint8_t*> ReserveRawBytes(size_t bytes); // Writing V8 objects of various kinds. void WriteOddball(Oddball* oddball); @@ -112,7 +121,8 @@ class ValueSerializer { void WriteJSRegExp(JSRegExp* regexp); Maybe<bool> WriteJSMap(Handle<JSMap> map) WARN_UNUSED_RESULT; Maybe<bool> WriteJSSet(Handle<JSSet> map) WARN_UNUSED_RESULT; - Maybe<bool> WriteJSArrayBuffer(JSArrayBuffer* array_buffer); + Maybe<bool> WriteJSArrayBuffer(Handle<JSArrayBuffer> array_buffer) + WARN_UNUSED_RESULT; Maybe<bool> WriteJSArrayBufferView(JSArrayBufferView* array_buffer); Maybe<bool> WriteWasmModule(Handle<JSObject> object) WARN_UNUSED_RESULT; Maybe<bool> WriteHostObject(Handle<JSObject> object) WARN_UNUSED_RESULT; @@ -133,21 +143,25 @@ class ValueSerializer { V8_NOINLINE void ThrowDataCloneError(MessageTemplate::Template template_index, Handle<Object> arg0); + Maybe<bool> ThrowIfOutOfMemory(); + Isolate* const isolate_; v8::ValueSerializer::Delegate* const delegate_; + bool treat_array_buffer_views_as_host_objects_ = false; uint8_t* buffer_ = nullptr; size_t buffer_size_ = 0; size_t buffer_capacity_ = 0; + bool out_of_memory_ = false; Zone zone_; // To avoid extra lookups in the identity map, ID+1 is actually stored in the // map (checking if the used identity is zero is the fast way of checking if // the entry is new). - IdentityMap<uint32_t> id_map_; + IdentityMap<uint32_t, ZoneAllocationPolicy> id_map_; uint32_t next_id_ = 0; // A similar map, for transferred array buffers. - IdentityMap<uint32_t> array_buffer_transfer_map_; + IdentityMap<uint32_t, ZoneAllocationPolicy> array_buffer_transfer_map_; DISALLOW_COPY_AND_ASSIGN(ValueSerializer); }; @@ -225,9 +239,15 @@ class ValueDeserializer { // "stack machine". MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; + // Reads a string intended to be part of a more complicated object. + // Before v12, these are UTF-8 strings. After, they can be any encoding + // permissible for a string (with the relevant tag). + MaybeHandle<String> ReadString() WARN_UNUSED_RESULT; + // Reading V8 objects of specific kinds. // The tag is assumed to have already been read. MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; + MaybeHandle<String> ReadOneByteString() WARN_UNUSED_RESULT; MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; |