| OLD | NEW |
| 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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Register result_reg = final_result_reg.is(rcx) ? rax : final_result_reg; | 155 Register result_reg = final_result_reg.is(rcx) ? rax : final_result_reg; |
| 156 // Save ecx if it isn't the return register and therefore volatile, or if it | 156 // Save ecx if it isn't the return register and therefore volatile, or if it |
| 157 // is the return register, then save the temp register we use in its stead | 157 // is the return register, then save the temp register we use in its stead |
| 158 // for the result. | 158 // for the result. |
| 159 Register save_reg = final_result_reg.is(rcx) ? rax : rcx; | 159 Register save_reg = final_result_reg.is(rcx) ? rax : rcx; |
| 160 __ pushq(scratch1); | 160 __ pushq(scratch1); |
| 161 __ pushq(save_reg); | 161 __ pushq(save_reg); |
| 162 | 162 |
| 163 bool stash_exponent_copy = !input_reg.is(rsp); | 163 bool stash_exponent_copy = !input_reg.is(rsp); |
| 164 __ movl(scratch1, mantissa_operand); | 164 __ movl(scratch1, mantissa_operand); |
| 165 __ Movsd(xmm0, mantissa_operand); | 165 __ Movsd(kScratchDoubleReg, mantissa_operand); |
| 166 __ movl(rcx, exponent_operand); | 166 __ movl(rcx, exponent_operand); |
| 167 if (stash_exponent_copy) __ pushq(rcx); | 167 if (stash_exponent_copy) __ pushq(rcx); |
| 168 | 168 |
| 169 __ andl(rcx, Immediate(HeapNumber::kExponentMask)); | 169 __ andl(rcx, Immediate(HeapNumber::kExponentMask)); |
| 170 __ shrl(rcx, Immediate(HeapNumber::kExponentShift)); | 170 __ shrl(rcx, Immediate(HeapNumber::kExponentShift)); |
| 171 __ leal(result_reg, MemOperand(rcx, -HeapNumber::kExponentBias)); | 171 __ leal(result_reg, MemOperand(rcx, -HeapNumber::kExponentBias)); |
| 172 __ cmpl(result_reg, Immediate(HeapNumber::kMantissaBits)); | 172 __ cmpl(result_reg, Immediate(HeapNumber::kMantissaBits)); |
| 173 __ j(below, &process_64_bits); | 173 __ j(below, &process_64_bits); |
| 174 | 174 |
| 175 // Result is entirely in lower 32-bits of mantissa | 175 // Result is entirely in lower 32-bits of mantissa |
| 176 int delta = HeapNumber::kExponentBias + Double::kPhysicalSignificandSize; | 176 int delta = HeapNumber::kExponentBias + Double::kPhysicalSignificandSize; |
| 177 __ subl(rcx, Immediate(delta)); | 177 __ subl(rcx, Immediate(delta)); |
| 178 __ xorl(result_reg, result_reg); | 178 __ xorl(result_reg, result_reg); |
| 179 __ cmpl(rcx, Immediate(31)); | 179 __ cmpl(rcx, Immediate(31)); |
| 180 __ j(above, &done); | 180 __ j(above, &done); |
| 181 __ shll_cl(scratch1); | 181 __ shll_cl(scratch1); |
| 182 __ jmp(&check_negative); | 182 __ jmp(&check_negative); |
| 183 | 183 |
| 184 __ bind(&process_64_bits); | 184 __ bind(&process_64_bits); |
| 185 __ Cvttsd2siq(result_reg, xmm0); | 185 __ Cvttsd2siq(result_reg, kScratchDoubleReg); |
| 186 __ jmp(&done, Label::kNear); | 186 __ jmp(&done, Label::kNear); |
| 187 | 187 |
| 188 // If the double was negative, negate the integer result. | 188 // If the double was negative, negate the integer result. |
| 189 __ bind(&check_negative); | 189 __ bind(&check_negative); |
| 190 __ movl(result_reg, scratch1); | 190 __ movl(result_reg, scratch1); |
| 191 __ negl(result_reg); | 191 __ negl(result_reg); |
| 192 if (stash_exponent_copy) { | 192 if (stash_exponent_copy) { |
| 193 __ cmpl(MemOperand(rsp, 0), Immediate(0)); | 193 __ cmpl(MemOperand(rsp, 0), Immediate(0)); |
| 194 } else { | 194 } else { |
| 195 __ cmpl(exponent_operand, Immediate(0)); | 195 __ cmpl(exponent_operand, Immediate(0)); |
| (...skipping 5247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5443 kStackUnwindSpace, nullptr, return_value_operand, | 5443 kStackUnwindSpace, nullptr, return_value_operand, |
| 5444 NULL); | 5444 NULL); |
| 5445 } | 5445 } |
| 5446 | 5446 |
| 5447 #undef __ | 5447 #undef __ |
| 5448 | 5448 |
| 5449 } // namespace internal | 5449 } // namespace internal |
| 5450 } // namespace v8 | 5450 } // namespace v8 |
| 5451 | 5451 |
| 5452 #endif // V8_TARGET_ARCH_X64 | 5452 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |