blob: d0ab7c0583379d255526e745a4cf5032e2c16188 [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:
Emily Bernierd0a1eb72015-03-24 16:35:39 -040039 Zone* local_zone_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000040 CompilationInfo* info_;
41 JSGraph* jsgraph_;
42
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000043 Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
44 int parameter_count,
45 FrameStateType frame_state_type,
46 Handle<SharedFunctionInfo> shared);
47
Ben Murdochda12d292016-06-02 14:46:10 +010048 Node* CreateTailCallerFrameState(Node* node, Node* outer_frame_state);
49
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000050 Reduction InlineCall(Node* call, Node* new_target, Node* context,
51 Node* frame_state, Node* start, Node* end);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053
54} // namespace compiler
55} // namespace internal
56} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +000057
58#endif // V8_COMPILER_JS_INLINING_H_