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

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

Issue 10836362: Clean up EmitSmiBinaryOp template to remove redundant moves. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 break; 1508 break;
1509 default: 1509 default:
1510 can_deopt = true; 1510 can_deopt = true;
1511 } 1511 }
1512 Label* deopt = NULL; 1512 Label* deopt = NULL;
1513 if (can_deopt) { 1513 if (can_deopt) {
1514 deopt = compiler->AddDeoptStub(comp->instance_call()->deopt_id(), 1514 deopt = compiler->AddDeoptStub(comp->instance_call()->deopt_id(),
1515 comp->instance_call()->try_index(), 1515 comp->instance_call()->try_index(),
1516 kDeoptSmiBinaryOp); 1516 kDeoptSmiBinaryOp);
1517 } 1517 }
1518 if (left_is_smi && right_is_smi) { 1518 if (!left_is_smi || !right_is_smi) {
1519 if (can_deopt) {
1520 // Preserve left for deopt.
1521 __ movq(temp, left);
1522 }
1523 } else {
1524 // TODO(vegorov): for many binary operations this pattern can be rearranged
1525 // to save one move.
1526 __ movq(temp, left); 1519 __ movq(temp, left);
1527 __ orq(left, right); 1520 __ orq(temp, right);
1528 __ testq(left, Immediate(kSmiTagMask)); 1521 __ testq(temp, Immediate(kSmiTagMask));
1529 __ j(NOT_ZERO, deopt); 1522 __ j(NOT_ZERO, deopt);
1530 __ movq(left, temp);
1531 } 1523 }
1532 switch (comp->op_kind()) { 1524 switch (comp->op_kind()) {
1533 case Token::kADD: { 1525 case Token::kADD: {
1534 __ addq(left, right); 1526 __ addq(left, right);
1535 __ j(OVERFLOW, deopt); 1527 __ j(OVERFLOW, deopt);
1536 break; 1528 break;
1537 } 1529 }
1538 case Token::kSUB: { 1530 case Token::kSUB: {
1539 __ subq(left, right); 1531 __ subq(left, right);
1540 __ j(OVERFLOW, deopt); 1532 __ j(OVERFLOW, deopt);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 __ Bind(&count_ok); 1589 __ Bind(&count_ok);
1598 ASSERT(right == RCX); // Count must be in RCX 1590 ASSERT(right == RCX); // Count must be in RCX
1599 __ SmiUntag(left); 1591 __ SmiUntag(left);
1600 __ sarq(left, right); 1592 __ sarq(left, right);
1601 __ SmiTag(left); 1593 __ SmiTag(left);
1602 break; 1594 break;
1603 } 1595 }
1604 case Token::kSHL: { 1596 case Token::kSHL: {
1605 Label call_method, done; 1597 Label call_method, done;
1606 // Check if count too large for handling it inlined. 1598 // Check if count too large for handling it inlined.
1599 __ movq(temp, left);
1607 __ cmpq(right, 1600 __ cmpq(right,
1608 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits)))); 1601 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits))));
1609 __ j(ABOVE_EQUAL, &call_method, Assembler::kNearJump); 1602 __ j(ABOVE_EQUAL, &call_method, Assembler::kNearJump);
1610 Register right_temp = comp->locs()->temp(1).reg(); 1603 Register right_temp = comp->locs()->temp(1).reg();
1611 ASSERT(right_temp == RCX); // Count must be in RCX 1604 ASSERT(right_temp == RCX); // Count must be in RCX
1612 __ movq(right_temp, right); 1605 __ movq(right_temp, right);
1613 __ SmiUntag(right_temp); 1606 __ SmiUntag(right_temp);
1614 // Overflow test (preserve temp and right); 1607 // Overflow test (preserve temp and right);
1615 __ shlq(left, right_temp); 1608 __ shlq(left, right_temp);
1616 __ sarq(left, right_temp); 1609 __ sarq(left, right_temp);
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 } 2216 }
2224 } 2217 }
2225 __ Bind(&is_ok); 2218 __ Bind(&is_ok);
2226 } 2219 }
2227 2220
2228 } // namespace dart 2221 } // namespace dart
2229 2222
2230 #undef __ 2223 #undef __
2231 2224
2232 #endif // defined TARGET_ARCH_X64 2225 #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