OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 private: | 192 private: |
193 friend class SCTableReference; | 193 friend class SCTableReference; |
194 static const int kPrimaryTableSize = 2048; | 194 static const int kPrimaryTableSize = 2048; |
195 static const int kSecondaryTableSize = 512; | 195 static const int kSecondaryTableSize = 512; |
196 static Entry primary_[]; | 196 static Entry primary_[]; |
197 static Entry secondary_[]; | 197 static Entry secondary_[]; |
198 | 198 |
199 // Computes the hashed offsets for primary and secondary caches. | 199 // Computes the hashed offsets for primary and secondary caches. |
200 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { | 200 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { |
| 201 // This works well because the heap object tag size and the hash |
| 202 // shift are equal. Shifting down the length field to get the |
| 203 // hash code would effectively throw away two bits of the hash |
| 204 // code. |
| 205 ASSERT(kHeapObjectTagSize == kHashShift); |
201 // Compute the hash of the name (use entire length field). | 206 // Compute the hash of the name (use entire length field). |
202 uint32_t name_hash = name->length_field(); | 207 ASSERT(name->HasHashCode()); |
203 ASSERT(name_hash & String::kHashComputedMask); | 208 uint32_t field = name->length_field(); |
204 // Base the offset on a simple combination of name, flags, and map. | 209 // Base the offset on a simple combination of name, flags, and map. |
205 uint32_t key = (reinterpret_cast<uint32_t>(map) + name_hash) ^ flags; | 210 uint32_t key = (reinterpret_cast<uint32_t>(map) + field) ^ flags; |
206 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); | 211 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); |
207 } | 212 } |
208 | 213 |
209 static int SecondaryOffset(String* name, Code::Flags flags, int seed) { | 214 static int SecondaryOffset(String* name, Code::Flags flags, int seed) { |
210 // Use the seed from the primary cache in the secondary cache. | 215 // Use the seed from the primary cache in the secondary cache. |
211 uint32_t key = seed - reinterpret_cast<uint32_t>(name) + flags; | 216 uint32_t key = seed - reinterpret_cast<uint32_t>(name) + flags; |
212 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); | 217 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); |
213 } | 218 } |
214 | 219 |
215 // Compute the entry for a given offset in exactly the same way as | 220 // Compute the entry for a given offset in exactly the same way as |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 467 |
463 const ParameterCount& arguments() { return arguments_; } | 468 const ParameterCount& arguments() { return arguments_; } |
464 | 469 |
465 Object* GetCode(PropertyType type); | 470 Object* GetCode(PropertyType type); |
466 }; | 471 }; |
467 | 472 |
468 | 473 |
469 } } // namespace v8::internal | 474 } } // namespace v8::internal |
470 | 475 |
471 #endif // V8_STUB_CACHE_H_ | 476 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |