[Truffle] Abstract the safepoint mechanism so other features can re-use it.