Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 196383025: Merged r19798, r19896 into 3.23 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.23
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/version.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 3594
3595 __ bind(&done); 3595 __ bind(&done);
3596 } 3596 }
3597 } 3597 }
3598 3598
3599 3599
3600 void LCodeGen::DoMathRound(LMathRound* instr) { 3600 void LCodeGen::DoMathRound(LMathRound* instr) {
3601 const XMMRegister xmm_scratch = double_scratch0(); 3601 const XMMRegister xmm_scratch = double_scratch0();
3602 Register output_reg = ToRegister(instr->result()); 3602 Register output_reg = ToRegister(instr->result());
3603 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3603 XMMRegister input_reg = ToDoubleRegister(instr->value());
3604 XMMRegister input_temp = ToDoubleRegister(instr->temp());
3604 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 3605 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5
3605 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 3606 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5
3606 3607
3607 Label done, round_to_zero, below_one_half, do_not_compensate, restore; 3608 Label done, round_to_zero, below_one_half;
3608 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; 3609 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
3609 __ movq(kScratchRegister, one_half); 3610 __ movq(kScratchRegister, one_half);
3610 __ movq(xmm_scratch, kScratchRegister); 3611 __ movq(xmm_scratch, kScratchRegister);
3611 __ ucomisd(xmm_scratch, input_reg); 3612 __ ucomisd(xmm_scratch, input_reg);
3612 __ j(above, &below_one_half, Label::kNear); 3613 __ j(above, &below_one_half, Label::kNear);
3613 3614
3614 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x). 3615 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x).
3615 __ addsd(xmm_scratch, input_reg); 3616 __ addsd(xmm_scratch, input_reg);
3616 __ cvttsd2si(output_reg, xmm_scratch); 3617 __ cvttsd2si(output_reg, xmm_scratch);
3617 // Overflow is signalled with minint. 3618 // Overflow is signalled with minint.
3618 __ cmpl(output_reg, Immediate(0x80000000)); 3619 __ cmpl(output_reg, Immediate(0x80000000));
3619 __ RecordComment("D2I conversion overflow"); 3620 __ RecordComment("D2I conversion overflow");
3620 DeoptimizeIf(equal, instr->environment()); 3621 DeoptimizeIf(equal, instr->environment());
3621 __ jmp(&done, dist); 3622 __ jmp(&done, dist);
3622 3623
3623 __ bind(&below_one_half); 3624 __ bind(&below_one_half);
3624 __ movq(kScratchRegister, minus_one_half); 3625 __ movq(kScratchRegister, minus_one_half);
3625 __ movq(xmm_scratch, kScratchRegister); 3626 __ movq(xmm_scratch, kScratchRegister);
3626 __ ucomisd(xmm_scratch, input_reg); 3627 __ ucomisd(xmm_scratch, input_reg);
3627 __ j(below_equal, &round_to_zero, Label::kNear); 3628 __ j(below_equal, &round_to_zero, Label::kNear);
3628 3629
3629 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then 3630 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then
3630 // compare and compensate. 3631 // compare and compensate.
3631 __ movq(kScratchRegister, input_reg); // Back up input_reg. 3632 __ movq(input_temp, input_reg); // Do not alter input_reg.
3632 __ subsd(input_reg, xmm_scratch); 3633 __ subsd(input_temp, xmm_scratch);
3633 __ cvttsd2si(output_reg, input_reg); 3634 __ cvttsd2si(output_reg, input_temp);
3634 // Catch minint due to overflow, and to prevent overflow when compensating. 3635 // Catch minint due to overflow, and to prevent overflow when compensating.
3635 __ cmpl(output_reg, Immediate(0x80000000)); 3636 __ cmpl(output_reg, Immediate(0x80000000));
3636 __ RecordComment("D2I conversion overflow"); 3637 __ RecordComment("D2I conversion overflow");
3637 DeoptimizeIf(equal, instr->environment()); 3638 DeoptimizeIf(equal, instr->environment());
3638 3639
3639 __ Cvtlsi2sd(xmm_scratch, output_reg); 3640 __ Cvtlsi2sd(xmm_scratch, output_reg);
3640 __ ucomisd(input_reg, xmm_scratch); 3641 __ ucomisd(xmm_scratch, input_temp);
3641 __ j(equal, &restore, Label::kNear); 3642 __ j(equal, &done, dist);
3642 __ subl(output_reg, Immediate(1)); 3643 __ subl(output_reg, Immediate(1));
3643 // No overflow because we already ruled out minint. 3644 // No overflow because we already ruled out minint.
3644 __ bind(&restore);
3645 __ movq(input_reg, kScratchRegister); // Restore input_reg.
3646 __ jmp(&done, dist); 3645 __ jmp(&done, dist);
3647 3646
3648 __ bind(&round_to_zero); 3647 __ bind(&round_to_zero);
3649 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if 3648 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if
3650 // we can ignore the difference between a result of -0 and +0. 3649 // we can ignore the difference between a result of -0 and +0.
3651 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3650 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3652 __ movq(output_reg, input_reg); 3651 __ movq(output_reg, input_reg);
3653 __ testq(output_reg, output_reg); 3652 __ testq(output_reg, output_reg);
3654 __ RecordComment("Minus zero"); 3653 __ RecordComment("Minus zero");
3655 DeoptimizeIf(negative, instr->environment()); 3654 DeoptimizeIf(negative, instr->environment());
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
5649 FixedArray::kHeaderSize - kPointerSize)); 5648 FixedArray::kHeaderSize - kPointerSize));
5650 __ bind(&done); 5649 __ bind(&done);
5651 } 5650 }
5652 5651
5653 5652
5654 #undef __ 5653 #undef __
5655 5654
5656 } } // namespace v8::internal 5655 } } // namespace v8::internal
5657 5656
5658 #endif // V8_TARGET_ARCH_X64 5657 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/version.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698