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

Side by Side Diff: vm/snapshot.h

Issue 10446104: Use memmove instead of a loop to read bytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 static T Read(ReadStream* st) { 183 static T Read(ReadStream* st) {
184 return bit_cast<T>(st->Read<int64_t>()); 184 return bit_cast<T>(st->Read<int64_t>());
185 } 185 }
186 }; 186 };
187 187
188 uint8_t ReadByte() { 188 uint8_t ReadByte() {
189 ASSERT(current_ < end_); 189 ASSERT(current_ < end_);
190 return *current_++; 190 return *current_++;
191 } 191 }
192 192
193 void ReadBytes(uint8_t* addr, intptr_t len) {
194 ASSERT((current_ + len) < end_);
195 memmove(addr, current_, len);
196 current_ += len;
197 }
198
193 private: 199 private:
194 const uint8_t* buffer_; 200 const uint8_t* buffer_;
195 const uint8_t* current_; 201 const uint8_t* current_;
196 const uint8_t* end_; 202 const uint8_t* end_;
197 203
198 // SnapshotReader needs access to the private Raw classes. 204 // SnapshotReader needs access to the private Raw classes.
199 friend class SnapshotReader; 205 friend class SnapshotReader;
200 friend class BaseReader; 206 friend class BaseReader;
201 DISALLOW_COPY_AND_ASSIGN(ReadStream); 207 DISALLOW_COPY_AND_ASSIGN(ReadStream);
202 }; 208 };
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 return ReadStream::Raw<sizeof(T), T>::Read(&stream_); 319 return ReadStream::Raw<sizeof(T), T>::Read(&stream_);
314 } 320 }
315 321
316 // Reads an intptr_t type value. 322 // Reads an intptr_t type value.
317 intptr_t ReadIntptrValue() { 323 intptr_t ReadIntptrValue() {
318 int64_t value = Read<int64_t>(); 324 int64_t value = Read<int64_t>();
319 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin)); 325 ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
320 return value; 326 return value;
321 } 327 }
322 328
329 void ReadBytes(uint8_t* addr, intptr_t len) {
330 stream_.ReadBytes(addr, len);
331 }
332
323 RawSmi* ReadAsSmi(); 333 RawSmi* ReadAsSmi();
324 intptr_t ReadSmiValue(); 334 intptr_t ReadSmiValue();
325 335
326 private: 336 private:
327 ReadStream stream_; // input stream. 337 ReadStream stream_; // input stream.
328 }; 338 };
329 339
330 340
331 // Reads a snapshot into objects. 341 // Reads a snapshot into objects.
332 class SnapshotReader : public BaseReader { 342 class SnapshotReader : public BaseReader {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 574
565 private: 575 private:
566 SnapshotWriter* writer_; 576 SnapshotWriter* writer_;
567 577
568 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 578 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
569 }; 579 };
570 580
571 } // namespace dart 581 } // namespace dart
572 582
573 #endif // VM_SNAPSHOT_H_ 583 #endif // VM_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « vm/raw_object_snapshot.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698