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

Side by Side Diff: src/objects.cc

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