How to enable JIT support for android ?

271 views
Skip to first unread message

James Chen

unread,
Apr 9, 2013, 11:30:23 PM4/9/13
to Surith Thekkiam, cocos2d-...@googlegroups.com
Hi Surith,
As I know, the build.sh for android does generate library with JIT support. 
But in ScriptingCore.cpp, there are two lines which disable it.

    JS_SetOptions(this->cx_, JS_GetOptions(this->cx_) & ~JSOPTION_METHODJIT);
    JS_SetOptions(this->cx_, JS_GetOptions(this->cx_) & ~JSOPTION_METHODJIT_ALWAYS);

Do we only need to comment these two lines to make JSB games support JIT for Android?
Or any other ways to achieve that?  I think JIT will improve much performance, right? 

Best Regards
James

folecr

unread,
Apr 10, 2013, 8:12:03 PM4/10/13
to cocos2d-...@googlegroups.com
> Do we only need to comment these two lines to make JSB games support JIT for Android?

We also have to ensure that the build is using the correct flags. Mozilla changes the build flags need for JIT fairly often. I think the best thing would be to check a recent Mozilla build log and use the flags that Mozilla has tested with.

For example, you can see all the build status for Android here :
http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-release-android-armv6/1365539014/
http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-release-android/1365539014/

And you can look at the build logs here for all the build flags used to build :
http://ftp.mozilla.org/pub/mozilla.org/mobile/tinderbox-builds/mozilla-release-android/1365539014/mozilla-release-android-bm25-build1-build9.txt.gz

I think it would be great to test with JIT enabled to see the effects. However the current Spidermonkey itself requires a lot of testing and we are still finding bugs ... I would not enable JIT in the default build until we have completely tested it.


> I think JIT will improve much performance, right?

In theory, yes, it should increase performance of the JavaScript execution. It is worth trying it out. I think the overall game performance increase depends on the kind of game : whether it is using a lot of JavaScript logic, whether it is GPU dependent etc.

Please let me know if you are able to test the JIT.

Regards,
 Surith

James Chen

unread,
Apr 11, 2013, 1:49:59 AM4/11/13
to folecr, cocos2d-...@googlegroups.com
Thanks, Surith.
I'll try to find out the way of enabling JIT for android.

Best Regards
James

--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

folecr

unread,
May 21, 2013, 7:05:56 PM5/21/13
to cocos2d-...@googlegroups.com
James,

Do you have any updates on the SpiderMonkey JIT on Android?

Two issues to be tested :
1 - Does the JIT cause any bugs? (Ricardo mentioned that he has tested with JIT enabled on OSX and did not see any bugs.)
2 - Does the compilation process of the JIT add any performance overhead?

Please let me know. I can try enabling the Android JIT...

Thanks,
 Surith

Ricardo Quesada

unread,
May 21, 2013, 7:07:49 PM5/21/13
to folecr, cocos2d-...@googlegroups.com
Hi,
I noticed that ion is disabled on Android.
Is there any reason to have it disabled ? Thanks.

https://github.com/ricardoquesada/Spidermonkey/blob/v21/js/src/build-android/build.sh#L56

James Chen

unread,
May 21, 2013, 10:08:12 PM5/21/13
to folecr, cocos2d-...@googlegroups.com
Hi Surith,
Sorry, I didn't find a good way to enable JIT on android. Yep, that'll be great if you could help us to make it works. :) Thanks.
@Riq, yep, we disabled some compile options in build.sh of android:

--disable-ion \
--disable-jm \ 
--disable-tm

But I looked at the terminal when compiling, it did compile spidermonkey with JIT enabled. I don't know what's the meaning of these three opinions.

James

James Chen

unread,
May 21, 2013, 10:31:41 PM5/21/13
to folecr, cocos2d-...@googlegroups.com
I found that android build seems to be broken in the latest codes of Riq's spidermonkey repo.

Ricardo Quesada

unread,
May 22, 2013, 12:54:59 AM5/22/13
to James Chen, folecr, cocos2d-...@googlegroups.com
Hi James,
Could you be more specific regarding the Android compilation issues ? What error do you see ? How are  you compiling it ? thanks.

James Chen

unread,
May 22, 2013, 1:42:11 AM5/22/13
to Ricardo Quesada, folecr, cocos2d-...@googlegroups.com
Hi Riq,
You could reproduce the issue by:
cd Spidermonkey/js/src/build-android
./build.sh -r

It seems that the compilation options of spidermonkey for android have been changed.

James

Ricardo Quesada

unread,
May 22, 2013, 1:59:51 AM5/22/13
to James Chen, folecr, cocos2d-...@googlegroups.com
Hi James,

Thanks. 
I haven't changed the Android build code (and I only maintain the iOS and OS X builds). So if it doesnt build on Android I guess that SpiderMonkey 21 has new Android compile options. 
If you could fix the Android compile issues it would be great. Thanks. 

Sent from my iPad

James Chen

unread,
May 22, 2013, 2:37:51 AM5/22/13
to Ricardo Quesada, folecr, cocos2d-...@googlegroups.com
OK, I'll try to fix it.

James Chen

unread,
May 22, 2013, 6:23:26 AM5/22/13
to Ricardo Quesada, cocos2d-...@googlegroups.com
Hi Riq,

Spidermonkey android build was fixed at https://github.com/ricardoquesada/Spidermonkey/pull/18 , please review.

Also, I enabled JIT support for win32 and android. But I didn't test the performance.

jscompile tool in cocos2d-console also needs to be updated. PR is here: https://github.com/cocos2d/cocos2d-console/pull/2 , 
I added the source code of command line tool (jsbcc) too.

Cocos2d-x also uses spidermonkey v21 now.  Fixed at https://github.com/cocos2d/cocos2d-x/pull/2613 .

Regards
James

Ricardo Quesada

unread,
May 22, 2013, 2:55:36 PM5/22/13
to James Chen, cocos2d-...@googlegroups.com
Thanks James.
Most probably I am going to create a new project to host the source code of the console... I will move the source code of the compiler there. thanks.

Ricardo Quesada

unread,
May 22, 2013, 3:13:06 PM5/22/13
to James Chen, cocos2d-...@googlegroups.com
@james:

Instead of creating a new repo, I moved the sources to the /src directory:
https://github.com/cocos2d/cocos2d-console/tree/develop/src

We can create a new repo later if needed.


Also, I added the "lib" directory, since it was missing in your PR. Most probably because .gitignore contains the "lib" there. I removed "lib" from .gitignore.

Reply all
Reply to author
Forward
0 new messages