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

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: Remove residual watched bit. 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
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 kMarkBit = 0,
260 kMarkBit = 1, 260 kCanonicalBit = 1,
261 kCanonicalBit = 2, 261 kVMHeapObjectBit = 2,
262 kVMHeapObjectBit = 3, 262 kRememberedBit = 3,
263 kRememberedBit = 4, 263 kReservedTagPos = 4, // kReservedBit{100K,1M,10M}
264 #if defined(ARCH_IS_32_BIT) 264 #if defined(ARCH_IS_32_BIT)
265 kReservedTagPos = 5, // kReservedBit{100K,1M,10M}
266 kReservedTagSize = 3, 265 kReservedTagSize = 3,
rmacnak 2016/05/24 20:58:42 = 4
267 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 266 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8
268 kSizeTagSize = 8, 267 kSizeTagSize = 8,
269 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 268 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16
270 kClassIdTagSize = 16, 269 kClassIdTagSize = 16,
271 #elif defined(ARCH_IS_64_BIT) 270 #elif defined(ARCH_IS_64_BIT)
272 kReservedTagPos = 5, // kReservedBit{100K,1M,10M} 271 kReservedTagSize = 12,
273 kReservedTagSize = 11,
274 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 16 272 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 16
275 kSizeTagSize = 16, 273 kSizeTagSize = 16,
276 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 32 274 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 32
277 kClassIdTagSize = 32, 275 kClassIdTagSize = 32,
278 #else 276 #else
279 #error Unexpected architecture word size 277 #error Unexpected architecture word size
280 #endif 278 #endif
281 }; 279 };
282 280
283 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte)); 281 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 void ClearMarkBit() { 365 void ClearMarkBit() {
368 ASSERT(IsMarked()); 366 ASSERT(IsMarked());
369 UpdateTagBit<MarkBit>(false); 367 UpdateTagBit<MarkBit>(false);
370 } 368 }
371 // Returns false if the bit was already set. 369 // Returns false if the bit was already set.
372 // TODO(koda): Add "must use result" annotation here, after we add support. 370 // TODO(koda): Add "must use result" annotation here, after we add support.
373 bool TryAcquireMarkBit() { 371 bool TryAcquireMarkBit() {
374 return TryAcquireTagBit<MarkBit>(); 372 return TryAcquireTagBit<MarkBit>();
375 } 373 }
376 374
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. 375 // Support for object tags.
393 bool IsCanonical() const { 376 bool IsCanonical() const {
394 return CanonicalObjectTag::decode(ptr()->tags_); 377 return CanonicalObjectTag::decode(ptr()->tags_);
395 } 378 }
396 void SetCanonical() { 379 void SetCanonical() {
397 UpdateTagBit<CanonicalObjectTag>(true); 380 UpdateTagBit<CanonicalObjectTag>(true);
398 } 381 }
399 void ClearCanonical() { 382 void ClearCanonical() {
400 UpdateTagBit<CanonicalObjectTag>(false); 383 UpdateTagBit<CanonicalObjectTag>(false);
401 } 384 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 static bool IsExternalTypedDataClassId(intptr_t index); 497 static bool IsExternalTypedDataClassId(intptr_t index);
515 static bool IsInternalVMdefinedClassId(intptr_t index); 498 static bool IsInternalVMdefinedClassId(intptr_t index);
516 static bool IsVariableSizeClassId(intptr_t index); 499 static bool IsVariableSizeClassId(intptr_t index);
517 static bool IsImplicitFieldClassId(intptr_t index); 500 static bool IsImplicitFieldClassId(intptr_t index);
518 501
519 static intptr_t NumberOfTypedDataClasses(); 502 static intptr_t NumberOfTypedDataClasses();
520 503
521 private: 504 private:
522 uword tags_; // Various object tags (bits). 505 uword tags_; // Various object tags (bits).
523 506
524 class WatchedBit : public BitField<uword, bool, kWatchedBit, 1> {};
525
526 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {}; 507 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {};
527 508
528 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {}; 509 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {};
529 510
530 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {}; 511 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {};
531 512
532 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {}; 513 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {};
533 514
534 class ReservedBits : public 515 class ReservedBits : public
535 BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {}; 516 BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {};
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 2157
2177 RawObject** from() { 2158 RawObject** from() {
2178 return reinterpret_cast<RawObject**>(&ptr()->key_); 2159 return reinterpret_cast<RawObject**>(&ptr()->key_);
2179 } 2160 }
2180 RawObject* key_; 2161 RawObject* key_;
2181 RawObject* value_; 2162 RawObject* value_;
2182 RawObject** to() { 2163 RawObject** to() {
2183 return reinterpret_cast<RawObject**>(&ptr()->value_); 2164 return reinterpret_cast<RawObject**>(&ptr()->value_);
2184 } 2165 }
2185 2166
2186 friend class DelaySet; 2167 // Linked list is chaining all pending weak properties.
2168 // Untyped to make it clear that it is not to be visited by GC.
2169 uword next_;
2170
2187 friend class GCMarker; 2171 friend class GCMarker;
2188 template<bool> friend class MarkingVisitorBase; 2172 template<bool> friend class MarkingVisitorBase;
2189 friend class Scavenger; 2173 friend class Scavenger;
2190 friend class ScavengerVisitor; 2174 friend class ScavengerVisitor;
2191 }; 2175 };
2192 2176
2193 // MirrorReferences are used by mirrors to hold reflectees that are VM 2177 // MirrorReferences are used by mirrors to hold reflectees that are VM
2194 // internal objects, such as libraries, classes, functions or types. 2178 // internal objects, such as libraries, classes, functions or types.
2195 class RawMirrorReference : public RawInstance { 2179 class RawMirrorReference : public RawInstance {
2196 RAW_HEAP_OBJECT_IMPLEMENTATION(MirrorReference); 2180 RAW_HEAP_OBJECT_IMPLEMENTATION(MirrorReference);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2440 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2424 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2441 kTypedDataInt8ArrayViewCid + 15); 2425 kTypedDataInt8ArrayViewCid + 15);
2442 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2426 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2443 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2427 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2444 return (kNullCid - kTypedDataInt8ArrayCid); 2428 return (kNullCid - kTypedDataInt8ArrayCid);
2445 } 2429 }
2446 2430
2447 } // namespace dart 2431 } // namespace dart
2448 2432
2449 #endif // VM_RAW_OBJECT_H_ 2433 #endif // VM_RAW_OBJECT_H_
OLDNEW
« runtime/vm/gc_marker.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/scavenger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698