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

Side by Side Diff: src/elements.cc

Issue 2872173003: [runtime] do not left-trim short arrays (Closed)
Patch Set: Created 3 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
« 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 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/elements.h" 5 #include "src/elements.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/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 *nof_items = count; 2143 *nof_items = count;
2144 return Just(true); 2144 return Just(true);
2145 } 2145 }
2146 2146
2147 static void MoveElements(Isolate* isolate, Handle<JSArray> receiver, 2147 static void MoveElements(Isolate* isolate, Handle<JSArray> receiver,
2148 Handle<FixedArrayBase> backing_store, int dst_index, 2148 Handle<FixedArrayBase> backing_store, int dst_index,
2149 int src_index, int len, int hole_start, 2149 int src_index, int len, int hole_start,
2150 int hole_end) { 2150 int hole_end) {
2151 Heap* heap = isolate->heap(); 2151 Heap* heap = isolate->heap();
2152 Handle<BackingStore> dst_elms = Handle<BackingStore>::cast(backing_store); 2152 Handle<BackingStore> dst_elms = Handle<BackingStore>::cast(backing_store);
2153 if (heap->CanMoveObjectStart(*dst_elms) && dst_index == 0) { 2153 if (heap->CanMoveObjectStart(*dst_elms) && dst_index == 0 &&
2154 len > JSArray::kMaxCopyElements) {
2154 // Update all the copies of this backing_store handle. 2155 // Update all the copies of this backing_store handle.
2155 *dst_elms.location() = 2156 *dst_elms.location() =
2156 BackingStore::cast(heap->LeftTrimFixedArray(*dst_elms, src_index)); 2157 BackingStore::cast(heap->LeftTrimFixedArray(*dst_elms, src_index));
2157 receiver->set_elements(*dst_elms); 2158 receiver->set_elements(*dst_elms);
2158 // Adjust the hole offset as the array has been shrunk. 2159 // Adjust the hole offset as the array has been shrunk.
2159 hole_end -= src_index; 2160 hole_end -= src_index;
2160 DCHECK_LE(hole_start, backing_store->length()); 2161 DCHECK_LE(hole_start, backing_store->length());
2161 DCHECK_LE(hole_end, backing_store->length()); 2162 DCHECK_LE(hole_end, backing_store->length());
2162 } else if (len != 0) { 2163 } else if (len != 0) {
2163 if (IsFastDoubleElementsKind(KindTraits::Kind)) { 2164 if (IsFastDoubleElementsKind(KindTraits::Kind)) {
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 insertion_index += len; 4302 insertion_index += len;
4302 } 4303 }
4303 4304
4304 DCHECK_EQ(insertion_index, result_len); 4305 DCHECK_EQ(insertion_index, result_len);
4305 return result_array; 4306 return result_array;
4306 } 4307 }
4307 4308
4308 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 4309 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
4309 } // namespace internal 4310 } // namespace internal
4310 } // namespace v8 4311 } // namespace v8
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