| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 return NoChange(); | 342 return NoChange(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 if (!Compiler::EnsureDeoptimizationSupport(&info)) { | 345 if (!Compiler::EnsureDeoptimizationSupport(&info)) { |
| 346 TRACE("Not inlining %s into %s because deoptimization support failed\n", | 346 TRACE("Not inlining %s into %s because deoptimization support failed\n", |
| 347 function->shared()->DebugName()->ToCString().get(), | 347 function->shared()->DebugName()->ToCString().get(), |
| 348 info_->shared_info()->DebugName()->ToCString().get()); | 348 info_->shared_info()->DebugName()->ToCString().get()); |
| 349 return NoChange(); | 349 return NoChange(); |
| 350 } | 350 } |
| 351 // Remember that we inlined this function. This needs to be called right |
| 352 // after we ensure deoptimization support so that the code flusher |
| 353 // does not remove the code with the deoptimization support. |
| 354 info_->AddInlinedFunction(info.shared_info()); |
| 355 |
| 356 // ---------------------------------------------------------------- |
| 357 // After this point, we've made a decision to inline this function. |
| 358 // We shall not bailout from inlining if we got here. |
| 351 | 359 |
| 352 TRACE("Inlining %s into %s\n", | 360 TRACE("Inlining %s into %s\n", |
| 353 function->shared()->DebugName()->ToCString().get(), | 361 function->shared()->DebugName()->ToCString().get(), |
| 354 info_->shared_info()->DebugName()->ToCString().get()); | 362 info_->shared_info()->DebugName()->ToCString().get()); |
| 355 | 363 |
| 356 Graph graph(info.zone()); | 364 Graph graph(info.zone()); |
| 357 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), | 365 JSGraph jsgraph(info.isolate(), &graph, jsgraph_->common(), |
| 358 jsgraph_->javascript(), jsgraph_->simplified(), | 366 jsgraph_->javascript(), jsgraph_->simplified(), |
| 359 jsgraph_->machine()); | 367 jsgraph_->machine()); |
| 360 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); | 368 AstGraphBuilder graph_builder(local_zone_, &info, &jsgraph); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 400 |
| 393 Node* start = visitor.GetCopy(graph.start()); | 401 Node* start = visitor.GetCopy(graph.start()); |
| 394 Node* end = visitor.GetCopy(graph.end()); | 402 Node* end = visitor.GetCopy(graph.end()); |
| 395 | 403 |
| 396 Node* frame_state = call.frame_state(); | 404 Node* frame_state = call.frame_state(); |
| 397 size_t const inlinee_formal_parameters = start->op()->ValueOutputCount() - 3; | 405 size_t const inlinee_formal_parameters = start->op()->ValueOutputCount() - 3; |
| 398 // Insert argument adaptor frame if required. | 406 // Insert argument adaptor frame if required. |
| 399 if (call.formal_arguments() != inlinee_formal_parameters) { | 407 if (call.formal_arguments() != inlinee_formal_parameters) { |
| 400 // In strong mode, in case of too few arguments we need to throw a | 408 // In strong mode, in case of too few arguments we need to throw a |
| 401 // TypeError so we must not inline this call. | 409 // TypeError so we must not inline this call. |
| 410 // TODO(jarin) This check should be moved before the decision point |
| 411 // above so that we do not compile the function uselessly. |
| 402 if (is_strong(info.language_mode()) && | 412 if (is_strong(info.language_mode()) && |
| 403 call.formal_arguments() < inlinee_formal_parameters) { | 413 call.formal_arguments() < inlinee_formal_parameters) { |
| 404 return NoChange(); | 414 return NoChange(); |
| 405 } | 415 } |
| 406 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info(), | 416 frame_state = CreateArgumentsAdaptorFrameState(&call, info.shared_info(), |
| 407 info.zone()); | 417 info.zone()); |
| 408 } | 418 } |
| 409 | 419 |
| 410 // Remember that we inlined this function. | |
| 411 info_->AddInlinedFunction(info.shared_info()); | |
| 412 | |
| 413 return InlineCall(node, context, frame_state, start, end); | 420 return InlineCall(node, context, frame_state, start, end); |
| 414 } | 421 } |
| 415 | 422 |
| 416 } // namespace compiler | 423 } // namespace compiler |
| 417 } // namespace internal | 424 } // namespace internal |
| 418 } // namespace v8 | 425 } // namespace v8 |
| OLD | NEW |