Changeset 106126 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Sep 23, 2024 10:45:45 PM (2 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp
r106125 r106126 6867 6867 } 6868 6868 6869 6870 #ifndef IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON6871 /**6872 * Emits a standard prolog.6873 */6874 static uint32_t iemNativeEmitProlog(PIEMRECOMPILERSTATE pReNative, uint32_t off)6875 {6876 #ifdef RT_ARCH_AMD646877 /*6878 * Set up a regular xBP stack frame, pushing all non-volatile GPRs,6879 * reserving 64 bytes for stack variables plus 4 non-register argument6880 * slots. Fixed register assignment: xBX = pReNative;6881 *6882 * Since we always do the same register spilling, we can use the same6883 * unwind description for all the code.6884 */6885 uint8_t *const pbCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 32);6886 pbCodeBuf[off++] = 0x50 + X86_GREG_xBP; /* push rbp */6887 pbCodeBuf[off++] = X86_OP_REX_W; /* mov rbp, rsp */6888 pbCodeBuf[off++] = 0x8b;6889 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xBP, X86_GREG_xSP);6890 pbCodeBuf[off++] = 0x50 + X86_GREG_xBX; /* push rbx */6891 AssertCompile(IEMNATIVE_REG_FIXED_PVMCPU == X86_GREG_xBX);6892 # ifdef RT_OS_WINDOWS6893 pbCodeBuf[off++] = X86_OP_REX_W; /* mov rbx, rcx ; RBX = pVCpu */6894 pbCodeBuf[off++] = 0x8b;6895 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xBX, X86_GREG_xCX);6896 pbCodeBuf[off++] = 0x50 + X86_GREG_xSI; /* push rsi */6897 pbCodeBuf[off++] = 0x50 + X86_GREG_xDI; /* push rdi */6898 # else6899 pbCodeBuf[off++] = X86_OP_REX_W; /* mov rbx, rdi ; RBX = pVCpu */6900 pbCodeBuf[off++] = 0x8b;6901 pbCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, X86_GREG_xBX, X86_GREG_xDI);6902 # endif6903 pbCodeBuf[off++] = X86_OP_REX_B; /* push r12 */6904 pbCodeBuf[off++] = 0x50 + X86_GREG_x12 - 8;6905 pbCodeBuf[off++] = X86_OP_REX_B; /* push r13 */6906 pbCodeBuf[off++] = 0x50 + X86_GREG_x13 - 8;6907 pbCodeBuf[off++] = X86_OP_REX_B; /* push r14 */6908 pbCodeBuf[off++] = 0x50 + X86_GREG_x14 - 8;6909 pbCodeBuf[off++] = X86_OP_REX_B; /* push r15 */6910 pbCodeBuf[off++] = 0x50 + X86_GREG_x15 - 8;6911 6912 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP6913 /* Save the frame pointer. */6914 off = iemNativeEmitStoreGprToVCpuU64Ex(pbCodeBuf, off, X86_GREG_xBP, RT_UOFFSETOF(VMCPUCC, iem.s.pvTbFramePointerR3));6915 # endif6916 6917 off = iemNativeEmitSubGprImm(pReNative, off, /* sub rsp, byte 28h */6918 X86_GREG_xSP,6919 IEMNATIVE_FRAME_ALIGN_SIZE6920 + IEMNATIVE_FRAME_VAR_SIZE6921 + IEMNATIVE_FRAME_STACK_ARG_COUNT * 86922 + IEMNATIVE_FRAME_SHADOW_ARG_COUNT * 8);6923 AssertCompile(!(IEMNATIVE_FRAME_VAR_SIZE & 0xf));6924 AssertCompile(!(IEMNATIVE_FRAME_STACK_ARG_COUNT & 0x1));6925 AssertCompile(!(IEMNATIVE_FRAME_SHADOW_ARG_COUNT & 0x1));6926 6927 #elif RT_ARCH_ARM646928 /*6929 * We set up a stack frame exactly like on x86, only we have to push the6930 * return address our selves here. We save all non-volatile registers.6931 */6932 uint32_t * const pu32CodeBuf = iemNativeInstrBufEnsure(pReNative, off, 16);6933 6934 # ifdef RT_OS_DARWIN /** @todo This seems to be requirement by libunwind for JIT FDEs. Investigate further as been unable6935 * to figure out where the BRK following AUTHB*+XPACB* stuff comes from in libunwind. It's6936 * definitely the dwarf stepping code, but till found it's very tedious to figure out whether it's6937 * in any way conditional, so just emitting this instructions now and hoping for the best... */6938 /* pacibsp */6939 pu32CodeBuf[off++] = ARMV8_A64_INSTR_PACIBSP;6940 # endif6941 6942 /* stp x19, x20, [sp, #-IEMNATIVE_FRAME_SAVE_REG_SIZE] ; Allocate space for saving registers and place x19+x20 at the bottom. */6943 AssertCompile(IEMNATIVE_FRAME_SAVE_REG_SIZE < 64*8);6944 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_PreIndex,6945 ARMV8_A64_REG_X19, ARMV8_A64_REG_X20, ARMV8_A64_REG_SP,6946 -IEMNATIVE_FRAME_SAVE_REG_SIZE / 8);6947 /* Save x21 thru x28 (SP remains unchanged in the kSigned variant). */6948 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_Signed,6949 ARMV8_A64_REG_X21, ARMV8_A64_REG_X22, ARMV8_A64_REG_SP, 2);6950 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_Signed,6951 ARMV8_A64_REG_X23, ARMV8_A64_REG_X24, ARMV8_A64_REG_SP, 4);6952 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_Signed,6953 ARMV8_A64_REG_X25, ARMV8_A64_REG_X26, ARMV8_A64_REG_SP, 6);6954 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_Signed,6955 ARMV8_A64_REG_X27, ARMV8_A64_REG_X28, ARMV8_A64_REG_SP, 8);6956 /* Save the BP and LR (ret address) registers at the top of the frame. */6957 pu32CodeBuf[off++] = Armv8A64MkInstrStLdPair(false /*fLoad*/, 2 /*64-bit*/, kArm64InstrStLdPairType_Signed,6958 ARMV8_A64_REG_BP, ARMV8_A64_REG_LR, ARMV8_A64_REG_SP, 10);6959 AssertCompile(IEMNATIVE_FRAME_SAVE_REG_SIZE / 8 == 12);6960 /* add bp, sp, IEMNATIVE_FRAME_SAVE_REG_SIZE - 16 ; Set BP to point to the old BP stack address. */6961 pu32CodeBuf[off++] = Armv8A64MkInstrAddSubUImm12(false /*fSub*/, ARMV8_A64_REG_BP,6962 ARMV8_A64_REG_SP, IEMNATIVE_FRAME_SAVE_REG_SIZE - 16);6963 6964 /* sub sp, sp, IEMNATIVE_FRAME_VAR_SIZE ; Allocate the variable area from SP. */6965 pu32CodeBuf[off++] = Armv8A64MkInstrAddSubUImm12(true /*fSub*/, ARMV8_A64_REG_SP, ARMV8_A64_REG_SP, IEMNATIVE_FRAME_VAR_SIZE);6966 6967 /* mov r28, r0 */6968 off = iemNativeEmitLoadGprFromGprEx(pu32CodeBuf, off, IEMNATIVE_REG_FIXED_PVMCPU, IEMNATIVE_CALL_ARG0_GREG);6969 /* mov r27, r1 */6970 off = iemNativeEmitLoadGprFromGprEx(pu32CodeBuf, off, IEMNATIVE_REG_FIXED_PCPUMCTX, IEMNATIVE_CALL_ARG1_GREG);6971 6972 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP6973 /* Save the frame pointer. */6974 off = iemNativeEmitStoreGprToVCpuU64Ex(pu32CodeBuf, off, ARMV8_A64_REG_BP, RT_UOFFSETOF(VMCPUCC, iem.s.pvTbFramePointerR3),6975 ARMV8_A64_REG_X2);6976 # endif6977 6978 #else6979 # error "port me"6980 #endif6981 IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off);6982 return off;6983 }6984 #endif6985 6869 6986 6870 … … 9982 9866 IEMNATIVE_TRY_SETJMP(pReNative, rc) 9983 9867 { 9984 #ifndef IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON9985 /*9986 * Emit prolog code (fixed).9987 */9988 off = iemNativeEmitProlog(pReNative, off);9989 #endif9990 9991 9868 /* 9992 9869 * Convert the calls to native code. -
trunk/src/VBox/VMM/VMMAll/IEMAllThrdRecompiler.cpp
r106061 r106126 3215 3215 # endif 3216 3216 3217 # ifndef IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON 3218 # ifdef RT_ARCH_AMD64 3219 VBOXSTRICTRC const rcStrict = ((PFNIEMTBNATIVE)pTb->Native.paInstructions)(pVCpu); 3220 # else 3221 VBOXSTRICTRC const rcStrict = ((PFNIEMTBNATIVE)pTb->Native.paInstructions)(pVCpu, &pVCpu->cpum.GstCtx); 3222 # endif 3217 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP 3218 AssertCompileMemberOffset(VMCPUCC, iem.s.pvTbFramePointerR3, 0x7c8); /* This is assumed in iemNativeTbEntry */ 3219 # endif 3220 # ifdef RT_ARCH_AMD64 3221 VBOXSTRICTRC const rcStrict = iemNativeTbEntry(pVCpu, (uintptr_t)pTb->Native.paInstructions); 3223 3222 # else 3224 # ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP3225 AssertCompileMemberOffset(VMCPUCC, iem.s.pvTbFramePointerR3, 0x7c8); /* This is assumed in iemNativeTbEntry */3226 # endif3227 # ifdef RT_ARCH_AMD643228 VBOXSTRICTRC const rcStrict = iemNativeTbEntry(pVCpu, (uintptr_t)pTb->Native.paInstructions);3229 # else3230 3223 VBOXSTRICTRC const rcStrict = iemNativeTbEntry(pVCpu, &pVCpu->cpum.GstCtx, (uintptr_t)pTb->Native.paInstructions); 3231 # endif3232 3224 # endif 3233 3225 -
trunk/src/VBox/VMM/include/IEMN8veRecompiler.h
r106125 r106126 93 93 /** Always count instructions for now. */ 94 94 # define IEMNATIVE_WITH_INSTRUCTION_COUNTING 95 #endif96 97 /** @def IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON98 * Enables having only a single prologue for native TBs. */99 #if 1 || defined(DOXYGEN_RUNNING)100 # define IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON101 95 #endif 102 96 … … 2821 2815 2822 2816 2823 #ifdef IEMNATIVE_WITH_RECOMPILER_PROLOGUE_SINGLETON2824 2817 /** @note iemNativeTbEntry returns VBOXSTRICTRC, but we don't declare it as 2825 2818 * it saves us the trouble of a hidden parameter on MSC/amd64. */ 2826 # 2819 #ifdef RT_ARCH_AMD64 2827 2820 extern "C" IEM_DECL_NATIVE_HLP_DEF(int, iemNativeTbEntry, (PVMCPUCC pVCpu, uintptr_t pfnTbBody)); 2828 # 2821 #elif defined(RT_ARCH_ARM64) 2829 2822 extern "C" IEM_DECL_NATIVE_HLP_DEF(int, iemNativeTbEntry, (PVMCPUCC pVCpu, PCPUMCTX pCpumCtx, uintptr_t pfnTbBody)); 2830 # endif2831 2823 #endif 2832 2824
Note:
See TracChangeset
for help on using the changeset viewer.