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

Unified Diff: src/ia32/lithium-codegen-ia32.cc

Issue 10581014: BoundsCheck should be extended to support array_bounds_checks_elimination (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/lithium-codegen-ia32.cc
===================================================================
--- src/ia32/lithium-codegen-ia32.cc (revision 11854)
+++ src/ia32/lithium-codegen-ia32.cc (working copy)
@@ -3557,13 +3557,35 @@
void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
+ int32_t lower_offset = instr->hydrogen()->lower_offset();
+ int32_t upper_offset = instr->hydrogen()->upper_offset();
if (instr->index()->IsConstantOperand()) {
- __ cmp(ToOperand(instr->length()),
- Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
+ int32_t c_index = ToInteger32(LConstantOperand::cast(instr->index()));
+ int64_t upper_range = (int64_t)c_index + (int64_t)upper_offset;
+ if (c_index < -lower_offset || upper_range > ((int64_t)1 << 32)) {
+ DeoptimizeIf(no_condition, instr->environment());
+ }
+ __ cmp(ToOperand(instr->length()), Immediate(c_index + upper_offset));
DeoptimizeIf(below_equal, instr->environment());
} else {
- __ cmp(ToRegister(instr->index()), ToOperand(instr->length()));
- DeoptimizeIf(above_equal, instr->environment());
+ ASSERT(instr->index()->IsRegister());
+ Register reg_index = ToRegister(instr->index());
+ if (lower_offset == 0 && upper_offset == 0) {
+ __ cmp(reg_index, ToOperand(instr->length()));
+ DeoptimizeIf(above_equal, instr->environment());
+ } else {
+ Register temp_length = ToRegister(instr->TempAt(0));
+ __ mov(temp_length, ToOperand(instr->length()));
+ __ cmp(reg_index, Immediate(-lower_offset));
+ DeoptimizeIf(less, instr->environment());
+ __ sub(temp_length, Immediate(upper_offset));
+ __ cmp(reg_index, temp_length);
+ if (upper_offset >= 0) {
+ DeoptimizeIf(greater_equal, instr->environment());
+ } else {
+ DeoptimizeIf(above_equal, instr->environment());
+ }
+ }
}
}
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698