| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 7271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7282 break; | 7282 break; |
| 7283 } | 7283 } |
| 7284 } | 7284 } |
| 7285 } | 7285 } |
| 7286 for (; i < length; i++) { | 7286 for (; i < length; i++) { |
| 7287 DCHECK(!is_array_index_); | 7287 DCHECK(!is_array_index_); |
| 7288 AddCharacter(chars[i]); | 7288 AddCharacter(chars[i]); |
| 7289 } | 7289 } |
| 7290 } | 7290 } |
| 7291 | 7291 |
| 7292 uint32_t StringHasher::GetHashField() { |
| 7293 if (length_ <= String::kMaxHashCalcLength) { |
| 7294 if (is_array_index_) { |
| 7295 return MakeArrayIndexHash(array_index_, length_); |
| 7296 } |
| 7297 return (GetHashCore(raw_running_hash_) << String::kHashShift) | |
| 7298 String::kIsNotArrayIndexMask; |
| 7299 } else { |
| 7300 return (length_ << String::kHashShift) | String::kIsNotArrayIndexMask; |
| 7301 } |
| 7302 } |
| 7292 | 7303 |
| 7293 template <typename schar> | 7304 template <typename schar> |
| 7294 uint32_t StringHasher::HashSequentialString(const schar* chars, | 7305 uint32_t StringHasher::HashSequentialString(const schar* chars, |
| 7295 int length, | 7306 int length, |
| 7296 uint32_t seed) { | 7307 uint32_t seed) { |
| 7297 StringHasher hasher(length, seed); | 7308 StringHasher hasher(length, seed); |
| 7298 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); | 7309 if (!hasher.has_trivial_hash()) hasher.AddCharacters(chars, length); |
| 7299 return hasher.GetHashField(); | 7310 return hasher.GetHashField(); |
| 7300 } | 7311 } |
| 7301 | 7312 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7700 | 7711 |
| 7701 bool AccessorPair::ContainsAccessor() { | 7712 bool AccessorPair::ContainsAccessor() { |
| 7702 return IsJSAccessor(getter()) || IsJSAccessor(setter()); | 7713 return IsJSAccessor(getter()) || IsJSAccessor(setter()); |
| 7703 } | 7714 } |
| 7704 | 7715 |
| 7705 | 7716 |
| 7706 bool AccessorPair::IsJSAccessor(Object* obj) { | 7717 bool AccessorPair::IsJSAccessor(Object* obj) { |
| 7707 return obj->IsCallable() || obj->IsUndefined(GetIsolate()); | 7718 return obj->IsCallable() || obj->IsUndefined(GetIsolate()); |
| 7708 } | 7719 } |
| 7709 | 7720 |
| 7721 Handle<String> StringTable::LookupKey(Isolate* isolate, HashTableKey* key) { |
| 7722 Handle<StringTable> table = isolate->factory()->string_table(); |
| 7723 int32_t hash = key->Hash(); |
| 7724 int entry = table->FindEntry(isolate, key, hash); |
| 7725 |
| 7726 // String already in table. |
| 7727 if (entry != kNotFound) { |
| 7728 return handle(String::cast(table->KeyAt(entry)), isolate); |
| 7729 } |
| 7730 |
| 7731 return InsertKey(isolate, table, key, hash); |
| 7732 } |
| 7710 | 7733 |
| 7711 template<typename Derived, typename Shape, typename Key> | 7734 template<typename Derived, typename Shape, typename Key> |
| 7712 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, | 7735 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
| 7713 Handle<Object> key, | 7736 Handle<Object> key, |
| 7714 Handle<Object> value) { | 7737 Handle<Object> value) { |
| 7715 this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero)); | 7738 this->SetEntry(entry, key, value, PropertyDetails(Smi::kZero)); |
| 7716 } | 7739 } |
| 7717 | 7740 |
| 7718 | 7741 |
| 7719 template<typename Derived, typename Shape, typename Key> | 7742 template<typename Derived, typename Shape, typename Key> |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8276 #undef WRITE_INT64_FIELD | 8299 #undef WRITE_INT64_FIELD |
| 8277 #undef READ_BYTE_FIELD | 8300 #undef READ_BYTE_FIELD |
| 8278 #undef WRITE_BYTE_FIELD | 8301 #undef WRITE_BYTE_FIELD |
| 8279 #undef NOBARRIER_READ_BYTE_FIELD | 8302 #undef NOBARRIER_READ_BYTE_FIELD |
| 8280 #undef NOBARRIER_WRITE_BYTE_FIELD | 8303 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8281 | 8304 |
| 8282 } // namespace internal | 8305 } // namespace internal |
| 8283 } // namespace v8 | 8306 } // namespace v8 |
| 8284 | 8307 |
| 8285 #endif // V8_OBJECTS_INL_H_ | 8308 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |