Optimize copying data in to/out of native code