This is something the CHERI architecture[0] (an extension to ARM and RISC-V that implements a capability memory model) can allow this performantly with compiled code (without needing to context switch). This PhD dissertation from Cambridge[1] implements this for C/C++ under CheriBSD (their fork of FreeBSD that supports CHERI).
[0]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
[1]: https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-949.pdf