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

Side by Side Diff: src/mips/lithium-mips.cc

Issue 153913002: A64: Synchronize with r16756. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | « src/mips/lithium-mips.h ('k') | src/mips/stub-cache-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 } 708 }
709 709
710 710
711 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { 711 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
712 return AssignEnvironment(new(zone()) LDeoptimize); 712 return AssignEnvironment(new(zone()) LDeoptimize);
713 } 713 }
714 714
715 715
716 LInstruction* LChunkBuilder::DoShift(Token::Value op, 716 LInstruction* LChunkBuilder::DoShift(Token::Value op,
717 HBitwiseBinaryOperation* instr) { 717 HBitwiseBinaryOperation* instr) {
718 if (instr->representation().IsTagged()) { 718 if (instr->representation().IsSmiOrInteger32()) {
719 ASSERT(instr->left()->representation().IsTagged()); 719 ASSERT(instr->left()->representation().Equals(instr->representation()));
720 ASSERT(instr->right()->representation().IsTagged()); 720 ASSERT(instr->right()->representation().Equals(instr->representation()));
721 LOperand* left = UseRegisterAtStart(instr->left());
721 722
722 LOperand* left = UseFixed(instr->left(), a1); 723 HValue* right_value = instr->right();
723 LOperand* right = UseFixed(instr->right(), a0); 724 LOperand* right = NULL;
724 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); 725 int constant_value = 0;
725 return MarkAsCall(DefineFixed(result, v0), instr); 726 bool does_deopt = false;
727 if (right_value->IsConstant()) {
728 HConstant* constant = HConstant::cast(right_value);
729 right = chunk_->DefineConstantOperand(constant);
730 constant_value = constant->Integer32Value() & 0x1f;
731 // Left shifts can deoptimize if we shift by > 0 and the result cannot be
732 // truncated to smi.
733 if (instr->representation().IsSmi() && constant_value > 0) {
734 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
735 }
736 } else {
737 right = UseRegisterAtStart(right_value);
738 }
739
740 // Shift operations can only deoptimize if we do a logical shift
741 // by 0 and the result cannot be truncated to int32.
742 if (op == Token::SHR && constant_value == 0) {
743 if (FLAG_opt_safe_uint32_operations) {
744 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
745 } else {
746 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
747 }
748 }
749
750 LInstruction* result =
751 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt));
752 return does_deopt ? AssignEnvironment(result) : result;
753 } else {
754 return DoArithmeticT(op, instr);
726 } 755 }
727
728 ASSERT(instr->representation().IsSmiOrInteger32());
729 ASSERT(instr->left()->representation().Equals(instr->representation()));
730 ASSERT(instr->right()->representation().Equals(instr->representation()));
731 LOperand* left = UseRegisterAtStart(instr->left());
732
733 HValue* right_value = instr->right();
734 LOperand* right = NULL;
735 int constant_value = 0;
736 bool does_deopt = false;
737 if (right_value->IsConstant()) {
738 HConstant* constant = HConstant::cast(right_value);
739 right = chunk_->DefineConstantOperand(constant);
740 constant_value = constant->Integer32Value() & 0x1f;
741 // Left shifts can deoptimize if we shift by > 0 and the result cannot be
742 // truncated to smi.
743 if (instr->representation().IsSmi() && constant_value > 0) {
744 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
745 }
746 } else {
747 right = UseRegisterAtStart(right_value);
748 }
749
750 // Shift operations can deoptimize if we do a logical shift
751 // by 0 and the result cannot be truncated to int32.
752 if (op == Token::SHR && constant_value == 0) {
753 if (FLAG_opt_safe_uint32_operations) {
754 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
755 } else {
756 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
757 }
758 }
759
760 LInstruction* result =
761 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt));
762 return does_deopt ? AssignEnvironment(result) : result;
763 } 756 }
764 757
765 758
766 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, 759 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
767 HArithmeticBinaryOperation* instr) { 760 HArithmeticBinaryOperation* instr) {
768 ASSERT(instr->representation().IsDouble()); 761 ASSERT(instr->representation().IsDouble());
769 ASSERT(instr->left()->representation().IsDouble()); 762 ASSERT(instr->left()->representation().IsDouble());
770 ASSERT(instr->right()->representation().IsDouble()); 763 ASSERT(instr->right()->representation().IsDouble());
771 ASSERT(op != Token::MOD); 764 if (op == Token::MOD) {
772 LOperand* left = UseRegisterAtStart(instr->left()); 765 LOperand* left = UseFixedDouble(instr->left(), f2);
773 LOperand* right = UseRegisterAtStart(instr->right()); 766 LOperand* right = UseFixedDouble(instr->right(), f4);
774 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); 767 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
775 return DefineAsRegister(result); 768 // We call a C function for double modulo. It can't trigger a GC. We need
769 // to use fixed result register for the call.
770 // TODO(fschneider): Allow any register as input registers.
771 return MarkAsCall(DefineFixedDouble(result, f2), instr);
772 } else {
773 LOperand* left = UseRegisterAtStart(instr->left());
774 LOperand* right = UseRegisterAtStart(instr->right());
775 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
776 return DefineAsRegister(result);
777 }
776 } 778 }
777 779
778 780
779 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, 781 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op,
780 HArithmeticBinaryOperation* instr) { 782 HBinaryOperation* instr) {
781 ASSERT(op == Token::ADD ||
782 op == Token::DIV ||
783 op == Token::MOD ||
784 op == Token::MUL ||
785 op == Token::SUB);
786 HValue* left = instr->left(); 783 HValue* left = instr->left();
787 HValue* right = instr->right(); 784 HValue* right = instr->right();
788 ASSERT(left->representation().IsTagged()); 785 ASSERT(left->representation().IsTagged());
789 ASSERT(right->representation().IsTagged()); 786 ASSERT(right->representation().IsTagged());
790 LOperand* left_operand = UseFixed(left, a1); 787 LOperand* left_operand = UseFixed(left, a1);
791 LOperand* right_operand = UseFixed(right, a0); 788 LOperand* right_operand = UseFixed(right, a0);
792 LArithmeticT* result = 789 LArithmeticT* result =
793 new(zone()) LArithmeticT(op, left_operand, right_operand); 790 new(zone()) LArithmeticT(op, left_operand, right_operand);
794 return MarkAsCall(DefineFixed(result, v0), instr); 791 return MarkAsCall(DefineFixed(result, v0), instr);
795 } 792 }
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 1339
1343 LInstruction* LChunkBuilder::DoShl(HShl* instr) { 1340 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1344 return DoShift(Token::SHL, instr); 1341 return DoShift(Token::SHL, instr);
1345 } 1342 }
1346 1343
1347 1344
1348 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { 1345 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1349 if (instr->representation().IsSmiOrInteger32()) { 1346 if (instr->representation().IsSmiOrInteger32()) {
1350 ASSERT(instr->left()->representation().Equals(instr->representation())); 1347 ASSERT(instr->left()->representation().Equals(instr->representation()));
1351 ASSERT(instr->right()->representation().Equals(instr->representation())); 1348 ASSERT(instr->right()->representation().Equals(instr->representation()));
1349 ASSERT(instr->CheckFlag(HValue::kTruncatingToInt32));
1352 1350
1353 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); 1351 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1354 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); 1352 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1355 return DefineAsRegister(new(zone()) LBitI(left, right)); 1353 return DefineAsRegister(new(zone()) LBitI(left, right));
1356 } else { 1354 } else {
1357 ASSERT(instr->representation().IsTagged()); 1355 return DoArithmeticT(instr->op(), instr);
1358 ASSERT(instr->left()->representation().IsTagged());
1359 ASSERT(instr->right()->representation().IsTagged());
1360
1361 LOperand* left = UseFixed(instr->left(), a1);
1362 LOperand* right = UseFixed(instr->right(), a0);
1363 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right);
1364 return MarkAsCall(DefineFixed(result, v0), instr);
1365 } 1356 }
1366 } 1357 }
1367 1358
1368 1359
1369 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { 1360 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1370 if (instr->representation().IsDouble()) { 1361 if (instr->representation().IsSmiOrInteger32()) {
1371 return DoArithmeticD(Token::DIV, instr);
1372 } else if (instr->representation().IsSmiOrInteger32()) {
1373 ASSERT(instr->left()->representation().Equals(instr->representation())); 1362 ASSERT(instr->left()->representation().Equals(instr->representation()));
1374 ASSERT(instr->right()->representation().Equals(instr->representation())); 1363 ASSERT(instr->right()->representation().Equals(instr->representation()));
1375 LOperand* dividend = UseRegister(instr->left()); 1364 LOperand* dividend = UseRegister(instr->left());
1376 LOperand* divisor = UseRegister(instr->right()); 1365 LOperand* divisor = UseRegister(instr->right());
1377 LDivI* div = new(zone()) LDivI(dividend, divisor); 1366 LDivI* div = new(zone()) LDivI(dividend, divisor);
1378 return AssignEnvironment(DefineAsRegister(div)); 1367 return AssignEnvironment(DefineAsRegister(div));
1368 } else if (instr->representation().IsDouble()) {
1369 return DoArithmeticD(Token::DIV, instr);
1379 } else { 1370 } else {
1380 return DoArithmeticT(Token::DIV, instr); 1371 return DoArithmeticT(Token::DIV, instr);
1381 } 1372 }
1382 } 1373 }
1383 1374
1384 1375
1385 bool LChunkBuilder::HasMagicNumberForDivisor(int32_t divisor) { 1376 bool LChunkBuilder::HasMagicNumberForDivisor(int32_t divisor) {
1386 uint32_t divisor_abs = abs(divisor); 1377 uint32_t divisor_abs = abs(divisor);
1387 // Dividing by 0, 1, and powers of 2 is easy. 1378 // Dividing by 0, 1, and powers of 2 is easy.
1388 // Note that IsPowerOf2(0) returns true; 1379 // Note that IsPowerOf2(0) returns true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 FixedTemp(f20), 1450 FixedTemp(f20),
1460 FixedTemp(f22)); 1451 FixedTemp(f22));
1461 LInstruction* result = DefineAsRegister(mod); 1452 LInstruction* result = DefineAsRegister(mod);
1462 return (right->CanBeZero() || 1453 return (right->CanBeZero() ||
1463 (left->RangeCanInclude(kMinInt) && 1454 (left->RangeCanInclude(kMinInt) &&
1464 right->RangeCanInclude(-1)) || 1455 right->RangeCanInclude(-1)) ||
1465 instr->CheckFlag(HValue::kBailoutOnMinusZero)) 1456 instr->CheckFlag(HValue::kBailoutOnMinusZero))
1466 ? AssignEnvironment(result) 1457 ? AssignEnvironment(result)
1467 : result; 1458 : result;
1468 } 1459 }
1469 } else if (instr->representation().IsTagged()) { 1460 } else if (instr->representation().IsDouble()) {
1461 return DoArithmeticD(Token::MOD, instr);
1462 } else {
1470 return DoArithmeticT(Token::MOD, instr); 1463 return DoArithmeticT(Token::MOD, instr);
1471 } else {
1472 ASSERT(instr->representation().IsDouble());
1473 // We call a C function for double modulo. It can't trigger a GC. We need
1474 // to use fixed result register for the call.
1475 // TODO(fschneider): Allow any register as input registers.
1476 LArithmeticD* mod = new(zone()) LArithmeticD(Token::MOD,
1477 UseFixedDouble(left, f2),
1478 UseFixedDouble(right, f4));
1479 return MarkAsCall(DefineFixedDouble(mod, f2), instr);
1480 } 1464 }
1481 } 1465 }
1482 1466
1483 1467
1484 LInstruction* LChunkBuilder::DoMul(HMul* instr) { 1468 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1485 if (instr->representation().IsSmiOrInteger32()) { 1469 if (instr->representation().IsSmiOrInteger32()) {
1486 ASSERT(instr->left()->representation().Equals(instr->representation())); 1470 ASSERT(instr->left()->representation().Equals(instr->representation()));
1487 ASSERT(instr->right()->representation().Equals(instr->representation())); 1471 ASSERT(instr->right()->representation().Equals(instr->representation()));
1488 LOperand* left; 1472 LOperand* left;
1489 LOperand* right = UseOrConstant(instr->BetterRightOperand()); 1473 LOperand* right = UseOrConstant(instr->BetterRightOperand());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 if (instr->left()->IsMul()) 1556 if (instr->left()->IsMul())
1573 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right()); 1557 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1574 1558
1575 if (instr->right()->IsMul()) { 1559 if (instr->right()->IsMul()) {
1576 ASSERT(!instr->left()->IsMul()); 1560 ASSERT(!instr->left()->IsMul());
1577 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left()); 1561 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1578 } 1562 }
1579 } 1563 }
1580 return DoArithmeticD(Token::ADD, instr); 1564 return DoArithmeticD(Token::ADD, instr);
1581 } else { 1565 } else {
1582 ASSERT(instr->representation().IsTagged());
1583 return DoArithmeticT(Token::ADD, instr); 1566 return DoArithmeticT(Token::ADD, instr);
1584 } 1567 }
1585 } 1568 }
1586 1569
1587 1570
1588 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { 1571 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1589 LOperand* left = NULL; 1572 LOperand* left = NULL;
1590 LOperand* right = NULL; 1573 LOperand* right = NULL;
1591 if (instr->representation().IsSmiOrInteger32()) { 1574 if (instr->representation().IsSmiOrInteger32()) {
1592 ASSERT(instr->left()->representation().Equals(instr->representation())); 1575 ASSERT(instr->left()->representation().Equals(instr->representation()));
(...skipping 24 matching lines...) Expand all
1617 LPower* result = new(zone()) LPower(left, right); 1600 LPower* result = new(zone()) LPower(left, right);
1618 return MarkAsCall(DefineFixedDouble(result, f0), 1601 return MarkAsCall(DefineFixedDouble(result, f0),
1619 instr, 1602 instr,
1620 CAN_DEOPTIMIZE_EAGERLY); 1603 CAN_DEOPTIMIZE_EAGERLY);
1621 } 1604 }
1622 1605
1623 1606
1624 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) { 1607 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) {
1625 ASSERT(instr->representation().IsDouble()); 1608 ASSERT(instr->representation().IsDouble());
1626 ASSERT(instr->global_object()->representation().IsTagged()); 1609 ASSERT(instr->global_object()->representation().IsTagged());
1627 LOperand* global_object = UseFixed(instr->global_object(), a0); 1610 LOperand* global_object = UseTempRegister(instr->global_object());
1628 LRandom* result = new(zone()) LRandom(global_object); 1611 LOperand* scratch = TempRegister();
1629 return MarkAsCall(DefineFixedDouble(result, f0), instr); 1612 LOperand* scratch2 = TempRegister();
1613 LOperand* scratch3 = TempRegister();
1614 LRandom* result = new(zone()) LRandom(
1615 global_object, scratch, scratch2, scratch3);
1616 return DefineFixedDouble(result, f0);
1630 } 1617 }
1631 1618
1632 1619
1633 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { 1620 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1634 ASSERT(instr->left()->representation().IsTagged()); 1621 ASSERT(instr->left()->representation().IsTagged());
1635 ASSERT(instr->right()->representation().IsTagged()); 1622 ASSERT(instr->right()->representation().IsTagged());
1636 LOperand* left = UseFixed(instr->left(), a1); 1623 LOperand* left = UseFixed(instr->left(), a1);
1637 LOperand* right = UseFixed(instr->right(), a0); 1624 LOperand* right = UseFixed(instr->right(), a0);
1638 LCmpT* result = new(zone()) LCmpT(left, right); 1625 LCmpT* result = new(zone()) LCmpT(left, right);
1639 return MarkAsCall(DefineFixed(result, v0), instr); 1626 return MarkAsCall(DefineFixed(result, v0), instr);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { 1759 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1773 LOperand* object = UseFixed(instr->value(), a0); 1760 LOperand* object = UseFixed(instr->value(), a0);
1774 LDateField* result = 1761 LDateField* result =
1775 new(zone()) LDateField(object, FixedTemp(a1), instr->index()); 1762 new(zone()) LDateField(object, FixedTemp(a1), instr->index());
1776 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY); 1763 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
1777 } 1764 }
1778 1765
1779 1766
1780 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { 1767 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1781 LOperand* string = UseRegister(instr->string()); 1768 LOperand* string = UseRegister(instr->string());
1782 LOperand* index = UseRegister(instr->index()); 1769 LOperand* index = UseRegisterOrConstant(instr->index());
1783 LOperand* value = UseTempRegister(instr->value()); 1770 LOperand* value = UseRegister(instr->value());
1784 LSeqStringSetChar* result = 1771 return new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
1785 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
1786 return DefineAsRegister(result);
1787 } 1772 }
1788 1773
1789 1774
1790 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { 1775 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1791 LOperand* value = UseRegisterOrConstantAtStart(instr->index()); 1776 LOperand* value = UseRegisterOrConstantAtStart(instr->index());
1792 LOperand* length = UseRegister(instr->length()); 1777 LOperand* length = UseRegister(instr->length());
1793 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); 1778 return AssignEnvironment(new(zone()) LBoundsCheck(value, length));
1794 } 1779 }
1795 1780
1796 1781
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 2507
2523 2508
2524 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2509 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2525 LOperand* object = UseRegister(instr->object()); 2510 LOperand* object = UseRegister(instr->object());
2526 LOperand* index = UseRegister(instr->index()); 2511 LOperand* index = UseRegister(instr->index());
2527 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); 2512 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
2528 } 2513 }
2529 2514
2530 2515
2531 } } // namespace v8::internal 2516 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-mips.h ('k') | src/mips/stub-cache-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698