hydrogen-escape-analysis.h 2.13 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_ESCAPE_ANALYSIS_H_
#define V8_CRANKSHAFT_HYDROGEN_ESCAPE_ANALYSIS_H_
7

8
#include "src/allocation.h"
9
#include "src/crankshaft/hydrogen.h"
10 11 12 13 14

namespace v8 {
namespace internal {


15
class HEscapeAnalysisPhase : public HPhase {
16
 public:
17
  explicit HEscapeAnalysisPhase(HGraph* graph)
18 19
      : HPhase("H_Escape analysis", graph),
        captured_(0, zone()),
20
        number_of_objects_(0),
21 22 23
        number_of_values_(0),
        cumulative_values_(0),
        block_states_(graph->blocks()->length(), zone()) { }
24

25
  void Run();
26 27 28

 private:
  void CollectCapturedValues();
29
  bool HasNoEscapingUses(HValue* value, int size);
30 31
  void PerformScalarReplacement();
  void AnalyzeDataFlow(HInstruction* instr);
32

33 34 35 36 37 38 39
  HCapturedObject* NewState(HInstruction* prev);
  HCapturedObject* NewStateForAllocation(HInstruction* prev);
  HCapturedObject* NewStateForLoopHeader(HInstruction* prev, HCapturedObject*);
  HCapturedObject* NewStateCopy(HInstruction* prev, HCapturedObject* state);

  HPhi* NewPhiAndInsert(HBasicBlock* block, HValue* incoming_value, int index);

40 41
  HValue* NewMapCheckAndInsert(HCapturedObject* state, HCheckMaps* mapcheck);

42 43
  HValue* NewLoadReplacement(HLoadNamedField* load, HValue* load_value);

44 45 46 47 48 49 50 51 52 53 54
  HCapturedObject* StateAt(HBasicBlock* block) {
    return block_states_.at(block->block_id());
  }

  void SetStateAt(HBasicBlock* block, HCapturedObject* state) {
    block_states_.Set(block->block_id(), state);
  }

  // List of allocations captured during collection phase.
  ZoneList<HInstruction*> captured_;

55 56 57
  // Number of captured objects on which scalar replacement was done.
  int number_of_objects_;

58 59 60 61 62 63 64
  // Number of scalar values tracked during scalar replacement phase.
  int number_of_values_;
  int cumulative_values_;

  // Map of block IDs to the data-flow state at block entry during the
  // scalar replacement phase.
  ZoneList<HCapturedObject*> block_states_;
65 66 67
};


68 69
}  // namespace internal
}  // namespace v8
70

71
#endif  // V8_CRANKSHAFT_HYDROGEN_ESCAPE_ANALYSIS_H_