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

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

Issue 685583002: Add more missing StorePointer/StoreSmi calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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/object.cc ('k') | runtime/vm/snapshot.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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 intptr_t result = SizeTag::decode(tags); 396 intptr_t result = SizeTag::decode(tags);
397 if (result != 0) { 397 if (result != 0) {
398 ASSERT(result == SizeFromClass()); 398 ASSERT(result == SizeFromClass());
399 return result; 399 return result;
400 } 400 }
401 result = SizeFromClass(); 401 result = SizeFromClass();
402 ASSERT(result > SizeTag::kMaxSizeTag); 402 ASSERT(result > SizeTag::kMaxSizeTag);
403 return result; 403 return result;
404 } 404 }
405 405
406 bool Contains(uword addr) const {
407 intptr_t this_size = Size();
408 uword this_addr = RawObject::ToAddr(this);
409 return (addr >= this_addr) && (addr < (this_addr + this_size));
410 }
411
406 void Validate(Isolate* isolate) const; 412 void Validate(Isolate* isolate) const;
407 intptr_t VisitPointers(ObjectPointerVisitor* visitor); 413 intptr_t VisitPointers(ObjectPointerVisitor* visitor);
408 bool FindObject(FindObjectVisitor* visitor); 414 bool FindObject(FindObjectVisitor* visitor);
409 415
410 static RawObject* FromAddr(uword addr) { 416 static RawObject* FromAddr(uword addr) {
411 // We expect the untagged address here. 417 // We expect the untagged address here.
412 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); 418 ASSERT((addr & kSmiTagMask) != kHeapObjectTag);
413 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); 419 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag);
414 } 420 }
415 421
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 458
453 class RememberedBit : public BitField<bool, kRememberedBit, 1> {}; 459 class RememberedBit : public BitField<bool, kRememberedBit, 1> {};
454 460
455 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; 461 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {};
456 462
457 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; 463 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {};
458 464
459 class ReservedBits : public 465 class ReservedBits : public
460 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT 466 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT
461 467
462 // TODO(koda): Return const*, like Object::raw_ptr(). 468 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr().
463 RawObject* ptr() const { 469 RawObject* ptr() const {
464 ASSERT(IsHeapObject()); 470 ASSERT(IsHeapObject());
465 return reinterpret_cast<RawObject*>( 471 return reinterpret_cast<RawObject*>(
466 reinterpret_cast<uword>(this) - kHeapObjectTag); 472 reinterpret_cast<uword>(this) - kHeapObjectTag);
467 } 473 }
468 474
469 intptr_t SizeFromClass() const; 475 intptr_t SizeFromClass() const;
470 476
471 intptr_t GetClassId() const { 477 intptr_t GetClassId() const {
472 uword tags = ptr()->tags_; 478 uword tags = ptr()->tags_;
473 return ClassIdTag::decode(tags); 479 return ClassIdTag::decode(tags);
474 } 480 }
475 481
482 // Start of field mutator guards.
Ivan Posva 2014/10/29 06:17:34 Please remove superfluous comment.
koda 2014/10/29 19:30:16 Done.
483 //
484 // All writes to heap objects should ultimately pass through one of the
485 // methods below or their counterparts in Object, to ensure that the
486 // write barrier is correctly applied.
487
488 template<typename type>
489 void StorePointer(type const* addr, type value) {
490 // Ensure that this object contains the addr.
491 ASSERT(Contains(reinterpret_cast<uword>(addr)));
492 *const_cast<type*>(addr) = value;
493 // Filter stores based on source and target.
494 if (!value->IsHeapObject()) return;
495 if (value->IsNewObject() && this->IsOldObject() &&
496 !this->IsRemembered()) {
497 this->SetRememberedBit();
498 Isolate::Current()->store_buffer()->AddObject(this);
499 }
500 }
501
502 // Use for storing into an explicitly Smi-typed field of an object
503 // (i.e., both the previous and new value are Smis).
504 void StoreSmi(RawSmi* const* addr, RawSmi* value) {
505 // Can't use Contains, as array length is initialized through this method.
506 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this));
507 *const_cast<RawSmi**>(addr) = value;
508 }
509
510 // End of field mutator guards.
Ivan Posva 2014/10/29 06:17:34 ditto
koda 2014/10/29 19:30:16 Done.
511
476 friend class Api; 512 friend class Api;
477 friend class Array; 513 friend class Array;
478 friend class ByteBuffer; 514 friend class ByteBuffer;
479 friend class Code; 515 friend class Code;
480 friend class FreeListElement; 516 friend class FreeListElement;
481 friend class GCMarker; 517 friend class GCMarker;
482 friend class ExternalTypedData; 518 friend class ExternalTypedData;
483 friend class ForwardList; 519 friend class ForwardList;
520 friend class GrowableObjectArray; // StorePointer
484 friend class Heap; 521 friend class Heap;
485 friend class HeapMapAsJSONVisitor; 522 friend class HeapMapAsJSONVisitor;
486 friend class ClassStatsVisitor; 523 friend class ClassStatsVisitor;
487 friend class MarkingVisitor; 524 friend class MarkingVisitor;
488 friend class Object; 525 friend class Object;
489 friend class RawExternalTypedData; 526 friend class RawExternalTypedData;
490 friend class RawInstructions; 527 friend class RawInstructions;
491 friend class RawInstance; 528 friend class RawInstance;
492 friend class RawTypedData; 529 friend class RawTypedData;
493 friend class Scavenger; 530 friend class Scavenger;
494 friend class ScavengerVisitor; 531 friend class ScavengerVisitor;
495 friend class SizeExcludingClassVisitor; // GetClassId 532 friend class SizeExcludingClassVisitor; // GetClassId
496 friend class SnapshotReader; 533 friend class SnapshotReader;
497 friend class SnapshotWriter; 534 friend class SnapshotWriter;
498 friend class String; 535 friend class String;
499 friend class TypedData; 536 friend class TypedData;
500 friend class TypedDataView; 537 friend class TypedDataView;
538 friend class WeakProperty; // StorePointer
501 539
502 DISALLOW_ALLOCATION(); 540 DISALLOW_ALLOCATION();
503 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); 541 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
504 }; 542 };
505 543
506 544
507 class RawClass : public RawObject { 545 class RawClass : public RawObject {
508 public: 546 public:
509 enum ClassFinalizedState { 547 enum ClassFinalizedState {
510 kAllocated = 0, // Initial state. 548 kAllocated = 0, // Initial state.
(...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2106 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2069 kTypedDataInt8ArrayViewCid + 15); 2107 kTypedDataInt8ArrayViewCid + 15);
2070 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2108 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2071 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2109 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2072 return (kNullCid - kTypedDataInt8ArrayCid); 2110 return (kNullCid - kTypedDataInt8ArrayCid);
2073 } 2111 }
2074 2112
2075 } // namespace dart 2113 } // namespace dart
2076 2114
2077 #endif // VM_RAW_OBJECT_H_ 2115 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698