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 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 | 1621 |
1622 // These prototypes handle the four types of FP calls. | 1622 // These prototypes handle the four types of FP calls. |
1623 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1623 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
1624 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1624 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
1625 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1625 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
1626 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1626 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
1627 | 1627 |
1628 // This signature supports direct call in to API function native callback | 1628 // This signature supports direct call in to API function native callback |
1629 // (refer to InvocationCallback in v8.h). | 1629 // (refer to InvocationCallback in v8.h). |
1630 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1630 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1631 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); |
1631 | 1632 |
1632 // This signature supports direct call to accessor getter callback. | 1633 // This signature supports direct call to accessor getter callback. |
1633 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, | 1634 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, |
1634 int32_t arg1); | 1635 int32_t arg1); |
| 1636 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, |
| 1637 int32_t arg1); |
1635 | 1638 |
1636 // Software interrupt instructions are used by the simulator to call into the | 1639 // Software interrupt instructions are used by the simulator to call into the |
1637 // C-based V8 runtime. | 1640 // C-based V8 runtime. |
1638 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1641 void Simulator::SoftwareInterrupt(Instruction* instr) { |
1639 int svc = instr->SvcValue(); | 1642 int svc = instr->SvcValue(); |
1640 switch (svc) { | 1643 switch (svc) { |
1641 case kCallRtRedirected: { | 1644 case kCallRtRedirected: { |
1642 // Check if stack is aligned. Error if not aligned is reported below to | 1645 // Check if stack is aligned. Error if not aligned is reported below to |
1643 // include information on the function called. | 1646 // include information on the function called. |
1644 bool stack_aligned = | 1647 bool stack_aligned = |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 case ExternalReference::BUILTIN_FP_FP_CALL: | 1766 case ExternalReference::BUILTIN_FP_FP_CALL: |
1764 case ExternalReference::BUILTIN_FP_CALL: | 1767 case ExternalReference::BUILTIN_FP_CALL: |
1765 case ExternalReference::BUILTIN_FP_INT_CALL: | 1768 case ExternalReference::BUILTIN_FP_INT_CALL: |
1766 PrintF("Returned %f\n", dresult); | 1769 PrintF("Returned %f\n", dresult); |
1767 break; | 1770 break; |
1768 default: | 1771 default: |
1769 UNREACHABLE(); | 1772 UNREACHABLE(); |
1770 break; | 1773 break; |
1771 } | 1774 } |
1772 } | 1775 } |
1773 } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { | 1776 } else if ( |
1774 SimulatorRuntimeDirectApiCall target = | 1777 redirection->type() == ExternalReference::DIRECT_API_CALL || |
1775 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); | 1778 redirection->type() == ExternalReference::DIRECT_API_CALL_NEW) { |
1776 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1779 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1777 PrintF("Call to host function at %p args %08x", | 1780 PrintF("Call to host function at %p args %08x", |
1778 FUNCTION_ADDR(target), arg0); | 1781 reinterpret_cast<void*>(external), arg0); |
1779 if (!stack_aligned) { | 1782 if (!stack_aligned) { |
1780 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1783 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
1781 } | 1784 } |
1782 PrintF("\n"); | 1785 PrintF("\n"); |
1783 } | 1786 } |
1784 CHECK(stack_aligned); | 1787 CHECK(stack_aligned); |
1785 v8::Handle<v8::Value> result = target(arg0); | 1788 if (redirection->type() == ExternalReference::DIRECT_API_CALL) { |
1786 if (::v8::internal::FLAG_trace_sim) { | 1789 SimulatorRuntimeDirectApiCall target = |
1787 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | 1790 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); |
| 1791 v8::Handle<v8::Value> result = target(arg0); |
| 1792 if (::v8::internal::FLAG_trace_sim) { |
| 1793 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
| 1794 } |
| 1795 set_register(r0, reinterpret_cast<int32_t>(*result)); |
| 1796 } else { |
| 1797 SimulatorRuntimeDirectApiCallNew target = |
| 1798 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); |
| 1799 target(arg0); |
1788 } | 1800 } |
1789 set_register(r0, reinterpret_cast<int32_t>(*result)); | 1801 } else if ( |
1790 } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1802 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || |
1791 SimulatorRuntimeDirectGetterCall target = | 1803 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { |
1792 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | |
1793 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1804 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1794 PrintF("Call to host function at %p args %08x %08x", | 1805 PrintF("Call to host function at %p args %08x %08x", |
1795 FUNCTION_ADDR(target), arg0, arg1); | 1806 reinterpret_cast<void*>(external), arg0, arg1); |
1796 if (!stack_aligned) { | 1807 if (!stack_aligned) { |
1797 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1808 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
1798 } | 1809 } |
1799 PrintF("\n"); | 1810 PrintF("\n"); |
1800 } | 1811 } |
1801 CHECK(stack_aligned); | 1812 CHECK(stack_aligned); |
1802 v8::Handle<v8::Value> result = target(arg0, arg1); | 1813 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
1803 if (::v8::internal::FLAG_trace_sim) { | 1814 SimulatorRuntimeDirectGetterCall target = |
1804 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | 1815 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
| 1816 v8::Handle<v8::Value> result = target(arg0, arg1); |
| 1817 if (::v8::internal::FLAG_trace_sim) { |
| 1818 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
| 1819 } |
| 1820 set_register(r0, reinterpret_cast<int32_t>(*result)); |
| 1821 } else { |
| 1822 SimulatorRuntimeDirectGetterCallNew target = |
| 1823 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); |
| 1824 target(arg0, arg1); |
1805 } | 1825 } |
1806 set_register(r0, reinterpret_cast<int32_t>(*result)); | |
1807 } else { | 1826 } else { |
1808 // builtin call. | 1827 // builtin call. |
1809 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); | 1828 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); |
1810 SimulatorRuntimeCall target = | 1829 SimulatorRuntimeCall target = |
1811 reinterpret_cast<SimulatorRuntimeCall>(external); | 1830 reinterpret_cast<SimulatorRuntimeCall>(external); |
1812 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1831 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1813 PrintF( | 1832 PrintF( |
1814 "Call to host function at %p" | 1833 "Call to host function at %p" |
1815 "args %08x, %08x, %08x, %08x, %08x, %08x", | 1834 "args %08x, %08x, %08x, %08x, %08x, %08x", |
1816 FUNCTION_ADDR(target), | 1835 FUNCTION_ADDR(target), |
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3497 uintptr_t address = *stack_slot; | 3516 uintptr_t address = *stack_slot; |
3498 set_register(sp, current_sp + sizeof(uintptr_t)); | 3517 set_register(sp, current_sp + sizeof(uintptr_t)); |
3499 return address; | 3518 return address; |
3500 } | 3519 } |
3501 | 3520 |
3502 } } // namespace v8::internal | 3521 } } // namespace v8::internal |
3503 | 3522 |
3504 #endif // USE_SIMULATOR | 3523 #endif // USE_SIMULATOR |
3505 | 3524 |
3506 #endif // V8_TARGET_ARCH_ARM | 3525 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |