Fuzion is a new language targeting safety-critical systems by building on few but powerful concepts and enabling static analysis of applications to verify their correctness. The Fuzion Intermediate Representation (FUIR) plays a key role in providing a basis for static analysis tools as well as inte...
Fuzion is a new language targeting safety-critical systems by building on few but powerful concepts and enabling static analysis of applications to verify their correctness. The Fuzion Intermediate Representation (FUIR) plays a key role in providing a basis for static analysis tools as well as interpreters and code generators that produce runnable programs.
FUIR has a number of aspects that are different from most other intermediate representations: Code is grouped into Fuzion features that are a common abstraction for functions, classes, types, etc. There are only 10 commands used in FUIR, calls to intrinsic features are used for operations not present as explicit commands. There is no support for loop or conditional jumps, recursion is used instead. The usual distinction between stack frames and heap instances does not exist in the FUIR.
This work-in-progress paper will give a quick overview of the Fuzion language and explain the aspects of the FUIR in more detail before presenting the impact it has on the tools processing the FUIR code.
Size: 773.88 KB
Language: en
Added: Oct 20, 2024
Slides: 33 pages
Slide Content
The Fuzion Intermediate Representation
An IR for static analysis for safety-critical systems
Fridtjof Siebert, Michael Lill
Tokiwa Software GmbH
VMIL’24, October 20, 2024, Pasadena, CA, USA
VMIL’24: The Fuzion Intermediate Representation2/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects
➡ Toolchain and Static Analysis
➡ The Fuzion IR
➡ Status
VMIL’24: The Fuzion Intermediate Representation3/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects ➡ Toolchain and Static Analysis ➡ The Fuzion IR ➡ Status
VMIL’24: The Fuzion Intermediate Representation4/33
Fuzion Intro
➡ One concept: a feature
➡ - generalization of class / method /
➡ - function / etc.
➡ - may be nested
➡ statically typed
➡ polymorphic: union types, parametric types, inheritance
➡ pure using effects
hello_world ! io.out =>
io.out.println "hello!"
hello_world
VMIL’24: The Fuzion Intermediate Representation5/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects ➡ Toolchain and Static Analysis ➡ The Fuzion IR ➡ Status
VMIL’24: The Fuzion Intermediate Representation6/33
Safety-Critical Aspects
➡ Formal Guidelines (DO178C, IEC61508, ISO26262, etc.)
➡ Rigorous Verification and Validation
➡ Determinism
- bounded worst-case execution time
- real-time GC or static memory management
- no probabilistic algorithms
➡ Fuzion: simple IR enables tool support
VMIL’24: The Fuzion Intermediate Representation7/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects
➡ Toolchain and Static Analysis ➡ The Fuzion IR ➡ Status
VMIL’24: The Fuzion Intermediate Representation8/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
VMIL’24: The Fuzion Intermediate Representation9/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
VMIL’24: The Fuzion Intermediate Representation10/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
Static analysis for Modules
➡local correctness
➡supply chain security
VMIL’24: The Fuzion Intermediate Representation11/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
VMIL’24: The Fuzion Intermediate Representation12/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
Create whole program
➡monomorphization
➡dead-code removal
➡...
VMIL’24: The Fuzion Intermediate Representation13/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
VMIL’24: The Fuzion Intermediate Representation14/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
Whole program analysis
➡no run-time errors
➡specialization
➡escape analysis /
stack allocation
➡instrumentation, test
generation, etc.
➡...
VMIL’24: The Fuzion Intermediate Representation15/33
Fuzion Toolchain and Static Analysis
Fuzion
source
Front
end
Middle
end
Fuzion
IR
Analyzer
Optimizer
JVM
backend
.class
.c
Fuzion
module
C
backend
Inter-
preter
JVM
VMIL’24: The Fuzion Intermediate Representation16/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects ➡ Toolchain and Static Analysis
➡ The Fuzion IR ➡ Status
VMIL’24: The Fuzion Intermediate Representation17/33
The Fuzion IR
VMIL’24: The Fuzion Intermediate Representation18/33
The Fuzion IR: Runtime Features
➡ Set of runtime features
VMIL’24: The Fuzion Intermediate Representation19/33
The Fuzion IR: Runtime Features
➡ Set of runtime features of the kinds
➡ - routine
➡ - abstract
➡ - field
➡ - choice
➡ - intrinsic
➡ - native
VMIL’24: The Fuzion Intermediate Representation20/33
The Fuzion IR: Runtime Features
➡ Set of runtime features of the kinds
➡ - routinetype
➡ - abstract
➡ - field
➡ - choicetype
➡ - intrinsic
➡ - native
VMIL’24: The Fuzion Intermediate Representation21/33
The Fuzion IR: Runtime Features
➡ Set of runtime features of the kinds
➡ - routinetypecallable
➡ - abstract callable
➡ - field callable
➡ - choicetype
➡ - intrinsic callable
➡ - native callable
VMIL’24: The Fuzion Intermediate Representation22/33
The Fuzion IR: Runtime Features
➡ Set of runtime features of the kinds
➡ - routinetypecallablehas code
➡ - abstract callable
➡ - field callable
➡ - choicetype
➡ - intrinsic callable
➡ - native callable
VMIL’24: The Fuzion Intermediate Representation23/33
The Fuzion IR: Code
VMIL’24: The Fuzion Intermediate Representation24/33
The Fuzion IR: Code
➡ Stack machine
VMIL’24: The Fuzion Intermediate Representation25/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
VMIL’24: The Fuzion Intermediate Representation26/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
VMIL’24: The Fuzion Intermediate Representation27/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
VMIL’24: The Fuzion Intermediate Representation28/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
VMIL’24: The Fuzion Intermediate Representation29/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
VMIL’24: The Fuzion Intermediate Representation30/33
The Fuzion IR: Code
➡ Stack machine
➡ Only 10 commands
➡ - Call
➡ - Assign
➡ - Tag / Match
➡ - Box, Env, Current, Const, Pop, Comment
➡ Intrinsics for arithmetic, runtime system, etc.
VMIL’24: The Fuzion Intermediate Representation31/33
Overview
➡ Fuzion quick intro
➡ Safety-Critical Aspects ➡ Toolchain and Static Analysis ➡ The Fuzion IR
➡ Status
VMIL’24: The Fuzion Intermediate Representation32/33
Fuzion: Status
Fuzion still under development
➡ language definition stabilizing
➡ base library work in progress
➡ current implementation providing JVM and C backends
➡ basic analysis tools available
➡ greencode.ai project starting now
VMIL’24: The Fuzion Intermediate Representation33/33
Thank you. Any questions?
Please follow and stay informed
➡ https://github.com/tokiwa-software/fuzion
➡ https://fuzion-lang.dev
➡ @FuzionLang
➡ @[email protected]