Java Reference
In-Depth Information
x a[i] o.f C.sf
lhs=y iloady'
[dup]
istorex'
[dup_x2]
iastore
aloada'
iloadi'
iloady'
putfieldf
aloado'
iloady
[dup_x1]
iloady'
[dup]
putstaticsf
lhs+=yiloadx'
iloady'
iadd
[dup]
istorex'
iadd
[dup_x2]
iastore
aloada'
iloadi'
dup2
iaload
iloady'
[dup_x1]
putfieldf
aloado'
dup
getfieldf
iloady'
iadd
getstaticsf
iloady'
iadd
[dup]
putstaticsf
++lhs iincx',1
[iloadx']
dup2
iaload
iconst_1
iadd
[dup_x2]
iastore
aloada'
iloadi'
getfieldf
iconst_1
iadd
[dup_x1]
putfieldf
aloado'
dup
iadd
[dup]
putstaticsf
getstaticsf
iconst_1
lhs-- [iloadx']
iincx',1
dup2
iaload
[dup_x2]
iconst_1
isub
iastore
aloada'
iloadi'
getfieldf
[dup_x1]
iconst_1
isub
putfieldf
aloado'
dup
iconst_1
isub
putstaticsf
getstaticsf
[dup]
The instructions in brackets [...] must be generated if and only if the operation is a sub-
expression of some other expression, that is, if the operation is not a statement expression.
Notice that there are all sorts of stack instructions for duplicating values and moving
them into various locations on the stack:
dup duplicates the top value on the stack (pushing a copy on top)
dup2 duplicates the top pair of items on the stack (pushing a second pair on top)
dup_x2 duplicates the top value, but copies it below the two items that are below the
original top value
dup_x1 duplicates the top value, but copies it below the single item that is below the
original top value
Figure 5.2 illustrates the effect of each of these. As one might guess, these instructions
were included in the JVM instruction set for just these sorts of operations.
Search WWH ::




Custom Search