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

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

Issue 2264403004: Blink-compatible serialization of ArrayBuffer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: review comments Created 4 years, 3 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 JSArrayBuffer;
23 class JSDate; 24 class JSDate;
24 class JSMap; 25 class JSMap;
25 class JSRegExp; 26 class JSRegExp;
26 class JSSet; 27 class JSSet;
27 class JSValue; 28 class JSValue;
28 class Object; 29 class Object;
29 class Oddball; 30 class Oddball;
30 class Smi; 31 class Smi;
31 32
32 enum class SerializationTag : uint8_t; 33 enum class SerializationTag : uint8_t;
(...skipping 28 matching lines...) Expand all
61 private: 62 private:
62 // Writing the wire format. 63 // Writing the wire format.
63 void WriteTag(SerializationTag tag); 64 void WriteTag(SerializationTag tag);
64 template <typename T> 65 template <typename T>
65 void WriteVarint(T value); 66 void WriteVarint(T value);
66 template <typename T> 67 template <typename T>
67 void WriteZigZag(T value); 68 void WriteZigZag(T value);
68 void WriteDouble(double value); 69 void WriteDouble(double value);
69 void WriteOneByteString(Vector<const uint8_t> chars); 70 void WriteOneByteString(Vector<const uint8_t> chars);
70 void WriteTwoByteString(Vector<const uc16> chars); 71 void WriteTwoByteString(Vector<const uc16> chars);
72 void WriteRawBytes(const void* source, size_t length);
71 uint8_t* ReserveRawBytes(size_t bytes); 73 uint8_t* ReserveRawBytes(size_t bytes);
72 74
73 // Writing V8 objects of various kinds. 75 // Writing V8 objects of various kinds.
74 void WriteOddball(Oddball* oddball); 76 void WriteOddball(Oddball* oddball);
75 void WriteSmi(Smi* smi); 77 void WriteSmi(Smi* smi);
76 void WriteHeapNumber(HeapNumber* number); 78 void WriteHeapNumber(HeapNumber* number);
77 void WriteString(Handle<String> string); 79 void WriteString(Handle<String> string);
78 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT; 80 Maybe<bool> WriteJSReceiver(Handle<JSReceiver> receiver) WARN_UNUSED_RESULT;
79 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT; 81 Maybe<bool> WriteJSObject(Handle<JSObject> object) WARN_UNUSED_RESULT;
80 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT; 82 Maybe<bool> WriteJSArray(Handle<JSArray> array) WARN_UNUSED_RESULT;
81 void WriteJSDate(JSDate* date); 83 void WriteJSDate(JSDate* date);
82 Maybe<bool> WriteJSValue(Handle<JSValue> value) WARN_UNUSED_RESULT; 84 Maybe<bool> WriteJSValue(Handle<JSValue> value) WARN_UNUSED_RESULT;
83 void WriteJSRegExp(JSRegExp* regexp); 85 void WriteJSRegExp(JSRegExp* regexp);
84 Maybe<bool> WriteJSMap(Handle<JSMap> map) WARN_UNUSED_RESULT; 86 Maybe<bool> WriteJSMap(Handle<JSMap> map) WARN_UNUSED_RESULT;
85 Maybe<bool> WriteJSSet(Handle<JSSet> map) WARN_UNUSED_RESULT; 87 Maybe<bool> WriteJSSet(Handle<JSSet> map) WARN_UNUSED_RESULT;
88 Maybe<bool> WriteJSArrayBuffer(JSArrayBuffer* array_buffer);
86 89
87 /* 90 /*
88 * Reads the specified keys from the object and writes key-value pairs to the 91 * Reads the specified keys from the object and writes key-value pairs to the
89 * buffer. Returns the number of keys actually written, which may be smaller 92 * buffer. Returns the number of keys actually written, which may be smaller
90 * if some keys are not own properties when accessed. 93 * if some keys are not own properties when accessed.
91 */ 94 */
92 Maybe<uint32_t> WriteJSObjectProperties( 95 Maybe<uint32_t> WriteJSObjectProperties(
93 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT; 96 Handle<JSObject> object, Handle<FixedArray> keys) WARN_UNUSED_RESULT;
94 97
95 Isolate* const isolate_; 98 Isolate* const isolate_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT; 154 MaybeHandle<String> ReadUtf8String() WARN_UNUSED_RESULT;
152 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT; 155 MaybeHandle<String> ReadTwoByteString() WARN_UNUSED_RESULT;
153 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT; 156 MaybeHandle<JSObject> ReadJSObject() WARN_UNUSED_RESULT;
154 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT; 157 MaybeHandle<JSArray> ReadSparseJSArray() WARN_UNUSED_RESULT;
155 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT; 158 MaybeHandle<JSArray> ReadDenseJSArray() WARN_UNUSED_RESULT;
156 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT; 159 MaybeHandle<JSDate> ReadJSDate() WARN_UNUSED_RESULT;
157 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT; 160 MaybeHandle<JSValue> ReadJSValue(SerializationTag tag) WARN_UNUSED_RESULT;
158 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT; 161 MaybeHandle<JSRegExp> ReadJSRegExp() WARN_UNUSED_RESULT;
159 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT; 162 MaybeHandle<JSMap> ReadJSMap() WARN_UNUSED_RESULT;
160 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT; 163 MaybeHandle<JSSet> ReadJSSet() WARN_UNUSED_RESULT;
164 MaybeHandle<JSArrayBuffer> ReadJSArrayBuffer() WARN_UNUSED_RESULT;
161 165
162 /* 166 /*
163 * Reads key-value pairs into the object until the specified end tag is 167 * Reads key-value pairs into the object until the specified end tag is
164 * encountered. If successful, returns the number of properties read. 168 * encountered. If successful, returns the number of properties read.
165 */ 169 */
166 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object, 170 Maybe<uint32_t> ReadJSObjectProperties(Handle<JSObject> object,
167 SerializationTag end_tag); 171 SerializationTag end_tag);
168 172
169 // Manipulating the map from IDs to reified objects. 173 // Manipulating the map from IDs to reified objects.
170 bool HasObjectWithID(uint32_t id); 174 bool HasObjectWithID(uint32_t id);
171 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id); 175 MaybeHandle<JSReceiver> GetObjectWithID(uint32_t id);
172 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object); 176 void AddObjectWithID(uint32_t id, Handle<JSReceiver> object);
173 177
174 Isolate* const isolate_; 178 Isolate* const isolate_;
175 const uint8_t* position_; 179 const uint8_t* position_;
176 const uint8_t* const end_; 180 const uint8_t* const end_;
177 uint32_t version_ = 0; 181 uint32_t version_ = 0;
178 Handle<SeededNumberDictionary> id_map_; // Always a global handle. 182 Handle<SeededNumberDictionary> id_map_; // Always a global handle.
179 uint32_t next_id_ = 0; 183 uint32_t next_id_ = 0;
180 184
181 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); 185 DISALLOW_COPY_AND_ASSIGN(ValueDeserializer);
182 }; 186 };
183 187
184 } // namespace internal 188 } // namespace internal
185 } // namespace v8 189 } // namespace v8
186 190
187 #endif // V8_VALUE_SERIALIZER_H_ 191 #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