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_ENVIRONMENT_LIVENESS_H_
6 #define V8_HYDROGEN_ENVIRONMENT_LIVENESS_H_
9 #include "src/hydrogen.h"
15 // Trims live ranges of environment slots by doing explicit liveness analysis.
16 // Values in the environment are kept alive by every subsequent LInstruction
17 // that is assigned an LEnvironment, which creates register pressure and
18 // unnecessary spill slot moves. Therefore it is beneficial to trim the
19 // live ranges of environment slots by zapping them with a constant after
20 // the last lookup that refers to them.
21 // Slots are identified by their index and only affected if whitelisted in
22 // HOptimizedGraphBuilder::IsEligibleForEnvironmentLivenessAnalysis().
23 class HEnvironmentLivenessAnalysisPhase : public HPhase {
25 explicit HEnvironmentLivenessAnalysisPhase(HGraph* graph);
30 void ZapEnvironmentSlot(int index, HSimulate* simulate);
31 void ZapEnvironmentSlotsInSuccessors(HBasicBlock* block, BitVector* live);
32 void ZapEnvironmentSlotsForInstruction(HEnvironmentMarker* marker);
33 void UpdateLivenessAtBlockEnd(HBasicBlock* block, BitVector* live);
34 void UpdateLivenessAtInstruction(HInstruction* instr, BitVector* live);
36 bool VerifyClosures(Handle<JSFunction> a, Handle<JSFunction> b);
41 // Largest number of local variables in any environment in the graph
42 // (including inlined environments).
43 int maximum_environment_size_;
45 // Per-block data. All these lists are indexed by block_id.
46 ZoneList<BitVector*> live_at_block_start_;
47 ZoneList<HSimulate*> first_simulate_;
48 ZoneList<BitVector*> first_simulate_invalid_for_index_;
50 // List of all HEnvironmentMarker instructions for quick iteration/deletion.
51 // It is populated during the first pass over the graph, controlled by
52 // |collect_markers_|.
53 ZoneList<HEnvironmentMarker*> markers_;
54 bool collect_markers_;
56 // Keeps track of the last simulate seen, as well as the environment slots
57 // for which a new live range has started since (so they must not be zapped
58 // in that simulate when the end of another live range of theirs is found).
59 HSimulate* last_simulate_;
60 BitVector went_live_since_last_simulate_;
62 DISALLOW_COPY_AND_ASSIGN(HEnvironmentLivenessAnalysisPhase);
66 } } // namespace v8::internal
68 #endif /* V8_HYDROGEN_ENVIRONMENT_LIVENESS_H_ */