mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 04:05:09 +02:00
Update LuaJIT to the latest 2.1.0 source (0bee44c)
This commit is contained in:
+20
-12
@@ -8,8 +8,8 @@
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1700)
|
||||
/* Old MSVC is stuck in the last century and doesn't have C99's stdint.h. */
|
||||
typedef __int8 int8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int32 int32_t;
|
||||
@@ -46,10 +46,14 @@ typedef unsigned int uintptr_t;
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Various VM limits. */
|
||||
#define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */
|
||||
#define LJ_MAX_MEM32 0x7fffff00 /* Max. 32 bit memory allocation. */
|
||||
#define LJ_MAX_MEM64 ((uint64_t)1<<47) /* Max. 64 bit memory allocation. */
|
||||
/* Max. total memory allocation. */
|
||||
#define LJ_MAX_MEM (LJ_GC64 ? LJ_MAX_MEM64 : LJ_MAX_MEM32)
|
||||
#define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */
|
||||
#define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */
|
||||
#define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */
|
||||
#define LJ_MAX_STR LJ_MAX_MEM32 /* Max. string length. */
|
||||
#define LJ_MAX_BUF LJ_MAX_MEM32 /* Max. buffer length. */
|
||||
#define LJ_MAX_UDATA LJ_MAX_MEM32 /* Max. userdata length. */
|
||||
|
||||
#define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */
|
||||
#define LJ_MAX_HBITS 26 /* Max. hash bits. */
|
||||
@@ -57,7 +61,7 @@ typedef unsigned int uintptr_t;
|
||||
#define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */
|
||||
#define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */
|
||||
|
||||
#define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */
|
||||
#define LJ_MAX_LINE LJ_MAX_MEM32 /* Max. source code line number. */
|
||||
#define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */
|
||||
#define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */
|
||||
#define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */
|
||||
@@ -65,7 +69,7 @@ typedef unsigned int uintptr_t;
|
||||
#define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */
|
||||
|
||||
#define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */
|
||||
#define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */
|
||||
#define LJ_STACK_EXTRA (5+2*LJ_FR2) /* Extra stack space (metamethods). */
|
||||
|
||||
#define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */
|
||||
|
||||
@@ -76,7 +80,6 @@ typedef unsigned int uintptr_t;
|
||||
#define LJ_MIN_SBUF 32 /* Min. string buffer length. */
|
||||
#define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */
|
||||
#define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */
|
||||
#define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */
|
||||
|
||||
/* JIT compiler limits. */
|
||||
#define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */
|
||||
@@ -91,6 +94,9 @@ typedef unsigned int uintptr_t;
|
||||
#define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo)
|
||||
#define i32ptr(p) ((int32_t)(intptr_t)(void *)(p))
|
||||
#define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p))
|
||||
#define i64ptr(p) ((int64_t)(intptr_t)(void *)(p))
|
||||
#define u64ptr(p) ((uint64_t)(intptr_t)(void *)(p))
|
||||
#define igcptr(p) (LJ_GC64 ? i64ptr(p) : i32ptr(p))
|
||||
|
||||
#define checki8(x) ((x) == (int32_t)(int8_t)(x))
|
||||
#define checku8(x) ((x) == (int32_t)(uint8_t)(x))
|
||||
@@ -99,6 +105,8 @@ typedef unsigned int uintptr_t;
|
||||
#define checki32(x) ((x) == (int32_t)(x))
|
||||
#define checku32(x) ((x) == (uint32_t)(x))
|
||||
#define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x))
|
||||
#define checkptr47(x) (((uint64_t)(uintptr_t)(x) >> 47) == 0)
|
||||
#define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr32((x)) :1)
|
||||
|
||||
/* Every half-decent C compiler transforms this into a rotate instruction. */
|
||||
#define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1))))
|
||||
@@ -254,19 +262,19 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
|
||||
return _CountLeadingZeros(x) ^ 31;
|
||||
}
|
||||
#else
|
||||
unsigned char _BitScanForward(uint32_t *, unsigned long);
|
||||
unsigned char _BitScanReverse(uint32_t *, unsigned long);
|
||||
unsigned char _BitScanForward(unsigned long *, unsigned long);
|
||||
unsigned char _BitScanReverse(unsigned long *, unsigned long);
|
||||
#pragma intrinsic(_BitScanForward)
|
||||
#pragma intrinsic(_BitScanReverse)
|
||||
|
||||
static LJ_AINLINE uint32_t lj_ffs(uint32_t x)
|
||||
{
|
||||
uint32_t r; _BitScanForward(&r, x); return r;
|
||||
unsigned long r; _BitScanForward(&r, x); return (uint32_t)r;
|
||||
}
|
||||
|
||||
static LJ_AINLINE uint32_t lj_fls(uint32_t x)
|
||||
{
|
||||
uint32_t r; _BitScanReverse(&r, x); return r;
|
||||
unsigned long r; _BitScanReverse(&r, x); return (uint32_t)r;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user