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.h" | 9 #include "src/compiler.h" |
10 #include "src/compiler/all-nodes.h" | 10 #include "src/compiler/all-nodes.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 case IrOpcode::kThrow: | 182 case IrOpcode::kThrow: |
183 jsgraph_->graph()->end()->AppendInput(jsgraph_->zone(), input); | 183 jsgraph_->graph()->end()->AppendInput(jsgraph_->zone(), input); |
184 jsgraph_->graph()->end()->set_op( | 184 jsgraph_->graph()->end()->set_op( |
185 jsgraph_->common()->End(jsgraph_->graph()->end()->InputCount())); | 185 jsgraph_->common()->End(jsgraph_->graph()->end()->InputCount())); |
186 break; | 186 break; |
187 default: | 187 default: |
188 UNREACHABLE(); | 188 UNREACHABLE(); |
189 break; | 189 break; |
190 } | 190 } |
191 } | 191 } |
192 DCHECK_NE(0u, values.size()); | |
193 DCHECK_EQ(values.size(), effects.size()); | 192 DCHECK_EQ(values.size(), effects.size()); |
194 DCHECK_EQ(values.size(), controls.size()); | 193 DCHECK_EQ(values.size(), controls.size()); |
195 int const input_count = static_cast<int>(controls.size()); | |
196 Node* control_output = jsgraph_->graph()->NewNode( | |
197 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); | |
198 values.push_back(control_output); | |
199 effects.push_back(control_output); | |
200 Node* value_output = jsgraph_->graph()->NewNode( | |
201 jsgraph_->common()->Phi(kMachAnyTagged, input_count), | |
202 static_cast<int>(values.size()), &values.front()); | |
203 Node* effect_output = jsgraph_->graph()->NewNode( | |
204 jsgraph_->common()->EffectPhi(input_count), | |
205 static_cast<int>(effects.size()), &effects.front()); | |
206 | 194 |
207 ReplaceWithValue(call, value_output, effect_output, control_output); | 195 // Depending on whether the inlinee produces a value, we either replace value |
208 | 196 // uses with said value or kill value uses if no value can be returned. |
209 return Changed(value_output); | 197 if (values.size() > 0) { |
198 int const input_count = static_cast<int>(controls.size()); | |
199 Node* control_output = jsgraph_->graph()->NewNode( | |
200 jsgraph_->common()->Merge(input_count), input_count, &controls.front()); | |
201 values.push_back(control_output); | |
202 effects.push_back(control_output); | |
203 Node* value_output = jsgraph_->graph()->NewNode( | |
204 jsgraph_->common()->Phi(kMachAnyTagged, input_count), | |
205 static_cast<int>(values.size()), &values.front()); | |
206 Node* effect_output = jsgraph_->graph()->NewNode( | |
207 jsgraph_->common()->EffectPhi(input_count), | |
208 static_cast<int>(effects.size()), &effects.front()); | |
209 ReplaceWithValue(call, value_output, effect_output, control_output); | |
210 return Changed(value_output); | |
211 } else { | |
212 ReplaceWithValue(call, call, call, jsgraph_->Dead()); | |
Michael Starzinger
2015/09/15 09:44:15
Ideally this could be a helper method on AdvancedR
| |
213 return Changed(call); | |
214 } | |
210 } | 215 } |
211 | 216 |
212 | 217 |
213 Node* JSInliner::CreateArgumentsAdaptorFrameState( | 218 Node* JSInliner::CreateArgumentsAdaptorFrameState( |
214 JSCallFunctionAccessor* call, Handle<SharedFunctionInfo> shared_info, | 219 JSCallFunctionAccessor* call, Handle<SharedFunctionInfo> shared_info, |
215 Zone* temp_zone) { | 220 Zone* temp_zone) { |
216 const FrameStateFunctionInfo* state_info = | 221 const FrameStateFunctionInfo* state_info = |
217 jsgraph_->common()->CreateFrameStateFunctionInfo( | 222 jsgraph_->common()->CreateFrameStateFunctionInfo( |
218 FrameStateType::kArgumentsAdaptor, | 223 FrameStateType::kArgumentsAdaptor, |
219 static_cast<int>(call->formal_arguments()) + 1, 0, shared_info, | 224 static_cast<int>(call->formal_arguments()) + 1, 0, shared_info, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 | 365 |
361 // Remember that we inlined this function. | 366 // Remember that we inlined this function. |
362 info_->AddInlinedFunction(info.shared_info()); | 367 info_->AddInlinedFunction(info.shared_info()); |
363 | 368 |
364 return InlineCall(node, context, frame_state, start, end); | 369 return InlineCall(node, context, frame_state, start, end); |
365 } | 370 } |
366 | 371 |
367 } // namespace compiler | 372 } // namespace compiler |
368 } // namespace internal | 373 } // namespace internal |
369 } // namespace v8 | 374 } // namespace v8 |
OLD | NEW |