| 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_IC_INL_H_ | 5 #ifndef V8_IC_INL_H_ |
| 6 #define V8_IC_INL_H_ | 6 #define V8_IC_INL_H_ |
| 7 | 7 |
| 8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
| 9 | 9 |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 Code* IC::raw_target() const { | 123 Code* IC::raw_target() const { |
| 124 return GetTargetAtAddress(address(), constant_pool()); | 124 return GetTargetAtAddress(address(), constant_pool()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void IC::UpdateTarget() { target_ = handle(raw_target(), isolate_); } | 127 void IC::UpdateTarget() { target_ = handle(raw_target(), isolate_); } |
| 128 | 128 |
| 129 | 129 |
| 130 JSFunction* IC::GetRootConstructor(Map* receiver_map, Context* native_context) { | |
| 131 DisallowHeapAllocation no_alloc; | |
| 132 if (receiver_map->IsPrimitiveMap()) { | |
| 133 int constructor_function_index = | |
| 134 receiver_map->GetConstructorFunctionIndex(); | |
| 135 if (constructor_function_index != Map::kNoConstructorFunctionIndex) { | |
| 136 return JSFunction::cast(native_context->get(constructor_function_index)); | |
| 137 } | |
| 138 } | |
| 139 return nullptr; | |
| 140 } | |
| 141 | |
| 142 | |
| 143 Handle<Map> IC::GetHandlerCacheHolder(Handle<Map> receiver_map, | 130 Handle<Map> IC::GetHandlerCacheHolder(Handle<Map> receiver_map, |
| 144 bool receiver_is_holder, Isolate* isolate, | 131 bool receiver_is_holder, Isolate* isolate, |
| 145 CacheHolderFlag* flag) { | 132 CacheHolderFlag* flag) { |
| 146 if (receiver_is_holder) { | 133 if (receiver_is_holder) { |
| 147 *flag = kCacheOnReceiver; | 134 *flag = kCacheOnReceiver; |
| 148 return receiver_map; | 135 return receiver_map; |
| 149 } | 136 } |
| 150 Context* native_context = *isolate->native_context(); | 137 Handle<JSFunction> builtin_ctor; |
| 151 JSFunction* builtin_ctor = GetRootConstructor(*receiver_map, native_context); | 138 if (Map::GetConstructorFunction(receiver_map, isolate->native_context()) |
| 152 if (builtin_ctor != NULL) { | 139 .ToHandle(&builtin_ctor)) { |
| 153 *flag = kCacheOnPrototypeReceiverIsPrimitive; | 140 *flag = kCacheOnPrototypeReceiverIsPrimitive; |
| 154 return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map()); | 141 return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map()); |
| 155 } | 142 } |
| 156 *flag = receiver_map->is_dictionary_map() | 143 *flag = receiver_map->is_dictionary_map() |
| 157 ? kCacheOnPrototypeReceiverIsDictionary | 144 ? kCacheOnPrototypeReceiverIsDictionary |
| 158 : kCacheOnPrototype; | 145 : kCacheOnPrototype; |
| 159 // Callers must ensure that the prototype is non-null. | 146 // Callers must ensure that the prototype is non-null. |
| 160 return handle(JSObject::cast(receiver_map->prototype())->map()); | 147 return handle(JSObject::cast(receiver_map->prototype())->map()); |
| 161 } | 148 } |
| 162 | 149 |
| 163 | 150 |
| 164 Handle<Map> IC::GetICCacheHolder(Handle<Map> map, Isolate* isolate, | 151 Handle<Map> IC::GetICCacheHolder(Handle<Map> map, Isolate* isolate, |
| 165 CacheHolderFlag* flag) { | 152 CacheHolderFlag* flag) { |
| 166 Context* native_context = *isolate->native_context(); | 153 Handle<JSFunction> builtin_ctor; |
| 167 JSFunction* builtin_ctor = GetRootConstructor(*map, native_context); | 154 if (Map::GetConstructorFunction(map, isolate->native_context()) |
| 168 if (builtin_ctor != NULL) { | 155 .ToHandle(&builtin_ctor)) { |
| 169 *flag = kCacheOnPrototype; | 156 *flag = kCacheOnPrototype; |
| 170 return handle(builtin_ctor->initial_map()); | 157 return handle(builtin_ctor->initial_map()); |
| 171 } | 158 } |
| 172 *flag = kCacheOnReceiver; | 159 *flag = kCacheOnReceiver; |
| 173 return map; | 160 return map; |
| 174 } | 161 } |
| 175 | 162 |
| 176 | 163 |
| 177 Code* IC::get_host() { | 164 Code* IC::get_host() { |
| 178 return isolate() | 165 return isolate() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 190 bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) { | 177 bool IC::AddressIsDeoptimizedCode(Isolate* isolate, Address address) { |
| 191 Code* host = | 178 Code* host = |
| 192 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code; | 179 isolate->inner_pointer_to_code_cache()->GetCacheEntry(address)->code; |
| 193 return (host->kind() == Code::OPTIMIZED_FUNCTION && | 180 return (host->kind() == Code::OPTIMIZED_FUNCTION && |
| 194 host->marked_for_deoptimization()); | 181 host->marked_for_deoptimization()); |
| 195 } | 182 } |
| 196 } // namespace internal | 183 } // namespace internal |
| 197 } // namespace v8 | 184 } // namespace v8 |
| 198 | 185 |
| 199 #endif // V8_IC_INL_H_ | 186 #endif // V8_IC_INL_H_ |
| OLD | NEW |