Q: Give a good reason why you might add a primitive to a VM
A good reason for adding a primitive to a Virtual Machine is efficiency/performance. Primitives are usually used to store simple data hence the term primitive. This means that the data stored in primitives is very simple to manipulate like integers and characters and that the possible operation on this data are very limited as is the case for integers where the operations consist of arithmetic functions.
Q: Name one significant difference between the Java and the Squeak VM and explain possible implications of this difference.
One major difference between the Java virtual machine and the Squeak virtual machine is the primitive types found in the Java virtual machine. The primitive types allow the Java vm to perform faster and more efficient due to this difference but it takes Java further away from a pure Object Oriented language since these primitive data types are not really objects and in Squeak even simple numbers are treated line objects and any manipulation on these objects is done using calls to the objects.
Another implication is that the Java VM is more complicated as it has to deal with these primitive types
Q Describe the garbage collection algorithm used by the Squeak virtual machine?
Squeak uses a generational mark-and-sweep-compact algorithm with only 2 generations (tenured and eden).
Garbage collection in eden is triggered when the number of objects in eden excedes 4000. Objects are moved to the tenured generation when more than 2000 objects in eden survive a garbage collection. Objects are moved to the tenured generation all at once regardless of the individual ages.