| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 | 1363 |
| 1364 | 1364 |
| 1365 void DescriptorArray::Swap(int first, int second) { | 1365 void DescriptorArray::Swap(int first, int second) { |
| 1366 fast_swap(this, ToKeyIndex(first), ToKeyIndex(second)); | 1366 fast_swap(this, ToKeyIndex(first), ToKeyIndex(second)); |
| 1367 FixedArray* content_array = GetContentArray(); | 1367 FixedArray* content_array = GetContentArray(); |
| 1368 fast_swap(content_array, ToValueIndex(first), ToValueIndex(second)); | 1368 fast_swap(content_array, ToValueIndex(first), ToValueIndex(second)); |
| 1369 fast_swap(content_array, ToDetailsIndex(first), ToDetailsIndex(second)); | 1369 fast_swap(content_array, ToDetailsIndex(first), ToDetailsIndex(second)); |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 | 1372 |
| 1373 bool Dictionary::requires_slow_elements() { | 1373 bool NumberDictionary::requires_slow_elements() { |
| 1374 Object* max_index_object = get(kMaxNumberKeyIndex); | 1374 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 1375 if (!max_index_object->IsSmi()) return false; | 1375 if (!max_index_object->IsSmi()) return false; |
| 1376 return 0 != | 1376 return 0 != |
| 1377 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); | 1377 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 | 1380 uint32_t NumberDictionary::max_number_key() { |
| 1381 uint32_t Dictionary::max_number_key() { | |
| 1382 ASSERT(!requires_slow_elements()); | 1381 ASSERT(!requires_slow_elements()); |
| 1383 Object* max_index_object = get(kMaxNumberKeyIndex); | 1382 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 1384 if (!max_index_object->IsSmi()) return 0; | 1383 if (!max_index_object->IsSmi()) return 0; |
| 1385 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); | 1384 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); |
| 1386 return value >> kRequiresSlowElementsTagSize; | 1385 return value >> kRequiresSlowElementsTagSize; |
| 1387 } | 1386 } |
| 1388 | 1387 |
| 1389 | 1388 void NumberDictionary::set_requires_slow_elements() { |
| 1390 void Dictionary::set_requires_slow_elements() { | |
| 1391 set(kMaxNumberKeyIndex, | 1389 set(kMaxNumberKeyIndex, |
| 1392 Smi::FromInt(kRequiresSlowElementsMask), | 1390 Smi::FromInt(kRequiresSlowElementsMask), |
| 1393 SKIP_WRITE_BARRIER); | 1391 SKIP_WRITE_BARRIER); |
| 1394 } | 1392 } |
| 1395 | 1393 |
| 1396 | 1394 |
| 1397 // ------------------------------------ | 1395 // ------------------------------------ |
| 1398 // Cast operations | 1396 // Cast operations |
| 1399 | 1397 |
| 1400 | 1398 |
| 1401 CAST_ACCESSOR(FixedArray) | 1399 CAST_ACCESSOR(FixedArray) |
| 1402 CAST_ACCESSOR(DescriptorArray) | 1400 CAST_ACCESSOR(DescriptorArray) |
| 1403 CAST_ACCESSOR(Dictionary) | |
| 1404 CAST_ACCESSOR(SymbolTable) | 1401 CAST_ACCESSOR(SymbolTable) |
| 1405 CAST_ACCESSOR(CompilationCacheTable) | 1402 CAST_ACCESSOR(CompilationCacheTable) |
| 1406 CAST_ACCESSOR(MapCache) | 1403 CAST_ACCESSOR(MapCache) |
| 1407 CAST_ACCESSOR(String) | 1404 CAST_ACCESSOR(String) |
| 1408 CAST_ACCESSOR(SeqString) | 1405 CAST_ACCESSOR(SeqString) |
| 1409 CAST_ACCESSOR(SeqAsciiString) | 1406 CAST_ACCESSOR(SeqAsciiString) |
| 1410 CAST_ACCESSOR(SeqTwoByteString) | 1407 CAST_ACCESSOR(SeqTwoByteString) |
| 1411 CAST_ACCESSOR(ConsString) | 1408 CAST_ACCESSOR(ConsString) |
| 1412 CAST_ACCESSOR(SlicedString) | 1409 CAST_ACCESSOR(SlicedString) |
| 1413 CAST_ACCESSOR(ExternalString) | 1410 CAST_ACCESSOR(ExternalString) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1432 CAST_ACCESSOR(JSRegExp) | 1429 CAST_ACCESSOR(JSRegExp) |
| 1433 CAST_ACCESSOR(Proxy) | 1430 CAST_ACCESSOR(Proxy) |
| 1434 CAST_ACCESSOR(ByteArray) | 1431 CAST_ACCESSOR(ByteArray) |
| 1435 CAST_ACCESSOR(Struct) | 1432 CAST_ACCESSOR(Struct) |
| 1436 | 1433 |
| 1437 | 1434 |
| 1438 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 1435 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
| 1439 STRUCT_LIST(MAKE_STRUCT_CAST) | 1436 STRUCT_LIST(MAKE_STRUCT_CAST) |
| 1440 #undef MAKE_STRUCT_CAST | 1437 #undef MAKE_STRUCT_CAST |
| 1441 | 1438 |
| 1442 template <int prefix_size, int elem_size> | 1439 |
| 1443 HashTable<prefix_size, elem_size>* HashTable<prefix_size, elem_size>::cast( | 1440 template <typename Shape, typename Key> |
| 1444 Object* obj) { | 1441 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { |
| 1445 ASSERT(obj->IsHashTable()); | 1442 ASSERT(obj->IsHashTable()); |
| 1446 return reinterpret_cast<HashTable*>(obj); | 1443 return reinterpret_cast<HashTable*>(obj); |
| 1447 } | 1444 } |
| 1448 | 1445 |
| 1449 | 1446 |
| 1450 INT_ACCESSORS(Array, length, kLengthOffset) | 1447 INT_ACCESSORS(Array, length, kLengthOffset) |
| 1451 | 1448 |
| 1452 | 1449 |
| 1453 bool String::Equals(String* other) { | 1450 bool String::Equals(String* other) { |
| 1454 if (other == this) return true; | 1451 if (other == this) return true; |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2461 bool JSObject::HasNamedInterceptor() { | 2458 bool JSObject::HasNamedInterceptor() { |
| 2462 return map()->has_named_interceptor(); | 2459 return map()->has_named_interceptor(); |
| 2463 } | 2460 } |
| 2464 | 2461 |
| 2465 | 2462 |
| 2466 bool JSObject::HasIndexedInterceptor() { | 2463 bool JSObject::HasIndexedInterceptor() { |
| 2467 return map()->has_indexed_interceptor(); | 2464 return map()->has_indexed_interceptor(); |
| 2468 } | 2465 } |
| 2469 | 2466 |
| 2470 | 2467 |
| 2471 Dictionary* JSObject::property_dictionary() { | 2468 StringDictionary* JSObject::property_dictionary() { |
| 2472 ASSERT(!HasFastProperties()); | 2469 ASSERT(!HasFastProperties()); |
| 2473 return Dictionary::cast(properties()); | 2470 return StringDictionary::cast(properties()); |
| 2474 } | 2471 } |
| 2475 | 2472 |
| 2476 | 2473 |
| 2477 Dictionary* JSObject::element_dictionary() { | 2474 NumberDictionary* JSObject::element_dictionary() { |
| 2478 ASSERT(!HasFastElements()); | 2475 ASSERT(!HasFastElements()); |
| 2479 return Dictionary::cast(elements()); | 2476 return NumberDictionary::cast(elements()); |
| 2480 } | 2477 } |
| 2481 | 2478 |
| 2482 | 2479 |
| 2483 bool String::HasHashCode() { | 2480 bool String::HasHashCode() { |
| 2484 return (length_field() & kHashComputedMask) != 0; | 2481 return (length_field() & kHashComputedMask) != 0; |
| 2485 } | 2482 } |
| 2486 | 2483 |
| 2487 | 2484 |
| 2488 uint32_t String::Hash() { | 2485 uint32_t String::Hash() { |
| 2489 // Fast case: has hash code already been computed? | 2486 // Fast case: has hash code already been computed? |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2633 return AttributesField::decode(static_cast<uint32_t>(flag()->value())); | 2630 return AttributesField::decode(static_cast<uint32_t>(flag()->value())); |
| 2634 } | 2631 } |
| 2635 | 2632 |
| 2636 | 2633 |
| 2637 void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { | 2634 void AccessorInfo::set_property_attributes(PropertyAttributes attributes) { |
| 2638 ASSERT(AttributesField::is_valid(attributes)); | 2635 ASSERT(AttributesField::is_valid(attributes)); |
| 2639 int rest_value = flag()->value() & ~AttributesField::mask(); | 2636 int rest_value = flag()->value() & ~AttributesField::mask(); |
| 2640 set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); | 2637 set_flag(Smi::FromInt(rest_value | AttributesField::encode(attributes))); |
| 2641 } | 2638 } |
| 2642 | 2639 |
| 2643 void Dictionary::SetEntry(int entry, | 2640 template<typename Shape, typename Key> |
| 2644 Object* key, | 2641 void Dictionary<Shape, Key>::SetEntry(int entry, |
| 2645 Object* value, | 2642 Object* key, |
| 2646 PropertyDetails details) { | 2643 Object* value, |
| 2644 PropertyDetails details) { |
| 2647 ASSERT(!key->IsString() || details.index() > 0); | 2645 ASSERT(!key->IsString() || details.index() > 0); |
| 2648 int index = EntryToIndex(entry); | 2646 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 2649 WriteBarrierMode mode = GetWriteBarrierMode(); | 2647 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(); |
| 2650 set(index, key, mode); | 2648 FixedArray::set(index, key, mode); |
| 2651 set(index+1, value, mode); | 2649 FixedArray::set(index+1, value, mode); |
| 2652 fast_set(this, index+2, details.AsSmi()); | 2650 FixedArray::fast_set(this, index+2, details.AsSmi()); |
| 2653 } | 2651 } |
| 2654 | 2652 |
| 2655 | 2653 |
| 2656 void Map::ClearCodeCache() { | 2654 void Map::ClearCodeCache() { |
| 2657 // No write barrier is needed since empty_fixed_array is not in new space. | 2655 // No write barrier is needed since empty_fixed_array is not in new space. |
| 2658 // Please note this function is used during marking: | 2656 // Please note this function is used during marking: |
| 2659 // - MarkCompactCollector::MarkUnmarkedObject | 2657 // - MarkCompactCollector::MarkUnmarkedObject |
| 2660 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); | 2658 ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array())); |
| 2661 WRITE_FIELD(this, kCodeCacheOffset, Heap::empty_fixed_array()); | 2659 WRITE_FIELD(this, kCodeCacheOffset, Heap::empty_fixed_array()); |
| 2662 } | 2660 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2698 #undef WRITE_INT_FIELD | 2696 #undef WRITE_INT_FIELD |
| 2699 #undef READ_SHORT_FIELD | 2697 #undef READ_SHORT_FIELD |
| 2700 #undef WRITE_SHORT_FIELD | 2698 #undef WRITE_SHORT_FIELD |
| 2701 #undef READ_BYTE_FIELD | 2699 #undef READ_BYTE_FIELD |
| 2702 #undef WRITE_BYTE_FIELD | 2700 #undef WRITE_BYTE_FIELD |
| 2703 | 2701 |
| 2704 | 2702 |
| 2705 } } // namespace v8::internal | 2703 } } // namespace v8::internal |
| 2706 | 2704 |
| 2707 #endif // V8_OBJECTS_INL_H_ | 2705 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |