blob: 88cbf89128089a203651c0da3424fba386b67ae4 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_JS_INLINING_H_
6#define V8_COMPILER_JS_INLINING_H_
7
8#include "src/compiler/js-graph.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009#include "src/compiler/graph-reducer.h"
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010
11namespace v8 {
12namespace internal {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000013
14// Forward declarations.
15class CompilationInfo;
16
Ben Murdochb8a8cc12014-11-26 15:28:44 +000017namespace compiler {
18
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000019// The JSInliner provides the core graph inlining machinery. Note that this
20// class only deals with the mechanics of how to inline one graph into another,
21// heuristics that decide what and how much to inline are beyond its scope.
22class JSInliner final : public AdvancedReducer {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000023 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000024 JSInliner(Editor* editor, Zone* local_zone, CompilationInfo* info,
25 JSGraph* jsgraph)
26 : AdvancedReducer(editor),
27 local_zone_(local_zone),
28 info_(info),
29 jsgraph_(jsgraph) {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000030
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000031 // Reducer interface, eagerly inlines everything.
32 Reduction Reduce(Node* node) final;
33
34 // Can be used by inlining heuristics or by testing code directly, without
35 // using the above generic reducer interface of the inlining machinery.
36 Reduction ReduceJSCall(Node* node, Handle<JSFunction> function);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000037
38 private:
Ben Murdoch61f157c2016-09-16 13:49:30 +010039 Graph* graph() const;
40 JSGraph* jsgraph() const { return jsgraph_; }
41
42 Zone* const local_zone_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000043 CompilationInfo* info_;
Ben Murdoch61f157c2016-09-16 13:49:30 +010044 JSGraph* const jsgraph_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000045
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000046 Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
47 int parameter_count,
48 FrameStateType frame_state_type,
49 Handle<SharedFunctionInfo> shared);
50
Ben Murdochda12d292016-06-02 14:46:10 +010051 Node* CreateTailCallerFrameState(Node* node, Node* outer_frame_state);
52
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053 Reduction InlineCall(Node* call, Node* new_target, Node* context,
54 Node* frame_state, Node* start, Node* end);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000055};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000056
57} // namespace compiler
58} // namespace internal
59} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000060
61#endif // V8_COMPILER_JS_INLINING_H_