1 // Copyright 2013 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.
5 #ifndef V8_HYDROGEN_ESCAPE_ANALYSIS_H_
6 #define V8_HYDROGEN_ESCAPE_ANALYSIS_H_
8 #include "src/allocation.h"
9 #include "src/hydrogen.h"
15 class HEscapeAnalysisPhase : public HPhase {
17 explicit HEscapeAnalysisPhase(HGraph* graph)
18 : HPhase("H_Escape analysis", graph),
20 number_of_objects_(0),
22 cumulative_values_(0),
23 block_states_(graph->blocks()->length(), zone()) { }
28 void CollectCapturedValues();
29 bool HasNoEscapingUses(HValue* value, int size);
30 void PerformScalarReplacement();
31 void AnalyzeDataFlow(HInstruction* instr);
33 HCapturedObject* NewState(HInstruction* prev);
34 HCapturedObject* NewStateForAllocation(HInstruction* prev);
35 HCapturedObject* NewStateForLoopHeader(HInstruction* prev, HCapturedObject*);
36 HCapturedObject* NewStateCopy(HInstruction* prev, HCapturedObject* state);
38 HPhi* NewPhiAndInsert(HBasicBlock* block, HValue* incoming_value, int index);
40 HValue* NewMapCheckAndInsert(HCapturedObject* state, HCheckMaps* mapcheck);
42 HValue* NewLoadReplacement(HLoadNamedField* load, HValue* load_value);
44 HCapturedObject* StateAt(HBasicBlock* block) {
45 return block_states_.at(block->block_id());
48 void SetStateAt(HBasicBlock* block, HCapturedObject* state) {
49 block_states_.Set(block->block_id(), state);
52 // List of allocations captured during collection phase.
53 ZoneList<HInstruction*> captured_;
55 // Number of captured objects on which scalar replacement was done.
56 int number_of_objects_;
58 // Number of scalar values tracked during scalar replacement phase.
59 int number_of_values_;
60 int cumulative_values_;
62 // Map of block IDs to the data-flow state at block entry during the
63 // scalar replacement phase.
64 ZoneList<HCapturedObject*> block_states_;
68 } } // namespace v8::internal
70 #endif // V8_HYDROGEN_ESCAPE_ANALYSIS_H_