Commit 97ce448c authored by peastman's avatar peastman
Browse files

Merge pull request #806 from peastman/jit32

Updated to latest asmjit, which supports 32 bit mode
parents fabb38d1 01da1b51
...@@ -274,14 +274,12 @@ ELSE (ANDROID OR PNACL) ...@@ -274,14 +274,12 @@ ELSE (ANDROID OR PNACL)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/libraries/sfmt/src/SFMT.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_SSE2=1") SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/libraries/sfmt/src/SFMT.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_SSE2=1")
ENDIF(ANDROID OR PNACL) ENDIF(ANDROID OR PNACL)
IF (NOT (ANDROID OR PNACL)) IF (NOT (ANDROID OR PNACL))
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
FILE(GLOB src_files ${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit/*/*.cpp) FILE(GLOB src_files ${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit/*/*.cpp)
FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit/*.h) FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit/*.h)
SET(SOURCE_FILES ${SOURCE_FILES} ${src_files}) SET(SOURCE_FILES ${SOURCE_FILES} ${src_files})
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files}) SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit") INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/libraries/asmjit")
SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DLEPTON_USE_JIT") SET(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DLEPTON_USE_JIT")
ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF (NOT (ANDROID OR PNACL)) ENDIF (NOT (ANDROID OR PNACL))
# If API wrappers are being generated, and add them to the build. # If API wrappers are being generated, and add them to the build.
......
...@@ -4,12 +4,38 @@ ...@@ -4,12 +4,38 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
// [Dependencies - AsmJit]
#if !defined(_ASMJIT_BUILD_H) #if !defined(_ASMJIT_BUILD_H)
#include "build.h" #include "build.h"
#endif // !_ASMJIT_BUILD_H #endif // !_ASMJIT_BUILD_H
// [Guard]
#if !defined(ASMJIT_API_SCOPE)
# define ASMJIT_API_SCOPE
#else
# error "AsmJit - Api-Scope is already active, previous scope not closed by apiend.h?"
#endif // ASMJIT_API_SCOPE
// ============================================================================ // ============================================================================
// [MSVC] // [Override]
// ============================================================================
#if !defined(ASMJIT_CC_HAS_OVERRIDE) && !defined(override)
# define override
# define ASMJIT_UNDEF_OVERRIDE
#endif // !ASMJIT_CC_HAS_OVERRIDE && !override
// ============================================================================
// [NoExcept]
// ============================================================================
#if !defined(ASMJIT_CC_HAS_NOEXCEPT) && !defined(noexcept)
# define noexcept ASMJIT_NOEXCEPT
# define ASMJIT_UNDEF_NOEXCEPT
#endif // !ASMJIT_CC_HAS_NOEXCEPT && !noexcept
// ============================================================================
// [MSC]
// ============================================================================ // ============================================================================
#if defined(_MSC_VER) #if defined(_MSC_VER)
...@@ -29,21 +55,30 @@ ...@@ -29,21 +55,30 @@
// Rename symbols. // Rename symbols.
# if !defined(vsnprintf) # if !defined(vsnprintf)
# define ASMJIT_DEFINED_VSNPRINTF # define ASMJIT_UNDEF_VSNPRINTF
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
# endif // !vsnprintf # endif // !vsnprintf
# if !defined(snprintf) # if !defined(snprintf)
# define ASMJIT_DEFINED_SNPRINTF # define ASMJIT_UNDEF_SNPRINTF
# define snprintf _snprintf # define snprintf _snprintf
# endif // !snprintf # endif // !snprintf
#endif // _MSC_VER #endif // _MSC_VER
// ============================================================================ // ============================================================================
// [GNUC] // [CLang]
// ============================================================================
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunnamed-type-template-args"
#endif // __clang__
// ============================================================================
// [GCC]
// ============================================================================ // ============================================================================
#if defined(__GNUC__) && !defined(__clang__) #if defined(__GNUC__) && !defined(__clang__)
# if __GNUC__ >= 4 && !defined(__MINGW32__) # if __GNUC__ >= 4 && !defined(__MINGW32__)
# pragma GCC visibility push(hidden) # pragma GCC visibility push(hidden)
# endif // __GNUC__ >= 4 # endif // GCC 4+
#endif // __GNUC__ #endif // __GNUC__
...@@ -4,30 +4,64 @@ ...@@ -4,30 +4,64 @@
// [License] // [License]
// Zlib - See LICENSE.md file in the package. // Zlib - See LICENSE.md file in the package.
// [Guard]
#if defined(ASMJIT_API_SCOPE)
# undef ASMJIT_API_SCOPE
#else
# error "AsmJit - Api-Scope not active, forgot to include apibegin.h?"
#endif // ASMJIT_API_SCOPE
// ============================================================================
// [Override]
// ============================================================================
#if defined(ASMJIT_UNDEF_OVERRIDE)
# undef override
# undef ASMJIT_UNDEF_OVERRIDE
#endif // ASMJIT_UNDEF_OVERRIDE
// ============================================================================
// [NoExcept]
// ============================================================================
#if defined(ASMJIT_UNDEF_NOEXCEPT)
# undef noexcept
# undef ASMJIT_UNDEF_NOEXCEPT
#endif // ASMJIT_UNDEF_NOEXCEPT
// ============================================================================ // ============================================================================
// [MSVC] // [MSC]
// ============================================================================ // ============================================================================
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Pop disabled warnings by ApiBegin.h
# pragma warning(pop) # pragma warning(pop)
// Rename symbols back.
# if defined(ASMJIT_DEFINED_VSNPRINTF) # if defined(ASMJIT_UNDEF_VSNPRINTF)
# undef ASMJIT_DEFINED_VSNPRINTF
# undef vsnprintf # undef vsnprintf
# endif // ASMJIT_DEFINED_VSNPRINTF # undef ASMJIT_UNDEF_VSNPRINTF
# if defined(ASMJIT_DEFINED_SNPRINTF) # endif // ASMJIT_UNDEF_VSNPRINTF
# undef ASMJIT_DEFINED_SNPRINTF
# if defined(ASMJIT_UNDEF_SNPRINTF)
# undef snprintf # undef snprintf
# endif // ASMJIT_DEFINED_SNPRINTF # undef ASMJIT_UNDEF_SNPRINTF
# endif // ASMJIT_UNDEF_SNPRINTF
#endif // _MSC_VER #endif // _MSC_VER
// ============================================================================ // ============================================================================
// [GNUC] // [CLang]
// ============================================================================
#if defined(__clang__)
# pragma clang diagnostic pop
#endif // __clang__
// ============================================================================
// [GCC]
// ============================================================================ // ============================================================================
#if defined(__GNUC__) && !defined(__clang__) #if defined(__GNUC__) && !defined(__clang__)
# if __GNUC__ >= 4 && !defined(__MINGW32__) # if __GNUC__ >= 4 && !defined(__MINGW32__)
# pragma GCC visibility pop # pragma GCC visibility pop
# endif // __GNUC__ >= 4 # endif // GCC 4+
#endif // __GNUC__ #endif // __GNUC__
...@@ -235,15 +235,15 @@ ...@@ -235,15 +235,15 @@
//! `BaseMem` class. These functions are used to make operands that represents //! `BaseMem` class. These functions are used to make operands that represents
//! memory addresses: //! memory addresses:
//! //!
//! - `asmjit::ptr()` //! - `asmjit::ptr()` - Address size not specified.
//! - `asmjit::byte_ptr()` //! - `asmjit::byte_ptr()` - 1 byte.
//! - `asmjit::word_ptr()` //! - `asmjit::word_ptr()` - 2 bytes (Gpw size).
//! - `asmjit::dword_ptr()` //! - `asmjit::dword_ptr()` - 4 bytes (Gpd size).
//! - `asmjit::qword_ptr()` //! - `asmjit::qword_ptr()` - 8 bytes (Gpq/Mm size).
//! - `asmjit::tword_ptr()` //! - `asmjit::tword_ptr()` - 10 bytes (FPU).
//! - `asmjit::oword_ptr()` //! - `asmjit::oword_ptr()` - 16 bytes (Xmm size).
//! - `asmjit::yword_ptr()` //! - `asmjit::yword_ptr()` - 32 bytes (Ymm size).
//! - `asmjit::zword_ptr()` //! - `asmjit::zword_ptr()` - 64 bytes (Zmm size).
//! //!
//! Most useful function to make pointer should be `asmjit::ptr()`. It creates //! Most useful function to make pointer should be `asmjit::ptr()`. It creates
//! pointer to the target with unspecified size. Unspecified size works in all //! pointer to the target with unspecified size. Unspecified size works in all
...@@ -298,10 +298,10 @@ ...@@ -298,10 +298,10 @@
//! // Get `X86CpuInfo` global instance. //! // Get `X86CpuInfo` global instance.
//! const X86CpuInfo* cpuInfo = X86CpuInfo::getHost(); //! const X86CpuInfo* cpuInfo = X86CpuInfo::getHost();
//! //!
//! if (cpuInfo->hasFeature(kX86CpuFeatureSse2)) { //! if (cpuInfo->hasFeature(kX86CpuFeatureSSE2)) {
//! // Processor has SSE2. //! // Processor has SSE2.
//! } //! }
//! else if (cpuInfo->hasFeature(kX86CpuFeatureMmx)) { //! else if (cpuInfo->hasFeature(kX86CpuFeatureMMX)) {
//! // Processor doesn't have SSE2, but has MMX. //! // Processor doesn't have SSE2, but has MMX.
//! } //! }
//! else { //! else {
......
...@@ -340,43 +340,35 @@ Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const ...@@ -340,43 +340,35 @@ Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const
} }
Error Assembler::emit(uint32_t code, int o0) { Error Assembler::emit(uint32_t code, int o0) {
Imm imm(o0); return _emit(code, Imm(o0), NA, NA, NA);
return _emit(code, imm, NA, NA, NA);
} }
Error Assembler::emit(uint32_t code, uint64_t o0) { Error Assembler::emit(uint32_t code, const Operand& o0, int o1) {
Imm imm(o0); return _emit(code, o0, Imm(o1), NA, NA);
return _emit(code, imm, NA, NA, NA);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, int o1) { Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, int o2) {
Imm imm(o1); return _emit(code, o0, o1, Imm(o2), NA);
return _emit(code, o0, imm, NA, NA);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, uint64_t o1) { Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int o3) {
Imm imm(o1); return _emit(code, o0, o1, o2, Imm(o3));
return _emit(code, o0, imm, NA, NA);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, int o2) { Error Assembler::emit(uint32_t code, int64_t o0) {
Imm imm(o2); return _emit(code, Imm(o0), NA, NA, NA);
return _emit(code, o0, o1, imm, NA);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, uint64_t o2) { Error Assembler::emit(uint32_t code, const Operand& o0, int64_t o1) {
Imm imm(o2); return _emit(code, o0, Imm(o1), NA, NA);
return _emit(code, o0, o1, imm, NA);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int o3) { Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, int64_t o2) {
Imm imm(o3); return _emit(code, o0, o1, Imm(o2), NA);
return _emit(code, o0, o1, o2, imm);
} }
Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, uint64_t o3) { Error Assembler::emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int64_t o3) {
Imm imm(o3); return _emit(code, o0, o1, o2, Imm(o3));
return _emit(code, o0, o1, o2, imm);
} }
#undef NA #undef NA
......
...@@ -26,23 +26,23 @@ namespace asmjit { ...@@ -26,23 +26,23 @@ namespace asmjit {
//! \{ //! \{
// ============================================================================ // ============================================================================
// [asmjit::kInstId] // [asmjit::InstId]
// ============================================================================ // ============================================================================
//! Instruction codes (stub). //! Instruction codes (stub).
ASMJIT_ENUM(kInstId) { ASMJIT_ENUM(InstId) {
//! No instruction. //! No instruction.
kInstIdNone = 0 kInstIdNone = 0
}; };
// ============================================================================ // ============================================================================
// [asmjit::kInstOptions] // [asmjit::InstOptions]
// ============================================================================ // ============================================================================
//! Instruction options (stub). //! Instruction options.
ASMJIT_ENUM(kInstOptions) { ASMJIT_ENUM(InstOptions) {
//! No instruction options. //! No instruction options.
kInstOptionNone = 0x00, kInstOptionNone = 0x00000000,
//! Emit short form of the instruction. //! Emit short form of the instruction.
//! //!
...@@ -53,7 +53,8 @@ ASMJIT_ENUM(kInstOptions) { ...@@ -53,7 +53,8 @@ ASMJIT_ENUM(kInstOptions) {
//! can be dangerous if the short jmp/jcc is required, but not encodable due //! can be dangerous if the short jmp/jcc is required, but not encodable due
//! to large displacement, in such case an error happens and the whole //! to large displacement, in such case an error happens and the whole
//! assembler/compiler stream is unusable. //! assembler/compiler stream is unusable.
kInstOptionShortForm = 0x01, kInstOptionShortForm = 0x00000001,
//! Emit long form of the instruction. //! Emit long form of the instruction.
//! //!
//! X86/X64: //! X86/X64:
...@@ -61,12 +62,13 @@ ASMJIT_ENUM(kInstOptions) { ...@@ -61,12 +62,13 @@ ASMJIT_ENUM(kInstOptions) {
//! Long form is mosrlt related to jmp and jcc instructions, but like the //! Long form is mosrlt related to jmp and jcc instructions, but like the
//! `kInstOptionShortForm` option it can be used by other instructions //! `kInstOptionShortForm` option it can be used by other instructions
//! supporting both 8-bit and 32-bit immediates. //! supporting both 8-bit and 32-bit immediates.
kInstOptionLongForm = 0x02, kInstOptionLongForm = 0x00000002,
//! Condition is likely to be taken. //! Condition is likely to be taken.
kInstOptionTaken = 0x04, kInstOptionTaken = 0x00000004,
//! Condition is unlikely to be taken. //! Condition is unlikely to be taken.
kInstOptionNotTaken = 0x08 kInstOptionNotTaken = 0x00000008
}; };
// ============================================================================ // ============================================================================
...@@ -474,19 +476,20 @@ struct ASMJIT_VCLASS Assembler : public CodeGen { ...@@ -474,19 +476,20 @@ struct ASMJIT_VCLASS Assembler : public CodeGen {
//! Emit an instruction with integer immediate operand. //! Emit an instruction with integer immediate operand.
ASMJIT_API Error emit(uint32_t code, int o0); ASMJIT_API Error emit(uint32_t code, int o0);
//! \overload //! \overload
ASMJIT_API Error emit(uint32_t code, uint64_t o0);
//! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, int o1); ASMJIT_API Error emit(uint32_t code, const Operand& o0, int o1);
//! \overload //! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, uint64_t o1);
//! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, int o2); ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, int o2);
//! \overload //! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, uint64_t o2);
//! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int o3); ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int o3);
//! \overload
ASMJIT_API Error emit(uint32_t code, int64_t o0);
//! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, int64_t o1);
//! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, int64_t o2);
//! \overload //! \overload
ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, uint64_t o3); ASMJIT_API Error emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, int64_t o3);
//! Emit an instruction (virtual). //! Emit an instruction (virtual).
virtual Error _emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, const Operand& o3) = 0; virtual Error _emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, const Operand& o3) = 0;
......
...@@ -23,11 +23,11 @@ namespace asmjit { ...@@ -23,11 +23,11 @@ namespace asmjit {
//! \{ //! \{
// ============================================================================ // ============================================================================
// [asmjit::kCodeGen] // [asmjit::CodeGenFeatures]
// ============================================================================ // ============================================================================
//! Features of \ref CodeGen. //! Features of \ref CodeGen.
ASMJIT_ENUM(kCodeGen) { ASMJIT_ENUM(CodeGenFeatures) {
//! Emit optimized code-alignment sequences (`Assembler` and `Compiler`). //! Emit optimized code-alignment sequences (`Assembler` and `Compiler`).
//! //!
//! Default `true`. //! Default `true`.
...@@ -80,11 +80,11 @@ ASMJIT_ENUM(kCodeGen) { ...@@ -80,11 +80,11 @@ ASMJIT_ENUM(kCodeGen) {
}; };
// ============================================================================ // ============================================================================
// [asmjit::kAlignMode] // [asmjit::AlignMode]
// ============================================================================ // ============================================================================
//! Code aligning mode. //! Code aligning mode.
ASMJIT_ENUM(kAlignMode) { ASMJIT_ENUM(AlignMode) {
//! Align by emitting a sequence that can be executed (code). //! Align by emitting a sequence that can be executed (code).
kAlignCode = 0, kAlignCode = 0,
//! Align by emitting sequence that shouldn't be executed (data). //! Align by emitting sequence that shouldn't be executed (data).
...@@ -92,11 +92,11 @@ ASMJIT_ENUM(kAlignMode) { ...@@ -92,11 +92,11 @@ ASMJIT_ENUM(kAlignMode) {
}; };
// ============================================================================ // ============================================================================
// [asmjit::kRelocMode] // [asmjit::RelocMode]
// ============================================================================ // ============================================================================
//! Relocation mode. //! Relocation mode.
ASMJIT_ENUM(kRelocMode) { ASMJIT_ENUM(RelocMode) {
//! Relocate an absolute address to an absolute address. //! Relocate an absolute address to an absolute address.
kRelocAbsToAbs = 0, kRelocAbsToAbs = 0,
//! Relocate a relative address to an absolute address. //! Relocate a relative address to an absolute address.
......
...@@ -40,11 +40,11 @@ enum { kBaseCompilerDefaultLookAhead = 64 }; ...@@ -40,11 +40,11 @@ enum { kBaseCompilerDefaultLookAhead = 64 };
Compiler::Compiler(Runtime* runtime) : Compiler::Compiler(Runtime* runtime) :
CodeGen(runtime), CodeGen(runtime),
_assembler(NULL),
_nodeFlowId(0), _nodeFlowId(0),
_nodeFlags(0), _nodeFlags(0),
_maxLookAhead(kBaseCompilerDefaultLookAhead), _maxLookAhead(kBaseCompilerDefaultLookAhead),
_targetVarMapping(NULL), _targetVarMapping(NULL),
_assembler(NULL),
_firstNode(NULL), _firstNode(NULL),
_lastNode(NULL), _lastNode(NULL),
_cursor(NULL), _cursor(NULL),
...@@ -482,7 +482,7 @@ VarData* Compiler::_newVd(uint32_t type, uint32_t size, uint32_t c, const char* ...@@ -482,7 +482,7 @@ VarData* Compiler::_newVd(uint32_t type, uint32_t size, uint32_t c, const char*
vd->_flags = 0; vd->_flags = 0;
vd->_priority = 10; vd->_priority = 10;
vd->_state = kVarStateUnused; vd->_state = kVarStateNone;
vd->_regIndex = kInvalidReg; vd->_regIndex = kInvalidReg;
vd->_isStack = false; vd->_isStack = false;
vd->_isMemArg = false; vd->_isMemArg = false;
......
This diff is collapsed.
...@@ -162,19 +162,6 @@ void ConstPool::reset() { ...@@ -162,19 +162,6 @@ void ConstPool::reset() {
// [asmjit::ConstPool - Ops] // [asmjit::ConstPool - Ops]
// ============================================================================ // ============================================================================
static ASMJIT_INLINE size_t ConstPool_getGapIndex(size_t size) {
if (size <= 1)
return ConstPool::kIndex1;
else if (size <= 3)
return ConstPool::kIndex2;
else if (size <= 7)
return ConstPool::kIndex4;
else if (size <= 15)
return ConstPool::kIndex8;
else
return ConstPool::kIndex16;
}
static ASMJIT_INLINE ConstPoolGap* ConstPool_allocGap(ConstPool* self) { static ASMJIT_INLINE ConstPoolGap* ConstPool_allocGap(ConstPool* self) {
ConstPoolGap* gap = self->_gapPool; ConstPoolGap* gap = self->_gapPool;
if (gap == NULL) if (gap == NULL)
...@@ -396,7 +383,7 @@ UNIT(base_constpool) { ...@@ -396,7 +383,7 @@ UNIT(base_constpool) {
EXPECT(prevOffset + 8 == curOffset, EXPECT(prevOffset + 8 == curOffset,
"pool.add() - Returned incorrect curOffset."); "pool.add() - Returned incorrect curOffset.");
EXPECT(pool.getSize() == (i + 1) * 8, EXPECT(pool.getSize() == (i + 1) * 8,
"pool.getSize() - Reports incorrect size."); "pool.getSize() - Reported incorrect size.");
prevOffset = curOffset; prevOffset = curOffset;
} }
...@@ -481,7 +468,6 @@ UNIT(base_constpool) { ...@@ -481,7 +468,6 @@ UNIT(base_constpool) {
INFO("Checking pool alignment when combined constants are added."); INFO("Checking pool alignment when combined constants are added.");
{ {
uint8_t bytes[32] = { 0 }; uint8_t bytes[32] = { 0 };
uint64_t c = 0;
size_t offset; size_t offset;
pool.add(bytes, 1, offset); pool.add(bytes, 1, offset);
......
...@@ -128,9 +128,12 @@ struct ConstPoolTree { ...@@ -128,9 +128,12 @@ struct ConstPoolTree {
if (link != NULL) { if (link != NULL) {
ASMJIT_ASSERT(top != kHeightLimit); ASMJIT_ASSERT(top != kHeightLimit);
stack[top++] = node; stack[top++] = node;
node = link;
continue; continue;
} }
_Visit:
visitor.visit(node); visitor.visit(node);
link = node->_link[1]; link = node->_link[1];
...@@ -143,6 +146,7 @@ struct ConstPoolTree { ...@@ -143,6 +146,7 @@ struct ConstPoolTree {
break; break;
node = stack[--top]; node = stack[--top];
goto _Visit;
} }
} }
......
...@@ -26,8 +26,8 @@ namespace asmjit { ...@@ -26,8 +26,8 @@ namespace asmjit {
Context::Context(Compiler* compiler) : Context::Context(Compiler* compiler) :
_compiler(compiler), _compiler(compiler),
_varMapToVaListOffset(0), _baseZone(8192 - kZoneOverhead),
_baseZone(8192 - kZoneOverhead) { _varMapToVaListOffset(0) {
Context::reset(); Context::reset();
} }
...@@ -217,7 +217,7 @@ Error Context::resolveCellOffsets() { ...@@ -217,7 +217,7 @@ Error Context::resolveCellOffsets() {
// Vars - Allocated according to alignment/width. // Vars - Allocated according to alignment/width.
while (varCell != NULL) { while (varCell != NULL) {
uint32_t size = varCell->getSize(); uint32_t size = varCell->getSize();
uint32_t offset; uint32_t offset = 0;
switch (size) { switch (size) {
case 1: offset = pos1 ; pos1 += 1 ; break; case 1: offset = pos1 ; pos1 += 1 ; break;
...@@ -234,13 +234,13 @@ Error Context::resolveCellOffsets() { ...@@ -234,13 +234,13 @@ Error Context::resolveCellOffsets() {
varCell = varCell->_next; varCell = varCell->_next;
} }
// Stack - Allocated according to alignment and width. // Stack - Allocated according to alignment/width.
while (stackCell != NULL) { while (stackCell != NULL) {
uint32_t size = stackCell->getSize(); uint32_t size = stackCell->getSize();
uint32_t alignment = stackCell->getAlignment(); uint32_t alignment = stackCell->getAlignment();
uint32_t offset; uint32_t offset;
// Try to fill the gap between variables / stack first. // Try to fill the gap between variables/stack first.
if (size <= gapSize && alignment <= gapAlignment) { if (size <= gapSize && alignment <= gapAlignment) {
offset = gapPos; offset = gapPos;
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/cpuinfo.h" #include "../base/cpuinfo.h"
#if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64) #if defined(ASMJIT_ARCH_X86) || defined(ASMJIT_ARCH_X64)
#include "../x86/x86cpuinfo.h" #include "../x86/x86cpuinfo.h"
#else #else
// ? // ?
#endif // ASMJIT_HOST || ASMJIT_HOST_X64 #endif
// [Dependencies - Posix] // [Dependencies - Posix]
#if defined(ASMJIT_OS_POSIX) #if defined(ASMJIT_OS_POSIX)
...@@ -54,7 +54,7 @@ uint32_t CpuInfo::detectHwThreadsCount() { ...@@ -54,7 +54,7 @@ uint32_t CpuInfo::detectHwThreadsCount() {
// [asmjit::CpuInfo - GetHost] // [asmjit::CpuInfo - GetHost]
// ============================================================================ // ============================================================================
#if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64) #if defined(ASMJIT_ARCH_X86) || defined(ASMJIT_ARCH_X64)
struct AutoX86CpuInfo : public X86CpuInfo { struct AutoX86CpuInfo : public X86CpuInfo {
ASMJIT_INLINE AutoX86CpuInfo() : X86CpuInfo() { ASMJIT_INLINE AutoX86CpuInfo() : X86CpuInfo() {
X86CpuUtil::detect(this); X86CpuUtil::detect(this);
...@@ -62,14 +62,14 @@ struct AutoX86CpuInfo : public X86CpuInfo { ...@@ -62,14 +62,14 @@ struct AutoX86CpuInfo : public X86CpuInfo {
}; };
#else #else
#error "AsmJit - Unsupported CPU." #error "AsmJit - Unsupported CPU."
#endif // ASMJIT_HOST || ASMJIT_HOST_X64 #endif
const CpuInfo* CpuInfo::getHost() { const CpuInfo* CpuInfo::getHost() {
#if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64) #if defined(ASMJIT_ARCH_X86) || defined(ASMJIT_ARCH_X64)
static AutoX86CpuInfo cpuInfo; static AutoX86CpuInfo cpuInfo;
#else #else
#error "AsmJit - Unsupported CPU." #error "AsmJit - Unsupported CPU."
#endif // ASMJIT_HOST || ASMJIT_HOST_X64 #endif
return &cpuInfo; return &cpuInfo;
} }
......
...@@ -20,7 +20,7 @@ namespace asmjit { ...@@ -20,7 +20,7 @@ namespace asmjit {
//! \{ //! \{
// ============================================================================ // ============================================================================
// [asmjit::kCpuVendor] // [asmjit::CpuVendor]
// ============================================================================ // ============================================================================
//! Cpu vendor ID. //! Cpu vendor ID.
...@@ -30,7 +30,7 @@ namespace asmjit { ...@@ -30,7 +30,7 @@ namespace asmjit {
//! calls. Some manufacturers changed their vendor strings and AsmJit is aware //! calls. Some manufacturers changed their vendor strings and AsmJit is aware
//! of that - it checks multiple combinations and decides which vendor ID should //! of that - it checks multiple combinations and decides which vendor ID should
//! be used. //! be used.
ASMJIT_ENUM(kCpuVendor) { ASMJIT_ENUM(CpuVendor) {
//! No/Unknown vendor. //! No/Unknown vendor.
kCpuVendorNone = 0, kCpuVendorNone = 0,
...@@ -59,7 +59,7 @@ struct CpuInfo { ...@@ -59,7 +59,7 @@ struct CpuInfo {
// [Construction / Destruction] // [Construction / Destruction]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_INLINE CpuInfo(uint32_t size = sizeof(CpuInfo)) : _size(size) {} ASMJIT_INLINE CpuInfo(uint32_t size) : _size(size) {}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Accessors] // [Accessors]
...@@ -120,7 +120,7 @@ struct CpuInfo { ...@@ -120,7 +120,7 @@ struct CpuInfo {
//! Cpu long vendor string (brand). //! Cpu long vendor string (brand).
char _brandString[64]; char _brandString[64];
//! Cpu vendor id, see `asmjit::kCpuVendor`. //! Cpu vendor id, see \ref CpuVendor.
uint32_t _vendorId; uint32_t _vendorId;
//! Cpu family ID. //! Cpu family ID.
uint32_t _family; uint32_t _family;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
// [Dependencies - Windows] // [Dependencies - Windows]
#if defined(ASMJIT_OS_WINDOWS) #if defined(ASMJIT_OS_WINDOWS)
// `_InterlockedCompareExchange` is only available as intrinsic (MS Compiler). // `_InterlockedCompareExchange` is only available as intrinsic (MS Compiler).
# if defined(_MSC_VER) # if defined(_MSC_VER) && _MSC_VER >= 1400
# include <intrin.h> # include <intrin.h>
# pragma intrinsic(_InterlockedCompareExchange) # pragma intrinsic(_InterlockedCompareExchange)
# else # else
......
...@@ -64,7 +64,9 @@ static const char* findPackedString(const char* p, uint32_t id, uint32_t maxId) ...@@ -64,7 +64,9 @@ static const char* findPackedString(const char* p, uint32_t id, uint32_t maxId)
while (i < id) { while (i < id) {
while (p[0]) while (p[0])
p++; p++;
p++; p++;
i++;
} }
return p; return p;
......
...@@ -8,23 +8,23 @@ ...@@ -8,23 +8,23 @@
#ifndef _ASMJIT_BASE_ERROR_H #ifndef _ASMJIT_BASE_ERROR_H
#define _ASMJIT_BASE_ERROR_H #define _ASMJIT_BASE_ERROR_H
// [Api-Begin]
#include "../apibegin.h"
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/globals.h" #include "../base/globals.h"
// [Api-Begin]
#include "../apibegin.h"
namespace asmjit { namespace asmjit {
//! \addtogroup asmjit_base_general //! \addtogroup asmjit_base_general
//! \{ //! \{
// ============================================================================ // ============================================================================
// [asmjit::kError] // [asmjit::ErrorCode]
// ============================================================================ // ============================================================================
//! AsmJit error codes. //! AsmJit error codes.
ASMJIT_ENUM(kError) { ASMJIT_ENUM(ErrorCode) {
//! No error (success). //! No error (success).
//! //!
//! This is default state and state you want. //! This is default state and state you want.
...@@ -188,7 +188,7 @@ struct ASMJIT_VCLASS ErrorHandler { ...@@ -188,7 +188,7 @@ struct ASMJIT_VCLASS ErrorHandler {
//! Error utilities. //! Error utilities.
struct ErrorUtil { struct ErrorUtil {
#if !defined(ASMJIT_DISABLE_NAMES) #if !defined(ASMJIT_DISABLE_NAMES)
//! Get printable version of AsmJit `kError` code. //! Get a printable version of AsmJit `Error` code.
static ASMJIT_API const char* asString(Error code); static ASMJIT_API const char* asString(Error code);
#endif // ASMJIT_DISABLE_NAMES #endif // ASMJIT_DISABLE_NAMES
}; };
......
...@@ -34,7 +34,7 @@ typedef uint64_t Ptr; ...@@ -34,7 +34,7 @@ typedef uint64_t Ptr;
typedef int64_t SignedPtr; typedef int64_t SignedPtr;
// ============================================================================ // ============================================================================
// [asmjit::kGlobals] // [asmjit::GlobalDefs]
// ============================================================================ // ============================================================================
//! Invalid index //! Invalid index
...@@ -48,7 +48,7 @@ static const size_t kInvalidIndex = ~static_cast<size_t>(0); ...@@ -48,7 +48,7 @@ static const size_t kInvalidIndex = ~static_cast<size_t>(0);
static const Ptr kNoBaseAddress = static_cast<Ptr>(static_cast<SignedPtr>(-1)); static const Ptr kNoBaseAddress = static_cast<Ptr>(static_cast<SignedPtr>(-1));
//! Global constants. //! Global constants.
ASMJIT_ENUM(kGlobals) { ASMJIT_ENUM(GlobalDefs) {
//! Invalid value or operand id. //! Invalid value or operand id.
kInvalidValue = 0xFFFFFFFF, kInvalidValue = 0xFFFFFFFF,
...@@ -74,11 +74,11 @@ ASMJIT_ENUM(kGlobals) { ...@@ -74,11 +74,11 @@ ASMJIT_ENUM(kGlobals) {
}; };
// ============================================================================ // ============================================================================
// [asmjit::kArch] // [asmjit::ArchId]
// ============================================================================ // ============================================================================
//! Architecture. //! CPU architecture identifier.
ASMJIT_ENUM(kArch) { ASMJIT_ENUM(ArchId) {
//! No/Unknown architecture. //! No/Unknown architecture.
kArchNone = 0, kArchNone = 0,
...@@ -90,17 +90,17 @@ ASMJIT_ENUM(kArch) { ...@@ -90,17 +90,17 @@ ASMJIT_ENUM(kArch) {
//! Arm architecture. //! Arm architecture.
kArchArm = 4, kArchArm = 4,
#if defined(ASMJIT_HOST_X86) #if defined(ASMJIT_ARCH_X86)
kArchHost = kArchX86, kArchHost = kArchX86,
#endif // ASMJIT_HOST_X86 #endif // ASMJIT_ARCH_X86
#if defined(ASMJIT_HOST_X64) #if defined(ASMJIT_ARCH_X64)
kArchHost = kArchX64, kArchHost = kArchX64,
#endif // ASMJIT_HOST_X64 #endif // ASMJIT_ARCH_X64
#if defined(ASMJIT_HOST_ARM) #if defined(ASMJIT_ARCH_ARM)
kArchHost = kArchArm, kArchHost = kArchArm,
#endif // ASMJIT_HOST_ARM #endif // ASMJIT_ARCH_ARM
//! Whether the host is 64-bit. //! Whether the host is 64-bit.
kArchHost64Bit = sizeof(intptr_t) >= 8 kArchHost64Bit = sizeof(intptr_t) >= 8
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/globals.h" #include "../base/globals.h"
#if defined(_MSC_VER) #if defined(_MSC_VER) && _MSC_VER >= 1400
#pragma intrinsic(_BitScanForward) # include <intrin.h>
# pragma intrinsic(_BitScanForward)
#endif // ASMJIT_OS_WINDOWS #endif // ASMJIT_OS_WINDOWS
// [Api-Begin] // [Api-Begin]
...@@ -43,6 +44,31 @@ struct IntTraits { ...@@ -43,6 +44,31 @@ struct IntTraits {
}; };
}; };
// \internal
template<size_t Size, int IsSigned>
struct AsInt_ { typedef int64_t Int; };
template<> struct AsInt_<1, 0> { typedef int Int; };
template<> struct AsInt_<1, 1> { typedef int Int; };
template<> struct AsInt_<2, 0> { typedef int Int; };
template<> struct AsInt_<2, 1> { typedef int Int; };
template<> struct AsInt_<4, 1> { typedef int Int; };
// \internal
//
// Map an integer `T` to an `int` or `int64_t`, depending on the type. Used
// internally by AsmJit to dispatch an argument of arbitrary integer type into
// a function that accepts either `int` or `int64_t`.
template<typename T>
struct AsInt {
typedef typename AsInt_<sizeof(T), IntTraits<T>::kIsSigned>::Int Int;
};
template<typename T>
ASMJIT_INLINE typename AsInt<T>::Int asInt(T value) {
return static_cast<typename AsInt<T>::Int>(value);
}
// ============================================================================ // ============================================================================
// [asmjit::IntUtil] // [asmjit::IntUtil]
// ============================================================================ // ============================================================================
...@@ -82,29 +108,29 @@ struct IntUtil { ...@@ -82,29 +108,29 @@ struct IntUtil {
//! Pack two 8-bit integer and one 16-bit integer into a 32-bit integer as it //! Pack two 8-bit integer and one 16-bit integer into a 32-bit integer as it
//! is an array of `{u0,u1,w2}`. //! is an array of `{u0,u1,w2}`.
static ASMJIT_INLINE uint32_t pack32_2x8_1x16(uint32_t u0, uint32_t u1, uint32_t w2) { static ASMJIT_INLINE uint32_t pack32_2x8_1x16(uint32_t u0, uint32_t u1, uint32_t w2) {
#if defined(ASMJIT_HOST_LE) #if defined(ASMJIT_ARCH_LE)
return u0 + (u1 << 8) + (w2 << 16); return u0 + (u1 << 8) + (w2 << 16);
#else #else
return (u0 << 24) + (u1 << 16) + (w2); return (u0 << 24) + (u1 << 16) + (w2);
#endif // ASMJIT_HOST #endif
} }
//! Pack four 8-bit integer into a 32-bit integer as it is an array of `{u0,u1,u2,u3}`. //! Pack four 8-bit integer into a 32-bit integer as it is an array of `{u0,u1,u2,u3}`.
static ASMJIT_INLINE uint32_t pack32_4x8(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3) { static ASMJIT_INLINE uint32_t pack32_4x8(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3) {
#if defined(ASMJIT_HOST_LE) #if defined(ASMJIT_ARCH_LE)
return u0 + (u1 << 8) + (u2 << 16) + (u3 << 24); return u0 + (u1 << 8) + (u2 << 16) + (u3 << 24);
#else #else
return (u0 << 24) + (u1 << 16) + (u2 << 8) + u3; return (u0 << 24) + (u1 << 16) + (u2 << 8) + u3;
#endif // ASMJIT_HOST #endif
} }
//! Pack two 32-bit integer into a 64-bit integer as it is an array of `{u0,u1}`. //! Pack two 32-bit integer into a 64-bit integer as it is an array of `{u0,u1}`.
static ASMJIT_INLINE uint64_t pack64_2x32(uint32_t u0, uint32_t u1) { static ASMJIT_INLINE uint64_t pack64_2x32(uint32_t u0, uint32_t u1) {
#if defined(ASMJIT_HOST_LE) #if defined(ASMJIT_ARCH_LE)
return (static_cast<uint64_t>(u1) << 32) + u0; return (static_cast<uint64_t>(u1) << 32) + u0;
#else #else
return (static_cast<uint64_t>(u0) << 32) + u1; return (static_cast<uint64_t>(u0) << 32) + u1;
#endif // ASMJIT_HOST #endif
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -336,7 +362,7 @@ struct IntUtil { ...@@ -336,7 +362,7 @@ struct IntUtil {
//! Find a first bit in `mask`. //! Find a first bit in `mask`.
static ASMJIT_INLINE uint32_t findFirstBit(uint32_t mask) { static ASMJIT_INLINE uint32_t findFirstBit(uint32_t mask) {
#if defined(_MSC_VER) #if defined(_MSC_VER) && _MSC_VER >= 1400
DWORD i; DWORD i;
if (_BitScanForward(&i, mask)) { if (_BitScanForward(&i, mask)) {
ASMJIT_ASSERT(findFirstBitSlow(mask) == i); ASMJIT_ASSERT(findFirstBitSlow(mask) == i);
...@@ -566,6 +592,26 @@ union UInt64 { ...@@ -566,6 +592,26 @@ union UInt64 {
return *this; return *this;
} }
// --------------------------------------------------------------------------
// [AndNot]
// --------------------------------------------------------------------------
ASMJIT_INLINE UInt64& andNot(uint64_t val) {
u64 &= ~val;
return *this;
}
ASMJIT_INLINE UInt64& andNot(const UInt64& val) {
if (kArchHost64Bit) {
u64 &= ~val.u64;
}
else {
u32[0] &= ~val.u32[0];
u32[1] &= ~val.u32[1];
}
return *this;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Or] // [Or]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -606,26 +652,6 @@ union UInt64 { ...@@ -606,26 +652,6 @@ union UInt64 {
return *this; return *this;
} }
// --------------------------------------------------------------------------
// [Del]
// --------------------------------------------------------------------------
ASMJIT_INLINE UInt64& del(uint64_t val) {
u64 &= ~val;
return *this;
}
ASMJIT_INLINE UInt64& del(const UInt64& val) {
if (kArchHost64Bit) {
u64 &= ~val.u64;
}
else {
u32[0] &= ~val.u32[0];
u32[1] &= ~val.u32[1];
}
return *this;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Eq] // [Eq]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -694,11 +720,11 @@ union UInt64 { ...@@ -694,11 +720,11 @@ union UInt64 {
uint8_t u8[8]; uint8_t u8[8];
struct { struct {
#if defined(ASMJIT_HOST_LE) #if defined(ASMJIT_ARCH_LE)
uint32_t lo, hi; uint32_t lo, hi;
#else #else
uint32_t hi, lo; uint32_t hi, lo;
#endif // ASMJIT_HOST_LE #endif // ASMJIT_ARCH_LE
}; };
}; };
......
...@@ -45,9 +45,12 @@ void Logger::logFormat(uint32_t style, const char* fmt, ...) { ...@@ -45,9 +45,12 @@ void Logger::logFormat(uint32_t style, const char* fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
len = vsnprintf(buf, 1023, fmt, ap); len = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap); va_end(ap);
if (len >= sizeof(buf))
len = sizeof(buf) - 1;
logString(style, buf, len); logString(style, buf, len);
} }
...@@ -120,15 +123,6 @@ FileLogger::FileLogger(FILE* stream) : _stream(NULL) { ...@@ -120,15 +123,6 @@ FileLogger::FileLogger(FILE* stream) : _stream(NULL) {
FileLogger::~FileLogger() {} FileLogger::~FileLogger() {}
// ============================================================================
// [asmjit::FileLogger - Accessors]
// ============================================================================
//! Set file stream.
void FileLogger::setStream(FILE* stream) {
_stream = stream;
}
// ============================================================================ // ============================================================================
// [asmjit::FileLogger - Logging] // [asmjit::FileLogger - Logging]
// ============================================================================ // ============================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment