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

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: Make GCMole happy again. Created 4 years, 10 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
« no previous file with comments | « src/ic/call-optimization.h ('k') | src/ic/ia32/handler-compiler-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (prototype == *holder) return true; 81 if (prototype == *holder) return true;
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
91 void CallOptimization::Initialize(
92 Handle<FunctionTemplateInfo> function_template_info) {
93 if (function_template_info->call_code()->IsUndefined()) return;
94 api_call_info_ =
95 handle(CallHandlerInfo::cast(function_template_info->call_code()));
96
97 if (!function_template_info->signature()->IsUndefined()) {
98 expected_receiver_type_ =
99 handle(FunctionTemplateInfo::cast(function_template_info->signature()));
100 }
101 is_simple_api_call_ = true;
102 }
83 103
84 void CallOptimization::Initialize(Handle<JSFunction> function) { 104 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; 105 if (function.is_null() || !function->is_compiled()) return;
91 106
92 constant_function_ = function; 107 constant_function_ = function;
93 AnalyzePossibleApiFunction(function); 108 AnalyzePossibleApiFunction(function);
94 } 109 }
95 110
96 111
97 void CallOptimization::AnalyzePossibleApiFunction(Handle<JSFunction> function) { 112 void CallOptimization::AnalyzePossibleApiFunction(Handle<JSFunction> function) {
98 if (!function->shared()->IsApiFunction()) return; 113 if (!function->shared()->IsApiFunction()) return;
99 Handle<FunctionTemplateInfo> info(function->shared()->get_api_func_data()); 114 Handle<FunctionTemplateInfo> info(function->shared()->get_api_func_data());
100 115
101 // Require a C++ callback. 116 // Require a C++ callback.
102 if (info->call_code()->IsUndefined()) return; 117 if (info->call_code()->IsUndefined()) return;
103 api_call_info_ = handle(CallHandlerInfo::cast(info->call_code())); 118 api_call_info_ = handle(CallHandlerInfo::cast(info->call_code()));
104 119
105 if (!info->signature()->IsUndefined()) { 120 if (!info->signature()->IsUndefined()) {
106 expected_receiver_type_ = 121 expected_receiver_type_ =
107 handle(FunctionTemplateInfo::cast(info->signature())); 122 handle(FunctionTemplateInfo::cast(info->signature()));
108 } 123 }
109 124
110 is_simple_api_call_ = true; 125 is_simple_api_call_ = true;
111 } 126 }
112 } // namespace internal 127 } // namespace internal
113 } // namespace v8 128 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/call-optimization.h ('k') | src/ic/ia32/handler-compiler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698