OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 } else { | 1116 } else { |
1117 Register reg1 = ToRegister(instr->temp()); | 1117 Register reg1 = ToRegister(instr->temp()); |
1118 Register reg2 = ToRegister(instr->result()); | 1118 Register reg2 = ToRegister(instr->result()); |
1119 | 1119 |
1120 // Find b which: 2^b < divisor_abs < 2^(b+1). | 1120 // Find b which: 2^b < divisor_abs < 2^(b+1). |
1121 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs); | 1121 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs); |
1122 unsigned shift = 32 + b; // Precision +1bit (effectively). | 1122 unsigned shift = 32 + b; // Precision +1bit (effectively). |
1123 double multiplier_f = | 1123 double multiplier_f = |
1124 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs; | 1124 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs; |
1125 int64_t multiplier; | 1125 int64_t multiplier; |
1126 if (multiplier_f - floor(multiplier_f) < 0.5) { | 1126 if (multiplier_f - std::floor(multiplier_f) < 0.5) { |
1127 multiplier = static_cast<int64_t>(floor(multiplier_f)); | 1127 multiplier = static_cast<int64_t>(std::floor(multiplier_f)); |
1128 } else { | 1128 } else { |
1129 multiplier = static_cast<int64_t>(floor(multiplier_f)) + 1; | 1129 multiplier = static_cast<int64_t>(std::floor(multiplier_f)) + 1; |
1130 } | 1130 } |
1131 // The multiplier is a uint32. | 1131 // The multiplier is a uint32. |
1132 ASSERT(multiplier > 0 && | 1132 ASSERT(multiplier > 0 && |
1133 multiplier < (static_cast<int64_t>(1) << 32)); | 1133 multiplier < (static_cast<int64_t>(1) << 32)); |
1134 // The multiply is int64, so sign-extend to r64. | 1134 // The multiply is int64, so sign-extend to r64. |
1135 __ movsxlq(reg1, dividend); | 1135 __ movsxlq(reg1, dividend); |
1136 if (divisor < 0 && | 1136 if (divisor < 0 && |
1137 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1137 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1138 __ neg(reg1); | 1138 __ neg(reg1); |
1139 DeoptimizeIf(zero, instr->environment()); | 1139 DeoptimizeIf(zero, instr->environment()); |
(...skipping 4489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5629 FixedArray::kHeaderSize - kPointerSize)); | 5629 FixedArray::kHeaderSize - kPointerSize)); |
5630 __ bind(&done); | 5630 __ bind(&done); |
5631 } | 5631 } |
5632 | 5632 |
5633 | 5633 |
5634 #undef __ | 5634 #undef __ |
5635 | 5635 |
5636 } } // namespace v8::internal | 5636 } } // namespace v8::internal |
5637 | 5637 |
5638 #endif // V8_TARGET_ARCH_X64 | 5638 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |