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

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

Issue 2650543004: VM: [GC] Array::MakeArray is racing with the sweeper. (Closed)
Patch Set: Add a workaround for the MakeArray race Created 3 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
« no previous file with comments | « no previous file | no next file » | 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 RUNTIME_VM_RAW_OBJECT_H_ 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_
6 #define RUNTIME_VM_RAW_OBJECT_H_ 6 #define RUNTIME_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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return ((GetClassId() == kForwardingCorpse)); 428 return ((GetClassId() == kForwardingCorpse));
429 } 429 }
430 bool IsPseudoObject() const { 430 bool IsPseudoObject() const {
431 return IsFreeListElement() || IsForwardingCorpse(); 431 return IsFreeListElement() || IsForwardingCorpse();
432 } 432 }
433 433
434 intptr_t Size() const { 434 intptr_t Size() const {
435 uword tags = ptr()->tags_; 435 uword tags = ptr()->tags_;
436 intptr_t result = SizeTag::decode(tags); 436 intptr_t result = SizeTag::decode(tags);
437 if (result != 0) { 437 if (result != 0) {
438 ASSERT(result == SizeFromClass()); 438 #if defined(DEBUG)
439 // TODO(22501) Array::MakeArray has a race with this code: we might have
440 // loaded tags field and then MakeArray could have updated it leading
441 // to inconsistency between SizeFromClass() and SizeTag::decode(tags).
442 // We are working around it by reloading tags_ and recomputing
443 // size from tags.
444 const intptr_t size_from_class = SizeFromClass();
445 if ((result > size_from_class) && (GetClassId() == kArrayCid) &&
446 (ptr()->tags_ != tags)) {
447 result = SizeTag::decode(ptr()->tags_);
448 }
449 ASSERT(result == size_from_class);
450 #endif
439 return result; 451 return result;
440 } 452 }
441 result = SizeFromClass(); 453 result = SizeFromClass();
442 ASSERT(result > SizeTag::kMaxSizeTag); 454 ASSERT(result > SizeTag::kMaxSizeTag);
443 return result; 455 return result;
444 } 456 }
445 457
446 bool Contains(uword addr) const { 458 bool Contains(uword addr) const {
447 intptr_t this_size = Size(); 459 intptr_t this_size = Size();
448 uword this_addr = RawObject::ToAddr(this); 460 uword this_addr = RawObject::ToAddr(this);
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2436 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2425 kTypedDataInt8ArrayViewCid + 15); 2437 kTypedDataInt8ArrayViewCid + 15);
2426 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2438 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2427 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2439 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2428 return (kNullCid - kTypedDataInt8ArrayCid); 2440 return (kNullCid - kTypedDataInt8ArrayCid);
2429 } 2441 }
2430 2442
2431 } // namespace dart 2443 } // namespace dart
2432 2444
2433 #endif // RUNTIME_VM_RAW_OBJECT_H_ 2445 #endif // RUNTIME_VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698