OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/frame-states.h" | 5 #include "src/compiler/frame-states.h" |
6 | 6 |
7 #include "src/base/functional.h" | 7 #include "src/base/functional.h" |
8 #include "src/callable.h" | 8 #include "src/callable.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 BailoutId bailout_id = Builtins::GetContinuationBailoutId(name); | 106 BailoutId bailout_id = Builtins::GetContinuationBailoutId(name); |
107 Callable callable = Builtins::CallableFor(isolate, name); | 107 Callable callable = Builtins::CallableFor(isolate, name); |
108 | 108 |
109 const Operator* op_param = | 109 const Operator* op_param = |
110 common->StateValues(parameter_count, SparseInputMask::Dense()); | 110 common->StateValues(parameter_count, SparseInputMask::Dense()); |
111 Node* params_node = graph->NewNode(op_param, parameter_count, parameters); | 111 Node* params_node = graph->NewNode(op_param, parameter_count, parameters); |
112 | 112 |
113 FrameStateType frame_type = | 113 FrameStateType frame_type = |
114 function.is_null() ? FrameStateType::kBuiltinContinuation | 114 function.is_null() ? FrameStateType::kBuiltinContinuation |
115 : FrameStateType::kJavaScriptBuiltinContinuation; | 115 : FrameStateType::kJavaScriptBuiltinContinuation; |
116 Handle<SharedFunctionInfo> shared( | |
117 Handle<SharedFunctionInfo>(function->shared())); | |
118 const FrameStateFunctionInfo* state_info = | 116 const FrameStateFunctionInfo* state_info = |
119 common->CreateFrameStateFunctionInfo(frame_type, parameter_count, 0, | 117 common->CreateFrameStateFunctionInfo( |
120 shared); | 118 frame_type, parameter_count, 0, |
| 119 function.is_null() ? Handle<SharedFunctionInfo>() |
| 120 : Handle<SharedFunctionInfo>(function->shared())); |
121 const Operator* op = common->FrameState( | 121 const Operator* op = common->FrameState( |
122 bailout_id, OutputFrameStateCombine::Ignore(), state_info); | 122 bailout_id, OutputFrameStateCombine::Ignore(), state_info); |
123 | 123 |
124 Node* function_node = function.is_null() ? js_graph->UndefinedConstant() | 124 Node* function_node = function.is_null() ? js_graph->UndefinedConstant() |
125 : js_graph->HeapConstant(function); | 125 : js_graph->HeapConstant(function); |
126 | 126 |
127 Node* frame_state = graph->NewNode( | 127 Node* frame_state = graph->NewNode( |
128 op, params_node, js_graph->EmptyStateValues(), | 128 op, params_node, js_graph->EmptyStateValues(), |
129 js_graph->EmptyStateValues(), context, function_node, outer_frame_state); | 129 js_graph->EmptyStateValues(), context, function_node, outer_frame_state); |
130 | 130 |
131 return frame_state; | 131 return frame_state; |
132 } | 132 } |
133 } // namespace | 133 } // namespace |
134 | 134 |
135 Node* CreateStubBuiltinContinuationFrameState(JSGraph* js_graph, | 135 Node* CreateStubBuiltinContinuationFrameState(JSGraph* js_graph, |
136 Builtins::Name name, | 136 Builtins::Name name, |
137 Node* context, Node** parameters, | 137 Node* context, Node** parameters, |
138 int parameter_count, | 138 int parameter_count, |
139 Node* outer_frame_state, | 139 Node* outer_frame_state, |
140 ContinuationFrameStateMode mode) { | 140 ContinuationFrameStateMode mode) { |
141 Isolate* isolate = js_graph->isolate(); | 141 Isolate* isolate = js_graph->isolate(); |
142 Callable callable = Builtins::CallableFor(isolate, name); | 142 Callable callable = Builtins::CallableFor(isolate, name); |
143 CallInterfaceDescriptor descriptor = callable.descriptor(); | 143 CallInterfaceDescriptor descriptor = callable.descriptor(); |
144 | 144 |
145 std::vector<Node*> actual_parameters; | 145 std::vector<Node*> actual_parameters; |
146 // Stack parameters first | 146 // Stack parameters first. If the deoptimization is LAZY, the final parameter |
147 for (int i = 0; i < descriptor.GetStackParameterCount(); ++i) { | 147 // is added by the deoptimizer and isn't explicitly passed in the frame state. |
| 148 int stack_parameter_count = |
| 149 descriptor.GetRegisterParameterCount() - |
| 150 (mode == ContinuationFrameStateMode::LAZY ? 1 : 0); |
| 151 for (int i = 0; i < stack_parameter_count; ++i) { |
148 actual_parameters.push_back( | 152 actual_parameters.push_back( |
149 parameters[descriptor.GetRegisterParameterCount() + i]); | 153 parameters[descriptor.GetRegisterParameterCount() + i]); |
150 } | 154 } |
151 // Register parameters follow, context will be added by instruction selector | 155 // Register parameters follow, context will be added by instruction selector |
152 // during FrameState translation. | 156 // during FrameState translation. |
153 for (int i = 0; i < descriptor.GetRegisterParameterCount(); ++i) { | 157 for (int i = 0; i < descriptor.GetRegisterParameterCount(); ++i) { |
154 actual_parameters.push_back(parameters[i]); | 158 actual_parameters.push_back(parameters[i]); |
155 } | 159 } |
156 | 160 |
157 return CreateBuiltinContinuationFrameStateCommon( | 161 return CreateBuiltinContinuationFrameStateCommon( |
158 js_graph, name, context, &actual_parameters[0], | 162 js_graph, name, context, actual_parameters.data(), |
159 static_cast<int>(actual_parameters.size()), outer_frame_state, | 163 static_cast<int>(actual_parameters.size()), outer_frame_state, |
160 Handle<JSFunction>()); | 164 Handle<JSFunction>()); |
161 } | 165 } |
162 | 166 |
163 Node* CreateJavaScriptBuiltinContinuationFrameState( | 167 Node* CreateJavaScriptBuiltinContinuationFrameState( |
164 JSGraph* js_graph, Handle<JSFunction> function, Builtins::Name name, | 168 JSGraph* js_graph, Handle<JSFunction> function, Builtins::Name name, |
165 Node* target, Node* context, Node** stack_parameters, | 169 Node* target, Node* context, Node** stack_parameters, |
166 int stack_parameter_count, Node* outer_frame_state, | 170 int stack_parameter_count, Node* outer_frame_state, |
167 ContinuationFrameStateMode mode) { | 171 ContinuationFrameStateMode mode) { |
168 Isolate* isolate = js_graph->isolate(); | 172 Isolate* isolate = js_graph->isolate(); |
(...skipping 28 matching lines...) Expand all Loading... |
197 actual_parameters.push_back(argc); | 201 actual_parameters.push_back(argc); |
198 | 202 |
199 return CreateBuiltinContinuationFrameStateCommon( | 203 return CreateBuiltinContinuationFrameStateCommon( |
200 js_graph, name, context, &actual_parameters[0], | 204 js_graph, name, context, &actual_parameters[0], |
201 static_cast<int>(actual_parameters.size()), outer_frame_state, function); | 205 static_cast<int>(actual_parameters.size()), outer_frame_state, function); |
202 } | 206 } |
203 | 207 |
204 } // namespace compiler | 208 } // namespace compiler |
205 } // namespace internal | 209 } // namespace internal |
206 } // namespace v8 | 210 } // namespace v8 |
OLD | NEW |