Index: src/compiler/x64/code-generator-x64.cc |
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
index 4a96fe866bf2b1ee442f33d6ffab8ef294a4391a..fd02916fa22257b2c6ace4ded72d6d1aa9ff01c1 100644 |
--- a/src/compiler/x64/code-generator-x64.cc |
+++ b/src/compiler/x64/code-generator-x64.cc |
@@ -155,6 +155,25 @@ class OutOfLineLoadFloat FINAL : public OutOfLineCode { |
XMMRegister const result_; |
}; |
+ |
+class OutOfLineTruncateDoubleToI FINAL : public OutOfLineCode { |
+ public: |
+ OutOfLineTruncateDoubleToI(CodeGenerator* gen, Register result, |
+ XMMRegister input) |
+ : OutOfLineCode(gen), result_(result), input_(input) {} |
+ |
+ void Generate() FINAL { |
+ __ subp(rsp, Immediate(kDoubleSize)); |
+ __ movsd(MemOperand(rsp, 0), input_); |
+ __ SlowTruncateToI(result_, rsp, 0); |
+ __ addp(rsp, Immediate(kDoubleSize)); |
+ } |
+ |
+ private: |
+ Register const result_; |
+ XMMRegister const input_; |
+}; |
+ |
} // namespace |
@@ -355,9 +374,16 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
case kArchStackPointer: |
__ movq(i.OutputRegister(), rsp); |
break; |
- case kArchTruncateDoubleToI: |
- __ TruncateDoubleToI(i.OutputRegister(), i.InputDoubleRegister(0)); |
+ case kArchTruncateDoubleToI: { |
+ auto result = i.OutputRegister(); |
+ auto input = i.InputDoubleRegister(0); |
+ auto ool = new (zone()) OutOfLineTruncateDoubleToI(this, result, input); |
+ __ cvttsd2siq(result, input); |
+ __ cmpq(result, Immediate(1)); |
+ __ j(overflow, ool->entry()); |
+ __ bind(ool->exit()); |
break; |
+ } |
case kX64Add32: |
ASSEMBLE_BINOP(addl); |
break; |