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

Unified Diff: src/x64/lithium-codegen-x64.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/mips/lithium-mips.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/lithium-codegen-x64.cc
===================================================================
--- src/x64/lithium-codegen-x64.cc (revision 11854)
+++ src/x64/lithium-codegen-x64.cc (working copy)
@@ -3489,30 +3489,63 @@
void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
- if (instr->length()->IsRegister()) {
- Register reg = ToRegister(instr->length());
- if (FLAG_debug_code) {
- __ AbortIfNotZeroExtended(reg);
+ int32_t lower_offset = instr->hydrogen()->lower_offset();
+ int32_t upper_offset = instr->hydrogen()->upper_offset();
+ LOperand* length = instr->length();
+ LOperand* index = instr->index();
+ if (instr->index()->IsConstantOperand()) {
+ int32_t c_index = ToInteger32(LConstantOperand::cast(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());
}
- if (instr->index()->IsConstantOperand()) {
- __ cmpq(reg,
- Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
- } else {
- Register reg2 = ToRegister(instr->index());
+ if (length->IsRegister()) {
if (FLAG_debug_code) {
- __ AbortIfNotZeroExtended(reg2);
+ __ AbortIfNotZeroExtended(ToRegister(length));
}
- __ cmpq(reg, reg2);
+ __ cmpl(ToRegister(length), Immediate(c_index + upper_offset));
+ } else {
+ __ cmpq(ToOperand(length), Immediate(c_index + upper_offset));
}
+ DeoptimizeIf(below_equal, instr->environment());
} else {
- if (instr->index()->IsConstantOperand()) {
- __ cmpq(ToOperand(instr->length()),
- Immediate(ToInteger32(LConstantOperand::cast(instr->index()))));
+ ASSERT(index->IsRegister());
+ Register reg_index = ToRegister(index);
+ if (FLAG_debug_code) {
+ __ AbortIfNotZeroExtended(reg_index);
+ }
+ if (lower_offset == 0 && upper_offset == 0) {
+ if (length->IsRegister()) {
+ if (FLAG_debug_code) {
+ __ AbortIfNotZeroExtended(ToRegister(length));
+ }
+ __ cmpl(ToRegister(length), ToRegister(index));
+ } else {
+ __ cmpq(ToOperand(length), ToRegister(index));
+ }
+ DeoptimizeIf(below_equal, instr->environment());
} else {
- __ cmpq(ToOperand(instr->length()), ToRegister(instr->index()));
+ ASSERT(instr->TempAt(0)->IsRegister());
+ Register temp_length = ToRegister(instr->TempAt(0));
+ if (length->IsRegister()) {
+ if (FLAG_debug_code) {
+ __ AbortIfNotZeroExtended(ToRegister(length));
+ }
+ __ movl(temp_length, ToRegister(length));
+ } else {
+ __ movq(temp_length, ToOperand(length));
+ }
+ __ cmpl(reg_index, Immediate(-lower_offset));
+ DeoptimizeIf(less, instr->environment());
+ __ subl(temp_length, Immediate(upper_offset));
+ __ cmpl(reg_index, temp_length);
+ if (upper_offset >= 0) {
+ DeoptimizeIf(greater_equal, instr->environment());
+ } else {
+ DeoptimizeIf(above_equal, instr->environment());
+ }
}
}
- DeoptimizeIf(below_equal, instr->environment());
}
« no previous file with comments | « src/mips/lithium-mips.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698