13.10.2014 Views

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

OPTIMIZING THE JAVA VIRTUAL MACHINE INSTRUCTION SET BY ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

17<br />

Condition<br />

Equal<br />

Unequal<br />

Greater Than<br />

Greater Than or Equal<br />

Less Than<br />

Less Than or Equal<br />

Abbreviation<br />

eq<br />

ne<br />

gt<br />

ge<br />

lt<br />

le<br />

Table 2.8: Branch Condition Abbreviations<br />

can be treated as an instance of a specific class. The checkcast bytecode performs<br />

a similar check. However, unlike instanceof, which pushes a result value onto the<br />

operand stack to indicate the result of the comparison, checkcast throws an exception<br />

when the test fails.<br />

2.3.7 Branching<br />

Branching bytecodes are used to change the flow of control within the method. The<br />

goto and goto w bytecodes are unconditional branches which jump to a new location<br />

within the method independent of the values on the operand stack. Other conditional<br />

branch bytecodes consider one or more values on the operand stack. These bytecodes<br />

branch if the condition specified by the bytecode is true. If the condition is false,<br />

execution continues at the bytecode immediately after the branch bytecode.<br />

Branch bytecodes can be used to change the flow of control within the method<br />

based on the values of integer or object reference operands at the top of the stack.<br />

Branch bytecodes that compare an integer at the top of the operand stack with 0<br />

follow the format if where is a two letter abbreviation that indicates<br />

the condition being tested. The conditions that can be tested and their abbreviations<br />

are listed in Table 2.8.<br />

Two integer values stored on the stack can be tested using bytecodes of the form<br />

if icmp. These bytecodes allow an integer to be compared against an arbitrary<br />

value. In addition, object references can also be compared using bytecodes of<br />

the form if acmp. When object references are compared the only conditions<br />

that are supported are eq and ne. An object reference located at the top of the<br />

operand stack can be tested against null using the bytecodes ifnull and ifnonnull<br />

which branch if the object reference is null or non-null respectively.<br />

Two additional branch bytecodes are provided which branch based on the value of<br />

an integer. These bytecodes, denoted by lookupswitch and tableswitch, allow for

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!