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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/lithium-mips.cc ('k') | src/x64/lithium-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 case DICTIONARY_ELEMENTS: 3482 case DICTIONARY_ELEMENTS:
3483 case NON_STRICT_ARGUMENTS_ELEMENTS: 3483 case NON_STRICT_ARGUMENTS_ELEMENTS:
3484 UNREACHABLE(); 3484 UNREACHABLE();
3485 break; 3485 break;
3486 } 3486 }
3487 } 3487 }
3488 } 3488 }
3489 3489
3490 3490
3491 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) { 3491 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
3492 if (instr->length()->IsRegister()) { 3492 int32_t lower_offset = instr->hydrogen()->lower_offset();
3493 Register reg = ToRegister(instr->length()); 3493 int32_t upper_offset = instr->hydrogen()->upper_offset();
3494 LOperand* length = instr->length();
3495 LOperand* index = instr->index();
3496 if (instr->index()->IsConstantOperand()) {
3497 int32_t c_index = ToInteger32(LConstantOperand::cast(index));
3498 int64_t upper_range = (int64_t)c_index + (int64_t)upper_offset;
3499 if (c_index < -lower_offset || upper_range > ((int64_t)1 << 32)) {
3500 DeoptimizeIf(no_condition, instr->environment());
3501 }
3502 if (length->IsRegister()) {
3503 if (FLAG_debug_code) {
3504 __ AbortIfNotZeroExtended(ToRegister(length));
3505 }
3506 __ cmpl(ToRegister(length), Immediate(c_index + upper_offset));
3507 } else {
3508 __ cmpq(ToOperand(length), Immediate(c_index + upper_offset));
3509 }
3510 DeoptimizeIf(below_equal, instr->environment());
3511 } else {
3512 ASSERT(index->IsRegister());
3513 Register reg_index = ToRegister(index);
3494 if (FLAG_debug_code) { 3514 if (FLAG_debug_code) {
3495 __ AbortIfNotZeroExtended(reg); 3515 __ AbortIfNotZeroExtended(reg_index);
3496 } 3516 }
3497 if (instr->index()->IsConstantOperand()) { 3517 if (lower_offset == 0 && upper_offset == 0) {
3498 __ cmpq(reg, 3518 if (length->IsRegister()) {
3499 Immediate(ToInteger32(LConstantOperand::cast(instr->index())))); 3519 if (FLAG_debug_code) {
3520 __ AbortIfNotZeroExtended(ToRegister(length));
3521 }
3522 __ cmpl(ToRegister(length), ToRegister(index));
3523 } else {
3524 __ cmpq(ToOperand(length), ToRegister(index));
3525 }
3526 DeoptimizeIf(below_equal, instr->environment());
3500 } else { 3527 } else {
3501 Register reg2 = ToRegister(instr->index()); 3528 ASSERT(instr->TempAt(0)->IsRegister());
3502 if (FLAG_debug_code) { 3529 Register temp_length = ToRegister(instr->TempAt(0));
3503 __ AbortIfNotZeroExtended(reg2); 3530 if (length->IsRegister()) {
3531 if (FLAG_debug_code) {
3532 __ AbortIfNotZeroExtended(ToRegister(length));
3533 }
3534 __ movl(temp_length, ToRegister(length));
3535 } else {
3536 __ movq(temp_length, ToOperand(length));
3504 } 3537 }
3505 __ cmpq(reg, reg2); 3538 __ cmpl(reg_index, Immediate(-lower_offset));
3506 } 3539 DeoptimizeIf(less, instr->environment());
3507 } else { 3540 __ subl(temp_length, Immediate(upper_offset));
3508 if (instr->index()->IsConstantOperand()) { 3541 __ cmpl(reg_index, temp_length);
3509 __ cmpq(ToOperand(instr->length()), 3542 if (upper_offset >= 0) {
3510 Immediate(ToInteger32(LConstantOperand::cast(instr->index())))); 3543 DeoptimizeIf(greater_equal, instr->environment());
3511 } else { 3544 } else {
3512 __ cmpq(ToOperand(instr->length()), ToRegister(instr->index())); 3545 DeoptimizeIf(above_equal, instr->environment());
3546 }
3513 } 3547 }
3514 } 3548 }
3515 DeoptimizeIf(below_equal, instr->environment());
3516 } 3549 }
3517 3550
3518 3551
3519 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { 3552 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
3520 Register value = ToRegister(instr->value()); 3553 Register value = ToRegister(instr->value());
3521 Register elements = ToRegister(instr->object()); 3554 Register elements = ToRegister(instr->object());
3522 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; 3555 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
3523 3556
3524 Operand operand = 3557 Operand operand =
3525 BuildFastArrayOperand(instr->object(), 3558 BuildFastArrayOperand(instr->object(),
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
4948 FixedArray::kHeaderSize - kPointerSize)); 4981 FixedArray::kHeaderSize - kPointerSize));
4949 __ bind(&done); 4982 __ bind(&done);
4950 } 4983 }
4951 4984
4952 4985
4953 #undef __ 4986 #undef __
4954 4987
4955 } } // namespace v8::internal 4988 } } // namespace v8::internal
4956 4989
4957 #endif // V8_TARGET_ARCH_X64 4990 #endif // V8_TARGET_ARCH_X64
OLDNEW
« 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