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 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 } | 1718 } |
1719 } | 1719 } |
1720 int offset = kHeaderSize + old_length * kDoubleSize; | 1720 int offset = kHeaderSize + old_length * kDoubleSize; |
1721 for (int current = from->length(); current < length(); ++current) { | 1721 for (int current = from->length(); current < length(); ++current) { |
1722 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 1722 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
1723 offset += kDoubleSize; | 1723 offset += kDoubleSize; |
1724 } | 1724 } |
1725 } | 1725 } |
1726 | 1726 |
1727 | 1727 |
1728 void FixedDoubleArray::Initialize(NumberDictionary* from) { | 1728 void FixedDoubleArray::Initialize(SeededNumberDictionary* from) { |
1729 int offset = kHeaderSize; | 1729 int offset = kHeaderSize; |
1730 for (int current = 0; current < length(); ++current) { | 1730 for (int current = 0; current < length(); ++current) { |
1731 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); | 1731 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double()); |
1732 offset += kDoubleSize; | 1732 offset += kDoubleSize; |
1733 } | 1733 } |
1734 for (int i = 0; i < from->Capacity(); i++) { | 1734 for (int i = 0; i < from->Capacity(); i++) { |
1735 Object* key = from->KeyAt(i); | 1735 Object* key = from->KeyAt(i); |
1736 if (key->IsNumber()) { | 1736 if (key->IsNumber()) { |
1737 uint32_t entry = static_cast<uint32_t>(key->Number()); | 1737 uint32_t entry = static_cast<uint32_t>(key->Number()); |
1738 set(entry, from->ValueAt(i)->Number()); | 1738 set(entry, from->ValueAt(i)->Number()); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 // Empty entry. | 2065 // Empty entry. |
2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; | 2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; |
2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() && | 2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() && |
2068 Shape::IsMatch(key, element)) return entry; | 2068 Shape::IsMatch(key, element)) return entry; |
2069 entry = NextProbe(entry, count++, capacity); | 2069 entry = NextProbe(entry, count++, capacity); |
2070 } | 2070 } |
2071 return kNotFound; | 2071 return kNotFound; |
2072 } | 2072 } |
2073 | 2073 |
2074 | 2074 |
2075 bool NumberDictionary::requires_slow_elements() { | 2075 bool SeededNumberDictionary::requires_slow_elements() { |
2076 Object* max_index_object = get(kMaxNumberKeyIndex); | 2076 Object* max_index_object = get(kMaxNumberKeyIndex); |
2077 if (!max_index_object->IsSmi()) return false; | 2077 if (!max_index_object->IsSmi()) return false; |
2078 return 0 != | 2078 return 0 != |
2079 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); | 2079 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); |
2080 } | 2080 } |
2081 | 2081 |
2082 uint32_t NumberDictionary::max_number_key() { | 2082 uint32_t SeededNumberDictionary::max_number_key() { |
2083 ASSERT(!requires_slow_elements()); | 2083 ASSERT(!requires_slow_elements()); |
2084 Object* max_index_object = get(kMaxNumberKeyIndex); | 2084 Object* max_index_object = get(kMaxNumberKeyIndex); |
2085 if (!max_index_object->IsSmi()) return 0; | 2085 if (!max_index_object->IsSmi()) return 0; |
2086 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); | 2086 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); |
2087 return value >> kRequiresSlowElementsTagSize; | 2087 return value >> kRequiresSlowElementsTagSize; |
2088 } | 2088 } |
2089 | 2089 |
2090 void NumberDictionary::set_requires_slow_elements() { | 2090 void SeededNumberDictionary::set_requires_slow_elements() { |
2091 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2091 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
2092 } | 2092 } |
2093 | 2093 |
2094 | 2094 |
2095 // ------------------------------------ | 2095 // ------------------------------------ |
2096 // Cast operations | 2096 // Cast operations |
2097 | 2097 |
2098 | 2098 |
2099 CAST_ACCESSOR(FixedArray) | 2099 CAST_ACCESSOR(FixedArray) |
2100 CAST_ACCESSOR(FixedDoubleArray) | 2100 CAST_ACCESSOR(FixedDoubleArray) |
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4292 return writable_elems; | 4292 return writable_elems; |
4293 } | 4293 } |
4294 | 4294 |
4295 | 4295 |
4296 StringDictionary* JSObject::property_dictionary() { | 4296 StringDictionary* JSObject::property_dictionary() { |
4297 ASSERT(!HasFastProperties()); | 4297 ASSERT(!HasFastProperties()); |
4298 return StringDictionary::cast(properties()); | 4298 return StringDictionary::cast(properties()); |
4299 } | 4299 } |
4300 | 4300 |
4301 | 4301 |
4302 NumberDictionary* JSObject::element_dictionary() { | 4302 SeededNumberDictionary* JSObject::element_dictionary() { |
4303 ASSERT(HasDictionaryElements()); | 4303 ASSERT(HasDictionaryElements()); |
4304 return NumberDictionary::cast(elements()); | 4304 return SeededNumberDictionary::cast(elements()); |
4305 } | 4305 } |
4306 | 4306 |
4307 | 4307 |
4308 bool String::IsHashFieldComputed(uint32_t field) { | 4308 bool String::IsHashFieldComputed(uint32_t field) { |
4309 return (field & kHashNotComputedMask) == 0; | 4309 return (field & kHashNotComputedMask) == 0; |
4310 } | 4310 } |
4311 | 4311 |
4312 | 4312 |
4313 bool String::HasHashCode() { | 4313 bool String::HasHashCode() { |
4314 return IsHashFieldComputed(hash_field()); | 4314 return IsHashFieldComputed(hash_field()); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4531 FixedArray::set(index+2, details.AsSmi()); | 4531 FixedArray::set(index+2, details.AsSmi()); |
4532 } | 4532 } |
4533 | 4533 |
4534 | 4534 |
4535 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 4535 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
4536 ASSERT(other->IsNumber()); | 4536 ASSERT(other->IsNumber()); |
4537 return key == static_cast<uint32_t>(other->Number()); | 4537 return key == static_cast<uint32_t>(other->Number()); |
4538 } | 4538 } |
4539 | 4539 |
4540 | 4540 |
4541 uint32_t NumberDictionaryShape::Hash(uint32_t key) { | 4541 uint32_t UnseededNumberDictionaryShape::Hash(uint32_t key) { |
4542 // This function is unreachable, since shape has UsesSeed=true flag. | 4542 return ComputeIntegerHash(key, 0); |
4543 UNREACHABLE(); | |
4544 return 0; | |
4545 } | 4543 } |
4546 | 4544 |
4547 | 4545 |
4548 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) { | 4546 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, |
4549 // This function is unreachable, since shape has UsesSeed=true flag. | 4547 Object* other) { |
4550 UNREACHABLE(); | 4548 ASSERT(other->IsNumber()); |
4551 return 0; | 4549 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
4552 } | 4550 } |
4553 | 4551 |
4554 uint32_t NumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 4552 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { |
4555 return ComputeIntegerHash(key, seed); | 4553 return ComputeIntegerHash(key, seed); |
4556 } | 4554 } |
4557 | 4555 |
4558 uint32_t NumberDictionaryShape::SeededHashForObject(uint32_t key, | 4556 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
4559 uint32_t seed, | 4557 uint32_t seed, |
4560 Object* other) { | 4558 Object* other) { |
4561 ASSERT(other->IsNumber()); | 4559 ASSERT(other->IsNumber()); |
4562 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 4560 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
4563 } | 4561 } |
4564 | 4562 |
4565 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { | 4563 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { |
4566 return Isolate::Current()->heap()->NumberFromUint32(key); | 4564 return Isolate::Current()->heap()->NumberFromUint32(key); |
4567 } | 4565 } |
4568 | 4566 |
4569 | 4567 |
4570 bool StringDictionaryShape::IsMatch(String* key, Object* other) { | 4568 bool StringDictionaryShape::IsMatch(String* key, Object* other) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4785 #undef WRITE_INT_FIELD | 4783 #undef WRITE_INT_FIELD |
4786 #undef READ_SHORT_FIELD | 4784 #undef READ_SHORT_FIELD |
4787 #undef WRITE_SHORT_FIELD | 4785 #undef WRITE_SHORT_FIELD |
4788 #undef READ_BYTE_FIELD | 4786 #undef READ_BYTE_FIELD |
4789 #undef WRITE_BYTE_FIELD | 4787 #undef WRITE_BYTE_FIELD |
4790 | 4788 |
4791 | 4789 |
4792 } } // namespace v8::internal | 4790 } } // namespace v8::internal |
4793 | 4791 |
4794 #endif // V8_OBJECTS_INL_H_ | 4792 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |