aboutsummaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h89
1 files changed, 5 insertions, 84 deletions
diff --git a/llimits.h b/llimits.h
index 51dbe7af..2b288981 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.27 2001/02/23 20:28:56 roberto Exp roberto $ 2** $Id: llimits.h,v 1.28 2001/03/26 14:31:49 roberto Exp roberto $
3** Limits, basic types, and some other `installation-dependent' definitions 3** Limits, basic types, and some other `installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -89,92 +89,23 @@ union L_Umaxalign { double d; void *s; long l; };
89/* 89/*
90** type for virtual-machine instructions 90** type for virtual-machine instructions
91** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) 91** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
92** For a very small machine, you may change that to 2 bytes (and adjust
93** the following limits accordingly)
94*/ 92*/
95typedef unsigned long Instruction; 93typedef unsigned long Instruction;
96 94
97 95
98/* 96/* maximum stack for a Lua function */
99** size and position of opcode arguments.
100** For an instruction with 2 bytes, size is 16, and size_b can be 5
101** (accordingly, size_u will be 10, and size_a will be 5)
102*/
103#define SIZE_INSTRUCTION 32
104#define SIZE_B 8
105
106#define SIZE_OP 6
107#define SIZE_U (SIZE_INSTRUCTION-SIZE_OP)
108#define POS_U SIZE_OP
109#define POS_B SIZE_OP
110#define SIZE_A (SIZE_INSTRUCTION-(SIZE_OP+SIZE_B))
111#define POS_A (SIZE_OP+SIZE_B)
112
113
114/*
115** limits for opcode arguments.
116** we use (signed) int to manipulate most arguments,
117** so they must fit in BITS_INT-1 bits (-1 for sign)
118*/
119#if SIZE_U < BITS_INT-1
120#define MAXARG_U ((1<<SIZE_U)-1)
121#define MAXARG_S (MAXARG_U>>1) /* `S' is signed */
122#else
123#define MAXARG_U MAX_INT
124#define MAXARG_S MAX_INT
125#endif
126
127#if SIZE_A < BITS_INT-1
128#define MAXARG_A ((1<<SIZE_A)-1)
129#else
130#define MAXARG_A MAX_INT
131#endif
132
133#if SIZE_B < BITS_INT-1
134#define MAXARG_B ((1<<SIZE_B)-1)
135#else
136#define MAXARG_B MAX_INT
137#endif
138
139
140/* maximum stack size in a function */
141#ifndef MAXSTACK
142#define MAXSTACK 250 97#define MAXSTACK 250
143#endif
144
145#if MAXSTACK > MAXARG_B
146#undef MAXSTACK
147#define MAXSTACK MAXARG_B
148#endif
149 98
150 99
151/* maximum number of local variables */ 100/* maximum number of local variables */
152#ifndef MAXLOCALS 101#ifndef MAXLOCALS
153#define MAXLOCALS 200 /* arbitrary limit (<MAXSTACK) */ 102#define MAXLOCALS 200 /* arbitrary limit (<MAXSTACK) */
154#endif 103#endif
155#if MAXLOCALS>=MAXSTACK
156#undef MAXLOCALS
157#define MAXLOCALS (MAXSTACK-1)
158#endif
159 104
160 105
161/* maximum number of upvalues */ 106/* maximum number of upvalues */
162#ifndef MAXUPVALUES 107#ifndef MAXUPVALUES
163#define MAXUPVALUES 32 /* arbitrary limit (<=MAXARG_B) */ 108#define MAXUPVALUES 32 /* arbitrary limit (<MAXSTACK) */
164#endif
165#if MAXUPVALUES>MAXARG_B
166#undef MAXUPVALUES
167#define MAXUPVALUES MAXARG_B
168#endif
169
170
171/* maximum number of variables in the left side of an assignment */
172#ifndef MAXVARSLH
173#define MAXVARSLH 100 /* arbitrary limit (<MULT_RET) */
174#endif
175#if MAXVARSLH>=MULT_RET
176#undef MAXVARSLH
177#define MAXVARSLH (MULT_RET-1)
178#endif 109#endif
179 110
180 111
@@ -182,27 +113,17 @@ typedef unsigned long Instruction;
182#ifndef MAXPARAMS 113#ifndef MAXPARAMS
183#define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */ 114#define MAXPARAMS 100 /* arbitrary limit (<MAXLOCALS) */
184#endif 115#endif
185#if MAXPARAMS>=MAXLOCALS
186#undef MAXPARAMS
187#define MAXPARAMS (MAXLOCALS-1)
188#endif
189 116
190 117
191/* number of list items to accumulate before a SETLIST instruction */ 118/* number of list items to accumulate before a SETLIST instruction */
119/* (must be a power of 2) */
192#define LFIELDS_PER_FLUSH 64 120#define LFIELDS_PER_FLUSH 64
193#if LFIELDS_PER_FLUSH>(MAXSTACK/4)
194#undef LFIELDS_PER_FLUSH
195#define LFIELDS_PER_FLUSH (MAXSTACK/4)
196#endif
197 121
198/* number of record items to accumulate before a SETMAP instruction */
199/* (each item counts 2 elements on the stack: an index and a value) */
200#define RFIELDS_PER_FLUSH (LFIELDS_PER_FLUSH/2)
201 122
202 123
203/* maximum lookback to find a real constant (for code generation) */ 124/* maximum lookback to find a real constant (for code generation) */
204#ifndef LOOKBACKNUMS 125#ifndef LOOKBACKNUMS
205#define LOOKBACKNUMS 20 /* arbitrary constant */ 126#define LOOKBACKNUMS 40 /* arbitrary constant */
206#endif 127#endif
207 128
208 129