MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / commitJIT

Method commitJIT

source/emulation/cpu/jit/jitCodeGen.cpp:905–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

903}
904
905void JitCodeGen::commitJIT(DecodedOp* op) {
906 if (!blockOpCount) {
907 return;
908 }
909 U32 size = 0;
910 U8* begin = createDynamicExecutableMemory(&size);
911
912 removeJIT(op, blockOpCount);
913 op->blockLen = emulatedLen;
914 op->blockOpCount = blockOpCount;
915#ifdef _DEBUG
916 if (0) {
917 logBlock(cpu, startingEip, op, op->blockLen);
918 }
919#endif
920 U32 address = startingEip;
921 DecodedOp* nextOp = op;
922 DecodedOp* last = op;
923#if defined (_DEBUG) && !defined (__TEST)
924 BOXEDWINE_CRITICAL_SECTION;
925 static int totalBlocks;
926 totalBlocks++;
927 static int totalOps;
928 totalOps += blockOpCount;
929 static int totalEmulatedLen;
930 totalEmulatedLen += emulatedLen;
931 static int totalCompiledLen;
932 totalCompiledLen += size;
933 if ((totalBlocks % 1000) == 0) {
934 klog_fmt("Compiled Blocks: %d, ave block size: %d ops. ops = %d, elen = %d, clen = %d", totalBlocks, totalOps / totalBlocks, totalOps, totalEmulatedLen, totalCompiledLen);
935 }
936#endif
937 DecodedOp* lastJitOp = nullptr;
938 U32 lastJitEip = 0;
939
940 for (U32 i = 0; i < blockOpCount; i++) {
941 U32 bufferIndex = 0;
942
943 if (!eipToBufferPos.get(address, bufferIndex)) {
944 kpanic("x32CPU commitJIT 2");
945 }
946 if (bufferIndex == SKIPPED_OP) {
947 nextOp->jumpTargetFlags |= JUMP_TARGET_ASSUMED_FALSE;
948 } else {
949 bufferIndex = getBufferLocation(bufferIndex);
950 nextOp->pfnJitCode = begin + bufferIndex;
951 nextOp->jitLen = 0;
952 nextOp->pfn = cpu->thread->process->startJITOp;
953 if (lastJitOp) {
954 lastJitOp->jitLen = (U8*)nextOp->pfnJitCode - (U8*)lastJitOp->pfnJitCode;
955#ifdef BOXEDWINE_HOST_EXCEPTIONS
956 getMemData(cpu->memory)->jitAddressToEip[(U8*)lastJitOp->pfnJitCode] = JitData(lastJitOp->jitLen, lastJitEip - cpu->seg[CS].address);
957#endif
958 }
959 lastJitEip = address;
960 lastJitOp = nextOp;
961 }
962 nextOp->flags |= OP_FLAG_JIT;

Callers

nothing calls this directly

Calls 6

logBlockFunction · 0.85
klog_fmtFunction · 0.85
kpanicFunction · 0.85
getMemDataFunction · 0.85
JitDataClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected