jvm

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FrameReady = 0
	FrameExit  = 1
	FramePush  = 2
)
View Source
const (
	OpNop = 0x0

	OpIConstM1 = 0x2
	OpIConst0  = 0x3
	OpIConst1  = 0x4
	OpIConst2  = 0x5
	OpIConst3  = 0x6
	OpIConst4  = 0x7
	OpIConst5  = 0x8
	OpLDC      = 0x12

	OpILoad  = 0x15
	OpILoad0 = 0x1a
	OpILoad1 = 0x1b
	OpILoad2 = 0x1c
	OpILoad3 = 0x1d

	OpALoad  = 0x25
	OpALoad0 = 0x2a
	OpALoad1 = 0x2b
	OpALoad2 = 0x2c
	OpALoad3 = 0x2d

	OpIStore  = 0x36
	OpIStore0 = 0x3b
	OpIStore1 = 0x3c
	OpIStore2 = 0x3d
	OpIStore3 = 0x3e

	OpAStore  = 0x3A
	OpAStore0 = 0x4b
	OpAStore1 = 0x4c
	OpAStore2 = 0x4d
	OpAStore3 = 0x4e

	OpDup = 0x59

	OpIAdd = 0x60
	OpIMul = 0x68

	OpIReturn = 0xAC
	OpAReturn = 0xB0
	OpReturn  = 0xB1

	OpGetStatic = 0xB2
	OpGetField  = 0xB4
	OpPutField  = 0xB5

	OpInvokeVirtual = 0xB6
	OpInvokeSpecial = 0xB7
	OpInvokeStatic  = 0xB8
	OpInvokeDynamic = 0xBA

	OpNew = 0xBB

	OpBiPush = 0x10
	OpSiPush = 0x11

	OpIfICmpEq = 0x9f
	OpIfICmpNe = 0xa0
	OpIfICmpLt = 0xa1
	OpIfICmpGe = 0xa2
	OpIfICmpGt = 0xa3
	OpIfICmpLe = 0xa4

	OpIfACmpEq = 0xa5
	OpIfACmpNe = 0xa6

	OpGoto = 0xa7

	OpIInc = 0x84

	OpPatch = 0xff
)
View Source
const (
	ThreadReady   = 0
	ThreadBlocked = 1
	ThreadExit    = 2
)

Variables

This section is empty.

Functions

func GetParamCount

func GetParamCount(desc string) int

func Load

func Load(raw []byte) *entity.ByteCode

Types

type Frame

type Frame struct {
	entity.ByteCode
	PC     uint32
	Stack  []interface{}
	Locals []interface{}

	MethodRef *entity.Method
	State     int

	This *entity.Class
}

type Thread

type Thread struct {
	Id         int // reserved
	State      int
	FrameStack []*Frame
	Prev       *Thread
	Next       *Thread
}

type ThreadPool

type ThreadPool struct {
	// contains filtered or unexported fields
}

func (*ThreadPool) CreateThread

func (p *ThreadPool) CreateThread(frame *Frame) *Thread

func (*ThreadPool) DeleteThread

func (p *ThreadPool) DeleteThread(idx int)

DeleteThread delete a thread permanently

func (*ThreadPool) GetThread

func (p *ThreadPool) GetThread(idx int) *Thread

func (*ThreadPool) Schedule

func (p *ThreadPool) Schedule()

Schedule to schedule the threads in the pool

type VM

type VM struct {
	// contains filtered or unexported fields
}

func CreateVM

func CreateVM(out io.Writer, in io.Reader) *VM

func (*VM) AppendClass

func (v *VM) AppendClass(class *entity.Class)

func (*VM) Boot

func (v *VM) Boot()

Boot to boot a JVM

func (*VM) CreateThreadPool

func (v *VM) CreateThreadPool() *ThreadPool

func (*VM) Exec

func (v *VM) Exec(f *Frame) []interface{}

Exec execute the frame

func (*VM) InvokeMethod

func (v *VM) InvokeMethod(method *entity.Method, args ...interface{}) *Frame

func (*VM) InvokeRuntimeMethod

func (v *VM) InvokeRuntimeMethod(method *entity.Method, args ...interface{}) *Frame

func (*VM) InvokeVirtualMethod

func (v *VM) InvokeVirtualMethod(method *entity.Method, args ...interface{}) *Frame

func (*VM) LocateClass

func (v *VM) LocateClass(className string) *entity.Class

func (*VM) LocateMethod

func (v *VM) LocateMethod(className string, methodName string, desc string) *entity.Method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL