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

Side by Side Diff: src/elements.cc

Issue 1716833002: [runtime] Speed up C++ version of ArrayPush (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add TODO for Toon's comment Created 4 years, 10 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 | « src/debug/liveedit.cc ('k') | src/objects.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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 698 }
699 } 699 }
700 700
701 // Check whether the backing store should be shrunk. 701 // Check whether the backing store should be shrunk.
702 uint32_t capacity = backing_store->length(); 702 uint32_t capacity = backing_store->length();
703 old_length = Min(old_length, capacity); 703 old_length = Min(old_length, capacity);
704 if (length == 0) { 704 if (length == 0) {
705 array->initialize_elements(); 705 array->initialize_elements();
706 } else if (length <= capacity) { 706 } else if (length <= capacity) {
707 if (array->HasFastSmiOrObjectElements()) { 707 if (array->HasFastSmiOrObjectElements()) {
708 backing_store = JSObject::EnsureWritableFastElements(array); 708 JSObject::EnsureWritableFastElements(array);
709 if (array->elements() != *backing_store) {
710 backing_store = handle(array->elements(), isolate);
711 }
709 } 712 }
710 if (2 * length <= capacity) { 713 if (2 * length <= capacity) {
711 // If more than half the elements won't be used, trim the array. 714 // If more than half the elements won't be used, trim the array.
712 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( 715 isolate->heap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(
713 *backing_store, capacity - length); 716 *backing_store, capacity - length);
714 } else { 717 } else {
715 // Otherwise, fill the unused tail with holes. 718 // Otherwise, fill the unused tail with holes.
716 for (uint32_t i = length; i < old_length; i++) { 719 for (uint32_t i = length; i < old_length; i++) {
717 BackingStore::cast(*backing_store)->set_the_hole(i); 720 BackingStore::cast(*backing_store)->set_the_hole(i);
718 } 721 }
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 } 2680 }
2678 } 2681 }
2679 2682
2680 DCHECK(j == result_len); 2683 DCHECK(j == result_len);
2681 return result_array; 2684 return result_array;
2682 } 2685 }
2683 2686
2684 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2687 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
2685 } // namespace internal 2688 } // namespace internal
2686 } // namespace v8 2689 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/liveedit.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698