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

Unified Diff: runtime/vm/raw_object.h

Issue 792163003: Deletion barrier preparation: validate overwritten references. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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
Index: runtime/vm/raw_object.h
===================================================================
--- runtime/vm/raw_object.h (revision 42249)
+++ runtime/vm/raw_object.h (working copy)
@@ -486,6 +486,9 @@
template<typename type>
void StorePointer(type const* addr, type value) {
+#if defined(DEBUG)
+ ValidateOverwrittenPointer(*addr);
+#endif // DEBUG
// Ensure that this object contains the addr.
ASSERT(Contains(reinterpret_cast<uword>(addr)));
VerifiedMemory::Write(const_cast<type*>(addr), value);
@@ -501,11 +504,25 @@
// Use for storing into an explicitly Smi-typed field of an object
// (i.e., both the previous and new value are Smis).
void StoreSmi(RawSmi* const* addr, RawSmi* value) {
+#if defined(DEBUG)
+ ValidateOverwrittenSmi(*addr);
+#endif // DEBUG
// Can't use Contains, as array length is initialized through this method.
ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this));
VerifiedMemory::Write(const_cast<RawSmi**>(addr), value);
}
+ void InitializeSmi(RawSmi* const* addr, RawSmi* value) {
+ // Can't use Contains, as array length is initialized through this method.
+ ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this));
+ VerifiedMemory::Write(const_cast<RawSmi**>(addr), value);
+ }
+
+#if defined(DEBUG)
+ static void ValidateOverwrittenPointer(RawObject* raw);
+ static void ValidateOverwrittenSmi(RawSmi* raw);
+#endif // DEBUG
+
friend class Api;
friend class Array;
friend class ByteBuffer;

Powered by Google App Engine
This is Rietveld 408576698