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

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

Issue 59613005: Merge (x & y) == 0 pattern to emit a single test instruction. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 if (operation_cid() == kDoubleCid) { 542 if (operation_cid() == kDoubleCid) {
543 // Deoptimizes if both arguments are Smi, or if none is Double or Smi. 543 // Deoptimizes if both arguments are Smi, or if none is Double or Smi.
544 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch); 544 EmitDoubleComparisonOp(compiler, *locs(), kind(), branch);
545 return; 545 return;
546 } 546 }
547 UNREACHABLE(); 547 UNREACHABLE();
548 } 548 }
549 549
550 550
551 LocationSummary* TestSmiInstr::MakeLocationSummary() const {
552 const intptr_t kNumInputs = 2;
553 const intptr_t kNumTemps = 0;
554 LocationSummary* locs =
555 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
556 locs->set_in(0, Location::RequiresRegister());
557 // Only one input can be a constant operand. The case of two constant
558 // operands should be handled by constant propagation.
559 locs->set_in(1, Location::RegisterOrConstant(right()));
560 return locs;
561 }
562
563
564 void TestSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
565 // Never emitted outside of the BranchInstr.
566 UNREACHABLE();
567 }
568
569
570 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler,
571 BranchInstr* branch) {
572 Condition branch_condition = (kind() == Token::kNE) ? NOT_ZERO : ZERO;
573 Register left_reg = locs()->in(0).reg();
574 Location right = locs()->in(1);
575 if (right.IsConstant()) {
576 ASSERT(right.constant().IsSmi());
577 const int64_t imm =
578 reinterpret_cast<int64_t>(right.constant().raw());
579 __ TestImmediate(left_reg, Immediate(imm), PP);
580 } else {
581 __ testq(left_reg, right.reg());
582 }
583 branch->EmitBranchOnCondition(compiler, branch_condition);
584 }
585
586
551 LocationSummary* RelationalOpInstr::MakeLocationSummary() const { 587 LocationSummary* RelationalOpInstr::MakeLocationSummary() const {
552 const intptr_t kNumInputs = 2; 588 const intptr_t kNumInputs = 2;
553 const intptr_t kNumTemps = 0; 589 const intptr_t kNumTemps = 0;
554 if (operation_cid() == kDoubleCid) { 590 if (operation_cid() == kDoubleCid) {
555 LocationSummary* summary = 591 LocationSummary* summary =
556 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 592 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
557 summary->set_in(0, Location::RequiresFpuRegister()); 593 summary->set_in(0, Location::RequiresFpuRegister());
558 summary->set_in(1, Location::RequiresFpuRegister()); 594 summary->set_in(1, Location::RequiresFpuRegister());
559 summary->set_out(Location::RequiresRegister()); 595 summary->set_out(Location::RequiresRegister());
560 return summary; 596 return summary;
(...skipping 3957 matching lines...) Expand 10 before | Expand all | Expand 10 after
4518 PcDescriptors::kOther, 4554 PcDescriptors::kOther,
4519 locs()); 4555 locs());
4520 __ Drop(2); // Discard type arguments and receiver. 4556 __ Drop(2); // Discard type arguments and receiver.
4521 } 4557 }
4522 4558
4523 } // namespace dart 4559 } // namespace dart
4524 4560
4525 #undef __ 4561 #undef __
4526 4562
4527 #endif // defined TARGET_ARCH_X64 4563 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698