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

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

Issue 2001713002: - Removed the kWatchedBit and the associated weak property handling (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/scavenger.h » ('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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 HEAP_PROFILER_SUPPORT() \ 249 HEAP_PROFILER_SUPPORT() \
250 250
251 // RawObject is the base class of all raw objects, even though it carries the 251 // RawObject is the base class of all raw objects, even though it carries the
252 // class_ field not all raw objects are allocated in the heap and thus cannot 252 // class_ field not all raw objects are allocated in the heap and thus cannot
253 // be dereferenced (e.g. RawSmi). 253 // be dereferenced (e.g. RawSmi).
254 class RawObject { 254 class RawObject {
255 public: 255 public:
256 // The tags field which is a part of the object header uses the following 256 // The tags field which is a part of the object header uses the following
257 // bit fields for storing tags. 257 // bit fields for storing tags.
258 enum TagBits { 258 enum TagBits {
259 kWatchedBit = 0, 259 kTheBitFormerlyKnownAsTheWatchedBit = 0,
Ivan Posva 2016/05/20 18:13:35 I am planning to move the bits up by one separatel
260 kMarkBit = 1, 260 kMarkBit = 1,
261 kCanonicalBit = 2, 261 kCanonicalBit = 2,
262 kVMHeapObjectBit = 3, 262 kVMHeapObjectBit = 3,
263 kRememberedBit = 4, 263 kRememberedBit = 4,
264 #if defined(ARCH_IS_32_BIT) 264 #if defined(ARCH_IS_32_BIT)
265 kReservedTagPos = 5, // kReservedBit{100K,1M,10M} 265 kReservedTagPos = 5, // kReservedBit{100K,1M,10M}
266 kReservedTagSize = 3, 266 kReservedTagSize = 3,
267 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 267 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8
268 kSizeTagSize = 8, 268 kSizeTagSize = 8,
269 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 269 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 void ClearMarkBit() { 367 void ClearMarkBit() {
368 ASSERT(IsMarked()); 368 ASSERT(IsMarked());
369 UpdateTagBit<MarkBit>(false); 369 UpdateTagBit<MarkBit>(false);
370 } 370 }
371 // Returns false if the bit was already set. 371 // Returns false if the bit was already set.
372 // TODO(koda): Add "must use result" annotation here, after we add support. 372 // TODO(koda): Add "must use result" annotation here, after we add support.
373 bool TryAcquireMarkBit() { 373 bool TryAcquireMarkBit() {
374 return TryAcquireTagBit<MarkBit>(); 374 return TryAcquireTagBit<MarkBit>();
375 } 375 }
376 376
377 // Support for GC watched bit.
378 // TODO(iposva): Get rid of this.
379 bool IsWatched() const {
380 return WatchedBit::decode(ptr()->tags_);
381 }
382 void SetWatchedBitUnsynchronized() {
383 ASSERT(!IsWatched());
384 uword tags = ptr()->tags_;
385 ptr()->tags_ = WatchedBit::update(true, tags);
386 }
387 void ClearWatchedBitUnsynchronized() {
388 uword tags = ptr()->tags_;
389 ptr()->tags_ = WatchedBit::update(false, tags);
390 }
391
392 // Support for object tags. 377 // Support for object tags.
393 bool IsCanonical() const { 378 bool IsCanonical() const {
394 return CanonicalObjectTag::decode(ptr()->tags_); 379 return CanonicalObjectTag::decode(ptr()->tags_);
395 } 380 }
396 void SetCanonical() { 381 void SetCanonical() {
397 UpdateTagBit<CanonicalObjectTag>(true); 382 UpdateTagBit<CanonicalObjectTag>(true);
398 } 383 }
399 void ClearCanonical() { 384 void ClearCanonical() {
400 UpdateTagBit<CanonicalObjectTag>(false); 385 UpdateTagBit<CanonicalObjectTag>(false);
401 } 386 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 static bool IsExternalTypedDataClassId(intptr_t index); 499 static bool IsExternalTypedDataClassId(intptr_t index);
515 static bool IsInternalVMdefinedClassId(intptr_t index); 500 static bool IsInternalVMdefinedClassId(intptr_t index);
516 static bool IsVariableSizeClassId(intptr_t index); 501 static bool IsVariableSizeClassId(intptr_t index);
517 static bool IsImplicitFieldClassId(intptr_t index); 502 static bool IsImplicitFieldClassId(intptr_t index);
518 503
519 static intptr_t NumberOfTypedDataClasses(); 504 static intptr_t NumberOfTypedDataClasses();
520 505
521 private: 506 private:
522 uword tags_; // Various object tags (bits). 507 uword tags_; // Various object tags (bits).
523 508
524 class WatchedBit : public BitField<uword, bool, kWatchedBit, 1> {};
525
526 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {}; 509 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {};
527 510
528 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {}; 511 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {};
529 512
530 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {}; 513 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {};
531 514
532 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {}; 515 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {};
533 516
534 class ReservedBits : public 517 class ReservedBits : public
535 BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {}; 518 BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {};
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 2150
2168 RawObject** from() { 2151 RawObject** from() {
2169 return reinterpret_cast<RawObject**>(&ptr()->key_); 2152 return reinterpret_cast<RawObject**>(&ptr()->key_);
2170 } 2153 }
2171 RawObject* key_; 2154 RawObject* key_;
2172 RawObject* value_; 2155 RawObject* value_;
2173 RawObject** to() { 2156 RawObject** to() {
2174 return reinterpret_cast<RawObject**>(&ptr()->value_); 2157 return reinterpret_cast<RawObject**>(&ptr()->value_);
2175 } 2158 }
2176 2159
2177 friend class DelaySet; 2160 // Linked list is chaining all pending weak properties.
2161 // Untyped to make it clear that it is not to be visited by GC.
2162 uword next_;
2163
2178 friend class GCMarker; 2164 friend class GCMarker;
2179 template<bool> friend class MarkingVisitorBase; 2165 template<bool> friend class MarkingVisitorBase;
2180 friend class Scavenger; 2166 friend class Scavenger;
2181 friend class ScavengerVisitor; 2167 friend class ScavengerVisitor;
2182 }; 2168 };
2183 2169
2184 // MirrorReferences are used by mirrors to hold reflectees that are VM 2170 // MirrorReferences are used by mirrors to hold reflectees that are VM
2185 // internal objects, such as libraries, classes, functions or types. 2171 // internal objects, such as libraries, classes, functions or types.
2186 class RawMirrorReference : public RawInstance { 2172 class RawMirrorReference : public RawInstance {
2187 RAW_HEAP_OBJECT_IMPLEMENTATION(MirrorReference); 2173 RAW_HEAP_OBJECT_IMPLEMENTATION(MirrorReference);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2417 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2432 kTypedDataInt8ArrayViewCid + 15); 2418 kTypedDataInt8ArrayViewCid + 15);
2433 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2419 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2434 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2420 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2435 return (kNullCid - kTypedDataInt8ArrayCid); 2421 return (kNullCid - kTypedDataInt8ArrayCid);
2436 } 2422 }
2437 2423
2438 } // namespace dart 2424 } // namespace dart
2439 2425
2440 #endif // VM_RAW_OBJECT_H_ 2426 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698