Merge "Revert "Revert "Redesign implementation of RegisterNativeAllocation."""