⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appa.html

📁 Inside the java virtualMachine,深入研究java虚拟机
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<P><H3>Opcode:</H3> 85 (0x55)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">castore</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., arrayref, index, value</P></EM></H4>
<P>After:<I>...</P></EM></H4>
<P><H3>Description:</H3></P>
<P>To execute the <FONT FACE="Courier New">castore</FONT> instruction, the Java Virtual Machine first pops three words from the operand stack. The <I>arrayref</I> word must be a <FONT FACE="Courier New">reference</FONT> that refers to an array of <FONT FACE="Courier New">char</FONT>s. The <I>index</I> and <I>value</I> words must be <FONT FACE="Courier New">int</FONT>s. The virtual machine truncates the <FONT FACE="Courier New">int</FONT> <I>value</I> to a <FONT FACE="Courier New">char</FONT> and stores it into the <I>arrayref</I> array location specified by <I>index</I>.</P>
<P>If <I>arrayref</I> is <FONT FACE="Courier New">null</FONT>, the Java Virtual Machine throws <FONT FACE="Courier New">NullPointerException</FONT>. Otherwise, if <I>index</I> is not a legal index into the <I>arrayref</I> array, the virtual machine throws <FONT FACE="Courier New">ArrayIndexOutOfBoundsException</FONT>.</P>
<P>For more information about the <FONT FACE="Courier New">castore</FONT> instruction, see Chapter 15, &quot;Objects and Arrays.&quot;</P>
<P><H3><FONT FACE="Courier New">checkcast</H3></FONT> - Make sure object is of given type</P>
<P><H3>Opcode:</H3> 192 (0xc0)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">checkcast</FONT>, <I>indexbyte1</I>, <I>indexbyte2</P></I></H4>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., objectref</P></EM></H4>
<P>After:<I>..., objectref</P></EM></H4>
<P><H3>Description:</H3></P>
<P>The top word of the stack, <I>objectref</I>, must be a <FONT FACE="Courier New">reference</FONT>. To execute the <FONT FACE="Courier New">checkcast</FONT> instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating <I>(indexbyte1 <FONT FACE="Courier New"> 8) | indexbyte2</I>. </I>The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a <FONT FACE="Courier New">CONSTANT_Class_info</FONT> entry. If it hasn韙 already, the virtual machine resolves the entry. The entry may be a class, interface, or array type. If <I>objectref</I> is <FONT FACE="Courier New">null</FONT> or if <I>objectref</I> can be cast to the resolved type, the stack remains unchanged. Otherwise, the virtual machine throws <FONT FACE="Courier New">ClassCastException</FONT>.</P>
</I><P>To determine whether the object pointed to by <I>objectref</I> can be cast to the resolved type, the virtual machine first determines whether the object is a class instance or array. (It can韙 be an interface instance, because interfaces can韙 be instantiated.) If it is a class instance, and the resolved type is a class, not an interface, the object can be cast to the resolved class if the object韘 class is the resolved class or a subclass of the resolved class. Else, if it is a class instance, and the resolved type is an interface, not an class, the object can be cast to the resolved interface if the object韘 class implements the resolved interface. Otherwise, the object is an array. If the resolved type is a class, it must be <FONT FACE="Courier New">java.lang.Object</FONT>. Else, if the resolved type is an array of primitive types, the object must be an array of the same primitive type. Otherwise, the resolved type must be an array with a component type of some reference type, and the object must be an array with a component type that can be cast to the component type of the resolved array type. (Note that the dimension of an array doesn韙 enter into the <FONT FACE="Courier New">checkcast</FONT> check, only the component type of the array.)</P>
<P>As a result of executing this instruction, the virtual machine may throw any of the linking errors listed in Chapter 8, &quot;The Linking Model,&quot; as possible during resolution of a <FONT FACE="Courier New">CONSTANT_Class_info</FONT> entry. If resolution succeeds, but the resolved type cannot be cast to the resolved type, the virtual machine throws an <FONT FACE="Courier New">ClassCastException</FONT>.</P>
<P>For more information about the <FONT FACE="Courier New">checkcast</FONT> instruction, see Chapter 15, &quot;Objects and Arrays.&quot;</P>
<P><H3><FONT FACE="Courier New">d2f</H3></FONT> - Convert <FONT FACE="Courier New">double</FONT> to <FONT FACE="Courier New">float</FONT></P>
<P><H3>Opcode:</H3> 144 (0x90)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">d2f</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., value.word1, value.word2</P></EM></H4>
<P>After:<I>..., result</P></EM></H4>
<P><H3>Description:</H3></P>
<P>The top two words of the operand stack must be a <FONT FACE="Courier New">double</FONT>. To execute the <FONT FACE="Courier New">d2f</FONT> instruction, the Java Virtual Machine pops the <FONT FACE="Courier New">double</FONT> <I>value</I> from the operand stack, converts the <FONT FACE="Courier New">double</FONT> to a <FONT FACE="Courier New">float</FONT>, and pushes the <FONT FACE="Courier New">float</FONT> <I>result</I>. </P>
<P>To convert the <FONT FACE="Courier New">double</FONT> <I>value</I> to <FONT FACE="Courier New">float</FONT>, the Java Virtual Machine first checks to see if the <I>value</I> equals NaN (Not a Number). If so, the <FONT FACE="Courier New">float</FONT> <I>result</I> is also NaN. Else, if the magnitude of the <FONT FACE="Courier New">double</FONT> <I>value</I> is too small to be represented by a <FONT FACE="Courier New">float</FONT>, the <FONT FACE="Courier New">float</FONT> <I>result</I> is a zero of the same sign. Else, if the magnitude of the <FONT FACE="Courier New">double</FONT> <I>value</I> is too large to be represented by a <FONT FACE="Courier New">float</FONT>, the <FONT FACE="Courier New">float</FONT> <I>result</I> is an infinity of the same sign. Otherwise, the virtual machine converts the <FONT FACE="Courier New">double</FONT> <I>value</I> to <FONT FACE="Courier New">float</FONT> zero using IEEE 754 round-to-nearest mode.</P>
<P>Note that this instruction performs a narrowing primitive conversion. Because not all <FONT FACE="Courier New">double</FONT> values are representable by a <FONT FACE="Courier New">float</FONT>, the conversion may result in a loss of magnitude and precision.</P>
<P>For more information about the <FONT FACE="Courier New">d2f</FONT> instruction, see Chapter 11, &quot;Type Conversion.&quot;</P>
<P><H3><FONT FACE="Courier New">d2i</H3></FONT> - Convert <FONT FACE="Courier New">double</FONT> to <FONT FACE="Courier New">int</FONT></P>
<P><H3>Opcode:</H3> 142 (0x8e)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">d2i</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., value.word1, value.word2</P></EM></H4>
<P>After:<I>..., result</P></EM></H4>
<P><H3>Description:</H3></P>
<P>The top two words of the operand stack must be a <FONT FACE="Courier New">double</FONT>. To execute the <FONT FACE="Courier New">d2i</FONT> instruction, the Java Virtual Machine pops the <FONT FACE="Courier New">double</FONT> <I>value</I> from the operand stack, converts the <FONT FACE="Courier New">double</FONT> to an <FONT FACE="Courier New">int</FONT>, and pushes the <FONT FACE="Courier New">int</FONT> <I>result</I>.</P>
<P>To convert the <FONT FACE="Courier New">double</FONT> <I>value</I> to <FONT FACE="Courier New">int</FONT>, the Java Virtual Machine first checks to see if the <I>value</I> equals NaN (Not a Number). If so, the <FONT FACE="Courier New">int</FONT> <I>result</I> is zero. Else, if the <FONT FACE="Courier New">double</FONT> <I>value</I> is not a positive or negative infinity, the virtual machine rounds the <I>value</I> towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by an <FONT FACE="Courier New">int</FONT>, the <FONT FACE="Courier New">int</FONT> <I>result</I> is that integral value. Otherwise, the magnitude of the <FONT FACE="Courier New">double</FONT> <I>value</I> is too great be represented in an  <FONT FACE="Courier New">int</FONT>. If <I>value</I> is positive, the <FONT FACE="Courier New">int</FONT> <I>result</I> is the largest positive integer representable in an <FONT FACE="Courier New">int</FONT>. If <I>value</I> is negative, the <FONT FACE="Courier New">int</FONT> <I>result</I> is the smallest negative integer representable in an <FONT FACE="Courier New">int</FONT>.</P>
<P>Note that this instruction performs a narrowing primitive conversion. Because not all <FONT FACE="Courier New">double</FONT> values are representable by an <FONT FACE="Courier New">int</FONT>, the conversion may result in a loss of magnitude and precision.</P>
<P>For more information about the <FONT FACE="Courier New">d2i</FONT> instruction, see Chapter 11, &quot;Type Conversion.&quot;</P>
<P><H3><FONT FACE="Courier New">d2l</H3></FONT> - Convert <FONT FACE="Courier New">double</FONT> to <FONT FACE="Courier New">long</FONT></P>
<P><H3>Opcode:</H3> 143 (0x8f)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">d2l</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., value.word1, value.word2</P></EM></H4>
<P>After:<I>..., result.word1, result.word2</P></EM></H4>
<P><H3>Description:</H3></P>
<P>The top two words of the operand stack must be a <FONT FACE="Courier New">double</FONT>. To execute the <FONT FACE="Courier New">d2l</FONT> instruction, the Java Virtual Machine pops the <FONT FACE="Courier New">double</FONT> <I>value</I> from the operand stack, converts the <FONT FACE="Courier New">double</FONT> to a <FONT FACE="Courier New">long</FONT>, and pushes the <FONT FACE="Courier New">long</FONT> <I>result</I>.</P>
<P>To convert the <FONT FACE="Courier New">double</FONT> <I>value</I> to <FONT FACE="Courier New">long</FONT>, the Java Virtual Machine first checks to see if the <I>value</I> equals NaN (Not a Number). If so, the <FONT FACE="Courier New">long</FONT> <I>result</I> is zero. Else, if the <FONT FACE="Courier New">double</FONT> <I>value</I> is not a positive or negative infinity, the virtual machine rounds the <I>value</I> towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by a <FONT FACE="Courier New">long</FONT>, the <FONT FACE="Courier New">long</FONT> <I>result</I> is that integral value. Otherwise, the magnitude of the <FONT FACE="Courier New">double</FONT> <I>value</I> is too great be represented in a  <FONT FACE="Courier New">long</FONT>. If <I>value</I> is positive, the <FONT FACE="Courier New">long</FONT> <I>result</I> is the largest positive integer representable in a <FONT FACE="Courier New">long</FONT>. If <I>value</I> is negative, the <FONT FACE="Courier New">long</FONT> <I>result</I> is the smallest negative integer representable in an <FONT FACE="Courier New">long</FONT>.</P>
<P>Note that this instruction performs a narrowing primitive conversion. Because not all <FONT FACE="Courier New">double</FONT> values are representable by a <FONT FACE="Courier New">long</FONT>, the conversion may result in a loss of magnitude and precision.</P>
<P>For more information about the <FONT FACE="Courier New">d2l</FONT> instruction, see Chapter 11, &quot;Type Conversion.&quot;</P>
<P><H3><FONT FACE="Courier New">dadd</H3></FONT> - Add <FONT FACE="Courier New">double</FONT>s</P>
<P><H3>Opcode:</H3> 99 (0x63)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">dadd</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., value1.word1, value1.word2, value2.word1, value2.word2</P></EM></H4>
<P>After:<I>..., result.word1, result.word2</P></EM></H4>
<P><H3>Description:</H3></P>
<P>The top four words of the operand stack must be two <FONT FACE="Courier New">double</FONT>s, <I>value1</I> and <I>value2</I>. To execute the <FONT FACE="Courier New">dadd</FONT> instruction, the Java Virtual Machine pops <I>value1</I> and <I>value2</I>, adds them, and pushes the <FONT FACE="Courier New">double</FONT> <I>result</I>. The <I>result</I> produced by the <FONT FACE="Courier New">dadd</FONT> instruction is governed by the rules of IEEE 754 floating point arithmetic.</P>
<P>For more information about the <FONT FACE="Courier New">dadd</FONT> instruction, see Chapter 14, &quot;Floating Point Arithmetic.&quot;</P>
<P><H3><FONT FACE="Courier New">daload</H3></FONT> - Load <FONT FACE="Courier New">double</FONT> from array</P>
<P><H3>Opcode:</H3> 49 (0x31)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">daload</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., arrayref, index</P></EM></H4>
<P>After:<I>..., value.word1, value.word2</P></EM></H4>
<P><H3>Description:</H3></P>
<P>To execute the <FONT FACE="Courier New">daload</FONT> instruction, the Java Virtual Machine first pops two words from the operand stack. The <I>arrayref</I> word must be a <FONT FACE="Courier New">reference</FONT> that refers to an array of <FONT FACE="Courier New">double</FONT>s. The <I>index</I> word must be an <FONT FACE="Courier New">int</FONT>. The virtual machine retrieves from the <I>arrayref</I> array the <FONT FACE="Courier New">double</FONT> <I>value</I> specified by <I>index</I> and pushes it onto the operand stack.</P>
<P>If <I>arrayref</I> is <FONT FACE="Courier New">null</FONT>, the Java Virtual Machine throws <FONT FACE="Courier New">NullPointerException</FONT>. Otherwise, if <I>index</I> is not a legal index into the <I>arrayref</I> array, the virtual machine throws <FONT FACE="Courier New">ArrayIndexOutOfBoundsException</FONT>.</P>
<P>For more information about the <FONT FACE="Courier New">daload</FONT> instruction, see Chapter 15, &quot;Objects and Arrays.&quot;</P>
<P><H3><FONT FACE="Courier New">dastore</H3></FONT> - Store into <FONT FACE="Courier New">double</FONT> array</P>
<P><H3>Opcode:</H3> 82 (0x52)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">dastore</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., arrayref, index, value.word1, value.word2</P></EM></H4>
<P>After:<I>...</P></EM></H4>
<P><H3>Description:</H3></P>
<P>To execute the <FONT FACE="Courier New">daload</FONT> instruction, the Java Virtual Machine first pops four words from the operand stack. The <I>arrayref</I> word must be a <FONT FACE="Courier New">reference</FONT> that refers to an array of <FONT FACE="Courier New">double</FONT>s. The <I>index</I> word must be an <FONT FACE="Courier New">int</FONT>, and the <I>value</I> words must be a <FONT FACE="Courier New">double</FONT>. The virtual machine stores <FONT FACE="Courier New">double</FONT> <I>value</I> into the <I>arrayref</I> array location specified by <I>index</I>.</P>
<P>If <I>arrayref</I> is <FONT FACE="Courier New">null</FONT>, the Java Virtual Machine throws <FONT FACE="Courier New">NullPointerException</FONT>. Otherwise, if <I>index</I> is not a legal index into the <I>arrayref</I> array, the virtual machine throws <FONT FACE="Courier New">ArrayIndexOutOfBoundsException</FONT>.</P>
<P>For more information about the <FONT FACE="Courier New">dastore</FONT> instruction, see Chapter 15, &quot;Objects and Arrays.&quot;</P>
<P><H3><FONT FACE="Courier New">dcmpg</H3></FONT> - Compare <FONT FACE="Courier New">double</FONT>s (1 on NaN)</P>
<P><H3>Opcode:</H3> 152 (0x98)</P>
<P><H3>Instruction Format:</H3> <FONT FACE="Courier New">dcmpg</FONT></P>
<P><H3>Stack:</H3></P>
<P>Before:<I>..., value1.word1, value1.word2, value2.word1, value2.word2</P></EM></H4>
<P>After:<I>..., result</P></EM></H4>
<P><H3>Description:</H3></P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -