OLD | NEW |
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/compiler/access-builder.h" |
5 #include "src/compiler/ast-graph-builder.h" | 6 #include "src/compiler/ast-graph-builder.h" |
6 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
8 #include "src/compiler/graph-inl.h" | 9 #include "src/compiler/graph-inl.h" |
9 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
10 #include "src/compiler/js-inlining.h" | 11 #include "src/compiler/js-inlining.h" |
11 #include "src/compiler/js-operator.h" | 12 #include "src/compiler/js-operator.h" |
12 #include "src/compiler/node-aux-data-inl.h" | 13 #include "src/compiler/node-aux-data-inl.h" |
13 #include "src/compiler/node-matchers.h" | 14 #include "src/compiler/node-matchers.h" |
14 #include "src/compiler/node-properties-inl.h" | 15 #include "src/compiler/node-properties-inl.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 graph->NewNode(op_phi, static_cast<int>(values.size()), &values.front()); | 150 graph->NewNode(op_phi, static_cast<int>(values.size()), &values.front()); |
150 Node* ephi = graph->NewNode(op_ephi, static_cast<int>(effects.size()), | 151 Node* ephi = graph->NewNode(op_ephi, static_cast<int>(effects.size()), |
151 &effects.front()); | 152 &effects.front()); |
152 Node* new_return = | 153 Node* new_return = |
153 graph->NewNode(jsgraph_->common()->Return(), phi, ephi, final_merge); | 154 graph->NewNode(jsgraph_->common()->Return(), phi, ephi, final_merge); |
154 graph->end()->ReplaceInput(0, new_return); | 155 graph->end()->ReplaceInput(0, new_return); |
155 } | 156 } |
156 | 157 |
157 | 158 |
158 void Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) { | 159 void Inlinee::InlineAtCall(JSGraph* jsgraph, Node* call) { |
159 MachineOperatorBuilder machine(jsgraph->zone()); | |
160 | |
161 // The scheduler is smart enough to place our code; we just ensure {control} | 160 // The scheduler is smart enough to place our code; we just ensure {control} |
162 // becomes the control input of the start of the inlinee. | 161 // becomes the control input of the start of the inlinee. |
163 Node* control = NodeProperties::GetControlInput(call); | 162 Node* control = NodeProperties::GetControlInput(call); |
164 | 163 |
165 // The inlinee uses the context from the JSFunction object. This will | 164 // The inlinee uses the context from the JSFunction object. This will |
166 // also be the effect dependency for the inlinee as it produces an effect. | 165 // also be the effect dependency for the inlinee as it produces an effect. |
167 // TODO(sigurds) Use simplified load once it is ready. | 166 SimplifiedOperatorBuilder simplified(jsgraph->zone()); |
168 Node* context = jsgraph->graph()->NewNode( | 167 Node* context = jsgraph->graph()->NewNode( |
169 machine.Load(kMachAnyTagged), NodeProperties::GetValueInput(call, 0), | 168 simplified.LoadField(AccessBuilder::ForJSFunctionContext()), |
170 jsgraph->Int32Constant(JSFunction::kContextOffset - kHeapObjectTag), | 169 NodeProperties::GetValueInput(call, 0), |
171 NodeProperties::GetEffectInput(call)); | 170 NodeProperties::GetEffectInput(call)); |
172 | 171 |
173 // {inlinee_inputs} counts JSFunction, Receiver, arguments, context, | 172 // {inlinee_inputs} counts JSFunction, Receiver, arguments, context, |
174 // but not effect, control. | 173 // but not effect, control. |
175 int inlinee_inputs = graph()->start()->op()->OutputCount(); | 174 int inlinee_inputs = graph()->start()->op()->OutputCount(); |
176 // Context is last argument. | 175 // Context is last argument. |
177 int inlinee_context_index = inlinee_inputs - 1; | 176 int inlinee_context_index = inlinee_inputs - 1; |
178 // {inliner_inputs} counts JSFunction, Receiver, arguments, but not | 177 // {inliner_inputs} counts JSFunction, Receiver, arguments, but not |
179 // context, effect, control. | 178 // context, effect, control. |
180 int inliner_inputs = OperatorProperties::GetValueInputCount(call->op()); | 179 int inliner_inputs = OperatorProperties::GetValueInputCount(call->op()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 286 |
288 Inlinee inlinee(&jsgraph); | 287 Inlinee inlinee(&jsgraph); |
289 inlinee.UnifyReturn(); | 288 inlinee.UnifyReturn(); |
290 inlinee.InlineAtCall(jsgraph_, node); | 289 inlinee.InlineAtCall(jsgraph_, node); |
291 | 290 |
292 jsgraph_->graph()->SetNextNodeId(inlinee.graph()->NextNodeID()); | 291 jsgraph_->graph()->SetNextNodeId(inlinee.graph()->NextNodeID()); |
293 } | 292 } |
294 } | 293 } |
295 } | 294 } |
296 } // namespace v8::internal::compiler | 295 } // namespace v8::internal::compiler |
OLD | NEW |