diff options
Diffstat (limited to 'src/lj_def.h')
-rw-r--r-- | src/lj_def.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lj_def.h b/src/lj_def.h index b5e26d69..75aaeb79 100644 --- a/src/lj_def.h +++ b/src/lj_def.h | |||
@@ -46,10 +46,14 @@ typedef unsigned int uintptr_t; | |||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | 47 | ||
48 | /* Various VM limits. */ | 48 | /* Various VM limits. */ |
49 | #define LJ_MAX_MEM 0x7fffff00 /* Max. total memory allocation. */ | 49 | #define LJ_MAX_MEM32 0x7fffff00 /* Max. 32 bit memory allocation. */ |
50 | #define LJ_MAX_MEM64 ((uint64_t)1<<47) /* Max. 64 bit memory allocation. */ | ||
51 | /* Max. total memory allocation. */ | ||
52 | #define LJ_MAX_MEM (LJ_GC64 ? LJ_MAX_MEM64 : LJ_MAX_MEM32) | ||
50 | #define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ | 53 | #define LJ_MAX_ALLOC LJ_MAX_MEM /* Max. individual allocation length. */ |
51 | #define LJ_MAX_STR LJ_MAX_MEM /* Max. string length. */ | 54 | #define LJ_MAX_STR LJ_MAX_MEM32 /* Max. string length. */ |
52 | #define LJ_MAX_UDATA LJ_MAX_MEM /* Max. userdata length. */ | 55 | #define LJ_MAX_BUF LJ_MAX_MEM32 /* Max. buffer length. */ |
56 | #define LJ_MAX_UDATA LJ_MAX_MEM32 /* Max. userdata length. */ | ||
53 | 57 | ||
54 | #define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ | 58 | #define LJ_MAX_STRTAB (1<<26) /* Max. string table size. */ |
55 | #define LJ_MAX_HBITS 26 /* Max. hash bits. */ | 59 | #define LJ_MAX_HBITS 26 /* Max. hash bits. */ |
@@ -57,7 +61,7 @@ typedef unsigned int uintptr_t; | |||
57 | #define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ | 61 | #define LJ_MAX_ASIZE ((1<<(LJ_MAX_ABITS-1))+1) /* Max. array part size. */ |
58 | #define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ | 62 | #define LJ_MAX_COLOSIZE 16 /* Max. elems for colocated array. */ |
59 | 63 | ||
60 | #define LJ_MAX_LINE LJ_MAX_MEM /* Max. source code line number. */ | 64 | #define LJ_MAX_LINE LJ_MAX_MEM32 /* Max. source code line number. */ |
61 | #define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ | 65 | #define LJ_MAX_XLEVEL 200 /* Max. syntactic nesting level. */ |
62 | #define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ | 66 | #define LJ_MAX_BCINS (1<<26) /* Max. # of bytecode instructions. */ |
63 | #define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ | 67 | #define LJ_MAX_SLOTS 250 /* Max. # of slots in a Lua func. */ |
@@ -65,7 +69,7 @@ typedef unsigned int uintptr_t; | |||
65 | #define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ | 69 | #define LJ_MAX_UPVAL 60 /* Max. # of upvalues. */ |
66 | 70 | ||
67 | #define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ | 71 | #define LJ_MAX_IDXCHAIN 100 /* __index/__newindex chain limit. */ |
68 | #define LJ_STACK_EXTRA 5 /* Extra stack space (metamethods). */ | 72 | #define LJ_STACK_EXTRA (5+2*LJ_FR2) /* Extra stack space (metamethods). */ |
69 | 73 | ||
70 | #define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ | 74 | #define LJ_NUM_CBPAGE 1 /* Number of FFI callback pages. */ |
71 | 75 | ||
@@ -76,7 +80,6 @@ typedef unsigned int uintptr_t; | |||
76 | #define LJ_MIN_SBUF 32 /* Min. string buffer length. */ | 80 | #define LJ_MIN_SBUF 32 /* Min. string buffer length. */ |
77 | #define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ | 81 | #define LJ_MIN_VECSZ 8 /* Min. size for growable vectors. */ |
78 | #define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ | 82 | #define LJ_MIN_IRSZ 32 /* Min. size for growable IR. */ |
79 | #define LJ_MIN_K64SZ 16 /* Min. size for chained K64Array. */ | ||
80 | 83 | ||
81 | /* JIT compiler limits. */ | 84 | /* JIT compiler limits. */ |
82 | #define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ | 85 | #define LJ_MAX_JSLOTS 250 /* Max. # of stack slots for a trace. */ |
@@ -91,6 +94,9 @@ typedef unsigned int uintptr_t; | |||
91 | #define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) | 94 | #define U64x(hi, lo) (((uint64_t)0x##hi << 32) + (uint64_t)0x##lo) |
92 | #define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) | 95 | #define i32ptr(p) ((int32_t)(intptr_t)(void *)(p)) |
93 | #define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) | 96 | #define u32ptr(p) ((uint32_t)(intptr_t)(void *)(p)) |
97 | #define i64ptr(p) ((int64_t)(intptr_t)(void *)(p)) | ||
98 | #define u64ptr(p) ((uint64_t)(intptr_t)(void *)(p)) | ||
99 | #define igcptr(p) (LJ_GC64 ? i64ptr(p) : i32ptr(p)) | ||
94 | 100 | ||
95 | #define checki8(x) ((x) == (int32_t)(int8_t)(x)) | 101 | #define checki8(x) ((x) == (int32_t)(int8_t)(x)) |
96 | #define checku8(x) ((x) == (int32_t)(uint8_t)(x)) | 102 | #define checku8(x) ((x) == (int32_t)(uint8_t)(x)) |
@@ -99,6 +105,8 @@ typedef unsigned int uintptr_t; | |||
99 | #define checki32(x) ((x) == (int32_t)(x)) | 105 | #define checki32(x) ((x) == (int32_t)(x)) |
100 | #define checku32(x) ((x) == (uint32_t)(x)) | 106 | #define checku32(x) ((x) == (uint32_t)(x)) |
101 | #define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) | 107 | #define checkptr32(x) ((uintptr_t)(x) == (uint32_t)(uintptr_t)(x)) |
108 | #define checkptr47(x) (((uint64_t)(uintptr_t)(x) >> 47) == 0) | ||
109 | #define checkptrGC(x) (LJ_GC64 ? checkptr47((x)) : LJ_64 ? checkptr32((x)) :1) | ||
102 | 110 | ||
103 | /* Every half-decent C compiler transforms this into a rotate instruction. */ | 111 | /* Every half-decent C compiler transforms this into a rotate instruction. */ |
104 | #define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1)))) | 112 | #define lj_rol(x, n) (((x)<<(n)) | ((x)>>(-(int)(n)&(8*sizeof(x)-1)))) |