OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 7886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7897 // is created using the flags and not a code object it can only be used for | 7897 // is created using the flags and not a code object it can only be used for |
7898 // lookup not to create a new entry. | 7898 // lookup not to create a new entry. |
7899 class CodeCacheHashTableKey : public HashTableKey { | 7899 class CodeCacheHashTableKey : public HashTableKey { |
7900 public: | 7900 public: |
7901 CodeCacheHashTableKey(Handle<Name> name, Code::Flags flags) | 7901 CodeCacheHashTableKey(Handle<Name> name, Code::Flags flags) |
7902 : name_(name), flags_(flags), code_() { } | 7902 : name_(name), flags_(flags), code_() { } |
7903 | 7903 |
7904 CodeCacheHashTableKey(Handle<Name> name, Handle<Code> code) | 7904 CodeCacheHashTableKey(Handle<Name> name, Handle<Code> code) |
7905 : name_(name), flags_(code->flags()), code_(code) { } | 7905 : name_(name), flags_(code->flags()), code_(code) { } |
7906 | 7906 |
7907 bool IsMatch(Object* other) OVERRIDE { | 7907 bool IsMatch(Object* other) override { |
7908 if (!other->IsFixedArray()) return false; | 7908 if (!other->IsFixedArray()) return false; |
7909 FixedArray* pair = FixedArray::cast(other); | 7909 FixedArray* pair = FixedArray::cast(other); |
7910 Name* name = Name::cast(pair->get(0)); | 7910 Name* name = Name::cast(pair->get(0)); |
7911 Code::Flags flags = Code::cast(pair->get(1))->flags(); | 7911 Code::Flags flags = Code::cast(pair->get(1))->flags(); |
7912 if (flags != flags_) { | 7912 if (flags != flags_) { |
7913 return false; | 7913 return false; |
7914 } | 7914 } |
7915 return name_->Equals(name); | 7915 return name_->Equals(name); |
7916 } | 7916 } |
7917 | 7917 |
7918 static uint32_t NameFlagsHashHelper(Name* name, Code::Flags flags) { | 7918 static uint32_t NameFlagsHashHelper(Name* name, Code::Flags flags) { |
7919 return name->Hash() ^ flags; | 7919 return name->Hash() ^ flags; |
7920 } | 7920 } |
7921 | 7921 |
7922 uint32_t Hash() OVERRIDE { return NameFlagsHashHelper(*name_, flags_); } | 7922 uint32_t Hash() override { return NameFlagsHashHelper(*name_, flags_); } |
7923 | 7923 |
7924 uint32_t HashForObject(Object* obj) OVERRIDE { | 7924 uint32_t HashForObject(Object* obj) override { |
7925 FixedArray* pair = FixedArray::cast(obj); | 7925 FixedArray* pair = FixedArray::cast(obj); |
7926 Name* name = Name::cast(pair->get(0)); | 7926 Name* name = Name::cast(pair->get(0)); |
7927 Code* code = Code::cast(pair->get(1)); | 7927 Code* code = Code::cast(pair->get(1)); |
7928 return NameFlagsHashHelper(name, code->flags()); | 7928 return NameFlagsHashHelper(name, code->flags()); |
7929 } | 7929 } |
7930 | 7930 |
7931 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 7931 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) override { |
7932 Handle<Code> code = code_.ToHandleChecked(); | 7932 Handle<Code> code = code_.ToHandleChecked(); |
7933 Handle<FixedArray> pair = isolate->factory()->NewFixedArray(2); | 7933 Handle<FixedArray> pair = isolate->factory()->NewFixedArray(2); |
7934 pair->set(0, *name_); | 7934 pair->set(0, *name_); |
7935 pair->set(1, *code); | 7935 pair->set(1, *code); |
7936 return pair; | 7936 return pair; |
7937 } | 7937 } |
7938 | 7938 |
7939 private: | 7939 private: |
7940 Handle<Name> name_; | 7940 Handle<Name> name_; |
7941 Code::Flags flags_; | 7941 Code::Flags flags_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8025 // Despite their name, object of this class are not stored in the actual | 8025 // Despite their name, object of this class are not stored in the actual |
8026 // hash table; instead they're temporarily used for lookups. It is therefore | 8026 // hash table; instead they're temporarily used for lookups. It is therefore |
8027 // safe to have a weak (non-owning) pointer to a MapList as a member field. | 8027 // safe to have a weak (non-owning) pointer to a MapList as a member field. |
8028 class PolymorphicCodeCacheHashTableKey : public HashTableKey { | 8028 class PolymorphicCodeCacheHashTableKey : public HashTableKey { |
8029 public: | 8029 public: |
8030 // Callers must ensure that |maps| outlives the newly constructed object. | 8030 // Callers must ensure that |maps| outlives the newly constructed object. |
8031 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) | 8031 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) |
8032 : maps_(maps), | 8032 : maps_(maps), |
8033 code_flags_(code_flags) {} | 8033 code_flags_(code_flags) {} |
8034 | 8034 |
8035 bool IsMatch(Object* other) OVERRIDE { | 8035 bool IsMatch(Object* other) override { |
8036 MapHandleList other_maps(kDefaultListAllocationSize); | 8036 MapHandleList other_maps(kDefaultListAllocationSize); |
8037 int other_flags; | 8037 int other_flags; |
8038 FromObject(other, &other_flags, &other_maps); | 8038 FromObject(other, &other_flags, &other_maps); |
8039 if (code_flags_ != other_flags) return false; | 8039 if (code_flags_ != other_flags) return false; |
8040 if (maps_->length() != other_maps.length()) return false; | 8040 if (maps_->length() != other_maps.length()) return false; |
8041 // Compare just the hashes first because it's faster. | 8041 // Compare just the hashes first because it's faster. |
8042 int this_hash = MapsHashHelper(maps_, code_flags_); | 8042 int this_hash = MapsHashHelper(maps_, code_flags_); |
8043 int other_hash = MapsHashHelper(&other_maps, other_flags); | 8043 int other_hash = MapsHashHelper(&other_maps, other_flags); |
8044 if (this_hash != other_hash) return false; | 8044 if (this_hash != other_hash) return false; |
8045 | 8045 |
(...skipping 14 matching lines...) Expand all Loading... |
8060 } | 8060 } |
8061 | 8061 |
8062 static uint32_t MapsHashHelper(MapHandleList* maps, int code_flags) { | 8062 static uint32_t MapsHashHelper(MapHandleList* maps, int code_flags) { |
8063 uint32_t hash = code_flags; | 8063 uint32_t hash = code_flags; |
8064 for (int i = 0; i < maps->length(); ++i) { | 8064 for (int i = 0; i < maps->length(); ++i) { |
8065 hash ^= maps->at(i)->Hash(); | 8065 hash ^= maps->at(i)->Hash(); |
8066 } | 8066 } |
8067 return hash; | 8067 return hash; |
8068 } | 8068 } |
8069 | 8069 |
8070 uint32_t Hash() OVERRIDE { | 8070 uint32_t Hash() override { return MapsHashHelper(maps_, code_flags_); } |
8071 return MapsHashHelper(maps_, code_flags_); | |
8072 } | |
8073 | 8071 |
8074 uint32_t HashForObject(Object* obj) OVERRIDE { | 8072 uint32_t HashForObject(Object* obj) override { |
8075 MapHandleList other_maps(kDefaultListAllocationSize); | 8073 MapHandleList other_maps(kDefaultListAllocationSize); |
8076 int other_flags; | 8074 int other_flags; |
8077 FromObject(obj, &other_flags, &other_maps); | 8075 FromObject(obj, &other_flags, &other_maps); |
8078 return MapsHashHelper(&other_maps, other_flags); | 8076 return MapsHashHelper(&other_maps, other_flags); |
8079 } | 8077 } |
8080 | 8078 |
8081 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 8079 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) override { |
8082 // The maps in |maps_| must be copied to a newly allocated FixedArray, | 8080 // The maps in |maps_| must be copied to a newly allocated FixedArray, |
8083 // both because the referenced MapList is short-lived, and because C++ | 8081 // both because the referenced MapList is short-lived, and because C++ |
8084 // objects can't be stored in the heap anyway. | 8082 // objects can't be stored in the heap anyway. |
8085 Handle<FixedArray> list = | 8083 Handle<FixedArray> list = |
8086 isolate->factory()->NewUninitializedFixedArray(maps_->length() + 1); | 8084 isolate->factory()->NewUninitializedFixedArray(maps_->length() + 1); |
8087 list->set(0, Smi::FromInt(code_flags_)); | 8085 list->set(0, Smi::FromInt(code_flags_)); |
8088 for (int i = 0; i < maps_->length(); ++i) { | 8086 for (int i = 0; i < maps_->length(); ++i) { |
8089 list->set(i + 1, *maps_->at(i)); | 8087 list->set(i + 1, *maps_->at(i)); |
8090 } | 8088 } |
8091 return list; | 8089 return list; |
(...skipping 6310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14402 // StringSharedKeys are used as keys in the eval cache. | 14400 // StringSharedKeys are used as keys in the eval cache. |
14403 class StringSharedKey : public HashTableKey { | 14401 class StringSharedKey : public HashTableKey { |
14404 public: | 14402 public: |
14405 StringSharedKey(Handle<String> source, Handle<SharedFunctionInfo> shared, | 14403 StringSharedKey(Handle<String> source, Handle<SharedFunctionInfo> shared, |
14406 LanguageMode language_mode, int scope_position) | 14404 LanguageMode language_mode, int scope_position) |
14407 : source_(source), | 14405 : source_(source), |
14408 shared_(shared), | 14406 shared_(shared), |
14409 language_mode_(language_mode), | 14407 language_mode_(language_mode), |
14410 scope_position_(scope_position) {} | 14408 scope_position_(scope_position) {} |
14411 | 14409 |
14412 bool IsMatch(Object* other) OVERRIDE { | 14410 bool IsMatch(Object* other) override { |
14413 DisallowHeapAllocation no_allocation; | 14411 DisallowHeapAllocation no_allocation; |
14414 if (!other->IsFixedArray()) { | 14412 if (!other->IsFixedArray()) { |
14415 if (!other->IsNumber()) return false; | 14413 if (!other->IsNumber()) return false; |
14416 uint32_t other_hash = static_cast<uint32_t>(other->Number()); | 14414 uint32_t other_hash = static_cast<uint32_t>(other->Number()); |
14417 return Hash() == other_hash; | 14415 return Hash() == other_hash; |
14418 } | 14416 } |
14419 FixedArray* other_array = FixedArray::cast(other); | 14417 FixedArray* other_array = FixedArray::cast(other); |
14420 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); | 14418 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); |
14421 if (shared != *shared_) return false; | 14419 if (shared != *shared_) return false; |
14422 int language_unchecked = Smi::cast(other_array->get(2))->value(); | 14420 int language_unchecked = Smi::cast(other_array->get(2))->value(); |
(...skipping 20 matching lines...) Expand all Loading... |
14443 Script* script(Script::cast(shared->script())); | 14441 Script* script(Script::cast(shared->script())); |
14444 hash ^= String::cast(script->source())->Hash(); | 14442 hash ^= String::cast(script->source())->Hash(); |
14445 STATIC_ASSERT(LANGUAGE_END == 3); | 14443 STATIC_ASSERT(LANGUAGE_END == 3); |
14446 if (is_strict(language_mode)) hash ^= 0x8000; | 14444 if (is_strict(language_mode)) hash ^= 0x8000; |
14447 if (is_strong(language_mode)) hash ^= 0x10000; | 14445 if (is_strong(language_mode)) hash ^= 0x10000; |
14448 hash += scope_position; | 14446 hash += scope_position; |
14449 } | 14447 } |
14450 return hash; | 14448 return hash; |
14451 } | 14449 } |
14452 | 14450 |
14453 uint32_t Hash() OVERRIDE { | 14451 uint32_t Hash() override { |
14454 return StringSharedHashHelper(*source_, *shared_, language_mode_, | 14452 return StringSharedHashHelper(*source_, *shared_, language_mode_, |
14455 scope_position_); | 14453 scope_position_); |
14456 } | 14454 } |
14457 | 14455 |
14458 uint32_t HashForObject(Object* obj) OVERRIDE { | 14456 uint32_t HashForObject(Object* obj) override { |
14459 DisallowHeapAllocation no_allocation; | 14457 DisallowHeapAllocation no_allocation; |
14460 if (obj->IsNumber()) { | 14458 if (obj->IsNumber()) { |
14461 return static_cast<uint32_t>(obj->Number()); | 14459 return static_cast<uint32_t>(obj->Number()); |
14462 } | 14460 } |
14463 FixedArray* other_array = FixedArray::cast(obj); | 14461 FixedArray* other_array = FixedArray::cast(obj); |
14464 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); | 14462 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); |
14465 String* source = String::cast(other_array->get(1)); | 14463 String* source = String::cast(other_array->get(1)); |
14466 int language_unchecked = Smi::cast(other_array->get(2))->value(); | 14464 int language_unchecked = Smi::cast(other_array->get(2))->value(); |
14467 DCHECK(is_valid_language_mode(language_unchecked)); | 14465 DCHECK(is_valid_language_mode(language_unchecked)); |
14468 LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); | 14466 LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); |
14469 int scope_position = Smi::cast(other_array->get(3))->value(); | 14467 int scope_position = Smi::cast(other_array->get(3))->value(); |
14470 return StringSharedHashHelper(source, shared, language_mode, | 14468 return StringSharedHashHelper(source, shared, language_mode, |
14471 scope_position); | 14469 scope_position); |
14472 } | 14470 } |
14473 | 14471 |
14474 | 14472 |
14475 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 14473 Handle<Object> AsHandle(Isolate* isolate) override { |
14476 Handle<FixedArray> array = isolate->factory()->NewFixedArray(4); | 14474 Handle<FixedArray> array = isolate->factory()->NewFixedArray(4); |
14477 array->set(0, *shared_); | 14475 array->set(0, *shared_); |
14478 array->set(1, *source_); | 14476 array->set(1, *source_); |
14479 array->set(2, Smi::FromInt(language_mode_)); | 14477 array->set(2, Smi::FromInt(language_mode_)); |
14480 array->set(3, Smi::FromInt(scope_position_)); | 14478 array->set(3, Smi::FromInt(scope_position_)); |
14481 return array; | 14479 return array; |
14482 } | 14480 } |
14483 | 14481 |
14484 private: | 14482 private: |
14485 Handle<String> source_; | 14483 Handle<String> source_; |
14486 Handle<SharedFunctionInfo> shared_; | 14484 Handle<SharedFunctionInfo> shared_; |
14487 LanguageMode language_mode_; | 14485 LanguageMode language_mode_; |
14488 int scope_position_; | 14486 int scope_position_; |
14489 }; | 14487 }; |
14490 | 14488 |
14491 | 14489 |
14492 // RegExpKey carries the source and flags of a regular expression as key. | 14490 // RegExpKey carries the source and flags of a regular expression as key. |
14493 class RegExpKey : public HashTableKey { | 14491 class RegExpKey : public HashTableKey { |
14494 public: | 14492 public: |
14495 RegExpKey(Handle<String> string, JSRegExp::Flags flags) | 14493 RegExpKey(Handle<String> string, JSRegExp::Flags flags) |
14496 : string_(string), | 14494 : string_(string), |
14497 flags_(Smi::FromInt(flags.value())) { } | 14495 flags_(Smi::FromInt(flags.value())) { } |
14498 | 14496 |
14499 // Rather than storing the key in the hash table, a pointer to the | 14497 // Rather than storing the key in the hash table, a pointer to the |
14500 // stored value is stored where the key should be. IsMatch then | 14498 // stored value is stored where the key should be. IsMatch then |
14501 // compares the search key to the found object, rather than comparing | 14499 // compares the search key to the found object, rather than comparing |
14502 // a key to a key. | 14500 // a key to a key. |
14503 bool IsMatch(Object* obj) OVERRIDE { | 14501 bool IsMatch(Object* obj) override { |
14504 FixedArray* val = FixedArray::cast(obj); | 14502 FixedArray* val = FixedArray::cast(obj); |
14505 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) | 14503 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) |
14506 && (flags_ == val->get(JSRegExp::kFlagsIndex)); | 14504 && (flags_ == val->get(JSRegExp::kFlagsIndex)); |
14507 } | 14505 } |
14508 | 14506 |
14509 uint32_t Hash() OVERRIDE { return RegExpHash(*string_, flags_); } | 14507 uint32_t Hash() override { return RegExpHash(*string_, flags_); } |
14510 | 14508 |
14511 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 14509 Handle<Object> AsHandle(Isolate* isolate) override { |
14512 // Plain hash maps, which is where regexp keys are used, don't | 14510 // Plain hash maps, which is where regexp keys are used, don't |
14513 // use this function. | 14511 // use this function. |
14514 UNREACHABLE(); | 14512 UNREACHABLE(); |
14515 return MaybeHandle<Object>().ToHandleChecked(); | 14513 return MaybeHandle<Object>().ToHandleChecked(); |
14516 } | 14514 } |
14517 | 14515 |
14518 uint32_t HashForObject(Object* obj) OVERRIDE { | 14516 uint32_t HashForObject(Object* obj) override { |
14519 FixedArray* val = FixedArray::cast(obj); | 14517 FixedArray* val = FixedArray::cast(obj); |
14520 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), | 14518 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), |
14521 Smi::cast(val->get(JSRegExp::kFlagsIndex))); | 14519 Smi::cast(val->get(JSRegExp::kFlagsIndex))); |
14522 } | 14520 } |
14523 | 14521 |
14524 static uint32_t RegExpHash(String* string, Smi* flags) { | 14522 static uint32_t RegExpHash(String* string, Smi* flags) { |
14525 return string->Hash() + flags->value(); | 14523 return string->Hash() + flags->value(); |
14526 } | 14524 } |
14527 | 14525 |
14528 Handle<String> string_; | 14526 Handle<String> string_; |
(...skipping 25 matching lines...) Expand all Loading... |
14554 return String::cast(string)->IsOneByteEqualTo(chars); | 14552 return String::cast(string)->IsOneByteEqualTo(chars); |
14555 } | 14553 } |
14556 | 14554 |
14557 | 14555 |
14558 // InternalizedStringKey carries a string/internalized-string object as key. | 14556 // InternalizedStringKey carries a string/internalized-string object as key. |
14559 class InternalizedStringKey : public HashTableKey { | 14557 class InternalizedStringKey : public HashTableKey { |
14560 public: | 14558 public: |
14561 explicit InternalizedStringKey(Handle<String> string) | 14559 explicit InternalizedStringKey(Handle<String> string) |
14562 : string_(string) { } | 14560 : string_(string) { } |
14563 | 14561 |
14564 bool IsMatch(Object* string) OVERRIDE { | 14562 bool IsMatch(Object* string) override { |
14565 return String::cast(string)->Equals(*string_); | 14563 return String::cast(string)->Equals(*string_); |
14566 } | 14564 } |
14567 | 14565 |
14568 uint32_t Hash() OVERRIDE { return string_->Hash(); } | 14566 uint32_t Hash() override { return string_->Hash(); } |
14569 | 14567 |
14570 uint32_t HashForObject(Object* other) OVERRIDE { | 14568 uint32_t HashForObject(Object* other) override { |
14571 return String::cast(other)->Hash(); | 14569 return String::cast(other)->Hash(); |
14572 } | 14570 } |
14573 | 14571 |
14574 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 14572 Handle<Object> AsHandle(Isolate* isolate) override { |
14575 // Internalize the string if possible. | 14573 // Internalize the string if possible. |
14576 MaybeHandle<Map> maybe_map = | 14574 MaybeHandle<Map> maybe_map = |
14577 isolate->factory()->InternalizedStringMapForString(string_); | 14575 isolate->factory()->InternalizedStringMapForString(string_); |
14578 Handle<Map> map; | 14576 Handle<Map> map; |
14579 if (maybe_map.ToHandle(&map)) { | 14577 if (maybe_map.ToHandle(&map)) { |
14580 string_->set_map_no_write_barrier(*map); | 14578 string_->set_map_no_write_barrier(*map); |
14581 DCHECK(string_->IsInternalizedString()); | 14579 DCHECK(string_->IsInternalizedString()); |
14582 return string_; | 14580 return string_; |
14583 } | 14581 } |
14584 // Otherwise allocate a new internalized string. | 14582 // Otherwise allocate a new internalized string. |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15471 // version of the string hashing algorithm above. One reason could be | 15469 // version of the string hashing algorithm above. One reason could be |
15472 // that we were passed two digits as characters, since the hash | 15470 // that we were passed two digits as characters, since the hash |
15473 // algorithm is different in that case. | 15471 // algorithm is different in that case. |
15474 uint16_t chars[2] = {c1, c2}; | 15472 uint16_t chars[2] = {c1, c2}; |
15475 uint32_t check_hash = StringHasher::HashSequentialString(chars, 2, seed); | 15473 uint32_t check_hash = StringHasher::HashSequentialString(chars, 2, seed); |
15476 hash = (hash << String::kHashShift) | String::kIsNotArrayIndexMask; | 15474 hash = (hash << String::kHashShift) | String::kIsNotArrayIndexMask; |
15477 DCHECK_EQ(static_cast<int32_t>(hash), static_cast<int32_t>(check_hash)); | 15475 DCHECK_EQ(static_cast<int32_t>(hash), static_cast<int32_t>(check_hash)); |
15478 #endif | 15476 #endif |
15479 } | 15477 } |
15480 | 15478 |
15481 bool IsMatch(Object* o) OVERRIDE { | 15479 bool IsMatch(Object* o) override { |
15482 if (!o->IsString()) return false; | 15480 if (!o->IsString()) return false; |
15483 String* other = String::cast(o); | 15481 String* other = String::cast(o); |
15484 if (other->length() != 2) return false; | 15482 if (other->length() != 2) return false; |
15485 if (other->Get(0) != c1_) return false; | 15483 if (other->Get(0) != c1_) return false; |
15486 return other->Get(1) == c2_; | 15484 return other->Get(1) == c2_; |
15487 } | 15485 } |
15488 | 15486 |
15489 uint32_t Hash() OVERRIDE { return hash_; } | 15487 uint32_t Hash() override { return hash_; } |
15490 uint32_t HashForObject(Object* key) OVERRIDE { | 15488 uint32_t HashForObject(Object* key) override { |
15491 if (!key->IsString()) return 0; | 15489 if (!key->IsString()) return 0; |
15492 return String::cast(key)->Hash(); | 15490 return String::cast(key)->Hash(); |
15493 } | 15491 } |
15494 | 15492 |
15495 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { | 15493 Handle<Object> AsHandle(Isolate* isolate) override { |
15496 // The TwoCharHashTableKey is only used for looking in the string | 15494 // The TwoCharHashTableKey is only used for looking in the string |
15497 // table, not for adding to it. | 15495 // table, not for adding to it. |
15498 UNREACHABLE(); | 15496 UNREACHABLE(); |
15499 return MaybeHandle<Object>().ToHandleChecked(); | 15497 return MaybeHandle<Object>().ToHandleChecked(); |
15500 } | 15498 } |
15501 | 15499 |
15502 private: | 15500 private: |
15503 uint16_t c1_; | 15501 uint16_t c1_; |
15504 uint16_t c2_; | 15502 uint16_t c2_; |
15505 uint32_t hash_; | 15503 uint32_t hash_; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15748 } | 15746 } |
15749 return; | 15747 return; |
15750 } | 15748 } |
15751 | 15749 |
15752 | 15750 |
15753 // StringsKey used for HashTable where key is array of internalized strings. | 15751 // StringsKey used for HashTable where key is array of internalized strings. |
15754 class StringsKey : public HashTableKey { | 15752 class StringsKey : public HashTableKey { |
15755 public: | 15753 public: |
15756 explicit StringsKey(Handle<FixedArray> strings) : strings_(strings) { } | 15754 explicit StringsKey(Handle<FixedArray> strings) : strings_(strings) { } |
15757 | 15755 |
15758 bool IsMatch(Object* strings) OVERRIDE { | 15756 bool IsMatch(Object* strings) override { |
15759 FixedArray* o = FixedArray::cast(strings); | 15757 FixedArray* o = FixedArray::cast(strings); |
15760 int len = strings_->length(); | 15758 int len = strings_->length(); |
15761 if (o->length() != len) return false; | 15759 if (o->length() != len) return false; |
15762 for (int i = 0; i < len; i++) { | 15760 for (int i = 0; i < len; i++) { |
15763 if (o->get(i) != strings_->get(i)) return false; | 15761 if (o->get(i) != strings_->get(i)) return false; |
15764 } | 15762 } |
15765 return true; | 15763 return true; |
15766 } | 15764 } |
15767 | 15765 |
15768 uint32_t Hash() OVERRIDE { return HashForObject(*strings_); } | 15766 uint32_t Hash() override { return HashForObject(*strings_); } |
15769 | 15767 |
15770 uint32_t HashForObject(Object* obj) OVERRIDE { | 15768 uint32_t HashForObject(Object* obj) override { |
15771 FixedArray* strings = FixedArray::cast(obj); | 15769 FixedArray* strings = FixedArray::cast(obj); |
15772 int len = strings->length(); | 15770 int len = strings->length(); |
15773 uint32_t hash = 0; | 15771 uint32_t hash = 0; |
15774 for (int i = 0; i < len; i++) { | 15772 for (int i = 0; i < len; i++) { |
15775 hash ^= String::cast(strings->get(i))->Hash(); | 15773 hash ^= String::cast(strings->get(i))->Hash(); |
15776 } | 15774 } |
15777 return hash; | 15775 return hash; |
15778 } | 15776 } |
15779 | 15777 |
15780 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { return strings_; } | 15778 Handle<Object> AsHandle(Isolate* isolate) override { return strings_; } |
15781 | 15779 |
15782 private: | 15780 private: |
15783 Handle<FixedArray> strings_; | 15781 Handle<FixedArray> strings_; |
15784 }; | 15782 }; |
15785 | 15783 |
15786 | 15784 |
15787 template<typename Derived, typename Shape, typename Key> | 15785 template<typename Derived, typename Shape, typename Key> |
15788 Handle<Derived> Dictionary<Derived, Shape, Key>::New( | 15786 Handle<Derived> Dictionary<Derived, Shape, Key>::New( |
15789 Isolate* isolate, | 15787 Isolate* isolate, |
15790 int at_least_space_for, | 15788 int at_least_space_for, |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17163 CompilationInfo* info) { | 17161 CompilationInfo* info) { |
17164 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17162 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17165 handle(cell->dependent_code(), info->isolate()), | 17163 handle(cell->dependent_code(), info->isolate()), |
17166 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17164 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17167 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17165 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17168 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17166 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17169 cell, info->zone()); | 17167 cell, info->zone()); |
17170 } | 17168 } |
17171 | 17169 |
17172 } } // namespace v8::internal | 17170 } } // namespace v8::internal |
OLD | NEW |