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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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
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_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
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 index_scale, 4106 index_scale,
4091 result, 4107 result,
4092 1)); 4108 1));
4093 __ SmiTag(EAX); 4109 __ SmiTag(EAX);
4094 __ SmiTag(EDX); 4110 __ SmiTag(EDX);
4095 __ StoreIntoObjectNoBarrier(result, trunc_div_address, EAX); 4111 __ StoreIntoObjectNoBarrier(result, trunc_div_address, EAX);
4096 __ StoreIntoObjectNoBarrier(result, mod_address, EDX); 4112 __ StoreIntoObjectNoBarrier(result, mod_address, EDX);
4097 return; 4113 return;
4098 } 4114 }
4099 4115
4116 if (kind() == MergedMathInstr::kSinCos) {
4117 // Do x87 sincos, since the ia32 compilers may not fuse sin/cos into
4118 // sincos.
4119 __ pushl(EAX);
4120 __ pushl(EAX);
4121 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg());
4122 __ fldl(Address(ESP, 0));
4123 __ fsincos();
4124 __ fstpl(Address(ESP, 0));
4125 __ movsd(XMM1, Address(ESP, 0));
4126 __ fstpl(Address(ESP, 0));
4127 __ movsd(XMM0, Address(ESP, 0));
4128 __ addl(ESP, Immediate(2 * kWordSize));
4129
4130 Register result = locs()->out().reg();
4131 const TypedData& res_array = TypedData::ZoneHandle(
4132 TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld));
4133 __ LoadObject(result, res_array);
4134 const intptr_t index_scale =
4135 FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid);
4136 Address sin_address(
4137 FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid,
4138 index_scale,
4139 result,
4140 0));
4141 Address cos_address(
4142 FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid,
4143 index_scale,
4144 result,
4145 1));
4146 __ movsd(sin_address, XMM0);
4147 __ movsd(cos_address, XMM1);
4148 return;
4149 }
4150
4100 UNIMPLEMENTED(); 4151 UNIMPLEMENTED();
4101 } 4152 }
4102 4153
4103 4154
4104 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { 4155 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const {
4105 return MakeCallSummary(); 4156 return MakeCallSummary();
4106 } 4157 }
4107 4158
4108 4159
4109 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4160 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
4968 PcDescriptors::kOther, 5019 PcDescriptors::kOther,
4969 locs()); 5020 locs());
4970 __ Drop(2); // Discard type arguments and receiver. 5021 __ Drop(2); // Discard type arguments and receiver.
4971 } 5022 }
4972 5023
4973 } // namespace dart 5024 } // namespace dart
4974 5025
4975 #undef __ 5026 #undef __
4976 5027
4977 #endif // defined TARGET_ARCH_IA32 5028 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698