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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 1877133004: [x64] Avoid sign extension in TruncateFloat64ToInt32(TruncationMode::kJavaScript) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Avoid to use the additional movl instruction. 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 | « src/compiler/x64/code-generator-x64.cc ('k') | 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_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 int offset) { 3737 int offset) {
3738 DoubleToIStub stub(isolate(), input_reg, result_reg, offset, true); 3738 DoubleToIStub stub(isolate(), input_reg, result_reg, offset, true);
3739 call(stub.GetCode(), RelocInfo::CODE_TARGET); 3739 call(stub.GetCode(), RelocInfo::CODE_TARGET);
3740 } 3740 }
3741 3741
3742 3742
3743 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, 3743 void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
3744 Register input_reg) { 3744 Register input_reg) {
3745 Label done; 3745 Label done;
3746 Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 3746 Movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3747 Cvttsd2siq(result_reg, xmm0); 3747 Cvttsd2si(result_reg, xmm0);
3748 cmpq(result_reg, Immediate(1)); 3748 cmpl(result_reg, Immediate(1));
3749 j(no_overflow, &done, Label::kNear); 3749 j(no_overflow, &done, Label::kNear);
3750 3750
3751 // Slow case. 3751 // Slow case.
3752 if (input_reg.is(result_reg)) { 3752 if (input_reg.is(result_reg)) {
3753 subp(rsp, Immediate(kDoubleSize)); 3753 subp(rsp, Immediate(kDoubleSize));
3754 Movsd(MemOperand(rsp, 0), xmm0); 3754 Movsd(MemOperand(rsp, 0), xmm0);
3755 SlowTruncateToI(result_reg, rsp, 0); 3755 SlowTruncateToI(result_reg, rsp, 0);
3756 addp(rsp, Immediate(kDoubleSize)); 3756 addp(rsp, Immediate(kDoubleSize));
3757 } else { 3757 } else {
3758 SlowTruncateToI(result_reg, input_reg); 3758 SlowTruncateToI(result_reg, input_reg);
3759 } 3759 }
3760 3760
3761 bind(&done); 3761 bind(&done);
3762 // Keep our invariant that the upper 32 bits are zero. 3762 // Keep our invariant that the upper 32 bits are zero.
3763 movl(result_reg, result_reg); 3763 movl(result_reg, result_reg);
3764 } 3764 }
3765 3765
3766 3766
3767 void MacroAssembler::TruncateDoubleToI(Register result_reg, 3767 void MacroAssembler::TruncateDoubleToI(Register result_reg,
3768 XMMRegister input_reg) { 3768 XMMRegister input_reg) {
3769 Label done; 3769 Label done;
3770 Cvttsd2siq(result_reg, input_reg); 3770 Cvttsd2si(result_reg, input_reg);
3771 cmpq(result_reg, Immediate(1)); 3771 cmpl(result_reg, Immediate(1));
3772 j(no_overflow, &done, Label::kNear); 3772 j(no_overflow, &done, Label::kNear);
3773 3773
3774 subp(rsp, Immediate(kDoubleSize)); 3774 subp(rsp, Immediate(kDoubleSize));
3775 Movsd(MemOperand(rsp, 0), input_reg); 3775 Movsd(MemOperand(rsp, 0), input_reg);
3776 SlowTruncateToI(result_reg, rsp, 0); 3776 SlowTruncateToI(result_reg, rsp, 0);
3777 addp(rsp, Immediate(kDoubleSize)); 3777 addp(rsp, Immediate(kDoubleSize));
3778 3778
3779 bind(&done); 3779 bind(&done);
3780 // Keep our invariant that the upper 32 bits are zero. 3780 // Keep our invariant that the upper 32 bits are zero.
3781 movl(result_reg, result_reg); 3781 movl(result_reg, result_reg);
(...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
5704 movl(rax, dividend); 5704 movl(rax, dividend);
5705 shrl(rax, Immediate(31)); 5705 shrl(rax, Immediate(31));
5706 addl(rdx, rax); 5706 addl(rdx, rax);
5707 } 5707 }
5708 5708
5709 5709
5710 } // namespace internal 5710 } // namespace internal
5711 } // namespace v8 5711 } // namespace v8
5712 5712
5713 #endif // V8_TARGET_ARCH_X64 5713 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/compiler/x64/code-generator-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698