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

Fall 2004 Final Exam Review: Virtual Machines

a) Why are VMs usually stack-based architectures? Why not have registers?
"The Smalltalk virtual machine is not register-based. There are registers, but they're not made visible to the programmer. Instead it's stack-based. Parameters are pushed onto the stack, and then are manipulated from there".
(16-SqueakVM.ppt)

b) Give two reasons for implementing a language using a VM rather than by compiling it to C, which can be compiled for almost any machine.
It is "better for O-O. Objects are complex. VM handles initializations" and "supports message sending - not function calling."
(16-SqueakVM.ppt)

c) _T_ Executing native code is faster then executing bytecodes for any kind of operation.

d) _?_ Garbage collection is more easily implemented using a VMs because programmers donít have access to native machine addresses.

e) _T_ One reason that a highly optimized Dictionary collection is available in Smalltalk is because the virtual machine depends on the same mechanism for good performance.

f) _T_ Java can be compiled to Smalltalk bytecodes.

g) _F_ Smalltalk can be compiled to Java bytecodes.



a) Why are VMs usually stack-based architectures? Why not have registers?

Educated Guess to answer the question. The use of a Stack Based system, as opposed to registers, lets the VM vary itself depending on the system its running on. Itaniums don't have the same number of registers as Pentium2's which don't have the same number of registers as PowerPC's. By pushing everything onto a stack, the VM for the given system can decide what it wants to do with the variables and stick them in registers if it so chooses.

There is no question, however, that the VM's use stack-based systems.

b) C has machine specific libraries (i.e. it'll compile, if you're lucky, but you'll get bus errors on one system due to pointer usage methods while it'll work perfectly fine on another, for example) and VM's are, generally, more memory efficient.

d) _T_ Garbage collection is more easily implemented using a VMs because programmers donít have access to native machine addresses.

Reasoning: it is possible to tell when something isn't being pointed to. In machine language, just because you aren't pointing to something, doesn't mean you don't know where it is (for (i=0;i10;i++,arrayP++) (DEREF)arrayP = i; //Assuming arrayP is a pointer to a malloc'd chunk of memory).

g) _DEPENDS_ Smalltalk can be compiled to Java bytecodes.

It can be compiled into Java bytecode, just not easily. Question needs to be more specific. (Slide 56, VM)


Link to this Page