OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } else if (r.IsSmi()) { | 394 } else if (r.IsSmi()) { |
395 ASSERT(constant->HasSmiValue()); | 395 ASSERT(constant->HasSmiValue()); |
396 __ li(scratch, Operand(Smi::FromInt(constant->Integer32Value()))); | 396 __ li(scratch, Operand(Smi::FromInt(constant->Integer32Value()))); |
397 } else if (r.IsDouble()) { | 397 } else if (r.IsDouble()) { |
398 Abort(kEmitLoadRegisterUnsupportedDoubleImmediate); | 398 Abort(kEmitLoadRegisterUnsupportedDoubleImmediate); |
399 } else { | 399 } else { |
400 ASSERT(r.IsSmiOrTagged()); | 400 ASSERT(r.IsSmiOrTagged()); |
401 __ li(scratch, literal); | 401 __ li(scratch, literal); |
402 } | 402 } |
403 return scratch; | 403 return scratch; |
404 } else if (op->IsStackSlot() || op->IsArgument()) { | 404 } else if (op->IsStackSlot()) { |
405 __ lw(scratch, ToMemOperand(op)); | 405 __ lw(scratch, ToMemOperand(op)); |
406 return scratch; | 406 return scratch; |
407 } | 407 } |
408 UNREACHABLE(); | 408 UNREACHABLE(); |
409 return scratch; | 409 return scratch; |
410 } | 410 } |
411 | 411 |
412 | 412 |
413 DoubleRegister LCodeGen::ToDoubleRegister(LOperand* op) const { | 413 DoubleRegister LCodeGen::ToDoubleRegister(LOperand* op) const { |
414 ASSERT(op->IsDoubleRegister()); | 414 ASSERT(op->IsDoubleRegister()); |
(...skipping 15 matching lines...) Expand all Loading... |
430 ASSERT(literal->IsNumber()); | 430 ASSERT(literal->IsNumber()); |
431 __ li(at, Operand(static_cast<int32_t>(literal->Number()))); | 431 __ li(at, Operand(static_cast<int32_t>(literal->Number()))); |
432 __ mtc1(at, flt_scratch); | 432 __ mtc1(at, flt_scratch); |
433 __ cvt_d_w(dbl_scratch, flt_scratch); | 433 __ cvt_d_w(dbl_scratch, flt_scratch); |
434 return dbl_scratch; | 434 return dbl_scratch; |
435 } else if (r.IsDouble()) { | 435 } else if (r.IsDouble()) { |
436 Abort(kUnsupportedDoubleImmediate); | 436 Abort(kUnsupportedDoubleImmediate); |
437 } else if (r.IsTagged()) { | 437 } else if (r.IsTagged()) { |
438 Abort(kUnsupportedTaggedImmediate); | 438 Abort(kUnsupportedTaggedImmediate); |
439 } | 439 } |
440 } else if (op->IsStackSlot() || op->IsArgument()) { | 440 } else if (op->IsStackSlot()) { |
441 MemOperand mem_op = ToMemOperand(op); | 441 MemOperand mem_op = ToMemOperand(op); |
442 __ ldc1(dbl_scratch, mem_op); | 442 __ ldc1(dbl_scratch, mem_op); |
443 return dbl_scratch; | 443 return dbl_scratch; |
444 } | 444 } |
445 UNREACHABLE(); | 445 UNREACHABLE(); |
446 return dbl_scratch; | 446 return dbl_scratch; |
447 } | 447 } |
448 | 448 |
449 | 449 |
450 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { | 450 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (op->IsStackSlot()) { | 648 if (op->IsStackSlot()) { |
649 if (is_tagged) { | 649 if (is_tagged) { |
650 translation->StoreStackSlot(op->index()); | 650 translation->StoreStackSlot(op->index()); |
651 } else if (is_uint32) { | 651 } else if (is_uint32) { |
652 translation->StoreUint32StackSlot(op->index()); | 652 translation->StoreUint32StackSlot(op->index()); |
653 } else { | 653 } else { |
654 translation->StoreInt32StackSlot(op->index()); | 654 translation->StoreInt32StackSlot(op->index()); |
655 } | 655 } |
656 } else if (op->IsDoubleStackSlot()) { | 656 } else if (op->IsDoubleStackSlot()) { |
657 translation->StoreDoubleStackSlot(op->index()); | 657 translation->StoreDoubleStackSlot(op->index()); |
658 } else if (op->IsArgument()) { | |
659 ASSERT(is_tagged); | |
660 int src_index = GetStackSlotCount() + op->index(); | |
661 translation->StoreStackSlot(src_index); | |
662 } else if (op->IsRegister()) { | 658 } else if (op->IsRegister()) { |
663 Register reg = ToRegister(op); | 659 Register reg = ToRegister(op); |
664 if (is_tagged) { | 660 if (is_tagged) { |
665 translation->StoreRegister(reg); | 661 translation->StoreRegister(reg); |
666 } else if (is_uint32) { | 662 } else if (is_uint32) { |
667 translation->StoreUint32Register(reg); | 663 translation->StoreUint32Register(reg); |
668 } else { | 664 } else { |
669 translation->StoreInt32Register(reg); | 665 translation->StoreInt32Register(reg); |
670 } | 666 } |
671 } else if (op->IsDoubleRegister()) { | 667 } else if (op->IsDoubleRegister()) { |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1456 |
1461 | 1457 |
1462 void LCodeGen::DoBitI(LBitI* instr) { | 1458 void LCodeGen::DoBitI(LBitI* instr) { |
1463 LOperand* left_op = instr->left(); | 1459 LOperand* left_op = instr->left(); |
1464 LOperand* right_op = instr->right(); | 1460 LOperand* right_op = instr->right(); |
1465 ASSERT(left_op->IsRegister()); | 1461 ASSERT(left_op->IsRegister()); |
1466 Register left = ToRegister(left_op); | 1462 Register left = ToRegister(left_op); |
1467 Register result = ToRegister(instr->result()); | 1463 Register result = ToRegister(instr->result()); |
1468 Operand right(no_reg); | 1464 Operand right(no_reg); |
1469 | 1465 |
1470 if (right_op->IsStackSlot() || right_op->IsArgument()) { | 1466 if (right_op->IsStackSlot()) { |
1471 right = Operand(EmitLoadRegister(right_op, at)); | 1467 right = Operand(EmitLoadRegister(right_op, at)); |
1472 } else { | 1468 } else { |
1473 ASSERT(right_op->IsRegister() || right_op->IsConstantOperand()); | 1469 ASSERT(right_op->IsRegister() || right_op->IsConstantOperand()); |
1474 right = ToOperand(right_op); | 1470 right = ToOperand(right_op); |
1475 } | 1471 } |
1476 | 1472 |
1477 switch (instr->op()) { | 1473 switch (instr->op()) { |
1478 case Token::BIT_AND: | 1474 case Token::BIT_AND: |
1479 __ And(result, left, right); | 1475 __ And(result, left, right); |
1480 break; | 1476 break; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 } | 1578 } |
1583 | 1579 |
1584 | 1580 |
1585 void LCodeGen::DoSubI(LSubI* instr) { | 1581 void LCodeGen::DoSubI(LSubI* instr) { |
1586 LOperand* left = instr->left(); | 1582 LOperand* left = instr->left(); |
1587 LOperand* right = instr->right(); | 1583 LOperand* right = instr->right(); |
1588 LOperand* result = instr->result(); | 1584 LOperand* result = instr->result(); |
1589 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); | 1585 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
1590 | 1586 |
1591 if (!can_overflow) { | 1587 if (!can_overflow) { |
1592 if (right->IsStackSlot() || right->IsArgument()) { | 1588 if (right->IsStackSlot()) { |
1593 Register right_reg = EmitLoadRegister(right, at); | 1589 Register right_reg = EmitLoadRegister(right, at); |
1594 __ Subu(ToRegister(result), ToRegister(left), Operand(right_reg)); | 1590 __ Subu(ToRegister(result), ToRegister(left), Operand(right_reg)); |
1595 } else { | 1591 } else { |
1596 ASSERT(right->IsRegister() || right->IsConstantOperand()); | 1592 ASSERT(right->IsRegister() || right->IsConstantOperand()); |
1597 __ Subu(ToRegister(result), ToRegister(left), ToOperand(right)); | 1593 __ Subu(ToRegister(result), ToRegister(left), ToOperand(right)); |
1598 } | 1594 } |
1599 } else { // can_overflow. | 1595 } else { // can_overflow. |
1600 Register overflow = scratch0(); | 1596 Register overflow = scratch0(); |
1601 Register scratch = scratch1(); | 1597 Register scratch = scratch1(); |
1602 if (right->IsStackSlot() || | 1598 if (right->IsStackSlot() || right->IsConstantOperand()) { |
1603 right->IsArgument() || | |
1604 right->IsConstantOperand()) { | |
1605 Register right_reg = EmitLoadRegister(right, scratch); | 1599 Register right_reg = EmitLoadRegister(right, scratch); |
1606 __ SubuAndCheckForOverflow(ToRegister(result), | 1600 __ SubuAndCheckForOverflow(ToRegister(result), |
1607 ToRegister(left), | 1601 ToRegister(left), |
1608 right_reg, | 1602 right_reg, |
1609 overflow); // Reg at also used as scratch. | 1603 overflow); // Reg at also used as scratch. |
1610 } else { | 1604 } else { |
1611 ASSERT(right->IsRegister()); | 1605 ASSERT(right->IsRegister()); |
1612 // Due to overflow check macros not supporting constant operands, | 1606 // Due to overflow check macros not supporting constant operands, |
1613 // handling the IsConstantOperand case was moved to prev if clause. | 1607 // handling the IsConstantOperand case was moved to prev if clause. |
1614 __ SubuAndCheckForOverflow(ToRegister(result), | 1608 __ SubuAndCheckForOverflow(ToRegister(result), |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 } | 1768 } |
1775 | 1769 |
1776 | 1770 |
1777 void LCodeGen::DoAddI(LAddI* instr) { | 1771 void LCodeGen::DoAddI(LAddI* instr) { |
1778 LOperand* left = instr->left(); | 1772 LOperand* left = instr->left(); |
1779 LOperand* right = instr->right(); | 1773 LOperand* right = instr->right(); |
1780 LOperand* result = instr->result(); | 1774 LOperand* result = instr->result(); |
1781 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); | 1775 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
1782 | 1776 |
1783 if (!can_overflow) { | 1777 if (!can_overflow) { |
1784 if (right->IsStackSlot() || right->IsArgument()) { | 1778 if (right->IsStackSlot()) { |
1785 Register right_reg = EmitLoadRegister(right, at); | 1779 Register right_reg = EmitLoadRegister(right, at); |
1786 __ Addu(ToRegister(result), ToRegister(left), Operand(right_reg)); | 1780 __ Addu(ToRegister(result), ToRegister(left), Operand(right_reg)); |
1787 } else { | 1781 } else { |
1788 ASSERT(right->IsRegister() || right->IsConstantOperand()); | 1782 ASSERT(right->IsRegister() || right->IsConstantOperand()); |
1789 __ Addu(ToRegister(result), ToRegister(left), ToOperand(right)); | 1783 __ Addu(ToRegister(result), ToRegister(left), ToOperand(right)); |
1790 } | 1784 } |
1791 } else { // can_overflow. | 1785 } else { // can_overflow. |
1792 Register overflow = scratch0(); | 1786 Register overflow = scratch0(); |
1793 Register scratch = scratch1(); | 1787 Register scratch = scratch1(); |
1794 if (right->IsStackSlot() || | 1788 if (right->IsStackSlot() || |
1795 right->IsArgument() || | |
1796 right->IsConstantOperand()) { | 1789 right->IsConstantOperand()) { |
1797 Register right_reg = EmitLoadRegister(right, scratch); | 1790 Register right_reg = EmitLoadRegister(right, scratch); |
1798 __ AdduAndCheckForOverflow(ToRegister(result), | 1791 __ AdduAndCheckForOverflow(ToRegister(result), |
1799 ToRegister(left), | 1792 ToRegister(left), |
1800 right_reg, | 1793 right_reg, |
1801 overflow); // Reg at also used as scratch. | 1794 overflow); // Reg at also used as scratch. |
1802 } else { | 1795 } else { |
1803 ASSERT(right->IsRegister()); | 1796 ASSERT(right->IsRegister()); |
1804 // Due to overflow check macros not supporting constant operands, | 1797 // Due to overflow check macros not supporting constant operands, |
1805 // handling the IsConstantOperand case was moved to prev if clause. | 1798 // handling the IsConstantOperand case was moved to prev if clause. |
(...skipping 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5753 __ Subu(scratch, result, scratch); | 5746 __ Subu(scratch, result, scratch); |
5754 __ lw(result, FieldMemOperand(scratch, | 5747 __ lw(result, FieldMemOperand(scratch, |
5755 FixedArray::kHeaderSize - kPointerSize)); | 5748 FixedArray::kHeaderSize - kPointerSize)); |
5756 __ bind(&done); | 5749 __ bind(&done); |
5757 } | 5750 } |
5758 | 5751 |
5759 | 5752 |
5760 #undef __ | 5753 #undef __ |
5761 | 5754 |
5762 } } // namespace v8::internal | 5755 } } // namespace v8::internal |
OLD | NEW |