Page 1 of 1

Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 3:46 pm
by Dmitr
Hello! First I want to thank all involved in making love2d and all those who are helping people here on the forums. Also, please excuse my English.

My question is is it possible to use luajit command-line parameters with love, like -jv and -jdump to see where my code is falling out of compiler, and -jp for profiler when (and if) luajit 2.1 will be implemented in love? I tried the obvious, adding them (-jv and -jdump) as switches to love.exe, that did nothing.

If not possible, isn't it worth considering to include in love?

I am really bad at this stuff, so I gave up with existing profilers, but I want to see if I could handle these built-in luajit thingies.

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 4:48 pm
by s-ol
I think you can require("love") from other Lua environments, so you could start luajit with -jv and give that a go.

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 7:40 pm
by I~=Spam
S0lll0s wrote:I think you can require("love") from other Lua environments, so you could start luajit with -jv and give that a go.
Ummm... no you can't. LOVE isn't not a lua library. The difference is that LOVE initializes lua internally while a library is passed an already existing lua state.
Dmitr wrote:Hello! First I want to thank all involved in making love2d and all those who are helping people here on the forums. Also, please excuse my English.

My question is is it possible to use luajit command-line parameters with love, like -jv and -jdump to see where my code is falling out of compiler, and -jp for profiler when (and if) luajit 2.1 will be implemented in love? I tried the obvious, adding them (-jv and -jdump) as switches to love.exe, that did nothing.

If not possible, isn't it worth considering to include in love?

I am really bad at this stuff, so I gave up with existing profilers, but I want to see if I could handle these built-in luajit thingies.
I suggest that you modify and compile LOVE yourself so that it will do this.

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 7:43 pm
by Nixola
I~=Spam wrote:Ummm... no you can't. LOVE isn't not a lua library. The difference is that LOVE initializes lua internally while a library is passed an already existing lua state.
Yes, you can. Try getting a terminal, navigating to LÖVE's folder, running LuaJIT and requiring "love" and see what happens.

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 8:12 pm
by slime
I~=Spam wrote:
S0lll0s wrote:I think you can require("love") from other Lua environments, so you could start luajit with -jv and give that a go.
Ummm... no you can't. LOVE isn't not a lua library. The difference is that LOVE initializes lua internally while a library is passed an already existing lua state.
You can, actually!

I believe the correct way to do it this way would be something like: luajit -jv init.lua

Where init.lua contains something like this (untested):

Code: Select all

table.insert(arg, 1, "C:/path/to/mygame")

love = require("love")

local bootfunc = require("love.boot")
return bootfunc()
I~=Spam wrote:I suggest that you modify and compile LOVE yourself so that it will do this.
Even if you don't use liblove, you can still do it with regular LÖVE without recompiling.

You'll have to get the lua files that the LuaJIT 2.0.3 standalone interpreter installs (v.lua, vmdef.lua, dump.lua, etc.) and put them in a place that require will look in, then require one of them (e.g. require("v") to get -jv's functionality.) The lua files have extensive documentation as comments at the start of the file.

For the LuaJIT 2.1 profiler, you can use it directly in LÖVE without doing all that (again via require), as long as LuaJIT 2.1's lua51.dll (rather than LuaJIT 2.0.3's lua51.dll) is next to love.exe.
Documentation describing how to use the LuaJIT 2.1 profiler is here: http://repo.or.cz/w/luajit-2.0.git/blob ... filer.html

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sat May 02, 2015 10:42 pm
by Dmitr
S0lll0s, I~=Spam, Nixola, thanks for the suggestions, simply requiring didn't work, and recompiling is way over my head, but see below:
slime wrote:Even if you don't use liblove, you can still do it with regular LÖVE without recompiling
Wow, that worked from the first try, even with relative path in table.insert, as in (arg, 1, "mygame"). I tried without any switches and with -jv, will try -jp later. Thank you. Results from -jv are awful, but now at least I know. Also, -jv worked without require("v"), maybe that's how luapower windows binaries are compiled. (see edit)

Even without switches I now have a console that doesn't close when game exits, I wanted that since forever, and all I had to do is ask!

Edit: All this was about luajit init.lua method, I was so happy with it that I didn't realise that next ones were about regular love binary.

Re: Luajit command line options (-jv, -jdump, -jp)

Posted: Sun May 03, 2015 11:49 am
by Dmitr
Well, profiler works too. Results are strange and not helpful, but that's out of scope of the original question, technically it's working, I'm sure it's doing its best :)