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/js-inlining.h" | 5 #include "src/compiler/js-inlining.h" |
6 | 6 |
7 #include "src/ast.h" | 7 #include "src/ast.h" |
8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
9 #include "src/compiler/all-nodes.h" | 9 #include "src/compiler/all-nodes.h" |
10 #include "src/compiler/ast-graph-builder.h" | 10 #include "src/compiler/ast-graph-builder.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 private: | 109 private: |
110 Operator const sentinel_op_; | 110 Operator const sentinel_op_; |
111 Node* const sentinel_; | 111 Node* const sentinel_; |
112 NodeVector copies_; | 112 NodeVector copies_; |
113 Graph* const source_graph_; | 113 Graph* const source_graph_; |
114 Graph* const target_graph_; | 114 Graph* const target_graph_; |
115 Zone* const temp_zone_; | 115 Zone* const temp_zone_; |
116 }; | 116 }; |
117 | 117 |
118 | 118 |
119 Reduction JSInliner::InlineCall(Node* call, Node* start, Node* end) { | 119 Reduction JSInliner::InlineCall(Node* call, Node* frame_state, Node* start, |
| 120 Node* end) { |
120 // The scheduler is smart enough to place our code; we just ensure {control} | 121 // The scheduler is smart enough to place our code; we just ensure {control} |
121 // becomes the control input of the start of the inlinee, and {effect} becomes | 122 // becomes the control input of the start of the inlinee, and {effect} becomes |
122 // the effect input of the start of the inlinee. | 123 // the effect input of the start of the inlinee. |
123 Node* control = NodeProperties::GetControlInput(call); | 124 Node* control = NodeProperties::GetControlInput(call); |
124 Node* effect = NodeProperties::GetEffectInput(call); | 125 Node* effect = NodeProperties::GetEffectInput(call); |
125 | 126 |
126 // Context is last argument. | 127 // Context is last argument. |
127 int const inlinee_context_index = | 128 int const inlinee_context_index = |
128 static_cast<int>(start->op()->ValueOutputCount()) - 1; | 129 static_cast<int>(start->op()->ValueOutputCount()) - 1; |
129 | 130 |
(...skipping 21 matching lines...) Expand all Loading... |
151 // We got too many arguments, discard for now. | 152 // We got too many arguments, discard for now. |
152 // TODO(sigurds): Fix to treat arguments array correctly. | 153 // TODO(sigurds): Fix to treat arguments array correctly. |
153 } | 154 } |
154 break; | 155 break; |
155 } | 156 } |
156 default: | 157 default: |
157 if (NodeProperties::IsEffectEdge(edge)) { | 158 if (NodeProperties::IsEffectEdge(edge)) { |
158 edge.UpdateTo(effect); | 159 edge.UpdateTo(effect); |
159 } else if (NodeProperties::IsControlEdge(edge)) { | 160 } else if (NodeProperties::IsControlEdge(edge)) { |
160 edge.UpdateTo(control); | 161 edge.UpdateTo(control); |
| 162 } else if (NodeProperties::IsFrameStateEdge(edge)) { |
| 163 edge.UpdateTo(frame_state); |
161 } else { | 164 } else { |
162 UNREACHABLE(); | 165 UNREACHABLE(); |
163 } | 166 } |
164 break; | 167 break; |
165 } | 168 } |
166 } | 169 } |
167 | 170 |
168 NodeVector values(local_zone_); | 171 NodeVector values(local_zone_); |
169 NodeVector effects(local_zone_); | 172 NodeVector effects(local_zone_); |
170 NodeVector controls(local_zone_); | 173 NodeVector controls(local_zone_); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 GraphReducer graph_reducer(&graph, local_zone_); | 280 GraphReducer graph_reducer(&graph, local_zone_); |
278 graph_reducer.AddReducer(&context_specializer); | 281 graph_reducer.AddReducer(&context_specializer); |
279 graph_reducer.ReduceGraph(); | 282 graph_reducer.ReduceGraph(); |
280 | 283 |
281 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); | 284 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); |
282 visitor.CopyGraph(); | 285 visitor.CopyGraph(); |
283 | 286 |
284 Node* start = visitor.GetCopy(graph.start()); | 287 Node* start = visitor.GetCopy(graph.start()); |
285 Node* end = visitor.GetCopy(graph.end()); | 288 Node* end = visitor.GetCopy(graph.end()); |
286 | 289 |
287 Node* outer_frame_state = call.frame_state(); | 290 Node* frame_state = call.frame_state(); |
288 size_t const inlinee_formal_parameters = start->op()->ValueOutputCount() - 3; | 291 size_t const inlinee_formal_parameters = start->op()->ValueOutputCount() - 3; |
289 // Insert argument adaptor frame if required. | 292 // Insert argument adaptor frame if required. |
290 if (call.formal_arguments() != inlinee_formal_parameters) { | 293 if (call.formal_arguments() != inlinee_formal_parameters) { |
291 // In strong mode, in case of too few arguments we need to throw a | 294 // In strong mode, in case of too few arguments we need to throw a |
292 // TypeError so we must not inline this call. | 295 // TypeError so we must not inline this call. |
293 if (is_strong(info.language_mode()) && | 296 if (is_strong(info.language_mode()) && |
294 call.formal_arguments() < inlinee_formal_parameters) { | 297 call.formal_arguments() < inlinee_formal_parameters) { |
295 return NoChange(); | 298 return NoChange(); |
296 } | 299 } |
297 outer_frame_state = CreateArgumentsAdaptorFrameState(&call, info.zone()); | 300 frame_state = CreateArgumentsAdaptorFrameState(&call, info.zone()); |
298 } | 301 } |
299 | 302 |
300 // Fix up all outer frame states from the inlinee. | 303 return InlineCall(node, frame_state, start, end); |
301 for (Node* const node : visitor.copies()) { | |
302 if (node->opcode() == IrOpcode::kFrameState) { | |
303 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | |
304 // Don't touch this frame state, if it already has an "outer frame state". | |
305 if (NodeProperties::GetFrameStateInput(node, 0)->opcode() != | |
306 IrOpcode::kFrameState) { | |
307 NodeProperties::ReplaceFrameStateInput(node, 0, outer_frame_state); | |
308 } | |
309 } | |
310 } | |
311 | |
312 return InlineCall(node, start, end); | |
313 } | 304 } |
314 | 305 |
315 } // namespace compiler | 306 } // namespace compiler |
316 } // namespace internal | 307 } // namespace internal |
317 } // namespace v8 | 308 } // namespace v8 |
OLD | NEW |