Chromium Code Reviews| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 String::cast(this)->IsAsciiRepresentation(); | 210 String::cast(this)->IsAsciiRepresentation(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 bool Object::IsExternalTwoByteString() { | 214 bool Object::IsExternalTwoByteString() { |
| 215 if (!IsString()) return false; | 215 if (!IsString()) return false; |
| 216 return StringShape(String::cast(this)).IsExternal() && | 216 return StringShape(String::cast(this)).IsExternal() && |
| 217 String::cast(this)->IsTwoByteRepresentation(); | 217 String::cast(this)->IsTwoByteRepresentation(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool Object::HasValidElements() { | |
| 221 // Dictionary is covered under FixedArray. | |
| 222 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray(); | |
| 223 } | |
| 220 | 224 |
| 221 StringShape::StringShape(String* str) | 225 StringShape::StringShape(String* str) |
| 222 : type_(str->map()->instance_type()) { | 226 : type_(str->map()->instance_type()) { |
| 223 set_valid(); | 227 set_valid(); |
| 224 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 228 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 225 } | 229 } |
| 226 | 230 |
| 227 | 231 |
| 228 StringShape::StringShape(Map* map) | 232 StringShape::StringShape(Map* map) |
| 229 : type_(map->instance_type()) { | 233 : type_(map->instance_type()) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; | 486 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; |
| 483 } | 487 } |
| 484 | 488 |
| 485 | 489 |
| 486 bool Object::IsFixedArray() { | 490 bool Object::IsFixedArray() { |
| 487 return Object::IsHeapObject() | 491 return Object::IsHeapObject() |
| 488 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; | 492 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; |
| 489 } | 493 } |
| 490 | 494 |
| 491 | 495 |
| 496 bool Object::IsFixedDoubleArray() { | |
| 497 return Object::IsHeapObject() | |
| 498 && HeapObject::cast(this)->map()->instance_type() == | |
| 499 FIXED_DOUBLE_ARRAY_TYPE; | |
| 500 } | |
| 501 | |
| 502 | |
| 492 bool Object::IsDescriptorArray() { | 503 bool Object::IsDescriptorArray() { |
| 493 return IsFixedArray(); | 504 return IsFixedArray(); |
| 494 } | 505 } |
| 495 | 506 |
| 496 | 507 |
| 497 bool Object::IsDeoptimizationInputData() { | 508 bool Object::IsDeoptimizationInputData() { |
| 498 // Must be a fixed array. | 509 // Must be a fixed array. |
| 499 if (!IsFixedArray()) return false; | 510 if (!IsFixedArray()) return false; |
| 500 | 511 |
| 501 // There's no sure way to detect the difference between a fixed array and | 512 // There's no sure way to detect the difference between a fixed array and |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1311 int HeapNumber::get_sign() { | 1322 int HeapNumber::get_sign() { |
| 1312 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; | 1323 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; |
| 1313 } | 1324 } |
| 1314 | 1325 |
| 1315 | 1326 |
| 1316 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) | 1327 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) |
| 1317 | 1328 |
| 1318 | 1329 |
| 1319 HeapObject* JSObject::elements() { | 1330 HeapObject* JSObject::elements() { |
| 1320 Object* array = READ_FIELD(this, kElementsOffset); | 1331 Object* array = READ_FIELD(this, kElementsOffset); |
| 1321 // In the assert below Dictionary is covered under FixedArray. | 1332 ASSERT(array->HasValidElements()); |
| 1322 ASSERT(array->IsFixedArray() || array->IsExternalArray()); | |
| 1323 return reinterpret_cast<HeapObject*>(array); | 1333 return reinterpret_cast<HeapObject*>(array); |
| 1324 } | 1334 } |
| 1325 | 1335 |
| 1326 | 1336 |
| 1327 void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) { | 1337 void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) { |
| 1328 ASSERT(map()->has_fast_elements() == | 1338 ASSERT(map()->has_fast_elements() == |
| 1329 (value->map() == GetHeap()->fixed_array_map() || | 1339 (value->map() == GetHeap()->fixed_array_map() || |
| 1330 value->map() == GetHeap()->fixed_cow_array_map())); | 1340 value->map() == GetHeap()->fixed_cow_array_map())); |
| 1331 // In the assert below Dictionary is covered under FixedArray. | 1341 ASSERT(value->HasValidElements()); |
| 1332 ASSERT(value->IsFixedArray() || value->IsExternalArray()); | |
| 1333 WRITE_FIELD(this, kElementsOffset, value); | 1342 WRITE_FIELD(this, kElementsOffset, value); |
| 1334 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, mode); | 1343 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, mode); |
| 1335 } | 1344 } |
| 1336 | 1345 |
| 1337 | 1346 |
| 1338 void JSObject::initialize_properties() { | 1347 void JSObject::initialize_properties() { |
| 1339 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); | 1348 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); |
| 1340 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); | 1349 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); |
| 1341 } | 1350 } |
| 1342 | 1351 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1570 JSValue* js_value = JSValue::cast(this); | 1579 JSValue* js_value = JSValue::cast(this); |
| 1571 if (!js_value->value()->IsString()) return false; | 1580 if (!js_value->value()->IsString()) return false; |
| 1572 | 1581 |
| 1573 String* str = String::cast(js_value->value()); | 1582 String* str = String::cast(js_value->value()); |
| 1574 if (index >= (uint32_t)str->length()) return false; | 1583 if (index >= (uint32_t)str->length()) return false; |
| 1575 | 1584 |
| 1576 return true; | 1585 return true; |
| 1577 } | 1586 } |
| 1578 | 1587 |
| 1579 | 1588 |
| 1589 FixedArrayBase* FixedArrayBase::cast(Object* object) { | |
| 1590 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray()); | |
| 1591 return reinterpret_cast<FixedArrayBase*>(object); | |
| 1592 } | |
| 1593 | |
| 1594 | |
| 1580 Object* FixedArray::get(int index) { | 1595 Object* FixedArray::get(int index) { |
| 1581 ASSERT(index >= 0 && index < this->length()); | 1596 ASSERT(index >= 0 && index < this->length()); |
| 1582 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 1597 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
| 1583 } | 1598 } |
| 1584 | 1599 |
| 1585 | 1600 |
| 1586 void FixedArray::set(int index, Smi* value) { | 1601 void FixedArray::set(int index, Smi* value) { |
| 1587 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1602 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| 1588 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); | 1603 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); |
| 1589 int offset = kHeaderSize + index * kPointerSize; | 1604 int offset = kHeaderSize + index * kPointerSize; |
| 1590 WRITE_FIELD(this, offset, value); | 1605 WRITE_FIELD(this, offset, value); |
| 1591 } | 1606 } |
| 1592 | 1607 |
| 1593 | 1608 |
| 1594 void FixedArray::set(int index, Object* value) { | 1609 void FixedArray::set(int index, Object* value) { |
| 1595 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1610 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| 1596 ASSERT(index >= 0 && index < this->length()); | 1611 ASSERT(index >= 0 && index < this->length()); |
| 1597 int offset = kHeaderSize + index * kPointerSize; | 1612 int offset = kHeaderSize + index * kPointerSize; |
| 1598 WRITE_FIELD(this, offset, value); | 1613 WRITE_FIELD(this, offset, value); |
| 1599 WRITE_BARRIER(this, offset); | 1614 WRITE_BARRIER(this, offset); |
| 1600 } | 1615 } |
| 1601 | 1616 |
| 1602 | 1617 |
| 1618 double FixedDoubleArray::get(int index) { | |
| 1619 ASSERT(index >= 0 && index < this->length()); | |
| 1620 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize); | |
| 1621 ASSERT(!is_the_hole_nan(result)); | |
| 1622 return result; | |
| 1623 } | |
| 1624 | |
| 1625 | |
| 1626 void FixedDoubleArray::set(int index, double value) { | |
| 1627 ASSERT(map() != HEAP->fixed_cow_array_map()); | |
|
Mads Ager (chromium)
2011/06/08 13:13:13
If you assert for fixed_cow_array_map should you a
danno
2011/06/09 09:45:40
Done.
| |
| 1628 int offset = kHeaderSize + index * kDoubleSize; | |
| 1629 if (isnan(value)) value = canonical_not_the_hole_nan_as_double(); | |
| 1630 WRITE_DOUBLE_FIELD(this, offset, value); | |
| 1631 } | |
| 1632 | |
| 1633 | |
| 1634 void FixedDoubleArray::set_the_hole(int index) { | |
| 1635 ASSERT(map() != HEAP->fixed_cow_array_map()); | |
|
Mads Ager (chromium)
2011/06/08 13:13:13
Ditto?
danno
2011/06/09 09:45:40
Done.
| |
| 1636 int offset = kHeaderSize + index * kDoubleSize; | |
| 1637 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
| 1638 } | |
| 1639 | |
| 1640 | |
| 1641 bool FixedDoubleArray::is_the_hole(int index) { | |
| 1642 int offset = kHeaderSize + index * kDoubleSize; | |
| 1643 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset)); | |
| 1644 } | |
| 1645 | |
| 1646 | |
| 1647 void FixedDoubleArray::Initialize(FixedDoubleArray* from) { | |
| 1648 int old_length = from->length(); | |
| 1649 ASSERT(old_length < length()); | |
| 1650 OS::MemCopy(FIELD_ADDR(this, kHeaderSize), | |
| 1651 FIELD_ADDR(from, kHeaderSize), | |
| 1652 old_length * kDoubleSize); | |
| 1653 int offset = kHeaderSize + old_length * kDoubleSize; | |
| 1654 for (int current = from->length(); current < length(); ++current) { | |
| 1655 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
| 1656 offset += kDoubleSize; | |
| 1657 } | |
| 1658 } | |
| 1659 | |
| 1660 | |
| 1661 void FixedDoubleArray::Initialize(FixedArray* from) { | |
| 1662 int old_length = from->length(); | |
| 1663 ASSERT(old_length < length()); | |
| 1664 for (int i = 0; i < old_length; i++) { | |
| 1665 Object* hole_or_object = from->get(i); | |
| 1666 if (hole_or_object->IsTheHole()) { | |
| 1667 set_the_hole(i); | |
| 1668 } else { | |
| 1669 set(i, hole_or_object->Number()); | |
| 1670 } | |
| 1671 } | |
| 1672 int offset = kHeaderSize + old_length * kDoubleSize; | |
| 1673 for (int current = from->length(); current < length(); ++current) { | |
| 1674 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
| 1675 offset += kDoubleSize; | |
| 1676 } | |
| 1677 } | |
| 1678 | |
| 1679 | |
| 1680 void FixedDoubleArray::Initialize(NumberDictionary* from) { | |
| 1681 int offset = kHeaderSize; | |
| 1682 for (int current = 0; current < length(); ++current) { | |
| 1683 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | |
| 1684 offset += kDoubleSize; | |
| 1685 } | |
| 1686 for (int i = 0; i < from->Capacity(); i++) { | |
| 1687 Object* key = from->KeyAt(i); | |
| 1688 if (key->IsNumber()) { | |
| 1689 uint32_t entry = static_cast<uint32_t>(key->Number()); | |
| 1690 set(entry, from->ValueAt(i)->Number()); | |
| 1691 } | |
| 1692 } | |
| 1693 } | |
| 1694 | |
| 1695 | |
| 1603 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { | 1696 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { |
| 1604 if (GetHeap()->InNewSpace(this)) return SKIP_WRITE_BARRIER; | 1697 if (GetHeap()->InNewSpace(this)) return SKIP_WRITE_BARRIER; |
| 1605 return UPDATE_WRITE_BARRIER; | 1698 return UPDATE_WRITE_BARRIER; |
| 1606 } | 1699 } |
| 1607 | 1700 |
| 1608 | 1701 |
| 1609 void FixedArray::set(int index, | 1702 void FixedArray::set(int index, |
| 1610 Object* value, | 1703 Object* value, |
| 1611 WriteBarrierMode mode) { | 1704 WriteBarrierMode mode) { |
| 1612 ASSERT(map() != HEAP->fixed_cow_array_map()); | 1705 ASSERT(map() != HEAP->fixed_cow_array_map()); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1893 void NumberDictionary::set_requires_slow_elements() { | 1986 void NumberDictionary::set_requires_slow_elements() { |
| 1894 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 1987 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 1895 } | 1988 } |
| 1896 | 1989 |
| 1897 | 1990 |
| 1898 // ------------------------------------ | 1991 // ------------------------------------ |
| 1899 // Cast operations | 1992 // Cast operations |
| 1900 | 1993 |
| 1901 | 1994 |
| 1902 CAST_ACCESSOR(FixedArray) | 1995 CAST_ACCESSOR(FixedArray) |
| 1996 CAST_ACCESSOR(FixedDoubleArray) | |
| 1903 CAST_ACCESSOR(DescriptorArray) | 1997 CAST_ACCESSOR(DescriptorArray) |
| 1904 CAST_ACCESSOR(DeoptimizationInputData) | 1998 CAST_ACCESSOR(DeoptimizationInputData) |
| 1905 CAST_ACCESSOR(DeoptimizationOutputData) | 1999 CAST_ACCESSOR(DeoptimizationOutputData) |
| 1906 CAST_ACCESSOR(SymbolTable) | 2000 CAST_ACCESSOR(SymbolTable) |
| 1907 CAST_ACCESSOR(JSFunctionResultCache) | 2001 CAST_ACCESSOR(JSFunctionResultCache) |
| 1908 CAST_ACCESSOR(NormalizedMapCache) | 2002 CAST_ACCESSOR(NormalizedMapCache) |
| 1909 CAST_ACCESSOR(CompilationCacheTable) | 2003 CAST_ACCESSOR(CompilationCacheTable) |
| 1910 CAST_ACCESSOR(CodeCacheHashTable) | 2004 CAST_ACCESSOR(CodeCacheHashTable) |
| 1911 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) | 2005 CAST_ACCESSOR(PolymorphicCodeCacheHashTable) |
| 1912 CAST_ACCESSOR(MapCache) | 2006 CAST_ACCESSOR(MapCache) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1957 #undef MAKE_STRUCT_CAST | 2051 #undef MAKE_STRUCT_CAST |
| 1958 | 2052 |
| 1959 | 2053 |
| 1960 template <typename Shape, typename Key> | 2054 template <typename Shape, typename Key> |
| 1961 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { | 2055 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { |
| 1962 ASSERT(obj->IsHashTable()); | 2056 ASSERT(obj->IsHashTable()); |
| 1963 return reinterpret_cast<HashTable*>(obj); | 2057 return reinterpret_cast<HashTable*>(obj); |
| 1964 } | 2058 } |
| 1965 | 2059 |
| 1966 | 2060 |
| 1967 SMI_ACCESSORS(FixedArray, length, kLengthOffset) | 2061 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) |
| 1968 SMI_ACCESSORS(ByteArray, length, kLengthOffset) | 2062 SMI_ACCESSORS(ByteArray, length, kLengthOffset) |
| 1969 | 2063 |
| 1970 INT_ACCESSORS(ExternalArray, length, kLengthOffset) | 2064 INT_ACCESSORS(ExternalArray, length, kLengthOffset) |
| 1971 | 2065 |
| 1972 | 2066 |
| 1973 SMI_ACCESSORS(String, length, kLengthOffset) | 2067 SMI_ACCESSORS(String, length, kLengthOffset) |
| 1974 | 2068 |
| 1975 | 2069 |
| 1976 uint32_t String::hash_field() { | 2070 uint32_t String::hash_field() { |
| 1977 return READ_UINT32_FIELD(this, kHashFieldOffset); | 2071 return READ_UINT32_FIELD(this, kHashFieldOffset); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2416 return SeqAsciiString::SizeFor( | 2510 return SeqAsciiString::SizeFor( |
| 2417 reinterpret_cast<SeqAsciiString*>(this)->length()); | 2511 reinterpret_cast<SeqAsciiString*>(this)->length()); |
| 2418 } | 2512 } |
| 2419 if (instance_type == BYTE_ARRAY_TYPE) { | 2513 if (instance_type == BYTE_ARRAY_TYPE) { |
| 2420 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 2514 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
| 2421 } | 2515 } |
| 2422 if (instance_type == STRING_TYPE) { | 2516 if (instance_type == STRING_TYPE) { |
| 2423 return SeqTwoByteString::SizeFor( | 2517 return SeqTwoByteString::SizeFor( |
| 2424 reinterpret_cast<SeqTwoByteString*>(this)->length()); | 2518 reinterpret_cast<SeqTwoByteString*>(this)->length()); |
| 2425 } | 2519 } |
| 2520 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) { | |
| 2521 return FixedDoubleArray::SizeFor( | |
| 2522 reinterpret_cast<FixedDoubleArray*>(this)->length()); | |
| 2523 } | |
| 2426 ASSERT(instance_type == CODE_TYPE); | 2524 ASSERT(instance_type == CODE_TYPE); |
| 2427 return reinterpret_cast<Code*>(this)->CodeSize(); | 2525 return reinterpret_cast<Code*>(this)->CodeSize(); |
| 2428 } | 2526 } |
| 2429 | 2527 |
| 2430 | 2528 |
| 2431 void Map::set_instance_size(int value) { | 2529 void Map::set_instance_size(int value) { |
| 2432 ASSERT_EQ(0, value & (kPointerSize - 1)); | 2530 ASSERT_EQ(0, value & (kPointerSize - 1)); |
| 2433 value >>= kPointerSizeLog2; | 2531 value >>= kPointerSizeLog2; |
| 2434 ASSERT(0 <= value && value < 256); | 2532 ASSERT(0 <= value && value < 256); |
| 2435 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); | 2533 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2974 | 3072 |
| 2975 | 3073 |
| 2976 MaybeObject* Map::GetFastElementsMap() { | 3074 MaybeObject* Map::GetFastElementsMap() { |
| 2977 if (has_fast_elements()) return this; | 3075 if (has_fast_elements()) return this; |
| 2978 Object* obj; | 3076 Object* obj; |
| 2979 { MaybeObject* maybe_obj = CopyDropTransitions(); | 3077 { MaybeObject* maybe_obj = CopyDropTransitions(); |
| 2980 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3078 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2981 } | 3079 } |
| 2982 Map* new_map = Map::cast(obj); | 3080 Map* new_map = Map::cast(obj); |
| 2983 new_map->set_elements_kind(JSObject::FAST_ELEMENTS); | 3081 new_map->set_elements_kind(JSObject::FAST_ELEMENTS); |
| 2984 isolate()->counters()->map_slow_to_fast_elements()->Increment(); | 3082 isolate()->counters()->map_to_fast_elements()->Increment(); |
| 3083 return new_map; | |
| 3084 } | |
| 3085 | |
| 3086 | |
| 3087 MaybeObject* Map::GetFastDoubleElementsMap() { | |
| 3088 if (has_fast_double_elements()) return this; | |
| 3089 Object* obj; | |
| 3090 { MaybeObject* maybe_obj = CopyDropTransitions(); | |
| 3091 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | |
| 3092 } | |
| 3093 Map* new_map = Map::cast(obj); | |
| 3094 new_map->set_elements_kind(JSObject::FAST_DOUBLE_ELEMENTS); | |
| 3095 isolate()->counters()->map_to_fast_double_elements()->Increment(); | |
| 2985 return new_map; | 3096 return new_map; |
| 2986 } | 3097 } |
| 2987 | 3098 |
| 2988 | 3099 |
| 2989 MaybeObject* Map::GetSlowElementsMap() { | 3100 MaybeObject* Map::GetSlowElementsMap() { |
| 2990 if (!has_fast_elements()) return this; | 3101 if (!has_fast_elements() && !has_fast_double_elements()) return this; |
| 2991 Object* obj; | 3102 Object* obj; |
| 2992 { MaybeObject* maybe_obj = CopyDropTransitions(); | 3103 { MaybeObject* maybe_obj = CopyDropTransitions(); |
| 2993 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 3104 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
| 2994 } | 3105 } |
| 2995 Map* new_map = Map::cast(obj); | 3106 Map* new_map = Map::cast(obj); |
| 2996 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS); | 3107 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS); |
| 2997 isolate()->counters()->map_fast_to_slow_elements()->Increment(); | 3108 isolate()->counters()->map_to_slow_elements()->Increment(); |
| 2998 return new_map; | 3109 return new_map; |
| 2999 } | 3110 } |
| 3000 | 3111 |
| 3001 | 3112 |
| 3002 DescriptorArray* Map::instance_descriptors() { | 3113 DescriptorArray* Map::instance_descriptors() { |
| 3003 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); | 3114 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); |
| 3004 if (object->IsSmi()) { | 3115 if (object->IsSmi()) { |
| 3005 return HEAP->empty_descriptor_array(); | 3116 return HEAP->empty_descriptor_array(); |
| 3006 } else { | 3117 } else { |
| 3007 return DescriptorArray::cast(object); | 3118 return DescriptorArray::cast(object); |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3781 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. | 3892 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. |
| 3782 FixedArray::cast(data())->set(index, value); | 3893 FixedArray::cast(data())->set(index, value); |
| 3783 } | 3894 } |
| 3784 | 3895 |
| 3785 | 3896 |
| 3786 JSObject::ElementsKind JSObject::GetElementsKind() { | 3897 JSObject::ElementsKind JSObject::GetElementsKind() { |
| 3787 ElementsKind kind = map()->elements_kind(); | 3898 ElementsKind kind = map()->elements_kind(); |
| 3788 ASSERT((kind == FAST_ELEMENTS && | 3899 ASSERT((kind == FAST_ELEMENTS && |
| 3789 (elements()->map() == GetHeap()->fixed_array_map() || | 3900 (elements()->map() == GetHeap()->fixed_array_map() || |
| 3790 elements()->map() == GetHeap()->fixed_cow_array_map())) || | 3901 elements()->map() == GetHeap()->fixed_cow_array_map())) || |
| 3902 (kind == FAST_DOUBLE_ELEMENTS && | |
| 3903 elements()->IsFixedDoubleArray()) || | |
| 3791 (kind == DICTIONARY_ELEMENTS && | 3904 (kind == DICTIONARY_ELEMENTS && |
| 3792 elements()->IsFixedArray() && | 3905 elements()->IsFixedArray() && |
| 3793 elements()->IsDictionary()) || | 3906 elements()->IsDictionary()) || |
| 3794 (kind > DICTIONARY_ELEMENTS)); | 3907 (kind > DICTIONARY_ELEMENTS)); |
| 3795 return kind; | 3908 return kind; |
| 3796 } | 3909 } |
| 3797 | 3910 |
| 3798 | 3911 |
| 3799 bool JSObject::HasFastElements() { | 3912 bool JSObject::HasFastElements() { |
| 3800 return GetElementsKind() == FAST_ELEMENTS; | 3913 return GetElementsKind() == FAST_ELEMENTS; |
| 3801 } | 3914 } |
| 3802 | 3915 |
| 3803 | 3916 |
| 3917 bool JSObject::HasFastDoubleElements() { | |
| 3918 return GetElementsKind() == FAST_DOUBLE_ELEMENTS; | |
| 3919 } | |
| 3920 | |
| 3921 | |
| 3804 bool JSObject::HasDictionaryElements() { | 3922 bool JSObject::HasDictionaryElements() { |
| 3805 return GetElementsKind() == DICTIONARY_ELEMENTS; | 3923 return GetElementsKind() == DICTIONARY_ELEMENTS; |
| 3806 } | 3924 } |
| 3807 | 3925 |
| 3808 | 3926 |
| 3809 bool JSObject::HasExternalArrayElements() { | 3927 bool JSObject::HasExternalArrayElements() { |
| 3810 HeapObject* array = elements(); | 3928 HeapObject* array = elements(); |
| 3811 ASSERT(array != NULL); | 3929 ASSERT(array != NULL); |
| 3812 return array->IsExternalArray(); | 3930 return array->IsExternalArray(); |
| 3813 } | 3931 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4306 #undef WRITE_INT_FIELD | 4424 #undef WRITE_INT_FIELD |
| 4307 #undef READ_SHORT_FIELD | 4425 #undef READ_SHORT_FIELD |
| 4308 #undef WRITE_SHORT_FIELD | 4426 #undef WRITE_SHORT_FIELD |
| 4309 #undef READ_BYTE_FIELD | 4427 #undef READ_BYTE_FIELD |
| 4310 #undef WRITE_BYTE_FIELD | 4428 #undef WRITE_BYTE_FIELD |
| 4311 | 4429 |
| 4312 | 4430 |
| 4313 } } // namespace v8::internal | 4431 } } // namespace v8::internal |
| 4314 | 4432 |
| 4315 #endif // V8_OBJECTS_INL_H_ | 4433 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |