| 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 #include "src/ic/stub-cache.h" | 5 #include "src/ic/stub-cache.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/counters.h" | 9 #include "src/counters.h" |
| 10 #include "src/ic/ic-inl.h" | 10 #include "src/ic/ic-inl.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return secondary->value; | 93 return secondary->value; |
| 94 } | 94 } |
| 95 return nullptr; | 95 return nullptr; |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 void StubCache::Clear() { | 99 void StubCache::Clear() { |
| 100 Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal); | 100 Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal); |
| 101 for (int i = 0; i < kPrimaryTableSize; i++) { | 101 for (int i = 0; i < kPrimaryTableSize; i++) { |
| 102 primary_[i].key = isolate()->heap()->empty_string(); | 102 primary_[i].key = isolate()->heap()->empty_string(); |
| 103 primary_[i].map = NULL; | 103 primary_[i].map = nullptr; |
| 104 primary_[i].value = empty; | 104 primary_[i].value = empty; |
| 105 } | 105 } |
| 106 for (int j = 0; j < kSecondaryTableSize; j++) { | 106 for (int j = 0; j < kSecondaryTableSize; j++) { |
| 107 secondary_[j].key = isolate()->heap()->empty_string(); | 107 secondary_[j].key = isolate()->heap()->empty_string(); |
| 108 secondary_[j].map = NULL; | 108 secondary_[j].map = nullptr; |
| 109 secondary_[j].value = empty; | 109 secondary_[j].value = empty; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name, | 114 void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name, |
| 115 Handle<Context> native_context, | 115 Handle<Context> native_context, |
| 116 Zone* zone) { | 116 Zone* zone) { |
| 117 for (int i = 0; i < kPrimaryTableSize; i++) { | 117 for (int i = 0; i < kPrimaryTableSize; i++) { |
| 118 if (primary_[i].key == *name) { | 118 if (primary_[i].key == *name) { |
| 119 Map* map = primary_[i].map; | 119 Map* map = primary_[i].map; |
| 120 // Map can be NULL, if the stub is constant function call | 120 // Map can be nullptr, if the stub is constant function call |
| 121 // with a primitive receiver. | 121 // with a primitive receiver. |
| 122 if (map == NULL) continue; | 122 if (map == nullptr) continue; |
| 123 | 123 |
| 124 int offset = PrimaryOffset(*name, map); | 124 int offset = PrimaryOffset(*name, map); |
| 125 if (entry(primary_, offset) == &primary_[i] && | 125 if (entry(primary_, offset) == &primary_[i] && |
| 126 TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { | 126 TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { |
| 127 types->AddMapIfMissing(Handle<Map>(map), zone); | 127 types->AddMapIfMissing(Handle<Map>(map), zone); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 for (int i = 0; i < kSecondaryTableSize; i++) { | 132 for (int i = 0; i < kSecondaryTableSize; i++) { |
| 133 if (secondary_[i].key == *name) { | 133 if (secondary_[i].key == *name) { |
| 134 Map* map = secondary_[i].map; | 134 Map* map = secondary_[i].map; |
| 135 // Map can be NULL, if the stub is constant function call | 135 // Map can be nullptr, if the stub is constant function call |
| 136 // with a primitive receiver. | 136 // with a primitive receiver. |
| 137 if (map == NULL) continue; | 137 if (map == nullptr) continue; |
| 138 | 138 |
| 139 // Lookup in primary table and skip duplicates. | 139 // Lookup in primary table and skip duplicates. |
| 140 int primary_offset = PrimaryOffset(*name, map); | 140 int primary_offset = PrimaryOffset(*name, map); |
| 141 | 141 |
| 142 // Lookup in secondary table and add matches. | 142 // Lookup in secondary table and add matches. |
| 143 int offset = SecondaryOffset(*name, primary_offset); | 143 int offset = SecondaryOffset(*name, primary_offset); |
| 144 if (entry(secondary_, offset) == &secondary_[i] && | 144 if (entry(secondary_, offset) == &secondary_[i] && |
| 145 TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { | 145 TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { |
| 146 types->AddMapIfMissing(Handle<Map>(map), zone); | 146 types->AddMapIfMissing(Handle<Map>(map), zone); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 } // namespace internal | 151 } // namespace internal |
| 152 } // namespace v8 | 152 } // namespace v8 |
| OLD | NEW |