LCOV - code coverage report
Current view: top level - src/compiler - js-inlining-heuristic.h (source / functions) Hit Total Coverage
Test: app.info Lines: 3 3 100.0 %
Date: 2017-04-26 Functions: 1 2 50.0 %

          Line data    Source code
       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_JS_INLINING_HEURISTIC_H_
       6             : #define V8_COMPILER_JS_INLINING_HEURISTIC_H_
       7             : 
       8             : #include "src/compiler/js-inlining.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : namespace compiler {
      13             : 
      14      790686 : class JSInliningHeuristic final : public AdvancedReducer {
      15             :  public:
      16             :   enum Mode { kGeneralInlining, kRestrictedInlining, kStressInlining };
      17             :   JSInliningHeuristic(Editor* editor, Mode mode, Zone* local_zone,
      18             :                       CompilationInfo* info, JSGraph* jsgraph,
      19             :                       SourcePositionTable* source_positions)
      20             :       : AdvancedReducer(editor),
      21             :         mode_(mode),
      22             :         inliner_(editor, local_zone, info, jsgraph, source_positions),
      23             :         candidates_(local_zone),
      24             :         seen_(local_zone),
      25      790684 :         jsgraph_(jsgraph) {}
      26             : 
      27             :   Reduction Reduce(Node* node) final;
      28             : 
      29             :   // Processes the list of candidates gathered while the reducer was running,
      30             :   // and inlines call sites that the heuristic determines to be important.
      31             :   void Finalize() final;
      32             : 
      33             :  private:
      34             :   // This limit currently matches what Crankshaft does. We may want to
      35             :   // re-evaluate and come up with a proper limit for TurboFan.
      36             :   static const int kMaxCallPolymorphism = 4;
      37             : 
      38     1467155 :   struct Candidate {
      39             :     Handle<JSFunction> functions[kMaxCallPolymorphism];
      40             :     // TODO(2206): For now polymorphic inlining is treated orthogonally to
      41             :     // inlining based on SharedFunctionInfo. This should be unified and the
      42             :     // above array should be switched to SharedFunctionInfo instead. Currently
      43             :     // we use {num_functions == 1 && functions[0].is_null()} as an indicator.
      44             :     Handle<SharedFunctionInfo> shared_info;
      45             :     int num_functions;
      46             :     Node* node = nullptr;    // The call site at which to inline.
      47             :     float frequency = 0.0f;  // Relative frequency of this call site.
      48             :   };
      49             : 
      50             :   // Comparator for candidates.
      51             :   struct CandidateCompare {
      52             :     bool operator()(const Candidate& left, const Candidate& right) const;
      53             :   };
      54             : 
      55             :   // Candidates are kept in a sorted set of unique candidates.
      56             :   typedef ZoneSet<Candidate, CandidateCompare> Candidates;
      57             : 
      58             :   // Dumps candidates to console.
      59             :   void PrintCandidates();
      60             :   Reduction InlineCandidate(Candidate const& candidate);
      61             : 
      62             :   CommonOperatorBuilder* common() const;
      63             :   Graph* graph() const;
      64             :   JSGraph* jsgraph() const { return jsgraph_; }
      65             :   SimplifiedOperatorBuilder* simplified() const;
      66             : 
      67             :   Mode const mode_;
      68             :   JSInliner inliner_;
      69             :   Candidates candidates_;
      70             :   ZoneSet<NodeId> seen_;
      71             :   JSGraph* const jsgraph_;
      72             :   int cumulative_count_ = 0;
      73             : };
      74             : 
      75             : }  // namespace compiler
      76             : }  // namespace internal
      77             : }  // namespace v8
      78             : 
      79             : #endif  // V8_COMPILER_JS_INLINING_HEURISTIC_H_

Generated by: LCOV version 1.10