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

Side by Side Diff: src/elements.cc

Issue 1034163002: Use atomic operation to read the length of a fixed array. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile error Created 5 years, 8 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 | src/factory.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // Check whether the backing store should be shrunk. 877 // Check whether the backing store should be shrunk.
878 if (length <= old_capacity) { 878 if (length <= old_capacity) {
879 if (array->HasFastSmiOrObjectElements()) { 879 if (array->HasFastSmiOrObjectElements()) {
880 backing_store = JSObject::EnsureWritableFastElements(array); 880 backing_store = JSObject::EnsureWritableFastElements(array);
881 } 881 }
882 if (2 * length <= old_capacity) { 882 if (2 * length <= old_capacity) {
883 // If more than half the elements won't be used, trim the array. 883 // If more than half the elements won't be used, trim the array.
884 if (length == 0) { 884 if (length == 0) {
885 array->initialize_elements(); 885 array->initialize_elements();
886 } else { 886 } else {
887 isolate->heap()->RightTrimFixedArray<Heap::FROM_MUTATOR>( 887 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
888 *backing_store, old_capacity - length); 888 *backing_store, old_capacity - length);
889 } 889 }
890 } else { 890 } else {
891 // Otherwise, fill the unused tail with holes. 891 // Otherwise, fill the unused tail with holes.
892 int old_length = FastD2IChecked(array->length()->Number()); 892 int old_length = FastD2IChecked(array->length()->Number());
893 for (int i = length; i < old_length; i++) { 893 for (int i = length; i < old_length; i++) {
894 Handle<BackingStore>::cast(backing_store)->set_the_hole(i); 894 Handle<BackingStore>::cast(backing_store)->set_the_hole(i);
895 } 895 }
896 } 896 }
897 return length_object; 897 return length_object;
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 UNREACHABLE(); 1843 UNREACHABLE();
1844 break; 1844 break;
1845 } 1845 }
1846 1846
1847 array->set_elements(*elms); 1847 array->set_elements(*elms);
1848 array->set_length(Smi::FromInt(number_of_elements)); 1848 array->set_length(Smi::FromInt(number_of_elements));
1849 return array; 1849 return array;
1850 } 1850 }
1851 1851
1852 } } // namespace v8::internal 1852 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698