| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4229 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary() const { | 4229 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary() const { |
| 4230 // Calling convention on x64 uses XMM0 and XMM1 to pass the first two | 4230 // Calling convention on x64 uses XMM0 and XMM1 to pass the first two |
| 4231 // double arguments and XMM0 to return the result. Unfortunately | 4231 // double arguments and XMM0 to return the result. Unfortunately |
| 4232 // currently we can't specify these registers because ParallelMoveResolver | 4232 // currently we can't specify these registers because ParallelMoveResolver |
| 4233 // assumes that XMM0 is free at all times. | 4233 // assumes that XMM0 is free at all times. |
| 4234 // TODO(vegorov): allow XMM0 to be used. | 4234 // TODO(vegorov): allow XMM0 to be used. |
| 4235 ASSERT((InputCount() == 1) || (InputCount() == 2)); | 4235 ASSERT((InputCount() == 1) || (InputCount() == 2)); |
| 4236 const intptr_t kNumTemps = 0; | 4236 const intptr_t kNumTemps = 0; |
| 4237 LocationSummary* result = | 4237 LocationSummary* result = |
| 4238 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); | 4238 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); |
| 4239 result->set_in(0, Location::FpuRegisterLocation(XMM1)); | 4239 result->set_in(0, Location::FpuRegisterLocation(XMM2)); |
| 4240 if (InputCount() == 2) { | 4240 if (InputCount() == 2) { |
| 4241 result->set_in(1, Location::FpuRegisterLocation(XMM2)); | 4241 result->set_in(1, Location::FpuRegisterLocation(XMM1)); |
| 4242 } | 4242 } |
| 4243 result->set_out(Location::FpuRegisterLocation(XMM1)); | 4243 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4244 result->AddTemp(Location::RegisterLocation(RAX)); |
| 4245 result->AddTemp(Location::FpuRegisterLocation(XMM4)); |
| 4246 } |
| 4247 result->set_out(Location::FpuRegisterLocation(XMM3)); |
| 4244 return result; | 4248 return result; |
| 4245 } | 4249 } |
| 4246 | 4250 |
| 4247 | 4251 |
| 4248 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4252 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4249 ASSERT(locs()->in(0).fpu_reg() == XMM1); | |
| 4250 __ EnterFrame(0); | 4253 __ EnterFrame(0); |
| 4251 __ ReserveAlignedFrameSpace(0); | 4254 __ ReserveAlignedFrameSpace(0); |
| 4252 __ movaps(XMM0, locs()->in(0).fpu_reg()); | 4255 __ movaps(XMM0, locs()->in(0).fpu_reg()); |
| 4253 if (InputCount() == 2) { | 4256 if (InputCount() == 2) { |
| 4254 ASSERT(locs()->in(1).fpu_reg() == XMM2); | 4257 ASSERT(locs()->in(1).fpu_reg() == XMM1); |
| 4255 __ movaps(XMM1, locs()->in(1).fpu_reg()); | |
| 4256 } | 4258 } |
| 4257 // For pow-function return NaN if exponent is NaN. | 4259 // For pow-function return NaN if exponent is NaN. |
| 4258 Label do_call, skip_call; | 4260 Label do_call, skip_call; |
| 4259 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { | 4261 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4262 // Pseudo code: |
| 4263 // if (exponent == 0.0) return 0.0; |
| 4264 // if (base == 1.0) return 1.0; |
| 4265 // if (base.isNaN || exponent.isNaN) { |
| 4266 // return double.NAN; |
| 4267 // } |
| 4268 XmmRegister base = locs()->in(0).fpu_reg(); |
| 4260 XmmRegister exp = locs()->in(1).fpu_reg(); | 4269 XmmRegister exp = locs()->in(1).fpu_reg(); |
| 4261 __ comisd(exp, exp); | 4270 XmmRegister result = locs()->out().fpu_reg(); |
| 4262 __ j(PARITY_ODD, &do_call, Assembler::kNearJump); // NaN -> false; | 4271 Register temp = locs()->temp(0).reg(); |
| 4263 // Exponent is NaN, return NaN. | 4272 XmmRegister zero_temp = locs()->temp(1).fpu_reg(); |
| 4264 __ movaps(locs()->out().fpu_reg(), exp); | 4273 |
| 4274 Label check_base_is_one; |
| 4275 // Check if exponent is 0.0 -> return 1.0; |
| 4276 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0))); |
| 4277 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset())); |
| 4278 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1))); |
| 4279 __ movsd(result, FieldAddress(temp, Double::value_offset())); |
| 4280 // 'result' contains 1.0. |
| 4281 __ comisd(exp, zero_temp); |
| 4282 __ j(PARITY_EVEN, &check_base_is_one, Assembler::kNearJump); // NaN. |
| 4283 __ j(EQUAL, &skip_call, Assembler::kNearJump); // exp is 0, result is 1.0. |
| 4284 |
| 4285 Label base_is_nan; |
| 4286 __ Bind(&check_base_is_one); |
| 4287 // Checks if base == 1.0. |
| 4288 __ comisd(base, result); |
| 4289 __ j(PARITY_EVEN, &base_is_nan, Assembler::kNearJump); |
| 4290 __ j(EQUAL, &skip_call, Assembler::kNearJump); // base and result are 1.0 |
| 4291 __ jmp(&do_call, Assembler::kNearJump); |
| 4292 |
| 4293 __ Bind(&base_is_nan); |
| 4294 // Returns NaN. |
| 4295 __ movsd(result, base); |
| 4265 __ jmp(&skip_call, Assembler::kNearJump); | 4296 __ jmp(&skip_call, Assembler::kNearJump); |
| 4297 // exp is Nan case is handled correctly in the C-library. |
| 4266 } | 4298 } |
| 4267 __ Bind(&do_call); | 4299 __ Bind(&do_call); |
| 4268 __ CallRuntime(TargetFunction()); | 4300 __ CallRuntime(TargetFunction()); |
| 4269 __ movaps(locs()->out().fpu_reg(), XMM0); | 4301 __ movaps(locs()->out().fpu_reg(), XMM0); |
| 4270 __ Bind(&skip_call); | 4302 __ Bind(&skip_call); |
| 4271 __ leave(); | 4303 __ leave(); |
| 4272 } | 4304 } |
| 4273 | 4305 |
| 4274 | 4306 |
| 4275 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { | 4307 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4795 PcDescriptors::kOther, | 4827 PcDescriptors::kOther, |
| 4796 locs()); | 4828 locs()); |
| 4797 __ Drop(2); // Discard type arguments and receiver. | 4829 __ Drop(2); // Discard type arguments and receiver. |
| 4798 } | 4830 } |
| 4799 | 4831 |
| 4800 } // namespace dart | 4832 } // namespace dart |
| 4801 | 4833 |
| 4802 #undef __ | 4834 #undef __ |
| 4803 | 4835 |
| 4804 #endif // defined TARGET_ARCH_X64 | 4836 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |