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

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

Issue 1470793004: X87: Adopt the fix of the sqrt precision issue from TurboFan to CrankShaft. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 3848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3859 X87Register input_reg = ToX87Register(instr->value()); 3859 X87Register input_reg = ToX87Register(instr->value());
3860 X87Fxch(input_reg); 3860 X87Fxch(input_reg);
3861 __ sub(esp, Immediate(kPointerSize)); 3861 __ sub(esp, Immediate(kPointerSize));
3862 __ fstp_s(MemOperand(esp, 0)); 3862 __ fstp_s(MemOperand(esp, 0));
3863 X87Fld(MemOperand(esp, 0), kX87FloatOperand); 3863 X87Fld(MemOperand(esp, 0), kX87FloatOperand);
3864 __ add(esp, Immediate(kPointerSize)); 3864 __ add(esp, Immediate(kPointerSize));
3865 } 3865 }
3866 3866
3867 3867
3868 void LCodeGen::DoMathSqrt(LMathSqrt* instr) { 3868 void LCodeGen::DoMathSqrt(LMathSqrt* instr) {
3869 X87Register input = ToX87Register(instr->value()); 3869 X87Register input_reg = ToX87Register(instr->value());
3870 X87Register result_reg = ToX87Register(instr->result()); 3870 __ X87SetFPUCW(0x027F);
3871 Register temp_result = ToRegister(instr->temp1()); 3871 X87Fxch(input_reg);
3872 Register temp = ToRegister(instr->temp2()); 3872 __ fsqrt();
3873 Label slow, done, smi, finish; 3873 __ X87SetFPUCW(0x037F);
3874 DCHECK(result_reg.is(input));
3875
3876 // Store input into Heap number and call runtime function kMathExpRT.
3877 if (FLAG_inline_new) {
3878 __ AllocateHeapNumber(temp_result, temp, no_reg, &slow);
3879 __ jmp(&done, Label::kNear);
3880 }
3881
3882 // Slow case: Call the runtime system to do the number allocation.
3883 __ bind(&slow);
3884 {
3885 // TODO(3095996): Put a valid pointer value in the stack slot where the
3886 // result register is stored, as this register is in the pointer map, but
3887 // contains an integer value.
3888 __ Move(temp_result, Immediate(0));
3889
3890 // Preserve the value of all registers.
3891 PushSafepointRegistersScope scope(this);
3892
3893 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3894 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
3895 RecordSafepointWithRegisters(
3896 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
3897 __ StoreToSafepointRegisterSlot(temp_result, eax);
3898 }
3899 __ bind(&done);
3900 X87LoadForUsage(input);
3901 __ fstp_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
3902
3903 {
3904 // Preserve the value of all registers.
3905 PushSafepointRegistersScope scope(this);
3906
3907 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3908 __ push(temp_result);
3909 __ CallRuntimeSaveDoubles(Runtime::kMathSqrt);
3910 RecordSafepointWithRegisters(instr->pointer_map(), 1,
3911 Safepoint::kNoLazyDeopt);
3912 __ StoreToSafepointRegisterSlot(temp_result, eax);
3913 }
3914 X87PrepareToWrite(result_reg);
3915 // return value of MathExpRT is Smi or Heap Number.
3916 __ JumpIfSmi(temp_result, &smi);
3917 // Heap number(double)
3918 __ fld_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
3919 __ jmp(&finish);
3920 // SMI
3921 __ bind(&smi);
3922 __ SmiUntag(temp_result);
3923 __ push(temp_result);
3924 __ fild_s(MemOperand(esp, 0));
3925 __ pop(temp_result);
3926 __ bind(&finish);
3927 X87CommitWrite(result_reg);
3928 } 3874 }
3929 3875
3930 3876
3931 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { 3877 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
3932 X87Register input_reg = ToX87Register(instr->value()); 3878 X87Register input_reg = ToX87Register(instr->value());
3933 DCHECK(ToX87Register(instr->result()).is(input_reg)); 3879 DCHECK(ToX87Register(instr->result()).is(input_reg));
3934 X87Fxch(input_reg); 3880 X87Fxch(input_reg);
3935 // Note that according to ECMA-262 15.8.2.13: 3881 // Note that according to ECMA-262 15.8.2.13:
3936 // Math.pow(-Infinity, 0.5) == Infinity 3882 // Math.pow(-Infinity, 0.5) == Infinity
3937 // Math.sqrt(-Infinity) == NaN 3883 // Math.sqrt(-Infinity) == NaN
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
6269 RecordSafepoint(Safepoint::kNoLazyDeopt); 6215 RecordSafepoint(Safepoint::kNoLazyDeopt);
6270 } 6216 }
6271 6217
6272 6218
6273 #undef __ 6219 #undef __
6274 6220
6275 } // namespace internal 6221 } // namespace internal
6276 } // namespace v8 6222 } // namespace v8
6277 6223
6278 #endif // V8_TARGET_ARCH_X87 6224 #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