sampsyo / cs6120

advanced compilers
https://www.cs.cornell.edu/courses/cs6120/2023fa/
MIT License
739 stars 157 forks source link

Project Proposal: Implementing Object for Bril #339

Closed yy665 closed 1 year ago

yy665 commented 2 years ago

What will you do? Bril currently only supports a few primitive types, as well as pointers to indicate heap memory. Having objects would provide a valuable extension to Bril since it greatly improves the expressibility of Bril, and provides interesting opportunities and challenges for future 6120 students to write their optimizations upon objects.

Therefore, my main goal is to implement object in Bril, including most of the very basic things that people would expect from an OO (inheritance, constructors, object-specific methods, etc.) Eventually after some polishing, I would hope this could be a nice addition to Bril.

How will you do it? There're a couple of changes, across different stacks in Bril. Here are some of my main objectives:

  1. Implementing memory model for objects. I am planning to adopt the message passing model from SELF. Since it's clean and simple, while there's still room for people to do interesting optimization on it.
  2. Implementing object syntax and associated type-checking, allowing objects to be passed around, called, or returned. This would rely on changes both on the frontend and the interpreter.
  3. Implementing some OO features to make it actually interesting and useful, including inheritance (which I might adopt prototype inheritance), object methods, constructor, and possibly encapsulation. I would try to translate and reuse the current Bril syntax as much possible.

How will you empirically measure success? I would probably pick some object models which could test the expressibility of my OO implementation. I would like to see that the representation is correct, and benchmark memory/time usage to do a certain object operation.

Team members: Just myself

sampsyo commented 2 years ago

Because you are doing this entire project after the deadline, you will need to keep it small. I recommend not attempting to do these extensions:

inheritance, constructors, object-specific methods, etc.

Instead, get something basic working and implement/evaluate that.

Some basic questions:

  1. Are you planning on modifying the reference (TypeScript) interpreter?
  2. Where will your benchmarks come from? I presume you will need to write them yourself. Which benchmarks will you write?
  3. Will you also modify the text format (parser and pretty-printer)? I strongly recommend skipping this.
  4. In your evaluation, what numbers will you compare? A good evaluation should say "X is faster than Y" or "X uses the same amount of memory as Y", etc. What are X and Y?

About the specifics of the language extension: