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

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

Issue 14251023: Merge (x & y) == 0 pattern to emit a single test instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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_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 "lib/error.h" 10 #include "lib/error.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 bool IfThenElseInstr::IsSupported() { 158 bool IfThenElseInstr::IsSupported() {
159 return true; 159 return true;
160 } 160 }
161 161
162 162
163 bool IfThenElseInstr::Supports(ComparisonInstr* comparison, 163 bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
164 Value* v1, 164 Value* v1,
165 Value* v2) { 165 Value* v2) {
166 if (!(comparison->IsStrictCompare() && 166 if (!(comparison->IsStrictCompare() &&
167 !comparison->AsStrictCompare()->needs_number_check()) && 167 !comparison->AsStrictCompare()->needs_number_check()) &&
168 !(comparison->IsEqualityCompare() && 168 !comparison->IsSmiEquality()) {
169 (comparison->AsEqualityCompare()->receiver_class_id() == kSmiCid))) {
170 return false; 169 return false;
171 } 170 }
172 171
173 intptr_t v1_value, v2_value; 172 intptr_t v1_value, v2_value;
174 173
175 if (!BindsToSmiConstant(v1, &v1_value) || 174 if (!BindsToSmiConstant(v1, &v1_value) ||
176 !BindsToSmiConstant(v2, &v2_value)) { 175 !BindsToSmiConstant(v2, &v2_value)) {
177 return false; 176 return false;
178 } 177 }
179 178
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 *ic_data()); 910 *ic_data());
912 if (branch->is_checked()) { 911 if (branch->is_checked()) {
913 EmitAssertBoolean(RAX, token_pos(), deopt_id(), locs(), compiler); 912 EmitAssertBoolean(RAX, token_pos(), deopt_id(), locs(), compiler);
914 } 913 }
915 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL; 914 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL;
916 __ CompareObject(RAX, Bool::True()); 915 __ CompareObject(RAX, Bool::True());
917 branch->EmitBranchOnCondition(compiler, branch_condition); 916 branch->EmitBranchOnCondition(compiler, branch_condition);
918 } 917 }
919 918
920 919
920 LocationSummary* TestSmiInstr::MakeLocationSummary() const {
921 const intptr_t kNumInputs = 2;
922 const intptr_t kNumTemps = 0;
923 LocationSummary* locs =
924 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
925 locs->set_in(0, Location::RequiresRegister());
926 // Only one input can be a constant operand. The case of two constant
927 // operands should be handled by constant propagation.
928 locs->set_in(1, Location::RegisterOrConstant(right()));
929 return locs;
930 }
931
932
933 void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
934 // Never emitted outside of the BranchInstr.
935 UNREACHABLE();
936 }
937
938
939 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler,
940 BranchInstr* branch) {
941 Condition branch_condition = (kind() == Token::kNE) ? NOT_ZERO : ZERO;
942 Location right = locs()->in(1);
943 if (right.IsConstant()) {
944 ASSERT(right.constant().IsSmi());
945 const int64_t imm =
946 reinterpret_cast<int64_t>(right.constant().raw());
947 __ testq(locs()->in(0).reg(), Immediate(imm));
948 } else {
949 __ testq(locs()->in(0).reg(), right.reg());
950 }
951 branch->EmitBranchOnCondition(compiler, branch_condition);
952 }
953
954
921 LocationSummary* RelationalOpInstr::MakeLocationSummary() const { 955 LocationSummary* RelationalOpInstr::MakeLocationSummary() const {
922 const intptr_t kNumInputs = 2; 956 const intptr_t kNumInputs = 2;
923 const intptr_t kNumTemps = 0; 957 const intptr_t kNumTemps = 0;
924 if (operands_class_id() == kDoubleCid) { 958 if (operands_class_id() == kDoubleCid) {
925 LocationSummary* summary = 959 LocationSummary* summary =
926 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 960 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
927 summary->set_in(0, Location::RequiresFpuRegister()); 961 summary->set_in(0, Location::RequiresFpuRegister());
928 summary->set_in(1, Location::RequiresFpuRegister()); 962 summary->set_in(1, Location::RequiresFpuRegister());
929 summary->set_out(Location::RequiresRegister()); 963 summary->set_out(Location::RequiresRegister());
930 return summary; 964 return summary;
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 PcDescriptors::kOther, 3614 PcDescriptors::kOther,
3581 locs()); 3615 locs());
3582 __ Drop(2); // Discard type arguments and receiver. 3616 __ Drop(2); // Discard type arguments and receiver.
3583 } 3617 }
3584 3618
3585 } // namespace dart 3619 } // namespace dart
3586 3620
3587 #undef __ 3621 #undef __
3588 3622
3589 #endif // defined TARGET_ARCH_X64 3623 #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