Chromium Code Reviews| Index: src/hydrogen-gvn.cc |
| diff --git a/src/hydrogen-gvn.cc b/src/hydrogen-gvn.cc |
| index 6bf5a1b68e4fc3a2a8cdcaf02da63e614c63e1ee..4c98015bee1ef86d9ff7fc2f2c646c4e60e7fd82 100644 |
| --- a/src/hydrogen-gvn.cc |
| +++ b/src/hydrogen-gvn.cc |
| @@ -367,15 +367,28 @@ void HSideEffectMap::Store(SideEffects side_effects, HInstruction* instr) { |
| SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { |
| + int index; |
| SideEffects result(instr->ChangesFlags()); |
| + if (result.ContainsFlag(kGlobalVars)) { |
| + if (instr->IsStoreGlobalCell() && |
| + ComputeGlobalVar(HStoreGlobalCell::cast(instr)->cell(), &index)) { |
| + result.RemoveFlag(kGlobalVars); |
| + result.AddSpecial(GlobalVar(index)); |
| + } else { |
| + for (index = 0; index < kNumberOfGlobalVars; ++index) { |
| + result.AddSpecial(GlobalVar(index)); |
| + } |
| + } |
| + } |
| if (result.ContainsFlag(kInobjectFields)) { |
| - int index; |
| if (instr->IsStoreNamedField() && |
| ComputeInobjectField(HStoreNamedField::cast(instr)->access(), &index)) { |
| result.RemoveFlag(kInobjectFields); |
| - result.AddSpecial(index); |
| + result.AddSpecial(InobjectField(index)); |
| } else { |
| - result.AddAllSpecial(); |
| + for (index = 0; index < kNumberOfInobjectFields; ++index) { |
| + result.AddSpecial(InobjectField(index)); |
| + } |
| } |
| } |
| return result; |
| @@ -383,15 +396,28 @@ SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { |
| SideEffects SideEffectsTracker::ComputeDependsOn(HInstruction* instr) { |
| + int index; |
| SideEffects result(instr->DependsOnFlags()); |
| + if (result.ContainsFlag(kGlobalVars)) { |
| + if (instr->IsLoadGlobalCell() && |
| + ComputeGlobalVar(HLoadGlobalCell::cast(instr)->cell(), &index)) { |
| + result.RemoveFlag(kGlobalVars); |
| + result.AddSpecial(GlobalVar(index)); |
| + } else { |
| + for (index = 0; index < kNumberOfGlobalVars; ++index) { |
| + result.AddSpecial(GlobalVar(index)); |
| + } |
| + } |
| + } |
| if (result.ContainsFlag(kInobjectFields)) { |
| - int index; |
| if (instr->IsLoadNamedField() && |
| ComputeInobjectField(HLoadNamedField::cast(instr)->access(), &index)) { |
| result.RemoveFlag(kInobjectFields); |
| - result.AddSpecial(index); |
| + result.AddSpecial(InobjectField(index)); |
| } else { |
| - result.AddAllSpecial(); |
| + for (index = 0; index < kNumberOfInobjectFields; ++index) { |
| + result.AddSpecial(InobjectField(index)); |
| + } |
| } |
| } |
| return result; |
| @@ -420,8 +446,15 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
| } |
| } |
| } |
| + for (int index = 0; index < num_global_vars_; ++index) { |
| + if (side_effects.ContainsSpecial(GlobalVar(index))) { |
| + stream->Add(separator); |
| + separator = ", "; |
| + stream->Add("[%p]", *global_vars_[index].handle()); |
|
Michael Starzinger
2014/03/06 15:45:28
See comment below.
Benedikt Meurer
2014/03/07 06:23:58
Done.
|
| + } |
| + } |
| for (int index = 0; index < num_inobject_fields_; ++index) { |
| - if (side_effects.ContainsSpecial(index)) { |
| + if (side_effects.ContainsSpecial(InobjectField(index))) { |
| stream->Add(separator); |
| separator = ", "; |
| inobject_fields_[index].PrintTo(stream); |
| @@ -431,6 +464,29 @@ GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
| } |
| +bool SideEffectsTracker::ComputeGlobalVar(Unique<Cell> cell, int* index) { |
| + for (int i = 0; i < num_global_vars_; ++i) { |
| + if (cell == global_vars_[i]) { |
| + *index = i; |
| + return true; |
| + } |
| + } |
| + if (num_global_vars_ < kNumberOfGlobalVars) { |
| + if (FLAG_trace_gvn) { |
| + HeapStringAllocator allocator; |
| + StringStream stream(&allocator); |
| + stream.Add("Tracking global var [%p] (mapped to index %d)\n", |
| + *cell.handle(), num_global_vars_); |
|
Michael Starzinger
2014/03/06 15:45:28
Dereferencing the handle here will not work if we
Benedikt Meurer
2014/03/07 06:23:58
Done.
|
| + stream.OutputToStdOut(); |
| + } |
| + *index = num_global_vars_; |
| + global_vars_[num_global_vars_++] = cell; |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| + |
| bool SideEffectsTracker::ComputeInobjectField(HObjectAccess access, |
| int* index) { |
| for (int i = 0; i < num_inobject_fields_; ++i) { |
| @@ -439,13 +495,13 @@ bool SideEffectsTracker::ComputeInobjectField(HObjectAccess access, |
| return true; |
| } |
| } |
| - if (num_inobject_fields_ < SideEffects::kNumberOfSpecials) { |
| + if (num_inobject_fields_ < kNumberOfInobjectFields) { |
| if (FLAG_trace_gvn) { |
| HeapStringAllocator allocator; |
| StringStream stream(&allocator); |
| stream.Add("Tracking inobject field access "); |
| access.PrintTo(&stream); |
| - stream.Add(" (mapped to special index %d)\n", num_inobject_fields_); |
| + stream.Add(" (mapped to index %d)\n", num_inobject_fields_); |
| stream.OutputToStdOut(); |
| } |
| *index = num_inobject_fields_; |