diff options
author | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
commit | 6523585c66c04cea54df50013df8886b589847d8 (patch) | |
tree | 0b22aee7064166d88595eda260ca2d17c0773da5 /libraries/LuaJIT-1.1.7/jit | |
parent | Update the EFL to what I'm actually using, coz I'm using some stuff not yet r... (diff) | |
download | SledjHamr-6523585c66c04cea54df50013df8886b589847d8.zip SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.gz SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.bz2 SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.xz |
Add luaproc and LuaJIT libraries.
Two versions of LuaJIT, the stable release, and the dev version. Try the dev version first, until ih fails badly.
Diffstat (limited to '')
31 files changed, 6509 insertions, 0 deletions
diff --git a/libraries/LuaJIT-1.1.7/jit/dis_x86.lua b/libraries/LuaJIT-1.1.7/jit/dis_x86.lua new file mode 100644 index 0000000..b9ca150 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/dis_x86.lua | |||
@@ -0,0 +1,622 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT x86 disassembler module. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- This is a helper module used by the LuaJIT machine code dumper module. | ||
8 | -- | ||
9 | -- Sending small code snippets to an external disassembler and mixing the | ||
10 | -- output with our own stuff was too fragile. So I had to bite the bullet | ||
11 | -- and write yet another x86 disassembler. Oh well ... | ||
12 | -- | ||
13 | -- The output format is very similar to what ndisasm generates. But it has | ||
14 | -- been developed independently by looking at the opcode tables from the | ||
15 | -- Intel and AMD manuals. The supported instruction set is quite extensive | ||
16 | -- and reflects what a current generation P4 or K8 implements in 32 bit | ||
17 | -- mode. Yes, this includes MMX, SSE, SSE2, SSE3, SSSE3 and even privileged | ||
18 | -- instructions. | ||
19 | -- | ||
20 | -- Notes: | ||
21 | -- * The (useless) a16 prefix, 3DNow and pre-586 opcodes are unsupported. | ||
22 | -- * No attempt at optimization has been made -- it's fast enough for my needs. | ||
23 | -- * The public API may change when more architectures are added. | ||
24 | -- | ||
25 | -- TODO: | ||
26 | -- * More testing with arbitrary x86 code (not just LuaJIT generated code). | ||
27 | -- * The output for a few MMX/SSE opcodes could be improved. | ||
28 | -- * Adding x64 support would be straightforward. | ||
29 | -- * Better input API (iterator) and output API (structured access to instr). | ||
30 | ------------------------------------------------------------------------------ | ||
31 | |||
32 | local type = type | ||
33 | local sub, byte, format = string.sub, string.byte, string.format | ||
34 | local match, gmatch, gsub = string.match, string.gmatch, string.gsub | ||
35 | |||
36 | -- Map for 1st opcode byte. Ugly? Well ... read on. | ||
37 | local map_opc1 = { | ||
38 | --0x | ||
39 | [0]="addBmr","addVmr","addBrm","addVrm","addBai","addVai","push es","pop es", | ||
40 | "orBmr","orVmr","orBrm","orVrm","orBai","orVai","push cs","opc2*", | ||
41 | --1x | ||
42 | "adcBmr","adcVmr","adcBrm","adcVrm","adcBai","adcVai","push ss","pop ss", | ||
43 | "sbbBmr","sbbVmr","sbbBrm","sbbVrm","sbbBai","sbbVai","push ds","pop ds", | ||
44 | --2x | ||
45 | "andBmr","andVmr","andBrm","andVrm","andBai","andVai","es:seg","daa", | ||
46 | "subBmr","subVmr","subBrm","subVrm","subBai","subVai","cs:seg","das", | ||
47 | --3x | ||
48 | "xorBmr","xorVmr","xorBrm","xorVrm","xorBai","xorVai","ss:seg","aaa", | ||
49 | "cmpBmr","cmpVmr","cmpBrm","cmpVrm","cmpBai","cmpVai","ds:seg","aas", | ||
50 | --4x | ||
51 | "incVR","incVR","incVR","incVR","incVR","incVR","incVR","incVR", | ||
52 | "decVR","decVR","decVR","decVR","decVR","decVR","decVR","decVR", | ||
53 | --5x | ||
54 | "pushVR","pushVR","pushVR","pushVR","pushVR","pushVR","pushVR","pushVR", | ||
55 | "popVR","popVR","popVR","popVR","popVR","popVR","popVR","popVR", | ||
56 | --6x | ||
57 | "pusha/pushaw","popa/popaw","boundVrm","arplWmr", | ||
58 | "fs:seg","gs:seg","o16:","a16", | ||
59 | "pushVi","imulVrmi","pushBs","imulVrms", | ||
60 | "insb","insd/insw","outsb","outsd/outsw", | ||
61 | --7x | ||
62 | "joBj","jnoBj","jbBj","jnbBj","jzBj","jnzBj","jbeBj","jaBj", | ||
63 | "jsBj","jnsBj","jpeBj","jpoBj","jlBj","jgeBj","jleBj","jgBj", | ||
64 | --8x | ||
65 | "arith!Bmi","arith!Vmi","arith!Bmi","arith!Vms", | ||
66 | "testBmr","testVmr","xchgBrm","xchgVrm", | ||
67 | "movBmr","movVmr","movBrm","movVrm", | ||
68 | "movVmg","leaVrm","movWgm","popVm", | ||
69 | --9x | ||
70 | "nop|pause|xchgWaR|repne nop","xchgVaR","xchgVaR","xchgVaR", | ||
71 | "xchgVaR","xchgVaR","xchgVaR","xchgVaR", | ||
72 | "cwde/cbw","cdq/cwd","call farViw","wait", | ||
73 | "pushf/pushfw","popf/popfw","sahf","lahf", | ||
74 | --Ax | ||
75 | "movBao","movVao","movBoa","movVoa", | ||
76 | "movsb","movsd/movsb","cmpsb","cmpsd/cmpsw", | ||
77 | "testBai","testVai","stosb","stosd/stosw", | ||
78 | "lodsb","lodsd/lodsw","scasb","scasd/scasw", | ||
79 | --Bx | ||
80 | "movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi","movBRi", | ||
81 | "movVRi","movVRi","movVRi","movVRi","movVRi","movVRi","movVRi","movVRi", | ||
82 | --Cx | ||
83 | "shift!Bmu","shift!Vmu","retBw","ret","lesVrm","ldsVrm","movBmi","movVmi", | ||
84 | "enterBwu","leave","retfBw","retf","int3","intBu","into","iret/iretw", | ||
85 | --Dx | ||
86 | "shift!Bm1","shift!Vm1","shift!Bmc","shift!Vmc","aamBu","aadBu","salc","xlatb", | ||
87 | "fp*0","fp*1","fp*2","fp*3","fp*4","fp*5","fp*6","fp*7", | ||
88 | --Ex | ||
89 | "loopneBj","loopeBj","loopBj","jecxz/jcxzBj","inBau","inVau","outBua","outVua", | ||
90 | "callDj","jmpDj","jmp farViw","jmpBj","inBad","inVad","outBda","outVda", | ||
91 | --Fx | ||
92 | "lock:","int1","repne:rep","rep:","hlt","cmc","testb!Bm","testv!Vm", | ||
93 | "clc","stc","cli","sti","cld","std","inc!Bm","inc!Vm", | ||
94 | } | ||
95 | assert(#map_opc1 == 255) | ||
96 | |||
97 | -- Map for 2nd opcode byte (0f xx). True CISC hell. Hey, I told you. | ||
98 | -- Prefix dependent MMX/SSE opcodes: (none)|rep|o16|repne | ||
99 | local map_opc2 = { | ||
100 | --0x | ||
101 | [0]="sldt!Dmp","sgdt!Dmp","larVrm","lslVrm",nil,"syscall","clts","sysret", | ||
102 | "invd","wbinvd",nil,"ud1",nil,"prefetch!Bm","femms","3dnowMrmu", | ||
103 | --1x | ||
104 | "movupsXrm|movssXrm|movupdXrm|movsdXrm", | ||
105 | "movupsXmr|movssXmr|movupdXmr|movsdXmr", | ||
106 | "movhlpsXrm|movsldupXrm|movlpdXrm|movddupXrm", -- TODO: movlpsXrMm (mem case). | ||
107 | "movlpsXmr||movlpdXmr", | ||
108 | "unpcklpsXrm||unpcklpdXrm", | ||
109 | "unpckhpsXrm||unpckhpdXrm", | ||
110 | "movlhpsXrm|movshdupXrm|movhpdXrm", -- TODO: movhpsXrMm (mem case). | ||
111 | "movhpsXmr||movhpdXmr", | ||
112 | "prefetcht!Bm","hintnopBm","hintnopBm","hintnopBm", | ||
113 | "hintnopBm","hintnopBm","hintnopBm","hintnopBm", | ||
114 | --2x | ||
115 | "movDmx","movDmy","movDxm","movDym","movDmz",nil,"movDzm",nil, | ||
116 | "movapsXrm||movapdXrm", | ||
117 | "movapsXmr||movapdXmr", | ||
118 | "cvtpi2psXrMm|cvtsi2ssXrDm|cvtpi2pdXrMm|cvtsi2sdXrDm", | ||
119 | "movntpsXmr||movntpdXmr", | ||
120 | "cvttps2piMrXm|cvttss2siDrXm|cvttpd2piMrXm|cvttsd2siDrXm", | ||
121 | "cvtps2piMrXm|cvtss2siDrXm|cvtpd2piMrXm|cvtsd2siDrXm", | ||
122 | "ucomissXrm||ucomisdXrm", | ||
123 | "comissXrm||comisdXrm", | ||
124 | --3x | ||
125 | "wrmsr","rdtsc","rdmsr","rdpmc","sysenter","sysexit",nil,nil, | ||
126 | "ssse3*38",nil,"ssse3*3a",nil,nil,nil,nil,nil, | ||
127 | --4x | ||
128 | "cmovoVrm","cmovnoVrm","cmovbVrm","cmovnbVrm", | ||
129 | "cmovzVrm","cmovnzVrm","cmovbeVrm","cmovaVrm", | ||
130 | "cmovsVrm","cmovnsVrm","cmovpeVrm","cmovpoVrm", | ||
131 | "cmovlVrm","cmovgeVrm","cmovleVrm","cmovgVrm", | ||
132 | --5x | ||
133 | "movmskpsDrXm||movmskpdDrXm","sqrtpsXrm|sqrtssXrm|sqrtpdXrm|sqrtsdXrm", | ||
134 | "rsqrtpsXrm|rsqrtssXrm","rcppsXrm|rcpssXrm", | ||
135 | "andpsXrm||andpdXrm","andnpsXrm||andnpdXrm", | ||
136 | "orpsXrm||orpdXrm","xorpsXrm||xorpdXrm", | ||
137 | "addpsXrm|addssXrm|addpdXrm|addsdXrm","mulpsXrm|mulssXrm|mulpdXrm|mulsdXrm", | ||
138 | "cvtps2pdXrm|cvtss2sdXrm|cvtpd2psXrm|cvtsd2ssXrm", | ||
139 | "cvtdq2psXrm|cvttps2dqXrm|cvtps2dqXrm", | ||
140 | "subpsXrm|subssXrm|subpdXrm|subsdXrm","minpsXrm|minssXrm|minpdXrm|minsdXrm", | ||
141 | "divpsXrm|divssXrm|divpdXrm|divsdXrm","maxpsXrm|maxssXrm|maxpdXrm|maxsdXrm", | ||
142 | --6x | ||
143 | "punpcklbwMrm||punpcklbqXrm","punpcklwdPrm","punpckldqPrm","packsswbPrm", | ||
144 | "pcmpgtbPrm","pcmpgtwPrm","pcmpgtdPrm","packuswbPrm", | ||
145 | "punpckhbwPrm","punpckhwdPrm","punpckhdqPrm","packssdwPrm", | ||
146 | "||punpcklqdqXrm","||punpckhqdqXrm", | ||
147 | "movdPrDm","movqMrm|movdquXrm|movdqaXrm", | ||
148 | --7x | ||
149 | "pshufwPrmu","pshiftw!Pmu","pshiftd!Pmu","pshiftq!Mmu||pshiftdq!Xmu", | ||
150 | "pcmpeqbPrm","pcmpeqwPrm","pcmpeqdPrm","emms|", | ||
151 | nil,nil,nil,nil, | ||
152 | "||haddpdXrm|haddpsXrm","||hsubpdXrm|hsubpsXrm", | ||
153 | "movdDmMr|movqXrm|movdDmXr","movqMmr|movdquXmr|movdqaXmr", | ||
154 | --8x | ||
155 | "joVj","jnoVj","jbVj","jnbVj","jzVj","jnzVj","jbeVj","jaVj", | ||
156 | "jsVj","jnsVj","jpeVj","jpoVj","jlVj","jgeVj","jleVj","jgVj", | ||
157 | --9x | ||
158 | "setoBm","setnoBm","setbBm","setnbBm","setzBm","setnzBm","setbeBm","setaBm", | ||
159 | "setsBm","setnsBm","setpeBm","setpoBm","setlBm","setgeBm","setleBm","setgBm", | ||
160 | --Ax | ||
161 | "push fs","pop fs","cpuid","btVmr","shldVmru","shldVmrc",nil,nil, | ||
162 | "push gs","pop gs","rsm","btsVmr","shrdVmru","shrdVmrc","fxsave!Dmp","imulVrm", | ||
163 | --Bx | ||
164 | "cmpxchgBmr","cmpxchgVmr","lssVrm","btrVmr", | ||
165 | "lfsVrm","lgsVrm","movzxVrBm","movzxDrWm", | ||
166 | nil,"ud2","bt!Vmu","btcVmr", | ||
167 | "bsfVrm","bsrVrm","movsxVrBm","movsxDrWm", | ||
168 | --Cx | ||
169 | "xaddBmr","xaddVmr", | ||
170 | "cmppsXrmu|cmpssXrmu|cmppdXrmu|cmpsdXrmu","movntiDmr|", | ||
171 | "pinsrwPrWmu","pextrwDrPmu", | ||
172 | "shufpsXrmu||shufpdXrmu","cmpxchg!Dmp", | ||
173 | "bswapDR","bswapDR","bswapDR","bswapDR","bswapDR","bswapDR","bswapDR","bswapDR", | ||
174 | --Dx | ||
175 | "||addsubpdXrm|addsubpsXrm","psrlwPrm","psrldPrm","psrlqPrm", | ||
176 | "paddqPrm","pmullwPrm", | ||
177 | "|movq2dqXrMm|movqXmr|movdq2qMrXm","pmovmskbDrPm", | ||
178 | "psubusbPrm","psubuswPrm","pminubPrm","pandPrm", | ||
179 | "paddusbPrm","padduswPrm","pmaxubPrm","pandnPrm", | ||
180 | --Ex | ||
181 | "pavgbPrm","psrawPrm","psradPrm","pavgwPrm", | ||
182 | "pmulhuwPrm","pmulhwPrm", | ||
183 | "|cvtdq2pdXrm|cvttpd2dqXrm|cvtpd2dqXrm","movntqMmr||movntdqXmr", | ||
184 | "psubsbPrm","psubswPrm","pminswPrm","porPrm", | ||
185 | "paddsbPrm","paddswPrm","pmaxswPrm","pxorPrm", | ||
186 | --Fx | ||
187 | "|||lddquXrm","psllwPrm","pslldPrm","psllqPrm", | ||
188 | "pmuludqPrm","pmaddwdPrm","psadbwPrm","maskmovqMrm||maskmovdquXrm", | ||
189 | "psubbPrm","psubwPrm","psubdPrm","psubqPrm", | ||
190 | "paddbPrm","paddwPrm","padddPrm","ud", | ||
191 | } | ||
192 | assert(map_opc2[255] == "ud") | ||
193 | |||
194 | -- Map for SSSE3 opcodes. | ||
195 | local map_ssse3 = { | ||
196 | ["38"] = { -- [66] 0f 38 xx | ||
197 | --0x | ||
198 | [0]="pshufbPrm","phaddwPrm","phadddPrm","phaddswPrm", | ||
199 | "pmaddubswPrm","phsubwPrm","phsubdPrm","phsubswPrm", | ||
200 | "psignbPrm","psignwPrm","psigndPrm","pmulhrswPrm", | ||
201 | nil,nil,nil,nil, | ||
202 | --1x | ||
203 | nil,nil,nil,nil,nil,nil,nil,nil, | ||
204 | nil,nil,nil,nil,"pabsbPrm","pabswPrm","pabsdPrm",nil, | ||
205 | }, | ||
206 | ["3a"] = { -- [66] 0f 3a xx | ||
207 | [0x0f] = "palignrPrmu", | ||
208 | }, | ||
209 | } | ||
210 | |||
211 | -- Map for FP opcodes. And you thought stack machines are simple? | ||
212 | local map_opcfp = { | ||
213 | -- D8-DF 00-BF: opcodes with a memory operand. | ||
214 | -- D8 | ||
215 | [0]="faddFm","fmulFm","fcomFm","fcompFm","fsubFm","fsubrFm","fdivFm","fdivrFm", | ||
216 | "fldFm",nil,"fstFm","fstpFm","fldenvDmp","fldcwWm","fnstenvDmp","fnstcwWm", | ||
217 | -- DA | ||
218 | "fiaddDm","fimulDm","ficomDm","ficompDm", | ||
219 | "fisubDm","fisubrDm","fidivDm","fidivrDm", | ||
220 | -- DB | ||
221 | "fildDm","fisttpDm","fistDm","fistpDm",nil,"fld twordFmp",nil,"fstp twordFmp", | ||
222 | -- DC | ||
223 | "faddGm","fmulGm","fcomGm","fcompGm","fsubGm","fsubrGm","fdivGm","fdivrGm", | ||
224 | -- DD | ||
225 | "fldGm","fisttpQm","fstGm","fstpGm","frstorDmp",nil,"fnsaveDmp","fnstswWm", | ||
226 | -- DE | ||
227 | "fiaddWm","fimulWm","ficomWm","ficompWm", | ||
228 | "fisubWm","fisubrWm","fidivWm","fidivrWm", | ||
229 | -- DF | ||
230 | "fildWm","fisttpWm","fistWm","fistpWm", | ||
231 | "fbld twordFmp","fildQm","fbstp twordFmp","fistpQm", | ||
232 | -- xx C0-FF: opcodes with a pseudo-register operand. | ||
233 | -- D8 | ||
234 | "faddFf","fmulFf","fcomFf","fcompFf","fsubFf","fsubrFf","fdivFf","fdivrFf", | ||
235 | -- D9 | ||
236 | "fldFf","fxchFf",{"fnop"},nil, | ||
237 | {"fchs","fabs",nil,nil,"ftst","fxam"}, | ||
238 | {"fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz"}, | ||
239 | {"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp"}, | ||
240 | {"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"}, | ||
241 | -- DA | ||
242 | "fcmovbFf","fcmoveFf","fcmovbeFf","fcmovuFf",nil,{nil,"fucompp"},nil,nil, | ||
243 | -- DB | ||
244 | "fcmovnbFf","fcmovneFf","fcmovnbeFf","fcmovnuFf", | ||
245 | {nil,nil,"fnclex","fninit"},"fucomiFf","fcomiFf",nil, | ||
246 | -- DC | ||
247 | "fadd toFf","fmul toFf",nil,nil, | ||
248 | "fsub toFf","fsubr toFf","fdivr toFf","fdiv toFf", | ||
249 | -- DD | ||
250 | "ffreeFf",nil,"fstFf","fstpFf","fucomFf","fucompFf",nil,nil, | ||
251 | -- DE | ||
252 | "faddpFf","fmulpFf",nil,{nil,"fcompp"}, | ||
253 | "fsubrpFf","fsubpFf","fdivrpFf","fdivpFf", | ||
254 | -- DF | ||
255 | nil,nil,nil,nil,{"fnstsw ax"},"fucomipFf","fcomipFf",nil, | ||
256 | } | ||
257 | assert(map_opcfp[126] == "fcomipFf") | ||
258 | |||
259 | -- Map for opcode groups. The subkey is sp from the ModRM byte. | ||
260 | local map_opcgroup = { | ||
261 | arith = { "add", "or", "adc", "sbb", "and", "sub", "xor", "cmp" }, | ||
262 | shift = { "rol", "ror", "rcl", "rcr", "shl", "shr", "sal", "sar" }, | ||
263 | testb = { "testBmi", "testBmi", "not", "neg", "mul", "imul", "div", "idiv" }, | ||
264 | testv = { "testVmi", "testVmi", "not", "neg", "mul", "imul", "div", "idiv" }, | ||
265 | inc = { "inc", "dec", "callDmp", "call farDmp", | ||
266 | "jmpDmp", "jmp farDmp", "push" }, | ||
267 | sldt = { "sldt", "str", "lldt", "ltr", "verr", "verw" }, | ||
268 | sgdt = { "sgdt", "sidt", "lgdt", "lidt", "smsw", nil, "lmsw", "invlpg" }, | ||
269 | bt = { nil, nil, nil, nil, "bt", "bts", "btr", "btc" }, | ||
270 | cmpxchg = { nil, "cmpxchg8b" }, | ||
271 | pshiftw = { nil, nil, "psrlw", nil, "psraw", nil, "psllw" }, | ||
272 | pshiftd = { nil, nil, "psrld", nil, "psrad", nil, "pslld" }, | ||
273 | pshiftq = { nil, nil, "psrlq", nil, nil, nil, "psllq" }, | ||
274 | pshiftdq = { nil, nil, "psrlq", "psrldq", nil, nil, "psllq", "pslldq" }, | ||
275 | fxsave = { "fxsave", "fxrstor", "ldmxcsr", "stmxcsr", | ||
276 | nil, "lfenceDp", "mfenceDp", "sfenceDp" }, -- TODO: clflush. | ||
277 | prefetch = { "prefetch", "prefetchw" }, | ||
278 | prefetcht = { "prefetchnta", "prefetcht0", "prefetcht1", "prefetcht2" }, | ||
279 | } | ||
280 | |||
281 | ------------------------------------------------------------------------------ | ||
282 | |||
283 | -- Maps for register names. | ||
284 | local map_aregs = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" } | ||
285 | local map_regs = { | ||
286 | B = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" }, | ||
287 | W = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" }, | ||
288 | D = map_aregs, | ||
289 | M = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }, | ||
290 | X = { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7" }, | ||
291 | } | ||
292 | local map_segregs = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" } | ||
293 | |||
294 | -- Maps for size names. | ||
295 | local map_sz2n = { | ||
296 | B = 1, W = 2, D = 4, Q = 8, M = 8, X = 16, | ||
297 | } | ||
298 | local map_sz2prefix = { | ||
299 | B = "byte", W = "word", D = "dword", | ||
300 | Q = "qword", -- No associated reg in 32 bit mode. | ||
301 | F = "dword", G = "qword", -- No need for sizes/register names for these two. | ||
302 | M = "qword", X = "xword", | ||
303 | } | ||
304 | |||
305 | ------------------------------------------------------------------------------ | ||
306 | |||
307 | -- Output a nicely formatted line with an opcode and operands. | ||
308 | local function putop(ctx, text, operands) | ||
309 | local code, pos, hex = ctx.code, ctx.pos, "" | ||
310 | for i=ctx.start,pos-1 do | ||
311 | hex = hex..format("%02X", byte(code, i, i)) | ||
312 | end | ||
313 | if #hex > 16 then hex = sub(hex, 1, 16).."." end | ||
314 | if operands then text = text.." "..operands end | ||
315 | if ctx.o16 then text = "o16 "..text; ctx.o16 = false end | ||
316 | if ctx.rep then text = ctx.rep.." "..text; ctx.rep = false end | ||
317 | if ctx.seg then | ||
318 | local text2, n = gsub(text, "%[", "["..ctx.seg..":") | ||
319 | if n == 0 then text = ctx.seg.." "..text else text = text2 end | ||
320 | ctx.seg = false | ||
321 | end | ||
322 | if ctx.lock then text = "lock "..text; ctx.lock = false end | ||
323 | local imm = ctx.imm | ||
324 | if imm then | ||
325 | local sym = ctx.symtab[imm] | ||
326 | if sym then text = text.."\t->"..sym end | ||
327 | end | ||
328 | ctx.out(format("%08x %-18s%s\n", ctx.addr+ctx.start, hex, text)) | ||
329 | ctx.mrm = false | ||
330 | ctx.start = pos | ||
331 | ctx.imm = nil | ||
332 | end | ||
333 | |||
334 | -- Fallback for incomplete opcodes at the end. | ||
335 | local function incomplete(ctx) | ||
336 | ctx.pos = ctx.stop+1 | ||
337 | ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false | ||
338 | return putop(ctx, "(incomplete)") | ||
339 | end | ||
340 | |||
341 | -- Fallback for unknown opcodes. | ||
342 | local function unknown(ctx) | ||
343 | ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false | ||
344 | return putop(ctx, "(unknown)") | ||
345 | end | ||
346 | |||
347 | -- Return an immediate of the specified size. | ||
348 | local function getimm(ctx, pos, n) | ||
349 | if pos+n-1 > ctx.stop then return incomplete(ctx) end | ||
350 | local code = ctx.code | ||
351 | if n == 1 then | ||
352 | local b1 = byte(code, pos, pos) | ||
353 | return b1 | ||
354 | elseif n == 2 then | ||
355 | local b1, b2 = byte(code, pos, pos+1) | ||
356 | return b1+b2*256 | ||
357 | else | ||
358 | local b1, b2, b3, b4 = byte(code, pos, pos+3) | ||
359 | local imm = b1+b2*256+b3*65536+b4*16777216 | ||
360 | ctx.imm = imm | ||
361 | return imm | ||
362 | end | ||
363 | end | ||
364 | |||
365 | -- Process pattern string and generate the operands. | ||
366 | local function putpat(ctx, name, pat) | ||
367 | local operands, regs, sz, mode, sp, rm, sc, rx, disp, sdisp | ||
368 | local code, pos, stop = ctx.code, ctx.pos, ctx.stop | ||
369 | |||
370 | -- Chars used: 1DFGMPQRVWXacdfgijmoprsuwxyz | ||
371 | for p in gmatch(pat, ".") do | ||
372 | local x = nil | ||
373 | if p == "V" then | ||
374 | sz = ctx.o16 and "W" or "D"; ctx.o16 = false | ||
375 | regs = map_regs[sz] | ||
376 | elseif match(p, "[BWDQFGMX]") then | ||
377 | sz = p | ||
378 | regs = map_regs[sz] | ||
379 | elseif p == "P" then | ||
380 | sz = ctx.o16 and "X" or "M"; ctx.o16 = false | ||
381 | regs = map_regs[sz] | ||
382 | elseif p == "s" then | ||
383 | local imm = getimm(ctx, pos, 1); if not imm then return end | ||
384 | x = imm <= 127 and format("byte +0x%02x", imm) | ||
385 | or format("byte -0x%02x", 256-imm) | ||
386 | pos = pos+1 | ||
387 | elseif p == "u" then | ||
388 | local imm = getimm(ctx, pos, 1); if not imm then return end | ||
389 | x = format("0x%02x", imm) | ||
390 | pos = pos+1 | ||
391 | elseif p == "w" then | ||
392 | local imm = getimm(ctx, pos, 2); if not imm then return end | ||
393 | x = format("0x%x", imm) | ||
394 | pos = pos+2 | ||
395 | elseif p == "o" then -- [offset] | ||
396 | local imm = getimm(ctx, pos, 4); if not imm then return end | ||
397 | x = format("[0x%08x]", imm) | ||
398 | pos = pos+4 | ||
399 | elseif p == "i" then | ||
400 | local n = map_sz2n[sz] | ||
401 | local imm = getimm(ctx, pos, n); if not imm then return end | ||
402 | x = format(imm > 65535 and "0x%08x" or "0x%x", imm) | ||
403 | pos = pos+n | ||
404 | elseif p == "j" then | ||
405 | local n = map_sz2n[sz] | ||
406 | local imm = getimm(ctx, pos, n); if not imm then return end | ||
407 | if sz == "B" and imm > 127 then imm = imm-256 | ||
408 | elseif imm > 2147483647 then imm = imm-4294967296 end | ||
409 | pos = pos+n | ||
410 | imm = imm + pos + ctx.addr | ||
411 | ctx.imm = imm | ||
412 | x = sz == "W" and format("word 0x%04x", imm%65536) | ||
413 | or format("0x%08x", imm) | ||
414 | elseif p == "R" then x = regs[byte(code, pos-1, pos-1)%8+1] | ||
415 | elseif p == "a" then x = regs[1] | ||
416 | elseif p == "c" then x = "cl" | ||
417 | elseif p == "d" then x = "dx" | ||
418 | elseif p == "1" then x = "1" | ||
419 | else | ||
420 | if not mode then | ||
421 | mode = ctx.mrm | ||
422 | if not mode then | ||
423 | if pos > stop then return incomplete(ctx) end | ||
424 | mode = byte(code, pos, pos) | ||
425 | pos = pos+1 | ||
426 | end | ||
427 | rm = mode%8; mode = (mode-rm)/8 | ||
428 | sp = mode%8; mode = (mode-sp)/8 | ||
429 | sdisp = "" | ||
430 | if mode < 3 then | ||
431 | if rm == 4 then | ||
432 | if pos > stop then return incomplete(ctx) end | ||
433 | sc = byte(code, pos, pos) | ||
434 | pos = pos+1 | ||
435 | rm = sc%8; sc = (sc-rm)/8 | ||
436 | rx = sc%8; sc = (sc-rx)/8 | ||
437 | if rx == 4 then rx = nil end | ||
438 | end | ||
439 | if mode > 0 or rm == 5 then | ||
440 | local dsz = mode | ||
441 | if dsz ~= 1 then dsz = 4 end | ||
442 | disp = getimm(ctx, pos, dsz); if not disp then return end | ||
443 | sdisp = (dsz == 4 or disp <= 127) and | ||
444 | format(disp > 65535 and "+0x%08x" or "+0x%x", disp) or | ||
445 | format("-0x%x", 256-disp) | ||
446 | pos = pos+dsz | ||
447 | end | ||
448 | end | ||
449 | end | ||
450 | if p == "m" then | ||
451 | if mode == 3 then x = regs[rm+1] | ||
452 | else | ||
453 | local srm, srx = map_aregs[rm+1], "" | ||
454 | if rx then | ||
455 | srm = srm.."+" | ||
456 | srx = map_aregs[rx+1] | ||
457 | if sc > 0 then srx = srx.."*"..(2^sc) end | ||
458 | end | ||
459 | if mode == 0 and rm == 5 then | ||
460 | srm = "" | ||
461 | sdisp = format("%s0x%08x", rx and "+" or "", disp) | ||
462 | end | ||
463 | x = format("[%s%s%s]", srm, srx, sdisp) | ||
464 | end | ||
465 | if mode < 3 and | ||
466 | (not match(pat, "[aRrgp]") or | ||
467 | name == "movzx" or name == "movsx") then -- Yuck. | ||
468 | x = map_sz2prefix[sz].." "..x | ||
469 | end | ||
470 | elseif p == "r" then x = regs[sp+1] | ||
471 | elseif p == "g" then x = map_segregs[sp+1] | ||
472 | elseif p == "p" then -- Suppress prefix. | ||
473 | elseif p == "f" then x = "st"..rm | ||
474 | elseif p == "x" then x = "CR"..sp | ||
475 | elseif p == "y" then x = "DR"..sp | ||
476 | elseif p == "z" then x = "TR"..sp | ||
477 | else | ||
478 | error("bad pattern `"..pat.."'") | ||
479 | end | ||
480 | end | ||
481 | if x then operands = operands and operands..","..x or x end | ||
482 | end | ||
483 | ctx.pos = pos | ||
484 | return putop(ctx, name, operands) | ||
485 | end | ||
486 | |||
487 | -- Forward declaration. | ||
488 | local map_act | ||
489 | |||
490 | -- Get a pattern from an opcode map and dispatch to handler. | ||
491 | local function opcdispatch(ctx, opcmap) | ||
492 | local pos = ctx.pos | ||
493 | local opat = opcmap[byte(ctx.code, pos, pos)] | ||
494 | if not opat then return unknown(ctx) end | ||
495 | if match(opat, "%|") then -- MMX/SSE variants depending on prefix. | ||
496 | local p | ||
497 | if ctx.rep then p = ctx.rep=="rep" and "%|([^%|]*)" or "%|.-%|.-%|([^%|]*)" | ||
498 | elseif ctx.o16 then p = "%|.-%|([^%|]*)" | ||
499 | else p = "^[^%|]*" end | ||
500 | opat = match(opat, p) | ||
501 | if not opat or opat == "" then return unknown(ctx) end | ||
502 | ctx.rep = false; ctx.o16 = false | ||
503 | end | ||
504 | local name, pat, act = match(opat, "^([a-z0-9 ]*)((.?).*)") | ||
505 | ctx.pos = pos + 1 | ||
506 | return map_act[act](ctx, name, pat) | ||
507 | end | ||
508 | |||
509 | -- Map for action codes. The key is the first char after the name. | ||
510 | map_act = { | ||
511 | -- Simple opcodes without operands. | ||
512 | [""] = function(ctx, name, pat) | ||
513 | return putop(ctx, name) | ||
514 | end, | ||
515 | |||
516 | -- Operand size chars fall right through. | ||
517 | B = putpat, W = putpat, D = putpat, V = putpat, | ||
518 | F = putpat, G = putpat, | ||
519 | M = putpat, X = putpat, P = putpat, | ||
520 | |||
521 | -- Collect prefixes. | ||
522 | [":"] = function(ctx, name, pat) | ||
523 | ctx[pat == ":" and name or sub(pat, 2)] = name | ||
524 | end, | ||
525 | |||
526 | -- Select alternate opcode name when prefixed with o16. | ||
527 | ["/"] = function(ctx, name, pat) | ||
528 | local wname, rpat = match(pat, "^/([a-z0-9 ]+)(.*)") | ||
529 | if ctx.o16 then name = wname; ctx.o16 = false end | ||
530 | return putpat(ctx, name, rpat) | ||
531 | end, | ||
532 | |||
533 | -- Chain to special handler specified by name. | ||
534 | ["*"] = function(ctx, name, pat) | ||
535 | return map_act[name](ctx, name, sub(pat, 2)) | ||
536 | end, | ||
537 | |||
538 | -- Use named subtable for opcode group. | ||
539 | ["!"] = function(ctx, name, pat) | ||
540 | |||
541 | local pos = ctx.pos | ||
542 | if pos > ctx.stop then return incomplete(ctx) end | ||
543 | local mrm = byte(ctx.code, pos, pos) | ||
544 | ctx.pos = pos+1 | ||
545 | ctx.mrm = mrm | ||
546 | |||
547 | local opat = map_opcgroup[name][((mrm-(mrm%8))/8)%8+1] | ||
548 | if not opat then return unknown(ctx) end | ||
549 | local name, pat2 = match(opat, "^([a-z0-9 ]*)(.*)") | ||
550 | return putpat(ctx, name, pat2 ~= "" and pat2 or sub(pat, 2)) | ||
551 | end, | ||
552 | |||
553 | -- Two-byte opcode dispatch. | ||
554 | opc2 = function(ctx, name, pat) | ||
555 | return opcdispatch(ctx, map_opc2) | ||
556 | end, | ||
557 | |||
558 | -- SSSE3 dispatch. | ||
559 | ssse3 = function(ctx, name, pat) | ||
560 | return opcdispatch(ctx, map_ssse3[pat]) | ||
561 | end, | ||
562 | |||
563 | -- Floating point opcode dispatch. | ||
564 | fp = function(ctx, name, pat) | ||
565 | |||
566 | local pos = ctx.pos | ||
567 | if pos > ctx.stop then return incomplete(ctx) end | ||
568 | local mrm = byte(ctx.code, pos, pos) | ||
569 | ctx.pos = pos+1 | ||
570 | ctx.mrm = mrm | ||
571 | |||
572 | local rm = mrm%8 | ||
573 | local idx = pat*8 + ((mrm-rm)/8)%8 | ||
574 | if mrm >= 192 then idx = idx + 64 end | ||
575 | local opat = map_opcfp[idx] | ||
576 | if type(opat) == "table" then opat = opat[rm+1] end | ||
577 | if not opat then return unknown(ctx) end | ||
578 | local name, pat2 = match(opat, "^([a-z0-9 ]*)(.*)") | ||
579 | return putpat(ctx, name, pat2) | ||
580 | end, | ||
581 | } | ||
582 | |||
583 | ------------------------------------------------------------------------------ | ||
584 | |||
585 | -- Disassemble a block of code. | ||
586 | local function disass_block(ctx, ofs, len) | ||
587 | if not ofs then ofs = 0 end | ||
588 | local stop = len and ofs+len or #ctx.code | ||
589 | ofs = ofs + 1 | ||
590 | ctx.start = ofs | ||
591 | ctx.pos = ofs | ||
592 | ctx.stop = stop | ||
593 | ctx.imm = nil | ||
594 | ctx.mrm = false | ||
595 | ctx.o16 = false; ctx.seg = false; ctx.lock = false; ctx.rep = false | ||
596 | while ctx.pos <= stop do opcdispatch(ctx, map_opc1) end | ||
597 | if ctx.pos ~= ctx.start then incomplete(ctx) end | ||
598 | end | ||
599 | |||
600 | -- Extended API: create a disassembler context. Then call ctx:disass(ofs, len). | ||
601 | local function create_(code, addr, out) | ||
602 | local ctx = {} | ||
603 | ctx.code = code | ||
604 | ctx.addr = (addr or 0) - 1 | ||
605 | ctx.out = out or io.write | ||
606 | ctx.symtab = {} | ||
607 | ctx.disass = disass_block | ||
608 | return ctx | ||
609 | end | ||
610 | |||
611 | -- Simple API: disassemble code (a string) at address and output via out. | ||
612 | local function disass_(code, addr, out) | ||
613 | create_(code, addr, out):disass() | ||
614 | end | ||
615 | |||
616 | |||
617 | -- Public module functions. | ||
618 | module(...) | ||
619 | |||
620 | create = create_ | ||
621 | disass = disass_ | ||
622 | |||
diff --git a/libraries/LuaJIT-1.1.7/jit/dump.lua b/libraries/LuaJIT-1.1.7/jit/dump.lua new file mode 100644 index 0000000..2287c23 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/dump.lua | |||
@@ -0,0 +1,265 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT machine code dumper module. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- Activate this module to dump the machine code for all functions | ||
8 | -- immediately after they have been compiled. The disassembler | ||
9 | -- output is mixed with the bytecode listing. | ||
10 | -- | ||
11 | -- Try: luajit -j dump -e 'print "foo"' | ||
12 | -- luajit -j dump=foo.dump foo.lua | ||
13 | -- luajit -j off -j dump -e 'jit.compile(assert(loadfile"foo.lua")))' | ||
14 | -- | ||
15 | -- Default output is to stderr. To redirect output to a file, | ||
16 | -- pass a filename as an argument or set the environment variable | ||
17 | -- "LUAJIT_DUMPFILE". | ||
18 | -- Note: The file is overwritten each time you run luajit. | ||
19 | -- | ||
20 | -- TODO: Find a way to be more selective on what to dump. | ||
21 | ------------------------------------------------------------------------------ | ||
22 | |||
23 | -- Priority for compiler pipeline. Must run after backend (negative) | ||
24 | -- and should be even because we only catch successful compiles. | ||
25 | local PRIORITY = -98 | ||
26 | |||
27 | -- Cache some library functions and objects. | ||
28 | local jit = require("jit") | ||
29 | assert(jit.version_num == 10107, "LuaJIT core/library version mismatch") | ||
30 | local jutil = require("jit.util") | ||
31 | local type, format, gsub = type, string.format, string.gsub | ||
32 | local bytecode, const = jutil.bytecode, jutil.const | ||
33 | local getinfo = debug.getinfo | ||
34 | local stdout, stderr = io.stdout, io.stderr | ||
35 | |||
36 | -- Load the right disassembler. | ||
37 | local dis = require("jit.dis_"..jit.arch) | ||
38 | local discreate, disass_ = dis.create, dis.disass | ||
39 | |||
40 | -- Turn compilation off for the whole module. LuaJIT would do that anyway. | ||
41 | jit.off(true, true) | ||
42 | |||
43 | -- Separator line. | ||
44 | local sepline = "-------------------------------" | ||
45 | |||
46 | -- Map JSUB indices to names. | ||
47 | -- CHECK: must match the order in ljit_x86.h. Regenerate with: | ||
48 | -- grep '^ *JSUB_[^_].*,' ljit_x86.h | sed -e 's/^ *JSUB_/ "/' -e 's/,.*/",/' | ||
49 | local jsubnames = { | ||
50 | "STACKPTR", | ||
51 | "GATE_LJ", | ||
52 | "GATE_JL", | ||
53 | "GATE_JC", | ||
54 | "GROW_STACK", | ||
55 | "GROW_CI", | ||
56 | "GATE_JC_PATCH", | ||
57 | "GATE_JC_DEBUG", | ||
58 | "DEOPTIMIZE_CALLER", | ||
59 | "DEOPTIMIZE", | ||
60 | "DEOPTIMIZE_OPEN", | ||
61 | "HOOKINS", | ||
62 | "GCSTEP", | ||
63 | "STRING_SUB3", | ||
64 | "STRING_SUB2", | ||
65 | "HOOKCALL", | ||
66 | "HOOKRET", | ||
67 | "METACALL", | ||
68 | "METATAILCALL", | ||
69 | "BARRIERF", | ||
70 | "GETGLOBAL", | ||
71 | "GETTABLE_KSTR", | ||
72 | "GETTABLE_STR", | ||
73 | "BARRIERBACK", | ||
74 | "SETGLOBAL", | ||
75 | "SETTABLE_KSTR", | ||
76 | "SETTABLE_STR", | ||
77 | "GETTABLE_KNUM", | ||
78 | "GETTABLE_NUM", | ||
79 | "SETTABLE_KNUM", | ||
80 | "SETTABLE_NUM", | ||
81 | "LOG2_TWORD", | ||
82 | "CONCAT_STR2", | ||
83 | } | ||
84 | |||
85 | -- Generate map from JSUB addresses to JSUB names. | ||
86 | local jsubmap = {} | ||
87 | do | ||
88 | local jsubmcode = jutil.jsubmcode | ||
89 | for pc=0,100000 do | ||
90 | local addr = jsubmcode(pc) | ||
91 | if not addr then break end | ||
92 | jsubmap[addr] = jsubnames[pc+1] or "JSUB#"..pc | ||
93 | end | ||
94 | end | ||
95 | |||
96 | -- Pretty-print a constant. | ||
97 | local function conststr(func, idx) | ||
98 | local k = const(func, idx) | ||
99 | if k == nil then return "nil" | ||
100 | elseif k == true then return "true" | ||
101 | elseif k == false then return "false" | ||
102 | elseif type(k) == "string" then | ||
103 | if #k > 10 then return format('"%.10s"~', k) | ||
104 | else return '"'..k..'"' end | ||
105 | else return k.."" end | ||
106 | end | ||
107 | |||
108 | -- Pretty-print a bytecode instruction (one or two lines). | ||
109 | local function bytecodeout(out, func, pc) | ||
110 | local op, a, b, c = bytecode(func, pc) | ||
111 | if not op then | ||
112 | return true | ||
113 | elseif op == "JMP" then | ||
114 | out:write(format("\n--%04d-- JMP => %04d", pc, pc+1+b)) | ||
115 | elseif op == "FORLOOP" or op == "FORPREP" then | ||
116 | out:write(format("\n--%04d-- %-9s %3d => %04d", pc, op, a, pc+1+b)) | ||
117 | else | ||
118 | out:write(format("\n--%04d-- %-9s %3d %4s %4s", | ||
119 | pc, op, a, b or "", c or "")) | ||
120 | if b and b < 0 then out:write(" ; ", conststr(func, b)) end | ||
121 | if c and c < 0 then out:write(" ; ", conststr(func, c)) end | ||
122 | end | ||
123 | end | ||
124 | |||
125 | -- Dump machine code and mix it with the bytecode listing. | ||
126 | local function dumpfunc(func, out, deopt) | ||
127 | if not out then out = stderr end | ||
128 | local info = getinfo(func, "S") | ||
129 | |||
130 | -- Don't bother checking for the right blocks to dump. | ||
131 | -- Dump the main block (if not deopt) and always all deopt blocks. | ||
132 | for block=deopt and 2 or 1,1000000 do | ||
133 | local addr, code, mfmiter = jutil.mcode(func, block) | ||
134 | if not addr then | ||
135 | if code then return code end -- Not compiled: return status. | ||
136 | break -- No more blocks to dump. | ||
137 | end | ||
138 | |||
139 | -- Print header. | ||
140 | out:write(sepline, " ", info.source, ":", info.linedefined) | ||
141 | if block ~= 1 then out:write(" DEOPT block ", block) end | ||
142 | |||
143 | -- Create disassembler context. | ||
144 | local ctx = discreate(code, addr, function(s) out:write(s) end) | ||
145 | ctx.symtab = jsubmap | ||
146 | |||
147 | -- Dump an mcode block. | ||
148 | local pc, ofs = 1, 0 | ||
149 | local len, isdeopt = mfmiter() | ||
150 | if isdeopt then pc = len; len = 0 | ||
151 | elseif block ~= 1 then break end -- Stop before next main block. | ||
152 | for t, m in mfmiter do | ||
153 | if t == "COMBINE" then | ||
154 | bytecodeout(out, func, pc) | ||
155 | else | ||
156 | if len ~= 0 then | ||
157 | out:write("\n") | ||
158 | if len > 0 then | ||
159 | ctx:disass(ofs, len) | ||
160 | ofs = ofs + len | ||
161 | else | ||
162 | out:write(format("%08x ** deoptimized\n", addr+ofs)) | ||
163 | ofs = ofs - len | ||
164 | end | ||
165 | len = 0 | ||
166 | end | ||
167 | if type(t) == "number" then | ||
168 | if m then | ||
169 | if isdeopt then | ||
170 | pc = t - 1 | ||
171 | else | ||
172 | bytecodeout(out, func, pc) | ||
173 | len = -t | ||
174 | end | ||
175 | else | ||
176 | len = t | ||
177 | if bytecodeout(out, func, pc) then break end | ||
178 | end | ||
179 | end | ||
180 | end | ||
181 | pc = pc + 1 | ||
182 | end | ||
183 | if len and len ~= 0 then | ||
184 | out:write(sepline, " tail code\n") | ||
185 | ctx:disass(ofs, len) | ||
186 | end | ||
187 | end | ||
188 | |||
189 | -- Print footer. | ||
190 | out:write(sepline, "\n") | ||
191 | out:flush() | ||
192 | end | ||
193 | |||
194 | -- Dump the internal JIT subroutines. | ||
195 | local function dumpjsub_(out) | ||
196 | if not out then out = stderr end | ||
197 | local addr, code = jutil.jsubmcode() | ||
198 | |||
199 | -- Create disassembler context. | ||
200 | local ctx = discreate(code, addr, function(s) out:write(s) end) | ||
201 | ctx.symtab = jsubmap | ||
202 | |||
203 | -- Collect addresses and sort them. | ||
204 | local t = {} | ||
205 | for addr in pairs(jsubmap) do t[#t+1] = addr end | ||
206 | t[#t+1] = addr + #code | ||
207 | table.sort(t) | ||
208 | |||
209 | -- Go through the addresses in ascending order. | ||
210 | local ofs = addr | ||
211 | for i=2,#t do | ||
212 | local next = t[i] | ||
213 | out:write("\n->", jsubmap[ofs], ":\n") -- Output label for JSUB. | ||
214 | ctx:disass(ofs-addr, next-ofs) -- Disassemble corresponding code block. | ||
215 | ofs = next | ||
216 | end | ||
217 | out:flush() | ||
218 | end | ||
219 | |||
220 | |||
221 | -- Active flag and output file handle. | ||
222 | local active, out | ||
223 | |||
224 | -- Dump handler for compiler pipeline. | ||
225 | local function h_dump(st) | ||
226 | local ok, err = pcall(dumpfunc, st.func, out, st.deopt) | ||
227 | if not ok then | ||
228 | stderr:write("\nERROR: jit.dump disabled: ", err, "\n") | ||
229 | jit.attach(h_dump) -- Better turn ourselves off after a failure. | ||
230 | if out and out ~= stdout then out:close() end | ||
231 | out = nil | ||
232 | active = nil | ||
233 | end | ||
234 | end | ||
235 | |||
236 | -- Detach dump handler from compiler pipeline. | ||
237 | local function dumpoff() | ||
238 | if active then | ||
239 | active = false | ||
240 | jit.attach(h_dump) | ||
241 | if out and out ~= stdout then out:close() end | ||
242 | out = nil | ||
243 | end | ||
244 | end | ||
245 | |||
246 | -- Open the output file and attach dump handler to compiler pipeline. | ||
247 | local function dumpon(filename) | ||
248 | if active then dumpoff() end | ||
249 | local outfile = filename or os.getenv("LUAJIT_DUMPFILE") | ||
250 | out = outfile and (outfile == "-" and stdout or assert(io.open(outfile, "w"))) | ||
251 | jit.attach(h_dump, PRIORITY) | ||
252 | active = true | ||
253 | end | ||
254 | |||
255 | |||
256 | -- Public module functions. | ||
257 | module(...) | ||
258 | |||
259 | disass = disass_ | ||
260 | dump = dumpfunc | ||
261 | dumpjsub = dumpjsub_ | ||
262 | on = dumpon | ||
263 | off = dumpoff | ||
264 | start = dumpon -- For -j command line option. | ||
265 | |||
diff --git a/libraries/LuaJIT-1.1.7/jit/dumphints.lua b/libraries/LuaJIT-1.1.7/jit/dumphints.lua new file mode 100644 index 0000000..4a64676 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/dumphints.lua | |||
@@ -0,0 +1,239 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT hints dumper module. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- Activate this module to dump the bytecode and the hints from | ||
8 | -- the optimizer for all functions to be compiled. | ||
9 | -- | ||
10 | -- Try: luajit -O -j dumphints -e 'return 1' | ||
11 | -- | ||
12 | -- Default output is to stderr. To redirect output to a file, | ||
13 | -- pass a filename as an argument or set the environment variable | ||
14 | -- "LUAJIT_DUMPHINTSFILE". | ||
15 | -- Note: The file is overwritten each time you run luajit. | ||
16 | -- | ||
17 | -- TODO: Find a way to be more selective on what to dump. | ||
18 | ------------------------------------------------------------------------------ | ||
19 | |||
20 | -- Priority for compiler pipeline. Should run before backend (positive) | ||
21 | -- and should be even because we only catch successful compiles. | ||
22 | local PRIORITY = 10 | ||
23 | |||
24 | -- Cache some library functions and objects. | ||
25 | local jit = require("jit") | ||
26 | assert(jit.version_num == 10107, "LuaJIT core/library version mismatch") | ||
27 | local jutil = require("jit.util") | ||
28 | local type, pairs, format = type, pairs, string.format | ||
29 | local bytecode, const = jutil.bytecode, jutil.const | ||
30 | local hints, fhints = jutil.hints, jutil.fhints | ||
31 | local stdout, stderr = io.stdout, io.stderr | ||
32 | |||
33 | -- Turn compilation off for the whole module. LuaJIT would do that anyway. | ||
34 | jit.off(true, true) | ||
35 | |||
36 | -- Separator line. | ||
37 | local sepline = "-------------------------------" | ||
38 | |||
39 | |||
40 | -- Pretty-print a constant. | ||
41 | local function conststr(func, idx) | ||
42 | local k = const(func, idx) | ||
43 | if k == nil then return "nil" | ||
44 | elseif k == true then return "true" | ||
45 | elseif k == false then return "false" | ||
46 | elseif type(k) == "string" then | ||
47 | if #k > 10 then return format('"%.10s"~', k) | ||
48 | else return '"'..k..'"' end | ||
49 | else return k.."" end | ||
50 | end | ||
51 | |||
52 | -- Pretty-print a bytecode instruction. | ||
53 | local function bytecodeline(func, pc, flag) | ||
54 | local op, a, b, c = bytecode(func, pc) | ||
55 | if not op then return end | ||
56 | if op == "JMP" then | ||
57 | return format("\n%04d %s JMP => %04d", pc, flag, pc+1+b) | ||
58 | end | ||
59 | if op == "FORLOOP" or op == "FORPREP" then | ||
60 | return format("\n%04d %s %-9s %3d => %04d", pc, flag, op, a, pc+1+b) | ||
61 | end | ||
62 | local s = format("\n%04d %s %-9s %3d %4s %4s", | ||
63 | pc, flag, op, a, b or "", c or "") | ||
64 | if b and b < 0 then s = s.." ; "..conststr(func, b) end | ||
65 | if c and c < 0 then s = s.." ; "..conststr(func, c) end | ||
66 | return s | ||
67 | end | ||
68 | |||
69 | -- Precompute inverse hints table. | ||
70 | local invhints = {} | ||
71 | for k,v in pairs(hints) do invhints[v] = k end | ||
72 | |||
73 | -- The inverse resolver for inline functions is loaded on demand. | ||
74 | local getname | ||
75 | |||
76 | -- Helper functions to pretty-print hints. | ||
77 | local function typehint(h, v, st, pc) | ||
78 | if st[pc+hints.INLINE] then return "" end | ||
79 | local tp = type(v) | ||
80 | if tp == "function" then | ||
81 | tp = debug.getinfo(v, "S").what | ||
82 | elseif tp == "number" and v % 1 == 0 then | ||
83 | tp = "integer" | ||
84 | elseif v == false then | ||
85 | tp = "mixed" | ||
86 | end | ||
87 | return " #"..h.."("..tp..")" | ||
88 | end | ||
89 | |||
90 | local hintprint = { | ||
91 | COMBINE = function(h, v, st, pc) | ||
92 | if v == false then return "" end -- Dead instructions are already marked. | ||
93 | end, | ||
94 | TYPE = typehint, | ||
95 | TYPEKEY = typehint, | ||
96 | INLINE = function(h, v, st, pc) | ||
97 | if not getname then getname = require("jit.opt_inline").getname end | ||
98 | return " #INLINE("..getname(st[pc+hints.TYPE], v)..")" | ||
99 | end, | ||
100 | } | ||
101 | |||
102 | -- Generate range string from table: pc[-pc] [,...] | ||
103 | local function rangestring(t) | ||
104 | local s = "" | ||
105 | for i,range in ipairs(t) do | ||
106 | if i ~= 1 then s = s.."," end | ||
107 | local pc = range % 65536 | ||
108 | range = (range - pc) / 65536 | ||
109 | s = s..pc | ||
110 | if range ~= 0 then s = s..(-(pc+range)) end | ||
111 | end | ||
112 | return s | ||
113 | end | ||
114 | |||
115 | -- Dump instructions and hints for a (to be compiled) function. | ||
116 | local function dumphints(st, out) | ||
117 | if not out then out = stderr end | ||
118 | local func = st.func | ||
119 | local COMBINE = hints.COMBINE | ||
120 | |||
121 | -- Need to recompute branch targets (not part of hints). | ||
122 | local target = {} | ||
123 | for pc=1,1e6 do | ||
124 | local op, a, b, c = bytecode(func, pc) | ||
125 | if not op then break end | ||
126 | if op == "JMP" or op == "FORLOOP" then | ||
127 | local t = pc+1+b | ||
128 | if st[pc+COMBINE] ~= false then target[t] = true end | ||
129 | elseif op == "LOADBOOL" and c ~= 0 then | ||
130 | target[pc+2] = true | ||
131 | end | ||
132 | end | ||
133 | |||
134 | -- Map hints to bytecode instructions. | ||
135 | local hintstr = {} | ||
136 | for k,v in pairs(st) do | ||
137 | -- CHECK: must match hint shift in ljit_hints.h:JIT_H2NUM(). | ||
138 | if type(k) == "number" and k >= 65536 then | ||
139 | local pc = k % 65536 | ||
140 | if pc > 0 then | ||
141 | k = k - pc | ||
142 | local h = invhints[k] or (k/65536) | ||
143 | local hp = hintprint[h] | ||
144 | local s = hp and hp(h, v, st, pc) or (" #"..h) | ||
145 | local hs = hintstr[pc] | ||
146 | hintstr[pc] = hs and (hs..s) or s | ||
147 | end | ||
148 | end | ||
149 | end | ||
150 | |||
151 | -- Write header. | ||
152 | local info = debug.getinfo(func, "S") | ||
153 | out:write(sepline, " ", info.source, ":", info.linedefined) | ||
154 | |||
155 | -- Write function hints. | ||
156 | for k,v in pairs(fhints) do | ||
157 | if st[v] then out:write("\n#", k) end | ||
158 | end | ||
159 | |||
160 | -- Write instruction hints and bytecode. | ||
161 | local function dumprange(firstpc, lastpc) | ||
162 | for pc=firstpc,lastpc do | ||
163 | local prefix = " " | ||
164 | if st[pc+COMBINE] == false then prefix = "**" | ||
165 | elseif target[pc] then prefix = "=>" end | ||
166 | local line = bytecodeline(func, pc, prefix) | ||
167 | if not line then break end | ||
168 | local h = hintstr[pc] | ||
169 | if h then | ||
170 | out:write(format("%-40s %s", line, h)) | ||
171 | else | ||
172 | out:write(line) | ||
173 | end | ||
174 | end | ||
175 | end | ||
176 | |||
177 | -- Handle deoptimization range table. | ||
178 | local t = st.deopt | ||
179 | if t then | ||
180 | out:write(" DEOPT=", rangestring(t)) | ||
181 | for i,range in ipairs(t) do | ||
182 | if i ~= 1 then out:write("\n----") end | ||
183 | local pc = range % 65536 | ||
184 | range = (range - pc) / 65536 | ||
185 | dumprange(pc, pc+range) | ||
186 | end | ||
187 | else | ||
188 | dumprange(1, 1000000) | ||
189 | end | ||
190 | |||
191 | -- Write footer. | ||
192 | out:write("\n", sepline, "\n") | ||
193 | out:flush() | ||
194 | end | ||
195 | |||
196 | |||
197 | -- Active flag and output file handle. | ||
198 | local active, out | ||
199 | |||
200 | -- Dump hints handler for compiler pipeline. | ||
201 | local function h_dumphints(st) | ||
202 | local ok, err = pcall(dumphints, st, out) | ||
203 | if not ok then | ||
204 | stderr:write("\nERROR: jit.dumphints disabled: ", err, "\n") | ||
205 | jit.attach(h_dumphints) -- Better turn ourselves off after a failure. | ||
206 | if out and out ~= stdout then out:close() end | ||
207 | out = nil | ||
208 | active = nil | ||
209 | end | ||
210 | end | ||
211 | |||
212 | -- Detach dump handler from compiler pipeline. | ||
213 | local function dumphintsoff() | ||
214 | if active then | ||
215 | active = false | ||
216 | jit.attach(h_dumphints) | ||
217 | if out and out ~= stdout then out:close() end | ||
218 | out = nil | ||
219 | end | ||
220 | end | ||
221 | |||
222 | -- Open the output file and attach dump handler to compiler pipeline. | ||
223 | local function dumphintson(filename) | ||
224 | if active then dumphintsoff() end | ||
225 | local outfile = filename or os.getenv("LUAJIT_DUMPHINTSFILE") | ||
226 | out = outfile and (outfile == "-" and stdout or assert(io.open(outfile, "w"))) | ||
227 | jit.attach(h_dumphints, PRIORITY) | ||
228 | active = true | ||
229 | end | ||
230 | |||
231 | |||
232 | -- Public module functions. | ||
233 | module(...) | ||
234 | |||
235 | dump = dumphints | ||
236 | on = dumphintson | ||
237 | off = dumphintsoff | ||
238 | start = dumphintson -- For -j command line option. | ||
239 | |||
diff --git a/libraries/LuaJIT-1.1.7/jit/opt.lua b/libraries/LuaJIT-1.1.7/jit/opt.lua new file mode 100644 index 0000000..5fe0f34 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/opt.lua | |||
@@ -0,0 +1,508 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT optimizer. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- This module contains a simple optimizer that generates some hints for | ||
8 | -- the compiler backend. | ||
9 | -- | ||
10 | -- Compare: luajit -j dump -e 'return 1' | ||
11 | -- with: luajit -O -j dumphints -j dump -e 'return 1' | ||
12 | -- | ||
13 | -- This module uses a very simplistic (but fast) abstract interpretation | ||
14 | -- algorithm. It mostly ignores control flow and/or basic block boundaries. | ||
15 | -- Thus the results of the analysis are really only predictions (e.g. about | ||
16 | -- monomorphic use of operators). The backend _must_ check all contracts | ||
17 | -- (e.g. verify the object type) and use a (polymorphic) fallback or | ||
18 | -- deoptimization in case a contract is broken. | ||
19 | -- | ||
20 | -- Although simplistic, the generated hints are pretty accurate. Note that | ||
21 | -- some hints are really definitive and don't need to be checked (like | ||
22 | -- COMBINE or FOR_STEP_K). | ||
23 | -- | ||
24 | -- TODO: Try MFP with an extended lattice. But it's unclear whether the | ||
25 | -- added complexity really pays off with the current backend. | ||
26 | ------------------------------------------------------------------------------ | ||
27 | |||
28 | -- Priority for compiler pipeline. Right in the middle before the backend. | ||
29 | local PRIORITY = 50 | ||
30 | |||
31 | -- Default optimizer level, i.e. what you get with -O. | ||
32 | -- Caveat: this may change in the future when more optimizations are added. | ||
33 | local OPTLEVEL = 2 | ||
34 | |||
35 | -- Heuristic limits for what the compiler should reasonably handle. | ||
36 | -- Functions outside these limits are unlikely to be run more than once. | ||
37 | -- Maybe a bit on the generous side. Check ljit.h for backend limits, too. | ||
38 | -- TODO: make it depend on the bytecode distribution, too. | ||
39 | local LIMITS = { | ||
40 | bytecodes = 4000, | ||
41 | stackslots = 150, | ||
42 | params = 20, | ||
43 | consts = 200, | ||
44 | subs = 30, | ||
45 | } | ||
46 | |||
47 | -- Cache some library functions and objects. | ||
48 | local jit = require("jit") | ||
49 | assert(jit.version_num == 10107, "LuaJIT core/library version mismatch") | ||
50 | local jutil = require("jit.util") | ||
51 | local type, rawget, next, pcall = type, rawget, next, pcall | ||
52 | local bytecode, const = jutil.bytecode, jutil.const | ||
53 | local hints, fhints = jutil.hints, jutil.fhints | ||
54 | local getmetatable = getmetatable | ||
55 | |||
56 | -- Turn compilation off for the whole module. LuaJIT would do that anyway. | ||
57 | jit.off(true, true) | ||
58 | |||
59 | -- Default optimizer level after loading. But -O runs setlevel(), too. | ||
60 | local optlevel = -1 | ||
61 | |||
62 | |||
63 | -- Use iterative path marking to mark live instructions and branch targets. | ||
64 | local function marklive(func) | ||
65 | local live, work, workn, pc = {}, {}, 0, 1 | ||
66 | repeat | ||
67 | repeat | ||
68 | local op, a, b, c, test = bytecode(func, pc) | ||
69 | live[pc] = true | ||
70 | pc = pc + 1 | ||
71 | if op == "JMP" then | ||
72 | pc = pc + b | ||
73 | live[-pc] = true | ||
74 | elseif op == "FORLOOP" then | ||
75 | local mpc = -pc | ||
76 | live[mpc - b] = true | ||
77 | live[mpc] = true | ||
78 | elseif op == "RETURN" then | ||
79 | break | ||
80 | elseif test then | ||
81 | local fpc = pc + 1 | ||
82 | -- No need for fallthrough target mark live[-fpc] in our analysis. | ||
83 | if not live[fpc] then -- Add fallthrough path to work list. | ||
84 | workn = workn + 1 | ||
85 | work[workn] = fpc | ||
86 | end | ||
87 | elseif op == "CLOSURE" then | ||
88 | pc = pc + jutil.closurenup(func, b) -- Do not mark pseudo-ins live. | ||
89 | elseif op == "LOADBOOL" and c ~= 0 then | ||
90 | pc = pc + 1 | ||
91 | live[-pc] = true | ||
92 | elseif op == "SETLIST" and c == 0 then | ||
93 | pc = pc + 1 -- Do not mark pseudo-ins live. | ||
94 | end | ||
95 | until live[pc] | ||
96 | if workn == 0 then return live end -- Return if work list is empty. | ||
97 | pc = work[workn] -- Else fetch next path to mark from work list. | ||
98 | workn = workn - 1 | ||
99 | until false | ||
100 | end | ||
101 | |||
102 | |||
103 | -- Empty objects. | ||
104 | local function empty() end | ||
105 | |||
106 | -- Dummy function to set call hints. Replaced when jit.opt_inline is loaded. | ||
107 | local function callhint(st, slot, pc, base, narg, nres) | ||
108 | st[pc+hints.TYPE] = slot[base] | ||
109 | for i=base,base+nres-1 do slot[i] = nil end | ||
110 | end | ||
111 | |||
112 | -- Set TYPE hint, but only for numbers, strings or tables. | ||
113 | local function typehint(st, pc, o) | ||
114 | local tp = type(o) | ||
115 | if tp == "number" or tp == "string" or tp == "table" then | ||
116 | st[pc+hints.TYPE] = o | ||
117 | end | ||
118 | end | ||
119 | |||
120 | -- Set TYPE and TYPEKEY hints for table operations. | ||
121 | local function tablehint(st, slot, pc, t, kslot) | ||
122 | local tp = type(t) | ||
123 | if tp == "table" or tp == "userdata" then st[pc+hints.TYPE] = t end | ||
124 | if kslot >= 0 then -- Don't need this hint for constants. | ||
125 | local key = slot[kslot] | ||
126 | local tp = type(key) | ||
127 | if tp == "number" or tp == "string" then st[pc+hints.TYPEKEY] = key end | ||
128 | end | ||
129 | end | ||
130 | |||
131 | -- Try to lookup a value. Guess the value or at least the value type. | ||
132 | local function trylookup(st, t, k) | ||
133 | if k == nil then return nil end | ||
134 | if type(t) == "table" then | ||
135 | local v = rawget(t, k) | ||
136 | if v ~= nil then return v end | ||
137 | end | ||
138 | local mt = getmetatable(t) | ||
139 | if type(mt) == "table" then | ||
140 | -- One __index level is enough for our purposes. | ||
141 | local it = rawget(mt, "__index") | ||
142 | if type(it) == "table" then | ||
143 | local v = rawget(it, k) | ||
144 | if v ~= nil then return v end | ||
145 | end | ||
146 | end | ||
147 | local v = st.tableval[t] -- Resort to a generic guess. | ||
148 | if v == nil and type(t) == "table" then v = next(t) end -- Getting desperate. | ||
149 | return v | ||
150 | end | ||
151 | |||
152 | -- Check whether the previous instruction sets a const. | ||
153 | local function prevconst(st, slot, pc, reg) | ||
154 | if st.live[-pc] == nil then -- Current instruction must not be a target. | ||
155 | local op, ka, kb = bytecode(st.func, pc-1) | ||
156 | if ka == reg and (op == "LOADK" or op == "LOADBOOL" or | ||
157 | (op == "LOADNIL" and kb == reg)) then | ||
158 | return true, slot[reg] | ||
159 | end | ||
160 | end | ||
161 | end | ||
162 | |||
163 | -- Common handler for arithmetic and comparison opcodes. | ||
164 | local function arithop(st, slot, pc, a, b, c, op) | ||
165 | local sb, sc = slot[b], slot[c] | ||
166 | if sb == nil then sb = sc elseif sc == nil then sc = sb end | ||
167 | local tb, tc = type(sb), type(sc) | ||
168 | if tb == tc then | ||
169 | if tb == "number" then -- Improve the guess for numbers. | ||
170 | if op == "DIV" or sb % 1 ~= 0 or sc % 1 ~= 0 then | ||
171 | sb = 0.5 -- Probably a non-integral number. | ||
172 | else | ||
173 | sb = 1 -- Optimistic guess. | ||
174 | end | ||
175 | end | ||
176 | if sb ~= nil then st[pc+hints.TYPE] = sb end | ||
177 | else | ||
178 | st[pc+hints.TYPE] = false -- Marker for mixed types. | ||
179 | end | ||
180 | if op ~= "LT" and op ~= "LE" then | ||
181 | slot[a] = sb -- Assume coercion to 1st type if different. | ||
182 | end | ||
183 | end | ||
184 | |||
185 | -- Common handler for TEST and TESTSET. | ||
186 | local function testop(st, slot, pc, a, b, c) | ||
187 | -- Optimize the 'expr and k1 or k2' idiom. | ||
188 | local ok, k = prevconst(st, slot, pc, b) | ||
189 | if k and a == b then | ||
190 | st[pc+hints.COMBINE] = false -- Kill the TEST/TESTSET. | ||
191 | if c == 0 then st.live[pc+1] = nil end -- Kill the JMP. | ||
192 | end | ||
193 | slot[a] = slot[b] | ||
194 | end | ||
195 | |||
196 | -- Dispatch table for opcode handlers. | ||
197 | local handler = { | ||
198 | MOVE = function(st, slot, pc, a, b, c) | ||
199 | slot[a] = slot[b] | ||
200 | end, | ||
201 | |||
202 | LOADK = function(st, slot, pc, a, b, c) | ||
203 | slot[a] = const(st.func, b) | ||
204 | end, | ||
205 | |||
206 | LOADBOOL = function(st, slot, pc, a, b, c) | ||
207 | slot[a] = (b == 1) | ||
208 | end, | ||
209 | |||
210 | LOADNIL = function(st, slot, pc, a, b, c) | ||
211 | for i=a,b do slot[i] = nil end | ||
212 | end, | ||
213 | |||
214 | GETUPVAL = function(st, slot, pc, a, b, c) | ||
215 | slot[a] = jutil.upvalue(st.func, b) | ||
216 | end, | ||
217 | |||
218 | GETGLOBAL = function(st, slot, pc, a, b, c) | ||
219 | slot[a] = trylookup(st, st.stats.env, const(st.func, b)) | ||
220 | end, | ||
221 | |||
222 | GETTABLE = function(st, slot, pc, a, b, c) | ||
223 | local t = slot[b] | ||
224 | tablehint(st, slot, pc, t, c) | ||
225 | slot[a] = trylookup(st, t, slot[c]) | ||
226 | end, | ||
227 | |||
228 | SETGLOBAL = empty, | ||
229 | |||
230 | SETUPVAL = empty, -- TODO: shortcut -- but this is rare? | ||
231 | |||
232 | SETTABLE = function(st, slot, pc, a, b, c) | ||
233 | local t = slot[a] | ||
234 | tablehint(st, slot, pc, t, b) | ||
235 | if type(t) == "table" or type(t) == "userdata" then -- Must validate setkey. | ||
236 | local val = slot[c] | ||
237 | if val ~= nil then st.tableval[t] = val end | ||
238 | end | ||
239 | end, | ||
240 | |||
241 | NEWTABLE = function(st, slot, pc, a, b, c) | ||
242 | slot[a] = {} -- Need unique tables for indexing st.tableval. | ||
243 | end, | ||
244 | |||
245 | SELF = function(st, slot, pc, a, b, c) | ||
246 | local t = slot[b] | ||
247 | tablehint(st, slot, pc, t, c) | ||
248 | slot[a+1] = t | ||
249 | slot[a] = trylookup(st, t, slot[c]) | ||
250 | end, | ||
251 | |||
252 | ADD = arithop, SUB = arithop, MUL = arithop, DIV = arithop, | ||
253 | MOD = arithop, POW = arithop, LT = arithop, LE = arithop, | ||
254 | |||
255 | UNM = function(st, slot, pc, a, b, c) | ||
256 | return arithop(st, slot, pc, a, b, b, "UNM") | ||
257 | end, | ||
258 | |||
259 | NOT = function(st, slot, pc, a, b, c) | ||
260 | slot[a] = true | ||
261 | end, | ||
262 | |||
263 | LEN = function(st, slot, pc, a, b, c) | ||
264 | typehint(st, pc, slot[b]) | ||
265 | slot[a] = 1 | ||
266 | end, | ||
267 | |||
268 | CONCAT = function(st, slot, pc, a, b, c) | ||
269 | local mixed | ||
270 | local sb = slot[b] | ||
271 | for i=b+1,c do | ||
272 | local si = slot[i] | ||
273 | if sb == nil then | ||
274 | sb = si | ||
275 | elseif si ~= nil and type(sb) ~= type(si) then | ||
276 | mixed = true | ||
277 | break | ||
278 | end | ||
279 | end | ||
280 | if sb == nil then | ||
281 | sb = "" | ||
282 | else | ||
283 | st[pc+hints.TYPE] = not mixed and sb or false | ||
284 | if type(sb) == "number" then sb = "" end | ||
285 | end | ||
286 | slot[a] = sb -- Assume coercion to 1st type (if different) or string. | ||
287 | end, | ||
288 | |||
289 | JMP = function(st, slot, pc, a, b, c) | ||
290 | if b >= 0 then -- Kill JMPs across dead code. | ||
291 | local tpc = pc + b | ||
292 | while not st.live[tpc] do tpc = tpc - 1 end | ||
293 | if tpc == pc then st[pc+hints.COMBINE] = false end | ||
294 | end | ||
295 | end, | ||
296 | |||
297 | EQ = function(st, slot, pc, a, b, c) | ||
298 | if b >= 0 and c >= 0 then typehint(st, pc, slot[b] or slot[c]) end | ||
299 | end, | ||
300 | |||
301 | TEST = function(st, slot, pc, a, b, c) | ||
302 | return testop(st, slot, pc, a, a, c) | ||
303 | end, | ||
304 | |||
305 | TESTSET = testop, | ||
306 | |||
307 | CALL = function(st, slot, pc, a, b, c) | ||
308 | callhint(st, slot, pc, a, b-1, c-1) | ||
309 | end, | ||
310 | |||
311 | TAILCALL = function(st, slot, pc, a, b, c) | ||
312 | callhint(st, slot, pc, a, b-1, -1) | ||
313 | end, | ||
314 | |||
315 | RETURN = function(st, slot, pc, a, b, c) | ||
316 | if b == 2 and prevconst(st, slot, pc, a) then | ||
317 | st[pc-1+hints.COMBINE] = true -- Set COMBINE hint for prev. instruction. | ||
318 | end | ||
319 | end, | ||
320 | |||
321 | FORLOOP = empty, | ||
322 | |||
323 | FORPREP = function(st, slot, pc, a, b, c) | ||
324 | local ok, step = prevconst(st, slot, pc, a+2) | ||
325 | if type(step) == "number" then | ||
326 | st[pc+hints.FOR_STEP_K] = step | ||
327 | end | ||
328 | local nstart, nstep = slot[a], slot[a+2] | ||
329 | local tnstart, tnstep = type(nstart), type(nstep) | ||
330 | local ntype = ((tnstart == "number" and nstart % 1 ~= 0) or | ||
331 | (tnstep == "number" and nstep % 1 ~= 0)) and 0.5 or 1 | ||
332 | slot[a+3] = ntype | ||
333 | if tnstart == "number" and tnstep == "number" and | ||
334 | type(slot[a+1]) == "number" then | ||
335 | st[pc+hints.TYPE] = ntype | ||
336 | end | ||
337 | end, | ||
338 | |||
339 | -- TFORLOOP is at the end of the loop. Setting slots would be pointless. | ||
340 | -- Inlining is handled by the corresponding iterator constructor (CALL). | ||
341 | TFORLOOP = function(st, slot, pc, a, b, c) | ||
342 | st[pc+hints.TYPE] = slot[a] | ||
343 | end, | ||
344 | |||
345 | SETLIST = function(st, slot, pc, a, b, c) | ||
346 | -- TODO: if only (numeric) const: shortcut (+ nobarrier). | ||
347 | local t = slot[a] | ||
348 | -- Very imprecise. But better than nothing. | ||
349 | if type(t) == "table" then st.tableval[t] = slot[a+1] end | ||
350 | end, | ||
351 | |||
352 | CLOSE = empty, | ||
353 | |||
354 | CLOSURE = function(st, slot, pc, a, b, c) | ||
355 | slot[a] = empty | ||
356 | if st.noclose then | ||
357 | local nup = jutil.closurenup(st.func, b) | ||
358 | for i=pc+1,pc+nup do | ||
359 | local op = bytecode(st.func, i) | ||
360 | if op == "MOVE" then | ||
361 | st.noclose = false | ||
362 | return | ||
363 | end | ||
364 | end | ||
365 | end | ||
366 | end, | ||
367 | |||
368 | VARARG = function(st, slot, pc, a, b, c) | ||
369 | local params = st.stats.params | ||
370 | for i=1,b do slot[a+i-1] = st[params+i] end | ||
371 | end, | ||
372 | } | ||
373 | |||
374 | -- Generate some hints for the compiler backend. | ||
375 | local function optimize(st) | ||
376 | -- Deoptimization is simple: just don't generate any hints. :-) | ||
377 | if st.deopt then return end | ||
378 | |||
379 | local func = st.func | ||
380 | local stats = jutil.stats(func) | ||
381 | if not stats then return jutil.status.COMPILER_ERROR end -- Eh? | ||
382 | |||
383 | -- Check limits. | ||
384 | if stats.bytecodes > LIMITS.bytecodes or | ||
385 | stats.stackslots > LIMITS.stackslots or | ||
386 | stats.params > LIMITS.params or | ||
387 | stats.consts > LIMITS.consts or | ||
388 | stats.subs > LIMITS.subs then | ||
389 | return jutil.status.TOOLARGE | ||
390 | end | ||
391 | |||
392 | -- Mark live instructions (live[pc]) and branch targets (live[-pc]). | ||
393 | local live = marklive(func) | ||
394 | |||
395 | -- Handlers need access to some temporary state fields. | ||
396 | st.noclose = true | ||
397 | st.stats = stats | ||
398 | st.live = live | ||
399 | st.tableval = { [stats.env] = empty } -- Guess: unknown globals are functions. | ||
400 | |||
401 | -- Initialize slots with argument hints and constants. | ||
402 | local slot = {} | ||
403 | for i=1,stats.params do slot[i-1] = st[i] end | ||
404 | for i=-1,-256,-1 do -- No need to copy non-RK-able consts. | ||
405 | local k, ok = const(func, i) | ||
406 | if not ok then break end | ||
407 | slot[i] = k | ||
408 | end | ||
409 | |||
410 | -- Step through all live instructions, update slots and add hints. | ||
411 | for pc=1,stats.bytecodes do | ||
412 | if live[pc] then | ||
413 | local op, a, b, c, test = bytecode(func, pc) | ||
414 | handler[op](st, slot, pc, a, b, c, op) | ||
415 | else | ||
416 | st[pc+hints.COMBINE] = false -- Dead instruction hint. | ||
417 | end | ||
418 | end | ||
419 | |||
420 | -- Update function hints. | ||
421 | if st.noclose then st[fhints.NOCLOSE] = true end | ||
422 | |||
423 | -- Clear temporary state fields. | ||
424 | st.noclose = nil | ||
425 | st.stats = nil | ||
426 | st.live = nil | ||
427 | st.tableval = nil | ||
428 | end | ||
429 | |||
430 | |||
431 | -- Active flags. | ||
432 | local active, active_opt_inline | ||
433 | |||
434 | -- Handler for compiler pipeline. | ||
435 | local function h_opt(st) | ||
436 | if optlevel <= 0 then return end | ||
437 | local ok, err = pcall(optimize, st) | ||
438 | if not ok then | ||
439 | io.stderr:write("\nERROR: jit.opt disabled: ", err, "\n") | ||
440 | jit.attach(h_opt) -- Better turn ourselves off after a failure. | ||
441 | active = nil | ||
442 | else | ||
443 | if err then return err end | ||
444 | end | ||
445 | end | ||
446 | |||
447 | -- Load add-on module. | ||
448 | local function loadaddon(opt) | ||
449 | local name, val = string.match(opt, "^(.-)=(.*)$") -- Strip value. | ||
450 | if not name then name = opt end | ||
451 | name = "jit.opt_"..name | ||
452 | local ok, mod = pcall(require, name) | ||
453 | if not ok then | ||
454 | -- Return error if not installed, but propagate other errors. | ||
455 | if string.sub(mod, 1, 7) ~= "module " then error(mod, 0) end | ||
456 | return "optimizer add-on module "..name.." not found" | ||
457 | end | ||
458 | mod.start(val) | ||
459 | end | ||
460 | |||
461 | -- Attach optimizer and set optimizer level or load add-on module. | ||
462 | local function setlevel_(opt) | ||
463 | -- Easier to always attach the optimizer (even for -O0). | ||
464 | if not active then | ||
465 | jit.attach(h_opt, PRIORITY) | ||
466 | active = true | ||
467 | end | ||
468 | |||
469 | -- Parse -O<level> or -O<name[=value]>. | ||
470 | if opt == nil or opt == "" then | ||
471 | optlevel = OPTLEVEL | ||
472 | else | ||
473 | local level = tonumber(opt) -- Numeric level? | ||
474 | if level then | ||
475 | if level < 0 or level % 1 ~= 0 then | ||
476 | error("bad optimizer level", 0) | ||
477 | end | ||
478 | optlevel = level | ||
479 | else | ||
480 | if optlevel == -1 then optlevel = OPTLEVEL end | ||
481 | local err = loadaddon(opt) | ||
482 | if err then error(err, 0) end | ||
483 | end | ||
484 | end | ||
485 | |||
486 | -- Load add-on module for inlining functions for -O2 and above. | ||
487 | if not active_opt_inline and optlevel >= 2 then | ||
488 | loadaddon("inline") -- Be silent if not installed. | ||
489 | active_opt_inline = true -- Try this only once. | ||
490 | end | ||
491 | end | ||
492 | |||
493 | |||
494 | -- Public module functions. | ||
495 | module(...) | ||
496 | |||
497 | -- Callback to allow attaching a call hinter. Used by jit.opt_inline. | ||
498 | function attach_callhint(f) | ||
499 | callhint = f | ||
500 | end | ||
501 | |||
502 | function getlevel() | ||
503 | return optlevel | ||
504 | end | ||
505 | |||
506 | setlevel = setlevel_ | ||
507 | start = setlevel_ -- For -O command line option. | ||
508 | |||
diff --git a/libraries/LuaJIT-1.1.7/jit/opt_inline.lua b/libraries/LuaJIT-1.1.7/jit/opt_inline.lua new file mode 100644 index 0000000..cc19bf4 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/opt_inline.lua | |||
@@ -0,0 +1,397 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT optimizer add-on module for function inlining. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- This is a simple framework for C function signature maps. | ||
8 | -- It helps with type propagation and C function inlining. | ||
9 | -- | ||
10 | -- This module is automatically loaded with -O2 and above. | ||
11 | -- By default most standard library functions are added. | ||
12 | -- | ||
13 | -- TODO: generalize it, e.g. for back propagation (i.e. arg types). | ||
14 | -- TODO: extend it for Lua functions (but need to analyze them before use). | ||
15 | ------------------------------------------------------------------------------ | ||
16 | |||
17 | -- Cache some library functions and objects. | ||
18 | local jit = require("jit") | ||
19 | assert(jit.version_num == 10107, "LuaJIT core/library version mismatch") | ||
20 | local jutil = require("jit.util") | ||
21 | local type, rawget, next = type, rawget, next | ||
22 | local hints, fhints = jutil.hints, jutil.fhints | ||
23 | local sub, match, gsub = string.sub, string.match, string.gsub | ||
24 | |||
25 | -- Turn compilation off for the whole module. LuaJIT would do that anyway. | ||
26 | jit.off(true, true) | ||
27 | |||
28 | -- Prototypical objects used for type hints. | ||
29 | local TABLE = {} | ||
30 | local CFUNC = collectgarbage -- Pretty sure this is never inlined. | ||
31 | |||
32 | |||
33 | -- Map from C closures to signatures. Cannot use a weak table. | ||
34 | -- Closures must be kept alive because inlining checks against their addrs. | ||
35 | local map_sign = {} | ||
36 | |||
37 | -- For jit.dumphints: get printable name for TYPE hint: "#INLINE(foo.bar)". | ||
38 | local function getname_(f, idx) | ||
39 | local sign = map_sign[f] | ||
40 | if sign then | ||
41 | local libname, name = sign.libname, sign.name | ||
42 | if libname then | ||
43 | return libname.."."..name | ||
44 | else | ||
45 | return name | ||
46 | end | ||
47 | elseif idx == 0 then | ||
48 | return "recursive" | ||
49 | else | ||
50 | return "?" | ||
51 | end | ||
52 | end | ||
53 | |||
54 | -- Name, base table and running index for convenience functions. | ||
55 | -- CHECK: the library index and the order below must match with ljit_hints.h | ||
56 | local flibname, flib, fidx | ||
57 | |||
58 | local function fadd(name, results, args, handler) | ||
59 | local f = rawget(flib, name) | ||
60 | if f then | ||
61 | map_sign[f] = { | ||
62 | libname = flibname, name = name, idx = fidx, | ||
63 | results = results, args = args, handler = handler, | ||
64 | } | ||
65 | end | ||
66 | if fidx then fidx = fidx + 1 end | ||
67 | end | ||
68 | |||
69 | local function faddf(name, f, results, args, handler) | ||
70 | map_sign[f] = { | ||
71 | libname = flibname, name = name, idx = fidx, | ||
72 | results = results, args = args, handler = handler, | ||
73 | } | ||
74 | if fidx then fidx = fidx + 1 end | ||
75 | end | ||
76 | |||
77 | |||
78 | -- Signature handler: copy first argument to first result. | ||
79 | local function copyfirst(st, slot, pc, base, narg, nres) | ||
80 | slot[base] = slot[base+1] | ||
81 | end | ||
82 | |||
83 | -- Helper for iterators: check if the function is an iterator constructor. | ||
84 | -- | ||
85 | -- 'for ivars in func(args) do body end' | ||
86 | -- | ||
87 | -- ...load func+args... | ||
88 | -- CALL func <-- pc | ||
89 | -- JMP fwd ---+ | ||
90 | -- back: | <--+ | ||
91 | -- ...body... | | | ||
92 | -- fwd: <--+ | | ||
93 | -- TFORLOOP ivars | <-- tforpc | ||
94 | -- JMP back ---+ | ||
95 | -- | ||
96 | local function itercheck(st, slot, pc, base, idx) | ||
97 | if idx then | ||
98 | local bytecode, func = jutil.bytecode, st.func | ||
99 | local op, _, fwd = bytecode(func, pc+1) | ||
100 | if op == "JMP" then | ||
101 | local tforpc = pc+2+fwd | ||
102 | local op, tfbase, _, tfnres = bytecode(func, tforpc) | ||
103 | if op == "TFORLOOP" and tfbase == base and tfnres <= 2 then | ||
104 | local op, _, back = bytecode(func, tforpc+1) | ||
105 | if op == "JMP" and fwd+back == -2 then | ||
106 | -- Must set inlining hint for TFORLOOP instruction here. | ||
107 | st[tforpc+hints.INLINE] = idx -- Serves as iterator index, too. | ||
108 | return -- Inline it. | ||
109 | end | ||
110 | end | ||
111 | end | ||
112 | end | ||
113 | slot[base] = CFUNC -- Better make it different from pairs. | ||
114 | return true -- Better not inline it, if not used in a for statement. | ||
115 | end | ||
116 | |||
117 | -- Helper for pairs/next: guess result types for standard table iterator. | ||
118 | local function guessnext(st, slot, base, dest) | ||
119 | local t, k, v = slot[base+1] | ||
120 | if type(t) == "table" then | ||
121 | k, v = next(t) | ||
122 | if v == nil then v = st.tableval[t] end | ||
123 | end | ||
124 | slot[dest] = k or "" -- Strings are a good guess for the key type. | ||
125 | slot[dest+1] = v -- But better not guess any fixed value type. | ||
126 | end | ||
127 | |||
128 | |||
129 | -- Signatures for base library functions. | ||
130 | -- Note: Only add functions where result type hints or inlining makes sense. | ||
131 | flibname, flib, fidx = nil, _G, 65536*1 | ||
132 | fadd("pairs", "..0", "T", | ||
133 | function(st, slot, pc, base, narg, nres, idx) | ||
134 | -- Table in slot[base+1] is kept (2nd result = 1st arg). | ||
135 | -- Fill result slots for the iterator here (TFORLOOP is at the end). | ||
136 | guessnext(st, slot, base, base+3) | ||
137 | return itercheck(st, slot, pc, base, idx) | ||
138 | end) | ||
139 | |||
140 | fadd("ipairs", "..I", "T", | ||
141 | function(st, slot, pc, base, narg, nres, idx) | ||
142 | -- Table in slot[base+1] is kept (2nd result = 1st arg). | ||
143 | -- Fill result slots for the iterator here (TFORLOOP is at the end). | ||
144 | local t = slot[base+1] | ||
145 | slot[base+3] = 1 -- Integer key. | ||
146 | local v | ||
147 | if type(t) == "table" then | ||
148 | v = rawget(t, 1) | ||
149 | if v == nil then v = st.tableval[t] end | ||
150 | end | ||
151 | slot[base+4] = v | ||
152 | return itercheck(st, slot, pc, base, idx) | ||
153 | end) | ||
154 | |||
155 | fidx = nil -- Pure result type signatures follow: | ||
156 | fadd("next", "..", "T.?", | ||
157 | function(st, slot, pc, base, narg, nres) | ||
158 | guessnext(st, slot, base, base) | ||
159 | end) | ||
160 | fadd("type", "S", ".") | ||
161 | fadd("getmetatable", "T", ".") | ||
162 | fadd("setmetatable", ".", "TT?", copyfirst) | ||
163 | fadd("rawequal", "B", "..") | ||
164 | fadd("rawget", ".", "T.", | ||
165 | function(st, slot, pc, base, narg, nres) | ||
166 | local t = slot[base+1] | ||
167 | slot[base] = type(t) == "table" and rawget(t, slot[base+2]) or "" | ||
168 | end) | ||
169 | fadd("rawset", ".", "T..", copyfirst) | ||
170 | fadd("assert", "*", "..*", | ||
171 | function(st, slot, pc, base, narg, nres) | ||
172 | for i=1,nres do slot[base+i-1] = i <= narg and slot[base+i] or nil end | ||
173 | end) | ||
174 | fadd("tonumber", "I", ".I?") | ||
175 | fadd("tostring", "S", ".") | ||
176 | fadd("require", "T", "S") | ||
177 | |||
178 | -- Signatures for coroutine library functions. | ||
179 | flibname, flib, fidx = "coroutine", coroutine, 65536*2 | ||
180 | if flib then | ||
181 | fadd("yield", "*", ".*") | ||
182 | fadd("resume", "*", "R.*", | ||
183 | function(st, slot, pc, base, narg, nres) | ||
184 | slot[base] = true | ||
185 | for i=1,nres-1 do slot[base+i] = nil end -- No guess. | ||
186 | end) | ||
187 | |||
188 | fidx = nil -- Pure result type signatures follow: | ||
189 | fadd("wrap", "C", "F") | ||
190 | end | ||
191 | |||
192 | -- Signatures for string library functions. | ||
193 | flibname, flib, fidx = "string", string, 65536*3 | ||
194 | if flib then | ||
195 | fadd("len", "I", "S") | ||
196 | fadd("sub", "S", "SII?") | ||
197 | fadd("char", "S", "I*") | ||
198 | |||
199 | fidx = nil -- Pure result type signatures follow: | ||
200 | fadd("byte", "I", "S", | ||
201 | function(st, slot, pc, base, narg, nres) | ||
202 | for i=0,nres-1 do slot[base+i] = 1 end -- Set all result hints. | ||
203 | end) | ||
204 | fadd("rep", "S", "SI") | ||
205 | fadd("reverse", "S", "S") | ||
206 | fadd("upper", "S", "S") | ||
207 | fadd("lower", "S", "S") | ||
208 | |||
209 | fadd("format", "S", "S.*") | ||
210 | fadd("find", "*", "SSI?.?", | ||
211 | function(st, slot, pc, base, narg, nres) | ||
212 | slot[base] = 1 | ||
213 | slot[base+1] = 1 | ||
214 | for i=2,nres-1 do slot[base+i] = "" end -- Hints for matches. | ||
215 | end) | ||
216 | fadd("match", "*", "SSI?", | ||
217 | function(st, slot, pc, base, narg, nres) | ||
218 | for i=0,nres-1 do slot[base+i] = "" end -- Hints for matches. | ||
219 | end) | ||
220 | fadd("gsub", "SI", "SSGI?") | ||
221 | fadd("gmatch", "C00", "SS", | ||
222 | function(st, slot, pc, base, narg, nres) | ||
223 | -- Fill result slots for gmatch_iter here (TFORLOOP is at the end). | ||
224 | for i=base+3,st.stats.stackslots-1 do slot[i] = "" end | ||
225 | end) | ||
226 | -- The gmatch iterator itself is never inlined. No point in adding it. | ||
227 | end | ||
228 | |||
229 | -- Signatures for table library functions. | ||
230 | flibname, flib, fidx = "table", table, 65536*4 | ||
231 | if flib then | ||
232 | fadd("insert", "", "TI?.") | ||
233 | fadd("remove", ".", "T", | ||
234 | function(st, slot, pc, base, narg, nres) | ||
235 | if nres >= 1 then | ||
236 | local t = slot[base+1] | ||
237 | slot[base] = type(t) == "table" and rawget(t, 1) or "" | ||
238 | end | ||
239 | end) | ||
240 | fadd("getn", "I", "T") | ||
241 | |||
242 | fidx = nil -- Pure result type signatures follow: | ||
243 | fadd("concat", "S", "TS?I?I?") | ||
244 | end | ||
245 | |||
246 | -- Signatures for math library functions. | ||
247 | flibname, flib, fidx = "math", math, 65536*5 | ||
248 | if flib then | ||
249 | -- 1 arg, 1 result. | ||
250 | fadd("log", "N", "N") | ||
251 | fadd("log10", "N", "N") | ||
252 | fadd("exp", "N", "N") | ||
253 | fadd("sinh", "N", "N") | ||
254 | fadd("cosh", "N", "N") | ||
255 | fadd("tanh", "N", "N") | ||
256 | fadd("asin", "N", "N") | ||
257 | fadd("acos", "N", "N") | ||
258 | fadd("atan", "N", "N") | ||
259 | fadd("sin", "N", "N") | ||
260 | fadd("cos", "N", "N") | ||
261 | fadd("tan", "N", "N") | ||
262 | fadd("ceil", "I", "N") | ||
263 | fadd("floor", "I", "N") | ||
264 | fadd("abs", ".", "N", copyfirst) | ||
265 | fadd("sqrt", "N", "N") | ||
266 | -- 2 args, 1 result. | ||
267 | -- math.fmod is aliased to math.mod for compatibility. | ||
268 | fadd("fmod", ".", "NN", | ||
269 | function(st, slot, pc, base, narg, nres) | ||
270 | slot[base] = slot[base+2] or 1 -- Copy integer or number hint. | ||
271 | end) | ||
272 | fadd("atan2", "N", "NN") | ||
273 | |||
274 | fidx = nil -- Pure result type signatures follow: | ||
275 | -- 1-n args, 1 result. | ||
276 | fadd("min", ".", "NN*", copyfirst) -- Really depends on all args. | ||
277 | fadd("max", ".", "NN*", copyfirst) -- Really depends on all args. | ||
278 | -- 1 arg, 1 result. | ||
279 | fadd("deg", "N", "N") | ||
280 | fadd("rad", "N", "N") | ||
281 | -- 1 arg, 2 results. | ||
282 | fadd("modf", "IN", "N") | ||
283 | fadd("frexp", "NI", "N") | ||
284 | -- 2 args, 1 result. | ||
285 | fadd("pow", "N", "NN") | ||
286 | fadd("ldexp", ".", "NI", copyfirst) | ||
287 | -- 1 arg, 0 results. | ||
288 | fadd("randomseed", "", "I") | ||
289 | -- 0-2 args, 1 result. | ||
290 | fadd("random", "N", "I?I?", | ||
291 | function(st, slot, pc, base, narg, nres) | ||
292 | if narg > 0 then slot[base] = 1 end | ||
293 | end) | ||
294 | end | ||
295 | |||
296 | -- Signatures for I/O library functions. | ||
297 | -- Not inlined anytime soon. Used for result types only. | ||
298 | flibname, flib, fidx = "io", io, nil | ||
299 | if flib then | ||
300 | fadd("lines", "C00S", "S?") | ||
301 | fadd("read", "S", "") -- Simplified (a lot). | ||
302 | -- Adding io methods doesn't work, because we don't deal with userdata (yet). | ||
303 | end | ||
304 | |||
305 | |||
306 | -- Type names to argument type shorthands. | ||
307 | -- TODO: make the matches more exact? Need to differentiate nil/unknown. | ||
308 | local map_argtype = { | ||
309 | ["nil"] = "0", boolean = "b", number = "n", string = "s", | ||
310 | table = "t", ["function"] = "f", userdata = "u", thread = "r", | ||
311 | } | ||
312 | |||
313 | -- Complex argument match patterns to regexp fragments. | ||
314 | local map_argmatch = { | ||
315 | B = "[b0]", S = "[s0]", T = "[t0]", F = "[f0]", U = "[u0]", R = "[r0]", | ||
316 | N = "[n0]", I = "[n0]", -- Number/int args are the same for now. | ||
317 | G = "[stf0]", -- For string.gsub. | ||
318 | } | ||
319 | |||
320 | -- Result type shorthands to sample types. | ||
321 | local map_restype = { | ||
322 | -- ["0"] = nil, | ||
323 | B = true, S = "", T = {}, | ||
324 | N = 0.5, I = 1, | ||
325 | L = function() end, C = collectgarbage, -- Pretty sure this is never inlined. | ||
326 | } | ||
327 | |||
328 | -- Create argument match regexp and cache it. | ||
329 | local function getargmatch(sign) | ||
330 | local argmatch = "^"..gsub(sign.args, ".", map_argmatch).."0*$" | ||
331 | sign.argmatch = argmatch | ||
332 | return argmatch | ||
333 | end | ||
334 | |||
335 | -- Set INLINE hints and result types for known C functions. | ||
336 | local function inlinehint(sign, st, slot, pc, base, narg, nres) | ||
337 | local idx = sign.idx | ||
338 | if idx then | ||
339 | if narg ~= -1 then | ||
340 | local argpat = "" | ||
341 | for i=1,narg do argpat = argpat..map_argtype[type(slot[base+i])] end | ||
342 | if not match(argpat, sign.argmatch or getargmatch(sign)) then | ||
343 | idx = nil | ||
344 | end | ||
345 | end | ||
346 | end | ||
347 | |||
348 | local results = sign.results | ||
349 | if results ~= "*" and nres ~= -1 then | ||
350 | if nres > #results then idx = nil end | ||
351 | for i=1,#results do | ||
352 | local c = sub(results, i, i) | ||
353 | if c ~= "." then slot[base+i-1] = map_restype[c] end | ||
354 | end | ||
355 | end | ||
356 | |||
357 | local handler = sign.handler | ||
358 | if handler and handler(st, slot, pc, base, narg, nres, idx) then idx = nil end | ||
359 | |||
360 | if idx then st[pc+hints.INLINE] = idx end | ||
361 | end | ||
362 | |||
363 | -- Set call hints and result types during forward propagation. | ||
364 | local function fwdcallhint(st, slot, pc, base, narg, nres) | ||
365 | local f = slot[base] | ||
366 | st[pc+hints.TYPE] = f | ||
367 | if type(f) == "function" then | ||
368 | local sign = map_sign[f] | ||
369 | if sign then | ||
370 | inlinehint(sign, st, slot, pc, base, narg, nres) | ||
371 | return | ||
372 | end | ||
373 | if f == st.func and not st.stats.isvararg and | ||
374 | (narg == -1 or narg == st.stats.params) then | ||
375 | st[pc+hints.INLINE] = 0 -- Recursive call. | ||
376 | end | ||
377 | end | ||
378 | -- Clear result types for unknown functions. | ||
379 | for i=base,base+nres-1 do slot[i] = nil end | ||
380 | end | ||
381 | |||
382 | |||
383 | -- Attach call hinter to optimizer. | ||
384 | local function start_() | ||
385 | local jopt = require "jit.opt" | ||
386 | jopt.attach_callhint(fwdcallhint) | ||
387 | -- Note that just loading the optimizer does not start it, yet. | ||
388 | end | ||
389 | |||
390 | |||
391 | -- Public module functions. | ||
392 | module(...) | ||
393 | |||
394 | -- TODO: Public API to add signatures. Alas, the API is still in flux. | ||
395 | getname = getname_ | ||
396 | start = start_ | ||
397 | |||
diff --git a/libraries/LuaJIT-1.1.7/jit/trace.lua b/libraries/LuaJIT-1.1.7/jit/trace.lua new file mode 100644 index 0000000..42367c6 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jit/trace.lua | |||
@@ -0,0 +1,111 @@ | |||
1 | ---------------------------------------------------------------------------- | ||
2 | -- LuaJIT compiler tracing module. | ||
3 | -- | ||
4 | -- Copyright (C) 2005-2011 Mike Pall. All rights reserved. | ||
5 | -- Released under the MIT/X license. See luajit.h for full copyright notice. | ||
6 | ---------------------------------------------------------------------------- | ||
7 | -- Activate this module to trace the progress of the JIT compiler. | ||
8 | -- | ||
9 | -- Try: luajit -j trace -e 'print "foo"' | ||
10 | -- luajit -j trace=foo.trace foo.lua | ||
11 | -- | ||
12 | -- Default output is to stderr. To redirect output to a file, | ||
13 | -- pass a filename as an argument or set the environment variable | ||
14 | -- "LUAJIT_TRACEFILE". | ||
15 | -- Note: the file is overwritten each time you run luajit. | ||
16 | ------------------------------------------------------------------------------ | ||
17 | |||
18 | -- Priority for compiler pipeline. Must run after backend (negative) | ||
19 | -- and should be odd to catch compiler errors, too. | ||
20 | local PRIORITY = -99 | ||
21 | |||
22 | -- Cache some library functions and objects. | ||
23 | local jit = require("jit") | ||
24 | assert(jit.version_num == 10107, "LuaJIT core/library version mismatch") | ||
25 | local jutil = require("jit.util") | ||
26 | local type, tostring, sub, format = type, tostring, string.sub, string.format | ||
27 | local getinfo, justats = debug.getinfo, jutil.stats | ||
28 | local stdout, stderr = io.stdout, io.stderr | ||
29 | |||
30 | -- Turn compilation off for the whole module. LuaJIT would do that anyway. | ||
31 | jit.off(true, true) | ||
32 | |||
33 | -- Active flag and output file handle. | ||
34 | local active, out | ||
35 | |||
36 | -- Generate range string from table: pc[-pc] [,...] | ||
37 | local function rangestring(t) | ||
38 | local s = "" | ||
39 | for i,range in ipairs(t) do | ||
40 | if i ~= 1 then s = s.."," end | ||
41 | local pc = range % 65536 | ||
42 | range = (range - pc) / 65536 | ||
43 | s = s..pc | ||
44 | if range ~= 0 then s = s..(-(pc+range)) end | ||
45 | end | ||
46 | return s | ||
47 | end | ||
48 | |||
49 | -- Trace handler for compiler pipeline. | ||
50 | local function h_trace(st, status) | ||
51 | local o = out or stderr | ||
52 | local func = st.func | ||
53 | if type(func) ~= "function" then return end | ||
54 | local info = getinfo(func, "S") | ||
55 | local src, line = info.source, info.linedefined or 0 | ||
56 | if src then | ||
57 | if sub(src, 1, 1) == "@" or sub(src, 1, 2) == "=(" then | ||
58 | src = sub(src, 2) | ||
59 | else | ||
60 | src = "**"..string.gsub(sub(src, 1, 40), "%c", " ").."**" | ||
61 | end | ||
62 | else | ||
63 | src = "?" | ||
64 | end | ||
65 | local aux = st.deopt and " DEOPT="..rangestring(st.deopt) or "" | ||
66 | if status == nil then | ||
67 | local stats = justats(func) | ||
68 | if not stats then return end | ||
69 | o:write(format("[LuaJIT: OK %4d %6d %s:%d%s]\n", | ||
70 | stats.bytecodes, stats.mcodesize or -1, src, line, aux)) | ||
71 | return | ||
72 | else | ||
73 | local stname = jit.util.status[status] or status | ||
74 | local pc, err = st.dasm_pc, st.dasm_err | ||
75 | if type(pc) == "number" and type(err) == "number" then | ||
76 | local op = jutil.bytecode(func, pc) or "END" | ||
77 | o:write(format("[LuaJIT: %s %s@%d %08x %s:%d%s]\n", | ||
78 | stname, op, pc, err, src, line, aux)) | ||
79 | else | ||
80 | o:write(format("[LuaJIT: %s %s:%d%s]\n", stname, src, line, aux)) | ||
81 | end | ||
82 | end | ||
83 | end | ||
84 | |||
85 | -- Detach trace handler from compiler pipeline. | ||
86 | local function traceoff() | ||
87 | if active then | ||
88 | active = false | ||
89 | jit.attach(h_trace) | ||
90 | if out and out ~= stdout then out:close() end | ||
91 | out = nil | ||
92 | end | ||
93 | end | ||
94 | |||
95 | -- Open the output file and attach trace handler to compiler pipeline. | ||
96 | local function traceon(filename) | ||
97 | if active then traceoff() end | ||
98 | local outfile = filename or os.getenv("LUAJIT_TRACEFILE") | ||
99 | out = outfile and (outfile == "-" and stdout or assert(io.open(outfile, "w"))) | ||
100 | jit.attach(h_trace, PRIORITY) | ||
101 | active = true | ||
102 | end | ||
103 | |||
104 | |||
105 | -- Public module functions. | ||
106 | module(...) | ||
107 | |||
108 | on = traceon | ||
109 | off = traceoff | ||
110 | start = traceon -- For -j command line option. | ||
111 | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/bluequad-print.css b/libraries/LuaJIT-1.1.7/jitdoc/bluequad-print.css new file mode 100644 index 0000000..69c07d6 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/bluequad-print.css | |||
@@ -0,0 +1,166 @@ | |||
1 | /* Copyright (C) 2004-2011 Mike Pall. | ||
2 | * | ||
3 | * You are welcome to use the general ideas of this design for your own sites. | ||
4 | * But please do not steal the stylesheet, the layout or the color scheme. | ||
5 | */ | ||
6 | body { | ||
7 | font-family: serif; | ||
8 | font-size: 11pt; | ||
9 | margin: 0 3em; | ||
10 | padding: 0; | ||
11 | border: none; | ||
12 | } | ||
13 | a:link, a:visited, a:hover, a:active { | ||
14 | text-decoration: none; | ||
15 | background: transparent; | ||
16 | color: #0000ff; | ||
17 | } | ||
18 | h1, h2, h3 { | ||
19 | font-family: sans-serif; | ||
20 | font-weight: bold; | ||
21 | text-align: left; | ||
22 | margin: 0.5em 0; | ||
23 | padding: 0; | ||
24 | } | ||
25 | h1 { | ||
26 | font-size: 200%; | ||
27 | } | ||
28 | h2 { | ||
29 | font-size: 150%; | ||
30 | } | ||
31 | h3 { | ||
32 | font-size: 125%; | ||
33 | } | ||
34 | p { | ||
35 | margin: 0 0 0.5em 0; | ||
36 | padding: 0; | ||
37 | } | ||
38 | ul, ol { | ||
39 | margin: 0.5em 0; | ||
40 | padding: 0 0 0 2em; | ||
41 | } | ||
42 | ul { | ||
43 | list-style: outside square; | ||
44 | } | ||
45 | ol { | ||
46 | list-style: outside decimal; | ||
47 | } | ||
48 | li { | ||
49 | margin: 0; | ||
50 | padding: 0; | ||
51 | } | ||
52 | dl { | ||
53 | margin: 1em 0; | ||
54 | padding: 1em; | ||
55 | border: 1px solid black; | ||
56 | } | ||
57 | dt { | ||
58 | font-weight: bold; | ||
59 | margin: 0; | ||
60 | padding: 0; | ||
61 | } | ||
62 | dt sup { | ||
63 | float: right; | ||
64 | margin-left: 1em; | ||
65 | } | ||
66 | dd { | ||
67 | margin: 0.5em 0 0 2em; | ||
68 | padding: 0; | ||
69 | } | ||
70 | table { | ||
71 | table-layout: fixed; | ||
72 | width: 100%; | ||
73 | margin: 1em 0; | ||
74 | padding: 0; | ||
75 | border: 1px solid black; | ||
76 | border-spacing: 0; | ||
77 | border-collapse: collapse; | ||
78 | } | ||
79 | tr { | ||
80 | margin: 0; | ||
81 | padding: 0; | ||
82 | border: none; | ||
83 | } | ||
84 | td { | ||
85 | text-align: left; | ||
86 | margin: 0; | ||
87 | padding: 0.2em 0.5em; | ||
88 | border-top: 1px solid black; | ||
89 | border-bottom: 1px solid black; | ||
90 | } | ||
91 | tr.separate td { | ||
92 | border-top: double; | ||
93 | } | ||
94 | tt, pre, code, kbd, samp { | ||
95 | font-family: monospace; | ||
96 | font-size: 75%; | ||
97 | } | ||
98 | kbd { | ||
99 | font-weight: bolder; | ||
100 | } | ||
101 | blockquote, pre { | ||
102 | margin: 1em 2em; | ||
103 | padding: 0; | ||
104 | } | ||
105 | img { | ||
106 | border: none; | ||
107 | vertical-align: baseline; | ||
108 | margin: 0; | ||
109 | padding: 0; | ||
110 | } | ||
111 | img.left { | ||
112 | float: left; | ||
113 | margin: 0.5em 1em 0.5em 0; | ||
114 | } | ||
115 | img.right { | ||
116 | float: right; | ||
117 | margin: 0.5em 0 0.5em 1em; | ||
118 | } | ||
119 | .flush { | ||
120 | clear: both; | ||
121 | visibility: hidden; | ||
122 | } | ||
123 | .hide, .noprint, #nav { | ||
124 | display: none !important; | ||
125 | } | ||
126 | .pagebreak { | ||
127 | page-break-before: always; | ||
128 | } | ||
129 | #site { | ||
130 | text-align: right; | ||
131 | font-family: sans-serif; | ||
132 | font-weight: bold; | ||
133 | margin: 0 1em; | ||
134 | border-bottom: 1pt solid black; | ||
135 | } | ||
136 | #site a { | ||
137 | font-size: 1.2em; | ||
138 | } | ||
139 | #site a:link, #site a:visited { | ||
140 | text-decoration: none; | ||
141 | font-weight: bold; | ||
142 | background: transparent; | ||
143 | color: #ffffff; | ||
144 | } | ||
145 | #logo { | ||
146 | color: #ff8000; | ||
147 | } | ||
148 | #head { | ||
149 | clear: both; | ||
150 | margin: 0 1em; | ||
151 | } | ||
152 | #main { | ||
153 | line-height: 1.3; | ||
154 | text-align: justify; | ||
155 | margin: 1em; | ||
156 | } | ||
157 | #foot { | ||
158 | clear: both; | ||
159 | font-size: 80%; | ||
160 | text-align: center; | ||
161 | margin: 0 1.25em; | ||
162 | padding: 0.5em 0 0 0; | ||
163 | border-top: 1pt solid black; | ||
164 | page-break-before: avoid; | ||
165 | page-break-after: avoid; | ||
166 | } | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/bluequad.css b/libraries/LuaJIT-1.1.7/jitdoc/bluequad.css new file mode 100644 index 0000000..8d72de9 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/bluequad.css | |||
@@ -0,0 +1,292 @@ | |||
1 | /* Copyright (C) 2004-2011 Mike Pall. | ||
2 | * | ||
3 | * You are welcome to use the general ideas of this design for your own sites. | ||
4 | * But please do not steal the stylesheet, the layout or the color scheme. | ||
5 | */ | ||
6 | /* colorscheme: | ||
7 | * | ||
8 | * site | head #4162bf/white | #6078bf/#e6ecff | ||
9 | * ------+------ ----------------+------------------- | ||
10 | * nav | main #bfcfff | #e6ecff/black | ||
11 | * | ||
12 | * nav: hiback loback #c5d5ff #b9c9f9 | ||
13 | * hiborder loborder #e6ecff #97a7d7 | ||
14 | * link hover #2142bf #ff0000 | ||
15 | * | ||
16 | * link: link visited hover #2142bf #8122bf #ff0000 | ||
17 | * | ||
18 | * main: boxback boxborder #f0f4ff #bfcfff | ||
19 | */ | ||
20 | body { | ||
21 | font-family: Verdana, Arial, Helvetica, sans-serif; | ||
22 | font-size: 10pt; | ||
23 | margin: 0; | ||
24 | padding: 0; | ||
25 | border: none; | ||
26 | background: #e0e0e0; | ||
27 | color: #000000; | ||
28 | } | ||
29 | a:link { | ||
30 | text-decoration: none; | ||
31 | background: transparent; | ||
32 | color: #2142bf; | ||
33 | } | ||
34 | a:visited { | ||
35 | text-decoration: none; | ||
36 | background: transparent; | ||
37 | color: #8122bf; | ||
38 | } | ||
39 | a:hover, a:active { | ||
40 | text-decoration: underline; | ||
41 | background: transparent; | ||
42 | color: #ff0000; | ||
43 | } | ||
44 | h1, h2, h3 { | ||
45 | font-weight: bold; | ||
46 | text-align: left; | ||
47 | margin: 0.5em 0; | ||
48 | padding: 0; | ||
49 | background: transparent; | ||
50 | } | ||
51 | h1 { | ||
52 | font-size: 200%; | ||
53 | line-height: 3em; /* really 6em relative to body, match #site span */ | ||
54 | margin: 0; | ||
55 | } | ||
56 | h2 { | ||
57 | font-size: 150%; | ||
58 | color: #606060; | ||
59 | } | ||
60 | h3 { | ||
61 | font-size: 125%; | ||
62 | color: #404040; | ||
63 | } | ||
64 | p { | ||
65 | max-width: 600px; | ||
66 | margin: 0 0 0.5em 0; | ||
67 | padding: 0; | ||
68 | } | ||
69 | ul, ol { | ||
70 | max-width: 600px; | ||
71 | margin: 0.5em 0; | ||
72 | padding: 0 0 0 2em; | ||
73 | } | ||
74 | ul { | ||
75 | list-style: outside square; | ||
76 | } | ||
77 | ol { | ||
78 | list-style: outside decimal; | ||
79 | } | ||
80 | li { | ||
81 | margin: 0; | ||
82 | padding: 0; | ||
83 | } | ||
84 | dl { | ||
85 | max-width: 600px; | ||
86 | margin: 1em 0; | ||
87 | padding: 1em; | ||
88 | border: 1px solid #bfcfff; | ||
89 | background: #f0f4ff; | ||
90 | } | ||
91 | dt { | ||
92 | font-weight: bold; | ||
93 | margin: 0; | ||
94 | padding: 0; | ||
95 | } | ||
96 | dt sup { | ||
97 | float: right; | ||
98 | margin-left: 1em; | ||
99 | color: #808080; | ||
100 | } | ||
101 | dt a:visited { | ||
102 | text-decoration: none; | ||
103 | color: #2142bf; | ||
104 | } | ||
105 | dt a:hover, dt a:active { | ||
106 | text-decoration: none; | ||
107 | color: #ff0000; | ||
108 | } | ||
109 | dd { | ||
110 | margin: 0.5em 0 0 2em; | ||
111 | padding: 0; | ||
112 | } | ||
113 | div.tablewrap { /* for IE *sigh* */ | ||
114 | max-width: 600px; | ||
115 | } | ||
116 | table { | ||
117 | table-layout: fixed; | ||
118 | border-spacing: 0; | ||
119 | border-collapse: collapse; | ||
120 | max-width: 600px; | ||
121 | width: 100%; | ||
122 | margin: 1em 0; | ||
123 | padding: 0; | ||
124 | border: 1px solid #bfcfff; | ||
125 | } | ||
126 | tr { | ||
127 | margin: 0; | ||
128 | padding: 0; | ||
129 | border: none; | ||
130 | } | ||
131 | tr.odd { | ||
132 | background: #f0f4ff; | ||
133 | } | ||
134 | tr.separate td { | ||
135 | border-top: 1px solid #bfcfff; | ||
136 | } | ||
137 | td { | ||
138 | text-align: left; | ||
139 | margin: 0; | ||
140 | padding: 0.2em 0.5em; | ||
141 | border: none; | ||
142 | } | ||
143 | tt, code, kbd, samp { | ||
144 | font-family: Courier New, Courier, monospace; | ||
145 | font-size: 110%; | ||
146 | } | ||
147 | kbd { | ||
148 | font-weight: bolder; | ||
149 | } | ||
150 | blockquote, pre { | ||
151 | max-width: 600px; | ||
152 | margin: 1em 2em; | ||
153 | padding: 0; | ||
154 | } | ||
155 | pre { | ||
156 | line-height: 1.1; | ||
157 | } | ||
158 | img { | ||
159 | border: none; | ||
160 | vertical-align: baseline; | ||
161 | margin: 0; | ||
162 | padding: 0; | ||
163 | } | ||
164 | img.left { | ||
165 | float: left; | ||
166 | margin: 0.5em 1em 0.5em 0; | ||
167 | } | ||
168 | img.right { | ||
169 | float: right; | ||
170 | margin: 0.5em 0 0.5em 1em; | ||
171 | } | ||
172 | .indent { | ||
173 | padding-left: 1em; | ||
174 | } | ||
175 | .flush { | ||
176 | clear: both; | ||
177 | visibility: hidden; | ||
178 | } | ||
179 | .hide, .noscreen { | ||
180 | display: none !important; | ||
181 | } | ||
182 | .ext { | ||
183 | color: #ff8000; | ||
184 | } | ||
185 | #site { | ||
186 | clear: both; | ||
187 | float: left; | ||
188 | width: 13em; | ||
189 | text-align: center; | ||
190 | font-weight: bold; | ||
191 | margin: 0; | ||
192 | padding: 0; | ||
193 | background: transparent; | ||
194 | color: #ffffff; | ||
195 | } | ||
196 | #site a { | ||
197 | font-size: 200%; | ||
198 | } | ||
199 | #site a:link, #site a:visited { | ||
200 | text-decoration: none; | ||
201 | font-weight: bold; | ||
202 | background: transparent; | ||
203 | color: #ffffff; | ||
204 | } | ||
205 | #site span { | ||
206 | line-height: 3em; /* really 6em relative to body, match h1 */ | ||
207 | } | ||
208 | #logo { | ||
209 | color: #ffb380; | ||
210 | } | ||
211 | #head { | ||
212 | margin: 0; | ||
213 | padding: 0 0 0 2em; | ||
214 | border-left: solid 13em #4162bf; | ||
215 | border-right: solid 3em #6078bf; | ||
216 | background: #6078bf; | ||
217 | color: #e6ecff; | ||
218 | } | ||
219 | #nav { | ||
220 | clear: both; | ||
221 | float: left; | ||
222 | overflow: hidden; | ||
223 | text-align: left; | ||
224 | line-height: 1.5; | ||
225 | width: 13em; | ||
226 | padding-top: 1em; | ||
227 | background: transparent; | ||
228 | } | ||
229 | #nav ul { | ||
230 | list-style: none outside; | ||
231 | margin: 0; | ||
232 | padding: 0; | ||
233 | } | ||
234 | #nav li { | ||
235 | margin: 0; | ||
236 | padding: 0; | ||
237 | } | ||
238 | #nav a { | ||
239 | display: block; | ||
240 | text-decoration: none; | ||
241 | font-weight: bold; | ||
242 | margin: 0; | ||
243 | padding: 2px 1em; | ||
244 | border-top: 1px solid transparent; | ||
245 | border-bottom: 1px solid transparent; | ||
246 | background: transparent; | ||
247 | color: #2142bf; | ||
248 | } | ||
249 | #nav a:hover, #nav a:active { | ||
250 | text-decoration: none; | ||
251 | border-top: 1px solid #97a7d7; | ||
252 | border-bottom: 1px solid #e6ecff; | ||
253 | background: #b9c9f9; | ||
254 | color: #ff0000; | ||
255 | } | ||
256 | #nav a.current, #nav a.current:hover, #nav a.current:active { | ||
257 | border-top: 1px solid #e6ecff; | ||
258 | border-bottom: 1px solid #97a7d7; | ||
259 | background: #c5d5ff; | ||
260 | color: #2142bf; | ||
261 | } | ||
262 | #nav ul ul a { | ||
263 | padding: 0 1em 0 2em; | ||
264 | } | ||
265 | #main { | ||
266 | line-height: 1.5; | ||
267 | text-align: left; | ||
268 | margin: 0; | ||
269 | padding: 1em 2em; | ||
270 | border-left: solid 13em #bfcfff; | ||
271 | border-right: solid 3em #e6ecff; | ||
272 | background: #e6ecff; | ||
273 | } | ||
274 | #foot { | ||
275 | clear: both; | ||
276 | font-size: 80%; | ||
277 | text-align: center; | ||
278 | margin: 0; | ||
279 | padding: 0.5em; | ||
280 | background: #6078bf; | ||
281 | color: #ffffff; | ||
282 | } | ||
283 | #foot a:link, #foot a:visited { | ||
284 | text-decoration: underline; | ||
285 | background: transparent; | ||
286 | color: #ffffff; | ||
287 | } | ||
288 | #foot a:hover, #foot a:active { | ||
289 | text-decoration: underline; | ||
290 | background: transparent; | ||
291 | color: #bfcfff; | ||
292 | } | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/coco.html b/libraries/LuaJIT-1.1.7/jitdoc/coco.html new file mode 100644 index 0000000..0ef43f1 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/coco.html | |||
@@ -0,0 +1,132 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Coco</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Coco</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a class="current" href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | Coco is a small extension to get <strong>True C Coroutine</strong> | ||
64 | semantics for Lua 5.1. | ||
65 | </p> | ||
66 | <p> | ||
67 | Coco is both available as a stand-alone release and integrated | ||
68 | into <a href="luajit.html">LuaJIT</a> 1.x. | ||
69 | </p> | ||
70 | <p> | ||
71 | The stand-alone release is a patchset against the | ||
72 | <a href="http://www.lua.org/ftp/"><span class="ext">»</span> standard Lua 5.1.4</a> | ||
73 | distribution. There are no dependencies on LuaJIT. However LuaJIT 1.x | ||
74 | depends on Coco to allow yielding for JIT compiled functions. | ||
75 | </p> | ||
76 | <p> | ||
77 | Coco is Copyright © 2004-2011 Mike Pall. | ||
78 | Coco is free software, released under the | ||
79 | <a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">»</span> MIT/X license</a> | ||
80 | (same license as the Lua core). | ||
81 | </p> | ||
82 | <h2>Features</h2> | ||
83 | <p> | ||
84 | True C coroutine semantics mean you can yield from a coroutine | ||
85 | across a C call boundary and resume back to it. | ||
86 | </p> | ||
87 | <p> | ||
88 | Coco allows you to use a dedicated C stack for each coroutine. | ||
89 | Resuming a coroutine and yielding from a coroutine automatically switches | ||
90 | C stacks, too. | ||
91 | </p> | ||
92 | <p> | ||
93 | In particular you can now: | ||
94 | </p> | ||
95 | <ul> | ||
96 | <li>Yield across all metamethods (not advised for <tt>__gc</tt>).</li> | ||
97 | <li>Yield across iterator functions (<tt>for x in func do</tt>).</li> | ||
98 | <li>Yield across callbacks (<tt>table.foreach()</tt>, <tt>dofile()</tt>, ...).</li> | ||
99 | <li>Yield across protected callbacks (<tt>pcall()</tt>, <tt>xpcall()</tt>, ...).</li> | ||
100 | <li>Yield from C functions and resume back to them.</li> | ||
101 | </ul> | ||
102 | <p> | ||
103 | Best of all, you don't need to change your Lua or C sources | ||
104 | and still get the benefits. It's fully integrated into the | ||
105 | Lua core, but tries to minimize the required changes. | ||
106 | </p> | ||
107 | |||
108 | <h2>More ...</h2> | ||
109 | <p> | ||
110 | Please visit the <a href="http://luajit.org/download.html"><span class="ext">»</span> Download</a> page | ||
111 | to fetch the current version of the stand-alone package. | ||
112 | </p> | ||
113 | <p> | ||
114 | Coco needs some machine-specific features — please have a look | ||
115 | at the <a href="coco_portability.html">Portability Requirements</a>. | ||
116 | </p> | ||
117 | <p> | ||
118 | Coco also provides some upwards-compatible | ||
119 | <a href="coco_api.html">API Extensions</a> for Lua. | ||
120 | </p> | ||
121 | <br class="flush"> | ||
122 | </div> | ||
123 | <div id="foot"> | ||
124 | <hr class="hide"> | ||
125 | Copyright © 2005-2011 Mike Pall | ||
126 | <span class="noprint"> | ||
127 | · | ||
128 | <a href="contact.html">Contact</a> | ||
129 | </span> | ||
130 | </div> | ||
131 | </body> | ||
132 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/coco_api.html b/libraries/LuaJIT-1.1.7/jitdoc/coco_api.html new file mode 100644 index 0000000..990ac5b --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/coco_api.html | |||
@@ -0,0 +1,182 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Coco API Extensions</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Coco API Extensions</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a class="current" href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | Coco changes the semantics of several standard API functions and | ||
64 | provides a few API extensions for Lua. | ||
65 | </p> | ||
66 | <p> | ||
67 | By default all your coroutines get an associated C stack. | ||
68 | If you want to be more selective, see below. | ||
69 | </p> | ||
70 | |||
71 | <h2>Lua API extensions</h2> | ||
72 | <p> | ||
73 | All <tt>coroutine.*</tt> functions should be fully upwards compatible. | ||
74 | </p> | ||
75 | |||
76 | <h3><tt>coroutine.coco</tt></h3> | ||
77 | <p> | ||
78 | This field is <tt>true</tt> when Coco is present (nil otherwise). | ||
79 | </p> | ||
80 | |||
81 | <h3><tt>coro = coroutine.create(f [, cstacksize])<br> | ||
82 | func = coroutine.wrap(f [, cstacksize])</tt></h3> | ||
83 | <p> | ||
84 | The optional argument <tt>cstacksize</tt> specifies the size of the | ||
85 | C stack to allocate for the coroutine: | ||
86 | </p> | ||
87 | <ul> | ||
88 | <li>A default stack size is used if <tt>cstacksize</tt> is not given | ||
89 | or is nil or zero.</li> | ||
90 | <li>No C stack is allocated if <tt>cstacksize</tt> is -1.</li> | ||
91 | <li>Any other value is rounded up to the minimum size | ||
92 | (i.e. use 1 to get the minimum size).</li> | ||
93 | </ul> | ||
94 | <p> | ||
95 | Important notice for LuaJIT: JIT compiled functions cannot | ||
96 | yield if a coroutine does not have a dedicated C stack. | ||
97 | </p> | ||
98 | |||
99 | <h3><tt>olddefault = coroutine.cstacksize([newdefault])</tt></h3> | ||
100 | <p> | ||
101 | Returns the current default C stack size (may be 0 if the | ||
102 | underlying context switch method has its own default). | ||
103 | Sets a new default C stack size if <tt>newdefault</tt> is present. | ||
104 | Use 0 to reset it to the default C stack size. Any other | ||
105 | value is rounded up to the minimum size. | ||
106 | </p> | ||
107 | |||
108 | <h2>C API extensions</h2> | ||
109 | <p> | ||
110 | All C API functions are either unchanged or upwards compatible. | ||
111 | </p> | ||
112 | |||
113 | <h3><tt>int lua_yield(lua_State *L, int nresults)</tt></h3> | ||
114 | <p> | ||
115 | The semantics for <tt>lua_yield()</tt> have changed slightly. | ||
116 | Existing programs should work fine as long as they follow | ||
117 | the usage conventions from the Lua manual: | ||
118 | </p> | ||
119 | <pre> | ||
120 | return lua_yield(L, nresults); | ||
121 | </pre> | ||
122 | <p> | ||
123 | Previously <tt>lua_yield()</tt> returned a 'magic' value (<tt>-1</tt>) that | ||
124 | indicated a yield. Your C function had to pass this value | ||
125 | on to the Lua core and was <em>not</em> called again. | ||
126 | </p> | ||
127 | <p> | ||
128 | Now, if the current coroutine has an associated C stack, | ||
129 | <tt>lua_yield()</tt> returns the number of arguments passed back from | ||
130 | the resume. This just happens to be the right convention for | ||
131 | returning them as a result from a C function. I.e. if you | ||
132 | used the above convention, you'll never notice the change. | ||
133 | </p> | ||
134 | <p> | ||
135 | But the results <em>are</em> on the Lua stack when <tt>lua_yield()</tt> | ||
136 | returns. So the C function can just continue and process them | ||
137 | or retry an I/O operation etc. And your whole C stack frame | ||
138 | (local variables etc.) is still there, too. You can yield from | ||
139 | anywhere in your C program, even several call levels deeper. | ||
140 | </p> | ||
141 | <p> | ||
142 | Of course all of this only works with Lua+Coco and not with standard Lua. | ||
143 | </p> | ||
144 | |||
145 | <h3><tt>lua_State *lua_newcthread(lua_State *L, int cstacksize)</tt></h3> | ||
146 | <p> | ||
147 | This is an (optional) new function that allows you to create | ||
148 | a coroutine with an associated C stack directly from the C API. | ||
149 | Other than that it works the same as <tt>lua_newthread(L)</tt>. | ||
150 | </p> | ||
151 | <p> | ||
152 | You have to declare this function as <tt>extern</tt> | ||
153 | yourself, since it's not part of the official Lua API. | ||
154 | This means that a C module that uses this call cannot | ||
155 | be loaded with standard Lua. This may be intentional. | ||
156 | </p> | ||
157 | <p> | ||
158 | If you want your C module to work with both standard Lua | ||
159 | and Lua+Coco you can check whether Coco is available with: | ||
160 | </p> | ||
161 | <pre> | ||
162 | lua_getfield(L, LUA_GLOBALSINDEX, "coroutine"); | ||
163 | lua_getfield(L, -1, "coco"); | ||
164 | coco_available = lua_toboolean(L, -1); | ||
165 | lua_pop(L, 2); | ||
166 | </pre> | ||
167 | <p> | ||
168 | You can create coroutines with a C stack by calling | ||
169 | the Lua function <tt>coroutine.create()</tt> from C, too. | ||
170 | </p> | ||
171 | <br class="flush"> | ||
172 | </div> | ||
173 | <div id="foot"> | ||
174 | <hr class="hide"> | ||
175 | Copyright © 2005-2011 Mike Pall | ||
176 | <span class="noprint"> | ||
177 | · | ||
178 | <a href="contact.html">Contact</a> | ||
179 | </span> | ||
180 | </div> | ||
181 | </body> | ||
182 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/coco_changes.html b/libraries/LuaJIT-1.1.7/jitdoc/coco_changes.html new file mode 100644 index 0000000..ea2dc16 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/coco_changes.html | |||
@@ -0,0 +1,146 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Coco Change History</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Coco Change History</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a class="current" href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | This is a list of changes between the released versions of Coco. | ||
64 | The current stand-alone release is <strong>Coco 1.1.6</strong>. | ||
65 | </p> | ||
66 | <p> | ||
67 | Please check the | ||
68 | <a href="http://coco.luajit.org/changes.html"><span class="ext">»</span> Online Change History</a> | ||
69 | to see whether newer versions are available. | ||
70 | </p> | ||
71 | |||
72 | <h2 id="Coco-1.1.6">Coco 1.1.6 — 2009-09-08</h2> | ||
73 | <ul> | ||
74 | <li>Fix compilation of the GCC inline assembler code on x64. | ||
75 | Now works when compiled as C++ code (reported by Jonathan Sauer) | ||
76 | or with -fPIC (reported by Jim Pryor).</li> | ||
77 | <li>Added GCC inline assembler for faster context switching on Sparc. | ||
78 | Thanks to Takayuki Usui.</li> | ||
79 | </ul> | ||
80 | |||
81 | <h2 id="Coco-1.1.5">Coco 1.1.5 — 2008-10-25</h2> | ||
82 | <ul> | ||
83 | <li>Upgraded to patch cleanly into Lua 5.1.4.</li> | ||
84 | <li>Added GCC inline assembler for faster context switching on x64. | ||
85 | Thanks to Robert G. Jakabosky.</li> | ||
86 | </ul> | ||
87 | |||
88 | <h2 id="Coco-1.1.4">Coco 1.1.4 — 2008-02-05</h2> | ||
89 | <ul> | ||
90 | <li>Upgraded to patch cleanly into Lua 5.1.3.</li> | ||
91 | <li>Fixed setjmp method for ARM with recent glibc versions. | ||
92 | Thanks to the LuaTeX developers.</li> | ||
93 | <li>Fixed setjmp method for x86 on Mac OS X (rarely used, | ||
94 | default is GCC inline assembler). Thanks to Jason Toffaletti.</li> | ||
95 | </ul> | ||
96 | |||
97 | <h2 id="Coco-1.1.3">Coco 1.1.3 — 2007-05-24</h2> | ||
98 | <ul> | ||
99 | <li>Upgraded to patch cleanly into Lua 5.1.2.</li> | ||
100 | <li>Merged patch from Zachary P. Landau for a Linux/ARM setjmp method (uClibc and glibc).</li> | ||
101 | </ul> | ||
102 | |||
103 | <h2 id="Coco-1.1.1">Coco 1.1.1 — 2006-06-20</h2> | ||
104 | <ul> | ||
105 | <li>Upgraded to patch cleanly into Lua 5.1.1.</li> | ||
106 | <li>C stacks are deallocated early: when a coroutine ends, and not when | ||
107 | the coroutine object is collected. This mainly benefits Windows Fibers.</li> | ||
108 | <li>Windows threads get the required Fiber context when resuming | ||
109 | a coroutine and not just on creation.</li> | ||
110 | </ul> | ||
111 | |||
112 | <h2 id="Coco-1.1.0">Coco 1.1.0 — 2006-02-18</h2> | ||
113 | <ul> | ||
114 | <li>Upgraded to patch cleanly into Lua 5.1 (final).</li> | ||
115 | <li>Added GCC inline assembler for context switching on x86 and MIPS32 | ||
116 | [up to 3x faster].</li> | ||
117 | <li>New targets for setjmp method: | ||
118 | Mac OS X/x86, Solaris/x86 and x64 and Linux/MIPS32.</li> | ||
119 | <li>Workaround for WinXP problem with GetCurrentFiber().</li> | ||
120 | <li>The minimum C stack size has been increased to 32K+4K.</li> | ||
121 | <li>Removed <tt>lcocolib.c</tt> and integrated the (much smaller) changes | ||
122 | into <tt>lbaselib.c</tt>.<br> | ||
123 | Note for embedders: this means you no longer need to call | ||
124 | <tt>luaopen_coco()</tt>.</li> | ||
125 | <li>Optional Valgrind support requires version 3.x. | ||
126 | Renamed define to USE_VALGRIND.</li> | ||
127 | <li>C stacks are now registered with Valgrind.</li> | ||
128 | </ul> | ||
129 | |||
130 | <h2 id="Coco-51w6">Coco pre-release 51w6 — 2005-08-09</h2> | ||
131 | <p> | ||
132 | This is the first pre-release of Coco. It targets Lua 5.1-work6 only | ||
133 | and is no longer available for download. | ||
134 | </p> | ||
135 | <br class="flush"> | ||
136 | </div> | ||
137 | <div id="foot"> | ||
138 | <hr class="hide"> | ||
139 | Copyright © 2005-2011 Mike Pall | ||
140 | <span class="noprint"> | ||
141 | · | ||
142 | <a href="contact.html">Contact</a> | ||
143 | </span> | ||
144 | </div> | ||
145 | </body> | ||
146 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html b/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html new file mode 100644 index 0000000..e120ae9 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html | |||
@@ -0,0 +1,235 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Portability Requirements for Coco</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | <style type="text/css"> | ||
12 | table.support { | ||
13 | line-height: 1.2; | ||
14 | width: 25em; | ||
15 | } | ||
16 | tr.supporthead td { | ||
17 | font-weight: bold; | ||
18 | } | ||
19 | td.supportcpu { | ||
20 | width: 6em; | ||
21 | } | ||
22 | td.supportsys { | ||
23 | width: 8em; | ||
24 | } | ||
25 | </style> | ||
26 | </head> | ||
27 | <body> | ||
28 | <div id="site"> | ||
29 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
30 | </div> | ||
31 | <div id="head"> | ||
32 | <h1>Portability Requirements for Coco</h1> | ||
33 | </div> | ||
34 | <div id="nav"> | ||
35 | <ul><li> | ||
36 | <a href="index.html">Index</a> | ||
37 | </li><li> | ||
38 | <a href="luajit.html">LuaJIT</a> | ||
39 | <ul><li> | ||
40 | <a href="luajit_features.html">Features</a> | ||
41 | </li><li> | ||
42 | <a href="luajit_install.html">Installation</a> | ||
43 | </li><li> | ||
44 | <a href="luajit_run.html">Running</a> | ||
45 | </li><li> | ||
46 | <a href="luajit_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="luajit_intro.html">Introduction</a> | ||
49 | </li><li> | ||
50 | <a href="luajit_performance.html">Performance</a> | ||
51 | </li><li> | ||
52 | <a href="luajit_debug.html">Debugging</a> | ||
53 | </li><li> | ||
54 | <a href="luajit_changes.html">Changes</a> | ||
55 | </li></ul> | ||
56 | </li><li> | ||
57 | <a href="coco.html">Coco</a> | ||
58 | <ul><li> | ||
59 | <a class="current" href="coco_portability.html">Portability</a> | ||
60 | </li><li> | ||
61 | <a href="coco_api.html">API Extensions</a> | ||
62 | </li><li> | ||
63 | <a href="coco_changes.html">Changes</a> | ||
64 | </li></ul> | ||
65 | </li><li> | ||
66 | <a href="dynasm.html">DynASM</a> | ||
67 | <ul><li> | ||
68 | <a href="dynasm_features.html">Features</a> | ||
69 | </li><li> | ||
70 | <a href="dynasm_examples.html">Examples</a> | ||
71 | </li></ul> | ||
72 | </li><li> | ||
73 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
74 | </li></ul> | ||
75 | </div> | ||
76 | <div id="main"> | ||
77 | <p> | ||
78 | Coco needs some machine-specific features which are | ||
79 | inherently non-portable. Although the coverage is pretty good, | ||
80 | this means that Coco will probably never be a standard part | ||
81 | of the Lua core (which is pure ANSI C). | ||
82 | </p> | ||
83 | |||
84 | <h2>Context Switching Methods</h2> | ||
85 | <p> | ||
86 | Coco relies on four different machine-specific methods | ||
87 | for allocating a C stack and switching context. | ||
88 | The appropriate method is automatically selected at compile time. | ||
89 | </p> | ||
90 | |||
91 | <h3>GCC Inline Assembler</h3> | ||
92 | <p> | ||
93 | This method is only available when GCC 3.x/4.x is used | ||
94 | to compile the source. | ||
95 | This is the fastest method for context switching, but only available | ||
96 | for a few CPUs (see below). | ||
97 | </p> | ||
98 | |||
99 | <h3>Modified setjmp Buffer</h3> | ||
100 | <p> | ||
101 | This method changes a few fields in the setjmp buffer to | ||
102 | redirect the next longjmp to a new function with a new stack | ||
103 | frame. It needs a bit of guesswork and lots of #ifdef's to | ||
104 | handle the supported CPU/OS combinations, but this is quite | ||
105 | manageable. | ||
106 | </p> | ||
107 | <p> | ||
108 | This is the fallback method if inline assembler is not available. | ||
109 | It's pretty fast because it doesn't have to save or restore signals | ||
110 | (which is slow and generally undesirable for Lua coroutines). | ||
111 | </p> | ||
112 | |||
113 | <h3>POSIX ucontext</h3> | ||
114 | <p> | ||
115 | The POSIX calls getcontext, makecontext and switchcontext | ||
116 | are used to set up and switch between different C stacks. | ||
117 | Although highly portable and even available for some | ||
118 | esoteric platforms, it's slower than the setjmp method | ||
119 | because it saves and restores signals, too (using at least one | ||
120 | syscall for each context switch). | ||
121 | </p> | ||
122 | <p> | ||
123 | You can force the use of ucontext (instead of setjmp) by enabling | ||
124 | <tt>-DCOCO_USE_UCONTEXT</tt> in <tt>src/Makefile</tt>. | ||
125 | </p> | ||
126 | |||
127 | <h3>Windows Fibers</h3> | ||
128 | <p> | ||
129 | This is the standard method to set up and switch between | ||
130 | different C stacks on Windows. It's available on Windows 98 | ||
131 | and later. | ||
132 | </p> | ||
133 | <p> | ||
134 | None of the other methods work for Windows because OS specific code | ||
135 | is required to switch exception handling contexts. | ||
136 | </p> | ||
137 | |||
138 | <h2 class="pagebreak">Supported Platforms</h2> | ||
139 | <p> | ||
140 | Coco has support for the following platforms: | ||
141 | </p> | ||
142 | <table class="support"> | ||
143 | <tr class="supporthead"> | ||
144 | <td class="supportcpu">CPU</td> | ||
145 | <td class="supportsys">System</td> | ||
146 | <td>Method</td> | ||
147 | </tr> | ||
148 | <tr class="odd separate"> | ||
149 | <td class="supportcpu">x86</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
150 | <tr class="even"> | ||
151 | <td class="supportcpu">x86</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
152 | <tr class="odd"> | ||
153 | <td class="supportcpu">x86</td><td class="supportsys">FreeBSD</td><td>setjmp</td></tr> | ||
154 | <tr class="even"> | ||
155 | <td class="supportcpu">x86</td><td class="supportsys">NetBSD</td><td>setjmp</td></tr> | ||
156 | <tr class="odd"> | ||
157 | <td class="supportcpu">x86</td><td class="supportsys">OpenBSD</td><td>setjmp</td></tr> | ||
158 | <tr class="even"> | ||
159 | <td class="supportcpu">x86</td><td class="supportsys">Solaris</td><td>setjmp</td></tr> | ||
160 | <tr class="odd"> | ||
161 | <td class="supportcpu">x86</td><td class="supportsys">Mac OS X</td><td>setjmp</td></tr> | ||
162 | <tr class="even separate"> | ||
163 | <td class="supportcpu">x64</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
164 | <tr class="odd"> | ||
165 | <td class="supportcpu">x64</td><td class="supportsys">Solaris</td><td>setjmp</td></tr> | ||
166 | <tr class="even separate"> | ||
167 | <td class="supportcpu">MIPS32</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
168 | <tr class="odd"> | ||
169 | <td class="supportcpu">MIPS32</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
170 | <tr class="even separate"> | ||
171 | <td class="supportcpu">ARM</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
172 | <tr class="odd separate"> | ||
173 | <td class="supportcpu">PPC32</td><td class="supportsys">Mac OS X</td><td>setjmp</td></tr> | ||
174 | <tr class="even separate"> | ||
175 | <td class="supportcpu">(any CPU)</td><td class="supportsys">POSIX</td><td>ucontext</td></tr> | ||
176 | <tr class="odd separate"> | ||
177 | <td class="supportcpu">(any CPU)</td><td class="supportsys">Windows</td><td>fibers</td></tr> | ||
178 | </table> | ||
179 | <pre> | ||
180 | </pre> | ||
181 | <p> | ||
182 | It should work pretty much anywhere where a <em>correct</em> | ||
183 | POSIX ucontext implementation is available. It has been tested | ||
184 | on every systems I could get hold of (e.g. Sparc, PPC32/PPC64, | ||
185 | IA64, Alpha, HPPA with various operating systems). | ||
186 | </p> | ||
187 | |||
188 | <h2>Caveats</h2> | ||
189 | <ul> | ||
190 | <li> | ||
191 | Some older operating systems may have defective ucontext | ||
192 | implementations because this feature is not widely used. E.g. some | ||
193 | implementations don't mix well with other C library functions | ||
194 | like <tt>malloc()</tt> or with native threads. | ||
195 | This is really not the fault of Coco — please upgrade your OS. | ||
196 | </li> | ||
197 | <li> | ||
198 | Note for Windows: Please read the explanation for the default | ||
199 | <a href="http://msdn.microsoft.com/library/en-us/dllproc/base/thread_stack_size.asp"><span class="ext">»</span> Thread Stack Size</a> | ||
200 | in case you want to create large numbers of Fiber-based coroutines. | ||
201 | </li> | ||
202 | <li> | ||
203 | Note for MinGW/Cygwin: Older releases of GCC (before 4.0) generate | ||
204 | wrong unwind information when <tt>-fomit-frame-pointer</tt> is used | ||
205 | with stdcalls. This may lead to crashes when exceptions are thrown. | ||
206 | The workaround is to always use two flags:<br> | ||
207 | <tt>-fomit-frame-pointer -maccumulate-outgoing-args</tt>. | ||
208 | </li> | ||
209 | <li> | ||
210 | Note for MIPS CPUs without FPU: It's recommended to compile | ||
211 | <em>all</em> sources with <tt>-msoft-float</tt>, even if you don't use | ||
212 | any floating point ops anywhere. Otherwise context switching must | ||
213 | save and restore FPU registers (which needs to go through | ||
214 | the slow kernel emulation). | ||
215 | </li> | ||
216 | <li> | ||
217 | To run Coco with <a href="http://valgrind.org/"><span class="ext">»</span> Valgrind</a> | ||
218 | (a memory debugger) you <em>must</em> add <tt>-DUSE_VALGRIND</tt> | ||
219 | to <tt>MYCFLAGS</tt> and recompile. You will get random errors | ||
220 | if you don't! Valgrind 3.x or later is required. Earlier versions | ||
221 | do not work well with newly allocated C stacks. | ||
222 | </li> | ||
223 | </ul> | ||
224 | <br class="flush"> | ||
225 | </div> | ||
226 | <div id="foot"> | ||
227 | <hr class="hide"> | ||
228 | Copyright © 2005-2011 Mike Pall | ||
229 | <span class="noprint"> | ||
230 | · | ||
231 | <a href="contact.html">Contact</a> | ||
232 | </span> | ||
233 | </div> | ||
234 | </body> | ||
235 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/contact.html b/libraries/LuaJIT-1.1.7/jitdoc/contact.html new file mode 100644 index 0000000..5da1ecf --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/contact.html | |||
@@ -0,0 +1,105 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Contact</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Contact</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | Please send general questions regarding LuaJIT or Coco to the | ||
64 | <a href="http://www.lua.org/lua-l.html"><span class="ext">»</span> Lua mailing list</a>. | ||
65 | You can also send any questions you have directly to me: | ||
66 | </p> | ||
67 | |||
68 | <script type="text/javascript"> | ||
69 | <!-- | ||
70 | var xS="@-: .0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZa<b>cdefghijklmnopqrstuvwxyz" | ||
71 | function xD(s) | ||
72 | {var len=s.length;var r="";for(var i=0;i<len;i++) | ||
73 | {var c=s.charAt(i);var n=xS.indexOf(c);if(n!=-1) | ||
74 | c=xS.charAt(66-n);r+=c;} | ||
75 | document.write("<"+"p>"+r+"<"+"/p>\n");} | ||
76 | //--> | ||
77 | </script> | ||
78 | <script type="text/javascript"> | ||
79 | <!-- | ||
80 | xD("ewYKA7vu-EIwslx7 K9A.t41C") | ||
81 | //--></script> | ||
82 | <noscript> | ||
83 | <p><img src="img/contact.png" alt="Contact info in image" width="170" height="13"> | ||
84 | </p> | ||
85 | </noscript> | ||
86 | |||
87 | <h2>Copyright</h2> | ||
88 | <p> | ||
89 | All documentation is | ||
90 | Copyright © 2005-2011 Mike Pall. | ||
91 | </p> | ||
92 | |||
93 | |||
94 | <br class="flush"> | ||
95 | </div> | ||
96 | <div id="foot"> | ||
97 | <hr class="hide"> | ||
98 | Copyright © 2005-2011 Mike Pall | ||
99 | <span class="noprint"> | ||
100 | · | ||
101 | <a href="contact.html">Contact</a> | ||
102 | </span> | ||
103 | </div> | ||
104 | </body> | ||
105 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/dynasm.html b/libraries/LuaJIT-1.1.7/jitdoc/dynasm.html new file mode 100644 index 0000000..de8f859 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/dynasm.html | |||
@@ -0,0 +1,116 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>DynASM</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>DynASM</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a class="current" href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | DynASM is a <strong>Dynamic Assembler</strong> for code generation | ||
64 | engines. | ||
65 | </p> | ||
66 | <p> | ||
67 | DynASM has been developed primarily as a tool for | ||
68 | <a href="luajit.html">LuaJIT</a>, but might be useful for other | ||
69 | projects, too. | ||
70 | </p> | ||
71 | <p> | ||
72 | If you are writing a just-in-time compiler or need to generate | ||
73 | code on the fly (e.g. for high-performance graphics or other | ||
74 | CPU-intensive computations), DynASM might be just what you | ||
75 | are looking for. | ||
76 | </p> | ||
77 | <p> | ||
78 | Please have a look at the list of <a href="dynasm_features.html">Features</a> | ||
79 | to find out whether DynASM could be useful for your project. | ||
80 | </p> | ||
81 | <p> | ||
82 | DynASM is Copyright © 2005-2011 Mike Pall. | ||
83 | DynASM is free software, released under the | ||
84 | <a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">»</span> MIT/X license</a>. | ||
85 | </p> | ||
86 | |||
87 | <h2>More ...</h2> | ||
88 | <p> | ||
89 | Sorry, right now there is no proper documentation available other | ||
90 | than some <a href="dynasm_examples.html">Examples</a> and of course | ||
91 | the source code. The source <em>is</em> well documented, though (IMHO). | ||
92 | </p> | ||
93 | <p> | ||
94 | I may add more docs in case someone actually finds DynASM to be | ||
95 | useful outside of LuaJIT. If you do, I'd like to | ||
96 | <a href="contact.html">hear</a> from you, please. Thank you! | ||
97 | </p> | ||
98 | <p> | ||
99 | If you want to check it out please visit the | ||
100 | <a href="http://luajit.org/download.html"><span class="ext">»</span> Download</a> page and fetch the most recent | ||
101 | version of LuaJIT. All you need is in the dynasm directory. | ||
102 | For some complex examples take a peek at the | ||
103 | <tt>*.dasc</tt> and <tt>*.dash</tt> files in LuaJIT, too. | ||
104 | </p> | ||
105 | <br class="flush"> | ||
106 | </div> | ||
107 | <div id="foot"> | ||
108 | <hr class="hide"> | ||
109 | Copyright © 2005-2011 Mike Pall | ||
110 | <span class="noprint"> | ||
111 | · | ||
112 | <a href="contact.html">Contact</a> | ||
113 | </span> | ||
114 | </div> | ||
115 | </body> | ||
116 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/dynasm_examples.html b/libraries/LuaJIT-1.1.7/jitdoc/dynasm_examples.html new file mode 100644 index 0000000..5d2331e --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/dynasm_examples.html | |||
@@ -0,0 +1,188 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>DynASM Examples</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>DynASM Examples</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a class="current" href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <h2>A Simple Example</h2> | ||
63 | <p> | ||
64 | To get you started, here is a simple code snippet to be pre-processed. | ||
65 | The lines starting with '|' (the pipe symbol) are for DynASM: | ||
66 | </p> | ||
67 | <pre> | ||
68 | if (ptr != NULL) { | ||
69 | | mov eax, foo+17 | ||
70 | | mov edx, [eax+esi*2+0x20] | ||
71 | | add ebx, [ecx+bar(ptr, 9)] | ||
72 | } | ||
73 | </pre> | ||
74 | <p> | ||
75 | After pre-processing you get: | ||
76 | </p> | ||
77 | <pre> | ||
78 | if (ptr != NULL) { | ||
79 | dasm_put(Dst, 123, foo+17, bar(ptr, 9)); | ||
80 | } | ||
81 | </pre> | ||
82 | <p style="font-size: 80%;"> | ||
83 | Note: yes, you usually get the assembler code as comments and proper | ||
84 | CPP directives to match them up with the source. I've omitted | ||
85 | them here for clarity. Oh and BTW: the pipe symbols probably | ||
86 | line up much more nicely in your editor than in a browser. | ||
87 | </p> | ||
88 | <p> | ||
89 | Here 123 is an offset into the action list buffer that | ||
90 | holds the partially specified machine code. Without going | ||
91 | into too much detail, the embedded C library implements a | ||
92 | tiny bytecode engine that takes the action list as input and | ||
93 | outputs machine code. It basically copies machine code snippets | ||
94 | from the action list and merges them with the arguments | ||
95 | passed in by <tt>dasm_put()</tt>. | ||
96 | </p> | ||
97 | <p> | ||
98 | The arguments can be any kind of C expressions. In practical | ||
99 | use most of them evaluate to constants (e.g. structure offsets). | ||
100 | Your C compiler should generate very compact code out of it. | ||
101 | </p> | ||
102 | <p> | ||
103 | The embedded C library knows only what's absolutely needed to | ||
104 | generate proper machine code for the target CPU (e.g. variable | ||
105 | displacement sizes, variable branch offset sizes and so on). | ||
106 | It doesn't have a clue about other atrocities like x86 opcode | ||
107 | encodings — and it doesn't need to. This dramatically | ||
108 | reduces the minimum required code size to around 2K [sic!]. | ||
109 | </p> | ||
110 | <p> | ||
111 | The action list buffer itself has a pretty compact encoding, too. | ||
112 | E.g. the whole action list buffer for an early version of LuaJIT | ||
113 | needs only around 3K. | ||
114 | </p> | ||
115 | |||
116 | <h2>Advanced Features</h2> | ||
117 | <p> | ||
118 | Here's a real-life example taken from LuaJIT that shows some | ||
119 | advanced features like type maps, macros and how to access | ||
120 | C structures: | ||
121 | </p> | ||
122 | <pre> | ||
123 | |.type L, lua_State, esi // L. | ||
124 | |.type BASE, TValue, ebx // L->base. | ||
125 | |.type TOP, TValue, edi // L->top. | ||
126 | |.type CI, CallInfo, ecx // L->ci. | ||
127 | |.type LCL, LClosure, eax // L->ci->func->value. | ||
128 | |.type UPVAL, UpVal | ||
129 | |||
130 | |.macro copyslot, D, S, R1, R2, R3 | ||
131 | | mov R1, S.value; mov R2, S.value.na[1]; mov R3, S.tt | ||
132 | | mov D.value, R1; mov D.value.na[1], R2; mov D.tt, R3 | ||
133 | |.endmacro | ||
134 | |||
135 | |.macro copyslot, D, S; copyslot D, S, ecx, edx, eax; .endmacro | ||
136 | |||
137 | |.macro getLCL, reg | ||
138 | ||if (!J->pt->is_vararg) { | ||
139 | | mov LCL:reg, BASE[-1].value | ||
140 | ||} else { | ||
141 | | mov CI, L->ci | ||
142 | | mov TOP, CI->func | ||
143 | | mov LCL:reg, TOP->value | ||
144 | ||} | ||
145 | |.endmacro | ||
146 | |||
147 | |.macro getLCL; getLCL eax; .endmacro | ||
148 | |||
149 | [...] | ||
150 | |||
151 | static void jit_op_getupval(jit_State *J, int dest, int uvidx) | ||
152 | { | ||
153 | | getLCL | ||
154 | | mov UPVAL:ecx, LCL->upvals[uvidx] | ||
155 | | mov TOP, UPVAL:ecx->v | ||
156 | | copyslot BASE[dest], TOP[0] | ||
157 | } | ||
158 | </pre> | ||
159 | <p> | ||
160 | And here is the pre-processed output (stripped a bit for clarity): | ||
161 | </p> | ||
162 | <pre> | ||
163 | #define Dt1(_V) (int)&(((lua_State *)0)_V) | ||
164 | [...] | ||
165 | static void jit_op_getupval(jit_State *J, int dest, int uvidx) | ||
166 | { | ||
167 | if (!J->pt->is_vararg) { | ||
168 | dasm_put(Dst, 1164, Dt2([-1].value)); | ||
169 | } else { | ||
170 | dasm_put(Dst, 1168, Dt1(->ci), Dt4(->func), Dt3(->value)); | ||
171 | } | ||
172 | dasm_put(Dst, 1178, Dt5(->upvals[uvidx]), DtF(->v), Dt3([0].value), | ||
173 | Dt3([0].value.na[1]), Dt3([0].tt), Dt2([dest].value), | ||
174 | Dt2([dest].value.na[1]), Dt2([dest].tt)); | ||
175 | } | ||
176 | </pre> | ||
177 | <br class="flush"> | ||
178 | </div> | ||
179 | <div id="foot"> | ||
180 | <hr class="hide"> | ||
181 | Copyright © 2005-2011 Mike Pall | ||
182 | <span class="noprint"> | ||
183 | · | ||
184 | <a href="contact.html">Contact</a> | ||
185 | </span> | ||
186 | </div> | ||
187 | </body> | ||
188 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/dynasm_features.html b/libraries/LuaJIT-1.1.7/jitdoc/dynasm_features.html new file mode 100644 index 0000000..1b8ce69 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/dynasm_features.html | |||
@@ -0,0 +1,139 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>DynASM Features</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>DynASM Features</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a class="current" href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <h2>DynASM Toolchain Features</h2> | ||
63 | <ul> | ||
64 | <li>DynASM is a pre-processing assembler.</li> | ||
65 | <li>DynASM converts mixed C/Assembler source to plain C code.</li> | ||
66 | <li>The primary knowledge about instruction names, operand modes, | ||
67 | registers, opcodes and how to encode them is <em>only</em> | ||
68 | needed in the pre-processor.</li> | ||
69 | <li>The generated C code is extremely small and fast.</li> | ||
70 | <li>A tiny embeddable C library helps with the process of dynamically | ||
71 | assembling, relocating and linking machine code.</li> | ||
72 | <li>There are no outside dependencies on other tools (such as | ||
73 | stand-alone assemblers or linkers).</li> | ||
74 | <li>Internal consistency checks catch runtime errors | ||
75 | (e.g. undefined labels).</li> | ||
76 | <li>The toolchain is split into a portable subset and | ||
77 | CPU-specific modules.</li> | ||
78 | <li>DynASM itself (the pre-processor) is written in Lua.</li> | ||
79 | <li>There is no machine-dependency for the pre-processor itself. | ||
80 | It should work everywhere you can get Lua 5.1 up and running | ||
81 | (i.e. Linux, *BSD, Solaris, Windows, ... you name it).</li> | ||
82 | </ul> | ||
83 | |||
84 | <h2>DynASM Assembler Features</h2> | ||
85 | <ul> | ||
86 | <li>C code and assembler code can be freely mixed. | ||
87 | <em>Readable</em>, too.</li> | ||
88 | <li>All the usual syntax for instructions and operand modes | ||
89 | you come to expect from a standard assembler.</li> | ||
90 | <li>Access to C variables and CPP defines in assembler statements.</li> | ||
91 | <li>Access to C structures and unions via type mapping.</li> | ||
92 | <li>Convenient shortcuts for accessing C structures.</li> | ||
93 | <li>Local and global labels.</li> | ||
94 | <li>Numbered labels (e.g. for mapping bytecode instruction numbers).</li> | ||
95 | <li>Multiple code sections (e.g. for tailcode).</li> | ||
96 | <li>Defines/substitutions (inline and from command line).</li> | ||
97 | <li>Conditionals (translation time) with proper nesting.</li> | ||
98 | <li>Macros with parameters.</li> | ||
99 | <li>Macros can mix assembler statements and C code.</li> | ||
100 | <li>Captures (output diversion for code reordering).</li> | ||
101 | <li>Simple and extensible template system for instruction definitions.</li> | ||
102 | </ul> | ||
103 | |||
104 | <h2>Restrictions</h2> | ||
105 | <p> | ||
106 | Currently only a subset of x86 (i386+) instructions is supported. | ||
107 | Unsupported instructions are either not usable in user-mode or | ||
108 | are slow on modern CPUs (i.e. not suited for a code generator). | ||
109 | SSE, SSE2, SSE3 and SSSE3 are fully supported. MMX is not supported. | ||
110 | </p> | ||
111 | <p> | ||
112 | The whole toolchain has been designed to support multiple CPU | ||
113 | architectures. As LuaJIT gets support for more architectures, | ||
114 | DynASM will be extended with new CPU-specific modules. | ||
115 | </p> | ||
116 | <p> | ||
117 | The assembler itself will be extended with more features on an | ||
118 | as-needed basis. E.g. I'm thinking about vararg macros. | ||
119 | </p> | ||
120 | <p> | ||
121 | Note that runtime conditionals are not really needed, since you can | ||
122 | just use plain C code for that (and LuaJIT does this <em>a lot</em>). | ||
123 | It's not going to be more (time-) efficient if conditionals are done | ||
124 | by the embedded C library (maybe a bit more space-efficient). | ||
125 | </p> | ||
126 | |||
127 | |||
128 | <br class="flush"> | ||
129 | </div> | ||
130 | <div id="foot"> | ||
131 | <hr class="hide"> | ||
132 | Copyright © 2005-2011 Mike Pall | ||
133 | <span class="noprint"> | ||
134 | · | ||
135 | <a href="contact.html">Contact</a> | ||
136 | </span> | ||
137 | </div> | ||
138 | </body> | ||
139 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/img/backbar.png b/libraries/LuaJIT-1.1.7/jitdoc/img/backbar.png new file mode 100644 index 0000000..3c90029 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/img/backbar.png | |||
Binary files differ | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/img/bluebar.png b/libraries/LuaJIT-1.1.7/jitdoc/img/bluebar.png new file mode 100644 index 0000000..70dcf07 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/img/bluebar.png | |||
Binary files differ | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/img/contact.png b/libraries/LuaJIT-1.1.7/jitdoc/img/contact.png new file mode 100644 index 0000000..9c73dc5 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/img/contact.png | |||
Binary files differ | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/img/magentabar.png b/libraries/LuaJIT-1.1.7/jitdoc/img/magentabar.png new file mode 100644 index 0000000..11ebd2b --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/img/magentabar.png | |||
Binary files differ | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/img/spacer.png b/libraries/LuaJIT-1.1.7/jitdoc/img/spacer.png new file mode 100644 index 0000000..75a203c --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/img/spacer.png | |||
Binary files differ | |||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/index.html b/libraries/LuaJIT-1.1.7/jitdoc/index.html new file mode 100644 index 0000000..22236b4 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/index.html | |||
@@ -0,0 +1,103 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>The LuaJIT Project</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>The LuaJIT Project</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a class="current" href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | This is the offline documentation for: | ||
64 | </p> | ||
65 | <ul> | ||
66 | <li> | ||
67 | <a href="luajit.html">LuaJIT</a> — | ||
68 | a <strong>Just-In-Time Compiler</strong> for Lua. | ||
69 | </li> | ||
70 | <li> | ||
71 | <a href="coco.html">Coco</a> — | ||
72 | a Lua extension for <strong>True C Coroutines</strong>. | ||
73 | </li> | ||
74 | <li> | ||
75 | <a href="dynasm.html">DynASM</a> — | ||
76 | a <strong>Dynamic Assembler</strong> for code generation engines. | ||
77 | </li> | ||
78 | </ul> | ||
79 | |||
80 | |||
81 | |||
82 | <h2>More ...</h2> | ||
83 | <p> | ||
84 | Please click on one of the links in the navigation bar to your left | ||
85 | to learn more. | ||
86 | </p> | ||
87 | <p> | ||
88 | Click on the Logo in the upper left corner to visit | ||
89 | the LuaJIT project page on the web. All other links to online | ||
90 | resources are marked with a '<span class="ext">»</span>'. | ||
91 | </p> | ||
92 | <br class="flush"> | ||
93 | </div> | ||
94 | <div id="foot"> | ||
95 | <hr class="hide"> | ||
96 | Copyright © 2005-2011 Mike Pall | ||
97 | <span class="noprint"> | ||
98 | · | ||
99 | <a href="contact.html">Contact</a> | ||
100 | </span> | ||
101 | </div> | ||
102 | </body> | ||
103 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit.html new file mode 100644 index 0000000..f9a7245 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit.html | |||
@@ -0,0 +1,109 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>LuaJIT</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>LuaJIT</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a class="current" href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | LuaJIT is a <strong>Just-In-Time Compiler</strong> for the Lua | ||
64 | programming language. | ||
65 | </p> | ||
66 | <p class="indent"> | ||
67 | Lua is a powerful, light-weight programming language designed | ||
68 | for extending applications. Lua is also frequently used as a | ||
69 | general-purpose, stand-alone language. More information about | ||
70 | Lua can be found at: <a href="http://www.lua.org/"><span class="ext">»</span> http://www.lua.org/</a> | ||
71 | </p> | ||
72 | <p> | ||
73 | LuaJIT 1.x is based on the Lua 5.1.x virtual machine and bytecode interpreter | ||
74 | from lua.org. It compiles bytecode to native x86 (i386+) machine code | ||
75 | to speed up the execution of Lua programs. | ||
76 | </p> | ||
77 | <p> | ||
78 | LuaJIT depends on <a href="coco.html">Coco</a> to allow yielding | ||
79 | from coroutines for JIT compiled functions. Coco is part of the | ||
80 | LuaJIT distribution. | ||
81 | </p> | ||
82 | <p> | ||
83 | LuaJIT is Copyright © 2005-2011 Mike Pall. | ||
84 | LuaJIT is free software, released under the | ||
85 | <a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">»</span> MIT/X license</a> | ||
86 | (same license as the Lua core). | ||
87 | </p> | ||
88 | <h2>More ...</h2> | ||
89 | <p> | ||
90 | Click on the LuaJIT sub-topics in the navigation bar to learn more | ||
91 | about LuaJIT. | ||
92 | </p> | ||
93 | <p style="background: #ffd0d0; text-align: center;"> | ||
94 | LuaJIT 2.0 is available with much improved performance!<br> | ||
95 | Please visit the <a href="http://luajit.org/download.html"><span class="ext">»</span> Download</a> page to fetch | ||
96 | the current version of LuaJIT. | ||
97 | </p> | ||
98 | <br class="flush"> | ||
99 | </div> | ||
100 | <div id="foot"> | ||
101 | <hr class="hide"> | ||
102 | Copyright © 2005-2011 Mike Pall | ||
103 | <span class="noprint"> | ||
104 | · | ||
105 | <a href="contact.html">Contact</a> | ||
106 | </span> | ||
107 | </div> | ||
108 | </body> | ||
109 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_api.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_api.html new file mode 100644 index 0000000..58ac809 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_api.html | |||
@@ -0,0 +1,372 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>LuaJIT API Extensions</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | <style type="text/css"> | ||
12 | td.stname { width: 10em; } | ||
13 | tr.sthead td { font-weight: bold; } | ||
14 | </style> | ||
15 | </head> | ||
16 | <body> | ||
17 | <div id="site"> | ||
18 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
19 | </div> | ||
20 | <div id="head"> | ||
21 | <h1>LuaJIT API Extensions</h1> | ||
22 | </div> | ||
23 | <div id="nav"> | ||
24 | <ul><li> | ||
25 | <a href="index.html">Index</a> | ||
26 | </li><li> | ||
27 | <a href="luajit.html">LuaJIT</a> | ||
28 | <ul><li> | ||
29 | <a href="luajit_features.html">Features</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_install.html">Installation</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_run.html">Running</a> | ||
34 | </li><li> | ||
35 | <a class="current" href="luajit_api.html">API Extensions</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_intro.html">Introduction</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_performance.html">Performance</a> | ||
40 | </li><li> | ||
41 | <a href="luajit_debug.html">Debugging</a> | ||
42 | </li><li> | ||
43 | <a href="luajit_changes.html">Changes</a> | ||
44 | </li></ul> | ||
45 | </li><li> | ||
46 | <a href="coco.html">Coco</a> | ||
47 | <ul><li> | ||
48 | <a href="coco_portability.html">Portability</a> | ||
49 | </li><li> | ||
50 | <a href="coco_api.html">API Extensions</a> | ||
51 | </li><li> | ||
52 | <a href="coco_changes.html">Changes</a> | ||
53 | </li></ul> | ||
54 | </li><li> | ||
55 | <a href="dynasm.html">DynASM</a> | ||
56 | <ul><li> | ||
57 | <a href="dynasm_features.html">Features</a> | ||
58 | </li><li> | ||
59 | <a href="dynasm_examples.html">Examples</a> | ||
60 | </li></ul> | ||
61 | </li><li> | ||
62 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
63 | </li></ul> | ||
64 | </div> | ||
65 | <div id="main"> | ||
66 | <p> | ||
67 | LuaJIT provides several new API functions organized into two | ||
68 | libraries. | ||
69 | </p> | ||
70 | <p> | ||
71 | LuaJIT includes Coco — so have a look at the | ||
72 | <a href="coco_api.html">Coco API Extensions</a>, too. | ||
73 | </p> | ||
74 | |||
75 | <h2>Standard Library Functions</h2> | ||
76 | <p> | ||
77 | All standard library functions have the same behaviour as | ||
78 | in the Lua distribution LuaJIT is based on. | ||
79 | </p> | ||
80 | <p> | ||
81 | The Lua loader used by the standard <tt>require()</tt> library | ||
82 | function has been modified to turn off compilation of the main | ||
83 | chunk of a module. The main chunk is only run once when the module | ||
84 | is loaded for the first time. There is no point in compiling it. | ||
85 | </p> | ||
86 | <p> | ||
87 | You might want to adapt this behaviour if you use your own utility | ||
88 | functions (and not <tt>require()</tt>) to load modules. | ||
89 | </p> | ||
90 | <p> | ||
91 | Note that the subfunctions defined in a loaded module <em>are</em> | ||
92 | of course compiled. See below if you want to override this. | ||
93 | </p> | ||
94 | |||
95 | <h2>The jit.* Library</h2> | ||
96 | <p> | ||
97 | This library holds several functions to control the behaviour | ||
98 | of the JIT engine. | ||
99 | </p> | ||
100 | |||
101 | <h3 id="jit_onoff"><tt>jit.on()<br> | ||
102 | jit.off()</tt></h3> | ||
103 | <p> | ||
104 | Turns the JIT engine on (default) or off. | ||
105 | </p> | ||
106 | <p> | ||
107 | These functions are typically used with the command line options | ||
108 | <tt>-j on</tt> or <tt>-j off</tt>. | ||
109 | </p> | ||
110 | |||
111 | <h3 id="jit_onoff_func"><tt>jit.on(func|true [,true|false])<br> | ||
112 | jit.off(func|true [,true|false])</tt></h3> | ||
113 | <p> | ||
114 | Enable (with <tt>jit.on</tt>, default) or disable (with <tt>jit.off</tt>) | ||
115 | JIT compilation for a Lua function. The current function (the Lua function | ||
116 | calling this library function) can be specified with <tt>true</tt>. | ||
117 | </p> | ||
118 | <p> | ||
119 | If the second argument is <tt>true</tt>, JIT compilation is also | ||
120 | enabled/disabled recursively for all subfunctions of a function. | ||
121 | With <tt>false</tt> only the subfunctions are affected. | ||
122 | </p> | ||
123 | <p> | ||
124 | Both library functions only set a flag which is checked when | ||
125 | the function is executed for the first/next time. They do not | ||
126 | trigger immediate compilation. | ||
127 | </p> | ||
128 | <p> | ||
129 | Typical usage is <tt>jit.off(true, true)</tt> in the main chunk | ||
130 | of a module to turn off JIT compilation for the whole module. | ||
131 | Note that <tt>require()</tt> already turns off compilation for | ||
132 | the main chunk itself. | ||
133 | </p> | ||
134 | |||
135 | <h3 id="jit_compile"><tt>status = jit.compile(func [,args...])</tt></h3> | ||
136 | <p> | ||
137 | Compiles a Lua function and returns the compilation status. | ||
138 | Successful compilation is indicated with a <tt>nil</tt> status. | ||
139 | Failure is indicated with a numeric status (see <tt>jit.util.status</tt>). | ||
140 | </p> | ||
141 | <p> | ||
142 | The optimizer pass of the compiler tries to derive hints from the | ||
143 | passed arguments. Not passing any arguments or passing untypical | ||
144 | arguments (esp. the wrong types) reduces the efficiency of the | ||
145 | optimizer. The compiled function will still run, but probably not | ||
146 | with maximum speed. | ||
147 | </p> | ||
148 | <p> | ||
149 | This library function is typically used for Ahead-Of-Time (AOT) | ||
150 | compilation of time-critical functions or for testing/debugging. | ||
151 | </p> | ||
152 | |||
153 | <h3 id="jit_compilesub"><tt>status = jit.compilesub(func|true [,true])</tt></h3> | ||
154 | <p> | ||
155 | Recursively compile all subfunctions of a Lua function. | ||
156 | The current function (the Lua function calling this library function) | ||
157 | can be specified with <tt>true</tt>. Note that the function | ||
158 | <em>itself</em> is not compiled (use <tt>jit.compile()</tt>). | ||
159 | </p> | ||
160 | <p> | ||
161 | If the second argument is <tt>true</tt>, compilation will stop | ||
162 | when the first error is encountered. Otherwise compilation will | ||
163 | continue with the next subfunction. | ||
164 | </p> | ||
165 | <p> | ||
166 | The returned status is <tt>nil</tt>, if all subfunctions have been | ||
167 | compiled successfully. A numeric status (see <tt>jit.util.status</tt>) | ||
168 | indicates that at least one compilation failed and gives the status | ||
169 | of the last failure (this is only helpful when stop on error | ||
170 | is <tt>true</tt>). | ||
171 | </p> | ||
172 | |||
173 | <h3 id="jit_debug"><tt>jit.debug([level])</tt></h3> | ||
174 | <p> | ||
175 | Set the debug level for JIT compilation. If no <tt>level</tt> is given, | ||
176 | the maximum debug level is set. | ||
177 | </p> | ||
178 | <ul> | ||
179 | <li>Level 0 disables debugging: no checks for hooks are compiled | ||
180 | into the code. This is the default when LuaJIT is started and | ||
181 | provides the maximum performance.</li> | ||
182 | <li>Level 1 enables function call debugging: call hooks and | ||
183 | return hooks are checked in the function prologue and epilogue. | ||
184 | This slows down function calls somewhat (by up to 10%).</li> | ||
185 | <li>Level 2 enables full debugging: all hooks are checked. | ||
186 | This slows down execution quite a bit, even when the hooks | ||
187 | are not active.</li> | ||
188 | </ul> | ||
189 | <p> | ||
190 | Note that some compiler optimizations are turned off when | ||
191 | debugging is enabled. | ||
192 | </p> | ||
193 | <p> | ||
194 | This function is typically used with the command line options | ||
195 | <tt>-j debug</tt> or <tt>-j debug=level</tt>. | ||
196 | </p> | ||
197 | |||
198 | <h3 id="jit_attach"><tt>jit.attach(handler [, priority])</tt></h3> | ||
199 | <p> | ||
200 | Attach a handler to the compiler pipeline with the given priority. | ||
201 | The handler is detached if no priority is given. | ||
202 | </p> | ||
203 | <p> | ||
204 | The inner workings of the compiler pipeline and the API for handlers | ||
205 | are still in flux. Please see the source code for more details. | ||
206 | </p> | ||
207 | |||
208 | <h3 id="jit_version"><tt>jit.version</tt></h3> | ||
209 | <p> | ||
210 | Contains the LuaJIT version string. | ||
211 | </p> | ||
212 | |||
213 | <h3 id="jit_version_num"><tt>jit.version_num</tt></h3> | ||
214 | <p> | ||
215 | Contains the version number of the LuaJIT core. Version xx.yy.zz | ||
216 | is represented by the decimal number xxyyzz. | ||
217 | </p> | ||
218 | |||
219 | <h3 id="jit_arch"><tt>jit.arch</tt></h3> | ||
220 | <p> | ||
221 | Contains the target architecture name (CPU and optional ABI). | ||
222 | </p> | ||
223 | |||
224 | |||
225 | <h2 id="jit_util">The jit.util.* Library</h2> | ||
226 | <p> | ||
227 | This library holds many utility functions used by the provided | ||
228 | extension modules for LuaJIT (e.g. the optimizer). The API may | ||
229 | change in future versions. | ||
230 | </p> | ||
231 | |||
232 | <h3 id="jit_util_stats"><tt>stats = jit.util.stats(func)</tt></h3> | ||
233 | <p> | ||
234 | Retrieves information about a function. Returns <tt>nil</tt> | ||
235 | for C functions. Returns a table with the following fields for | ||
236 | Lua functions: | ||
237 | </p> | ||
238 | <ul> | ||
239 | <li><tt>status</tt>: numeric compilation status (see <tt>jit.util.status</tt>).</li> | ||
240 | <li><tt>stackslots</tt>: number of stack slots.</li> | ||
241 | <li><tt>params</tt>: number of fixed parameters (arguments).</li> | ||
242 | <li><tt>consts</tt>: number of constants.</li> | ||
243 | <li><tt>upvalues</tt>: number of upvalues.</li> | ||
244 | <li><tt>subs</tt>: number of subfunctions (sub prototypes).</li> | ||
245 | <li><tt>bytecodes</tt>: number of bytecode instructions.</li> | ||
246 | <li><tt>isvararg</tt>: fixarg (false) or vararg (true) function.</li> | ||
247 | <li><tt>env</tt>: function environment table.</li> | ||
248 | <li><tt>mcodesize</tt>: size of the compiled machine code.</li> | ||
249 | <li><tt>mcodeaddr</tt>: start address of the compiled machine code.</li> | ||
250 | </ul> | ||
251 | <p> | ||
252 | <tt>mcodesize</tt> and <tt>mcodeaddr</tt> are not set if the | ||
253 | function has not been compiled (yet). | ||
254 | </p> | ||
255 | |||
256 | <h3 id="jit_util_bytecode"><tt>op, a, b, c, test = jit.util.bytecode(func, pc)</tt></h3> | ||
257 | <p> | ||
258 | Returns the fields of the bytecode instruction at the given <tt>pc</tt> | ||
259 | for a Lua function. The first instruction is at <tt>pc</tt> = 1. | ||
260 | Nothing is returned if <tt>pc</tt> is out of range. | ||
261 | </p> | ||
262 | <p> | ||
263 | The opcode name is returned as an uppercase string in <tt>op</tt>. | ||
264 | The opcode arguments are returned as <tt>a</tt>, <tt>b</tt> and | ||
265 | optionally <tt>c</tt>. Arguments that indicate an index into the | ||
266 | array of constants are translated to negative numbers (the first | ||
267 | constant is referred to with -1). Branch targets are signed numbers | ||
268 | relative to the next instruction. | ||
269 | </p> | ||
270 | <p> | ||
271 | <tt>test</tt> is true if the instruction is a test (i.e. followed | ||
272 | by a JMP). | ||
273 | </p> | ||
274 | |||
275 | <h3 id="jit_util_const"><tt>const, ok = jit.util.const(func, idx)</tt></h3> | ||
276 | <p> | ||
277 | Returns a constant from the array of constants for a Lua function. | ||
278 | <tt>ok</tt> is true if <tt>idx</tt> is in range. Otherwise nothing | ||
279 | is returned. | ||
280 | </p> | ||
281 | <p> | ||
282 | Constants are numbered starting with 1. A negative <tt>idx</tt> | ||
283 | is mapped to a positive index. | ||
284 | </p> | ||
285 | |||
286 | <h3 id="jit_util_upvalue"><tt>upvalue, ok = jit.util.upvalue(func, idx)</tt></h3> | ||
287 | <p> | ||
288 | Returns an upvalue from the array of upvalues for a Lua function. | ||
289 | <tt>ok</tt> is true if <tt>idx</tt> is in range. Otherwise nothing | ||
290 | is returned. Upvalues are numbered starting with 0. | ||
291 | </p> | ||
292 | |||
293 | <h3 id="jit_util_closurenup"><tt>nup = jit.util.closurenup(func, idx)</tt></h3> | ||
294 | <p> | ||
295 | Returns the number of upvalues for the subfunction prototype with | ||
296 | the given index <tt>idx</tt> for a Lua function. Nothing is returned | ||
297 | if <tt>idx</tt> is out of range. Subfunctions are numbered starting | ||
298 | with 0. | ||
299 | </p> | ||
300 | |||
301 | <h3 id="jit_util_mcode"><tt>addr, mcode, mfmiter = jit.util.mcode(func, block])</tt></h3> | ||
302 | <p> | ||
303 | Returns the numeric start address, the compiled machine code | ||
304 | (converted to a string) and an iterator for the machine code fragment map | ||
305 | for the specified machine code block associated with a Lua function. | ||
306 | </p> | ||
307 | <p> | ||
308 | Returns <tt>nil</tt> and a numeric status code (see <tt>jit.util.status</tt>) | ||
309 | if the function has not been compiled yet or compilation has failed | ||
310 | or compilation is disabled. Returns nothing if the selected | ||
311 | machine code block does not exist. | ||
312 | </p> | ||
313 | <p> | ||
314 | The machine code fragment map is used for debugging and error handling. | ||
315 | The format may change between versions and is an internal implementation | ||
316 | detail of LuaJIT. | ||
317 | </p> | ||
318 | |||
319 | <h3 id="jit_util_jsubmcode"><tt>addr [, mcode] = jit.util.jsubmcode([idx])</tt></h3> | ||
320 | <p> | ||
321 | If <tt>idx</tt> is omitted or nil: | ||
322 | Returns the numeric start address and the compiled machine code | ||
323 | (converted to a string) for internal subroutines used by the | ||
324 | compiled machine code. | ||
325 | </p> | ||
326 | <p> | ||
327 | If <tt>idx</tt> is given: | ||
328 | Returns the numeric start address of the machine code for a specific | ||
329 | internal subroutine (0 based). Nothing is returned if <tt>idx</tt> is | ||
330 | out of range. | ||
331 | </p> | ||
332 | |||
333 | <h3 id="jit_util_status"><tt>jit.util.status</tt></h3> | ||
334 | <p> | ||
335 | This is a table that bidirectionally maps status numbers and | ||
336 | status names (strings): | ||
337 | </p> | ||
338 | <div class="tablewrap"> | ||
339 | <table> | ||
340 | <tr class="sthead"><td class="stname">Status Name</td><td>Description</td></tr> | ||
341 | <tr class="odd"><td class="stname">OK</td><td>Ok, code has been compiled.</td></tr> | ||
342 | <tr class="even"><td class="stname">NONE</td><td>Nothing analyzed or compiled, yet (default).</td></tr> | ||
343 | <tr class="odd"><td class="stname">OFF</td><td>Compilation disabled for this function.</td></tr> | ||
344 | <tr class="even"><td class="stname">ENGINE_OFF</td><td>JIT engine is turned off.</td></tr> | ||
345 | <tr class="odd"><td class="stname">DELAYED</td><td>Compilation delayed (recursive invocation).</td></tr> | ||
346 | <tr class="even"><td class="stname">TOOLARGE</td><td>Bytecode or machine code is too large.</td></tr> | ||
347 | <tr class="odd"><td class="stname">COMPILER_ERROR</td><td>Error from compiler frontend.</td></tr> | ||
348 | <tr class="even"><td class="stname">DASM_ERROR</td><td>Error from DynASM engine.</td></tr> | ||
349 | </table> | ||
350 | </div> | ||
351 | |||
352 | <h3 id="jit_util_hints"><tt>jit.util.hints<br> | ||
353 | jit.util.fhints</tt></h3> | ||
354 | <p> | ||
355 | These two tables map compiler hint names to internal hint numbers. | ||
356 | </p> | ||
357 | <p> | ||
358 | The hint system is an internal implementation detail of LuaJIT. | ||
359 | Please see the source code for more info. | ||
360 | </p> | ||
361 | <br class="flush"> | ||
362 | </div> | ||
363 | <div id="foot"> | ||
364 | <hr class="hide"> | ||
365 | Copyright © 2005-2011 Mike Pall | ||
366 | <span class="noprint"> | ||
367 | · | ||
368 | <a href="contact.html">Contact</a> | ||
369 | </span> | ||
370 | </div> | ||
371 | </body> | ||
372 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_changes.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_changes.html new file mode 100644 index 0000000..bf42b93 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_changes.html | |||
@@ -0,0 +1,301 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>LuaJIT Change History</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>LuaJIT Change History</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a class="current" href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | This is a list of changes between the released versions of LuaJIT. | ||
64 | The current version is <strong>LuaJIT 1.1.7</strong>. | ||
65 | </p> | ||
66 | <p> | ||
67 | Please check the | ||
68 | <a href="http://luajit.org/changes.html"><span class="ext">»</span> Online Change History</a> | ||
69 | to see whether newer versions are available. | ||
70 | </p> | ||
71 | |||
72 | <h2 id="LuaJIT-1.1.7">LuaJIT 1.1.7 — 2011-05-05</h2> | ||
73 | <ul> | ||
74 | <li>Added fixes for the | ||
75 | <a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li> | ||
76 | </ul> | ||
77 | |||
78 | <h2 id="LuaJIT-1.1.6">LuaJIT 1.1.6 — 2010-03-28</h2> | ||
79 | <ul> | ||
80 | <li>Added fixes for the | ||
81 | <a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li> | ||
82 | <li>Removed wrong GC check in <tt>jit_createstate()</tt>. | ||
83 | Thanks to Tim Mensch.</li> | ||
84 | <li>Fixed bad assertions while compiling <tt>table.insert()</tt> and | ||
85 | <tt>table.remove()</tt>.</li> | ||
86 | </ul> | ||
87 | |||
88 | <h2 id="LuaJIT-1.1.5">LuaJIT 1.1.5 — 2008-10-25</h2> | ||
89 | <ul> | ||
90 | <li>Merged with Lua 5.1.4. Fixes all | ||
91 | <a href="http://www.lua.org/bugs.html#5.1.3"><span class="ext">»</span> known bugs in Lua 5.1.3</a>.</li> | ||
92 | </ul> | ||
93 | |||
94 | <h2 id="LuaJIT-1.1.4">LuaJIT 1.1.4 — 2008-02-05</h2> | ||
95 | <ul> | ||
96 | <li>Merged with Lua 5.1.3. Fixes all | ||
97 | <a href="http://www.lua.org/bugs.html#5.1.2"><span class="ext">»</span> known bugs in Lua 5.1.2</a>.</li> | ||
98 | <li>Fixed possible (but unlikely) stack corruption while compiling | ||
99 | <tt>k^x</tt> expressions.</li> | ||
100 | <li>Fixed DynASM template for cmpss instruction.</li> | ||
101 | </ul> | ||
102 | |||
103 | <h2 id="LuaJIT-1.1.3">LuaJIT 1.1.3 — 2007-05-24</h2> | ||
104 | <ul> | ||
105 | <li>Merged with Lua 5.1.2. Fixes all | ||
106 | <a href="http://www.lua.org/bugs.html#5.1.1"><span class="ext">»</span> known bugs in Lua 5.1.1</a>.</li> | ||
107 | <li>Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.</li> | ||
108 | <li>Remove a (sometimes) wrong assertion in <tt>luaJIT_findpc()</tt>.</li> | ||
109 | <li>DynASM now allows labels for displacements and <tt>.aword</tt>.</li> | ||
110 | <li>Fix some compiler warnings for DynASM glue (internal API change).</li> | ||
111 | <li>Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.</li> | ||
112 | <li>The loadable debug modules now handle redirection to stdout | ||
113 | (e.g. <tt>-j trace=-</tt>).</li> | ||
114 | </ul> | ||
115 | |||
116 | <h2 id="LuaJIT-1.1.2">LuaJIT 1.1.2 — 2006-06-24</h2> | ||
117 | <ul> | ||
118 | <li>Fix MSVC inline assembly: use only local variables with | ||
119 | <tt>lua_number2int()</tt>.</li> | ||
120 | <li>Fix "attempt to call a thread value" bug on Mac OS X: | ||
121 | make values of consts used as lightuserdata keys unique | ||
122 | to avoid joining by the compiler/linker.</li> | ||
123 | </ul> | ||
124 | |||
125 | <h2 id="LuaJIT-1.1.1">LuaJIT 1.1.1 — 2006-06-20</h2> | ||
126 | <ul> | ||
127 | <li>Merged with Lua 5.1.1. Fixes all | ||
128 | <a href="http://www.lua.org/bugs.html#5.1"><span class="ext">»</span> known bugs in Lua 5.1</a>.</li> | ||
129 | <li>Enforce (dynamic) linker error for EXE/DLL version mismatches.</li> | ||
130 | <li>Minor changes to DynASM: faster preprocessing, smaller encoding | ||
131 | for some immediates.</li> | ||
132 | </ul> | ||
133 | <p> | ||
134 | This release is in sync with Coco 1.1.1 (see the | ||
135 | <a href="coco_changes.html">Coco Change History</a>). | ||
136 | </p> | ||
137 | |||
138 | <h2 id="LuaJIT-1.1.0">LuaJIT 1.1.0 — 2006-03-13</h2> | ||
139 | <ul> | ||
140 | <li>Merged with Lua 5.1 (final).</li> | ||
141 | |||
142 | <li>New JIT call frame setup: | ||
143 | <ul> | ||
144 | <li>The C stack is kept 16 byte aligned (faster). | ||
145 | Mandatory for Mac OS X on Intel, too.</li> | ||
146 | <li>Faster calling conventions for internal C helper functions.</li> | ||
147 | <li>Better instruction scheduling for function prologue, OP_CALL and | ||
148 | OP_RETURN.</li> | ||
149 | </ul></li> | ||
150 | |||
151 | <li>Miscellaneous optimizations: | ||
152 | <ul> | ||
153 | <li>Faster loads of FP constants. Remove narrow-to-wide store-to-load | ||
154 | forwarding stalls.</li> | ||
155 | <li>Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves | ||
156 | and FP to integer conversions.</li> | ||
157 | <li>Optimized the two-argument form of <tt>OP_CONCAT</tt> (<tt>a..b</tt>).</li> | ||
158 | <li>Inlined <tt>OP_MOD</tt> (<tt>a%b</tt>). | ||
159 | With better accuracy than the C variant, too.</li> | ||
160 | <li>Inlined <tt>OP_POW</tt> (<tt>a^b</tt>). Unroll <tt>x^k</tt> or | ||
161 | use <tt>k^x = 2^(log2(k)*x)</tt> or call <tt>pow()</tt>.</li> | ||
162 | </ul></li> | ||
163 | |||
164 | <li>Changes in the optimizer: | ||
165 | <ul> | ||
166 | <li>Improved hinting for table keys derived from table values | ||
167 | (<tt>t1[t2[x]]</tt>).</li> | ||
168 | <li>Lookup hinting now works with arbitrary object types and | ||
169 | supports index chains, too.</li> | ||
170 | <li>Generate type hints for arithmetic and comparison operators, | ||
171 | OP_LEN, OP_CONCAT and OP_FORPREP.</li> | ||
172 | <li>Remove several hint definitions in favour of a generic COMBINE hint.</li> | ||
173 | <li>Complete rewrite of <tt>jit.opt_inline</tt> module | ||
174 | (ex <tt>jit.opt_lib</tt>).</li> | ||
175 | </ul></li> | ||
176 | |||
177 | <li>Use adaptive deoptimization: | ||
178 | <ul> | ||
179 | <li>If runtime verification of a contract fails, the affected | ||
180 | instruction is recompiled and patched on-the-fly. | ||
181 | Regular programs will trigger deoptimization only occasionally.</li> | ||
182 | <li>This avoids generating code for uncommon fallback cases | ||
183 | most of the time. Generated code is up to 30% smaller compared to | ||
184 | LuaJIT 1.0.3.</li> | ||
185 | <li>Deoptimization is used for many opcodes and contracts: | ||
186 | <ul> | ||
187 | <li>OP_CALL, OP_TAILCALL: type mismatch for callable.</li> | ||
188 | <li>Inlined calls: closure mismatch, parameter number and type mismatches.</li> | ||
189 | <li>OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.</li> | ||
190 | <li>All arithmetic and comparison operators, OP_LEN, OP_CONCAT, | ||
191 | OP_FORPREP: operand type and range mismatches.</li> | ||
192 | </ul></li> | ||
193 | <li>Complete redesign of the debug and traceback info | ||
194 | (bytecode ↔ mcode) to support deoptimization. | ||
195 | Much more flexible and needs only 50% of the space.</li> | ||
196 | <li>The modules <tt>jit.trace</tt>, <tt>jit.dumphints</tt> and | ||
197 | <tt>jit.dump</tt> handle deoptimization.</li> | ||
198 | </ul></li> | ||
199 | |||
200 | <li>Inlined many popular library functions | ||
201 | (for commonly used arguments only): | ||
202 | <ul> | ||
203 | <li>Most <tt>math.*</tt> functions (the 18 most used ones) | ||
204 | [2x-10x faster].</li> | ||
205 | <li><tt>string.len</tt>, <tt>string.sub</tt> and <tt>string.char</tt> | ||
206 | [2x-10x faster].</li> | ||
207 | <li><tt>table.insert</tt>, <tt>table.remove</tt> and <tt>table.getn</tt> | ||
208 | [3x-5x faster].</li> | ||
209 | <li><tt>coroutine.yield</tt> and <tt>coroutine.resume</tt> | ||
210 | [3x-5x faster].</li> | ||
211 | <li><tt>pairs</tt>, <tt>ipairs</tt> and the corresponding iterators | ||
212 | [8x-15x faster].</li> | ||
213 | </ul></li> | ||
214 | |||
215 | <li>Changes in the core and loadable modules and the stand-alone executable: | ||
216 | <ul> | ||
217 | <li>Added <tt>jit.version</tt>, <tt>jit.version_num</tt> | ||
218 | and <tt>jit.arch</tt>.</li> | ||
219 | <li>Reorganized some internal API functions (<tt>jit.util.*mcode*</tt>).</li> | ||
220 | <li>The <tt>-j dump</tt> output now shows JSUB names, too.</li> | ||
221 | <li>New x86 disassembler module written in pure Lua. No dependency | ||
222 | on ndisasm anymore. Flexible API, very compact (500 lines) | ||
223 | and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).</li> | ||
224 | <li><tt>luajit -v</tt> prints the LuaJIT version and copyright | ||
225 | on a separate line.</li> | ||
226 | </ul></li> | ||
227 | |||
228 | <li>Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.</li> | ||
229 | <li>Miscellaneous doc changes. Added a section about | ||
230 | <a href="luajit_install.html#embedding">embedding LuaJIT</a>.</li> | ||
231 | </ul> | ||
232 | <p> | ||
233 | This release is in sync with Coco 1.1.0 (see the | ||
234 | <a href="coco_changes.html">Coco Change History</a>). | ||
235 | </p> | ||
236 | |||
237 | <h2 id="LuaJIT-1.0.3">LuaJIT 1.0.3 — 2005-09-08</h2> | ||
238 | <ul> | ||
239 | <li>Even more docs.</li> | ||
240 | <li>Unified closure checks in <tt>jit.*</tt>.</li> | ||
241 | <li>Fixed some range checks in <tt>jit.util.*</tt>.</li> | ||
242 | <li>Fixed __newindex call originating from <tt>jit_settable_str()</tt>.</li> | ||
243 | <li>Merged with Lua 5.1 alpha (including early bugfixes).</li> | ||
244 | </ul> | ||
245 | <p> | ||
246 | This is the first public release of LuaJIT. | ||
247 | </p> | ||
248 | |||
249 | <h2 id="LuaJIT-1.0.2">LuaJIT 1.0.2 — 2005-09-02</h2> | ||
250 | <ul> | ||
251 | <li>Add support for flushing the Valgrind translation cache <br> | ||
252 | (<tt>MYCFLAGS= -DUSE_VALGRIND</tt>).</li> | ||
253 | <li>Add support for freeing executable mcode memory to the <tt>mmap()</tt>-based | ||
254 | variant for POSIX systems.</li> | ||
255 | <li>Reorganized the C function signature handling in | ||
256 | <tt>jit.opt_lib</tt>.</li> | ||
257 | <li>Changed to index-based hints for inlining C functions. | ||
258 | Still no support in the backend for inlining.</li> | ||
259 | <li>Hardcode <tt>HEAP_CREATE_ENABLE_EXECUTE</tt> value if undefined.</li> | ||
260 | <li>Misc. changes to the <tt>jit.*</tt> modules.</li> | ||
261 | <li>Misc. changes to the Makefiles.</li> | ||
262 | <li>Lots of new docs.</li> | ||
263 | <li>Complete doc reorg.</li> | ||
264 | </ul> | ||
265 | <p> | ||
266 | Not released because Lua 5.1 alpha came out today. | ||
267 | </p> | ||
268 | |||
269 | <h2 id="LuaJIT-1.0.1">LuaJIT 1.0.1 — 2005-08-31</h2> | ||
270 | <ul> | ||
271 | <li>Missing GC step in <tt>OP_CONCAT</tt>.</li> | ||
272 | <li>Fix result handling for C –> JIT calls.</li> | ||
273 | <li>Detect CPU feature bits.</li> | ||
274 | <li>Encode conditional moves (<tt>fucomip</tt>) only when supported.</li> | ||
275 | <li>Add fallback instructions for FP compares.</li> | ||
276 | <li>Add support for <tt>LUA_COMPAT_VARARG</tt>. Still disabled by default.</li> | ||
277 | <li>MSVC needs a specific place for the <tt>CALLBACK</tt> attribute | ||
278 | (David Burgess).</li> | ||
279 | <li>Misc. doc updates.</li> | ||
280 | </ul> | ||
281 | <p> | ||
282 | Interim non-public release. | ||
283 | Special thanks to Adam D. Moss for reporting most of the bugs. | ||
284 | </p> | ||
285 | |||
286 | <h2 id="LuaJIT-1.0.0">LuaJIT 1.0.0 — 2005-08-29</h2> | ||
287 | <p> | ||
288 | This is the initial non-public release of LuaJIT. | ||
289 | </p> | ||
290 | <br class="flush"> | ||
291 | </div> | ||
292 | <div id="foot"> | ||
293 | <hr class="hide"> | ||
294 | Copyright © 2005-2011 Mike Pall | ||
295 | <span class="noprint"> | ||
296 | · | ||
297 | <a href="contact.html">Contact</a> | ||
298 | </span> | ||
299 | </div> | ||
300 | </body> | ||
301 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_debug.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_debug.html new file mode 100644 index 0000000..95d5565 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_debug.html | |||
@@ -0,0 +1,273 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Debugging LuaJIT</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Debugging LuaJIT</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a class="current" href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | LuaJIT is a rather complex application. There will undoubtedly | ||
64 | be bugs lurking in there. You have been warned. :-) | ||
65 | </p> | ||
66 | <p> | ||
67 | If you came here looking for information on how to debug | ||
68 | <em>your application</em> (and not LuaJIT itself) then please | ||
69 | check out <a href="luajit_api.html#jit_debug"><tt>jit.debug()</tt></a> | ||
70 | and the <a href="luajit_run.html#j_debug"><tt>-j debug</tt></a> | ||
71 | command line option. | ||
72 | </p> | ||
73 | <p> | ||
74 | But if you suspect a problem with LuaJIT itself, then try | ||
75 | any of the following suggestions (in order). | ||
76 | </p> | ||
77 | |||
78 | <h2>Is LuaJIT the Problem?</h2> | ||
79 | <p> | ||
80 | Try to run your application in several different ways: | ||
81 | </p> | ||
82 | <ul> | ||
83 | <li><tt>luajit app.lua</tt></li> | ||
84 | <li><tt>luajit -O1 app.lua</tt></li> | ||
85 | <li><tt>luajit -O app.lua</tt></li> | ||
86 | <li><tt>luajit -j off app.lua</tt></li> | ||
87 | <li><tt>lua app.lua</tt> (i.e. with standard Lua)</li> | ||
88 | </ul> | ||
89 | <p> | ||
90 | If the behaviour is the <em>same</em> as with standard Lua then ... | ||
91 | well ... that's what LuaJIT is about: doing the same things, | ||
92 | just faster. Even bugs fly faster. :-) | ||
93 | </p> | ||
94 | <p> | ||
95 | So this is most likely a bug in your application then. It may be easier | ||
96 | to debug this with plain Lua — the remainder of this page | ||
97 | is probably not helpful for you. | ||
98 | </p> | ||
99 | <p> | ||
100 | But if the behaviour is <em>different</em>, there is some likelihood | ||
101 | that you caught a bug in LuaJIT. Oh dear ... | ||
102 | </p> | ||
103 | <p> | ||
104 | Ok, so don't just give up. Please read on and help the community | ||
105 | by finding the bug. Thank you! | ||
106 | </p> | ||
107 | |||
108 | <h2>Get the Latest Version</h2> | ||
109 | <p> | ||
110 | Number one on your list of things to check is the | ||
111 | <a href="http://luajit.org/luajit_changes.html"><span class="ext">»</span> Online Change History</a>. | ||
112 | </p> | ||
113 | <p> | ||
114 | Please check if a newer version is available. Maybe the bug | ||
115 | you have encountered has been fixed already. Always download the | ||
116 | latest version and try it with your application before continuing. | ||
117 | </p> | ||
118 | |||
119 | <h2>Reproduce the Bug</h2> | ||
120 | <p> | ||
121 | First try to make the bug reproducible. Try to isolate the module | ||
122 | and the function the bug occurs in: | ||
123 | </p> | ||
124 | <p> | ||
125 | Either selectively turn off compilation for some modules with<br> | ||
126 | <tt> jit.off(true, true)</tt><br> | ||
127 | until the bug disappears ... | ||
128 | </p> | ||
129 | <p> | ||
130 | And/or turn the whole JIT engine off and selectively compile | ||
131 | functions with<br> | ||
132 | <tt> jit.compile(func)</tt><br> | ||
133 | until it reappears. | ||
134 | </p> | ||
135 | <p> | ||
136 | If you have isolated the point where it happens, it's most helpful | ||
137 | to reduce the affected Lua code to a short code snippet that | ||
138 | still shows the problem. You may need to <tt>print()</tt> some | ||
139 | variables until you can pinpoint the exact spot where it happens. | ||
140 | </p> | ||
141 | <p> | ||
142 | If you've got a <em>reproducible</em> and <em>short</em> test | ||
143 | you can either send it directly to me or the mailing list | ||
144 | (see the <a href="contact.html">Contact Information</a>) | ||
145 | or you can try to debug this a bit further. | ||
146 | </p> | ||
147 | <p> | ||
148 | Well — if you are brave enough. :-) | ||
149 | </p> | ||
150 | |||
151 | <h2>Look at the Generated Code</h2> | ||
152 | <p> | ||
153 | You may want to have a look at the output of <tt>-j dumphints</tt> | ||
154 | first. Try to change things around until you can see which hint | ||
155 | or which instruction is the cause of the bug. If you suspect | ||
156 | an optimizer bug then have a look at the backend (<tt>*.das[ch]</tt>) | ||
157 | and check how the hint is encoded. | ||
158 | </p> | ||
159 | <p> | ||
160 | Otherwise have a look at <tt>-j dump</tt> and see whether | ||
161 | you can spot the problem around the affected instruction. | ||
162 | It's helpful to have a good knowledge of assembler, though | ||
163 | (sorry). | ||
164 | </p> | ||
165 | |||
166 | <h2>Locate a Crash</h2> | ||
167 | <p> | ||
168 | If you get a crash, you should compile LuaJIT with debugging | ||
169 | turned on: | ||
170 | </p> | ||
171 | <p> | ||
172 | Add <tt>-g</tt> to <tt>CFLAGS</tt> and <tt>MYLDFLAGS</tt> | ||
173 | or whatever is needed to turn on debugging. For Windows you | ||
174 | need both an executable and a DLL built with debugging. | ||
175 | </p> | ||
176 | <p> | ||
177 | Then start LuaJIT with your debugger. Run it with | ||
178 | <tt>-j dump=test.dump</tt>. | ||
179 | </p> | ||
180 | <p> | ||
181 | Have a look at the backtrace and compare it with the generated | ||
182 | dump file to find out exactly where it crashes. I'm sorry, but | ||
183 | symbols or instructions for JIT compiled functions are not | ||
184 | displayed in your debugger (this is really hard to solve). | ||
185 | </p> | ||
186 | |||
187 | <h2>Turn on Assertions</h2> | ||
188 | <p> | ||
189 | Another way to debug LuaJIT is to turn on assertions. | ||
190 | They can be turned on only for the JIT engine by adding | ||
191 | <tt>-DLUAJIT_ASSERT</tt> to <tt>JITCFLAGS</tt> in <tt>src/Makefile</tt>. | ||
192 | Then recompile with <tt>make clean</tt> and <tt>make</tt>. | ||
193 | </p> | ||
194 | <p> | ||
195 | Add these two lines to <tt>src/luaconf.h</tt> to turn on all assertions in the Lua core:<br> | ||
196 | <tt> #include <assert.h></tt><br> | ||
197 | <tt> #define lua_assert(x) assert(x)</tt><br> | ||
198 | This turns on the JIT engine assertions, too. | ||
199 | Recompile and see whether any assertions trigger. | ||
200 | Don't forget to turn off the (slow) assertions when you're done! | ||
201 | </p> | ||
202 | |||
203 | <h2>Use Valgrind</h2> | ||
204 | <p> | ||
205 | A tremendously useful (and free) tool for runtime code analysis | ||
206 | is <a href="http://valgrind.org/"><span class="ext">»</span> Valgrind</a>. Regularly | ||
207 | run your applications with <tt>valgrind --memcheck</tt> and | ||
208 | your life will be better. | ||
209 | </p> | ||
210 | <p> | ||
211 | To run LuaJIT under Valgrind you <em>must</em> add | ||
212 | <tt>-DUSE_VALGRIND</tt> to <tt>MYCFLAGS</tt> | ||
213 | and recompile LuaJIT. You will get random errors if you don't! | ||
214 | Valgrind 3.x or later is required. Earlier versions | ||
215 | do not work well with newly allocated C stacks. | ||
216 | </p> | ||
217 | <p> | ||
218 | An executable built with this option runs fine without Valgrind | ||
219 | and without a performance loss. But it needs the Valgrind header | ||
220 | files for compilation (which is why it's not enabled by default). | ||
221 | </p> | ||
222 | <p> | ||
223 | It's helpful to compile LuaJIT with debugging turned on, too | ||
224 | (see above). | ||
225 | </p> | ||
226 | <p> | ||
227 | If Valgrind spots many invalid memory accesses that involve | ||
228 | memory allocation/free functions you've probably found a bug | ||
229 | related to garbage collection. Some object reference must have | ||
230 | gone astray. | ||
231 | </p> | ||
232 | <p> | ||
233 | Try to find out which object is disappearing. You can force | ||
234 | eager garbage collection with repeated calls to | ||
235 | <tt>collectgarbage()</tt> or by setting a very low threshold | ||
236 | with <tt>collectgarbage("setpause", 1)</tt>. | ||
237 | </p> | ||
238 | |||
239 | <h2>Don't Despair</h2> | ||
240 | <p> | ||
241 | If all of this doesn't help to find the bug, please send | ||
242 | a summary of your findings to the mailing list. Describe as much | ||
243 | of the circumstances you think are relevant. | ||
244 | </p> | ||
245 | <p> | ||
246 | Please <em>don't</em> send your whole application to me | ||
247 | (without asking first) and especially not to the mailing list. | ||
248 | Code snippets should preferrably be less than 50 lines and | ||
249 | up to the point. | ||
250 | </p> | ||
251 | <p> | ||
252 | All bug reports are helpful, even if no immediate solution | ||
253 | is available. Often enough someone else finds the same bug | ||
254 | in a different setting and together with your bug report | ||
255 | this may help to track it down. | ||
256 | </p> | ||
257 | <p> | ||
258 | Finally I have to say a <strong>BIG THANK YOU</strong> | ||
259 | to everyone who has helped to make LuaJIT better by finding | ||
260 | and fixing bugs! | ||
261 | </p> | ||
262 | <br class="flush"> | ||
263 | </div> | ||
264 | <div id="foot"> | ||
265 | <hr class="hide"> | ||
266 | Copyright © 2005-2011 Mike Pall | ||
267 | <span class="noprint"> | ||
268 | · | ||
269 | <a href="contact.html">Contact</a> | ||
270 | </span> | ||
271 | </div> | ||
272 | </body> | ||
273 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_features.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_features.html new file mode 100644 index 0000000..b4e896f --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_features.html | |||
@@ -0,0 +1,226 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>LuaJIT Features</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>LuaJIT Features</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a class="current" href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | LuaJIT tries to keep the spirit of Lua — it's <em>light-weight</em>, | ||
64 | <em>efficient</em> and <em>extensible</em>. | ||
65 | </p> | ||
66 | |||
67 | <h2>Features</h2> | ||
68 | <p> | ||
69 | All functions are by default compiled Just-In-Time (JIT) to | ||
70 | machine code: | ||
71 | </p> | ||
72 | <ul> | ||
73 | <li>Functions that are unused are not compiled at all.</li> | ||
74 | <li>Compilation can be enabled/disabled selectively for individual | ||
75 | functions and subfunctions or even whole modules.</li> | ||
76 | <li>Interpreted and compiled functions can be freely mixed.</li> | ||
77 | </ul> | ||
78 | <p> | ||
79 | Ahead-Of-Time (AOT) compilation (at runtime) is supported, too: | ||
80 | </p> | ||
81 | <ul> | ||
82 | <li>A number of API functions and command line options allows | ||
83 | full user control over the compilation process.</li> | ||
84 | </ul> | ||
85 | <p> | ||
86 | The JIT compiler is extensible: | ||
87 | </p> | ||
88 | <ul> | ||
89 | <li>The optimizer is an extra module that attaches to the compiler | ||
90 | pipeline.</li> | ||
91 | <li>Various modules provide trace and debug information about | ||
92 | the compilation process.</li> | ||
93 | <li>All of these features can be activated with command line options.</li> | ||
94 | </ul> | ||
95 | |||
96 | <h2>Performance</h2> | ||
97 | <p> | ||
98 | The compiled machine code is <em>very efficient</em>: | ||
99 | </p> | ||
100 | <ul> | ||
101 | <li>Have a look at some | ||
102 | <a href="luajit_performance.html">Performance Measurements</a>.</li> | ||
103 | <li>Aggressive optimizations (specialization, inlining) are enabled | ||
104 | wherever possible. Inlined contracts catch wrong optimizer predictions | ||
105 | at runtime (undetected polymorphism).</li> | ||
106 | <li>Adaptive deoptimization is used to recompile individual bytecode | ||
107 | instructions with broken contracts. This avoids generating code for the | ||
108 | generic fallback cases most of the time (faster compilation, reduced | ||
109 | I-cache contention).</li> | ||
110 | <li>Special CPU features (such as conditional moves or SSE2) | ||
111 | are automatically used when detected.</li> | ||
112 | </ul> | ||
113 | <p> | ||
114 | The JIT compiler is <em>very fast</em>: | ||
115 | </p> | ||
116 | <ul> | ||
117 | <li>Compilation times vary a great deal (depending on the nature of | ||
118 | the function to be compiled) but are generally in the | ||
119 | <em>microsecond</em> range.</li> | ||
120 | <li>Even compiling large functions (hundreds of lines) with the | ||
121 | maximum optimization level takes only a few milliseconds in the | ||
122 | worst case.</li> | ||
123 | </ul> | ||
124 | <p> | ||
125 | LuaJIT is <em>very small</em>: | ||
126 | </p> | ||
127 | <ul> | ||
128 | <li>The whole JIT compiler engine adds only around <strong>32K</strong> | ||
129 | of code to the Lua core (if compiled with <tt>-Os</tt>).</li> | ||
130 | <li>The optimizer is split into several optional modules that | ||
131 | can be loaded at runtime if requested.</li> | ||
132 | <li>LuaJIT adds around 6.000 lines of C and assembler code and | ||
133 | 2.000 lines of Lua code to the Lua 5.1 core (17.000 lines of C).</li> | ||
134 | <li>Required build tools (<a href="dynasm.html">DynASM</a>) | ||
135 | take another 2.500 lines of Lua code.</li> | ||
136 | </ul> | ||
137 | |||
138 | <h2>Compatibility</h2> | ||
139 | <p> | ||
140 | LuaJIT is designed to be <em>fully compatible</em> with Lua 5.1. | ||
141 | It accepts the same source code and/or precompiled bytecode. | ||
142 | It supports all standard language semantics. In particular: | ||
143 | </p> | ||
144 | <ul> | ||
145 | <li>All standard types, operators and metamethods are supported.</li> | ||
146 | <li>Implicit type coercions (number/string) work as expected.</li> | ||
147 | <li>Full IEEE-754 semantics for floating point arithmetics | ||
148 | (NaN, +-Inf, +-0, ...).</li> | ||
149 | <li>Full support for lexical closures. | ||
150 | Proper tail calls do not consume a call frame.</li> | ||
151 | <li>Exceptions are precise. Backtraces work fine.</li> | ||
152 | <li>Coroutines are supported with the help of <a href="coco.html">Coco</a>.</li> | ||
153 | <li>No changes to the Lua 5.1 incremental garbage collector.</li> | ||
154 | <li>No changes to the standard Lua/C API.</li> | ||
155 | <li>Dynamically loaded C modules are link compatible with Lua 5.1 | ||
156 | (same ABI).</li> | ||
157 | <li>LuaJIT can be <a href="luajit_install.html#embedding">embedded</a> | ||
158 | into an application just like Lua.</li> | ||
159 | </ul> | ||
160 | <p> | ||
161 | Some minor differences are related to debugging: | ||
162 | </p> | ||
163 | <ul> | ||
164 | <li>Debug hooks are only called if debug code generation is enabled.</li> | ||
165 | <li>There is no support for tailcall counting in JIT compiled code. | ||
166 | HOOKTAILRET is not called, too. Note: this won't affect you unless | ||
167 | you are writing a Lua debugger. <sup>*</sup></li> | ||
168 | </ul> | ||
169 | <p style="font-size: 80%;"> | ||
170 | <sup>*</sup> There is not much I can do to improve this situation without undue | ||
171 | complications. A suggestion to modify the behaviour of standard Lua | ||
172 | has been made on the mailing list (it would be beneficial there, too). | ||
173 | </p> | ||
174 | |||
175 | <h2>Restrictions</h2> | ||
176 | <ul> | ||
177 | <li>Only x86 (i386+) CPUs are supported right now (but see below).</li> | ||
178 | <li>Only the default type for <tt>lua_Number</tt> is supported | ||
179 | (<tt>double</tt>).</li> | ||
180 | <li>The interrupt signal (Ctrl-C) is ignored unless you enable | ||
181 | debug hooks (with <tt>-j debug</tt>). But this will seriously | ||
182 | slow down your application. I'm looking for better ways to handle | ||
183 | this. In the meantime you have to press Ctrl-C twice to interrupt | ||
184 | a currently running JIT compiled function (just like C functions).</li> | ||
185 | <li>GDB, Valgrind and other debugging tools can't report symbols | ||
186 | or stack frames for JIT compiled code. This is rather difficult to solve. | ||
187 | Have a look at <a href="luajit_debug.html">Debugging LuaJIT</a>, too.</li> | ||
188 | </ul> | ||
189 | |||
190 | <h2>Caveats</h2> | ||
191 | <ul> | ||
192 | <li>LuaJIT allocates executable memory for the generated machine code | ||
193 | if your OS has support for it: either <tt>HeapCreate()</tt> for Windows or | ||
194 | <tt>mmap()</tt> on POSIX systems.<br> | ||
195 | The fallback is the standard Lua allocator (i.e. malloc()). | ||
196 | But this usually means the allocated memory is not marked executable. | ||
197 | Running compiled code will trap on CPUs/OS with the NX (No eXecute) | ||
198 | extension <em>if you can only use the fallback</em>.</li> | ||
199 | <li><a href="dynasm.html">DynASM</a> is needed to regenerate the | ||
200 | <tt>ljit_x86.h</tt> file. But only in case you want to <em>modify</em> | ||
201 | the <tt>*.dasc</tt>/<tt>*.dash</tt> files. A pre-processed <tt>*.h</tt> | ||
202 | file is supplied with LuaJIT.<br> | ||
203 | DynASM is written in Lua and needs a plain copy of Lua 5.1 | ||
204 | (installed as <tt>lua</tt>). Or you can run it with LuaJIT built from | ||
205 | the <tt>*.h</tt> file supplied with the distribution (modify | ||
206 | <tt>DASM=</tt> in <tt>src/Makefile</tt>). It's a good idea to install | ||
207 | a known good copy of LuaJIT under a different name for this.</li> | ||
208 | <li>LuaJIT ships with <tt>LUA_COMPAT_VARARG</tt> turned off. | ||
209 | I.e. the implicit <tt>arg</tt> parameter is not created anymore. | ||
210 | Please have a look at the comments in <tt>luaconf.h</tt> for | ||
211 | this configuration option. You can turn it on, if you really need it. | ||
212 | Or better yet, convert your code to the new Lua 5.1 vararg syntax.</li> | ||
213 | </ul> | ||
214 | |||
215 | <br class="flush"> | ||
216 | </div> | ||
217 | <div id="foot"> | ||
218 | <hr class="hide"> | ||
219 | Copyright © 2005-2011 Mike Pall | ||
220 | <span class="noprint"> | ||
221 | · | ||
222 | <a href="contact.html">Contact</a> | ||
223 | </span> | ||
224 | </div> | ||
225 | </body> | ||
226 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_install.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_install.html new file mode 100644 index 0000000..bc5a3cd --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_install.html | |||
@@ -0,0 +1,340 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Installing LuaJIT</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | <style type="text/css"> | ||
12 | table.build { | ||
13 | line-height: 1.2; | ||
14 | } | ||
15 | td.buildsys { | ||
16 | width: 11em; | ||
17 | } | ||
18 | td.buildcmd { | ||
19 | width: 10em; | ||
20 | font-family: Courier New, Courier, monospace; | ||
21 | } | ||
22 | tr.buildhead td { | ||
23 | /* font-family: inherit; ... not supported in IE *sigh* */ | ||
24 | font-family: Verdana, Arial, Helvetica, sans-serif; | ||
25 | font-weight: bold; | ||
26 | } | ||
27 | </style> | ||
28 | </head> | ||
29 | <body> | ||
30 | <div id="site"> | ||
31 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
32 | </div> | ||
33 | <div id="head"> | ||
34 | <h1>Installing LuaJIT</h1> | ||
35 | </div> | ||
36 | <div id="nav"> | ||
37 | <ul><li> | ||
38 | <a href="index.html">Index</a> | ||
39 | </li><li> | ||
40 | <a href="luajit.html">LuaJIT</a> | ||
41 | <ul><li> | ||
42 | <a href="luajit_features.html">Features</a> | ||
43 | </li><li> | ||
44 | <a class="current" href="luajit_install.html">Installation</a> | ||
45 | </li><li> | ||
46 | <a href="luajit_run.html">Running</a> | ||
47 | </li><li> | ||
48 | <a href="luajit_api.html">API Extensions</a> | ||
49 | </li><li> | ||
50 | <a href="luajit_intro.html">Introduction</a> | ||
51 | </li><li> | ||
52 | <a href="luajit_performance.html">Performance</a> | ||
53 | </li><li> | ||
54 | <a href="luajit_debug.html">Debugging</a> | ||
55 | </li><li> | ||
56 | <a href="luajit_changes.html">Changes</a> | ||
57 | </li></ul> | ||
58 | </li><li> | ||
59 | <a href="coco.html">Coco</a> | ||
60 | <ul><li> | ||
61 | <a href="coco_portability.html">Portability</a> | ||
62 | </li><li> | ||
63 | <a href="coco_api.html">API Extensions</a> | ||
64 | </li><li> | ||
65 | <a href="coco_changes.html">Changes</a> | ||
66 | </li></ul> | ||
67 | </li><li> | ||
68 | <a href="dynasm.html">DynASM</a> | ||
69 | <ul><li> | ||
70 | <a href="dynasm_features.html">Features</a> | ||
71 | </li><li> | ||
72 | <a href="dynasm_examples.html">Examples</a> | ||
73 | </li></ul> | ||
74 | </li><li> | ||
75 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
76 | </li></ul> | ||
77 | </div> | ||
78 | <div id="main"> | ||
79 | <p> | ||
80 | LuaJIT is not much more difficult to install than Lua itself. | ||
81 | Just unpack the distribution file, change into the newly created | ||
82 | directory and follow the instructions below. | ||
83 | </p> | ||
84 | <p class="indent"> | ||
85 | For the impatient: <b><tt>make linux && sudo make install</tt></b><br> | ||
86 | Replace <tt>linux</tt> with e.g. <tt>bsd</tt> or <tt>macosx</tt> depending on your OS. | ||
87 | </p> | ||
88 | <p> | ||
89 | In case you've missed this in <a href="luajit_features.html">Features</a>: | ||
90 | LuaJIT only works on x86 (i386+) systems right now. Support for | ||
91 | other architectures may be added in future versions. | ||
92 | </p> | ||
93 | |||
94 | <h2>Configuring LuaJIT</h2> | ||
95 | <p> | ||
96 | LuaJIT is (deliberately) <em>not</em> autoconfigured — the | ||
97 | defaults should work fine on most systems. But please check the | ||
98 | system-specific instructions below. | ||
99 | </p> | ||
100 | <p> | ||
101 | The following three files hold all configuration information: | ||
102 | </p> | ||
103 | <ul> | ||
104 | <li><tt>Makefile</tt> holds settings for installing LuaJIT.</li> | ||
105 | <li><tt>src/Makefile</tt> holds settings for compiling LuaJIT.</li> | ||
106 | <li><tt>src/luaconf.h</tt> sets a multitude of configuration | ||
107 | variables.</li> | ||
108 | </ul> | ||
109 | <p> | ||
110 | If this is your first build then it's better not to give into | ||
111 | the temptation to tweak every little setting. The standard | ||
112 | configuration provides sensible defaults (IMHO). | ||
113 | </p> | ||
114 | <p> | ||
115 | One particular setting you might want to change is the installation | ||
116 | path. Note that you need to modify both the top-level <tt>Makefile</tt> | ||
117 | and <tt>src/luaconf.h</tt> (right at the start) to take | ||
118 | effect. | ||
119 | </p> | ||
120 | <p> | ||
121 | If you have trouble getting Coco to work, you can disable it by | ||
122 | uncommenting the <tt>COCOFLAGS= -DCOCO_DISABLE</tt> line in | ||
123 | <tt>src/Makefile</tt>. But note that this effectively disables | ||
124 | yielding from coroutines for JIT compiled functions. | ||
125 | </p> | ||
126 | <p> | ||
127 | A few more settings need to be changed if you want to | ||
128 | <a href="luajit_debug.html">Debug LuaJIT</a> <em>itself</em>. | ||
129 | Application debugging can be turned on/off at runtime. | ||
130 | </p> | ||
131 | |||
132 | <h3>Upgrading From Previous Versions</h3> | ||
133 | <p> | ||
134 | It's important to keep the LuaJIT core and the add-on modules in sync. | ||
135 | Be sure to delete any old versions of LuaJIT modules from the | ||
136 | Lua module search path (check the current directory, too!). | ||
137 | </p> | ||
138 | <p> | ||
139 | Lua files compiled to bytecode may be incompatible if the underlying | ||
140 | Lua core has changed (like from Lua 5.1 alpha to Lua 5.1 | ||
141 | final between LuaJIT 1.0.3 and LuaJIT 1.1.0). The same | ||
142 | applies to any | ||
143 | <a href="http://lua-users.org/wiki/BuildingModules"><span class="ext">»</span> loadable C modules</a> | ||
144 | (shared libraries, DLLs) which need to be recompiled with the new | ||
145 | Lua header files. | ||
146 | </p> | ||
147 | <p> | ||
148 | Compiled bytecode and loadable C modules are fully compatible and | ||
149 | can be freely exchanged between LuaJIT and the <em>same</em> | ||
150 | version of Lua it is based on. Please verify that <tt>LUA_RELEASE</tt> | ||
151 | in <tt>src/lua.h</tt> is the same in both distributions. | ||
152 | </p> | ||
153 | |||
154 | <h2>Building LuaJIT</h2> | ||
155 | |||
156 | <h3>Makefile Targets</h3> | ||
157 | <p> | ||
158 | The Makefiles have a number of targets for various operating systems: | ||
159 | </p> | ||
160 | |||
161 | <div class="tablewrap"> | ||
162 | <table class="build"> | ||
163 | <tr class="buildhead"><td class="buildsys">System</td><td class="buildcmd">Build Command</td><td>Notes</td></tr> | ||
164 | <tr class="odd"><td class="buildsys">Linux i386</td><td class="buildcmd">make linux</td><td></td></tr> | ||
165 | <tr class="even"><td class="buildsys">BSD i386</td><td class="buildcmd">make bsd</td><td>FreeBSD, NetBSD or OpenBSD</td></tr> | ||
166 | <tr class="odd"><td class="buildsys">Mac OS X on Intel</td><td class="buildcmd">make macosx</td><td>Check <tt>src/Makefile</tt> for OS X < 10.4</td></tr> | ||
167 | <tr class="even"><td class="buildsys">Solaris x86</td><td class="buildcmd">make solaris</td><td>GCC only, SunCC miscompiles LuaJIT</td></tr> | ||
168 | <tr class="odd"><td class="buildsys">MinGW (Win32)</td><td class="buildcmd">make mingw</td><td>cross-MinGW: must be 1st in PATH</td></tr> | ||
169 | <tr class="even"><td class="buildsys">Cygwin</td><td class="buildcmd">make cygwin</td><td></td></tr> | ||
170 | <tr class="odd"><td class="buildsys">POSIX on x86</td><td class="buildcmd">make posix</td><td>Check <a href="coco_portability.html">Portability Req. for Coco</a>, too</td></tr> | ||
171 | <tr class="even"><td class="buildsys">Generic x86</td><td class="buildcmd">make generic</td><td>Check <a href="coco_portability.html">Portability Req. for Coco</a>, too</td></tr> | ||
172 | </table> | ||
173 | </div> | ||
174 | |||
175 | <p> | ||
176 | You may want to enable interactive line editing for the stand-alone | ||
177 | executable. There are extra targets for Linux, BSD and Mac OS X: | ||
178 | <tt>make linux_rl</tt>, <tt>make bsd_rl</tt> | ||
179 | and <tt>make macosx_rl</tt>. | ||
180 | </p> | ||
181 | |||
182 | <h3>MSVC (Win32)</h3> | ||
183 | <p> | ||
184 | First check out <tt>etc\luavs.bat</tt> if it suits your needs. Then try | ||
185 | running it from the MSVC command prompt (start it from the toplevel directory). | ||
186 | </p> | ||
187 | <p> | ||
188 | Another option is to set up your own MSVC project: | ||
189 | </p> | ||
190 | <p> | ||
191 | Change to the <tt>src</tt> directory | ||
192 | and create a new DLL project for <tt>lua51.dll</tt>. | ||
193 | Add all C files to it except for <tt>lua.c</tt>, <tt>luac.c</tt> | ||
194 | and <tt>print.c</tt>. Add the <tt>..\dynasm</tt> directory | ||
195 | to the include path and build the DLL. | ||
196 | </p> | ||
197 | <p> | ||
198 | Next create a new EXE project for <tt>luajit.exe</tt>. | ||
199 | Add <tt>lua.c</tt> to it and link with the import library | ||
200 | <tt>lua51.lib</tt> created for <tt>lua51.dll</tt>. Build | ||
201 | the executable. | ||
202 | </p> | ||
203 | |||
204 | <h2>Installation</h2> | ||
205 | |||
206 | <h3>POSIX systems</h3> | ||
207 | <p> | ||
208 | Run <tt>make install</tt> from the top-level directory. | ||
209 | You probably need to be the root user before doing so, i.e. use | ||
210 | <tt>sudo make install</tt> or <tt>su - root</tt> | ||
211 | before the <tt>make install</tt>. | ||
212 | </p> | ||
213 | <p> | ||
214 | By default this installs only:<br> | ||
215 | <tt> /usr/local/bin/<strong>luajit</strong></tt> — The stand-alone executable.<br> | ||
216 | <tt> /usr/local/lib/lua/5.1</tt> — C module directory.<br> | ||
217 | <tt> /usr/local/share/lua/5.1</tt> — Lua module directory.<br> | ||
218 | <tt> /usr/local/share/lua/5.1/<strong>jit/*.lua</strong></tt> — | ||
219 | <tt>jit.*</tt> modules.<br> | ||
220 | </p> | ||
221 | <p> | ||
222 | The Lua docs and includes are not installed to avoid overwriting | ||
223 | an existing Lua installation. In any case these are identical | ||
224 | to the version of Lua that LuaJIT is based on. If you want | ||
225 | to install them, edit the top-level makefile (look for <tt>###</tt>). | ||
226 | </p> | ||
227 | <p> | ||
228 | The stand-alone Lua bytecode compiler <tt>luac</tt> is neither | ||
229 | built nor installed, for the same reason. If you really need it, | ||
230 | you may be better off with <tt>luac</tt> built from the original Lua | ||
231 | distribution (use the <em>same</em> version your copy of LuaJIT | ||
232 | is based on). This avoids dragging in most of LuaJIT which is not | ||
233 | needed for the pure bytecode compiler. You can also use the bare-bones | ||
234 | Lua to bytecode translator <tt>luac.lua</tt> (look in the <tt>test</tt> | ||
235 | directory of the original Lua distribution). | ||
236 | </p> | ||
237 | |||
238 | <h3>Windows</h3> | ||
239 | <p> | ||
240 | Copy <tt>luajit.exe</tt> and <tt>lua51.dll</tt> | ||
241 | to a newly created directory (any location is ok). Add <tt>lua</tt> | ||
242 | and <tt>lua\jit</tt> directories below it and copy all Lua files | ||
243 | from the <tt>jit</tt> directory of the distribution to the latter directory. | ||
244 | </p> | ||
245 | <p> | ||
246 | There are no hardcoded | ||
247 | absolute path names — all modules are loaded relative to the | ||
248 | directory where <tt>luajit.exe</tt> is installed | ||
249 | (see <tt>src/luaconf.h</tt>). | ||
250 | </p> | ||
251 | |||
252 | <h2 id="embedding">Embedding LuaJIT</h2> | ||
253 | <p> | ||
254 | It's strongly recommended that you build the stand-alone executable | ||
255 | with your toolchain and verify that it works <em>before</em> starting | ||
256 | to embed LuaJIT into an application. The stand-alone executable is | ||
257 | also useful later on, when you want to experiment with code snippets | ||
258 | or try out some Lua files. | ||
259 | </p> | ||
260 | <p> | ||
261 | Please consult the Lua docs for general information about how to | ||
262 | embed Lua into your application. The following list only shows | ||
263 | the additional steps needed for embedding LuaJIT: | ||
264 | </p> | ||
265 | <ul> | ||
266 | <li>You need to add the LuaJIT library functions by running | ||
267 | <tt>luaopen_jit()</tt> after all the other standard library functions. | ||
268 | The modified <tt>src/linit.c</tt> used by the stand-alone executable | ||
269 | already does this for you.</li> | ||
270 | <li><em>Caveat:</em> LuaJIT is based on Lua 5.1 which | ||
271 | means the <tt>luaopen_*()</tt> functions <em>must not</em> | ||
272 | be called directly. See <tt>src/linit.c</tt> for the proper way to | ||
273 | run them. You'll get an error initializing the <tt>io</tt> library | ||
274 | if you don't follow these instructions.</li> | ||
275 | <li>To use the optimizer (strongly recommended) you need to: | ||
276 | <ul> | ||
277 | <li>Install the optimizer modules <tt>jit.opt</tt> and | ||
278 | <tt>jit.opt_inline</tt> relative to the Lua module path | ||
279 | (you've probably modified it — see <tt>src/luaconf.h</tt>):<br> | ||
280 | <tt>jit/opt.lua</tt><br> | ||
281 | <tt>jit/opt_inline.lua</tt></li> | ||
282 | <li>If you want to ship a single executable then you may want to | ||
283 | embed the optimizer modules into your application (but don't loose | ||
284 | time with this during the early development phase). This involves: | ||
285 | <ul> | ||
286 | <li>Compile the two modules to bytecode | ||
287 | (using <tt>luac -s</tt> from a plain Lua installation).</li> | ||
288 | <li>Convert them to C include files (search for "Lua bin2c").</li> | ||
289 | <li>On Windows you can also put the compiled bytecode into a resource | ||
290 | (search for "Lua bin2res").</li> | ||
291 | <li>Load the bytecode with <tt>luaL_loadbuffer</tt> (but don't run it).</li> | ||
292 | <li>Put the resulting functions into <tt>package.preload["jit.opt"]</tt> | ||
293 | and <tt>package.preload["jit.opt_inline"]</tt>.</li> | ||
294 | </ul></li> | ||
295 | <li>Activate the LuaJIT optimizer from Lua code to be run at startup: | ||
296 | <tt> require("jit.opt").start()</tt><br> | ||
297 | Or use equivalent C code. See <tt>dojitopt()</tt> in <tt>src/lua.c</tt>.</li> | ||
298 | </ul></li> | ||
299 | <li>All other LuaJIT specific modules (<tt>jit.*</tt>) are for debugging only. | ||
300 | They do not need to be shipped with an application. But they may be quite | ||
301 | useful, anyway (especially <tt>jit.trace</tt>).</li> | ||
302 | <li>DynASM is only needed while <em>building</em> LuaJIT. It's not | ||
303 | needed while running LuaJIT and there is no point in shipping or | ||
304 | installing it together with an application.</li> | ||
305 | <li>In case you want to strip some of the standard libraries from | ||
306 | your application: The optimizer modules need several functions from | ||
307 | the base library and the string library (and of course the LuaJIT | ||
308 | core libraries). The io library is only used to print a fatal error | ||
309 | message (you may want to replace it). The optional modules | ||
310 | for debugging depend on a few more library functions — | ||
311 | please check the source.</li> | ||
312 | </ul> | ||
313 | <p> | ||
314 | Although the very liberal LuaJIT | ||
315 | <a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">»</span> license</a> | ||
316 | does not require any acknowledgment whatsoever, it would be appreciated | ||
317 | if you give some credit in the docs (or the "About" box) of your application. | ||
318 | A simple line like:<br> | ||
319 | <tt> This product includes LuaJIT, http://luajit.org/</tt><br> | ||
320 | would be nice. Please do not include any E-Mail addresses. Thank you! | ||
321 | </p> | ||
322 | <p> | ||
323 | I'm always interested where LuaJIT can be put to good use in applications. | ||
324 | Please <a href="contact.html">tell me</a> | ||
325 | or better yet write a few lines about your project to the | ||
326 | <a href="http://www.lua.org/lua-l.html"><span class="ext">»</span> Lua mailing list</a>. | ||
327 | Thank you! | ||
328 | </p> | ||
329 | <br class="flush"> | ||
330 | </div> | ||
331 | <div id="foot"> | ||
332 | <hr class="hide"> | ||
333 | Copyright © 2005-2011 Mike Pall | ||
334 | <span class="noprint"> | ||
335 | · | ||
336 | <a href="contact.html">Contact</a> | ||
337 | </span> | ||
338 | </div> | ||
339 | </body> | ||
340 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_intro.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_intro.html new file mode 100644 index 0000000..9e1fb23 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_intro.html | |||
@@ -0,0 +1,389 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Introducing LuaJIT</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Introducing LuaJIT</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a class="current" href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | This is a little essay that tries to answer the question: | ||
64 | <em>'So, how does LuaJIT really work?'</em>. | ||
65 | </p> | ||
66 | <p> | ||
67 | I tried to avoid going into all the gory details, but at the | ||
68 | same time provide a deep enough explanation, to let you find | ||
69 | your way around LuaJIT's inner workings. | ||
70 | </p> | ||
71 | <p> | ||
72 | The learning curve is maybe a little bit steep for newbies and | ||
73 | compiler gurus will certainly fall asleep after two paragraphs. | ||
74 | It's difficult to strike a balance here. | ||
75 | </p> | ||
76 | |||
77 | <h2>Acronym Soup</h2> | ||
78 | <p> | ||
79 | As the name says LuaJIT is a <em>Just-In-Time</em> (JIT) compiler. | ||
80 | This means that functions are compiled on demand, i.e. when they | ||
81 | are run first. This ensures both a quick application startup | ||
82 | and helps to avoid useless work, too. E.g. unused functions | ||
83 | are not compiled at all. | ||
84 | </p> | ||
85 | <p> | ||
86 | The other alternative is known as <em>Ahead-Of-Time</em> (AOT) | ||
87 | compilation. Here everything is compiled before running any function. | ||
88 | This is the classic way for many languages, such as C or C++. | ||
89 | </p> | ||
90 | <p> | ||
91 | In fact plain Lua allows you to pre-compile Lua source code into | ||
92 | Lua bytecode and store it in a binary file that can be run | ||
93 | later on. This is used only in specific settings (e.g. memory limited | ||
94 | embedded systems), because the Lua bytecode compiler is really fast. | ||
95 | The ability to run source files right away is part of what makes | ||
96 | a dynamic language (aka scripting language) so powerful. | ||
97 | </p> | ||
98 | <p> | ||
99 | JIT compilation has a few other advantages for dynamic languages | ||
100 | that AOT compilation can only provide with a massive amount | ||
101 | of code analysis. More can be found in the literature. | ||
102 | One particular advantage is explained later. | ||
103 | </p> | ||
104 | |||
105 | <h2>Quick, JIT — Run!</h2> | ||
106 | <p> | ||
107 | JIT compilation happens mostly invisible. You'll probably never | ||
108 | notice that a compilation is going on. Part of the secret is | ||
109 | that everything happens in little pieces intermixed with running | ||
110 | the application itself inbetween. The other part of the secret | ||
111 | is that JIT compilation can be made pretty fast. | ||
112 | </p> | ||
113 | <p> | ||
114 | Most applications quickly converge to a stable state where | ||
115 | everything that really needs to be compiled is compiled | ||
116 | right away. Only occasional isolated compiles happen later on. | ||
117 | </p> | ||
118 | <p> | ||
119 | Even though the name doesn't suggest it, LuaJIT <em>can</em> operate | ||
120 | in AOT mode, too. But this is completely under user control | ||
121 | (see <a href="luajit_api.html#jit_compile"><tt>jit.compile()</tt></a>) | ||
122 | and doesn't happen automatically. | ||
123 | </p> | ||
124 | <p> | ||
125 | Unless you have good reason to suspect that AOT compilation | ||
126 | might help for a specific application, I wouldn't bother though. | ||
127 | Compilation speed is usually a non-argument, because LuaJIT | ||
128 | is extremely fast. Compilation times are typically in the | ||
129 | <em>microsecond range</em> for individual Lua functions. | ||
130 | </p> | ||
131 | |||
132 | <h2>Starting Up</h2> | ||
133 | <p> | ||
134 | The next few paragraphs may not be exactly breaking news to you, | ||
135 | if you are familiar with JIT compilers. Still, please read on, | ||
136 | because some terms are introduced that are used later on. | ||
137 | </p> | ||
138 | <p> | ||
139 | When you start LuaJIT everything proceeds like in standard Lua: | ||
140 | the Lua core is initialized, the standard libraries are loaded and | ||
141 | the command line is analyzed. Then usually the first Lua source | ||
142 | code file is loaded and is translated to Lua bytecode. And finally | ||
143 | the function for the initial main chunk is run ... | ||
144 | </p> | ||
145 | |||
146 | <h2>Kicking the Compiler</h2> | ||
147 | <p> | ||
148 | This is where LuaJIT kicks in: | ||
149 | </p> | ||
150 | <p> | ||
151 | All Lua functions carry an additional <em>status code</em> for LuaJIT. | ||
152 | Initially this is set to 'NONE', i.e. the function has not been | ||
153 | looked at (yet). If a function is run with this setting, | ||
154 | the LuaJIT <em>compiler pipeline</em> is started up. | ||
155 | </p> | ||
156 | <p> | ||
157 | If you haven't loaded any special LuaJIT modules and optimization | ||
158 | is not turned on, the compiler pipeline only consists of the | ||
159 | <em>compiler backend</em>. | ||
160 | </p> | ||
161 | <p> | ||
162 | The compiler backend is the low-level encoding engine that translates | ||
163 | bytecode instructions to machine code instructions. Without any | ||
164 | further hints from other modules, the backend more or less does a | ||
165 | 1:1 translation. I.e. a single variant of a bytecode instruction | ||
166 | corresponds to a single piece of machine code. | ||
167 | </p> | ||
168 | <p> | ||
169 | If all goes well, these little code pieces are put together, | ||
170 | a function prologue is slapped on and voila: your Lua function | ||
171 | has been translated to machine code. Of course things are not | ||
172 | that simple when you look closer, but hey — this is | ||
173 | the theory. | ||
174 | </p> | ||
175 | <p> | ||
176 | Anyway, the status code for the function is set to 'OK' and the | ||
177 | machine code is run. If this function runs another Lua function | ||
178 | which has not been compiled, that one is compiled, too. And so on. | ||
179 | </p> | ||
180 | |||
181 | <h2>Call Gates</h2> | ||
182 | <p> | ||
183 | Ok, so what happens when a function is called repeatedly? After all | ||
184 | this is the most common case. | ||
185 | </p> | ||
186 | <p> | ||
187 | Simple: The status code is checked again. This time it's set to 'OK', | ||
188 | so the machine code can be run directly. Well — that's not the | ||
189 | whole truth: for calls that originate in a JIT compiled function | ||
190 | a better mechanism, tentatively named <em>call gates</em> is used. | ||
191 | </p> | ||
192 | <p> | ||
193 | Every function has a call gate field (a function pointer). By default | ||
194 | it's set to a function that does the above checks and runs the | ||
195 | compiler. But as soon as a function is compiled, the call gate | ||
196 | is modified to point to the just compiled machine code. | ||
197 | </p> | ||
198 | <p> | ||
199 | Calling a function is then as easy as calling the code that the | ||
200 | call gate points to. But due to special (faster) calling conventions | ||
201 | this function pointer cannot be used directly from C. So calls from | ||
202 | a non-compiled function or from a C function use an extra entry | ||
203 | call gate which in turn calls the real call gate. But this is | ||
204 | really a non-issue since most calls in typical applications | ||
205 | are intra-JIT calls. | ||
206 | </p> | ||
207 | |||
208 | <h2>The Compiler Pipeline</h2> | ||
209 | <p> | ||
210 | The compiler pipeline has already been mentioned. This sounds | ||
211 | more complicated than it is. Basically this is a coroutine that | ||
212 | runs a <em>frontend</em> function which in turn calls all functions | ||
213 | from the <em>pipeline table</em>. | ||
214 | </p> | ||
215 | <p> | ||
216 | The pipeline table is sorted by <em>priorities</em>. The standard | ||
217 | backend has priority 0. Positive priorities are run before the | ||
218 | backend and negative priorities are run after the backend. Modules | ||
219 | can dynamically attach or detach themselves to the pipeline with | ||
220 | the library function <tt>jit.attach()</tt>. | ||
221 | </p> | ||
222 | <p> | ||
223 | So a typical optimizer pass better have a positive priority, | ||
224 | because it needs to be run before the backend is run. E.g. the | ||
225 | LuaJIT optimizer module registers itself with priority 50. | ||
226 | </p> | ||
227 | <p> | ||
228 | On the other hand a typical helper module for debugging — | ||
229 | a machine code disassembler — needs to be run after the | ||
230 | backend and is attached with a negative priority. | ||
231 | </p> | ||
232 | <p> | ||
233 | One special case occurs when compilation fails. This can be due to | ||
234 | an internal error (ouch) or on purpose. E.g. the optimizer module | ||
235 | checks some characteristics of the function to be compiled and | ||
236 | may decide that it's just not worth it. In this case a status | ||
237 | other than OK is passed back to the pipeline frontend. | ||
238 | </p> | ||
239 | <p> | ||
240 | The easiest thing would be to abort pipeline processing and just | ||
241 | give up. But this would remove the ability to trace the progress | ||
242 | of the compiler (which better include failed compilations, too). | ||
243 | So there is a special rule that odd priorities are still run, | ||
244 | but even priorities are not. That's why e.g. <tt>-j trace</tt> | ||
245 | registers itself with priority -99. | ||
246 | </p> | ||
247 | |||
248 | <h2>The Optimizer</h2> | ||
249 | <p> | ||
250 | Maybe it hasn't become clear from the above description, | ||
251 | but a module can attach any Lua or C function to the compiler | ||
252 | pipeline. In fact all of the loadable modules are Lua modules. | ||
253 | Only the backend itself is written in C. | ||
254 | </p> | ||
255 | <p> | ||
256 | So, yes — the LuaJIT optimizer is written in pure Lua! | ||
257 | </p> | ||
258 | <p> | ||
259 | And no, don't worry, it's quite fast. One reason for this is | ||
260 | that a very simple <em>abstract interpretation</em> algorithm | ||
261 | is used. It mostly ignores control flow and/or basic block | ||
262 | boundaries. | ||
263 | </p> | ||
264 | <p> | ||
265 | Thus the results of the analysis are really only <em>hints</em>. | ||
266 | The backend <em>must</em> check the preconditions (the contracts) | ||
267 | for these hints (e.g. the object type). Still, the generated | ||
268 | hints are pretty accurate and quite useful to speed up the | ||
269 | compiled code (see below). | ||
270 | </p> | ||
271 | <p> | ||
272 | Explaining how abstract interpretation works is not within the | ||
273 | scope for this short essay. You may want to have a look at the | ||
274 | optimizer source code and/or read some articles or books on | ||
275 | this topic. The canonical reference is | ||
276 | <a href="http://www2.imm.dtu.dk/~riis/PPA/ppa.html"><span class="ext">»</span> Principles of Program Analysis</a>. | ||
277 | Ok, so this one is a bit more on the theoretical side (a gross | ||
278 | understatement). Try a search engine with the keywords "abstract | ||
279 | interpretation", too. | ||
280 | </p> | ||
281 | <p> | ||
282 | Suffice to say the optimizer generates hints and passes these | ||
283 | on to the backend. The backend then decides to encode different | ||
284 | forms for the same bytecode instruction, to combine several | ||
285 | instructions or to inline code for C functions. If the hints | ||
286 | from the optimizer are good, the resulting code will perform | ||
287 | better because shorter code paths are used for the typical cases. | ||
288 | </p> | ||
289 | |||
290 | <h2>The JIT Advantage</h2> | ||
291 | <p> | ||
292 | One important feature of the optimizer is that it takes 'live' | ||
293 | function arguments into account. Since the JIT compiler is | ||
294 | called just before the function is run, the arguments for this | ||
295 | first invocation are already present. This can be used to great | ||
296 | advantage in a <em>dynamically typed language</em>, such as Lua. | ||
297 | </p> | ||
298 | <p> | ||
299 | Here's a trivial example: | ||
300 | </p> | ||
301 | <pre> | ||
302 | function foo(t, k) | ||
303 | return t[k] | ||
304 | end | ||
305 | </pre> | ||
306 | <p> | ||
307 | Without knowing the most likely arguments for the function | ||
308 | there's not much to optimize. | ||
309 | </p> | ||
310 | <p> | ||
311 | Ok, so 't' is most likely a table. But it could be userdata, too. | ||
312 | In fact it could be any type since the introduction of generic | ||
313 | metatables for types. | ||
314 | </p> | ||
315 | <p> | ||
316 | And more importantly 'k' can be a number, a string | ||
317 | or any other type. Oh and let's not forget about metamethods ... | ||
318 | </p> | ||
319 | <p> | ||
320 | If you know a bit about Lua internals, it should be clear by now | ||
321 | that the code for this function could potentially branch to half | ||
322 | of the Lua core. And it's of course impossible to inline all | ||
323 | these cases. | ||
324 | </p> | ||
325 | <p> | ||
326 | On the other hand if it's <em>known</em> (or there's a good hint) | ||
327 | that 't' is a table and that 'k' is a positive integer, then there | ||
328 | is a high likeliness that the key 'k' is in the array part | ||
329 | of the table. This lookup can be done with just a few machine code | ||
330 | instructions. | ||
331 | </p> | ||
332 | <p> | ||
333 | Of course the preconditions for this fast path have to be checked | ||
334 | (unless there are definitive hints). But if the hints are right, | ||
335 | the code runs a lot faster (about a factor of 3 in this case | ||
336 | for the pure table lookup). | ||
337 | </p> | ||
338 | |||
339 | <h2>Optimizing the Optimizer</h2> | ||
340 | <p> | ||
341 | A question that surely popped up in your mind while reading | ||
342 | the above section: does the optimizer optimize itself? I.e. | ||
343 | is the optimizer module compiled? | ||
344 | </p> | ||
345 | <p> | ||
346 | The current answer is no. Mainly because the compiler pipeline | ||
347 | is single-threaded only. It's locked during compilation and | ||
348 | any parallel attempt to JIT compile a function results in | ||
349 | a 'DELAYED' status code. In fact all modules that attach to | ||
350 | the compiler pipeline disable compilation for the entire | ||
351 | module (because LuaJIT would do that anyway). The main chunk | ||
352 | of modules loaded with <tt>require()</tt> is never compiled, | ||
353 | so there is no chicken-and-egg problem here. | ||
354 | </p> | ||
355 | <p> | ||
356 | Of course you could do an AOT compilation in the main chunk of | ||
357 | the optimizer module. But then only with the plain backend. | ||
358 | Recompiling it later on with the optimizer attached doesn't work, | ||
359 | because a function cannot be compiled twice (I plan to lift | ||
360 | this restriction). | ||
361 | </p> | ||
362 | <p> | ||
363 | The other question is whether it pays off to compile the optimizer | ||
364 | at all? Honestly, I haven't tried, because the current optimizer | ||
365 | is really simple. It runs very quickly, even under the bytecode | ||
366 | interpreter. | ||
367 | </p> | ||
368 | |||
369 | <h2>That's All Folks</h2> | ||
370 | <p> | ||
371 | Ok, that's all for now. I'll extend this text later on with | ||
372 | new topics that come up in questions. Keep on asking these | ||
373 | on the mailing list if you are interested. | ||
374 | </p> | ||
375 | <p> | ||
376 | Thank you for your attention! | ||
377 | </p> | ||
378 | <br class="flush"> | ||
379 | </div> | ||
380 | <div id="foot"> | ||
381 | <hr class="hide"> | ||
382 | Copyright © 2005-2011 Mike Pall | ||
383 | <span class="noprint"> | ||
384 | · | ||
385 | <a href="contact.html">Contact</a> | ||
386 | </span> | ||
387 | </div> | ||
388 | </body> | ||
389 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_performance.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_performance.html new file mode 100644 index 0000000..7f2307c --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_performance.html | |||
@@ -0,0 +1,394 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>LuaJIT Performance</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | <style type="text/css"> | ||
12 | table.bench { | ||
13 | line-height: 1.2; | ||
14 | } | ||
15 | tr.benchhead td { | ||
16 | font-weight: bold; | ||
17 | } | ||
18 | td img, li img { | ||
19 | vertical-align: middle; | ||
20 | } | ||
21 | td.barhead, td.bar { | ||
22 | font-size: 8pt; | ||
23 | font-family: Courier New, Courier, monospace; | ||
24 | width: 360px; | ||
25 | padding: 0; | ||
26 | } | ||
27 | td.bar { | ||
28 | background: url('img/backbar.png'); | ||
29 | } | ||
30 | td.speedup { | ||
31 | text-align: center; | ||
32 | } | ||
33 | </style> | ||
34 | </head> | ||
35 | <body> | ||
36 | <div id="site"> | ||
37 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
38 | </div> | ||
39 | <div id="head"> | ||
40 | <h1>LuaJIT Performance</h1> | ||
41 | </div> | ||
42 | <div id="nav"> | ||
43 | <ul><li> | ||
44 | <a href="index.html">Index</a> | ||
45 | </li><li> | ||
46 | <a href="luajit.html">LuaJIT</a> | ||
47 | <ul><li> | ||
48 | <a href="luajit_features.html">Features</a> | ||
49 | </li><li> | ||
50 | <a href="luajit_install.html">Installation</a> | ||
51 | </li><li> | ||
52 | <a href="luajit_run.html">Running</a> | ||
53 | </li><li> | ||
54 | <a href="luajit_api.html">API Extensions</a> | ||
55 | </li><li> | ||
56 | <a href="luajit_intro.html">Introduction</a> | ||
57 | </li><li> | ||
58 | <a class="current" href="luajit_performance.html">Performance</a> | ||
59 | </li><li> | ||
60 | <a href="luajit_debug.html">Debugging</a> | ||
61 | </li><li> | ||
62 | <a href="luajit_changes.html">Changes</a> | ||
63 | </li></ul> | ||
64 | </li><li> | ||
65 | <a href="coco.html">Coco</a> | ||
66 | <ul><li> | ||
67 | <a href="coco_portability.html">Portability</a> | ||
68 | </li><li> | ||
69 | <a href="coco_api.html">API Extensions</a> | ||
70 | </li><li> | ||
71 | <a href="coco_changes.html">Changes</a> | ||
72 | </li></ul> | ||
73 | </li><li> | ||
74 | <a href="dynasm.html">DynASM</a> | ||
75 | <ul><li> | ||
76 | <a href="dynasm_features.html">Features</a> | ||
77 | </li><li> | ||
78 | <a href="dynasm_examples.html">Examples</a> | ||
79 | </li></ul> | ||
80 | </li><li> | ||
81 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
82 | </li></ul> | ||
83 | </div> | ||
84 | <div id="main"> | ||
85 | <p> | ||
86 | Here are some performance measurements, based on a few benchmarks. | ||
87 | </p> | ||
88 | <p style="background: #ffd0d0; text-align: center;"> | ||
89 | LuaJIT 2.0 is available with much improved performance!<br> | ||
90 | Please check the new | ||
91 | <a href="http://luajit.org/performance.html"><span class="ext">»</span> interactive performance comparison</a>. | ||
92 | </p> | ||
93 | |||
94 | <h2 id="interpretation">Interpreting the Results</h2> | ||
95 | <p> | ||
96 | As is always the case with benchmarks, care must be taken to | ||
97 | interpret the results: | ||
98 | </p> | ||
99 | <p> | ||
100 | First, the standard Lua interpreter is already <em>very</em> fast. | ||
101 | It's commonly the fastest of it's class (interpreters) in the | ||
102 | <a href="http://shootout.alioth.debian.org/"><span class="ext">»</span> Great Computer Language Shootout</a>. | ||
103 | Only true machine code compilers get a better overall score. | ||
104 | </p> | ||
105 | <p> | ||
106 | Any performance improvements due to LuaJIT can only be incremental. | ||
107 | You can't expect a speedup of 50x if the fastest compiled language | ||
108 | is only 5x faster than interpreted Lua in a particular benchmark. | ||
109 | LuaJIT can't do miracles. | ||
110 | </p> | ||
111 | <p> | ||
112 | Also please note that most of the benchmarks below are <em>not</em> | ||
113 | trivial micro-benchmarks, which are often cited with marvelous numbers. | ||
114 | Micro-benchmarks do not realistically model the performance gains you | ||
115 | can expect in your own programs. | ||
116 | </p> | ||
117 | <p> | ||
118 | It's easy to make up a few one-liners like:<br> | ||
119 | <tt> local function f(...) end; for i=1,1e7 do f() end</tt><br> | ||
120 | This is more than 30x faster with LuaJIT. But you won't find | ||
121 | this in a real-world program. | ||
122 | </p> | ||
123 | |||
124 | <h2 id="methods">Measurement Methods</h2> | ||
125 | <p> | ||
126 | All measurements have been taken on a Pentium III 1.139 GHz | ||
127 | running Linux 2.6. Both Lua and LuaJIT have been compiled with | ||
128 | GCC 3.3.6 with <tt>-O3 -fomit-frame-pointer</tt>. | ||
129 | You'll definitely get different results on different machines or | ||
130 | with different C compiler options. <sup>*</sup> | ||
131 | </p> | ||
132 | <p> | ||
133 | The base for the comparison are the user CPU times as reported by | ||
134 | <tt>/usr/bin/time</tt>. The runtime of each benchmark is parametrized | ||
135 | and has been adjusted to minimize the variation between several runs. | ||
136 | The ratio between the times for LuaJIT and Lua gives the speedup. | ||
137 | Only this number is shown because it's less dependent on a specific system. | ||
138 | </p> | ||
139 | <p> | ||
140 | E.g. a speedup of 6.74 means the same benchmark runs almost 7 times | ||
141 | faster with <tt>luajit -O</tt> than with standard Lua (or with | ||
142 | <tt>-j off</tt>). Your mileage may vary. | ||
143 | </p> | ||
144 | <p style="font-size: 80%;"> | ||
145 | <sup>*</sup> Yes, LuaJIT relies on quite a bit of the Lua core infrastructure | ||
146 | like table and string handling. All of this is written in C and | ||
147 | should be compiled with full optimization turned on, or performance | ||
148 | will suffer. | ||
149 | </p> | ||
150 | |||
151 | <h2 id="lua_luajit" class="pagebreak">Comparing Lua to LuaJIT</h2> | ||
152 | <p> | ||
153 | Here is a comparison using the current benchmark collection of the | ||
154 | <a href="http://shootout.alioth.debian.org/"><span class="ext">»</span> Great Computer Language Shootout</a> (as of 3/2006): | ||
155 | </p> | ||
156 | |||
157 | <div class="tablewrap"> | ||
158 | <table class="bench"> | ||
159 | <tr class="benchhead"> | ||
160 | <td>Benchmark</td> | ||
161 | <td class="speedup">Speedup</td> | ||
162 | <td class="barhead"> | ||
163 | <img src="img/spacer.png" width="360" height="12" alt="-----1x----2x----3x----4x----5x----6x----7x----8x"> | ||
164 | </td> | ||
165 | </tr> | ||
166 | <tr class="odd"> | ||
167 | <td>mandelbrot</td> | ||
168 | <td class="speedup">6.74</td> | ||
169 | <td class="bar"><img src="img/bluebar.png" width="303" height="12" alt="========================================"></td> | ||
170 | </tr> | ||
171 | <tr class="even"> | ||
172 | <td>recursive</td> | ||
173 | <td class="speedup">6.64</td> | ||
174 | <td class="bar"><img src="img/bluebar.png" width="299" height="12" alt="========================================"></td> | ||
175 | </tr> | ||
176 | <tr class="odd"> | ||
177 | <td>fannkuch</td> | ||
178 | <td class="speedup">5.37</td> | ||
179 | <td class="bar"><img src="img/bluebar.png" width="242" height="12" alt="================================"></td> | ||
180 | </tr> | ||
181 | <tr class="even"> | ||
182 | <td>chameneos</td> | ||
183 | <td class="speedup">5.08</td> | ||
184 | <td class="bar"><img src="img/bluebar.png" width="229" height="12" alt="=============================="></td> | ||
185 | </tr> | ||
186 | <tr class="odd"> | ||
187 | <td>nsievebits</td> | ||
188 | <td class="speedup">5.05</td> | ||
189 | <td class="bar"><img src="img/bluebar.png" width="227" height="12" alt="=============================="></td> | ||
190 | </tr> | ||
191 | <tr class="even"> | ||
192 | <td>pidigits</td> | ||
193 | <td class="speedup">4.94</td> | ||
194 | <td class="bar"><img src="img/bluebar.png" width="222" height="12" alt="=============================="></td> | ||
195 | </tr> | ||
196 | <tr class="odd"> | ||
197 | <td>nbody</td> | ||
198 | <td class="speedup">4.63</td> | ||
199 | <td class="bar"><img src="img/bluebar.png" width="208" height="12" alt="============================"></td> | ||
200 | </tr> | ||
201 | <tr class="even"> | ||
202 | <td>spectralnorm</td> | ||
203 | <td class="speedup">4.59</td> | ||
204 | <td class="bar"><img src="img/bluebar.png" width="207" height="12" alt="============================"></td> | ||
205 | </tr> | ||
206 | <tr class="odd"> | ||
207 | <td>cheapconcr</td> | ||
208 | <td class="speedup">4.46</td> | ||
209 | <td class="bar"><img src="img/bluebar.png" width="201" height="12" alt="==========================="></td> | ||
210 | </tr> | ||
211 | <tr class="even"> | ||
212 | <td>partialsums</td> | ||
213 | <td class="speedup">3.73</td> | ||
214 | <td class="bar"><img src="img/bluebar.png" width="168" height="12" alt="======================"></td> | ||
215 | </tr> | ||
216 | <tr class="odd"> | ||
217 | <td>fasta</td> | ||
218 | <td class="speedup">2.68</td> | ||
219 | <td class="bar"><img src="img/bluebar.png" width="121" height="12" alt="================"></td> | ||
220 | </tr> | ||
221 | <tr class="even"> | ||
222 | <td>cheapconcw</td> | ||
223 | <td class="speedup">2.52</td> | ||
224 | <td class="bar"><img src="img/bluebar.png" width="113" height="12" alt="==============="></td> | ||
225 | </tr> | ||
226 | <tr class="odd"> | ||
227 | <td>nsieve</td> | ||
228 | <td class="speedup">1.95</td> | ||
229 | <td class="bar"><img src="img/bluebar.png" width="88" height="12" alt="============"></td> | ||
230 | </tr> | ||
231 | <tr class="even"> | ||
232 | <td>revcomp</td> | ||
233 | <td class="speedup">1.92</td> | ||
234 | <td class="bar"><img src="img/bluebar.png" width="86" height="12" alt="============"></td> | ||
235 | </tr> | ||
236 | <tr class="odd"> | ||
237 | <td>knucleotide</td> | ||
238 | <td class="speedup">1.59</td> | ||
239 | <td class="bar"><img src="img/bluebar.png" width="72" height="12" alt="=========="></td> | ||
240 | </tr> | ||
241 | <tr class="even"> | ||
242 | <td>binarytrees</td> | ||
243 | <td class="speedup">1.52</td> | ||
244 | <td class="bar"><img src="img/bluebar.png" width="68" height="12" alt="========="></td> | ||
245 | </tr> | ||
246 | <tr class="odd"> | ||
247 | <td>sumfile</td> | ||
248 | <td class="speedup">1.27</td> | ||
249 | <td class="bar"><img src="img/bluebar.png" width="57" height="12" alt="========"></td> | ||
250 | </tr> | ||
251 | <tr class="even"> | ||
252 | <td>regexdna</td> | ||
253 | <td class="speedup">1.01</td> | ||
254 | <td class="bar"><img src="img/bluebar.png" width="45" height="12" alt="======"></td> | ||
255 | </tr> | ||
256 | </table> | ||
257 | </div> | ||
258 | <p> | ||
259 | Note that many of these benchmarks have changed over time (both spec | ||
260 | and code). Benchmark results shown in previous versions of LuaJIT | ||
261 | are not directly comparable. The next section compares different | ||
262 | versions with the current set of benchmarks. | ||
263 | </p> | ||
264 | |||
265 | <h2 id="luajit_versions" class="pagebreak">Comparing LuaJIT Versions</h2> | ||
266 | <p> | ||
267 | This shows the improvements between the following versions: | ||
268 | </p> | ||
269 | <ul> | ||
270 | <li>LuaJIT 1.0.x <img src="img/bluebar.png" width="30" height="12" alt="(===)"></li> | ||
271 | <li>LuaJIT 1.1.x <img src="img/bluebar.png" width="30" height="12" alt="(===##)"><img src="img/magentabar.png" width="20" height="12" alt=""></li> | ||
272 | </ul> | ||
273 | |||
274 | <div class="tablewrap"> | ||
275 | <table class="bench"> | ||
276 | <tr class="benchhead"> | ||
277 | <td>Benchmark</td> | ||
278 | <td class="speedup">Speedup</td> | ||
279 | <td class="barhead"> | ||
280 | <img src="img/spacer.png" width="360" height="12" alt="-----1x----2x----3x----4x----5x----6x----7x----8x"> | ||
281 | </td> | ||
282 | </tr> | ||
283 | <tr class="odd"> | ||
284 | <td>fannkuch</td> | ||
285 | <td class="speedup">3.96 → 5.37</td> | ||
286 | <td class="bar"><img src="img/bluebar.png" width="178" height="12" alt="========================"><img src="img/magentabar.png" width="64" height="12" alt="########"></td> | ||
287 | </tr> | ||
288 | <tr class="even"> | ||
289 | <td>chameneos</td> | ||
290 | <td class="speedup">2.25 → 5.08</td> | ||
291 | <td class="bar"><img src="img/bluebar.png" width="101" height="12" alt="=============="><img src="img/magentabar.png" width="128" height="12" alt="################"></td> | ||
292 | </tr> | ||
293 | <tr class="odd"> | ||
294 | <td>nsievebits</td> | ||
295 | <td class="speedup">2.90 → 5.05</td> | ||
296 | <td class="bar"><img src="img/bluebar.png" width="131" height="12" alt="================="><img src="img/magentabar.png" width="96" height="12" alt="#############"></td> | ||
297 | </tr> | ||
298 | <tr class="even"> | ||
299 | <td>pidigits</td> | ||
300 | <td class="speedup">3.58 → 4.94</td> | ||
301 | <td class="bar"><img src="img/bluebar.png" width="161" height="12" alt="====================="><img src="img/magentabar.png" width="61" height="12" alt="#########"></td> | ||
302 | </tr> | ||
303 | <tr class="odd"> | ||
304 | <td>nbody</td> | ||
305 | <td class="speedup">4.16 → 4.63</td> | ||
306 | <td class="bar"><img src="img/bluebar.png" width="187" height="12" alt="========================="><img src="img/magentabar.png" width="21" height="12" alt="###"></td> | ||
307 | </tr> | ||
308 | <tr class="even"> | ||
309 | <td>cheapconcr</td> | ||
310 | <td class="speedup">1.46 → 4.46</td> | ||
311 | <td class="bar"><img src="img/bluebar.png" width="66" height="12" alt="========="><img src="img/magentabar.png" width="135" height="12" alt="##################"></td> | ||
312 | </tr> | ||
313 | <tr class="odd"> | ||
314 | <td>partialsums</td> | ||
315 | <td class="speedup">1.71 → 3.73</td> | ||
316 | <td class="bar"><img src="img/bluebar.png" width="77" height="12" alt="=========="><img src="img/magentabar.png" width="91" height="12" alt="############"></td> | ||
317 | </tr> | ||
318 | <tr class="even"> | ||
319 | <td>fasta</td> | ||
320 | <td class="speedup">2.37 → 2.68</td> | ||
321 | <td class="bar"><img src="img/bluebar.png" width="107" height="12" alt="=============="><img src="img/magentabar.png" width="14" height="12" alt="##"></td> | ||
322 | </tr> | ||
323 | <tr class="odd"> | ||
324 | <td>cheapconcw</td> | ||
325 | <td class="speedup">1.27 → 2.52</td> | ||
326 | <td class="bar"><img src="img/bluebar.png" width="57" height="12" alt="========"><img src="img/magentabar.png" width="56" height="12" alt="#######"></td> | ||
327 | </tr> | ||
328 | <tr class="even"> | ||
329 | <td>revcomp</td> | ||
330 | <td class="speedup">1.45 → 1.92</td> | ||
331 | <td class="bar"><img src="img/bluebar.png" width="65" height="12" alt="========="><img src="img/magentabar.png" width="21" height="12" alt="###"></td> | ||
332 | </tr> | ||
333 | <tr class="odd"> | ||
334 | <td>knucleotide</td> | ||
335 | <td class="speedup">1.32 → 1.59</td> | ||
336 | <td class="bar"><img src="img/bluebar.png" width="59" height="12" alt="========"><img src="img/magentabar.png" width="13" height="12" alt="##"></td> | ||
337 | </tr> | ||
338 | </table> | ||
339 | </div> | ||
340 | <p> | ||
341 | All other benchmarks show only minor performance differences. | ||
342 | </p> | ||
343 | |||
344 | <h2 id="summary">Summary</h2> | ||
345 | <p> | ||
346 | These results should give you an idea about what speedup | ||
347 | you can expect depending on the nature of your Lua code: | ||
348 | </p> | ||
349 | <ul> | ||
350 | <li> | ||
351 | LuaJIT is really good at (floating-point) math and loops | ||
352 | (mandelbrot, pidigits, spectralnorm, partialsums). | ||
353 | </li> | ||
354 | <li> | ||
355 | Function calls (recursive), vararg calls, table lookups (nbody), | ||
356 | table iteration and coroutine switching (chameneos, cheapconc) | ||
357 | are a lot faster than with plain Lua. | ||
358 | </li> | ||
359 | <li> | ||
360 | It's still pretty good for indexed table access (fannkuch, nsieve) | ||
361 | and string processing (fasta, revcomp, knucleotide). | ||
362 | But there is room for improvement in a future version. | ||
363 | </li> | ||
364 | <li> | ||
365 | If your application spends most of the time in C code | ||
366 | you won't see much of a difference (regexdna, sumfile). | ||
367 | Ok, so write more code in pure Lua. :-) | ||
368 | </li> | ||
369 | <li> | ||
370 | The real speedup may be shadowed by other dominant factors in a benchmark: | ||
371 | <ul> | ||
372 | <li>Common parts of the Lua core: e.g. memory allocation | ||
373 | and GC (binarytrees).</li> | ||
374 | <li>Language characteristics: e.g. lack of bit operations (nsievebits).</li> | ||
375 | <li>System characteristics: e.g. CPU cache size and memory speed (nsieve).</li> | ||
376 | </ul> | ||
377 | </li> | ||
378 | </ul> | ||
379 | <p> | ||
380 | The best idea is of course to benchmark your <em>own</em> applications. | ||
381 | Please report any interesting results you may find. Thank you! | ||
382 | </p> | ||
383 | <br class="flush"> | ||
384 | </div> | ||
385 | <div id="foot"> | ||
386 | <hr class="hide"> | ||
387 | Copyright © 2005-2011 Mike Pall | ||
388 | <span class="noprint"> | ||
389 | · | ||
390 | <a href="contact.html">Contact</a> | ||
391 | </span> | ||
392 | </div> | ||
393 | </body> | ||
394 | </html> | ||
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/luajit_run.html b/libraries/LuaJIT-1.1.7/jitdoc/luajit_run.html new file mode 100644 index 0000000..bc9105b --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/luajit_run.html | |||
@@ -0,0 +1,159 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Running LuaJIT</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Running LuaJIT</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="index.html">Index</a> | ||
22 | </li><li> | ||
23 | <a href="luajit.html">LuaJIT</a> | ||
24 | <ul><li> | ||
25 | <a href="luajit_features.html">Features</a> | ||
26 | </li><li> | ||
27 | <a href="luajit_install.html">Installation</a> | ||
28 | </li><li> | ||
29 | <a class="current" href="luajit_run.html">Running</a> | ||
30 | </li><li> | ||
31 | <a href="luajit_api.html">API Extensions</a> | ||
32 | </li><li> | ||
33 | <a href="luajit_intro.html">Introduction</a> | ||
34 | </li><li> | ||
35 | <a href="luajit_performance.html">Performance</a> | ||
36 | </li><li> | ||
37 | <a href="luajit_debug.html">Debugging</a> | ||
38 | </li><li> | ||
39 | <a href="luajit_changes.html">Changes</a> | ||
40 | </li></ul> | ||
41 | </li><li> | ||
42 | <a href="coco.html">Coco</a> | ||
43 | <ul><li> | ||
44 | <a href="coco_portability.html">Portability</a> | ||
45 | </li><li> | ||
46 | <a href="coco_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="coco_changes.html">Changes</a> | ||
49 | </li></ul> | ||
50 | </li><li> | ||
51 | <a href="dynasm.html">DynASM</a> | ||
52 | <ul><li> | ||
53 | <a href="dynasm_features.html">Features</a> | ||
54 | </li><li> | ||
55 | <a href="dynasm_examples.html">Examples</a> | ||
56 | </li></ul> | ||
57 | </li><li> | ||
58 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
59 | </li></ul> | ||
60 | </div> | ||
61 | <div id="main"> | ||
62 | <p> | ||
63 | LuaJIT has only a single stand-alone executable, called <tt>luajit</tt>. | ||
64 | It can be used to run simple Lua statements or whole Lua applications | ||
65 | from the command line. It has an interactive mode, too. | ||
66 | </p> | ||
67 | <p> | ||
68 | <em>Note: The optimizer is not activated by default because it resides | ||
69 | in an external module | ||
70 | (see <a href="luajit_install.html">Installing LuaJIT</a>). | ||
71 | It's recommended to always use the optimizer, i.e.:</em> <tt>luajit -O</tt> | ||
72 | </p> | ||
73 | |||
74 | <h2 id="options">Command Line Options</h2> | ||
75 | <p> | ||
76 | The <tt>luajit</tt> stand-alone executable is just a slightly modified | ||
77 | version of the regular <tt>lua</tt> stand-alone executable. | ||
78 | It supports the same basic options, too. Please have a look at the | ||
79 | <a href="../doc/lua.html">Manual Page</a> | ||
80 | for the regular <tt>lua</tt> stand-alone executable. | ||
81 | </p> | ||
82 | <p> | ||
83 | Two additional options control LuaJIT behaviour: | ||
84 | </p> | ||
85 | |||
86 | <h3 id="opt_j"><tt>-j cmd[=value]</tt></h3> | ||
87 | <p> | ||
88 | This option performs a LuaJIT control command. LuaJIT has a small | ||
89 | but extensible set of control commands. It's easy to add your own. | ||
90 | </p> | ||
91 | <p> | ||
92 | The command is first searched for in the <tt>jit.*</tt> library. | ||
93 | If no matching function is found, a module named <tt>jit.<cmd></tt> | ||
94 | is loaded. The module table must provide a <tt>start()</tt> function. | ||
95 | </p> | ||
96 | <p> | ||
97 | For the <tt>-j cmd</tt> form the function is called without an argument. | ||
98 | Otherwise the <tt>value</tt> is passed as the first argument (a string). | ||
99 | </p> | ||
100 | <p> | ||
101 | Here are the built-in LuaJIT control commands: | ||
102 | </p> | ||
103 | <ul> | ||
104 | <li id="j_on"><tt>-j on</tt> — Turns the JIT engine on (default).</li> | ||
105 | <li id="j_off"><tt>-j off</tt> — Turns the JIT engine off.</li> | ||
106 | <li id="j_debug"><tt>-j debug[=level]</tt> — Set debug level. See | ||
107 | <a href="luajit_api.html#jit_debug">jit.debug()</a>.</li> | ||
108 | </ul> | ||
109 | <p> | ||
110 | The following control commands are loaded from add-on modules: | ||
111 | </p> | ||
112 | <ul> | ||
113 | <li id="j_trace"><tt>-j trace[=file]</tt> — Trace the progress of the JIT compiler.</li> | ||
114 | <li id="j_dumphints"><tt>-j dumphints[=file]</tt> — Dump bytecode + hints before compilation.</li> | ||
115 | <li id="j_dump"><tt>-j dump[=file]</tt> — Dump machine code after compilation.</li> | ||
116 | </ul> | ||
117 | |||
118 | <!-- | ||
119 | <h3 id="opt_O"><tt>-O[level|ext]</tt></h3> | ||
120 | --> | ||
121 | <h3 id="opt_O"><tt>-O[level]</tt></h3> | ||
122 | <p> | ||
123 | This option loads and runs the optimizer module <tt>jit.opt</tt>. | ||
124 | The optimizer generates hints for the compiler backend to improve | ||
125 | the performance of the compiled code. The optimizer slows down | ||
126 | compilation slightly, but the end result should make up for it | ||
127 | in almost every case. | ||
128 | </p> | ||
129 | <p> | ||
130 | The <tt>-O</tt> form sets the default optimizer level, which is | ||
131 | currently <tt>2</tt> (this may change in future versions | ||
132 | of LuaJIT). | ||
133 | </p> | ||
134 | <p> | ||
135 | The <tt>-Olevel</tt> form explicitly sets the optimizer level: | ||
136 | </p> | ||
137 | <ul> | ||
138 | <li><tt>-O0</tt> — disable the optimizer but leave it attached.</li> | ||
139 | <li><tt>-O1</tt> — perform standard optimizations (like hints for table lookups).</li> | ||
140 | <li><tt>-O2</tt> — like <tt>-O1</tt> but also loads <tt>jit.opt_inline</tt> to enable result hints and inlining for standard library functions.</li> | ||
141 | </ul> | ||
142 | <!-- | ||
143 | <p> | ||
144 | The <tt>-Oext</tt> form loads optimizer extension modules | ||
145 | from <tt>jit.opt_<ext></tt>. | ||
146 | </p> | ||
147 | --> | ||
148 | <br class="flush"> | ||
149 | </div> | ||
150 | <div id="foot"> | ||
151 | <hr class="hide"> | ||
152 | Copyright © 2005-2011 Mike Pall | ||
153 | <span class="noprint"> | ||
154 | · | ||
155 | <a href="contact.html">Contact</a> | ||
156 | </span> | ||
157 | </div> | ||
158 | </body> | ||
159 | </html> | ||