I n t e r p r
- c
e d u r a l S p e c i a l i z a t i
- n
- f
H i g h e r
- O
r d e r D y n a m i c L a n g u a g e s W i t h
- u
I n t e r p r o c e d u r a l S p e c i a l i - - PowerPoint PPT Presentation
I n t e r p r o c e d u r a l S p e c i a l i z a t i o n o f H i g h e r - O r d e r D y n a m i c L a n g u a g e s W i t h o u t S t a t i c A n a l y s i s ECOOP
1
Dynamic languages Dynamic techniques
Scheme and Functional Programming Workshop 2014 & 2015 https://github.com/bsaleil/lc
2
Work done at compilation Work done at execution
Ensures safety of the primitives :) Impact on performance :(
3
3
3
4
s u m
: ( x : i n t )
4
i n t
s u m
: ( x : i n t ) s u m
: ( x : f l
t )
4
i n t
f l
t
5
5
6
JIT incompatible Lacks precision
6
JIT incompatible Lacks precision
6
7
7
7
7
Simple and Efgective Type Check Removal through Lazy Basic
Block Versioning Maxime Chevalier-Boisvert and Marc Feeley, ECOOP 2015
Lazy intraprocedural code specialization (JIT) No static analysis Dynamic languages (JavaScript, Scheme, ...) 7
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
8
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
8
9
E n t r y p
n t S t u b 1
x : u n k n : u n k
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
E n t r y p
n t i n t ? x S t u b 2 S t u b 3
x : u n k n : u n k x : i n t n : u n k x : u n k n : u n k
t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
9
E n t r y p
n t i n t ? x i n t ? n S t u b 2 S t u b 4 S t u b 5
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : u n k n : u n k x : i n t n : u n k
t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? S t u b 2 S t u b 4 S t u b 6 S t u b 7
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? t 1 = x +
i n t
1 t 2 = f ( t 1 ) S t u b 2 S t u b 4 S t u b 6 S t u b 8
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : i n t t 2 : u n k x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? t 1 = x +
i n t
1 t 2 = f ( t 1 ) S t u b 2 S t u b 4 S t u b 8
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : i n t t 2 : u n k x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
r e t u r n
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? t 1 = x +
i n t
1 t 2 = f ( t 1 ) i n t ? t 2 S t u b 2 S t u b 4 S t u b 9 S t u b 1
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : i n t x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
r e t u r n
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? t 1 = x +
i n t
1 t 2 = f ( t 1 ) i n t ? t 2 S t u b 2 S t u b 4 S t u b 9
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : i n t x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
r e t u r n r e t u r n ( x +
i n t
t 2 )
9
E n t r y p
n t i n t ? x i n t ? n x >
i n t
n ? t 1 = x +
i n t
1 t 2 = f ( t 1 ) i n t ? t 2 r e t u r n ( x +
i n t
t 2 ) r e t u r n S t u b 2 S t u b 4 S t u b 9
x : u n k n : u n k x : i n t n : u n k x : i n t n : i n t x : i n t n : i n t x : u n k n : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : u n k x : i n t n : i n t t 2 : i n t x : i n t n : u n k x : i n t n : i n t
t r u e f a l s e t r u e f a l s e t r u e f a l s e t r u e f a l s e
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
9
10
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
10
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
10
11
11
11
11
12 v1 ... vn code address captured variable 1 ... captured variable n ... ...
13
Stub memory space Closure instances Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) ) 13
Stub memory space Closure instances Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) ) 12 13
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Generated code
13
14
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t )
14
( i n t ) ( f l
t )
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
14
( i n t ) ( f l
t )
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
14
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t )
m a k e
u m e r
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t ) ( f l
t )
m a k e
u m e r
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t ) ( f l
t )
m a k e
u m e r f
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t ) ( f l
t )
m a k e
u m e r f
15
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t ) ( f l
t )
m a k e
u m e r f
15
16
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
16
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) ) ( i n t )
m a k e
u m e r
16
( i n t )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) ) ( i n t ) ( f l
t )
m a k e
u m e r
16
( i n t ) ( f l
t )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
15
( i n t ) ( f l
t )
m a k e
u m e r f
16
( i n t ) ( f l
t )
Stub memory space Closure instances Entry point tables Generated code
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
15
( i n t ) ( f l
t )
m a k e
u m e r f
16
( i n t ) ( f l
t )
( d e f i n e ( m a k e
u m e r n ) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m
( m a k e
u m e r 1 ) ) ( d e f i n e s u m
i ( m a k e
u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m
6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m
7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m
i 1 . 1 ) )
Stub memory space Closure instances Entry point tables Generated code
( i n t ) ( f l
t )
( i n t ) ( f l
t )
15
m a k e
u m e r f
16
17
17
16
Propagated types → Type of the returned value Captured types → Type of the local variables
17
18
Intraprocedural BBV Interprocedural: function specialization Interprocedural: continuation specialization Interprocedural: function and continuation specialization
Number of type checks Generated code size Execution / Compilation / Total time
Number of executed type checks relative to pure intraprocedural specialization
19
No checks for 9 benchmarks Significantly fewer checks for most of the
Generated code size relative to pure intraprocedural specialization
20
Less code generated for half of the
Just 9% more code generated on average
Execution time relative to pure intraprocedural specialization
21
Almost all benchmarks are faster No benchmark is significantly slower Up to 2x faster
Execution time relative to the execution time of the code generated by the Gambit
Scheme compiler with dynamic checks turned off (capped at 400%) 22
Faster than Gambit with dynamic checks
Varies from 0.5x to 4x (6x slower with
Compilation time relative to pure intraprocedural BBV
23
Compilation time increase for most of
Mostly small increase in compilation
Total time relative to pure intraprocedural BBV
24
Large speedup for floating point (avoids
Most of the benchmarks are faster From 0.14x to 1.33x
25