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

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

Issue 1773633002: Add fast path smi comparison operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: other platforms Created 4 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
« no previous file with comments | « runtime/vm/intermediate_language_mips.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) 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/compiler.h" 10 #include "vm/compiler.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // Fall through or jump to the true successor. 472 // Fall through or jump to the true successor.
473 if (labels.fall_through != labels.true_label) { 473 if (labels.fall_through != labels.true_label) {
474 __ jmp(labels.true_label); 474 __ jmp(labels.true_label);
475 } 475 }
476 } 476 }
477 } 477 }
478 478
479 479
480 static Condition EmitInt64ComparisonOp(FlowGraphCompiler* compiler, 480 static Condition EmitInt64ComparisonOp(FlowGraphCompiler* compiler,
481 const LocationSummary& locs, 481 const LocationSummary& locs,
482 Token::Kind kind, 482 Token::Kind kind) {
483 BranchLabels labels) {
484 Location left = locs.in(0); 483 Location left = locs.in(0);
485 Location right = locs.in(1); 484 Location right = locs.in(1);
486 ASSERT(!left.IsConstant() || !right.IsConstant()); 485 ASSERT(!left.IsConstant() || !right.IsConstant());
487 486
488 Condition true_condition = TokenKindToIntCondition(kind); 487 Condition true_condition = TokenKindToIntCondition(kind);
489 488
490 if (left.IsConstant()) { 489 if (left.IsConstant()) {
491 __ CompareObject(right.reg(), left.constant()); 490 __ CompareObject(right.reg(), left.constant());
492 true_condition = FlipCondition(true_condition); 491 true_condition = FlipCondition(true_condition);
493 } else if (right.IsConstant()) { 492 } else if (right.IsConstant()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 Label* nan_result = (true_condition == NOT_EQUAL) 528 Label* nan_result = (true_condition == NOT_EQUAL)
530 ? labels.true_label : labels.false_label; 529 ? labels.true_label : labels.false_label;
531 __ j(PARITY_EVEN, nan_result); 530 __ j(PARITY_EVEN, nan_result);
532 return true_condition; 531 return true_condition;
533 } 532 }
534 533
535 534
536 Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 535 Condition EqualityCompareInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
537 BranchLabels labels) { 536 BranchLabels labels) {
538 if ((operation_cid() == kSmiCid) || (operation_cid() == kMintCid)) { 537 if ((operation_cid() == kSmiCid) || (operation_cid() == kMintCid)) {
539 return EmitInt64ComparisonOp(compiler, *locs(), kind(), labels); 538 return EmitInt64ComparisonOp(compiler, *locs(), kind());
540 } else { 539 } else {
541 ASSERT(operation_cid() == kDoubleCid); 540 ASSERT(operation_cid() == kDoubleCid);
542 return EmitDoubleComparisonOp(compiler, *locs(), kind(), labels); 541 return EmitDoubleComparisonOp(compiler, *locs(), kind(), labels);
543 } 542 }
544 } 543 }
545 544
546 545
547 void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 546 void EqualityCompareInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
548 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE)); 547 ASSERT((kind() == Token::kEQ) || (kind() == Token::kNE));
549 548
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 ? Location::RequiresRegister() 719 ? Location::RequiresRegister()
721 : Location::RegisterOrConstant(right())); 720 : Location::RegisterOrConstant(right()));
722 summary->set_out(0, Location::RequiresRegister()); 721 summary->set_out(0, Location::RequiresRegister());
723 return summary; 722 return summary;
724 } 723 }
725 724
726 725
727 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler, 726 Condition RelationalOpInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
728 BranchLabels labels) { 727 BranchLabels labels) {
729 if ((operation_cid() == kSmiCid) || (operation_cid() == kMintCid)) { 728 if ((operation_cid() == kSmiCid) || (operation_cid() == kMintCid)) {
730 return EmitInt64ComparisonOp(compiler, *locs(), kind(), labels); 729 return EmitInt64ComparisonOp(compiler, *locs(), kind());
731 } else { 730 } else {
732 ASSERT(operation_cid() == kDoubleCid); 731 ASSERT(operation_cid() == kDoubleCid);
733 return EmitDoubleComparisonOp(compiler, *locs(), kind(), labels); 732 return EmitDoubleComparisonOp(compiler, *locs(), kind(), labels);
734 } 733 }
735 } 734 }
736 735
737 736
738 void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 737 void RelationalOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
739 Label is_true, is_false; 738 Label is_true, is_false;
740 BranchLabels labels = { &is_true, &is_false, &is_false }; 739 BranchLabels labels = { &is_true, &is_false, &is_false };
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 2830
2832 LocationSummary* CheckedSmiOpInstr::MakeLocationSummary(Zone* zone, 2831 LocationSummary* CheckedSmiOpInstr::MakeLocationSummary(Zone* zone,
2833 bool opt) const { 2832 bool opt) const {
2834 const intptr_t kNumInputs = 2; 2833 const intptr_t kNumInputs = 2;
2835 const intptr_t kNumTemps = 0; 2834 const intptr_t kNumTemps = 0;
2836 LocationSummary* summary = new(zone) LocationSummary( 2835 LocationSummary* summary = new(zone) LocationSummary(
2837 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath); 2836 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
2838 summary->set_in(0, Location::RequiresRegister()); 2837 summary->set_in(0, Location::RequiresRegister());
2839 summary->set_in(1, Location::RequiresRegister()); 2838 summary->set_in(1, Location::RequiresRegister());
2840 switch (op_kind()) { 2839 switch (op_kind()) {
2840 case Token::kEQ:
2841 case Token::kLT:
2842 case Token::kLTE:
2843 case Token::kGT:
2844 case Token::kGTE:
2841 case Token::kADD: 2845 case Token::kADD:
2842 case Token::kSUB: 2846 case Token::kSUB:
2843 summary->set_out(0, Location::RequiresRegister()); 2847 summary->set_out(0, Location::RequiresRegister());
2844 break; 2848 break;
2845 case Token::kBIT_OR: 2849 case Token::kBIT_OR:
2846 case Token::kBIT_AND: 2850 case Token::kBIT_AND:
2847 case Token::kBIT_XOR: 2851 case Token::kBIT_XOR:
2848 summary->set_out(0, Location::SameAsFirstInput()); 2852 summary->set_out(0, Location::SameAsFirstInput());
2849 break; 2853 break;
2850 default: 2854 default:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 __ orq(result, right); 2886 __ orq(result, right);
2883 break; 2887 break;
2884 case Token::kBIT_AND: 2888 case Token::kBIT_AND:
2885 ASSERT(left == result); 2889 ASSERT(left == result);
2886 __ andq(result, right); 2890 __ andq(result, right);
2887 break; 2891 break;
2888 case Token::kBIT_XOR: 2892 case Token::kBIT_XOR:
2889 ASSERT(left == result); 2893 ASSERT(left == result);
2890 __ xorq(result, right); 2894 __ xorq(result, right);
2891 break; 2895 break;
2896 case Token::kEQ:
2897 case Token::kLT:
2898 case Token::kLTE:
2899 case Token::kGT:
2900 case Token::kGTE: {
2901 Label true_label, false_label, done;
2902 BranchLabels labels = { &true_label, &false_label, &false_label };
2903 Condition true_condition =
2904 EmitInt64ComparisonOp(compiler, *locs(), op_kind());
2905 EmitBranchOnCondition(compiler, true_condition, labels);
2906 __ Bind(&false_label);
2907 __ LoadObject(result, Bool::False());
2908 __ jmp(&done);
2909 __ Bind(&true_label);
2910 __ LoadObject(result, Bool::True());
2911 __ Bind(&done);
2912 break;
2913 }
2892 default: 2914 default:
2893 UNIMPLEMENTED(); 2915 UNIMPLEMENTED();
2894 } 2916 }
2895 __ Bind(slow_path->exit_label()); 2917 __ Bind(slow_path->exit_label());
2896 } 2918 }
2897 2919
2898 2920
2899 static bool CanBeImmediate(const Object& constant) { 2921 static bool CanBeImmediate(const Object& constant) {
2900 return constant.IsSmi() && 2922 return constant.IsSmi() &&
2901 Immediate(reinterpret_cast<int64_t>(constant.raw())).is_int32(); 2923 Immediate(reinterpret_cast<int64_t>(constant.raw())).is_int32();
(...skipping 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after
6500 __ Drop(1); 6522 __ Drop(1);
6501 __ popq(result); 6523 __ popq(result);
6502 } 6524 }
6503 6525
6504 6526
6505 } // namespace dart 6527 } // namespace dart
6506 6528
6507 #undef __ 6529 #undef __
6508 6530
6509 #endif // defined TARGET_ARCH_X64 6531 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698