Instructor:
Steve Zdancewic    e-mail: cis341 (AT) seas.upenn.edu
    office hours: Thursdays 4:00-5:00pm (and by appointment) Levine 511
Teaching Assistants:
Dmitri Garbuzov      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Thursdays 1:30-3:30pm
Hongbo (Bob) Zhang
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Wednesday 3:00-5:00pm
Course information:
  time: TR 10:30-noon  room: Moore 216
  piazza: cis341
Prerequisites: CIS 121 and CIS 240
Topics:
- Lexing/Parsing
- Code generation
- Semantic analysis
- Optimization
- Run-time support
Reading and References
The following books contain useful course material, and much of the lecture content is derived from them (and other sources). Copies of these books are on reserve in the Penn Engineering Library.
- Compilers (2nd edition) by Aho, Lam, Sethi, and Ullman
- Advanced Compiler Design and Implementation by Muchnick
- Modern Compiler Implementation in ML by Appel
- OCaml Programming Style Guide
- The Caml Web Site, particularly the documentation and users' manual and the standard libraries
- Developing Applications with Objective Caml by Emmanuel Chailloux, Pascal Manoury and Bruno Pagano
- Introduction to Objective Caml by Jason Hickey
Projects: The Quaker OAT Compiler
There are a total of 8 projects. Project 0 is an individual project. The rest of the projects are pair-programming projects -- students are strongly encouraged to work in pairs, but may ask permission to work alone on them.
Here are instructions for getting access to the tools you need to complete course assignments.

- Project 0: Hellocaml
Due: Tuesday, January 22 at 11:59pm
- Project 1: X86lite
Due: Thursday, January 31 at 11:59pm
- Project 2: Parsing and Compiling Expressions
Due: Tuesday, February 12 at 11:59pm - Project 3: Control Flow
Due: Monday, February 25 at 11:59pm - Project 4: Procedures and Arrays
Due: Thursday, March 21 at 11:59pm - Project 5: Objects and Inheritance
Due: Monday, April 8 at 11:59pm - Project 6: Optimizations
Due:Thursday, April 18 at 11:59pm - Project 7: Fun with OAT programming
Due: Sunday, May 5 at 11:59pm
Grading Criteria
- 12% Midterm - Date: 28 Feb. 2013, in class.
SOLUTIONS
- Example Midterm (2008) and (partial) Solutions (2008)
- Example Midterm (2011) and (partial) Solutions (2011)
- 16% Final exam - Date: Tuesday, April 30th noon-2:00pm
- 72% Course projects (group projects)
Lecture Slides and Notes
Note: The following schedule is tentative!Date | Topic | Slides | Handouts |
---|---|---|---|
1/8 |
|
||
1/10 |
Introductions: Compilers, Interpreters, and OCaml | lec01.pdf |
Makefile foo.c simple.ml |
1/15* |
OCaml Crash Course | |
|
1/17 |
OCaml Modules / Bootstrapping Compilers / Metaprogramming | |
Lec02.zip |
1/22 |
X86lite | lec03.pdf |
Lec03.zip |
1/24 |
X86lite programming / C calling conventions | lec04.pdf |
Lec04.zip |
1/29 |
Lexing: DFAs and ocamllex | lec05.pdf |
Lec05.zip |
1/31 |
Parsing I: Context Free Grammars and ocamlyacc | lec06.pdf |
Lec06.zip |
2/5 |
Parsing II: LL(k) parsing, LR(0) parsing | lec07.pdf |
Lec07.zip |
2/7 |
Parsing III: LR parsing, ocamlyacc revisited | lec08.pdf |
Lec08.zip |
2/12 |
Intermediate Representations | lec09.pdf |
Lec09.zip |
2/14 |
LLVM IR, Contexts and Scoping | lec10.pdf |
|
2/19 |
Inference Rules, Compiling Control Flow | lec11.pdf |
oat0-defn.pdf scope.ml |
2/21 |
Structured Data | lec12.pdf |
|
2/26 |
Structured Data II, First-class Functions | lec13.pdf |
struct.c struct.ll |
2/28 |
Midterm Exam | |
|
3/5 |
no class | |
Spring Break |
3/7 |
no class | |
Spring Break |
3/12 |
First-class Functions: Interpretation and Typechecking | lec14.pdf |
fun.ml tc.ml |
3/14 |
Closure Conversion; Types and Subtypes | lec15.pdf |
fun-lec15.ml cc.ml |
3/19 |
Types II | lec16.pdf |
|
3/21 |
Objects and Dynamic Dispatch | lec17.pdf |
|
3/26 |
Multiple Inheritance, Typechecking Classes | lec18.pdf |
|
3/28 |
Typechecking OAT, Intro to Optimizations | lec19.pdf |
example.oat example.ll example.s example-opt.s example-hand.s |
4/2 |
Optimizations | lec20.pdf |
|
4/4 |
Dataflow Analysis I | lec21.pdf |
|
4/9 |
Dataflow Analysis II | lec22.pdf |
|
4/11 |
Control Flow Analysis, SSA with Phi nodes | lec23.pdf |
|
4/16 |
Register Allocation, Manual Memory Management | lec24.pdf |
|
4/18 |
Garbage Collection | lec25.pdf |
|
4/23 |
Reference Counts / Oat Programming / Course Wrap-up | lec26.pdf |
|
4/30 |
Final Exam | |
Many of the slides in these lectures have been adapted (with permission) from course materials by Andrew Myers at Cornell University and Greg Morrisett at Harvard University.

Course Policies
General Project Guidelines
- Groups:
Teams for group projects will consist of one or two students. - Difficulty:
The course projects are challenging and time consuming. They may require significant effort to understand the implementation details and concepts:Start Early! - Late Projects:
All projects are due at 11:59pm on the due date. Late projects will be penalized as follows: projects up to two days late will receive a penalty of 10% of the total score, projects later than that will receive no credit.Students with legitimate excuses (illness, family emergencies, etc.) can request an extension. Please try to let the course staff know as soon as you are aware that your project might be late.
- Regrade Policy:
Regrade requests should be sent to the TA. Only reasonable requests will be considered. The entire project or exam will be regraded. Note that this means that the score on a regraded project might decrease.
Submission Policy
- Projects that do not compile will get no credit.
- Projects that compile will receive partial credit according to the grading guidelines provided in the project description.
- It is fine to submit a project multiple times. Only the last project submitted will count for grading purposes.
-
All projects should include a team.txt file that includes
the following information:
Team Members: pennkey name email Known issues with your implementation: ------------------------ Course Project Feedback: ------------------------ 1. How much time did it take to complete this project? 2. How effective was this project? [0-10]: 0 = learned nothing 10 = highly educational 3. How engaging was this project? [0-10]: 0 = tedious and boring 10 = fun and engaging 4. How difficult was this project? [0-10]: 0 = piece of cake 10 = extremely hard (note that hard is not necessarily bad, if it's "hard" as in "challenging") [Feel free to add comments about this project]
Academic Integrity
This course will abide by the University's Code of Academic Integrity. In particular, for individual projects and group projects, the following guidelines should be followed:- For individual projects, you must type in and edit
your own code, documentation, and any other materials submitted
for grading.
- Copying someone else's file is not allowed.
- Allowing someone else to copy a file of yours, either explicitly or implicitly by leaving your code unprotected, is not allowed.
- Editing each other's files is not allowed
- Regarding the ethics of what you may or may not discuss with
others:
- "High level" discussions are fine.
For example, discussions about the problem statement. - "Low level" discussions are fine.
For example, discussions about OCaml syntax or using omake, understanding compiler error messages, understanding the mechanics of the tools and libraries used for the projects. - "Mid level" discussions require
discretion. In this CIS course, discussions at this
level must be limited. Unless explicitly stated
otherwise, you may not collaborate significantly with
classmates (except group project members) at this level.
If you have minor discussions with others at this level or get
help from outside resources (tutors, web sites, etc), you must
cite in the readme of the submitted projects the names of the
people or websites who helped you and how they did. For
example:
Name: Chris Brown Email: ***@seas.upenn.edu I received tips from Jo Johnson on the i/o and example.com/mem.htm on memory ...
- "High level" discussions are fine.
- If there is any doubt about the use of external sources or collaboration, please ask for clarification by the course staff.