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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 30802)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -4052,11 +4052,28 @@
summary->set_temp(0, Location::RegisterLocation(RDX));
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(RAX));
+ 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()) {
@@ -4164,6 +4181,52 @@
// in-range arguments, cannot create out-of-range result.
return;
}
+ if (kind() == MergedMathInstr::kSinCos) {
+ __ EnterFrame(0);
+ // +-------------------------------+
+ // | double-argument | <- TOS
+ // +-------------------------------+
+ // | address-cos-result | +8
+ // +-------------------------------+
+ // | address-sin-result | +16
+ // +-------------------------------+
+ // | double-storage-for-cos-result | +24
+ // +-------------------------------+
+ // | double-storage-for-sin-result | +32
+ // +-------------------------------+
+ // ....
+ __ ReserveAlignedFrameSpace(kDoubleSize * 3 + kWordSize * 2);
+ __ movsd(Address(RSP, 0), locs()->in(0).fpu_reg());
+
+ __ leaq(RDI, Address(RSP, 2 * kWordSize + kDoubleSize));
+ __ leaq(RSI, Address(RSP, 2 * kWordSize + 2 * kDoubleSize));
+ __ movaps(XMM0, locs()->in(0).fpu_reg());
+
+ __ CallRuntime(kSinCosRuntimeEntry, InputCount());
+ __ movsd(XMM0, Address(RSP, 2 * kWordSize + kDoubleSize * 2)); // sin.
+ __ movsd(XMM1, Address(RSP, 2 * kWordSize + kDoubleSize)); // cos.
+ __ leave();
+
+ Register result = locs()->out().reg();
+ const TypedData& res_array = TypedData::ZoneHandle(
+ TypedData::New(kTypedDataFloat64ArrayCid, 2, Heap::kOld));
+ __ LoadObject(result, res_array, PP);
+ const intptr_t index_scale =
+ FlowGraphCompiler::ElementSizeFor(kTypedDataFloat64ArrayCid);
+ Address sin_address(
+ FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid,
+ index_scale,
+ result,
+ 0));
+ Address cos_address(
+ FlowGraphCompiler::ElementAddressForIntIndex(kTypedDataFloat64ArrayCid,
+ index_scale,
+ result,
+ 1));
+ __ movsd(sin_address, XMM0);
+ __ movsd(cos_address, XMM1);
+ return;
+ }
UNIMPLEMENTED();
}

Powered by Google App Engine
This is Rietveld 408576698