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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 7438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7449 // is created using the flags and not a code object it can only be used for | 7449 // is created using the flags and not a code object it can only be used for |
7450 // lookup not to create a new entry. | 7450 // lookup not to create a new entry. |
7451 class CodeCacheHashTableKey : public HashTableKey { | 7451 class CodeCacheHashTableKey : public HashTableKey { |
7452 public: | 7452 public: |
7453 CodeCacheHashTableKey(Handle<Name> name, Code::Flags flags) | 7453 CodeCacheHashTableKey(Handle<Name> name, Code::Flags flags) |
7454 : name_(name), flags_(flags), code_() { } | 7454 : name_(name), flags_(flags), code_() { } |
7455 | 7455 |
7456 CodeCacheHashTableKey(Handle<Name> name, Handle<Code> code) | 7456 CodeCacheHashTableKey(Handle<Name> name, Handle<Code> code) |
7457 : name_(name), flags_(code->flags()), code_(code) { } | 7457 : name_(name), flags_(code->flags()), code_(code) { } |
7458 | 7458 |
7459 bool IsMatch(Object* other) V8_OVERRIDE { | 7459 bool IsMatch(Object* other) OVERRIDE { |
7460 if (!other->IsFixedArray()) return false; | 7460 if (!other->IsFixedArray()) return false; |
7461 FixedArray* pair = FixedArray::cast(other); | 7461 FixedArray* pair = FixedArray::cast(other); |
7462 Name* name = Name::cast(pair->get(0)); | 7462 Name* name = Name::cast(pair->get(0)); |
7463 Code::Flags flags = Code::cast(pair->get(1))->flags(); | 7463 Code::Flags flags = Code::cast(pair->get(1))->flags(); |
7464 if (flags != flags_) { | 7464 if (flags != flags_) { |
7465 return false; | 7465 return false; |
7466 } | 7466 } |
7467 return name_->Equals(name); | 7467 return name_->Equals(name); |
7468 } | 7468 } |
7469 | 7469 |
7470 static uint32_t NameFlagsHashHelper(Name* name, Code::Flags flags) { | 7470 static uint32_t NameFlagsHashHelper(Name* name, Code::Flags flags) { |
7471 return name->Hash() ^ flags; | 7471 return name->Hash() ^ flags; |
7472 } | 7472 } |
7473 | 7473 |
7474 uint32_t Hash() V8_OVERRIDE { return NameFlagsHashHelper(*name_, flags_); } | 7474 uint32_t Hash() OVERRIDE { return NameFlagsHashHelper(*name_, flags_); } |
7475 | 7475 |
7476 uint32_t HashForObject(Object* obj) V8_OVERRIDE { | 7476 uint32_t HashForObject(Object* obj) OVERRIDE { |
7477 FixedArray* pair = FixedArray::cast(obj); | 7477 FixedArray* pair = FixedArray::cast(obj); |
7478 Name* name = Name::cast(pair->get(0)); | 7478 Name* name = Name::cast(pair->get(0)); |
7479 Code* code = Code::cast(pair->get(1)); | 7479 Code* code = Code::cast(pair->get(1)); |
7480 return NameFlagsHashHelper(name, code->flags()); | 7480 return NameFlagsHashHelper(name, code->flags()); |
7481 } | 7481 } |
7482 | 7482 |
7483 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 7483 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
7484 Handle<Code> code = code_.ToHandleChecked(); | 7484 Handle<Code> code = code_.ToHandleChecked(); |
7485 Handle<FixedArray> pair = isolate->factory()->NewFixedArray(2); | 7485 Handle<FixedArray> pair = isolate->factory()->NewFixedArray(2); |
7486 pair->set(0, *name_); | 7486 pair->set(0, *name_); |
7487 pair->set(1, *code); | 7487 pair->set(1, *code); |
7488 return pair; | 7488 return pair; |
7489 } | 7489 } |
7490 | 7490 |
7491 private: | 7491 private: |
7492 Handle<Name> name_; | 7492 Handle<Name> name_; |
7493 Code::Flags flags_; | 7493 Code::Flags flags_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7577 // Despite their name, object of this class are not stored in the actual | 7577 // Despite their name, object of this class are not stored in the actual |
7578 // hash table; instead they're temporarily used for lookups. It is therefore | 7578 // hash table; instead they're temporarily used for lookups. It is therefore |
7579 // safe to have a weak (non-owning) pointer to a MapList as a member field. | 7579 // safe to have a weak (non-owning) pointer to a MapList as a member field. |
7580 class PolymorphicCodeCacheHashTableKey : public HashTableKey { | 7580 class PolymorphicCodeCacheHashTableKey : public HashTableKey { |
7581 public: | 7581 public: |
7582 // Callers must ensure that |maps| outlives the newly constructed object. | 7582 // Callers must ensure that |maps| outlives the newly constructed object. |
7583 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) | 7583 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) |
7584 : maps_(maps), | 7584 : maps_(maps), |
7585 code_flags_(code_flags) {} | 7585 code_flags_(code_flags) {} |
7586 | 7586 |
7587 bool IsMatch(Object* other) V8_OVERRIDE { | 7587 bool IsMatch(Object* other) OVERRIDE { |
7588 MapHandleList other_maps(kDefaultListAllocationSize); | 7588 MapHandleList other_maps(kDefaultListAllocationSize); |
7589 int other_flags; | 7589 int other_flags; |
7590 FromObject(other, &other_flags, &other_maps); | 7590 FromObject(other, &other_flags, &other_maps); |
7591 if (code_flags_ != other_flags) return false; | 7591 if (code_flags_ != other_flags) return false; |
7592 if (maps_->length() != other_maps.length()) return false; | 7592 if (maps_->length() != other_maps.length()) return false; |
7593 // Compare just the hashes first because it's faster. | 7593 // Compare just the hashes first because it's faster. |
7594 int this_hash = MapsHashHelper(maps_, code_flags_); | 7594 int this_hash = MapsHashHelper(maps_, code_flags_); |
7595 int other_hash = MapsHashHelper(&other_maps, other_flags); | 7595 int other_hash = MapsHashHelper(&other_maps, other_flags); |
7596 if (this_hash != other_hash) return false; | 7596 if (this_hash != other_hash) return false; |
7597 | 7597 |
(...skipping 14 matching lines...) Expand all Loading... |
7612 } | 7612 } |
7613 | 7613 |
7614 static uint32_t MapsHashHelper(MapHandleList* maps, int code_flags) { | 7614 static uint32_t MapsHashHelper(MapHandleList* maps, int code_flags) { |
7615 uint32_t hash = code_flags; | 7615 uint32_t hash = code_flags; |
7616 for (int i = 0; i < maps->length(); ++i) { | 7616 for (int i = 0; i < maps->length(); ++i) { |
7617 hash ^= maps->at(i)->Hash(); | 7617 hash ^= maps->at(i)->Hash(); |
7618 } | 7618 } |
7619 return hash; | 7619 return hash; |
7620 } | 7620 } |
7621 | 7621 |
7622 uint32_t Hash() V8_OVERRIDE { | 7622 uint32_t Hash() OVERRIDE { |
7623 return MapsHashHelper(maps_, code_flags_); | 7623 return MapsHashHelper(maps_, code_flags_); |
7624 } | 7624 } |
7625 | 7625 |
7626 uint32_t HashForObject(Object* obj) V8_OVERRIDE { | 7626 uint32_t HashForObject(Object* obj) OVERRIDE { |
7627 MapHandleList other_maps(kDefaultListAllocationSize); | 7627 MapHandleList other_maps(kDefaultListAllocationSize); |
7628 int other_flags; | 7628 int other_flags; |
7629 FromObject(obj, &other_flags, &other_maps); | 7629 FromObject(obj, &other_flags, &other_maps); |
7630 return MapsHashHelper(&other_maps, other_flags); | 7630 return MapsHashHelper(&other_maps, other_flags); |
7631 } | 7631 } |
7632 | 7632 |
7633 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 7633 MUST_USE_RESULT Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
7634 // The maps in |maps_| must be copied to a newly allocated FixedArray, | 7634 // The maps in |maps_| must be copied to a newly allocated FixedArray, |
7635 // both because the referenced MapList is short-lived, and because C++ | 7635 // both because the referenced MapList is short-lived, and because C++ |
7636 // objects can't be stored in the heap anyway. | 7636 // objects can't be stored in the heap anyway. |
7637 Handle<FixedArray> list = | 7637 Handle<FixedArray> list = |
7638 isolate->factory()->NewUninitializedFixedArray(maps_->length() + 1); | 7638 isolate->factory()->NewUninitializedFixedArray(maps_->length() + 1); |
7639 list->set(0, Smi::FromInt(code_flags_)); | 7639 list->set(0, Smi::FromInt(code_flags_)); |
7640 for (int i = 0; i < maps_->length(); ++i) { | 7640 for (int i = 0; i < maps_->length(); ++i) { |
7641 list->set(i + 1, *maps_->at(i)); | 7641 list->set(i + 1, *maps_->at(i)); |
7642 } | 7642 } |
7643 return list; | 7643 return list; |
(...skipping 5939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13583 public: | 13583 public: |
13584 StringSharedKey(Handle<String> source, | 13584 StringSharedKey(Handle<String> source, |
13585 Handle<SharedFunctionInfo> shared, | 13585 Handle<SharedFunctionInfo> shared, |
13586 StrictMode strict_mode, | 13586 StrictMode strict_mode, |
13587 int scope_position) | 13587 int scope_position) |
13588 : source_(source), | 13588 : source_(source), |
13589 shared_(shared), | 13589 shared_(shared), |
13590 strict_mode_(strict_mode), | 13590 strict_mode_(strict_mode), |
13591 scope_position_(scope_position) { } | 13591 scope_position_(scope_position) { } |
13592 | 13592 |
13593 bool IsMatch(Object* other) V8_OVERRIDE { | 13593 bool IsMatch(Object* other) OVERRIDE { |
13594 DisallowHeapAllocation no_allocation; | 13594 DisallowHeapAllocation no_allocation; |
13595 if (!other->IsFixedArray()) return false; | 13595 if (!other->IsFixedArray()) return false; |
13596 FixedArray* other_array = FixedArray::cast(other); | 13596 FixedArray* other_array = FixedArray::cast(other); |
13597 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); | 13597 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); |
13598 if (shared != *shared_) return false; | 13598 if (shared != *shared_) return false; |
13599 int strict_unchecked = Smi::cast(other_array->get(2))->value(); | 13599 int strict_unchecked = Smi::cast(other_array->get(2))->value(); |
13600 DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT); | 13600 DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT); |
13601 StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked); | 13601 StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked); |
13602 if (strict_mode != strict_mode_) return false; | 13602 if (strict_mode != strict_mode_) return false; |
13603 int scope_position = Smi::cast(other_array->get(3))->value(); | 13603 int scope_position = Smi::cast(other_array->get(3))->value(); |
(...skipping 14 matching lines...) Expand all Loading... |
13618 // We do this to ensure that the cache entries can survive garbage | 13618 // We do this to ensure that the cache entries can survive garbage |
13619 // collection. | 13619 // collection. |
13620 Script* script(Script::cast(shared->script())); | 13620 Script* script(Script::cast(shared->script())); |
13621 hash ^= String::cast(script->source())->Hash(); | 13621 hash ^= String::cast(script->source())->Hash(); |
13622 if (strict_mode == STRICT) hash ^= 0x8000; | 13622 if (strict_mode == STRICT) hash ^= 0x8000; |
13623 hash += scope_position; | 13623 hash += scope_position; |
13624 } | 13624 } |
13625 return hash; | 13625 return hash; |
13626 } | 13626 } |
13627 | 13627 |
13628 uint32_t Hash() V8_OVERRIDE { | 13628 uint32_t Hash() OVERRIDE { |
13629 return StringSharedHashHelper(*source_, *shared_, strict_mode_, | 13629 return StringSharedHashHelper(*source_, *shared_, strict_mode_, |
13630 scope_position_); | 13630 scope_position_); |
13631 } | 13631 } |
13632 | 13632 |
13633 uint32_t HashForObject(Object* obj) V8_OVERRIDE { | 13633 uint32_t HashForObject(Object* obj) OVERRIDE { |
13634 DisallowHeapAllocation no_allocation; | 13634 DisallowHeapAllocation no_allocation; |
13635 FixedArray* other_array = FixedArray::cast(obj); | 13635 FixedArray* other_array = FixedArray::cast(obj); |
13636 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); | 13636 SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0)); |
13637 String* source = String::cast(other_array->get(1)); | 13637 String* source = String::cast(other_array->get(1)); |
13638 int strict_unchecked = Smi::cast(other_array->get(2))->value(); | 13638 int strict_unchecked = Smi::cast(other_array->get(2))->value(); |
13639 DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT); | 13639 DCHECK(strict_unchecked == SLOPPY || strict_unchecked == STRICT); |
13640 StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked); | 13640 StrictMode strict_mode = static_cast<StrictMode>(strict_unchecked); |
13641 int scope_position = Smi::cast(other_array->get(3))->value(); | 13641 int scope_position = Smi::cast(other_array->get(3))->value(); |
13642 return StringSharedHashHelper( | 13642 return StringSharedHashHelper( |
13643 source, shared, strict_mode, scope_position); | 13643 source, shared, strict_mode, scope_position); |
13644 } | 13644 } |
13645 | 13645 |
13646 | 13646 |
13647 Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 13647 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
13648 Handle<FixedArray> array = isolate->factory()->NewFixedArray(4); | 13648 Handle<FixedArray> array = isolate->factory()->NewFixedArray(4); |
13649 array->set(0, *shared_); | 13649 array->set(0, *shared_); |
13650 array->set(1, *source_); | 13650 array->set(1, *source_); |
13651 array->set(2, Smi::FromInt(strict_mode_)); | 13651 array->set(2, Smi::FromInt(strict_mode_)); |
13652 array->set(3, Smi::FromInt(scope_position_)); | 13652 array->set(3, Smi::FromInt(scope_position_)); |
13653 return array; | 13653 return array; |
13654 } | 13654 } |
13655 | 13655 |
13656 private: | 13656 private: |
13657 Handle<String> source_; | 13657 Handle<String> source_; |
13658 Handle<SharedFunctionInfo> shared_; | 13658 Handle<SharedFunctionInfo> shared_; |
13659 StrictMode strict_mode_; | 13659 StrictMode strict_mode_; |
13660 int scope_position_; | 13660 int scope_position_; |
13661 }; | 13661 }; |
13662 | 13662 |
13663 | 13663 |
13664 // RegExpKey carries the source and flags of a regular expression as key. | 13664 // RegExpKey carries the source and flags of a regular expression as key. |
13665 class RegExpKey : public HashTableKey { | 13665 class RegExpKey : public HashTableKey { |
13666 public: | 13666 public: |
13667 RegExpKey(Handle<String> string, JSRegExp::Flags flags) | 13667 RegExpKey(Handle<String> string, JSRegExp::Flags flags) |
13668 : string_(string), | 13668 : string_(string), |
13669 flags_(Smi::FromInt(flags.value())) { } | 13669 flags_(Smi::FromInt(flags.value())) { } |
13670 | 13670 |
13671 // Rather than storing the key in the hash table, a pointer to the | 13671 // Rather than storing the key in the hash table, a pointer to the |
13672 // stored value is stored where the key should be. IsMatch then | 13672 // stored value is stored where the key should be. IsMatch then |
13673 // compares the search key to the found object, rather than comparing | 13673 // compares the search key to the found object, rather than comparing |
13674 // a key to a key. | 13674 // a key to a key. |
13675 bool IsMatch(Object* obj) V8_OVERRIDE { | 13675 bool IsMatch(Object* obj) OVERRIDE { |
13676 FixedArray* val = FixedArray::cast(obj); | 13676 FixedArray* val = FixedArray::cast(obj); |
13677 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) | 13677 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) |
13678 && (flags_ == val->get(JSRegExp::kFlagsIndex)); | 13678 && (flags_ == val->get(JSRegExp::kFlagsIndex)); |
13679 } | 13679 } |
13680 | 13680 |
13681 uint32_t Hash() V8_OVERRIDE { return RegExpHash(*string_, flags_); } | 13681 uint32_t Hash() OVERRIDE { return RegExpHash(*string_, flags_); } |
13682 | 13682 |
13683 Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 13683 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
13684 // Plain hash maps, which is where regexp keys are used, don't | 13684 // Plain hash maps, which is where regexp keys are used, don't |
13685 // use this function. | 13685 // use this function. |
13686 UNREACHABLE(); | 13686 UNREACHABLE(); |
13687 return MaybeHandle<Object>().ToHandleChecked(); | 13687 return MaybeHandle<Object>().ToHandleChecked(); |
13688 } | 13688 } |
13689 | 13689 |
13690 uint32_t HashForObject(Object* obj) V8_OVERRIDE { | 13690 uint32_t HashForObject(Object* obj) OVERRIDE { |
13691 FixedArray* val = FixedArray::cast(obj); | 13691 FixedArray* val = FixedArray::cast(obj); |
13692 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), | 13692 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), |
13693 Smi::cast(val->get(JSRegExp::kFlagsIndex))); | 13693 Smi::cast(val->get(JSRegExp::kFlagsIndex))); |
13694 } | 13694 } |
13695 | 13695 |
13696 static uint32_t RegExpHash(String* string, Smi* flags) { | 13696 static uint32_t RegExpHash(String* string, Smi* flags) { |
13697 return string->Hash() + flags->value(); | 13697 return string->Hash() + flags->value(); |
13698 } | 13698 } |
13699 | 13699 |
13700 Handle<String> string_; | 13700 Handle<String> string_; |
(...skipping 25 matching lines...) Expand all Loading... |
13726 return String::cast(string)->IsOneByteEqualTo(chars); | 13726 return String::cast(string)->IsOneByteEqualTo(chars); |
13727 } | 13727 } |
13728 | 13728 |
13729 | 13729 |
13730 // InternalizedStringKey carries a string/internalized-string object as key. | 13730 // InternalizedStringKey carries a string/internalized-string object as key. |
13731 class InternalizedStringKey : public HashTableKey { | 13731 class InternalizedStringKey : public HashTableKey { |
13732 public: | 13732 public: |
13733 explicit InternalizedStringKey(Handle<String> string) | 13733 explicit InternalizedStringKey(Handle<String> string) |
13734 : string_(string) { } | 13734 : string_(string) { } |
13735 | 13735 |
13736 virtual bool IsMatch(Object* string) V8_OVERRIDE { | 13736 virtual bool IsMatch(Object* string) OVERRIDE { |
13737 return String::cast(string)->Equals(*string_); | 13737 return String::cast(string)->Equals(*string_); |
13738 } | 13738 } |
13739 | 13739 |
13740 virtual uint32_t Hash() V8_OVERRIDE { return string_->Hash(); } | 13740 virtual uint32_t Hash() OVERRIDE { return string_->Hash(); } |
13741 | 13741 |
13742 virtual uint32_t HashForObject(Object* other) V8_OVERRIDE { | 13742 virtual uint32_t HashForObject(Object* other) OVERRIDE { |
13743 return String::cast(other)->Hash(); | 13743 return String::cast(other)->Hash(); |
13744 } | 13744 } |
13745 | 13745 |
13746 virtual Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 13746 virtual Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
13747 // Internalize the string if possible. | 13747 // Internalize the string if possible. |
13748 MaybeHandle<Map> maybe_map = | 13748 MaybeHandle<Map> maybe_map = |
13749 isolate->factory()->InternalizedStringMapForString(string_); | 13749 isolate->factory()->InternalizedStringMapForString(string_); |
13750 Handle<Map> map; | 13750 Handle<Map> map; |
13751 if (maybe_map.ToHandle(&map)) { | 13751 if (maybe_map.ToHandle(&map)) { |
13752 string_->set_map_no_write_barrier(*map); | 13752 string_->set_map_no_write_barrier(*map); |
13753 DCHECK(string_->IsInternalizedString()); | 13753 DCHECK(string_->IsInternalizedString()); |
13754 return string_; | 13754 return string_; |
13755 } | 13755 } |
13756 // Otherwise allocate a new internalized string. | 13756 // Otherwise allocate a new internalized string. |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14653 // version of the string hashing algorithm above. One reason could be | 14653 // version of the string hashing algorithm above. One reason could be |
14654 // that we were passed two digits as characters, since the hash | 14654 // that we were passed two digits as characters, since the hash |
14655 // algorithm is different in that case. | 14655 // algorithm is different in that case. |
14656 uint16_t chars[2] = {c1, c2}; | 14656 uint16_t chars[2] = {c1, c2}; |
14657 uint32_t check_hash = StringHasher::HashSequentialString(chars, 2, seed); | 14657 uint32_t check_hash = StringHasher::HashSequentialString(chars, 2, seed); |
14658 hash = (hash << String::kHashShift) | String::kIsNotArrayIndexMask; | 14658 hash = (hash << String::kHashShift) | String::kIsNotArrayIndexMask; |
14659 DCHECK_EQ(static_cast<int32_t>(hash), static_cast<int32_t>(check_hash)); | 14659 DCHECK_EQ(static_cast<int32_t>(hash), static_cast<int32_t>(check_hash)); |
14660 #endif | 14660 #endif |
14661 } | 14661 } |
14662 | 14662 |
14663 bool IsMatch(Object* o) V8_OVERRIDE { | 14663 bool IsMatch(Object* o) OVERRIDE { |
14664 if (!o->IsString()) return false; | 14664 if (!o->IsString()) return false; |
14665 String* other = String::cast(o); | 14665 String* other = String::cast(o); |
14666 if (other->length() != 2) return false; | 14666 if (other->length() != 2) return false; |
14667 if (other->Get(0) != c1_) return false; | 14667 if (other->Get(0) != c1_) return false; |
14668 return other->Get(1) == c2_; | 14668 return other->Get(1) == c2_; |
14669 } | 14669 } |
14670 | 14670 |
14671 uint32_t Hash() V8_OVERRIDE { return hash_; } | 14671 uint32_t Hash() OVERRIDE { return hash_; } |
14672 uint32_t HashForObject(Object* key) V8_OVERRIDE { | 14672 uint32_t HashForObject(Object* key) OVERRIDE { |
14673 if (!key->IsString()) return 0; | 14673 if (!key->IsString()) return 0; |
14674 return String::cast(key)->Hash(); | 14674 return String::cast(key)->Hash(); |
14675 } | 14675 } |
14676 | 14676 |
14677 Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { | 14677 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { |
14678 // The TwoCharHashTableKey is only used for looking in the string | 14678 // The TwoCharHashTableKey is only used for looking in the string |
14679 // table, not for adding to it. | 14679 // table, not for adding to it. |
14680 UNREACHABLE(); | 14680 UNREACHABLE(); |
14681 return MaybeHandle<Object>().ToHandleChecked(); | 14681 return MaybeHandle<Object>().ToHandleChecked(); |
14682 } | 14682 } |
14683 | 14683 |
14684 private: | 14684 private: |
14685 uint16_t c1_; | 14685 uint16_t c1_; |
14686 uint16_t c2_; | 14686 uint16_t c2_; |
14687 uint32_t hash_; | 14687 uint32_t hash_; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14865 } | 14865 } |
14866 return; | 14866 return; |
14867 } | 14867 } |
14868 | 14868 |
14869 | 14869 |
14870 // StringsKey used for HashTable where key is array of internalized strings. | 14870 // StringsKey used for HashTable where key is array of internalized strings. |
14871 class StringsKey : public HashTableKey { | 14871 class StringsKey : public HashTableKey { |
14872 public: | 14872 public: |
14873 explicit StringsKey(Handle<FixedArray> strings) : strings_(strings) { } | 14873 explicit StringsKey(Handle<FixedArray> strings) : strings_(strings) { } |
14874 | 14874 |
14875 bool IsMatch(Object* strings) V8_OVERRIDE { | 14875 bool IsMatch(Object* strings) OVERRIDE { |
14876 FixedArray* o = FixedArray::cast(strings); | 14876 FixedArray* o = FixedArray::cast(strings); |
14877 int len = strings_->length(); | 14877 int len = strings_->length(); |
14878 if (o->length() != len) return false; | 14878 if (o->length() != len) return false; |
14879 for (int i = 0; i < len; i++) { | 14879 for (int i = 0; i < len; i++) { |
14880 if (o->get(i) != strings_->get(i)) return false; | 14880 if (o->get(i) != strings_->get(i)) return false; |
14881 } | 14881 } |
14882 return true; | 14882 return true; |
14883 } | 14883 } |
14884 | 14884 |
14885 uint32_t Hash() V8_OVERRIDE { return HashForObject(*strings_); } | 14885 uint32_t Hash() OVERRIDE { return HashForObject(*strings_); } |
14886 | 14886 |
14887 uint32_t HashForObject(Object* obj) V8_OVERRIDE { | 14887 uint32_t HashForObject(Object* obj) OVERRIDE { |
14888 FixedArray* strings = FixedArray::cast(obj); | 14888 FixedArray* strings = FixedArray::cast(obj); |
14889 int len = strings->length(); | 14889 int len = strings->length(); |
14890 uint32_t hash = 0; | 14890 uint32_t hash = 0; |
14891 for (int i = 0; i < len; i++) { | 14891 for (int i = 0; i < len; i++) { |
14892 hash ^= String::cast(strings->get(i))->Hash(); | 14892 hash ^= String::cast(strings->get(i))->Hash(); |
14893 } | 14893 } |
14894 return hash; | 14894 return hash; |
14895 } | 14895 } |
14896 | 14896 |
14897 Handle<Object> AsHandle(Isolate* isolate) V8_OVERRIDE { return strings_; } | 14897 Handle<Object> AsHandle(Isolate* isolate) OVERRIDE { return strings_; } |
14898 | 14898 |
14899 private: | 14899 private: |
14900 Handle<FixedArray> strings_; | 14900 Handle<FixedArray> strings_; |
14901 }; | 14901 }; |
14902 | 14902 |
14903 | 14903 |
14904 Object* MapCache::Lookup(FixedArray* array) { | 14904 Object* MapCache::Lookup(FixedArray* array) { |
14905 DisallowHeapAllocation no_alloc; | 14905 DisallowHeapAllocation no_alloc; |
14906 StringsKey key(handle(array)); | 14906 StringsKey key(handle(array)); |
14907 int entry = FindEntry(&key); | 14907 int entry = FindEntry(&key); |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16420 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16420 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16421 static const char* error_messages_[] = { | 16421 static const char* error_messages_[] = { |
16422 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16422 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16423 }; | 16423 }; |
16424 #undef ERROR_MESSAGES_TEXTS | 16424 #undef ERROR_MESSAGES_TEXTS |
16425 return error_messages_[reason]; | 16425 return error_messages_[reason]; |
16426 } | 16426 } |
16427 | 16427 |
16428 | 16428 |
16429 } } // namespace v8::internal | 16429 } } // namespace v8::internal |
OLD | NEW |