Chromium Code Reviews| 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 3963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3974 break; | 3974 break; |
| 3975 default: UNREACHABLE(); | 3975 default: UNREACHABLE(); |
| 3976 } | 3976 } |
| 3977 } | 3977 } |
| 3978 | 3978 |
| 3979 | 3979 |
| 3980 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { | 3980 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { |
| 3981 if ((kind() == MethodRecognizer::kMathSin) || | 3981 if ((kind() == MethodRecognizer::kMathSin) || |
| 3982 (kind() == MethodRecognizer::kMathCos)) { | 3982 (kind() == MethodRecognizer::kMathCos)) { |
| 3983 const intptr_t kNumInputs = 1; | 3983 const intptr_t kNumInputs = 1; |
| 3984 const intptr_t kNumTemps = 0; | 3984 const intptr_t kNumTemps = 1; |
| 3985 LocationSummary* summary = | 3985 LocationSummary* summary = |
| 3986 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 3986 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 3987 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); | 3987 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 3988 summary->set_temp(0, Location::RegisterLocation(CALLEE_SAVED)); | |
|
regis
2014/02/26 23:53:12
CALLEE_SAVED -> EDI)); // Callee saved.
Cutch
2014/02/27 15:52:37
Done.
| |
| 3988 summary->set_out(Location::FpuRegisterLocation(XMM1)); | 3989 summary->set_out(Location::FpuRegisterLocation(XMM1)); |
| 3989 return summary; | 3990 return summary; |
| 3990 } | 3991 } |
| 3992 ASSERT(kind() == MethodRecognizer::kMathSqrt); | |
| 3991 const intptr_t kNumInputs = 1; | 3993 const intptr_t kNumInputs = 1; |
| 3992 const intptr_t kNumTemps = 0; | 3994 const intptr_t kNumTemps = 0; |
| 3993 LocationSummary* summary = | 3995 LocationSummary* summary = |
| 3994 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3996 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 3995 summary->set_in(0, Location::RequiresFpuRegister()); | 3997 summary->set_in(0, Location::RequiresFpuRegister()); |
| 3996 summary->set_out(Location::RequiresFpuRegister()); | 3998 summary->set_out(Location::RequiresFpuRegister()); |
| 3997 return summary; | 3999 return summary; |
| 3998 } | 4000 } |
| 3999 | 4001 |
| 4000 | 4002 |
| 4001 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4003 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4002 if (kind() == MethodRecognizer::kMathSqrt) { | 4004 if (kind() == MethodRecognizer::kMathSqrt) { |
| 4003 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); | 4005 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); |
| 4004 } else { | 4006 } else { |
| 4005 __ EnterFrame(0); | 4007 ASSERT((kind() == MethodRecognizer::kMathSin) || |
| 4008 (kind() == MethodRecognizer::kMathCos)); | |
| 4009 // Save ESP. | |
| 4010 __ movl(locs()->temp(0).reg(), ESP); | |
| 4006 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); | 4011 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); |
| 4007 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); | 4012 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
| 4008 __ CallRuntime(TargetFunction(), InputCount()); | 4013 __ CallRuntime(TargetFunction(), InputCount()); |
| 4009 __ fstpl(Address(ESP, 0)); | 4014 __ fstpl(Address(ESP, 0)); |
| 4010 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); | 4015 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); |
| 4011 __ leave(); | 4016 // Restore ESP. |
| 4017 __ movl(ESP, locs()->temp(0).reg()); | |
| 4012 } | 4018 } |
| 4013 } | 4019 } |
| 4014 | 4020 |
| 4015 | 4021 |
| 4016 LocationSummary* MathMinMaxInstr::MakeLocationSummary(bool opt) const { | 4022 LocationSummary* MathMinMaxInstr::MakeLocationSummary(bool opt) const { |
| 4017 if (result_cid() == kDoubleCid) { | 4023 if (result_cid() == kDoubleCid) { |
| 4018 const intptr_t kNumInputs = 2; | 4024 const intptr_t kNumInputs = 2; |
| 4019 const intptr_t kNumTemps = 1; | 4025 const intptr_t kNumTemps = 1; |
| 4020 LocationSummary* summary = | 4026 LocationSummary* summary = |
| 4021 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4027 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4291 } | 4297 } |
| 4292 | 4298 |
| 4293 | 4299 |
| 4294 void FloatToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4300 void FloatToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4295 __ cvtss2sd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); | 4301 __ cvtss2sd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); |
| 4296 } | 4302 } |
| 4297 | 4303 |
| 4298 | 4304 |
| 4299 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const { | 4305 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const { |
| 4300 ASSERT((InputCount() == 1) || (InputCount() == 2)); | 4306 ASSERT((InputCount() == 1) || (InputCount() == 2)); |
| 4301 const intptr_t kNumTemps = 0; | 4307 const intptr_t kNumTemps = 1; |
| 4302 LocationSummary* result = | 4308 LocationSummary* result = |
| 4303 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); | 4309 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); |
| 4310 result->set_temp(0, Location::RegisterLocation(CALLEE_SAVED)); | |
| 4304 result->set_in(0, Location::FpuRegisterLocation(XMM1)); | 4311 result->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 4305 if (InputCount() == 2) { | 4312 if (InputCount() == 2) { |
| 4306 result->set_in(1, Location::FpuRegisterLocation(XMM2)); | 4313 result->set_in(1, Location::FpuRegisterLocation(XMM2)); |
| 4307 } | 4314 } |
| 4308 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { | 4315 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4309 result->AddTemp(Location::RegisterLocation(EAX)); | 4316 result->AddTemp(Location::RegisterLocation(EAX)); |
| 4310 result->AddTemp(Location::FpuRegisterLocation(XMM4)); | 4317 result->AddTemp(Location::FpuRegisterLocation(XMM4)); |
| 4311 } | 4318 } |
| 4312 result->set_out(Location::FpuRegisterLocation(XMM3)); | 4319 result->set_out(Location::FpuRegisterLocation(XMM3)); |
| 4313 return result; | 4320 return result; |
| 4314 } | 4321 } |
| 4315 | 4322 |
| 4316 | 4323 |
| 4317 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4324 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4318 __ EnterFrame(0); | 4325 // Save ESP. |
| 4326 __ movl(locs()->temp(0).reg(), ESP); | |
| 4319 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); | 4327 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); |
| 4320 for (intptr_t i = 0; i < InputCount(); i++) { | 4328 for (intptr_t i = 0; i < InputCount(); i++) { |
| 4321 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); | 4329 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); |
| 4322 } | 4330 } |
| 4323 Label do_call, skip_call; | 4331 Label do_call, skip_call; |
| 4324 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { | 4332 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { |
| 4325 // Pseudo code: | 4333 // Pseudo code: |
| 4326 // if (exponent == 0.0) return 1.0; | 4334 // if (exponent == 0.0) return 1.0; |
| 4327 // if (base == 1.0) return 1.0; | 4335 // if (base == 1.0) return 1.0; |
| 4328 // if (base.isNaN || exponent.isNaN) { | 4336 // if (base.isNaN || exponent.isNaN) { |
| 4329 // return double.NAN; | 4337 // return double.NAN; |
| 4330 // } | 4338 // } |
| 4331 XmmRegister base = locs()->in(0).fpu_reg(); | 4339 XmmRegister base = locs()->in(0).fpu_reg(); |
| 4332 XmmRegister exp = locs()->in(1).fpu_reg(); | 4340 XmmRegister exp = locs()->in(1).fpu_reg(); |
| 4333 XmmRegister result = locs()->out().fpu_reg(); | 4341 XmmRegister result = locs()->out().fpu_reg(); |
| 4334 Register temp = locs()->temp(0).reg(); | 4342 Register temp = locs()->temp(0).reg(); |
|
siva
2014/02/27 00:00:26
The index here is wrong, we are essentially using
Cutch
2014/02/27 15:52:37
Done.
| |
| 4335 XmmRegister zero_temp = locs()->temp(1).fpu_reg(); | 4343 XmmRegister zero_temp = locs()->temp(1).fpu_reg(); |
| 4336 | 4344 |
| 4337 Label check_base_is_one; | 4345 Label check_base_is_one; |
| 4338 // Check if exponent is 0.0 -> return 1.0; | 4346 // Check if exponent is 0.0 -> return 1.0; |
| 4339 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0))); | 4347 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0))); |
| 4340 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset())); | 4348 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset())); |
| 4341 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1))); | 4349 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1))); |
| 4342 __ movsd(result, FieldAddress(temp, Double::value_offset())); | 4350 __ movsd(result, FieldAddress(temp, Double::value_offset())); |
| 4343 // 'result' contains 1.0. | 4351 // 'result' contains 1.0. |
| 4344 __ comisd(exp, zero_temp); | 4352 __ comisd(exp, zero_temp); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 4356 // Returns NaN. | 4364 // Returns NaN. |
| 4357 __ movsd(result, base); | 4365 __ movsd(result, base); |
| 4358 __ jmp(&skip_call, Assembler::kNearJump); | 4366 __ jmp(&skip_call, Assembler::kNearJump); |
| 4359 // exp is Nan case is handled correctly in the C-library. | 4367 // exp is Nan case is handled correctly in the C-library. |
| 4360 } | 4368 } |
| 4361 __ Bind(&do_call); | 4369 __ Bind(&do_call); |
| 4362 __ CallRuntime(TargetFunction(), InputCount()); | 4370 __ CallRuntime(TargetFunction(), InputCount()); |
| 4363 __ fstpl(Address(ESP, 0)); | 4371 __ fstpl(Address(ESP, 0)); |
| 4364 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); | 4372 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); |
| 4365 __ Bind(&skip_call); | 4373 __ Bind(&skip_call); |
| 4366 __ leave(); | 4374 // Restore ESP. |
| 4375 __ movl(ESP, locs()->temp(0).reg()); | |
| 4367 } | 4376 } |
| 4368 | 4377 |
| 4369 | 4378 |
| 4370 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { | 4379 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { |
| 4371 if (kind() == MergedMathInstr::kTruncDivMod) { | 4380 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 4372 const intptr_t kNumInputs = 2; | 4381 const intptr_t kNumInputs = 2; |
| 4373 const intptr_t kNumTemps = 1; | 4382 const intptr_t kNumTemps = 1; |
| 4374 LocationSummary* summary = | 4383 LocationSummary* summary = |
| 4375 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4384 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 4376 // Both inputs must be writable because they will be untagged. | 4385 // Both inputs must be writable because they will be untagged. |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5379 PcDescriptors::kOther, | 5388 PcDescriptors::kOther, |
| 5380 locs()); | 5389 locs()); |
| 5381 __ Drop(2); // Discard type arguments and receiver. | 5390 __ Drop(2); // Discard type arguments and receiver. |
| 5382 } | 5391 } |
| 5383 | 5392 |
| 5384 } // namespace dart | 5393 } // namespace dart |
| 5385 | 5394 |
| 5386 #undef __ | 5395 #undef __ |
| 5387 | 5396 |
| 5388 #endif // defined TARGET_ARCH_IA32 | 5397 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |