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

Side by Side Diff: src/objects.cc

Issue 1193343002: Move SetFastDoubleElementsCapacity into GrowCapacityAndConvert (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « src/objects.h ('k') | src/runtime/runtime-array.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 11831 matching lines...) Expand 10 before | Expand all | Expand 10 after
11842 SetFastElementsCapacitySmiMode smi_mode) { 11842 SetFastElementsCapacitySmiMode smi_mode) {
11843 Handle<FixedArray> new_elements = 11843 Handle<FixedArray> new_elements =
11844 SetFastElementsCapacity(object, capacity, smi_mode); 11844 SetFastElementsCapacity(object, capacity, smi_mode);
11845 if (object->IsJSArray()) { 11845 if (object->IsJSArray()) {
11846 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); 11846 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11847 } 11847 }
11848 return new_elements; 11848 return new_elements;
11849 } 11849 }
11850 11850
11851 11851
11852 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacity( 11852 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
11853 Handle<JSObject> object, int capacity) { 11853 int capacity,
11854 // We should never end in here with a pixel or external array. 11854 int length) {
11855 DCHECK(!object->HasExternalArrayElements()); 11855 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
11856 11856 accessor->GrowCapacityAndConvert(object, capacity);
11857 Handle<FixedArrayBase> elems = 11857 if (object->IsJSArray()) {
11858 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity); 11858 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11859
11860 ElementsKind elements_kind = object->GetElementsKind();
11861 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS);
11862 ElementsKind new_elements_kind = elements_kind;
11863 if (IsHoleyElementsKind(elements_kind)) {
11864 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
11865 } else {
11866 new_elements_kind = FAST_DOUBLE_ELEMENTS;
11867 } 11859 }
11868
11869 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind);
11870
11871 Handle<FixedArrayBase> old_elements(object->elements());
11872 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
11873 accessor->CopyElements(object, elems, elements_kind);
11874
11875 JSObject::ValidateElements(object);
11876 JSObject::SetMapAndElements(object, new_map, elems);
11877
11878 if (FLAG_trace_elements_transitions) {
11879 PrintElementsTransition(stdout, object, elements_kind, old_elements,
11880 object->GetElementsKind(), elems);
11881 }
11882
11883 return elems;
11884 } 11860 }
11885 11861
11886 11862
11887 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacityAndLength(
11888 Handle<JSObject> object, int capacity, int length) {
11889 Handle<FixedArrayBase> new_elements =
11890 SetFastDoubleElementsCapacity(object, capacity);
11891 if (object->IsJSArray()) {
11892 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11893 }
11894 return new_elements;
11895 }
11896
11897
11898 // static 11863 // static
11899 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) { 11864 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) {
11900 DCHECK(capacity >= 0); 11865 DCHECK(capacity >= 0);
11901 array->GetIsolate()->factory()->NewJSArrayStorage( 11866 array->GetIsolate()->factory()->NewJSArrayStorage(
11902 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 11867 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
11903 } 11868 }
11904 11869
11905 11870
11906 // Returns false if the passed-in index is marked non-configurable, which will 11871 // Returns false if the passed-in index is marked non-configurable, which will
11907 // cause the truncation operation to halt, and thus no further old values need 11872 // cause the truncation operation to halt, and thus no further old values need
(...skipping 4743 matching lines...) Expand 10 before | Expand all | Expand 10 after
16651 Handle<Object> new_value) { 16616 Handle<Object> new_value) {
16652 if (cell->value() != *new_value) { 16617 if (cell->value() != *new_value) {
16653 cell->set_value(*new_value); 16618 cell->set_value(*new_value);
16654 Isolate* isolate = cell->GetIsolate(); 16619 Isolate* isolate = cell->GetIsolate();
16655 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16620 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16656 isolate, DependentCode::kPropertyCellChangedGroup); 16621 isolate, DependentCode::kPropertyCellChangedGroup);
16657 } 16622 }
16658 } 16623 }
16659 } // namespace internal 16624 } // namespace internal
16660 } // namespace v8 16625 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698