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

Side by Side Diff: src/objects.cc

Issue 735653003: Revert "Use a stub in crankshaft for grow store arrays." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 11249 matching lines...) Expand 10 before | Expand all | Expand 10 after
11260 os << "Constant Pool\n"; 11260 os << "Constant Pool\n";
11261 pool->Print(os); 11261 pool->Print(os);
11262 os << "\n"; 11262 os << "\n";
11263 } 11263 }
11264 } 11264 }
11265 #endif 11265 #endif
11266 } 11266 }
11267 #endif // ENABLE_DISASSEMBLER 11267 #endif // ENABLE_DISASSEMBLER
11268 11268
11269 11269
11270 Handle<FixedArray> JSObject::SetFastElementsCapacity( 11270 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
11271 Handle<JSObject> object, int capacity, 11271 Handle<JSObject> object,
11272 int capacity,
11273 int length,
11272 SetFastElementsCapacitySmiMode smi_mode) { 11274 SetFastElementsCapacitySmiMode smi_mode) {
11273 // We should never end in here with a pixel or external array. 11275 // We should never end in here with a pixel or external array.
11274 DCHECK(!object->HasExternalArrayElements()); 11276 DCHECK(!object->HasExternalArrayElements());
11275 11277
11276 // Allocate a new fast elements backing store. 11278 // Allocate a new fast elements backing store.
11277 Handle<FixedArray> new_elements = 11279 Handle<FixedArray> new_elements =
11278 object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity); 11280 object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity);
11279 11281
11280 ElementsKind elements_kind = object->GetElementsKind(); 11282 ElementsKind elements_kind = object->GetElementsKind();
11281 ElementsKind new_elements_kind; 11283 ElementsKind new_elements_kind;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
11313 } else { 11315 } else {
11314 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); 11316 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements);
11315 parameter_map->set(1, *new_elements); 11317 parameter_map->set(1, *new_elements);
11316 } 11318 }
11317 11319
11318 if (FLAG_trace_elements_transitions) { 11320 if (FLAG_trace_elements_transitions) {
11319 PrintElementsTransition(stdout, object, elements_kind, old_elements, 11321 PrintElementsTransition(stdout, object, elements_kind, old_elements,
11320 object->GetElementsKind(), new_elements); 11322 object->GetElementsKind(), new_elements);
11321 } 11323 }
11322 11324
11323 return new_elements;
11324 }
11325
11326
11327 Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
11328 Handle<JSObject> object, int capacity, int length,
11329 SetFastElementsCapacitySmiMode smi_mode) {
11330 Handle<FixedArray> new_elements =
11331 SetFastElementsCapacity(object, capacity, smi_mode);
11332 if (object->IsJSArray()) { 11325 if (object->IsJSArray()) {
11333 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); 11326 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11334 } 11327 }
11335 return new_elements; 11328 return new_elements;
11336 } 11329 }
11337 11330
11338 11331
11339 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacity( 11332 void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
11340 Handle<JSObject> object, int capacity) { 11333 int capacity,
11334 int length) {
11341 // We should never end in here with a pixel or external array. 11335 // We should never end in here with a pixel or external array.
11342 DCHECK(!object->HasExternalArrayElements()); 11336 DCHECK(!object->HasExternalArrayElements());
11343 11337
11344 Handle<FixedArrayBase> elems = 11338 Handle<FixedArrayBase> elems =
11345 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity); 11339 object->GetIsolate()->factory()->NewFixedDoubleArray(capacity);
11346 11340
11347 ElementsKind elements_kind = object->GetElementsKind(); 11341 ElementsKind elements_kind = object->GetElementsKind();
11348 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS); 11342 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS);
11349 ElementsKind new_elements_kind = elements_kind; 11343 ElementsKind new_elements_kind = elements_kind;
11350 if (IsHoleyElementsKind(elements_kind)) { 11344 if (IsHoleyElementsKind(elements_kind)) {
11351 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS; 11345 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS;
11352 } else { 11346 } else {
11353 new_elements_kind = FAST_DOUBLE_ELEMENTS; 11347 new_elements_kind = FAST_DOUBLE_ELEMENTS;
11354 } 11348 }
11355 11349
11356 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); 11350 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind);
11357 11351
11358 Handle<FixedArrayBase> old_elements(object->elements()); 11352 Handle<FixedArrayBase> old_elements(object->elements());
11359 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); 11353 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
11360 accessor->CopyElements(object, elems, elements_kind); 11354 accessor->CopyElements(object, elems, elements_kind);
11361 11355
11362 JSObject::ValidateElements(object); 11356 JSObject::ValidateElements(object);
11363 JSObject::SetMapAndElements(object, new_map, elems); 11357 JSObject::SetMapAndElements(object, new_map, elems);
11364 11358
11365 if (FLAG_trace_elements_transitions) { 11359 if (FLAG_trace_elements_transitions) {
11366 PrintElementsTransition(stdout, object, elements_kind, old_elements, 11360 PrintElementsTransition(stdout, object, elements_kind, old_elements,
11367 object->GetElementsKind(), elems); 11361 object->GetElementsKind(), elems);
11368 } 11362 }
11369 11363
11370 return elems; 11364 if (object->IsJSArray()) {
11365 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11366 }
11371 } 11367 }
11372 11368
11373 11369
11374 Handle<FixedArrayBase> JSObject::SetFastDoubleElementsCapacityAndLength(
11375 Handle<JSObject> object, int capacity, int length) {
11376 Handle<FixedArrayBase> new_elements =
11377 SetFastDoubleElementsCapacity(object, capacity);
11378 if (object->IsJSArray()) {
11379 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length));
11380 }
11381 return new_elements;
11382 }
11383
11384
11385 // static 11370 // static
11386 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) { 11371 void JSArray::Initialize(Handle<JSArray> array, int capacity, int length) {
11387 DCHECK(capacity >= 0); 11372 DCHECK(capacity >= 0);
11388 array->GetIsolate()->factory()->NewJSArrayStorage( 11373 array->GetIsolate()->factory()->NewJSArrayStorage(
11389 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 11374 array, length, capacity, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
11390 } 11375 }
11391 11376
11392 11377
11393 void JSArray::Expand(Handle<JSArray> array, int required_size) { 11378 void JSArray::Expand(Handle<JSArray> array, int required_size) {
11394 ElementsAccessor* accessor = array->GetElementsAccessor(); 11379 ElementsAccessor* accessor = array->GetElementsAccessor();
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
13296 // External arrays are considered 100% used. 13281 // External arrays are considered 100% used.
13297 FixedArrayBase* external_array = FixedArrayBase::cast(elements()); 13282 FixedArrayBase* external_array = FixedArrayBase::cast(elements());
13298 *capacity = external_array->length(); 13283 *capacity = external_array->length();
13299 *used = external_array->length(); 13284 *used = external_array->length();
13300 break; 13285 break;
13301 } 13286 }
13302 } 13287 }
13303 } 13288 }
13304 13289
13305 13290
13306 bool JSObject::WouldConvertToSlowElements(uint32_t index) { 13291 bool JSObject::WouldConvertToSlowElements(Handle<Object> key) {
13307 if (HasFastElements()) { 13292 uint32_t index;
13293 if (HasFastElements() && key->ToArrayIndex(&index)) {
13308 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements())); 13294 Handle<FixedArrayBase> backing_store(FixedArrayBase::cast(elements()));
13309 uint32_t capacity = static_cast<uint32_t>(backing_store->length()); 13295 uint32_t capacity = static_cast<uint32_t>(backing_store->length());
13310 if (index >= capacity) { 13296 if (index >= capacity) {
13311 if ((index - capacity) >= kMaxGap) return true; 13297 if ((index - capacity) >= kMaxGap) return true;
13312 uint32_t new_capacity = NewElementsCapacity(index + 1); 13298 uint32_t new_capacity = NewElementsCapacity(index + 1);
13313 return ShouldConvertToSlowElements(new_capacity); 13299 return ShouldConvertToSlowElements(new_capacity);
13314 } 13300 }
13315 } 13301 }
13316 return false; 13302 return false;
13317 } 13303 }
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after
16843 Handle<DependentCode> codes = 16829 Handle<DependentCode> codes =
16844 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16830 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16845 DependentCode::kPropertyCellChangedGroup, 16831 DependentCode::kPropertyCellChangedGroup,
16846 info->object_wrapper()); 16832 info->object_wrapper());
16847 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16833 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16848 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16834 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16849 cell, info->zone()); 16835 cell, info->zone());
16850 } 16836 }
16851 16837
16852 } } // namespace v8::internal 16838 } } // 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