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