Instructor:
Steve Zdancewic    e-mail: cis341 (AT) seas.upenn.edu
    office hours: Tuesday 3:30-5:00pm (and by appointment) Levine 511
Teaching Assistants:
Dmitri Garbuzov      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Thursday 3:30-5pm, Levine 5th floor
Rohan Shah
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Monday 5-7pm, Levine 5th floor
Mitchell Stern
      e-mail: cis341 (AT) seas.upenn.edu
      office hours: Wednesday 6-7:30pm, Levine 5th floor
Course information:
  time: noon - 1:30  room: Towne 321
  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).
- Compilers (2nd edition) by Aho, Lam, Sethi, and Ullman
- Advanced Compiler Design and Implementation by Muchnick
- Modern Compiler Implementation in ML by Appel
- Real World OCaml
- OCaml Programming Style Guide
- The Caml Web Site, particularly the documentation and users' manual and the standard libraries
- OCaml.org
- 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 homework projects. Homework 1 is an individual assignment. 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.

- Homework 1: Hellocaml
Due: Thursday, January 22 at 11:59pm - Homework 2: X86lite
Due: Monday, February 2 at 11:59pm - Homework 3: Compiling LLVMlite
Due: Monday, February 23 at 11:59pm - Homework 4: Compiling Oat v.1
Due: Thursday, March 26th at 11:59pm - Homework 5: Full Oat - Classes and Objects
Due: Monday, April 6th at 11:59pm - Homework 6: Dataflow Analysis and Optimizations
Due: Monday, April 20th at 11:59pm - Homework 7: Optimization and Experiments
Due: Wednesday, April 29th at 11:59pm
Grading Criteria
- 12% Midterm - Date: March 5th , in class.
- Midterm (2015) and Solutions (2015)
- Midterm (2008) and (partial) Solutions (2008)
- Midterm (2011) and (partial) Solutions (2011)
- Midterm (2013) and (partial) Solutions (2013)
- 16% Final exam - Date: TBA
- Final Exam (2008) and (partial) solution
- Final Exam (2013) and (partial) solution
- 72% Course projects (group projects)
Lecture Slides and Notes
Note: The following schedule is tentative!Date | Topic | Slides | Handouts |
---|---|---|---|
1/13 |
|
||
1/15 |
Introductions: Compilers, Interpreters, and OCaml | lec01.pdf |
lec01.zip |
1/20 |
OCaml Crash Course: Translating Simple to OCaml | lec02.pdf |
lec02.zip |
1/22 |
X86lite Metaprogramming | lec03.pdf |
lec03.zip |
1/27 |
X86lite programming / C calling conventions | lec04.pdf |
lec04.zip |
1/29 |
Intermediate Representations I | lec05.pdf |
lec05.zip |
2/3 |
Intermediate Representations II | lec06.pdf |
See ir3.ml, ir4.ml and,ir4.ml in lec05.zip |
2/5 |
Structured Data | lec07.pdf |
lec07.zip |
2/10 |
Structured Data in the LLVM IR, LLVMlite | lec08.pdf |
|
2/12 |
Lexing: DFAs and ocamllex | lec09.pdf |
lec09.zip |
2/17 |
Parsing I: Context Free Grammars | lec10.pdf |
lec10.zip |
2/19 |
Parsing II: LL(k) parsing, LR(0) parsing | lec11.pdf |
lec11.zip |
2/24 |
Parsing III: LR(1) Parsing and Menhir | lec12.pdf |
lec12.zip |
2/26 |
Typechecking: Inference Rules | (none) |
oat0-defn.pdf |
3/3 |
Type-directed Compilation | lec14.pdf |
|
3/5 |
Midterm Exam | |
|
3/10 |
no class | |
Spring Break |
3/12 |
no class | |
Spring Break |
3/17 |
First-class Functions: Interpretation and Typechecking | lec15.pdf |
fun.ml |
3/19 |
Closure Conversion; Types and Subtypes | lec16.pdf |
lec16.zip |
3/24 |
Types II | lec17.pdf |
|
3/26 |
Objects and Dynamic Dispatch | lec18.pdf |
|
3/31 |
Multiple Inheritance, Intro to Optimizations | lec19.pdf |
lec19.zip |
4/2 |
Optimizations / Dataflow Analysis I | lec20.pdf |
|
4/7 |
Dataflow Analaysis II | lec21.pdf |
|
4/9 |
Control Flow Analysis | lec22.pdf |
|
4/14 |
Control Flow Analysis, SSA with Phi nodes | lec23.pdf |
|
4/16 |
Register Allocation / Intro to Memory Management | lec24.pdf |
|
4/21 |
GC and Copying Collection / Intro to Compiler Verification | lec25.pdf |
|
4/23 |
Compiler Verification II | lec26.pdf |
|
4/28 |
Course Wrap-up | lec27.pdf |
|
5/7 |
Final Exam: 9:00 AM Moore 216 | |
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.- Each student has four late days to use as you wish throughout the semester. Each late day allows your group to submit an assignment up to 24 hours late. Late days are designed to accommodate unusual circumstances, such as short illness, travel, an unusually busy week, religous holidays, and other issues that crop up. Use them wisely.
- You may use at most two late days on any given assignment. After two days, you will receive no credit.
- Deadlines are automatically enforced. Forty-eight (48) hours after the deadline, the submission link will disappear. If you have fewer than two late days remaining, the like will disappear sooner.
- Late days are deducted automatically. You do not need to ask permission to use them.
- If you submit anytime after the deadline, you will use at least one late day. You cannot get your late day back, even if the version that you submitted before the deadline is your highest-scoring autograded version.
- 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.
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.