Project 1 - JVM2JS
A follow-on assignment may involve a compiler-like transformation to this code, so please plan your project accordingly.
I would first parse everything into an appropriate internal representation and then run your interpreter on that. It would also make a lot of sense to break out the various operations into classes, organized by functionality.
Comments from previous semesters (focused on the Java Virtual Machine):
The Long class from the Prototype library was useful for emulating signed long support. We were surprised by some parts of the bytecode. The three biggest things were wide opcodes, low level support for invokevirtual/special/etc..., and the peculiar method of exception handling. We ended up reading in much more of the class file format than was necessary to run arbitrary code.
There were several instructions that, had we encountered earlier, like tableswitch, we might have changed our machine design. The problem with tableswitch is that it is variable-length. We easily dealt with the "wide" instruction prefix, but this one was a surprise...
Also, IIRC, knowing what parts of the Java standard library were native and which ones were not would have been very helpful. It ended up being that the only way we knew which parts we needed to implement was to try to load it and to see where it failed. But IIRC, all of the "native" functions are marked as such-- had we known this ahead of time, and not been so sleep-deprived when we discovered it, our first order of business would have been to scan the library and make a catalog of functions that needed our attention.
Lastly-- this is kind of a "duh" when you think about it-- println requires synchronization. Relaxing the requirement to implement concurrency primitives is fine, but it would have been nice to have a heads-up that println pulls this in. I remember [one student] proudly showing us his class loader and watching his reaction (i.e., horror) as his call to println pulled in what looked like every class in the standard library.
Don't forget to mention the broken implementation of the same-origin policy in Chrome, which requires the ominous "--disable-web-security" startup flag for code loaded through the file:// protocol. A nice workaround is to run a simple web server: python -m SimpleHTTPServer 8000 will serve out the current directory.
Discussion / honesty policy:
You may, as a class, discuss all details of this assignment -- and I encourage you to do so via the mail alias. However, no code can be shared across teams. All assignments will be checked with plagiarism detection software. Submission of your project constitutes acceptance of the University Honesty Policy. More details below.
Organization / Due date:
You will do this in teams of 2 or 3 (please send me a note ASAP indicating your team preferences). It is due 11:59pm on 10/23.
- JVM on Wikipedia
- The JVM Specification - on-line draft
- Jasmin JVM assembler - useful for detailed info on bytecodes
Please submit the code / examples in a .zip file, directly to me (though all of your code and all activity should be done on a GitHub repository). Your project deliverables should include:
- a small suite of test programs (in Java)
- a description of the work performed by each team member and, very importantly,
- a description of around 5 pages of your project. This needs to include:
- overall approach and architecture
- key challenges to implementing the Dalvik VM
- some examples
- "preliminary results": some timing numbers, the "reach" of your implementation (how much is done, how much it can do)
All projects in this course are to be done by you / your group. Violation will result in a zero on the project in question and initiation of the formal procedures of the University. We use an automated program and manual checks to correlate projects with each other and with prior solutions. At the same time, we encourage students to help each other learn the course material. As in most courses, there is a boundary separating these two situations. You may give or receive help on any of the concepts covered in lecture or discussion and on the specifics of programming language syntax.
You are allowed to consult with other students in the current class to help you understand the project specification (i.e. the problem definition). However, you may not collaborate in any way when constructing your solution: the solution to the project must be generated by you or your group working alone. You are not allowed to work out the programming details of the problems with anyone or to collaborate to the extent that your programs are identifiably similar. You are not allowed to look at or in any way derive advantage from the existence of project specifications or solutions prepared elsewhere.
If you have any questions as to what constitutes unacceptable collaboration, please talk to the instructor right away. You are expected to exercise reasonable precautions in protecting your own work. Don't let other students borrow your account or computer, don't leave your program in a publicly accessible directory, and take care when discarding printouts.
For your reference, here is the University Academic Honesty Policy.