| 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 3902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3913 } | 3913 } |
| 3914 | 3914 |
| 3915 | 3915 |
| 3916 bool String::SlowAsArrayIndex(uint32_t* index) { | 3916 bool String::SlowAsArrayIndex(uint32_t* index) { |
| 3917 StringInputBuffer buffer(this); | 3917 StringInputBuffer buffer(this); |
| 3918 return ComputeArrayIndex(&buffer, index, length()); | 3918 return ComputeArrayIndex(&buffer, index, length()); |
| 3919 } | 3919 } |
| 3920 | 3920 |
| 3921 | 3921 |
| 3922 static inline uint32_t HashField(uint32_t hash, bool is_array_index) { | 3922 static inline uint32_t HashField(uint32_t hash, bool is_array_index) { |
| 3923 return (hash << String::kLongLengthShift) | (is_array_index ? 3 : 1); | 3923 uint32_t result = |
| 3924 (hash << String::kLongLengthShift) | String::kHashComputedMask; |
| 3925 if (is_array_index) result |= String::kIsArrayIndexMask; |
| 3926 return result; |
| 3924 } | 3927 } |
| 3925 | 3928 |
| 3926 | 3929 |
| 3927 uint32_t StringHasher::GetHashField() { | 3930 uint32_t StringHasher::GetHashField() { |
| 3928 ASSERT(is_valid()); | 3931 ASSERT(is_valid()); |
| 3929 if (length_ <= String::kMaxShortStringSize) { | 3932 if (length_ <= String::kMaxShortStringSize) { |
| 3930 uint32_t payload; | 3933 uint32_t payload; |
| 3931 if (is_array_index()) { | 3934 if (is_array_index()) { |
| 3932 payload = v8::internal::HashField(array_index(), true); | 3935 payload = v8::internal::HashField(array_index(), true); |
| 3933 } else { | 3936 } else { |
| (...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6056 } | 6059 } |
| 6057 | 6060 |
| 6058 | 6061 |
| 6059 void Dictionary::UpdateMaxNumberKey(uint32_t key) { | 6062 void Dictionary::UpdateMaxNumberKey(uint32_t key) { |
| 6060 // If the dictionary requires slow elements an element has already | 6063 // If the dictionary requires slow elements an element has already |
| 6061 // been added at a high index. | 6064 // been added at a high index. |
| 6062 if (requires_slow_elements()) return; | 6065 if (requires_slow_elements()) return; |
| 6063 // Check if this index is high enough that we should require slow | 6066 // Check if this index is high enough that we should require slow |
| 6064 // elements. | 6067 // elements. |
| 6065 if (key > kRequiresSlowElementsLimit) { | 6068 if (key > kRequiresSlowElementsLimit) { |
| 6066 set(kPrefixStartIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 6069 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); |
| 6067 return; | 6070 return; |
| 6068 } | 6071 } |
| 6069 // Update max key value. | 6072 // Update max key value. |
| 6070 Object* max_index_object = get(kPrefixStartIndex); | 6073 Object* max_index_object = get(kMaxNumberKeyIndex); |
| 6071 if (!max_index_object->IsSmi() || max_number_key() < key) { | 6074 if (!max_index_object->IsSmi() || max_number_key() < key) { |
| 6072 set(kPrefixStartIndex, Smi::FromInt(key << kRequiresSlowElementsTagSize)); | 6075 set(kMaxNumberKeyIndex, Smi::FromInt(key << kRequiresSlowElementsTagSize)); |
| 6073 } | 6076 } |
| 6074 } | 6077 } |
| 6075 | 6078 |
| 6076 | 6079 |
| 6077 Object* Dictionary::AddStringEntry(String* key, | 6080 Object* Dictionary::AddStringEntry(String* key, |
| 6078 Object* value, | 6081 Object* value, |
| 6079 PropertyDetails details) { | 6082 PropertyDetails details) { |
| 6080 StringKey k(key); | 6083 StringKey k(key); |
| 6081 SLOW_ASSERT(FindEntry(&k) == -1); | 6084 SLOW_ASSERT(FindEntry(&k) == -1); |
| 6082 return Add(&k, value, details); | 6085 return Add(&k, value, details); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6544 // No break point. | 6547 // No break point. |
| 6545 if (break_point_objects()->IsUndefined()) return 0; | 6548 if (break_point_objects()->IsUndefined()) return 0; |
| 6546 // Single beak point. | 6549 // Single beak point. |
| 6547 if (!break_point_objects()->IsFixedArray()) return 1; | 6550 if (!break_point_objects()->IsFixedArray()) return 1; |
| 6548 // Multiple break points. | 6551 // Multiple break points. |
| 6549 return FixedArray::cast(break_point_objects())->length(); | 6552 return FixedArray::cast(break_point_objects())->length(); |
| 6550 } | 6553 } |
| 6551 | 6554 |
| 6552 | 6555 |
| 6553 } } // namespace v8::internal | 6556 } } // namespace v8::internal |
| OLD | NEW |