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

Side by Side Diff: src/objects.cc

Issue 1109333003: Use a stub in crankshaft for grow store arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ARM failure. Created 5 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 | « src/objects.h ('k') | src/objects-inl.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 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 11936 matching lines...) Expand 10 before | Expand all | Expand 10 after
11947 os << "Constant Pool\n"; 11947 os << "Constant Pool\n";
11948 pool->Print(os); 11948 pool->Print(os);
11949 os << "\n"; 11949 os << "\n";
11950 } 11950 }
11951 } 11951 }
11952 #endif 11952 #endif
11953 } 11953 }
11954 #endif // ENABLE_DISASSEMBLER 11954 #endif // ENABLE_DISASSEMBLER
11955 11955
11956 11956
11957 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength( 11957 Handle<FixedArray> JSObject::SetFastElementsCapacity(
11958 Handle<JSObject> object, 11958 Handle<JSObject> object, int capacity,
11959 int capacity,
11960 int length,
11961 SetFastElementsCapacitySmiMode smi_mode) { 11959 SetFastElementsCapacitySmiMode smi_mode) {
11962 // We should never end in here with a pixel or external array. 11960 // We should never end in here with a pixel or external array.
11963 DCHECK(!object->HasExternalArrayElements()); 11961 DCHECK(!object->HasExternalArrayElements());
11964 11962
11965 // Allocate a new fast elements backing store. 11963 // Allocate a new fast elements backing store.
11966 Isolate* isolate = object->GetIsolate(); 11964 Isolate* isolate = object->GetIsolate();
11967 Handle<FixedArray> new_elements = 11965 Handle<FixedArray> new_elements =
11968 isolate->factory()->NewUninitializedFixedArray(capacity); 11966 isolate->factory()->NewUninitializedFixedArray(capacity);
11969 11967
11970 isolate->UpdateArrayProtectorOnSetLength(object); 11968 isolate->UpdateArrayProtectorOnSetLength(object);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
12005 } else { 12003 } else {
12006 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); 12004 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements);
12007 parameter_map->set(1, *new_elements); 12005 parameter_map->set(1, *new_elements);
12008 } 12006 }
12009 12007
12010 if (FLAG_trace_elements_transitions) { 12008 if (FLAG_trace_elements_transitions) {
12011 PrintElementsTransition(stdout, object, elements_kind, old_elements, 12009 PrintElementsTransition(stdout, object, elements_kind, old_elements,
12012 object->GetElementsKind(), new_elements); 12010 object->GetElementsKind(), new_elements);
12013 } 12011 }
12014 12012
12013 return new_elements;
12014 }
12015
12016
12017 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
12018 Handle<JSObject> object, int capacity, int length,
12019 SetFastElementsCapacitySmiMode smi_mode) {
12020 Handle<FixedArray> new_elements =
12021 SetFastElementsCapacity(object, capacity, smi_mode);
12015 if (object->IsJSArray()) { 12022 if (object->IsJSArray()) {
12016 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); 12023 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
12017 } 12024 }
12018 return new_elements; 12025 return new_elements;
12019 } 12026 }
12020 12027
12021 12028
12022 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object, 12029 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacity(
12023 int capacity, 12030 Handle<JSObject> object, int capacity) {
12024 int length) {
12025 // We should never end in here with a pixel or external array. 12031 // We should never end in here with a pixel or external array.
12026 DCHECK(!object->HasExternalArrayElements()); 12032 DCHECK(!object->HasExternalArrayElements());
12027 12033
12028 Handle<FixedArrayBase> elems = 12034 Handle<FixedArrayBase> elems =
12029 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity); 12035 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity);
12030 12036
12031 ElementsKind elements_kind = object->GetElementsKind(); 12037 ElementsKind elements_kind = object->GetElementsKind();
12032 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS); 12038 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS);
12033 ElementsKind new_elements_kind = elements_kind; 12039 ElementsKind new_elements_kind = elements_kind;
12034 if (IsHoleyElementsKind(elements_kind)) { 12040 if (IsHoleyElementsKind(elements_kind)) {
12035 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS; 12041 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
12036 } else { 12042 } else {
12037 new_elements_kind = FAST_DOUBLE_ELEMENTS; 12043 new_elements_kind = FAST_DOUBLE_ELEMENTS;
12038 } 12044 }
12039 12045
12040 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); 12046 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind);
12041 12047
12042 Handle<FixedArrayBase> old_elements(object->elements()); 12048 Handle<FixedArrayBase> old_elements(object->elements());
12043 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); 12049 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
12044 accessor->CopyElements(object, elems, elements_kind); 12050 accessor->CopyElements(object, elems, elements_kind);
12045 12051
12046 JSObject::ValidateElements(object); 12052 JSObject::ValidateElements(object);
12047 JSObject::SetMapAndElements(object, new_map, elems); 12053 JSObject::SetMapAndElements(object, new_map, elems);
12048 12054
12049 if (FLAG_trace_elements_transitions) { 12055 if (FLAG_trace_elements_transitions) {
12050 PrintElementsTransition(stdout, object, elements_kind, old_elements, 12056 PrintElementsTransition(stdout, object, elements_kind, old_elements,
12051 object->GetElementsKind(), elems); 12057 object->GetElementsKind(), elems);
12052 } 12058 }
12053 12059
12060 return elems;
12061 }
12062
12063
12064 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacityAndLength(
12065 Handle<JSObject> object, int capacity, int length) {
12066 Handle<FixedArrayBase> new_elements =
12067 SetFastDoubleElementsCapacity(object, capacity);
12054 if (object->IsJSArray()) { 12068 if (object->IsJSArray()) {
12055 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); 12069 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
12056 } 12070 }
12071 return new_elements;
12057 } 12072 }
12058 12073
12059 12074
12060 // static 12075 // static
12061 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) { 12076 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) {
12062 DCHECK(capacity >= 0); 12077 DCHECK(capacity >= 0);
12063 array->GetIsolate()->factory()->NewJSArrayStorage( 12078 array->GetIsolate()->factory()->NewJSArrayStorage(
12064 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 12079 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
12065 } 12080 }
12066 12081
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
13805 // External arrays are considered 100% used. 13820 // External arrays are considered 100% used.
13806 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); 13821 FixedArrayBase* external_array = FixedArrayBase::cast(elements());
13807 *capacity = external_array->length(); 13822 *capacity = external_array->length();
13808 *used = external_array->length(); 13823 *used = external_array->length();
13809 break; 13824 break;
13810 } 13825 }
13811 } 13826 }
13812 } 13827 }
13813 13828
13814 13829
13815 bool JSObject::WouldConvertToSlowElements(Handle<Object> key) { 13830 bool JSObject::WouldConvertToSlowElements(uint32_t index) {
13816 uint32_t index; 13831 if (HasFastElements()) {
13817 if (HasFastElements() && key->ToArrayIndex(&index)) {
13818 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements())); 13832 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements()));
13819 uint32_t capacity = static_cast<uint32_t>(backing_store->length()); 13833 uint32_t capacity = static_cast<uint32_t>(backing_store->length());
13820 if (index >= capacity) { 13834 if (index >= capacity) {
13821 if ((index - capacity) >= kMaxGap) return true; 13835 if ((index - capacity) >= kMaxGap) return true;
13822 uint32_t new_capacity = NewElementsCapacity(index + 1); 13836 uint32_t new_capacity = NewElementsCapacity(index + 1);
13823 return ShouldConvertToSlowElements(new_capacity); 13837 return ShouldConvertToSlowElements(new_capacity);
13824 } 13838 }
13825 } 13839 }
13826 return false; 13840 return false;
13827 } 13841 }
(...skipping 3374 matching lines...) Expand 10 before | Expand all | Expand 10 after
17202 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, 17216 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell,
17203 Handle<Object> new_value) { 17217 Handle<Object> new_value) {
17204 if (cell->value() != *new_value) { 17218 if (cell->value() != *new_value) {
17205 cell->set_value(*new_value); 17219 cell->set_value(*new_value);
17206 Isolate* isolate = cell->GetIsolate(); 17220 Isolate* isolate = cell->GetIsolate();
17207 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17221 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17208 isolate, DependentCode::kPropertyCellChangedGroup); 17222 isolate, DependentCode::kPropertyCellChangedGroup);
17209 } 17223 }
17210 } 17224 }
17211 } } // namespace v8::internal 17225 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698