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

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

Issue 199093003: Merged r19798, r19896 into 3.24 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.24
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 3533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3544 3544
3545 __ bind(&done); 3545 __ bind(&done);
3546 } 3546 }
3547 } 3547 }
3548 3548
3549 3549
3550 void LCodeGen::DoMathRound(LMathRound* instr) { 3550 void LCodeGen::DoMathRound(LMathRound* instr) {
3551 const XMMRegister xmm_scratch = double_scratch0(); 3551 const XMMRegister xmm_scratch = double_scratch0();
3552 Register output_reg = ToRegister(instr->result()); 3552 Register output_reg = ToRegister(instr->result());
3553 XMMRegister input_reg = ToDoubleRegister(instr->value()); 3553 XMMRegister input_reg = ToDoubleRegister(instr->value());
3554 XMMRegister input_temp = ToDoubleRegister(instr->temp());
3554 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5 3555 static int64_t one_half = V8_INT64_C(0x3FE0000000000000); // 0.5
3555 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5 3556 static int64_t minus_one_half = V8_INT64_C(0xBFE0000000000000); // -0.5
3556 3557
3557 Label done, round_to_zero, below_one_half, do_not_compensate, restore; 3558 Label done, round_to_zero, below_one_half;
3558 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; 3559 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear;
3559 __ movq(kScratchRegister, one_half); 3560 __ movq(kScratchRegister, one_half);
3560 __ movq(xmm_scratch, kScratchRegister); 3561 __ movq(xmm_scratch, kScratchRegister);
3561 __ ucomisd(xmm_scratch, input_reg); 3562 __ ucomisd(xmm_scratch, input_reg);
3562 __ j(above, &below_one_half, Label::kNear); 3563 __ j(above, &below_one_half, Label::kNear);
3563 3564
3564 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x). 3565 // CVTTSD2SI rounds towards zero, since 0.5 <= x, we use floor(0.5 + x).
3565 __ addsd(xmm_scratch, input_reg); 3566 __ addsd(xmm_scratch, input_reg);
3566 __ cvttsd2si(output_reg, xmm_scratch); 3567 __ cvttsd2si(output_reg, xmm_scratch);
3567 // Overflow is signalled with minint. 3568 // Overflow is signalled with minint.
3568 __ cmpl(output_reg, Immediate(0x80000000)); 3569 __ cmpl(output_reg, Immediate(0x80000000));
3569 __ RecordComment("D2I conversion overflow"); 3570 __ RecordComment("D2I conversion overflow");
3570 DeoptimizeIf(equal, instr->environment()); 3571 DeoptimizeIf(equal, instr->environment());
3571 __ jmp(&done, dist); 3572 __ jmp(&done, dist);
3572 3573
3573 __ bind(&below_one_half); 3574 __ bind(&below_one_half);
3574 __ movq(kScratchRegister, minus_one_half); 3575 __ movq(kScratchRegister, minus_one_half);
3575 __ movq(xmm_scratch, kScratchRegister); 3576 __ movq(xmm_scratch, kScratchRegister);
3576 __ ucomisd(xmm_scratch, input_reg); 3577 __ ucomisd(xmm_scratch, input_reg);
3577 __ j(below_equal, &round_to_zero, Label::kNear); 3578 __ j(below_equal, &round_to_zero, Label::kNear);
3578 3579
3579 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then 3580 // CVTTSD2SI rounds towards zero, we use ceil(x - (-0.5)) and then
3580 // compare and compensate. 3581 // compare and compensate.
3581 __ movq(kScratchRegister, input_reg); // Back up input_reg. 3582 __ movq(input_temp, input_reg); // Do not alter input_reg.
3582 __ subsd(input_reg, xmm_scratch); 3583 __ subsd(input_temp, xmm_scratch);
3583 __ cvttsd2si(output_reg, input_reg); 3584 __ cvttsd2si(output_reg, input_temp);
3584 // Catch minint due to overflow, and to prevent overflow when compensating. 3585 // Catch minint due to overflow, and to prevent overflow when compensating.
3585 __ cmpl(output_reg, Immediate(0x80000000)); 3586 __ cmpl(output_reg, Immediate(0x80000000));
3586 __ RecordComment("D2I conversion overflow"); 3587 __ RecordComment("D2I conversion overflow");
3587 DeoptimizeIf(equal, instr->environment()); 3588 DeoptimizeIf(equal, instr->environment());
3588 3589
3589 __ Cvtlsi2sd(xmm_scratch, output_reg); 3590 __ Cvtlsi2sd(xmm_scratch, output_reg);
3590 __ ucomisd(input_reg, xmm_scratch); 3591 __ ucomisd(xmm_scratch, input_temp);
3591 __ j(equal, &restore, Label::kNear); 3592 __ j(equal, &done, dist);
3592 __ subl(output_reg, Immediate(1)); 3593 __ subl(output_reg, Immediate(1));
3593 // No overflow because we already ruled out minint. 3594 // No overflow because we already ruled out minint.
3594 __ bind(&restore);
3595 __ movq(input_reg, kScratchRegister); // Restore input_reg.
3596 __ jmp(&done, dist); 3595 __ jmp(&done, dist);
3597 3596
3598 __ bind(&round_to_zero); 3597 __ bind(&round_to_zero);
3599 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if 3598 // We return 0 for the input range [+0, 0.5[, or [-0.5, 0.5[ if
3600 // we can ignore the difference between a result of -0 and +0. 3599 // we can ignore the difference between a result of -0 and +0.
3601 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 3600 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3602 __ movq(output_reg, input_reg); 3601 __ movq(output_reg, input_reg);
3603 __ testq(output_reg, output_reg); 3602 __ testq(output_reg, output_reg);
3604 __ RecordComment("Minus zero"); 3603 __ RecordComment("Minus zero");
3605 DeoptimizeIf(negative, instr->environment()); 3604 DeoptimizeIf(negative, instr->environment());
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
5549 FixedArray::kHeaderSize - kPointerSize)); 5548 FixedArray::kHeaderSize - kPointerSize));
5550 __ bind(&done); 5549 __ bind(&done);
5551 } 5550 }
5552 5551
5553 5552
5554 #undef __ 5553 #undef __
5555 5554
5556 } } // namespace v8::internal 5555 } } // namespace v8::internal
5557 5556
5558 #endif // V8_TARGET_ARCH_X64 5557 #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