| OLD | NEW |
| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 has_upper_constant_limit = false; | 271 has_upper_constant_limit = false; |
| 272 } | 272 } |
| 273 | 273 |
| 274 current_check->check()->block()->graph()->isolate()->counters()-> | 274 current_check->check()->block()->graph()->isolate()->counters()-> |
| 275 bounds_checks_eliminated()->Increment(); | 275 bounds_checks_eliminated()->Increment(); |
| 276 current_check->check()->set_skip_check(); | 276 current_check->check()->set_skip_check(); |
| 277 current_check = current_check->next(); | 277 current_check = current_check->next(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 // Choose the appropriate limit. | 280 // Choose the appropriate limit. |
| 281 Zone* zone = graph()->zone(); |
| 282 HValue* context = graph()->GetInvalidContext(); |
| 281 HValue* limit = data->limit(); | 283 HValue* limit = data->limit(); |
| 282 if (has_upper_constant_limit) { | 284 if (has_upper_constant_limit) { |
| 283 HConstant* new_limit = new(pre_header->graph()->zone()) HConstant( | 285 HConstant* new_limit = HConstant::New(zone, context, |
| 284 upper_constant_limit, length->representation()); | 286 upper_constant_limit); |
| 285 new_limit->InsertBefore(pre_header->end()); | 287 new_limit->InsertBefore(pre_header->end()); |
| 286 limit = new_limit; | 288 limit = new_limit; |
| 287 } | 289 } |
| 288 | 290 |
| 289 // If necessary, redefine the limit in the preheader. | 291 // If necessary, redefine the limit in the preheader. |
| 290 if (limit->IsInteger32Constant() && | 292 if (limit->IsInteger32Constant() && |
| 291 limit->block() != pre_header && | 293 limit->block() != pre_header && |
| 292 !limit->block()->Dominates(pre_header)) { | 294 !limit->block()->Dominates(pre_header)) { |
| 293 HConstant* new_limit = new(pre_header->graph()->zone()) HConstant( | 295 HConstant* new_limit = HConstant::New(zone, context, |
| 294 limit->GetInteger32Constant(), length->representation()); | 296 limit->GetInteger32Constant()); |
| 295 new_limit->InsertBefore(pre_header->end()); | 297 new_limit->InsertBefore(pre_header->end()); |
| 296 limit = new_limit; | 298 limit = new_limit; |
| 297 } | 299 } |
| 298 | 300 |
| 299 // Do the hoisting. | 301 // Do the hoisting. |
| 300 HBoundsCheck* hoisted_check = new(pre_header->zone()) HBoundsCheck( | 302 HBoundsCheck* hoisted_check = HBoundsCheck::New( |
| 301 limit, check->check()->length()); | 303 zone, context, limit, check->check()->length()); |
| 302 hoisted_check->InsertBefore(pre_header->end()); | 304 hoisted_check->InsertBefore(pre_header->end()); |
| 303 hoisted_check->set_allow_equality(true); | 305 hoisted_check->set_allow_equality(true); |
| 304 hoisted_check->block()->graph()->isolate()->counters()-> | 306 hoisted_check->block()->graph()->isolate()->counters()-> |
| 305 bounds_checks_hoisted()->Increment(); | 307 bounds_checks_hoisted()->Increment(); |
| 306 } | 308 } |
| 307 | 309 |
| 308 void CollectInductionVariableData(HBasicBlock* bb) { | 310 void CollectInductionVariableData(HBasicBlock* bb) { |
| 309 bool additional_limit = false; | 311 bool additional_limit = false; |
| 310 | 312 |
| 311 for (int i = 0; i < bb->phis()->length(); i++) { | 313 for (int i = 0; i < bb->phis()->length(); i++) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 void HBoundsCheckHoistingPhase::HoistRedundantBoundsChecks() { | 401 void HBoundsCheckHoistingPhase::HoistRedundantBoundsChecks() { |
| 400 InductionVariableBlocksTable table(graph()); | 402 InductionVariableBlocksTable table(graph()); |
| 401 table.CollectInductionVariableData(graph()->entry_block()); | 403 table.CollectInductionVariableData(graph()->entry_block()); |
| 402 for (int i = 0; i < graph()->blocks()->length(); i++) { | 404 for (int i = 0; i < graph()->blocks()->length(); i++) { |
| 403 table.EliminateRedundantBoundsChecks(graph()->blocks()->at(i)); | 405 table.EliminateRedundantBoundsChecks(graph()->blocks()->at(i)); |
| 404 } | 406 } |
| 405 } | 407 } |
| 406 | 408 |
| 407 } } // namespace v8::internal | 409 } } // namespace v8::internal |
| 408 | 410 |
| OLD | NEW |