COS 441 Exam Stuff - PowerPoint PPT Presentation

About This Presentation
Title:

COS 441 Exam Stuff

Description:

take-home exam will become available on the course web site Jan 15-18 ... hype: $, tools, libraries, books, training. Cons: trusted computing base includes JIT ... – PowerPoint PPT presentation

Number of Views:16
Avg rating:3.0/5.0
Slides: 25
Provided by: gregm166
Category:
Tags: cos | exam | hype | stuff

less

Transcript and Presenter's Notes

Title: COS 441 Exam Stuff


1
COS 441 Exam Stuff
  • David Walker

2
Logistics
  • take-home exam will become available on the
    course web site Jan 15-18
  • write down when you download when you turn in
  • email to kenny or deliver to his office by hand
  • you have 24 hours to complete the exam
  • content anything from class, assignments, or
    assigned textbook readings

3
Content Pre-midterm
  • Judgments, inductive definitions, proofs by
    induction (Chapter 3)
  • Intuitionistic logic formulas, proofs, proof
    checking the Curry-Howard isomorphism
  • Untyped lambda calculus, operational semantics,
    properties, encodings (Chapter 5)
  • Typed lambda calculus syntax, operational
    semantics, typing rules, properties including
    type safety, progress, preservation, canonical
    forms, substitution, inversion principles, etc.
    (Chapter 8,9,11)
  • Typed datastructures tuples, sums (Chapter 11)
  • Implementation of programming language concepts
    (syntax, substitution, operational semantics,
    type checking)

4
Content Post-midterm
  • recursive types (Chap 20.1, 20.2)
  • effectful computations  references, exceptions,
    semantics using evaluation contexts (Chap 13,14
    evaluation contexts note above)
  • quantified types  universal polymorphism,
    existential types, type inference (Chap
    22.1-22.6, 23.1-23.5, 24)
  • subtyping subtyping relations, co-, contra-, and
    in-variance, subsumption rule, proving soundness
    of declarative system, showing subtyping rules
    are bad, dont worry about relating declarative
    and algorithmic subtyping formally (Chap 15.1-5,
    16.1-3)
  • class-based, object-oriented languages 
    featherweight Java (Chap 19.1-19.5)
  • applications of operational semantics type
    systems  stack inspection
  • stuff we cover today in lecture
  • implementation of any of the concepts above

5
Typed Assembly Language
  • David Walker
  • Slides stolen from
  • Greg Morrisett

6
Types
  • Type systems for programming languages are a
    syntactic mechanism for enforcing abstraction.
  • J. Reynolds

7
What is TAL?
  • A type system for assembly language(s)
  • built-in abstractions (tuple,code)
  • operators to build new abstractions (?,?,l)
  • annotations on assembly code
  • an abstraction checker
  • Thm well-annotated code cannot violate
  • abstractions.

8
What We Did popl 98, toplas 99 others
  • Theory
  • small RISC-style assembly language
  • compiler from System F to TAL
  • soundness and preservation theorems
  • Practice
  • most of IA32 (32-bit Intel x86)
  • more type constructors
  • everything you can think of and more
  • safe C compiler
  • 40,000LOC compiles itself

9
Why Type Assembly?
  • Theory
  • simplifies proofs of compiler correctness
  • deeper understanding of compilation
  • Practice
  • compiler debugging
  • software-based protection

10
Type-Based Protection (JVM)
JVM verifier
System Interface
Low-Level IL
Java Source
Kernel
javac
Optimizer
JVM bytecodes
System Binary
Binary
11
JVM Pros Cons
  • Pros
  • portable
  • hype , tools, libraries, books, training
  • Cons
  • trusted computing base includes JIT
  • requires many run-time tests
  • down casts, arrays, null pointers, etc.
  • only suitable for Java (too high-level)
  • no formal spec (when we started with TAL)

12
Ideally
verifier
System Interface
Your favorite language
Low-Level IL (SSA)
System Binary
Kernel
optimizer
machine code
13
Rest of the Lecture Examples
  • TAL core types
  • bytes, tuples, code,?
  • Control-Flow
  • calling conventions, stacks, exns
  • I wont get to
  • closures, objects, modules, type analysis, ADTs

14
Simple Built-In Types
  • Bytes b1, b2, b4
  • Tuples (t1f1,,tnfn) (f 0,1)
  • Code r1t1,, rntn
  • like a pre-condition
  • argument type of function
  • no return type because code doesnt really
    return, just jumps somewhere else...
  • Polymorphic types ?a.t, ?a.t

15
Simple Loop
  • sum ecxb4, ebxeaxb4
    int sum(int x)
  • mov eax,0
    int a 0
  • jmp test
  • loop eaxb4, ecxb4, ebxeaxb4
    while(!x)
  • add eax,ecx
    a x
  • dec ecx
    x--
  • FALLTHRU
  • test eaxb4, ecxb4, ebxeaxb4
  • cmp ecx,0
  • jne loop
    return(a)
  • jmp ebx

16
Allocation
  • mkpair eaxb4, ebxeax(b41, b41)
  • mov ecx,eax
  • MALLOC eax,8,(b4, b4) eax (b40, b40)
  • mov eax0,ecx eax (b41, b40)
  • mov eax4,ecx eax (b41, b41)
  • jmp ebx

17
Callee-Saves Register
  • addone ?a.eaxb4, ecxa, ebxeaxb4, ecxa
  • inc eax x1
  • jmp ebx return
  • main ebxeaxb4
  • mov eax,3
  • mov ecx,ebx save mains return address
  • mov ebx,done
  • jmp addoneeaxb4
  • done eaxb4,ecxeaxb4
  • inc eax
  • jmp ecx

18
In General
  • Need to save more stuff (e.g., locals)
  • MALLOC ecx,4n,(t1,,tn) frame for storage
  • mov ecx0,r1
  • save locals
  • mov ecx4n-4,rn
  • jmp addone(t1,,tn)

Heap-Allocated Activation Records
19
Stacks
  • Want to use stack for activation frames.
  • Stack types
  • s nil tfs r s1 _at_ s2

20
Typing Stack Operations
  • esp s esp
    t1ft2ftifs
  • sub esp,i4 add esp,i4
  • esp b40b40b40s esp s
  • r t, esp t1ft2ftifs r t,
    esp s
  • mov espi4,r push r
  • r t, esp t1ft2ft1s r t,
    esp t1s
  • esp t1ft2fti1s esp
    t1s
  • mov r,espi4 pop r
  • r ti, esp t1ft2fti1s r t,
    esp s

21
Recursion thru Stack Variables
  • fact ?r.eaxb4, espeaxb4, esprr
  • cmp eax,1
  • jne Lr
  • retn
  • L?r.eaxb4, espeaxb4, esprr
  • push eax
  • dec eax
  • call factb4eaxb4, esprr
  • pop ecx
  • imul eax,ecx
  • retn

22
Fact Fact
  • fact ?r.eaxb4, espeaxb4, esprr
  • Because r is abstract, fact cannot read or write
    this portion of the stack.
  • Callers frame is protected from callee

23
Scope, Closures, and Objects
  • let foo unit -gt int
  • let seed ref 42
  • in fun () -gt (seed !seed 1 !seed)
  • final class Foo
  • private int seed 42
  • public int foo() return(seed)
  • In both cases, seed is private to the code foo.

24
Encoding Private Data ?
  • foo ?a.( a, ?r.eaxa, espeaxb4,esprr )
  • Read
  • - there is some (abstract) type a
  • - foo is a pair of an a value and a code
    pointer
  • - the code requires the a value as an argument
  • - no other a values can exist
  • (i.e., you cant forge the private data)

25
Self and Recursive Closures
  • ?a.mg.(a,?r.eaxg, espeaxb4,esprr)
  • Read
  • - there is some (abstract) type a
  • - g (a,?r.eaxg, espeaxb4,esprr)
  • - that is, the code takes the whole object as
  • an argument

26
Other TAL Features
  • Module system
  • interfaces, implementations, ADTs
  • Sum type/datatype support
  • Fancy arrays/vector typing
  • (Higher Order) Type constructors
  • Fault tolerance checking
  • Other people still writing papers about more ...

27
Long Term?
  • Low-level, portable, safe language
  • OO-support of Java
  • typing support of ML
  • programmer control of C
  • good model of space
  • good model of running time
  • many optimizations expressible in the language
  • Microsoft research working on a new compiler
    (Phoenix) to generate TAL
Write a Comment
User Comments (0)
About PowerShow.com