Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: src/ic/call-optimization.cc

Issue 1609233002: Do not eagerly instantiate accessors' JSFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/call-optimization.h" 5 #include "src/ic/call-optimization.h"
6 6
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
11 CallOptimization::CallOptimization(Handle<JSFunction> function) { 11 CallOptimization::CallOptimization(Handle<Object> function) {
12 Initialize(function); 12 constant_function_ = Handle<JSFunction>::null();
13 is_simple_api_call_ = false;
14 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null();
15 api_call_info_ = Handle<CallHandlerInfo>::null();
16 if (function->IsJSFunction()) {
17 Initialize(Handle<JSFunction>::cast(function));
18 } else if (function->IsFunctionTemplateInfo()) {
19 Initialize(Handle<FunctionTemplateInfo>::cast(function));
20 }
13 } 21 }
14 22
15 23
16 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( 24 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
17 Handle<Map> object_map, HolderLookup* holder_lookup, 25 Handle<Map> object_map, HolderLookup* holder_lookup,
18 int* holder_depth_in_prototype_chain) const { 26 int* holder_depth_in_prototype_chain) const {
19 DCHECK(is_simple_api_call()); 27 DCHECK(is_simple_api_call());
20 if (!object_map->IsJSObjectMap()) { 28 if (!object_map->IsJSObjectMap()) {
21 *holder_lookup = kHolderNotFound; 29 *holder_lookup = kHolderNotFound;
22 return Handle<JSObject>::null(); 30 return Handle<JSObject>::null();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 object = JSObject::cast(prototype); 82 object = JSObject::cast(prototype);
75 } 83 }
76 } 84 }
77 break; 85 break;
78 } 86 }
79 UNREACHABLE(); 87 UNREACHABLE();
80 return false; 88 return false;
81 } 89 }
82 90
83 91
92 void CallOptimization::Initialize(
93 Handle<FunctionTemplateInfo> function_template_info) {
94 if (function_template_info->call_code()->IsUndefined()) return;
95 api_call_info_ =
96 handle(CallHandlerInfo::cast(function_template_info->call_code()));
97
98 if (!function_template_info->signature()->IsUndefined()) {
99 expected_receiver_type_ =
100 handle(FunctionTemplateInfo::cast(function_template_info->signature()));
101 }
102 is_simple_api_call_ = true;
103 }
104
105
84 void CallOptimization::Initialize(Handle<JSFunction> function) { 106 void CallOptimization::Initialize(Handle<JSFunction> function) {
85 constant_function_ = Handle<JSFunction>::null();
86 is_simple_api_call_ = false;
87 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null();
88 api_call_info_ = Handle<CallHandlerInfo>::null();
89
90 if (function.is_null() || !function->is_compiled()) return; 107 if (function.is_null() || !function->is_compiled()) return;
91 108
92 constant_function_ = function; 109 constant_function_ = function;
93 AnalyzePossibleApiFunction(function); 110 AnalyzePossibleApiFunction(function);
94 } 111 }
95 112
96 113
97 void CallOptimization::AnalyzePossibleApiFunction(Handle<JSFunction> function) { 114 void CallOptimization::AnalyzePossibleApiFunction(Handle<JSFunction> function) {
98 if (!function->shared()->IsApiFunction()) return; 115 if (!function->shared()->IsApiFunction()) return;
99 Handle<FunctionTemplateInfo> info(function->shared()->get_api_func_data()); 116 Handle<FunctionTemplateInfo> info(function->shared()->get_api_func_data());
100 117
101 // Require a C++ callback. 118 // Require a C++ callback.
102 if (info->call_code()->IsUndefined()) return; 119 if (info->call_code()->IsUndefined()) return;
103 api_call_info_ = handle(CallHandlerInfo::cast(info->call_code())); 120 api_call_info_ = handle(CallHandlerInfo::cast(info->call_code()));
104 121
105 if (!info->signature()->IsUndefined()) { 122 if (!info->signature()->IsUndefined()) {
106 expected_receiver_type_ = 123 expected_receiver_type_ =
107 handle(FunctionTemplateInfo::cast(info->signature())); 124 handle(FunctionTemplateInfo::cast(info->signature()));
108 } 125 }
109 126
110 is_simple_api_call_ = true; 127 is_simple_api_call_ = true;
111 } 128 }
112 } // namespace internal 129 } // namespace internal
113 } // namespace v8 130 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698