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

Side by Side Diff: src/elements.cc

Issue 1305353010: Remove LeftTrimFixedArray (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | src/heap/heap.h » ('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/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/messages.h" 10 #include "src/messages.h"
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 static Handle<Object> ShiftImpl(Handle<JSArray> receiver, 1330 static Handle<Object> ShiftImpl(Handle<JSArray> receiver,
1331 Handle<FixedArrayBase> backing_store) { 1331 Handle<FixedArrayBase> backing_store) {
1332 uint32_t len = 1332 uint32_t len =
1333 static_cast<uint32_t>(Smi::cast(receiver->length())->value()); 1333 static_cast<uint32_t>(Smi::cast(receiver->length())->value());
1334 Isolate* isolate = receiver->GetIsolate(); 1334 Isolate* isolate = receiver->GetIsolate();
1335 DCHECK(len > 0); 1335 DCHECK(len > 0);
1336 int new_length = len - 1; 1336 int new_length = len - 1;
1337 Handle<Object> result = 1337 Handle<Object> result =
1338 FastElementsAccessorSubclass::GetImpl(backing_store, 0); 1338 FastElementsAccessorSubclass::GetImpl(backing_store, 0);
1339 Heap* heap = isolate->heap(); 1339 Heap* heap = isolate->heap();
1340 if (heap->CanMoveObjectStart(*backing_store)) { 1340 FastElementsAccessorSubclass::MoveElements(heap, backing_store, 0, 1,
1341 receiver->set_elements(heap->LeftTrimFixedArray(*backing_store, 1)); 1341 new_length, 0, 0);
1342 } else {
1343 FastElementsAccessorSubclass::MoveElements(heap, backing_store, 0, 1,
1344 new_length, 0, 0);
1345 }
1346 FastElementsAccessorSubclass::SetLengthImpl(receiver, new_length, 1342 FastElementsAccessorSubclass::SetLengthImpl(receiver, new_length,
1347 backing_store); 1343 backing_store);
1348 1344
1349 if (IsHoleyElementsKind(KindTraits::Kind) && result->IsTheHole()) { 1345 if (IsHoleyElementsKind(KindTraits::Kind) && result->IsTheHole()) {
1350 result = receiver->GetIsolate()->factory()->undefined_value(); 1346 result = receiver->GetIsolate()->factory()->undefined_value();
1351 } 1347 }
1352 return result; 1348 return result;
1353 } 1349 }
1354 1350
1355 static uint32_t PushImpl(Handle<JSArray> receiver, 1351 static uint32_t PushImpl(Handle<JSArray> receiver,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 return deleted_elements; 1498 return deleted_elements;
1503 } 1499 }
1504 1500
1505 private: 1501 private:
1506 static bool SpliceShrinkStep(Handle<FixedArrayBase>& backing_store, 1502 static bool SpliceShrinkStep(Handle<FixedArrayBase>& backing_store,
1507 Heap* heap, uint32_t start, 1503 Heap* heap, uint32_t start,
1508 uint32_t delete_count, uint32_t add_count, 1504 uint32_t delete_count, uint32_t add_count,
1509 uint32_t len, uint32_t new_length) { 1505 uint32_t len, uint32_t new_length) {
1510 const int move_left_count = len - delete_count - start; 1506 const int move_left_count = len - delete_count - start;
1511 const int move_left_dst_index = start + add_count; 1507 const int move_left_dst_index = start + add_count;
1512 const bool left_trim_array = heap->CanMoveObjectStart(*backing_store) && 1508 FastElementsAccessorSubclass::MoveElements(
1513 (move_left_dst_index < move_left_count); 1509 heap, backing_store, move_left_dst_index, start + delete_count,
1514 if (left_trim_array) { 1510 move_left_count, new_length, len);
1515 const int delta = delete_count - add_count;
1516 // shift from before the insertion point to the right
1517 FastElementsAccessorSubclass::MoveElements(heap, backing_store, delta, 0,
1518 start, 0, 0);
1519 backing_store = handle(heap->LeftTrimFixedArray(*backing_store, delta));
1520 return true;
1521 } else {
1522 // No left-trim needed or possible (in this case we left-move and store
1523 // the hole)
1524 FastElementsAccessorSubclass::MoveElements(
1525 heap, backing_store, move_left_dst_index, start + delete_count,
1526 move_left_count, new_length, len);
1527 }
1528 return false; 1511 return false;
1529 } 1512 }
1530 1513
1531 1514
1532 static bool SpliceGrowStep(Handle<JSArray> receiver, 1515 static bool SpliceGrowStep(Handle<JSArray> receiver,
1533 Handle<FixedArrayBase>& backing_store, 1516 Handle<FixedArrayBase>& backing_store,
1534 Isolate* isolate, Heap* heap, uint32_t start, 1517 Isolate* isolate, Heap* heap, uint32_t start,
1535 uint32_t delete_count, uint32_t add_count, 1518 uint32_t delete_count, uint32_t add_count,
1536 uint32_t len, uint32_t new_length) { 1519 uint32_t len, uint32_t new_length) {
1537 // Currently fixed arrays cannot grow too big, so 1520 // Currently fixed arrays cannot grow too big, so
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 } 2392 }
2410 } 2393 }
2411 2394
2412 DCHECK(j == result_len); 2395 DCHECK(j == result_len);
2413 return result_array; 2396 return result_array;
2414 } 2397 }
2415 2398
2416 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2399 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
2417 } // namespace internal 2400 } // namespace internal
2418 } // namespace v8 2401 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698