SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 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
 

Similar a 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
 

Más 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
 

Más 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
 

Último

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 

Último (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 

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