Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Sum01 Final Exam Review: Virtual Machines
a) VM's vs. Compilers?
1. security- it is easy to custom write VM's to stop the user from calling certain functions, ie, Netscape's Java VM
2. portability- if a VM exists for the target platform, porting is relatively easy
3. ease of implementation- some features, like garbage collection are easy to implement in a VM
b) why use primitives in a VM?
primitives might increase speed and require less space?
a 1 byte integer takes less space than an object with a pointer to a 1 byte integer
c) why can't stacks be implemented as contiguous blocks?
not sure. because memory in an object is inherently
non-contiguous? ie, objects are pointer based?
c) the computer's stack instructions are incompatible with some language constructs? say, bytecodes? you couldn't just relinquish the stack evaluation to the CPU architecture... it has to unbox the instructions for the native machine code? Maybe squeak can explain! myobj mess: (SomeClass new)
try popping frames off for evaluating such an expression. SomeClass new evaulates to some value that can be pushed back on the stack but now underneath is the mysterious myobj, which is no good. Obviously this will cause problems with the contiguous stack since such unboxing must take place simultaneously between the message and object. ?? -webb
What other reasons might you have for (a) and (b) ?
On (c), try a different approach: when can a method return, but its temporary variables still be in use? A Java stack, by the way, can perfectly well be implemented using a linear hardware stack. -Lex Spoon
b) Additional reasons to use primitives
- they provide access to external things (for examples look at the primitives in the MPEG change sort)
- they provide access to the internal workings of the VM
(c) From what Lex said above, I'll say maybe it has something to do with static (terminology in squeak?) variables, those which have the life of the program, which are declared in a function. Straight pushing and popping of variables off a contiguous stack would not work if there were such variables in the program. Am I close?
cause if you use a contigious only memory alloc system, you run out of contigious space quickly, and your computer crashes? that close?