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

Side by Side Diff: src/objects-inl.h

Issue 8177005: Active smi-only optimizations for large array literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | src/runtime.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1299
1300 1300
1301 FixedArrayBase* JSObject::elements() { 1301 FixedArrayBase* JSObject::elements() {
1302 Object* array = READ_FIELD(this, kElementsOffset); 1302 Object* array = READ_FIELD(this, kElementsOffset);
1303 ASSERT(array->HasValidElements()); 1303 ASSERT(array->HasValidElements());
1304 return static_cast<FixedArrayBase*>(array); 1304 return static_cast<FixedArrayBase*>(array);
1305 } 1305 }
1306 1306
1307 void JSObject::ValidateSmiOnlyElements() { 1307 void JSObject::ValidateSmiOnlyElements() {
1308 #if DEBUG 1308 #if DEBUG
1309 if (FLAG_smi_only_arrays && 1309 if (map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) {
1310 map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) {
1311 Heap* heap = GetHeap(); 1310 Heap* heap = GetHeap();
1312 // Don't use elements, since integrity checks will fail if there 1311 // Don't use elements, since integrity checks will fail if there
1313 // are filler pointers in the array. 1312 // are filler pointers in the array.
1314 FixedArray* fixed_array = 1313 FixedArray* fixed_array =
1315 reinterpret_cast<FixedArray*>(READ_FIELD(this, kElementsOffset)); 1314 reinterpret_cast<FixedArray*>(READ_FIELD(this, kElementsOffset));
1316 Map* map = fixed_array->map(); 1315 Map* map = fixed_array->map();
1317 // Arrays that have been shifted in place can't be verified. 1316 // Arrays that have been shifted in place can't be verified.
1318 if (map != heap->raw_unchecked_one_pointer_filler_map() && 1317 if (map != heap->raw_unchecked_one_pointer_filler_map() &&
1319 map != heap->raw_unchecked_two_pointer_filler_map() && 1318 map != heap->raw_unchecked_two_pointer_filler_map() &&
1320 map != heap->free_space_map()) { 1319 map != heap->free_space_map()) {
1321 for (int i = 0; i < fixed_array->length(); i++) { 1320 for (int i = 0; i < fixed_array->length(); i++) {
1322 Object* current = fixed_array->get(i); 1321 Object* current = fixed_array->get(i);
1323 ASSERT(current->IsSmi() || current == heap->the_hole_value()); 1322 ASSERT(current->IsSmi() || current == heap->the_hole_value());
1324 } 1323 }
1325 } 1324 }
1326 } 1325 }
1327 #endif 1326 #endif
1328 } 1327 }
1329 1328
1330 1329
1331 MaybeObject* JSObject::EnsureCanContainNonSmiElements() { 1330 MaybeObject* JSObject::EnsureCanContainNonSmiElements() {
1332 #if DEBUG 1331 #if DEBUG
1333 ValidateSmiOnlyElements(); 1332 ValidateSmiOnlyElements();
1334 #endif 1333 #endif
1335 if (FLAG_smi_only_arrays && 1334 if ((map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS)) {
1336 (map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS)) {
1337 Object* obj; 1335 Object* obj;
1338 MaybeObject* maybe_obj = GetElementsTransitionMap(FAST_ELEMENTS); 1336 MaybeObject* maybe_obj = GetElementsTransitionMap(FAST_ELEMENTS);
1339 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 1337 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
1340 set_map(Map::cast(obj)); 1338 set_map(Map::cast(obj));
1341 } 1339 }
1342 return this; 1340 return this;
1343 } 1341 }
1344 1342
1345 1343
1346 MaybeObject* JSObject::EnsureCanContainElements(Object** objects, 1344 MaybeObject* JSObject::EnsureCanContainElements(Object** objects,
1347 uint32_t count) { 1345 uint32_t count) {
1348 if (FLAG_smi_only_arrays && 1346 if (map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) {
1349 map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS) {
1350 for (uint32_t i = 0; i < count; ++i) { 1347 for (uint32_t i = 0; i < count; ++i) {
1351 Object* current = *objects++; 1348 Object* current = *objects++;
1352 if (!current->IsSmi() && current != GetHeap()->the_hole_value()) { 1349 if (!current->IsSmi() && current != GetHeap()->the_hole_value()) {
1353 return EnsureCanContainNonSmiElements(); 1350 return EnsureCanContainNonSmiElements();
1354 } 1351 }
1355 } 1352 }
1356 } 1353 }
1357 return this; 1354 return this;
1358 } 1355 }
1359 1356
1360 1357
1361 MaybeObject* JSObject::EnsureCanContainElements(FixedArray* elements) { 1358 MaybeObject* JSObject::EnsureCanContainElements(FixedArray* elements) {
1362 if (FLAG_smi_only_arrays) { 1359 Object** objects = reinterpret_cast<Object**>(
1363 Object** objects = reinterpret_cast<Object**>( 1360 FIELD_ADDR(elements, elements->OffsetOfElementAt(0)));
1364 FIELD_ADDR(elements, elements->OffsetOfElementAt(0))); 1361 return EnsureCanContainElements(objects, elements->length());
1365 return EnsureCanContainElements(objects, elements->length());
1366 } else {
1367 return this;
1368 }
1369 } 1362 }
1370 1363
1371 1364
1372 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) { 1365 void JSObject::set_elements(FixedArrayBase* value, WriteBarrierMode mode) {
1373 ASSERT((map()->has_fast_elements() || 1366 ASSERT((map()->has_fast_elements() ||
1374 map()->has_fast_smi_only_elements()) == 1367 map()->has_fast_smi_only_elements()) ==
1375 (value->map() == GetHeap()->fixed_array_map() || 1368 (value->map() == GetHeap()->fixed_array_map() ||
1376 value->map() == GetHeap()->fixed_cow_array_map())); 1369 value->map() == GetHeap()->fixed_cow_array_map()));
1377 ASSERT(map()->has_fast_double_elements() == 1370 ASSERT(map()->has_fast_double_elements() ==
1378 value->IsFixedDoubleArray()); 1371 value->IsFixedDoubleArray());
(...skipping 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 #undef WRITE_INT_FIELD 4634 #undef WRITE_INT_FIELD
4642 #undef READ_SHORT_FIELD 4635 #undef READ_SHORT_FIELD
4643 #undef WRITE_SHORT_FIELD 4636 #undef WRITE_SHORT_FIELD
4644 #undef READ_BYTE_FIELD 4637 #undef READ_BYTE_FIELD
4645 #undef WRITE_BYTE_FIELD 4638 #undef WRITE_BYTE_FIELD
4646 4639
4647 4640
4648 } } // namespace v8::internal 4641 } } // namespace v8::internal
4649 4642
4650 #endif // V8_OBJECTS_INL_H_ 4643 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698