hydrogen-check-elimination.h 1.88 KB
Newer Older
1
// Copyright 2013 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_CRANKSHAFT_HYDROGEN_CHECK_ELIMINATION_H_
#define V8_CRANKSHAFT_HYDROGEN_CHECK_ELIMINATION_H_
7

8 9
#include "src/crankshaft/hydrogen.h"
#include "src/crankshaft/hydrogen-alias-analysis.h"
10 11 12 13 14 15 16 17 18

namespace v8 {
namespace internal {


// Remove CheckMaps instructions through flow- and branch-sensitive analysis.
class HCheckEliminationPhase : public HPhase {
 public:
  explicit HCheckEliminationPhase(HGraph* graph)
19 20 21 22 23 24 25 26
      : HPhase("H_Check Elimination", graph), aliasing_(),
        string_maps_(kStringMapsSize, zone()) {
    // Compute the set of string maps.
    #define ADD_STRING_MAP(type, size, name, Name)                  \
      string_maps_.Add(Unique<Map>::CreateImmovable(                \
              graph->isolate()->factory()->name##_map()), zone());
    STRING_TYPE_LIST(ADD_STRING_MAP)
    #undef ADD_STRING_MAP
27
    DCHECK_EQ(kStringMapsSize, string_maps_.size());
28 29 30 31
#ifdef DEBUG
    redundant_ = 0;
    removed_ = 0;
    removed_cho_ = 0;
32
    removed_cit_ = 0;
33 34 35 36 37 38 39 40
    narrowed_ = 0;
    loads_ = 0;
    empty_ = 0;
    compares_true_ = 0;
    compares_false_ = 0;
    transitions_ = 0;
#endif
  }
41 42 43

  void Run();

44 45
  friend class HCheckTable;

46
 private:
47 48
  const UniqueSet<Map>* string_maps() const { return &string_maps_; }

49 50 51
  void PrintStats();

  HAliasAnalyzer* aliasing_;
52 53 54 55
  #define COUNT(type, size, name, Name) + 1
  static const int kStringMapsSize = 0 STRING_TYPE_LIST(COUNT);
  #undef COUNT
  UniqueSet<Map> string_maps_;
56
#ifdef DEBUG
57 58
  int redundant_;
  int removed_;
59
  int removed_cho_;
60
  int removed_cit_;
61 62 63 64 65 66
  int narrowed_;
  int loads_;
  int empty_;
  int compares_true_;
  int compares_false_;
  int transitions_;
67
#endif
68 69 70
};


71 72
}  // namespace internal
}  // namespace v8
73

74
#endif  // V8_CRANKSHAFT_HYDROGEN_CHECK_ELIMINATION_H_