blob: b5d4f961fe52ebe5ee4f2f30b7b9e6780374c07f [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
10namespace v8 {
11namespace internal {
12namespace compiler {
13
14// Forward declarations.
15class CommonOperatorBuilder;
16class Graph;
17
18
19// Performs tail call optimization by replacing certain combinations of Return
20// and Call nodes with a single TailCall.
21class TailCallOptimization final : public Reducer {
22 public:
23 TailCallOptimization(CommonOperatorBuilder* common, Graph* graph)
24 : common_(common), graph_(graph) {}
25
26 Reduction Reduce(Node* node) final;
27
28 private:
29 CommonOperatorBuilder* common() const { return common_; }
30 Graph* graph() const { return graph_; }
31
32 CommonOperatorBuilder* const common_;
33 Graph* const graph_;
34};
35
36} // namespace compiler
37} // namespace internal
38} // namespace v8
39
40#endif // V8_COMPILER_TAIL_CALL_OPTIMIZATION_H_