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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ReplaceWithValue(call, value_output, effect_output, control_output); | 210 ReplaceWithValue(call, value_output, effect_output, control_output); |
211 return Changed(value_output); | 211 return Changed(value_output); |
212 } else { | 212 } else { |
213 ReplaceWithValue(call, call, call, jsgraph_->Dead()); | 213 ReplaceWithValue(call, call, call, jsgraph_->Dead()); |
214 return Changed(call); | 214 return Changed(call); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 | 218 |
219 Node* JSInliner::CreateArgumentsAdaptorFrameState( | 219 Node* JSInliner::CreateArgumentsAdaptorFrameState( |
220 JSCallFunctionAccessor* call, Handle<SharedFunctionInfo> shared_info, | 220 JSCallFunctionAccessor* call, Handle<SharedFunctionInfo> shared_info) { |
221 Zone* temp_zone) { | |
222 const FrameStateFunctionInfo* state_info = | 221 const FrameStateFunctionInfo* state_info = |
223 jsgraph_->common()->CreateFrameStateFunctionInfo( | 222 jsgraph_->common()->CreateFrameStateFunctionInfo( |
224 FrameStateType::kArgumentsAdaptor, | 223 FrameStateType::kArgumentsAdaptor, |
225 static_cast<int>(call->formal_arguments()) + 1, 0, shared_info, | 224 static_cast<int>(call->formal_arguments()) + 1, 0, shared_info, |
226 CALL_MAINTAINS_NATIVE_CONTEXT); | 225 CALL_MAINTAINS_NATIVE_CONTEXT); |
227 | 226 |
228 const Operator* op = jsgraph_->common()->FrameState( | 227 const Operator* op = jsgraph_->common()->FrameState( |
229 BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info); | 228 BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info); |
230 const Operator* op0 = jsgraph_->common()->StateValues(0); | 229 const Operator* op0 = jsgraph_->common()->StateValues(0); |
231 Node* node0 = jsgraph_->graph()->NewNode(op0); | 230 Node* node0 = jsgraph_->graph()->NewNode(op0); |
232 NodeVector params(temp_zone); | 231 NodeVector params(local_zone_); |
233 params.push_back(call->receiver()); | 232 params.push_back(call->receiver()); |
234 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) { | 233 for (size_t argument = 0; argument != call->formal_arguments(); ++argument) { |
235 params.push_back(call->formal_argument(argument)); | 234 params.push_back(call->formal_argument(argument)); |
236 } | 235 } |
237 const Operator* op_param = | 236 const Operator* op_param = |
238 jsgraph_->common()->StateValues(static_cast<int>(params.size())); | 237 jsgraph_->common()->StateValues(static_cast<int>(params.size())); |
239 Node* params_node = jsgraph_->graph()->NewNode( | 238 Node* params_node = jsgraph_->graph()->NewNode( |
240 op_param, static_cast<int>(params.size()), ¶ms.front()); | 239 op_param, static_cast<int>(params.size()), ¶ms.front()); |
241 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, | 240 return jsgraph_->graph()->NewNode(op, params_node, node0, node0, |
242 jsgraph_->UndefinedConstant(), | 241 jsgraph_->UndefinedConstant(), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 } | 310 } |
312 | 311 |
313 // TODO(turbofan): Inlining into a try-block is not yet supported. | 312 // TODO(turbofan): Inlining into a try-block is not yet supported. |
314 if (NodeProperties::IsExceptionalCall(node)) { | 313 if (NodeProperties::IsExceptionalCall(node)) { |
315 TRACE("Not inlining %s into %s because of surrounding try-block\n", | 314 TRACE("Not inlining %s into %s because of surrounding try-block\n", |
316 function->shared()->DebugName()->ToCString().get(), | 315 function->shared()->DebugName()->ToCString().get(), |
317 info_->shared_info()->DebugName()->ToCString().get()); | 316 info_->shared_info()->DebugName()->ToCString().get()); |
318 return NoChange(); | 317 return NoChange(); |
319 } | 318 } |
320 | 319 |
321 // TODO(mstarzinger): The correct thing would be to use a local zone here for | 320 Zone zone; |
322 // the inner graph. This however leads to Zone-Types being allocated in the | 321 ParseInfo parse_info(&zone, function); |
323 // wrong zone and makes the engine explode at high speeds. Explosion bad! | |
324 // Zone zone; | |
325 // ParseInfo parse_info(&zone, function); | |
326 ParseInfo parse_info(jsgraph_->zone(), function); | |
327 CompilationInfo info(&parse_info); | 322 CompilationInfo info(&parse_info); |
328 if (info_->is_deoptimization_enabled()) { | 323 if (info_->is_deoptimization_enabled()) { |
329 info.MarkAsDeoptimizationEnabled(); | 324 info.MarkAsDeoptimizationEnabled(); |
330 } | 325 } |
331 if (info_->is_native_context_specializing()) { | 326 if (info_->is_native_context_specializing()) { |
332 info.MarkAsNativeContextSpecializing(); | 327 info.MarkAsNativeContextSpecializing(); |
333 } | 328 } |
334 | 329 |
335 if (!Compiler::ParseAndAnalyze(info.parse_info())) { | 330 if (!Compiler::ParseAndAnalyze(info.parse_info())) { |
336 TRACE("Not inlining %s into %s because parsing failed\n", | 331 TRACE("Not inlining %s into %s because parsing failed\n", |
(...skipping 28 matching lines...) Expand all Loading... |
365 info_->AddInlinedFunction(info.shared_info()); | 360 info_->AddInlinedFunction(info.shared_info()); |
366 | 361 |
367 // ---------------------------------------------------------------- | 362 // ---------------------------------------------------------------- |
368 // After this point, we've made a decision to inline this function. | 363 // After this point, we've made a decision to inline this function. |
369 // We shall not bailout from inlining if we got here. | 364 // We shall not bailout from inlining if we got here. |
370 | 365 |
371 TRACE("Inlining %s into %s\n", | 366 TRACE("Inlining %s into %s\n", |
372 function->shared()->DebugName()->ToCString().get(), | 367 function->shared()->DebugName()->ToCString().get(), |
373 info_->shared_info()->DebugName()->ToCString().get()); | 368 info_->shared_info()->DebugName()->ToCString().get()); |
374 | 369 |
375 Graph graph(info.zone()); | 370 // TODO(mstarzinger): We could use the temporary zone for the graph because |
| 371 // nodes are copied. This however leads to Zone-Types being allocated in the |
| 372 // wrong zone and makes the engine explode at high speeds. Explosion bad! |
| 373 Graph graph(jsgraph_->zone()); |
376 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), | 374 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), |
377 jsgraph_->javascript(), jsgraph_->simplified(), | 375 jsgraph_->javascript(), jsgraph_->simplified(), |
378 jsgraph_->machine()); | 376 jsgraph_->machine()); |
379 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); | 377 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
380 graph_builder.CreateGraph(false); | 378 graph_builder.CreateGraph(false); |
381 | 379 |
382 // TODO(mstarzinger): Unify this with the Pipeline once JSInliner refactoring | 380 // TODO(mstarzinger): Unify this with the Pipeline once JSInliner refactoring |
383 // starts. | 381 // starts. |
384 if (info.is_native_context_specializing()) { | 382 if (info.is_native_context_specializing()) { |
385 GraphReducer graph_reducer(local_zone_, &graph, jsgraph.Dead()); | 383 GraphReducer graph_reducer(local_zone_, &graph, jsgraph.Dead()); |
(...skipping 13 matching lines...) Expand all Loading... |
399 graph_reducer.AddReducer(&native_context_specialization); | 397 graph_reducer.AddReducer(&native_context_specialization); |
400 graph_reducer.ReduceGraph(); | 398 graph_reducer.ReduceGraph(); |
401 } | 399 } |
402 | 400 |
403 // The inlinee specializes to the context from the JSFunction object. | 401 // The inlinee specializes to the context from the JSFunction object. |
404 // TODO(turbofan): We might want to load the context from the JSFunction at | 402 // TODO(turbofan): We might want to load the context from the JSFunction at |
405 // runtime in case we only know the SharedFunctionInfo once we have dynamic | 403 // runtime in case we only know the SharedFunctionInfo once we have dynamic |
406 // type feedback in the compiler. | 404 // type feedback in the compiler. |
407 Node* context = jsgraph_->Constant(handle(function->context())); | 405 Node* context = jsgraph_->Constant(handle(function->context())); |
408 | 406 |
409 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); | 407 CopyVisitor visitor(&graph, jsgraph_->graph(), &zone); |
410 visitor.CopyGraph(); | 408 visitor.CopyGraph(); |
411 | 409 |
412 Node* start = visitor.GetCopy(graph.start()); | 410 Node* start = visitor.GetCopy(graph.start()); |
413 Node* end = visitor.GetCopy(graph.end()); | 411 Node* end = visitor.GetCopy(graph.end()); |
414 Node* frame_state = call.frame_state(); | 412 Node* frame_state = call.frame_state(); |
415 | 413 |
416 // Insert argument adaptor frame if required. The callees formal parameter | 414 // Insert argument adaptor frame if required. The callees formal parameter |
417 // count (i.e. value outputs of start node minus target, receiver & context) | 415 // count (i.e. value outputs of start node minus target, receiver & context) |
418 // have to match the number of arguments passed to the call. | 416 // have to match the number of arguments passed to the call. |
419 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 3); | 417 DCHECK_EQ(parameter_count, start->op()->ValueOutputCount() - 3); |
420 if (call.formal_arguments() != parameter_count) { | 418 if (call.formal_arguments() != parameter_count) { |
421 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info(), | 419 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info()); |
422 info.zone()); | |
423 } | 420 } |
424 | 421 |
425 return InlineCall(node, context, frame_state, start, end); | 422 return InlineCall(node, context, frame_state, start, end); |
426 } | 423 } |
427 | 424 |
428 } // namespace compiler | 425 } // namespace compiler |
429 } // namespace internal | 426 } // namespace internal |
430 } // namespace v8 | 427 } // namespace v8 |
OLD | NEW |