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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 void WriteTwoByteString(Vector<const uc16> chars); | 65 void WriteTwoByteString(Vector<const uc16> chars); |
66 uint8_t* ReserveRawBytes(size_t bytes); | 66 uint8_t* ReserveRawBytes(size_t bytes); |
67 | 67 |
68 // Writing V8 objects of various kinds. | 68 // Writing V8 objects of various kinds. |
69 void WriteOddball(Oddball* oddball); | 69 void WriteOddball(Oddball* oddball); |
70 void WriteSmi(Smi* smi); | 70 void WriteSmi(Smi* smi); |
71 void WriteHeapNumber(HeapNumber* number); | 71 void WriteHeapNumber(HeapNumber* number); |
72 void WriteString(Handle<String> string); | 72 void WriteString(Handle<String> string); |
73 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; | 73 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; |
74 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; | 74 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; |
| 75 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT; |
75 | 76 |
76 /* | 77 /* |
77 * Reads the specified keys from the object and writes key-value pairs to the | 78 * Reads the specified keys from the object and writes key-value pairs to the |
78 * buffer. Returns the number of keys actually written, which may be smaller | 79 * buffer. Returns the number of keys actually written, which may be smaller |
79 * if some keys are not own properties when accessed. | 80 * if some keys are not own properties when accessed. |
80 */ | 81 */ |
81 Maybe<uint32_t> WriteJSObjectProperties( | 82 Maybe<uint32_t> WriteJSObjectProperties( |
82 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; | 83 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; |
83 | 84 |
84 Isolate* const isolate_; | 85 Isolate* const isolate_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 template <typename T> | 134 template <typename T> |
134 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; | 135 Maybe<T> ReadZigZag() WARN_UNUSED_RESULT; |
135 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; | 136 Maybe<double> ReadDouble() WARN_UNUSED_RESULT; |
136 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; | 137 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; |
137 | 138 |
138 // Reading V8 objects of specific kinds. | 139 // Reading V8 objects of specific kinds. |
139 // The tag is assumed to have already been read. | 140 // The tag is assumed to have already been read. |
140 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; | 141 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; |
141 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; | 142 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; |
142 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; | 143 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; |
| 144 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; |
| 145 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; |
143 | 146 |
144 /* | 147 /* |
145 * Reads key-value pairs into the object until the specified end tag is | 148 * Reads key-value pairs into the object until the specified end tag is |
146 * encountered. If successful, returns the number of properties read. | 149 * encountered. If successful, returns the number of properties read. |
147 */ | 150 */ |
148 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, | 151 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, |
149 SerializationTag end_tag); | 152 SerializationTag end_tag); |
150 | 153 |
151 // Manipulating the map from IDs to reified objects. | 154 // Manipulating the map from IDs to reified objects. |
152 bool HasObjectWithID(uint32_t id); | 155 bool HasObjectWithID(uint32_t id); |
153 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); | 156 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); |
154 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); | 157 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); |
155 | 158 |
156 Isolate* const isolate_; | 159 Isolate* const isolate_; |
157 const uint8_t* position_; | 160 const uint8_t* position_; |
158 const uint8_t* const end_; | 161 const uint8_t* const end_; |
159 uint32_t version_ = 0; | 162 uint32_t version_ = 0; |
160 Handle<SeededNumberDictionary> id_map_; // Always a global handle. | 163 Handle<SeededNumberDictionary> id_map_; // Always a global handle. |
161 uint32_t next_id_ = 0; | 164 uint32_t next_id_ = 0; |
162 | 165 |
163 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 166 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
164 }; | 167 }; |
165 | 168 |
166 } // namespace internal | 169 } // namespace internal |
167 } // namespace v8 | 170 } // namespace v8 |
168 | 171 |
169 #endif // V8_VALUE_SERIALIZER_H_ | 172 #endif // V8_VALUE_SERIALIZER_H_ |
OLD | NEW |