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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 } | 823 } |
824 | 824 |
825 void* external_function() { return external_function_; } | 825 void* external_function() { return external_function_; } |
826 ExternalReference::Type type() { return type_; } | 826 ExternalReference::Type type() { return type_; } |
827 | 827 |
828 static Redirection* Get(void* external_function, | 828 static Redirection* Get(void* external_function, |
829 ExternalReference::Type type) { | 829 ExternalReference::Type type) { |
830 Isolate* isolate = Isolate::Current(); | 830 Isolate* isolate = Isolate::Current(); |
831 Redirection* current = isolate->simulator_redirection(); | 831 Redirection* current = isolate->simulator_redirection(); |
832 for (; current != NULL; current = current->next_) { | 832 for (; current != NULL; current = current->next_) { |
833 if (current->external_function_ == external_function) { | 833 if (current->external_function_ == external_function) return current; |
834 ASSERT_EQ(current->type(), type); | |
835 return current; | |
836 } | |
837 } | 834 } |
838 return new Redirection(external_function, type); | 835 return new Redirection(external_function, type); |
839 } | 836 } |
840 | 837 |
841 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { | 838 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { |
842 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); | 839 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); |
843 char* addr_of_redirection = | 840 char* addr_of_redirection = |
844 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); | 841 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); |
845 return reinterpret_cast<Redirection*>(addr_of_redirection); | 842 return reinterpret_cast<Redirection*>(addr_of_redirection); |
846 } | 843 } |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 // These prototypes handle the four types of FP calls. | 1622 // These prototypes handle the four types of FP calls. |
1626 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1623 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
1627 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1624 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
1628 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1625 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
1629 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1626 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
1630 | 1627 |
1631 // This signature supports direct call in to API function native callback | 1628 // This signature supports direct call in to API function native callback |
1632 // (refer to InvocationCallback in v8.h). | 1629 // (refer to InvocationCallback in v8.h). |
1633 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1630 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
1634 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); | 1631 typedef void (*SimulatorRuntimeDirectApiCallNew)(int32_t arg0); |
1635 typedef v8::Handle<v8::Value> (*SimulatorRuntimeProfilingApiCall)( | |
1636 int32_t arg0, int32_t arg1); | |
1637 typedef void (*SimulatorRuntimeProfilingApiCallNew)(int32_t arg0, int32_t arg1); | |
1638 | 1632 |
1639 // This signature supports direct call to accessor getter callback. | 1633 // This signature supports direct call to accessor getter callback. |
1640 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, | 1634 typedef v8::Handle<v8::Value> (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, |
1641 int32_t arg1); | 1635 int32_t arg1); |
1642 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, | 1636 typedef void (*SimulatorRuntimeDirectGetterCallNew)(int32_t arg0, |
1643 int32_t arg1); | 1637 int32_t arg1); |
1644 typedef v8::Handle<v8::Value> (*SimulatorRuntimeProfilingGetterCall)( | |
1645 int32_t arg0, int32_t arg1, int32_t arg2); | |
1646 typedef void (*SimulatorRuntimeProfilingGetterCallNew)( | |
1647 int32_t arg0, int32_t arg1, int32_t arg2); | |
1648 | 1638 |
1649 // 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 |
1650 // C-based V8 runtime. | 1640 // C-based V8 runtime. |
1651 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1641 void Simulator::SoftwareInterrupt(Instruction* instr) { |
1652 int svc = instr->SvcValue(); | 1642 int svc = instr->SvcValue(); |
1653 switch (svc) { | 1643 switch (svc) { |
1654 case kCallRtRedirected: { | 1644 case kCallRtRedirected: { |
1655 // 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 |
1656 // include information on the function called. | 1646 // include information on the function called. |
1657 bool stack_aligned = | 1647 bool stack_aligned = |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 if (::v8::internal::FLAG_trace_sim) { | 1792 if (::v8::internal::FLAG_trace_sim) { |
1803 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | 1793 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
1804 } | 1794 } |
1805 set_register(r0, reinterpret_cast<int32_t>(*result)); | 1795 set_register(r0, reinterpret_cast<int32_t>(*result)); |
1806 } else { | 1796 } else { |
1807 SimulatorRuntimeDirectApiCallNew target = | 1797 SimulatorRuntimeDirectApiCallNew target = |
1808 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); | 1798 reinterpret_cast<SimulatorRuntimeDirectApiCallNew>(external); |
1809 target(arg0); | 1799 target(arg0); |
1810 } | 1800 } |
1811 } else if ( | 1801 } else if ( |
1812 redirection->type() == ExternalReference::PROFILING_API_CALL || | |
1813 redirection->type() == ExternalReference::PROFILING_API_CALL_NEW) { | |
1814 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | |
1815 PrintF("Call to host function at %p args %08x %08x", | |
1816 reinterpret_cast<void*>(external), arg0, arg1); | |
1817 if (!stack_aligned) { | |
1818 PrintF(" with unaligned stack %08x\n", get_register(sp)); | |
1819 } | |
1820 PrintF("\n"); | |
1821 } | |
1822 CHECK(stack_aligned); | |
1823 if (redirection->type() == ExternalReference::PROFILING_API_CALL) { | |
1824 SimulatorRuntimeProfilingApiCall target = | |
1825 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); | |
1826 v8::Handle<v8::Value> result = target(arg0, arg1); | |
1827 if (::v8::internal::FLAG_trace_sim) { | |
1828 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | |
1829 } | |
1830 set_register(r0, reinterpret_cast<int32_t>(*result)); | |
1831 } else { | |
1832 SimulatorRuntimeProfilingApiCallNew target = | |
1833 reinterpret_cast<SimulatorRuntimeProfilingApiCallNew>(external); | |
1834 target(arg0, arg1); | |
1835 } | |
1836 } else if ( | |
1837 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || | 1802 redirection->type() == ExternalReference::DIRECT_GETTER_CALL || |
1838 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { | 1803 redirection->type() == ExternalReference::DIRECT_GETTER_CALL_NEW) { |
1839 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1804 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1840 PrintF("Call to host function at %p args %08x %08x", | 1805 PrintF("Call to host function at %p args %08x %08x", |
1841 reinterpret_cast<void*>(external), arg0, arg1); | 1806 reinterpret_cast<void*>(external), arg0, arg1); |
1842 if (!stack_aligned) { | 1807 if (!stack_aligned) { |
1843 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1808 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
1844 } | 1809 } |
1845 PrintF("\n"); | 1810 PrintF("\n"); |
1846 } | 1811 } |
1847 CHECK(stack_aligned); | 1812 CHECK(stack_aligned); |
1848 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1813 if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
1849 SimulatorRuntimeDirectGetterCall target = | 1814 SimulatorRuntimeDirectGetterCall target = |
1850 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 1815 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
1851 v8::Handle<v8::Value> result = target(arg0, arg1); | 1816 v8::Handle<v8::Value> result = target(arg0, arg1); |
1852 if (::v8::internal::FLAG_trace_sim) { | 1817 if (::v8::internal::FLAG_trace_sim) { |
1853 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | 1818 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); |
1854 } | 1819 } |
1855 set_register(r0, reinterpret_cast<int32_t>(*result)); | 1820 set_register(r0, reinterpret_cast<int32_t>(*result)); |
1856 } else { | 1821 } else { |
1857 SimulatorRuntimeDirectGetterCallNew target = | 1822 SimulatorRuntimeDirectGetterCallNew target = |
1858 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); | 1823 reinterpret_cast<SimulatorRuntimeDirectGetterCallNew>(external); |
1859 target(arg0, arg1); | 1824 target(arg0, arg1); |
1860 } | 1825 } |
1861 } else if ( | |
1862 redirection->type() == ExternalReference::PROFILING_GETTER_CALL || | |
1863 redirection->type() == ExternalReference::PROFILING_GETTER_CALL_NEW) { | |
1864 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | |
1865 PrintF("Call to host function at %p args %08x %08x %08x", | |
1866 reinterpret_cast<void*>(external), arg0, arg1, arg2); | |
1867 if (!stack_aligned) { | |
1868 PrintF(" with unaligned stack %08x\n", get_register(sp)); | |
1869 } | |
1870 PrintF("\n"); | |
1871 } | |
1872 CHECK(stack_aligned); | |
1873 if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | |
1874 SimulatorRuntimeProfilingGetterCall target = | |
1875 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>(external); | |
1876 v8::Handle<v8::Value> result = target(arg0, arg1, arg2); | |
1877 if (::v8::internal::FLAG_trace_sim) { | |
1878 PrintF("Returned %p\n", reinterpret_cast<void *>(*result)); | |
1879 } | |
1880 set_register(r0, reinterpret_cast<int32_t>(*result)); | |
1881 } else { | |
1882 SimulatorRuntimeProfilingGetterCallNew target = | |
1883 reinterpret_cast<SimulatorRuntimeProfilingGetterCallNew>( | |
1884 external); | |
1885 target(arg0, arg1, arg2); | |
1886 } | |
1887 } else { | 1826 } else { |
1888 // builtin call. | 1827 // builtin call. |
1889 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); | 1828 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); |
1890 SimulatorRuntimeCall target = | 1829 SimulatorRuntimeCall target = |
1891 reinterpret_cast<SimulatorRuntimeCall>(external); | 1830 reinterpret_cast<SimulatorRuntimeCall>(external); |
1892 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1831 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
1893 PrintF( | 1832 PrintF( |
1894 "Call to host function at %p " | 1833 "Call to host function at %p" |
1895 "args %08x, %08x, %08x, %08x, %08x, %08x", | 1834 "args %08x, %08x, %08x, %08x, %08x, %08x", |
1896 FUNCTION_ADDR(target), | 1835 FUNCTION_ADDR(target), |
1897 arg0, | 1836 arg0, |
1898 arg1, | 1837 arg1, |
1899 arg2, | 1838 arg2, |
1900 arg3, | 1839 arg3, |
1901 arg4, | 1840 arg4, |
1902 arg5); | 1841 arg5); |
1903 if (!stack_aligned) { | 1842 if (!stack_aligned) { |
1904 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1843 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 uintptr_t address = *stack_slot; | 3516 uintptr_t address = *stack_slot; |
3578 set_register(sp, current_sp + sizeof(uintptr_t)); | 3517 set_register(sp, current_sp + sizeof(uintptr_t)); |
3579 return address; | 3518 return address; |
3580 } | 3519 } |
3581 | 3520 |
3582 } } // namespace v8::internal | 3521 } } // namespace v8::internal |
3583 | 3522 |
3584 #endif // USE_SIMULATOR | 3523 #endif // USE_SIMULATOR |
3585 | 3524 |
3586 #endif // V8_TARGET_ARCH_ARM | 3525 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |