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

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

Issue 1133343003: Fix harmless HGraph verification failure after hoisting inlined bounds checks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git add testcase Created 5 years, 7 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
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-487608.js » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/hydrogen-bce.h" 5 #include "src/hydrogen-bce.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 9
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 HBoundsCheck* insert_before, 224 HBoundsCheck* insert_before,
225 HInstruction* end_of_scan_range) { 225 HInstruction* end_of_scan_range) {
226 // index_raw can be HAdd(index_base, offset), HSub(index_base, offset), 226 // index_raw can be HAdd(index_base, offset), HSub(index_base, offset),
227 // HConstant(offset) or index_base directly. 227 // HConstant(offset) or index_base directly.
228 // In the latter case, no need to move anything. 228 // In the latter case, no need to move anything.
229 if (index_raw->IsAdd() || index_raw->IsSub()) { 229 if (index_raw->IsAdd() || index_raw->IsSub()) {
230 HArithmeticBinaryOperation* index = 230 HArithmeticBinaryOperation* index =
231 HArithmeticBinaryOperation::cast(index_raw); 231 HArithmeticBinaryOperation::cast(index_raw);
232 HValue* left_input = index->left(); 232 HValue* left_input = index->left();
233 HValue* right_input = index->right(); 233 HValue* right_input = index->right();
234 HValue* context = index->context();
234 bool must_move_index = false; 235 bool must_move_index = false;
235 bool must_move_left_input = false; 236 bool must_move_left_input = false;
236 bool must_move_right_input = false; 237 bool must_move_right_input = false;
238 bool must_move_context = false;
237 for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) { 239 for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) {
238 if (cursor == left_input) must_move_left_input = true; 240 if (cursor == left_input) must_move_left_input = true;
239 if (cursor == right_input) must_move_right_input = true; 241 if (cursor == right_input) must_move_right_input = true;
242 if (cursor == context) must_move_context = true;
240 if (cursor == index) must_move_index = true; 243 if (cursor == index) must_move_index = true;
241 if (cursor->previous() == NULL) { 244 if (cursor->previous() == NULL) {
242 cursor = cursor->block()->dominator()->end(); 245 cursor = cursor->block()->dominator()->end();
243 } else { 246 } else {
244 cursor = cursor->previous(); 247 cursor = cursor->previous();
245 } 248 }
246 } 249 }
247 if (must_move_index) { 250 if (must_move_index) {
248 index->Unlink(); 251 index->Unlink();
249 index->InsertBefore(insert_before); 252 index->InsertBefore(insert_before);
250 } 253 }
251 // The BCE algorithm only selects mergeable bounds checks that share 254 // The BCE algorithm only selects mergeable bounds checks that share
252 // the same "index_base", so we'll only ever have to move constants. 255 // the same "index_base", so we'll only ever have to move constants.
253 if (must_move_left_input) { 256 if (must_move_left_input) {
254 HConstant::cast(left_input)->Unlink(); 257 HConstant::cast(left_input)->Unlink();
255 HConstant::cast(left_input)->InsertBefore(index); 258 HConstant::cast(left_input)->InsertBefore(index);
256 } 259 }
257 if (must_move_right_input) { 260 if (must_move_right_input) {
258 HConstant::cast(right_input)->Unlink(); 261 HConstant::cast(right_input)->Unlink();
259 HConstant::cast(right_input)->InsertBefore(index); 262 HConstant::cast(right_input)->InsertBefore(index);
260 } 263 }
264 if (must_move_context) {
265 // Contexts are always constants.
266 HConstant::cast(context)->Unlink();
267 HConstant::cast(context)->InsertBefore(index);
268 }
261 } else if (index_raw->IsConstant()) { 269 } else if (index_raw->IsConstant()) {
262 HConstant* index = HConstant::cast(index_raw); 270 HConstant* index = HConstant::cast(index_raw);
263 bool must_move = false; 271 bool must_move = false;
264 for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) { 272 for (HInstruction* cursor = end_of_scan_range; cursor != insert_before;) {
265 if (cursor == index) must_move = true; 273 if (cursor == index) must_move = true;
266 if (cursor->previous() == NULL) { 274 if (cursor->previous() == NULL) {
267 cursor = cursor->block()->dominator()->end(); 275 cursor = cursor->block()->dominator()->end();
268 } else { 276 } else {
269 cursor = cursor->previous(); 277 cursor = cursor->previous();
270 } 278 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (data->FatherInDominatorTree()) { 467 if (data->FatherInDominatorTree()) {
460 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone()); 468 table_.Insert(data->Key(), data->FatherInDominatorTree(), zone());
461 } else { 469 } else {
462 table_.Delete(data->Key()); 470 table_.Delete(data->Key());
463 } 471 }
464 data = data->NextInBasicBlock(); 472 data = data->NextInBasicBlock();
465 } 473 }
466 } 474 }
467 475
468 } } // namespace v8::internal 476 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-487608.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698