1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_TAIL_CALL_OPTIMIZATION_H_ 6 #define V8_COMPILER_TAIL_CALL_OPTIMIZATION_H_ 7 8 #include "src/compiler/graph-reducer.h" 9 #include "src/globals.h" 10 11 namespace v8 { 12 namespace internal { 13 namespace compiler { 14 15 // Forward declarations. 16 class CommonOperatorBuilder; 17 class Graph; 18 19 20 // Performs tail call optimization by replacing certain combinations of Return 21 // and Call nodes with a single TailCall. 22 class V8_EXPORT_PRIVATE TailCallOptimization final : public Reducer { 23 public: 24 TailCallOptimization(CommonOperatorBuilder* common, Graph* graph) 25 : common_(common), graph_(graph) {} 26 27 Reduction Reduce(Node* node) final; 28 29 private: 30 CommonOperatorBuilder* common() const { return common_; } 31 Graph* graph() const { return graph_; } 32 33 CommonOperatorBuilder* const common_; 34 Graph* const graph_; 35 }; 36 37 } // namespace compiler 38 } // namespace internal 39 } // namespace v8 40 41 #endif // V8_COMPILER_TAIL_CALL_OPTIMIZATION_H_ 42