What exactly is an Abstract Virtual Machine?

Hi. I'm preparing a little dev-talk about uninitialised memory and I want to introduce a concept of an Abstract Virtual Machine. I intuitively understand what it is, but have trouble with coming up with precise definition and examples of specific rules of Rust's AVM (and C, C++ ones). Googling didn't help, because most links point to implementing Virtual Machines. :grin: For the purpose of my talk I want to concentrate on "general" Abstract Virtual Machines and maybe give a couple of examples for C, C++, and Rust ones.

Could you help to systemise my intuition and point me to precise definiotions, please? Here's what I think I know so far:

  • abstract machines describe a model of some computation
  • abstract virtual machine is a concept introduces by languages and describe capabilities of machines they target
  • when we write programs in "higher level languages" we do not target specific CPU that will end up executing it, but this abstract virtual machine. It is the compiler's job to translate program from AVM to concrete CPU
  • AVM describes for example what memory accesses a program can perform, what atomic ordering mean, how number arithmetic works (both integer and floating), etc.
  • I've read somewhere that LLVM's IR describes AVM, but I'm not sure how to understand that
  • Undefined Behaviour as a concept only exists in relation to AVM. Program exhibits an UB when it violates some assumption made by AVM

I don't know about "abstract virtual machine" but there is such a thing as the "C++ abstract machine". The defined as :

The C++ abstract machine is a portable abstraction of your operating system, kernel and hardware.

and described as:

The C++ abstract machine is a portable abstraction of your operating system, kernel and hardware. The abstract machine is the intermediary between your
C++ program and the system that it is run on.

C++ programs describe operations that are performed on the abstract machine.

C++ implementations define the characteristics of the abstract machine and translate operations on the abstract machine into operations on the system.

All of which I get from here: https://corecppil.github.io/CoreCpp2019/Presentations/Bryce_C++_Execution_Model.pdf which has a lot more detail.

I get the impression one would have to read and fully understand the C++ standard to get a precise idea of the C++ abstract machine.

Presumably other languages have similar notions although they may not be documented so well. I hear that Rust still does not have a formal spec.

1 Like