core/frame: add helper functions for dealing with reference-counted buffer