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

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

Issue 10542079: Implement Smi binops ia32 (new compiler). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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_ia32.cc ('k') | no next file » | 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) 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps); 808 LocationSummary* summary = new LocationSummary(kNumInputs, kNumTemps);
809 summary->set_in(0, Location::RequiresRegister()); 809 summary->set_in(0, Location::RequiresRegister());
810 summary->set_in(1, Location::RequiresRegister()); 810 summary->set_in(1, Location::RequiresRegister());
811 summary->set_out(Location::SameAsFirstInput()); 811 summary->set_out(Location::SameAsFirstInput());
812 summary->set_temp(0, Location::RequiresRegister()); 812 summary->set_temp(0, Location::RequiresRegister());
813 return summary; 813 return summary;
814 } 814 }
815 } 815 }
816 816
817 817
818 // TODO(srdjan): Implement variations.
819 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) { 818 static void EmitSmiBinaryOp(FlowGraphCompiler* compiler, BinaryOpComp* comp) {
820 // TODO(srdjan): need to allocate a temporary register (now using r10)
821 Register left = comp->locs()->in(0).reg(); 819 Register left = comp->locs()->in(0).reg();
822 Register right = comp->locs()->in(1).reg(); 820 Register right = comp->locs()->in(1).reg();
823 Register result = comp->locs()->out().reg(); 821 Register result = comp->locs()->out().reg();
824 Register temp = comp->locs()->temp(0).reg(); 822 Register temp = comp->locs()->temp(0).reg();
825 ASSERT(left == result); 823 ASSERT(left == result);
826 Label* deopt = compiler->AddDeoptStub(comp->instance_call()->cid(), 824 Label* deopt = compiler->AddDeoptStub(comp->instance_call()->cid(),
827 comp->instance_call()->token_index(), 825 comp->instance_call()->token_index(),
828 comp->instance_call()->try_index(), 826 comp->instance_call()->try_index(),
829 kDeoptSmiBinaryOp, 827 kDeoptSmiBinaryOp,
830 temp, 828 temp,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 __ cqo(); // Sign extend RAX -> RDX:RAX. 881 __ cqo(); // Sign extend RAX -> RDX:RAX.
884 __ idivq(right_temp); // RAX: quotient, RDX: remainder. 882 __ idivq(right_temp); // RAX: quotient, RDX: remainder.
885 // Check the corner case of dividing the 'MIN_SMI' with -1, in which 883 // Check the corner case of dividing the 'MIN_SMI' with -1, in which
886 // case we cannot tag the result. 884 // case we cannot tag the result.
887 __ cmpq(result, Immediate(0x4000000000000000)); 885 __ cmpq(result, Immediate(0x4000000000000000));
888 __ j(EQUAL, deopt); 886 __ j(EQUAL, deopt);
889 __ SmiTag(result); 887 __ SmiTag(result);
890 break; 888 break;
891 } 889 }
892 case Token::kSHR: { 890 case Token::kSHR: {
893 const Immediate kCountLimit = Immediate(0x1F); 891 // sarq operation masks the count to 6 bits.
892 const Immediate kCountLimit = Immediate(0x3F);
894 __ cmpq(right, Immediate(0)); 893 __ cmpq(right, Immediate(0));
895 __ j(LESS, deopt); 894 __ j(LESS, deopt);
896 __ SmiUntag(right); 895 __ SmiUntag(right);
897 __ cmpq(right, kCountLimit); 896 __ cmpq(right, kCountLimit);
898 Label count_ok; 897 Label count_ok;
899 __ j(LESS, &count_ok, Assembler::kNearJump); 898 __ j(LESS, &count_ok, Assembler::kNearJump);
900 __ movq(right, kCountLimit); 899 __ movq(right, kCountLimit);
901 __ Bind(&count_ok); 900 __ Bind(&count_ok);
902 ASSERT(right == RCX); // Count must be in ECX 901 ASSERT(right == RCX); // Count must be in RCX
903 __ SmiUntag(left); 902 __ SmiUntag(left);
904 __ sarq(left, right); 903 __ sarq(left, right);
905 __ SmiTag(left); 904 __ SmiTag(left);
906 break; 905 break;
907 } 906 }
908 case Token::kSHL: { 907 case Token::kSHL: {
909 // Check if count too large for handling it inlined. 908 // Check if count too large for handling it inlined.
910 __ cmpq(right, 909 __ cmpq(right,
911 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits)))); 910 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits))));
912 __ j(ABOVE_EQUAL, deopt); 911 __ j(ABOVE_EQUAL, deopt);
(...skipping 28 matching lines...) Expand all
941 UNREACHABLE(); 940 UNREACHABLE();
942 break; 941 break;
943 } 942 }
944 default: 943 default:
945 UNREACHABLE(); 944 UNREACHABLE();
946 break; 945 break;
947 } 946 }
948 } 947 }
949 948
950 949
951 static bool EmitDoubleBinaryOp(FlowGraphCompiler* compiler, 950 static void EmitDoubleBinaryOp(FlowGraphCompiler* compiler,
952 BinaryOpComp* comp) { 951 BinaryOpComp* comp) {
953 Register left = comp->locs()->in(0).reg(); 952 Register left = comp->locs()->in(0).reg();
954 Register right = comp->locs()->in(1).reg(); 953 Register right = comp->locs()->in(1).reg();
955 Register temp = comp->locs()->temp(0).reg(); 954 Register temp = comp->locs()->temp(0).reg();
956 Register result = comp->locs()->out().reg(); 955 Register result = comp->locs()->out().reg();
957 956
958 957
959 const Class& double_class = 958 const Class& double_class =
960 Class::ZoneHandle(Isolate::Current()->object_store()->double_class()); 959 Class::ZoneHandle(Isolate::Current()->object_store()->double_class());
961 const Code& stub = 960 const Code& stub =
(...skipping 22 matching lines...) Expand all
984 983
985 switch (comp->op_kind()) { 984 switch (comp->op_kind()) {
986 case Token::kADD: __ addsd(XMM0, XMM1); break; 985 case Token::kADD: __ addsd(XMM0, XMM1); break;
987 case Token::kSUB: __ subsd(XMM0, XMM1); break; 986 case Token::kSUB: __ subsd(XMM0, XMM1); break;
988 case Token::kMUL: __ mulsd(XMM0, XMM1); break; 987 case Token::kMUL: __ mulsd(XMM0, XMM1); break;
989 case Token::kDIV: __ divsd(XMM0, XMM1); break; 988 case Token::kDIV: __ divsd(XMM0, XMM1); break;
990 default: UNREACHABLE(); 989 default: UNREACHABLE();
991 } 990 }
992 991
993 __ movsd(FieldAddress(result, Double::value_offset()), XMM0); 992 __ movsd(FieldAddress(result, Double::value_offset()), XMM0);
994 return true;
995 } 993 }
996 994
997 995
998 void BinaryOpComp::EmitNativeCode(FlowGraphCompiler* compiler) { 996 void BinaryOpComp::EmitNativeCode(FlowGraphCompiler* compiler) {
999 switch (operands_type()) { 997 switch (operands_type()) {
1000 case kSmiOperands: 998 case kSmiOperands:
1001 EmitSmiBinaryOp(compiler, this); 999 EmitSmiBinaryOp(compiler, this);
1002 break; 1000 break;
1003 1001
1004 case kDoubleOperands: 1002 case kDoubleOperands:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 } else { 1117 } else {
1120 UNREACHABLE(); 1118 UNREACHABLE();
1121 } 1119 }
1122 } 1120 }
1123 1121
1124 } // namespace dart 1122 } // namespace dart
1125 1123
1126 #undef __ 1124 #undef __
1127 1125
1128 #endif // defined TARGET_ARCH_X64 1126 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698