Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: src/objects-inl.h

Issue 9148006: [objects] seed NumberDictionary (only ia32 now) Base URL: gh:v8/v8@master
Patch Set: fixed linter issues, use pseudo-random function in test Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 template<typename Shape, typename Key> 2050 template<typename Shape, typename Key>
2051 int HashTable<Shape, Key>::FindEntry(Key key) { 2051 int HashTable<Shape, Key>::FindEntry(Key key) {
2052 return FindEntry(GetIsolate(), key); 2052 return FindEntry(GetIsolate(), key);
2053 } 2053 }
2054 2054
2055 2055
2056 // Find entry for key otherwise return kNotFound. 2056 // Find entry for key otherwise return kNotFound.
2057 template<typename Shape, typename Key> 2057 template<typename Shape, typename Key>
2058 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { 2058 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) {
2059 uint32_t capacity = Capacity(); 2059 uint32_t capacity = Capacity();
2060 uint32_t entry = FirstProbe(Shape::Hash(key), capacity); 2060 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity);
2061 uint32_t count = 1; 2061 uint32_t count = 1;
2062 // EnsureCapacity will guarantee the hash table is never full. 2062 // EnsureCapacity will guarantee the hash table is never full.
2063 while (true) { 2063 while (true) {
2064 Object* element = KeyAt(entry); 2064 Object* element = KeyAt(entry);
2065 // Empty entry. 2065 // Empty entry.
2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; 2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break;
2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() && 2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() &&
2068 Shape::IsMatch(key, element)) return entry; 2068 Shape::IsMatch(key, element)) return entry;
2069 entry = NextProbe(entry, count++, capacity); 2069 entry = NextProbe(entry, count++, capacity);
2070 } 2070 }
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 } 4529 }
4530 4530
4531 4531
4532 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { 4532 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
4533 ASSERT(other->IsNumber()); 4533 ASSERT(other->IsNumber());
4534 return key == static_cast<uint32_t>(other->Number()); 4534 return key == static_cast<uint32_t>(other->Number());
4535 } 4535 }
4536 4536
4537 4537
4538 uint32_t NumberDictionaryShape::Hash(uint32_t key) { 4538 uint32_t NumberDictionaryShape::Hash(uint32_t key) {
4539 return ComputeIntegerHash(key); 4539 // This function is unreachable, since shape has UsesSeed=true flag.
4540 UNREACHABLE();
4541 return 0;
4540 } 4542 }
4541 4543
4542 4544
4543 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) { 4545 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) {
4544 ASSERT(other->IsNumber()); 4546 // This function is unreachable, since shape has UsesSeed=true flag.
4545 return ComputeIntegerHash(static_cast<uint32_t>(other->Number())); 4547 UNREACHABLE();
4548 return 0;
4546 } 4549 }
4547 4550
4551 uint32_t NumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) {
4552 return ComputeIntegerHash(key, seed);
4553 }
4554
4555 uint32_t NumberDictionaryShape::SeededHashForObject(uint32_t key,
4556 uint32_t seed,
4557 Object* other) {
4558 ASSERT(other->IsNumber());
4559 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed);
4560 }
4548 4561
4549 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { 4562 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
4550 return Isolate::Current()->heap()->NumberFromUint32(key); 4563 return Isolate::Current()->heap()->NumberFromUint32(key);
4551 } 4564 }
4552 4565
4553 4566
4554 bool StringDictionaryShape::IsMatch(String* key, Object* other) { 4567 bool StringDictionaryShape::IsMatch(String* key, Object* other) {
4555 // We know that all entries in a hash table had their hash keys created. 4568 // We know that all entries in a hash table had their hash keys created.
4556 // Use that knowledge to have fast failure. 4569 // Use that knowledge to have fast failure.
4557 if (key->Hash() != String::cast(other)->Hash()) return false; 4570 if (key->Hash() != String::cast(other)->Hash()) return false;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
4769 #undef WRITE_INT_FIELD 4782 #undef WRITE_INT_FIELD
4770 #undef READ_SHORT_FIELD 4783 #undef READ_SHORT_FIELD
4771 #undef WRITE_SHORT_FIELD 4784 #undef WRITE_SHORT_FIELD
4772 #undef READ_BYTE_FIELD 4785 #undef READ_BYTE_FIELD
4773 #undef WRITE_BYTE_FIELD 4786 #undef WRITE_BYTE_FIELD
4774 4787
4775 4788
4776 } } // namespace v8::internal 4789 } } // namespace v8::internal
4777 4790
4778 #endif // V8_OBJECTS_INL_H_ 4791 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698