OLD | NEW |
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 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 isolate->set_fp_stubs_generated(true); | 1599 isolate->set_fp_stubs_generated(true); |
1600 } | 1600 } |
1601 | 1601 |
1602 | 1602 |
1603 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 1603 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
1604 CEntryStub stub(1, kDontSaveFPRegs); | 1604 CEntryStub stub(1, kDontSaveFPRegs); |
1605 stub.GetCode(isolate); | 1605 stub.GetCode(isolate); |
1606 } | 1606 } |
1607 | 1607 |
1608 | 1608 |
| 1609 static void JumpIfOOM(MacroAssembler* masm, |
| 1610 Register value, |
| 1611 Register scratch, |
| 1612 Label* oom_label) { |
| 1613 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3); |
| 1614 STATIC_ASSERT(kFailureTag == 3); |
| 1615 __ andi(scratch, value, 0xf); |
| 1616 __ Branch(oom_label, eq, scratch, Operand(0xf)); |
| 1617 } |
| 1618 |
| 1619 |
1609 void CEntryStub::GenerateCore(MacroAssembler* masm, | 1620 void CEntryStub::GenerateCore(MacroAssembler* masm, |
1610 Label* throw_normal_exception, | 1621 Label* throw_normal_exception, |
1611 Label* throw_termination_exception, | 1622 Label* throw_termination_exception, |
| 1623 Label* throw_out_of_memory_exception, |
1612 bool do_gc, | 1624 bool do_gc, |
1613 bool always_allocate) { | 1625 bool always_allocate) { |
1614 // v0: result parameter for PerformGC, if any | 1626 // v0: result parameter for PerformGC, if any |
1615 // s0: number of arguments including receiver (C callee-saved) | 1627 // s0: number of arguments including receiver (C callee-saved) |
1616 // s1: pointer to the first argument (C callee-saved) | 1628 // s1: pointer to the first argument (C callee-saved) |
1617 // s2: pointer to builtin function (C callee-saved) | 1629 // s2: pointer to builtin function (C callee-saved) |
1618 | 1630 |
1619 Isolate* isolate = masm->isolate(); | 1631 Isolate* isolate = masm->isolate(); |
1620 | 1632 |
1621 if (do_gc) { | 1633 if (do_gc) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 // fp: frame pointer | 1716 // fp: frame pointer |
1705 __ LeaveExitFrame(save_doubles_, s0, true, EMIT_RETURN); | 1717 __ LeaveExitFrame(save_doubles_, s0, true, EMIT_RETURN); |
1706 | 1718 |
1707 // Check if we should retry or throw exception. | 1719 // Check if we should retry or throw exception. |
1708 Label retry; | 1720 Label retry; |
1709 __ bind(&failure_returned); | 1721 __ bind(&failure_returned); |
1710 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 1722 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
1711 __ andi(t0, v0, ((1 << kFailureTypeTagSize) - 1) << kFailureTagSize); | 1723 __ andi(t0, v0, ((1 << kFailureTypeTagSize) - 1) << kFailureTagSize); |
1712 __ Branch(&retry, eq, t0, Operand(zero_reg)); | 1724 __ Branch(&retry, eq, t0, Operand(zero_reg)); |
1713 | 1725 |
| 1726 // Special handling of out of memory exceptions. |
| 1727 JumpIfOOM(masm, v0, t0, throw_out_of_memory_exception); |
| 1728 |
1714 // Retrieve the pending exception. | 1729 // Retrieve the pending exception. |
1715 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1730 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1716 isolate))); | 1731 isolate))); |
1717 __ lw(v0, MemOperand(t0)); | 1732 __ lw(v0, MemOperand(t0)); |
1718 | 1733 |
| 1734 // See if we just retrieved an OOM exception. |
| 1735 JumpIfOOM(masm, v0, t0, throw_out_of_memory_exception); |
| 1736 |
1719 // Clear the pending exception. | 1737 // Clear the pending exception. |
1720 __ li(a3, Operand(isolate->factory()->the_hole_value())); | 1738 __ li(a3, Operand(isolate->factory()->the_hole_value())); |
1721 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1739 __ li(t0, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1722 isolate))); | 1740 isolate))); |
1723 __ sw(a3, MemOperand(t0)); | 1741 __ sw(a3, MemOperand(t0)); |
1724 | 1742 |
1725 // Special handling of termination exceptions which are uncatchable | 1743 // Special handling of termination exceptions which are uncatchable |
1726 // by javascript code. | 1744 // by javascript code. |
1727 __ LoadRoot(t0, Heap::kTerminationExceptionRootIndex); | 1745 __ LoadRoot(t0, Heap::kTerminationExceptionRootIndex); |
1728 __ Branch(throw_termination_exception, eq, v0, Operand(t0)); | 1746 __ Branch(throw_termination_exception, eq, v0, Operand(t0)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 // Enter the exit frame that transitions from JavaScript to C++. | 1780 // Enter the exit frame that transitions from JavaScript to C++. |
1763 FrameScope scope(masm, StackFrame::MANUAL); | 1781 FrameScope scope(masm, StackFrame::MANUAL); |
1764 __ EnterExitFrame(save_doubles_); | 1782 __ EnterExitFrame(save_doubles_); |
1765 | 1783 |
1766 // s0: number of arguments (C callee-saved) | 1784 // s0: number of arguments (C callee-saved) |
1767 // s1: pointer to first argument (C callee-saved) | 1785 // s1: pointer to first argument (C callee-saved) |
1768 // s2: pointer to builtin function (C callee-saved) | 1786 // s2: pointer to builtin function (C callee-saved) |
1769 | 1787 |
1770 Label throw_normal_exception; | 1788 Label throw_normal_exception; |
1771 Label throw_termination_exception; | 1789 Label throw_termination_exception; |
| 1790 Label throw_out_of_memory_exception; |
1772 | 1791 |
1773 // Call into the runtime system. | 1792 // Call into the runtime system. |
1774 GenerateCore(masm, | 1793 GenerateCore(masm, |
1775 &throw_normal_exception, | 1794 &throw_normal_exception, |
1776 &throw_termination_exception, | 1795 &throw_termination_exception, |
| 1796 &throw_out_of_memory_exception, |
1777 false, | 1797 false, |
1778 false); | 1798 false); |
1779 | 1799 |
1780 // Do space-specific GC and retry runtime call. | 1800 // Do space-specific GC and retry runtime call. |
1781 GenerateCore(masm, | 1801 GenerateCore(masm, |
1782 &throw_normal_exception, | 1802 &throw_normal_exception, |
1783 &throw_termination_exception, | 1803 &throw_termination_exception, |
| 1804 &throw_out_of_memory_exception, |
1784 true, | 1805 true, |
1785 false); | 1806 false); |
1786 | 1807 |
1787 // Do full GC and retry runtime call one final time. | 1808 // Do full GC and retry runtime call one final time. |
1788 Failure* failure = Failure::InternalError(); | 1809 Failure* failure = Failure::InternalError(); |
1789 __ li(v0, Operand(reinterpret_cast<int32_t>(failure))); | 1810 __ li(v0, Operand(reinterpret_cast<int32_t>(failure))); |
1790 GenerateCore(masm, | 1811 GenerateCore(masm, |
1791 &throw_normal_exception, | 1812 &throw_normal_exception, |
1792 &throw_termination_exception, | 1813 &throw_termination_exception, |
| 1814 &throw_out_of_memory_exception, |
1793 true, | 1815 true, |
1794 true); | 1816 true); |
1795 | 1817 |
| 1818 __ bind(&throw_out_of_memory_exception); |
| 1819 // Set external caught exception to false. |
| 1820 Isolate* isolate = masm->isolate(); |
| 1821 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
| 1822 isolate); |
| 1823 __ li(a0, Operand(false, RelocInfo::NONE32)); |
| 1824 __ li(a2, Operand(external_caught)); |
| 1825 __ sw(a0, MemOperand(a2)); |
| 1826 |
| 1827 // Set pending exception and v0 to out of memory exception. |
| 1828 Label already_have_failure; |
| 1829 JumpIfOOM(masm, v0, t0, &already_have_failure); |
| 1830 Failure* out_of_memory = Failure::OutOfMemoryException(0x1); |
| 1831 __ li(v0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
| 1832 __ bind(&already_have_failure); |
| 1833 __ li(a2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 1834 isolate))); |
| 1835 __ sw(v0, MemOperand(a2)); |
| 1836 // Fall through to the next label. |
| 1837 |
1796 __ bind(&throw_termination_exception); | 1838 __ bind(&throw_termination_exception); |
1797 __ ThrowUncatchable(v0); | 1839 __ ThrowUncatchable(v0); |
1798 | 1840 |
1799 __ bind(&throw_normal_exception); | 1841 __ bind(&throw_normal_exception); |
1800 __ Throw(v0); | 1842 __ Throw(v0); |
1801 } | 1843 } |
1802 | 1844 |
1803 | 1845 |
1804 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 1846 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
1805 Label invoke, handler_entry, exit; | 1847 Label invoke, handler_entry, exit; |
(...skipping 3831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5637 MemOperand(fp, 6 * kPointerSize), | 5679 MemOperand(fp, 6 * kPointerSize), |
5638 NULL); | 5680 NULL); |
5639 } | 5681 } |
5640 | 5682 |
5641 | 5683 |
5642 #undef __ | 5684 #undef __ |
5643 | 5685 |
5644 } } // namespace v8::internal | 5686 } } // namespace v8::internal |
5645 | 5687 |
5646 #endif // V8_TARGET_ARCH_MIPS | 5688 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |