js-inlining.h 2.72 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_JS_INLINING_H_
#define V8_COMPILER_JS_INLINING_H_

8
#include "src/compiler/graph-reducer.h"
9
#include "src/compiler/js-graph.h"
10 11 12

namespace v8 {
namespace internal {
13

14
class BailoutId;
15
class OptimizedCompilationInfo;
16

17 18
namespace compiler {

19 20
class SourcePositionTable;

21 22 23
// The JSInliner provides the core graph inlining machinery. Note that this
// class only deals with the mechanics of how to inline one graph into another,
// heuristics that decide what and how much to inline are beyond its scope.
24
class JSInliner final : public AdvancedReducer {
25
 public:
26
  JSInliner(Editor* editor, Zone* local_zone, OptimizedCompilationInfo* info,
27
            JSGraph* jsgraph, SourcePositionTable* source_positions)
28 29 30
      : AdvancedReducer(editor),
        local_zone_(local_zone),
        info_(info),
31 32
        jsgraph_(jsgraph),
        source_positions_(source_positions) {}
33

34 35
  const char* reducer_name() const override { return "JSInliner"; }

36
  // Reducer interface, eagerly inlines everything.
37
  Reduction Reduce(Node* node) final;
38

39 40
  // Can be used by inlining heuristics or by testing code directly, without
  // using the above generic reducer interface of the inlining machinery.
41
  Reduction ReduceJSCall(Node* node);
42

43
 private:
44
  Zone* zone() const { return local_zone_; }
45 46
  CommonOperatorBuilder* common() const;
  JSOperatorBuilder* javascript() const;
47
  SimplifiedOperatorBuilder* simplified() const;
48 49
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
50
  Isolate* isolate() const { return jsgraph_->isolate(); }
51
  Handle<Context> native_context() const;
52 53

  Zone* const local_zone_;
54
  OptimizedCompilationInfo* info_;
55
  JSGraph* const jsgraph_;
56
  SourcePositionTable* const source_positions_;
57

58 59 60
  bool DetermineCallTarget(Node* node,
                           Handle<SharedFunctionInfo>& shared_info_out);
  void DetermineCallContext(Node* node, Node*& context_out,
61
                            Handle<FeedbackVector>& feedback_vector_out);
62

63
  Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
64
                                   int parameter_count, BailoutId bailout_id,
65 66
                                   FrameStateType frame_state_type,
                                   Handle<SharedFunctionInfo> shared);
67

68
  Reduction InlineCall(Node* call, Node* new_target, Node* context,
69 70 71
                       Node* frame_state, Node* start, Node* end,
                       Node* exception_target,
                       const NodeVector& uncaught_subcalls);
72
};
73 74 75 76

}  // namespace compiler
}  // namespace internal
}  // namespace v8
77 78

#endif  // V8_COMPILER_JS_INLINING_H_