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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // Computes the hashed offsets for primary and secondary caches. | 196 // Computes the hashed offsets for primary and secondary caches. |
197 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { | 197 static int PrimaryOffset(String* name, Code::Flags flags, Map* map) { |
198 // This works well because the heap object tag size and the hash | 198 // This works well because the heap object tag size and the hash |
199 // shift are equal. Shifting down the length field to get the | 199 // shift are equal. Shifting down the length field to get the |
200 // hash code would effectively throw away two bits of the hash | 200 // hash code would effectively throw away two bits of the hash |
201 // code. | 201 // code. |
202 ASSERT(kHeapObjectTagSize == String::kHashShift); | 202 ASSERT(kHeapObjectTagSize == String::kHashShift); |
203 // Compute the hash of the name (use entire length field). | 203 // Compute the hash of the name (use entire length field). |
204 ASSERT(name->HasHashCode()); | 204 ASSERT(name->HasHashCode()); |
205 uint32_t field = name->length_field(); | 205 uint32_t field = name->length_field(); |
206 uint32_t map_lowbits = | |
Dean McNamee
2009/05/06 08:29:17
lowbits makes it sounds differnt than low32, speci
| |
207 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)); | |
206 // Base the offset on a simple combination of name, flags, and map. | 208 // Base the offset on a simple combination of name, flags, and map. |
207 uint32_t key = (reinterpret_cast<uint32_t>(map) + field) ^ flags; | 209 uint32_t key = (map_lowbits + field) ^ flags; |
208 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); | 210 return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); |
209 } | 211 } |
210 | 212 |
211 static int SecondaryOffset(String* name, Code::Flags flags, int seed) { | 213 static int SecondaryOffset(String* name, Code::Flags flags, int seed) { |
212 // Use the seed from the primary cache in the secondary cache. | 214 // Use the seed from the primary cache in the secondary cache. |
213 uint32_t key = seed - reinterpret_cast<uint32_t>(name) + flags; | 215 uint32_t string_lowbits = |
216 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name)); | |
217 uint32_t key = seed - string_lowbits + flags; | |
214 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); | 218 return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); |
215 } | 219 } |
216 | 220 |
217 // Compute the entry for a given offset in exactly the same way as | 221 // Compute the entry for a given offset in exactly the same way as |
218 // we done in generated code. This makes it a lot easier to avoid | 222 // we done in generated code. This makes it a lot easier to avoid |
219 // making mistakes in the hashed offset computations. | 223 // making mistakes in the hashed offset computations. |
220 static Entry* entry(Entry* table, int offset) { | 224 static Entry* entry(Entry* table, int offset) { |
221 return reinterpret_cast<Entry*>( | 225 return reinterpret_cast<Entry*>( |
222 reinterpret_cast<Address>(table) + (offset << 1)); | 226 reinterpret_cast<Address>(table) + (offset << 1)); |
223 } | 227 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 | 479 |
476 const ParameterCount& arguments() { return arguments_; } | 480 const ParameterCount& arguments() { return arguments_; } |
477 | 481 |
478 Object* GetCode(PropertyType type, String* name); | 482 Object* GetCode(PropertyType type, String* name); |
479 }; | 483 }; |
480 | 484 |
481 | 485 |
482 } } // namespace v8::internal | 486 } } // namespace v8::internal |
483 | 487 |
484 #endif // V8_STUB_CACHE_H_ | 488 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |