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
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

t S t a t i c A n a l y s i s

Baptiste Saleil baptiste.saleil@umontreal.ca Marc Feeley feeley@iro.umontreal.ca ECOOP June 22, 2017

slide-2
SLIDE 2

I n t r

  • d

u c t i

  • n

1

 Research on JIT compilation

 Dynamic languages  Dynamic techniques

 LC: Research oriented Scheme compiler

 Scheme and Functional Programming Workshop 2014 & 2015  https://github.com/bsaleil/lc

slide-3
SLIDE 3

I n t r

  • d

u c t i

  • n

2

 Dynamic languages

 Work done at compilation  Work done at execution

 Dynamic type checking

 Ensures safety of the primitives :)  Impact on performance :(

slide-4
SLIDE 4

D y n a m i c t y p e c h e c k i n g

3

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) )

 Example

slide-5
SLIDE 5

D y n a m i c t y p e c h e c k i n g

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) )

4 type checks in this code

 Example

3

slide-6
SLIDE 6

D y n a m i c t y p e c h e c k i n g

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) )

 Example  How can we remove them ?

4 type checks in this code

3

slide-7
SLIDE 7

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

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) ) ( p r i n t ( s u m

  • t
  • 1

6 ) ) ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) )

4

slide-8
SLIDE 8

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

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) ) ( p r i n t ( s u m

  • t
  • 1

6 ) ) ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) )

s u m

  • t
  • 1

: ( x : i n t )

4

+

i n t

slide-9
SLIDE 9

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

( d e f i n e ( s u m

  • t
  • 1

x ) ( i f ( > x 1 ) ( + x ( s u m

  • t
  • 1

( + x 1 ) ) ) ) ) ( p r i n t ( s u m

  • t
  • 1

6 ) ) ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) )

s u m

  • t
  • 1

: ( x : i n t ) s u m

  • t
  • 1

: ( x : f l

  • a

t )

4

+

i n t

+

f l

  • a

t

slide-10
SLIDE 10

R u n n i n g E x a m p l e : H i g h e r

  • r

d e r f u n c t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

5

Closure that captures n

slide-11
SLIDE 11

R u n n i n g E x a m p l e : H i g h e r

  • r

d e r f u n c t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Closure that captures n

5

slide-12
SLIDE 12

6

R u n n i n g E x a m p l e : H i g h e r

  • r

d e r f u n c t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

→ Static analysis (e.g. 0-CFA)

slide-13
SLIDE 13

→ Static analysis (e.g. 0-CFA)

 JIT incompatible  Lacks precision

R u n n i n g E x a m p l e : H i g h e r

  • r

d e r f u n c t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

6

slide-14
SLIDE 14

R u n n i n g E x a m p l e : H i g h e r

  • r

d e r f u n c t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

→ Static analysis (e.g. 0-CFA)

 JIT incompatible  Lacks precision

6

slide-15
SLIDE 15

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

t S t a t i c A n a l y s i s

7

slide-16
SLIDE 16

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

t S t a t i c A n a l y s i s

7

slide-17
SLIDE 17

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

t S t a t i c A n a l y s i s

7

slide-18
SLIDE 18

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

t S t a t i c A n a l y s i s

7

slide-19
SLIDE 19

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

t S t a t i c A n a l y s i s

→ Basic Block Versioning (BBV)

 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

slide-20
SLIDE 20

N a i v e c

  • m

p i l a t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

8

slide-21
SLIDE 21

N a i v e c

  • m

p i l a t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

5 checks needed

8

slide-22
SLIDE 22

B a s i c B l

  • c

k V e r s i

  • n

i n g

9

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

slide-23
SLIDE 23

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

9

slide-24
SLIDE 24

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

9

slide-25
SLIDE 25

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

9

slide-26
SLIDE 26

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

9

slide-27
SLIDE 27

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

r e t u r n

9

slide-28
SLIDE 28

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

r e t u r n

9

slide-29
SLIDE 29

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

r e t u r n r e t u r n ( x +

i n t

t 2 )

9

slide-30
SLIDE 30

B a s i c B l

  • c

k V e r s i

  • n

i n g

E n t r y p

  • i

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

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

3 checks needed (2 removed)

9

slide-31
SLIDE 31

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

10

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

2 checks needed (3 removed)

  • Propagate the types through

function calls → no check on x

slide-32
SLIDE 32

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

1 check needed (4 removed)

  • Propagate the types through

function calls → no check on x

  • Propagate the types through

function returns → no check on the returned value

10

slide-33
SLIDE 33

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

  • Propagate the types through

function calls → no check on x

  • Propagate the types through

function returns → no check on the returned value

  • Specialize the code using

captured information → no check on n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

no checks needed (5 removed)

10

slide-34
SLIDE 34

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

11

→ Several entry points, each specialized for a type combination

  • 1. Extend the closure representation
  • Allow to store several entry points instead of 1
  • 2. Dynamic dispatch to jump to the entry point
  • Each function call
  • Each function return (each continuation call)
  • 3. Specialize using captured information
slide-35
SLIDE 35

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

→ Several entry points, each specialized for a type combination

  • 1. Extend the closure representation
  • Allow storing multiple entry points instead of 1
  • 2. Dynamic dispatch to jump to the entry point
  • Each function call
  • Each function return (each continuation call)
  • 3. Specialize using captured information

11

slide-36
SLIDE 36

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

→ Several entry points, each specialized for a type combination

  • 1. Extend the closure representation
  • Allow storing multiple entry points instead of 1
  • 2. Dynamic dispatch to jump to the entry point
  • Each function call
  • Each function return (each continuation call)
  • 3. Specialize using captured information

11

slide-37
SLIDE 37

O u r w

  • r

k : I n t e r p r

  • c

e d u r a l E x t e n s i

  • n

s

→ Several entry points, each specialized for a type combination

  • 1. Extend the closure representation
  • Allow storing multiple entry points instead of 1
  • 2. Dynamic dispatch to jump to the entry point
  • Each function call
  • Each function return (each continuation call)
  • 3. Specialize using captured information

11

slide-38
SLIDE 38

I m p l e m e n t a t i

  • n

Closure representation extension

slide-39
SLIDE 39

F l a t c l

  • s

u r e r e p r e s e n t a t i

  • n

12 v1 ... vn code address captured variable 1 ... captured variable n ... ...

slide-40
SLIDE 40

F l a t c l

  • s

u r e r e p r e s e n t a t i

  • n

13

Stub memory space Closure instances Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

slide-41
SLIDE 41

F l a t c l

  • s

u r e r e p r e s e n t a t i

  • n

Stub memory space Closure instances Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) ) 13

slide-42
SLIDE 42

F l a t c l

  • s

u r e r e p r e s e n t a t i

  • n

Stub memory space Closure instances Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) ) 12 13

slide-43
SLIDE 43

F l a t c l

  • s

u r e r e p r e s e n t a t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Generated code

13

slide-44
SLIDE 44

I m p l e m e n t a t i

  • n

: F l a t c l

  • s

u r e e x t e n s i

  • n

14

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

slide-45
SLIDE 45

I m p l e m e n t a t i

  • n

: F l a t c l

  • s

u r e e x t e n s i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t )

14

slide-46
SLIDE 46

I m p l e m e n t a t i

  • n

: F l a t c l

  • s

u r e e x t e n s i

  • n

( i n t ) ( f l

  • a

t )

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

14

slide-47
SLIDE 47

I m p l e m e n t a t i

  • n

: F l a t c l

  • s

u r e e x t e n s i

  • n

( i n t ) ( f l

  • a

t )

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

14

slide-48
SLIDE 48

I m p l e m e n t a t i

  • n

Dynamic dispatch

slide-49
SLIDE 49

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

15

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

slide-50
SLIDE 50

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

15

slide-51
SLIDE 51

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t )

m a k e

  • s

u m e r

15

slide-52
SLIDE 52

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r

15

slide-53
SLIDE 53

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r f

15

slide-54
SLIDE 54

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r f

15

slide-55
SLIDE 55

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

I m p l e m e n t a t i

  • n

: D y n a m i c d i s p a t c h

Stub memory space Closure instances Entry point tables Generated code

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r f

15

slide-56
SLIDE 56

I m p l e m e n t a t i

  • n

Captured information

slide-57
SLIDE 57

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

16

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

slide-58
SLIDE 58

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

16

slide-59
SLIDE 59

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) ) ( i n t )

m a k e

  • s

u m e r

16

( i n t )

slide-60
SLIDE 60

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) ) ( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r

16

( i n t ) ( f l

  • a

t )

slide-61
SLIDE 61

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

15

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r f

16

( i n t ) ( f l

  • a

t )

slide-62
SLIDE 62

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

Stub memory space Closure instances Entry point tables Generated code

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

15

( i n t ) ( f l

  • a

t )

m a k e

  • s

u m e r f

16

( i n t ) ( f l

  • a

t )

slide-63
SLIDE 63

I m p l e m e n t a t i

  • n

: C a p t u r e d i n f

  • r

m a t i

  • n

( d e f i n e ( m a k e

  • s

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

  • t
  • 1

( m a k e

  • s

u m e r 1 ) ) ( d e f i n e s u m

  • t
  • p

i ( m a k e

  • s

u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 ( p r i n t ( s u m

  • t
  • 1

6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m

  • t
  • 1

7 . 5 ) ) ; 1 . 1 + 2 . 1 + 3 . 1 ( p r i n t ( s u m

  • t
  • p

i 1 . 1 ) )

Stub memory space Closure instances Entry point tables Generated code

( i n t ) ( f l

  • a

t )

( i n t ) ( f l

  • a

t )

15

m a k e

  • s

u m e r f

16

slide-64
SLIDE 64

I m p l e m e n t a t i

  • n

17

 What about continuations ?

slide-65
SLIDE 65

I m p l e m e n t a t i

  • n

 What about continuations ? → Function return is a call to the continuation → Conceptually same implementation !

17

slide-66
SLIDE 66

I m p l e m e n t a t i

  • n

16

 What about continuations ? → Function return is a call to the continuation → Conceptually same implementation !

 Propagated types → Type of the returned value  Captured types → Type of the local variables

17

slide-67
SLIDE 67

R E S U L T S

slide-68
SLIDE 68

R e s u l t s

18

 35 benchmarks: Standard Scheme benchmarks  Confjgurations

 Intraprocedural BBV  Interprocedural: function specialization  Interprocedural: continuation specialization  Interprocedural: function and continuation specialization

 Metrics

 Number of type checks  Generated code size  Execution / Compilation / Total time

slide-69
SLIDE 69

N u m b e r

  • f

t y p e c h e C k s

 Number of executed type checks relative to pure intraprocedural specialization

19

 No checks for 9 benchmarks  Significantly fewer checks for most of the

benchmarks

slide-70
SLIDE 70

C

  • d

e s i z e

 Generated code size relative to pure intraprocedural specialization

20

 Less code generated for half of the

benchmarks

 Just 9% more code generated on average

slide-71
SLIDE 71

E x e c u t i

  • n

t i m e

 Execution time relative to pure intraprocedural specialization

21

 Almost all benchmarks are faster  No benchmark is significantly slower  Up to 2x faster

slide-72
SLIDE 72

E x e c u t i

  • n

t i m e ( v s G a m b i t )

 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

turned on

 Varies from 0.5x to 4x (6x slower with

Gambit executing all the checks)

slide-73
SLIDE 73

C

  • m

p i l a t i

  • n

t i m e

 Compilation time relative to pure intraprocedural BBV

23

 Compilation time increase for most of

the benchmarks

 Mostly small increase in compilation

time, but up to 4x

slide-74
SLIDE 74

T

  • t

a l t i m e

 Total time relative to pure intraprocedural BBV

24

 Large speedup for floating point (avoids

boxing)

 Most of the benchmarks are faster  From 0.14x to 1.33x

slide-75
SLIDE 75

C O N C L U S I O N

slide-76
SLIDE 76

C

  • n

c l u s i

  • n

 Lazy interprocedural specialization  Works well

Checks removed (up to 100%)

Faster code (up to 50%)

 Simple

Simple to implement

Does not require complex architecture

25

slide-77
SLIDE 77

 Propagating other properties

Value (e.g. x = 1 )

Variable relationship (e.g. x < y )

 Function identity and return address propagation

Dynamic function inlining

 Register allocation information

Arguments

Returned value

F u t u r e w

  • r

k