Index: src/ic/call-optimization.cc |
diff --git a/src/ic/call-optimization.cc b/src/ic/call-optimization.cc |
index 45717b50a7bf6af607ac25a67023c167514166e3..94bf5eaf21dbb4d900fb98dbf6e4560f54fcdced 100644 |
--- a/src/ic/call-optimization.cc |
+++ b/src/ic/call-optimization.cc |
@@ -8,8 +8,16 @@ |
namespace v8 { |
namespace internal { |
-CallOptimization::CallOptimization(Handle<JSFunction> function) { |
- Initialize(function); |
+CallOptimization::CallOptimization(Handle<Object> function) { |
+ constant_function_ = Handle<JSFunction>::null(); |
+ is_simple_api_call_ = false; |
+ expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); |
+ api_call_info_ = Handle<CallHandlerInfo>::null(); |
+ if (function->IsJSFunction()) { |
+ Initialize(Handle<JSFunction>::cast(function)); |
+ } else if (function->IsFunctionTemplateInfo()) { |
+ Initialize(Handle<FunctionTemplateInfo>::cast(function)); |
+ } |
} |
@@ -80,13 +88,20 @@ bool CallOptimization::IsCompatibleReceiverMap(Handle<Map> map, |
return false; |
} |
+void CallOptimization::Initialize( |
+ Handle<FunctionTemplateInfo> function_template_info) { |
+ if (function_template_info->call_code()->IsUndefined()) return; |
+ api_call_info_ = |
+ handle(CallHandlerInfo::cast(function_template_info->call_code())); |
-void CallOptimization::Initialize(Handle<JSFunction> function) { |
- constant_function_ = Handle<JSFunction>::null(); |
- is_simple_api_call_ = false; |
- expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); |
- api_call_info_ = Handle<CallHandlerInfo>::null(); |
+ if (!function_template_info->signature()->IsUndefined()) { |
+ expected_receiver_type_ = |
+ handle(FunctionTemplateInfo::cast(function_template_info->signature())); |
+ } |
+ is_simple_api_call_ = true; |
+} |
+void CallOptimization::Initialize(Handle<JSFunction> function) { |
if (function.is_null() || !function->is_compiled()) return; |
constant_function_ = function; |