Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
LuaJIT patch — Gideros Forum

LuaJIT patch

SinisterSoftSinisterSoft Maintainer
edited April 2015 in General questions
If you use the lua jit plugin then your code will execute much faster. The problem is that it's exported as source code if you use the normal plugin.

I've written a patch that ouputs LuaJIT bytecode.

I've tested it and it seems to work fine on my latest project.

Just copy the files in the zip folder to your Gideros folder, it will overwrite some files - don't panic :) .

Then create a new project and it will use luajit bytecode rather than lua bytecode.

If you have an existing project then you need to update your libs (see the libs\android folder in the zip) to luaJIT versions.

http://www.sinistersoft.com/downloads/luajit_patch.zip

Likes: pie, hgy29, keszegh

Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
+1 -1 (+3 / -0 )Share on Facebook
«1

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited April 2015
    I've updated this file to also update the template folder. Please redownload if you already have it.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • antixantix Member
    Looks really cool SinisterSoft, I haven;t looked at the videos though, facebook doesn't work on my pc heheh. I remember being a lot younger and pumping a lot of 20 cent prices into Gauntlet! Cool stuff.

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks. :)

    Here is a Youtube video of the Dungeons game multiplayer test on a mobile phone...


    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • antixantix Member
    edited April 2015
    @SinisterSoft - strange, I don't see any video or link to any youtube video. I guess my pc is a bit too locked down :)

    It shows on my tablet but since its android it doesn't do I flash player LOL. I will watch it on the dining room PC in the morning.

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    @SinisterSoft, I tried building a jit gideros player for direct wifi testing after installing your patch, but sooner or later I get these errors running it from eclipse and wifi testing my projects:

    @ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x51adec90
    A/libc(10281): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)

    I am using gideros 2014.10
    I tried the 2 main projects I am working on:
    the biggest one doesn't even load (the player crashes instantly)
    the other one runs until I reload a scene, then the player crashes.


    If I export and compile a debug apk of the biggest project, it seems to run fine (faster than "base" luajit on this one ) I still have to test it thoroughly, maybe it is still going to crash later (hope not... %%- )

    Didn't try compiling a test apk for the other one yet.

    This is what I did to build jit gideros player:
    export blank project
    remove assets folder
    overwrite libs directory with libs from the patch zip inside Android Template
    import in eclipse
    run
    -------------------------

    Any suggestion about those errors? :) Thank you
  • antixantix Member
    Not being to serial or anything but my favourite hex string of alltime would have to be $DEADBEEF, it sure beats b$DEADBAAD handsdown! :D
    +1 -1 (+3 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited April 2015
    I've tested the LuaJIT libs in the wild for about a year, no crashes (on both arm versions and x86).

    It might be something in your program that is unrelated but is showing up because of the way LuaJIT works. EG if somehow memory is getting corrupted or is leaking then the interpreter might work slightly differently than the JIT compiler.

    You can turn off the JIT compiler by putting this at the start of your code:

    jit.off()

    In interpreter mode it still runs faster than standard Lua.

    Do you include any other libs that are not in the standard Gideros build?

    I'm using Gideros Update 2015.04.18 btw.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    @SinisterSoft no luck yet :(

    jit.off() won't help and updating gideros neither (got the same error).

    BUT, if I compile my projects as standalone debug apk I don't get the errors.. I have to test those carefully to be sure, but no problem so far, with a quick test of both.

    The small project is running a bit smoother than without jit, the bigger one is keeping up pace with precompiled lua (as said before, faster than with "base" luajit)

    I don't include external libs, just lua libs (like giderosCodingEasy, tntparticle.. ).

    The thing is: Gideros without ondevice wifi testing is a bit 3:-O
    I still can test on desktop, but It's not the same thing to check game performance.

    I don't think to have memory leaks, and if I had some, I believe I should have had at least the same errors and FC in the compiled apks (but nothing crashed so far..)



    thank you :)




  • ar2rsawseenar2rsawseen Maintainer
    @pie you can also create Gideros player from your android project and test on it as a player

    http://docs.giderosmobile.com/deployment.html

    check device player with plugins

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • I have iab, ads (chartboost and applovin), flurry, controller and possibly a couple of others, tested it on a variety of different devices (both arms and x86 Android) running a varied set of games - always a speed increase, no crashes.

    I test on Android with a player made using the method @ar2rsawseen described.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    @ar2sawseen thanks for the link, that's what I was doing to build the player (but I was relaying on my mind and was deleting both assets folders :) ) :
    however, still no luck.. :(

    I just include luajit from @SinisterSoft as an external plugin, no other tampering with exported project.
    If I send my source through wifi I get the deadbaad error I posted before, if I compile as debug apk the entire project runs fine. Maybe it has to do with incomplete loading of resources? I am guessing.. Can you think of any way to narrow down my bug search?

    I can "workaround" this, using non jitted gideros to make my tests and development, and then exporting the project with jitted Gideros for publishing.. still it's a bit of a pain, mostly because if luajit would ever generate some bug, I would know it only after compiling with eclipse and testing it on device.

    Another chance is that I am doing something wrong while building the jitplayer, could please someone give me a "working" jitted one to make a try?

    Thank you very much! :)
  • @pie Can you try this on your device:

    https://play.google.com/store/apps/details?id=com.sinistersoft.savethemartians

    It uses the same luajit lib and is a production apk (the same as a player but with the assets folder filled in with stuff).

    Please let me know if it crashes on your phone.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    Thank you @SinisterSoft:

    Save the martians works perfectly on my device, as well as my jitted apk apps do, while I have the same errors with your jitplayer. :(

    At least I am sure that it's something in my project, but I don't have a clue to backtrace it - and still my question remains:
    why there is no error if I export my project and compile it with eclipse - even if jit is enabled - but wifi testing on the "same player with empty assets" rise the deadbaad?
    :-?
  • Do the gideros demos all work?
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    edited April 2015
    I remember I found an error in Print a while back it seems to mess up the stack sometimes. I got it to go wrong when doing calculations in it eg print(x+3).

    I don't know if it was fixed. But if it wasn't then it would make jit go wrong.

    Try commenting out your print() messages - see if it goes wrong then.

    Likes: pie

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    @SinisterSoft great idea! :-bd redefining print() as
    function print() end
    did the trick! :)
    So I guess there still is some issue in print function - which unfortunately I use a lot for debugging purposes.. at least is something to start from :)

    Thank you very much!

  • @Sinistersoft,
    with your player my android dialogs are transparent.
    see:
    https://github.com/gideros/gideros/issues/56#issuecomment-96418185

    can you tell us what is the targetsdk for your compiled apk?
  • SinisterSoftSinisterSoft Maintainer
    edited April 2015
    @pie I suppose that because jit is compiled then the problem is much more 'fatal' than with the interpreter. I noticed it ages ago as simple corruption and reported it to Atilim, it must have been missed in the many bug fixes since.

    I've added it to the github list of issues...

    @keszegh api 19 is the target (from what I remember - but it might have been higher - it was whatever is output default).

    Likes: pie

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited April 2015
    @SinisterSoft, i set the target to 19 for my (nonjit) android player and the dialogs now appear normal, so perhaps that's the case with your jitted apk too, contrary to what you remember. at least otherwise i don't know what is causing this bug in your player. although the output default is 19 in an exported gideros project.
  • I must have targetted it at 22? Odd.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • I deleted it. :(

    I always use custom players.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • in fact i just noticed that you also shared with us the files you used to make that apk, there its 19 in the manifest file. so who knows what happened, let's hope that the transparent dialog error won't bother us anymore (you can check in your custom players using luajit).
  • I have a quit dialog appear in my games if the back is pressed out of the main menu - not transparent though...
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • SinisterSoftSinisterSoft Maintainer
    @pie the problem with Print crashing was spotted in the Gideros sourcecode by @hgy29 and he has fixed it for the next version. :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • hgy29hgy29 Maintainer
    @SinisterSoft, @pie, hopefully the problem I fixed was the cause of your issue...
  • SinisterSoftSinisterSoft Maintainer
    I think it will be. :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    @hgy29 @SinisterSoft Thank you :)
    I can't wait to try the next release with all these bug fixes
    =D>
Sign In or Register to comment.