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

Side by Side Diff: src/objects.cc

Issue 735323002: Revert "Re-land r25392 Use a stub in crankshaft for grow store arrays." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 6 years, 1 month 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 11235 matching lines...) Expand 10 before | Expand all | Expand 10 after
11246 os << "Constant Pool\n"; 11246 os << "Constant Pool\n";
11247 pool->Print(os); 11247 pool->Print(os);
11248 os << "\n"; 11248 os << "\n";
11249 } 11249 }
11250 } 11250 }
11251 #endif 11251 #endif
11252 } 11252 }
11253 #endif // ENABLE_DISASSEMBLER 11253 #endif // ENABLE_DISASSEMBLER
11254 11254
11255 11255
11256 Handle<FixedArray> JSObject::SetFastElementsCapacity( 11256 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
11257 Handle<JSObject> object, int capacity, 11257 Handle<JSObject> object,
11258 int capacity,
11259 int length,
11258 SetFastElementsCapacitySmiMode smi_mode) { 11260 SetFastElementsCapacitySmiMode smi_mode) {
11259 // We should never end in here with a pixel or external array. 11261 // We should never end in here with a pixel or external array.
11260 DCHECK(!object->HasExternalArrayElements()); 11262 DCHECK(!object->HasExternalArrayElements());
11261 11263
11262 // Allocate a new fast elements backing store. 11264 // Allocate a new fast elements backing store.
11263 Handle<FixedArray> new_elements = 11265 Handle<FixedArray> new_elements =
11264 object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity); 11266 object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity);
11265 11267
11266 ElementsKind elements_kind = object->GetElementsKind(); 11268 ElementsKind elements_kind = object->GetElementsKind();
11267 ElementsKind new_elements_kind; 11269 ElementsKind new_elements_kind;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
11299 } else { 11301 } else {
11300 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); 11302 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements);
11301 parameter_map->set(1, *new_elements); 11303 parameter_map->set(1, *new_elements);
11302 } 11304 }
11303 11305
11304 if (FLAG_trace_elements_transitions) { 11306 if (FLAG_trace_elements_transitions) {
11305 PrintElementsTransition(stdout, object, elements_kind, old_elements, 11307 PrintElementsTransition(stdout, object, elements_kind, old_elements,
11306 object->GetElementsKind(), new_elements); 11308 object->GetElementsKind(), new_elements);
11307 } 11309 }
11308 11310
11309 return new_elements;
11310 }
11311
11312
11313 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
11314 Handle<JSObject> object, int capacity, int length,
11315 SetFastElementsCapacitySmiMode smi_mode) {
11316 Handle<FixedArray> new_elements =
11317 SetFastElementsCapacity(object, capacity, smi_mode);
11318 if (object->IsJSArray()) { 11311 if (object->IsJSArray()) {
11319 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); 11312 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11320 } 11313 }
11321 return new_elements; 11314 return new_elements;
11322 } 11315 }
11323 11316
11324 11317
11325 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacity( 11318 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
11326 Handle<JSObject> object, int capacity) { 11319 int capacity,
11320 int length) {
11327 // We should never end in here with a pixel or external array. 11321 // We should never end in here with a pixel or external array.
11328 DCHECK(!object->HasExternalArrayElements()); 11322 DCHECK(!object->HasExternalArrayElements());
11329 11323
11330 Handle<FixedArrayBase> elems = 11324 Handle<FixedArrayBase> elems =
11331 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity); 11325 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity);
11332 11326
11333 ElementsKind elements_kind = object->GetElementsKind(); 11327 ElementsKind elements_kind = object->GetElementsKind();
11334 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS); 11328 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS);
11335 ElementsKind new_elements_kind = elements_kind; 11329 ElementsKind new_elements_kind = elements_kind;
11336 if (IsHoleyElementsKind(elements_kind)) { 11330 if (IsHoleyElementsKind(elements_kind)) {
11337 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS; 11331 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
11338 } else { 11332 } else {
11339 new_elements_kind = FAST_DOUBLE_ELEMENTS; 11333 new_elements_kind = FAST_DOUBLE_ELEMENTS;
11340 } 11334 }
11341 11335
11342 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); 11336 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind);
11343 11337
11344 Handle<FixedArrayBase> old_elements(object->elements()); 11338 Handle<FixedArrayBase> old_elements(object->elements());
11345 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); 11339 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
11346 accessor->CopyElements(object, elems, elements_kind); 11340 accessor->CopyElements(object, elems, elements_kind);
11347 11341
11348 JSObject::ValidateElements(object); 11342 JSObject::ValidateElements(object);
11349 JSObject::SetMapAndElements(object, new_map, elems); 11343 JSObject::SetMapAndElements(object, new_map, elems);
11350 11344
11351 if (FLAG_trace_elements_transitions) { 11345 if (FLAG_trace_elements_transitions) {
11352 PrintElementsTransition(stdout, object, elements_kind, old_elements, 11346 PrintElementsTransition(stdout, object, elements_kind, old_elements,
11353 object->GetElementsKind(), elems); 11347 object->GetElementsKind(), elems);
11354 } 11348 }
11355 11349
11356 return elems; 11350 if (object->IsJSArray()) {
11351 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11352 }
11357 } 11353 }
11358 11354
11359 11355
11360 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacityAndLength(
11361 Handle<JSObject> object, int capacity, int length) {
11362 Handle<FixedArrayBase> new_elements =
11363 SetFastDoubleElementsCapacity(object, capacity);
11364 if (object->IsJSArray()) {
11365 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11366 }
11367 return new_elements;
11368 }
11369
11370
11371 // static 11356 // static
11372 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) { 11357 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) {
11373 DCHECK(capacity >= 0); 11358 DCHECK(capacity >= 0);
11374 array->GetIsolate()->factory()->NewJSArrayStorage( 11359 array->GetIsolate()->factory()->NewJSArrayStorage(
11375 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 11360 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
11376 } 11361 }
11377 11362
11378 11363
11379 void JSArray::Expand(Handle<JSArray> array, int required_size) { 11364 void JSArray::Expand(Handle<JSArray> array, int required_size) {
11380 ElementsAccessor* accessor = array->GetElementsAccessor(); 11365 ElementsAccessor* accessor = array->GetElementsAccessor();
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
13282 // External arrays are considered 100% used. 13267 // External arrays are considered 100% used.
13283 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); 13268 FixedArrayBase* external_array = FixedArrayBase::cast(elements());
13284 *capacity = external_array->length(); 13269 *capacity = external_array->length();
13285 *used = external_array->length(); 13270 *used = external_array->length();
13286 break; 13271 break;
13287 } 13272 }
13288 } 13273 }
13289 } 13274 }
13290 13275
13291 13276
13292 bool JSObject::WouldConvertToSlowElements(uint32_t index) { 13277 bool JSObject::WouldConvertToSlowElements(Handle<Object> key) {
13293 if (HasFastElements()) { 13278 uint32_t index;
13279 if (HasFastElements() && key->ToArrayIndex(&index)) {
13294 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements())); 13280 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements()));
13295 uint32_t capacity = static_cast<uint32_t>(backing_store->length()); 13281 uint32_t capacity = static_cast<uint32_t>(backing_store->length());
13296 if (index >= capacity) { 13282 if (index >= capacity) {
13297 if ((index - capacity) >= kMaxGap) return true; 13283 if ((index - capacity) >= kMaxGap) return true;
13298 uint32_t new_capacity = NewElementsCapacity(index + 1); 13284 uint32_t new_capacity = NewElementsCapacity(index + 1);
13299 return ShouldConvertToSlowElements(new_capacity); 13285 return ShouldConvertToSlowElements(new_capacity);
13300 } 13286 }
13301 } 13287 }
13302 return false; 13288 return false;
13303 } 13289 }
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after
16829 Handle<DependentCode> codes = 16815 Handle<DependentCode> codes =
16830 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16816 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16831 DependentCode::kPropertyCellChangedGroup, 16817 DependentCode::kPropertyCellChangedGroup,
16832 info->object_wrapper()); 16818 info->object_wrapper());
16833 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16819 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16834 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16820 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16835 cell, info->zone()); 16821 cell, info->zone());
16836 } 16822 }
16837 16823
16838 } } // namespace v8::internal 16824 } } // 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