SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
Strategies for Online Partial Evaluation
Program Transformation 2004–2005

Eelco Visser
Institute of Information & Computing Sciences
Utrecht University
The Netherlands

March 17, 2005
Online Partial Evaluation
Goal
Inputs: program, inputs for some arguments
Output: program specialized to these inputs, optimized as
much as possible
Simplification
Input: program with constant expressions
Output: program specialized to constant expressions,
optimized as much as possible
Online vs Offline
Online: decision to specialize based on program + inputs
Offline: decision to specialized based on program +
declaration of static inputs

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Outline
Refine constant propagation strategy to online specializer
Specialize 0: constant propagation
Specialize 1: function unfolding
Specialize 2: unfold only static calls
Specialize 3: memoize call unfolding
Specialize 4: specialization of function definitions
Specialize 5: reduction of specialized functions

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 0: Constant Propagation
pe = PropConst <+ pe-assign <+ pe-declare
<+ pe-let <+ pe-if <+ pe-while <+ pe-for
<+ all(pe); try(EvalBinOp <+ EvalRelOp <+ EvalString)
pe-assign =
|[ x := <pe => e> ]|
; if <is-value> e
then rules( PropConst.x : |[ x ]| -> |[ e ]| )
else rules( PropConst.x :- |[ x ]| ) end
pe-declare =
? |[ var x ta ]|
; rules( PropConst+x :- |[ x ]| )
pe-declare =
|[ var x ta := <pe => e> ]|
; if <is-value> e
then rules( PropConst+x : |[ x ]| -> |[ e ]| )
else rules( PropConst+x :- |[ x ]| ) end
pe-let =
|[ let <*id> in <*id> end ]|
; {| PropConst : all(pe) |}
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 0: Constant Propagation (control flow)
pe-if =
|[ if <pe> then <id> ]|
; (EvalIf <+ (|[ if <id> then <pe> ]| /PropConst id))
pe-if =
|[ if <pe> then <id> else <id> ]|
; (EvalIf; pe
<+ (|[ if <id> then <pe> else <id> ]|
/PropConst |[ if <id> then <id> else <pe> ]|))
pe-while =
|[ while <id> do <id> ]|
; (|[ while <pe> do <id> ]|; EvalWhile
<+ /PropConst* |[ while <pe> do <pe> ]|)

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(fact(10))
end

⇓
let function fact(n : int) : int =
if n < 1 then 1 else n * fact(n - 1)
in printint(3628800)
end

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding
Replace call and substitute arguments
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(fact(10))
end

⇓
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(
if 10 < 1 then 1 else (10 * fact(10 - 1))
)
end

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Substitution
pe = PropConst <+ {| PropConst : UnfoldCall; pe |} <+ ...
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ e ]|
where <zip(SubstArg)> (x*, a*) => d*
)
SubstArg =
?(FArg|[ x ta ]|, e)
; rules( PropConst : |[ x ]| -> |[ e ]| )

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Substitution
pe = PropConst <+ {| PropConst : UnfoldCall; pe |} <+ ...
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ e ]|
where <zip(SubstArg)> (x*, a*) => d*
)
SubstArg =
?(FArg|[ x ta ]|, e)
; rules( PropConst : |[ x ]| -> |[ e ]| )

Substitution may lead to duplication of computations and side
effects.
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Let Binding
pe = PropConst <+ UnfoldCall; pe <+ ...
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ let d* in e end ]|
where <zip(BindArg)> (x*, a*) => d*
)
BindArg :
(FArg|[ x ta ]|, e) -> |[ var x ta := e ]|

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Let Binding
pe = PropConst <+ UnfoldCall; pe <+ ...
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ let d* in e end ]|
where <zip(BindArg)> (x*, a*) => d*
)
BindArg :
(FArg|[ x ta ]|, e) -> |[ var x ta := e ]|

Binding expressions to variable and subsequent constant
propagation have same effect as substitution, but is safe.

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Replace call by body
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(fact(10))
end

⇓
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(
let var n := 10
in if n < 1 then 1 else (n * fact(n - 1))
end)
end

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Constant propagation
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(
let var n := 10
in if n < 1 then 1 else (n * fact(n - 1))
end)
end

⇓
let function fact(n : int) : int =
if n < 1 then 1 else (n * fact(n - 1))
in printint(
let var n := 10
in 10 * fact(9)
end)
end
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Constant Fold Let
EvalLet :
|[ let d* in i end ]| -> |[ i ]|
pe-let =
|[ let <*id> in <*id> end ]|
; {| PropConst : all(pe) |}
; try(EvalLet)

If let body reduces to a constant value, the bindings are dead.

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 1: Function Unfolding — Cleaning up
pe-let =
|[ let <*id> in <*id> end ]|
; {| PropConst, UnfoldCall : all(pe) |}
; |[ let <*filter(not(DeadBinding))> in <*id> end ]|
; try(EvalLet)
DeadBinding =
?|[ var x ta := x ]|
DeadBinding =
?|[ var x ta := i ]|
EvalLet :
|[ let d* in i end ]| -> |[ i ]|

Remove useless variable bindings
http://www.strategoxt.org

Strategies for Online Partial Evaluation
let ...
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5))
end

⇓
in printint(
let var x : int := readint()
in x * let var x : int :=
let var x : int := x * 1
in x * x end
in x * x end
end)
end

Specialize 1
http://www.strategoxt.org

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(6, readint())); print("n")
end

Problem: Specialize 1 does not terminate for many programs
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 2: Unfold only calls with all static arguments
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ let d* in e end ]|
where <map(is-value)> a*
; <zip(BindArg)> (x*, a*) => d*
)

http://www.strategoxt.org

Strategies for Online Partial Evaluation
let
function fibonacci(n:int):int =
if (n >= 2) then
fibonacci(n-1) + fibonacci(n-2)
else if (n = 1) then
1
else 0
in printint(fibonacci(30))
end

Problem: re-evaluation of same static calls

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize 3: memoize call unfoldings
unfold-call :
|[ f(a*) ]| -> |[ e ]|
where <RetrieveUnfolding> |[ f(a*) ]| => |[ e ]|
<+ <UnfoldCall; pe> |[ f(a*) ]| => |[ e ]|
; rules(
RetrieveUnfolding.f : |[ f(a*) ]| -> |[ e ]|
)
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ let d* in e end ]|
where <map(is-value)> a*
; <zip(BindArg)> (x*, a*) => d*
RetrieveUnfolding+f
)
http://www.strategoxt.org

Strategies for Online Partial Evaluation
memoization works
fib
15
17
20

Specialize2
0m1.656s
0m3.955s
0m14.906s

http://www.strategoxt.org

Specialize3
0m0.219s
0m0.227s
0m0.232s

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5)); print("n")
end

Problem: Specialize 3 does not specialize partially static calls
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: specialization of function definitions
pe = ... <+ all(pe); try(... <+ SpecializeCall)
pe-declare =
?|[ function f(x*) ta = e ]|
; rules(
UnfoldCall :
|[ f(a*) ]| -> |[ let d* in e end ]|
where <map(is-value)> a*
; <zip(BindArg)> (x*, a*) => d*
RetrieveUnfolding+f
Specialization+f
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where // next slide
)

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: specialize function to static arguments
pe-declare = ?|[ function f(x*) ta = e ]|;
rules(
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*))
; new => g; !e => e2
; rules(
Specialization.f :+
|[ function f(x*) ta = e’ ]| ->
|[ function g(x2*) ta = let d* in e2 end ]|
)
)
split-static-dynamic-args =
zip; partition(BindArgValue); (not([]), unzip)
BindArgValue :
(FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: specialize function to static arguments
pe-declare = ?|[ function f(x*) ta = e ]|;
rules(
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*))
; new => g; !e => e2
; rules(
Specialization.f :+
|[ function f(x*) ta = e’ ]| ->
|[ function g(x2*) ta = let d* in e2 end ]|
)
)
split-static-dynamic-args =
zip; partition(BindArgValue); (not([]), unzip)
BindArgValue :
(FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e

separate static from dynamic arguments

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: specialize function to static arguments
pe-declare = ?|[ function f(x*) ta = e ]|;
rules(
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*))
; new => g; !e => e2
; rules(
Specialization.f :+
|[ function f(x*) ta = e’ ]| ->
|[ function g(x2*) ta = let d* in e2 end ]|
)
)
split-static-dynamic-args =
zip; partition(BindArgValue); (not([]), unzip)
BindArgValue :
(FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e

separate static from dynamic arguments
R :+ l -> r — dynamic rule with multiple right-hand sides
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: replace functions with their specialization
pe-let =
|[ let <*id> in <*id> end ]|
; {| PropConst, UnfoldCall, RetrieveUnfolding, Specialization :
all(pe)
; |[ let <*filter(|[ <fd*:mapconcat(bagof-Specialization)> ]|
<+ not(DeadBinding))>
in <*id> end ]|
|}
; try(EvalLet)

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize4: replace functions with their specialization
pe-let =
|[ let <*id> in <*id> end ]|
; {| PropConst, UnfoldCall, RetrieveUnfolding, Specialization :
all(pe)
; |[ let <*filter(|[ <fd*:mapconcat(bagof-Specialization)> ]|
<+ not(DeadBinding))>
in <*id> end ]|
|}
; try(EvalLet)

bagof-R: all rewritings of R

http://www.strategoxt.org

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5))
end

⇓
let function a_0(x : int) : int =
let var n : int := 5
in if n= 0 then 1
else if even(n) then square(power(x, n / 2))
else x * power(x, n - 1)
end
in printint(a_0(readint()))
end

http://www.strategoxt.org

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5))
end

⇓
let function a_0(x : int) : int =
let var n : int := 5
in if n= 0 then 1
else if even(n) then square(power(x, n / 2))
else x * power(x, n - 1)
end
in printint(a_0(readint()))
end

Problem: body of specialized function is not transformed
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize5: reduce body of specialized function
pe-declare = ?|[ function f(x*) ta = e ]|;
rules(
...
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where <split-static-dynamic-args>
(x*, a1*) => (d*, (x2*, a2*))
; new => g
; <pe>|[ let d* in e end ]| => e2
; rules(
Specialization.f :+
|[ function f(x*) ta = e’ ]| ->
|[ function g(x2*) ta = e2 ]|
)
)

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Specialize5: reduce body of specialized function
pe-declare = ?|[ function f(x*) ta = e ]|;
rules(
...
SpecializeCall :
|[ f(a1*) ]| -> |[ g(a2*) ]|
where <split-static-dynamic-args>
(x*, a1*) => (d*, (x2*, a2*))
; new => g
; <pe>|[ let d* in e end ]| => e2
; rules(
Specialization.f :+
|[ function f(x*) ta = e’ ]| ->
|[ function g(x2*) ta = e2 ]|
)
)

transform instantiated body before declaring specialization
http://www.strategoxt.org

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5))
end

⇓
let function a_0(x : int) : int
function d_0(x : int) : int
function e_0(x : int) : int
function g_0(x : int) : int
function h_0(x : int) : int
in printint(a_0(readint()));
print("n")
end

=
=
=
=
=

x * d_0(x)
square(e_0(x))
square(g_0(x))
x * h_0(x)
1

http://www.strategoxt.org

Strategies for Online Partial Evaluation
let function square(x : int) : int =
x * x
function mod(x : int, y : int) : int =
x - (x / y) * y
function even(x : int) : int =
mod(x, 2) = 0
function power(x : int, n : int) : int =
if n = 0 then 1
else if even(n) then square(power(x, n/2))
else (x * power(x, n - 1))
in printint(power(readint(), 5))
end

⇓
let function a_0(x : int) : int
function d_0(x : int) : int
function e_0(x : int) : int
function g_0(x : int) : int
function h_0(x : int) : int
in printint(a_0(readint()));
print("n")
end

=
=
=
=
=

x * d_0(x)
square(e_0(x))
square(g_0(x))
x * h_0(x)
1

Problem: lots of ‘trivial’ functions generated
http://www.strategoxt.org

Strategies for Online Partial Evaluation
Cliffhanger ...
Try to unfold as many functions as possible
Doing to much will lead to non-termination
How to control unfolding?

http://www.strategoxt.org

Strategies for Online Partial Evaluation
Cliffhanger ...
Try to unfold as many functions as possible
Doing to much will lead to non-termination
How to control unfolding?
Next week:
Memoization to catch calls to specializations in progress
Offline partial evaluation: use binding time analysis to decide
which calls to unfold and which to specialize

http://www.strategoxt.org

Strategies for Online Partial Evaluation

Contenu connexe

Tendances

Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6Microsoft
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Code Optimization
Code OptimizationCode Optimization
Code Optimizationguest9f8315
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation19magnet
 
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)PouriaDerakhshanfar
 
Java Puzzle
Java PuzzleJava Puzzle
Java PuzzleSFilipp
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in ScalaHermann Hueck
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professionalIsabella789
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaanwalia Shaan
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightWiem Zine Elabidine
 
Programação reativa e o actor model
Programação reativa e o actor modelProgramação reativa e o actor model
Programação reativa e o actor modelFabrício Rissetto
 

Tendances (18)

Parameters
ParametersParameters
Parameters
 
Haskell 101
Haskell 101Haskell 101
Haskell 101
 
Berlin meetup
Berlin meetupBerlin meetup
Berlin meetup
 
Les nouveautés de C# 6
Les nouveautés de C# 6Les nouveautés de C# 6
Les nouveautés de C# 6
 
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Compiler Optimization Presentation
Compiler Optimization PresentationCompiler Optimization Presentation
Compiler Optimization Presentation
 
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)
Hybrid Multi-level Crossover for Unit Test Case Generation (SSBSE 2021)
 
Pure Future
Pure FuturePure Future
Pure Future
 
Java Puzzle
Java PuzzleJava Puzzle
Java Puzzle
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
C#
C#C#
C#
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnight
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
Programação reativa e o actor model
Programação reativa e o actor modelProgramação reativa e o actor model
Programação reativa e o actor model
 

Similaire à Online partial evaluation

Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rulesEelco Visser
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?jonbodner
 
TDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação FuncionalTDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação Funcionaltdc-globalcode
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a ElixirSvet Ivantchev
 
Declare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsDeclare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsEelco Visser
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simpleAteji Px
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Qiangning Hong
 
Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHPDavid de Boer
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programmingLukasz Dynowski
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)David de Boer
 
GPars For Beginners
GPars For BeginnersGPars For Beginners
GPars For BeginnersMatt Passell
 
Dependent dynamic rules
Dependent dynamic rulesDependent dynamic rules
Dependent dynamic rulesEelco Visser
 
“Tasks” in NetLogo 5.0beta1
“Tasks” in NetLogo 5.0beta1“Tasks” in NetLogo 5.0beta1
“Tasks” in NetLogo 5.0beta1SethTisue
 
Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Scott Wlaschin
 
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
 
Reasonable Code With Fsharp
Reasonable Code With FsharpReasonable Code With Fsharp
Reasonable Code With FsharpMichael Falanga
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxkarlynwih
 

Similaire à Online partial evaluation (20)

Scoped dynamic rewrite rules
Scoped dynamic rewrite rulesScoped dynamic rewrite rules
Scoped dynamic rewrite rules
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
TDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação FuncionalTDC2016SP - Trilha Programação Funcional
TDC2016SP - Trilha Programação Funcional
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Declare Your Language: Dynamic Semantics
Declare Your Language: Dynamic SemanticsDeclare Your Language: Dynamic Semantics
Declare Your Language: Dynamic Semantics
 
Dafunctor
DafunctorDafunctor
Dafunctor
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simple
 
Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010Python于Web 2.0网站的应用 - QCon Beijing 2010
Python于Web 2.0网站的应用 - QCon Beijing 2010
 
Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHP
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)Being functional in PHP (DPC 2016)
Being functional in PHP (DPC 2016)
 
GPars For Beginners
GPars For BeginnersGPars For Beginners
GPars For Beginners
 
Monads in Swift
Monads in SwiftMonads in Swift
Monads in Swift
 
Dependent dynamic rules
Dependent dynamic rulesDependent dynamic rules
Dependent dynamic rules
 
“Tasks” in NetLogo 5.0beta1
“Tasks” in NetLogo 5.0beta1“Tasks” in NetLogo 5.0beta1
“Tasks” in NetLogo 5.0beta1
 
Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)Functional Programming Patterns (NDC London 2014)
Functional Programming Patterns (NDC London 2014)
 
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
 
Reasonable Code With Fsharp
Reasonable Code With FsharpReasonable Code With Fsharp
Reasonable Code With Fsharp
 
PythonOOP
PythonOOPPythonOOP
PythonOOP
 
Write an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docxWrite an algorithm for a program that shows the use of all six math fu.docx
Write an algorithm for a program that shows the use of all six math fu.docx
 

Plus de Eelco Visser

CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingEelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco 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
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with StatixEelco 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 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersEelco Visser
 
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 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco 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 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionEelco Visser
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco 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 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Eelco Visser
 

Plus de Eelco Visser (20)

CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
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
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
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 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
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 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
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 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
 

Dernier

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Online partial evaluation

  • 1. Strategies for Online Partial Evaluation Program Transformation 2004–2005 Eelco Visser Institute of Information & Computing Sciences Utrecht University The Netherlands March 17, 2005
  • 2. Online Partial Evaluation Goal Inputs: program, inputs for some arguments Output: program specialized to these inputs, optimized as much as possible Simplification Input: program with constant expressions Output: program specialized to constant expressions, optimized as much as possible Online vs Offline Online: decision to specialize based on program + inputs Offline: decision to specialized based on program + declaration of static inputs http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 3. Outline Refine constant propagation strategy to online specializer Specialize 0: constant propagation Specialize 1: function unfolding Specialize 2: unfold only static calls Specialize 3: memoize call unfolding Specialize 4: specialization of function definitions Specialize 5: reduction of specialized functions http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 4. Specialize 0: Constant Propagation pe = PropConst <+ pe-assign <+ pe-declare <+ pe-let <+ pe-if <+ pe-while <+ pe-for <+ all(pe); try(EvalBinOp <+ EvalRelOp <+ EvalString) pe-assign = |[ x := <pe => e> ]| ; if <is-value> e then rules( PropConst.x : |[ x ]| -> |[ e ]| ) else rules( PropConst.x :- |[ x ]| ) end pe-declare = ? |[ var x ta ]| ; rules( PropConst+x :- |[ x ]| ) pe-declare = |[ var x ta := <pe => e> ]| ; if <is-value> e then rules( PropConst+x : |[ x ]| -> |[ e ]| ) else rules( PropConst+x :- |[ x ]| ) end pe-let = |[ let <*id> in <*id> end ]| ; {| PropConst : all(pe) |} http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 5. Specialize 0: Constant Propagation (control flow) pe-if = |[ if <pe> then <id> ]| ; (EvalIf <+ (|[ if <id> then <pe> ]| /PropConst id)) pe-if = |[ if <pe> then <id> else <id> ]| ; (EvalIf; pe <+ (|[ if <id> then <pe> else <id> ]| /PropConst |[ if <id> then <id> else <pe> ]|)) pe-while = |[ while <id> do <id> ]| ; (|[ while <pe> do <id> ]|; EvalWhile <+ /PropConst* |[ while <pe> do <pe> ]|) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 6. Specialize 1: Function Unfolding let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint(fact(10)) end ⇓ let function fact(n : int) : int = if n < 1 then 1 else n * fact(n - 1) in printint(3628800) end http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 7. Specialize 1: Function Unfolding Replace call and substitute arguments let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint(fact(10)) end ⇓ let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint( if 10 < 1 then 1 else (10 * fact(10 - 1)) ) end http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 8. Specialize 1: Function Unfolding — Substitution pe = PropConst <+ {| PropConst : UnfoldCall; pe |} <+ ... pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ e ]| where <zip(SubstArg)> (x*, a*) => d* ) SubstArg = ?(FArg|[ x ta ]|, e) ; rules( PropConst : |[ x ]| -> |[ e ]| ) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 9. Specialize 1: Function Unfolding — Substitution pe = PropConst <+ {| PropConst : UnfoldCall; pe |} <+ ... pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ e ]| where <zip(SubstArg)> (x*, a*) => d* ) SubstArg = ?(FArg|[ x ta ]|, e) ; rules( PropConst : |[ x ]| -> |[ e ]| ) Substitution may lead to duplication of computations and side effects. http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 10. Specialize 1: Function Unfolding — Let Binding pe = PropConst <+ UnfoldCall; pe <+ ... pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ let d* in e end ]| where <zip(BindArg)> (x*, a*) => d* ) BindArg : (FArg|[ x ta ]|, e) -> |[ var x ta := e ]| http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 11. Specialize 1: Function Unfolding — Let Binding pe = PropConst <+ UnfoldCall; pe <+ ... pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ let d* in e end ]| where <zip(BindArg)> (x*, a*) => d* ) BindArg : (FArg|[ x ta ]|, e) -> |[ var x ta := e ]| Binding expressions to variable and subsequent constant propagation have same effect as substitution, but is safe. http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 12. Specialize 1: Function Unfolding — Replace call by body let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint(fact(10)) end ⇓ let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint( let var n := 10 in if n < 1 then 1 else (n * fact(n - 1)) end) end http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 13. Specialize 1: Function Unfolding — Constant propagation let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint( let var n := 10 in if n < 1 then 1 else (n * fact(n - 1)) end) end ⇓ let function fact(n : int) : int = if n < 1 then 1 else (n * fact(n - 1)) in printint( let var n := 10 in 10 * fact(9) end) end http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 14. Specialize 1: Function Unfolding — Constant Fold Let EvalLet : |[ let d* in i end ]| -> |[ i ]| pe-let = |[ let <*id> in <*id> end ]| ; {| PropConst : all(pe) |} ; try(EvalLet) If let body reduces to a constant value, the bindings are dead. http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 15. Specialize 1: Function Unfolding — Cleaning up pe-let = |[ let <*id> in <*id> end ]| ; {| PropConst, UnfoldCall : all(pe) |} ; |[ let <*filter(not(DeadBinding))> in <*id> end ]| ; try(EvalLet) DeadBinding = ?|[ var x ta := x ]| DeadBinding = ?|[ var x ta := i ]| EvalLet : |[ let d* in i end ]| -> |[ i ]| Remove useless variable bindings http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 16. let ... function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)) end ⇓ in printint( let var x : int := readint() in x * let var x : int := let var x : int := x * 1 in x * x end in x * x end end) end Specialize 1 http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 17. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(6, readint())); print("n") end Problem: Specialize 1 does not terminate for many programs http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 18. Specialize 2: Unfold only calls with all static arguments pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ let d* in e end ]| where <map(is-value)> a* ; <zip(BindArg)> (x*, a*) => d* ) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 19. let function fibonacci(n:int):int = if (n >= 2) then fibonacci(n-1) + fibonacci(n-2) else if (n = 1) then 1 else 0 in printint(fibonacci(30)) end Problem: re-evaluation of same static calls http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 20. Specialize 3: memoize call unfoldings unfold-call : |[ f(a*) ]| -> |[ e ]| where <RetrieveUnfolding> |[ f(a*) ]| => |[ e ]| <+ <UnfoldCall; pe> |[ f(a*) ]| => |[ e ]| ; rules( RetrieveUnfolding.f : |[ f(a*) ]| -> |[ e ]| ) pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ let d* in e end ]| where <map(is-value)> a* ; <zip(BindArg)> (x*, a*) => d* RetrieveUnfolding+f ) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 22. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)); print("n") end Problem: Specialize 3 does not specialize partially static calls http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 23. Specialize4: specialization of function definitions pe = ... <+ all(pe); try(... <+ SpecializeCall) pe-declare = ?|[ function f(x*) ta = e ]| ; rules( UnfoldCall : |[ f(a*) ]| -> |[ let d* in e end ]| where <map(is-value)> a* ; <zip(BindArg)> (x*, a*) => d* RetrieveUnfolding+f Specialization+f SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where // next slide ) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 24. Specialize4: specialize function to static arguments pe-declare = ?|[ function f(x*) ta = e ]|; rules( SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*)) ; new => g; !e => e2 ; rules( Specialization.f :+ |[ function f(x*) ta = e’ ]| -> |[ function g(x2*) ta = let d* in e2 end ]| ) ) split-static-dynamic-args = zip; partition(BindArgValue); (not([]), unzip) BindArgValue : (FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 25. Specialize4: specialize function to static arguments pe-declare = ?|[ function f(x*) ta = e ]|; rules( SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*)) ; new => g; !e => e2 ; rules( Specialization.f :+ |[ function f(x*) ta = e’ ]| -> |[ function g(x2*) ta = let d* in e2 end ]| ) ) split-static-dynamic-args = zip; partition(BindArgValue); (not([]), unzip) BindArgValue : (FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e separate static from dynamic arguments http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 26. Specialize4: specialize function to static arguments pe-declare = ?|[ function f(x*) ta = e ]|; rules( SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*)) ; new => g; !e => e2 ; rules( Specialization.f :+ |[ function f(x*) ta = e’ ]| -> |[ function g(x2*) ta = let d* in e2 end ]| ) ) split-static-dynamic-args = zip; partition(BindArgValue); (not([]), unzip) BindArgValue : (FArg|[ x ta ]|, e) -> |[ var x ta := e ]| where <is-value> e separate static from dynamic arguments R :+ l -> r — dynamic rule with multiple right-hand sides http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 27. Specialize4: replace functions with their specialization pe-let = |[ let <*id> in <*id> end ]| ; {| PropConst, UnfoldCall, RetrieveUnfolding, Specialization : all(pe) ; |[ let <*filter(|[ <fd*:mapconcat(bagof-Specialization)> ]| <+ not(DeadBinding))> in <*id> end ]| |} ; try(EvalLet) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 28. Specialize4: replace functions with their specialization pe-let = |[ let <*id> in <*id> end ]| ; {| PropConst, UnfoldCall, RetrieveUnfolding, Specialization : all(pe) ; |[ let <*filter(|[ <fd*:mapconcat(bagof-Specialization)> ]| <+ not(DeadBinding))> in <*id> end ]| |} ; try(EvalLet) bagof-R: all rewritings of R http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 29. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)) end ⇓ let function a_0(x : int) : int = let var n : int := 5 in if n= 0 then 1 else if even(n) then square(power(x, n / 2)) else x * power(x, n - 1) end in printint(a_0(readint())) end http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 30. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)) end ⇓ let function a_0(x : int) : int = let var n : int := 5 in if n= 0 then 1 else if even(n) then square(power(x, n / 2)) else x * power(x, n - 1) end in printint(a_0(readint())) end Problem: body of specialized function is not transformed http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 31. Specialize5: reduce body of specialized function pe-declare = ?|[ function f(x*) ta = e ]|; rules( ... SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*)) ; new => g ; <pe>|[ let d* in e end ]| => e2 ; rules( Specialization.f :+ |[ function f(x*) ta = e’ ]| -> |[ function g(x2*) ta = e2 ]| ) ) http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 32. Specialize5: reduce body of specialized function pe-declare = ?|[ function f(x*) ta = e ]|; rules( ... SpecializeCall : |[ f(a1*) ]| -> |[ g(a2*) ]| where <split-static-dynamic-args> (x*, a1*) => (d*, (x2*, a2*)) ; new => g ; <pe>|[ let d* in e end ]| => e2 ; rules( Specialization.f :+ |[ function f(x*) ta = e’ ]| -> |[ function g(x2*) ta = e2 ]| ) ) transform instantiated body before declaring specialization http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 33. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)) end ⇓ let function a_0(x : int) : int function d_0(x : int) : int function e_0(x : int) : int function g_0(x : int) : int function h_0(x : int) : int in printint(a_0(readint())); print("n") end = = = = = x * d_0(x) square(e_0(x)) square(g_0(x)) x * h_0(x) 1 http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 34. let function square(x : int) : int = x * x function mod(x : int, y : int) : int = x - (x / y) * y function even(x : int) : int = mod(x, 2) = 0 function power(x : int, n : int) : int = if n = 0 then 1 else if even(n) then square(power(x, n/2)) else (x * power(x, n - 1)) in printint(power(readint(), 5)) end ⇓ let function a_0(x : int) : int function d_0(x : int) : int function e_0(x : int) : int function g_0(x : int) : int function h_0(x : int) : int in printint(a_0(readint())); print("n") end = = = = = x * d_0(x) square(e_0(x)) square(g_0(x)) x * h_0(x) 1 Problem: lots of ‘trivial’ functions generated http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 35. Cliffhanger ... Try to unfold as many functions as possible Doing to much will lead to non-termination How to control unfolding? http://www.strategoxt.org Strategies for Online Partial Evaluation
  • 36. Cliffhanger ... Try to unfold as many functions as possible Doing to much will lead to non-termination How to control unfolding? Next week: Memoization to catch calls to specializations in progress Offline partial evaluation: use binding time analysis to decide which calls to unfold and which to specialize http://www.strategoxt.org Strategies for Online Partial Evaluation