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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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 | « no previous file | runtime/vm/intermediate_language_x64.cc » ('j') | 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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 break; 1493 break;
1494 default: 1494 default:
1495 can_deopt = true; 1495 can_deopt = true;
1496 } 1496 }
1497 Label* deopt = NULL; 1497 Label* deopt = NULL;
1498 if (can_deopt) { 1498 if (can_deopt) {
1499 deopt = compiler->AddDeoptStub(comp->instance_call()->deopt_id(), 1499 deopt = compiler->AddDeoptStub(comp->instance_call()->deopt_id(),
1500 comp->instance_call()->try_index(), 1500 comp->instance_call()->try_index(),
1501 kDeoptSmiBinaryOp); 1501 kDeoptSmiBinaryOp);
1502 } 1502 }
1503 if (left_is_smi && right_is_smi) { 1503 if (!left_is_smi || !right_is_smi) {
1504 if (can_deopt) {
1505 // Preserve left for deopt.
1506 __ movl(temp, left);
1507 }
1508 } else {
1509 // TODO(vegorov): for many binary operations this pattern can be rearranged 1504 // TODO(vegorov): for many binary operations this pattern can be rearranged
1510 // to save one move. 1505 // to save one move.
1511 __ movl(temp, left); 1506 __ movl(temp, left);
1512 __ orl(left, right); 1507 __ orl(temp, right);
1513 __ testl(left, Immediate(kSmiTagMask)); 1508 __ testl(temp, Immediate(kSmiTagMask));
1514 __ j(NOT_ZERO, deopt); 1509 __ j(NOT_ZERO, deopt);
1515 __ movl(left, temp);
1516 } 1510 }
1517 switch (comp->op_kind()) { 1511 switch (comp->op_kind()) {
1518 case Token::kADD: { 1512 case Token::kADD: {
1519 __ addl(left, right); 1513 __ addl(left, right);
1520 __ j(OVERFLOW, deopt); 1514 __ j(OVERFLOW, deopt);
1521 break; 1515 break;
1522 } 1516 }
1523 case Token::kSUB: { 1517 case Token::kSUB: {
1524 __ subl(left, right); 1518 __ subl(left, right);
1525 __ j(OVERFLOW, deopt); 1519 __ j(OVERFLOW, deopt);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 __ Bind(&count_ok); 1576 __ Bind(&count_ok);
1583 ASSERT(right == ECX); // Count must be in ECX 1577 ASSERT(right == ECX); // Count must be in ECX
1584 __ SmiUntag(left); 1578 __ SmiUntag(left);
1585 __ sarl(left, right); 1579 __ sarl(left, right);
1586 __ SmiTag(left); 1580 __ SmiTag(left);
1587 break; 1581 break;
1588 } 1582 }
1589 case Token::kSHL: { 1583 case Token::kSHL: {
1590 Label call_method, done; 1584 Label call_method, done;
1591 // Check if count too large for handling it inlined. 1585 // Check if count too large for handling it inlined.
1586 __ movl(temp, left);
1592 __ cmpl(right, 1587 __ cmpl(right,
1593 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits)))); 1588 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits))));
1594 __ j(ABOVE_EQUAL, &call_method, Assembler::kNearJump); 1589 __ j(ABOVE_EQUAL, &call_method, Assembler::kNearJump);
1595 Register right_temp = comp->locs()->temp(1).reg(); 1590 Register right_temp = comp->locs()->temp(1).reg();
1596 ASSERT(right_temp == ECX); // Count must be in ECX 1591 ASSERT(right_temp == ECX); // Count must be in ECX
1597 __ movl(right_temp, right); 1592 __ movl(right_temp, right);
1598 __ SmiUntag(right_temp); 1593 __ SmiUntag(right_temp);
1599 // Overflow test (preserve temp and right); 1594 // Overflow test (preserve temp and right);
1600 __ shll(left, right_temp); 1595 __ shll(left, right_temp);
1601 __ sarl(left, right_temp); 1596 __ sarl(left, right_temp);
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 } 2205 }
2211 } 2206 }
2212 __ Bind(&is_ok); 2207 __ Bind(&is_ok);
2213 } 2208 }
2214 2209
2215 } // namespace dart 2210 } // namespace dart
2216 2211
2217 #undef __ 2212 #undef __
2218 2213
2219 #endif // defined TARGET_ARCH_X64 2214 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698