- disabled VM JIT completely on unsuported platforms

This commit is contained in:
alexey.lysiuk 2019-02-04 11:14:52 +02:00 committed by drfrag
parent 1382d79ab1
commit 7fecc973f5
5 changed files with 60 additions and 35 deletions

View file

@ -163,9 +163,21 @@ option( NO_OPENAL "Disable OpenAL sound support" OFF )
find_package( BZip2 )
find_package( JPEG )
find_package( ZLIB )
# find_package( asmjit )
# no, we're not using external asmjit for now, we made too many modifications to our's.
# if the asmjit author uses our changes then we'll update this.
include( TargetArch )
target_architecture(ZDOOM_TARGET_ARCH)
if( ${ZDOOM_TARGET_ARCH} MATCHES "x86_64" )
set( HAVE_VM_JIT ON )
endif()
# no, we're not using external asmjit for now, we made too many modifications to our's.
# if the asmjit author uses our changes then we'll update this.
#if( ${HAVE_VM_JIT} )
# find_package( asmjit )
#endif()
# GME
#find_path( GME_INCLUDE_DIR gme/gme.h )
@ -299,15 +311,17 @@ else()
set( ZLIB_LIBRARY z )
endif()
if( ASMJIT_FOUND AND NOT FORCE_INTERNAL_ASMJIT )
message( STATUS "Using system asmjit, includes found at ${ASMJIT_INCLUDE_DIR}" )
else()
message( STATUS "Using internal asmjit" )
set( SKIP_INSTALL_ALL TRUE ) # Avoid installing asmjit alongside zdoom
add_subdirectory( asmjit )
set( ASMJIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/asmjit )
set( ASMJIT_LIBRARIES asmjit )
set( ASMJIT_LIBRARY asmjit )
if( ${HAVE_VM_JIT} )
if( ASMJIT_FOUND AND NOT FORCE_INTERNAL_ASMJIT )
message( STATUS "Using system asmjit, includes found at ${ASMJIT_INCLUDE_DIR}" )
else()
message( STATUS "Using internal asmjit" )
set( SKIP_INSTALL_ALL TRUE ) # Avoid installing asmjit alongside zdoom
add_subdirectory( asmjit )
set( ASMJIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/asmjit )
set( ASMJIT_LIBRARIES asmjit )
set( ASMJIT_LIBRARY asmjit )
endif()
endif()
if( JPEG_FOUND AND NOT FORCE_INTERNAL_JPEG )

View file

@ -13,7 +13,6 @@ include( CheckIncludeFile )
include( CheckIncludeFiles )
include( CheckLibraryExists )
include( FindPkgConfig )
include( TargetArch )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
option( NO_STRIP "Do not strip Release or MinSizeRel builds" )
@ -33,8 +32,6 @@ if( APPLE )
option( OSX_COCOA_BACKEND "Use native Cocoa backend instead of SDL" ON )
endif()
target_architecture(ZDOOM_TARGET_ARCH)
if( ${ZDOOM_TARGET_ARCH} MATCHES "x86_64" )
set( X64 64 )
endif()
@ -492,8 +489,14 @@ add_custom_target( revision_check ALL
# Libraries ZDoom needs
message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${ASMJIT_LIBRARIES}" "${CMAKE_DL_LIBS}" )
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" "${ASMJIT_INCLUDE_DIR}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${GME_LIBRARIES}" "${CMAKE_DL_LIBS}" )
include_directories( "${ZLIB_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${GME_INCLUDE_DIR}" )
if( ${HAVE_VM_JIT} )
add_definitions( -DHAVE_VM_JIT )
include_directories( "${ASMJIT_INCLUDE_DIR}" )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ASMJIT_LIBRARIES}")
endif()
if( SNDFILE_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SNDFILE_LIBRARIES}" )
@ -830,6 +833,17 @@ set( NOT_COMPILED_SOURCE_FILES
zcc-parse.h
)
set( VM_JIT_SOURCES
scripting/vm/jit.cpp
scripting/vm/jit_runtime.cpp
scripting/vm/jit_call.cpp
scripting/vm/jit_flow.cpp
scripting/vm/jit_load.cpp
scripting/vm/jit_math.cpp
scripting/vm/jit_move.cpp
scripting/vm/jit_store.cpp
)
# This is disabled for now because I cannot find a way to give the .pch file a different name.
# Visual C++ 2015 seems hell-bent of only allowing one .pch file with the same name as the executable.
#enable_precompiled_headers( g_pch2.h FASTMATH_PCH_SOURCES )
@ -1208,14 +1222,6 @@ set (PCH_SOURCES
scripting/decorate/thingdef_states.cpp
scripting/vm/vmexec.cpp
scripting/vm/vmframe.cpp
scripting/vm/jit.cpp
scripting/vm/jit_runtime.cpp
scripting/vm/jit_call.cpp
scripting/vm/jit_flow.cpp
scripting/vm/jit_load.cpp
scripting/vm/jit_math.cpp
scripting/vm/jit_move.cpp
scripting/vm/jit_store.cpp
scripting/zscript/ast.cpp
scripting/zscript/zcc_compile.cpp
scripting/zscript/zcc_parser.cpp
@ -1289,6 +1295,12 @@ set (PCH_SOURCES
SkylineBinPack.cpp
)
if( ${HAVE_VM_JIT} )
set( PCH_SOURCES ${PCH_SOURCES} ${VM_JIT_SOURCES} )
else()
set( NOT_COMPILED_SOURCE_FILES ${NOT_COMPILED_SOURCE_FILES} ${VM_JIT_SOURCES} )
endif()
enable_precompiled_headers( g_pch.h PCH_SOURCES )
add_executable( zdoom WIN32 MACOSX_BUNDLE
@ -1296,7 +1308,6 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE
${NOT_COMPILED_SOURCE_FILES}
__autostart.cpp
${SYSTEM_SOURCES}
${X86_SOURCES}
${FASTMATH_SOURCES}
${PCH_SOURCES}
x86.cpp

View file

@ -819,6 +819,7 @@ void SetDehParams(FState *state, int codepointer)
}
fclose(dump);
}
#ifdef HAVE_VM_JIT
if (Args->CheckParm("-dumpjit"))
{
FILE *dump = fopen("dumpjit.txt", "a");
@ -828,6 +829,7 @@ void SetDehParams(FState *state, int codepointer)
}
fclose(dump);
}
#endif // HAVE_VM_JIT
}
}

View file

@ -925,6 +925,7 @@ void FFunctionBuildList::Build()
void FFunctionBuildList::DumpJit()
{
#ifdef HAVE_VM_JIT
FILE *dump = fopen("dumpjit.txt", "w");
if (dump == nullptr)
return;
@ -935,6 +936,7 @@ void FFunctionBuildList::DumpJit()
}
fclose(dump);
#endif // HAVE_VM_JIT
}

View file

@ -44,11 +44,7 @@
#include "c_cvars.h"
#include "version.h"
#if (defined(_M_X64 ) || defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(__amd64 ) || defined(__amd64__ ))
#define ARCH_X64
#endif
#ifdef ARCH_X64
#ifdef HAVE_VM_JIT
CUSTOM_CVAR(Bool, vm_jit, true, CVAR_NOINITCALL)
{
Printf("You must restart " GAMENAME " for this change to take effect.\n");
@ -56,6 +52,8 @@ CUSTOM_CVAR(Bool, vm_jit, true, CVAR_NOINITCALL)
}
#else
CVAR(Bool, vm_jit, false, CVAR_NOINITCALL|CVAR_NOSET)
FString JitCaptureStackTrace(int framesToSkip, bool includeNativeFrames) { return FString(); }
void JitRelease() {}
#endif
#ifdef __MINGW32__
@ -286,7 +284,7 @@ static bool CanJit(VMScriptFunction *func)
int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int numparams, VMReturn *ret, int numret)
{
#ifdef ARCH_X64
#ifdef HAVE_VM_JIT
if (vm_jit && CanJit(static_cast<VMScriptFunction*>(func)))
{
func->ScriptCall = JitCompile(static_cast<VMScriptFunction*>(func));
@ -294,12 +292,10 @@ int VMScriptFunction::FirstScriptCall(VMFunction *func, VMValue *params, int num
func->ScriptCall = VMExec;
}
else
#endif // HAVE_VM_JIT
{
func->ScriptCall = VMExec;
}
#else
func->ScriptCall = VMExec;
#endif
return func->ScriptCall(func, params, numparams, ret, numret);
}