The most elaborate deployed version of this idea is probably PyPy, an alternative Python implementation that works by giving a JIT-compiling partial evaluator a hint-annotated Python interpreter as the program, and the Python code to be executed as its input. Slightly abstruse overview here: https://doc.pypy.org/en/latest/architecture.html