<figure><img src="image_1.png" /></figure>

HAL
open science

# High-performance language virtual machines: an analysis and challenges

Stéphane Ducasse, Guillermo Polito, Pablo Tesone, Gaël Thomas, Loïc Lagadec

<figure><img src="image_2.png" /></figure>

## To cite this version:

Stéphane Ducasse, Guillermo Polito, Pablo Tesone, Gaël Thomas, Loïc Lagadec. High-performance language virtual machines: an analysis and challenges. 2022. hal-03770053

HAL Id: hal-03770053

https://inria.hal.science/hal-03770053

Submitted on 6 Sep 2022

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
High-Performance Language
Virtual Machines:
an analysis and challenges

S. Ducasse G. Polito [RMOD/Evref - Inria] P. Tesone [Pharo consortium]

G. Thomas [Telecom SudParis]

L. Lagadec [ENSTA]
# Language VMs are Ubiquitous

* They are everywhere: browsers, mobile phones, drones, robots...

* Banks, servers, aircrafts

* Portability, self-optimisation and adaptation, high-level services (GC)

* Java, Javascript, Pharo, PHP, Python, Ruby, C#...

* Derivates: Typescript, Scala, web assembly
# Language Virtual Machines

## Modern Language Implementations

Managed Execution

<figure><img src="image_4.png" /></figure>

Runtime Binary Translation

<figure><img src="image_5.png" /></figure>

Managed Memory

<figure><img src="image_6.png" /></figure>

Hardware/System Interaction

<figure><img src="image_7.png" /></figure>
# Key Players

* Javascript: Safari (Apple), V8 (Google), SpiderMonkey (Mozilla)

* Java: Truffle, GraalVM (Oracle)

* .NET, C#, VB: (Microsoft)

<figure><img src="image_8.png" /></figure>

ORACLE

<figure><img src="image_9.png" /></figure>

<figure><img src="image_10.png" /></figure>

<figure><img src="image_11.png" /></figure>

Microsoft

<figure><img src="image_12.png" /></figure>
# VMs as Competitive Advantage

Large companies developed their OWN

* Hack: Facebook's PHP

* Ruby: Shopify

* GemTalk Systems

* Netflix

<figure><img src="image_13.png" /></figure>

<figure><img src="image_14.png" /></figure>

<figure><img src="image_15.png" /></figure>

* Many python, ruby are popping up

<figure><img src="image_16.png" /></figure>
# Virtual Machines

## Typical Architecture Overview

<figure><img src="image_17.png" /></figure>

VMs: **auto-adaptive**
systems
# Compiler Pipeline Example

source code - to - bytecode interpreter.

Example: arithmetics

<figure><img src="image_18.png" /></figure>
# A concrete example: Javascript core

<figure><img src="image_19.png" /></figure>

Multiple levels

Different representations

Engineering cost!
# Quid Complexity and Cost of VMs?

## Apple's Safari JavascriptCore[2021]

<figure><img src="image_20.png" /></figure>

https://webkit.org/blog/10308/speculation-in-javascriptcore/

https://ponyfoo.com/articles/an-introduction-to-speculative-optimization-in-v8
<figure><img src="image_21.png" /></figure>

# Managed Execution

## Remarkable Challenges

* Challenge 1: What are **optimal** organisations of multi-tier engines?

* Combining interpreters with **many levels** of optimising compilers

* Challenge 2: What is a **better/minimal runtime** support for developer **tooling**?

* Better debugging support

* Runtime (speed, energy...) profiling

* Benchmark automatic generation
<figure><img src="image_22.png" /></figure>

# Runtime Binary Translation
## Remarkable Challenges

VMs are **auto-adaptive** systems

* Challenge 3: How can runtime-compilers **better speculate** on application behaviour?

* Speculate **on** more than types

* Speculate **for** more than speed

* Challenge 4: How can we improve the efficiency of **cold code**?

* Better interpreter optimisations

* Low overhead binary translators
# Managed Memory
## Remarkable Challenges

<figure><img src="image_23.png" /></figure>

### Challenge 5: How can managed memory adapt to memory consumption patterns?

* Scalability to multi-TB heaps

* Automatically memory re-organisation

* Reduce pauses

* Support for modern hardware (e.g., disaggregated memory, non-volatile memories)

* encrypted memory (arm trustzone/intel sgx), compressed memory

* OS and System VM Interations
<figure><img src="image_24.png" /></figure>

# Hardware/System Interaction

## Remarkable Challenges

### Challenge 6: How can modern VMs exploit hardware-software co-design?

* Automatic deport computation to dedicated hardware

* GPU

* FPGA

* Extensible ISAs (e.g., RISC-V)
# Cross-Cutting Challenges

(And Contradictory Challenges!)

<figure><img src="image_25.png" /></figure>

<figure><img src="image_26.png" /></figure>

<figure><img src="image_27.png" /></figure>

<figure><img src="image_28.png" /></figure>

<figure><img src="image_29.png" /></figure>

Energy Consumption

<figure><img src="image_30.png" /></figure>

Execution Speed

<figure><img src="image_31.png" /></figure>

Security

<figure><img src="image_32.png" /></figure>

Correctness

<figure><img src="image_33.png" /></figure>

Modularity
# Cross-Cutting Challenges

## Selected Challenges

* **Security threats** of multi-tier execution engines

<figure><img src="image_34.png" /></figure>

<figure><img src="image_35.png" /></figure>

* **Speculative runtime compilation for frugal systems**

<figure><img src="image_36.png" /></figure>

<figure><img src="image_37.png" /></figure>

<figure><img src="image_38.png" /></figure>

* **Profile-guided detection of application parallelisation opportunities**

<figure><img src="image_39.png" /></figure>

<figure><img src="image_40.png" /></figure>

* **Securing VMs through dedicated hardware**

<figure><img src="image_41.png" /></figure>

<figure><img src="image_42.png" /></figure>

* **Minimising energy impact of garbage collection algorithms**

<figure><img src="image_43.png" /></figure>

<figure><img src="image_44.png" /></figure>
# Selected Software Engineering Challenges

## €

* **Automatic** detection of performance regressions

<figure><img src="image_45.png" /></figure>

* **Automatic** validation of multi-tier execution engines

<figure><img src="image_46.png" /></figure>

* **Controling** the **construction** COST of efficient JIT compilers

<figure><img src="image_47.png" /></figure>
# AlaMVic: a generative approach

<figure><img src="image_48.png" /></figure>

* Compiler generation

* Exchangeable components

* Optimization heuristics

* Open exploratory platform
# Early RMOD achievements

## Dev side of things

* JIT for Apple M1, Windows, Raspberry ARM 64bits in production

* Helping ENSTA Bretagne to develop a RISC-V JIT

* Streamlining transpilation/compilation chain

* Taking advantage of VM tests [MPLR, MoreVM paper]

* Some productivity enhancer tools (Unicorn simulator, assembly browser, interactive CFG navigation,...)
# Early RMOD achievements

## Research side

* RQ: **static** code reordering: is it worth ? (alternative to Pettis-Hansen BB reordering)

<figure><img src="image_49.png" /></figure>

* Reducing manual code (~100 bytecodes, ~300 primitives)

* RQ: Are interpreted and compiled code equivalent? Concolic + differential testing

* RQ: Can we generate JIT compilers? Abstract interpreter for compiled code generation (underway)
# Benagil
Research side

* J-NVM: Efficient integration of a persistent memory in a Java Virtual Machine

* PrivaDSL: Use of Intel SGX in a Java virtual machine

* Study of a Java virtual machine for disaggregated memory

* A shell language and runtime for serverless applications
# Early ENSTA achievements

## Dev side of things

* RISC-V JIT for a production level VM - Pharo consortium

* RISC-V board

## Research side

* Study language VM level attacks

* Starting to propose protections against language VM-level attacks
# Language VMs are strategical assets

* Controlling the execution engine, controls the world

* French research should not miss the opportunity

* Independence from the will of big companies is crucial for research

* Rare french teams on the topic should be supported!