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

Side by Side Diff: src/snapshot/serializer.h

Issue 2052433003: [snapshot] make snapshot sink a non-dynamic member of the serializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@noref
Patch Set: rebase Created 4 years, 6 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 | « src/snapshot/partial-serializer.cc ('k') | src/snapshot/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_SNAPSHOT_SERIALIZER_H_ 5 #ifndef V8_SNAPSHOT_SERIALIZER_H_
6 #define V8_SNAPSHOT_SERIALIZER_H_ 6 #define V8_SNAPSHOT_SERIALIZER_H_
7 7
8 #include "src/isolate.h" 8 #include "src/isolate.h"
9 #include "src/log.h" 9 #include "src/log.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 address_to_name_map_.Insert(code->address(), name, length); 113 address_to_name_map_.Insert(code->address(), name, length);
114 } 114 }
115 115
116 NameMap address_to_name_map_; 116 NameMap address_to_name_map_;
117 Isolate* isolate_; 117 Isolate* isolate_;
118 }; 118 };
119 119
120 // There can be only one serializer per V8 process. 120 // There can be only one serializer per V8 process.
121 class Serializer : public SerializerDeserializer { 121 class Serializer : public SerializerDeserializer {
122 public: 122 public:
123 Serializer(Isolate* isolate, SnapshotByteSink* sink); 123 explicit Serializer(Isolate* isolate);
124 ~Serializer() override; 124 ~Serializer() override;
125 125
126 void EncodeReservations(List<SerializedData::Reservation>* out) const; 126 void EncodeReservations(List<SerializedData::Reservation>* out) const;
127 127
128 void SerializeDeferredObjects(); 128 void SerializeDeferredObjects();
129 129
130 Isolate* isolate() const { return isolate_; } 130 Isolate* isolate() const { return isolate_; }
131 131
132 SerializerReferenceMap* reference_map() { return &reference_map_; } 132 SerializerReferenceMap* reference_map() { return &reference_map_; }
133 RootIndexMap* root_index_map() { return &root_index_map_; } 133 RootIndexMap* root_index_map() { return &root_index_map_; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 // Emit alignment prefix if necessary, return required padding space in bytes. 171 // Emit alignment prefix if necessary, return required padding space in bytes.
172 int PutAlignmentPrefix(HeapObject* object); 172 int PutAlignmentPrefix(HeapObject* object);
173 173
174 // Returns true if the object was successfully serialized. 174 // Returns true if the object was successfully serialized.
175 bool SerializeKnownObject(HeapObject* obj, HowToCode how_to_code, 175 bool SerializeKnownObject(HeapObject* obj, HowToCode how_to_code,
176 WhereToPoint where_to_point, int skip); 176 WhereToPoint where_to_point, int skip);
177 177
178 inline void FlushSkip(int skip) { 178 inline void FlushSkip(int skip) {
179 if (skip != 0) { 179 if (skip != 0) {
180 sink_->Put(kSkip, "SkipFromSerializeObject"); 180 sink_.Put(kSkip, "SkipFromSerializeObject");
181 sink_->PutInt(skip, "SkipDistanceFromSerializeObject"); 181 sink_.PutInt(skip, "SkipDistanceFromSerializeObject");
182 } 182 }
183 } 183 }
184 184
185 bool BackReferenceIsAlreadyAllocated(SerializerReference back_reference); 185 bool BackReferenceIsAlreadyAllocated(SerializerReference back_reference);
186 186
187 // This will return the space for an object. 187 // This will return the space for an object.
188 SerializerReference AllocateLargeObject(int size); 188 SerializerReference AllocateLargeObject(int size);
189 SerializerReference Allocate(AllocationSpace space, int size); 189 SerializerReference Allocate(AllocationSpace space, int size);
190 int EncodeExternalReference(Address addr) { 190 int EncodeExternalReference(Address addr) {
191 return external_reference_encoder_.Encode(addr); 191 return external_reference_encoder_.Encode(addr);
192 } 192 }
193 193
194 bool HasNotExceededFirstPageOfEachSpace(); 194 bool HasNotExceededFirstPageOfEachSpace();
195 195
196 // GetInt reads 4 bytes at once, requiring padding at the end. 196 // GetInt reads 4 bytes at once, requiring padding at the end.
197 void Pad(); 197 void Pad();
198 198
199 // We may not need the code address map for logging for every instance 199 // We may not need the code address map for logging for every instance
200 // of the serializer. Initialize it on demand. 200 // of the serializer. Initialize it on demand.
201 void InitializeCodeAddressMap(); 201 void InitializeCodeAddressMap();
202 202
203 Code* CopyCode(Code* code); 203 Code* CopyCode(Code* code);
204 204
205 inline uint32_t max_chunk_size(int space) const { 205 inline uint32_t max_chunk_size(int space) const {
206 DCHECK_LE(0, space); 206 DCHECK_LE(0, space);
207 DCHECK_LT(space, kNumberOfSpaces); 207 DCHECK_LT(space, kNumberOfSpaces);
208 return max_chunk_size_[space]; 208 return max_chunk_size_[space];
209 } 209 }
210 210
211 SnapshotByteSink* sink() const { return sink_; } 211 const SnapshotByteSink* sink() const { return &sink_; }
212 212
213 void QueueDeferredObject(HeapObject* obj) { 213 void QueueDeferredObject(HeapObject* obj) {
214 DCHECK(reference_map_.Lookup(obj).is_back_reference()); 214 DCHECK(reference_map_.Lookup(obj).is_back_reference());
215 deferred_objects_.Add(obj); 215 deferred_objects_.Add(obj);
216 } 216 }
217 217
218 void OutputStatistics(const char* name); 218 void OutputStatistics(const char* name);
219 219
220 Isolate* isolate_; 220 Isolate* isolate_;
221 221
222 SnapshotByteSink* sink_; 222 SnapshotByteSink sink_;
223 ExternalReferenceEncoder external_reference_encoder_; 223 ExternalReferenceEncoder external_reference_encoder_;
224 224
225 SerializerReferenceMap reference_map_; 225 SerializerReferenceMap reference_map_;
226 RootIndexMap root_index_map_; 226 RootIndexMap root_index_map_;
227 227
228 int recursion_depth_; 228 int recursion_depth_;
229 229
230 friend class Deserializer; 230 friend class Deserializer;
231 friend class ObjectSerializer; 231 friend class ObjectSerializer;
232 friend class RecursionScope; 232 friend class RecursionScope;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 SnapshotByteSink* sink_; 316 SnapshotByteSink* sink_;
317 int reference_representation_; 317 int reference_representation_;
318 int bytes_processed_so_far_; 318 int bytes_processed_so_far_;
319 bool code_has_been_output_; 319 bool code_has_been_output_;
320 }; 320 };
321 321
322 } // namespace internal 322 } // namespace internal
323 } // namespace v8 323 } // namespace v8
324 324
325 #endif // V8_SNAPSHOT_SERIALIZER_H_ 325 #endif // V8_SNAPSHOT_SERIALIZER_H_
OLDNEW
« no previous file with comments | « src/snapshot/partial-serializer.cc ('k') | src/snapshot/serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698