SlideShare a Scribd company logo
1 of 66
Download to read offline
Eelco Visser
CS4200 Compiler Construction
TU Delft
December 2018
Lecture 14: Interpreters
Reading Material
2
!3
Design and implementation of DynSem, a
domain-specific language for the definition
of the dynamic semantics of programming
languages.
DynSem provides facilities for implicitly
passing memory (environment, store).
DynSem specifications can be compiled to or
interpreted as interpreters for the languages
they define.
http://dx.doi.org/10.4230/LIPIcs.RTA.2015.365
RTA 2015
!4
This paper describes the partial evaluation
of the DynSem meta-interpreter with an object
program.
The implementation makes use of Truffle a
framework for run-time (online) partial
evaluation.
Truffle gets most of it benefit from Graal,
an implementation of the JVM with special
support for partial evaluation.
https://doi.org/10.1145/3237009.3237018
ManLang 2018
Semantics
5
What is the meaning of a program?
6
meaning(p) = what happens when executing the
generated (byte) code to which p is compiled
source
code
parse generate
machine
code
check
meaning(p) = behavior(p)
What is the meaning of a program?
7
Mapping input to output
What is behavior?
Changes to state of the system
How can we observe behavior?
meaning(p) = behavior(p)
Which behavior is essential, which accidental?
How can we define the semantics of a program?
8
Is there a more direct description of semanticsL1?
Compiler defines translational semantics
semanticsL1(p) = semanticsL2(translate(p))
Requires understanding translate and semanticsL2
How do we know that translate is correct?
source
code
machine
code
translate
value
value
equal
run
semanticsL1
run
semanticsL2
Verifying Compiler Correctness
10
Direct semantics of source language provides a specification
How to check correctness?
Testing: for many programs p (and inputs i) test that
run(p)(i) == run(translate(p))(i)
Verification: for all programs p (and inputs i) prove that
run(p)(i) == run(translate(p))(i)
Validating Semantics
11
Is this the right semantics?
Testing: for many programs p (and inputs i) test that
run(p)(i) == v
Requires specifying desired <p, i, v> combinations

(aka unit testing)
The CompCert C Compiler
12
http://compcert.inria.fr/compcert-C.html
Compiler Construction Courses of the Future
13
Language Specification
syntax definition
name binding
type system
dynamic semantics
translation
transformation
safety properties
Language Testing
test generation
Language Implementation
generating implementations
from specifications
parser generation
constraint resolution
partial evaluation
…
Language Verification
proving correctness
Operational Semantics
14
What is the result of execution of a program?
- How is that result achieved?

Natural Semantics
- How is overall result of execution obtained?

Structural Operational Semantics
- What are the individual steps of an execution?

Defined using a transition system
!15
Operational Semantics
DynSem
16
!17
Design and implementation of DynSem, a
domain-specific language for the definition
of the dynamic semantics of programming
languages.
DynSem provides facilities for implicitly
passing memory (environment, store).
DynSem specifications can be compiled to or
interpreted as interpreters for the languages
they define.
http://dx.doi.org/10.4230/LIPIcs.RTA.2015.365
RTA 2015
Interpreters for Spoofax Languages
18
Example: DynSem Semantics of PAPL-Box
19
let
fac = box(0)
in
let f = fun (n) {
if (n == 0)
1
else
n * (unbox(fac) (n - 1))
end
}
in
setbox(fac, f);
unbox(fac)(10)
end
end
Features
- Arithmetic
- Booleans
- Comparisons
- Mutable variables
- Functions
- Boxes
Components
- Syntax in SDF3
- Dynamic Semantics in DynSem
Abstract Syntax from Concrete Syntax
20
module Arithmetic
imports Expressions
imports Common
context-free syntax
Expr.Num = INT
Expr.Plus = [[Expr] + [Expr]] {left}
Expr.Minus = [[Expr] - [Expr]] {left}
Expr.Times = [[Expr] * [Expr]] {left}
Expr.Mod = [[Expr] % [Expr]] {left}
context-free priorities
{left: Expr.Times Expr.Mod }
> {left: Expr.Minus Expr.Plus }
module Arithmetic-sig
imports Expressions-sig
imports Common-sig
signature
sorts Expr
constructors
Num : INT -> Expr
Plus : Expr * Expr -> Expr
Minus : Expr * Expr -> Expr
Times : Expr * Expr -> Expr
Mod : Expr * Expr -> Expr
src-gen/ds-signatures/Arithmetic-sig
Values, Meta-Variables, and Arrows
21
module values
signature
sorts V Unit
constructors
U : Unit
variables
v: V
module expressions
imports values
imports Expressions-sig
signature
arrows
Expr --> V
variables
e : Expr
x : String
Term Reduction Rules
22
module arithmetic-explicit
imports expressions primitives Arithmetic-sig
signature
constructors
NumV: Int -> V
rules
Num(__String2INT__(n)) --> NumV(str2int(n)).
Plus(e1, e2) --> NumV(plusI(i1, i2))
where
e1 --> NumV(i1); e2 --> NumV(i2).
Minus(e1, e2) --> NumV(minusI(i1, i2))
where
e1 --> NumV(i1); e2 --> NumV(i2).
module expressions
imports values
imports Expressions-sig
signature
arrows
Expr --> V
variables
e : Expr
x : String
Native Operations
23
module arithmetic-explicit
imports expressions primitives Arithmetic-sig
signature
constructors
NumV: Int -> V
rules
Num(__String2INT__(n)) --> NumV(str2int(n)).
Plus(e1, e2) --> NumV(plusI(i1, i2))
where
e1 --> NumV(i1); e2 --> NumV(i2).
Minus(e1, e2) --> NumV(minusI(i1, i2))
where
e1 --> NumV(i1); e2 --> NumV(i2).
module primitives
signature
native operators
str2int : String -> Int
plusI : Int * Int -> Int
minusI : Int * Int -> Int
public class Natives {
public static int plusI_2(int i1, int i2) {
return i1 + i2;
}
public static int str2int_1(String s) {
return Integer.parseInt(s);
}
}
Arrows as Coercions
24
rules
Plus(e1, e2) --> NumV(plusI(i1, i2))
where
e1 --> NumV(i1);
e2 --> NumV(i2).
rules
Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
signature
constructors
Plus : Expr * Expr -> Expr
NumV : Int -> V
arrows
Expr --> V
Modular
25
module boolean
imports Booleans-sig expressions
signature
constructors
BoolV : Bool -> V
rules
True() --> BoolV(true).
False() --> BoolV(false).
Not(BoolV(false)) --> BoolV(true).
Not(BoolV(true)) --> BoolV(false).
Or(BoolV(true), _) --> BoolV(true).
Or(BoolV(false), e) --> e.
And(BoolV(false), _) --> BoolV(false).
And(BoolV(true), e) --> e.
module arithmetic
imports Arithmetic-sig
imports expressions
imports primitives
signature
constructors
NumV: Int -> V
rules
Num(str) --> NumV(str2int(str)).
Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
Minus(NumV(i1), NumV(i2)) --> NumV(minusI(i1, i2)).
Times(NumV(i1), NumV(i2)) --> NumV(timesI(i1, i2)).
Mod(NumV(i1), NumV(i2)) --> NumV(modI(i1, i2)).
module comparison
imports Comparisons-sig arithmetic boolean
rules
Gt(NumV(i1), NumV(i2)) --> BoolV(gtI(i1, i2)).
Eq(NumV(i1), NumV(i2)) --> BoolV(eqI(i1, i2)).
Eq(BoolV(b1), BoolV(b2)) --> BoolV(eqB(b1, b2)).
Interpreter is not defined as a single match over sort
Control-Flow
26
module controlflow
imports ControlFlow-sig
imports expressions
imports boolean
rules
Seq(v, e2) --> e2.
If(BoolV(true), e1, _) --> e1.
If(BoolV(false), _, e2) --> e2.
module controlflow
imports ControlFlow-sig
imports expressions
imports boolean
rules
Seq(e1, e2) --> v2
where
e1 --> v1;
e2 --> v2.
If(e1, e2, e3) --> v
where
e1 --> BoolV(true);
e2 --> v.
If(e1, e2, e3) --> v
where
e1 --> BoolV(false);
e3 --> v.
Immutable Variables: Environment Passing
27
constructors
Let : ID * Expr * Expr -> Expr
Var : ID -> Expr
module variables
imports Variables-sig environment
rules
E |- Let(x, v: V, e2) --> v2
where
Env {x |--> v, E} |- e2 --> v2.
E |- Var(x) --> E[x].
module environment
imports values
signature
sort aliases
Env = Map<String, V>
variables
E : Env
First-Class Functions: Environment in Closure
28
module unary-functions
imports expressions environment
signature
constructors
ClosV : String * Expr * Env -> V
rules
E |- Fun(x, e) --> ClosV(x, e, E).
E |- App(e1, e2) --> v
where
E |- e1 --> ClosV(x, e, E');
E |- e2 --> v2;
Env {x |--> v2, E'} |- e --> v.
constructors
Fun : ID * Expr -> Expr
App : Expr * Expr -> Expr
module environment
imports values
signature
sort aliases
Env = Map<String, V>
variables
E : Env
Implicit Propagation
29
rules
E |- Plus(e1, e2) --> NumV(plusI(i1, i2))
where
E |- e1 --> NumV(i1);
E |- e2 --> NumV(i2).
rules
Plus(e1, e2) --> NumV(plusI(i1, i2))
where
e1 --> NumV(i1);
e2 --> NumV(i2).
rules
Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
Mutable Boxes: Store
30
module box
imports store arithmetic
signature
constructors
Box : Expr -> Expr
Unbox : Expr -> Expr
SetBox : Expr * Expr -> Expr
constructors
BoxV: Int -> V
rules
Box(e) :: S --> BoxV(loc) :: Store {loc |--> v, S'}
where e :: S --> v :: S';
fresh => loc.
Unbox(BoxV(loc)) :: S --> S[loc].
SetBox(BoxV(loc), v) :: S --> v :: Store {loc |--> v, S}.
module store
imports values
signature
sort aliases
Store = Map<Int, V>
variables
S : Store
Mutable Variables: Environment + Store
31
constructors
Let : ID * Expr * Expr -> Expr
Var : ID -> Expr
Set : String * Expr -> Expr
module variables-mutable
imports Variables-sig store
rules
E |- Var(x) :: S --> v :: S
where E[x] => loc; S[loc] => v.
E |- Let(x, v, e2) :: S1 --> v2 :: S3
where
fresh => loc;
{loc |--> v, S1} => S2;
Env {x |--> loc, E} |- e2 :: S2 --> v2 :: S3.
E |- Set(x, v) :: S --> v :: Store {loc |--> v, S}
where E[x] => loc.
module store
imports values
signature
sort aliases
Env = Map<ID, Int>
Store = Map<Int, V>
variables
E : Env
S : Store
Implicit Store Threading
32
rules
E |- Plus(e1, e2) :: S1 --> NumV(plusI(i1, i2)) :: S3
where
E |- e1 :: S1 --> NumV(i1) :: S2;
E |- e2 :: S2 --> NumV(i2) :: S3.
rules
Plus(e1, e2) --> NumV(plusI(i1, i2))
where
e1 --> NumV(i1);
e2 --> NumV(i2).
rules
Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
Abstraction: Env/Store Meta Functions
33
module store
imports values
signature
sort aliases
Env = Map<String, Int>
Store = Map<Int, V>
variables
E : Env
S : Store
arrows
readVar : String --> V
bindVar : String * V --> Env
writeVar : String * V --> V
allocate : V --> Int
write : Int * V --> V
read : Int --> V
rules
allocate(v) --> loc
where
fresh => loc;
write(loc, v) --> _.
write(loc, v) :: S -->
v :: Store {loc |--> v, S}.
read(loc) :: S --> S[loc] :: S.
rules
bindVar(x, v) --> {x |--> loc}
where allocate(v) --> loc.
E |- readVar(x) --> read(E[x]).
E |- writeVar(x, v) --> write(E[x], v).
Boxes with Env/Store Meta Functions
34
module boxes
signature
constructors
Box : Expr -> Expr
Unbox : Expr -> Expr
SetBox : Expr * Expr -> Expr
constructors
BoxV: V -> V
rules
Box(v) --> BoxV(NumV(allocate(v))).
Unbox(BoxV(NumV(loc))) --> read(loc).
SetBox(BoxV(NumV(loc)), v) --> write(loc, v).
Mutable Variables with Env/Store Meta Functions
35
module variables
imports expressions store
rules
Var(x) --> readVar(x).
E |- Let(x, v1, e) --> v2
where
bindVar(x, v1) --> E';
Env {E', E} |- e --> v2.
Set(x, v) --> v
where
writeVar(x, v) --> _.
constructors
Let : String * Expr * Expr -> Expr
Var : String -> Expr
Set : String * Expr -> Expr
Functions with Multiple Arguments
36
module functions
imports Functions-sig
imports variables
signature
constructors
ClosV : List(ID) * Expr * Env -> V
bindArgs : List(ID) * List(Expr) --> Env
rules
E |- Fun(xs, e) --> ClosV(xs, e, E).
App(ClosV(xs, e_body, E_clos), es) --> v'
where
bindArgs(xs, es) --> E_params;
Env {E_params, E_clos} |- e_body --> v'.
bindArgs([], []) --> {}.
bindArgs([x | xs], [e | es]) --> {E, E'}
where
bindVar(x, e) --> E;
bindArgs(xs, es) --> E'.
Tiger in DynSem
37https://github.com/MetaBorgCube/metaborg-tiger
Interpreter Generation
38
Generating AST Interpreter from Dynamic Semantics
39
DynSem
Specification
AST Value
Interpreter
in Java
DynSem Meta-Interpreter
40
DynSem
Specification
AST
AST Rep. of
DynSem Rules
Value
Term Rep.
in Java
DynSem
Interpreter
Truffle: Partial Evaluation of AST Interpreters
41
Würthinger et al. One VM to rule them all. Onward! 2013
!42
This paper describes the partial evaluation
of the DynSem meta-interpreter with an object
program.
The implementation makes use of Truffle a
framework for run-time (online) partial
evaluation.
Truffle gets most of it benefit from Graal,
an implementation of the JVM with special
support for partial evaluation.
https://doi.org/10.1145/3237009.3237018
ManLang 2018
Partial Evaluation
43
!44
!45
!46
!47
!48
!49
!50
!51
!52
!53
!54
How is this relevant for compilers and interpreters?
!55
!56
!57
!58
!59
!60
!61
!62
Instance-specific program
- Can make very efficient

- Hard to maintain (performance interventions tangled with implementation)

- Hard to reuse for variants

Generic program
- Parametric in instances 

- Easy to maintain

- Easy to reuse for variants 

- Not efficient: overhead of parametricity 

Partial evaluation
- Specialize generic program to specific instances
!63
Partial Evaluation: Summary
Specializing a meta-interpreter
- Meta-interpreter: DynSem specifications executed using interpreter

- Partial evaluation: remove two stages of interpretation

- Encouraging results using Truffle/Graal

- How close to native speed can we get?

Generate byte code compiler
- Input: DynSem specification

- Output: compiler from source to (custom) byte code 

- Output: byte code interpreter
!64
Some Research Projects
Partial evaluation
- Offline vs online partial evaluation

- Binding-time analysis

Multi-stage programming
- Explicit binding time annotations

Just-in-time (JIT) compilation
- Interpreter selectively compiles code (fragments) to machine code

Techniques for partial evaluation
- Meta-tracing

- Run-time specialisation (Truffle/Graal)
!65
Further Study
!66
Except where otherwise noted, this work is licensed under

More Related Content

What's hot

Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingEelco Visser
 
Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQIntro C# Book
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and MapsIntro C# Book
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationEelco Visser
 
Compiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor ServicesCompiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor ServicesEelco Visser
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionEelco Visser
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Andrey Akinshin
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 

What's hot (20)

Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQ
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Writing Parsers and Compilers with PLY
Writing Parsers and Compilers with PLYWriting Parsers and Compilers with PLY
Writing Parsers and Compilers with PLY
 
C++11 & C++14
C++11 & C++14C++11 & C++14
C++11 & C++14
 
Compiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor ServicesCompiler Construction | Lecture 3 | Syntactic Editor Services
Compiler Construction | Lecture 3 | Syntactic Editor Services
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
Declare Your Language: Syntax Definition
Declare Your Language: Syntax DefinitionDeclare Your Language: Syntax Definition
Declare Your Language: Syntax Definition
 
C++11
C++11C++11
C++11
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
 
C++11
C++11C++11
C++11
 
06.Loops
06.Loops06.Loops
06.Loops
 
C++11
C++11C++11
C++11
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
More on Lex
More on LexMore on Lex
More on Lex
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 

Similar to Compiler Construction | Lecture 14 | Interpreters

Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationEelco Visser
 
Declare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsDeclare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsEelco Visser
 
Attention mechanisms with tensorflow
Attention mechanisms with tensorflowAttention mechanisms with tensorflow
Attention mechanisms with tensorflowKeon Kim
 
PVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentPVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentOOO "Program Verification Systems"
 
Learning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesDongsun Kim
 
Mining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review WorksMining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review WorksYuki Ueda
 
Mining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review WorksMining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review Works奈良先端大 情報科学研究科
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a ElixirSvet Ivantchev
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnArnaud Joly
 
Letswift Swift 3.0
Letswift Swift 3.0Letswift Swift 3.0
Letswift Swift 3.0Sehyun Park
 
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...Sencha
 
NVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読みNVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読みNVIDIA Japan
 
Optimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and VulkanOptimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and Vulkanax inc.
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortStefan Marr
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
Design Verification Using SystemC
Design Verification Using SystemCDesign Verification Using SystemC
Design Verification Using SystemCDVClub
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityDefconRussia
 

Similar to Compiler Construction | Lecture 14 | Interpreters (20)

Dynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter GenerationDynamic Semantics Specification and Interpreter Generation
Dynamic Semantics Specification and Interpreter Generation
 
Declare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsDeclare Your Language: Dynamic Semantics
Declare Your Language: Dynamic Semantics
 
Dynamic Semantics
Dynamic SemanticsDynamic Semantics
Dynamic Semantics
 
Attention mechanisms with tensorflow
Attention mechanisms with tensorflowAttention mechanisms with tensorflow
Attention mechanisms with tensorflow
 
PVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications developmentPVS-Studio, a solution for resource intensive applications development
PVS-Studio, a solution for resource intensive applications development
 
Learning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method NamesLearning to Spot and Refactor Inconsistent Method Names
Learning to Spot and Refactor Inconsistent Method Names
 
Mining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review WorksMining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review Works
 
Mining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review WorksMining Source Code Improvement Patterns from Similar Code Review Works
Mining Source Code Improvement Patterns from Similar Code Review Works
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
NvFX GTC 2013
NvFX GTC 2013NvFX GTC 2013
NvFX GTC 2013
 
Letswift Swift 3.0
Letswift Swift 3.0Letswift Swift 3.0
Letswift Swift 3.0
 
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
SenchaCon 2016: Advanced Techniques for Buidling Ext JS Apps with Electron - ...
 
NVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読みNVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読み
 
Optimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and VulkanOptimizing NN inference performance on Arm NEON and Vulkan
Optimizing NN inference performance on Arm NEON and Vulkan
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
Design Verification Using SystemC
Design Verification Using SystemCDesign Verification Using SystemC
Design Verification Using SystemC
 
Georgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software securityGeorgy Nosenko - An introduction to the use SMT solvers for software security
Georgy Nosenko - An introduction to the use SMT solvers for software security
 
Andes open cl for RISC-V
Andes open cl for RISC-VAndes open cl for RISC-V
Andes open cl for RISC-V
 

More from Eelco Visser

CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionEelco Visser
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesEelco Visser
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionEelco Visser
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Eelco Visser
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementEelco Visser
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksEelco Visser
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisEelco Visser
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingEelco Visser
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisEelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Eelco Visser
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Eelco Visser
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationEelco Visser
 
Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2Eelco Visser
 
Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1Eelco Visser
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type CheckingEelco Visser
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name ResolutionEelco Visser
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingEelco Visser
 

More from Eelco Visser (17)

CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static AnalysisCompiler Construction | Lecture 6 | Introduction to Static Analysis
Compiler Construction | Lecture 6 | Introduction to Static Analysis
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
 
Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?Compiler Construction | Lecture 1 | What is a compiler?
Compiler Construction | Lecture 1 | What is a compiler?
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code Generation
 
Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2Declare Your Language: Constraint Resolution 2
Declare Your Language: Constraint Resolution 2
 
Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1Declare Your Language: Constraint Resolution 1
Declare Your Language: Constraint Resolution 1
 
Declare Your Language: Type Checking
Declare Your Language: Type CheckingDeclare Your Language: Type Checking
Declare Your Language: Type Checking
 
Declare Your Language: Name Resolution
Declare Your Language: Name ResolutionDeclare Your Language: Name Resolution
Declare Your Language: Name Resolution
 
Declare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term RewritingDeclare Your Language: Transformation by Strategic Term Rewriting
Declare Your Language: Transformation by Strategic Term Rewriting
 

Recently uploaded

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 

Recently uploaded (20)

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 

Compiler Construction | Lecture 14 | Interpreters

  • 1. Eelco Visser CS4200 Compiler Construction TU Delft December 2018 Lecture 14: Interpreters
  • 3. !3 Design and implementation of DynSem, a domain-specific language for the definition of the dynamic semantics of programming languages. DynSem provides facilities for implicitly passing memory (environment, store). DynSem specifications can be compiled to or interpreted as interpreters for the languages they define. http://dx.doi.org/10.4230/LIPIcs.RTA.2015.365 RTA 2015
  • 4. !4 This paper describes the partial evaluation of the DynSem meta-interpreter with an object program. The implementation makes use of Truffle a framework for run-time (online) partial evaluation. Truffle gets most of it benefit from Graal, an implementation of the JVM with special support for partial evaluation. https://doi.org/10.1145/3237009.3237018 ManLang 2018
  • 6. What is the meaning of a program? 6 meaning(p) = what happens when executing the generated (byte) code to which p is compiled source code parse generate machine code check meaning(p) = behavior(p)
  • 7. What is the meaning of a program? 7 Mapping input to output What is behavior? Changes to state of the system How can we observe behavior? meaning(p) = behavior(p) Which behavior is essential, which accidental?
  • 8. How can we define the semantics of a program? 8 Is there a more direct description of semanticsL1? Compiler defines translational semantics semanticsL1(p) = semanticsL2(translate(p)) Requires understanding translate and semanticsL2 How do we know that translate is correct?
  • 10. Verifying Compiler Correctness 10 Direct semantics of source language provides a specification How to check correctness? Testing: for many programs p (and inputs i) test that run(p)(i) == run(translate(p))(i) Verification: for all programs p (and inputs i) prove that run(p)(i) == run(translate(p))(i)
  • 11. Validating Semantics 11 Is this the right semantics? Testing: for many programs p (and inputs i) test that run(p)(i) == v Requires specifying desired <p, i, v> combinations
 (aka unit testing)
  • 12. The CompCert C Compiler 12 http://compcert.inria.fr/compcert-C.html
  • 13. Compiler Construction Courses of the Future 13 Language Specification syntax definition name binding type system dynamic semantics translation transformation safety properties Language Testing test generation Language Implementation generating implementations from specifications parser generation constraint resolution partial evaluation … Language Verification proving correctness
  • 15. What is the result of execution of a program? - How is that result achieved? Natural Semantics - How is overall result of execution obtained? Structural Operational Semantics - What are the individual steps of an execution? Defined using a transition system !15 Operational Semantics
  • 17. !17 Design and implementation of DynSem, a domain-specific language for the definition of the dynamic semantics of programming languages. DynSem provides facilities for implicitly passing memory (environment, store). DynSem specifications can be compiled to or interpreted as interpreters for the languages they define. http://dx.doi.org/10.4230/LIPIcs.RTA.2015.365 RTA 2015
  • 18. Interpreters for Spoofax Languages 18
  • 19. Example: DynSem Semantics of PAPL-Box 19 let fac = box(0) in let f = fun (n) { if (n == 0) 1 else n * (unbox(fac) (n - 1)) end } in setbox(fac, f); unbox(fac)(10) end end Features - Arithmetic - Booleans - Comparisons - Mutable variables - Functions - Boxes Components - Syntax in SDF3 - Dynamic Semantics in DynSem
  • 20. Abstract Syntax from Concrete Syntax 20 module Arithmetic imports Expressions imports Common context-free syntax Expr.Num = INT Expr.Plus = [[Expr] + [Expr]] {left} Expr.Minus = [[Expr] - [Expr]] {left} Expr.Times = [[Expr] * [Expr]] {left} Expr.Mod = [[Expr] % [Expr]] {left} context-free priorities {left: Expr.Times Expr.Mod } > {left: Expr.Minus Expr.Plus } module Arithmetic-sig imports Expressions-sig imports Common-sig signature sorts Expr constructors Num : INT -> Expr Plus : Expr * Expr -> Expr Minus : Expr * Expr -> Expr Times : Expr * Expr -> Expr Mod : Expr * Expr -> Expr src-gen/ds-signatures/Arithmetic-sig
  • 21. Values, Meta-Variables, and Arrows 21 module values signature sorts V Unit constructors U : Unit variables v: V module expressions imports values imports Expressions-sig signature arrows Expr --> V variables e : Expr x : String
  • 22. Term Reduction Rules 22 module arithmetic-explicit imports expressions primitives Arithmetic-sig signature constructors NumV: Int -> V rules Num(__String2INT__(n)) --> NumV(str2int(n)). Plus(e1, e2) --> NumV(plusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). Minus(e1, e2) --> NumV(minusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). module expressions imports values imports Expressions-sig signature arrows Expr --> V variables e : Expr x : String
  • 23. Native Operations 23 module arithmetic-explicit imports expressions primitives Arithmetic-sig signature constructors NumV: Int -> V rules Num(__String2INT__(n)) --> NumV(str2int(n)). Plus(e1, e2) --> NumV(plusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). Minus(e1, e2) --> NumV(minusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). module primitives signature native operators str2int : String -> Int plusI : Int * Int -> Int minusI : Int * Int -> Int public class Natives { public static int plusI_2(int i1, int i2) { return i1 + i2; } public static int str2int_1(String s) { return Integer.parseInt(s); } }
  • 24. Arrows as Coercions 24 rules Plus(e1, e2) --> NumV(plusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). rules Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)). signature constructors Plus : Expr * Expr -> Expr NumV : Int -> V arrows Expr --> V
  • 25. Modular 25 module boolean imports Booleans-sig expressions signature constructors BoolV : Bool -> V rules True() --> BoolV(true). False() --> BoolV(false). Not(BoolV(false)) --> BoolV(true). Not(BoolV(true)) --> BoolV(false). Or(BoolV(true), _) --> BoolV(true). Or(BoolV(false), e) --> e. And(BoolV(false), _) --> BoolV(false). And(BoolV(true), e) --> e. module arithmetic imports Arithmetic-sig imports expressions imports primitives signature constructors NumV: Int -> V rules Num(str) --> NumV(str2int(str)). Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)). Minus(NumV(i1), NumV(i2)) --> NumV(minusI(i1, i2)). Times(NumV(i1), NumV(i2)) --> NumV(timesI(i1, i2)). Mod(NumV(i1), NumV(i2)) --> NumV(modI(i1, i2)). module comparison imports Comparisons-sig arithmetic boolean rules Gt(NumV(i1), NumV(i2)) --> BoolV(gtI(i1, i2)). Eq(NumV(i1), NumV(i2)) --> BoolV(eqI(i1, i2)). Eq(BoolV(b1), BoolV(b2)) --> BoolV(eqB(b1, b2)). Interpreter is not defined as a single match over sort
  • 26. Control-Flow 26 module controlflow imports ControlFlow-sig imports expressions imports boolean rules Seq(v, e2) --> e2. If(BoolV(true), e1, _) --> e1. If(BoolV(false), _, e2) --> e2. module controlflow imports ControlFlow-sig imports expressions imports boolean rules Seq(e1, e2) --> v2 where e1 --> v1; e2 --> v2. If(e1, e2, e3) --> v where e1 --> BoolV(true); e2 --> v. If(e1, e2, e3) --> v where e1 --> BoolV(false); e3 --> v.
  • 27. Immutable Variables: Environment Passing 27 constructors Let : ID * Expr * Expr -> Expr Var : ID -> Expr module variables imports Variables-sig environment rules E |- Let(x, v: V, e2) --> v2 where Env {x |--> v, E} |- e2 --> v2. E |- Var(x) --> E[x]. module environment imports values signature sort aliases Env = Map<String, V> variables E : Env
  • 28. First-Class Functions: Environment in Closure 28 module unary-functions imports expressions environment signature constructors ClosV : String * Expr * Env -> V rules E |- Fun(x, e) --> ClosV(x, e, E). E |- App(e1, e2) --> v where E |- e1 --> ClosV(x, e, E'); E |- e2 --> v2; Env {x |--> v2, E'} |- e --> v. constructors Fun : ID * Expr -> Expr App : Expr * Expr -> Expr module environment imports values signature sort aliases Env = Map<String, V> variables E : Env
  • 29. Implicit Propagation 29 rules E |- Plus(e1, e2) --> NumV(plusI(i1, i2)) where E |- e1 --> NumV(i1); E |- e2 --> NumV(i2). rules Plus(e1, e2) --> NumV(plusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). rules Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
  • 30. Mutable Boxes: Store 30 module box imports store arithmetic signature constructors Box : Expr -> Expr Unbox : Expr -> Expr SetBox : Expr * Expr -> Expr constructors BoxV: Int -> V rules Box(e) :: S --> BoxV(loc) :: Store {loc |--> v, S'} where e :: S --> v :: S'; fresh => loc. Unbox(BoxV(loc)) :: S --> S[loc]. SetBox(BoxV(loc), v) :: S --> v :: Store {loc |--> v, S}. module store imports values signature sort aliases Store = Map<Int, V> variables S : Store
  • 31. Mutable Variables: Environment + Store 31 constructors Let : ID * Expr * Expr -> Expr Var : ID -> Expr Set : String * Expr -> Expr module variables-mutable imports Variables-sig store rules E |- Var(x) :: S --> v :: S where E[x] => loc; S[loc] => v. E |- Let(x, v, e2) :: S1 --> v2 :: S3 where fresh => loc; {loc |--> v, S1} => S2; Env {x |--> loc, E} |- e2 :: S2 --> v2 :: S3. E |- Set(x, v) :: S --> v :: Store {loc |--> v, S} where E[x] => loc. module store imports values signature sort aliases Env = Map<ID, Int> Store = Map<Int, V> variables E : Env S : Store
  • 32. Implicit Store Threading 32 rules E |- Plus(e1, e2) :: S1 --> NumV(plusI(i1, i2)) :: S3 where E |- e1 :: S1 --> NumV(i1) :: S2; E |- e2 :: S2 --> NumV(i2) :: S3. rules Plus(e1, e2) --> NumV(plusI(i1, i2)) where e1 --> NumV(i1); e2 --> NumV(i2). rules Plus(NumV(i1), NumV(i2)) --> NumV(plusI(i1, i2)).
  • 33. Abstraction: Env/Store Meta Functions 33 module store imports values signature sort aliases Env = Map<String, Int> Store = Map<Int, V> variables E : Env S : Store arrows readVar : String --> V bindVar : String * V --> Env writeVar : String * V --> V allocate : V --> Int write : Int * V --> V read : Int --> V rules allocate(v) --> loc where fresh => loc; write(loc, v) --> _. write(loc, v) :: S --> v :: Store {loc |--> v, S}. read(loc) :: S --> S[loc] :: S. rules bindVar(x, v) --> {x |--> loc} where allocate(v) --> loc. E |- readVar(x) --> read(E[x]). E |- writeVar(x, v) --> write(E[x], v).
  • 34. Boxes with Env/Store Meta Functions 34 module boxes signature constructors Box : Expr -> Expr Unbox : Expr -> Expr SetBox : Expr * Expr -> Expr constructors BoxV: V -> V rules Box(v) --> BoxV(NumV(allocate(v))). Unbox(BoxV(NumV(loc))) --> read(loc). SetBox(BoxV(NumV(loc)), v) --> write(loc, v).
  • 35. Mutable Variables with Env/Store Meta Functions 35 module variables imports expressions store rules Var(x) --> readVar(x). E |- Let(x, v1, e) --> v2 where bindVar(x, v1) --> E'; Env {E', E} |- e --> v2. Set(x, v) --> v where writeVar(x, v) --> _. constructors Let : String * Expr * Expr -> Expr Var : String -> Expr Set : String * Expr -> Expr
  • 36. Functions with Multiple Arguments 36 module functions imports Functions-sig imports variables signature constructors ClosV : List(ID) * Expr * Env -> V bindArgs : List(ID) * List(Expr) --> Env rules E |- Fun(xs, e) --> ClosV(xs, e, E). App(ClosV(xs, e_body, E_clos), es) --> v' where bindArgs(xs, es) --> E_params; Env {E_params, E_clos} |- e_body --> v'. bindArgs([], []) --> {}. bindArgs([x | xs], [e | es]) --> {E, E'} where bindVar(x, e) --> E; bindArgs(xs, es) --> E'.
  • 39. Generating AST Interpreter from Dynamic Semantics 39 DynSem Specification AST Value Interpreter in Java
  • 40. DynSem Meta-Interpreter 40 DynSem Specification AST AST Rep. of DynSem Rules Value Term Rep. in Java DynSem Interpreter
  • 41. Truffle: Partial Evaluation of AST Interpreters 41 Würthinger et al. One VM to rule them all. Onward! 2013
  • 42. !42 This paper describes the partial evaluation of the DynSem meta-interpreter with an object program. The implementation makes use of Truffle a framework for run-time (online) partial evaluation. Truffle gets most of it benefit from Graal, an implementation of the JVM with special support for partial evaluation. https://doi.org/10.1145/3237009.3237018 ManLang 2018
  • 44. !44
  • 45. !45
  • 46. !46
  • 47. !47
  • 48. !48
  • 49. !49
  • 50. !50
  • 51. !51
  • 52. !52
  • 53. !53
  • 54. !54 How is this relevant for compilers and interpreters?
  • 55. !55
  • 56. !56
  • 57. !57
  • 58. !58
  • 59. !59
  • 60. !60
  • 61. !61
  • 62. !62
  • 63. Instance-specific program - Can make very efficient - Hard to maintain (performance interventions tangled with implementation) - Hard to reuse for variants Generic program - Parametric in instances - Easy to maintain - Easy to reuse for variants - Not efficient: overhead of parametricity Partial evaluation - Specialize generic program to specific instances !63 Partial Evaluation: Summary
  • 64. Specializing a meta-interpreter - Meta-interpreter: DynSem specifications executed using interpreter - Partial evaluation: remove two stages of interpretation - Encouraging results using Truffle/Graal - How close to native speed can we get? Generate byte code compiler - Input: DynSem specification - Output: compiler from source to (custom) byte code - Output: byte code interpreter !64 Some Research Projects
  • 65. Partial evaluation - Offline vs online partial evaluation - Binding-time analysis Multi-stage programming - Explicit binding time annotations Just-in-time (JIT) compilation - Interpreter selectively compiles code (fragments) to machine code Techniques for partial evaluation - Meta-tracing - Run-time specialisation (Truffle/Graal) !65 Further Study
  • 66. !66 Except where otherwise noted, this work is licensed under