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

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

Issue 23757016: Simplify compilation of relational operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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) 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_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 "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 LocationSummary* RelationalOpInstr::MakeLocationSummary() const { 920 LocationSummary* RelationalOpInstr::MakeLocationSummary() const {
921 const intptr_t kNumInputs = 2; 921 const intptr_t kNumInputs = 2;
922 const intptr_t kNumTemps = 0; 922 const intptr_t kNumTemps = 0;
923 if (operation_cid() == kDoubleCid) { 923 if (operation_cid() == kDoubleCid) {
924 LocationSummary* summary = 924 LocationSummary* summary =
925 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 925 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
926 summary->set_in(0, Location::RequiresFpuRegister()); 926 summary->set_in(0, Location::RequiresFpuRegister());
927 summary->set_in(1, Location::RequiresFpuRegister()); 927 summary->set_in(1, Location::RequiresFpuRegister());
928 summary->set_out(Location::RequiresRegister()); 928 summary->set_out(Location::RequiresRegister());
929 return summary; 929 return summary;
930 } else if (operation_cid() == kSmiCid) {
931 LocationSummary* summary =
932 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
933 summary->set_in(0, Location::RegisterOrConstant(left()));
934 // Only one input can be a constant operand. The case of two constant
935 // operands should be handled by constant propagation.
936 summary->set_in(1, summary->in(0).IsConstant()
937 ? Location::RequiresRegister()
938 : Location::RegisterOrConstant(right()));
939 summary->set_out(Location::RequiresRegister());
940 return summary;
941 } 930 }
942 LocationSummary* locs = 931 ASSERT(operation_cid() == kSmiCid);
943 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 932 LocationSummary* summary =
944 // Pick arbitrary fixed input registers because this is a call. 933 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
945 locs->set_in(0, Location::RegisterLocation(RAX)); 934 summary->set_in(0, Location::RegisterOrConstant(left()));
946 locs->set_in(1, Location::RegisterLocation(RCX)); 935 // Only one input can be a constant operand. The case of two constant
947 locs->set_out(Location::RegisterLocation(RAX)); 936 // operands should be handled by constant propagation.
948 return locs; 937 summary->set_in(1, summary->in(0).IsConstant()
938 ? Location::RequiresRegister()
939 : Location::RegisterOrConstant(right()));
940 summary->set_out(Location::RequiresRegister());
941 return summary;
949 } 942 }
950 943
951 944
952 void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 945 void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
953 if (operation_cid() == kSmiCid) { 946 if (operation_cid() == kSmiCid) {
954 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL); 947 EmitSmiComparisonOp(compiler, *locs(), kind(), NULL);
955 return; 948 return;
956 } 949 }
957 if (operation_cid() == kDoubleCid) { 950 ASSERT(operation_cid() == kDoubleCid);
958 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL); 951 EmitDoubleComparisonOp(compiler, *locs(), kind(), NULL);
959 return;
960 }
961
962 // Push arguments for the call.
963 // TODO(fschneider): Split this instruction into different types to avoid
964 // explicitly pushing arguments to the call here.
965 Register left = locs()->in(0).reg();
966 Register right = locs()->in(1).reg();
967 __ pushq(left);
968 __ pushq(right);
969 if (HasICData() && (ic_data()->NumberOfChecks() > 0)) {
970 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptRelationalOp);
971
972 // Load class into RDI. Since this is a call, any register except
973 // the fixed input registers would be ok.
974 ASSERT((left != RDI) && (right != RDI));
975 LoadValueCid(compiler, RDI, left);
976 const intptr_t kNumArguments = 2;
977 compiler->EmitTestAndCall(ICData::Handle(ic_data()->AsUnaryClassChecks()),
978 RDI, // Class id register.
979 kNumArguments,
980 Object::null_array(), // No named arguments.
981 deopt, // Deoptimize target.
982 deopt_id(),
983 token_pos(),
984 locs());
985 return;
986 }
987 const String& function_name =
988 String::ZoneHandle(Symbols::New(Token::Str(kind())));
989 if (!compiler->is_optimizing()) {
990 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
991 deopt_id(),
992 token_pos());
993 }
994 const intptr_t kNumArguments = 2;
995 const intptr_t kNumArgsChecked = 2; // Type-feedback.
996 ICData& relational_ic_data = ICData::ZoneHandle(ic_data()->raw());
997 if (compiler->is_optimizing() && FLAG_propagate_ic_data) {
998 ASSERT(!ic_data()->IsNull());
999 if (ic_data()->NumberOfChecks() == 0) {
1000 // IC call for reoptimization populates original ICData.
1001 relational_ic_data = ic_data()->raw();
1002 } else {
1003 // Megamorphic call.
1004 relational_ic_data = ic_data()->AsUnaryClassChecks();
1005 }
1006 } else {
1007 const Array& arguments_descriptor =
1008 Array::Handle(ArgumentsDescriptor::New(kNumArguments,
1009 Object::null_array()));
1010 relational_ic_data = ICData::New(compiler->parsed_function().function(),
1011 function_name,
1012 arguments_descriptor,
1013 deopt_id(),
1014 kNumArgsChecked);
1015 }
1016 compiler->GenerateInstanceCall(deopt_id(),
1017 token_pos(),
1018 kNumArguments,
1019 Object::null_array(), // No optional args.
1020 locs(),
1021 relational_ic_data);
1022 } 952 }
1023 953
1024 954
1025 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler, 955 void RelationalOpInstr::EmitBranchCode(FlowGraphCompiler* compiler,
1026 BranchInstr* branch) { 956 BranchInstr* branch) {
1027 if (operation_cid() == kSmiCid) { 957 if (operation_cid() == kSmiCid) {
1028 EmitSmiComparisonOp(compiler, *locs(), kind(), branch); 958 EmitSmiComparisonOp(compiler, *locs(), kind(), branch);
1029 return; 959 return;
1030 } 960 }
1031 if (operation_cid() == kDoubleCid) { 961 ASSERT(operation_cid() == kDoubleCid);
1032 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); 962 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch);
1033 return;
1034 }
1035 EmitNativeCode(compiler);
1036 __ CompareObject(RAX, Bool::True());
1037 branch->EmitBranchOnCondition(compiler, EQUAL);
1038 } 963 }
1039 964
1040 965
1041 LocationSummary* NativeCallInstr::MakeLocationSummary() const { 966 LocationSummary* NativeCallInstr::MakeLocationSummary() const {
1042 const intptr_t kNumInputs = 0; 967 const intptr_t kNumInputs = 0;
1043 const intptr_t kNumTemps = 3; 968 const intptr_t kNumTemps = 3;
1044 LocationSummary* locs = 969 LocationSummary* locs =
1045 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 970 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
1046 locs->set_temp(0, Location::RegisterLocation(RAX)); 971 locs->set_temp(0, Location::RegisterLocation(RAX));
1047 locs->set_temp(1, Location::RegisterLocation(RBX)); 972 locs->set_temp(1, Location::RegisterLocation(RBX));
(...skipping 3833 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 PcDescriptors::kOther, 4806 PcDescriptors::kOther,
4882 locs()); 4807 locs());
4883 __ Drop(2); // Discard type arguments and receiver. 4808 __ Drop(2); // Discard type arguments and receiver.
4884 } 4809 }
4885 4810
4886 } // namespace dart 4811 } // namespace dart
4887 4812
4888 #undef __ 4813 #undef __
4889 4814
4890 #endif // defined TARGET_ARCH_X64 4815 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language.h ('K') | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698