Documentation ¶
Index ¶
- func Branch(frame *chapter4_rtdt.Frame, offset int)
- func InitClass(thread *chapter4_rtdt.Thread, class *heap.Class)
- func InvokeMethod(invokerFrame *chapter4_rtdt.Frame, method *heap.Method)
- type BranchInstruction
- type BytecodeReader
- func (self *BytecodeReader) PC() int
- func (self *BytecodeReader) ReadInt16() int16
- func (self *BytecodeReader) ReadInt32() int32
- func (self *BytecodeReader) ReadInt32s(len int32) []int32
- func (self *BytecodeReader) ReadInt8() int8
- func (self *BytecodeReader) ReadUInt16() uint16
- func (self *BytecodeReader) ReadUInt8() uint8
- func (self *BytecodeReader) Reset(code []byte, pc int)
- func (self *BytecodeReader) SkipPadding()
- type Index16Instruction
- type Index8Instruction
- type Instruction
- type NoOperandsInstruction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InvokeMethod ¶
*
重点是参数传递: 1.确定方法的参数在局部变量表中占用多少位置,注意,这个数量不一定等于java代码中看到的参数个数,原因: 1.long和double类型的参数要占用两个位置 2.对于实例方法,java编译器会在参数列表的前面添加一个参数,这个参数的类型就是this引用 2.假设实际的参数占用 n 个位置,一次把这 n 个变量从调用者的操作数栈中弹出,放进调用方法的局部变量表中
Types ¶
type BranchInstruction ¶
type BranchInstruction struct {
Offset int
}
*
表示跳转指令
func (*BranchInstruction) FetchOperands ¶
func (self *BranchInstruction) FetchOperands(reader *BytecodeReader)
*
读取一个16字节的int
type BytecodeReader ¶
type BytecodeReader struct {
// contains filtered or unexported fields
}
func (*BytecodeReader) PC ¶
func (self *BytecodeReader) PC() int
func (*BytecodeReader) ReadInt16 ¶
func (self *BytecodeReader) ReadInt16() int16
func (*BytecodeReader) ReadInt32 ¶
func (self *BytecodeReader) ReadInt32() int32
func (*BytecodeReader) ReadInt32s ¶
func (self *BytecodeReader) ReadInt32s(len int32) []int32
func (*BytecodeReader) ReadInt8 ¶
func (self *BytecodeReader) ReadInt8() int8
func (*BytecodeReader) ReadUInt16 ¶
func (self *BytecodeReader) ReadUInt16() uint16
func (*BytecodeReader) ReadUInt8 ¶
func (self *BytecodeReader) ReadUInt8() uint8
func (*BytecodeReader) Reset ¶
func (self *BytecodeReader) Reset(code []byte, pc int)
*
为了避免每次解码指令都新创建一个BytecodeReader实例
func (*BytecodeReader) SkipPadding ¶
func (self *BytecodeReader) SkipPadding()
type Index16Instruction ¶
type Index16Instruction struct {
Index uint
}
*
用于指令访问运行时常量池,Index8Instruction用于访问局部变量表 有一些指令需要访问运行时常量池,常量池索引由两个字节的操作数给出
func (*Index16Instruction) FetchOperands ¶
func (self *Index16Instruction) FetchOperands(reader *BytecodeReader)
type Index8Instruction ¶
type Index8Instruction struct {
Index uint
}
*
存储和加载指令需要根据索引存取 -> 局部变量表 索引由单字节操作数给出 用Index表示局部变量表索引
func (*Index8Instruction) FetchOperands ¶
func (self *Index8Instruction) FetchOperands(reader *BytecodeReader)
type Instruction ¶
type Instruction interface { //从字节码中提取操作数 FetchOperands(reader *BytecodeReader) //执行具体指令 Execute(frame *chapter4_rtdt.Frame) }
*
操作码后面可以跟零字节或多字节的操作数,操作数就相当于函数的参数
type NoOperandsInstruction ¶
type NoOperandsInstruction struct { }
*
没有操作数的指令,及没有参数的指令
func (*NoOperandsInstruction) FetchOperands ¶
func (self *NoOperandsInstruction) FetchOperands(reader *BytecodeReader)
*
什么也不做,这是个没有操作数的指令
Click to show internal directories.
Click to hide internal directories.