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

Side by Side Diff: src/arm64/lithium-codegen-arm64.cc

Issue 280883003: Fix FlooringDivByPowerOf2I on ARM/ARM64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | no next file » | 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "arm64/lithium-codegen-arm64.h" 7 #include "arm64/lithium-codegen-arm64.h"
8 #include "arm64/lithium-gap-resolver-arm64.h" 8 #include "arm64/lithium-gap-resolver-arm64.h"
9 #include "code-stubs.h" 9 #include "code-stubs.h"
10 #include "stub-cache.h" 10 #include "stub-cache.h"
(...skipping 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after
3863 __ Fccmp(input, input, NoFlag, eq); 3863 __ Fccmp(input, input, NoFlag, eq);
3864 DeoptimizeIf(ne, instr->environment()); 3864 DeoptimizeIf(ne, instr->environment());
3865 } 3865 }
3866 3866
3867 3867
3868 void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { 3868 void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) {
3869 Register dividend = ToRegister32(instr->dividend()); 3869 Register dividend = ToRegister32(instr->dividend());
3870 Register result = ToRegister32(instr->result()); 3870 Register result = ToRegister32(instr->result());
3871 int32_t divisor = instr->divisor(); 3871 int32_t divisor = instr->divisor();
3872 3872
3873 // If the divisor is 1, return the dividend.
3874 if (divisor == 1) {
3875 __ Mov(result, dividend, kDiscardForSameWReg);
3876 return;
3877 }
3878
3873 // If the divisor is positive, things are easy: There can be no deopts and we 3879 // If the divisor is positive, things are easy: There can be no deopts and we
3874 // can simply do an arithmetic right shift. 3880 // can simply do an arithmetic right shift.
3875 if (divisor == 1) return;
3876 int32_t shift = WhichPowerOf2Abs(divisor); 3881 int32_t shift = WhichPowerOf2Abs(divisor);
3877 if (divisor > 1) { 3882 if (divisor > 1) {
3878 __ Mov(result, Operand(dividend, ASR, shift)); 3883 __ Mov(result, Operand(dividend, ASR, shift));
3879 return; 3884 return;
3880 } 3885 }
3881 3886
3882 // If the divisor is negative, we have to negate and handle edge cases. 3887 // If the divisor is negative, we have to negate and handle edge cases.
3883 __ Negs(result, dividend); 3888 __ Negs(result, dividend);
3884 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3889 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3885 DeoptimizeIf(eq, instr->environment()); 3890 DeoptimizeIf(eq, instr->environment());
3886 } 3891 }
3887 3892
3888 // If the negation could not overflow, simply shifting is OK. 3893 // If the negation could not overflow, simply shifting is OK.
3889 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { 3894 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) {
3890 __ Mov(result, Operand(dividend, ASR, shift)); 3895 __ Mov(result, Operand(dividend, ASR, shift));
3891 return; 3896 return;
3892 } 3897 }
3893 3898
3894 // Dividing by -1 is basically negation, unless we overflow. 3899 // Dividing by -1 is basically negation, unless we overflow.
3895 if (divisor == -1) { 3900 if (divisor == -1) {
3896 DeoptimizeIf(vs, instr->environment()); 3901 DeoptimizeIf(vs, instr->environment());
3897 return; 3902 return;
3898 } 3903 }
3899 3904
3900 // Using a conditional data processing instruction would need 1 more register. 3905 __ Asr(result, dividend, shift);
3901 Label not_kmin_int, done; 3906 __ Csel(result, result, kMinInt / divisor, vc);
3902 __ B(vc, &not_kmin_int);
3903 __ Mov(result, kMinInt / divisor);
3904 __ B(&done);
3905 __ bind(&not_kmin_int);
3906 __ Mov(result, Operand(dividend, ASR, shift));
3907 __ bind(&done);
3908 } 3907 }
3909 3908
3910 3909
3911 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) { 3910 void LCodeGen::DoFlooringDivByConstI(LFlooringDivByConstI* instr) {
3912 Register dividend = ToRegister32(instr->dividend()); 3911 Register dividend = ToRegister32(instr->dividend());
3913 int32_t divisor = instr->divisor(); 3912 int32_t divisor = instr->divisor();
3914 Register result = ToRegister32(instr->result()); 3913 Register result = ToRegister32(instr->result());
3915 ASSERT(!AreAliased(dividend, result)); 3914 ASSERT(!AreAliased(dividend, result));
3916 3915
3917 if (divisor == 0) { 3916 if (divisor == 0) {
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
6001 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 6000 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
6002 // Index is equal to negated out of object property index plus 1. 6001 // Index is equal to negated out of object property index plus 1.
6003 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); 6002 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2));
6004 __ Ldr(result, FieldMemOperand(result, 6003 __ Ldr(result, FieldMemOperand(result,
6005 FixedArray::kHeaderSize - kPointerSize)); 6004 FixedArray::kHeaderSize - kPointerSize));
6006 __ Bind(deferred->exit()); 6005 __ Bind(deferred->exit());
6007 __ Bind(&done); 6006 __ Bind(&done);
6008 } 6007 }
6009 6008
6010 } } // namespace v8::internal 6009 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698