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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3963 matching lines...) Expand 10 before | Expand all | Expand 10 after
3974 break; 3974 break;
3975 default: UNREACHABLE(); 3975 default: UNREACHABLE();
3976 } 3976 }
3977 } 3977 }
3978 3978
3979 3979
3980 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const { 3980 LocationSummary* MathUnaryInstr::MakeLocationSummary(bool opt) const {
3981 if ((kind() == MethodRecognizer::kMathSin) || 3981 if ((kind() == MethodRecognizer::kMathSin) ||
3982 (kind() == MethodRecognizer::kMathCos)) { 3982 (kind() == MethodRecognizer::kMathCos)) {
3983 const intptr_t kNumInputs = 1; 3983 const intptr_t kNumInputs = 1;
3984 const intptr_t kNumTemps = 0; 3984 const intptr_t kNumTemps = 1;
3985 LocationSummary* summary = 3985 LocationSummary* summary =
3986 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 3986 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
3987 summary->set_in(0, Location::FpuRegisterLocation(XMM1)); 3987 summary->set_in(0, Location::FpuRegisterLocation(XMM1));
3988 // EDI is chosen because it is callee saved so we do not need to back it
3989 // up before calling into the runtime.
3990 summary->set_temp(0, Location::RegisterLocation(EDI));
3988 summary->set_out(Location::FpuRegisterLocation(XMM1)); 3991 summary->set_out(Location::FpuRegisterLocation(XMM1));
3989 return summary; 3992 return summary;
3990 } 3993 }
3994 ASSERT(kind() == MethodRecognizer::kMathSqrt);
3991 const intptr_t kNumInputs = 1; 3995 const intptr_t kNumInputs = 1;
3992 const intptr_t kNumTemps = 0; 3996 const intptr_t kNumTemps = 0;
3993 LocationSummary* summary = 3997 LocationSummary* summary =
3994 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 3998 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
3995 summary->set_in(0, Location::RequiresFpuRegister()); 3999 summary->set_in(0, Location::RequiresFpuRegister());
3996 summary->set_out(Location::RequiresFpuRegister()); 4000 summary->set_out(Location::RequiresFpuRegister());
3997 return summary; 4001 return summary;
3998 } 4002 }
3999 4003
4000 4004
4001 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4005 void MathUnaryInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4002 if (kind() == MethodRecognizer::kMathSqrt) { 4006 if (kind() == MethodRecognizer::kMathSqrt) {
4003 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); 4007 __ sqrtsd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg());
4004 } else { 4008 } else {
4005 __ EnterFrame(0); 4009 ASSERT((kind() == MethodRecognizer::kMathSin) ||
4010 (kind() == MethodRecognizer::kMathCos));
4011 // Save ESP.
4012 __ movl(locs()->temp(0).reg(), ESP);
4006 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); 4013 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount());
4007 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg()); 4014 __ movsd(Address(ESP, 0), locs()->in(0).fpu_reg());
4008 __ CallRuntime(TargetFunction(), InputCount()); 4015 __ CallRuntime(TargetFunction(), InputCount());
4009 __ fstpl(Address(ESP, 0)); 4016 __ fstpl(Address(ESP, 0));
4010 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); 4017 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0));
4011 __ leave(); 4018 // Restore ESP.
4019 __ movl(ESP, locs()->temp(0).reg());
4012 } 4020 }
4013 } 4021 }
4014 4022
4015 4023
4016 LocationSummary* MathMinMaxInstr::MakeLocationSummary(bool opt) const { 4024 LocationSummary* MathMinMaxInstr::MakeLocationSummary(bool opt) const {
4017 if (result_cid() == kDoubleCid) { 4025 if (result_cid() == kDoubleCid) {
4018 const intptr_t kNumInputs = 2; 4026 const intptr_t kNumInputs = 2;
4019 const intptr_t kNumTemps = 1; 4027 const intptr_t kNumTemps = 1;
4020 LocationSummary* summary = 4028 LocationSummary* summary =
4021 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 4029 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 } 4299 }
4292 4300
4293 4301
4294 void FloatToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4302 void FloatToDoubleInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4295 __ cvtss2sd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg()); 4303 __ cvtss2sd(locs()->out().fpu_reg(), locs()->in(0).fpu_reg());
4296 } 4304 }
4297 4305
4298 4306
4299 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const { 4307 LocationSummary* InvokeMathCFunctionInstr::MakeLocationSummary(bool opt) const {
4300 ASSERT((InputCount() == 1) || (InputCount() == 2)); 4308 ASSERT((InputCount() == 1) || (InputCount() == 2));
4301 const intptr_t kNumTemps = 0; 4309 const intptr_t kNumTemps = 1;
4302 LocationSummary* result = 4310 LocationSummary* result =
4303 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall); 4311 new LocationSummary(InputCount(), kNumTemps, LocationSummary::kCall);
4312 // EDI is chosen because it is callee saved so we do not need to back it
4313 // up before calling into the runtime.
4314 result->set_temp(0, Location::RegisterLocation(EDI));
4304 result->set_in(0, Location::FpuRegisterLocation(XMM1)); 4315 result->set_in(0, Location::FpuRegisterLocation(XMM1));
4305 if (InputCount() == 2) { 4316 if (InputCount() == 2) {
4306 result->set_in(1, Location::FpuRegisterLocation(XMM2)); 4317 result->set_in(1, Location::FpuRegisterLocation(XMM2));
4307 } 4318 }
4308 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { 4319 if (recognized_kind() == MethodRecognizer::kMathDoublePow) {
4320 // Temp index 1.
4309 result->AddTemp(Location::RegisterLocation(EAX)); 4321 result->AddTemp(Location::RegisterLocation(EAX));
4322 // Temp index 2.
4310 result->AddTemp(Location::FpuRegisterLocation(XMM4)); 4323 result->AddTemp(Location::FpuRegisterLocation(XMM4));
4311 } 4324 }
4312 result->set_out(Location::FpuRegisterLocation(XMM3)); 4325 result->set_out(Location::FpuRegisterLocation(XMM3));
4313 return result; 4326 return result;
4314 } 4327 }
4315 4328
4316 4329
4317 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4330 void InvokeMathCFunctionInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4318 __ EnterFrame(0); 4331 // Save ESP.
4332 __ movl(locs()->temp(kSavedSpTempIndex).reg(), ESP);
4319 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount()); 4333 __ ReserveAlignedFrameSpace(kDoubleSize * InputCount());
4320 for (intptr_t i = 0; i < InputCount(); i++) { 4334 for (intptr_t i = 0; i < InputCount(); i++) {
4321 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg()); 4335 __ movsd(Address(ESP, kDoubleSize * i), locs()->in(i).fpu_reg());
4322 } 4336 }
4323 Label do_call, skip_call; 4337 Label do_call, skip_call;
4324 if (recognized_kind() == MethodRecognizer::kMathDoublePow) { 4338 if (recognized_kind() == MethodRecognizer::kMathDoublePow) {
4325 // Pseudo code: 4339 // Pseudo code:
4326 // if (exponent == 0.0) return 1.0; 4340 // if (exponent == 0.0) return 1.0;
4327 // if (base == 1.0) return 1.0; 4341 // if (base == 1.0) return 1.0;
4328 // if (base.isNaN || exponent.isNaN) { 4342 // if (base.isNaN || exponent.isNaN) {
4329 // return double.NAN; 4343 // return double.NAN;
4330 // } 4344 // }
4331 XmmRegister base = locs()->in(0).fpu_reg(); 4345 XmmRegister base = locs()->in(0).fpu_reg();
4332 XmmRegister exp = locs()->in(1).fpu_reg(); 4346 XmmRegister exp = locs()->in(1).fpu_reg();
4333 XmmRegister result = locs()->out().fpu_reg(); 4347 XmmRegister result = locs()->out().fpu_reg();
4334 Register temp = locs()->temp(0).reg(); 4348 Register temp = locs()->temp(kObjectTempIndex).reg();
4335 XmmRegister zero_temp = locs()->temp(1).fpu_reg(); 4349 XmmRegister zero_temp = locs()->temp(kDoubleTempIndex).fpu_reg();
4336 4350
4337 Label check_base_is_one; 4351 Label check_base_is_one;
4338 // Check if exponent is 0.0 -> return 1.0; 4352 // Check if exponent is 0.0 -> return 1.0;
4339 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0))); 4353 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(0)));
4340 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset())); 4354 __ movsd(zero_temp, FieldAddress(temp, Double::value_offset()));
4341 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1))); 4355 __ LoadObject(temp, Double::ZoneHandle(Double::NewCanonical(1)));
4342 __ movsd(result, FieldAddress(temp, Double::value_offset())); 4356 __ movsd(result, FieldAddress(temp, Double::value_offset()));
4343 // 'result' contains 1.0. 4357 // 'result' contains 1.0.
4344 __ comisd(exp, zero_temp); 4358 __ comisd(exp, zero_temp);
4345 __ j(PARITY_EVEN, &check_base_is_one, Assembler::kNearJump); // NaN. 4359 __ j(PARITY_EVEN, &check_base_is_one, Assembler::kNearJump); // NaN.
(...skipping 10 matching lines...) Expand all
4356 // Returns NaN. 4370 // Returns NaN.
4357 __ movsd(result, base); 4371 __ movsd(result, base);
4358 __ jmp(&skip_call, Assembler::kNearJump); 4372 __ jmp(&skip_call, Assembler::kNearJump);
4359 // exp is Nan case is handled correctly in the C-library. 4373 // exp is Nan case is handled correctly in the C-library.
4360 } 4374 }
4361 __ Bind(&do_call); 4375 __ Bind(&do_call);
4362 __ CallRuntime(TargetFunction(), InputCount()); 4376 __ CallRuntime(TargetFunction(), InputCount());
4363 __ fstpl(Address(ESP, 0)); 4377 __ fstpl(Address(ESP, 0));
4364 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0)); 4378 __ movsd(locs()->out().fpu_reg(), Address(ESP, 0));
4365 __ Bind(&skip_call); 4379 __ Bind(&skip_call);
4366 __ leave(); 4380 // Restore ESP.
4381 __ movl(ESP, locs()->temp(kSavedSpTempIndex).reg());
4367 } 4382 }
4368 4383
4369 4384
4370 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const { 4385 LocationSummary* MergedMathInstr::MakeLocationSummary(bool opt) const {
4371 if (kind() == MergedMathInstr::kTruncDivMod) { 4386 if (kind() == MergedMathInstr::kTruncDivMod) {
4372 const intptr_t kNumInputs = 2; 4387 const intptr_t kNumInputs = 2;
4373 const intptr_t kNumTemps = 1; 4388 const intptr_t kNumTemps = 1;
4374 LocationSummary* summary = 4389 LocationSummary* summary =
4375 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 4390 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
4376 // Both inputs must be writable because they will be untagged. 4391 // Both inputs must be writable because they will be untagged.
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
5360 PcDescriptors::kOther, 5375 PcDescriptors::kOther,
5361 locs()); 5376 locs());
5362 __ Drop(ArgumentCount()); // Discard arguments. 5377 __ Drop(ArgumentCount()); // Discard arguments.
5363 } 5378 }
5364 5379
5365 } // namespace dart 5380 } // namespace dart
5366 5381
5367 #undef __ 5382 #undef __
5368 5383
5369 #endif // defined TARGET_ARCH_IA32 5384 #endif // defined TARGET_ARCH_IA32
OLDNEW
« 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