Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/hydrogen-gvn.h

Issue 144423010: Improve inobject field tracking during GVN. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-check-elimination.cc ('k') | src/hydrogen-gvn.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 18 matching lines...) Expand all
29 #define V8_HYDROGEN_GVN_H_ 29 #define V8_HYDROGEN_GVN_H_
30 30
31 #include "hydrogen.h" 31 #include "hydrogen.h"
32 #include "hydrogen-instructions.h" 32 #include "hydrogen-instructions.h"
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "zone.h" 34 #include "zone.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 // This class extends GVNFlagSet with additional "special" dynamic side effects,
40 // which can be used to represent side effects that cannot be expressed using
41 // the GVNFlags of an HInstruction. These special side effects are tracked by a
42 // SideEffectsTracker (see below).
43 class SideEffects V8_FINAL {
44 public:
45 static const int kNumberOfSpecials = 64 - kNumberOfFlags;
46
47 SideEffects() : bits_(0) {}
48 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {}
49 bool IsEmpty() const { return bits_ == 0; }
50 bool ContainsFlag(GVNFlag flag) const {
51 return (bits_ & MaskFlag(flag)) != 0;
52 }
53 bool ContainsSpecial(int special) const {
54 return (bits_ & MaskSpecial(special)) != 0;
55 }
56 bool ContainsAnyOf(SideEffects set) const { return (bits_ & set.bits_) != 0; }
57 void Add(SideEffects set) { bits_ |= set.bits_; }
58 void AddSpecial(int special) { bits_ |= MaskSpecial(special); }
59 void AddAllSpecial() { bits_ |= ~static_cast<uint64_t>(0) << kNumberOfFlags; }
60 void RemoveFlag(GVNFlag flag) { bits_ &= ~MaskFlag(flag); }
61 void RemoveAll() { bits_ = 0; }
62 uint64_t ToIntegral() const { return bits_; }
63 void PrintTo(StringStream* stream) const;
64
65 private:
66 uint64_t MaskFlag(GVNFlag flag) const {
67 return static_cast<uint64_t>(1) << static_cast<unsigned>(flag);
68 }
69 uint64_t MaskSpecial(int special) const {
70 ASSERT(special >= 0);
71 ASSERT(special < kNumberOfSpecials);
72 return static_cast<uint64_t>(1) << static_cast<unsigned>(
73 special + kNumberOfFlags);
74 }
75
76 uint64_t bits_;
77 STATIC_ASSERT(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT);
78 };
79
80
81 // Tracks inobject field loads/stores in a fine grained fashion, and represents
82 // them using the "special" dynamic side effects of the SideEffects class (see
83 // above). This way unrelated inobject field stores don't prevent hoisting and
84 // merging of inobject field loads.
85 class SideEffectsTracker V8_FINAL BASE_EMBEDDED {
86 public:
87 SideEffectsTracker() : num_inobject_fields_(0) {}
88 SideEffects ComputeChanges(HInstruction* instr);
89 SideEffects ComputeDependsOn(HInstruction* instr);
90 void PrintSideEffectsTo(StringStream* stream, SideEffects side_effects) const;
91
92 private:
93 bool ComputeInobjectField(HObjectAccess access, int* index);
94
95 HObjectAccess inobject_fields_[SideEffects::kNumberOfSpecials];
96 int num_inobject_fields_;
97 };
98
99
39 // Perform common subexpression elimination and loop-invariant code motion. 100 // Perform common subexpression elimination and loop-invariant code motion.
40 class HGlobalValueNumberingPhase : public HPhase { 101 class HGlobalValueNumberingPhase V8_FINAL : public HPhase {
41 public: 102 public:
42 explicit HGlobalValueNumberingPhase(HGraph* graph); 103 explicit HGlobalValueNumberingPhase(HGraph* graph);
43 104
44 void Run(); 105 void Run();
45 106
46 private: 107 private:
47 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock( 108 SideEffects CollectSideEffectsOnPathsToDominatedBlock(
48 HBasicBlock* dominator, 109 HBasicBlock* dominator,
49 HBasicBlock* dominated); 110 HBasicBlock* dominated);
50 void AnalyzeGraph(); 111 void AnalyzeGraph();
51 void ComputeBlockSideEffects(); 112 void ComputeBlockSideEffects();
52 void LoopInvariantCodeMotion(); 113 void LoopInvariantCodeMotion();
53 void ProcessLoopBlock(HBasicBlock* block, 114 void ProcessLoopBlock(HBasicBlock* block,
54 HBasicBlock* before_loop, 115 HBasicBlock* before_loop,
55 GVNFlagSet loop_kills); 116 SideEffects loop_kills);
56 bool AllowCodeMotion(); 117 bool AllowCodeMotion();
57 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header); 118 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header);
58 119
120 SideEffectsTracker side_effects_tracker_;
59 bool removed_side_effects_; 121 bool removed_side_effects_;
60 122
61 // A map of block IDs to their side effects. 123 // A map of block IDs to their side effects.
62 ZoneList<GVNFlagSet> block_side_effects_; 124 ZoneList<SideEffects> block_side_effects_;
63 125
64 // A map of loop header block IDs to their loop's side effects. 126 // A map of loop header block IDs to their loop's side effects.
65 ZoneList<GVNFlagSet> loop_side_effects_; 127 ZoneList<SideEffects> loop_side_effects_;
66 128
67 // Used when collecting side effects on paths from dominator to 129 // Used when collecting side effects on paths from dominator to
68 // dominated. 130 // dominated.
69 BitVector visited_on_paths_; 131 BitVector visited_on_paths_;
70 132
71 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); 133 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase);
72 }; 134 };
73 135
74
75 } } // namespace v8::internal 136 } } // namespace v8::internal
76 137
77 #endif // V8_HYDROGEN_GVN_H_ 138 #endif // V8_HYDROGEN_GVN_H_
OLDNEW
« no previous file with comments | « src/hydrogen-check-elimination.cc ('k') | src/hydrogen-gvn.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698