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

Side by Side 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 5 years, 11 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/pages.cc ('k') | runtime/vm/raw_object.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) 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_RAW_OBJECT_H_ 5 #ifndef VM_RAW_OBJECT_H_
6 #define VM_RAW_OBJECT_H_ 6 #define VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 &ptr()->tags_, old_tags, new_tags); 487 &ptr()->tags_, old_tags, new_tags);
488 } while (tags != old_tags); 488 } while (tags != old_tags);
489 } 489 }
490 490
491 // All writes to heap objects should ultimately pass through one of the 491 // All writes to heap objects should ultimately pass through one of the
492 // methods below or their counterparts in Object, to ensure that the 492 // methods below or their counterparts in Object, to ensure that the
493 // write barrier is correctly applied. 493 // write barrier is correctly applied.
494 494
495 template<typename type> 495 template<typename type>
496 void StorePointer(type const* addr, type value) { 496 void StorePointer(type const* addr, type value) {
497 #if defined(DEBUG)
498 ValidateOverwrittenPointer(*addr);
499 #endif // DEBUG
497 // Ensure that this object contains the addr. 500 // Ensure that this object contains the addr.
498 ASSERT(Contains(reinterpret_cast<uword>(addr))); 501 ASSERT(Contains(reinterpret_cast<uword>(addr)));
499 VerifiedMemory::Write(const_cast<type*>(addr), value); 502 VerifiedMemory::Write(const_cast<type*>(addr), value);
500 // Filter stores based on source and target. 503 // Filter stores based on source and target.
501 if (!value->IsHeapObject()) return; 504 if (!value->IsHeapObject()) return;
502 if (value->IsNewObject() && this->IsOldObject() && 505 if (value->IsNewObject() && this->IsOldObject() &&
503 !this->IsRemembered()) { 506 !this->IsRemembered()) {
504 this->SetRememberedBit(); 507 this->SetRememberedBit();
505 Isolate::Current()->store_buffer()->AddObject(this); 508 Isolate::Current()->store_buffer()->AddObject(this);
506 } 509 }
507 } 510 }
508 511
509 // Use for storing into an explicitly Smi-typed field of an object 512 // Use for storing into an explicitly Smi-typed field of an object
510 // (i.e., both the previous and new value are Smis). 513 // (i.e., both the previous and new value are Smis).
511 void StoreSmi(RawSmi* const* addr, RawSmi* value) { 514 void StoreSmi(RawSmi* const* addr, RawSmi* value) {
515 #if defined(DEBUG)
516 ValidateOverwrittenSmi(*addr);
517 #endif // DEBUG
512 // Can't use Contains, as array length is initialized through this method. 518 // Can't use Contains, as array length is initialized through this method.
513 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this)); 519 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this));
514 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value); 520 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value);
515 } 521 }
516 522
523 void InitializeSmi(RawSmi* const* addr, RawSmi* value) {
524 // Can't use Contains, as array length is initialized through this method.
525 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this));
526 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value);
527 }
528
529 #if defined(DEBUG)
530 static void ValidateOverwrittenPointer(RawObject* raw);
531 static void ValidateOverwrittenSmi(RawSmi* raw);
532 #endif // DEBUG
533
517 friend class Api; 534 friend class Api;
518 friend class Array; 535 friend class Array;
519 friend class ByteBuffer; 536 friend class ByteBuffer;
520 friend class Code; 537 friend class Code;
521 friend class FreeListElement; 538 friend class FreeListElement;
522 friend class GCMarker; 539 friend class GCMarker;
523 friend class ExternalTypedData; 540 friend class ExternalTypedData;
524 friend class ForwardList; 541 friend class ForwardList;
525 friend class GrowableObjectArray; // StorePointer 542 friend class GrowableObjectArray; // StorePointer
526 friend class Heap; 543 friend class Heap;
(...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2152 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2136 kTypedDataInt8ArrayViewCid + 15); 2153 kTypedDataInt8ArrayViewCid + 15);
2137 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2154 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2138 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2155 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2139 return (kNullCid - kTypedDataInt8ArrayCid); 2156 return (kNullCid - kTypedDataInt8ArrayCid);
2140 } 2157 }
2141 2158
2142 } // namespace dart 2159 } // namespace dart
2143 2160
2144 #endif // VM_RAW_OBJECT_H_ 2161 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698