Honest and Lying Types Thesis Proposal Ben Greenman 2019-11-25 - - PowerPoint PPT Presentation

honest and lying types
SMART_READER_LITE
LIVE PREVIEW

Honest and Lying Types Thesis Proposal Ben Greenman 2019-11-25 - - PowerPoint PPT Presentation

Honest and Lying Types Thesis Proposal Ben Greenman 2019-11-25 Committee: 1. Matthias Felleisen 2. Amal Ahmed 3. Jan Vitek 4. Shriram Krishnamurthi 5. Fritz Henglein 6. Sam Tobin-Hochstadt Honest and Lying Types Thesis Proposal Ben


slide-1
SLIDE 1

Honest and Lying Types

Thesis Proposal Ben Greenman 2019-11-25

slide-2
SLIDE 2

Committee:

  • 1. Matthias Felleisen
  • 2. Amal Ahmed
  • 3. Jan Vitek
  • 4. Shriram Krishnamurthi
  • 5. Fritz Henglein
  • 6. Sam Tobin-Hochstadt
slide-3
SLIDE 3

Honest and Lying Types

Thesis Proposal Ben Greenman 2019-11-25

slide-4
SLIDE 4

Thesis Proposal: "Gradual Typing" November 18, 2019 Thesis Proposal: "Gradual Typing" November 25, 2019

slide-5
SLIDE 5

Properties

Last Week:

slide-6
SLIDE 6

Properties Performance

Today:

slide-7
SLIDE 7

Properties Performance

Future:

People

slide-8
SLIDE 8

Migratory Typing

slide-9
SLIDE 9

Migratory Typing

Add types to a dynamically-typed language

U T U U T

Mixed-Typed code

U U U U U

Untyped code

slide-10
SLIDE 10

Migratory Typing

Add types to a dynamically-typed language

U T U U T

Mixed-Typed code

U

= untyped code

T

= simply-typed

slide-11
SLIDE 11

Motivation

Because lots of untyped code exists.

slide-12
SLIDE 12

Landscape of Models and Implementations

slide-13
SLIDE 13

Challenge = Interoperability

U T U U T

What do types mean when untyped values and typed values interact?

slide-14
SLIDE 14

Challenge = Interoperability

Int

U T

Listof Str

U T

slide-15
SLIDE 15

Challenge = Interoperability

Int

U T

Listof Str

U T

Nat -> Bool

T U

slide-16
SLIDE 16

Many Answers, Many Implementations

slide-17
SLIDE 17

Many Answers, Many Implementations Guarantees?

slide-18
SLIDE 18

Many Answers, Many Implementations Guarantees? Performance?

slide-19
SLIDE 19

Many Answers, Many Implementations Guarantees? Performance?

~ ~

Icons made by Freepik from Flaticon.com

slide-20
SLIDE 20

My Research

slide-21
SLIDE 21

Research Agenda: Scientifc Comparison

slide-22
SLIDE 22

Research Agenda: Scientifc Comparison Guarantees

λ τ →

  • ne syntax, many

semantics for what fows across channels

Performance

  • ne syntax, many

type-compilers

~

Icons made by Freepik from Flaticon.com

slide-23
SLIDE 23

Research Agenda: Results so Far Design Space Analysis

OOPSLA 19 Ben Greenman , Matthias Felleisen , and Christos Dimoulas ICFP 18 Ben Greenman and Matthias Felleisen

slide-24
SLIDE 24

Research Agenda: Results so Far Design Space Analysis

OOPSLA 19 Ben Greenman , Matthias Felleisen , and Christos Dimoulas ICFP 18 Ben Greenman and Matthias Felleisen

Performance Evaluation

JFP 19 Ben Greenman , Asumu Takikawa , Max S. New , Daniel Feltey , Robert Bruce Findler , Jan Vitek , and Matthias Felleisen PEPM 18 Ben Greenman and Zeina Migeed POPL 16 Asumu Takikawa , Daniel Feltey , Ben Greenman , Max S. New , Jan Vitek , and Matthias Felleisen

slide-25
SLIDE 25

Landscape: Guarantees

slide-26
SLIDE 26

Landscape: Guarantees

Dyn Soundness Tag Soundness Type Soundness Complete Monitoring (a total spectrum)

slide-27
SLIDE 27

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-28
SLIDE 28

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-29
SLIDE 29

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-30
SLIDE 30

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-31
SLIDE 31

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-32
SLIDE 32

Complete Monitoring Type Soundness Tag Soundness Dyn Soundness

slide-33
SLIDE 33

Complete Monitoring Type Soundness Tag Soundness Dyn Soundness Complete Monitoring Honest Type Soundness Tag Soundness Dyn Soundness

slide-34
SLIDE 34

Complete Monitoring Type Soundness Tag Soundness Dyn Soundness Complete Monitoring Honest Type Soundness Lying Tag Soundness Dyn Soundness

slide-35
SLIDE 35

Complete Monitoring Type Soundness Tag Soundness Dyn Soundness Complete Monitoring Honest Type Soundness Lying Tag Soundness Dyn Soundness Vacuous

slide-36
SLIDE 36

Honest vs. Lying Types

slide-37
SLIDE 37

Honest vs. Lying Types

(define path "/tmp/file.txt") (define (count acc str) (+ 1 acc)) (t-fold-file path 0 count) Client

U

(provide t-fold-file : (-> Path Num (-> Num Str Num) Num))) (define t-fold-file u-fold-file) API

T

slide-38
SLIDE 38

Honest vs. Lying Types

(define path "/tmp/file.txt") (define (count acc str) (+ 1 acc)) (t-fold-file path 0 count) Client

U

(provide t-fold-file : (-> Path Num (-> Num Str Num) Num))) (define t-fold-file u-fold-file) API

T

(define (u-fold-file path acc f) ... ; read `str` from `path` ... (f str acc) ... ...) Library

U

slide-39
SLIDE 39

Honest vs. Lying Types

(define path "/tmp/file.txt") (define (count acc str) (+ 1 acc)) (t-fold-file path 0 count) Client

U

(provide t-fold-file : (-> Path Num (-> Num Str Num) Num))) (define t-fold-file u-fold-file) API

T

(define (u-fold-file path acc f) ... ; read `str` from `path` ... (f str acc) ... ...) Library

U

slide-40
SLIDE 40

Honest vs. Lying Types

(define path "/tmp/file.txt") (define (count acc str) (+ 1 acc)) (t-fold-file path 0 count) Client

U

(provide t-fold-file : (-> Path Num (-> Num Str Num) Num))) (define t-fold-file u-fold-file) API

T

(define (u-fold-file path acc f) ... ; read `str` from `path` ... (f str acc) ... ...) Library

U

Do the API types protect the Client?

slide-41
SLIDE 41

Honest vs. Lying Types

(define path "/tmp/file.txt") (define (count acc str) (+ 1 acc)) (t-fold-file path 0 count) Client

U

(provide t-fold-file : (-> Path Num (-> Num Str Num) Num))) (define t-fold-file u-fold-file) API

T

(define (u-fold-file path acc f) ... ; read `str` from `path` ... (f str acc) ... ...) Library

U

Do the API types protect the Client? Honest ⇒ yes Lying ⇒ yes

slide-42
SLIDE 42

Landscape: Guarantees

Dyn Soundness Tag Soundness Type Soundness Complete Monitoring

slide-43
SLIDE 43

Landscape: Performance

slide-44
SLIDE 44

Landscape: Performance

Varied space, diffcult to rank alternatives

slide-45
SLIDE 45

Performance Comparison

ICFP 2018

Natural vs. Transient

slide-46
SLIDE 46

Performance Comparison

ICFP 2018

Natural vs. Transient

Complete Monitoring

guard all boundaries with deep checks

(listof int?)

Tag Soundness

rewrite typed code to tag-check inputs

list?

slide-47
SLIDE 47

Performance Comparison

ICFP 2018

Natural boundaries add "large"

  • verhead

Overhead

  • Num. Types

Transient types add "small"

  • verhead

Overhead

  • Num. Types
slide-48
SLIDE 48

= Untyped Perf. = Natural = Transient

slide-49
SLIDE 49

Thesis Question

slide-50
SLIDE 50

Dyn Soundness Tag Soundness Type Soundness Complete Monitoring

U T U U T

slide-51
SLIDE 51

Goal = Migratory Typing Problem = Performance

L

What to do?

slide-52
SLIDE 52

Goal = Migratory Typing Problem = Performance

L

slide-53
SLIDE 53

Goal = Migratory Typing Problem = Performance

L

Improve the compiler

slide-54
SLIDE 54

Goal = Migratory Typing Problem = Performance

L

Improve the compiler Build a new compiler

slide-55
SLIDE 55

Goal = Migratory Typing Problem = Performance

L

Improve the compiler Build a new compiler Build a new language

L'

slide-56
SLIDE 56

Goal = Migratory Typing Problem = Performance

L

Improve the compiler Build a new compiler Build a new language

L'

Interoperate with a weaker semantics

slide-57
SLIDE 57
  • Q. Does migratory typing beneft

from a combination of honest and lying types?

slide-58
SLIDE 58
  • Q. Does migratory typing beneft

from a combination of honest and lying types? In particular, Natural + Transient

slide-59
SLIDE 59

Complementary Strengths

Natural types predict full behavior, but need to avoid certain boundaries Transient types predict shapes, but add

  • verhead to all typed code
slide-60
SLIDE 60

Benefts (1/3): Migration

U T

U T

Lib

U T

+

  • 1. Begin with Natural types
  • 2. Switch to Transient for performance
  • 3. Revisit Natural for debugging
  • 4. Return to Natural after typing all

critical boundaries

slide-61
SLIDE 61

Benefts (2/3): Library Interaction

Lib

U T

U T

Lib

U T

+

slide-62
SLIDE 62

Benefts (2/3): Library Interaction

Lib

U T

U T

Lib

U T

+

math/array: "25 to 50 times slower"

slide-63
SLIDE 63

Benefts (2/3): Library Interaction

Lib

U T

U T

Lib

U T

+

Changing a library to Transient may improve

  • verall performance
slide-64
SLIDE 64

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

(define stx #`#,(vector 0 1)) (provide stx) A

T

(require A) stx B

U

slide-65
SLIDE 65

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

(define stx #`#,(vector 0 1)) (provide stx) A

T

(require A) stx B

U

Type Check: Ok

slide-66
SLIDE 66

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

(define stx #`#,(vector 0 1)) (provide stx) A

T

(require A) stx B

U

Type Check: Ok Runtime: Error could not convert type to a contract

slide-67
SLIDE 67

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

slide-68
SLIDE 68

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

Typed Racket provides 203 base types; 12 lack runtime support (wrappers)

slide-69
SLIDE 69

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

Typed Racket provides 203 base types; 12 lack runtime support (wrappers)

(Async-Channel T) (Custodian-Box T) (C-Mark-Key T) (Evt T) (Ephemeron T) (Future T) (MPair T T') (MList T) (Prompt-Tag T T') (Syntax T) (Thread-Cell T) (Weak-Box T)

slide-70
SLIDE 70

Benefts (3/3): Compatibility

+

U T

Lib

U T

+

Typed Racket provides 203 base types; 12 lack runtime support (wrappers) Transient does not need wrappers, so more code can run

slide-71
SLIDE 71

Plan

slide-72
SLIDE 72
  • Q. Does migratory typing beneft

from a combination of honest and lying types?

slide-73
SLIDE 73
  • Q. Does migratory typing beneft

from a combination of honest and lying types?

  • Q1. Can honest and lying types coexist?
  • Q2. Are the benefts measurably signifcant?
slide-74
SLIDE 74

λ τ →

  • Q1. Can honest and lying coexist?

Model:

  • develop a combined model
  • formally prove basic properties
  • reduce overlap in runtime checks

λ τ →

slide-75
SLIDE 75

λ τ →

  • Q1. Can honest and lying coexist?
slide-76
SLIDE 76

λ τ →

  • Q1. Can honest and lying coexist?

Implementation:

  • re-use the type checker
  • support all Racket values
  • avoid the contract library
  • adapt the TR optimizer to

lying types

slide-77
SLIDE 77
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

slide-78
SLIDE 78
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

Goal: min(Natural, Transient)

slide-79
SLIDE 79
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

slide-80
SLIDE 80
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

Maybe: reduce cost of U/T edge

U U U T T T T T

slide-81
SLIDE 81
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

Maybe: reduce cost of U/T edge

U U U T T T T T

How to fnd?

slide-82
SLIDE 82

How to measure performance?

POPL 2016 = 2 N measurements

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U

slide-83
SLIDE 83

How to measure performance?

ICFP 2018 = 2 (N+1) measurements

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U T T T U U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U T U T U T U U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U U T U U T U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T U T U T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T U T U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U U U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U

slide-84
SLIDE 84

How to measure performance?

Next = 3

N measurements?

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T T U U T T T U T U T T U T T U T U T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U T T T U U T T T U T U T T T U U T T T T T T T U U U T T U T U U T U T T U U U T T T U U T T U U T U T U T U T U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U T U T U T U U T T U T T U U U T T U T U U T T U U T U T T U U U T T T T T U U U U T U T U U U U T T U U U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U U T U U T U U T U U U T U T U U U U T T T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T T T U U T U U T T T T T U T U T U T T T U U U T U U U T U U U
slide-85
SLIDE 85

How to measure performance?

Next = 3

N measurements?

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U

T T T T T T T T T T T U T T T T U T T T T U T T T T U T T T T U T T T T U T T T T T T T T T U U T T T U T U T T U T T U T U T T T U U T T T T U T T T U U T T T U T U T T U T T U T U T T T U T T T U U T T T U T U T T U T T U T T T U U T T T U T U T T T U U T T T T T T T U U U T T U T U U T U T T U U U T T T U U T T U U T U T U T U T U U T T U T U T U U T T U U T U T T U U U T T T U T T U U U T T U T U U T U T T U U T T U U T U T U T U T U T U U T T U T T U U U T T U T U U T T U U T U T T U U U T T T T T U U U U T U T U U U U T T U U U T U U T U U U T U T U U U U T T U U T U U U T U U T U U T U U U T U T U U U U T T U T U U U U T U T U U U T U U T U U T U U U T U T U U U U T T T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T U U U U U U T T T U U T U U T T T T T U T U T U T T T U U U T U U U T U U U

Need an alternative method to measure performance

slide-86
SLIDE 86
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

slide-87
SLIDE 87
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

Goal: change lib, improve overall

U U Lib

slide-88
SLIDE 88
  • Q2. Are the benefts signifcant?

U U U T T T T T

T T U T T U U U Lib

Goal: change lib, improve overall

T T U T T U U U Lib

slide-89
SLIDE 89

λ τ →

U U U T T T T T

T T U T T U U U Lib

U T

Lib

U T

+

slide-90
SLIDE 90

Timeline

slide-91
SLIDE 91

[ ]

measure the performance of honest types

[ ]

try to directly improve performance

[ ]

formally classify alternative types

[ ]

develop a combined model, measure combined performance

slide-92
SLIDE 92

[ ]

measure the performance of honest types

JFP 2019 POPL 2016

[ ]

try to directly improve performance

OOPSLA 2018

[ ]

formally classify alternative types

OOPSLA 2019 ICFP 2018

[ ]

develop a combined model, measure combined performance

slide-93
SLIDE 93

Nov . . . Dec . . . Jan'20 . . . Feb . . . Mar . . . Apr . . . May . . . Jun . . . Jul . . . Aug . . . model implementation evaluation paper dissertation

slide-94
SLIDE 94

Nov . . . Dec . . . Jan'20 . . . Feb . . . Mar . . . Apr . . . May . . . Jun . . . Jul . . . Aug . . . model implementation evaluation paper dissertation

slide-95
SLIDE 95

Nov . . . Dec . . . Jan'20 . . . Feb . . . Mar . . . Apr . . . May . . . Jun . . . Jul . . . Aug . . . model implementation evaluation paper dissertation

#lang typed/racket/base #:locally-defensive (provide make-timeline) (require typed/racket/class typed/racket/draw typed/pict) (require/typed ppict/2 [#:opaque Coord refpoint-placer?] [coord (-> Real Real Symbol Coord)]) (require/typed "ppict-simple.rkt" [ppict (-> Pict (Listof (Pairof Coord Pict)) Pict)]) (require/typed pict-abbrevs [add-rounded-border (->* [Pict] [#:radius Real #:y-margin Real #:frame-width Real #:frame-color String] Pict)]) (define-type Pict pict) (: make-timeline-bar (-> Real Real (U #f String) (-> String Pict) Pict)) (define (make-timeline-bar w h label tcodesize) (define color (if label "light gray" "white")) (define bar (filled-rounded-rectangle w h 1 #:color color #:draw-border? #f)) (ppict bar (list (cons (coord 2/100 48/100 'lc) (tcodesize (or label "."))) (cons (coord 98/100 48/100 'rc) (tcodesize "."))))) (: make-timeline-span : (-> Real String (-> String Pict) (Instance Color%) Pict)) (define (make-timeline-span h label ct timeline-span-color) (define span-radius 7) (define bar-pict (filled-rounded-rectangle 25 h span-radius #:color timeline-span-color #:draw-border? #f)) (define label-pict (ct label)) (ht-append 10 bar-pict label-pict)) (: make-timeline (-> Real Real (Instance Color%) (-> String Pict) (-> String Pict) Pict)) (define (make-timeline w h timeline-span-color ct tcodesize) (let* ((month* '("Nov" "Dec" "Jan'20" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug")) (bar-h (/ h (* 2 (length month*)))) (make-span-h (lambda ((i : Real)) (* i bar-h))) (make-span-% (lambda ((i : Real)) (/ (make-span-h i) h))) (base (for/fold : Pict ((acc : Pict (blank))) ((m : String (in-list month*))) (vl-append 0 acc (make-timeline-bar w bar-h m tcodesize) (make-timeline-bar w bar-h #f tcodesize)))) (timeline (ppict base (list (cons (coord 14/100 (make-span-% 1) 'lt) (make-timeline-span (make-span-h 5) "model" ct timeline-span-color)) (cons (coord 29/100 0 'lt) (make-timeline-span (make-span-h 12) "implementation" ct timeline-span-color)) (cons (coord 44/100 (make-span-% 7) 'lt) (make-timeline-span (make-span-h 8) "evaluation" ct timeline-span-color)) (cons (coord 59/100 (make-span-% 11) 'lt) (make-timeline-span (make-span-h 4) "paper" ct timeline-span-color)) (cons (coord 74/100 (make-span-% 13) 'lt) (make-timeline-span (make-span-h 7) "dissertation" ct timeline-span-color)))))) (add-rounded-border #:radius 5 #:y-margin 6 #:frame-width 3 #:frame-color "slategray" timeline))) Timeline

T

slide-96
SLIDE 96

Nov . . . Dec . . . Jan'20 . . . Feb . . . Mar . . . Apr . . . May . . . Jun . . . Jul . . . Aug . . . model implementation evaluation paper dissertation

slide-97
SLIDE 97

The End

slide-98
SLIDE 98
slide-99
SLIDE 99
  • Q. Does migratory typing beneft

from a combination of honest and lying types?

slide-100
SLIDE 100
slide-101
SLIDE 101

Complete Monitoring

types predict behavior

Type Soundness

types predict behavior in typed code, nothing in untyped code

Tag Soundness

types predict shapes in typed code, nothing in untyped code

Dyn Soundness

types predict nothing

slide-102
SLIDE 102

= Untyped Perf. = Natural = Transient

slide-103
SLIDE 103

Expressiveness

DLS 18 Preston Tunnell Wilson , Ben Greenman , Justin Pombrio , and Shriram Krishnamurthi

slide-104
SLIDE 104

TR Optimizations

apply box dead-code extfonum fxnum foat-complex foat list number pair sequence string struct unboxed-let vector

slide-105
SLIDE 105

dead-code = unsafe for Transient

(: g (-> Str Str)) (define g (case-lambda [(x) x] [(x y) y])) (define g (case-lambda [(x) x] [(x y) (void)]))

Problem: untyped code can call (g 0 1)

slide-106
SLIDE 106

pair = unsound for Transient

(: x (Pairof (Pairof Nat Int) Str)) (cdar x) (unsafe-cdr (unsafe-car x))

Problem: no guarantee (car x) is a pair

slide-107
SLIDE 107

apply = safe but risky for Transient

(: h (-> Str Str)) (: xs (Listof Str)) (apply + (map h xs)) (+ (h (unsafe-car xs)) (h (unsafe-car (unsafe-cdr xs))) ...)

Caution: h must check inputs

slide-108
SLIDE 108

list sequence = force choice for ⌊T⌋

(: xs (List Str Str)) (list-ref xs 1) (unsafe-list-ref xs 1)

Note: ⌊List Str Str⌋ needs more than a tag check

slide-109
SLIDE 109

number = ⌊T⌋ is more than a tag check Natural Exact-Nonnegative-Integer Nonpositive-Inexact-Real ExtFlonum-Negative-Zero

slide-110
SLIDE 110

unboxed-let = safe with escape analysis

(: f (-> Float-Complex Any)) (define (f n) ....) (define (f n-real n-imag) ....)

slide-111
SLIDE 111

foat = false alarm

(flrandom) (unsafe-flrandom (current-pseudo-random-generator))

Ok because the PRNG parameter checks inputs