refactor(kernel): move max_sharing to library

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
refactor(kernel): move shallow copy function to library

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>