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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_ia32.cc
===================================================================
--- runtime/vm/intermediate_language_ia32.cc (revision 30823)
+++ runtime/vm/intermediate_language_ia32.cc (working copy)
@@ -4012,11 +4012,27 @@
summary->set_temp(0, Location::RegisterLocation(EDX));
return summary;
}
+ if (kind() == MergedMathInstr::kSinCos) {
+ const intptr_t kNumInputs = 1;
+ const intptr_t kNumTemps = 0;
+ LocationSummary* summary =
+ new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
+ summary->set_in(0, Location::FpuRegisterLocation(XMM1));
+ summary->set_out(Location::RegisterLocation(EAX));
+ return summary;
+ }
UNIMPLEMENTED();
return NULL;
}
+typedef void (*SinCosCFunction) (double x, double* res_sin, double* res_cos);
+
+extern const RuntimeEntry kSinCosRuntimeEntry(
+ "libc_sincos", reinterpret_cast<RuntimeFunction>(
+ static_cast<SinCosCFunction>(&SinCos)), 1, true, true);
+
+
void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
Label* deopt = NULL;
if (CanDeoptimize()) {
@@ -4081,15 +4097,13 @@
__ LoadObject(result, Array::ZoneHandle(Array::New(2, Heap::kOld)));
const intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(kArrayCid);
Address trunc_div_address(
- FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid,
- index_scale,
- result,
- 0));
+ FlowGraphCompiler::ElementAddressForIntIndex(
+ kArrayCid, index_scale, result,
+ MergedMathInstr::ResultIndexOf(Token::kTRUNCDIV)));
Address mod_address(
- FlowGraphCompiler::ElementAddressForIntIndex(kArrayCid,
- index_scale,
- result,
- 1));
+ FlowGraphCompiler::ElementAddressForIntIndex(
+ kArrayCid, index_scale, result,
+ MergedMathInstr::ResultIndexOf(Token::kMOD)));
__ SmiTag(EAX);
__ SmiTag(EDX);
__ StoreIntoObjectNoBarrier(result, trunc_div_address, EAX);
@@ -4097,6 +4111,39 @@
return;
}
+ if (kind() == MergedMathInstr::kSinCos) {
+ // Do x87 sincos, since the ia32 compilers may not fuse sin/cos into
+ // sincos.
+ __ pushl(EAX);
+ __ pushl(EAX);
+ __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg());
+ __ fldl(Address(ESP, 0));
+ __ fsincos();
+ __ fstpl(Address(ESP, 0));
+ __ movsd(XMM1, Address(ESP, 0));
+ __ fstpl(Address(ESP, 0));
+ __ movsd(XMM0, Address(ESP, 0));
+ __ addl(ESP, Immediate(2 * kWordSize));
+
+ Register result = locs()->out().reg();
+ const TypedData& res_array = TypedData::ZoneHandle(
+ TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld));
+ __ LoadObject(result, res_array);
+ const intptr_t index_scale =
+ FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid);
+ Address sin_address(
+ FlowGraphCompiler::ElementAddressForIntIndex(
+ kTypedDataFloat64ArrayCid, index_scale, result,
+ MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathSin)));
+ Address cos_address(
+ FlowGraphCompiler::ElementAddressForIntIndex(
+ kTypedDataFloat64ArrayCid, index_scale, result,
+ MergedMathInstr::ResultIndexOf(MethodRecognizer::kMathCos)));
+ __ movsd(sin_address, XMM0);
+ __ movsd(cos_address, XMM1);
+ return;
+ }
+
UNIMPLEMENTED();
}
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698