2013-06-28 16:09:54 +00:00
|
|
|
// Copyright 2013 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-06-28 16:09:54 +00:00
|
|
|
|
|
|
|
#ifndef V8_HYDROGEN_ESCAPE_ANALYSIS_H_
|
|
|
|
#define V8_HYDROGEN_ESCAPE_ANALYSIS_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/hydrogen.h"
|
2013-06-28 16:09:54 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
|
2013-07-02 08:29:33 +00:00
|
|
|
class HEscapeAnalysisPhase : public HPhase {
|
2013-06-28 16:09:54 +00:00
|
|
|
public:
|
2013-07-02 08:29:33 +00:00
|
|
|
explicit HEscapeAnalysisPhase(HGraph* graph)
|
2013-08-07 11:24:14 +00:00
|
|
|
: HPhase("H_Escape analysis", graph),
|
|
|
|
captured_(0, zone()),
|
2013-08-26 16:43:19 +00:00
|
|
|
number_of_objects_(0),
|
2013-08-07 11:24:14 +00:00
|
|
|
number_of_values_(0),
|
|
|
|
cumulative_values_(0),
|
|
|
|
block_states_(graph->blocks()->length(), zone()) { }
|
2013-06-28 16:09:54 +00:00
|
|
|
|
2013-09-03 10:58:07 +00:00
|
|
|
void Run();
|
2013-06-28 16:09:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void CollectCapturedValues();
|
2013-09-09 09:53:58 +00:00
|
|
|
bool HasNoEscapingUses(HValue* value, int size);
|
2013-08-07 11:24:14 +00:00
|
|
|
void PerformScalarReplacement();
|
|
|
|
void AnalyzeDataFlow(HInstruction* instr);
|
2013-06-28 16:09:54 +00:00
|
|
|
|
2013-08-07 11:24:14 +00:00
|
|
|
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);
|
|
|
|
|
2013-08-28 14:16:57 +00:00
|
|
|
HValue* NewMapCheckAndInsert(HCapturedObject* state, HCheckMaps* mapcheck);
|
|
|
|
|
2014-04-25 11:29:02 +00:00
|
|
|
HValue* NewLoadReplacement(HLoadNamedField* load, HValue* load_value);
|
|
|
|
|
2013-08-07 11:24:14 +00:00
|
|
|
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_;
|
|
|
|
|
2013-08-26 16:43:19 +00:00
|
|
|
// Number of captured objects on which scalar replacement was done.
|
|
|
|
int number_of_objects_;
|
|
|
|
|
2013-08-07 11:24:14 +00:00
|
|
|
// 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_;
|
2013-06-28 16:09:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_HYDROGEN_ESCAPE_ANALYSIS_H_
|