Index: src/value-serializer.h |
diff --git a/src/value-serializer.h b/src/value-serializer.h |
index 93fc15166d4d0b375039b6e548d2c324011c8950..b05b875789f1130dd99c7a38d561cd90448cfb54 100644 |
--- a/src/value-serializer.h |
+++ b/src/value-serializer.h |
@@ -13,6 +13,7 @@ |
#include "src/base/macros.h" |
#include "src/identity-map.h" |
#include "src/vector.h" |
+#include "src/zone-containers.h" |
#include "src/zone.h" |
namespace v8 { |
@@ -51,6 +52,9 @@ class ValueSerializer { |
/* |
* Serializes a V8 object into the buffer. |
+ * |
+ * Code internal to this class should use WriteObjectInternal instead, which |
+ * will use the same states stack to avoid recursion on the call stack. |
*/ |
Maybe<bool> WriteObject(Handle<Object> object) WARN_UNUSED_RESULT; |
@@ -82,6 +86,11 @@ class ValueSerializer { |
uint8_t* ReserveRawBytes(size_t bytes); |
// Writing V8 objects of various kinds. |
+ // These are expected to be used internally only. For objects which require |
+ // recursive serialization, a state is pushed before returning. |
+ // WriteObject will iterate on the states until the object is fully |
+ // serialized. |
+ Maybe<bool> WriteObjectInternal(Handle<Object> object) WARN_UNUSED_RESULT; |
void WriteOddball(Oddball* oddball); |
void WriteSmi(Smi* smi); |
void WriteHeapNumber(HeapNumber* number); |
@@ -97,14 +106,6 @@ class ValueSerializer { |
Maybe<bool> WriteJSArrayBuffer(JSArrayBuffer* array_buffer); |
Maybe<bool> WriteJSArrayBufferView(JSArrayBufferView* array_buffer); |
- /* |
- * Reads the specified keys from the object and writes key-value pairs to the |
- * buffer. Returns the number of keys actually written, which may be smaller |
- * if some keys are not own properties when accessed. |
- */ |
- Maybe<uint32_t> WriteJSObjectProperties( |
- Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; |
- |
Isolate* const isolate_; |
std::vector<uint8_t> buffer_; |
Zone zone_; |
@@ -118,6 +119,10 @@ class ValueSerializer { |
// A similar map, for transferred array buffers. |
IdentityMap<uint32_t> array_buffer_transfer_map_; |
+ // A stack of states. |
+ struct State; |
+ ZoneVector<State> states_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ValueSerializer); |
}; |
@@ -176,12 +181,12 @@ class ValueDeserializer { |
Maybe<double> ReadDouble() WARN_UNUSED_RESULT; |
Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; |
- // Like ReadObject, but skips logic for special cases in simulating the |
- // "stack machine". |
- MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; |
- |
// Reading V8 objects of specific kinds. |
- // The tag is assumed to have already been read. |
+ // These are expected to be used internally only. For objects which require |
+ // recursive deserialization, a state is pushed before returning. |
+ // ReadObject will iterate on the states until the object is fully |
+ // serialized. |
+ MaybeHandle<Object> ReadObjectInternal() WARN_UNUSED_RESULT; |
MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; |
MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; |
MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; |
@@ -198,13 +203,6 @@ class ValueDeserializer { |
MaybeHandle<JSArrayBufferView> ReadJSArrayBufferView( |
Handle<JSArrayBuffer> buffer) WARN_UNUSED_RESULT; |
- /* |
- * Reads key-value pairs into the object until the specified end tag is |
- * encountered. If successful, returns the number of properties read. |
- */ |
- Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, |
- SerializationTag end_tag); |
- |
// Manipulating the map from IDs to reified objects. |
bool HasObjectWithID(uint32_t id); |
MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); |
@@ -220,6 +218,10 @@ class ValueDeserializer { |
Handle<SeededNumberDictionary> id_map_; |
MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; |
+ // A stack of states. |
+ struct State; |
+ std::vector<State> states_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
}; |