OLD | NEW |
---|---|
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 Loading... | |
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1655 } | 1648 } |
1656 | 1649 |
1657 | 1650 |
1658 Object* FixedArray::get(int index) { | 1651 Object* FixedArray::get(int index) { |
1659 ASSERT(index >= 0 && index < this->length()); | 1652 ASSERT(index >= 0 && index < this->length()); |
1660 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 1653 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
1661 } | 1654 } |
1662 | 1655 |
1663 | 1656 |
1664 void FixedArray::set(int index, Smi* value) { | 1657 void FixedArray::set(int index, Smi* value) { |
1658 static int foo = 0; | |
Jakob Kummerow
2011/10/07 17:58:13
debugging leftover?
danno
2011/10/10 11:26:33
Done.
| |
1659 ++foo; | |
1665 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1660 ASSERT(map() != HEAP->fixed_cow_array_map()); |
1666 ASSERT(index >= 0 && index < this->length()); | 1661 ASSERT(index >= 0 && index < this->length()); |
1667 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); | 1662 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); |
1668 int offset = kHeaderSize + index * kPointerSize; | 1663 int offset = kHeaderSize + index * kPointerSize; |
1669 WRITE_FIELD(this, offset, value); | 1664 WRITE_FIELD(this, offset, value); |
1670 } | 1665 } |
1671 | 1666 |
1672 | 1667 |
1673 void FixedArray::set(int index, Object* value) { | 1668 void FixedArray::set(int index, Object* value) { |
1674 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1669 ASSERT(map() != HEAP->fixed_cow_array_map()); |
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4641 #undef WRITE_INT_FIELD | 4636 #undef WRITE_INT_FIELD |
4642 #undef READ_SHORT_FIELD | 4637 #undef READ_SHORT_FIELD |
4643 #undef WRITE_SHORT_FIELD | 4638 #undef WRITE_SHORT_FIELD |
4644 #undef READ_BYTE_FIELD | 4639 #undef READ_BYTE_FIELD |
4645 #undef WRITE_BYTE_FIELD | 4640 #undef WRITE_BYTE_FIELD |
4646 | 4641 |
4647 | 4642 |
4648 } } // namespace v8::internal | 4643 } } // namespace v8::internal |
4649 | 4644 |
4650 #endif // V8_OBJECTS_INL_H_ | 4645 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |