COS 441 Exam Stuff David Walker. TAL 2 Logistics take-home exam will become available on the course web site Jan 15-18 write down when you download &

Slides:



Advertisements
Similar presentations
Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Advertisements

Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Type Inference David Walker COS 320. Criticisms of Typed Languages Types overly constrain functions & data polymorphism makes typed constructs useful.
Type Analysis and Typed Compilation Stephanie Weirich Cornell University.
The Semantic Soundness of a Type System for Interprocedural Register Allocation and Constructor Registration Torben Amtoft Kansas State University joint.
Programming Languages and Paradigms
Current Techniques in Language-based Security David Walker COS 597B With slides stolen from: Steve Zdancewic University of Pennsylvania.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Computer Architecture CSCE 350
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Procedures II (1) Fall 2005 Lecture 07: Procedure Calls (Part 2)
The University of Adelaide, School of Computer Science
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
Typed Assembly Languages COS 441, Fall 2004 Frances Spalding Based on slides from Dave Walker and Greg Morrisett.
Safety as a Software Metric Matthias Felleisen and Robert Corky Cartwright Rice University.
Survey of Typed Assembly Language (TAL) Introduction and Motivation –Conventional untyped compiler < Typed intermediate languages –Typed intermediate language.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
CS 536 Spring Code generation I Lecture 20.
Proofs, Types, and Safe Mobile Code CoS 598E David Walker.
Misc. Announcements Assignment available end of the day today –Due back in 11/03 (after break) Will also update slides on website –Today Midterm next week.
STAL David Walker (joint work with Karl Crary, Neal Glew and Greg Morrisett)
Wednesday, 10/9/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 10/9/02  QUESTIONS ??  Today:  Discuss HW #02  Discuss test question types  Review 
Run time vs. Compile time
8/14/03ALADDIN REU Symposium Implementing TALT William Lovas with Karl Crary.
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
MinML: an idealized programming language CS 510 David Walker.
A Type System for Expressive Security Policies David Walker Cornell University.
Type Inference David Walker COS 441. Criticisms of Typed Languages Types overly constrain functions & data polymorphism makes typed constructs useful.
Code Generation Compiler Baojian Hua
X86 ISA Compiler Baojian Hua Front End source code abstract syntax tree lexical analyzer parser tokens IR semantic analyzer.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Chapter TwelveModern Programming Languages1 Memory Locations For Variables.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
Types for Programs and Proofs Lecture 1. What are types? int, float, char, …, arrays types of procedures, functions, references, records, objects,...
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
CS212: Object Oriented Analysis and Design Lecture 10: Copy constructor.
Elements of Computing Systems, Nisan & Schocken, MIT Press, 2005, Chapter 11: Compiler II: Code Generation slide 1www.idc.ac.il/tecs.
Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County.
1 ICS 51 Introductory Computer Organization Fall 2009.
12/9/20151 Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC Based in part on slides by Mattox.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 21: Calling.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 10 – C: the heap and manual memory management.
CMSC 330: Organization of Programming Languages Lambda Calculus and Types.
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
CSCE 314 Programming Languages
Winter 2006CISC121 - Prof. McLeod1 Stuff Solution to midterm is posted. Marking has just started… Lab for this week is not posted (yet?). Final exam (full.
1 Assembly Language: Function Calls Jennifer Rexford.
CS5205Semantics1 CS5205: Foundation in Programming Languages Semantics Static Semantics Dynamic Semantics Operational Semantics Big-step Small-Step Denotational.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
Design issues for Object-Oriented Languages
Functional Programming
C function call conventions and the stack
Types for Programs and Proofs
CSE 374 Programming Concepts & Tools
143A: Principles of Operating Systems Lecture 4: Calling conventions
Introduction to Compilers Tim Teitelbaum
TALx86: A Realistic Typed Assembly Language
Introduction to programming languages, Algorithms & flowcharts
Introduction to Data Structures
Stack Frame Linkage.
Assembly Language Programming II: C Compiler Calling Sequences
Multi-modules programming
341 midterm review Xinrong Zhao Autumn 2018.
Scope, Function Calls and Storage Management
Programming Languages and Compilers (CS 421)
Presentation transcript:

COS 441 Exam Stuff David Walker

TAL 2 Logistics take-home exam will become available on the course web site Jan write down when you download & when you turn in 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

TAL 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)

TAL 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 , , 24) subtyping: subtyping relations, co-, contra-, and in-variance, subsumption rule, proving soundness of declarative system, showing subtyping rules are “bad”, don’t worry about relating declarative and algorithmic subtyping formally (Chap , ) class-based, object-oriented languages: featherweight Java (Chap ) applications of operational semantics & type systems: stack inspection stuff we cover today in lecture implementation of any of the concepts above

Typed Assembly Language David Walker Slides stolen from: Greg Morrisett

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

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

TAL 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

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

TAL 10 Type-Based Protection (JVM) Java Source javac JVM bytecodes JVM verifierSystem Interface Binary Optimizer Low-Level IL System Binary “Kernel”

TAL 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)

TAL 12 Ideally: Your favorite language Low-Level IL (SSA) optimizer machine code verifierSystem Interface System Binary “Kernel”

TAL 13 Rest of the Lecture: Examples TAL core types: bytes, tuples, code,  Control-Flow: calling conventions, stacks, exns I won’t get to: closures, objects, modules, type analysis, ADTs

TAL 14 Simple Built-In Types Bytes: b1, b2, b4 Tuples: (  1  1,…,  n  n )  Code: {r 1 :  1,…, r n :  n } like a pre-condition argument type of function no return type because code doesn’t really return, just jumps somewhere else... Polymorphic types:  . ,  . 

TAL 15 Simple Loop sum: {ecx:b4, ebx:{eax:b4}} ; int sum(int x) { moveax,0 ; int a = 0; jmptest ; loop: {eax:b4, ecx:b4, ebx:{eax:b4}} ; while(!x) { addeax,ecx ; a += x; dececx ; x--; FALLTHRU ; } test: {eax:b4, ecx:b4, ebx:{eax:b4}} ; cmpecx,0 ; jneloop ; return(a); jmpebx ; }

TAL 16 Allocation: mkpair: {eax:b4, ebx:{eax:(b4 1, b4 1 )}} movecx,eax MALLOCeax,8,(b4, b4) ; eax : (b4 0, b4 0 ) mov[eax+0],ecx ; eax : (b4 1, b4 0 ) mov[eax+4],ecx ; eax : (b4 1, b4 1 ) jmpebx

TAL 17 Callee-Saves Register addone: .{eax:b4, ecx: , ebx:{eax:b4, ecx:  }} inc eax ; x+1 jmpebx ; return main: {ebx:{eax:b4}} moveax,3 movecx,ebx ; save main’s return address movebx,done jmpaddone[{eax:b4}] done: {eax:b4,ecx:{eax:b4}} inceax jmpecx

TAL 18 In General: Need to save more stuff (e.g., locals): MALLOC ecx,4n,(  1,…,  n ) ; frame for storage mov[ecx+0],r1 … ; save locals mov[ecx+4n-4],rn jmpaddone[(  1,…,  n )] Heap-Allocated Activation Records

TAL 19 Stacks Want to use stack for activation frames. Stack types:  ::= nil |   ::  |  |   2

TAL 20 Typing Stack Operations { esp:  } { esp:  1  ::  2  ::…::  i  ::  } sub esp,i*4 add esp,i*4 { esp: b4 0 ::b4 0 ::…::b4 0 ::  } { esp :  { r: , esp:  1  ::  2  ::…::  i  ::  } { r: , esp:  } mov [esp+i*4],r push r { r: , esp:  1  ::  2  ::…::  1 ::  } { r:  esp:  1 ::  } { esp:  1  ::  2  ::…::  i 1 ::  } { esp:  1 ::  } mov r,[esp+i*4] pop r { r:  i, esp:  1  ::  2  ::…::  i 1 ::  } { r:  esp:  }

TAL 21 Recursion thru Stack Variables fact: .{eax:b4, esp:{eax:b4, esp:  }::  } cmpeax,1 jneL[  ] retn L:  ’.{eax:b4, esp:{eax:b4, esp:  ’}::  ’} pusheax deceax callfact[b4::{eax:b4, esp:  ’}::  ’] popecx imuleax,ecx retn

TAL 22 Fact Fact fact: .{eax:b4, esp:{eax:b4, esp:  }::  } Because  is abstract, fact cannot read or write this portion of the stack. Caller’s frame is protected from callee…

TAL 23 Scope, Closures, and Objects let foo : unit -> int = let seed = ref 42 in fun () -> (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.

TAL 24 Encoding “Private” Data:  foo :  .( ,  {eax: , esp:{eax:b4,esp:  }::  } ) Read: - there is some (abstract) type   - foo is a pair of an  value and a code pointer - the code requires the  value as an argument - no other  values can exist (i.e., you can’t forge the private data)

TAL 25 “Self” and Recursive Closures:  . .( ,  {eax: , esp:{eax:b4,esp:  }::  }) Read: - there is some (abstract) type   -  ( ,  {eax: , esp:{eax:b4,esp:  }::  }) - that is, the code takes the whole object as an argument

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

TAL 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