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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Dmitr
Prole
Posts: 5
Joined: Sat May 02, 2015 3:33 pm

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

Post 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.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

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

Post 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.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

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

Post 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.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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
Dmitr
Prole
Posts: 5
Joined: Sat May 02, 2015 3:33 pm

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

Post 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.
Dmitr
Prole
Posts: 5
Joined: Sat May 02, 2015 3:33 pm

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

Post 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 :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 146 guests