| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_STUB_CACHE_H_ | 5 #ifndef V8_STUB_CACHE_H_ |
| 6 #define V8_STUB_CACHE_H_ | 6 #define V8_STUB_CACHE_H_ |
| 7 | 7 |
| 8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Clear the lookup table (@ mark compact collection). | 45 // Clear the lookup table (@ mark compact collection). |
| 46 void Clear(); | 46 void Clear(); |
| 47 // Collect all maps that match the name and flags. | 47 // Collect all maps that match the name and flags. |
| 48 void CollectMatchingMaps(SmallMapList* types, Handle<Name> name, | 48 void CollectMatchingMaps(SmallMapList* types, Handle<Name> name, |
| 49 Code::Flags flags, Handle<Context> native_context, | 49 Code::Flags flags, Handle<Context> native_context, |
| 50 Zone* zone); | 50 Zone* zone); |
| 51 // Generate code for probing the stub cache table. | 51 // Generate code for probing the stub cache table. |
| 52 // Arguments extra, extra2 and extra3 may be used to pass additional scratch | 52 // Arguments extra, extra2 and extra3 may be used to pass additional scratch |
| 53 // registers. Set to no_reg if not needed. | 53 // registers. Set to no_reg if not needed. |
| 54 // If leave_frame is true, then exit a frame before the tail call. | 54 // If leave_frame is true, then exit a frame before the tail call. |
| 55 void GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 55 void GenerateProbe(MacroAssembler* masm, Register receiver, Register name, |
| 56 Code::Flags flags, Register receiver, Register name, | |
| 57 Register scratch, Register extra, Register extra2 = no_reg, | 56 Register scratch, Register extra, Register extra2 = no_reg, |
| 58 Register extra3 = no_reg); | 57 Register extra3 = no_reg); |
| 59 | 58 |
| 60 enum Table { kPrimary, kSecondary }; | 59 enum Table { kPrimary, kSecondary }; |
| 61 | 60 |
| 62 SCTableReference key_reference(StubCache::Table table) { | 61 SCTableReference key_reference(StubCache::Table table) { |
| 63 return SCTableReference( | 62 return SCTableReference( |
| 64 reinterpret_cast<Address>(&first_entry(table)->key)); | 63 reinterpret_cast<Address>(&first_entry(table)->key)); |
| 65 } | 64 } |
| 66 | 65 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 79 case StubCache::kPrimary: | 78 case StubCache::kPrimary: |
| 80 return StubCache::primary_; | 79 return StubCache::primary_; |
| 81 case StubCache::kSecondary: | 80 case StubCache::kSecondary: |
| 82 return StubCache::secondary_; | 81 return StubCache::secondary_; |
| 83 } | 82 } |
| 84 UNREACHABLE(); | 83 UNREACHABLE(); |
| 85 return NULL; | 84 return NULL; |
| 86 } | 85 } |
| 87 | 86 |
| 88 Isolate* isolate() { return isolate_; } | 87 Isolate* isolate() { return isolate_; } |
| 88 Code::Kind ic_kind() const { return ic_kind_; } |
| 89 | 89 |
| 90 // Setting the entry size such that the index is shifted by Name::kHashShift | 90 // Setting the entry size such that the index is shifted by Name::kHashShift |
| 91 // is convenient; shifting down the length field (to extract the hash code) | 91 // is convenient; shifting down the length field (to extract the hash code) |
| 92 // automatically discards the hash bit field. | 92 // automatically discards the hash bit field. |
| 93 static const int kCacheIndexShift = Name::kHashShift; | 93 static const int kCacheIndexShift = Name::kHashShift; |
| 94 | 94 |
| 95 static const int kPrimaryTableBits = 11; | 95 static const int kPrimaryTableBits = 11; |
| 96 static const int kPrimaryTableSize = (1 << kPrimaryTableBits); | 96 static const int kPrimaryTableSize = (1 << kPrimaryTableBits); |
| 97 static const int kSecondaryTableBits = 9; | 97 static const int kSecondaryTableBits = 9; |
| 98 static const int kSecondaryTableSize = (1 << kSecondaryTableBits); | 98 static const int kSecondaryTableSize = (1 << kSecondaryTableBits); |
| 99 | 99 |
| 100 static int PrimaryOffsetForTesting(Name* name, Code::Flags flags, Map* map) { | 100 static int PrimaryOffsetForTesting(Name* name, Code::Flags flags, Map* map) { |
| 101 return PrimaryOffset(name, flags, map); | 101 return PrimaryOffset(name, flags, map); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static int SecondaryOffsetForTesting(Name* name, Code::Flags flags, | 104 static int SecondaryOffsetForTesting(Name* name, Code::Flags flags, |
| 105 int seed) { | 105 int seed) { |
| 106 return SecondaryOffset(name, flags, seed); | 106 return SecondaryOffset(name, flags, seed); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // The constructor is made public only for the purposes of testing. | 109 // The constructor is made public only for the purposes of testing. |
| 110 explicit StubCache(Isolate* isolate); | 110 StubCache(Isolate* isolate, Code::Kind ic_kind); |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 // The stub cache has a primary and secondary level. The two levels have | 113 // The stub cache has a primary and secondary level. The two levels have |
| 114 // different hashing algorithms in order to avoid simultaneous collisions | 114 // different hashing algorithms in order to avoid simultaneous collisions |
| 115 // in both caches. Unlike a probing strategy (quadratic or otherwise) the | 115 // in both caches. Unlike a probing strategy (quadratic or otherwise) the |
| 116 // update strategy on updates is fairly clear and simple: Any existing entry | 116 // update strategy on updates is fairly clear and simple: Any existing entry |
| 117 // in the primary cache is moved to the secondary cache, and secondary cache | 117 // in the primary cache is moved to the secondary cache, and secondary cache |
| 118 // entries are overwritten. | 118 // entries are overwritten. |
| 119 | 119 |
| 120 // Hash algorithm for the primary table. This algorithm is replicated in | 120 // Hash algorithm for the primary table. This algorithm is replicated in |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 static Entry* entry(Entry* table, int offset) { | 162 static Entry* entry(Entry* table, int offset) { |
| 163 const int multiplier = sizeof(*table) >> Name::kHashShift; | 163 const int multiplier = sizeof(*table) >> Name::kHashShift; |
| 164 return reinterpret_cast<Entry*>(reinterpret_cast<Address>(table) + | 164 return reinterpret_cast<Entry*>(reinterpret_cast<Address>(table) + |
| 165 offset * multiplier); | 165 offset * multiplier); |
| 166 } | 166 } |
| 167 | 167 |
| 168 private: | 168 private: |
| 169 Entry primary_[kPrimaryTableSize]; | 169 Entry primary_[kPrimaryTableSize]; |
| 170 Entry secondary_[kSecondaryTableSize]; | 170 Entry secondary_[kSecondaryTableSize]; |
| 171 Isolate* isolate_; | 171 Isolate* isolate_; |
| 172 Code::Kind ic_kind_; |
| 172 | 173 |
| 173 friend class Isolate; | 174 friend class Isolate; |
| 174 friend class SCTableReference; | 175 friend class SCTableReference; |
| 175 | 176 |
| 176 DISALLOW_COPY_AND_ASSIGN(StubCache); | 177 DISALLOW_COPY_AND_ASSIGN(StubCache); |
| 177 }; | 178 }; |
| 178 } // namespace internal | 179 } // namespace internal |
| 179 } // namespace v8 | 180 } // namespace v8 |
| 180 | 181 |
| 181 #endif // V8_STUB_CACHE_H_ | 182 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |