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

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 180243013: Stop creating dummy call frames when calling out to C functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months 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
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc
index 4c2563e12f7ab6191c60abf77412452f517c0311..43619bc7849b892c982cb739a6f80849c34bda97 100644
--- a/runtime/vm/intermediate_language_x64.cc
+++ b/runtime/vm/intermediate_language_x64.cc
@@ -3980,13 +3980,15 @@ LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const {
// currently we can't specify these registers because ParallelMoveResolver
// assumes that XMM0 is free at all times.
// TODO(vegorov): allow XMM0 to be used.
- const intptr_t kNumTemps = 0;
+ const intptr_t kNumTemps = 1;
LocationSummary* summary =
new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
summary->set_in(0, Location::FpuRegisterLocation(XMM1));
+ summary->set_temp(0, Location::RegisterLocation(CALLEE_SAVED));
regis 2014/02/26 23:53:12 ditto
Cutch 2014/02/27 15:52:37 Done.
summary->set_out(Location::FpuRegisterLocation(XMM1));
return summary;
}
+ ASSERT(kind() == MethodRecognizer::kMathSqrt);
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = 0;
LocationSummary* summary =
@@ -4001,12 +4003,16 @@ void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
if (kind() == MethodRecognizer::kMathSqrt) {
__ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg());
} else {
- __ EnterFrame(0);
+ ASSERT((kind() == MethodRecognizer::kMathSin) ||
+ (kind() == MethodRecognizer::kMathCos));
+ // Save RSP.
+ __ movq(locs()->temp(0).reg(), RSP);
__ ReserveAlignedFrameSpace(0);
__ movaps(XMM0, locs()->in(0).fpu_reg());
__ CallRuntime(TargetFunction(), InputCount());
__ movaps(locs()->out().fpu_reg(), XMM0);
- __ leave();
+ // Restore RSP.
+ __ movq(RSP, locs()->temp(0).reg());
}
}
@@ -4322,9 +4328,10 @@ LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const {
// assumes that XMM0 is free at all times.
// TODO(vegorov): allow XMM0 to be used.
ASSERT((InputCount() == 1) || (InputCount() == 2));
- const intptr_t kNumTemps = 0;
+ const intptr_t kNumTemps = 1;
LocationSummary* result =
new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
+ result->set_temp(0, Location::RegisterLocation(CALLEE_SAVED));
result->set_in(0, Location::FpuRegisterLocation(XMM2));
if (InputCount() == 2) {
result->set_in(1, Location::FpuRegisterLocation(XMM1));
@@ -4339,7 +4346,8 @@ LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const {
void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- __ EnterFrame(0);
+ // Save RSP.
+ __ movq(locs()->temp(0).reg(), RSP);
__ ReserveAlignedFrameSpace(0);
__ movaps(XMM0, locs()->in(0).fpu_reg());
if (InputCount() == 2) {
@@ -4395,7 +4403,8 @@ void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ CallRuntime(TargetFunction(), InputCount());
__ movaps(locs()->out().fpu_reg(), XMM0);
__ Bind(&skip_call);
- __ leave();
+ // Restore RSP.
+ __ movq(RSP, locs()->temp(0).reg());
}
@@ -4415,10 +4424,11 @@ LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const {
}
if (kind() == MergedMathInstr::kSinCos) {
const intptr_t kNumInputs = 1;
- const intptr_t kNumTemps = 0;
+ const intptr_t kNumTemps = 1;
LocationSummary* summary =
new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
summary->set_in(0, Location::FpuRegisterLocation(XMM1));
+ summary->set_temp(0, Location::RegisterLocation(CALLEE_SAVED));
summary->set_out(Location::RegisterLocation(RAX));
return summary;
}
@@ -4541,7 +4551,8 @@ void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
return;
}
if (kind() == MergedMathInstr::kSinCos) {
- __ EnterFrame(0);
+ // Save RSP.
+ __ movq(locs()->temp(0).reg(), RSP);
// +-------------------------------+
// | double-argument | <- TOS
// +-------------------------------+
@@ -4564,7 +4575,8 @@ void MergedMathInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ CallRuntime(kSinCosRuntimeEntry, InputCount());
__ movsd(XMM0, Address(RSP, 2 * kWordSize + kDoubleSize * 2)); // sin.
__ movsd(XMM1, Address(RSP, 2 * kWordSize + kDoubleSize)); // cos.
- __ leave();
+ // Restore RSP.
+ __ movq(RSP, locs()->temp(0).reg());
Register result = locs()->out().reg();
const TypedData& res_array = TypedData::ZoneHandle(

Powered by Google App Engine
This is Rietveld 408576698