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 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 isolate->set_fp_stubs_generated(true); | 1494 isolate->set_fp_stubs_generated(true); |
1495 } | 1495 } |
1496 | 1496 |
1497 | 1497 |
1498 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { | 1498 void CEntryStub::GenerateAheadOfTime(Isolate* isolate) { |
1499 CEntryStub stub(1, kDontSaveFPRegs); | 1499 CEntryStub stub(1, kDontSaveFPRegs); |
1500 stub.GetCode(isolate); | 1500 stub.GetCode(isolate); |
1501 } | 1501 } |
1502 | 1502 |
1503 | 1503 |
| 1504 static void JumpIfOOM(MacroAssembler* masm, |
| 1505 Register value, |
| 1506 Register scratch, |
| 1507 Label* oom_label) { |
| 1508 STATIC_ASSERT(Failure::OUT_OF_MEMORY_EXCEPTION == 3); |
| 1509 STATIC_ASSERT(kFailureTag == 3); |
| 1510 __ and_(scratch, value, Operand(0xf)); |
| 1511 __ cmp(scratch, Operand(0xf)); |
| 1512 __ b(eq, oom_label); |
| 1513 } |
| 1514 |
| 1515 |
1504 void CEntryStub::GenerateCore(MacroAssembler* masm, | 1516 void CEntryStub::GenerateCore(MacroAssembler* masm, |
1505 Label* throw_normal_exception, | 1517 Label* throw_normal_exception, |
1506 Label* throw_termination_exception, | 1518 Label* throw_termination_exception, |
| 1519 Label* throw_out_of_memory_exception, |
1507 bool do_gc, | 1520 bool do_gc, |
1508 bool always_allocate) { | 1521 bool always_allocate) { |
1509 // r0: result parameter for PerformGC, if any | 1522 // r0: result parameter for PerformGC, if any |
1510 // r4: number of arguments including receiver (C callee-saved) | 1523 // r4: number of arguments including receiver (C callee-saved) |
1511 // r5: pointer to builtin function (C callee-saved) | 1524 // r5: pointer to builtin function (C callee-saved) |
1512 // r6: pointer to the first argument (C callee-saved) | 1525 // r6: pointer to the first argument (C callee-saved) |
1513 Isolate* isolate = masm->isolate(); | 1526 Isolate* isolate = masm->isolate(); |
1514 | 1527 |
1515 if (do_gc) { | 1528 if (do_gc) { |
1516 // Passing r0. | 1529 // Passing r0. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 __ LeaveExitFrame(save_doubles_, r4, true); | 1607 __ LeaveExitFrame(save_doubles_, r4, true); |
1595 __ mov(pc, lr); | 1608 __ mov(pc, lr); |
1596 | 1609 |
1597 // check if we should retry or throw exception | 1610 // check if we should retry or throw exception |
1598 Label retry; | 1611 Label retry; |
1599 __ bind(&failure_returned); | 1612 __ bind(&failure_returned); |
1600 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 1613 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
1601 __ tst(r0, Operand(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 1614 __ tst(r0, Operand(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
1602 __ b(eq, &retry); | 1615 __ b(eq, &retry); |
1603 | 1616 |
| 1617 // Special handling of out of memory exceptions. |
| 1618 JumpIfOOM(masm, r0, ip, throw_out_of_memory_exception); |
| 1619 |
1604 // Retrieve the pending exception. | 1620 // Retrieve the pending exception. |
1605 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1621 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1606 isolate))); | 1622 isolate))); |
1607 __ ldr(r0, MemOperand(ip)); | 1623 __ ldr(r0, MemOperand(ip)); |
1608 | 1624 |
| 1625 // See if we just retrieved an OOM exception. |
| 1626 JumpIfOOM(masm, r0, ip, throw_out_of_memory_exception); |
| 1627 |
1609 // Clear the pending exception. | 1628 // Clear the pending exception. |
1610 __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); | 1629 __ LoadRoot(r3, Heap::kTheHoleValueRootIndex); |
1611 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, | 1630 __ mov(ip, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
1612 isolate))); | 1631 isolate))); |
1613 __ str(r3, MemOperand(ip)); | 1632 __ str(r3, MemOperand(ip)); |
1614 | 1633 |
1615 // Special handling of termination exceptions which are uncatchable | 1634 // Special handling of termination exceptions which are uncatchable |
1616 // by javascript code. | 1635 // by javascript code. |
1617 __ LoadRoot(r3, Heap::kTerminationExceptionRootIndex); | 1636 __ LoadRoot(r3, Heap::kTerminationExceptionRootIndex); |
1618 __ cmp(r0, r3); | 1637 __ cmp(r0, r3); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 // Set up argc and the builtin function in callee-saved registers. | 1672 // Set up argc and the builtin function in callee-saved registers. |
1654 __ mov(r4, Operand(r0)); | 1673 __ mov(r4, Operand(r0)); |
1655 __ mov(r5, Operand(r1)); | 1674 __ mov(r5, Operand(r1)); |
1656 | 1675 |
1657 // r4: number of arguments (C callee-saved) | 1676 // r4: number of arguments (C callee-saved) |
1658 // r5: pointer to builtin function (C callee-saved) | 1677 // r5: pointer to builtin function (C callee-saved) |
1659 // r6: pointer to first argument (C callee-saved) | 1678 // r6: pointer to first argument (C callee-saved) |
1660 | 1679 |
1661 Label throw_normal_exception; | 1680 Label throw_normal_exception; |
1662 Label throw_termination_exception; | 1681 Label throw_termination_exception; |
| 1682 Label throw_out_of_memory_exception; |
1663 | 1683 |
1664 // Call into the runtime system. | 1684 // Call into the runtime system. |
1665 GenerateCore(masm, | 1685 GenerateCore(masm, |
1666 &throw_normal_exception, | 1686 &throw_normal_exception, |
1667 &throw_termination_exception, | 1687 &throw_termination_exception, |
| 1688 &throw_out_of_memory_exception, |
1668 false, | 1689 false, |
1669 false); | 1690 false); |
1670 | 1691 |
1671 // Do space-specific GC and retry runtime call. | 1692 // Do space-specific GC and retry runtime call. |
1672 GenerateCore(masm, | 1693 GenerateCore(masm, |
1673 &throw_normal_exception, | 1694 &throw_normal_exception, |
1674 &throw_termination_exception, | 1695 &throw_termination_exception, |
| 1696 &throw_out_of_memory_exception, |
1675 true, | 1697 true, |
1676 false); | 1698 false); |
1677 | 1699 |
1678 // Do full GC and retry runtime call one final time. | 1700 // Do full GC and retry runtime call one final time. |
1679 Failure* failure = Failure::InternalError(); | 1701 Failure* failure = Failure::InternalError(); |
1680 __ mov(r0, Operand(reinterpret_cast<int32_t>(failure))); | 1702 __ mov(r0, Operand(reinterpret_cast<int32_t>(failure))); |
1681 GenerateCore(masm, | 1703 GenerateCore(masm, |
1682 &throw_normal_exception, | 1704 &throw_normal_exception, |
1683 &throw_termination_exception, | 1705 &throw_termination_exception, |
| 1706 &throw_out_of_memory_exception, |
1684 true, | 1707 true, |
1685 true); | 1708 true); |
1686 | 1709 |
| 1710 __ bind(&throw_out_of_memory_exception); |
| 1711 // Set external caught exception to false. |
| 1712 Isolate* isolate = masm->isolate(); |
| 1713 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
| 1714 isolate); |
| 1715 __ mov(r0, Operand(false, RelocInfo::NONE32)); |
| 1716 __ mov(r2, Operand(external_caught)); |
| 1717 __ str(r0, MemOperand(r2)); |
| 1718 |
| 1719 // Set pending exception and r0 to out of memory exception. |
| 1720 Label already_have_failure; |
| 1721 JumpIfOOM(masm, r0, ip, &already_have_failure); |
| 1722 Failure* out_of_memory = Failure::OutOfMemoryException(0x1); |
| 1723 __ mov(r0, Operand(reinterpret_cast<int32_t>(out_of_memory))); |
| 1724 __ bind(&already_have_failure); |
| 1725 __ mov(r2, Operand(ExternalReference(Isolate::kPendingExceptionAddress, |
| 1726 isolate))); |
| 1727 __ str(r0, MemOperand(r2)); |
| 1728 // Fall through to the next label. |
| 1729 |
1687 __ bind(&throw_termination_exception); | 1730 __ bind(&throw_termination_exception); |
1688 __ ThrowUncatchable(r0); | 1731 __ ThrowUncatchable(r0); |
1689 | 1732 |
1690 __ bind(&throw_normal_exception); | 1733 __ bind(&throw_normal_exception); |
1691 __ Throw(r0); | 1734 __ Throw(r0); |
1692 } | 1735 } |
1693 | 1736 |
1694 | 1737 |
1695 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 1738 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
1696 // r0: code entry | 1739 // r0: code entry |
(...skipping 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5452 MemOperand(fp, 6 * kPointerSize), | 5495 MemOperand(fp, 6 * kPointerSize), |
5453 NULL); | 5496 NULL); |
5454 } | 5497 } |
5455 | 5498 |
5456 | 5499 |
5457 #undef __ | 5500 #undef __ |
5458 | 5501 |
5459 } } // namespace v8::internal | 5502 } } // namespace v8::internal |
5460 | 5503 |
5461 #endif // V8_TARGET_ARCH_ARM | 5504 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |