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

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

Issue 606403002: X87: fix the Sqrt issue. (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: fix the comments Created 6 years, 2 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 | src/x87/lithium-x87.h » ('j') | 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
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 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 X87Register input_reg = ToX87Register(instr->value()); 4014 X87Register input_reg = ToX87Register(instr->value());
4015 X87Fxch(input_reg); 4015 X87Fxch(input_reg);
4016 __ sub(esp, Immediate(kPointerSize)); 4016 __ sub(esp, Immediate(kPointerSize));
4017 __ fstp_s(MemOperand(esp, 0)); 4017 __ fstp_s(MemOperand(esp, 0));
4018 X87Fld(MemOperand(esp, 0), kX87FloatOperand); 4018 X87Fld(MemOperand(esp, 0), kX87FloatOperand);
4019 __ add(esp, Immediate(kPointerSize)); 4019 __ add(esp, Immediate(kPointerSize));
4020 } 4020 }
4021 4021
4022 4022
4023 void LCodeGen::DoMathSqrt(LMathSqrt* instr) { 4023 void LCodeGen::DoMathSqrt(LMathSqrt* instr) {
4024 X87Register input_reg = ToX87Register(instr->value()); 4024 X87Register input = ToX87Register(instr->value());
4025 X87Register output_reg = ToX87Register(instr->result()); 4025 X87Register result_reg = ToX87Register(instr->result());
4026 DCHECK(output_reg.is(input_reg)); 4026 Register temp_result = ToRegister(instr->temp1());
4027 USE(output_reg); 4027 Register temp = ToRegister(instr->temp2());
4028 X87Fxch(input_reg); 4028 Label slow, done, smi, finish;
4029 __ fsqrt(); 4029 DCHECK(result_reg.is(input));
4030
4031 // Store input into Heap number and call runtime function kMathExpRT.
4032 if (FLAG_inline_new) {
4033 __ AllocateHeapNumber(temp_result, temp, no_reg, &slow);
4034 __ jmp(&done, Label::kNear);
4035 }
4036
4037 // Slow case: Call the runtime system to do the number allocation.
4038 __ bind(&slow);
4039 {
4040 // TODO(3095996): Put a valid pointer value in the stack slot where the
4041 // result register is stored, as this register is in the pointer map, but
4042 // contains an integer value.
4043 __ Move(temp_result, Immediate(0));
4044
4045 // Preserve the value of all registers.
4046 PushSafepointRegistersScope scope(this);
4047
4048 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4049 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
4050 RecordSafepointWithRegisters(
4051 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
4052 __ StoreToSafepointRegisterSlot(temp_result, eax);
4053 }
4054 __ bind(&done);
4055 X87LoadForUsage(input);
4056 __ fstp_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
4057
4058 {
4059 // Preserve the value of all registers.
4060 PushSafepointRegistersScope scope(this);
4061
4062 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4063 __ push(temp_result);
4064 __ CallRuntimeSaveDoubles(Runtime::kMathSqrtRT);
4065 RecordSafepointWithRegisters(
4066 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
4067 __ StoreToSafepointRegisterSlot(temp_result, eax);
4068 }
4069 X87PrepareToWrite(result_reg);
4070 // return value of MathSqrtRT is Smi or Heap Number.
4071 __ JumpIfSmi(temp_result, &smi);
4072 // Heap number(double)
4073 __ fld_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
4074 __ jmp(&finish);
4075 // SMI
4076 __ bind(&smi);
4077 __ SmiUntag(temp_result);
4078 __ push(temp_result);
4079 __ fild_s(MemOperand(esp, 0));
4080 __ pop(temp_result);
4081 __ bind(&finish);
4082 X87CommitWrite(result_reg);
4030 } 4083 }
4031 4084
4032 4085
4033 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) { 4086 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
4034 X87Register input_reg = ToX87Register(instr->value()); 4087 X87Register input_reg = ToX87Register(instr->value());
4035 DCHECK(ToX87Register(instr->result()).is(input_reg)); 4088 DCHECK(ToX87Register(instr->result()).is(input_reg));
4036 X87Fxch(input_reg); 4089 X87Fxch(input_reg);
4037 // Note that according to ECMA-262 15.8.2.13: 4090 // Note that according to ECMA-262 15.8.2.13:
4038 // Math.pow(-Infinity, 0.5) == Infinity 4091 // Math.pow(-Infinity, 0.5) == Infinity
4039 // Math.sqrt(-Infinity) == NaN 4092 // Math.sqrt(-Infinity) == NaN
(...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
6243 CallRuntime(Runtime::kPushBlockContext, 2, instr); 6296 CallRuntime(Runtime::kPushBlockContext, 2, instr);
6244 RecordSafepoint(Safepoint::kNoLazyDeopt); 6297 RecordSafepoint(Safepoint::kNoLazyDeopt);
6245 } 6298 }
6246 6299
6247 6300
6248 #undef __ 6301 #undef __
6249 6302
6250 } } // namespace v8::internal 6303 } } // namespace v8::internal
6251 6304
6252 #endif // V8_TARGET_ARCH_X87 6305 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/lithium-x87.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698