OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 return static_cast<const uc16*>(start_)[index]; | 468 return static_cast<const uc16*>(start_)[index]; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 Handle<Object> HashTableKey::AsHandle(Isolate* isolate) { | 473 Handle<Object> HashTableKey::AsHandle(Isolate* isolate) { |
474 CALL_HEAP_FUNCTION(isolate, AsObject(isolate->heap()), Object); | 474 CALL_HEAP_FUNCTION(isolate, AsObject(isolate->heap()), Object); |
475 } | 475 } |
476 | 476 |
477 | 477 |
| 478 Handle<Object> StringTableShape::AsHandle(Isolate* isolate, HashTableKey* key) { |
| 479 return key->AsHandle(isolate); |
| 480 } |
| 481 |
| 482 |
| 483 Handle<Object> MapCacheShape::AsHandle(Isolate* isolate, HashTableKey* key) { |
| 484 return key->AsHandle(isolate); |
| 485 } |
| 486 |
| 487 |
| 488 Handle<Object> CompilationCacheShape::AsHandle(Isolate* isolate, |
| 489 HashTableKey* key) { |
| 490 return key->AsHandle(isolate); |
| 491 } |
| 492 |
| 493 |
| 494 Handle<Object> CodeCacheHashTableShape::AsHandle(Isolate* isolate, |
| 495 HashTableKey* key) { |
| 496 return key->AsHandle(isolate); |
| 497 } |
| 498 |
478 template <typename Char> | 499 template <typename Char> |
479 class SequentialStringKey : public HashTableKey { | 500 class SequentialStringKey : public HashTableKey { |
480 public: | 501 public: |
481 explicit SequentialStringKey(Vector<const Char> string, uint32_t seed) | 502 explicit SequentialStringKey(Vector<const Char> string, uint32_t seed) |
482 : string_(string), hash_field_(0), seed_(seed) { } | 503 : string_(string), hash_field_(0), seed_(seed) { } |
483 | 504 |
484 virtual uint32_t Hash() V8_OVERRIDE { | 505 virtual uint32_t Hash() V8_OVERRIDE { |
485 hash_field_ = StringHasher::HashSequentialString<Char>(string_.start(), | 506 hash_field_ = StringHasher::HashSequentialString<Char>(string_.start(), |
486 string_.length(), | 507 string_.length(), |
487 seed_); | 508 seed_); |
(...skipping 6133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6621 return ComputeIntegerHash(key, 0); | 6642 return ComputeIntegerHash(key, 0); |
6622 } | 6643 } |
6623 | 6644 |
6624 | 6645 |
6625 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, | 6646 uint32_t UnseededNumberDictionaryShape::HashForObject(uint32_t key, |
6626 Object* other) { | 6647 Object* other) { |
6627 ASSERT(other->IsNumber()); | 6648 ASSERT(other->IsNumber()); |
6628 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); | 6649 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
6629 } | 6650 } |
6630 | 6651 |
| 6652 |
6631 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 6653 uint32_t SeededNumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { |
6632 return ComputeIntegerHash(key, seed); | 6654 return ComputeIntegerHash(key, seed); |
6633 } | 6655 } |
6634 | 6656 |
| 6657 |
6635 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, | 6658 uint32_t SeededNumberDictionaryShape::SeededHashForObject(uint32_t key, |
6636 uint32_t seed, | 6659 uint32_t seed, |
6637 Object* other) { | 6660 Object* other) { |
6638 ASSERT(other->IsNumber()); | 6661 ASSERT(other->IsNumber()); |
6639 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 6662 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
6640 } | 6663 } |
6641 | 6664 |
6642 MaybeObject* NumberDictionaryShape::AsObject(Heap* heap, uint32_t key) { | |
6643 return heap->NumberFromUint32(key); | |
6644 } | |
6645 | 6665 |
6646 Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) { | 6666 Handle<Object> NumberDictionaryShape::AsHandle(Isolate* isolate, uint32_t key) { |
6647 return isolate->factory()->NewNumberFromUint(key); | 6667 return isolate->factory()->NewNumberFromUint(key); |
6648 } | 6668 } |
6649 | 6669 |
6650 | 6670 |
6651 bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) { | 6671 bool NameDictionaryShape::IsMatch(Handle<Name> key, Object* other) { |
6652 // We know that all entries in a hash table had their hash keys created. | 6672 // We know that all entries in a hash table had their hash keys created. |
6653 // Use that knowledge to have fast failure. | 6673 // Use that knowledge to have fast failure. |
6654 if (key->Hash() != Name::cast(other)->Hash()) return false; | 6674 if (key->Hash() != Name::cast(other)->Hash()) return false; |
6655 return key->Equals(Name::cast(other)); | 6675 return key->Equals(Name::cast(other)); |
6656 } | 6676 } |
6657 | 6677 |
6658 | 6678 |
6659 uint32_t NameDictionaryShape::Hash(Handle<Name> key) { | 6679 uint32_t NameDictionaryShape::Hash(Handle<Name> key) { |
6660 return key->Hash(); | 6680 return key->Hash(); |
6661 } | 6681 } |
6662 | 6682 |
6663 | 6683 |
6664 uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) { | 6684 uint32_t NameDictionaryShape::HashForObject(Handle<Name> key, Object* other) { |
6665 return Name::cast(other)->Hash(); | 6685 return Name::cast(other)->Hash(); |
6666 } | 6686 } |
6667 | 6687 |
6668 | 6688 |
6669 MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Handle<Name> key) { | |
6670 ASSERT(key->IsUniqueName()); | |
6671 return *key; | |
6672 } | |
6673 | |
6674 | |
6675 Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, | 6689 Handle<Object> NameDictionaryShape::AsHandle(Isolate* isolate, |
6676 Handle<Name> key) { | 6690 Handle<Name> key) { |
6677 ASSERT(key->IsUniqueName()); | 6691 ASSERT(key->IsUniqueName()); |
6678 return key; | 6692 return key; |
6679 } | 6693 } |
6680 | 6694 |
6681 | 6695 |
6682 void NameDictionary::DoGenerateNewEnumerationIndices( | 6696 void NameDictionary::DoGenerateNewEnumerationIndices( |
6683 Handle<NameDictionary> dictionary) { | 6697 Handle<NameDictionary> dictionary) { |
6684 DerivedDictionary::GenerateNewEnumerationIndices(dictionary); | 6698 DerivedDictionary::GenerateNewEnumerationIndices(dictionary); |
6685 } | 6699 } |
6686 | 6700 |
6687 | 6701 |
6688 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { | 6702 bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) { |
6689 return key->SameValue(other); | 6703 return key->SameValue(other); |
6690 } | 6704 } |
6691 | 6705 |
6692 | 6706 |
6693 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) { | 6707 uint32_t ObjectHashTableShape::Hash(Handle<Object> key) { |
6694 return Smi::cast(key->GetHash())->value(); | 6708 return Smi::cast(key->GetHash())->value(); |
6695 } | 6709 } |
6696 | 6710 |
6697 | 6711 |
6698 uint32_t ObjectHashTableShape::HashForObject(Handle<Object> key, | 6712 uint32_t ObjectHashTableShape::HashForObject(Handle<Object> key, |
6699 Object* other) { | 6713 Object* other) { |
6700 return Smi::cast(other->GetHash())->value(); | 6714 return Smi::cast(other->GetHash())->value(); |
6701 } | 6715 } |
6702 | 6716 |
6703 | 6717 |
6704 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Handle<Object> key) { | |
6705 return *key; | |
6706 } | |
6707 | |
6708 | |
6709 Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate, | 6718 Handle<Object> ObjectHashTableShape::AsHandle(Isolate* isolate, |
6710 Handle<Object> key) { | 6719 Handle<Object> key) { |
6711 return key; | 6720 return key; |
6712 } | 6721 } |
6713 | 6722 |
6714 | 6723 |
6715 Handle<ObjectHashTable> ObjectHashTable::Shrink( | 6724 Handle<ObjectHashTable> ObjectHashTable::Shrink( |
6716 Handle<ObjectHashTable> table, Handle<Object> key) { | 6725 Handle<ObjectHashTable> table, Handle<Object> key) { |
6717 return DerivedHashTable::Shrink(table, key); | 6726 return DerivedHashTable::Shrink(table, key); |
6718 } | 6727 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7034 #undef READ_SHORT_FIELD | 7043 #undef READ_SHORT_FIELD |
7035 #undef WRITE_SHORT_FIELD | 7044 #undef WRITE_SHORT_FIELD |
7036 #undef READ_BYTE_FIELD | 7045 #undef READ_BYTE_FIELD |
7037 #undef WRITE_BYTE_FIELD | 7046 #undef WRITE_BYTE_FIELD |
7038 #undef NOBARRIER_READ_BYTE_FIELD | 7047 #undef NOBARRIER_READ_BYTE_FIELD |
7039 #undef NOBARRIER_WRITE_BYTE_FIELD | 7048 #undef NOBARRIER_WRITE_BYTE_FIELD |
7040 | 7049 |
7041 } } // namespace v8::internal | 7050 } } // namespace v8::internal |
7042 | 7051 |
7043 #endif // V8_OBJECTS_INL_H_ | 7052 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |