Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: src/value-serializer.h

Issue 2265603002: Blink-compatible serialization of Boolean, Number and String objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@vs-date
Patch Set: remove HasSpecificClassOf Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/value-serializer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 JSValue;
24 class Object; 25 class Object;
25 class Oddball; 26 class Oddball;
26 class Smi; 27 class Smi;
27 28
28 enum class SerializationTag : uint8_t; 29 enum class SerializationTag : uint8_t;
29 30
30 /** 31 /**
31 * Writes V8 objects in a binary format that allows the objects to be cloned 32 * Writes V8 objects in a binary format that allows the objects to be cloned
32 * according to the HTML structured clone algorithm. 33 * according to the HTML structured clone algorithm.
33 * 34 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 69
69 // Writing V8 objects of various kinds. 70 // Writing V8 objects of various kinds.
70 void WriteOddball(Oddball* oddball); 71 void WriteOddball(Oddball* oddball);
71 void WriteSmi(Smi* smi); 72 void WriteSmi(Smi* smi);
72 void WriteHeapNumber(HeapNumber* number); 73 void WriteHeapNumber(HeapNumber* number);
73 void WriteString(Handle<String> string); 74 void WriteString(Handle<String> string);
74 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; 75 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT;
75 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; 76 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT;
76 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT; 77 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT;
77 void WriteJSDate(JSDate* date); 78 void WriteJSDate(JSDate* date);
79 Maybe<bool> WriteJSValue(Handle<JSValue> value) WARN_UNUSED_RESULT;
78 80
79 /* 81 /*
80 * Reads the specified keys from the object and writes key-value pairs to the 82 * Reads the specified keys from the object and writes key-value pairs to the
81 * buffer. Returns the number of keys actually written, which may be smaller 83 * buffer. Returns the number of keys actually written, which may be smaller
82 * if some keys are not own properties when accessed. 84 * if some keys are not own properties when accessed.
83 */ 85 */
84 Maybe<uint32_t> WriteJSObjectProperties( 86 Maybe<uint32_t> WriteJSObjectProperties(
85 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; 87 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT;
86 88
87 Isolate* const isolate_; 89 Isolate* const isolate_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT; 141 Maybe<Vector<const uint8_t>> ReadRawBytes(int size) WARN_UNUSED_RESULT;
140 142
141 // Reading V8 objects of specific kinds. 143 // Reading V8 objects of specific kinds.
142 // The tag is assumed to have already been read. 144 // The tag is assumed to have already been read.
143 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; 145 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT;
144 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; 146 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT;
145 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; 147 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT;
146 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; 148 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT;
147 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; 149 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT;
148 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; 150 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT;
151 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT;
149 152
150 /* 153 /*
151 * Reads key-value pairs into the object until the specified end tag is 154 * Reads key-value pairs into the object until the specified end tag is
152 * encountered. If successful, returns the number of properties read. 155 * encountered. If successful, returns the number of properties read.
153 */ 156 */
154 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, 157 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object,
155 SerializationTag end_tag); 158 SerializationTag end_tag);
156 159
157 // Manipulating the map from IDs to reified objects. 160 // Manipulating the map from IDs to reified objects.
158 bool HasObjectWithID(uint32_t id); 161 bool HasObjectWithID(uint32_t id);
159 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); 162 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id);
160 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); 163 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object);
161 164
162 Isolate* const isolate_; 165 Isolate* const isolate_;
163 const uint8_t* position_; 166 const uint8_t* position_;
164 const uint8_t* const end_; 167 const uint8_t* const end_;
165 uint32_t version_ = 0; 168 uint32_t version_ = 0;
166 Handle<SeededNumberDictionary> id_map_; // Always a global handle. 169 Handle<SeededNumberDictionary> id_map_; // Always a global handle.
167 uint32_t next_id_ = 0; 170 uint32_t next_id_ = 0;
168 171
169 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); 172 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer);
170 }; 173 };
171 174
172 } // namespace internal 175 } // namespace internal
173 } // namespace v8 176 } // namespace v8
174 177
175 #endif // V8_VALUE_SERIALIZER_H_ 178 #endif // V8_VALUE_SERIALIZER_H_
OLDNEW
« no previous file with comments | « no previous file | src/value-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698