Chromium Code Reviews| Index: src/compiler/x87/code-generator-x87.cc |
| diff --git a/src/compiler/x87/code-generator-x87.cc b/src/compiler/x87/code-generator-x87.cc |
| index 9b8b823be33beb2d5f76a603c40436a2251e0671..fa11dfcac21cf6459e7a187cbabadd32b91618bd 100644 |
| --- a/src/compiler/x87/code-generator-x87.cc |
| +++ b/src/compiler/x87/code-generator-x87.cc |
| @@ -191,25 +191,47 @@ class OutOfLineLoadInteger final : public OutOfLineCode { |
| Register const result_; |
| }; |
| -class OutOfLineLoadNaN final : public OutOfLineCode { |
| +class OutOfLineLoadFloat32NaN final : public OutOfLineCode { |
| public: |
| - OutOfLineLoadNaN(CodeGenerator* gen, X87Register result) |
| + OutOfLineLoadFloat32NaN(CodeGenerator* gen, X87Register result) |
| : OutOfLineCode(gen), result_(result) {} |
| void Generate() final { |
| DCHECK(result_.code() == 0); |
| USE(result_); |
| __ fstp(0); |
| - __ push(Immediate(0xffffffff)); |
|
ahaas
2016/08/11 06:39:00
I think you could also just push the default NaN i
|
| - __ push(Immediate(0x7fffffff)); |
| - __ fld_d(MemOperand(esp, 0)); |
| - __ lea(esp, Operand(esp, kDoubleSize)); |
| + __ fldz(); |
| + __ fldz(); |
| + __ fdiv(1); |
| + __ fstp(0); |
| + __ lea(esp, Operand(esp, -kFloatSize)); |
| + __ fstp_s(MemOperand(esp, 0)); |
| + __ fld_s(MemOperand(esp, 0)); |
| + __ lea(esp, Operand(esp, kFloatSize)); |
| } |
| private: |
| X87Register const result_; |
| }; |
| +class OutOfLineLoadFloat64NaN final : public OutOfLineCode { |
| + public: |
| + OutOfLineLoadFloat64NaN(CodeGenerator* gen, X87Register result) |
| + : OutOfLineCode(gen), result_(result) {} |
| + |
| + void Generate() final { |
| + DCHECK(result_.code() == 0); |
| + USE(result_); |
| + __ fstp(0); |
| + __ fldz(); |
| + __ fldz(); |
| + __ fdiv(1); |
| + __ fstp(0); |
| + } |
| + |
| + private: |
| + X87Register const result_; |
| +}; |
| class OutOfLineTruncateDoubleToI final : public OutOfLineCode { |
| public: |
| @@ -271,7 +293,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode { |
| } // namespace |
| -#define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr) \ |
| +#define ASSEMBLE_CHECKED_LOAD_FLOAT(asm_instr, OutOfLineLoadNaN) \ |
| do { \ |
| auto result = i.OutputDoubleRegister(); \ |
| auto offset = i.InputRegister(0); \ |
| @@ -1295,7 +1317,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| __ fld(1); |
| __ FCmp(); |
| - auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); |
| + auto ool = |
| + new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); |
| __ j(parity_even, ool->entry()); |
| __ j(below, &done_compare, Label::kNear); |
| __ j(above, &compare_swap, Label::kNear); |
| @@ -1330,7 +1353,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| __ fld(1); |
| __ FCmp(); |
| - auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister()); |
| + auto ool = |
| + new (zone()) OutOfLineLoadFloat64NaN(this, i.OutputDoubleRegister()); |
| __ j(parity_even, ool->entry()); |
| __ j(above, &done_compare, Label::kNear); |
| __ j(below, &compare_swap, Label::kNear); |
| @@ -1898,10 +1922,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| ASSEMBLE_CHECKED_LOAD_INTEGER(mov); |
| break; |
| case kCheckedLoadFloat32: |
| - ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s); |
| + ASSEMBLE_CHECKED_LOAD_FLOAT(fld_s, OutOfLineLoadFloat32NaN); |
| break; |
| case kCheckedLoadFloat64: |
| - ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d); |
| + ASSEMBLE_CHECKED_LOAD_FLOAT(fld_d, OutOfLineLoadFloat64NaN); |
| break; |
| case kCheckedStoreWord8: |
| ASSEMBLE_CHECKED_STORE_INTEGER(mov_b); |