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

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

Issue 529823002: - Add AtomicOperations::CompareAndSwapWord (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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
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/globals.h" 10 #include "vm/globals.h"
10 #include "vm/token.h" 11 #include "vm/token.h"
11 #include "vm/snapshot.h" 12 #include "vm/snapshot.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 // Macrobatics to define the Object hierarchy of VM implementation classes. 16 // Macrobatics to define the Object hierarchy of VM implementation classes.
16 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ 17 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \
17 V(Class) \ 18 V(Class) \
18 V(UnresolvedClass) \ 19 V(UnresolvedClass) \
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return MarkBit::decode(ptr()->tags_); 323 return MarkBit::decode(ptr()->tags_);
323 } 324 }
324 void SetMarkBit() { 325 void SetMarkBit() {
325 ASSERT(!IsMarked()); 326 ASSERT(!IsMarked());
326 uword tags = ptr()->tags_; 327 uword tags = ptr()->tags_;
327 ptr()->tags_ = MarkBit::update(true, tags); 328 ptr()->tags_ = MarkBit::update(true, tags);
328 } 329 }
329 void ClearMarkBit() { 330 void ClearMarkBit() {
330 ASSERT(IsMarked()); 331 ASSERT(IsMarked());
331 uword tags = ptr()->tags_; 332 uword tags = ptr()->tags_;
332 ptr()->tags_ = MarkBit::update(false, tags); 333 uword old_tags;
334 do {
335 old_tags = tags;
336 uword new_tags = MarkBit::update(false, old_tags);
koda 2014/09/02 04:18:31 All five changes in this file (and probably some i
337 tags = AtomicOperations::CompareAndSwapWord(
338 &ptr()->tags_, old_tags, new_tags);
339 } while (tags != old_tags);
333 } 340 }
334 341
335 // Support for GC watched bit. 342 // Support for GC watched bit.
336 bool IsWatched() const { 343 bool IsWatched() const {
337 return WatchedBit::decode(ptr()->tags_); 344 return WatchedBit::decode(ptr()->tags_);
338 } 345 }
339 void SetWatchedBit() { 346 void SetWatchedBit() {
340 ASSERT(!IsWatched()); 347 ASSERT(!IsWatched());
341 uword tags = ptr()->tags_; 348 uword tags = ptr()->tags_;
342 ptr()->tags_ = WatchedBit::update(true, tags); 349 ptr()->tags_ = WatchedBit::update(true, tags);
343 } 350 }
344 void ClearWatchedBit() { 351 void ClearWatchedBit() {
345 ASSERT(IsWatched()); 352 ASSERT(IsWatched());
346 uword tags = ptr()->tags_; 353 uword tags = ptr()->tags_;
347 ptr()->tags_ = WatchedBit::update(false, tags); 354 ptr()->tags_ = WatchedBit::update(false, tags);
348 } 355 }
349 356
350 // Support for object tags. 357 // Support for object tags.
351 bool IsCanonical() const { 358 bool IsCanonical() const {
352 return CanonicalObjectTag::decode(ptr()->tags_); 359 return CanonicalObjectTag::decode(ptr()->tags_);
353 } 360 }
354 void SetCanonical() { 361 void SetCanonical() {
355 uword tags = ptr()->tags_; 362 uword tags = ptr()->tags_;
356 ptr()->tags_ = CanonicalObjectTag::update(true, tags); 363 uword old_tags;
364 do {
365 old_tags = tags;
366 uword new_tags = CanonicalObjectTag::update(true, old_tags);
367 tags = AtomicOperations::CompareAndSwapWord(
368 &ptr()->tags_, old_tags, new_tags);
369 } while (tags != old_tags);
357 } 370 }
358 bool IsCreatedFromSnapshot() const { 371 bool IsCreatedFromSnapshot() const {
359 return CreatedFromSnapshotTag::decode(ptr()->tags_); 372 return CreatedFromSnapshotTag::decode(ptr()->tags_);
360 } 373 }
361 void SetCreatedFromSnapshot() { 374 void SetCreatedFromSnapshot() {
362 uword tags = ptr()->tags_; 375 uword tags = ptr()->tags_;
363 ptr()->tags_ = CreatedFromSnapshotTag::update(true, tags); 376 uword old_tags;
377 do {
378 old_tags = tags;
379 uword new_tags = CreatedFromSnapshotTag::update(true, old_tags);
380 tags = AtomicOperations::CompareAndSwapWord(
381 &ptr()->tags_, old_tags, new_tags);
382 } while (tags != old_tags);
364 } 383 }
365 384
366 // Support for GC remembered bit. 385 // Support for GC remembered bit.
367 bool IsRemembered() const { 386 bool IsRemembered() const {
368 return RememberedBit::decode(ptr()->tags_); 387 return RememberedBit::decode(ptr()->tags_);
369 } 388 }
370 void SetRememberedBit() { 389 void SetRememberedBit() {
371 ASSERT(!IsRemembered()); 390 ASSERT(!IsRemembered());
372 uword tags = ptr()->tags_; 391 uword tags = ptr()->tags_;
373 ptr()->tags_ = RememberedBit::update(true, tags); 392 uword old_tags;
393 do {
394 old_tags = tags;
395 uword new_tags = RememberedBit::update(true, old_tags);
396 tags = AtomicOperations::CompareAndSwapWord(
397 &ptr()->tags_, old_tags, new_tags);
398 } while (tags != old_tags);
374 } 399 }
375 void ClearRememberedBit() { 400 void ClearRememberedBit() {
376 uword tags = ptr()->tags_; 401 uword tags = ptr()->tags_;
377 ptr()->tags_ = RememberedBit::update(false, tags); 402 uword old_tags;
403 do {
404 old_tags = tags;
405 uword new_tags = RememberedBit::update(false, old_tags);
406 tags = AtomicOperations::CompareAndSwapWord(
407 &ptr()->tags_, old_tags, new_tags);
408 } while (tags != old_tags);
378 } 409 }
379 410
380 bool IsDartInstance() { 411 bool IsDartInstance() {
381 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); 412 return (!IsHeapObject() || (GetClassId() >= kInstanceCid));
382 } 413 }
383 bool IsFreeListElement() { 414 bool IsFreeListElement() {
384 return ((GetClassId() == kFreeListElement)); 415 return ((GetClassId() == kFreeListElement));
385 } 416 }
386 417
387 intptr_t Size() const { 418 intptr_t Size() const {
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2028 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
1998 kTypedDataInt8ArrayViewCid + 15); 2029 kTypedDataInt8ArrayViewCid + 15);
1999 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2030 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2000 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2031 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2001 return (kNullCid - kTypedDataInt8ArrayCid); 2032 return (kNullCid - kTypedDataInt8ArrayCid);
2002 } 2033 }
2003 2034
2004 } // namespace dart 2035 } // namespace dart
2005 2036
2006 #endif // VM_RAW_OBJECT_H_ 2037 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698