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 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 class KeyedLookupCache { | 1286 class KeyedLookupCache { |
1287 public: | 1287 public: |
1288 // Lookup field offset for (map, name). If absent, -1 is returned. | 1288 // Lookup field offset for (map, name). If absent, -1 is returned. |
1289 static int Lookup(Map* map, String* name); | 1289 static int Lookup(Map* map, String* name); |
1290 | 1290 |
1291 // Update an element in the cache. | 1291 // Update an element in the cache. |
1292 static void Update(Map* map, String* name, int field_offset); | 1292 static void Update(Map* map, String* name, int field_offset); |
1293 | 1293 |
1294 // Clear the cache. | 1294 // Clear the cache. |
1295 static void Clear(); | 1295 static void Clear(); |
1296 | |
1297 static const int kLength = 64; | |
Erik Corry
2009/12/09 10:43:40
On a related note we should run a few performance
Mads Ager (chromium)
2009/12/10 09:18:18
Makes sense, yes.
| |
1298 static const int kCapacityMask = kLength - 1; | |
1299 static const int kMapHashShift = 2; | |
1300 | |
1296 private: | 1301 private: |
1297 static inline int Hash(Map* map, String* name); | 1302 static inline int Hash(Map* map, String* name); |
1298 static const int kLength = 64; | 1303 |
1304 // Get the address of the keys and field_offsets arrays. Used in | |
1305 // generated code to perform cache lookups. | |
1306 static Address keys_address() { | |
1307 return reinterpret_cast<Address>(&keys_); | |
1308 } | |
1309 | |
1310 static Address field_offsets_address() { | |
1311 return reinterpret_cast<Address>(&field_offsets_); | |
1312 } | |
1313 | |
1299 struct Key { | 1314 struct Key { |
1300 Map* map; | 1315 Map* map; |
1301 String* name; | 1316 String* name; |
1302 }; | 1317 }; |
1303 static Key keys_[kLength]; | 1318 static Key keys_[kLength]; |
1304 static int field_offsets_[kLength]; | 1319 static int field_offsets_[kLength]; |
1320 | |
1321 friend class ExternalReference; | |
1305 }; | 1322 }; |
1306 | 1323 |
1307 | 1324 |
1308 | |
1309 // Cache for mapping (array, property name) into descriptor index. | 1325 // Cache for mapping (array, property name) into descriptor index. |
1310 // The cache contains both positive and negative results. | 1326 // The cache contains both positive and negative results. |
1311 // Descriptor index equals kNotFound means the property is absent. | 1327 // Descriptor index equals kNotFound means the property is absent. |
1312 // Cleared at startup and prior to any gc. | 1328 // Cleared at startup and prior to any gc. |
1313 class DescriptorLookupCache { | 1329 class DescriptorLookupCache { |
1314 public: | 1330 public: |
1315 // Lookup descriptor index for (map, name). | 1331 // Lookup descriptor index for (map, name). |
1316 // If absent, kAbsent is returned. | 1332 // If absent, kAbsent is returned. |
1317 static int Lookup(DescriptorArray* array, String* name) { | 1333 static int Lookup(DescriptorArray* array, String* name) { |
1318 if (!StringShape(name).IsSymbol()) return kAbsent; | 1334 if (!StringShape(name).IsSymbol()) return kAbsent; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1619 } | 1635 } |
1620 static TranscendentalCache* caches_[kNumberOfCaches]; | 1636 static TranscendentalCache* caches_[kNumberOfCaches]; |
1621 Element elements_[kCacheSize]; | 1637 Element elements_[kCacheSize]; |
1622 Type type_; | 1638 Type type_; |
1623 }; | 1639 }; |
1624 | 1640 |
1625 | 1641 |
1626 } } // namespace v8::internal | 1642 } } // namespace v8::internal |
1627 | 1643 |
1628 #endif // V8_HEAP_H_ | 1644 #endif // V8_HEAP_H_ |
OLD | NEW |