| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 4170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4181 | 4181 |
| 4182 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary() const { | 4182 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary() const { |
| 4183 ASSERT((InputCount() == 1) || (InputCount() == 2)); | 4183 ASSERT((InputCount() == 1) || (InputCount() == 2)); |
| 4184 const intptr_t kNumTemps = 0; | 4184 const intptr_t kNumTemps = 0; |
| 4185 LocationSummary* result = | 4185 LocationSummary* result = |
| 4186 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); | 4186 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); |
| 4187 result->set_in(0, Location::FpuRegisterLocation(XMM1)); | 4187 result->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 4188 if (InputCount() == 2) { | 4188 if (InputCount() == 2) { |
| 4189 result->set_in(1, Location::FpuRegisterLocation(XMM2)); | 4189 result->set_in(1, Location::FpuRegisterLocation(XMM2)); |
| 4190 } | 4190 } |
| 4191 result->set_out(Location::FpuRegisterLocation(XMM1)); | 4191 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4192 result->AddTemp(Location::RegisterLocation(EAX)); |
| 4193 result->AddTemp(Location::FpuRegisterLocation(XMM4)); |
| 4194 } |
| 4195 result->set_out(Location::FpuRegisterLocation(XMM3)); |
| 4192 return result; | 4196 return result; |
| 4193 } | 4197 } |
| 4194 | 4198 |
| 4195 | 4199 |
| 4196 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4200 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4197 __ EnterFrame(0); | 4201 __ EnterFrame(0); |
| 4198 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); | 4202 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); |
| 4199 for (intptr_t i = 0; i < InputCount(); i++) { | 4203 for (intptr_t i = 0; i < InputCount(); i++) { |
| 4200 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); | 4204 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); |
| 4201 } | 4205 } |
| 4202 // For pow-function return NaN if exponent is NaN. | |
| 4203 Label do_call, skip_call; | 4206 Label do_call, skip_call; |
| 4204 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { | 4207 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4208 // if (exponent == 0.0) return 1.0; |
| 4209 // if (base == 1.0) return 1.0; |
| 4210 // if (base.isNaN || exponent.isNaN) { |
| 4211 // return double.NAN; |
| 4212 // } |
| 4213 XmmRegister base = locs()->in(0).fpu_reg(); |
| 4205 XmmRegister exp = locs()->in(1).fpu_reg(); | 4214 XmmRegister exp = locs()->in(1).fpu_reg(); |
| 4206 __ comisd(exp, exp); | 4215 XmmRegister result = locs()->out().fpu_reg(); |
| 4207 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false; | 4216 Register temp = locs()->temp(0).reg(); |
| 4208 // Exponent is NaN, return NaN. | 4217 XmmRegister zero_temp = locs()->temp(1).fpu_reg(); |
| 4209 __ movsd(locs()->out().fpu_reg(), exp); | 4218 |
| 4219 Label check_base_is_one; |
| 4220 // Check if exponent is 0.0 -> return 1.0; |
| 4221 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0))); |
| 4222 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset())); |
| 4223 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1))); |
| 4224 __ movsd(result, FieldAddress(temp, Double::value_offset())); |
| 4225 // 'result' contains 1.0. |
| 4226 __ comisd(exp, zero_temp); |
| 4227 __ j(PARITY_EVEN, &check_base_is_one, Assembler::kNearJump); // NaN. |
| 4228 __ j(EQUAL, &skip_call, Assembler::kNearJump); // exp is 0, result is 1.0. |
| 4229 |
| 4230 Label base_is_nan; |
| 4231 __ Bind(&check_base_is_one); |
| 4232 __ comisd(base, result); |
| 4233 __ j(PARITY_EVEN, &base_is_nan, Assembler::kNearJump); |
| 4234 __ j(EQUAL, &skip_call, Assembler::kNearJump); // base and result are 1.0 |
| 4235 __ jmp(&do_call, Assembler::kNearJump); |
| 4236 |
| 4237 __ Bind(&base_is_nan); |
| 4238 // Returns NaN. |
| 4239 __ movsd(result, base); |
| 4210 __ jmp(&skip_call, Assembler::kNearJump); | 4240 __ jmp(&skip_call, Assembler::kNearJump); |
| 4241 // exp is Nan case is handled correctly in the C-library. |
| 4211 } | 4242 } |
| 4212 __ Bind(&do_call); | 4243 __ Bind(&do_call); |
| 4213 __ CallRuntime(TargetFunction()); | 4244 __ CallRuntime(TargetFunction()); |
| 4214 __ fstpl(Address(ESP, 0)); | 4245 __ fstpl(Address(ESP, 0)); |
| 4215 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); | 4246 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); |
| 4216 __ Bind(&skip_call); | 4247 __ Bind(&skip_call); |
| 4217 __ leave(); | 4248 __ leave(); |
| 4218 } | 4249 } |
| 4219 | 4250 |
| 4220 | 4251 |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5179 PcDescriptors::kOther, | 5210 PcDescriptors::kOther, |
| 5180 locs()); | 5211 locs()); |
| 5181 __ Drop(2); // Discard type arguments and receiver. | 5212 __ Drop(2); // Discard type arguments and receiver. |
| 5182 } | 5213 } |
| 5183 | 5214 |
| 5184 } // namespace dart | 5215 } // namespace dart |
| 5185 | 5216 |
| 5186 #undef __ | 5217 #undef __ |
| 5187 | 5218 |
| 5188 #endif // defined TARGET_ARCH_IA32 | 5219 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |