View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Fall01 Final Exam Review: Virtual Machines

Back to Final Exam Review - Fall2001

What takes up the majority of time and effort in a VM?
Boxing and unboxing (removing the data from objects and putting it into a form the CPU can read).Joaquin Madruga

Why are VMs stack based?
This makes it very easy to see the call stack and handle exceptions. Registers are used in traditional CPU hardware because they offer a speed bonus. However, in a VM you always incur a memory access time (negating VM optimizations), so you might as well represent things in a manner easier to understand. Joaquin Madruga
Any more on #2? Mark Guzdial

Memory Management - VM's handle all of the memory management(i.e. the users don't explicitly allocate or deallocate memory) so it's more efficient and stable. Sometimes will allow for faster memory access as a result of hte efficiency.

Portability - By compiling out to an intermediate language and not to machine code it can be ported to other platforms without recompiling and mcuh easier.

Security - Code in a VM is essentially run in a sandbox. This makes it easier to implement security.

Speed - Jumping to a predefined routine for adding two integers at the machine code level is much faster than at the VM level.

forgot rest :)
Arthimetic operations - This is once again a speed ideal. Java uses float primitives which are much faster than Squeak's because squeak doesn't use primitive floats
Input/Ouput methods are oftne primitives
Jared Parsons

3) The thing that takes up the most time is going from VM data to Machine Data and vise versa(boxing and unboxing)

4) VM's are stack based because it allows for more sophisticated exception handling. For instance, in Java, when an exception occurs it looks in the curent frame for the handler, if it's not found then it pops the current frame and moves to the next.

Registers are spots in processors that machine code places values to be manipulated in. Using registers in VM's makes no sense because you can manipulate the data directly. Puting it in a register would just add needless operations that will cost you lots of time.
Jared Parsons
Joaquin was right wrt registers aren't any faster than any other memory in a VM. (Though there has been some interesting research on VMs that DO have registers but manipulate things so that the "registers" stay in L1/L2 cache.) The other reason for stack-based is simplicity in the machine language, which makes for easier implementation and easier optimization. Mark Guzdial

2) I'm not really sure what else for number two but here is a guess.. if you only had the compiled code for something you needed to use in a program you could use it as a primitive. Can we have any hints for the others?

Jason Fulghum
2. You would use primitives for speeding up any sort of repetitive complex mathematic code, using shared libraries (?), and for i/o specific code.

Link to this Page