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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // Reserve space for the stack slots needed by the code. | 150 // Reserve space for the stack slots needed by the code. |
151 int slots = GetStackSlotCount(); | 151 int slots = GetStackSlotCount(); |
152 if (slots > 0) { | 152 if (slots > 0) { |
153 if (FLAG_debug_code) { | 153 if (FLAG_debug_code) { |
154 __ subq(rsp, Immediate(slots * kPointerSize)); | 154 __ subq(rsp, Immediate(slots * kPointerSize)); |
155 #ifdef _MSC_VER | 155 #ifdef _MSC_VER |
156 MakeSureStackPagesMapped(slots * kPointerSize); | 156 MakeSureStackPagesMapped(slots * kPointerSize); |
157 #endif | 157 #endif |
158 __ push(rax); | 158 __ push(rax); |
159 __ Set(rax, slots); | 159 __ Set(rax, slots); |
160 __ movq(kScratchRegister, kSlotsZapValue); | 160 __ Set(kScratchRegister, kSlotsZapValue); |
161 Label loop; | 161 Label loop; |
162 __ bind(&loop); | 162 __ bind(&loop); |
163 __ movq(MemOperand(rsp, rax, times_pointer_size, 0), | 163 __ movq(MemOperand(rsp, rax, times_pointer_size, 0), |
164 kScratchRegister); | 164 kScratchRegister); |
165 __ decl(rax); | 165 __ decl(rax); |
166 __ j(not_zero, &loop); | 166 __ j(not_zero, &loop); |
167 __ pop(rax); | 167 __ pop(rax); |
168 } else { | 168 } else { |
169 __ subq(rsp, Immediate(slots * kPointerSize)); | 169 __ subq(rsp, Immediate(slots * kPointerSize)); |
170 #ifdef _MSC_VER | 170 #ifdef _MSC_VER |
(...skipping 3303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3474 | 3474 |
3475 | 3475 |
3476 void LCodeGen::DoMathRound(LMathRound* instr) { | 3476 void LCodeGen::DoMathRound(LMathRound* instr) { |
3477 const XMMRegister xmm_scratch = double_scratch0(); | 3477 const XMMRegister xmm_scratch = double_scratch0(); |
3478 Register output_reg = ToRegister(instr->result()); | 3478 Register output_reg = ToRegister(instr->result()); |
3479 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3479 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3480 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 | 3480 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 |
3481 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 | 3481 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 |
3482 | 3482 |
3483 Label done, round_to_zero, below_one_half, do_not_compensate, restore; | 3483 Label done, round_to_zero, below_one_half, do_not_compensate, restore; |
3484 __ movq(kScratchRegister, one_half); | 3484 __ MoveInteger64(kScratchRegister, one_half); |
3485 __ movq(xmm_scratch, kScratchRegister); | 3485 __ movq(xmm_scratch, kScratchRegister); |
3486 __ ucomisd(xmm_scratch, input_reg); | 3486 __ ucomisd(xmm_scratch, input_reg); |
3487 __ j(above, &below_one_half); | 3487 __ j(above, &below_one_half); |
3488 | 3488 |
3489 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x). | 3489 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x). |
3490 __ addsd(xmm_scratch, input_reg); | 3490 __ addsd(xmm_scratch, input_reg); |
3491 __ cvttsd2si(output_reg, xmm_scratch); | 3491 __ cvttsd2si(output_reg, xmm_scratch); |
3492 // Overflow is signalled with minint. | 3492 // Overflow is signalled with minint. |
3493 __ cmpl(output_reg, Immediate(0x80000000)); | 3493 __ cmpl(output_reg, Immediate(0x80000000)); |
3494 __ RecordComment("D2I conversion overflow"); | 3494 __ RecordComment("D2I conversion overflow"); |
3495 DeoptimizeIf(equal, instr->environment()); | 3495 DeoptimizeIf(equal, instr->environment()); |
3496 __ jmp(&done); | 3496 __ jmp(&done); |
3497 | 3497 |
3498 __ bind(&below_one_half); | 3498 __ bind(&below_one_half); |
3499 __ movq(kScratchRegister, minus_one_half); | 3499 __ MoveInteger64(kScratchRegister, minus_one_half); |
3500 __ movq(xmm_scratch, kScratchRegister); | 3500 __ movq(xmm_scratch, kScratchRegister); |
3501 __ ucomisd(xmm_scratch, input_reg); | 3501 __ ucomisd(xmm_scratch, input_reg); |
3502 __ j(below_equal, &round_to_zero); | 3502 __ j(below_equal, &round_to_zero); |
3503 | 3503 |
3504 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then | 3504 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then |
3505 // compare and compensate. | 3505 // compare and compensate. |
3506 __ movq(kScratchRegister, input_reg); // Back up input_reg. | 3506 __ movq(kScratchRegister, input_reg); // Back up input_reg. |
3507 __ subsd(input_reg, xmm_scratch); | 3507 __ subsd(input_reg, xmm_scratch); |
3508 __ cvttsd2si(output_reg, input_reg); | 3508 __ cvttsd2si(output_reg, input_reg); |
3509 // Catch minint due to overflow, and to prevent overflow when compensating. | 3509 // Catch minint due to overflow, and to prevent overflow when compensating. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3545 XMMRegister xmm_scratch = double_scratch0(); | 3545 XMMRegister xmm_scratch = double_scratch0(); |
3546 XMMRegister input_reg = ToDoubleRegister(instr->value()); | 3546 XMMRegister input_reg = ToDoubleRegister(instr->value()); |
3547 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); | 3547 ASSERT(ToDoubleRegister(instr->result()).is(input_reg)); |
3548 | 3548 |
3549 // Note that according to ECMA-262 15.8.2.13: | 3549 // Note that according to ECMA-262 15.8.2.13: |
3550 // Math.pow(-Infinity, 0.5) == Infinity | 3550 // Math.pow(-Infinity, 0.5) == Infinity |
3551 // Math.sqrt(-Infinity) == NaN | 3551 // Math.sqrt(-Infinity) == NaN |
3552 Label done, sqrt; | 3552 Label done, sqrt; |
3553 // Check base for -Infinity. According to IEEE-754, double-precision | 3553 // Check base for -Infinity. According to IEEE-754, double-precision |
3554 // -Infinity has the highest 12 bits set and the lowest 52 bits cleared. | 3554 // -Infinity has the highest 12 bits set and the lowest 52 bits cleared. |
3555 __ movq(kScratchRegister, V8_INT64_C(0xFFF0000000000000)); | 3555 __ MoveInteger64(kScratchRegister, V8_INT64_C(0xFFF0000000000000)); |
3556 __ movq(xmm_scratch, kScratchRegister); | 3556 __ movq(xmm_scratch, kScratchRegister); |
3557 __ ucomisd(xmm_scratch, input_reg); | 3557 __ ucomisd(xmm_scratch, input_reg); |
3558 // Comparing -Infinity with NaN results in "unordered", which sets the | 3558 // Comparing -Infinity with NaN results in "unordered", which sets the |
3559 // zero flag as if both were equal. However, it also sets the carry flag. | 3559 // zero flag as if both were equal. However, it also sets the carry flag. |
3560 __ j(not_equal, &sqrt, Label::kNear); | 3560 __ j(not_equal, &sqrt, Label::kNear); |
3561 __ j(carry, &sqrt, Label::kNear); | 3561 __ j(carry, &sqrt, Label::kNear); |
3562 // If input is -Infinity, return Infinity. | 3562 // If input is -Infinity, return Infinity. |
3563 __ xorps(input_reg, input_reg); | 3563 __ xorps(input_reg, input_reg); |
3564 __ subsd(input_reg, xmm_scratch); | 3564 __ subsd(input_reg, xmm_scratch); |
3565 __ jmp(&done, Label::kNear); | 3565 __ jmp(&done, Label::kNear); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3653 Register random = state0; | 3653 Register random = state0; |
3654 __ shll(random, Immediate(14)); | 3654 __ shll(random, Immediate(14)); |
3655 __ andl(state1, Immediate(0x3FFFF)); | 3655 __ andl(state1, Immediate(0x3FFFF)); |
3656 __ addl(random, state1); | 3656 __ addl(random, state1); |
3657 | 3657 |
3658 // Convert 32 random bits in rax to 0.(32 random bits) in a double | 3658 // Convert 32 random bits in rax to 0.(32 random bits) in a double |
3659 // by computing: | 3659 // by computing: |
3660 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). | 3660 // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)). |
3661 XMMRegister result = ToDoubleRegister(instr->result()); | 3661 XMMRegister result = ToDoubleRegister(instr->result()); |
3662 XMMRegister scratch4 = double_scratch0(); | 3662 XMMRegister scratch4 = double_scratch0(); |
3663 __ movq(scratch3, V8_INT64_C(0x4130000000000000)); // 1.0 x 2^20 as double | 3663 __ MoveInteger64(scratch3, V8_INT64_C(0x4130000000000000)); // 1.0 x 2^20 |
3664 __ movq(scratch4, scratch3); | 3664 __ movq(scratch4, scratch3); |
3665 __ movd(result, random); | 3665 __ movd(result, random); |
3666 __ xorps(result, scratch4); | 3666 __ xorps(result, scratch4); |
3667 __ subsd(result, scratch4); | 3667 __ subsd(result, scratch4); |
3668 } | 3668 } |
3669 | 3669 |
3670 | 3670 |
3671 void LCodeGen::DoMathExp(LMathExp* instr) { | 3671 void LCodeGen::DoMathExp(LMathExp* instr) { |
3672 XMMRegister input = ToDoubleRegister(instr->value()); | 3672 XMMRegister input = ToDoubleRegister(instr->value()); |
3673 XMMRegister result = ToDoubleRegister(instr->result()); | 3673 XMMRegister result = ToDoubleRegister(instr->result()); |
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5498 FixedArray::kHeaderSize - kPointerSize)); | 5498 FixedArray::kHeaderSize - kPointerSize)); |
5499 __ bind(&done); | 5499 __ bind(&done); |
5500 } | 5500 } |
5501 | 5501 |
5502 | 5502 |
5503 #undef __ | 5503 #undef __ |
5504 | 5504 |
5505 } } // namespace v8::internal | 5505 } } // namespace v8::internal |
5506 | 5506 |
5507 #endif // V8_TARGET_ARCH_X64 | 5507 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |