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

📄 overview.doc.html

📁 Jvm 规范说明。The Java Virtual Machine was designed to support the Java programming language. Some concep
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<td><a name="24199"></a>
fcmpl
<td><a name="24201"></a>
dcmpl
<td><a name="24203"></a>

<td><a name="24205"></a>


<tr><td><a name="24207"></a>
Tcmpg
<td><a name="24209"></a>

<td><a name="24211"></a>

<td><a name="24213"></a>

<td><a name="24215"></a>

<td><a name="24217"></a>
fcmpg
<td><a name="24219"></a>
dcmpg
<td><a name="24221"></a>

<td><a name="24223"></a>


<tr><td><a name="24225"></a>
<i>if_TcmpOP</i>
<td><a name="24227"></a>

<td><a name="24229"></a>

<td><a name="24231"></a>
<i>if_icmpOP</i>
<td><a name="24233"></a>

<td><a name="24235"></a>

<td><a name="24237"></a>

<td><a name="24239"></a>

<td><a name="24241"></a>
<i>if_acmpOP</i>

<tr><td><a name="24243"></a>
<i>Treturn</i>
<td><a name="24245"></a>

<td><a name="24247"></a>

<td><a name="24249"></a>
<i>ireturn</i>
<td><a name="24251"></a>
<i>lreturn</i>
<td><a name="24253"></a>
<i>freturn</i>
<td><a name="24255"></a>
<i>dreturn</i>
<td><a name="24257"></a>

<td><a name="24259"></a>
<i>areturn</i>

</Table><br><br><p>
<a name="23586"></a>
The mapping between Java storage types and Java Virtual Machine computatational types is summarized by Table 3.2.<p>
<a name="24340"></a>
<p><Table Border="0">
<tr><th><b><i>Java (Storage) Type
</i></b>
<th><b><i><code><b>Size in Bits 
</b></code></i></b>
<th><b><i><code><b>Computational Type
</b></code></i></b>
<tr><td><a name="24291"></a>
<code>byte</code>
<td><a name="24293"></a>
8
<td><a name="24295"></a>
<code>int</code>

<tr><td><a name="24297"></a>
<code>char</code>
<td><a name="24299"></a>
16
<td><a name="24301"></a>
<code>int</code>

<tr><td><a name="24303"></a>
<code>short</code>
<td><a name="24305"></a>
16
<td><a name="24307"></a>
<code>int</code>

<tr><td><a name="24309"></a>
<code>int</code>
<td><a name="24311"></a>
32
<td><a name="24313"></a>
<code>int</code>

<tr><td><a name="24315"></a>
<code>long</code>
<td><a name="24317"></a>
64
<td><a name="24319"></a>
<code>long</code>

<tr><td><a name="24321"></a>
<code>float</code>
<td><a name="24323"></a>
32
<td><a name="24325"></a>
<code>float</code>

<tr><td><a name="24327"></a>
<code>double</code>
<td><a name="24329"></a>
64
<td><a name="24331"></a>
<code>double</code>

</Table><br><br><p>
<a name="23613"></a>
The exception to this mapping is in the case of arrays. Arrays of type <code>boolean</code>, <code>byte</code>, <code>char</code>, and <code>short</code> can be directly represented by the Java Virtual Machine. Arrays of type <code>byte</code>, <code>char</code>, and <code>short</code> are accessed using instructions specialized to those types. Arrays of type <code>boolean</code> are accessed using <code>byte</code> array instructions.<p>
<a name="7560"></a>
The remainder of this chapter summarizes the Java Virtual Machine instruction set.<p>
<a name="6348"></a>
<h3>3.11.2	 Load and Store Instructions</h3>
<a name="6351"></a>
The load and store instructions transfer values between the Java Virtual Machine's 
local variables and operand stack:
<p><ul><a name="6498"></a>
<li>Load a local variable onto the operand stack: <i>iload</i>, <i>iload_&lt;n&gt;</i>, <i>lload</i>, <i>lload_&lt;n&gt;</i>, <i>fload</i>, <i>fload_&lt;n&gt;</i>, <i>dload</i>, <i>dload_&lt;n&gt;</i>, <i>aload</i>, <i>aload_&lt;n&gt;</i>.
<a name="16219"></a>
<li>Store a value from the operand stack into a local variable: <i>istore</i>, <i>istore_&lt;n&gt;</i>, <i>lstore</i>, <i>lstore_&lt;n&gt;</i>, <i>fstore</i>, <i>fstore_&lt;n&gt;</i>, <i>dstore</i>, <i>dstore_&lt;n&gt;</i>, <i>astore</i>, <i>astore_&lt;n&gt;</i>.
<a name="16220"></a>
<li>Load a constant onto the operand stack: <i>bipush</i>, <i>sipush</i>, <i>ldc</i>, <i>ldc_w</i>, <i>ldc2_w</i>, <i>aconst_null</i>, <i>iconst_m1</i>, <i>iconst_&lt;i&gt;</i>, <i>lconst_&lt;l&gt;</i>, <i>fconst_&lt;f&gt;</i>, <i>dconst_&lt;d&gt;</i>.
<a name="6518"></a>
<li>Gain access to more local variables using a wider index, or to a larger immediate operand: <i>wide</i>.
</ul><a name="7346"></a>
Instructions that access fields of objects and elements of arrays also transfer data to 
and from the operand stack <a href="Overview.doc.html#15725">(&#167;3.6.2)</a>. 
<p><a name="22321"></a>
Instruction mnemonics shown above with trailing letters between angle brackets (for instance, <i>iload_&lt;n&gt;</i>) denote families of instructions (with members <i>iload_0</i>, <i>iload_1</i>, <i>iload_2</i>, and <i>iload_3</i> in the case of <i>iload_&lt;n&gt;</i>). Such families of instructions are specializations of an additional generic instruction (<i>iload</i>) that takes one operand. For the specialized instructions the operand is implicit and does not need to be stored or fetched. The semantics are otherwise the same (<i>iload_0</i> means the same thing as <i>iload</i> with the operand <i>0</i>). The letter between the angle brackets specifies the type of the implicit operand for that family of instructions: for <i>&lt;n&gt;</i> a natural number, for <i>&lt;i&gt;</i> an <code>int</code>, for <i>&lt;l&gt;</i> a <code>long</code>, for <i>&lt;f&gt;</i> a <code>float</code>, and for <i>&lt;d&gt;</i> a <code>double</code>. Forms for type <code>int</code> are used in many cases to perform operations on values of type <code>byte</code>, <code>char</code>, and <code>short</code> <a href="Overview.doc.html#7565">(&#167;3.11.1)</a>. <p>
<a name="22452"></a>
This notation for instruction families is used throughout <i>The Java Virtual Machine Specification</i>.<p>
<a name="6410"></a>
<h3>3.11.3	 Arithmetic Instructions</h3>
<a name="6421"></a>
The arithmetic instructions compute a result that is typically a function of two values on the operand stack, pushing the result back on the operand stack. There are 
two main kinds of arithmetic instructions, those operating on integer values and 
those operating on floating-point values. Within each of these kinds, the arithmetic 
instructions are specialized to Java Virtual Machine numeric types. There is no 
direct support for integer arithmetic on <code>byte</code>, <code>short</code>, and <code>char</code> types <a href="Overview.doc.html#7565">(&#167;3.11.1)</a>; 
those operations are handled by instructions operating on type <code>int</code>. Integer and 
floating-point instructions also differ in their behavior on overflow, underflow, and 
divide-by-zero. The arithmetic instructions are as follows:
<p><ul><a name="6459"></a>
<li>Add: <i>iadd</i>, <i>ladd</i>, <i>fadd</i>, <i>dadd</i>.
<a name="6462"></a>
<li>Subtract: <i>isub</i>, <i>lsub</i>, <i>fsub</i>, <i>dsub</i>.
<a name="6463"></a>
<li>Multiply: <i>imul</i>, <i>lmul</i>, <i>fmul</i>, <i>dmul</i>.
<a name="6464"></a>
<li>Divide: <i>idiv</i>, <i>ldiv</i>, <i>fdiv</i>, <i>ddiv</i>.
<a name="6465"></a>
<li>Remainder: <i>irem</i>, <i>lrem</i>, <i>frem</i>, <i>drem</i>.
<a name="6486"></a>
<li>Negate: <i>ineg</i>, <i>lneg</i>, <i>fneg</i>, <i>dneg</i>.
<a name="16214"></a>
<li>Shift: <i>ishl</i>, <i>ishr</i>, <i>iushr</i>, <i>lshl</i>, <i>lshr</i>, <i>lushr</i>.
<a name="16215"></a>
<li>Bitwise OR: <i>ior</i>, <i>lor</i>.
<a name="16216"></a>
<li>Bitwise AND: <i>iand</i>, <i>land</i>.
<a name="6482"></a>
<li>Bitwise exclusive OR: <i>ixor</i>, <i>lxor</i>.
<a name="6522"></a>
<li>Local variable increment: <i>iinc</i>.
</ul><a name="14544"></a>
The semantics of the Java operators on integer and floating-point values (<a href="Concepts.doc.html#17876">&#167;2.4.2</a>, <a href="Concepts.doc.html#17889">&#167;2.4.3)</a> are directly supported by the semantics of the Java Virtual Machine instruction set.<p>
<a name="16827"></a>
The Java Virtual Machine does not indicate overflow or underflow during operations on integer data types. The only integer operations that can throw an exception are the integer divide instructions (<i>idiv</i> and <i>ldiv</i>) and the integer remainder instructions (<i>irem</i> and <i>lrem</i>), which throw an <code>ArithmeticException</code> if the divisor is zero.<p>
<a name="14562"></a>
Java Virtual Machine operations on floating-point numbers behave exactly as specified in IEEE 754. In particular, the Java Virtual Machine requires full support of IEEE 754 <em>denormalized</em> floating-point numbers and <em>gradual underflow, </em>which make it easier to prove desirable properties of particular numerical algorithms.<p>
<a name="14548"></a>
The Java Virtual Machine requires that floating-point arithmetic behave as if every floating-point operator rounded its floating-point result to the result precision. <i>Inexact</i> results must be rounded to the representable value nearest to the infinitely precise result; if the two nearest representable values are equally near, the one with its least significant bit zero is chosen. This is the IEEE 754 standard's default rounding mode, known as <i>round-to-nearest</i>.<p>
<a name="14552"></a>
The Java Virtual Machine uses <i>round-towards-zero</i> when converting a floatingpoint value to an integer. This results in the number being truncated; any bits of the significand that represent the fractional part of the operand value are discarded. Round-towards-zero chooses as its result the type's value closest to, but no greater in magnitude than, the infinitely precise result.<p>
<a name="14553"></a>
The Java Virtual Machine's floating-point operators produce no exceptions. An operation that overflows produces a signed infinity, an operation that underflows produces a signed zero, and an operation that has no mathematically definite result produces NaN. All numeric operations with NaN as an operand produce NaN as a result.<p>
<a name="14620"></a>
<h3>3.11.4	 Type Conversion Instructions</h3>
<a name="21747"></a>
The type conversion instructions allow conversion between Java Virtual Machine 
numeric types. These may be used to implement explicit conversions in user code, or 
to mitigate the lack of orthogonality in the instruction set of the Java Virtual Machine. 
<p><a name="16068"></a>
The Java Virtual Machine directly supports the following widening numeric conversions, a subset of Java's widening primitive conversions <a href="Concepts.doc.html#23435">(&#167;2.6.2)</a>:<p>
<ul><a name="16069"></a>
<li><code>int</code> to <code>long</code>, <code>float</code>, or <code>double</code>
<a name="16070"></a>
<li><code>long</code> to <code>float</code> or <code>double</code>
<a name="16071"></a>
<li><code>float</code> to <code>double</code>
</ul><a name="16782"></a>
The widening numeric conversion instructions are <i>i2l</i>, <i>i2f</i>, <i>i2d</i>, <i>l2f</i>, <i>l2d</i>, and <i>f2d</i>. The mnemonics for these opcodes are straightforward given the naming conventions for typed instructions and the punning use of 2 to mean "to." For instance, the <i>i2d</i> instruction converts an <code>int</code> value to a <code>double</code>. Widening numeric conversions do not lose information about the overall magnitude of a numeric value. Indeed, conversions widening from the <code>int</code> type to the <code>long</code> type and from <code>float</code> to <code>double</code> do not lose any information at all; the numeric value is preserved exactly. Conversion of an <code>int</code> or a <code>long</code> value to <code>float</code>, or of a <code>long</code> value to <code>double</code>, may lose <i>precision</i>, that is, may lose some of the least significant bits of the value; the resulting floating-point value is a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode.<p>
<a name="16099"></a>
According to this rule, a widening numeric conversion of an <code>int</code> to a <code>long</code> simply sign-extends the two's-complement representation of the <code>int</code> value to fill the wider format. A widening numeric conversion of a <code>char</code> to an integral type zero-extends the representation of the <code>char</code> value to fill the wider format.<p>
<a name="16100"></a>
Despite the fact that loss of precision may occur, widening numeric conversions never result in a runtime exception.<p>
<a name="22401"></a>
Note that widening numeric conversions do not exist from integral types <code>byte</code>, <code>char</code>, and <code>short</code> to type <code>int</code>. As noted in <a href="Overview.doc.html#7565">&#167;3.11.1</a>, values of type <code>byte</code>, <code>char</code>, and <code>short</code> are internally widened to type <code>int</code>, making these conversions implicit.<p>
<a name="16095"></a>
The Java Virtual Machine also directly supports the following narrowing numeric conversions, a 

⌨️ 快捷键说明

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