Model of Computation
The model of computation of Java bytecode is that of a stack-oriented programming language. For example, assembly code for an x86 processor might look like this:
mov eax, byte mov edx, byte add eax, edx mov ecx, eaxThis code would add two values and move the result to a different location. Similar disassembled bytecode might look like this:
0 iload_1
1 iload_2
2 iadd
3 istore_3
Here, the two values to be added are pushed onto the stack, where they are retrieved by the addition instruction, summed, and the result placed back on the stack. The storage instruction then moves the top value of the stack into a variable location. The numbers in front of the instructions simply represent the offset of each instruction from the beginning of the method. This stack-oriented model extends to the object oriented aspects of the language as well. A method call called "getName", for example, may look like the following:
Method java.lang.String getName
0 aload_0 // The "this" object is stored in location 0 of the variable table
1 getfield #5 // This instruction pops an object from the top of the stack, retrieves the specified // field from it, and pushes the field onto the stack. // In this example, the "name" field corresponds to the fifth constant in the // constant pool of the class.
4 areturn // Returns the object on top of the stack from the method.
Read more about this topic: Java Bytecode
Famous quotes containing the words model of, model and/or computation:
“AIDS occupies such a large part in our awareness because of what it has been taken to represent. It seems the very model of all the catastrophes privileged populations feel await them.”
—Susan Sontag (b. 1933)
“... if we look around us in social life and note down who are the faithful wives, the most patient and careful mothers, the most exemplary housekeepers, the model sisters, the wisest philanthropists, and the women of the most social influence, we will have to admit that most frequently they are women of cultivated minds, without which even warm hearts and good intentions are but partial influences.”
—Mrs. H. O. Ward (18241899)
“I suppose that Paderewski can play superbly, if not quite at his best, while his thoughts wander to the other end of the world, or possibly busy themselves with a computation of the receipts as he gazes out across the auditorium. I know a great actor, a master technician, can let his thoughts play truant from the scene ...”
—Minnie Maddern Fiske (18651932)