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

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 11098009: Implement SmiToInt and DoubleToInt. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 1968
1969 __ testq(value, Immediate(kSmiTagMask)); 1969 __ testq(value, Immediate(kSmiTagMask));
1970 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi. 1970 __ j(NOT_ZERO, deopt); // Deoptimize if not Smi.
1971 __ SmiUntag(value); 1971 __ SmiUntag(value);
1972 __ cvtsi2sd(XMM0, value); 1972 __ cvtsi2sd(XMM0, value);
1973 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 1973 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
1974 __ Drop(1); 1974 __ Drop(1);
1975 } 1975 }
1976 1976
1977 1977
1978 LocationSummary* DoubleToIntegerInstr::MakeLocationSummary() const {
1979 return MakeCallSummary(); // Slow case calls the method.
1980 }
1981
1982
1983 void DoubleToIntegerInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1984 Register result = locs()->out().reg();
1985 ASSERT(result == RAX);
1986 Register value_obj = RBX;
1987 XmmRegister value_double = XMM0;
1988 __ movq(value_obj, Address(RSP, 0));
1989 __ movsd(value_double, FieldAddress(value_obj, Double::value_offset()));
1990 __ cvttsd2siq(result, value_double);
Florian Schneider 2012/10/09 11:13:58 Please make sure that the tests cover the corner c
srdjan 2012/10/09 21:23:04 Yes, this is covered in arithmetic_test.dart (thro
1991 // Overflow is signalled with minint.
1992 Label do_call, done;
1993 // Check for overflow and that it fits into Smi.
1994 __ cmpq(result, Immediate(0xC000000000000000));
cshapiro 2012/10/09 00:59:24 Why not use SH SHL result, 1 JO <overflow> The
srdjan 2012/10/09 21:23:04 Done, using a temporary register to preserve resul
1995 __ j(NEGATIVE, &do_call, Assembler::kNearJump);
1996 __ SmiTag(result);
1997 __ Drop(1);
1998 __ jmp(&done);
1999 __ Bind(&do_call);
2000 ASSERT(instance_call()->HasICData());
2001 const ICData& ic_data = *instance_call()->ic_data();
2002 ASSERT((ic_data.NumberOfChecks() == 1));
2003 const Function& target = Function::ZoneHandle(ic_data.GetTargetAt(0));
2004
2005 const intptr_t kNumberOfArguments = 1;
2006 compiler->GenerateStaticCall(instance_call()->deopt_id(),
2007 instance_call()->token_pos(),
2008 target,
2009 kNumberOfArguments,
2010 Array::Handle(), // No argument names.,
Florian Schneider 2012/10/09 11:13:58 Remove extra , at the end.
srdjan 2012/10/09 21:23:04 Done.
2011 locs());
2012 __ Bind(&done);
2013 }
2014
2015
1978 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const { 2016 LocationSummary* PolymorphicInstanceCallInstr::MakeLocationSummary() const {
1979 return MakeCallSummary(); 2017 return MakeCallSummary();
1980 } 2018 }
1981 2019
1982 2020
1983 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2021 void PolymorphicInstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1984 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(), 2022 Label* deopt = compiler->AddDeoptStub(instance_call()->deopt_id(),
1985 kDeoptPolymorphicInstanceCallTestFail); 2023 kDeoptPolymorphicInstanceCallTestFail);
1986 if (ic_data().NumberOfChecks() == 0) { 2024 if (ic_data().NumberOfChecks() == 0) {
1987 __ jmp(deopt); 2025 __ jmp(deopt);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2206 2244
2207 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2245 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2208 UNIMPLEMENTED(); 2246 UNIMPLEMENTED();
2209 } 2247 }
2210 2248
2211 } // namespace dart 2249 } // namespace dart
2212 2250
2213 #undef __ 2251 #undef __
2214 2252
2215 #endif // defined TARGET_ARCH_X64 2253 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698