| 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 |
| 11 #include "include/v8.h" | 11 #include "include/v8.h" |
| 12 #include "src/base/compiler-specific.h" | 12 #include "src/base/compiler-specific.h" |
| 13 #include "src/base/macros.h" | 13 #include "src/base/macros.h" |
| 14 #include "src/identity-map.h" | 14 #include "src/identity-map.h" |
| 15 #include "src/vector.h" | 15 #include "src/vector.h" |
| 16 #include "src/zone.h" | 16 #include "src/zone.h" |
| 17 | 17 |
| 18 namespace v8 { | 18 namespace v8 { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 class HeapNumber; | 21 class HeapNumber; |
| 22 class Isolate; | 22 class Isolate; |
| 23 class JSDate; | 23 class JSDate; |
| 24 class JSRegExp; |
| 24 class JSValue; | 25 class JSValue; |
| 25 class Object; | 26 class Object; |
| 26 class Oddball; | 27 class Oddball; |
| 27 class Smi; | 28 class Smi; |
| 28 | 29 |
| 29 enum class SerializationTag : uint8_t; | 30 enum class SerializationTag : uint8_t; |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * Writes V8 objects in a binary format that allows the objects to be cloned | 33 * Writes V8 objects in a binary format that allows the objects to be cloned |
| 33 * according to the HTML structured clone algorithm. | 34 * according to the HTML structured clone algorithm. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Writing V8 objects of various kinds. | 71 // Writing V8 objects of various kinds. |
| 71 void WriteOddball(Oddball* oddball); | 72 void WriteOddball(Oddball* oddball); |
| 72 void WriteSmi(Smi* smi); | 73 void WriteSmi(Smi* smi); |
| 73 void WriteHeapNumber(HeapNumber* number); | 74 void WriteHeapNumber(HeapNumber* number); |
| 74 void WriteString(Handle<String> string); | 75 void WriteString(Handle<String> string); |
| 75 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; | 76 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; |
| 76 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; | 77 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; |
| 77 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT; | 78 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT; |
| 78 void WriteJSDate(JSDate* date); | 79 void WriteJSDate(JSDate* date); |
| 79 Maybe<bool> WriteJSValue(Handle<JSValue> value) WARN_UNUSED_RESULT; | 80 Maybe<bool> WriteJSValue(Handle<JSValue> value) WARN_UNUSED_RESULT; |
| 81 void WriteJSRegExp(JSRegExp* regexp); |
| 80 | 82 |
| 81 /* | 83 /* |
| 82 * Reads the specified keys from the object and writes key-value pairs to the | 84 * Reads the specified keys from the object and writes key-value pairs to the |
| 83 * buffer. Returns the number of keys actually written, which may be smaller | 85 * buffer. Returns the number of keys actually written, which may be smaller |
| 84 * if some keys are not own properties when accessed. | 86 * if some keys are not own properties when accessed. |
| 85 */ | 87 */ |
| 86 Maybe<uint32_t> WriteJSObjectProperties( | 88 Maybe<uint32_t> WriteJSObjectProperties( |
| 87 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; | 89 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; |
| 88 | 90 |
| 89 Isolate* const isolate_; | 91 Isolate* const isolate_; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 144 |
| 143 // Reading V8 objects of specific kinds. | 145 // Reading V8 objects of specific kinds. |
| 144 // The tag is assumed to have already been read. | 146 // The tag is assumed to have already been read. |
| 145 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; | 147 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; |
| 146 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; | 148 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; |
| 147 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; | 149 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; |
| 148 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; | 150 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; |
| 149 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; | 151 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; |
| 150 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; | 152 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; |
| 151 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; | 153 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; |
| 154 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; |
| 152 | 155 |
| 153 /* | 156 /* |
| 154 * Reads key-value pairs into the object until the specified end tag is | 157 * Reads key-value pairs into the object until the specified end tag is |
| 155 * encountered. If successful, returns the number of properties read. | 158 * encountered. If successful, returns the number of properties read. |
| 156 */ | 159 */ |
| 157 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, | 160 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, |
| 158 SerializationTag end_tag); | 161 SerializationTag end_tag); |
| 159 | 162 |
| 160 // Manipulating the map from IDs to reified objects. | 163 // Manipulating the map from IDs to reified objects. |
| 161 bool HasObjectWithID(uint32_t id); | 164 bool HasObjectWithID(uint32_t id); |
| 162 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); | 165 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); |
| 163 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); | 166 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); |
| 164 | 167 |
| 165 Isolate* const isolate_; | 168 Isolate* const isolate_; |
| 166 const uint8_t* position_; | 169 const uint8_t* position_; |
| 167 const uint8_t* const end_; | 170 const uint8_t* const end_; |
| 168 uint32_t version_ = 0; | 171 uint32_t version_ = 0; |
| 169 Handle<SeededNumberDictionary> id_map_; // Always a global handle. | 172 Handle<SeededNumberDictionary> id_map_; // Always a global handle. |
| 170 uint32_t next_id_ = 0; | 173 uint32_t next_id_ = 0; |
| 171 | 174 |
| 172 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); | 175 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); |
| 173 }; | 176 }; |
| 174 | 177 |
| 175 } // namespace internal | 178 } // namespace internal |
| 176 } // namespace v8 | 179 } // namespace v8 |
| 177 | 180 |
| 178 #endif // V8_VALUE_SERIALIZER_H_ | 181 #endif // V8_VALUE_SERIALIZER_H_ |
| OLD | NEW |