| 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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 return new Redirection(external_function, type); | 839 return new Redirection(external_function, type); |
| 840 } | 840 } |
| 841 | 841 |
| 842 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { | 842 static Redirection* FromSwiInstruction(Instruction* swi_instruction) { |
| 843 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); | 843 char* addr_of_swi = reinterpret_cast<char*>(swi_instruction); |
| 844 char* addr_of_redirection = | 844 char* addr_of_redirection = |
| 845 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); | 845 addr_of_swi - OFFSET_OF(Redirection, swi_instruction_); |
| 846 return reinterpret_cast<Redirection*>(addr_of_redirection); | 846 return reinterpret_cast<Redirection*>(addr_of_redirection); |
| 847 } | 847 } |
| 848 | 848 |
| 849 static void* ReverseRedirection(int32_t reg) { |
| 850 Redirection* redirection = FromSwiInstruction( |
| 851 reinterpret_cast<Instruction*>(reinterpret_cast<void*>(reg))); |
| 852 return redirection->external_function(); |
| 853 } |
| 854 |
| 849 private: | 855 private: |
| 850 void* external_function_; | 856 void* external_function_; |
| 851 uint32_t swi_instruction_; | 857 uint32_t swi_instruction_; |
| 852 ExternalReference::Type type_; | 858 ExternalReference::Type type_; |
| 853 Redirection* next_; | 859 Redirection* next_; |
| 854 }; | 860 }; |
| 855 | 861 |
| 856 | 862 |
| 857 void* Simulator::RedirectExternalReference(void* external_function, | 863 void* Simulator::RedirectExternalReference(void* external_function, |
| 858 ExternalReference::Type type) { | 864 ExternalReference::Type type) { |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 | 1688 |
| 1683 // These prototypes handle the four types of FP calls. | 1689 // These prototypes handle the four types of FP calls. |
| 1684 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); | 1690 typedef int64_t (*SimulatorRuntimeCompareCall)(double darg0, double darg1); |
| 1685 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); | 1691 typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); |
| 1686 typedef double (*SimulatorRuntimeFPCall)(double darg0); | 1692 typedef double (*SimulatorRuntimeFPCall)(double darg0); |
| 1687 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); | 1693 typedef double (*SimulatorRuntimeFPIntCall)(double darg0, int32_t arg0); |
| 1688 | 1694 |
| 1689 // This signature supports direct call in to API function native callback | 1695 // This signature supports direct call in to API function native callback |
| 1690 // (refer to InvocationCallback in v8.h). | 1696 // (refer to InvocationCallback in v8.h). |
| 1691 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); | 1697 typedef void (*SimulatorRuntimeDirectApiCall)(int32_t arg0); |
| 1692 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, int32_t arg1); | 1698 typedef void (*SimulatorRuntimeProfilingApiCall)(int32_t arg0, void* arg1); |
| 1693 | 1699 |
| 1694 // This signature supports direct call to accessor getter callback. | 1700 // This signature supports direct call to accessor getter callback. |
| 1695 typedef void (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, int32_t arg1); | 1701 typedef void (*SimulatorRuntimeDirectGetterCall)(int32_t arg0, int32_t arg1); |
| 1696 typedef void (*SimulatorRuntimeProfilingGetterCall)( | 1702 typedef void (*SimulatorRuntimeProfilingGetterCall)( |
| 1697 int32_t arg0, int32_t arg1, int32_t arg2); | 1703 int32_t arg0, int32_t arg1, void* arg2); |
| 1698 | 1704 |
| 1699 // Software interrupt instructions are used by the simulator to call into the | 1705 // Software interrupt instructions are used by the simulator to call into the |
| 1700 // C-based V8 runtime. | 1706 // C-based V8 runtime. |
| 1701 void Simulator::SoftwareInterrupt(Instruction* instr) { | 1707 void Simulator::SoftwareInterrupt(Instruction* instr) { |
| 1702 int svc = instr->SvcValue(); | 1708 int svc = instr->SvcValue(); |
| 1703 switch (svc) { | 1709 switch (svc) { |
| 1704 case kCallRtRedirected: { | 1710 case kCallRtRedirected: { |
| 1705 // Check if stack is aligned. Error if not aligned is reported below to | 1711 // Check if stack is aligned. Error if not aligned is reported below to |
| 1706 // include information on the function called. | 1712 // include information on the function called. |
| 1707 bool stack_aligned = | 1713 bool stack_aligned = |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 PrintF("Call to host function at %p args %08x %08x", | 1832 PrintF("Call to host function at %p args %08x %08x", |
| 1827 reinterpret_cast<void*>(external), arg0, arg1); | 1833 reinterpret_cast<void*>(external), arg0, arg1); |
| 1828 if (!stack_aligned) { | 1834 if (!stack_aligned) { |
| 1829 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1835 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1830 } | 1836 } |
| 1831 PrintF("\n"); | 1837 PrintF("\n"); |
| 1832 } | 1838 } |
| 1833 CHECK(stack_aligned); | 1839 CHECK(stack_aligned); |
| 1834 SimulatorRuntimeProfilingApiCall target = | 1840 SimulatorRuntimeProfilingApiCall target = |
| 1835 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); | 1841 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); |
| 1836 target(arg0, arg1); | 1842 target(arg0, Redirection::ReverseRedirection(arg1)); |
| 1837 } else if ( | 1843 } else if ( |
| 1838 redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { | 1844 redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { |
| 1839 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1845 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| 1840 PrintF("Call to host function at %p args %08x %08x", | 1846 PrintF("Call to host function at %p args %08x %08x", |
| 1841 reinterpret_cast<void*>(external), arg0, arg1); | 1847 reinterpret_cast<void*>(external), arg0, arg1); |
| 1842 if (!stack_aligned) { | 1848 if (!stack_aligned) { |
| 1843 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1849 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1844 } | 1850 } |
| 1845 PrintF("\n"); | 1851 PrintF("\n"); |
| 1846 } | 1852 } |
| 1847 CHECK(stack_aligned); | 1853 CHECK(stack_aligned); |
| 1848 SimulatorRuntimeDirectGetterCall target = | 1854 SimulatorRuntimeDirectGetterCall target = |
| 1849 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 1855 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
| 1850 target(arg0, arg1); | 1856 target(arg0, arg1); |
| 1851 } else if ( | 1857 } else if ( |
| 1852 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { | 1858 redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { |
| 1853 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1859 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| 1854 PrintF("Call to host function at %p args %08x %08x %08x", | 1860 PrintF("Call to host function at %p args %08x %08x %08x", |
| 1855 reinterpret_cast<void*>(external), arg0, arg1, arg2); | 1861 reinterpret_cast<void*>(external), arg0, arg1, arg2); |
| 1856 if (!stack_aligned) { | 1862 if (!stack_aligned) { |
| 1857 PrintF(" with unaligned stack %08x\n", get_register(sp)); | 1863 PrintF(" with unaligned stack %08x\n", get_register(sp)); |
| 1858 } | 1864 } |
| 1859 PrintF("\n"); | 1865 PrintF("\n"); |
| 1860 } | 1866 } |
| 1861 CHECK(stack_aligned); | 1867 CHECK(stack_aligned); |
| 1862 SimulatorRuntimeProfilingGetterCall target = | 1868 SimulatorRuntimeProfilingGetterCall target = |
| 1863 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>( | 1869 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>( |
| 1864 external); | 1870 external); |
| 1865 target(arg0, arg1, arg2); | 1871 target(arg0, arg1, Redirection::ReverseRedirection(arg2)); |
| 1866 } else { | 1872 } else { |
| 1867 // builtin call. | 1873 // builtin call. |
| 1868 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); | 1874 ASSERT(redirection->type() == ExternalReference::BUILTIN_CALL); |
| 1869 SimulatorRuntimeCall target = | 1875 SimulatorRuntimeCall target = |
| 1870 reinterpret_cast<SimulatorRuntimeCall>(external); | 1876 reinterpret_cast<SimulatorRuntimeCall>(external); |
| 1871 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { | 1877 if (::v8::internal::FLAG_trace_sim || !stack_aligned) { |
| 1872 PrintF( | 1878 PrintF( |
| 1873 "Call to host function at %p " | 1879 "Call to host function at %p " |
| 1874 "args %08x, %08x, %08x, %08x, %08x, %08x", | 1880 "args %08x, %08x, %08x, %08x, %08x, %08x", |
| 1875 FUNCTION_ADDR(target), | 1881 FUNCTION_ADDR(target), |
| (...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3840 uintptr_t address = *stack_slot; | 3846 uintptr_t address = *stack_slot; |
| 3841 set_register(sp, current_sp + sizeof(uintptr_t)); | 3847 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 3842 return address; | 3848 return address; |
| 3843 } | 3849 } |
| 3844 | 3850 |
| 3845 } } // namespace v8::internal | 3851 } } // namespace v8::internal |
| 3846 | 3852 |
| 3847 #endif // USE_SIMULATOR | 3853 #endif // USE_SIMULATOR |
| 3848 | 3854 |
| 3849 #endif // V8_TARGET_ARCH_ARM | 3855 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |