aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Pall <mike>2009-12-08 20:35:29 +0100
committerMike Pall <mike>2009-12-08 20:35:29 +0100
commit3f1f9e11f4f699ae94182d4cba158092f434a7f6 (patch)
tree88fbb674a21a1d554d4b1ee9d4ef2c5fed6a1d88 /lib
parent5287b9326479ea2b7dddd6f642673e58e5a7f354 (diff)
downloadluajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.tar.gz
luajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.tar.bz2
luajit-3f1f9e11f4f699ae94182d4cba158092f434a7f6.zip
Fast forward to sync public repo.
Compile math.sinh(), math.cosh(), math.tanh() and math.random(). Compile various io.*() functions. Drive the GC forward on string allocations in the parser. Improve KNUM fuse vs. load heuristics. Add abstract C call handling to IR.
Diffstat (limited to 'lib')
-rw-r--r--lib/bc.lua2
-rw-r--r--lib/dump.lua40
2 files changed, 34 insertions, 8 deletions
diff --git a/lib/bc.lua b/lib/bc.lua
index 532f2493..6296174e 100644
--- a/lib/bc.lua
+++ b/lib/bc.lua
@@ -30,7 +30,7 @@
30-- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello" 30-- print(bc.line(foo, 2)) --> 0002 KSTR 1 1 ; "hello"
31-- 31--
32-- local out = { 32-- local out = {
33-- -- Do something wich each line: 33-- -- Do something with each line:
34-- write = function(t, ...) io.write(...) end, 34-- write = function(t, ...) io.write(...) end,
35-- close = function(t) end, 35-- close = function(t) end,
36-- flush = function(t) end, 36-- flush = function(t) end,
diff --git a/lib/dump.lua b/lib/dump.lua
index 9fde87c1..021fc1c9 100644
--- a/lib/dump.lua
+++ b/lib/dump.lua
@@ -144,7 +144,7 @@ local colortype_ansi = {
144 [0] = "%s", 144 [0] = "%s",
145 "%s", 145 "%s",
146 "%s", 146 "%s",
147 "%s", 147 "\027[36m%s\027[m",
148 "\027[32m%s\027[m", 148 "\027[32m%s\027[m",
149 "%s", 149 "%s",
150 "\027[1m%s\027[m", 150 "\027[1m%s\027[m",
@@ -199,9 +199,9 @@ margin-right: 2em;
199span.irt_str { color: #00a000; } 199span.irt_str { color: #00a000; }
200span.irt_thr, span.irt_fun { color: #404040; font-weight: bold; } 200span.irt_thr, span.irt_fun { color: #404040; font-weight: bold; }
201span.irt_tab { color: #c00000; } 201span.irt_tab { color: #c00000; }
202span.irt_udt { color: #00c0c0; } 202span.irt_udt, span.irt_lud { color: #00c0c0; }
203span.irt_num { color: #0000c0; } 203span.irt_num { color: #4040c0; }
204span.irt_int { color: #c000c0; } 204span.irt_int, span.irt_i8, span.irt_u8, span.irt_i16, span.irt_u16 { color: #b040b0; }
205</style> 205</style>
206]] 206]]
207 207
@@ -210,7 +210,7 @@ local colorize, irtype
210-- Lookup table to convert some literals into names. 210-- Lookup table to convert some literals into names.
211local litname = { 211local litname = {
212 ["SLOAD "] = { [0] = "", "I", "R", "RI", "P", "PI", "PR", "PRI", }, 212 ["SLOAD "] = { [0] = "", "I", "R", "RI", "P", "PI", "PR", "PRI", },
213 ["XLOAD "] = { [0] = "", "unaligned", }, 213 ["XLOAD "] = { [0] = "", "R", "U", "RU", },
214 ["TOINT "] = { [0] = "check", "index", "", }, 214 ["TOINT "] = { [0] = "check", "index", "", },
215 ["FLOAD "] = vmdef.irfield, 215 ["FLOAD "] = vmdef.irfield,
216 ["FREF "] = vmdef.irfield, 216 ["FREF "] = vmdef.irfield,
@@ -313,6 +313,27 @@ local function ridsp_name(ridsp)
313 return "" 313 return ""
314end 314end
315 315
316-- Recursively gather CALL* args and dump them.
317local function dumpcallargs(tr, ins)
318 if ins < 0 then
319 out:write(formatk(tr, ins))
320 else
321 local m, ot, op1, op2 = traceir(tr, ins)
322 local oidx = 6*shr(ot, 8)
323 local op = sub(vmdef.irnames, oidx+1, oidx+6)
324 if op == "CARG " then
325 dumpcallargs(tr, op1)
326 if op2 < 0 then
327 out:write(" ", formatk(tr, op2))
328 else
329 out:write(" ", format("%04d", op2))
330 end
331 else
332 out:write(format("%04d", ins))
333 end
334 end
335end
336
316-- Dump IR and interleaved snapshots. 337-- Dump IR and interleaved snapshots.
317local function dump_ir(tr, dumpsnap, dumpreg) 338local function dump_ir(tr, dumpsnap, dumpreg)
318 local info = traceinfo(tr) 339 local info = traceinfo(tr)
@@ -348,7 +369,8 @@ local function dump_ir(tr, dumpsnap, dumpreg)
348 else 369 else
349 out:write(format("%04d ------ LOOP ------------\n", ins)) 370 out:write(format("%04d ------ LOOP ------------\n", ins))
350 end 371 end
351 elseif op ~= "NOP " and (dumpreg or op ~= "RENAME") then 372 elseif op ~= "NOP " and op ~= "CARG " and
373 (dumpreg or op ~= "RENAME") then
352 if dumpreg then 374 if dumpreg then
353 out:write(format("%04d %-5s ", ins, ridsp_name(ridsp))) 375 out:write(format("%04d %-5s ", ins, ridsp_name(ridsp)))
354 else 376 else
@@ -359,7 +381,11 @@ local function dump_ir(tr, dumpsnap, dumpreg)
359 band(ot, 128) == 0 and " " or "+", 381 band(ot, 128) == 0 and " " or "+",
360 irtype[t], op)) 382 irtype[t], op))
361 local m1 = band(m, 3) 383 local m1 = band(m, 3)
362 if m1 ~= 3 then -- op1 != IRMnone 384 if sub(op, 1, 4) == "CALL" then
385 out:write(format("%-10s (", vmdef.ircall[op2]))
386 if op1 ~= -1 then dumpcallargs(tr, op1) end
387 out:write(")")
388 elseif m1 ~= 3 then -- op1 != IRMnone
363 if op1 < 0 then 389 if op1 < 0 then
364 out:write(formatk(tr, op1)) 390 out:write(formatk(tr, op1))
365 else 391 else