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

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

Issue 8222017: Fix compilation warnings/errors seen with newer versions of gcc compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 VM_SNAPSHOT_H_ 5 #ifndef VM_SNAPSHOT_H_
6 #define VM_SNAPSHOT_H_ 6 #define VM_SNAPSHOT_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assert.h" 9 #include "vm/assert.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 }; 52 };
53 53
54 54
55 // Structure capturing the raw snapshot. 55 // Structure capturing the raw snapshot.
56 class Snapshot { 56 class Snapshot {
57 public: 57 public:
58 static const int kHeaderSize = 2 * sizeof(int32_t); 58 static const int kHeaderSize = 2 * sizeof(int32_t);
59 static const int kLengthIndex = 0; 59 static const int kLengthIndex = 0;
60 static const int kSnapshotFlagIndex = 1; 60 static const int kSnapshotFlagIndex = 1;
61 61
62 static Snapshot* SetupFromBuffer(void* raw_memory); 62 static const Snapshot* SetupFromBuffer(const void* raw_memory);
63 63
64 // Getters. 64 // Getters.
65 uint8_t* content() { return content_; } 65 const uint8_t* content() const { return content_; }
66 int32_t length() const { return length_; } 66 int32_t length() const { return length_; }
67 67
68 bool IsPartialSnapshot() const { return full_snapshot_ == 0; } 68 bool IsPartialSnapshot() const { return full_snapshot_ == 0; }
69 bool IsFullSnapshot() const { return full_snapshot_ != 0; } 69 bool IsFullSnapshot() const { return full_snapshot_ != 0; }
70 int32_t Size() const { return length_ + sizeof(Snapshot); } 70 int32_t Size() const { return length_ + sizeof(Snapshot); }
71 uint8_t* Addr() { return reinterpret_cast<uint8_t*>(this); } 71 uint8_t* Addr() { return reinterpret_cast<uint8_t*>(this); }
72 72
73 static intptr_t length_offset() { return OFFSET_OF(Snapshot, length_); } 73 static intptr_t length_offset() { return OFFSET_OF(Snapshot, length_); }
74 static intptr_t full_snapshot_offset() { 74 static intptr_t full_snapshot_offset() {
75 return OFFSET_OF(Snapshot, full_snapshot_); 75 return OFFSET_OF(Snapshot, full_snapshot_);
76 } 76 }
77 77
78 private: 78 private:
79 Snapshot() : length_(0), full_snapshot_(0) {} 79 Snapshot() : length_(0), full_snapshot_(0) {}
80 80
81 int32_t length_; // Stream length. 81 int32_t length_; // Stream length.
82 int32_t full_snapshot_; // Classes are serialized too. 82 int32_t full_snapshot_; // Classes are serialized too.
83 uint8_t content_[]; // Stream content. 83 uint8_t content_[]; // Stream content.
84 84
85 DISALLOW_COPY_AND_ASSIGN(Snapshot); 85 DISALLOW_COPY_AND_ASSIGN(Snapshot);
86 }; 86 };
87 87
88 88
89 // Stream for reading various types from a buffer. 89 // Stream for reading various types from a buffer.
90 class ReadStream : public ValueObject { 90 class ReadStream : public ValueObject {
91 public: 91 public:
92 ReadStream(uint8_t* buffer, intptr_t size) : buffer_(buffer), 92 ReadStream(const uint8_t* buffer, intptr_t size) : buffer_(buffer),
93 current_(buffer), 93 current_(buffer),
94 end_(buffer + size) {} 94 end_(buffer + size) {}
95 95
96 private: 96 private:
97 template<typename T> 97 template<typename T>
98 T Read() { 98 T Read() {
99 uint8_t b = ReadByte(); 99 uint8_t b = ReadByte();
100 if (b > kMaxSerializedUnsignedValuePerByte) { 100 if (b > kMaxSerializedUnsignedValuePerByte) {
101 return static_cast<T>(b) - kEndByteMarker; 101 return static_cast<T>(b) - kEndByteMarker;
102 } 102 }
103 T r = 0; 103 T r = 0;
104 uint8_t s = 0; 104 uint8_t s = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return bit_cast<T>(st->Read<int64_t>()); 144 return bit_cast<T>(st->Read<int64_t>());
145 } 145 }
146 }; 146 };
147 147
148 uint8_t ReadByte() { 148 uint8_t ReadByte() {
149 ASSERT(current_ < end_); 149 ASSERT(current_ < end_);
150 return *current_++; 150 return *current_++;
151 } 151 }
152 152
153 private: 153 private:
154 uint8_t* buffer_; 154 const uint8_t* buffer_;
155 uint8_t* current_; 155 const uint8_t* current_;
156 uint8_t* end_; 156 const uint8_t* end_;
157 157
158 // SnapshotReader needs access to the private Raw classes. 158 // SnapshotReader needs access to the private Raw classes.
159 friend class SnapshotReader; 159 friend class SnapshotReader;
160 DISALLOW_COPY_AND_ASSIGN(ReadStream); 160 DISALLOW_COPY_AND_ASSIGN(ReadStream);
161 }; 161 };
162 162
163 163
164 // Stream for writing various types into a buffer. 164 // Stream for writing various types into a buffer.
165 class WriteStream : public ValueObject { 165 class WriteStream : public ValueObject {
166 public: 166 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // classes. 259 // classes.
260 friend class MessageWriter; 260 friend class MessageWriter;
261 friend class SnapshotWriter; 261 friend class SnapshotWriter;
262 DISALLOW_COPY_AND_ASSIGN(WriteStream); 262 DISALLOW_COPY_AND_ASSIGN(WriteStream);
263 }; 263 };
264 264
265 265
266 // Reads a snapshot into objects. 266 // Reads a snapshot into objects.
267 class SnapshotReader { 267 class SnapshotReader {
268 public: 268 public:
269 SnapshotReader(Snapshot* snapshot, Heap* heap, ObjectStore* object_store) 269 SnapshotReader(const Snapshot* snapshot,
270 Heap* heap,
271 ObjectStore* object_store)
270 : stream_(snapshot->content(), snapshot->length()), 272 : stream_(snapshot->content(), snapshot->length()),
271 classes_serialized_(snapshot->IsFullSnapshot()), 273 classes_serialized_(snapshot->IsFullSnapshot()),
272 heap_(heap), 274 heap_(heap),
273 object_store_(object_store), 275 object_store_(object_store),
274 backward_references_() { } 276 backward_references_() { }
275 ~SnapshotReader() { } 277 ~SnapshotReader() { }
276 278
277 // Reads raw data (for basic types). 279 // Reads raw data (for basic types).
278 // sizeof(T) must be in {1,2,4,8}. 280 // sizeof(T) must be in {1,2,4,8}.
279 template <typename T> 281 template <typename T>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 448
447 private: 449 private:
448 SnapshotWriter* writer_; 450 SnapshotWriter* writer_;
449 451
450 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 452 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
451 }; 453 };
452 454
453 } // namespace dart 455 } // namespace dart
454 456
455 #endif // VM_SNAPSHOT_H_ 457 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698