[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: precompiling lua script problem
- From: Peter Shook <pshook@...>
- Date: Mon, 07 Jul 2003 23:31:03 -0400
Shelby Hubick wrote:
In our game we procompile all of our lua scripts using luac.exe (offline) before running the game. In doing this we noticed a problem where lua will believe a table is nil when indexed if it contains more than 64 entries. When running the game with the regular lua text files it works fine.
So it seems that precompiling the file causes the file to execute differently... does anyone know anything about this? As a temporary fix we may have to split all of our large tables into chunks of less than 64 entries and/or fallback to using text files.
Interesting problem.
Are the lost values array values or hash values?
Did you change MAXSTACK on either the host or the target?
MAXSTACK = 250 and LFIELDS_PER_FLUSH = 62 by default on my PC.
Note the "SETLIST 0 62" in the output of luac below. This opcode copies
all the table values on the stack into the table.
In the following simple example, luaM_realloc is not called while the
table is being filled in. Does this simple example work on your system?
$ cat y.lua
y = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65,
}
print(y)
for n,v in y do print(n,v) end
$ bin/luac -p -l y.lua
main <0:@y.lua> (80 instructions/320 bytes at 0xa0408c0)
0 params, 63 stacks, 3 locals, 2 strings, 0 numbers, 0 functions, 10 lines
1 [1] CREATETABLE 65
2 [2] PUSHINT 1
3 [2] PUSHINT 2
4 [2] PUSHINT 3
5 [2] PUSHINT 4
6 [2] PUSHINT 5
7 [2] PUSHINT 6
8 [2] PUSHINT 7
9 [2] PUSHINT 8
10 [2] PUSHINT 9
11 [2] PUSHINT 10
12 [2] PUSHINT 11
13 [2] PUSHINT 12
14 [2] PUSHINT 13
15 [2] PUSHINT 14
16 [2] PUSHINT 15
17 [2] PUSHINT 16
18 [3] PUSHINT 17
19 [3] PUSHINT 18
20 [3] PUSHINT 19
21 [3] PUSHINT 20
22 [3] PUSHINT 21
23 [3] PUSHINT 22
24 [3] PUSHINT 23
25 [3] PUSHINT 24
26 [3] PUSHINT 25
27 [3] PUSHINT 26
28 [3] PUSHINT 27
29 [3] PUSHINT 28
30 [3] PUSHINT 29
31 [3] PUSHINT 30
32 [3] PUSHINT 31
33 [3] PUSHINT 32
34 [4] PUSHINT 33
35 [4] PUSHINT 34
36 [4] PUSHINT 35
37 [4] PUSHINT 36
38 [4] PUSHINT 37
39 [4] PUSHINT 38
40 [4] PUSHINT 39
41 [4] PUSHINT 40
42 [4] PUSHINT 41
43 [4] PUSHINT 42
44 [4] PUSHINT 43
45 [4] PUSHINT 44
46 [4] PUSHINT 45
47 [4] PUSHINT 46
48 [4] PUSHINT 47
49 [4] PUSHINT 48
50 [5] PUSHINT 49
51 [5] PUSHINT 50
52 [5] PUSHINT 51
53 [5] PUSHINT 52
54 [5] PUSHINT 53
55 [5] PUSHINT 54
56 [5] PUSHINT 55
57 [5] PUSHINT 56
58 [5] PUSHINT 57
59 [5] PUSHINT 58
60 [5] PUSHINT 59
61 [5] PUSHINT 60
62 [5] PUSHINT 61
63 [5] PUSHINT 62
64 [5] SETLIST 0 62
65 [5] PUSHINT 63
66 [5] PUSHINT 64
67 [6] PUSHINT 65
68 [6] SETLIST 1 3
69 [7] SETGLOBAL 0 ; y
70 [8] GETGLOBAL 1 ; print
71 [8] GETGLOBAL 0 ; y
72 [8] CALL 0 0
73 [9] GETGLOBAL 0 ; y
74 [9] LFORPREP 5 ; to 80
75 [9] GETGLOBAL 1 ; print
76 [9] GETLOCAL 1 ; n
77 [9] GETLOCAL 2 ; v
78 [9] CALL 3 0
79 [9] LFORLOOP -5 ; to 75
80 [9] END