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

Unified Diff: runtime/vm/snapshot.h

Issue 417093005: - Make sure to be able to deal with unaligned snapshot buffers (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/globals.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.h
===================================================================
--- runtime/vm/snapshot.h (revision 38738)
+++ runtime/vm/snapshot.h (working copy)
@@ -6,6 +6,7 @@
#define VM_SNAPSHOT_H_
#include "platform/assert.h"
+#include "platform/utils.h"
#include "vm/allocation.h"
#include "vm/bitfield.h"
#include "vm/datastream.h"
@@ -142,24 +143,32 @@
// Getters.
const uint8_t* content() const { return content_; }
- intptr_t length() const { return static_cast<intptr_t>(length_); }
- Kind kind() const { return static_cast<Kind>(kind_); }
+ intptr_t length() const {
+ return static_cast<intptr_t>(ReadUnaligned(&unaligned_length_));
+ }
+ Kind kind() const {
+ return static_cast<Kind>(ReadUnaligned(&unaligned_kind_));
+ }
- bool IsMessageSnapshot() const { return kind_ == kMessage; }
- bool IsScriptSnapshot() const { return kind_ == kScript; }
- bool IsFullSnapshot() const { return kind_ == kFull; }
+ bool IsMessageSnapshot() const { return kind() == kMessage; }
+ bool IsScriptSnapshot() const { return kind() == kScript; }
+ bool IsFullSnapshot() const { return kind() == kFull; }
uint8_t* Addr() { return reinterpret_cast<uint8_t*>(this); }
- static intptr_t length_offset() { return OFFSET_OF(Snapshot, length_); }
+ static intptr_t length_offset() {
+ return OFFSET_OF(Snapshot, unaligned_length_);
+ }
static intptr_t kind_offset() {
- return OFFSET_OF(Snapshot, kind_);
+ return OFFSET_OF(Snapshot, unaligned_kind_);
}
private:
- Snapshot() : length_(0), kind_(kFull) {}
+ // Prevent Snapshot from ever being allocated directly.
+ Snapshot();
- int64_t length_; // Stream length.
- int64_t kind_; // Kind of snapshot.
+ // The following fields are potentially unaligned.
+ int64_t unaligned_length_; // Stream length.
+ int64_t unaligned_kind_; // Kind of snapshot.
uint8_t content_[]; // Stream content.
DISALLOW_COPY_AND_ASSIGN(Snapshot);
« no previous file with comments | « runtime/vm/globals.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698