| OLD | NEW |
| 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 Register reg1 = ToRegister(instr->TempAt(0)); | 938 Register reg1 = ToRegister(instr->TempAt(0)); |
| 939 Register reg2 = ToRegister(instr->result()); | 939 Register reg2 = ToRegister(instr->result()); |
| 940 | 940 |
| 941 // Find b which: 2^b < divisor_abs < 2^(b+1). | 941 // Find b which: 2^b < divisor_abs < 2^(b+1). |
| 942 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs); | 942 unsigned b = 31 - CompilerIntrinsics::CountLeadingZeros(divisor_abs); |
| 943 unsigned shift = 32 + b; // Precision +1bit (effectively). | 943 unsigned shift = 32 + b; // Precision +1bit (effectively). |
| 944 double multiplier_f = | 944 double multiplier_f = |
| 945 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs; | 945 static_cast<double>(static_cast<uint64_t>(1) << shift) / divisor_abs; |
| 946 int64_t multiplier; | 946 int64_t multiplier; |
| 947 if (multiplier_f - floor(multiplier_f) < 0.5) { | 947 if (multiplier_f - floor(multiplier_f) < 0.5) { |
| 948 multiplier = floor(multiplier_f); | 948 multiplier = static_cast<int64_t>(floor(multiplier_f)); |
| 949 } else { | 949 } else { |
| 950 multiplier = floor(multiplier_f) + 1; | 950 multiplier = static_cast<int64_t>(floor(multiplier_f)) + 1; |
| 951 } | 951 } |
| 952 // The multiplier is a uint32. | 952 // The multiplier is a uint32. |
| 953 ASSERT(multiplier > 0 && | 953 ASSERT(multiplier > 0 && |
| 954 multiplier < (static_cast<int64_t>(1) << 32)); | 954 multiplier < (static_cast<int64_t>(1) << 32)); |
| 955 // The multiply is int64, so sign-extend to r64. | 955 // The multiply is int64, so sign-extend to r64. |
| 956 __ movsxlq(reg1, dividend); | 956 __ movsxlq(reg1, dividend); |
| 957 if (divisor < 0 && | 957 if (divisor < 0 && |
| 958 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 958 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 959 __ neg(reg1); | 959 __ neg(reg1); |
| 960 DeoptimizeIf(zero, instr->environment()); | 960 DeoptimizeIf(zero, instr->environment()); |
| (...skipping 4070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5031 FixedArray::kHeaderSize - kPointerSize)); | 5031 FixedArray::kHeaderSize - kPointerSize)); |
| 5032 __ bind(&done); | 5032 __ bind(&done); |
| 5033 } | 5033 } |
| 5034 | 5034 |
| 5035 | 5035 |
| 5036 #undef __ | 5036 #undef __ |
| 5037 | 5037 |
| 5038 } } // namespace v8::internal | 5038 } } // namespace v8::internal |
| 5039 | 5039 |
| 5040 #endif // V8_TARGET_ARCH_X64 | 5040 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |