perf(android): enable JavaScript Int32Array to be used when calling a Java method#13465
perf(android): enable JavaScript Int32Array to be used when calling a Java method#13465DzzD wants to merge 18 commits intotidev:mainfrom
Conversation
fix: prevent crash when calling Java method with an Int32Array as parameter Also auto detect Int32Array used within HashTable, KrollDict, etc...
…anium_mobile into perf-android-Int32Array
|
I set it to draft, as I think it is probably better to make a full package of optimisation, including at least Float32Array. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays |
fix: prevent crash when calling Java method with an Int32Array as parameter Also auto detect Int32Array used within HashTable, KrollDict, etc...
2ecc0d5 to
ae10c7d
Compare
|
The way i have implemented this will change the jsIntArrayToJavaIntArray signature from This is a method call embeded in module while compiled. So this will make module compiled with new SDK not compatible with Application build with older SDK. because new module will try to call Do you think it is a problem ? If it is, we could create a new java type Int32Array/Float32Array that will be requiered to know/force the use of real native int[]/float[]. So a module class But if a user dont knwow about the new types and use int[] as parameter of a java module method it will still use the old way and be as slow than before. IMO : I would prefer to use the first solution in[] => Int32Array, rather then a workaround even if it break a little compatibilities with old/new SDK modules. What is your opinions ? |
|
you can always set the As long as the otherway round works: old/existing module works with the new SDK. Otherwise: there is a waiting PR with some color changes. That is a breaking SDK change and modules have to recompiled for it in order to work. So there will be a SDK in the future where you have to rebuild modules |
…anium_mobile into perf-android-Int32Array
Originale discussion
JavaScript have special arrays "Int32Array" which are by the nature of there implementations a way faster than standard arrays.
Int32Array are stored in a single memory block and provide faster direct access.
This is the format that best matches native int[] arrays.
Actual version of Titanium SDK does not support their usage. Calling a Java method using Int32Array as a parameter will fail with
Invalid value, expected type Array.Int32Array arrays should be used when ever a native method require a native int array as they are stored in memory similary.
The performance gain by using Int32Array instead of Array is about 20 times faster.
This fix enable to call a Java module method with Int32Array parameters and will auto-detect Int32Array in other parameters like Object, Hasmap, etc...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays