OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 6219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6230 | 6230 |
6231 uint32_t Hash() { return NameFlagsHashHelper(name_, flags_); } | 6231 uint32_t Hash() { return NameFlagsHashHelper(name_, flags_); } |
6232 | 6232 |
6233 uint32_t HashForObject(Object* obj) { | 6233 uint32_t HashForObject(Object* obj) { |
6234 FixedArray* pair = FixedArray::cast(obj); | 6234 FixedArray* pair = FixedArray::cast(obj); |
6235 Name* name = Name::cast(pair->get(0)); | 6235 Name* name = Name::cast(pair->get(0)); |
6236 Code* code = Code::cast(pair->get(1)); | 6236 Code* code = Code::cast(pair->get(1)); |
6237 return NameFlagsHashHelper(name, code->flags()); | 6237 return NameFlagsHashHelper(name, code->flags()); |
6238 } | 6238 } |
6239 | 6239 |
6240 MUST_USE_RESULT MaybeObject* AsObject() { | 6240 MUST_USE_RESULT MaybeObject* AsObject(Heap* heap) { |
6241 ASSERT(code_ != NULL); | 6241 ASSERT(code_ != NULL); |
6242 Object* obj; | 6242 Object* obj; |
6243 { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2); | 6243 { MaybeObject* maybe_obj = heap->AllocateFixedArray(2); |
6244 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6244 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6245 } | 6245 } |
6246 FixedArray* pair = FixedArray::cast(obj); | 6246 FixedArray* pair = FixedArray::cast(obj); |
6247 pair->set(0, name_); | 6247 pair->set(0, name_); |
6248 pair->set(1, code_); | 6248 pair->set(1, code_); |
6249 return pair; | 6249 return pair; |
6250 } | 6250 } |
6251 | 6251 |
6252 private: | 6252 private: |
6253 Name* name_; | 6253 Name* name_; |
(...skipping 16 matching lines...) Expand all Loading... |
6270 Object* obj; | 6270 Object* obj; |
6271 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); | 6271 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
6272 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6272 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6273 } | 6273 } |
6274 | 6274 |
6275 // Don't use |this|, as the table might have grown. | 6275 // Don't use |this|, as the table might have grown. |
6276 CodeCacheHashTable* cache = reinterpret_cast<CodeCacheHashTable*>(obj); | 6276 CodeCacheHashTable* cache = reinterpret_cast<CodeCacheHashTable*>(obj); |
6277 | 6277 |
6278 int entry = cache->FindInsertionEntry(key.Hash()); | 6278 int entry = cache->FindInsertionEntry(key.Hash()); |
6279 Object* k; | 6279 Object* k; |
6280 { MaybeObject* maybe_k = key.AsObject(); | 6280 { MaybeObject* maybe_k = key.AsObject(GetHeap()); |
6281 if (!maybe_k->ToObject(&k)) return maybe_k; | 6281 if (!maybe_k->ToObject(&k)) return maybe_k; |
6282 } | 6282 } |
6283 | 6283 |
6284 cache->set(EntryToIndex(entry), k); | 6284 cache->set(EntryToIndex(entry), k); |
6285 cache->set(EntryToIndex(entry) + 1, code); | 6285 cache->set(EntryToIndex(entry) + 1, code); |
6286 cache->ElementAdded(); | 6286 cache->ElementAdded(); |
6287 return cache; | 6287 return cache; |
6288 } | 6288 } |
6289 | 6289 |
6290 | 6290 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6403 return MapsHashHelper(maps_, code_flags_); | 6403 return MapsHashHelper(maps_, code_flags_); |
6404 } | 6404 } |
6405 | 6405 |
6406 uint32_t HashForObject(Object* obj) { | 6406 uint32_t HashForObject(Object* obj) { |
6407 MapHandleList other_maps(kDefaultListAllocationSize); | 6407 MapHandleList other_maps(kDefaultListAllocationSize); |
6408 int other_flags; | 6408 int other_flags; |
6409 FromObject(obj, &other_flags, &other_maps); | 6409 FromObject(obj, &other_flags, &other_maps); |
6410 return MapsHashHelper(&other_maps, other_flags); | 6410 return MapsHashHelper(&other_maps, other_flags); |
6411 } | 6411 } |
6412 | 6412 |
6413 MUST_USE_RESULT MaybeObject* AsObject() { | 6413 MUST_USE_RESULT MaybeObject* AsObject(Heap* heap) { |
6414 Object* obj; | 6414 Object* obj; |
6415 // The maps in |maps_| must be copied to a newly allocated FixedArray, | 6415 // The maps in |maps_| must be copied to a newly allocated FixedArray, |
6416 // both because the referenced MapList is short-lived, and because C++ | 6416 // both because the referenced MapList is short-lived, and because C++ |
6417 // objects can't be stored in the heap anyway. | 6417 // objects can't be stored in the heap anyway. |
6418 { MaybeObject* maybe_obj = | 6418 { MaybeObject* maybe_obj = |
6419 HEAP->AllocateUninitializedFixedArray(maps_->length() + 1); | 6419 heap->AllocateUninitializedFixedArray(maps_->length() + 1); |
6420 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6420 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6421 } | 6421 } |
6422 FixedArray* list = FixedArray::cast(obj); | 6422 FixedArray* list = FixedArray::cast(obj); |
6423 list->set(0, Smi::FromInt(code_flags_)); | 6423 list->set(0, Smi::FromInt(code_flags_)); |
6424 for (int i = 0; i < maps_->length(); ++i) { | 6424 for (int i = 0; i < maps_->length(); ++i) { |
6425 list->set(i + 1, *maps_->at(i)); | 6425 list->set(i + 1, *maps_->at(i)); |
6426 } | 6426 } |
6427 return list; | 6427 return list; |
6428 } | 6428 } |
6429 | 6429 |
(...skipping 29 matching lines...) Expand all Loading... |
6459 int code_flags, | 6459 int code_flags, |
6460 Code* code) { | 6460 Code* code) { |
6461 PolymorphicCodeCacheHashTableKey key(maps, code_flags); | 6461 PolymorphicCodeCacheHashTableKey key(maps, code_flags); |
6462 Object* obj; | 6462 Object* obj; |
6463 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); | 6463 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
6464 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6464 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6465 } | 6465 } |
6466 PolymorphicCodeCacheHashTable* cache = | 6466 PolymorphicCodeCacheHashTable* cache = |
6467 reinterpret_cast<PolymorphicCodeCacheHashTable*>(obj); | 6467 reinterpret_cast<PolymorphicCodeCacheHashTable*>(obj); |
6468 int entry = cache->FindInsertionEntry(key.Hash()); | 6468 int entry = cache->FindInsertionEntry(key.Hash()); |
6469 { MaybeObject* maybe_obj = key.AsObject(); | 6469 { MaybeObject* maybe_obj = key.AsObject(GetHeap()); |
6470 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6470 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6471 } | 6471 } |
6472 cache->set(EntryToIndex(entry), obj); | 6472 cache->set(EntryToIndex(entry), obj); |
6473 cache->set(EntryToIndex(entry) + 1, code); | 6473 cache->set(EntryToIndex(entry) + 1, code); |
6474 cache->ElementAdded(); | 6474 cache->ElementAdded(); |
6475 return cache; | 6475 return cache; |
6476 } | 6476 } |
6477 | 6477 |
6478 | 6478 |
6479 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { | 6479 MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) { |
(...skipping 5267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11747 if (hash_ != HashForObject(string)) { | 11747 if (hash_ != HashForObject(string)) { |
11748 return false; | 11748 return false; |
11749 } | 11749 } |
11750 return string_->Equals(String::cast(string)); | 11750 return string_->Equals(String::cast(string)); |
11751 } | 11751 } |
11752 | 11752 |
11753 uint32_t Hash() { return hash_; } | 11753 uint32_t Hash() { return hash_; } |
11754 | 11754 |
11755 uint32_t HashForObject(Object* other) { return String::cast(other)->Hash(); } | 11755 uint32_t HashForObject(Object* other) { return String::cast(other)->Hash(); } |
11756 | 11756 |
11757 Object* AsObject() { return string_; } | 11757 Object* AsObject(Heap* heap) { return string_; } |
11758 | 11758 |
11759 String* string_; | 11759 String* string_; |
11760 uint32_t hash_; | 11760 uint32_t hash_; |
11761 }; | 11761 }; |
11762 | 11762 |
11763 | 11763 |
11764 // StringSharedKeys are used as keys in the eval cache. | 11764 // StringSharedKeys are used as keys in the eval cache. |
11765 class StringSharedKey : public HashTableKey { | 11765 class StringSharedKey : public HashTableKey { |
11766 public: | 11766 public: |
11767 StringSharedKey(String* source, | 11767 StringSharedKey(String* source, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11822 int language_unchecked = Smi::cast(other_array->get(2))->value(); | 11822 int language_unchecked = Smi::cast(other_array->get(2))->value(); |
11823 ASSERT(language_unchecked == CLASSIC_MODE || | 11823 ASSERT(language_unchecked == CLASSIC_MODE || |
11824 language_unchecked == STRICT_MODE || | 11824 language_unchecked == STRICT_MODE || |
11825 language_unchecked == EXTENDED_MODE); | 11825 language_unchecked == EXTENDED_MODE); |
11826 LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); | 11826 LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked); |
11827 int scope_position = Smi::cast(other_array->get(3))->value(); | 11827 int scope_position = Smi::cast(other_array->get(3))->value(); |
11828 return StringSharedHashHelper( | 11828 return StringSharedHashHelper( |
11829 source, shared, language_mode, scope_position); | 11829 source, shared, language_mode, scope_position); |
11830 } | 11830 } |
11831 | 11831 |
11832 MUST_USE_RESULT MaybeObject* AsObject() { | 11832 MUST_USE_RESULT MaybeObject* AsObject(Heap* heap) { |
11833 Object* obj; | 11833 Object* obj; |
11834 { MaybeObject* maybe_obj = source_->GetHeap()->AllocateFixedArray(4); | 11834 { MaybeObject* maybe_obj = heap->AllocateFixedArray(4); |
11835 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 11835 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
11836 } | 11836 } |
11837 FixedArray* other_array = FixedArray::cast(obj); | 11837 FixedArray* other_array = FixedArray::cast(obj); |
11838 other_array->set(0, shared_); | 11838 other_array->set(0, shared_); |
11839 other_array->set(1, source_); | 11839 other_array->set(1, source_); |
11840 other_array->set(2, Smi::FromInt(language_mode_)); | 11840 other_array->set(2, Smi::FromInt(language_mode_)); |
11841 other_array->set(3, Smi::FromInt(scope_position_)); | 11841 other_array->set(3, Smi::FromInt(scope_position_)); |
11842 return other_array; | 11842 return other_array; |
11843 } | 11843 } |
11844 | 11844 |
(...skipping 17 matching lines...) Expand all Loading... |
11862 // compares the search key to the found object, rather than comparing | 11862 // compares the search key to the found object, rather than comparing |
11863 // a key to a key. | 11863 // a key to a key. |
11864 bool IsMatch(Object* obj) { | 11864 bool IsMatch(Object* obj) { |
11865 FixedArray* val = FixedArray::cast(obj); | 11865 FixedArray* val = FixedArray::cast(obj); |
11866 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) | 11866 return string_->Equals(String::cast(val->get(JSRegExp::kSourceIndex))) |
11867 && (flags_ == val->get(JSRegExp::kFlagsIndex)); | 11867 && (flags_ == val->get(JSRegExp::kFlagsIndex)); |
11868 } | 11868 } |
11869 | 11869 |
11870 uint32_t Hash() { return RegExpHash(string_, flags_); } | 11870 uint32_t Hash() { return RegExpHash(string_, flags_); } |
11871 | 11871 |
11872 Object* AsObject() { | 11872 Object* AsObject(Heap* heap) { |
11873 // Plain hash maps, which is where regexp keys are used, don't | 11873 // Plain hash maps, which is where regexp keys are used, don't |
11874 // use this function. | 11874 // use this function. |
11875 UNREACHABLE(); | 11875 UNREACHABLE(); |
11876 return NULL; | 11876 return NULL; |
11877 } | 11877 } |
11878 | 11878 |
11879 uint32_t HashForObject(Object* obj) { | 11879 uint32_t HashForObject(Object* obj) { |
11880 FixedArray* val = FixedArray::cast(obj); | 11880 FixedArray* val = FixedArray::cast(obj); |
11881 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), | 11881 return RegExpHash(String::cast(val->get(JSRegExp::kSourceIndex)), |
11882 Smi::cast(val->get(JSRegExp::kFlagsIndex))); | 11882 Smi::cast(val->get(JSRegExp::kFlagsIndex))); |
(...skipping 22 matching lines...) Expand all Loading... |
11905 hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_); | 11905 hash_field_ = StringHasher::ComputeUtf8Hash(string_, seed_, &chars_); |
11906 uint32_t result = hash_field_ >> String::kHashShift; | 11906 uint32_t result = hash_field_ >> String::kHashShift; |
11907 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. | 11907 ASSERT(result != 0); // Ensure that the hash value of 0 is never computed. |
11908 return result; | 11908 return result; |
11909 } | 11909 } |
11910 | 11910 |
11911 uint32_t HashForObject(Object* other) { | 11911 uint32_t HashForObject(Object* other) { |
11912 return String::cast(other)->Hash(); | 11912 return String::cast(other)->Hash(); |
11913 } | 11913 } |
11914 | 11914 |
11915 MaybeObject* AsObject() { | 11915 MaybeObject* AsObject(Heap* heap) { |
11916 if (hash_field_ == 0) Hash(); | 11916 if (hash_field_ == 0) Hash(); |
11917 return Isolate::Current()->heap()->AllocateInternalizedStringFromUtf8( | 11917 return heap->AllocateInternalizedStringFromUtf8(string_, |
11918 string_, chars_, hash_field_); | 11918 chars_, |
| 11919 hash_field_); |
11919 } | 11920 } |
11920 | 11921 |
11921 Vector<const char> string_; | 11922 Vector<const char> string_; |
11922 uint32_t hash_field_; | 11923 uint32_t hash_field_; |
11923 int chars_; // Caches the number of characters when computing the hash code. | 11924 int chars_; // Caches the number of characters when computing the hash code. |
11924 uint32_t seed_; | 11925 uint32_t seed_; |
11925 }; | 11926 }; |
11926 | 11927 |
11927 | 11928 |
11928 template <typename Char> | 11929 template <typename Char> |
(...skipping 26 matching lines...) Expand all Loading... |
11955 | 11956 |
11956 class OneByteStringKey : public SequentialStringKey<uint8_t> { | 11957 class OneByteStringKey : public SequentialStringKey<uint8_t> { |
11957 public: | 11958 public: |
11958 OneByteStringKey(Vector<const uint8_t> str, uint32_t seed) | 11959 OneByteStringKey(Vector<const uint8_t> str, uint32_t seed) |
11959 : SequentialStringKey<uint8_t>(str, seed) { } | 11960 : SequentialStringKey<uint8_t>(str, seed) { } |
11960 | 11961 |
11961 bool IsMatch(Object* string) { | 11962 bool IsMatch(Object* string) { |
11962 return String::cast(string)->IsOneByteEqualTo(string_); | 11963 return String::cast(string)->IsOneByteEqualTo(string_); |
11963 } | 11964 } |
11964 | 11965 |
11965 MaybeObject* AsObject() { | 11966 MaybeObject* AsObject(Heap* heap) { |
11966 if (hash_field_ == 0) Hash(); | 11967 if (hash_field_ == 0) Hash(); |
11967 return HEAP->AllocateOneByteInternalizedString(string_, hash_field_); | 11968 return heap->AllocateOneByteInternalizedString(string_, hash_field_); |
11968 } | 11969 } |
11969 }; | 11970 }; |
11970 | 11971 |
11971 | 11972 |
11972 class SubStringOneByteStringKey : public HashTableKey { | 11973 class SubStringOneByteStringKey : public HashTableKey { |
11973 public: | 11974 public: |
11974 explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string, | 11975 explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string, |
11975 int from, | 11976 int from, |
11976 int length) | 11977 int length) |
11977 : string_(string), from_(from), length_(length) { } | 11978 : string_(string), from_(from), length_(length) { } |
(...skipping 12 matching lines...) Expand all Loading... |
11990 | 11991 |
11991 uint32_t HashForObject(Object* other) { | 11992 uint32_t HashForObject(Object* other) { |
11992 return String::cast(other)->Hash(); | 11993 return String::cast(other)->Hash(); |
11993 } | 11994 } |
11994 | 11995 |
11995 bool IsMatch(Object* string) { | 11996 bool IsMatch(Object* string) { |
11996 Vector<const uint8_t> chars(string_->GetChars() + from_, length_); | 11997 Vector<const uint8_t> chars(string_->GetChars() + from_, length_); |
11997 return String::cast(string)->IsOneByteEqualTo(chars); | 11998 return String::cast(string)->IsOneByteEqualTo(chars); |
11998 } | 11999 } |
11999 | 12000 |
12000 MaybeObject* AsObject() { | 12001 MaybeObject* AsObject(Heap* heap) { |
12001 if (hash_field_ == 0) Hash(); | 12002 if (hash_field_ == 0) Hash(); |
12002 Vector<const uint8_t> chars(string_->GetChars() + from_, length_); | 12003 Vector<const uint8_t> chars(string_->GetChars() + from_, length_); |
12003 return HEAP->AllocateOneByteInternalizedString(chars, hash_field_); | 12004 return heap->AllocateOneByteInternalizedString(chars, hash_field_); |
12004 } | 12005 } |
12005 | 12006 |
12006 private: | 12007 private: |
12007 Handle<SeqOneByteString> string_; | 12008 Handle<SeqOneByteString> string_; |
12008 int from_; | 12009 int from_; |
12009 int length_; | 12010 int length_; |
12010 uint32_t hash_field_; | 12011 uint32_t hash_field_; |
12011 }; | 12012 }; |
12012 | 12013 |
12013 | 12014 |
12014 class TwoByteStringKey : public SequentialStringKey<uc16> { | 12015 class TwoByteStringKey : public SequentialStringKey<uc16> { |
12015 public: | 12016 public: |
12016 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed) | 12017 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed) |
12017 : SequentialStringKey<uc16>(str, seed) { } | 12018 : SequentialStringKey<uc16>(str, seed) { } |
12018 | 12019 |
12019 bool IsMatch(Object* string) { | 12020 bool IsMatch(Object* string) { |
12020 return String::cast(string)->IsTwoByteEqualTo(string_); | 12021 return String::cast(string)->IsTwoByteEqualTo(string_); |
12021 } | 12022 } |
12022 | 12023 |
12023 MaybeObject* AsObject() { | 12024 MaybeObject* AsObject(Heap* heap) { |
12024 if (hash_field_ == 0) Hash(); | 12025 if (hash_field_ == 0) Hash(); |
12025 return HEAP->AllocateTwoByteInternalizedString(string_, hash_field_); | 12026 return heap->AllocateTwoByteInternalizedString(string_, hash_field_); |
12026 } | 12027 } |
12027 }; | 12028 }; |
12028 | 12029 |
12029 | 12030 |
12030 // InternalizedStringKey carries a string/internalized-string object as key. | 12031 // InternalizedStringKey carries a string/internalized-string object as key. |
12031 class InternalizedStringKey : public HashTableKey { | 12032 class InternalizedStringKey : public HashTableKey { |
12032 public: | 12033 public: |
12033 explicit InternalizedStringKey(String* string) | 12034 explicit InternalizedStringKey(String* string) |
12034 : string_(string) { } | 12035 : string_(string) { } |
12035 | 12036 |
12036 bool IsMatch(Object* string) { | 12037 bool IsMatch(Object* string) { |
12037 return String::cast(string)->Equals(string_); | 12038 return String::cast(string)->Equals(string_); |
12038 } | 12039 } |
12039 | 12040 |
12040 uint32_t Hash() { return string_->Hash(); } | 12041 uint32_t Hash() { return string_->Hash(); } |
12041 | 12042 |
12042 uint32_t HashForObject(Object* other) { | 12043 uint32_t HashForObject(Object* other) { |
12043 return String::cast(other)->Hash(); | 12044 return String::cast(other)->Hash(); |
12044 } | 12045 } |
12045 | 12046 |
12046 MaybeObject* AsObject() { | 12047 MaybeObject* AsObject(Heap* heap) { |
12047 // Attempt to flatten the string, so that internalized strings will most | 12048 // Attempt to flatten the string, so that internalized strings will most |
12048 // often be flat strings. | 12049 // often be flat strings. |
12049 string_ = string_->TryFlattenGetString(); | 12050 string_ = string_->TryFlattenGetString(); |
12050 Heap* heap = string_->GetHeap(); | |
12051 // Internalize the string if possible. | 12051 // Internalize the string if possible. |
12052 Map* map = heap->InternalizedStringMapForString(string_); | 12052 Map* map = heap->InternalizedStringMapForString(string_); |
12053 if (map != NULL) { | 12053 if (map != NULL) { |
12054 string_->set_map_no_write_barrier(map); | 12054 string_->set_map_no_write_barrier(map); |
12055 ASSERT(string_->IsInternalizedString()); | 12055 ASSERT(string_->IsInternalizedString()); |
12056 return string_; | 12056 return string_; |
12057 } | 12057 } |
12058 // Otherwise allocate a new internalized string. | 12058 // Otherwise allocate a new internalized string. |
12059 return heap->AllocateInternalizedStringImpl( | 12059 return heap->AllocateInternalizedStringImpl( |
12060 string_, string_->length(), string_->hash_field()); | 12060 string_, string_->length(), string_->hash_field()); |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12864 if (other->Get(0) != c1_) return false; | 12864 if (other->Get(0) != c1_) return false; |
12865 return other->Get(1) == c2_; | 12865 return other->Get(1) == c2_; |
12866 } | 12866 } |
12867 | 12867 |
12868 uint32_t Hash() { return hash_; } | 12868 uint32_t Hash() { return hash_; } |
12869 uint32_t HashForObject(Object* key) { | 12869 uint32_t HashForObject(Object* key) { |
12870 if (!key->IsString()) return 0; | 12870 if (!key->IsString()) return 0; |
12871 return String::cast(key)->Hash(); | 12871 return String::cast(key)->Hash(); |
12872 } | 12872 } |
12873 | 12873 |
12874 Object* AsObject() { | 12874 Object* AsObject(Heap* heap) { |
12875 // The TwoCharHashTableKey is only used for looking in the string | 12875 // The TwoCharHashTableKey is only used for looking in the string |
12876 // table, not for adding to it. | 12876 // table, not for adding to it. |
12877 UNREACHABLE(); | 12877 UNREACHABLE(); |
12878 return NULL; | 12878 return NULL; |
12879 } | 12879 } |
12880 | 12880 |
12881 private: | 12881 private: |
12882 uint16_t c1_; | 12882 uint16_t c1_; |
12883 uint16_t c2_; | 12883 uint16_t c2_; |
12884 uint32_t hash_; | 12884 uint32_t hash_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12953 } | 12953 } |
12954 | 12954 |
12955 // Adding new string. Grow table if needed. | 12955 // Adding new string. Grow table if needed. |
12956 Object* obj; | 12956 Object* obj; |
12957 { MaybeObject* maybe_obj = EnsureCapacity(1, key); | 12957 { MaybeObject* maybe_obj = EnsureCapacity(1, key); |
12958 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 12958 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
12959 } | 12959 } |
12960 | 12960 |
12961 // Create string object. | 12961 // Create string object. |
12962 Object* string; | 12962 Object* string; |
12963 { MaybeObject* maybe_string = key->AsObject(); | 12963 { MaybeObject* maybe_string = key->AsObject(GetHeap()); |
12964 if (!maybe_string->ToObject(&string)) return maybe_string; | 12964 if (!maybe_string->ToObject(&string)) return maybe_string; |
12965 } | 12965 } |
12966 | 12966 |
12967 // If the string table grew as part of EnsureCapacity, obj is not | 12967 // If the string table grew as part of EnsureCapacity, obj is not |
12968 // the current string table and therefore we cannot use | 12968 // the current string table and therefore we cannot use |
12969 // StringTable::cast here. | 12969 // StringTable::cast here. |
12970 StringTable* table = reinterpret_cast<StringTable*>(obj); | 12970 StringTable* table = reinterpret_cast<StringTable*>(obj); |
12971 | 12971 |
12972 // Add the new string and return it along with the string table. | 12972 // Add the new string and return it along with the string table. |
12973 entry = table->FindInsertionEntry(key->Hash()); | 12973 entry = table->FindInsertionEntry(key->Hash()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13030 SharedFunctionInfo* shared = context->closure()->shared(); | 13030 SharedFunctionInfo* shared = context->closure()->shared(); |
13031 StringSharedKey key(src, | 13031 StringSharedKey key(src, |
13032 shared, | 13032 shared, |
13033 CurrentGlobalLanguageMode(), | 13033 CurrentGlobalLanguageMode(), |
13034 RelocInfo::kNoPosition); | 13034 RelocInfo::kNoPosition); |
13035 CompilationCacheTable* cache; | 13035 CompilationCacheTable* cache; |
13036 MaybeObject* maybe_cache = EnsureCapacity(1, &key); | 13036 MaybeObject* maybe_cache = EnsureCapacity(1, &key); |
13037 if (!maybe_cache->To(&cache)) return maybe_cache; | 13037 if (!maybe_cache->To(&cache)) return maybe_cache; |
13038 | 13038 |
13039 Object* k; | 13039 Object* k; |
13040 MaybeObject* maybe_k = key.AsObject(); | 13040 MaybeObject* maybe_k = key.AsObject(GetHeap()); |
13041 if (!maybe_k->To(&k)) return maybe_k; | 13041 if (!maybe_k->To(&k)) return maybe_k; |
13042 | 13042 |
13043 int entry = cache->FindInsertionEntry(key.Hash()); | 13043 int entry = cache->FindInsertionEntry(key.Hash()); |
13044 cache->set(EntryToIndex(entry), k); | 13044 cache->set(EntryToIndex(entry), k); |
13045 cache->set(EntryToIndex(entry) + 1, value); | 13045 cache->set(EntryToIndex(entry) + 1, value); |
13046 cache->ElementAdded(); | 13046 cache->ElementAdded(); |
13047 return cache; | 13047 return cache; |
13048 } | 13048 } |
13049 | 13049 |
13050 | 13050 |
13051 MaybeObject* CompilationCacheTable::PutEval(String* src, | 13051 MaybeObject* CompilationCacheTable::PutEval(String* src, |
13052 Context* context, | 13052 Context* context, |
13053 SharedFunctionInfo* value, | 13053 SharedFunctionInfo* value, |
13054 int scope_position) { | 13054 int scope_position) { |
13055 StringSharedKey key(src, | 13055 StringSharedKey key(src, |
13056 context->closure()->shared(), | 13056 context->closure()->shared(), |
13057 value->language_mode(), | 13057 value->language_mode(), |
13058 scope_position); | 13058 scope_position); |
13059 Object* obj; | 13059 Object* obj; |
13060 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); | 13060 { MaybeObject* maybe_obj = EnsureCapacity(1, &key); |
13061 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 13061 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
13062 } | 13062 } |
13063 | 13063 |
13064 CompilationCacheTable* cache = | 13064 CompilationCacheTable* cache = |
13065 reinterpret_cast<CompilationCacheTable*>(obj); | 13065 reinterpret_cast<CompilationCacheTable*>(obj); |
13066 int entry = cache->FindInsertionEntry(key.Hash()); | 13066 int entry = cache->FindInsertionEntry(key.Hash()); |
13067 | 13067 |
13068 Object* k; | 13068 Object* k; |
13069 { MaybeObject* maybe_k = key.AsObject(); | 13069 { MaybeObject* maybe_k = key.AsObject(GetHeap()); |
13070 if (!maybe_k->ToObject(&k)) return maybe_k; | 13070 if (!maybe_k->ToObject(&k)) return maybe_k; |
13071 } | 13071 } |
13072 | 13072 |
13073 cache->set(EntryToIndex(entry), k); | 13073 cache->set(EntryToIndex(entry), k); |
13074 cache->set(EntryToIndex(entry) + 1, value); | 13074 cache->set(EntryToIndex(entry) + 1, value); |
13075 cache->ElementAdded(); | 13075 cache->ElementAdded(); |
13076 return cache; | 13076 return cache; |
13077 } | 13077 } |
13078 | 13078 |
13079 | 13079 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13133 uint32_t HashForObject(Object* obj) { | 13133 uint32_t HashForObject(Object* obj) { |
13134 FixedArray* strings = FixedArray::cast(obj); | 13134 FixedArray* strings = FixedArray::cast(obj); |
13135 int len = strings->length(); | 13135 int len = strings->length(); |
13136 uint32_t hash = 0; | 13136 uint32_t hash = 0; |
13137 for (int i = 0; i < len; i++) { | 13137 for (int i = 0; i < len; i++) { |
13138 hash ^= String::cast(strings->get(i))->Hash(); | 13138 hash ^= String::cast(strings->get(i))->Hash(); |
13139 } | 13139 } |
13140 return hash; | 13140 return hash; |
13141 } | 13141 } |
13142 | 13142 |
13143 Object* AsObject() { return strings_; } | 13143 Object* AsObject(Heap* heap) { return strings_; } |
13144 | 13144 |
13145 private: | 13145 private: |
13146 FixedArray* strings_; | 13146 FixedArray* strings_; |
13147 }; | 13147 }; |
13148 | 13148 |
13149 | 13149 |
13150 Object* MapCache::Lookup(FixedArray* array) { | 13150 Object* MapCache::Lookup(FixedArray* array) { |
13151 StringsKey key(array); | 13151 StringsKey key(array); |
13152 int entry = FindEntry(&key); | 13152 int entry = FindEntry(&key); |
13153 if (entry == kNotFound) return GetHeap()->undefined_value(); | 13153 if (entry == kNotFound) return GetHeap()->undefined_value(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13297 return this; | 13297 return this; |
13298 } | 13298 } |
13299 | 13299 |
13300 // Check whether the dictionary should be extended. | 13300 // Check whether the dictionary should be extended. |
13301 Object* obj; | 13301 Object* obj; |
13302 { MaybeObject* maybe_obj = EnsureCapacity(1, key); | 13302 { MaybeObject* maybe_obj = EnsureCapacity(1, key); |
13303 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 13303 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
13304 } | 13304 } |
13305 | 13305 |
13306 Object* k; | 13306 Object* k; |
13307 { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key); | 13307 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); |
13308 if (!maybe_k->ToObject(&k)) return maybe_k; | 13308 if (!maybe_k->ToObject(&k)) return maybe_k; |
13309 } | 13309 } |
13310 PropertyDetails details = PropertyDetails(NONE, NORMAL); | 13310 PropertyDetails details = PropertyDetails(NONE, NORMAL); |
13311 | 13311 |
13312 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details, | 13312 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details, |
13313 Dictionary<Shape, Key>::Hash(key)); | 13313 Dictionary<Shape, Key>::Hash(key)); |
13314 } | 13314 } |
13315 | 13315 |
13316 | 13316 |
13317 template<typename Shape, typename Key> | 13317 template<typename Shape, typename Key> |
(...skipping 16 matching lines...) Expand all Loading... |
13334 | 13334 |
13335 | 13335 |
13336 // Add a key, value pair to the dictionary. | 13336 // Add a key, value pair to the dictionary. |
13337 template<typename Shape, typename Key> | 13337 template<typename Shape, typename Key> |
13338 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, | 13338 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, |
13339 Object* value, | 13339 Object* value, |
13340 PropertyDetails details, | 13340 PropertyDetails details, |
13341 uint32_t hash) { | 13341 uint32_t hash) { |
13342 // Compute the key object. | 13342 // Compute the key object. |
13343 Object* k; | 13343 Object* k; |
13344 { MaybeObject* maybe_k = Shape::AsObject(this->GetIsolate(), key); | 13344 { MaybeObject* maybe_k = Shape::AsObject(this->GetHeap(), key); |
13345 if (!maybe_k->ToObject(&k)) return maybe_k; | 13345 if (!maybe_k->ToObject(&k)) return maybe_k; |
13346 } | 13346 } |
13347 | 13347 |
13348 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash); | 13348 uint32_t entry = Dictionary<Shape, Key>::FindInsertionEntry(hash); |
13349 // Insert element at empty or deleted entry | 13349 // Insert element at empty or deleted entry |
13350 if (!details.IsDeleted() && | 13350 if (!details.IsDeleted() && |
13351 details.dictionary_index() == 0 && | 13351 details.dictionary_index() == 0 && |
13352 Shape::kIsEnumerable) { | 13352 Shape::kIsEnumerable) { |
13353 // Assign an enumeration index to the property and update | 13353 // Assign an enumeration index to the property and update |
13354 // SetNextEnumerationIndex. | 13354 // SetNextEnumerationIndex. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13435 MaybeObject* SeededNumberDictionary::Set(uint32_t key, | 13435 MaybeObject* SeededNumberDictionary::Set(uint32_t key, |
13436 Object* value, | 13436 Object* value, |
13437 PropertyDetails details) { | 13437 PropertyDetails details) { |
13438 int entry = FindEntry(key); | 13438 int entry = FindEntry(key); |
13439 if (entry == kNotFound) return AddNumberEntry(key, value, details); | 13439 if (entry == kNotFound) return AddNumberEntry(key, value, details); |
13440 // Preserve enumeration index. | 13440 // Preserve enumeration index. |
13441 details = PropertyDetails(details.attributes(), | 13441 details = PropertyDetails(details.attributes(), |
13442 details.type(), | 13442 details.type(), |
13443 DetailsAt(entry).dictionary_index()); | 13443 DetailsAt(entry).dictionary_index()); |
13444 MaybeObject* maybe_object_key = | 13444 MaybeObject* maybe_object_key = |
13445 SeededNumberDictionaryShape::AsObject(GetIsolate(), key); | 13445 SeededNumberDictionaryShape::AsObject(GetHeap(), key); |
13446 Object* object_key; | 13446 Object* object_key; |
13447 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; | 13447 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; |
13448 SetEntry(entry, object_key, value, details); | 13448 SetEntry(entry, object_key, value, details); |
13449 return this; | 13449 return this; |
13450 } | 13450 } |
13451 | 13451 |
13452 | 13452 |
13453 MaybeObject* UnseededNumberDictionary::Set(uint32_t key, | 13453 MaybeObject* UnseededNumberDictionary::Set(uint32_t key, |
13454 Object* value) { | 13454 Object* value) { |
13455 int entry = FindEntry(key); | 13455 int entry = FindEntry(key); |
13456 if (entry == kNotFound) return AddNumberEntry(key, value); | 13456 if (entry == kNotFound) return AddNumberEntry(key, value); |
13457 MaybeObject* maybe_object_key = | 13457 MaybeObject* maybe_object_key = |
13458 UnseededNumberDictionaryShape::AsObject(GetIsolate(), key); | 13458 UnseededNumberDictionaryShape::AsObject(GetHeap(), key); |
13459 Object* object_key; | 13459 Object* object_key; |
13460 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; | 13460 if (!maybe_object_key->ToObject(&object_key)) return maybe_object_key; |
13461 SetEntry(entry, object_key, value); | 13461 SetEntry(entry, object_key, value); |
13462 return this; | 13462 return this; |
13463 } | 13463 } |
13464 | 13464 |
13465 | 13465 |
13466 | 13466 |
13467 template<typename Shape, typename Key> | 13467 template<typename Shape, typename Key> |
13468 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( | 13468 int Dictionary<Shape, Key>::NumberOfElementsFilterAttributes( |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14296 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14296 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
14297 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14297 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
14298 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14298 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
14299 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14299 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
14300 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14300 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
14301 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14301 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
14302 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14302 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
14303 } | 14303 } |
14304 | 14304 |
14305 } } // namespace v8::internal | 14305 } } // namespace v8::internal |
OLD | NEW |