Regis wrote:
Regis Xu (JIRA) wrote:
[ https://issues.apache.org/jira/browse/HARMONY-6257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu updated HARMONY-6257:
------------------------------

    Attachment: HARMONY-6257.diff

[classlib][luni] - Optimize OSMemory.get/setByteArray
-----------------------------------------------------

                Key: HARMONY-6257
                URL: https://issues.apache.org/jira/browse/HARMONY-6257
            Project: Harmony
         Issue Type: Improvement
         Components: Classlib
   Affects Versions: 5.0M10
           Reporter: Regis Xu
        Attachments: HARMONY-6257.diff


in getByteArray, use SetByteArrayRegion to avoid memory copy from java to native in setByteArray, Get/ReleasePrimitiveArrayCritical instead of GetByteArrayElements/ReleaseByteArrayElements to avoid memory copy.


I just found in OSMemory.c, get/setByteArray do some unnecessary memory copies between Java and native.

In getByteArray, GetByteArrayElements copy data from java to native, and then ReleaseByteArrayElements do the reverse, I think using SetByteArrayRegion is enough.

In setByteArray, I found JNI calls GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical could get a pointer to the primitive array without any copy, but seems they has some side effects (on GC?), I don't have much confidence that they can apply here. I hope some one can give some advices about this patch. Thanks.


The patch passed all luni and nio tests, if no one objected, I'd like to commit 
it.

--
Best Regards,
Regis.

Reply via email to