| 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 4034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4045 LocationSummary* summary = | 4045 LocationSummary* summary = |
| 4046 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 4046 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 4047 // Both inputs must be writable because they will be untagged. | 4047 // Both inputs must be writable because they will be untagged. |
| 4048 summary->set_in(0, Location::RegisterLocation(RAX)); | 4048 summary->set_in(0, Location::RegisterLocation(RAX)); |
| 4049 summary->set_in(1, Location::WritableRegister()); | 4049 summary->set_in(1, Location::WritableRegister()); |
| 4050 summary->set_out(Location::RequiresRegister()); | 4050 summary->set_out(Location::RequiresRegister()); |
| 4051 // Will be used for sign extension and division. | 4051 // Will be used for sign extension and division. |
| 4052 summary->set_temp(0, Location::RegisterLocation(RDX)); | 4052 summary->set_temp(0, Location::RegisterLocation(RDX)); |
| 4053 return summary; | 4053 return summary; |
| 4054 } | 4054 } |
| 4055 if (kind() == MergedMathInstr::kSinCos) { |
| 4056 const intptr_t kNumInputs = 1; |
| 4057 const intptr_t kNumTemps = 0; |
| 4058 LocationSummary* summary = |
| 4059 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
| 4060 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); |
| 4061 summary->set_out(Location::RegisterLocation(RAX)); |
| 4062 return summary; |
| 4063 } |
| 4055 UNIMPLEMENTED(); | 4064 UNIMPLEMENTED(); |
| 4056 return NULL; | 4065 return NULL; |
| 4057 } | 4066 } |
| 4058 | 4067 |
| 4059 | 4068 |
| 4069 |
| 4070 typedef void (*SinCosCFunction) (double x, double* res_sin, double* res_cos); |
| 4071 |
| 4072 extern const RuntimeEntry kSinCosRuntimeEntry( |
| 4073 "libc_sincos", reinterpret_cast<RuntimeFunction>( |
| 4074 static_cast<SinCosCFunction>(&SinCos)), 1, true, true); |
| 4075 |
| 4076 |
| 4060 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4077 void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 4061 Label* deopt = NULL; | 4078 Label* deopt = NULL; |
| 4062 if (CanDeoptimize()) { | 4079 if (CanDeoptimize()) { |
| 4063 deopt = compiler->AddDeoptStub(deopt_id(), kDeoptBinarySmiOp); | 4080 deopt = compiler->AddDeoptStub(deopt_id(), kDeoptBinarySmiOp); |
| 4064 } | 4081 } |
| 4065 if (kind() == MergedMathInstr::kTruncDivMod) { | 4082 if (kind() == MergedMathInstr::kTruncDivMod) { |
| 4066 Register left = locs()->in(0).reg(); | 4083 Register left = locs()->in(0).reg(); |
| 4067 Register right = locs()->in(1).reg(); | 4084 Register right = locs()->in(1).reg(); |
| 4068 Register result = locs()->out().reg(); | 4085 Register result = locs()->out().reg(); |
| 4069 Label not_32bit, done; | 4086 Label not_32bit, done; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4157 1)); | 4174 1)); |
| 4158 __ SmiTag(RAX); | 4175 __ SmiTag(RAX); |
| 4159 __ SmiTag(RDX); | 4176 __ SmiTag(RDX); |
| 4160 __ StoreIntoObjectNoBarrier(result, trunc_div_address, RAX); | 4177 __ StoreIntoObjectNoBarrier(result, trunc_div_address, RAX); |
| 4161 __ StoreIntoObjectNoBarrier(result, mod_address, RDX); | 4178 __ StoreIntoObjectNoBarrier(result, mod_address, RDX); |
| 4162 // FLAG_throw_on_javascript_int_overflow: not needed. | 4179 // FLAG_throw_on_javascript_int_overflow: not needed. |
| 4163 // Note that the result of an integer division/modulo of two | 4180 // Note that the result of an integer division/modulo of two |
| 4164 // in-range arguments, cannot create out-of-range result. | 4181 // in-range arguments, cannot create out-of-range result. |
| 4165 return; | 4182 return; |
| 4166 } | 4183 } |
| 4184 if (kind() == MergedMathInstr::kSinCos) { |
| 4185 __ EnterFrame(0); |
| 4186 // +-------------------------------+ |
| 4187 // | double-argument | <- TOS |
| 4188 // +-------------------------------+ |
| 4189 // | address-cos-result | +8 |
| 4190 // +-------------------------------+ |
| 4191 // | address-sin-result | +16 |
| 4192 // +-------------------------------+ |
| 4193 // | double-storage-for-cos-result | +24 |
| 4194 // +-------------------------------+ |
| 4195 // | double-storage-for-sin-result | +32 |
| 4196 // +-------------------------------+ |
| 4197 // .... |
| 4198 __ ReserveAlignedFrameSpace(kDoubleSize * 3 + kWordSize * 2); |
| 4199 __ movsd(Address(RSP, 0), locs()->in(0).fpu_reg()); |
| 4200 |
| 4201 __ leaq(RDI, Address(RSP, 2 * kWordSize + kDoubleSize)); |
| 4202 __ leaq(RSI, Address(RSP, 2 * kWordSize + 2 * kDoubleSize)); |
| 4203 __ movaps(XMM0, locs()->in(0).fpu_reg()); |
| 4204 |
| 4205 __ CallRuntime(kSinCosRuntimeEntry, InputCount()); |
| 4206 __ movsd(XMM0, Address(RSP, 2 * kWordSize + kDoubleSize * 2)); // sin. |
| 4207 __ movsd(XMM1, Address(RSP, 2 * kWordSize + kDoubleSize)); // cos. |
| 4208 __ leave(); |
| 4209 |
| 4210 Register result = locs()->out().reg(); |
| 4211 const TypedData& res_array = TypedData::ZoneHandle( |
| 4212 TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld)); |
| 4213 __ LoadObject(result, res_array, PP); |
| 4214 const intptr_t index_scale = |
| 4215 FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid); |
| 4216 Address sin_address( |
| 4217 FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid, |
| 4218 index_scale, |
| 4219 result, |
| 4220 0)); |
| 4221 Address cos_address( |
| 4222 FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid, |
| 4223 index_scale, |
| 4224 result, |
| 4225 1)); |
| 4226 __ movsd(sin_address, XMM0); |
| 4227 __ movsd(cos_address, XMM1); |
| 4228 return; |
| 4229 } |
| 4167 UNIMPLEMENTED(); | 4230 UNIMPLEMENTED(); |
| 4168 } | 4231 } |
| 4169 | 4232 |
| 4170 | 4233 |
| 4171 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { | 4234 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { |
| 4172 return MakeCallSummary(); | 4235 return MakeCallSummary(); |
| 4173 } | 4236 } |
| 4174 | 4237 |
| 4175 | 4238 |
| 4176 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 4239 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4693 PcDescriptors::kOther, | 4756 PcDescriptors::kOther, |
| 4694 locs()); | 4757 locs()); |
| 4695 __ Drop(2); // Discard type arguments and receiver. | 4758 __ Drop(2); // Discard type arguments and receiver. |
| 4696 } | 4759 } |
| 4697 | 4760 |
| 4698 } // namespace dart | 4761 } // namespace dart |
| 4699 | 4762 |
| 4700 #undef __ | 4763 #undef __ |
| 4701 | 4764 |
| 4702 #endif // defined TARGET_ARCH_X64 | 4765 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |