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

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

Issue 2949803002: New growth strategy for growable arrays (Closed)
Patch Set: Branch-free grow size computation. Renamed function names to be clearer. Created 3 years, 6 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/profiler_test.cc ('k') | runtime/vm/raw_object.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 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/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 420 }
421 bool IsPseudoObject() const { 421 bool IsPseudoObject() const {
422 return IsFreeListElement() || IsForwardingCorpse(); 422 return IsFreeListElement() || IsForwardingCorpse();
423 } 423 }
424 424
425 intptr_t Size() const { 425 intptr_t Size() const {
426 uword tags = ptr()->tags_; 426 uword tags = ptr()->tags_;
427 intptr_t result = SizeTag::decode(tags); 427 intptr_t result = SizeTag::decode(tags);
428 if (result != 0) { 428 if (result != 0) {
429 #if defined(DEBUG) 429 #if defined(DEBUG)
430 // TODO(22501) Array::MakeArray has a race with this code: we might have 430 // TODO(22501) Array::MakeFixedLength has a race with this code: we might
431 // loaded tags field and then MakeArray could have updated it leading 431 // have loaded tags field and then MakeFixedLength could have updated it
432 // to inconsistency between SizeFromClass() and SizeTag::decode(tags). 432 // leading to inconsistency between SizeFromClass() and
433 // We are working around it by reloading tags_ and recomputing 433 // SizeTag::decode(tags). We are working around it by reloading tags_ and
434 // size from tags. 434 // recomputing size from tags.
435 const intptr_t size_from_class = SizeFromClass(); 435 const intptr_t size_from_class = SizeFromClass();
436 if ((result > size_from_class) && (GetClassId() == kArrayCid) && 436 if ((result > size_from_class) && (GetClassId() == kArrayCid) &&
437 (ptr()->tags_ != tags)) { 437 (ptr()->tags_ != tags)) {
438 result = SizeTag::decode(ptr()->tags_); 438 result = SizeTag::decode(ptr()->tags_);
439 } 439 }
440 ASSERT(result == size_from_class); 440 ASSERT(result == size_from_class);
441 #endif 441 #endif
442 return result; 442 return result;
443 } 443 }
444 result = SizeFromClass(); 444 result = SizeFromClass();
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 kTypedDataInt8ArrayViewCid + 15); 2496 kTypedDataInt8ArrayViewCid + 15);
2497 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2497 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2498 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2498 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2499 return (kNullCid - kTypedDataInt8ArrayCid); 2499 return (kNullCid - kTypedDataInt8ArrayCid);
2500 } 2500 }
2501 2501
2502 2502
2503 } // namespace dart 2503 } // namespace dart
2504 2504
2505 #endif // RUNTIME_VM_RAW_OBJECT_H_ 2505 #endif // RUNTIME_VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/profiler_test.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698