├── libs ├── asmjit │ ├── CHANGELOG.txt │ ├── scripts │ │ ├── configure-win-msvc6.bat │ │ ├── configure-mac-xcode.sh │ │ ├── configure-win-vs2010-x86.bat │ │ ├── configure-win-vs2005-x86.bat │ │ ├── configure-win-vs2008-x86.bat │ │ ├── configure-unix-makefiles-dbg.sh │ │ ├── configure-unix-makefiles-rel.sh │ │ ├── configure-win-vs2005-x64.bat │ │ ├── configure-win-vs2008-x64.bat │ │ ├── configure-win-vs2010-x64.bat │ │ ├── configure-win-mingw-dbg.bat │ │ ├── configure-win-mingw-rel.bat │ │ ├── configure-win-borland-dbg.bat │ │ ├── configure-win-borland-rel.bat │ │ └── generate-defs.py │ ├── src │ │ ├── asmjit │ │ │ ├── core │ │ │ │ ├── func.cpp │ │ │ │ ├── apiend.h │ │ │ │ ├── memorymarker.cpp │ │ │ │ ├── assert.cpp │ │ │ │ ├── compilercontext.cpp │ │ │ │ ├── operand.cpp │ │ │ │ ├── apibegin.h │ │ │ │ ├── stringutil.h │ │ │ │ ├── defs.cpp │ │ │ │ ├── memorymarker.h │ │ │ │ ├── assert.h │ │ │ │ ├── stringutil.cpp │ │ │ │ ├── buffer.cpp │ │ │ │ ├── cpuinfo.cpp │ │ │ │ ├── context.cpp │ │ │ │ ├── virtualmemory.h │ │ │ │ ├── zonememory.cpp │ │ │ │ ├── compilercontext.h │ │ │ │ ├── cpuinfo.h │ │ │ │ ├── lock.h │ │ │ │ ├── virtualmemory.cpp │ │ │ │ ├── zonememory.h │ │ │ │ ├── compilerfunc.cpp │ │ │ │ ├── context.h │ │ │ │ ├── assembler.cpp │ │ │ │ ├── logger.cpp │ │ │ │ ├── podvector.h │ │ │ │ ├── memorymanager.h │ │ │ │ ├── compiler.cpp │ │ │ │ ├── stringbuilder.h │ │ │ │ ├── intutil.h │ │ │ │ ├── compileritem.cpp │ │ │ │ ├── logger.h │ │ │ │ └── build.h │ │ │ ├── x86.h │ │ │ ├── core.h │ │ │ ├── config.h │ │ │ └── x86 │ │ │ │ ├── x86util.cpp │ │ │ │ ├── x86util.h │ │ │ │ ├── x86cpuinfo.h │ │ │ │ └── x86func.h │ │ └── app │ │ │ └── test │ │ │ ├── testdummy.cpp │ │ │ ├── testsizeof.cpp │ │ │ ├── testcpu.cpp │ │ │ └── testmem.cpp │ ├── COPYING.txt │ ├── extras │ │ ├── contrib │ │ │ ├── remotecontext.cpp │ │ │ └── remotecontext.h │ │ └── doc │ │ │ └── doxygen.css │ ├── README.txt │ └── CMakeLists.txt ├── CMakeLists.txt └── notes.txt ├── .gitignore ├── .clang_complete ├── CMakeLists.txt └── README.md /libs/asmjit/CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | *.swp 3 | -------------------------------------------------------------------------------- /libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(asmjit) 2 | -------------------------------------------------------------------------------- /.clang_complete: -------------------------------------------------------------------------------- 1 | -I. 2 | -I../libs/asmjit/src 3 | -std=c++0x 4 | -------------------------------------------------------------------------------- /libs/notes.txt: -------------------------------------------------------------------------------- 1 | asmjit svn checkout revision 445 from http://asmjit.googlecode.com/svn/trunk/ asmjit-read-only 2 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-msvc6.bat: -------------------------------------------------------------------------------- 1 | mkdir ..\build 2 | cd ..\build 3 | cmake .. -G"Visual Studio 6" -DASMJIT_BUILD_SAMPLES=1 4 | cd ..\scripts 5 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-mac-xcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ASMJIT_SCRIPTS_DIR=`pwd` 4 | ASMJIT_BUILD_DIR="build_xcode" 5 | 6 | mkdir ../${ASMJIT_BUILD_DIR} 7 | cd ../${ASMJIT_BUILD_DIR} 8 | cmake .. -G"Xcode" -DASMJIT_BUILD_SAMPLES=1 9 | cd ${ASMJIT_SCRIPTS_DIR} 10 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2010-x86.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2010_x86" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 10" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2005-x86.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2005_x86" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 8 2005" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2008-x86.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2008_x86" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 9 2008" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-unix-makefiles-dbg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ASMJIT_SCRIPTS_DIR=`pwd` 4 | ASMJIT_BUILD_DIR="build_makefiles_dbg" 5 | 6 | mkdir ../${ASMJIT_BUILD_DIR} 7 | cd ../${ASMJIT_BUILD_DIR} 8 | cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DASMJIT_BUILD_SAMPLES=1 9 | cd ${ASMJIT_SCRIPTS_DIR} 10 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-unix-makefiles-rel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ASMJIT_SCRIPTS_DIR=`pwd` 4 | ASMJIT_BUILD_DIR="build_makefiles_rel" 5 | 6 | mkdir ../${ASMJIT_BUILD_DIR} 7 | cd ../${ASMJIT_BUILD_DIR} 8 | cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DASMJIT_BUILD_SAMPLES=1 9 | cd ${ASMJIT_SCRIPTS_DIR} 10 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2005-x64.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2005_x64" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 8 2005 Win64" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2008-x64.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2008_x64" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 9 2008 Win64" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-vs2010-x64.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_vs2010_x64" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Visual Studio 10 Win64" -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-mingw-dbg.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_mingw_dbg" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-mingw-rel.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_mingw_rel" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-borland-dbg.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_borland_dbg" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Borland Makefiles" -DCMAKE_BUILD_TYPE=Debug -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/configure-win-borland-rel.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set ASMJIT_SCRIPTS_DIR=%CD% 4 | set ASMJIT_BUILD_DIR="build_borland_rel" 5 | 6 | mkdir ..\%ASMJIT_BUILD_DIR% 7 | cd ..\%ASMJIT_BUILD_DIR% 8 | cmake .. -G"Borland Makefiles" -DCMAKE_BUILD_TYPE=Release -DASMJIT_BUILD_SAMPLES=1 9 | cd %ASMJIT_SCRIPTS_DIR% 10 | 11 | pause 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(PIXSLAM) 3 | 4 | add_subdirectory(libs) 5 | 6 | # C++11 7 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 8 | 9 | include_directories(${PIXSLAM_SOURCE_DIR} ${PIXSLAM_SOURCE_DIR}/libs/asmjit/src) 10 | 11 | add_executable(jitcalc main.cpp) 12 | 13 | target_link_libraries(jitcalc asmjit) 14 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/func.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/func.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | namespace AsmJit { 16 | } // AsmJit 17 | 18 | // [Api-End] 19 | #include "../core/apiend.h" 20 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/apiend.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [MSVC] 8 | #if defined(_MSC_VER) 9 | 10 | // Pop disabled warnings by ApiBegin.h 11 | #pragma warning(pop) 12 | 13 | // Rename symbols back. 14 | #undef vsnprintf 15 | #undef snprintf 16 | 17 | #endif // _MSC_VER 18 | 19 | // [GNUC] 20 | #if defined(__GNUC__) 21 | #endif // __GNUC__ 22 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/x86.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_X86_H 9 | #define _ASMJIT_X86_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "core.h" 13 | 14 | #include "x86/x86assembler.h" 15 | #include "x86/x86compiler.h" 16 | #include "x86/x86compilercontext.h" 17 | #include "x86/x86compilerfunc.h" 18 | #include "x86/x86compileritem.h" 19 | #include "x86/x86cpuinfo.h" 20 | #include "x86/x86defs.h" 21 | #include "x86/x86func.h" 22 | #include "x86/x86operand.h" 23 | #include "x86/x86util.h" 24 | 25 | // [Guard] 26 | #endif // _ASMJIT_X86_H 27 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/memorymarker.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/build.h" 11 | #include "../core/memorymarker.h" 12 | 13 | // [Api-Begin] 14 | #include "../core/apibegin.h" 15 | 16 | namespace AsmJit { 17 | 18 | // ============================================================================ 19 | // [AsmJit::MemoryMarker] 20 | // ============================================================================ 21 | 22 | MemoryMarker::MemoryMarker() {} 23 | MemoryMarker::~MemoryMarker() {} 24 | 25 | } // AsmJit namespace 26 | 27 | // [Api-End] 28 | #include "../core/apiend.h" 29 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/assert.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assert.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | // helpers 16 | namespace AsmJit { 17 | 18 | // ============================================================================ 19 | // [AsmJit::Assert] 20 | // ============================================================================ 21 | 22 | void assertionFailure(const char* file, int line, const char* exp) 23 | { 24 | fprintf(stderr, 25 | "*** ASSERTION FAILURE at %s (line %d)\n" 26 | "*** %s\n", file, line, exp); 27 | 28 | exit(1); 29 | } 30 | 31 | } // AsmJit namespace 32 | 33 | // [Api-End] 34 | #include "../core/apiend.h" 35 | -------------------------------------------------------------------------------- /libs/asmjit/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2012, Petr Kobalicek 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_H 9 | #define _ASMJIT_CORE_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "core/build.h" 13 | 14 | #include "core/assembler.h" 15 | #include "core/assert.h" 16 | #include "core/buffer.h" 17 | #include "core/compiler.h" 18 | #include "core/compilercontext.h" 19 | #include "core/compilerfunc.h" 20 | #include "core/compileritem.h" 21 | #include "core/cpuinfo.h" 22 | #include "core/defs.h" 23 | #include "core/func.h" 24 | #include "core/intutil.h" 25 | #include "core/lock.h" 26 | #include "core/logger.h" 27 | #include "core/memorymanager.h" 28 | #include "core/memorymarker.h" 29 | #include "core/operand.h" 30 | #include "core/podvector.h" 31 | #include "core/stringbuilder.h" 32 | #include "core/stringutil.h" 33 | #include "core/virtualmemory.h" 34 | #include "core/zonememory.h" 35 | 36 | // [Guard] 37 | #endif // _ASMJIT_CORE_H 38 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/compilercontext.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/compilercontext.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | namespace AsmJit { 16 | 17 | // ============================================================================ 18 | // [AsmJit::CompilerContext - Construction / Destruction] 19 | // ============================================================================ 20 | 21 | CompilerContext::CompilerContext(Compiler* compiler) : 22 | _zoneMemory(8192 - sizeof(ZoneChunk) - 32), 23 | _compiler(compiler), 24 | _func(NULL), 25 | _start(NULL), 26 | _stop(NULL), 27 | _extraBlock(NULL), 28 | _state(NULL), 29 | _active(NULL), 30 | _currentOffset(0), 31 | _isUnreachable(0) 32 | { 33 | } 34 | 35 | CompilerContext::~CompilerContext() 36 | { 37 | } 38 | 39 | } // AsmJit namespace 40 | 41 | // [Api-End] 42 | #include "../core/apiend.h" 43 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/operand.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/operand.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | namespace AsmJit { 16 | 17 | // ============================================================================ 18 | // [AsmJit::Operand] 19 | // ============================================================================ 20 | 21 | const Operand noOperand; 22 | 23 | // ============================================================================ 24 | // [AsmJit::Imm] 25 | // ============================================================================ 26 | 27 | //! @brief Create signed immediate value operand. 28 | Imm imm(sysint_t i) 29 | { 30 | return Imm(i, false); 31 | } 32 | 33 | //! @brief Create unsigned immediate value operand. 34 | Imm uimm(sysuint_t i) 35 | { 36 | return Imm((sysint_t)i, true); 37 | } 38 | 39 | } // AsmJit namespace 40 | 41 | // [Api-End] 42 | #include "../core/apiend.h" 43 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/apibegin.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [MSVC] 8 | #if defined(_MSC_VER) 9 | 10 | // Disable some warnings we know about 11 | #pragma warning(push) 12 | #pragma warning(disable: 4127) // conditional expression is constant 13 | #pragma warning(disable: 4251) // struct needs to have dll-interface to be used 14 | // by clients of struct ... 15 | #pragma warning(disable: 4275) // non dll-interface struct ... used as base for 16 | // dll-interface struct 17 | #pragma warning(disable: 4355) // this used in base member initializer list 18 | #pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' 19 | 20 | // Rename symbols. 21 | #define vsnprintf _vsnprintf 22 | #define snprintf _snprintf 23 | 24 | #endif // _MSC_VER 25 | 26 | // [GNUC] 27 | #if defined(__GNUC__) 28 | // GCC warnings fix: I can't understand why GCC has no interface to push/pop 29 | // specific warnings. 30 | // # if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 402001 31 | // # pragma GCC diagnostic ignored "-w" 32 | // # endif 33 | #endif // __GNUC__ 34 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/stringutil.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_STRINGUTIL_H 9 | #define _ASMJIT_CORE_STRINGUTIL_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/defs.h" 13 | 14 | namespace AsmJit { 15 | 16 | //! @addtogroup AsmJit_Core 17 | //! @{ 18 | 19 | // ============================================================================ 20 | // [AsmJit::StringUtil] 21 | // ============================================================================ 22 | 23 | //! @brief String utilities. 24 | struct StringUtil 25 | { 26 | ASMJIT_API static char* copy(char* dst, const char* src, size_t len = kInvalidSize); 27 | ASMJIT_API static char* fill(char* dst, const int c, size_t len); 28 | ASMJIT_API static char* hex(char* dst, const uint8_t* src, size_t len); 29 | 30 | ASMJIT_API static char* utoa(char* dst, uintptr_t i, size_t base = 10); 31 | ASMJIT_API static char* itoa(char* dst, intptr_t i, size_t base = 10); 32 | 33 | static inline void memset32(uint32_t* p, uint32_t c, size_t len) 34 | { 35 | for (size_t i = 0; i < len; i++) p[i] = c; 36 | } 37 | }; 38 | 39 | //! @} 40 | 41 | } // AsmJit namespace 42 | 43 | #endif // _ASMJIT_CORE_STRINGUTIL_H 44 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/defs.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/defs.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | namespace AsmJit { 16 | 17 | // ============================================================================ 18 | // [AsmJit::getErrorString] 19 | // ============================================================================ 20 | 21 | const char* getErrorString(uint32_t error) 22 | { 23 | static const char* errorMessage[] = { 24 | "No error", 25 | 26 | "No heap memory", 27 | "No virtual memory", 28 | 29 | "Unknown instruction", 30 | "Illegal instruction", 31 | "Illegal addressing", 32 | "Illegal short jump", 33 | 34 | "No function defined", 35 | "Incomplete function", 36 | 37 | "Not enough registers", 38 | "Registers overlap", 39 | 40 | "Incompatible argument", 41 | "Incompatible return value", 42 | 43 | "Unknown error" 44 | }; 45 | 46 | // Saturate error code to be able to use errorMessage[]. 47 | if (error > kErrorCount) 48 | error = kErrorCount; 49 | 50 | return errorMessage[error]; 51 | } 52 | 53 | } // AsmJit 54 | 55 | // [Api-End] 56 | #include "../core/apiend.h" 57 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/memorymarker.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_MEMORYMARKER_H 9 | #define _ASMJIT_CORE_MEMORYMARKER_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | #include "../core/defs.h" 14 | 15 | // [Api-Begin] 16 | #include "../core/apibegin.h" 17 | 18 | namespace AsmJit { 19 | 20 | //! @addtogroup AsmJit_MemoryManagement 21 | //! @{ 22 | 23 | // ============================================================================ 24 | // [AsmJit::MemoryMarker] 25 | // ============================================================================ 26 | 27 | //! @brief Virtual memory marker interface. 28 | struct MemoryMarker 29 | { 30 | ASMJIT_NO_COPY(MemoryMarker) 31 | 32 | // -------------------------------------------------------------------------- 33 | // [Construction / Destruction] 34 | // -------------------------------------------------------------------------- 35 | 36 | ASMJIT_API MemoryMarker(); 37 | ASMJIT_API virtual ~MemoryMarker(); 38 | 39 | // -------------------------------------------------------------------------- 40 | // [Interface] 41 | // -------------------------------------------------------------------------- 42 | 43 | virtual void mark(const void* ptr, size_t size) = 0; 44 | }; 45 | 46 | //! @} 47 | 48 | } // AsmJit namespace 49 | 50 | // [Api-End] 51 | #include "../core/apiend.h" 52 | 53 | // [Guard] 54 | #endif // _ASMJIT_CORE_MEMORYMARKER_H 55 | -------------------------------------------------------------------------------- /libs/asmjit/extras/contrib/remotecontext.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit/Contrib] 2 | // Remote Context. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. #include #if defined(ASMJIT_WINDOWS) #include "remotecontext.h" namespace AsmJit { RemoteContext::RemoteContext(HANDLE hProcess) : _hProcess(hProcess), _memoryManager(hProcess) { // We are patching another process so set keep-virtual-memory property to // true. _memoryManager.setKeepVirtualMemory(true); } RemoteContext::~RemoteContext() { } uint32_t RemoteContext::generate(void** dest, Assembler* assembler); { // Disallow empty code generation. sysuint_t codeSize = assembler->getCodeSize(); if (codeSize == 0) { *dest = NULL; return AsmJit::kErrorNoFunction; } // Allocate temporary memory where the code will be stored and relocated. void* codeData = ASMJIT_MALLOC(codeSize); if (codeData == NULL) { *dest = NULL; return kErrorNoHeapMemory; } // Memory will be never freed, use pernament allocation. // // NOTE: This allocates memory of the hProcess, not our process. void* processMemPtr = _memoryManager.alloc(codeSize, kMemAllocPermanent); if (processMemPtr == NULL) { ASMJIT_FREE(codeData); *dest = NULL; return kErrorNoVirtualMemory; } // Relocate and write the code to the process memory. assembler->relocCode(codeData, (uintptr_t)processMemPtr); ::WriteProcessMemory(hProcess, processMemPtr, codeData, codeSize, NULL); ASMJIT_FREE(codeData); *dest = processMemPtr; 6 | return kErrorOk; } } // AsmJit namespace #endif // ASMJIT_WINDOWS -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/assert.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_ASSERT_H 9 | #define _ASMJIT_CORE_ASSERT_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | // [Api-Begin] 15 | #include "../core/apibegin.h" 16 | 17 | namespace AsmJit { 18 | 19 | //! @addtogroup AsmJit_Core 20 | //! @{ 21 | 22 | // ============================================================================ 23 | // [AsmJit::Assert] 24 | // ============================================================================ 25 | 26 | //! @brief Called in debug build on assertion failure. 27 | //! @param file Source file name where it happened. 28 | //! @param line Line in the source file. 29 | //! @param exp Expression what failed. 30 | //! 31 | //! If you have problems with assertions simply put a breakpoint into 32 | //! AsmJit::assertionFailure() method (AsmJit/Core/Assert.cpp file) and examine 33 | //! call stack. 34 | ASMJIT_API void assertionFailure(const char* file, int line, const char* exp); 35 | 36 | // ============================================================================ 37 | // [ASMJIT_ASSERT] 38 | // ============================================================================ 39 | 40 | #if defined(ASMJIT_DEBUG) 41 | 42 | #if !defined(ASMJIT_ASSERT) 43 | #define ASMJIT_ASSERT(exp) \ 44 | do { \ 45 | if (!(exp)) ::AsmJit::assertionFailure(__FILE__, __LINE__, #exp); \ 46 | } while(0) 47 | #endif 48 | 49 | #else 50 | 51 | #if !defined(ASMJIT_ASSERT) 52 | #define ASMJIT_ASSERT(exp) ASMJIT_NOP() 53 | #endif 54 | 55 | #endif // DEBUG 56 | 57 | //! @} 58 | 59 | } // AsmJit namespace 60 | 61 | // [Api-End] 62 | #include "../core/apiend.h" 63 | 64 | // [Guard] 65 | #endif // _ASMJIT_CORE_ASSERT_H 66 | -------------------------------------------------------------------------------- /libs/asmjit/extras/contrib/remotecontext.h: -------------------------------------------------------------------------------- 1 | // [AsmJit/Contrib] 2 | // Remote Context. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. // [Guard] #ifndef _ASMJIT_CONTRIB_REMOTECONTEXT_H #define _ASMJIT_CONTRIB_REMOTECONTEXT_H 6 | 7 | #include 8 | #if defined(ASMJIT_WINDOWS) 9 | 10 | namespace AsmJit { // ============================================================================ // [AsmJit::RemoteContext] // ============================================================================ //! @brief RemoteContext can be used to inject code into different process. struct RemoteContext : public Context { // -------------------------------------------------------------------------- // [Construction / Destruction] // -------------------------------------------------------------------------- //! @brief Create a @c RemoteCodeGenerator instance for @a hProcess. RemoteContext(HANDLE hProcess); //! @brief Destroy the @c RemoteCodeGenerator instance. virtual ~RemoteContext(); // -------------------------------------------------------------------------- // [Accessors] // -------------------------------------------------------------------------- //! @brief Get the remote process handle. inline HANDLE getProcess() const 11 | { return _hProcess; } 12 | 13 | //! @brief Get the virtual memory manager. inline VirtualMemoryManager* getMemoryManager() 14 | { return &_memoryManager; } // -------------------------------------------------------------------------- // [Interface] // -------------------------------------------------------------------------- 15 | virtual uint32_t generate(void** dest, Assembler* assembler); // -------------------------------------------------------------------------- // [Members] // -------------------------------------------------------------------------- //! @brief Process. HANDLE _hProcess; //! @brief Virtual memory manager. VirtualMemoryManager _memoryManager; ASMJIT_NO_COPY(RemoteContext) }; } // AsmJit namespace // [Guard] #endif // ASMJIT_WINDOWS #endif // _ASMJIT_CONTRIB_REMOTECONTEXT_H -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/stringutil.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assert.h" 11 | #include "../core/stringutil.h" 12 | 13 | // [Api-Begin] 14 | #include "../core/apibegin.h" 15 | 16 | namespace AsmJit { 17 | 18 | // ============================================================================ 19 | // [AsmJit::StringUtil] 20 | // ============================================================================ 21 | 22 | static const char letters[] = "0123456789ABCDEF"; 23 | 24 | char* StringUtil::copy(char* dst, const char* src, size_t len) 25 | { 26 | if (src == NULL) 27 | return dst; 28 | 29 | if (len == kInvalidSize) 30 | { 31 | while (*src) *dst++ = *src++; 32 | } 33 | else 34 | { 35 | memcpy(dst, src, len); 36 | dst += len; 37 | } 38 | 39 | return dst; 40 | } 41 | 42 | char* StringUtil::fill(char* dst, const int c, size_t len) 43 | { 44 | memset(dst, c, len); 45 | return dst + len; 46 | } 47 | 48 | char* StringUtil::hex(char* dst, const uint8_t* src, size_t len) 49 | { 50 | for (size_t i = len; i; i--, dst += 2, src += 1) 51 | { 52 | dst[0] = letters[(src[0] >> 4) & 0xF]; 53 | dst[1] = letters[(src[0] ) & 0xF]; 54 | } 55 | 56 | return dst; 57 | } 58 | 59 | // Not too efficient, but this is mainly for debugging:) 60 | char* StringUtil::utoa(char* dst, uintptr_t i, size_t base) 61 | { 62 | ASMJIT_ASSERT(base <= 16); 63 | 64 | char buf[128]; 65 | char* p = buf + 128; 66 | 67 | do { 68 | uintptr_t b = i % base; 69 | *--p = letters[b]; 70 | i /= base; 71 | } while (i); 72 | 73 | return StringUtil::copy(dst, p, (size_t)(buf + 128 - p)); 74 | } 75 | 76 | char* StringUtil::itoa(char* dst, intptr_t i, size_t base) 77 | { 78 | if (i < 0) 79 | { 80 | *dst++ = '-'; 81 | i = -i; 82 | } 83 | 84 | return StringUtil::utoa(dst, (size_t)i, base); 85 | } 86 | 87 | } // AsmJit namespace 88 | 89 | // [Api-End] 90 | #include "../core/apiend.h" 91 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/buffer.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/buffer.h" 11 | #include "../core/defs.h" 12 | 13 | // [Api-Begin] 14 | #include "../core/apibegin.h" 15 | 16 | namespace AsmJit { 17 | 18 | // ============================================================================ 19 | // [AsmJit::Buffer] 20 | // ============================================================================ 21 | 22 | void Buffer::emitData(const void* ptr, size_t len) 23 | { 24 | size_t max = getCapacity() - getOffset(); 25 | 26 | if (max < len && !realloc(getOffset() + len)) 27 | { 28 | return; 29 | } 30 | 31 | memcpy(_cur, ptr, len); 32 | _cur += len; 33 | } 34 | 35 | bool Buffer::realloc(size_t to) 36 | { 37 | if (getCapacity() < to) 38 | { 39 | size_t len = getOffset(); 40 | uint8_t *newdata; 41 | 42 | if (_data != NULL) 43 | newdata = (uint8_t*)ASMJIT_REALLOC(_data, to); 44 | else 45 | newdata = (uint8_t*)ASMJIT_MALLOC(to); 46 | 47 | if (newdata == NULL) 48 | return false; 49 | 50 | _data = newdata; 51 | _cur = newdata + len; 52 | _max = newdata + to; 53 | _max -= (to >= kBufferGrow) ? kBufferGrow : to; 54 | 55 | _capacity = to; 56 | } 57 | 58 | return true; 59 | } 60 | 61 | bool Buffer::grow() 62 | { 63 | size_t to = _capacity; 64 | 65 | if (to < 512) 66 | to = 1024; 67 | else if (to > 65536) 68 | to += 65536; 69 | else 70 | to <<= 1; 71 | 72 | return realloc(to); 73 | } 74 | 75 | void Buffer::reset() 76 | { 77 | if (_data == NULL) 78 | return; 79 | ASMJIT_FREE(_data); 80 | 81 | _data = NULL; 82 | _cur = NULL; 83 | _max = NULL; 84 | _capacity = 0; 85 | } 86 | 87 | uint8_t* Buffer::take() 88 | { 89 | uint8_t* data = _data; 90 | 91 | _data = NULL; 92 | _cur = NULL; 93 | _max = NULL; 94 | _capacity = 0; 95 | 96 | return data; 97 | } 98 | 99 | } // AsmJit namespace 100 | 101 | // [Api-End] 102 | #include "../core/apiend.h" 103 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/config.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CONFIG_H 9 | #define _ASMJIT_CONFIG_H 10 | 11 | // This file is designed to be modifyable. Platform specific changes should 12 | // be applied to this file so it's guaranteed that never versions of AsmJit 13 | // library will never overwrite generated config files. 14 | // 15 | // So modify this file by your build system or by hand. 16 | 17 | // ============================================================================ 18 | // [AsmJit - OS] 19 | // ============================================================================ 20 | 21 | // Provides definitions about your operating system. It's detected by default, 22 | // so override it if you have problems with automatic detection. 23 | // 24 | // #define ASMJIT_WINDOWS 25 | // #define ASMJIT_POSIX 26 | 27 | // ============================================================================ 28 | // [AsmJit - Architecture] 29 | // ============================================================================ 30 | 31 | // Provides definitions about your cpu architecture. It's detected by default, 32 | // so override it if you have problems with automatic detection. 33 | 34 | // #define ASMJIT_X86 35 | // #define ASMJIT_X64 36 | 37 | // ============================================================================ 38 | // [AsmJit - API] 39 | // ============================================================================ 40 | 41 | // If you are embedding AsmJit library into your project (statically), undef 42 | // ASMJIT_API macro. 43 | // #define ASMJIT_API 44 | 45 | // ============================================================================ 46 | // [AsmJit - Memory Management] 47 | // ============================================================================ 48 | 49 | // #define ASMJIT_MALLOC ::malloc 50 | // #define ASMJIT_REALLOC ::realloc 51 | // #define ASMJIT_FREE ::free 52 | 53 | // ============================================================================ 54 | // [AsmJit - Debug] 55 | // ============================================================================ 56 | 57 | // Turn debug on/off (to bypass autodetection) 58 | // #define ASMJIT_DEBUG 59 | // #define ASMJIT_NO_DEBUG 60 | 61 | // Setup custom assertion code. 62 | // #define ASMJIT_ASSERT(exp) do { if (!(exp)) ::AsmJit::assertionFailure(__FILE__, __LINE__, #exp); } while(0) 63 | 64 | // [Guard] 65 | #endif // _ASMJIT_CONFIG_H 66 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/cpuinfo.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/cpuinfo.h" 11 | 12 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 13 | #include "../x86/x86cpuinfo.h" 14 | #else 15 | // ? 16 | #endif // ASMJIT_X86 || ASMJIT_X64 17 | 18 | // [Dependencies - Windows] 19 | #if defined(ASMJIT_WINDOWS) 20 | # include 21 | #endif // ASMJIT_WINDOWS 22 | 23 | // [Dependencies - Posix] 24 | #if defined(ASMJIT_POSIX) 25 | # include 26 | # include 27 | # include 28 | # include 29 | #endif // ASMJIT_POSIX 30 | 31 | // [Api-Begin] 32 | #include "../core/apibegin.h" 33 | 34 | namespace AsmJit { 35 | 36 | // ============================================================================ 37 | // [AsmJit::CpuInfo - DetectNumberOfProcessors] 38 | // ============================================================================ 39 | 40 | uint32_t CpuInfo::detectNumberOfProcessors() 41 | { 42 | #if defined(ASMJIT_WINDOWS) 43 | SYSTEM_INFO info; 44 | ::GetSystemInfo(&info); 45 | return info.dwNumberOfProcessors; 46 | #elif defined(ASMJIT_POSIX) && defined(_SC_NPROCESSORS_ONLN) 47 | // It seems that sysconf returns the number of "logical" processors on both 48 | // mac and linux. So we get the number of "online logical" processors. 49 | long res = ::sysconf(_SC_NPROCESSORS_ONLN); 50 | if (res == -1) return 1; 51 | 52 | return static_cast(res); 53 | #else 54 | return 1; 55 | #endif 56 | } 57 | 58 | // ============================================================================ 59 | // [AsmJit::CpuInfo - GetGlobal] 60 | // ============================================================================ 61 | 62 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 63 | struct InitializedCpuInfo : public X86CpuInfo 64 | { 65 | inline InitializedCpuInfo() : 66 | X86CpuInfo() 67 | { 68 | x86CpuDetect(this); 69 | } 70 | }; 71 | #else 72 | #error "AsmJit::CpuInfo - Unsupported CPU or compiler." 73 | #endif // ASMJIT_X86 || ASMJIT_X64 74 | 75 | const CpuInfo* CpuInfo::getGlobal() 76 | { 77 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 78 | static InitializedCpuInfo cpuInfo; 79 | #else 80 | #error "AsmJit::CpuInfo - Unsupported CPU or compiler." 81 | #endif // ASMJIT_X86 || ASMJIT_X64 82 | return &cpuInfo; 83 | } 84 | 85 | } // AsmJit 86 | 87 | // [Api-End] 88 | #include "../core/apiend.h" 89 | -------------------------------------------------------------------------------- /libs/asmjit/src/app/test/testdummy.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // This file is used as a dummy test. It's changed during development. 8 | 9 | // [Dependencies - AsmJit] 10 | #include 11 | 12 | // [Dependencies - C] 13 | #include 14 | #include 15 | #include 16 | 17 | // This is type of function we will generate 18 | typedef void (*MyFn)(void); 19 | 20 | static void dummyFunc(void) {} 21 | 22 | int main(int argc, char* argv[]) 23 | { 24 | using namespace AsmJit; 25 | 26 | // ========================================================================== 27 | // Log compiler output. 28 | FileLogger logger(stderr); 29 | logger.setLogBinary(true); 30 | 31 | // Create compiler. 32 | /* 33 | X86Compiler c; 34 | c.setLogger(&logger); 35 | 36 | c.newFunc(kX86FuncConvDefault, FuncBuilder0()); 37 | c.getFunc()->setHint(kFuncHintNaked, true); 38 | 39 | X86CompilerFuncCall* ctx = c.call((void*)dummyFunc); 40 | ctx->setPrototype(kX86FuncConvDefault, FuncBuilder0()); 41 | 42 | c.endFunc(); 43 | */ 44 | 45 | X86Compiler c; 46 | c.setLogger(&logger); 47 | 48 | c.newFunc(kX86FuncConvDefault, FuncBuilder0()); 49 | c.getFunc()->setHint(kFuncHintNaked, true); 50 | 51 | Label l91 = c.newLabel(); 52 | Label l92 = c.newLabel(); 53 | Label l93 = c.newLabel(); 54 | Label l94 = c.newLabel(); 55 | Label l95 = c.newLabel(); 56 | Label l96 = c.newLabel(); 57 | Label l97 = c.newLabel(); 58 | c.bind(l92); 59 | 60 | GpVar _var91(c.newGpVar()); 61 | GpVar _var92(c.newGpVar()); 62 | 63 | c.bind(l93); 64 | c.jmp(l91); 65 | c.bind(l95); 66 | c.mov(_var91, imm(0)); 67 | c.bind(l96); 68 | c.jmp(l93); 69 | c.mov(_var92, imm(1)); 70 | c.jmp(l91); 71 | c.bind(l94); 72 | c.jmp(l92); 73 | c.bind(l97); 74 | c.add(_var91, _var92); 75 | c.bind(l91); 76 | c.ret(); 77 | c.endFunc(); 78 | 79 | typedef void (*Func9)(void); 80 | Func9 func9 = asmjit_cast(c.make()); 81 | // ========================================================================== 82 | 83 | // ========================================================================== 84 | // Make the function. 85 | // MyFn fn = asmjit_cast(c.make()); 86 | 87 | // Call it. 88 | // printf("Result %llu\n", (unsigned long long)fn()); 89 | 90 | // Free the generated function if it's not needed anymore. 91 | //MemoryManager::getGlobal()->free((void*)fn); 92 | // ========================================================================== 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/context.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assembler.h" 11 | #include "../core/context.h" 12 | #include "../core/defs.h" 13 | #include "../core/memorymanager.h" 14 | #include "../core/memorymarker.h" 15 | 16 | namespace AsmJit { 17 | 18 | // ============================================================================ 19 | // [AsmJit::Context - Construction / Destruction] 20 | // ============================================================================ 21 | 22 | Context::Context() {} 23 | Context::~Context() {} 24 | 25 | // ============================================================================ 26 | // [AsmJit::JitContext - Construction / Destruction] 27 | // ============================================================================ 28 | 29 | JitContext::JitContext() : 30 | _memoryManager(NULL), 31 | _memoryMarker(NULL), 32 | _allocType(kMemAllocFreeable) 33 | { 34 | } 35 | 36 | JitContext::~JitContext() 37 | { 38 | } 39 | 40 | // ============================================================================ 41 | // [AsmJit::JitContext - Generate] 42 | // ============================================================================ 43 | 44 | uint32_t JitContext::generate(void** dest, Assembler* assembler) 45 | { 46 | // Disallow empty code generation. 47 | size_t codeSize = assembler->getCodeSize(); 48 | if (codeSize == 0) 49 | { 50 | *dest = NULL; 51 | return kErrorNoFunction; 52 | } 53 | 54 | // Switch to global memory manager if not provided. 55 | MemoryManager* memmgr = getMemoryManager(); 56 | 57 | if (memmgr == NULL) 58 | memmgr = MemoryManager::getGlobal(); 59 | 60 | void* p = memmgr->alloc(codeSize, getAllocType()); 61 | if (p == NULL) 62 | { 63 | *dest = NULL; 64 | return kErrorNoVirtualMemory; 65 | } 66 | 67 | // Relocate the code. 68 | size_t relocatedSize = assembler->relocCode(p); 69 | 70 | // Return unused memory to MemoryManager. 71 | if (relocatedSize < codeSize) 72 | memmgr->shrink(p, relocatedSize); 73 | 74 | // Mark memory if MemoryMarker provided. 75 | if (_memoryMarker) 76 | _memoryMarker->mark(p, relocatedSize); 77 | 78 | // Return the code. 79 | *dest = p; 80 | return kErrorOk; 81 | } 82 | 83 | // ============================================================================ 84 | // [AsmJit::JitContext - GetGlobal] 85 | // ============================================================================ 86 | 87 | JitContext* JitContext::getGlobal() 88 | { 89 | static JitContext global; 90 | return &global; 91 | } 92 | 93 | } // AsmJit namespace 94 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/virtualmemory.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_VIRTUALMEMORY_H 9 | #define _ASMJIT_CORE_VIRTUALMEMORY_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | // [Api-Begin] 15 | #include "../core/apibegin.h" 16 | 17 | namespace AsmJit { 18 | 19 | //! @addtogroup AsmJit_Core 20 | //! @{ 21 | 22 | // ============================================================================ 23 | // [AsmJit::VirtualMemory] 24 | // ============================================================================ 25 | 26 | //! @brief Class that helps with allocating memory for executing code 27 | //! generated by JIT compiler. 28 | //! 29 | //! There are defined functions that provides facility to allocate and free 30 | //! memory where can be executed code. If processor and operating system 31 | //! supports execution protection then you can't run code from normally 32 | //! malloc()'ed memory. 33 | //! 34 | //! Functions are internally implemented by operating system dependent way. 35 | //! VirtualAlloc() function is used for Windows operating system and mmap() 36 | //! for posix ones. If you want to study or create your own functions, look 37 | //! at VirtualAlloc() or mmap() documentation (depends on you target OS). 38 | //! 39 | //! Under posix operating systems is also useable mprotect() function, that 40 | //! can enable execution protection to malloc()'ed memory block. 41 | struct VirtualMemory 42 | { 43 | //! @brief Allocate virtual memory. 44 | //! 45 | //! Pages are readable/writeable, but they are not guaranteed to be 46 | //! executable unless 'canExecute' is true. Returns the address of 47 | //! allocated memory, or NULL if failed. 48 | ASMJIT_API static void* alloc(size_t length, size_t* allocated, bool canExecute); 49 | 50 | //! @brief Free memory allocated by @c alloc() 51 | ASMJIT_API static void free(void* addr, size_t length); 52 | 53 | #if defined(ASMJIT_WINDOWS) 54 | //! @brief Allocate virtual memory of @a hProcess. 55 | //! 56 | //! @note This function is Windows specific. 57 | ASMJIT_API static void* allocProcessMemory(HANDLE hProcess, size_t length, size_t* allocated, bool canExecute); 58 | 59 | //! @brief Free virtual memory of @a hProcess. 60 | //! 61 | //! @note This function is Windows specific. 62 | ASMJIT_API static void freeProcessMemory(HANDLE hProcess, void* addr, size_t length); 63 | #endif // ASMJIT_WINDOWS 64 | 65 | //! @brief Get the alignment guaranteed by alloc(). 66 | ASMJIT_API static size_t getAlignment(); 67 | 68 | //! @brief Get size of single page. 69 | ASMJIT_API static size_t getPageSize(); 70 | }; 71 | 72 | //! @} 73 | 74 | } // AsmJit namespace 75 | 76 | // [Api-End] 77 | #include "../core/apiend.h" 78 | 79 | // [Guard] 80 | #endif // _ASMJIT_CORE_VIRTUALMEMORY_H 81 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/zonememory.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/defs.h" 11 | #include "../core/intutil.h" 12 | #include "../core/zonememory.h" 13 | 14 | // [Api-Begin] 15 | #include "../core/apibegin.h" 16 | 17 | namespace AsmJit { 18 | 19 | // ============================================================================ 20 | // [AsmJit::ZoneMemory] 21 | // ============================================================================ 22 | 23 | ZoneMemory::ZoneMemory(size_t chunkSize) 24 | { 25 | _chunks = NULL; 26 | _total = 0; 27 | _chunkSize = chunkSize; 28 | } 29 | 30 | ZoneMemory::~ZoneMemory() 31 | { 32 | reset(); 33 | } 34 | 35 | void* ZoneMemory::alloc(size_t size) 36 | { 37 | ZoneChunk* cur = _chunks; 38 | 39 | // Align to 4 or 8 bytes. 40 | size = IntUtil::align(size, sizeof(size_t)); 41 | 42 | if (cur == NULL || cur->getRemainingBytes() < size) 43 | { 44 | size_t chSize = _chunkSize; 45 | 46 | if (chSize < size) 47 | chSize = size; 48 | 49 | cur = (ZoneChunk*)ASMJIT_MALLOC(sizeof(ZoneChunk) - sizeof(void*) + chSize); 50 | if (cur == NULL) 51 | return NULL; 52 | 53 | cur->prev = _chunks; 54 | cur->pos = 0; 55 | cur->size = chSize; 56 | 57 | _chunks = cur; 58 | } 59 | 60 | uint8_t* p = cur->data + cur->pos; 61 | cur->pos += size; 62 | _total += size; 63 | 64 | ASMJIT_ASSERT(cur->pos <= cur->size); 65 | return (void*)p; 66 | } 67 | 68 | char* ZoneMemory::sdup(const char* str) 69 | { 70 | if (str == NULL) return NULL; 71 | 72 | size_t len = strlen(str); 73 | if (len == 0) return NULL; 74 | 75 | // Include NULL terminator and limit string length. 76 | if (++len > 256) 77 | len = 256; 78 | 79 | char* m = reinterpret_cast(alloc(IntUtil::align(len, 16))); 80 | if (m == NULL) 81 | return NULL; 82 | 83 | memcpy(m, str, len); 84 | m[len - 1] = '\0'; 85 | return m; 86 | } 87 | 88 | void ZoneMemory::clear() 89 | { 90 | ZoneChunk* cur = _chunks; 91 | 92 | if (cur == NULL) 93 | return; 94 | 95 | cur = cur->prev; 96 | while (cur != NULL) 97 | { 98 | ZoneChunk* prev = cur->prev; 99 | ASMJIT_FREE(cur); 100 | cur = prev; 101 | } 102 | 103 | _chunks->pos = 0; 104 | _chunks->prev = NULL; 105 | _total = 0; 106 | } 107 | 108 | void ZoneMemory::reset() 109 | { 110 | ZoneChunk* cur = _chunks; 111 | 112 | _chunks = NULL; 113 | _total = 0; 114 | 115 | while (cur != NULL) 116 | { 117 | ZoneChunk* prev = cur->prev; 118 | ASMJIT_FREE(cur); 119 | cur = prev; 120 | } 121 | } 122 | 123 | } // AsmJit namespace 124 | 125 | // [Api-End] 126 | #include "../core/apiend.h" 127 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/compilercontext.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_COMPILERCONTEXT_H 9 | #define _ASMJIT_CORE_COMPILERCONTEXT_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/compiler.h" 13 | #include "../core/compilerfunc.h" 14 | #include "../core/compileritem.h" 15 | #include "../core/zonememory.h" 16 | 17 | // [Api-Begin] 18 | #include "../core/apibegin.h" 19 | 20 | namespace AsmJit { 21 | 22 | // ============================================================================ 23 | // [AsmJit::CompilerContext] 24 | // ============================================================================ 25 | 26 | struct CompilerContext 27 | { 28 | ASMJIT_NO_COPY(CompilerContext) 29 | 30 | // -------------------------------------------------------------------------- 31 | // [Construction / Destruction] 32 | // -------------------------------------------------------------------------- 33 | 34 | ASMJIT_API CompilerContext(Compiler* compiler); 35 | ASMJIT_API virtual ~CompilerContext(); 36 | 37 | // -------------------------------------------------------------------------- 38 | // [Accessor] 39 | // -------------------------------------------------------------------------- 40 | 41 | inline Compiler* getCompiler() const 42 | { return _compiler; } 43 | 44 | inline CompilerFuncDecl* getFunc() const 45 | { return _func; } 46 | 47 | inline CompilerItem* getExtraBlock() const 48 | { return _extraBlock; } 49 | 50 | inline void setExtraBlock(CompilerItem* item) 51 | { _extraBlock = item; } 52 | 53 | // -------------------------------------------------------------------------- 54 | // [Members] 55 | // -------------------------------------------------------------------------- 56 | 57 | //! @brief ZoneMemory manager. 58 | ZoneMemory _zoneMemory; 59 | 60 | //! @brief Compiler. 61 | Compiler* _compiler; 62 | //! @brief Function. 63 | CompilerFuncDecl* _func; 64 | 65 | //! @brief Start of the current active scope. 66 | CompilerItem* _start; 67 | //! @brief End of the current active scope. 68 | CompilerItem* _stop; 69 | //! @brief Item that is used to insert some code after the function body. 70 | CompilerItem* _extraBlock; 71 | 72 | //! @brief Current state (used by register allocator). 73 | CompilerState* _state; 74 | //! @brief Link to circular double-linked list containing all active variables 75 | //! of the current state. 76 | CompilerVar* _active; 77 | 78 | //! @brief Current offset, used in prepare() stage. Each item should increment it. 79 | uint32_t _currentOffset; 80 | //! @brief Whether current code is unreachable. 81 | uint32_t _isUnreachable; 82 | }; 83 | 84 | } // AsmJit namespace 85 | 86 | // [Api-End] 87 | #include "../core/apiend.h" 88 | 89 | // [Guard] 90 | #endif // _ASMJIT_CORE_COMPILERCONTEXT_H 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JitCalc 2 | ======= 3 | 4 | A small program demonstrating how to use [AsmJit](http://code.google.com/p/asmjit/) to create a just-in-time mathematical expression evaluator. Further description of JitCalc and AsmJit [can be found in this blog post](http://www.lukedodd.com/?p=337). 5 | 6 | 7 | The objectives are to demonstrate how to use AsmJit (right now there are few examples online) and to demonstrate how much faster JIT code generation can be. 8 | 9 | For a more serious expression evaulator please see [mathspresso](https://code.google.com/p/mathpresso/). 10 | 11 | Compiling 12 | --------- 13 | 14 | This project uses a CMake build. You'll need a recent version of GCC or clang (C++11 features used). 15 | 16 | # git checkout 17 | git clone https://github.com/lukedodd/JitCalc.git 18 | # make build directory 19 | mdkir build-jitcalc 20 | cd build-jitcalc/ 21 | # run cmake and compile 22 | cmake ../JitCalc 23 | make 24 | # run an example 25 | ./jitcalc "((x y) (+ x (/ y 2)))" 5 20.5 26 | 27 | Tested on x86-64 Linux only. I would expect x86-64 OSX to work too. Windows (visual studio 2010+) might just work (perhaps requring small tweaks) but it has not been tested yet, the same is true of 32bit. 28 | 29 | Usage 30 | ----- 31 | 32 | 33 | Expressions are lisp like. Operations supported are addition, subtraction, multiplication and division (+, -, *, /). 34 | 35 | Code should be supplied to the jitcalc command in the first argument. An S-Expression of this form is expected `((args...) (expr))`. Subsequent command line arguments are bound to the function arguments of the supplied expression. Some examples should make this clear! 36 | 37 | $ ./jitcalc "((x) (+ x 10))" 5 # add 10 to x, which is bound to 5 38 | Interpreted output: 15 39 | Code gen output: 15 40 | 41 | $ ./jitcalc "((x y) (+ x y))" 100 1 # add two arguments 42 | Interpreted output: 101 43 | Code gen output: 101 44 | 45 | $ ./jitcalc "((x y) (+ x (* y 2)))" 2 2.5 # multiply second argument by 2 and add to first argument 46 | Interpreted output: 7 47 | Code gen output: 7 48 | 49 | $ # more complex expression 50 | $ ./jitcalc "((x y) (+ (* (+ x 20) y) (/ x (+ y 1))))" 1 10 51 | Interpreted output: 210.091 52 | Code gen output: 210.091 53 | 54 | Benchmark Results 55 | ----------------- 56 | 57 | Here are benchmark command examples and results. 58 | 59 | $ ./jitcalc -benchmark "((x y) (* x (+ y 10)))" 5 10 60 | Interpreted output: 100 61 | Code gen output: 100 62 | 63 | Benchmarking... 64 | Duration for 10000000 repeated evaluations: 65 | 66 | - Interpreted: 2532ms 67 | - JIT: 19ms 68 | 69 | $ ./jitcalc -benchmark "((x y) (+ (* (+ x 20) y) (/ x (+ y 1))))" 15.5 20 70 | Interpreted output: 710.738 71 | Code gen output: 710.738 72 | 73 | Benchmarking... 74 | Duration for 10000000 repeated evaluations: 75 | 76 | - Interpreted: 5732ms 77 | - JIT: 52ms 78 | 79 | License 80 | ------- 81 | 82 | This code is under the [BSD 2-Clause](http://opensource.org/licenses/BSD-2-Clause) license. 83 | -------------------------------------------------------------------------------- /libs/asmjit/scripts/generate-defs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # ============================================================================= 4 | # [generate-defs.py] 5 | # 6 | # The purpose of this script is to fetch all instruction names into single 7 | # string which won't cause huge reallocation by the linker. The script is 8 | # included for pure optimization purposes (decrease binary size and count of 9 | # relocation). 10 | # ============================================================================= 11 | 12 | # ============================================================================= 13 | # [Configuration] 14 | # ============================================================================= 15 | 16 | # Files to process. 17 | FILES = [ 18 | { "file": "../src/asmjit/x86/x86defs.cpp", "arch": "x86" } 19 | ] 20 | 21 | # ============================================================================= 22 | # [Imports] 23 | # ============================================================================= 24 | 25 | import os, re, string 26 | 27 | # ============================================================================= 28 | # [Helpers] 29 | # ============================================================================= 30 | 31 | def readFile(fileName): 32 | handle = open(fileName, "rb") 33 | data = handle.read() 34 | handle.close() 35 | return data 36 | 37 | def writeFile(fileName, data): 38 | handle = open(fileName, "wb") 39 | handle.truncate() 40 | handle.write(data) 41 | handle.close() 42 | 43 | # ============================================================================= 44 | # [Main] 45 | # ============================================================================= 46 | 47 | def processFile(fileName, arch): 48 | data = readFile(fileName); 49 | ARCH = arch.upper(); 50 | 51 | dIn = data 52 | r = re.compile(arch + r"InstInfo\[\][\s]*=[\s]*{(?P[^}])*}") 53 | m = r.search(dIn) 54 | 55 | if not m: 56 | print "Couldn't match " + arch + "InstInfo[] in " + fileName 57 | exit(0) 58 | 59 | dIn = dIn[m.start():m.end()] 60 | dOut = "" 61 | 62 | hInstId = {} 63 | 64 | dInstId = [] 65 | dInstAddr = [] 66 | 67 | dInstStr = [] 68 | dInstPos = 0 69 | 70 | r = re.compile(r'INST\((?P[A-Za-z0-9_]+)\s*,\s*\"(?P[A-Za-z0-9_ ]*)\"') 71 | for m in r.finditer(dIn): 72 | kId = m.group("kId") 73 | kStr = m.group("kStr") 74 | 75 | if not kId in hInstId: 76 | dInstStr.append(kStr) 77 | dInstId.append(kId) 78 | hInstId[kId] = dInstPos 79 | 80 | dInstAddr.append(dInstPos) 81 | dInstPos += len(kStr) + 1 82 | 83 | dOut += "const char " + arch + "InstName[] =\n" 84 | for i in xrange(len(dInstStr)): 85 | dOut += " \"" + dInstStr[i] + "\\0\"\n" 86 | dOut += " ;\n" 87 | 88 | dOut += "\n" 89 | 90 | for i in xrange(len(dInstId)): 91 | dOut += "#define INDEX_" + dInstId[i] + " " + str(dInstAddr[i]) + "\n" 92 | 93 | mb_string = "// ${" + ARCH + "_INST_DATA:BEGIN}\n" 94 | me_string = "// ${" + ARCH + "_INST_DATA:END}\n" 95 | 96 | mb = data.index(mb_string) 97 | me = data.index(me_string) 98 | 99 | data = data[:mb + len(mb_string)] + dOut + data[me:] 100 | writeFile(fileName, data) 101 | 102 | for item in FILES: 103 | processFile(item["file"], item["arch"]) 104 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/x86/x86util.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../x86/x86defs.h" 11 | 12 | // [Api-Begin] 13 | #include "../core/apibegin.h" 14 | 15 | namespace AsmJit { 16 | 17 | // ============================================================================ 18 | // [AsmJit::_x86UtilJccFromCond] 19 | // ============================================================================ 20 | 21 | const uint32_t _x86UtilJccFromCond[20] = 22 | { 23 | kX86InstJO, 24 | kX86InstJNO, 25 | kX86InstJB, 26 | kX86InstJAE, 27 | kX86InstJE, 28 | kX86InstJNE, 29 | kX86InstJBE, 30 | kX86InstJA, 31 | kX86InstJS, 32 | kX86InstJNS, 33 | kX86InstJPE, 34 | kX86InstJPO, 35 | kX86InstJL, 36 | kX86InstJGE, 37 | kX86InstJLE, 38 | kX86InstJG, 39 | 40 | kInstNone, 41 | kInstNone, 42 | kInstNone, 43 | kInstNone 44 | }; 45 | 46 | // ============================================================================ 47 | // [AsmJit::_x86UtilMovccFromCond] 48 | // ============================================================================ 49 | 50 | const uint32_t _x86UtilMovccFromCond[20] = 51 | { 52 | kX86InstCMovO, 53 | kX86InstCMovNO, 54 | kX86InstCMovB, 55 | kX86InstCMovAE, 56 | kX86InstCMovE, 57 | kX86InstCMovNE, 58 | kX86InstCMovBE, 59 | kX86InstCMovA, 60 | kX86InstCMovS, 61 | kX86InstCMovNS, 62 | kX86InstCMovPE, 63 | kX86InstCMovPO, 64 | kX86InstCMovL, 65 | kX86InstCMovGE, 66 | kX86InstCMovLE, 67 | kX86InstCMovG, 68 | 69 | kInstNone, 70 | kInstNone, 71 | kInstNone, 72 | kInstNone 73 | }; 74 | 75 | // ============================================================================ 76 | // [AsmJit::_x86UtilSetccFromCond] 77 | // ============================================================================ 78 | 79 | const uint32_t _x86UtilSetccFromCond[20] = 80 | { 81 | kX86InstSetO, 82 | kX86InstSetNO, 83 | kX86InstSetB, 84 | kX86InstSetAE, 85 | kX86InstSetE, 86 | kX86InstSetNE, 87 | kX86InstSetBE, 88 | kX86InstSetA, 89 | kX86InstSetS, 90 | kX86InstSetNS, 91 | kX86InstSetPE, 92 | kX86InstSetPO, 93 | kX86InstSetL, 94 | kX86InstSetGE, 95 | kX86InstSetLE, 96 | kX86InstSetG, 97 | 98 | kInstNone, 99 | kInstNone, 100 | kInstNone, 101 | kInstNone 102 | }; 103 | 104 | // ============================================================================ 105 | // [AsmJit::_x86UtilReversedCond] 106 | // ============================================================================ 107 | 108 | const uint32_t _x86UtilReversedCond[20] = 109 | { 110 | /* x86CondO -> */ kX86CondO, 111 | /* x86CondNO -> */ kX86CondNO, 112 | /* x86CondB -> */ kX86CondA, 113 | /* x86CondAE -> */ kX86CondBE, 114 | /* x86CondE -> */ kX86CondE, 115 | /* x86CondNE -> */ kX86CondNE, 116 | /* x86CondBE -> */ kX86CondAE, 117 | /* x86CondA -> */ kX86CondB, 118 | /* x86CondS -> */ kX86CondS, 119 | /* x86CondNS -> */ kX86CondNS, 120 | /* x86CondPE -> */ kX86CondPE, 121 | /* x86CondPO -> */ kX86CondPO, 122 | 123 | /* x86CondL -> */ kX86CondG, 124 | /* x86CondGE -> */ kX86CondLE, 125 | 126 | /* x86CondLE -> */ kX86CondGE, 127 | /* x86CondG -> */ kX86CondL, 128 | 129 | /* kX86CondFpuUnordered -> */ kX86CondFpuUnordered, 130 | /* kX86CondFpuNotUnordered -> */ kX86CondFpuNotUnordered, 131 | 132 | 0x12, 133 | 0x13 134 | }; 135 | 136 | } // AsmJit namespace 137 | 138 | #include "../core/apiend.h" 139 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/cpuinfo.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_CPUINFO_H 9 | #define _ASMJIT_CORE_CPUINFO_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | // [Api-Begin] 15 | #include "../core/apibegin.h" 16 | 17 | namespace AsmJit { 18 | 19 | //! @addtogroup AsmJit_Core 20 | //! @{ 21 | 22 | // ============================================================================ 23 | // [AsmJit::CpuInfo] 24 | // ============================================================================ 25 | 26 | //! @brief Informations about host cpu. 27 | struct CpuInfo 28 | { 29 | // -------------------------------------------------------------------------- 30 | // [Construction / Destruction] 31 | // -------------------------------------------------------------------------- 32 | 33 | inline CpuInfo(uint32_t size = sizeof(CpuInfo)) : 34 | _size(size) 35 | { 36 | } 37 | 38 | // -------------------------------------------------------------------------- 39 | // [Accessors] 40 | // -------------------------------------------------------------------------- 41 | 42 | //! @brief Get CPU vendor string. 43 | inline const char* getVendorString() const { return _vendorString; } 44 | //! @brief Get CPU brand string. 45 | inline const char* getBrandString() const { return _brandString; } 46 | 47 | //! @brief Get CPU vendor ID. 48 | inline uint32_t getVendorId() const { return _vendorId; } 49 | //! @brief Get CPU family ID. 50 | inline uint32_t getFamily() const { return _family; } 51 | //! @brief Get CPU model ID. 52 | inline uint32_t getModel() const { return _model; } 53 | //! @brief Get CPU stepping. 54 | inline uint32_t getStepping() const { return _stepping; } 55 | //! @brief Get CPU count. 56 | inline uint32_t getNumberOfProcessors() const { return _numberOfProcessors; } 57 | //! @brief Get CPU features. 58 | inline uint32_t getFeatures() const { return _features; } 59 | //! @brief Get CPU bugs. 60 | inline uint32_t getBugs() const { return _bugs; } 61 | 62 | //! @brief Get whether CPU has feature @a feature. 63 | inline bool hasFeature(uint32_t feature) { return (_features & feature) != 0; } 64 | //! @brief Get whether CPU has bug @a bug. 65 | inline bool hasBug(uint32_t bug) { return (_bugs & bug) != 0; } 66 | 67 | // -------------------------------------------------------------------------- 68 | // [Statics] 69 | // -------------------------------------------------------------------------- 70 | 71 | //! @brief Detect number of processors. 72 | ASMJIT_API static uint32_t detectNumberOfProcessors(); 73 | 74 | //! @brief Get global instance of @ref CpuInfo. 75 | ASMJIT_API static const CpuInfo* getGlobal(); 76 | 77 | // -------------------------------------------------------------------------- 78 | // [Members] 79 | // -------------------------------------------------------------------------- 80 | 81 | //! @brief Size of CpuInfo structure (in bytes). 82 | uint32_t _size; 83 | 84 | //! @brief Cpu short vendor string. 85 | char _vendorString[16]; 86 | //! @brief Cpu long vendor string (brand). 87 | char _brandString[64]; 88 | 89 | //! @brief Cpu vendor id (see @c AsmJit::CpuInfo::VendorId enum). 90 | uint32_t _vendorId; 91 | //! @brief Cpu family ID. 92 | uint32_t _family; 93 | //! @brief Cpu model ID. 94 | uint32_t _model; 95 | //! @brief Cpu stepping. 96 | uint32_t _stepping; 97 | //! @brief Number of processors or cores. 98 | uint32_t _numberOfProcessors; 99 | //! @brief Cpu features bitfield, see @c AsmJit::CpuInfo::Feature enum). 100 | uint32_t _features; 101 | //! @brief Cpu bugs bitfield, see @c AsmJit::CpuInfo::Bug enum). 102 | uint32_t _bugs; 103 | }; 104 | 105 | //! @} 106 | 107 | } // AsmJit namespace 108 | 109 | // [Api-End] 110 | #include "../core/apiend.h" 111 | 112 | // [Guard] 113 | #endif // _ASMJIT_CORE_CPUINFO_H 114 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/lock.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_LOCK_H 9 | #define _ASMJIT_CORE_LOCK_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | // [Dependencies - Windows] 15 | #if defined(ASMJIT_WINDOWS) 16 | # include 17 | #endif // ASMJIT_WINDOWS 18 | 19 | // [Dependencies - Posix] 20 | #if defined(ASMJIT_POSIX) 21 | # include 22 | #endif // ASMJIT_POSIX 23 | 24 | // [Api-Begin] 25 | #include "../core/apibegin.h" 26 | 27 | namespace AsmJit { 28 | 29 | //! @addtogroup AsmJit_Core 30 | //! @{ 31 | 32 | // ============================================================================ 33 | // [AsmJit::Lock] 34 | // ============================================================================ 35 | 36 | //! @brief Lock - used in thread-safe code for locking. 37 | struct Lock 38 | { 39 | ASMJIT_NO_COPY(Lock) 40 | 41 | // -------------------------------------------------------------------------- 42 | // [Windows] 43 | // -------------------------------------------------------------------------- 44 | 45 | #if defined(ASMJIT_WINDOWS) 46 | typedef CRITICAL_SECTION Handle; 47 | 48 | //! @brief Create a new @ref Lock instance. 49 | inline Lock() { InitializeCriticalSection(&_handle); } 50 | //! @brief Destroy the @ref Lock instance. 51 | inline ~Lock() { DeleteCriticalSection(&_handle); } 52 | 53 | //! @brief Lock. 54 | inline void lock() { EnterCriticalSection(&_handle); } 55 | //! @brief Unlock. 56 | inline void unlock() { LeaveCriticalSection(&_handle); } 57 | 58 | #endif // ASMJIT_WINDOWS 59 | 60 | // -------------------------------------------------------------------------- 61 | // [Posix] 62 | // -------------------------------------------------------------------------- 63 | 64 | #if defined(ASMJIT_POSIX) 65 | typedef pthread_mutex_t Handle; 66 | 67 | //! @brief Create a new @ref Lock instance. 68 | inline Lock() { pthread_mutex_init(&_handle, NULL); } 69 | //! @brief Destroy the @ref Lock instance. 70 | inline ~Lock() { pthread_mutex_destroy(&_handle); } 71 | 72 | //! @brief Lock. 73 | inline void lock() { pthread_mutex_lock(&_handle); } 74 | //! @brief Unlock. 75 | inline void unlock() { pthread_mutex_unlock(&_handle); } 76 | #endif // ASMJIT_POSIX 77 | 78 | // -------------------------------------------------------------------------- 79 | // [Accessors] 80 | // -------------------------------------------------------------------------- 81 | 82 | //! @brief Get handle. 83 | inline Handle& getHandle() { return _handle; } 84 | //! @overload 85 | inline const Handle& getHandle() const { return _handle; } 86 | 87 | // -------------------------------------------------------------------------- 88 | // [Members] 89 | // -------------------------------------------------------------------------- 90 | 91 | //! @brief Handle. 92 | Handle _handle; 93 | }; 94 | 95 | // ============================================================================ 96 | // [AsmJit::AutoLock] 97 | // ============================================================================ 98 | 99 | //! @brief Scope auto locker. 100 | struct AutoLock 101 | { 102 | ASMJIT_NO_COPY(AutoLock) 103 | 104 | // -------------------------------------------------------------------------- 105 | // [Construction / Destruction] 106 | // -------------------------------------------------------------------------- 107 | 108 | //! @brief Locks @a target. 109 | inline AutoLock(Lock& target) : _target(target) 110 | { 111 | _target.lock(); 112 | } 113 | 114 | //! @brief Unlocks target. 115 | inline ~AutoLock() 116 | { 117 | _target.unlock(); 118 | } 119 | 120 | // -------------------------------------------------------------------------- 121 | // [Members] 122 | // -------------------------------------------------------------------------- 123 | 124 | //! @brief Pointer to target (lock). 125 | Lock& _target; 126 | }; 127 | 128 | //! @} 129 | 130 | } // AsmJit namespace 131 | 132 | // [Api-End] 133 | #include "../core/apiend.h" 134 | 135 | // [Guard] 136 | #endif // _ASMJIT_CORE_LOCK_H 137 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/x86/x86util.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_X86_X86UTIL_H 9 | #define _ASMJIT_X86_X86UTIL_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../x86/x86defs.h" 13 | #include "../x86/x86operand.h" 14 | 15 | // [Api-Begin] 16 | #include "../core/apibegin.h" 17 | 18 | namespace AsmJit { 19 | 20 | //! @addtogroup AsmJit_X86 21 | //! @{ 22 | 23 | // ============================================================================ 24 | // [AsmJit::X86Util] 25 | // ============================================================================ 26 | 27 | //! @brief Map condition code to "jcc" group of instructions. 28 | ASMJIT_VAR const uint32_t _x86UtilJccFromCond[20]; 29 | //! @brief Map condition code to "cmovcc" group of instructions. 30 | ASMJIT_VAR const uint32_t _x86UtilMovccFromCond[20]; 31 | //! @brief Map condition code to "setcc" group of instructions. 32 | ASMJIT_VAR const uint32_t _x86UtilSetccFromCond[20]; 33 | //! @brief Map condition code to reversed condition code. 34 | ASMJIT_VAR const uint32_t _x86UtilReversedCond[20]; 35 | 36 | struct X86Util 37 | { 38 | // -------------------------------------------------------------------------- 39 | // [Condition Codes] 40 | // -------------------------------------------------------------------------- 41 | 42 | //! @brief Get the equivalent of negated condition code. 43 | static inline uint32_t getNegatedCond(uint32_t cond) 44 | { 45 | return static_cast(cond ^ static_cast(cond < kX86CondNone)); 46 | } 47 | 48 | //! @brief Corresponds to transposing the operands of a comparison. 49 | static inline uint32_t getReversedCond(uint32_t cond) 50 | { 51 | ASMJIT_ASSERT(static_cast(cond) < ASMJIT_ARRAY_SIZE(_x86UtilReversedCond)); 52 | return _x86UtilReversedCond[cond]; 53 | } 54 | 55 | //! @brief Translate condition code @a cc to jcc instruction code. 56 | //! @sa @c kX86InstCode, @c kX86InstJ. 57 | static inline uint32_t getJccInstFromCond(uint32_t cond) 58 | { 59 | ASMJIT_ASSERT(static_cast(cond) < ASMJIT_ARRAY_SIZE(_x86UtilJccFromCond)); 60 | return _x86UtilJccFromCond[cond]; 61 | } 62 | 63 | //! @brief Translate condition code @a cc to cmovcc instruction code. 64 | //! @sa @c kX86InstCode, @c kX86InstCMov. 65 | static inline uint32_t getCMovccInstFromCond(uint32_t cond) 66 | { 67 | ASMJIT_ASSERT(static_cast(cond) < ASMJIT_ARRAY_SIZE(_x86UtilMovccFromCond)); 68 | return _x86UtilMovccFromCond[cond]; 69 | } 70 | 71 | //! @brief Translate condition code @a cc to setcc instruction code. 72 | //! @sa @c kX86InstCode, @c kX86InstSet. 73 | static inline uint32_t getSetccInstFromCond(uint32_t cond) 74 | { 75 | ASMJIT_ASSERT(static_cast(cond) < ASMJIT_ARRAY_SIZE(_x86UtilSetccFromCond)); 76 | return _x86UtilSetccFromCond[cond]; 77 | } 78 | 79 | // -------------------------------------------------------------------------- 80 | // [Variables] 81 | // -------------------------------------------------------------------------- 82 | 83 | static inline uint32_t getVarClassFromVarType(uint32_t varType) 84 | { 85 | ASMJIT_ASSERT(varType < kX86VarTypeCount); 86 | return x86VarInfo[varType].getClass(); 87 | } 88 | 89 | static inline uint32_t getVarSizeFromVarType(uint32_t varType) 90 | { 91 | ASMJIT_ASSERT(varType < kX86VarTypeCount); 92 | return x86VarInfo[varType].getSize(); 93 | } 94 | 95 | static inline uint32_t getRegCodeFromVarType(uint32_t varType, uint32_t regIndex) 96 | { 97 | ASMJIT_ASSERT(varType < kX86VarTypeCount); 98 | return x86VarInfo[varType].getCode() | regIndex; 99 | } 100 | 101 | static inline bool isVarTypeInt(uint32_t varType) 102 | { 103 | ASMJIT_ASSERT(varType < kX86VarTypeCount); 104 | return (x86VarInfo[varType].getClass() & kX86VarClassGp) != 0; 105 | } 106 | 107 | static inline bool isVarTypeFloat(uint32_t varType) 108 | { 109 | ASMJIT_ASSERT(varType < kX86VarTypeCount); 110 | return (x86VarInfo[varType].getFlags() & (kX86VarFlagSP | kX86VarFlagDP)) != 0; 111 | } 112 | }; 113 | 114 | //! @} 115 | 116 | } // AsmJit namespace 117 | 118 | // [Api-End] 119 | #include "../core/apiend.h" 120 | 121 | // [Guard] 122 | #endif // _ASMJIT_X86_X86UTIL_H 123 | -------------------------------------------------------------------------------- /libs/asmjit/src/app/test/testsizeof.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Dependencies - AsmJit] 8 | #include 9 | 10 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 11 | #include 12 | #endif // ASMJIT_X86 || ASMJIT_X64 13 | 14 | // [Dependencies - C] 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace AsmJit; 20 | 21 | int main(int argc, char* argv[]) 22 | { 23 | printf("AsmJit size test\n"); 24 | printf("================\n"); 25 | printf("\n"); 26 | 27 | // -------------------------------------------------------------------------- 28 | // [C++] 29 | // -------------------------------------------------------------------------- 30 | 31 | printf("Variable sizes:\n"); 32 | printf(" uint8_t : %u\n", (uint32_t)sizeof(uint8_t)); 33 | printf(" uint16_t : %u\n", (uint32_t)sizeof(uint16_t)); 34 | printf(" uint32_t : %u\n", (uint32_t)sizeof(uint32_t)); 35 | printf(" uint64_t : %u\n", (uint32_t)sizeof(uint64_t)); 36 | printf(" size_t : %u\n", (uint32_t)sizeof(size_t)); 37 | printf(" uintptr_t : %u\n", (uint32_t)sizeof(uintptr_t)); 38 | printf(" float : %u\n", (uint32_t)sizeof(float)); 39 | printf(" double : %u\n", (uint32_t)sizeof(double)); 40 | printf(" void* : %u\n", (uint32_t)sizeof(void*)); 41 | printf("\n"); 42 | 43 | // -------------------------------------------------------------------------- 44 | // [Core] 45 | // -------------------------------------------------------------------------- 46 | 47 | printf("Structure sizes:\n"); 48 | printf(" AsmJit::Operand : %u\n", (uint32_t)sizeof(Operand)); 49 | printf("\n"); 50 | 51 | printf(" AsmJit::Assembler : %u\n", (uint32_t)sizeof(Assembler)); 52 | printf(" AsmJit::Compiler : %u\n", (uint32_t)sizeof(Compiler)); 53 | printf(" AsmJit::CompilerAlign : %u\n", (uint32_t)sizeof(CompilerAlign)); 54 | printf(" AsmJit::CompilerComment : %u\n", (uint32_t)sizeof(CompilerComment)); 55 | printf(" AsmJit::CompilerEmbed : %u\n", (uint32_t)sizeof(CompilerEmbed)); 56 | printf(" AsmJit::CompilerFuncCall : %u\n", (uint32_t)sizeof(CompilerFuncCall)); 57 | printf(" AsmJit::CompilerFuncDecl : %u\n", (uint32_t)sizeof(CompilerFuncDecl)); 58 | printf(" AsmJit::CompilerFuncEnd : %u\n", (uint32_t)sizeof(CompilerFuncEnd)); 59 | printf(" AsmJit::CompilerInst : %u\n", (uint32_t)sizeof(CompilerInst)); 60 | printf(" AsmJit::CompilerItem : %u\n", (uint32_t)sizeof(CompilerItem)); 61 | printf(" AsmJit::CompilerState : %u\n", (uint32_t)sizeof(CompilerState)); 62 | printf(" AsmJit::CompilerVar : %u\n", (uint32_t)sizeof(CompilerVar)); 63 | printf(" AsmJit::FuncArg : %u\n", (uint32_t)sizeof(FuncArg)); 64 | printf(" AsmJit::FuncDecl : %u\n", (uint32_t)sizeof(FuncDecl)); 65 | printf(" AsmJit::FuncPrototype : %u\n", (uint32_t)sizeof(FuncPrototype)); 66 | printf("\n"); 67 | 68 | // -------------------------------------------------------------------------- 69 | // [X86] 70 | // -------------------------------------------------------------------------- 71 | 72 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 73 | printf(" AsmJit::X86Assembler : %u\n", (uint32_t)sizeof(X86Assembler)); 74 | printf(" AsmJit::X86Compiler : %u\n", (uint32_t)sizeof(X86Compiler)); 75 | printf(" AsmJit::X86CompilerAlign : %u\n", (uint32_t)sizeof(X86CompilerAlign)); 76 | printf(" AsmJit::X86CompilerFuncCall: %u\n", (uint32_t)sizeof(X86CompilerFuncCall)); 77 | printf(" AsmJit::X86CompilerFuncDecl: %u\n", (uint32_t)sizeof(X86CompilerFuncDecl)); 78 | printf(" AsmJit::X86CompilerFuncEnd : %u\n", (uint32_t)sizeof(X86CompilerFuncEnd)); 79 | printf(" AsmJit::X86CompilerInst : %u\n", (uint32_t)sizeof(X86CompilerInst)); 80 | printf(" AsmJit::X86CompilerJmpInst : %u\n", (uint32_t)sizeof(X86CompilerJmpInst)); 81 | printf(" AsmJit::X86CompilerState : %u\n", (uint32_t)sizeof(X86CompilerState)); 82 | printf(" AsmJit::X86CompilerVar : %u\n", (uint32_t)sizeof(X86CompilerVar)); 83 | printf(" AsmJit::X86FuncDecl : %u\n", (uint32_t)sizeof(X86FuncDecl)); 84 | printf("\n"); 85 | #endif // ASMJIT_X86 || ASMJIT_X64 86 | 87 | return 0; 88 | } 89 | -------------------------------------------------------------------------------- /libs/asmjit/src/app/test/testcpu.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Dependencies - AsmJit] 8 | #include 9 | 10 | // [Dependencies - C] 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace AsmJit; 16 | 17 | struct BitDescription 18 | { 19 | uint32_t mask; 20 | const char* description; 21 | }; 22 | 23 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 24 | static const BitDescription x86Features[] = 25 | { 26 | { kX86FeatureRdtsc , "RDTSC" }, 27 | { kX86FeatureRdtscP , "RDTSCP" }, 28 | { kX86FeatureCMov , "CMOV" }, 29 | { kX86FeatureCmpXchg8B , "CMPXCHG8B" }, 30 | { kX86FeatureCmpXchg16B , "CMPXCHG16B" }, 31 | { kX86FeatureClFlush , "CLFLUSH" }, 32 | { kX86FeaturePrefetch , "PREFETCH" }, 33 | { kX86FeatureLahfSahf , "LAHF/SAHF" }, 34 | { kX86FeatureFXSR , "FXSAVE/FXRSTOR" }, 35 | { kX86FeatureFFXSR , "FXSAVE/FXRSTOR Optimizations" }, 36 | { kX86FeatureMmx , "MMX" }, 37 | { kX86FeatureMmxExt , "MMX Extensions" }, 38 | { kX86Feature3dNow , "3dNow!" }, 39 | { kX86Feature3dNowExt , "3dNow! Extensions" }, 40 | { kX86FeatureSse , "SSE" }, 41 | { kX86FeatureSse2 , "SSE2" }, 42 | { kX86FeatureSse3 , "SSE3" }, 43 | { kX86FeatureSsse3 , "SSSE3" }, 44 | { kX86FeatureSse4A , "SSE4A" }, 45 | { kX86FeatureSse41 , "SSE4.1" }, 46 | { kX86FeatureSse42 , "SSE4.2" }, 47 | { kX86FeatureAvx , "AVX" }, 48 | { kX86FeatureMSse , "Misaligned SSE" }, 49 | { kX86FeatureMonitorMWait , "MONITOR/MWAIT" }, 50 | { kX86FeatureMovBE , "MOVBE" }, 51 | { kX86FeaturePopCnt , "POPCNT" }, 52 | { kX86FeatureLzCnt , "LZCNT" }, 53 | { kX86FeaturePclMulDQ , "PCLMULDQ" }, 54 | { kX86FeatureMultiThreading , "Multi-Threading" }, 55 | { kX86FeatureExecuteDisableBit , "Execute-Disable Bit" }, 56 | { kX86Feature64Bit , "64-Bit Processor" }, 57 | { 0, NULL } 58 | }; 59 | #endif // ASMJIT_X86 || ASMJIT_X64 60 | 61 | static void printBits(const char* msg, uint32_t mask, const BitDescription* d) 62 | { 63 | for (; d->mask; d++) 64 | { 65 | if (mask & d->mask) 66 | printf("%s%s\n", msg, d->description); 67 | } 68 | } 69 | 70 | int main(int argc, char* argv[]) 71 | { 72 | const CpuInfo* cpu = CpuInfo::getGlobal(); 73 | 74 | // -------------------------------------------------------------------------- 75 | // [Core Features] 76 | // -------------------------------------------------------------------------- 77 | 78 | printf("CPU Detection\n"); 79 | printf("=============\n"); 80 | 81 | printf("\nBasic info\n"); 82 | printf(" Vendor string : %s\n", cpu->getVendorString()); 83 | printf(" Brand string : %s\n", cpu->getBrandString()); 84 | printf(" Family : %u\n", cpu->getFamily()); 85 | printf(" Model : %u\n", cpu->getModel()); 86 | printf(" Stepping : %u\n", cpu->getStepping()); 87 | printf(" Number of Processors : %u\n", cpu->getNumberOfProcessors()); 88 | printf(" Features : 0x%08X\n", cpu->getFeatures()); 89 | printf(" Bugs : 0x%08X\n", cpu->getBugs()); 90 | 91 | // -------------------------------------------------------------------------- 92 | // [X86 Features] 93 | // -------------------------------------------------------------------------- 94 | 95 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 96 | const X86CpuInfo* x86Cpu = static_cast(cpu); 97 | 98 | printf("\nX86/X64 Extended Info:\n"); 99 | printf(" Processor Type : %u\n", x86Cpu->getProcessorType()); 100 | printf(" Brand Index : %u\n", x86Cpu->getBrandIndex()); 101 | printf(" CL Flush Cache Line : %u\n", x86Cpu->getFlushCacheLineSize()); 102 | printf(" Max logical Processors: %u\n", x86Cpu->getMaxLogicalProcessors()); 103 | printf(" APIC Physical ID : %u\n", x86Cpu->getApicPhysicalId()); 104 | 105 | printf("\nX86/X64 Features:\n"); 106 | printBits(" ", cpu->getFeatures(), x86Features); 107 | #endif // ASMJIT_X86 || ASMJIT_X64 108 | 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/virtualmemory.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/intutil.h" 11 | #include "../core/virtualmemory.h" 12 | 13 | // [Dependencies - Windows] 14 | #if defined(ASMJIT_WINDOWS) 15 | # include 16 | #endif // ASMJIT_WINDOWS 17 | 18 | // [Dependencies - Posix] 19 | #if defined(ASMJIT_POSIX) 20 | # include 21 | # include 22 | # include 23 | #endif // ASMJIT_POSIX 24 | 25 | // [Api-Begin] 26 | #include "../core/apibegin.h" 27 | 28 | namespace AsmJit { 29 | 30 | // ============================================================================ 31 | // [AsmJit::VirtualMemory - Windows] 32 | // ============================================================================ 33 | 34 | #if defined(ASMJIT_WINDOWS) 35 | struct VirtualMemoryLocal 36 | { 37 | VirtualMemoryLocal() 38 | 39 | { 40 | SYSTEM_INFO info; 41 | GetSystemInfo(&info); 42 | 43 | alignment = info.dwAllocationGranularity; 44 | pageSize = IntUtil::roundUpToPowerOf2(info.dwPageSize); 45 | } 46 | 47 | size_t alignment; 48 | size_t pageSize; 49 | }; 50 | 51 | static VirtualMemoryLocal& vm() 52 | 53 | { 54 | static VirtualMemoryLocal vm; 55 | return vm; 56 | }; 57 | 58 | void* VirtualMemory::alloc(size_t length, size_t* allocated, bool canExecute) 59 | 60 | { 61 | return allocProcessMemory(GetCurrentProcess(), length, allocated, canExecute); 62 | } 63 | 64 | void VirtualMemory::free(void* addr, size_t length) 65 | 66 | { 67 | return freeProcessMemory(GetCurrentProcess(), addr, length); 68 | } 69 | 70 | void* VirtualMemory::allocProcessMemory(HANDLE hProcess, size_t length, size_t* allocated, bool canExecute) 71 | 72 | { 73 | // VirtualAlloc rounds allocated size to page size automatically. 74 | size_t msize = IntUtil::roundUp(length, vm().pageSize); 75 | 76 | // Windows XP SP2 / Vista allow Data Excution Prevention (DEP). 77 | WORD protect = canExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 78 | LPVOID mbase = VirtualAllocEx(hProcess, NULL, msize, MEM_COMMIT | MEM_RESERVE, protect); 79 | if (mbase == NULL) return NULL; 80 | 81 | ASMJIT_ASSERT(IntUtil::isAligned(reinterpret_cast(mbase), vm().alignment)); 82 | 83 | if (allocated != NULL) 84 | *allocated = msize; 85 | return mbase; 86 | } 87 | 88 | void VirtualMemory::freeProcessMemory(HANDLE hProcess, void* addr, size_t /* length */) 89 | 90 | { 91 | VirtualFreeEx(hProcess, addr, 0, MEM_RELEASE); 92 | } 93 | 94 | size_t VirtualMemory::getAlignment() 95 | 96 | { 97 | return vm().alignment; 98 | } 99 | 100 | size_t VirtualMemory::getPageSize() 101 | 102 | { 103 | return vm().pageSize; 104 | } 105 | #endif // ASMJIT_WINDOWS 106 | 107 | // ============================================================================ 108 | // [AsmJit::VirtualMemory - Posix] 109 | // ============================================================================ 110 | 111 | #if defined(ASMJIT_POSIX) 112 | 113 | // MacOS uses MAP_ANON instead of MAP_ANONYMOUS. 114 | #if !defined(MAP_ANONYMOUS) 115 | # define MAP_ANONYMOUS MAP_ANON 116 | #endif // MAP_ANONYMOUS 117 | 118 | struct VirtualMemoryLocal 119 | { 120 | VirtualMemoryLocal() 121 | { 122 | alignment = pageSize = ::getpagesize(); 123 | } 124 | 125 | size_t alignment; 126 | size_t pageSize; 127 | }; 128 | 129 | static VirtualMemoryLocal& vm() 130 | 131 | { 132 | static VirtualMemoryLocal vm; 133 | return vm; 134 | } 135 | 136 | void* VirtualMemory::alloc(size_t length, size_t* allocated, bool canExecute) 137 | 138 | { 139 | size_t msize = IntUtil::roundUp(length, vm().pageSize); 140 | int protection = PROT_READ | PROT_WRITE | (canExecute ? PROT_EXEC : 0); 141 | 142 | void* mbase = ::mmap(NULL, msize, protection, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 143 | if (mbase == MAP_FAILED) 144 | return NULL; 145 | 146 | if (allocated != NULL) 147 | *allocated = msize; 148 | return mbase; 149 | } 150 | 151 | void VirtualMemory::free(void* addr, size_t length) 152 | 153 | { 154 | munmap(addr, length); 155 | } 156 | 157 | size_t VirtualMemory::getAlignment() 158 | 159 | { 160 | return vm().alignment; 161 | } 162 | 163 | size_t VirtualMemory::getPageSize() 164 | 165 | { 166 | return vm().pageSize; 167 | } 168 | #endif // ASMJIT_POSIX 169 | 170 | } // AsmJit namespace 171 | 172 | // [Api-End] 173 | #include "../core/apiend.h" 174 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/x86/x86cpuinfo.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_X86_X86CPUINFO_H 9 | #define _ASMJIT_X86_X86CPUINFO_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/cpuinfo.h" 13 | #include "../core/defs.h" 14 | 15 | // [Api-Begin] 16 | #include "../core/apibegin.h" 17 | 18 | namespace AsmJit { 19 | 20 | //! @addtogroup AsmJit_X86 21 | //! @{ 22 | 23 | // ============================================================================ 24 | // [AsmJit::X86CpuId] 25 | // ============================================================================ 26 | 27 | //! @brief X86 CpuId output. 28 | union X86CpuId 29 | { 30 | //! @brief EAX/EBX/ECX/EDX output. 31 | uint32_t i[4]; 32 | 33 | struct 34 | { 35 | //! @brief EAX output. 36 | uint32_t eax; 37 | //! @brief EBX output. 38 | uint32_t ebx; 39 | //! @brief ECX output. 40 | uint32_t ecx; 41 | //! @brief EDX output. 42 | uint32_t edx; 43 | }; 44 | }; 45 | 46 | // ============================================================================ 47 | // [AsmJit::X86CpuInfo] 48 | // ============================================================================ 49 | 50 | struct X86CpuInfo : public CpuInfo 51 | { 52 | // -------------------------------------------------------------------------- 53 | // [Construction / Destruction] 54 | // -------------------------------------------------------------------------- 55 | 56 | inline X86CpuInfo(uint32_t size = sizeof(X86CpuInfo)) : 57 | CpuInfo(size) 58 | { 59 | } 60 | 61 | // -------------------------------------------------------------------------- 62 | // [Accessors] 63 | // -------------------------------------------------------------------------- 64 | 65 | //! @brief Get processor type. 66 | inline uint32_t getProcessorType() const { return _processorType; } 67 | //! @brief Get brand index. 68 | inline uint32_t getBrandIndex() const { return _brandIndex; } 69 | //! @brief Get flush cache line size. 70 | inline uint32_t getFlushCacheLineSize() const { return _flushCacheLineSize; } 71 | //! @brief Get maximum logical processors count. 72 | inline uint32_t getMaxLogicalProcessors() const { return _maxLogicalProcessors; } 73 | //! @brief Get APIC physical ID. 74 | inline uint32_t getApicPhysicalId() const { return _apicPhysicalId; } 75 | 76 | // -------------------------------------------------------------------------- 77 | // [Statics] 78 | // -------------------------------------------------------------------------- 79 | 80 | //! @brief Get global instance of @ref X86CpuInfo. 81 | static inline const X86CpuInfo* getGlobal() 82 | { return static_cast(CpuInfo::getGlobal()); } 83 | 84 | // -------------------------------------------------------------------------- 85 | // [Members] 86 | // -------------------------------------------------------------------------- 87 | 88 | //! @brief Processor type. 89 | uint32_t _processorType; 90 | //! @brief Brand index. 91 | uint32_t _brandIndex; 92 | //! @brief Flush cache line size in bytes. 93 | uint32_t _flushCacheLineSize; 94 | //! @brief Maximum number of addressable IDs for logical processors. 95 | uint32_t _maxLogicalProcessors; 96 | //! @brief Initial APIC ID. 97 | uint32_t _apicPhysicalId; 98 | }; 99 | 100 | // ============================================================================ 101 | // [AsmJit::x86CpuId] 102 | // ============================================================================ 103 | 104 | #if defined(ASMJIT_X86) || defined(ASMJIT_X64) 105 | //! @brief Calls CPUID instruction with eax == @a in and stores output to @a out. 106 | //! 107 | //! @c cpuid() function has one input parameter that is passed to cpuid through 108 | //! eax register and results in four output values representing result of cpuid 109 | //! instruction (eax, ebx, ecx and edx registers). 110 | ASMJIT_API void x86CpuId(uint32_t in, X86CpuId* out); 111 | 112 | // ============================================================================ 113 | // [AsmJit::x86CpuDetect] 114 | // ============================================================================ 115 | 116 | //! @brief Detect CPU features to CpuInfo structure @a out. 117 | //! 118 | //! @sa @c CpuInfo. 119 | ASMJIT_API void x86CpuDetect(X86CpuInfo* out); 120 | #endif // ASMJIT_X86 || ASMJIT_X64 121 | 122 | //! @} 123 | 124 | } // AsmJit namespace 125 | 126 | // [Api-End] 127 | #include "../core/apiend.h" 128 | 129 | // [Guard] 130 | #endif // _ASMJIT_X86_X86CPUINFO_H 131 | -------------------------------------------------------------------------------- /libs/asmjit/src/app/test/testmem.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Dependencies - AsmJit] 8 | #include 9 | 10 | // [Dependencies - C] 11 | #include 12 | #include 13 | #include 14 | 15 | static int problems = 0; 16 | 17 | static void gen(void* a, void* b, int i) 18 | { 19 | int pattern = rand() % 256; 20 | *(int *)a = i; 21 | *(int *)b = i; 22 | memset((char*)a + sizeof(int), pattern, i - sizeof(int)); 23 | memset((char*)b + sizeof(int), pattern, i - sizeof(int)); 24 | } 25 | 26 | static void verify(void* a, void* b) 27 | { 28 | int ai = *(int*)a; 29 | int bi = *(int*)b; 30 | if (ai != bi || memcmp(a, b, ai) != 0) 31 | { 32 | printf("Failed to verify %p\n", a); 33 | problems++; 34 | } 35 | } 36 | 37 | static void die() 38 | { 39 | printf("Couldn't allocate virtual memory, this test needs at least 100MB of free virtual memory.\n"); 40 | exit(1); 41 | } 42 | 43 | static void stats(const char* dumpFile) 44 | { 45 | AsmJit::MemoryManager* memmgr = AsmJit::MemoryManager::getGlobal(); 46 | 47 | printf("-- Used: %d\n", (int)memmgr->getUsedBytes()); 48 | printf("-- Allocated: %d\n", (int)memmgr->getAllocatedBytes()); 49 | 50 | #if defined(ASMJIT_MEMORY_MANAGER_DUMP) 51 | reinterpret_cast(memmgr)->dump(dumpFile); 52 | #endif // ASMJIT_MEMORY_MANAGER_DUMP 53 | } 54 | 55 | static void shuffle(void **a, void **b, size_t count) 56 | { 57 | for (size_t i = 0; i < count; ++i) 58 | { 59 | size_t si = (size_t)rand() % count; 60 | 61 | void *ta = a[i]; 62 | void *tb = b[i]; 63 | 64 | a[i] = a[si]; 65 | b[i] = b[si]; 66 | 67 | a[si] = ta; 68 | b[si] = tb; 69 | } 70 | } 71 | 72 | int main(int argc, char* argv[]) 73 | { 74 | AsmJit::MemoryManager* memmgr = AsmJit::MemoryManager::getGlobal(); 75 | 76 | size_t i; 77 | size_t count = 200000; 78 | 79 | printf("Memory alloc/free test - %d allocations\n\n", (int)count); 80 | 81 | void** a = (void**)malloc(sizeof(void*) * count); 82 | void** b = (void**)malloc(sizeof(void*) * count); 83 | if (!a || !b) die(); 84 | 85 | srand(100); 86 | printf("Allocating virtual memory..."); 87 | 88 | for (i = 0; i < count; i++) 89 | { 90 | int r = (rand() % 1000) + 4; 91 | 92 | a[i] = memmgr->alloc(r); 93 | if (a[i] == NULL) die(); 94 | 95 | memset(a[i], 0, r); 96 | } 97 | 98 | printf("done\n"); 99 | stats("dump0.dot"); 100 | 101 | printf("\n"); 102 | printf("Freeing virtual memory..."); 103 | 104 | for (i = 0; i < count; i++) 105 | { 106 | if (!memmgr->free(a[i])) 107 | { 108 | printf("Failed to free %p\n", b[i]); 109 | problems++; 110 | } 111 | } 112 | 113 | printf("done\n"); 114 | stats("dump1.dot"); 115 | 116 | printf("\n"); 117 | printf("Verified alloc/free test - %d allocations\n\n", (int)count); 118 | 119 | printf("Alloc..."); 120 | for (i = 0; i < count; i++) 121 | { 122 | int r = (rand() % 1000) + 4; 123 | 124 | a[i] = memmgr->alloc(r); 125 | b[i] = malloc(r); 126 | if (a[i] == NULL || b[i] == NULL) die(); 127 | 128 | gen(a[i], b[i], r); 129 | } 130 | printf("done\n"); 131 | stats("dump2.dot"); 132 | 133 | printf("\n"); 134 | printf("Shuffling..."); 135 | shuffle(a, b, count); 136 | printf("done\n"); 137 | 138 | printf("\n"); 139 | printf("Verify and free..."); 140 | for (i = 0; i < count/2; i++) 141 | { 142 | verify(a[i], b[i]); 143 | if (!memmgr->free(a[i])) 144 | { 145 | printf("Failed to free %p\n", b[i]); 146 | problems++; 147 | } 148 | free(b[i]); 149 | } 150 | printf("done\n"); 151 | stats("dump3.dot"); 152 | 153 | printf("\n"); 154 | printf("Alloc..."); 155 | for (i = 0; i < count/2; i++) 156 | { 157 | int r = (rand() % 1000) + 4; 158 | 159 | a[i] = memmgr->alloc(r); 160 | b[i] = malloc(r); 161 | if (a[i] == NULL || b[i] == NULL) die(); 162 | 163 | gen(a[i], b[i], r); 164 | } 165 | printf("done\n"); 166 | stats("dump4.dot"); 167 | 168 | printf("\n"); 169 | printf("Verify and free..."); 170 | for (i = 0; i < count; i++) 171 | { 172 | verify(a[i], b[i]); 173 | if (!memmgr->free(a[i])) 174 | { 175 | printf("Failed to free %p\n", b[i]); 176 | problems++; 177 | } 178 | free(b[i]); 179 | } 180 | printf("done\n"); 181 | stats("dump5.dot"); 182 | 183 | printf("\n"); 184 | if (problems) 185 | printf("Status: Failure: %d problems found\n", problems); 186 | else 187 | printf("Status: Success\n"); 188 | 189 | free(a); 190 | free(b); 191 | 192 | return 0; 193 | } 194 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/zonememory.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_ZONEMEMORY_H 9 | #define _ASMJIT_CORE_ZONEMEMORY_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | namespace AsmJit { 15 | 16 | //! @addtogroup AsmJit_Core 17 | //! @{ 18 | 19 | // ============================================================================ 20 | // [AsmJit::ZoneChunk] 21 | // ============================================================================ 22 | 23 | //! @internal 24 | //! 25 | //! @brief One allocated chunk of memory. 26 | struct ZoneChunk 27 | { 28 | // -------------------------------------------------------------------------- 29 | // [Methods] 30 | // -------------------------------------------------------------------------- 31 | 32 | //! @brief Get count of remaining (unused) bytes in chunk. 33 | inline size_t getRemainingBytes() const { return size - pos; } 34 | 35 | // -------------------------------------------------------------------------- 36 | // [Members] 37 | // -------------------------------------------------------------------------- 38 | 39 | //! @brief Link to previous chunk. 40 | ZoneChunk* prev; 41 | //! @brief Position in this chunk. 42 | size_t pos; 43 | //! @brief Size of this chunk (in bytes). 44 | size_t size; 45 | 46 | //! @brief Data. 47 | uint8_t data[sizeof(void*)]; 48 | }; 49 | 50 | // ============================================================================ 51 | // [AsmJit::ZoneMemory] 52 | // ============================================================================ 53 | 54 | //! @brief Memory allocator designed to fast alloc memory that will be freed 55 | //! in one step. 56 | //! 57 | //! @note This is hackery for performance. Concept is that objects created 58 | //! by @c ZoneMemory are freed all at once. This means that lifetime of 59 | //! these objects are the same as the zone object itself. 60 | struct ZoneMemory 61 | { 62 | // -------------------------------------------------------------------------- 63 | // [Construction / Destruction] 64 | // -------------------------------------------------------------------------- 65 | 66 | //! @brief Create new instance of @c ZoneMemory. 67 | //! @param chunkSize Default size for one zone chunk. 68 | ASMJIT_API ZoneMemory(size_t chunkSize); 69 | 70 | //! @brief Destroy @ref ZoneMemory instance. 71 | ASMJIT_API ~ZoneMemory(); 72 | 73 | // -------------------------------------------------------------------------- 74 | // [Methods] 75 | // -------------------------------------------------------------------------- 76 | 77 | //! @brief Allocate @c size bytes of memory and return pointer to it. 78 | //! 79 | //! Pointer allocated by this way will be valid until @c ZoneMemory object 80 | //! is destroyed. To create class by this way use placement @c new and 81 | //! @c delete operators: 82 | //! 83 | //! @code 84 | //! // Example of allocating simple class 85 | //! 86 | //! // Your class 87 | //! class Object 88 | //! { 89 | //! // members... 90 | //! }; 91 | //! 92 | //! // Your function 93 | //! void f() 94 | //! { 95 | //! // We are using AsmJit namespace 96 | //! using namespace AsmJit 97 | //! 98 | //! // Create zone object with chunk size of 65536 bytes. 99 | //! ZoneMemory zone(65536); 100 | //! 101 | //! // Create your objects using zone object allocating, for example: 102 | //! Object* obj = new(zone.alloc(sizeof(YourClass))) Object(); 103 | //! 104 | //! // ... lifetime of your objects ... 105 | //! 106 | //! // Destroy your objects: 107 | //! obj->~Object(); 108 | //! 109 | //! // ZoneMemory destructor will free all memory allocated through it, 110 | //! // alternative is to call @c zone.reset(). 111 | //! } 112 | //! @endcode 113 | ASMJIT_API void* alloc(size_t size); 114 | 115 | //! @brief Helper to duplicate string. 116 | ASMJIT_API char* sdup(const char* str); 117 | 118 | //! @brief Free all allocated memory except first block that remains for reuse. 119 | //! 120 | //! Note that this method will invalidate all instances using this memory 121 | //! allocated by this zone instance. 122 | ASMJIT_API void clear(); 123 | 124 | //! @brief Free all allocated memory at once. 125 | //! 126 | //! Note that this method will invalidate all instances using this memory 127 | //! allocated by this zone instance. 128 | ASMJIT_API void reset(); 129 | 130 | //! @brief Get total size of allocated objects - by @c alloc(). 131 | inline size_t getTotal() const { return _total; } 132 | //! @brief Get (default) chunk size. 133 | inline size_t getChunkSize() const { return _chunkSize; } 134 | 135 | // -------------------------------------------------------------------------- 136 | // [Members] 137 | // -------------------------------------------------------------------------- 138 | 139 | //! @brief Last allocated chunk of memory. 140 | ZoneChunk* _chunks; 141 | //! @brief Total size of allocated objects - by @c alloc() method. 142 | size_t _total; 143 | //! @brief One chunk size. 144 | size_t _chunkSize; 145 | }; 146 | 147 | //! @} 148 | 149 | } // AsmJit namespace 150 | 151 | #endif // _ASMJIT_CORE_ZONEMEMORY_H 152 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/compilerfunc.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assembler.h" 11 | #include "../core/compiler.h" 12 | #include "../core/compilerfunc.h" 13 | #include "../core/compileritem.h" 14 | #include "../core/intutil.h" 15 | #include "../core/logger.h" 16 | 17 | // [Api-Begin] 18 | #include "../core/apibegin.h" 19 | 20 | namespace AsmJit { 21 | 22 | // ============================================================================ 23 | // [AsmJit::CompilerFuncDecl - Construction / Destruction] 24 | // ============================================================================ 25 | 26 | CompilerFuncDecl::CompilerFuncDecl(Compiler* compiler) : 27 | CompilerItem(compiler, kCompilerItemFuncDecl), 28 | _entryTarget(NULL), 29 | _exitTarget(NULL), 30 | _end(NULL), 31 | _decl(NULL), 32 | _vars(NULL), 33 | _funcHints(0), 34 | _funcFlags(0), 35 | _funcCallStackSize(0) 36 | { 37 | } 38 | 39 | CompilerFuncDecl::~CompilerFuncDecl() 40 | { 41 | } 42 | 43 | // ============================================================================ 44 | // [AsmJit::CompilerFuncDecl - Hints] 45 | // ============================================================================ 46 | 47 | void CompilerFuncDecl::setHint(uint32_t hint, uint32_t value) 48 | { 49 | if (hint > 31) 50 | return; 51 | 52 | if (value) 53 | _funcHints |= IntUtil::maskFromIndex(hint); 54 | else 55 | _funcHints &= ~IntUtil::maskFromIndex(hint); 56 | } 57 | 58 | uint32_t CompilerFuncDecl::getHint(uint32_t hint) const 59 | { 60 | if (hint > 31) 61 | return 0; 62 | 63 | return (_funcHints & IntUtil::maskFromIndex(hint)) != 0; 64 | } 65 | 66 | // ============================================================================ 67 | // [AsmJit::CompilerFuncEnd - Construction / Destruction] 68 | // ============================================================================ 69 | 70 | CompilerFuncEnd::CompilerFuncEnd(Compiler* compiler, CompilerFuncDecl* func) : 71 | CompilerItem(compiler, kCompilerItemFuncEnd), 72 | _func(func) 73 | { 74 | } 75 | 76 | CompilerFuncEnd::~CompilerFuncEnd() 77 | { 78 | } 79 | 80 | // ============================================================================ 81 | // [AsmJit::CompilerFuncEnd - Interface] 82 | // ============================================================================ 83 | 84 | CompilerItem* CompilerFuncEnd::translate(CompilerContext& cc) 85 | { 86 | _isTranslated = true; 87 | return NULL; 88 | } 89 | 90 | // ============================================================================ 91 | // [AsmJit::CompilerFuncRet - Construction / Destruction] 92 | // ============================================================================ 93 | 94 | CompilerFuncRet::CompilerFuncRet(Compiler* compiler, CompilerFuncDecl* func, const Operand* first, const Operand* second) : 95 | CompilerItem(compiler, kCompilerItemFuncRet), 96 | _func(func) 97 | { 98 | if (first != NULL) 99 | _ret[0] = *first; 100 | 101 | if (second != NULL) 102 | _ret[1] = *second; 103 | } 104 | 105 | CompilerFuncRet::~CompilerFuncRet() 106 | { 107 | } 108 | 109 | // ============================================================================ 110 | // [AsmJit::CompilerFuncRet - Misc] 111 | // ============================================================================ 112 | 113 | bool CompilerFuncRet::mustEmitJump() const 114 | { 115 | // Iterate over next items until we found an item which emits a real instruction. 116 | CompilerItem* item = this->getNext(); 117 | 118 | while (item) 119 | { 120 | switch (item->getType()) 121 | { 122 | // Interesting item. 123 | case kCompilerItemEmbed: 124 | case kCompilerItemInst: 125 | case kCompilerItemFuncCall: 126 | case kCompilerItemFuncRet: 127 | return true; 128 | 129 | // Non-interesting item. 130 | case kCompilerItemComment: 131 | case kCompilerItemMark: 132 | case kCompilerItemAlign: 133 | case kCompilerItemHint: 134 | break; 135 | 136 | case kCompilerItemTarget: 137 | if (static_cast(item)->getLabel().getId() == getFunc()->getExitLabel().getId()) 138 | return false; 139 | break; 140 | 141 | // Invalid items - these items shouldn't be here. We are inside the 142 | // function, after prolog. 143 | case kCompilerItemFuncDecl: 144 | break; 145 | 146 | // We can't go forward from here. 147 | case kCompilerItemFuncEnd: 148 | return false; 149 | } 150 | 151 | item = item->getNext(); 152 | } 153 | 154 | return false; 155 | } 156 | 157 | // ============================================================================ 158 | // [AsmJit::CompilerFuncCall - Construction / Destruction] 159 | // ============================================================================ 160 | 161 | CompilerFuncCall::CompilerFuncCall(Compiler* compiler, CompilerFuncDecl* caller, const Operand* target) : 162 | CompilerItem(compiler, kCompilerItemFuncCall), 163 | _caller(caller), 164 | _decl(NULL), 165 | _args(NULL) 166 | { 167 | if (target != NULL) 168 | _target = *target; 169 | } 170 | 171 | CompilerFuncCall::~CompilerFuncCall() 172 | { 173 | } 174 | 175 | } // AsmJit namespace 176 | 177 | // [Api-Begin] 178 | #include "../core/apibegin.h" 179 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/context.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_CONTEXT_H 9 | #define _ASMJIT_CORE_CONTEXT_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | 14 | namespace AsmJit { 15 | 16 | // ============================================================================ 17 | // [Forward Declarations] 18 | // ============================================================================ 19 | 20 | struct Assembler; 21 | struct MemoryManager; 22 | struct MemoryMarker; 23 | 24 | // ============================================================================ 25 | // [AsmJit::Context] 26 | // ============================================================================ 27 | 28 | //! @brief Class for changing behavior of code generated by @ref Assembler and 29 | //! @ref Compiler. 30 | struct Context 31 | { 32 | ASMJIT_NO_COPY(Context) 33 | 34 | // -------------------------------------------------------------------------- 35 | // [Construction / Destruction] 36 | // -------------------------------------------------------------------------- 37 | 38 | //! @brief Create a @c Context instance. 39 | ASMJIT_API Context(); 40 | //! @brief Destroy the @c Context instance. 41 | ASMJIT_API virtual ~Context(); 42 | 43 | // -------------------------------------------------------------------------- 44 | // [Interface] 45 | // -------------------------------------------------------------------------- 46 | 47 | //! @brief Allocate memory for code generated in @a assembler and reloc it 48 | //! to target location. 49 | //! 50 | //! This method is universal allowing any pre-process / post-process work 51 | //! with code generated by @c Assembler or @c Compiler. Because @c Compiler 52 | //! always uses @c Assembler it's allowed to access only the @c Assembler 53 | //! instance. 54 | //! 55 | //! This method is always last step when using code generation. You can use 56 | //! it to allocate memory for JIT code, saving code to remote process or a 57 | //! shared library. 58 | //! 59 | //! @retrurn Error value, see @c kError. 60 | virtual uint32_t generate(void** dest, Assembler* assembler) = 0; 61 | }; 62 | 63 | // ============================================================================ 64 | // [AsmJit::JitContext] 65 | // ============================================================================ 66 | 67 | struct JitContext : public Context 68 | { 69 | ASMJIT_NO_COPY(JitContext) 70 | 71 | // -------------------------------------------------------------------------- 72 | // [Construction / Destruction] 73 | // -------------------------------------------------------------------------- 74 | 75 | //! @brief Create a @c JitContext instance. 76 | ASMJIT_API JitContext(); 77 | //! @brief Destroy the @c JitContext instance. 78 | ASMJIT_API virtual ~JitContext(); 79 | 80 | // -------------------------------------------------------------------------- 81 | // [Memory Manager and Alloc Type] 82 | // -------------------------------------------------------------------------- 83 | 84 | // Note: These members can be ignored by all derived classes. They are here 85 | // only to privide default implementation. All other implementations (remote 86 | // code patching or making dynamic loadable libraries/executables) ignore 87 | // members accessed by these accessors. 88 | 89 | //! @brief Get the @c MemoryManager instance. 90 | inline MemoryManager* getMemoryManager() const 91 | { return _memoryManager; } 92 | 93 | //! @brief Set the @c MemoryManager instance. 94 | inline void setMemoryManager(MemoryManager* memoryManager) 95 | { _memoryManager = memoryManager; } 96 | 97 | //! @brief Get the type of allocation. 98 | inline uint32_t getAllocType() const 99 | { return _allocType; } 100 | 101 | //! @brief Set the type of allocation. 102 | inline void setAllocType(uint32_t allocType) 103 | { _allocType = allocType; } 104 | 105 | // -------------------------------------------------------------------------- 106 | // [Memory Marker] 107 | // -------------------------------------------------------------------------- 108 | 109 | //! @brief Get the @c MemoryMarker instance. 110 | inline MemoryMarker* getMemoryMarker() const 111 | { return _memoryMarker; } 112 | 113 | //! @brief Set the @c MemoryMarker instance. 114 | inline void setMemoryMarker(MemoryMarker* memoryMarker) 115 | { _memoryMarker = memoryMarker; } 116 | 117 | // -------------------------------------------------------------------------- 118 | // [Interface] 119 | // -------------------------------------------------------------------------- 120 | 121 | ASMJIT_API virtual uint32_t generate(void** dest, Assembler* assembler); 122 | 123 | // -------------------------------------------------------------------------- 124 | // [Statics] 125 | // -------------------------------------------------------------------------- 126 | 127 | ASMJIT_API static JitContext* getGlobal(); 128 | 129 | // -------------------------------------------------------------------------- 130 | // [Members] 131 | // -------------------------------------------------------------------------- 132 | 133 | //! @brief Memory manager. 134 | MemoryManager* _memoryManager; 135 | //! @brief Memory marker. 136 | MemoryMarker* _memoryMarker; 137 | 138 | //! @brief Type of allocation. 139 | uint32_t _allocType; 140 | }; 141 | 142 | } // AsmJit namespace 143 | 144 | // [Guard] 145 | #endif // _ASMJIT_CORE_CONTEXT_H 146 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/assembler.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assembler.h" 11 | #include "../core/memorymanager.h" 12 | #include "../core/intutil.h" 13 | 14 | // [Dependenceis - C] 15 | #include 16 | 17 | // [Api-Begin] 18 | #include "../core/apibegin.h" 19 | 20 | namespace AsmJit { 21 | 22 | // ============================================================================ 23 | // [AsmJit::Assembler - Construction / Destruction] 24 | // ============================================================================ 25 | 26 | Assembler::Assembler(Context* context) : 27 | _zoneMemory(16384 - sizeof(ZoneChunk) - 32), 28 | _buffer(), 29 | _context(context != NULL 30 | ? context 31 | : static_cast(JitContext::getGlobal())), 32 | _logger(NULL), 33 | _error(kErrorOk), 34 | _properties(0), 35 | _emitOptions(0), 36 | _trampolineSize(0), 37 | _inlineComment(NULL), 38 | _unusedLinks(NULL) 39 | { 40 | } 41 | 42 | Assembler::~Assembler() 43 | { 44 | } 45 | 46 | // ============================================================================ 47 | // [AsmJit::Assembler - Logging] 48 | // ============================================================================ 49 | 50 | void Assembler::setLogger(Logger* logger) 51 | { 52 | _logger = logger; 53 | } 54 | 55 | // ============================================================================ 56 | // [AsmJit::Assembler - Error Handling] 57 | // ============================================================================ 58 | 59 | void Assembler::setError(uint32_t error) 60 | { 61 | _error = error; 62 | if (_error == kErrorOk) 63 | return; 64 | 65 | if (_logger) 66 | _logger->logFormat("*** ASSEMBLER ERROR: %s (%u).\n", getErrorString(error), (unsigned int)error); 67 | } 68 | 69 | // ============================================================================ 70 | // [AsmJit::Assembler - Properties] 71 | // ============================================================================ 72 | 73 | uint32_t Assembler::getProperty(uint32_t propertyId) const 74 | { 75 | if (propertyId > 31) 76 | return 0; 77 | 78 | return (_properties & (IntUtil::maskFromIndex(propertyId))) != 0; 79 | } 80 | 81 | void Assembler::setProperty(uint32_t propertyId, uint32_t value) 82 | { 83 | if (propertyId > 31) 84 | return; 85 | 86 | if (value) 87 | _properties |= IntUtil::maskFromIndex(propertyId); 88 | else 89 | _properties &= ~IntUtil::maskFromIndex(propertyId); 90 | } 91 | 92 | // ============================================================================ 93 | // [AsmJit::Assembler - TakeCode] 94 | // ============================================================================ 95 | 96 | uint8_t* Assembler::takeCode() 97 | { 98 | uint8_t* code = _buffer.take(); 99 | _relocData.clear(); 100 | _zoneMemory.clear(); 101 | 102 | if (_error != kErrorOk) 103 | setError(kErrorOk); 104 | 105 | return code; 106 | } 107 | 108 | // ============================================================================ 109 | // [AsmJit::Assembler - Clear / Reset] 110 | // ============================================================================ 111 | 112 | void Assembler::clear() 113 | { 114 | _purge(); 115 | 116 | if (_error != kErrorOk) 117 | setError(kErrorOk); 118 | } 119 | 120 | void Assembler::reset() 121 | { 122 | _purge(); 123 | 124 | _zoneMemory.reset(); 125 | _buffer.reset(); 126 | 127 | _labels.reset(); 128 | _relocData.reset(); 129 | 130 | if (_error != kErrorOk) 131 | setError(kErrorOk); 132 | } 133 | 134 | void Assembler::_purge() 135 | { 136 | _zoneMemory.clear(); 137 | _buffer.clear(); 138 | 139 | _emitOptions = 0; 140 | _trampolineSize = 0; 141 | 142 | _inlineComment = NULL; 143 | _unusedLinks = NULL; 144 | 145 | _labels.clear(); 146 | _relocData.clear(); 147 | } 148 | 149 | // ============================================================================ 150 | // [AsmJit::Assembler - Emit] 151 | // ============================================================================ 152 | 153 | void Assembler::embed(const void* data, size_t len) 154 | { 155 | if (!canEmit()) 156 | return; 157 | 158 | if (_logger) 159 | { 160 | size_t i, j; 161 | size_t max; 162 | 163 | char buf[128]; 164 | char dot[] = ".data "; 165 | char* p; 166 | 167 | memcpy(buf, dot, ASMJIT_ARRAY_SIZE(dot) - 1); 168 | 169 | for (i = 0; i < len; i += 16) 170 | { 171 | max = (len - i < 16) ? len - i : 16; 172 | p = buf + ASMJIT_ARRAY_SIZE(dot) - 1; 173 | 174 | for (j = 0; j < max; j++) 175 | p += sprintf(p, "%02X", reinterpret_cast(data)[i+j]); 176 | 177 | *p++ = '\n'; 178 | *p = '\0'; 179 | 180 | _logger->logString(buf); 181 | } 182 | } 183 | 184 | _buffer.emitData(data, len); 185 | } 186 | 187 | // ============================================================================ 188 | // [AsmJit::Assembler - Helpers] 189 | // ============================================================================ 190 | 191 | Assembler::LabelLink* Assembler::_newLabelLink() 192 | { 193 | LabelLink* link = _unusedLinks; 194 | 195 | if (link) 196 | { 197 | _unusedLinks = link->prev; 198 | } 199 | else 200 | { 201 | link = (LabelLink*)_zoneMemory.alloc(sizeof(LabelLink)); 202 | if (link == NULL) return NULL; 203 | } 204 | 205 | // clean link 206 | link->prev = NULL; 207 | link->offset = 0; 208 | link->displacement = 0; 209 | link->relocId = -1; 210 | 211 | return link; 212 | } 213 | 214 | } // AsmJit namespace 215 | 216 | // [Api-End] 217 | #include "../core/apiend.h" 218 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/logger.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/logger.h" 11 | 12 | // [Dependencies - C] 13 | #include 14 | 15 | // [Api-Begin] 16 | #include "../core/apibegin.h" 17 | 18 | namespace AsmJit { 19 | 20 | // ============================================================================ 21 | // [AsmJit::Logger - Construction / Destruction] 22 | // ============================================================================ 23 | 24 | Logger::Logger() : 25 | _flags(kLoggerIsEnabled | kLoggerIsUsed) 26 | { 27 | memset(_instructionPrefix, 0, ASMJIT_ARRAY_SIZE(_instructionPrefix)); 28 | } 29 | 30 | Logger::~Logger() 31 | { 32 | } 33 | 34 | // ============================================================================ 35 | // [AsmJit::Logger - Logging] 36 | // ============================================================================ 37 | 38 | void Logger::logFormat(const char* fmt, ...) 39 | { 40 | char buf[1024]; 41 | size_t len; 42 | 43 | va_list ap; 44 | va_start(ap, fmt); 45 | len = vsnprintf(buf, 1023, fmt, ap); 46 | va_end(ap); 47 | 48 | logString(buf, len); 49 | } 50 | 51 | // ============================================================================ 52 | // [AsmJit::Logger - Enabled] 53 | // ============================================================================ 54 | 55 | void Logger::setEnabled(bool enabled) 56 | { 57 | if (enabled) 58 | _flags |= kLoggerIsEnabled | kLoggerIsUsed; 59 | else 60 | _flags &= ~(kLoggerIsEnabled | kLoggerIsUsed); 61 | } 62 | 63 | // ============================================================================ 64 | // [AsmJit::Logger - LogBinary] 65 | // ============================================================================ 66 | 67 | void Logger::setLogBinary(bool value) 68 | { 69 | if (value) 70 | _flags |= kLoggerOutputBinary; 71 | else 72 | _flags &= ~kLoggerOutputBinary; 73 | } 74 | 75 | // ============================================================================ 76 | // [AsmJit::Logger - HexImmediate] 77 | // ============================================================================ 78 | 79 | void Logger::setHexImmediate(bool value) 80 | { 81 | if (value) 82 | _flags |= kLoggerOutputHexImmediate; 83 | else 84 | _flags &= ~kLoggerOutputHexImmediate; 85 | } 86 | 87 | // ============================================================================ 88 | // [AsmJit::Logger - HexDisplacement] 89 | // ============================================================================ 90 | 91 | void Logger::setHexDisplacement(bool value) 92 | { 93 | if (value) 94 | _flags |= kLoggerOutputHexDisplacement; 95 | else 96 | _flags &= ~kLoggerOutputHexDisplacement; 97 | } 98 | 99 | // ============================================================================ 100 | // [AsmJit::Logger - InstructionPrefix] 101 | // ============================================================================ 102 | 103 | void Logger::setInstructionPrefix(const char* prefix) 104 | { 105 | memset(_instructionPrefix, 0, ASMJIT_ARRAY_SIZE(_instructionPrefix)); 106 | 107 | if (!prefix) 108 | return; 109 | 110 | size_t length = strnlen(prefix, ASMJIT_ARRAY_SIZE(_instructionPrefix) - 1); 111 | memcpy(_instructionPrefix, prefix, length); 112 | } 113 | 114 | // ============================================================================ 115 | // [AsmJit::FileLogger - Construction / Destruction] 116 | // ============================================================================ 117 | 118 | FileLogger::FileLogger(FILE* stream) 119 | : _stream(NULL) 120 | { 121 | setStream(stream); 122 | } 123 | 124 | FileLogger::~FileLogger() 125 | { 126 | } 127 | 128 | // ============================================================================ 129 | // [AsmJit::FileLogger - Accessors] 130 | // ============================================================================ 131 | 132 | //! @brief Set file stream. 133 | void FileLogger::setStream(FILE* stream) 134 | { 135 | _stream = stream; 136 | 137 | if (isEnabled() && _stream != NULL) 138 | _flags |= kLoggerIsUsed; 139 | else 140 | _flags &= ~kLoggerIsUsed; 141 | } 142 | 143 | // ============================================================================ 144 | // [AsmJit::FileLogger - Logging] 145 | // ============================================================================ 146 | 147 | void FileLogger::logString(const char* buf, size_t len) 148 | { 149 | if (!isUsed()) 150 | return; 151 | 152 | if (len == kInvalidSize) 153 | len = strlen(buf); 154 | 155 | fwrite(buf, 1, len, _stream); 156 | } 157 | 158 | // ============================================================================ 159 | // [AsmJit::FileLogger - Enabled] 160 | // ============================================================================ 161 | 162 | void FileLogger::setEnabled(bool enabled) 163 | { 164 | if (enabled) 165 | _flags |= kLoggerIsEnabled | (_stream != NULL ? kLoggerIsUsed : 0); 166 | else 167 | _flags &= ~(kLoggerIsEnabled | kLoggerIsUsed); 168 | } 169 | 170 | // ============================================================================ 171 | // [AsmJit::StringLogger - Construction / Destruction] 172 | // ============================================================================ 173 | 174 | StringLogger::StringLogger() 175 | { 176 | } 177 | 178 | StringLogger::~StringLogger() 179 | { 180 | } 181 | 182 | // ============================================================================ 183 | // [AsmJit::StringLogger - Logging] 184 | // ============================================================================ 185 | 186 | void StringLogger::logString(const char* buf, size_t len) 187 | { 188 | if (!isUsed()) 189 | return; 190 | _stringBuilder.appendString(buf, len); 191 | } 192 | 193 | } // AsmJit namespace 194 | 195 | // [Api-End] 196 | #include "../core/apiend.h" 197 | -------------------------------------------------------------------------------- /libs/asmjit/README.txt: -------------------------------------------------------------------------------- 1 | AsmJit - Complete x86/x64 JIT Assembler for C++ Language - Version 1.0 2 | ====================================================================== 3 | 4 | http://code.google.com/p/asmjit/ 5 | 6 | Introduction 7 | ============ 8 | 9 | AsmJit is a complete x86/x64 JIT Assembler for C++ language. It supports 32-bit 10 | and 64-bit mode, FPU, MMX, 3dNow, SSE, SSE2, SSE3 and SSE4 through type-safe API 11 | which mimics an Intel assembler syntax and eliminates nearly all common mistakes 12 | which can be done by developers at compile time or run-time. 13 | 14 | AsmJit has a high-level code generation classes which can be used as a portable 15 | way to create JIT code. It abstracts differences caused by 32-bit/64-bit mode, 16 | function calling conventions, and platform specific ABI. 17 | 18 | AsmJit has been successfully tested by various C++ compilers (including MSVC, 19 | GCC, Clang, and BorlandC++) under all major operating systems (including Windows, 20 | Linux and Mac). 21 | 22 | Features 23 | ======== 24 | 25 | - Complete x86/x64 instruction set, including FPU, MMX, SSE, SSE2, SSE3, SSSE3 26 | and SSE4, 27 | - Compile time and run-time safety, 28 | - Low-level and high-level code generation, 29 | - Built-in CPU detection, 30 | - Virtual memory management, 31 | - Configurable memory management, logging and error handling, 32 | - Small and embeddable (size of compiled AsmJit is less than 200kB), 33 | - No dependencies on STL or other libraries, 34 | - No exceptions and RTTI, 35 | - Extensible design. 36 | 37 | Assembler / Compiler 38 | ==================== 39 | 40 | AsmJit library contains two main code generation concepts - Assembler and Compiler. 41 | The first concept, called Assembler, contains only interface to emit instructions 42 | and their operands (registers, memory locations, immediates, and labels). This 43 | class can be used by tools which do not need register allocator or contains their 44 | own. 45 | 46 | The second concept, called Compiler, is a high-level code generation, which uses 47 | variables (virtual registers) instead of physical registers. After the code 48 | serialization is finished, register allocator gathers the most important information 49 | about the usage of variables, their scope, and registers which might be used for 50 | each variable. Then all variables are translated into real registers or memory 51 | addresses. Compiler also contains built-in calling convention handling so it's 52 | portable between 32-bit and 64-bit architectures. 53 | 54 | The Compiler is probably not the best tool which can handle register allocation 55 | (linear-scan register allocation is designed for fast-execution). There are some 56 | areas where it could be improved. However, it's built-in, and in the most cases 57 | the output is comparable to the code that is generated by the C/C++ compiler. 58 | The main advantage of Compiler compared to other tools is that it has complete 59 | statistics of variables and their scope, because the register allocator is run 60 | after the code was serialized. There are also some hints which might be used to 61 | improve the process of register allocation. 62 | 63 | Configuring 64 | =========== 65 | 66 | AsmJit is designed to be easily embeddable into any project. It's only needed to 67 | add the C++ files into your project and sometimes to setup src/asmjit/config.h file. 68 | This file contains set of C macros which can be used to configure AsmJit to use 69 | your memory allocation functions, visibility attributes, and error handling. The 70 | standard way to build AsmJit is to create a dynamically linked library. To build 71 | AsmJit statically edit src/asmjit/config.h and uncomment // #define ASMJIT_API 72 | macro. See http://code.google.com/p/asmjit/wiki/Configuring section for details. 73 | 74 | AsmJit contains also CMakeLists.txt which can be used by cmake to generate project 75 | files for many platforms and compilers. If you don't know what cmake is, visit its 76 | homepage at http://www.cmake.org. 77 | 78 | Upgrading 79 | ========= 80 | 81 | Please see http://code.google.com/p/asmjit/wiki/Upgrading_Notes for detailed 82 | information about upgrading to latest AsmJit version. 83 | 84 | Examples 85 | ======== 86 | 87 | - AsmJit home page , 88 | - AsmJit wiki , 89 | - AsmJit Test directory (in this package). 90 | 91 | Directory Structure 92 | =================== 93 | 94 | - extras - Extras. 95 | - extras/doc - Documentation generator files. 96 | - extras/contrib - Contribution (source code/headers), not official part of 97 | AsmJit. 98 | - scripts - Scripts, including project generators. 99 | - src - Source code 100 | - src/asmjit - Public header files (always include files here!), 101 | - src/asmjit/core - Core files used by all AsmJit backends, 102 | - src/asmjit/x86 - X86 platform support and code-generation. 103 | 104 | Supported Compilers 105 | =================== 106 | 107 | - BorlandC++, 108 | - GNU (3.4.X+, 4.0+), 109 | - MinGW, 110 | - MSVC (VC6.0, VS2005, VS2008, VS2010), 111 | - Other compilers require testing. 112 | 113 | Supported Platforms 114 | =================== 115 | 116 | Fully supported platforms at this time are X86 (32-bit) and X86_64/X64 (64-bit). 117 | Other platforms need volunteers. Also note that AsmJit is designed to generate 118 | assembler binary only for host CPU, don't try to generate 64-bit assembler in 119 | 32 bit mode and vica versa - this is not designed to work and will not work. 120 | 121 | License 122 | ======= 123 | 124 | AsmJit can be distributed under zlib license: 125 | 126 | 127 | Google Groups and Mailing Lists 128 | =============================== 129 | 130 | AsmJit google group: 131 | * http://groups.google.com/group/asmjit-dev 132 | 133 | AsmJit mailing list: 134 | * asmjit-dev@googlegroups.com 135 | 136 | Contact Author/Maintainer 137 | ========================= 138 | 139 | Petr Kobalicek 140 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/podvector.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_PODVECTOR_H 9 | #define _ASMJIT_CORE_PODVECTOR_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/assert.h" 13 | #include "../core/defs.h" 14 | 15 | namespace AsmJit { 16 | 17 | //! @addtogroup AsmJit_Core 18 | //! @{ 19 | 20 | // ============================================================================ 21 | // [AsmJit::PodVector] 22 | // ============================================================================ 23 | 24 | //! @brief Template used to store and manage array of POD data. 25 | //! 26 | //! This template has these adventages over other vector<> templates: 27 | //! - Non-copyable (designed to be non-copyable, we want it) 28 | //! - No copy-on-write (some implementations of stl can use it) 29 | //! - Optimized for working only with POD types 30 | //! - Uses ASMJIT_... memory management macros 31 | template 32 | struct PodVector 33 | { 34 | ASMJIT_NO_COPY(PodVector) 35 | 36 | // -------------------------------------------------------------------------- 37 | // [Construction / Destruction] 38 | // -------------------------------------------------------------------------- 39 | 40 | //! @brief Create new instance of PodVector template. Data will not 41 | //! be allocated (will be NULL). 42 | inline PodVector() : 43 | _data(NULL), 44 | _length(0), 45 | _capacity(0) 46 | { 47 | } 48 | 49 | //! @brief Destroy PodVector and free all data. 50 | inline ~PodVector() 51 | { 52 | if (_data != NULL) 53 | ASMJIT_FREE(_data); 54 | } 55 | 56 | // -------------------------------------------------------------------------- 57 | // [Data] 58 | // -------------------------------------------------------------------------- 59 | 60 | //! @brief Get data. 61 | inline T* getData() { return _data; } 62 | //! @overload 63 | inline const T* getData() const { return _data; } 64 | 65 | //! @brief Get length. 66 | inline size_t getLength() const { return _length; } 67 | //! @brief Get capacity. 68 | inline size_t getCapacity() const { return _capacity; } 69 | 70 | // -------------------------------------------------------------------------- 71 | // [Manipulation] 72 | // -------------------------------------------------------------------------- 73 | 74 | //! @brief Clear vector data, but not free internal buffer. 75 | void clear() 76 | { 77 | _length = 0; 78 | } 79 | 80 | //! @brief Clear vector data and free internal buffer. 81 | void reset() 82 | { 83 | if (_data != NULL) 84 | { 85 | ASMJIT_FREE(_data); 86 | _data = 0; 87 | _length = 0; 88 | _capacity = 0; 89 | } 90 | } 91 | 92 | //! @brief Prepend @a item to vector. 93 | bool prepend(const T& item) 94 | { 95 | if (_length == _capacity && !_grow()) return false; 96 | 97 | memmove(_data + 1, _data, sizeof(T) * _length); 98 | memcpy(_data, &item, sizeof(T)); 99 | 100 | _length++; 101 | return true; 102 | } 103 | 104 | //! @brief Insert an @a item at the @a index. 105 | bool insert(size_t index, const T& item) 106 | { 107 | ASMJIT_ASSERT(index <= _length); 108 | if (_length == _capacity && !_grow()) return false; 109 | 110 | T* dst = _data + index; 111 | memmove(dst + 1, dst, _length - index); 112 | memcpy(dst, &item, sizeof(T)); 113 | 114 | _length++; 115 | return true; 116 | } 117 | 118 | //! @brief Append @a item to vector. 119 | bool append(const T& item) 120 | { 121 | if (_length == _capacity && !_grow()) return false; 122 | 123 | memcpy(_data + _length, &item, sizeof(T)); 124 | 125 | _length++; 126 | return true; 127 | } 128 | 129 | //! @brief Get index of @a val or kInvalidSize if not found. 130 | size_t indexOf(const T& val) const 131 | { 132 | size_t i = 0, len = _length; 133 | for (i = 0; i < len; i++) { if (_data[i] == val) return i; } 134 | return kInvalidSize; 135 | } 136 | 137 | //! @brief Remove element at index @a i. 138 | void removeAt(size_t i) 139 | { 140 | ASMJIT_ASSERT(i < _length); 141 | 142 | T* dst = _data + i; 143 | _length--; 144 | memmove(dst, dst + 1, _length - i); 145 | } 146 | 147 | //! @brief Swap this pod-vector with @a other. 148 | void swap(PodVector& other) 149 | { 150 | T* _tmp_data = _data; 151 | size_t _tmp_length = _length; 152 | size_t _tmp_capacity = _capacity; 153 | 154 | _data = other._data; 155 | _length = other._length; 156 | _capacity = other._capacity; 157 | 158 | other._data = _tmp_data; 159 | other._length = _tmp_length; 160 | other._capacity = _tmp_capacity; 161 | } 162 | 163 | //! @brief Get item at position @a i. 164 | inline T& operator[](size_t i) 165 | { 166 | ASMJIT_ASSERT(i < _length); 167 | return _data[i]; 168 | } 169 | //! @brief Get item at position @a i. 170 | inline const T& operator[](size_t i) const 171 | { 172 | ASMJIT_ASSERT(i < _length); 173 | return _data[i]; 174 | } 175 | 176 | //! @brief Append the item and return address so it can be initialized. 177 | T* newItem() 178 | { 179 | if (_length == _capacity && !_grow()) return NULL; 180 | return _data + (_length++); 181 | } 182 | 183 | // -------------------------------------------------------------------------- 184 | // [Private] 185 | // -------------------------------------------------------------------------- 186 | 187 | //! @brief Called to grow internal array. 188 | bool _grow() 189 | { 190 | return _realloc(_capacity < 16 ? 16 : _capacity * 2); 191 | } 192 | 193 | //! @brief Realloc internal array to fit @a to items. 194 | bool _realloc(size_t to) 195 | { 196 | ASMJIT_ASSERT(to >= _length); 197 | 198 | T* p = reinterpret_cast(_data ? ASMJIT_REALLOC(_data, to * sizeof(T)) : ASMJIT_MALLOC(to * sizeof(T))); 199 | 200 | if (p == NULL) 201 | return false; 202 | 203 | _data = p; 204 | _capacity = to; 205 | return true; 206 | } 207 | 208 | // -------------------------------------------------------------------------- 209 | // [Members] 210 | // -------------------------------------------------------------------------- 211 | 212 | //! @brief Items data. 213 | T* _data; 214 | //! @brief Length of buffer (count of items in array). 215 | size_t _length; 216 | //! @brief Capacity of buffer (maximum items that can fit to current array). 217 | size_t _capacity; 218 | }; 219 | 220 | //! @} 221 | 222 | } // AsmJit namespace 223 | 224 | #endif // _ASMJIT_CORE_PODVECTOR_H 225 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/memorymanager.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_MEMORYMANAGER_H 9 | #define _ASMJIT_CORE_MEMORYMANAGER_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | #include "../core/defs.h" 14 | 15 | // [Api-Begin] 16 | #include "../core/apibegin.h" 17 | 18 | // [Debug] 19 | // #define ASMJIT_MEMORY_MANAGER_DUMP 20 | 21 | namespace AsmJit { 22 | 23 | //! @addtogroup AsmJit_MemoryManagement 24 | //! @{ 25 | 26 | // ============================================================================ 27 | // [AsmJit::MemoryManager] 28 | // ============================================================================ 29 | 30 | //! @brief Virtual memory manager interface. 31 | //! 32 | //! This class is pure virtual. You can get default virtual memory manager using 33 | //! @c getGlobal() method. If you want to create more memory managers with same 34 | //! functionality as global memory manager use @c VirtualMemoryManager class. 35 | struct MemoryManager 36 | { 37 | // -------------------------------------------------------------------------- 38 | // [Construction / Destruction] 39 | // -------------------------------------------------------------------------- 40 | 41 | //! @brief Create memory manager instance. 42 | ASMJIT_API MemoryManager(); 43 | //! @brief Destroy memory manager instance, this means also to free all memory 44 | //! blocks. 45 | ASMJIT_API virtual ~MemoryManager(); 46 | 47 | // -------------------------------------------------------------------------- 48 | // [Interface] 49 | // -------------------------------------------------------------------------- 50 | 51 | //! @brief Allocate a @a size bytes of virtual memory. 52 | //! 53 | //! Note that if you are implementing your own virtual memory manager then you 54 | //! can quitly ignore type of allocation. This is mainly for AsmJit to memory 55 | //! manager that allocated memory will be never freed. 56 | virtual void* alloc(size_t size, uint32_t type = kMemAllocFreeable) = 0; 57 | //! @brief Free previously allocated memory at a given @a address. 58 | virtual bool free(void* address) = 0; 59 | //! @brief Free some tail memory. 60 | virtual bool shrink(void* address, size_t used) = 0; 61 | //! @brief Free all allocated memory. 62 | virtual void freeAll() = 0; 63 | 64 | //! @brief Get how many bytes are currently used. 65 | virtual size_t getUsedBytes() = 0; 66 | //! @brief Get how many bytes are currently allocated. 67 | virtual size_t getAllocatedBytes() = 0; 68 | 69 | // -------------------------------------------------------------------------- 70 | // [Statics] 71 | // -------------------------------------------------------------------------- 72 | 73 | //! @brief Get global memory manager instance. 74 | //! 75 | //! Global instance is instance of @c VirtualMemoryManager class. Global memory 76 | //! manager is used by default by @ref Assembler::make() and @ref Compiler::make() 77 | //! methods. 78 | ASMJIT_API static MemoryManager* getGlobal(); 79 | }; 80 | 81 | // ============================================================================ 82 | // [AsmJit::VirtualMemoryManager] 83 | // ============================================================================ 84 | 85 | //! @brief Reference implementation of memory manager that uses 86 | //! @ref AsmJit::VirtualMemory class to allocate chunks of virtual memory 87 | //! and bit arrays to manage it. 88 | struct VirtualMemoryManager : public MemoryManager 89 | { 90 | // -------------------------------------------------------------------------- 91 | // [Construction / Destruction] 92 | // -------------------------------------------------------------------------- 93 | 94 | //! @brief Create a @c VirtualMemoryManager instance. 95 | ASMJIT_API VirtualMemoryManager(); 96 | 97 | #if defined(ASMJIT_WINDOWS) 98 | //! @brief Create a @c VirtualMemoryManager instance for process @a hProcess. 99 | //! 100 | //! This is specialized version of constructor available only for windows and 101 | //! usable to alloc/free memory of different process. 102 | ASMJIT_API VirtualMemoryManager(HANDLE hProcess); 103 | #endif // ASMJIT_WINDOWS 104 | 105 | //! @brief Destroy the @c VirtualMemoryManager instance, this means also to 106 | //! free all blocks. 107 | ASMJIT_API virtual ~VirtualMemoryManager(); 108 | 109 | // -------------------------------------------------------------------------- 110 | // [Interface] 111 | // -------------------------------------------------------------------------- 112 | 113 | ASMJIT_API virtual void* alloc(size_t size, uint32_t type = kMemAllocFreeable); 114 | ASMJIT_API virtual bool free(void* address); 115 | ASMJIT_API virtual bool shrink(void* address, size_t used); 116 | ASMJIT_API virtual void freeAll(); 117 | 118 | ASMJIT_API virtual size_t getUsedBytes(); 119 | ASMJIT_API virtual size_t getAllocatedBytes(); 120 | 121 | // -------------------------------------------------------------------------- 122 | // [Virtual Memory Manager Specific] 123 | // -------------------------------------------------------------------------- 124 | 125 | //! @brief Get whether to keep allocated memory after memory manager is 126 | //! destroyed. 127 | //! 128 | //! @sa @c setKeepVirtualMemory(). 129 | ASMJIT_API bool getKeepVirtualMemory() const; 130 | 131 | //! @brief Set whether to keep allocated memory after memory manager is 132 | //! destroyed. 133 | //! 134 | //! This method is usable when patching code of remote process. You need to 135 | //! allocate process memory, store generated assembler into it and patch the 136 | //! method you want to redirect (into your code). This method affects only 137 | //! VirtualMemoryManager destructor. After destruction all internal 138 | //! structures are freed, only the process virtual memory remains. 139 | //! 140 | //! @note Memory allocated with kMemAllocPermanent is always kept. 141 | //! 142 | //! @sa @c getKeepVirtualMemory(). 143 | ASMJIT_API void setKeepVirtualMemory(bool keepVirtualMemory); 144 | 145 | // -------------------------------------------------------------------------- 146 | // [Debug] 147 | // -------------------------------------------------------------------------- 148 | 149 | #if defined(ASMJIT_MEMORY_MANAGER_DUMP) 150 | //! @brief Dump memory manager tree into file. 151 | //! 152 | //! Generated output is using DOT language (from graphviz package). 153 | ASMJIT_API void dump(const char* fileName); 154 | #endif // ASMJIT_MEMORY_MANAGER_DUMP 155 | 156 | // -------------------------------------------------------------------------- 157 | // [Members] 158 | // -------------------------------------------------------------------------- 159 | 160 | //! @brief Pointer to private data hidden from the public API. 161 | void* _d; 162 | }; 163 | 164 | //! @} 165 | 166 | } // AsmJit namespace 167 | 168 | // [Api-End] 169 | #include "../core/apiend.h" 170 | 171 | // [Guard] 172 | #endif // _ASMJIT_CORE_MEMORYMANAGER_H 173 | -------------------------------------------------------------------------------- /libs/asmjit/extras/doc/doxygen.css: -------------------------------------------------------------------------------- 1 | body, table, div, p, dl { 2 | font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; 3 | font-size: 12px; 4 | } 5 | 6 | /* @group Heading Levels */ 7 | 8 | h1 { 9 | text-align: center; 10 | font-size: 150%; 11 | } 12 | 13 | h2 { 14 | font-size: 120%; 15 | } 16 | 17 | h3 { 18 | font-size: 100%; 19 | } 20 | 21 | /* @end */ 22 | 23 | caption { 24 | font-weight: bold; 25 | } 26 | 27 | div.qindex, div.navtab{ 28 | background-color: #e8eef2; 29 | border: 1px solid #84b0c7; 30 | text-align: center; 31 | margin: 2px; 32 | padding: 2px; 33 | } 34 | 35 | div.qindex, div.navpath { 36 | width: 100%; 37 | line-height: 140%; 38 | } 39 | 40 | div.navtab { 41 | margin-right: 15px; 42 | } 43 | 44 | /* @group Link Styling */ 45 | 46 | a { 47 | color: #153788; 48 | font-weight: normal; 49 | text-decoration: none; 50 | } 51 | 52 | .contents a:visited { 53 | color: #1b77c5; 54 | } 55 | 56 | a:hover { 57 | text-decoration: underline; 58 | } 59 | 60 | a.qindex { 61 | font-weight: bold; 62 | } 63 | 64 | a.qindexHL { 65 | font-weight: bold; 66 | background-color: #6666cc; 67 | color: #ffffff; 68 | border: 1px double #9295C2; 69 | } 70 | 71 | .contents a.qindexHL:visited { 72 | color: #ffffff; 73 | } 74 | 75 | a.el { 76 | font-weight: bold; 77 | } 78 | 79 | a.elRef { 80 | } 81 | 82 | a.code { 83 | } 84 | 85 | a.codeRef { 86 | } 87 | 88 | /* @end */ 89 | 90 | dl.el { 91 | margin-left: -1cm; 92 | } 93 | 94 | .fragment { 95 | font-family: monospace, fixed; 96 | font-size: 105%; 97 | } 98 | 99 | pre.fragment { 100 | border: 1px dotted #CCCCFF; 101 | padding: 4px 6px; 102 | margin: 4px 8px 4px 2px; 103 | } 104 | 105 | div.ah { 106 | background-color: black; 107 | font-weight: bold; 108 | color: #ffffff; 109 | margin-bottom: 3px; 110 | margin-top: 3px 111 | } 112 | 113 | div.groupHeader { 114 | margin-left: 16px; 115 | margin-top: 12px; 116 | margin-bottom: 6px; 117 | font-weight: bold; 118 | } 119 | 120 | div.groupText { 121 | margin-left: 16px; 122 | font-style: italic; 123 | } 124 | 125 | body { 126 | background: white; 127 | color: black; 128 | margin-right: 20px; 129 | margin-left: 20px; 130 | } 131 | 132 | td.indexkey { 133 | background-color: #e8eef2; 134 | font-weight: bold; 135 | border: 1px solid #CCCCCC; 136 | margin: 2px 0px 2px 0; 137 | padding: 2px 10px; 138 | } 139 | 140 | td.indexvalue { 141 | background-color: #e8eef2; 142 | border: 1px solid #CCCCCC; 143 | padding: 2px 10px; 144 | margin: 2px 0px; 145 | } 146 | 147 | tr.memlist { 148 | background-color: #f0f0f0; 149 | } 150 | 151 | p.formulaDsp { 152 | text-align: center; 153 | } 154 | 155 | img.formulaDsp { 156 | 157 | } 158 | 159 | img.formulaInl { 160 | vertical-align: middle; 161 | } 162 | 163 | /* @group Code Colorization */ 164 | 165 | span.keyword { 166 | color: #008000 167 | } 168 | 169 | span.keywordtype { 170 | color: #604020 171 | } 172 | 173 | span.keywordflow { 174 | color: #e08000 175 | } 176 | 177 | span.comment { 178 | color: #800000 179 | } 180 | 181 | span.preprocessor { 182 | color: #806020 183 | } 184 | 185 | span.stringliteral { 186 | color: #002080 187 | } 188 | 189 | span.charliteral { 190 | color: #008080 191 | } 192 | 193 | /* @end */ 194 | 195 | td.tiny { 196 | font-size: 75%; 197 | } 198 | 199 | .dirtab { 200 | padding: 4px; 201 | border-collapse: collapse; 202 | border: 1px solid #84b0c7; 203 | } 204 | 205 | th.dirtab { 206 | background: #e8eef2; 207 | font-weight: bold; 208 | } 209 | 210 | hr { 211 | height: 0; 212 | border: none; 213 | border-top: 1px solid #666; 214 | } 215 | 216 | /* @group Member Descriptions */ 217 | 218 | .mdescLeft, .mdescRight, 219 | .memItemLeft, .memItemRight, 220 | .memTemplItemLeft, .memTemplItemRight, .memTemplParams { 221 | background-color: #FFFFFF; 222 | border: none; 223 | margin: 4px; 224 | padding: 1px 0 0 8px; 225 | } 226 | 227 | .mdescLeft, .mdescRight { 228 | padding: 0px 8px 4px 8px; 229 | color: #555; 230 | } 231 | 232 | .memItemLeft, .memItemRight { 233 | padding-top: 4px; 234 | padding-bottom: 4px; 235 | border-top: 1px solid #CCCCFF; 236 | } 237 | 238 | .mdescLeft, .mdescRight { 239 | } 240 | 241 | .memTemplParams { 242 | color: #606060; 243 | } 244 | 245 | /* @end */ 246 | 247 | /* @group Member Details */ 248 | 249 | /* Styles for detailed member documentation */ 250 | 251 | .memtemplate { 252 | margin-left: 3px; 253 | font-weight: normal; 254 | font-size: 80%; 255 | color: #606060; 256 | } 257 | 258 | .memnav { 259 | background-color: #e8eef2; 260 | border: 1px solid #84b0c7; 261 | text-align: center; 262 | margin: 2px; 263 | margin-right: 15px; 264 | padding: 2px; 265 | } 266 | 267 | .memitem { 268 | padding: 0; 269 | } 270 | 271 | .memname { 272 | white-space: nowrap; 273 | font-weight: bold; 274 | } 275 | 276 | .memproto, .memdoc { 277 | } 278 | 279 | .memproto { 280 | padding: 0; 281 | background-color: #EEEEFF; 282 | border: 1px solid #CCCCFF; 283 | } 284 | 285 | .memdoc { 286 | padding: 2px 5px; 287 | border-left: 1px solid #CCCCFF; 288 | border-right: 1px solid #CCCCFF; 289 | border-bottom: 1px solid #CCCCFF; 290 | } 291 | 292 | .paramkey { 293 | text-align: right; 294 | } 295 | 296 | .paramtype { 297 | white-space: nowrap; 298 | } 299 | 300 | .paramname { 301 | color: #606060; 302 | font-weight: normal; 303 | white-space: nowrap; 304 | } 305 | .paramname em { 306 | font-style: normal; 307 | } 308 | 309 | /* @end */ 310 | 311 | /* @group Directory (tree) */ 312 | 313 | /* for the tree view */ 314 | 315 | .ftvtree { 316 | font-family: sans-serif; 317 | margin: 0.5em; 318 | } 319 | 320 | /* these are for tree view when used as main index */ 321 | 322 | .directory { 323 | font-size: 9pt; 324 | font-weight: bold; 325 | } 326 | 327 | .directory h3 { 328 | margin: 0px; 329 | margin-top: 1em; 330 | font-size: 11pt; 331 | } 332 | 333 | /* 334 | The following two styles can be used to replace the root node title 335 | with an image of your choice. Simply uncomment the next two styles, 336 | specify the name of your image and be sure to set 'height' to the 337 | proper pixel height of your image. 338 | */ 339 | 340 | /* 341 | .directory h3.swap { 342 | height: 61px; 343 | background-repeat: no-repeat; 344 | background-image: url("yourimage.gif"); 345 | } 346 | .directory h3.swap span { 347 | display: none; 348 | } 349 | */ 350 | 351 | .directory > h3 { 352 | margin-top: 0; 353 | } 354 | 355 | .directory p { 356 | margin: 0px; 357 | white-space: nowrap; 358 | } 359 | 360 | .directory div { 361 | display: none; 362 | margin: 0px; 363 | } 364 | 365 | .directory img { 366 | vertical-align: -30%; 367 | } 368 | 369 | /* these are for tree view when not used as main index */ 370 | 371 | .directory-alt { 372 | font-size: 100%; 373 | font-weight: bold; 374 | } 375 | 376 | .directory-alt h3 { 377 | margin: 0px; 378 | margin-top: 1em; 379 | font-size: 11pt; 380 | } 381 | 382 | .directory-alt > h3 { 383 | margin-top: 0; 384 | } 385 | 386 | .directory-alt p { 387 | margin: 0px; 388 | white-space: nowrap; 389 | } 390 | 391 | .directory-alt div { 392 | display: none; 393 | margin: 0px; 394 | } 395 | 396 | .directory-alt img { 397 | vertical-align: -30%; 398 | } 399 | 400 | /* @end */ 401 | 402 | address { 403 | font-style: normal; 404 | color: #333; 405 | } 406 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/compiler.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assembler.h" 11 | #include "../core/compiler.h" 12 | #include "../core/compilercontext.h" 13 | #include "../core/compilerfunc.h" 14 | #include "../core/compileritem.h" 15 | #include "../core/cpuinfo.h" 16 | #include "../core/intutil.h" 17 | #include "../core/logger.h" 18 | 19 | // [Api-Begin] 20 | #include "../core/apibegin.h" 21 | 22 | namespace AsmJit { 23 | 24 | // ============================================================================ 25 | // [AsmJit::Compiler - Construction / Destruction] 26 | // ============================================================================ 27 | 28 | Compiler::Compiler(Context* context) : 29 | _zoneMemory(16384 - sizeof(ZoneChunk) - 32), 30 | _linkMemory(1024 - 32), 31 | _context(context != NULL ? context : static_cast(JitContext::getGlobal())), 32 | _logger(NULL), 33 | _error(0), 34 | _properties(0), 35 | _emitOptions(0), 36 | _finished(false), 37 | _first(NULL), 38 | _last(NULL), 39 | _current(NULL), 40 | _func(NULL), 41 | _cc(NULL), 42 | _varNameId(0) 43 | { 44 | } 45 | 46 | Compiler::~Compiler() 47 | { 48 | reset(); 49 | } 50 | 51 | // ============================================================================ 52 | // [AsmJit::Compiler - Logging] 53 | // ============================================================================ 54 | 55 | void Compiler::setLogger(Logger* logger) 56 | { 57 | _logger = logger; 58 | } 59 | 60 | // ============================================================================ 61 | // [AsmJit::Compiler - Error Handling] 62 | // ============================================================================ 63 | 64 | void Compiler::setError(uint32_t error) 65 | { 66 | _error = error; 67 | if (_error == kErrorOk) 68 | return; 69 | 70 | if (_logger) 71 | _logger->logFormat("*** COMPILER ERROR: %s (%u).\n", getErrorString(error), (unsigned int)error); 72 | } 73 | 74 | // ============================================================================ 75 | // [AsmJit::Compiler - Properties] 76 | // ============================================================================ 77 | 78 | uint32_t Compiler::getProperty(uint32_t propertyId) 79 | { 80 | if (propertyId > 31) 81 | return 0; 82 | 83 | return (_properties & IntUtil::maskFromIndex(propertyId)) != 0; 84 | } 85 | 86 | void Compiler::setProperty(uint32_t propertyId, uint32_t value) 87 | { 88 | if (propertyId > 31) 89 | return; 90 | 91 | if (value) 92 | _properties |= IntUtil::maskFromIndex(propertyId); 93 | else 94 | _properties &= ~IntUtil::maskFromIndex(propertyId); 95 | } 96 | 97 | // ============================================================================ 98 | // [AsmJit::Compiler - Clear / Reset] 99 | // ============================================================================ 100 | 101 | void Compiler::clear() 102 | { 103 | _purge(); 104 | 105 | if (_error != kErrorOk) 106 | setError(kErrorOk); 107 | } 108 | 109 | void Compiler::reset() 110 | { 111 | _purge(); 112 | 113 | _zoneMemory.reset(); 114 | _linkMemory.reset(); 115 | 116 | _targets.reset(); 117 | _vars.reset(); 118 | 119 | if (_error != kErrorOk) 120 | setError(kErrorOk); 121 | } 122 | 123 | void Compiler::_purge() 124 | { 125 | _zoneMemory.clear(); 126 | _linkMemory.clear(); 127 | 128 | _emitOptions = 0; 129 | _finished = false; 130 | 131 | _first = NULL; 132 | _last = NULL; 133 | _current = NULL; 134 | _func = NULL; 135 | 136 | _targets.clear(); 137 | _vars.clear(); 138 | 139 | _cc = NULL; 140 | _varNameId = 0; 141 | } 142 | 143 | // ============================================================================ 144 | // [AsmJit::Compiler - Item Management] 145 | // ============================================================================ 146 | 147 | CompilerItem* Compiler::setCurrentItem(CompilerItem* item) 148 | { 149 | CompilerItem* old = _current; 150 | _current = item; 151 | return old; 152 | } 153 | 154 | void Compiler::addItem(CompilerItem* item) 155 | { 156 | ASMJIT_ASSERT(item != NULL); 157 | ASMJIT_ASSERT(item->_prev == NULL); 158 | ASMJIT_ASSERT(item->_next == NULL); 159 | 160 | if (_current == NULL) 161 | { 162 | if (_first == NULL) 163 | { 164 | _first = item; 165 | _last = item; 166 | } 167 | else 168 | { 169 | item->_next = _first; 170 | _first->_prev = item; 171 | _first = item; 172 | } 173 | } 174 | else 175 | { 176 | CompilerItem* prev = _current; 177 | CompilerItem* next = _current->_next; 178 | 179 | item->_prev = prev; 180 | item->_next = next; 181 | 182 | prev->_next = item; 183 | if (next) 184 | next->_prev = item; 185 | else 186 | _last = item; 187 | } 188 | 189 | _current = item; 190 | } 191 | 192 | void Compiler::addItemAfter(CompilerItem* item, CompilerItem* ref) 193 | { 194 | ASMJIT_ASSERT(item != NULL); 195 | ASMJIT_ASSERT(item->_prev == NULL); 196 | ASMJIT_ASSERT(item->_next == NULL); 197 | ASMJIT_ASSERT(ref != NULL); 198 | 199 | CompilerItem* prev = ref; 200 | CompilerItem* next = ref->_next; 201 | 202 | item->_prev = prev; 203 | item->_next = next; 204 | 205 | prev->_next = item; 206 | if (next) 207 | next->_prev = item; 208 | else 209 | _last = item; 210 | } 211 | 212 | void Compiler::removeItem(CompilerItem* item) 213 | { 214 | CompilerItem* prev = item->_prev; 215 | CompilerItem* next = item->_next; 216 | 217 | if (_first == item) { _first = next; } else { prev->_next = next; } 218 | if (_last == item) { _last = prev; } else { next->_prev = prev; } 219 | 220 | item->_prev = NULL; 221 | item->_next = NULL; 222 | 223 | if (_current == item) 224 | _current = prev; 225 | } 226 | 227 | // ============================================================================ 228 | // [AsmJit::Compiler - Comment] 229 | // ============================================================================ 230 | 231 | void Compiler::comment(const char* fmt, ...) 232 | { 233 | char buf[128]; 234 | char* p = buf; 235 | 236 | if (fmt) 237 | { 238 | *p++ = ';'; 239 | *p++ = ' '; 240 | 241 | va_list ap; 242 | va_start(ap, fmt); 243 | p += vsnprintf(p, 100, fmt, ap); 244 | va_end(ap); 245 | } 246 | 247 | *p++ = '\n'; 248 | *p = '\0'; 249 | 250 | CompilerComment* item = Compiler_newItem(this, buf); 251 | addItem(item); 252 | } 253 | 254 | // ============================================================================ 255 | // [AsmJit::Compiler - Embed] 256 | // ============================================================================ 257 | 258 | void Compiler::embed(const void* data, size_t len) 259 | { 260 | // Align length to 16 bytes. 261 | size_t alignedSize = IntUtil::align(len, sizeof(uintptr_t)); 262 | void* p = _zoneMemory.alloc(sizeof(CompilerEmbed) - sizeof(void*) + alignedSize); 263 | 264 | if (p == NULL) 265 | return; 266 | 267 | CompilerEmbed* item = new(p) CompilerEmbed(this, data, len); 268 | addItem(item); 269 | } 270 | 271 | } // AsmJit namespace 272 | 273 | // [Api-Begin] 274 | #include "../core/apibegin.h" 275 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/stringbuilder.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_STRINGBUILDER_H 9 | #define _ASMJIT_CORE_STRINGBUILDER_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/assert.h" 13 | #include "../core/defs.h" 14 | 15 | namespace AsmJit { 16 | 17 | //! @addtogroup AsmJit_Core 18 | //! @{ 19 | 20 | // ============================================================================ 21 | // [AsmJit::StringBuilder] 22 | // ============================================================================ 23 | 24 | //! @brief String builder. 25 | //! 26 | //! String builder was designed to be able to build a string using append like 27 | //! operation to append numbers, other strings, or signle characters. It can 28 | //! allocate it's own buffer or use a buffer created on the stack. 29 | //! 30 | //! String builder contains method specific to AsmJit functionality, used for 31 | //! logging or HTML output. 32 | struct StringBuilder 33 | { 34 | ASMJIT_NO_COPY(StringBuilder) 35 | 36 | // -------------------------------------------------------------------------- 37 | // [Construction / Destruction] 38 | // -------------------------------------------------------------------------- 39 | 40 | ASMJIT_API StringBuilder(); 41 | ASMJIT_API ~StringBuilder(); 42 | 43 | inline StringBuilder(const _DontInitialize&) {} 44 | 45 | // -------------------------------------------------------------------------- 46 | // [Accessors] 47 | // -------------------------------------------------------------------------- 48 | 49 | //! @brief Get string builder capacity. 50 | inline size_t getCapacity() const 51 | { return _capacity; } 52 | 53 | //! @brief Get length. 54 | inline size_t getLength() const 55 | { return _length; } 56 | 57 | //! @brief Get null-terminated string data. 58 | inline char* getData() 59 | { return _data; } 60 | 61 | //! @brief Get null-terminated string data (const). 62 | inline const char* getData() const 63 | { return _data; } 64 | 65 | // -------------------------------------------------------------------------- 66 | // [Prepare / Reserve] 67 | // -------------------------------------------------------------------------- 68 | 69 | //! @brief Prepare to set/append. 70 | ASMJIT_API char* prepare(uint32_t op, size_t len); 71 | 72 | //! @brief Reserve @a to bytes in string builder. 73 | ASMJIT_API bool reserve(size_t to); 74 | 75 | // -------------------------------------------------------------------------- 76 | // [Clear] 77 | // -------------------------------------------------------------------------- 78 | 79 | //! @brief Clear the content in String builder. 80 | ASMJIT_API void clear(); 81 | 82 | // -------------------------------------------------------------------------- 83 | // [Methods] 84 | // -------------------------------------------------------------------------- 85 | 86 | ASMJIT_API bool _opString(uint32_t op, const char* str, size_t len = kInvalidSize); 87 | ASMJIT_API bool _opVFormat(uint32_t op, const char* fmt, va_list ap); 88 | ASMJIT_API bool _opChars(uint32_t op, char c, size_t len); 89 | ASMJIT_API bool _opNumber(uint32_t op, uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0); 90 | ASMJIT_API bool _opHex(uint32_t op, const void* data, size_t length); 91 | 92 | //! @brief Replace the current content by @a str of @a len. 93 | inline bool setString(const char* str, size_t len = kInvalidSize) 94 | { return _opString(kStringBuilderOpSet, str, len); } 95 | 96 | //! @brief Replace the current content by formatted string @a fmt. 97 | inline bool setVFormat(const char* fmt, va_list ap) 98 | { return _opVFormat(kStringBuilderOpSet, fmt, ap); } 99 | 100 | //! @brief Replace the current content by formatted string @a fmt. 101 | ASMJIT_API bool setFormat(const char* fmt, ...); 102 | 103 | //! @brief Replace the current content by @a c of @a len. 104 | inline bool setChars(char c, size_t len) 105 | { return _opChars(kStringBuilderOpSet, c, len); } 106 | 107 | //! @brief Replace the current content by @a i.. 108 | inline bool setNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0) 109 | { return _opNumber(kStringBuilderOpSet, i, base, width, flags); } 110 | 111 | //! @brief Append @a str of @a len. 112 | inline bool appendString(const char* str, size_t len = kInvalidSize) 113 | { return _opString(kStringBuilderOpAppend, str, len); } 114 | 115 | //! @brief Append a formatted string @a fmt to the current content. 116 | inline bool appendVFormat(const char* fmt, va_list ap) 117 | { return _opVFormat(kStringBuilderOpAppend, fmt, ap); } 118 | 119 | //! @brief Append a formatted string @a fmt to the current content. 120 | ASMJIT_API bool appendFormat(const char* fmt, ...); 121 | 122 | //! @brief Append @a c of @a len. 123 | inline bool appendChars(char c, size_t len) 124 | { return _opChars(kStringBuilderOpAppend, c, len); } 125 | 126 | //! @brief Append @a i. 127 | inline bool appendNumber(uint64_t i, uint32_t base = 0, size_t width = 0, uint32_t flags = 0) 128 | { return _opNumber(kStringBuilderOpAppend, i, base, width, flags); } 129 | 130 | //! @brief Check for equality with other @a str. 131 | ASMJIT_API bool eq(const char* str, size_t len = kInvalidSize) const; 132 | 133 | //! @brief Check for equality with StringBuilder @a other. 134 | inline bool eq(const StringBuilder& other) const 135 | { return eq(other._data); } 136 | 137 | // -------------------------------------------------------------------------- 138 | // [Operator Overload] 139 | // -------------------------------------------------------------------------- 140 | 141 | inline bool operator==(const StringBuilder& other) const { return eq(other); } 142 | inline bool operator!=(const StringBuilder& other) const { return !eq(other); } 143 | 144 | inline bool operator==(const char* str) const { return eq(str); } 145 | inline bool operator!=(const char* str) const { return !eq(str); } 146 | 147 | // -------------------------------------------------------------------------- 148 | // [Members] 149 | // -------------------------------------------------------------------------- 150 | 151 | //! @brief String data. 152 | char* _data; 153 | //! @brief Length. 154 | size_t _length; 155 | //! @brief Capacity. 156 | size_t _capacity; 157 | //! @brief Whether the string can be freed. 158 | size_t _canFree; 159 | }; 160 | 161 | // ============================================================================ 162 | // [AsmJit::StringBuilderT] 163 | // ============================================================================ 164 | 165 | template 166 | struct StringBuilderT : public StringBuilder 167 | { 168 | ASMJIT_NO_COPY(StringBuilderT) 169 | 170 | // -------------------------------------------------------------------------- 171 | // [Construction / Destruction] 172 | // -------------------------------------------------------------------------- 173 | 174 | inline StringBuilderT() : 175 | StringBuilder(_DontInitialize()) 176 | { 177 | _data = _embeddedData; 178 | _data[0] = 0; 179 | 180 | _length = 0; 181 | _capacity = 0; 182 | _canFree = false; 183 | } 184 | 185 | // -------------------------------------------------------------------------- 186 | // [Members] 187 | // -------------------------------------------------------------------------- 188 | 189 | //! @brief Embedded data. 190 | char _embeddedData[(N + sizeof(uintptr_t)) & ~(sizeof(uintptr_t) - 1)]; 191 | }; 192 | 193 | //! @} 194 | 195 | } // AsmJit namespace 196 | 197 | #endif // _ASMJIT_CORE_STRINGBUILDER_H 198 | -------------------------------------------------------------------------------- /libs/asmjit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ============================================================================= 2 | # [AsmJit - CMakeLists.txt] 3 | # ============================================================================= 4 | 5 | CMake_Minimum_Required(VERSION 2.8.7) 6 | 7 | # ============================================================================= 8 | # [AsmJit - Configuration] 9 | # ============================================================================= 10 | 11 | # Whether to build static library (default FALSE). 12 | # Set(ASMJIT_STATIC FALSE) 13 | 14 | # Whether to build samples (default FALSE). 15 | # Set(ASMJIT_BUILD_SAMPLES FALSE) 16 | 17 | # ============================================================================= 18 | # [AsmJit - Build] 19 | # ============================================================================= 20 | 21 | # Create AsmJit project. In case that you called Project() before the AsmJit 22 | # CMakeLists.txt the project won't be created (just included). 23 | Set(ASMJIT_PROJECT_STR "Project") 24 | 25 | If(NOT CMAKE_PROJECT_NAME) 26 | Project(asmjit C CXX) 27 | Else() 28 | # Do not create a project if this CMakeLists.txt is included by a different 29 | # project. This allows easy static library build including debugger support. 30 | Set(ASMJIT_PROJECT_STR "Included") 31 | EndIf() 32 | 33 | If(ASMJIT_STATIC) 34 | Set(ASMJIT_PROJECT_STR "${ASMJIT_PROJECT_STR}|Static") 35 | Else() 36 | Set(ASMJIT_PROJECT_STR "${ASMJIT_PROJECT_STR}|Shared") 37 | EndIf() 38 | 39 | Message("") 40 | Message("== ====================================================") 41 | Message("== [AsmJit ${ASMJIT_PROJECT_STR}]") 42 | Message("== ====================================================") 43 | Message("") 44 | 45 | # ============================================================================= 46 | # [AsmJit - Directory] 47 | # ============================================================================= 48 | 49 | If(NOT ASMJIT_DIR) 50 | Set(ASMJIT_DIR ${CMAKE_CURRENT_LIST_DIR}) 51 | Message("-- Initializing ASMJIT_DIR=${ASMJIT_DIR}") 52 | Else() 53 | Message("-- Using Custom ASMJIT_DIR=${ASMJIT_DIR}") 54 | EndIf() 55 | 56 | Set(ASMJIT_SRC_DIR "${ASMJIT_DIR}/src") 57 | 58 | # ============================================================================= 59 | # [AsmJit - Dependencies] 60 | # ============================================================================= 61 | 62 | Set(ASMJIT_DEPS "") 63 | 64 | # pthread library is needed for non-windows OSes. 65 | If(NOT WIN32) 66 | List(APPEND ASMJIT_DEPS pthread) 67 | EndIf() 68 | 69 | # ============================================================================= 70 | # [AsmJit - Include] 71 | # ============================================================================= 72 | 73 | Include_Directories(${ASMJIT_SRC_DIR}) 74 | 75 | # ============================================================================= 76 | # [AsmJit - Macros] 77 | # ============================================================================= 78 | 79 | Macro(AsmJitAddSrc dst_var base_path) 80 | Set(dst_src "") 81 | Set(dst_hdr "") 82 | Set(dst_test "") 83 | 84 | Set(dst_path "${ASMJIT_SRC_DIR}/${base_path}") 85 | 86 | ForEach(file ${ARGN}) 87 | Set(file_p "${dst_path}/${file}") 88 | 89 | If(file MATCHES "\\.c|\\.cc|\\.cpp|\\.cxx|\\.m|\\.mm") 90 | Set(file_cflags "") 91 | 92 | # Not ready for now... 93 | If(file MATCHES "_test\\.") 94 | List(APPEND dst_test ${file_p}) 95 | Else() 96 | List(APPEND dst_src ${file_p}) 97 | EndIf() 98 | 99 | If(optimize) 100 | Set_Source_Files_Properties(${file_p} PROPERTIES COMPILE_FLAGS ${file_cflags}) 101 | EndIf() 102 | EndIf() 103 | 104 | If(file MATCHES "\\.h|\\.hh|\\.hpp|\\.hxx|\\.inc") 105 | List(APPEND dst_hdr ${file_p}) 106 | EndIf() 107 | EndForEach() 108 | 109 | List(APPEND "${dst_var}" ${dst_src} ${dst_hdr}) 110 | List(APPEND "${dst_var}_TEST" ${dst_test}) 111 | Source_Group(${base_path} FILES ${dst_src} ${dst_hdr} ${dst_test}) 112 | EndMacro() 113 | 114 | # ============================================================================= 115 | # [AsmJit - Sources] 116 | # ============================================================================= 117 | 118 | Set(ASMJIT_SRC "") 119 | Set(ASMJIT_SRC_TEST "") 120 | 121 | AsmJitAddSrc(ASMJIT_SRC asmjit 122 | asmjit.h 123 | config.h 124 | core.h 125 | x86.h 126 | ) 127 | 128 | AsmJitAddSrc(ASMJIT_SRC asmjit/core 129 | apibegin.h 130 | apiend.h 131 | build.h 132 | 133 | assembler.cpp 134 | assembler.h 135 | assert.cpp 136 | assert.h 137 | buffer.cpp 138 | buffer.h 139 | compiler.cpp 140 | compiler.h 141 | compilercontext.cpp 142 | compilercontext.h 143 | compilerfunc.cpp 144 | compilerfunc.h 145 | compileritem.cpp 146 | compileritem.h 147 | context.cpp 148 | context.h 149 | cpuinfo.cpp 150 | cpuinfo.h 151 | defs.cpp 152 | defs.h 153 | func.cpp 154 | func.h 155 | intutil.h 156 | lock.h 157 | logger.cpp 158 | logger.h 159 | memorymanager.cpp 160 | memorymanager.h 161 | memorymarker.cpp 162 | memorymarker.h 163 | operand.cpp 164 | operand.h 165 | podvector.h 166 | stringbuilder.cpp 167 | stringbuilder.h 168 | stringutil.cpp 169 | stringutil.h 170 | virtualmemory.cpp 171 | virtualmemory.h 172 | zonememory.cpp 173 | zonememory.h 174 | ) 175 | 176 | AsmJitAddSrc(ASMJIT_SRC asmjit/x86 177 | x86assembler.cpp 178 | x86assembler.h 179 | x86compiler.cpp 180 | x86compiler.h 181 | x86compilercontext.cpp 182 | x86compilercontext.h 183 | x86compilerfunc.cpp 184 | x86compilerfunc.h 185 | x86compileritem.cpp 186 | x86compileritem.h 187 | x86cpuinfo.cpp 188 | x86cpuinfo.h 189 | x86defs.cpp 190 | x86defs.h 191 | x86func.cpp 192 | x86func.h 193 | x86operand.cpp 194 | x86operand.h 195 | x86util.cpp 196 | x86util.h 197 | ) 198 | 199 | # Build-Type. 200 | If(${CMAKE_BUILD_TYPE}) 201 | If(${CMAKE_BUILD_TYPE} MATCHES "Debug") 202 | Add_Definitions(-DASMJIT_DEBUG) 203 | Else() 204 | Add_Definitions(-DASMJIT_NO_DEBUG) 205 | EndIf() 206 | EndIf() 207 | 208 | # ============================================================================= 209 | # [Setup - Headers] 210 | # ============================================================================= 211 | 212 | If(NOT ASMJIT_STATIC) 213 | ForEach(i ${ASMJIT_SRC}) 214 | Get_Filename_Component(path ${i} PATH) 215 | Get_Filename_Component(name ${i} NAME) 216 | String(REGEX REPLACE "^${ASMJIT_SRC_DIR}/" "" targetpath "${path}") 217 | If(${name} MATCHES ".h$") 218 | If(NOT "${name}" MATCHES "_p.h$") 219 | Install(FILES ${i} DESTINATION "include/${targetpath}") 220 | EndIf() 221 | EndIf() 222 | EndForEach() 223 | EndIf() 224 | 225 | # ============================================================================= 226 | # [Setup - Lib - asmjit] 227 | # ============================================================================= 228 | 229 | If(NOT ASMJIT_STATIC) 230 | Add_Library(asmjit SHARED ${ASMJIT_SRC}) 231 | Target_Link_Libraries(asmjit ${ASMJIT_DEPS}) 232 | Install(TARGETS asmjit DESTINATION lib) 233 | Else() 234 | Add_Library(asmjit STATIC ${ASMJIT_SRC}) 235 | Target_Link_Libraries(asmjit ${ASMJIT_DEPS}) 236 | EndIf() 237 | 238 | # ============================================================================= 239 | # [Setup - App - test] 240 | # ============================================================================= 241 | 242 | # Build AsmJit test executables? 243 | If(ASMJIT_BUILD_SAMPLES) 244 | Set(ASMJIT_SRC_SAMPLES 245 | testcpu 246 | testdummy 247 | testmem 248 | testopcode 249 | testsizeOf 250 | testx86 251 | ) 252 | 253 | ForEach(file ${ASMJIT_SRC_SAMPLES}) 254 | Add_Executable(${file} src/app/test/${file}.cpp) 255 | Target_Link_Libraries(${file} asmjit ${ASMJIT_DEPS}) 256 | EndForEach(file) 257 | EndIf() 258 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/intutil.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_INTUTIL_H 9 | #define _ASMJIT_CORE_INTUTIL_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/assert.h" 13 | 14 | // [Api-Begin] 15 | #include "../core/apibegin.h" 16 | 17 | namespace AsmJit { 18 | 19 | //! @addtogroup AsmJit_Core 20 | //! @{ 21 | 22 | // ============================================================================ 23 | // [AsmJit::I32FPUnion] 24 | // ============================================================================ 25 | 26 | //! @internal 27 | //! 28 | //! @brief used to cast from float to 32-bit integer and vica versa. 29 | union I32FPUnion 30 | { 31 | //! @brief 32-bit signed integer value. 32 | int32_t i; 33 | //! @brief 32-bit SP-FP value. 34 | float f; 35 | }; 36 | 37 | // ============================================================================ 38 | // [AsmJit::I64FPUnion] 39 | // ============================================================================ 40 | 41 | //! @internal 42 | //! 43 | //! @brief used to cast from double to 64-bit integer and vica versa. 44 | union I64FPUnion 45 | { 46 | //! @brief 64-bit signed integer value. 47 | int64_t i; 48 | //! @brief 64-bit DP-FP value. 49 | double f; 50 | }; 51 | 52 | // ============================================================================ 53 | // [AsmJit::IntUtil] 54 | // ============================================================================ 55 | 56 | namespace IntUtil 57 | { 58 | // -------------------------------------------------------------------------- 59 | // [Min/Max] 60 | // -------------------------------------------------------------------------- 61 | 62 | // NOTE: Because some environments declare min() and max() as macros, we 63 | // decided to use different name so we never collide. 64 | 65 | template 66 | static inline T _min(const T& a, const T& b) { return a < b ? a : b; } 67 | template 68 | static inline T _max(const T& a, const T& b) { return a > b ? a : b; } 69 | 70 | // -------------------------------------------------------------------------- 71 | // [Limits] 72 | // -------------------------------------------------------------------------- 73 | 74 | template 75 | static inline T maxValue() { return ~T(0); } 76 | 77 | // -------------------------------------------------------------------------- 78 | // [IsInt / IsUInt] 79 | // -------------------------------------------------------------------------- 80 | 81 | //! @brief Returns @c true if a given integer @a x is signed 8-bit integer 82 | static inline bool isInt8(intptr_t x) { return x >= -128 && x <= 127; } 83 | //! @brief Returns @c true if a given integer @a x is unsigned 8-bit integer 84 | static inline bool isUInt8(intptr_t x) { return x >= 0 && x <= 255; } 85 | 86 | //! @brief Returns @c true if a given integer @a x is signed 16-bit integer 87 | static inline bool isInt16(intptr_t x) { return x >= -32768 && x <= 32767; } 88 | //! @brief Returns @c true if a given integer @a x is unsigned 16-bit integer 89 | static inline bool isUInt16(intptr_t x) { return x >= 0 && x <= 65535; } 90 | 91 | //! @brief Returns @c true if a given integer @a x is signed 16-bit integer 92 | static inline bool isInt32(intptr_t x) 93 | { 94 | #if defined(ASMJIT_X86) 95 | return true; 96 | #else 97 | return x >= ASMJIT_INT64_C(-2147483648) && x <= ASMJIT_INT64_C(2147483647); 98 | #endif 99 | } 100 | //! @brief Returns @c true if a given integer @a x is unsigned 16-bit integer 101 | static inline bool isUInt32(intptr_t x) 102 | { 103 | #if defined(ASMJIT_X86) 104 | return x >= 0; 105 | #else 106 | return x >= 0 && x <= ASMJIT_INT64_C(4294967295); 107 | #endif 108 | } 109 | 110 | // -------------------------------------------------------------------------- 111 | // [Masking] 112 | // -------------------------------------------------------------------------- 113 | 114 | static inline uint32_t maskFromIndex(uint32_t x) 115 | { 116 | ASMJIT_ASSERT(x < 32); 117 | return (1U << x); 118 | } 119 | 120 | static inline uint32_t maskUpToIndex(uint32_t x) 121 | { 122 | if (x >= 32) 123 | return 0xFFFFFFFF; 124 | else 125 | return (1U << x) - 1; 126 | } 127 | 128 | // -------------------------------------------------------------------------- 129 | // [Bits] 130 | // -------------------------------------------------------------------------- 131 | 132 | // From http://graphics.stanford.edu/~seander/bithacks.html . 133 | static inline uint32_t bitCount(uint32_t x) 134 | { 135 | x = x - ((x >> 1) & 0x55555555U); 136 | x = (x & 0x33333333U) + ((x >> 2) & 0x33333333U); 137 | return (((x + (x >> 4)) & 0x0F0F0F0FU) * 0x01010101U) >> 24; 138 | } 139 | 140 | static inline uint32_t findFirstBit(uint32_t mask) 141 | { 142 | for (uint32_t i = 0; i < sizeof(uint32_t) * 8; i++, mask >>= 1) 143 | { 144 | if (mask & 0x1) 145 | return i; 146 | } 147 | 148 | // kInvalidValue. 149 | return 0xFFFFFFFF; 150 | } 151 | 152 | // -------------------------------------------------------------------------- 153 | // [Alignment] 154 | // -------------------------------------------------------------------------- 155 | 156 | template 157 | static inline bool isAligned(T base, T alignment) 158 | { 159 | return (base % alignment) == 0; 160 | } 161 | 162 | //! @brief Align @a base to @a alignment. 163 | template 164 | static inline T align(T base, T alignment) 165 | { 166 | return (base + (alignment - 1)) & ~(alignment - 1); 167 | } 168 | 169 | //! @brief Get delta required to align @a base to @a alignment. 170 | template 171 | static inline T delta(T base, T alignment) 172 | { 173 | return align(base, alignment) - base; 174 | } 175 | 176 | // -------------------------------------------------------------------------- 177 | // [Round] 178 | // -------------------------------------------------------------------------- 179 | 180 | template 181 | static inline T roundUp(T base, T alignment) 182 | { 183 | T over = base % alignment; 184 | return base + (over > 0 ? alignment - over : 0); 185 | } 186 | 187 | template 188 | static inline T roundUpToPowerOf2(T base) 189 | { 190 | // Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., 191 | // figure 3-3, page 48, where the function is called clp2. 192 | base -= 1; 193 | 194 | // I'm trying to make this portable and MSVC strikes me the warning C4293: 195 | // "Shift count negative or too big, undefined behavior" 196 | // Fixing... 197 | #if defined(_MSC_VER) 198 | # pragma warning(push) 199 | # pragma warning(disable: 4293) 200 | #endif // _MSC_VER 201 | 202 | base = base | (base >> 1); 203 | base = base | (base >> 2); 204 | base = base | (base >> 4); 205 | 206 | if (sizeof(T) >= 2) base = base | (base >> 8); 207 | if (sizeof(T) >= 4) base = base | (base >> 16); 208 | if (sizeof(T) >= 8) base = base | (base >> 32); 209 | 210 | #if defined(_MSC_VER) 211 | # pragma warning(pop) 212 | #endif // _MSC_VER 213 | 214 | return base + 1; 215 | } 216 | 217 | // -------------------------------------------------------------------------- 218 | // [Cast] 219 | // -------------------------------------------------------------------------- 220 | 221 | //! @brief Binary cast from 32-bit integer to SP-FP value (@c float). 222 | static inline float int32AsFloat(int32_t i) 223 | { 224 | I32FPUnion u; 225 | u.i = i; 226 | return u.f; 227 | } 228 | 229 | //! @brief Binary cast SP-FP value (@c float) to 32-bit integer. 230 | static inline int32_t floatAsInt32(float f) 231 | { 232 | I32FPUnion u; 233 | u.f = f; 234 | return u.i; 235 | } 236 | 237 | //! @brief Binary cast from 64-bit integer to DP-FP value (@c double). 238 | static inline double int64AsDouble(int64_t i) 239 | { 240 | I64FPUnion u; 241 | u.i = i; 242 | return u.f; 243 | } 244 | 245 | //! @brief Binary cast from DP-FP value (@c double) to 64-bit integer. 246 | static inline int64_t doubleAsInt64(double f) 247 | { 248 | I64FPUnion u; 249 | u.f = f; 250 | return u.i; 251 | } 252 | }; 253 | 254 | //! @} 255 | 256 | } // AsmJit namespace 257 | 258 | // [Api-End] 259 | #include "../core/apiend.h" 260 | 261 | // [Guard] 262 | #endif // _ASMJIT_CORE_INTUTIL_H 263 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/compileritem.cpp: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | #define ASMJIT_EXPORTS 8 | 9 | // [Dependencies - AsmJit] 10 | #include "../core/assembler.h" 11 | #include "../core/compiler.h" 12 | #include "../core/compilercontext.h" 13 | #include "../core/compilerfunc.h" 14 | #include "../core/compileritem.h" 15 | #include "../core/intutil.h" 16 | #include "../core/logger.h" 17 | 18 | // [Dependencies - C] 19 | #include 20 | 21 | // [Api-Begin] 22 | #include "../core/apibegin.h" 23 | 24 | namespace AsmJit { 25 | 26 | // ============================================================================ 27 | // [AsmJit::CompilerItem - Construction / Destruction] 28 | // ============================================================================ 29 | 30 | CompilerItem::CompilerItem(Compiler* compiler, uint32_t type) : 31 | _compiler(compiler), 32 | _prev(NULL), 33 | _next(NULL), 34 | _comment(NULL), 35 | _type(static_cast(type)), 36 | _isTranslated(false), 37 | _isUnreachable(false), 38 | _reserved(0), 39 | _offset(kInvalidValue) 40 | { 41 | } 42 | 43 | CompilerItem::~CompilerItem() 44 | { 45 | } 46 | 47 | // ============================================================================ 48 | // [AsmJit::CompilerItem - Interface] 49 | // ============================================================================ 50 | 51 | void CompilerItem::prepare(CompilerContext& cc) 52 | { 53 | _offset = cc._currentOffset; 54 | } 55 | 56 | CompilerItem* CompilerItem::translate(CompilerContext& cc) 57 | { 58 | return translated(); 59 | } 60 | 61 | void CompilerItem::emit(Assembler& a) {} 62 | void CompilerItem::post(Assembler& a) {} 63 | 64 | // ============================================================================ 65 | // [AsmJit::CompilerItem - Misc] 66 | // ============================================================================ 67 | 68 | int CompilerItem::getMaxSize() const 69 | { 70 | // Default maximum size is -1 which means that it's not known. 71 | return -1; 72 | } 73 | 74 | bool CompilerItem::_tryUnuseVar(CompilerVar* v) 75 | { 76 | return false; 77 | } 78 | 79 | // ============================================================================ 80 | // [AsmJit::CompilerItem - Comment] 81 | // ============================================================================ 82 | 83 | void CompilerItem::setComment(const char* str) 84 | { 85 | _comment = _compiler->getZoneMemory().sdup(str); 86 | } 87 | 88 | void CompilerItem::formatComment(const char* fmt, ...) 89 | { 90 | // The capacity should be large enough. 91 | char buf[128]; 92 | 93 | va_list ap; 94 | va_start(ap, fmt); 95 | vsnprintf(buf, ASMJIT_ARRAY_SIZE(buf), fmt, ap); 96 | va_end(ap); 97 | 98 | // I don't know if vsnprintf can produce non-null terminated string, in case 99 | // it can, we terminate it here. 100 | buf[ASMJIT_ARRAY_SIZE(buf) - 1] = '\0'; 101 | 102 | setComment(buf); 103 | } 104 | 105 | // ============================================================================ 106 | // [AsmJit::CompilerMark - Construction / Destruction] 107 | // ============================================================================ 108 | 109 | CompilerMark::CompilerMark(Compiler* compiler) : 110 | CompilerItem(compiler, kCompilerItemMark) 111 | { 112 | } 113 | 114 | CompilerMark::~CompilerMark() 115 | { 116 | } 117 | 118 | // ============================================================================ 119 | // [AsmJit::CompilerMark - Misc] 120 | // ============================================================================ 121 | 122 | int CompilerMark::getMaxSize() const 123 | { 124 | return 0; 125 | } 126 | 127 | // ============================================================================ 128 | // [AsmJit::CompilerComment - Construction / Destruction] 129 | // ============================================================================ 130 | 131 | CompilerComment::CompilerComment(Compiler* compiler, const char* str) : 132 | CompilerItem(compiler, kCompilerItemComment) 133 | { 134 | if (str != NULL) 135 | setComment(str); 136 | } 137 | 138 | CompilerComment::~CompilerComment() 139 | { 140 | } 141 | 142 | // ============================================================================ 143 | // [AsmJit::CompilerComment - Interface] 144 | // ============================================================================ 145 | 146 | void CompilerComment::emit(Assembler& a) 147 | { 148 | Logger* logger = a.getLogger(); 149 | if (logger == NULL || !logger->isUsed()) 150 | return; 151 | 152 | logger->logString(logger->getInstructionPrefix()); 153 | logger->logString(getComment()); 154 | } 155 | 156 | // ============================================================================ 157 | // [AsmJit::CompilerComment - Misc] 158 | // ============================================================================ 159 | 160 | int CompilerComment::getMaxSize() const 161 | { 162 | return 0; 163 | } 164 | 165 | // ============================================================================ 166 | // [AsmJit::CompilerEmbed - Construction / Destruction] 167 | // ============================================================================ 168 | 169 | CompilerEmbed::CompilerEmbed(Compiler* compiler, const void* data, size_t length) : 170 | CompilerItem(compiler, kCompilerItemEmbed) 171 | { 172 | _length = length; 173 | memcpy(_data, data, length); 174 | } 175 | 176 | CompilerEmbed::~CompilerEmbed() 177 | { 178 | } 179 | 180 | // ============================================================================ 181 | // [AsmJit::CompilerEmbed - Interface] 182 | // ============================================================================ 183 | 184 | void CompilerEmbed::emit(Assembler& a) 185 | { 186 | a.embed(_data, _length); 187 | } 188 | 189 | // ============================================================================ 190 | // [AsmJit::CompilerEmbed - Misc] 191 | // ============================================================================ 192 | 193 | int CompilerEmbed::getMaxSize() const 194 | { 195 | return (int)_length;; 196 | } 197 | 198 | // ============================================================================ 199 | // [AsmJit::CompilerAlign - Construction / Destruction] 200 | // ============================================================================ 201 | 202 | CompilerAlign::CompilerAlign(Compiler* compiler, uint32_t size) : 203 | CompilerItem(compiler, kCompilerItemAlign), _size(size) 204 | { 205 | } 206 | 207 | CompilerAlign::~CompilerAlign() 208 | { 209 | } 210 | 211 | // ============================================================================ 212 | // [AsmJit::CompilerAlign - Misc] 213 | // ============================================================================ 214 | 215 | int CompilerAlign::getMaxSize() const 216 | { 217 | if (_size == 0) 218 | return 0; 219 | else 220 | return static_cast(_size - 1); 221 | } 222 | 223 | // ============================================================================ 224 | // [AsmJit::CompilerHint - Construction / Destruction] 225 | // ============================================================================ 226 | 227 | CompilerHint::CompilerHint(Compiler* compiler, CompilerVar* var, uint32_t hintId, uint32_t hintValue) : 228 | CompilerItem(compiler, kCompilerItemHint), 229 | _var(var), 230 | _hintId(hintId), 231 | _hintValue(hintValue) 232 | { 233 | ASMJIT_ASSERT(var != NULL); 234 | } 235 | 236 | CompilerHint::~CompilerHint() 237 | { 238 | } 239 | 240 | // ============================================================================ 241 | // [AsmJit::CompilerTarget - Construction / Destruction] 242 | // ============================================================================ 243 | 244 | CompilerTarget::CompilerTarget(Compiler* compiler, const Label& label) : 245 | CompilerItem(compiler, kCompilerItemTarget), 246 | _label(label), 247 | _from(NULL), 248 | _state(NULL), 249 | _jumpsCount(0) 250 | { 251 | } 252 | 253 | CompilerTarget::~CompilerTarget() 254 | { 255 | } 256 | 257 | // ============================================================================ 258 | // [AsmJit::CompilerTarget - Misc] 259 | // ============================================================================ 260 | 261 | int CompilerTarget::getMaxSize() const 262 | { 263 | return 0; 264 | } 265 | 266 | // ============================================================================ 267 | // [AsmJit::CompilerInst - Construction / Destruction] 268 | // ============================================================================ 269 | 270 | CompilerInst::CompilerInst(Compiler* compiler, uint32_t code, Operand* opData, uint32_t opCount) : 271 | CompilerItem(compiler, kCompilerItemInst), 272 | _code(code), 273 | _emitOptions(static_cast(compiler->_emitOptions)), 274 | _instFlags(0), 275 | _operandsCount(static_cast(opCount)), 276 | _variablesCount(0), 277 | _operands(opData) 278 | { 279 | // Each created instruction takes emit options and clears it. 280 | compiler->_emitOptions = 0; 281 | } 282 | 283 | CompilerInst::~CompilerInst() 284 | { 285 | } 286 | 287 | // ============================================================================ 288 | // [AsmJit::CompilerInst - GetJumpTarget] 289 | // ============================================================================ 290 | 291 | CompilerTarget* CompilerInst::getJumpTarget() const 292 | { 293 | return NULL; 294 | } 295 | 296 | } // AsmJit namespace 297 | 298 | // [Api-Begin] 299 | #include "../core/apibegin.h" 300 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/logger.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_LOGGER_H 9 | #define _ASMJIT_CORE_LOGGER_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/build.h" 13 | #include "../core/defs.h" 14 | #include "../core/stringbuilder.h" 15 | 16 | // [Dependencies - C] 17 | #include 18 | 19 | // [Api-Begin] 20 | #include "../core/apibegin.h" 21 | 22 | namespace AsmJit { 23 | 24 | //! @addtogroup AsmJit_Logging 25 | //! @{ 26 | 27 | // ============================================================================ 28 | // [AsmJit::Logger] 29 | // ============================================================================ 30 | 31 | //! @brief Abstract logging class. 32 | //! 33 | //! This class can be inherited and reimplemented to fit into your logging 34 | //! subsystem. When reimplementing use @c AsmJit::Logger::log() method to 35 | //! log into your stream. 36 | //! 37 | //! This class also contain @c _enabled member that can be used to enable 38 | //! or disable logging. 39 | struct Logger 40 | { 41 | ASMJIT_NO_COPY(Logger) 42 | 43 | // -------------------------------------------------------------------------- 44 | // [Construction / Destruction] 45 | // -------------------------------------------------------------------------- 46 | 47 | //! @brief Create logger. 48 | ASMJIT_API Logger(); 49 | //! @brief Destroy logger. 50 | ASMJIT_API virtual ~Logger(); 51 | 52 | // -------------------------------------------------------------------------- 53 | // [Logging] 54 | // -------------------------------------------------------------------------- 55 | 56 | //! @brief Abstract method to log output. 57 | //! 58 | //! Default implementation that is in @c AsmJit::Logger is to do nothing. 59 | //! It's virtual to fit to your logging system. 60 | virtual void logString(const char* buf, size_t len = kInvalidSize) = 0; 61 | 62 | //! @brief Log formatter message (like sprintf) sending output to @c logString() method. 63 | ASMJIT_API virtual void logFormat(const char* fmt, ...); 64 | 65 | // -------------------------------------------------------------------------- 66 | // [Flags] 67 | // -------------------------------------------------------------------------- 68 | 69 | //! @brief Get logger flags (used internally by Assembler/Compiler). 70 | inline uint32_t getFlags() const { return _flags; } 71 | 72 | // -------------------------------------------------------------------------- 73 | // [Enabled] 74 | // -------------------------------------------------------------------------- 75 | 76 | //! @brief Return @c true if logging is enabled. 77 | inline bool isEnabled() const { return (_flags & kLoggerIsEnabled) != 0; } 78 | 79 | //! @brief Set logging to enabled or disabled. 80 | ASMJIT_API virtual void setEnabled(bool enabled); 81 | 82 | // -------------------------------------------------------------------------- 83 | // [Used] 84 | // -------------------------------------------------------------------------- 85 | 86 | //! @brief Get whether the logger should be used. 87 | inline bool isUsed() const { return (_flags & kLoggerIsUsed) != 0; } 88 | 89 | // -------------------------------------------------------------------------- 90 | // [LogBinary] 91 | // -------------------------------------------------------------------------- 92 | 93 | //! @brief Get whether logging of binary output is enabled. 94 | inline bool getLogBinary() const { return (_flags & kLoggerOutputBinary) != 0; } 95 | //! @brief Enable or disable binary output logging. 96 | ASMJIT_API void setLogBinary(bool value); 97 | 98 | // -------------------------------------------------------------------------- 99 | // [HexImmediate] 100 | // -------------------------------------------------------------------------- 101 | 102 | inline bool getHexImmediate() const { return (_flags & kLoggerOutputHexImmediate) != 0; } 103 | ASMJIT_API void setHexImmediate(bool value); 104 | 105 | // -------------------------------------------------------------------------- 106 | // [HexDisplacement] 107 | // -------------------------------------------------------------------------- 108 | 109 | inline bool getHexDisplacement() const { return (_flags & kLoggerOutputHexDisplacement) != 0; } 110 | ASMJIT_API void setHexDisplacement(bool value); 111 | 112 | // -------------------------------------------------------------------------- 113 | // [InstructionPrefix] 114 | // -------------------------------------------------------------------------- 115 | 116 | //! @brief Get instruction prefix. 117 | inline const char* getInstructionPrefix() const { return _instructionPrefix; } 118 | //! @brief Set instruction prefix. 119 | ASMJIT_API void setInstructionPrefix(const char* prefix); 120 | //! @brief Reset instruction prefix. 121 | inline void resetInstructionPrefix() { setInstructionPrefix(NULL); } 122 | 123 | // -------------------------------------------------------------------------- 124 | // [Members] 125 | // -------------------------------------------------------------------------- 126 | 127 | //! @brief Flags, see @ref kLoggerFlag. 128 | uint32_t _flags; 129 | 130 | //! @brief Instrictions and macro-instructions prefix. 131 | char _instructionPrefix[12]; 132 | }; 133 | 134 | // ============================================================================ 135 | // [AsmJit::FileLogger] 136 | // ============================================================================ 137 | 138 | //! @brief Logger that can log to standard C @c FILE* stream. 139 | struct FileLogger : public Logger 140 | { 141 | ASMJIT_NO_COPY(FileLogger) 142 | 143 | // -------------------------------------------------------------------------- 144 | // [Construction / Destruction] 145 | // -------------------------------------------------------------------------- 146 | 147 | //! @brief Create a new @c FileLogger. 148 | //! @param stream FILE stream where logging will be sent (can be @c NULL 149 | //! to disable logging). 150 | ASMJIT_API FileLogger(FILE* stream = NULL); 151 | 152 | //! @brief Destroy the @ref FileLogger. 153 | ASMJIT_API virtual ~FileLogger(); 154 | 155 | // -------------------------------------------------------------------------- 156 | // [Accessors] 157 | // -------------------------------------------------------------------------- 158 | 159 | //! @brief Get @c FILE* stream. 160 | //! 161 | //! @note Return value can be @c NULL. 162 | inline FILE* getStream() const { return _stream; } 163 | 164 | //! @brief Set @c FILE* stream. 165 | //! 166 | //! @param stream @c FILE stream where to log output (can be @c NULL to 167 | //! disable logging). 168 | ASMJIT_API void setStream(FILE* stream); 169 | 170 | // -------------------------------------------------------------------------- 171 | // [Logging] 172 | // -------------------------------------------------------------------------- 173 | 174 | ASMJIT_API virtual void logString(const char* buf, size_t len = kInvalidSize); 175 | 176 | // -------------------------------------------------------------------------- 177 | // [Enabled] 178 | // -------------------------------------------------------------------------- 179 | 180 | ASMJIT_API virtual void setEnabled(bool enabled); 181 | 182 | // -------------------------------------------------------------------------- 183 | // [Members] 184 | // -------------------------------------------------------------------------- 185 | 186 | //! @brief C file stream. 187 | FILE* _stream; 188 | }; 189 | 190 | // ============================================================================ 191 | // [AsmJit::StringLogger] 192 | // ============================================================================ 193 | 194 | //! @brief String logger. 195 | struct StringLogger : public Logger 196 | { 197 | ASMJIT_NO_COPY(StringLogger) 198 | 199 | // -------------------------------------------------------------------------- 200 | // [Construction / Destruction] 201 | // -------------------------------------------------------------------------- 202 | 203 | //! @brief Create new @ref StringLogger. 204 | ASMJIT_API StringLogger(); 205 | 206 | //! @brief Destroy the @ref StringLogger. 207 | ASMJIT_API virtual ~StringLogger(); 208 | 209 | // -------------------------------------------------------------------------- 210 | // [Accessors] 211 | // -------------------------------------------------------------------------- 212 | 213 | //! @brief Get char* pointer which represents the serialized 214 | //! string. 215 | //! 216 | //! The pointer is owned by @ref StringLogger, it can't be modified or freed. 217 | inline const char* getString() const { return _stringBuilder.getData(); } 218 | 219 | //! @brief Clear the serialized string. 220 | inline void clearString() { _stringBuilder.clear(); } 221 | 222 | // -------------------------------------------------------------------------- 223 | // [Logging] 224 | // -------------------------------------------------------------------------- 225 | 226 | ASMJIT_API virtual void logString(const char* buf, size_t len = kInvalidSize); 227 | 228 | // -------------------------------------------------------------------------- 229 | // [Members] 230 | // -------------------------------------------------------------------------- 231 | 232 | //! @brief Output. 233 | StringBuilder _stringBuilder; 234 | }; 235 | 236 | //! @} 237 | 238 | } // AsmJit namespace 239 | 240 | // [Api-End] 241 | #include "../core/apiend.h" 242 | 243 | // [Guard] 244 | #endif // _ASMJIT_CORE_LOGGER_H 245 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/core/build.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_CORE_BUILD_H 9 | #define _ASMJIT_CORE_BUILD_H 10 | 11 | // [Include] 12 | #include "../config.h" 13 | 14 | #if defined(ASMJIT_EXPORTS) 15 | # if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 16 | # define _CRT_SECURE_NO_WARNINGS 17 | # endif // _MSC_VER 18 | #endif // ASMJIT_EXPORTS 19 | 20 | // Here should be optional include files that's needed fo successfuly 21 | // use macros defined here. Remember, AsmJit uses only AsmJit namespace 22 | // and all macros are used within it. 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | // ============================================================================ 30 | // [AsmJit - OS] 31 | // ============================================================================ 32 | 33 | #if defined(WINDOWS) || defined(_WINDOWS) || defined(__WINDOWS__) || defined(_WIN32) || defined(_WIN64) 34 | # define ASMJIT_WINDOWS 35 | #elif defined(__linux__) || defined(__unix__) || \ 36 | defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ 37 | defined(__DragonFly__) || defined(__BSD__) || defined(__FREEBSD__) || \ 38 | defined(__APPLE__) 39 | # define ASMJIT_POSIX 40 | #else 41 | # warning "AsmJit - Can't match operating system, using ASMJIT_POSIX" 42 | # define ASMJIT_POSIX 43 | #endif 44 | 45 | // ============================================================================ 46 | // [AsmJit - Architecture] 47 | // ============================================================================ 48 | 49 | // define it only if it's not defined. In some systems we can 50 | // use -D command in compiler to bypass this autodetection. 51 | #if !defined(ASMJIT_X86) && !defined(ASMJIT_X64) 52 | # if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || \ 53 | defined(_M_X64) || defined(_WIN64) 54 | # define ASMJIT_X64 // x86-64 55 | # else 56 | // _M_IX86, __INTEL__, __i386__ 57 | # define ASMJIT_X86 58 | # endif 59 | #endif 60 | 61 | // ============================================================================ 62 | // [AsmJit - API] 63 | // ============================================================================ 64 | 65 | // Make AsmJit as shared library by default. 66 | #if !defined(ASMJIT_API) 67 | # if defined(ASMJIT_WINDOWS) 68 | # if defined(__GNUC__) 69 | # if defined(ASMJIT_EXPORTS) 70 | # define ASMJIT_API __attribute__((dllexport)) 71 | # else 72 | # define ASMJIT_API __attribute__((dllimport)) 73 | # endif // ASMJIT_EXPORTS 74 | # else 75 | # if defined(ASMJIT_EXPORTS) 76 | # define ASMJIT_API __declspec(dllexport) 77 | # else 78 | # define ASMJIT_API __declspec(dllimport) 79 | # endif // ASMJIT_EXPORTS 80 | # endif // __GNUC__ 81 | # else 82 | # if defined(__GNUC__) 83 | # if __GNUC__ >= 4 84 | # define ASMJIT_API __attribute__((visibility("default"))) 85 | # define ASMJIT_VAR extern ASMJIT_API 86 | # endif // __GNUC__ >= 4 87 | # endif // __GNUC__ 88 | # endif 89 | #endif // ASMJIT_API 90 | 91 | #if !defined(ASMJIT_VAR) 92 | # if defined(ASMJIT_API) 93 | # define ASMJIT_VAR extern ASMJIT_API 94 | # else 95 | # define ASMJIT_VAR 96 | # endif // ASMJIT_API 97 | #endif // !ASMJIT_VAR 98 | 99 | // [AsmJit - Memory Management] 100 | #if !defined(ASMJIT_MALLOC) 101 | # define ASMJIT_MALLOC ::malloc 102 | #endif // ASMJIT_MALLOC 103 | 104 | #if !defined(ASMJIT_REALLOC) 105 | # define ASMJIT_REALLOC ::realloc 106 | #endif // ASMJIT_REALLOC 107 | 108 | #if !defined(ASMJIT_FREE) 109 | # define ASMJIT_FREE ::free 110 | #endif // ASMJIT_FREE 111 | 112 | // ============================================================================ 113 | // [AsmJit - Calling Conventions] 114 | // ============================================================================ 115 | 116 | #if defined(ASMJIT_X86) 117 | # if defined(__GNUC__) 118 | # define ASMJIT_REGPARM_1 __attribute__((regparm(1))) 119 | # define ASMJIT_REGPARM_2 __attribute__((regparm(2))) 120 | # define ASMJIT_REGPARM_3 __attribute__((regparm(3))) 121 | # define ASMJIT_FASTCALL __attribute__((fastcall)) 122 | # define ASMJIT_STDCALL __attribute__((stdcall)) 123 | # define ASMJIT_CDECL __attribute__((cdecl)) 124 | # else 125 | # define ASMJIT_FASTCALL __fastcall 126 | # define ASMJIT_STDCALL __stdcall 127 | # define ASMJIT_CDECL __cdecl 128 | # endif 129 | #else 130 | # define ASMJIT_FASTCALL 131 | # define ASMJIT_STDCALL 132 | # define ASMJIT_CDECL 133 | #endif // ASMJIT_X86 134 | 135 | #if !defined(ASMJIT_UNUSED) 136 | # define ASMJIT_UNUSED(var) ((void)var) 137 | #endif // ASMJIT_UNUSED 138 | 139 | #if !defined(ASMJIT_NOP) 140 | # define ASMJIT_NOP() ((void)0) 141 | #endif // ASMJIT_NOP 142 | 143 | // [AsmJit - C++ Compiler Support] 144 | #define ASMJIT_TYPE_TO_TYPE(_Type_) _Type_ 145 | #define ASMJIT_HAS_STANDARD_DEFINE_OPTIONS 146 | #define ASMJIT_HAS_PARTIAL_TEMPLATE_SPECIALIZATION 147 | 148 | // Support for VC6 149 | #if defined(_MSC_VER) && (_MSC_VER < 1400) 150 | 151 | namespace AsmJit { 152 | template 153 | struct _Type2Type { typedef T Type; }; 154 | } 155 | 156 | #undef ASMJIT_TYPE_TO_TYPE 157 | #define ASMJIT_TYPE_TO_TYPE(_Type_) ::AsmJit::_Type2Type<_Type_>::Type 158 | 159 | #undef ASMJIT_HAS_STANDARD_DEFINE_OPTIONS 160 | #undef ASMJIT_HAS_PARTIAL_TEMPLATE_SPECIALIZATION 161 | 162 | #endif 163 | 164 | // ============================================================================ 165 | // [AsmJit - Types] 166 | // ============================================================================ 167 | 168 | #if defined(__MINGW32__) || defined(__MINGW64__) 169 | # include 170 | #endif // __MINGW32__ || __MINGW64__ 171 | 172 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 173 | # if (_MSC_VER < 1300) 174 | typedef signed char int8_t; 175 | typedef signed short int16_t; 176 | typedef signed int int32_t; 177 | typedef signed __int64 int64_t; 178 | typedef unsigned char uint8_t; 179 | typedef unsigned short uint16_t; 180 | typedef unsigned int uint32_t; 181 | typedef unsigned __int64 uint64_t; 182 | # else 183 | typedef signed __int8 int8_t; 184 | typedef signed __int16 int16_t; 185 | typedef signed __int32 int32_t; 186 | typedef signed __int64 int64_t; 187 | typedef unsigned __int8 uint8_t; 188 | typedef unsigned __int16 uint16_t; 189 | typedef unsigned __int32 uint32_t; 190 | typedef unsigned __int64 uint64_t; 191 | # endif // _MSC_VER 192 | #else 193 | # include 194 | # include 195 | #endif 196 | 197 | typedef unsigned char uchar; 198 | typedef unsigned short ushort; 199 | typedef unsigned int uint; 200 | typedef unsigned long ulong; 201 | 202 | #if defined(ASMJIT_X86) 203 | typedef int32_t sysint_t; 204 | typedef uint32_t sysuint_t; 205 | #else 206 | typedef int64_t sysint_t; 207 | typedef uint64_t sysuint_t; 208 | #endif 209 | 210 | #if defined(_MSC_VER) 211 | # define ASMJIT_INT64_C(num) num##i64 212 | # define ASMJIT_UINT64_C(num) num##ui64 213 | #else 214 | # define ASMJIT_INT64_C(num) num##LL 215 | # define ASMJIT_UINT64_C(num) num##ULL 216 | #endif 217 | 218 | // ============================================================================ 219 | // [AsmJit - C++ Macros] 220 | // ============================================================================ 221 | 222 | #define ASMJIT_ARRAY_SIZE(A) (sizeof(A) / sizeof(*A)) 223 | 224 | #define ASMJIT_NO_COPY(__type__) \ 225 | private: \ 226 | inline __type__(const __type__& other); \ 227 | inline __type__& operator=(const __type__& other); \ 228 | public: 229 | 230 | // ============================================================================ 231 | // [AsmJit - Debug] 232 | // ============================================================================ 233 | 234 | // If ASMJIT_DEBUG and ASMJIT_NO_DEBUG is not defined then ASMJIT_DEBUG will be 235 | // detected using the compiler specific macros. This enables to set the build 236 | // type using IDE. 237 | #if !defined(ASMJIT_DEBUG) && !defined(ASMJIT_NO_DEBUG) 238 | 239 | #if defined(_DEBUG) 240 | #define ASMJIT_DEBUG 241 | #endif // _DEBUG 242 | 243 | #endif // !ASMJIT_DEBUG && !ASMJIT_NO_DEBUG 244 | 245 | // ============================================================================ 246 | // [AsmJit - Initialize/DontInitialize] 247 | // ============================================================================ 248 | 249 | // TODO: This should be moved to AsmJit namespace! 250 | 251 | // Skip documenting this. 252 | #if !defined(ASMJIT_NODOC) 253 | struct _Initialize {}; 254 | struct _DontInitialize {}; 255 | #endif // !ASMJIT_NODOC 256 | 257 | // ============================================================================ 258 | // [AsmJit - Void] 259 | // ============================================================================ 260 | 261 | // TODO: This should be moved to AsmJit namespace! 262 | 263 | //! @brief Void type which can be used in @ref FunctionDeclaration templates. 264 | struct Void {}; 265 | 266 | // ============================================================================ 267 | // [asmjit_cast<>] 268 | // ============================================================================ 269 | 270 | //! @brief Cast used to cast pointer to function. It's like reinterpret_cast<>, 271 | //! but uses internally C style cast to work with MinGW. 272 | //! 273 | //! If you are using single compiler and @c reinterpret_cast<> works for you, 274 | //! there is no reason to use @c asmjit_cast<>. If you are writing 275 | //! cross-platform software with various compiler support, consider using 276 | //! @c asmjit_cast<> instead of @c reinterpret_cast<>. 277 | template 278 | static inline T asmjit_cast(Z* p) { return (T)p; } 279 | 280 | // ============================================================================ 281 | // [AsmJit - OS Support] 282 | // ============================================================================ 283 | 284 | #if defined(ASMJIT_WINDOWS) 285 | #include 286 | #endif // ASMJIT_WINDOWS 287 | 288 | // [Guard] 289 | #endif // _ASMJIT_CORE_BUILD_H 290 | -------------------------------------------------------------------------------- /libs/asmjit/src/asmjit/x86/x86func.h: -------------------------------------------------------------------------------- 1 | // [AsmJit] 2 | // Complete JIT Assembler for C++ Language. 3 | // 4 | // [License] 5 | // Zlib - See COPYING file in this package. 6 | 7 | // [Guard] 8 | #ifndef _ASMJIT_X86_X86FUNC_H 9 | #define _ASMJIT_X86_X86FUNC_H 10 | 11 | // [Dependencies - AsmJit] 12 | #include "../core/defs.h" 13 | #include "../core/func.h" 14 | 15 | #include "../x86/x86defs.h" 16 | 17 | // [Api-Begin] 18 | #include "../core/apibegin.h" 19 | 20 | namespace AsmJit { 21 | 22 | //! @addtogroup AsmJit_X86 23 | //! @{ 24 | 25 | // ============================================================================ 26 | // [AsmJit::TypeId] 27 | // ============================================================================ 28 | 29 | ASMJIT_DECLARE_TYPE_CORE(kX86VarTypeIntPtr); 30 | ASMJIT_DECLARE_TYPE_ID(void, kVarTypeInvalid); 31 | ASMJIT_DECLARE_TYPE_ID(Void, kVarTypeInvalid); 32 | 33 | ASMJIT_DECLARE_TYPE_ID(int8_t, kX86VarTypeGpd); 34 | ASMJIT_DECLARE_TYPE_ID(uint8_t, kX86VarTypeGpd); 35 | 36 | ASMJIT_DECLARE_TYPE_ID(int16_t, kX86VarTypeGpd); 37 | ASMJIT_DECLARE_TYPE_ID(uint16_t, kX86VarTypeGpd); 38 | 39 | ASMJIT_DECLARE_TYPE_ID(int32_t, kX86VarTypeGpd); 40 | ASMJIT_DECLARE_TYPE_ID(uint32_t, kX86VarTypeGpd); 41 | 42 | #if defined(ASMJIT_X64) 43 | ASMJIT_DECLARE_TYPE_ID(int64_t, kX86VarTypeGpq); 44 | ASMJIT_DECLARE_TYPE_ID(uint64_t, kX86VarTypeGpq); 45 | #endif // ASMJIT_X64 46 | 47 | ASMJIT_DECLARE_TYPE_ID(float, kX86VarTypeFloat); 48 | ASMJIT_DECLARE_TYPE_ID(double, kX86VarTypeDouble); 49 | 50 | // ============================================================================ 51 | // [AsmJit::X86FuncDecl] 52 | // ============================================================================ 53 | 54 | //! @brief X86 function, including calling convention, arguments and their 55 | //! register indices or stack positions. 56 | struct X86FuncDecl : public FuncDecl 57 | { 58 | // -------------------------------------------------------------------------- 59 | // [Construction / Destruction] 60 | // -------------------------------------------------------------------------- 61 | 62 | //! @brief Create a new @ref FunctionX86 instance. 63 | inline X86FuncDecl() 64 | { reset(); } 65 | 66 | // -------------------------------------------------------------------------- 67 | // [Accessors - Core] 68 | // -------------------------------------------------------------------------- 69 | 70 | //! @brief Get stack size needed for function arguments passed on the stack. 71 | inline uint32_t getArgumentsStackSize() const 72 | { return _argumentsStackSize; } 73 | 74 | //! @brief Get bit-mask of GP registers used to pass function arguments. 75 | inline uint32_t getGpArgumentsMask() const 76 | { return _gpArgumentsMask; } 77 | 78 | //! @brief Get bit-mask of MM registers used to pass function arguments. 79 | inline uint32_t getMmArgumentsMask() const 80 | { return _mmArgumentsMask; } 81 | 82 | //! @brief Get bit-mask of XMM registers used to pass function arguments. 83 | inline uint32_t getXmmArgumentsMask() const 84 | { return _xmmArgumentsMask; } 85 | 86 | // -------------------------------------------------------------------------- 87 | // [Accessors - Convention] 88 | // -------------------------------------------------------------------------- 89 | 90 | //! @brief Get function calling convention, see @c kX86FuncConv. 91 | inline uint32_t getConvention() const 92 | { return _convention; } 93 | 94 | //! @brief Get whether the callee pops the stack. 95 | inline uint32_t getCalleePopsStack() const 96 | { return _calleePopsStack; } 97 | 98 | //! @brief Get direction of arguments passed on the stack. 99 | //! 100 | //! Direction should be always @c kFuncArgsRTL. 101 | //! 102 | //! @note This is related to used calling convention, it's not affected by 103 | //! number of function arguments or their types. 104 | inline uint32_t getArgumentsDirection() const 105 | { return _argumentsDirection; } 106 | 107 | //! @brief Get registers used to pass first integer parameters by current 108 | //! calling convention. 109 | //! 110 | //! @note This is related to used calling convention, it's not affected by 111 | //! number of function arguments or their types. 112 | inline const uint8_t* getGpList() const 113 | { return _gpList; } 114 | 115 | //! @brief Get registers used to pass first SP-FP or DP-FPparameters by 116 | //! current calling convention. 117 | //! 118 | //! @note This is related to used calling convention, it's not affected by 119 | //! number of function arguments or their types. 120 | inline const uint8_t* getXmmList() const 121 | { return _xmmList; } 122 | 123 | //! @brief Get bit-mask of GP registers which might be used for arguments. 124 | inline uint32_t getGpListMask() const 125 | { return _gpListMask; } 126 | 127 | //! @brief Get bit-mask of MM registers which might be used for arguments. 128 | inline uint32_t getMmListMask() const 129 | { return _mmListMask; } 130 | 131 | //! @brief Get bit-mask of XMM registers which might be used for arguments. 132 | inline uint32_t getXmmListMask() const 133 | { return _xmmListMask; } 134 | 135 | //! @brief Get bit-mask of general purpose registers that's preserved 136 | //! (non-volatile). 137 | //! 138 | //! @note This is related to used calling convention, it's not affected by 139 | //! number of function arguments or their types. 140 | inline uint32_t getGpPreservedMask() const 141 | { return _gpPreservedMask; } 142 | 143 | //! @brief Get bit-mask of MM registers that's preserved (non-volatile). 144 | //! 145 | //! @note No standardized calling function is not preserving MM registers. 146 | //! This member is here for extension writers who need for some reason custom 147 | //! calling convention that can be called through code generated by AsmJit 148 | //! (or other runtime code generator). 149 | inline uint32_t getMmPreservedMask() const 150 | { return _mmPreservedMask; } 151 | 152 | //! @brief Get bit-mask of XMM registers that's preserved (non-volatile). 153 | //! 154 | //! @note This is related to used calling convention, it's not affected by 155 | //! number of function arguments or their types. 156 | inline uint32_t getXmmPreservedMask() const 157 | { return _xmmPreservedMask; } 158 | 159 | // -------------------------------------------------------------------------- 160 | // [Methods] 161 | // -------------------------------------------------------------------------- 162 | 163 | //! @brief Find argument ID by the register code. 164 | ASMJIT_API uint32_t findArgumentByRegCode(uint32_t regCode) const; 165 | 166 | // -------------------------------------------------------------------------- 167 | // [SetPrototype] 168 | // -------------------------------------------------------------------------- 169 | 170 | //! @brief Set function prototype. 171 | //! 172 | //! This will set function calling convention and setup arguments variables. 173 | //! 174 | //! @note This function will allocate variables, it can be called only once. 175 | ASMJIT_API void setPrototype(uint32_t convention, uint32_t returnType, const uint32_t* arguments, uint32_t argumentsCount); 176 | 177 | // -------------------------------------------------------------------------- 178 | // [Reset] 179 | // -------------------------------------------------------------------------- 180 | 181 | ASMJIT_API void reset(); 182 | 183 | // -------------------------------------------------------------------------- 184 | // [Members - Core] 185 | // -------------------------------------------------------------------------- 186 | 187 | //! @brief Count of bytes consumed by arguments on the stack. 188 | uint16_t _argumentsStackSize; 189 | //! @brief Bitmask for GP registers used as passed function arguments. 190 | uint16_t _gpArgumentsMask; 191 | //! @brief Bitmask for MM registers used as passed function arguments. 192 | uint16_t _mmArgumentsMask; 193 | //! @brief Bitmask for XMM registers used as passed function arguments. 194 | uint16_t _xmmArgumentsMask; 195 | 196 | // -------------------------------------------------------------------------- 197 | // [Membes - Convention] 198 | // 199 | // This section doesn't depend on function arguments or return type. It 200 | // depends only on function calling convention and it's filled according to 201 | // that value. 202 | // -------------------------------------------------------------------------- 203 | 204 | //! @brief Calling convention. 205 | uint8_t _convention; 206 | //! @brief Whether a callee pops stack. 207 | uint8_t _calleePopsStack; 208 | //! @brief Direction for arguments passed on the stack, see @c kFuncArgsDirection. 209 | uint8_t _argumentsDirection; 210 | //! @brief Reserved for future use #1 (alignment). 211 | uint8_t _reserved1; 212 | 213 | //! @brief List of register IDs used for GP arguments (order is important). 214 | //! 215 | //! @note All registers in _gpList are also specified in @ref _gpListMask. 216 | //! Unused fields are filled by @ref kRegIndexInvalid. 217 | uint8_t _gpList[16]; 218 | //! @brief List of register IDs used for XMM arguments (order is important). 219 | //! 220 | //! @note All registers in _gpList are also specified in @ref _xmmListMask. 221 | //! Unused fields are filled by @ref kRegIndexInvalid. 222 | uint8_t _xmmList[16]; 223 | 224 | //! @brief Bitmask for GP registers which might be used by arguments. 225 | //! 226 | //! @note All registers in _gpListMask are also specified in @ref _gpList. 227 | uint16_t _gpListMask; 228 | //! @brief Bitmask for MM registers which might be used by arguments. 229 | uint16_t _mmListMask; 230 | //! @brief Bitmask for XMM registers which might be used by arguments. 231 | //! 232 | //! @note All registers in _xmmListMask are also specified in @ref _xmmList. 233 | uint16_t _xmmListMask; 234 | 235 | //! @brief Bitmask for GP registers preserved across the function call. 236 | //! 237 | //! @note Preserved register mask is complement to @ref _gpListMask. 238 | uint16_t _gpPreservedMask; 239 | //! @brief Bitmask for MM registers preserved across the function call. 240 | //! 241 | //! @note Preserved register mask is complement to @ref _mmListMask. 242 | uint16_t _mmPreservedMask; 243 | //! @brief Bitmask for XMM registers preserved across the function call. 244 | //! 245 | //! @note Preserved register mask is complement to @ref _xmmListMask. 246 | uint16_t _xmmPreservedMask; 247 | }; 248 | 249 | //! @} 250 | 251 | } // AsmJit namespace 252 | 253 | // [Api-End] 254 | #include "../core/apiend.h" 255 | 256 | // [Guard] 257 | #endif // _ASMJIT_X86_X86FUNC_H 258 | --------------------------------------------------------------------------------