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

Side by Side Diff: src/hydrogen-bce.cc

Issue 196133017: Experimental parser: merge r19949 (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.cc ('k') | src/hydrogen-gvn.h » ('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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 HBoundsCheck* UpperCheck() const { return upper_check_; } 125 HBoundsCheck* UpperCheck() const { return upper_check_; }
126 BoundsCheckBbData* NextInBasicBlock() const { return next_in_bb_; } 126 BoundsCheckBbData* NextInBasicBlock() const { return next_in_bb_; }
127 BoundsCheckBbData* FatherInDominatorTree() const { return father_in_dt_; } 127 BoundsCheckBbData* FatherInDominatorTree() const { return father_in_dt_; }
128 128
129 bool OffsetIsCovered(int32_t offset) const { 129 bool OffsetIsCovered(int32_t offset) const {
130 return offset >= LowerOffset() && offset <= UpperOffset(); 130 return offset >= LowerOffset() && offset <= UpperOffset();
131 } 131 }
132 132
133 bool HasSingleCheck() { return lower_check_ == upper_check_; } 133 bool HasSingleCheck() { return lower_check_ == upper_check_; }
134 134
135 void UpdateUpperOffsets(HBoundsCheck* check, int32_t offset) {
136 BoundsCheckBbData* data = FatherInDominatorTree();
137 while (data != NULL && data->UpperCheck() == check) {
138 ASSERT(data->upper_offset_ <= offset);
139 data->upper_offset_ = offset;
140 data = data->FatherInDominatorTree();
141 }
142 }
143
144 void UpdateLowerOffsets(HBoundsCheck* check, int32_t offset) {
145 BoundsCheckBbData* data = FatherInDominatorTree();
146 while (data != NULL && data->LowerCheck() == check) {
147 ASSERT(data->lower_offset_ > offset);
148 data->lower_offset_ = offset;
149 data = data->FatherInDominatorTree();
150 }
151 }
152
135 // The goal of this method is to modify either upper_offset_ or 153 // The goal of this method is to modify either upper_offset_ or
136 // lower_offset_ so that also new_offset is covered (the covered 154 // lower_offset_ so that also new_offset is covered (the covered
137 // range grows). 155 // range grows).
138 // 156 //
139 // The precondition is that new_check follows UpperCheck() and 157 // The precondition is that new_check follows UpperCheck() and
140 // LowerCheck() in the same basic block, and that new_offset is not 158 // LowerCheck() in the same basic block, and that new_offset is not
141 // covered (otherwise we could simply remove new_check). 159 // covered (otherwise we could simply remove new_check).
142 // 160 //
143 // If HasSingleCheck() is true then new_check is added as "second check" 161 // If HasSingleCheck() is true then new_check is added as "second check"
144 // (either upper or lower; note that HasSingleCheck() becomes false). 162 // (either upper or lower; note that HasSingleCheck() becomes false).
145 // Otherwise one of the current checks is modified so that it also covers 163 // Otherwise one of the current checks is modified so that it also covers
146 // new_offset, and new_check is removed. 164 // new_offset, and new_check is removed.
147 void CoverCheck(HBoundsCheck* new_check, 165 void CoverCheck(HBoundsCheck* new_check,
148 int32_t new_offset) { 166 int32_t new_offset) {
149 ASSERT(new_check->index()->representation().IsSmiOrInteger32()); 167 ASSERT(new_check->index()->representation().IsSmiOrInteger32());
150 bool keep_new_check = false; 168 bool keep_new_check = false;
151 169
152 if (new_offset > upper_offset_) { 170 if (new_offset > upper_offset_) {
153 upper_offset_ = new_offset; 171 upper_offset_ = new_offset;
154 if (HasSingleCheck()) { 172 if (HasSingleCheck()) {
155 keep_new_check = true; 173 keep_new_check = true;
156 upper_check_ = new_check; 174 upper_check_ = new_check;
157 } else { 175 } else {
158 TightenCheck(upper_check_, new_check); 176 TightenCheck(upper_check_, new_check);
177 UpdateUpperOffsets(upper_check_, upper_offset_);
159 } 178 }
160 } else if (new_offset < lower_offset_) { 179 } else if (new_offset < lower_offset_) {
161 lower_offset_ = new_offset; 180 lower_offset_ = new_offset;
162 if (HasSingleCheck()) { 181 if (HasSingleCheck()) {
163 keep_new_check = true; 182 keep_new_check = true;
164 lower_check_ = new_check; 183 lower_check_ = new_check;
165 } else { 184 } else {
166 TightenCheck(lower_check_, new_check); 185 TightenCheck(lower_check_, new_check);
186 UpdateLowerOffsets(upper_check_, upper_offset_);
167 } 187 }
168 } else { 188 } else {
169 // Should never have called CoverCheck() in this case. 189 // Should never have called CoverCheck() in this case.
170 UNREACHABLE(); 190 UNREACHABLE();
171 } 191 }
172 192
173 if (!keep_new_check) { 193 if (!keep_new_check) {
174 new_check->block()->graph()->isolate()->counters()-> 194 new_check->block()->graph()->isolate()->counters()->
175 bounds_checks_eliminated()->Increment(); 195 bounds_checks_eliminated()->Increment();
176 new_check->DeleteAndReplaceWith(new_check->ActualValue()); 196 new_check->DeleteAndReplaceWith(new_check->ActualValue());
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (data->FatherInDominatorTree()) { 425 if (data->FatherInDominatorTree()) {
406 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone()); 426 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone());
407 } else { 427 } else {
408 table_.Delete(data->Key()); 428 table_.Delete(data->Key());
409 } 429 }
410 data = data->NextInBasicBlock(); 430 data = data->NextInBasicBlock();
411 } 431 }
412 } 432 }
413 433
414 } } // namespace v8::internal 434 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-gvn.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698