dream.in.java

能以不变应万变是聪明人做事的准则。万事从小事做起,积累小成功,问鼎大成功,是成功者的秘诀。

来自我的<计算机组成与体系结构>关于JVM的一些语句摘录[原]

今天晚上在看<计算机组成与体系结构>的时候,很巧遇上了JVM这一章节,于是自己作了个总结,供大家参考下。因为课本是英文原版的,我在这里摘录了一些语句,就不翻译了~~有什么错误请各位指出~~~
A  virtual machine is a software emulation( 仿真) of a real machine.
It's the JVM's responsibility to load, check, find, and execute btyecodes at the runtime.
JVM acts as an interpreter, taking Java bytecodes and interpreting them into underlying machine instruction.
Compling a C++ program results in an assembly language program that is translated to machine code.
C++ is complied lanuage while Java ,Perl and Python are P-codes, which execute from 5 to 10 times more slowly than C++;
Java's bytecodes is a stack-based language, partially composed of zero address intructoin.要查看字节码是基于栈的话,可以用 javap -c命令来查看,这个链接是我在UC发的一个贴,是关于javap -c 和bytecodes is a stack-based language的:http://www.unix-center.net/bbs/viewthread.php?tid=12799&page=1&extra=page%3D1
Java uses two's complement to represent signed integers but does not allow for unsigned integers.请看截图:

Table 5-1. Ranges of the Java Virtual Machineís data types(来自 inside Java virtual Machine 一书)

Type Range
byte 8-bit signed two's complement integer (-27 to 27 - 1, inclusive)
short 16-bit signed two's complement integer (-215 to 215 - 1, inclusive)
int 32-bit signed two's complement integer (-231 to 231 - 1, inclusive)
long 64-bit signed two's complement integer (-263 to 263 - 1, inclusive)
char 16-bit unsigned Unicode character (0 to 216 - 1, inclusive)
float 32-bit IEEE 754 single-precision float
double 64-bit IEEE 754 double-precision float
returnValue address of an opcode within the same method
reference reference to an object on the heap, or null

从数的表示范围(-2 n-1 ---- 2 n-1-1)可以看出,是用补码保存的,
Java has four registers, which provide access to five different main memory regions.

JVM的内部组成:


Figure 5-1

JVM工作环境:
Figure 1-4, native methods are the connection between a Java program and an underlying host operating system.

Figure 1-4



最后给出一些Java 虚拟机规范定义的字节代码指令:

Opcode Mnemonic by Function Group

 

Stack Operations (Chapter 10)

Instructions that push a constant onto the stack

aconst_null Push null object reference
iconst_m1 Push int constant -1
iconst_0 Push int constant 0
iconst_1 Push int constant 1
iconst_2 Push int constant 2
iconst_3 Push int constant 3
iconst_4 Push int constant 4
iconst_5 Push int constant 5
lconst_0 Push long constant 0
lconst_1 Push long constant 1
fconst_0 Push float constant 0.0
fconst_1 Push float constant 1.0
fconst_2 Push float constant 2.0
dconst_0 Push double constant 0.0
dconst_1 Push double constant 1.0
bipush Push 8-bit signed integer
sipush Push 16-bit signed integer
ldc Push item from constant pool
ldcw Push item from constant pool (wide index)
ldc2_w Push long or double from constant pool (wide index)

Instructions that load a local variable onto the stack

iload Load int from local variable
lload Load long from local variable
fload Load float from local variable
dload Load double from local variable
aload Load reference from local variable
iload_0 Load int from local variable 0
iload_1 Load int from local variable 1
iload_2 Load int from local variable 2
iload_3 Load int from local variable 3
lload_0 Load long from local variable 0
lload_1 Load long from local variable 1
lload_2 Load long from local variable 2
lload_3 Load long from local variable 3
fload_0 Load float from local variable 0
fload_1 Load float from local variable 1
fload_2 Load float from local variable 2
fload_3 Load float from local variable 3
dload_0 Load double from local variable 0
dload_1 Load double from local variable 1
dload_2 Load double from local variable 2
dload_3 Load double from local variable 3
aload_0 Load reference from local variable 0
aload_1 Load reference from local variable 1
aload_2 Load reference from local variable 2
aload_3 Load reference from local variable 3
iaload Load int from array
laload Load long from array
faload Load float from array
daload Load double from array
aaload Load reference from array
baload Load byte or boolean from array
caload Load char from array
saload Load short from array

Instructions that store a value from the stack into a local variable

istore Store int into local variable
lstore Store long into local variable
fstore Store float into local variable
dstore Store double into local variable
astore Store reference or returnAddress into local variable
istore_0 Store int into local variable 0
istore_1 Store int into local variable 1
istore_2 Store int into local variable 2
istore_3 Store int into local variable 3
lstore_0 Store long into local variable 0
lstore_1 Store long into local variable 1
lstore_2 Store long into local variable 2
lstore_3 Store long into local variable 3
fstore_0 Store float into local variable 0
fstore_1 Store float into local variable 1
fstore_2 Store float into local variable 2
fstore_3 Store float into local variable 3
dstore_0 Store double into local variable 0
dstore_1 Store double into local variable 1
dstore_2 Store double into local variable 2
dstore_3 Store double into local variable 3
astore_0 Store reference or returnAddress into local variable 0
astore_1 Store reference or returnAddress into local variable 1
astore_2 Store reference or returnAddress into local variable 2
astore_3 Store reference or returnAddress into local variable 3
iastore Store into int array
lastore Store into long array
fastore Store into float array
dastore Store into double array
aastore Store into reference array
bastore Store into byte or boolean array
castore Store into char array
sastore Store into short array

The wide instruction

wide Extend a local variable index with additional bytes

Generic (typeless) stack operations

nop Do nothing
pop Pop top stack word
pop2 Pop top two stack words
dup Duplicate top stack word
dup_x1 Duplicate top stack word and put two down
dup_x2 Duplicate top stack word and put three down
dup2 Duplicate top two stack words
dup2_x1 Duplicate top two stack words and put two down
dup2_x2 Duplicate top two stack words and put three down
swap Swap top two stack words

Type Conversion (Chapter 11)

i2l Convert int to long
i2f Convert int to float
i2d Convert int to double
l2i Convert long to int
l2f Convert long to float
l2d Convert long to double
f2i Convert float to int
f2l Convert float to long
f2d Convert float to double
d2i Convert double to int
d2l Convert double to long
d2f Convert double to float
i2b Convert int to byte
i2c Convert int to char
i2s Convert int to short

Integer Arithmetic (Chapter 12)

iadd Add ints
ladd Add longs
isub Subtract ints
lsub Subtract longs
imul Multiply ints
lmul Multiply longs
idiv Divide ints
ldiv Divide longs
irem Calculate remainder of division of ints
lrem Calculate remainder of division of longs
ineg Negate int
lneg Negate long
iinc Increment int local variable by constant

Logic (Chapter 13)

Shift operations

ishl Perform left shift on int
lshl Perform left shift on long
ishr Perform arithmetic right shift on int
lshr Perform arithmetic right shift on long
iushr Perform logical right shift on int
lushr Perform logical right shift on long

Bitwise boolean operations

iand Perform boolean AND on ints
land Perform boolean AND on longs
ior Perform boolean OR on ints
lor Perform boolean OR on longs
ixor Perform boolean XOR on ints
lxor Perform boolean XOR on longs

Floating Point Arithmetic (Chapter 14)

fadd Add floats
dadd Add doubles
fsub Subtract floats
dsub Subtract doubles
fmul Multiply floats
dmul Multiply doubles
fdiv Divide floats
ddiv Divide doubles
frem Calculate remainder of division of floats
drem Calculate remainder of division of doubles
fneg Negate float
dneg Negate double

Objects and Arrays (Chapter 15)

Instructions that deal with objects

new Create a new object
checkcast Make sure object is of a given type
getfield Fetch field from object
putfield Set field in object
getstatic Fetch static field from class
putstatic Set static field in class
instanceof Determine if an object is of a given type

Instructions that deal with arrays

newarray Allocate new array of primitive type components
anewarray Allocate new array of reference type components
arraylength Get length of an array
multianewarray Allocate a new multi-dimensional array

Control Flow (Chapter 16)

Conditional branch instructions

ifeq Branch if equal to 0
ifne Branch if not equal to 0
iflt Branch if less than 0
ifge Branch if greater than or equal to 0
ifgt Branch if greater than 0
ifle Branch if less than or equal to 0
if_icmpeq Branch if ints equal
if_icmpne Branch if ints not equal
if_icmplt Branch if int less than other int
if_icmpge Branch if int greater than or equal to other int
if_icmpgt Branch if int greater than other int
if_icmple Branch if int less than or equal to other int
ifnull Branch if null
ifnonnull Branch if not null
if_acmpeq Branch if object references are equal
if_acmpne Branch if object references not equal

Comparison instructions

lcmp Compare longs
fcmpl Compare floats (-1 on NaN)
fcmpg Compare floats (1 on NaN)
dcmpl Compare doubles (-1 on NaN)
dcmpg Compare doubles (1 on NaN)

Unconditional branch instructions

goto Branch always
goto_w Branch always (wide index)

Table jumping instructions

tableswitch Access jump table by index and jump
lookupswitch Access jump table by key match and jump

Exceptions (Chapter 17)

athrow Throw exception or error

Finally Clauses (Chapter 18)

jsr Jump to subroutine
jsr_w Jump to subroutine (wide index)
ret Return from subroutine

Method Invocation and Return (Chapter 19)

Method invocation instructions

invokevirtual Invoke instance method, dispatch based on run-time type
invokespecial Invoke instance method, dispatching based on compile-time type
invokestatic Invoke a class (static) method
invokeinterface Invoke interface method

Method return instructions

ireturn Return int from method
lreturn Return long from method
freturn Return float from method
dreturn Return double from method
areturn Return reference from method
return Return (void) from method



posted on 2009-04-13 01:37 YXY 阅读(389) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: