Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 92433002: Merge sin(a), cos(a) into one instruction. TODO: Implement for ARM and MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/arithmetic_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4139 } else { 4156 } else {
4140 // Right is negative. 4157 // Right is negative.
4141 __ subq(RDX, right); 4158 __ subq(RDX, right);
4142 } 4159 }
4143 __ Bind(&all_done); 4160 __ Bind(&all_done);
4144 __ SmiTag(result); 4161 __ SmiTag(result);
4145 4162
4146 __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld)), PP); 4163 __ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld)), PP);
4147 const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(kArrayCid); 4164 const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(kArrayCid);
4148 Address trunc_div_address( 4165 Address trunc_div_address(
4149 FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid, 4166 FlowGraphCompiler::ElementAddressForIntIndex(
4150 index_scale, 4167 kArrayCid, index_scale, result,
4151 result, 4168 MergedMathInstr::ResultIndexOf(Token::kTRUNCDIV)));
4152 0));
4153 Address mod_address( 4169 Address mod_address(
4154 FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid, 4170 FlowGraphCompiler::ElementAddressForIntIndex(
4155 index_scale, 4171 kArrayCid, index_scale, result,
4156 result, 4172 MergedMathInstr::ResultIndexOf(Token::kMOD)));
4157 1));
4158 __ SmiTag(RAX); 4173 __ SmiTag(RAX);
4159 __ SmiTag(RDX); 4174 __ SmiTag(RDX);
4160 __ StoreIntoObjectNoBarrier(result, trunc_div_address, RAX); 4175 __ StoreIntoObjectNoBarrier(result, trunc_div_address, RAX);
4161 __ StoreIntoObjectNoBarrier(result, mod_address, RDX); 4176 __ StoreIntoObjectNoBarrier(result, mod_address, RDX);
4162 // FLAG_throw_on_javascript_int_overflow: not needed. 4177 // FLAG_throw_on_javascript_int_overflow: not needed.
4163 // Note that the result of an integer division/modulo of two 4178 // Note that the result of an integer division/modulo of two
4164 // in-range arguments, cannot create out-of-range result. 4179 // in-range arguments, cannot create out-of-range result.
4165 return; 4180 return;
4166 } 4181 }
4182 if (kind() == MergedMathInstr::kSinCos) {
4183 __ EnterFrame(0);
4184 // +-------------------------------+
4185 // | double-argument | <- TOS
4186 // +-------------------------------+
4187 // | address-cos-result | +8
4188 // +-------------------------------+
4189 // | address-sin-result | +16
4190 // +-------------------------------+
4191 // | double-storage-for-cos-result | +24
4192 // +-------------------------------+
4193 // | double-storage-for-sin-result | +32
4194 // +-------------------------------+
4195 // ....
4196 __ ReserveAlignedFrameSpace(kDoubleSize * 3 + kWordSize * 2);
4197 __ movsd(Address(RSP, 0), locs()->in(0).fpu_reg());
4198
4199 __ leaq(RDI, Address(RSP, 2 * kWordSize + kDoubleSize));
4200 __ leaq(RSI, Address(RSP, 2 * kWordSize + 2 * kDoubleSize));
4201 __ movaps(XMM0, locs()->in(0).fpu_reg());
4202
4203 __ CallRuntime(kSinCosRuntimeEntry, InputCount());
4204 __ movsd(XMM0, Address(RSP, 2 * kWordSize + kDoubleSize * 2)); // sin.
4205 __ movsd(XMM1, Address(RSP, 2 * kWordSize + kDoubleSize)); // cos.
4206 __ leave();
4207
4208 Register result = locs()->out().reg();
4209 const TypedData& res_array = TypedData::ZoneHandle(
4210 TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld));
4211 __ LoadObject(result, res_array, PP);
4212 const intptr_t index_scale =
4213 FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid);
4214 Address sin_address(
4215 FlowGraphCompiler::ElementAddressForIntIndex(
4216 kTypedDataFloat64ArrayCid, index_scale, result,
4217 MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathSin)));
4218 Address cos_address(
4219 FlowGraphCompiler::ElementAddressForIntIndex(
4220 kTypedDataFloat64ArrayCid, index_scale, result,
4221 MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathCos)));
4222 __ movsd(sin_address, XMM0);
4223 __ movsd(cos_address, XMM1);
4224 return;
4225 }
4167 UNIMPLEMENTED(); 4226 UNIMPLEMENTED();
4168 } 4227 }
4169 4228
4170 4229
4171 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { 4230 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const {
4172 return MakeCallSummary(); 4231 return MakeCallSummary();
4173 } 4232 }
4174 4233
4175 4234
4176 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4235 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
4693 PcDescriptors::kOther, 4752 PcDescriptors::kOther,
4694 locs()); 4753 locs());
4695 __ Drop(2); // Discard type arguments and receiver. 4754 __ Drop(2); // Discard type arguments and receiver.
4696 } 4755 }
4697 4756
4698 } // namespace dart 4757 } // namespace dart
4699 4758
4700 #undef __ 4759 #undef __
4701 4760
4702 #endif // defined TARGET_ARCH_X64 4761 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | tests/language/arithmetic_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698