| 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 3994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 LocationSummary* summary = | 4005 LocationSummary* summary = |
| 4006 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4006 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 4007 // Both inputs must be writable because they will be untagged. | 4007 // Both inputs must be writable because they will be untagged. |
| 4008 summary->set_in(0, Location::RegisterLocation(EAX)); | 4008 summary->set_in(0, Location::RegisterLocation(EAX)); |
| 4009 summary->set_in(1, Location::WritableRegister()); | 4009 summary->set_in(1, Location::WritableRegister()); |
| 4010 summary->set_out(Location::RequiresRegister()); | 4010 summary->set_out(Location::RequiresRegister()); |
| 4011 // Will be used for sign extension and division. | 4011 // Will be used for sign extension and division. |
| 4012 summary->set_temp(0, Location::RegisterLocation(EDX)); | 4012 summary->set_temp(0, Location::RegisterLocation(EDX)); |
| 4013 return summary; | 4013 return summary; |
| 4014 } | 4014 } |
| 4015 if (kind() == MergedMathInstr::kSinCos) { |
| 4016 const intptr_t kNumInputs = 1; |
| 4017 const intptr_t kNumTemps = 0; |
| 4018 LocationSummary* summary = |
| 4019 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 4020 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 4021 summary->set_out(Location::RegisterLocation(EAX)); |
| 4022 return summary; |
| 4023 } |
| 4015 UNIMPLEMENTED(); | 4024 UNIMPLEMENTED(); |
| 4016 return NULL; | 4025 return NULL; |
| 4017 } | 4026 } |
| 4018 | 4027 |
| 4019 | 4028 |
| 4029 typedef void (*SinCosCFunction) (double x, double* res_sin, double* res_cos); |
| 4030 |
| 4031 extern const RuntimeEntry kSinCosRuntimeEntry( |
| 4032 "libc_sincos", reinterpret_cast<RuntimeFunction>( |
| 4033 static_cast<SinCosCFunction>(&SinCos)), 1, true, true); |
| 4034 |
| 4035 |
| 4020 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4036 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4021 Label* deopt = NULL; | 4037 Label* deopt = NULL; |
| 4022 if (CanDeoptimize()) { | 4038 if (CanDeoptimize()) { |
| 4023 deopt = compiler->AddDeoptStub(deopt_id(), kDeoptBinarySmiOp); | 4039 deopt = compiler->AddDeoptStub(deopt_id(), kDeoptBinarySmiOp); |
| 4024 } | 4040 } |
| 4025 | 4041 |
| 4026 if (kind() == MergedMathInstr::kTruncDivMod) { | 4042 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 4027 Register left = locs()->in(0).reg(); | 4043 Register left = locs()->in(0).reg(); |
| 4028 Register right = locs()->in(1).reg(); | 4044 Register right = locs()->in(1).reg(); |
| 4029 Register result = locs()->out().reg(); | 4045 Register result = locs()->out().reg(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4074 __ addl(EDX, right); | 4090 __ addl(EDX, right); |
| 4075 } else { | 4091 } else { |
| 4076 // Right is negative. | 4092 // Right is negative. |
| 4077 __ subl(EDX, right); | 4093 __ subl(EDX, right); |
| 4078 } | 4094 } |
| 4079 __ Bind(&done); | 4095 __ Bind(&done); |
| 4080 | 4096 |
| 4081 __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld))); | 4097 __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld))); |
| 4082 const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(kArrayCid); | 4098 const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(kArrayCid); |
| 4083 Address trunc_div_address( | 4099 Address trunc_div_address( |
| 4084 FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid, | 4100 FlowGraphCompiler::ElementAddressForIntIndex( |
| 4085 index_scale, | 4101 kArrayCid, index_scale, result, |
| 4086 result, | 4102 MergedMathInstr::ResultIndexOf(Token::kTRUNCDIV))); |
| 4087 0)); | |
| 4088 Address mod_address( | 4103 Address mod_address( |
| 4089 FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid, | 4104 FlowGraphCompiler::ElementAddressForIntIndex( |
| 4090 index_scale, | 4105 kArrayCid, index_scale, result, |
| 4091 result, | 4106 MergedMathInstr::ResultIndexOf(Token::kMOD))); |
| 4092 1)); | |
| 4093 __ SmiTag(EAX); | 4107 __ SmiTag(EAX); |
| 4094 __ SmiTag(EDX); | 4108 __ SmiTag(EDX); |
| 4095 __ StoreIntoObjectNoBarrier(result, trunc_div_address, EAX); | 4109 __ StoreIntoObjectNoBarrier(result, trunc_div_address, EAX); |
| 4096 __ StoreIntoObjectNoBarrier(result, mod_address, EDX); | 4110 __ StoreIntoObjectNoBarrier(result, mod_address, EDX); |
| 4097 return; | 4111 return; |
| 4098 } | 4112 } |
| 4099 | 4113 |
| 4114 if (kind() == MergedMathInstr::kSinCos) { |
| 4115 // Do x87 sincos, since the ia32 compilers may not fuse sin/cos into |
| 4116 // sincos. |
| 4117 __ pushl(EAX); |
| 4118 __ pushl(EAX); |
| 4119 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); |
| 4120 __ fldl(Address(ESP, 0)); |
| 4121 __ fsincos(); |
| 4122 __ fstpl(Address(ESP, 0)); |
| 4123 __ movsd(XMM1, Address(ESP, 0)); |
| 4124 __ fstpl(Address(ESP, 0)); |
| 4125 __ movsd(XMM0, Address(ESP, 0)); |
| 4126 __ addl(ESP, Immediate(2 * kWordSize)); |
| 4127 |
| 4128 Register result = locs()->out().reg(); |
| 4129 const TypedData& res_array = TypedData::ZoneHandle( |
| 4130 TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld)); |
| 4131 __ LoadObject(result, res_array); |
| 4132 const intptr_t index_scale = |
| 4133 FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid); |
| 4134 Address sin_address( |
| 4135 FlowGraphCompiler::ElementAddressForIntIndex( |
| 4136 kTypedDataFloat64ArrayCid, index_scale, result, |
| 4137 MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathSin))); |
| 4138 Address cos_address( |
| 4139 FlowGraphCompiler::ElementAddressForIntIndex( |
| 4140 kTypedDataFloat64ArrayCid, index_scale, result, |
| 4141 MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathCos))); |
| 4142 __ movsd(sin_address, XMM0); |
| 4143 __ movsd(cos_address, XMM1); |
| 4144 return; |
| 4145 } |
| 4146 |
| 4100 UNIMPLEMENTED(); | 4147 UNIMPLEMENTED(); |
| 4101 } | 4148 } |
| 4102 | 4149 |
| 4103 | 4150 |
| 4104 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { | 4151 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { |
| 4105 return MakeCallSummary(); | 4152 return MakeCallSummary(); |
| 4106 } | 4153 } |
| 4107 | 4154 |
| 4108 | 4155 |
| 4109 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4156 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4968 PcDescriptors::kOther, | 5015 PcDescriptors::kOther, |
| 4969 locs()); | 5016 locs()); |
| 4970 __ Drop(2); // Discard type arguments and receiver. | 5017 __ Drop(2); // Discard type arguments and receiver. |
| 4971 } | 5018 } |
| 4972 | 5019 |
| 4973 } // namespace dart | 5020 } // namespace dart |
| 4974 | 5021 |
| 4975 #undef __ | 5022 #undef __ |
| 4976 | 5023 |
| 4977 #endif // defined TARGET_ARCH_IA32 | 5024 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |