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

Side by Side Diff: src/crankshaft/x87/lithium-codegen-x87.cc

Issue 1856303002: [X87] [Crankshaft] Fix DoMathFloor and DoMathRound code generation bug. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/crankshaft/x87/lithium-codegen-x87.h" 7 #include "src/crankshaft/x87/lithium-codegen-x87.h"
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3473 } 3473 }
3474 3474
3475 // Positive input. 3475 // Positive input.
3476 // rc=01B, round down. 3476 // rc=01B, round down.
3477 __ bind(&not_minus_zero); 3477 __ bind(&not_minus_zero);
3478 __ fnclex(); 3478 __ fnclex();
3479 __ X87SetRC(0x0400); 3479 __ X87SetRC(0x0400);
3480 __ sub(esp, Immediate(kPointerSize)); 3480 __ sub(esp, Immediate(kPointerSize));
3481 __ fist_s(Operand(esp, 0)); 3481 __ fist_s(Operand(esp, 0));
3482 __ pop(output_reg); 3482 __ pop(output_reg);
3483 __ X87SetRC(0x0000);
3483 __ X87CheckIA(); 3484 __ X87CheckIA();
3484 DeoptimizeIf(equal, instr, Deoptimizer::kOverflow); 3485 DeoptimizeIf(equal, instr, Deoptimizer::kOverflow);
3485 __ fnclex(); 3486 __ fnclex();
3486 __ X87SetRC(0x0000); 3487 __ X87SetRC(0x0000);
3487 __ bind(&done); 3488 __ bind(&done);
3488 } 3489 }
3489 3490
3490 3491
3491 void LCodeGen::DoMathRound(LMathRound* instr) { 3492 void LCodeGen::DoMathRound(LMathRound* instr) {
3492 X87Register input_reg = ToX87Register(instr->value()); 3493 X87Register input_reg = ToX87Register(instr->value());
(...skipping 12 matching lines...) Expand all
3505 3506
3506 // Use rounds towards zero, since 0.5 <= x, we use floor(0.5 + x) 3507 // Use rounds towards zero, since 0.5 <= x, we use floor(0.5 + x)
3507 __ fld(0); 3508 __ fld(0);
3508 __ fadd_d(Operand::StaticVariable(one_half)); 3509 __ fadd_d(Operand::StaticVariable(one_half));
3509 // rc=11B, round toward zero. 3510 // rc=11B, round toward zero.
3510 __ X87SetRC(0x0c00); 3511 __ X87SetRC(0x0c00);
3511 __ sub(esp, Immediate(kPointerSize)); 3512 __ sub(esp, Immediate(kPointerSize));
3512 // Clear exception bits. 3513 // Clear exception bits.
3513 __ fnclex(); 3514 __ fnclex();
3514 __ fistp_s(MemOperand(esp, 0)); 3515 __ fistp_s(MemOperand(esp, 0));
3516 // Restore round mode.
3517 __ X87SetRC(0x0000);
3515 // Check overflow. 3518 // Check overflow.
3516 __ X87CheckIA(); 3519 __ X87CheckIA();
3517 __ pop(result); 3520 __ pop(result);
3518 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); 3521 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow);
3519 __ fnclex(); 3522 __ fnclex();
3520 // Restore round mode. 3523 // Restore round mode.
3521 __ X87SetRC(0x0000); 3524 __ X87SetRC(0x0000);
3522 __ jmp(&done); 3525 __ jmp(&done);
3523 3526
3524 __ bind(&below_one_half); 3527 __ bind(&below_one_half);
(...skipping 14 matching lines...) Expand all
3539 3542
3540 __ bind(&below_minus_one_half); 3543 __ bind(&below_minus_one_half);
3541 __ fld(0); 3544 __ fld(0);
3542 __ fadd_d(Operand::StaticVariable(one_half)); 3545 __ fadd_d(Operand::StaticVariable(one_half));
3543 // rc=01B, round down. 3546 // rc=01B, round down.
3544 __ X87SetRC(0x0400); 3547 __ X87SetRC(0x0400);
3545 __ sub(esp, Immediate(kPointerSize)); 3548 __ sub(esp, Immediate(kPointerSize));
3546 // Clear exception bits. 3549 // Clear exception bits.
3547 __ fnclex(); 3550 __ fnclex();
3548 __ fistp_s(MemOperand(esp, 0)); 3551 __ fistp_s(MemOperand(esp, 0));
3552 // Restore round mode.
3553 __ X87SetRC(0x0000);
3549 // Check overflow. 3554 // Check overflow.
3550 __ X87CheckIA(); 3555 __ X87CheckIA();
3551 __ pop(result); 3556 __ pop(result);
3552 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow); 3557 DeoptimizeIf(equal, instr, Deoptimizer::kConversionOverflow);
3553 __ fnclex(); 3558 __ fnclex();
3554 // Restore round mode. 3559 // Restore round mode.
3555 __ X87SetRC(0x0000); 3560 __ X87SetRC(0x0000);
3556 3561
3557 __ bind(&done); 3562 __ bind(&done);
3558 } 3563 }
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after
5820 __ bind(deferred->exit()); 5825 __ bind(deferred->exit());
5821 __ bind(&done); 5826 __ bind(&done);
5822 } 5827 }
5823 5828
5824 #undef __ 5829 #undef __
5825 5830
5826 } // namespace internal 5831 } // namespace internal
5827 } // namespace v8 5832 } // namespace v8
5828 5833
5829 #endif // V8_TARGET_ARCH_X87 5834 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698