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

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. 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 June 22, 2017 Baptiste Saleil baptiste.saleil@umontreal.ca Marc Feeley feeley@iro.umontreal.ca

  2. I n t r o d u c t i o n  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 1

  3. I n t r o d u c t i o n  Dynamic languages  Work done at compilation  Work done at execution  Dynamic type checking  Ensures safety of the primitives :)  Impact on performance :( 2

  4. D y n a m i c t y p e c h e c k i n g  Example ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) 0 ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) 3

  5. D y n a m i c t y p e c h e c k i n g  Example ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) 0 ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) 4 type checks in this code 3

  6. D y n a m i c t y p e c h e c k i n g  Example ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) 0 ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) 4 type checks in this code  How can we remove them ? 3

  7. 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 ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) 0 ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) ( p r i n t ( s u m - t o - 1 0 6 ) ) ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) 4

  8. 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 ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) s u m - t o - 1 0 : 0 ( x : i n t ) ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) + i n t ( p r i n t ( s u m - t o - 1 0 6 ) ) ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) 4

  9. 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 ( d e f i n e ( s u m - t o - 1 0 x ) ( i f ( > x 1 0 ) s u m - t o - 1 0 : 0 ( x : i n t ) ( + x ( s u m - t o - 1 0 ( + x 1 ) ) ) ) ) + i n t ( p r i n t ( s u m - t o - 1 0 6 ) ) s u m - t o - 1 0 : ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ( x : f l o a t ) + f l o a t 4

  10. R u n n i n g E x a m p l e : H i g h e r o r d e r f u n c t i o n ( d e f i n e ( m a k e - s u m e r n ) Closure that captures n ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 5 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) )

  11. R u n n i n g E x a m p l e : H i g h e r o r d e r f u n c t i o n ( d e f i n e ( m a k e - s u m e r n ) Closure that captures n ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 5 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) )

  12. R u n n i n g E x a m p l e : H i g h e r o r d e r f u n c t i o n ( d e f i n e ( m a k e - s u m e r n ) → Static analysis (e.g. 0 -CFA) ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n ) 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 6 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) )

  13. R u n n i n g E x a m p l e : H i g h e r o r d e r f u n c t i o n ( d e f i n e ( m a k e - s u m e r n ) → Static analysis (e.g. 0 -CFA)  JIT incompatible ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n )  Lacks precision 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 6 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) )

  14. R u n n i n g E x a m p l e : H i g h e r o r d e r f u n c t i o n ( d e f i n e ( m a k e - s u m e r n ) → Static analysis (e.g. 0 -CFA)  JIT incompatible ( l e t r e c ( ( f ( l a m b d a ( x ) ( i f ( > x n )  Lacks precision 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 6 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) )

  15. 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 7

  16. 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 7

  17. 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 7

  18. 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 7

  19. 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 → 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

  20. N a i v e c o m p i l a t i o 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 ) 0 ( + x ( f ( + x 1 ) ) ) ) ) ) ) f ) ) ( d e f i n e s u m - t o - 1 0 ( m a k e - s u m e r 1 0 ) ) ( d e f i n e s u m - t o - p i ( m a k e - s u m e r 3 . 1 4 ) ) ; 6 + 7 + 8 + 9 + 1 0 ( p r i n t ( s u m - t o - 1 0 6 ) ) ; 7 . 5 + 8 . 5 + 9 . 5 ( p r i n t ( s u m - t o - 1 0 7 . 5 ) ) ; 1 . 1 0 + 2 . 1 0 + 3 . 1 0 ( p r i n t ( s u m - t o - p i 1 . 1 0 ) ) 8

Recommend


More recommend