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

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

Issue 323163002: Adds an assertion to limit snapshot intptr_t size. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 return ReadStream::Raw<sizeof(T), T>::Read(&stream_); 174 return ReadStream::Raw<sizeof(T), T>::Read(&stream_);
175 } 175 }
176 176
177 // Reads an intptr_t type value. 177 // Reads an intptr_t type value.
178 intptr_t ReadIntptrValue() { 178 intptr_t ReadIntptrValue() {
179 int64_t value = Read<int64_t>(); 179 int64_t value = Read<int64_t>();
180 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); 180 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
181 return static_cast<intptr_t>(value); 181 return static_cast<intptr_t>(value);
182 } 182 }
183 183
184 intptr_t ReadRawPointerValue() {
185 int64_t value = Read<int64_t>();
186 return static_cast<intptr_t>(value);
187 }
188
184 void ReadBytes(uint8_t* addr, intptr_t len) { 189 void ReadBytes(uint8_t* addr, intptr_t len) {
185 stream_.ReadBytes(addr, len); 190 stream_.ReadBytes(addr, len);
186 } 191 }
187 192
188 double ReadDouble() { 193 double ReadDouble() {
189 double result; 194 double result;
190 stream_.ReadBytes(reinterpret_cast<uint8_t*>(&result), sizeof(result)); 195 stream_.ReadBytes(reinterpret_cast<uint8_t*>(&result), sizeof(result));
191 return result; 196 return result;
192 } 197 }
193 198
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 397
393 // Writes raw data to the stream (basic type). 398 // Writes raw data to the stream (basic type).
394 // sizeof(T) must be in {1,2,4,8}. 399 // sizeof(T) must be in {1,2,4,8}.
395 template <typename T> 400 template <typename T>
396 void Write(T value) { 401 void Write(T value) {
397 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value); 402 WriteStream::Raw<sizeof(T), T>::Write(&stream_, value);
398 } 403 }
399 404
400 // Writes an intptr_t type value out. 405 // Writes an intptr_t type value out.
401 void WriteIntptrValue(intptr_t value) { 406 void WriteIntptrValue(intptr_t value) {
407 ASSERT((value >= kMinInt32) && (value <= kMaxInt32));
408 Write<int64_t>(value);
409 }
410
411 void WriteRawPointerValue(intptr_t value) {
402 Write<int64_t>(value); 412 Write<int64_t>(value);
403 } 413 }
404 414
405 // Write an object that is serialized as an Id (singleton in object store, 415 // Write an object that is serialized as an Id (singleton in object store,
406 // or an object that was already serialized before). 416 // or an object that was already serialized before).
407 void WriteIndexedObject(intptr_t object_id) { 417 void WriteIndexedObject(intptr_t object_id) {
408 ASSERT(object_id <= kMaxObjectId); 418 ASSERT(object_id <= kMaxObjectId);
409 intptr_t value = 0; 419 intptr_t value = 0;
410 value = SerializedHeaderTag::update(kObjectId, value); 420 value = SerializedHeaderTag::update(kObjectId, value);
411 value = SerializedHeaderData::update(object_id, value); 421 value = SerializedHeaderData::update(object_id, value);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 private: 649 private:
640 SnapshotWriter* writer_; 650 SnapshotWriter* writer_;
641 bool as_references_; 651 bool as_references_;
642 652
643 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 653 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
644 }; 654 };
645 655
646 } // namespace dart 656 } // namespace dart
647 657
648 #endif // VM_SNAPSHOT_H_ 658 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « runtime/vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698