| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 Code* IC::raw_target() const { | 157 Code* IC::raw_target() const { |
| 158 return GetTargetAtAddress(address(), constant_pool()); | 158 return GetTargetAtAddress(address(), constant_pool()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void IC::UpdateTarget() { target_ = handle(raw_target(), isolate_); } | 161 void IC::UpdateTarget() { target_ = handle(raw_target(), isolate_); } |
| 162 | 162 |
| 163 | 163 |
| 164 template <class TypeClass> | 164 JSFunction* IC::GetRootConstructor(Map* receiver_map, Context* native_context) { |
| 165 JSFunction* IC::GetRootConstructor(TypeClass* type, Context* native_context) { | 165 Isolate* isolate = receiver_map->GetIsolate(); |
| 166 if (type->Is(TypeClass::Boolean())) { | 166 if (receiver_map == isolate->heap()->boolean_map()) { |
| 167 return native_context->boolean_function(); | 167 return native_context->boolean_function(); |
| 168 } else if (type->Is(TypeClass::Number())) { | 168 } else if (receiver_map->instance_type() == HEAP_NUMBER_TYPE) { |
| 169 return native_context->number_function(); | 169 return native_context->number_function(); |
| 170 } else if (type->Is(TypeClass::String())) { | 170 } else if (receiver_map->instance_type() < FIRST_NONSTRING_TYPE) { |
| 171 return native_context->string_function(); | 171 return native_context->string_function(); |
| 172 } else if (type->Is(TypeClass::Symbol())) { | 172 } else if (receiver_map->instance_type() == SYMBOL_TYPE) { |
| 173 return native_context->symbol_function(); | 173 return native_context->symbol_function(); |
| 174 } else { | 174 } else { |
| 175 return NULL; | 175 return NULL; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 Handle<Map> IC::GetHandlerCacheHolder(HeapType* type, bool receiver_is_holder, | 180 Handle<Map> IC::GetHandlerCacheHolder(Handle<Map> receiver_map, |
| 181 Isolate* isolate, CacheHolderFlag* flag) { | 181 bool receiver_is_holder, Isolate* isolate, |
| 182 Handle<Map> receiver_map = TypeToMap(type, isolate); | 182 CacheHolderFlag* flag) { |
| 183 if (receiver_is_holder) { | 183 if (receiver_is_holder) { |
| 184 *flag = kCacheOnReceiver; | 184 *flag = kCacheOnReceiver; |
| 185 return receiver_map; | 185 return receiver_map; |
| 186 } | 186 } |
| 187 Context* native_context = *isolate->native_context(); | 187 Context* native_context = *isolate->native_context(); |
| 188 JSFunction* builtin_ctor = GetRootConstructor(type, native_context); | 188 JSFunction* builtin_ctor = GetRootConstructor(*receiver_map, native_context); |
| 189 if (builtin_ctor != NULL) { | 189 if (builtin_ctor != NULL) { |
| 190 *flag = kCacheOnPrototypeReceiverIsPrimitive; | 190 *flag = kCacheOnPrototypeReceiverIsPrimitive; |
| 191 return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map()); | 191 return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map()); |
| 192 } | 192 } |
| 193 *flag = receiver_map->is_dictionary_map() | 193 *flag = receiver_map->is_dictionary_map() |
| 194 ? kCacheOnPrototypeReceiverIsDictionary | 194 ? kCacheOnPrototypeReceiverIsDictionary |
| 195 : kCacheOnPrototype; | 195 : kCacheOnPrototype; |
| 196 // Callers must ensure that the prototype is non-null. | 196 // Callers must ensure that the prototype is non-null. |
| 197 return handle(JSObject::cast(receiver_map->prototype())->map()); | 197 return handle(JSObject::cast(receiver_map->prototype())->map()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 Handle<Map> IC::GetICCacheHolder(HeapType* type, Isolate* isolate, | 201 Handle<Map> IC::GetICCacheHolder(Handle<Map> map, Isolate* isolate, |
| 202 CacheHolderFlag* flag) { | 202 CacheHolderFlag* flag) { |
| 203 Context* native_context = *isolate->native_context(); | 203 Context* native_context = *isolate->native_context(); |
| 204 JSFunction* builtin_ctor = GetRootConstructor(type, native_context); | 204 JSFunction* builtin_ctor = GetRootConstructor(*map, native_context); |
| 205 if (builtin_ctor != NULL) { | 205 if (builtin_ctor != NULL) { |
| 206 *flag = kCacheOnPrototype; | 206 *flag = kCacheOnPrototype; |
| 207 return handle(builtin_ctor->initial_map()); | 207 return handle(builtin_ctor->initial_map()); |
| 208 } | 208 } |
| 209 *flag = kCacheOnReceiver; | 209 *flag = kCacheOnReceiver; |
| 210 return TypeToMap(type, isolate); | 210 return map; |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 214 inline Code* IC::get_host() { | 214 inline Code* IC::get_host() { |
| 215 return isolate() | 215 return isolate() |
| 216 ->inner_pointer_to_code_cache() | 216 ->inner_pointer_to_code_cache() |
| 217 ->GetCacheEntry(address()) | 217 ->GetCacheEntry(address()) |
| 218 ->code; | 218 ->code; |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 } // namespace v8::internal | 221 } // namespace v8::internal |
| 222 | 222 |
| 223 #endif // V8_IC_INL_H_ | 223 #endif // V8_IC_INL_H_ |
| OLD | NEW |