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

Side by Side Diff: runtime/vm/clustered_snapshot.h

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 | « runtime/vm/class_table.cc ('k') | runtime/vm/clustered_snapshot.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_CLUSTERED_SNAPSHOT_H_ 5 #ifndef RUNTIME_VM_CLUSTERED_SNAPSHOT_H_
6 #define RUNTIME_VM_CLUSTERED_SNAPSHOT_H_ 6 #define RUNTIME_VM_CLUSTERED_SNAPSHOT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // Write the cluster type and information needed to allocate the cluster's 58 // Write the cluster type and information needed to allocate the cluster's
59 // objects. For fixed sized objects, this is just the object count. For 59 // objects. For fixed sized objects, this is just the object count. For
60 // variable sized objects, this is the object count and length of each object. 60 // variable sized objects, this is the object count and length of each object.
61 virtual void WriteAlloc(Serializer* serializer) = 0; 61 virtual void WriteAlloc(Serializer* serializer) = 0;
62 62
63 // Write the byte and reference data of the cluster's objects. 63 // Write the byte and reference data of the cluster's objects.
64 virtual void WriteFill(Serializer* serializer) = 0; 64 virtual void WriteFill(Serializer* serializer) = 0;
65 }; 65 };
66 66
67
68 class DeserializationCluster : public ZoneAllocated { 67 class DeserializationCluster : public ZoneAllocated {
69 public: 68 public:
70 DeserializationCluster() : start_index_(-1), stop_index_(-1) {} 69 DeserializationCluster() : start_index_(-1), stop_index_(-1) {}
71 virtual ~DeserializationCluster() {} 70 virtual ~DeserializationCluster() {}
72 71
73 // Allocate memory for all objects in the cluster and write their addresses 72 // Allocate memory for all objects in the cluster and write their addresses
74 // into the ref array. Do not touch this memory. 73 // into the ref array. Do not touch this memory.
75 virtual void ReadAlloc(Deserializer* deserializer) = 0; 74 virtual void ReadAlloc(Deserializer* deserializer) = 0;
76 75
77 // Initialize the cluster's objects. Do not touch the memory of other objects. 76 // Initialize the cluster's objects. Do not touch the memory of other objects.
78 virtual void ReadFill(Deserializer* deserializer) = 0; 77 virtual void ReadFill(Deserializer* deserializer) = 0;
79 78
80 // Complete any action that requires the full graph to be deserialized, such 79 // Complete any action that requires the full graph to be deserialized, such
81 // as rehashing. 80 // as rehashing.
82 virtual void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) {} 81 virtual void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) {}
83 82
84 protected: 83 protected:
85 // The range of the ref array that belongs to this cluster. 84 // The range of the ref array that belongs to this cluster.
86 intptr_t start_index_; 85 intptr_t start_index_;
87 intptr_t stop_index_; 86 intptr_t stop_index_;
88 }; 87 };
89 88
90
91 class SmiObjectIdPair { 89 class SmiObjectIdPair {
92 public: 90 public:
93 SmiObjectIdPair() : smi_(NULL), id_(0) {} 91 SmiObjectIdPair() : smi_(NULL), id_(0) {}
94 RawSmi* smi_; 92 RawSmi* smi_;
95 intptr_t id_; 93 intptr_t id_;
96 94
97 bool operator==(const SmiObjectIdPair& other) const { 95 bool operator==(const SmiObjectIdPair& other) const {
98 return (smi_ == other.smi_) && (id_ == other.id_); 96 return (smi_ == other.smi_) && (id_ == other.id_);
99 } 97 }
100 }; 98 };
101 99
102
103 class SmiObjectIdPairTrait { 100 class SmiObjectIdPairTrait {
104 public: 101 public:
105 typedef RawSmi* Key; 102 typedef RawSmi* Key;
106 typedef intptr_t Value; 103 typedef intptr_t Value;
107 typedef SmiObjectIdPair Pair; 104 typedef SmiObjectIdPair Pair;
108 105
109 static Key KeyOf(Pair kv) { return kv.smi_; } 106 static Key KeyOf(Pair kv) { return kv.smi_; }
110 static Value ValueOf(Pair kv) { return kv.id_; } 107 static Value ValueOf(Pair kv) { return kv.id_; }
111 static inline intptr_t Hashcode(Key key) { return Smi::Value(key); } 108 static inline intptr_t Hashcode(Key key) { return Smi::Value(key); }
112 static inline bool IsKeyEqual(Pair kv, Key key) { return kv.smi_ == key; } 109 static inline bool IsKeyEqual(Pair kv, Key key) { return kv.smi_ == key; }
113 }; 110 };
114 111
115
116 typedef DirectChainedHashMap<SmiObjectIdPairTrait> SmiObjectIdMap; 112 typedef DirectChainedHashMap<SmiObjectIdPairTrait> SmiObjectIdMap;
117 113
118
119 class Serializer : public StackResource { 114 class Serializer : public StackResource {
120 public: 115 public:
121 Serializer(Thread* thread, 116 Serializer(Thread* thread,
122 Snapshot::Kind kind, 117 Snapshot::Kind kind,
123 uint8_t** buffer, 118 uint8_t** buffer,
124 ReAlloc alloc, 119 ReAlloc alloc,
125 intptr_t initial_size, 120 intptr_t initial_size,
126 ImageWriter* image_writer_); 121 ImageWriter* image_writer_);
127 ~Serializer(); 122 ~Serializer();
128 123
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 SmiObjectIdMap smi_ids_; 268 SmiObjectIdMap smi_ids_;
274 269
275 #if defined(SNAPSHOT_BACKTRACE) 270 #if defined(SNAPSHOT_BACKTRACE)
276 RawObject* current_parent_; 271 RawObject* current_parent_;
277 GrowableArray<Object*> parent_pairs_; 272 GrowableArray<Object*> parent_pairs_;
278 #endif 273 #endif
279 274
280 DISALLOW_IMPLICIT_CONSTRUCTORS(Serializer); 275 DISALLOW_IMPLICIT_CONSTRUCTORS(Serializer);
281 }; 276 };
282 277
283
284 class Deserializer : public StackResource { 278 class Deserializer : public StackResource {
285 public: 279 public:
286 Deserializer(Thread* thread, 280 Deserializer(Thread* thread,
287 Snapshot::Kind kind, 281 Snapshot::Kind kind,
288 const uint8_t* buffer, 282 const uint8_t* buffer,
289 intptr_t size, 283 intptr_t size,
290 const uint8_t* instructions_buffer, 284 const uint8_t* instructions_buffer,
291 const uint8_t* data_buffer); 285 const uint8_t* data_buffer);
292 ~Deserializer(); 286 ~Deserializer();
293 287
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 ReadStream stream_; 367 ReadStream stream_;
374 ImageReader* image_reader_; 368 ImageReader* image_reader_;
375 intptr_t num_base_objects_; 369 intptr_t num_base_objects_;
376 intptr_t num_objects_; 370 intptr_t num_objects_;
377 intptr_t num_clusters_; 371 intptr_t num_clusters_;
378 RawArray* refs_; 372 RawArray* refs_;
379 intptr_t next_ref_index_; 373 intptr_t next_ref_index_;
380 DeserializationCluster** clusters_; 374 DeserializationCluster** clusters_;
381 }; 375 };
382 376
383
384 class FullSnapshotWriter { 377 class FullSnapshotWriter {
385 public: 378 public:
386 static const intptr_t kInitialSize = 64 * KB; 379 static const intptr_t kInitialSize = 64 * KB;
387 FullSnapshotWriter(Snapshot::Kind kind, 380 FullSnapshotWriter(Snapshot::Kind kind,
388 uint8_t** vm_snapshot_data_buffer, 381 uint8_t** vm_snapshot_data_buffer,
389 uint8_t** isolate_snapshot_data_buffer, 382 uint8_t** isolate_snapshot_data_buffer,
390 ReAlloc alloc, 383 ReAlloc alloc,
391 ImageWriter* vm_image_writer, 384 ImageWriter* vm_image_writer,
392 ImageWriter* iso_image_writer); 385 ImageWriter* iso_image_writer);
393 ~FullSnapshotWriter(); 386 ~FullSnapshotWriter();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 425
433 // Stats for benchmarking. 426 // Stats for benchmarking.
434 intptr_t clustered_vm_size_; 427 intptr_t clustered_vm_size_;
435 intptr_t clustered_isolate_size_; 428 intptr_t clustered_isolate_size_;
436 intptr_t mapped_data_size_; 429 intptr_t mapped_data_size_;
437 intptr_t mapped_instructions_size_; 430 intptr_t mapped_instructions_size_;
438 431
439 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); 432 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter);
440 }; 433 };
441 434
442
443 class FullSnapshotReader { 435 class FullSnapshotReader {
444 public: 436 public:
445 FullSnapshotReader(const Snapshot* snapshot, 437 FullSnapshotReader(const Snapshot* snapshot,
446 const uint8_t* instructions_buffer, 438 const uint8_t* instructions_buffer,
447 Thread* thread); 439 Thread* thread);
448 ~FullSnapshotReader() {} 440 ~FullSnapshotReader() {}
449 441
450 RawApiError* ReadVMSnapshot(); 442 RawApiError* ReadVMSnapshot();
451 RawApiError* ReadIsolateSnapshot(); 443 RawApiError* ReadIsolateSnapshot();
452 444
453 private: 445 private:
454 Snapshot::Kind kind_; 446 Snapshot::Kind kind_;
455 Thread* thread_; 447 Thread* thread_;
456 const uint8_t* buffer_; 448 const uint8_t* buffer_;
457 intptr_t size_; 449 intptr_t size_;
458 const uint8_t* instructions_buffer_; 450 const uint8_t* instructions_buffer_;
459 const uint8_t* data_buffer_; 451 const uint8_t* data_buffer_;
460 452
461 DISALLOW_COPY_AND_ASSIGN(FullSnapshotReader); 453 DISALLOW_COPY_AND_ASSIGN(FullSnapshotReader);
462 }; 454 };
463 455
464 } // namespace dart 456 } // namespace dart
465 457
466 #endif // RUNTIME_VM_CLUSTERED_SNAPSHOT_H_ 458 #endif // RUNTIME_VM_CLUSTERED_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/class_table.cc ('k') | runtime/vm/clustered_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698