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

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

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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-flow-engine.h ('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 ASSERT(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT);
49 }
50 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {}
51 bool IsEmpty() const { return bits_ == 0; }
52 bool ContainsFlag(GVNFlag flag) const {
53 return (bits_ & MaskFlag(flag)) != 0;
54 }
55 bool ContainsSpecial(int special) const {
56 return (bits_ & MaskSpecial(special)) != 0;
57 }
58 bool ContainsAnyOf(SideEffects set) const { return (bits_ & set.bits_) != 0; }
59 void Add(SideEffects set) { bits_ |= set.bits_; }
60 void AddSpecial(int special) { bits_ |= MaskSpecial(special); }
61 void AddAllSpecial() { bits_ |= ~static_cast<uint64_t>(0) << kNumberOfFlags; }
62 void RemoveFlag(GVNFlag flag) { bits_ &= ~MaskFlag(flag); }
63 void RemoveAll() { bits_ = 0; }
64 uint64_t ToIntegral() const { return bits_; }
65 void PrintTo(StringStream* stream) const;
66
67 private:
68 uint64_t MaskFlag(GVNFlag flag) const {
69 return static_cast<uint64_t>(1) << static_cast<unsigned>(flag);
70 }
71 uint64_t MaskSpecial(int special) const {
72 ASSERT(special >= 0);
73 ASSERT(special < kNumberOfSpecials);
74 return static_cast<uint64_t>(1) << static_cast<unsigned>(
75 special + kNumberOfFlags);
76 }
77
78 uint64_t bits_;
79 };
80
81
82 // Tracks inobject field loads/stores in a fine grained fashion, and represents
83 // them using the "special" dynamic side effects of the SideEffects class (see
84 // above). This way unrelated inobject field stores don't prevent hoisting and
85 // merging of inobject field loads.
86 class SideEffectsTracker V8_FINAL BASE_EMBEDDED {
87 public:
88 SideEffectsTracker() : num_inobject_fields_(0) {}
89 SideEffects ComputeChanges(HInstruction* instr);
90 SideEffects ComputeDependsOn(HInstruction* instr);
91 void PrintSideEffectsTo(StringStream* stream, SideEffects side_effects) const;
92
93 private:
94 bool ComputeInobjectField(HObjectAccess access, int* index);
95
96 HObjectAccess inobject_fields_[SideEffects::kNumberOfSpecials];
97 int num_inobject_fields_;
98 };
99
100
39 // Perform common subexpression elimination and loop-invariant code motion. 101 // Perform common subexpression elimination and loop-invariant code motion.
40 class HGlobalValueNumberingPhase : public HPhase { 102 class HGlobalValueNumberingPhase V8_FINAL : public HPhase {
41 public: 103 public:
42 explicit HGlobalValueNumberingPhase(HGraph* graph); 104 explicit HGlobalValueNumberingPhase(HGraph* graph);
43 105
44 void Run() { 106 void Run();
45 Analyze();
46 // Trigger a second analysis pass to further eliminate duplicate values
47 // that could only be discovered by removing side-effect-generating
48 // instructions during the first pass.
49 if (FLAG_smi_only_arrays && removed_side_effects_) {
50 Analyze();
51 // TODO(danno): Turn this into a fixpoint iteration.
52 }
53 }
54 107
55 private: 108 private:
56 void Analyze(); 109 SideEffects CollectSideEffectsOnPathsToDominatedBlock(
57 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock(
58 HBasicBlock* dominator, 110 HBasicBlock* dominator,
59 HBasicBlock* dominated); 111 HBasicBlock* dominated);
60 void AnalyzeGraph(); 112 void AnalyzeGraph();
61 void ComputeBlockSideEffects(); 113 void ComputeBlockSideEffects();
62 void LoopInvariantCodeMotion(); 114 void LoopInvariantCodeMotion();
63 void ProcessLoopBlock(HBasicBlock* block, 115 void ProcessLoopBlock(HBasicBlock* block,
64 HBasicBlock* before_loop, 116 HBasicBlock* before_loop,
65 GVNFlagSet loop_kills, 117 SideEffects loop_kills);
66 GVNFlagSet* accumulated_first_time_depends,
67 GVNFlagSet* accumulated_first_time_changes);
68 bool AllowCodeMotion(); 118 bool AllowCodeMotion();
69 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header); 119 bool ShouldMove(HInstruction* instr, HBasicBlock* loop_header);
70 120
121 SideEffectsTracker side_effects_tracker_;
71 bool removed_side_effects_; 122 bool removed_side_effects_;
72 123
73 // A map of block IDs to their side effects. 124 // A map of block IDs to their side effects.
74 ZoneList<GVNFlagSet> block_side_effects_; 125 ZoneList<SideEffects> block_side_effects_;
75 126
76 // A map of loop header block IDs to their loop's side effects. 127 // A map of loop header block IDs to their loop's side effects.
77 ZoneList<GVNFlagSet> loop_side_effects_; 128 ZoneList<SideEffects> loop_side_effects_;
78 129
79 // Used when collecting side effects on paths from dominator to 130 // Used when collecting side effects on paths from dominator to
80 // dominated. 131 // dominated.
81 BitVector visited_on_paths_; 132 BitVector visited_on_paths_;
82 133
83 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); 134 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase);
84 }; 135 };
85 136
86
87 } } // namespace v8::internal 137 } } // namespace v8::internal
88 138
89 #endif // V8_HYDROGEN_GVN_H_ 139 #endif // V8_HYDROGEN_GVN_H_
OLDNEW
« no previous file with comments | « src/hydrogen-flow-engine.h ('k') | src/hydrogen-gvn.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698