[EXPERIMENTAL] Dalvik with JIT enabled for CyanogenMod 5.0.5.x

Search This thread

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
Just rebuilt CM from the source, with JIT enabled (and fixed the code to compile)

* With "plain" CyanogenMod 5.0.x ROM it appears to be at least partly functional (people reporting Linpack jump from 7 to 17 Mflops) but I expect instabilities so JIT is definitely still far from the "prime time"

* It appears that HTC Desire ROM and JIT do not mix well. You will get reboots as soon as you try to unlock via. slider. I am trying to figure out what is causing this

For people that want to experiment - I am providing the precompiled Dalvik libraries with JIT enabled. DO NOT TRY THIS IF YOU ARE INEXPERIENCED!!! I assume no liabilities for any problems. Please read the readme first!

Code:
JIT Support for Nexus One CyanogenMod 5.0.x / Kernel 2.6.33.1  (Eclair) 

By Ivan Dimkovic (psyq321)
--------------------------

NOTE:  JIT is totally unsupported and known to be NOT stable!!!  There is no guarantee your system will boot at all!!!  ALWAYS BACK UP YOUR SYSTEM WITH NANDROID FIRST!!!   This package is provided for TESTING PURPOSES ONLY.  Author assumes NO LIABILITY WHATSOEVER if you brick your phone!!!

1. What is this?

This package contains several Android system files that enable JIT ("Just in Time") feature in the Dalvik VM.  JIT is very unstable and it is not built-in the AOSP or Cyanogen's ROMs.  This package contains system files built with JIT feature ON and it could be useful for testing for people that do not wish to recompile the entire ROM

extra_tuning directory contains Dalvik JIT library compiled with WITH_JIT_TUNING option. This option presumably enables even more optimizations for the JIT, but it appears to be totally unstable (I get endless reboot cycle)

2. How to make JIT enabled?

Follow these steps:

   - BACK UP YOUR SYSTEM WITH NANDROID (IMPORTANT!!!)
   - Connect your phone to the PC

   - Copy the Dalvik files to the system directories:

     adb remount
     adb push libdvm.so /system/lib/libdvm.so
     adb push libnativehelper.so /system/lib/libnativehelper.so
     adb push dalvikvm /system/bin/dalvikvm

   - Go to the shell (e.g. via adb shell, or via ssh) and change the permissions:

     chmod 755 /system/bin/dalvikvm
     chmod 644 /system/lib/libdvm.so
     chmod 644 /system/lib/libnativehelper.so

   - Add this line at the end of your system's build.prop

     dalvik.vm.execution-mode=int:jit

   - Reboot into RECOVERY and wipe Dalvik cache!
   
   - Reboot

    
3. It does not work?  My system keeps rebooting / My system crashes randomly?

Unfortunately, this can happen and this is known issue with JIT.  This is the reason why it is not enabled.  You are free to look in the AOSP code and try to fix it by yourself, but I suggest to wait until original developers make it stable

Enjoy!
 

Attachments

  • cm5.0.5_jit_test.zip
    769.5 KB · Views: 455
Last edited:

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
I am not really sure, maybe HTC Sense components are much more intensive and force the JIT bugs to appear earlier.

Just tried everything (replaced libdvb.so, libnativehelper.so and dalvikvm - and cleaned up the dalvik cache) - and it is a no-go :(

If JIT is ON, SIM card is not accessed at all, I just get the lock screen, which triggers the system reboot if I slide it.

This is all on the HTC Desire a19 ROM... I guess JIT is a bit more stable on a stock ROM.
 

spyz88

Senior Member
Oct 28, 2008
428
33
I thought the last time JIT was in CyanogenMod was in cm-5.0 beta 3. I'm pretty sure it wont work on any ROM except that. I would use it but the multi-touch included in it is still the hacked together version.

I miss JIT ;/
 

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
JIT is just not compiled-in by default in CyanogenMod but it is definitely in the code.

You can still enable it manually, but you need to rebuild the ROM from the source.

If you wish to try it - put this line in the buildspec.mk:

Code:
WITH_JIT:=true

Then rebuild everything - and the Dalvik VM will have JIT features inside. Then you need to enable JIT in the build.prop (or by adb manually on runtime)
 

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
Doh...

Just fetched the latest source from Cyanogen's github...

Looks like CM+JIT compilation is broken now :( There are some asserts in the code (Jit.c, line 48 for example) that are referencing missing structure members (looks like they reorganized structure layouts and moved JIT-specific stuff to another one) so the JIT-enabled code won't compile.
 

Gimpeh

Senior Member
Feb 25, 2009
1,304
9
Springfield
Doh...

Just fetched the latest source from Cyanogen's github...

Looks like CM+JIT compilation is broken now :( There are some asserts in the code (Jit.c, line 48 for example) that are referencing missing structure members (looks like they reorganized structure layouts and moved JIT-specific stuff to another one) so the JIT-enabled code won't compile.

I saw a bunch of JIT related activity on GITHUB today from Cyan. Perhaps hes testing it again for a new experimental build.
 

bradsh1

Senior Member
Sep 16, 2009
286
71
This is one official upgrade I'm really looking forward to. Sadly, I bet it wont be released for another year.
 

serialtoon

Senior Member
May 25, 2006
929
118
I thought i was the only one that was interested in on JIT. Either that or Dalvik-Turbo :p
 

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
Looks like JIT breakage is coming from the AOSP itself.

What is going on is, in Jit.c (/dalvik/vm/interp/Jit.c) there are places that expect JIT stuff to be in the DvmGlobals structure - however, those elements are in the DvmJitGlobals structure.

For example, line 48 of Jit.c

Code:
        assert([b][u]gDvm.jitTableSize[/u][/b] &&
            !([b][u]gDvm.jitTableSize[/b][/u] & (gDvmJit.jitTableSize - 1))); // Power of 2?

gDvm (which is of DvmGlobals type) has no jitTableSize entry - it is part of gDvmJit

I'll try manually fixing these errors (there are few, and mostly confined to asserts fortunately) tonight but this smells like more things are broken.
 

hotweiss

Senior Member
Jun 17, 2009
1,534
29
Warsaw
I had JIT running on my Magic. It was 99% stable... I am actually hoping that Cyanogen fixes all of the bugs in the Java V8 script engine first. It made a big difference in the Browser.
 

Mi|enko

Senior Member
Jul 15, 2006
1,558
171
Doh...

Just fetched the latest source from Cyanogen's github...

Looks like CM+JIT compilation is broken now :( There are some asserts in the code (Jit.c, line 48 for example) that are referencing missing structure members (looks like they reorganized structure layouts and moved JIT-specific stuff to another one) so the JIT-enabled code won't compile.

IIRC, Cy removed Jit due to stability issues. I think there was a stability concern by just having the code in there, even if it wasn't enabled. You might want to dig through his thread a bit.
 

Ivan Dimkovic

Senior Member
Oct 13, 2006
170
0
Hmm

JIT is definitely still in CM's repository... and just by quickly looking at it, it looks exactly the same as in the current AOSP

But it is broken in both. I don't know when exactly it got broken - as the last CM snapshot I had on my Linux VM was from few weeks ago, and the JIT definitely compiled.

Perhaps the breakage is result of some AOSP checkin by Google.