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

Unified Diff: runtime/vm/intermediate_language_ia32.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
« no previous file with comments | « runtime/vm/intermediate_language.h ('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
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index 369d154f976867657a33cb0c6eb61a11c570ab77..f1248a215db4735154121b1620db5fde513b0802 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -3981,13 +3981,17 @@ LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const {
if ((kind() == MethodRecognizer::kMathSin) ||
(kind() == MethodRecognizer::kMathCos)) {
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));
+ // EDI is chosen because it is callee saved so we do not need to back it
+ // up before calling into the runtime.
+ summary->set_temp(0, Location::RegisterLocation(EDI));
summary->set_out(Location::FpuRegisterLocation(XMM1));
return summary;
}
+ ASSERT(kind() == MethodRecognizer::kMathSqrt);
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = 0;
LocationSummary* summary =
@@ -4002,13 +4006,17 @@ 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 ESP.
+ __ movl(locs()->temp(0).reg(), ESP);
__ ReserveAlignedFrameSpace(kDoubleSize * InputCount());
__ movsd(Address(ESP, 0), locs()->in(0).fpu_reg());
__ CallRuntime(TargetFunction(), InputCount());
__ fstpl(Address(ESP, 0));
__ movsd(locs()->out().fpu_reg(), Address(ESP, 0));
- __ leave();
+ // Restore ESP.
+ __ movl(ESP, locs()->temp(0).reg());
}
}
@@ -4298,15 +4306,20 @@ void FloatToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const {
ASSERT((InputCount() == 1) || (InputCount() == 2));
- const intptr_t kNumTemps = 0;
+ const intptr_t kNumTemps = 1;
LocationSummary* result =
new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
+ // EDI is chosen because it is callee saved so we do not need to back it
+ // up before calling into the runtime.
+ result->set_temp(0, Location::RegisterLocation(EDI));
result->set_in(0, Location::FpuRegisterLocation(XMM1));
if (InputCount() == 2) {
result->set_in(1, Location::FpuRegisterLocation(XMM2));
}
if (recognized_kind() == MethodRecognizer::kMathDoublePow) {
+ // Temp index 1.
result->AddTemp(Location::RegisterLocation(EAX));
+ // Temp index 2.
result->AddTemp(Location::FpuRegisterLocation(XMM4));
}
result->set_out(Location::FpuRegisterLocation(XMM3));
@@ -4315,7 +4328,8 @@ LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const {
void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- __ EnterFrame(0);
+ // Save ESP.
+ __ movl(locs()->temp(kSavedSpTempIndex).reg(), ESP);
__ ReserveAlignedFrameSpace(kDoubleSize * InputCount());
for (intptr_t i = 0; i < InputCount(); i++) {
__ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg());
@@ -4331,8 +4345,8 @@ void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
XmmRegister base = locs()->in(0).fpu_reg();
XmmRegister exp = locs()->in(1).fpu_reg();
XmmRegister result = locs()->out().fpu_reg();
- Register temp = locs()->temp(0).reg();
- XmmRegister zero_temp = locs()->temp(1).fpu_reg();
+ Register temp = locs()->temp(kObjectTempIndex).reg();
+ XmmRegister zero_temp = locs()->temp(kDoubleTempIndex).fpu_reg();
Label check_base_is_one;
// Check if exponent is 0.0 -> return 1.0;
@@ -4363,7 +4377,8 @@ void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ fstpl(Address(ESP, 0));
__ movsd(locs()->out().fpu_reg(), Address(ESP, 0));
__ Bind(&skip_call);
- __ leave();
+ // Restore ESP.
+ __ movl(ESP, locs()->temp(kSavedSpTempIndex).reg());
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698