1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html> 4 5 <head> 6 <title>instance-of</title> 7 <link rel=stylesheet href="opcode.css"> 8 </head> 9 10 <body> 11 12 <h1>instance-of</h1> 13 14 <h2>Purpose</h2> 15 16 <p> 17 Store in the given destination register 1 if the indicated reference is an 18 instance of the given type, or 0 if not. The type must be a reference type (not 19 a primitive type). 20 </p> 21 22 <h2>Details</h2> 23 24 <table class="instruc"> 25 <thead> 26 <tr> 27 <th>Op & Format</th> 28 <th>Mnemonic / Syntax</th> 29 <th>Arguments</th> 30 </tr> 31 </thead> 32 <tbody> 33 <tr> 34 <td>20 22c</td> 35 <td>instance-of vA, vB, type@CCCC</td> 36 <td><code>A:</code> destination register (4 bits)<br/> 37 <code>B:</code> reference-bearing register (4 bits)<br/> 38 <code>C:</code> type index (16 bits)</td> 39 </tr> 40 </tbody> 41 </table> 42 43 <h2>Constraints</h2> 44 45 <ul> 46 <li> 47 Both A and B must be a valid register indices for the current stack frame. 48 </li> 49 <li> 50 Register vB must contain a reference value. 51 </li> 52 <li> 53 C must be a valid index into the type constant pool. 54 </li> 55 <li> 56 Type constant pool entry C must contain a valid type descriptor for a 57 reference type. 58 </li> 59 </ul> 60 61 <h2>Behavior</h2> 62 63 <ul> 64 <li> 65 An attempt is made to get a reference to the class K the name of which is 66 contained in type pool entry C. 67 </li> 68 <li> 69 If K has not been loaded and resolved before, it is being loaded and 70 resolved. All exceptions that are possible during class loading can occur at 71 this point. 72 </li> 73 <li> 74 The run-time type of the object reference vB is compared against K. The 75 register vA reflects the result: 76 <ul> 77 <li> 78 vA' = 1 if (and only if) vB is not null and vB is assignment compatible 79 with K according to the usual rules of the Java programming language. 80 </li> 81 <li> 82 vA' = 0 otherwise 83 </li> 84 </ul> 85 </li> 86 <li> 87 If v(A-1) is the lower half of a register pair, v(A-1)' becomes undefined. 88 </li> 89 <li> 90 If v(A+1) is the upper half of a register pair, v(A+1)' becomes undefined. 91 </li> 92 93 <h2>Exceptions</h2> 94 95 <p> 96 None. 97 </p> 98 99 </body> 100 </html> 101