| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 Node* frame_state() { return NodeProperties::GetFrameStateInput(call_, 0); } | 55 Node* frame_state() { return NodeProperties::GetFrameStateInput(call_, 0); } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 Node* call_; | 58 Node* call_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 | 61 |
| 62 namespace { | 62 namespace { |
| 63 | 63 |
| 64 // A facade on a JSFunction's graph to facilitate inlining. It assumes the | 64 // A facade on a JSFunction's graph to facilitate inlining. It assumes |
| 65 // that the function graph has only one return statement, and provides | 65 // that the function graph has only one return statement, and provides |
| 66 // {UnifyReturn} to convert a function graph to that end. | 66 // {UnifyReturn} to convert a function graph to that end. |
| 67 class Inlinee { | 67 class Inlinee { |
| 68 public: | 68 public: |
| 69 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} | 69 Inlinee(Node* start, Node* end) : start_(start), end_(end) {} |
| 70 | 70 |
| 71 // Returns the last regular control node, that is | 71 // Returns the last regular control node, that is |
| 72 // the last control node before the end node. | 72 // the last control node before the end node. |
| 73 Node* end_block() { return NodeProperties::GetControlInput(unique_return()); } | 73 Node* end_block() { return NodeProperties::GetControlInput(unique_return()); } |
| 74 | 74 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 Inlinee::UnifyReturn(&jsgraph); | 356 Inlinee::UnifyReturn(&jsgraph); |
| 357 | 357 |
| 358 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); | 358 CopyVisitor visitor(&graph, jsgraph_->graph(), info.zone()); |
| 359 visitor.CopyGraph(); | 359 visitor.CopyGraph(); |
| 360 | 360 |
| 361 Inlinee inlinee(visitor.GetCopy(graph.start()), visitor.GetCopy(graph.end())); | 361 Inlinee inlinee(visitor.GetCopy(graph.start()), visitor.GetCopy(graph.end())); |
| 362 | 362 |
| 363 Node* outer_frame_state = call.frame_state(); | 363 Node* outer_frame_state = call.frame_state(); |
| 364 // Insert argument adaptor frame if required. | 364 // Insert argument adaptor frame if required. |
| 365 if (call.formal_arguments() != inlinee.formal_parameters()) { | 365 if (call.formal_arguments() != inlinee.formal_parameters()) { |
| 366 // In strong mode, in case of too few arguments we need to throw a |
| 367 // TypeError so we must not inline this call. |
| 368 if (is_strong(info.language_mode()) && |
| 369 call.formal_arguments() < inlinee.formal_parameters()) { |
| 370 return NoChange(); |
| 371 } |
| 366 outer_frame_state = | 372 outer_frame_state = |
| 367 CreateArgumentsAdaptorFrameState(&call, function, info.zone()); | 373 CreateArgumentsAdaptorFrameState(&call, function, info.zone()); |
| 368 } | 374 } |
| 369 | 375 |
| 370 for (Node* node : visitor.copies()) { | 376 for (Node* node : visitor.copies()) { |
| 371 if (node && node->opcode() == IrOpcode::kFrameState) { | 377 if (node && node->opcode() == IrOpcode::kFrameState) { |
| 372 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); | 378 DCHECK_EQ(1, OperatorProperties::GetFrameStateInputCount(node->op())); |
| 373 AddClosureToFrameState(node, function); | 379 AddClosureToFrameState(node, function); |
| 374 NodeProperties::ReplaceFrameStateInput(node, 0, outer_frame_state); | 380 NodeProperties::ReplaceFrameStateInput(node, 0, outer_frame_state); |
| 375 } | 381 } |
| 376 } | 382 } |
| 377 | 383 |
| 378 return inlinee.InlineAtCall(jsgraph_, node); | 384 return inlinee.InlineAtCall(jsgraph_, node); |
| 379 } | 385 } |
| 380 | 386 |
| 381 } // namespace compiler | 387 } // namespace compiler |
| 382 } // namespace internal | 388 } // namespace internal |
| 383 } // namespace v8 | 389 } // namespace v8 |
| OLD | NEW |