OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 // Theoretically, a variation of the branch-free code for integer division by | 1075 // Theoretically, a variation of the branch-free code for integer division by |
1076 // a power of 2 (calculating the remainder via an additional multiplication | 1076 // a power of 2 (calculating the remainder via an additional multiplication |
1077 // (which gets simplified to an 'and') and subtraction) should be faster, and | 1077 // (which gets simplified to an 'and') and subtraction) should be faster, and |
1078 // this is exactly what GCC and clang emit. Nevertheless, benchmarks seem to | 1078 // this is exactly what GCC and clang emit. Nevertheless, benchmarks seem to |
1079 // indicate that positive dividends are heavily favored, so the branching | 1079 // indicate that positive dividends are heavily favored, so the branching |
1080 // version performs better. | 1080 // version performs better. |
1081 HMod* hmod = instr->hydrogen(); | 1081 HMod* hmod = instr->hydrogen(); |
1082 int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); | 1082 int32_t mask = divisor < 0 ? -(divisor + 1) : (divisor - 1); |
1083 Label dividend_is_not_negative, done; | 1083 Label dividend_is_not_negative, done; |
1084 | 1084 |
1085 if (hmod->left()->CanBeNegative()) { | 1085 if (hmod->CheckFlag(HValue::kLeftCanBeNegative)) { |
1086 __ Branch(÷nd_is_not_negative, ge, dividend, Operand(zero_reg)); | 1086 __ Branch(÷nd_is_not_negative, ge, dividend, Operand(zero_reg)); |
1087 // Note: The code below even works when right contains kMinInt. | 1087 // Note: The code below even works when right contains kMinInt. |
1088 __ subu(dividend, zero_reg, dividend); | 1088 __ subu(dividend, zero_reg, dividend); |
1089 __ And(dividend, dividend, Operand(mask)); | 1089 __ And(dividend, dividend, Operand(mask)); |
1090 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1090 if (hmod->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1091 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); | 1091 DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); |
1092 } | 1092 } |
1093 __ Branch(USE_DELAY_SLOT, &done); | 1093 __ Branch(USE_DELAY_SLOT, &done); |
1094 __ subu(dividend, zero_reg, dividend); | 1094 __ subu(dividend, zero_reg, dividend); |
1095 } | 1095 } |
(...skipping 4622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5718 __ Subu(scratch, result, scratch); | 5718 __ Subu(scratch, result, scratch); |
5719 __ lw(result, FieldMemOperand(scratch, | 5719 __ lw(result, FieldMemOperand(scratch, |
5720 FixedArray::kHeaderSize - kPointerSize)); | 5720 FixedArray::kHeaderSize - kPointerSize)); |
5721 __ bind(&done); | 5721 __ bind(&done); |
5722 } | 5722 } |
5723 | 5723 |
5724 | 5724 |
5725 #undef __ | 5725 #undef __ |
5726 | 5726 |
5727 } } // namespace v8::internal | 5727 } } // namespace v8::internal |
OLD | NEW |