vm

package
v0.0.0-...-63c0616 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VoidClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescVoid,
		},
		arrayDim: -1,
	}
	BooleanClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescBool,
		},
		arrayDim: -1,
	}
	ByteClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescInt8,
		},
		arrayDim: -1,
	}
	CharClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescChar,
		},
		arrayDim: -1,
	}
	ShortClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescInt16,
		},
		arrayDim: -1,
	}
	IntClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescInt32,
		},
		arrayDim: -1,
	}
	FloatClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescFloat32,
		},
		arrayDim: -1,
	}
	LongClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescInt64,
		},
		arrayDim: -1,
	}
	DoubleClass = &Class{
		Class: &jcls.Class{
			ThisDesc: desc.DescFloat64,
		},
		arrayDim: -1,
	}

	ByteArrayClass = ByteClass.NewArrayClass(1)
)

Functions

func GetNextThreadId

func GetNextThreadId() int64

func GetNextThreadIdAddress

func GetNextThreadIdAddress() int64

Types

type Class

type Class struct {
	*jcls.Class

	Fields  []Field
	Methods []Method
	// contains filtered or unexported fields
}

vm.Class represents a loaded class

func LoadClass

func LoadClass(cls *jcls.Class, loader ir.ClassLoader) *Class

func (*Class) ArrayDim

func (c *Class) ArrayDim() int

func (*Class) Desc

func (c *Class) Desc() *desc.Desc

func (*Class) Elem

func (c *Class) Elem() ir.Class

func (*Class) GetAndPushConst

func (c *Class) GetAndPushConst(i uint16, s ir.Stack) error

func (*Class) GetField

func (c *Class) GetField(i uint16) ir.Field

func (*Class) GetFieldByName

func (c *Class) GetFieldByName(name string) ir.Field

func (*Class) GetMethod

func (c *Class) GetMethod(i uint16) ir.Method

func (*Class) GetMethodByDesc

func (c *Class) GetMethodByDesc(name string, dc *desc.MethodDesc) ir.Method

func (*Class) GetMethodByName

func (c *Class) GetMethodByName(location string) ir.Method

func (*Class) GetMethodByNameAndType

func (c *Class) GetMethodByNameAndType(name, typ string) ir.Method

func (*Class) InitBeforeUse

func (c *Class) InitBeforeUse(vm *VM)

func (*Class) Interfaces

func (c *Class) Interfaces() []ir.Class

func (*Class) IsAssignableFrom

func (c *Class) IsAssignableFrom(k ir.Class) bool

func (*Class) IsInstance

func (c *Class) IsInstance(r ir.Ref) bool

func (*Class) IsInterface

func (c *Class) IsInterface() bool

func (*Class) Modifiers

func (c *Class) Modifiers() int32

func (*Class) Name

func (c *Class) Name() string

func (*Class) NewArrayClass

func (c *Class) NewArrayClass(dim int) *Class

func (*Class) Reflect

func (c *Class) Reflect() reflect.Type

func (*Class) ShouldInit

func (c *Class) ShouldInit() bool

func (*Class) Super

func (c *Class) Super() ir.Class

type Field

type Field struct {
	*jcls.Field
	// contains filtered or unexported fields
}

func (*Field) GetAndPush

func (f *Field) GetAndPush(s ir.Stack) error

func (*Field) GetDeclaringClass

func (f *Field) GetDeclaringClass() ir.Class

func (*Field) GetPointer

func (f *Field) GetPointer(r ir.Ref) unsafe.Pointer

func (*Field) Offset

func (f *Field) Offset() int64

func (*Field) PopAndSet

func (f *Field) PopAndSet(s ir.Stack) error

func (*Field) Type

func (f *Field) Type() ir.Class

type Method

type Method struct {
	*jcls.Method
	// contains filtered or unexported fields
}

func (*Method) GetDeclaringClass

func (m *Method) GetDeclaringClass() ir.Class

func (*Method) Location

func (m *Method) Location() string

type NativeMethodCallback

type NativeMethodCallback = func(ir.VM) error

type Options

type Options struct {
	Loader      ir.ClassLoader
	EntryClass  string
	EntryMethod string
	EntryArgs   []string
}

VM Options

type Ref

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

func (*Ref) Class

func (r *Ref) Class() ir.Class

func (*Ref) Data

func (r *Ref) Data() unsafe.Pointer

func (*Ref) Desc

func (r *Ref) Desc() *desc.Desc

func (*Ref) GetArrInt16

func (r *Ref) GetArrInt16() []int16

func (*Ref) GetArrInt32

func (r *Ref) GetArrInt32() []int32

func (*Ref) GetArrInt64

func (r *Ref) GetArrInt64() []int64

func (*Ref) GetArrInt8

func (r *Ref) GetArrInt8() []int8

func (*Ref) GetArrRef

func (r *Ref) GetArrRef() []unsafe.Pointer

func (*Ref) GoString

func (r *Ref) GoString() string

func (*Ref) Id

func (r *Ref) Id() int32

func (*Ref) IsLocked

func (r *Ref) IsLocked(vm ir.VM) int

func (*Ref) Len

func (r *Ref) Len() int32

func (*Ref) Lock

func (r *Ref) Lock(vm ir.VM) int

func (*Ref) Lock0

func (r *Ref) Lock0(vm *VM) int

func (*Ref) Notify

func (r *Ref) Notify(vm ir.VM) error

func (*Ref) NotifyAll

func (r *Ref) NotifyAll(vm ir.VM) error

func (*Ref) Unlock

func (r *Ref) Unlock(vm ir.VM) (int, error)

func (*Ref) Unlock0

func (r *Ref) Unlock0(vm *VM) (int, error)

func (*Ref) UserData

func (r *Ref) UserData() *any

func (*Ref) Wait

func (r *Ref) Wait(vm ir.VM, millis int64) error

func (*Ref) Wait0

func (r *Ref) Wait0(vm *VM, dur time.Duration) error

type Stack

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

func (*Stack) GetVar

func (s *Stack) GetVar(i uint16) uint32

func (*Stack) GetVar64

func (s *Stack) GetVar64(i uint16) uint64

func (*Stack) GetVarFloat32

func (s *Stack) GetVarFloat32(i uint16) float32

func (*Stack) GetVarFloat64

func (s *Stack) GetVarFloat64(i uint16) float64

func (*Stack) GetVarInt16

func (s *Stack) GetVarInt16(i uint16) int16

func (*Stack) GetVarInt32

func (s *Stack) GetVarInt32(i uint16) int32

func (*Stack) GetVarInt64

func (s *Stack) GetVarInt64(i uint16) int64

func (*Stack) GetVarInt8

func (s *Stack) GetVarInt8(i uint16) int8

func (*Stack) GetVarPointer

func (s *Stack) GetVarPointer(i uint16) unsafe.Pointer

func (*Stack) GetVarRef

func (s *Stack) GetVarRef(i uint16) ir.Ref

func (*Stack) GoString

func (s *Stack) GoString() string

func (*Stack) IsRef

func (s *Stack) IsRef() bool

returns true only if the top element is a non-null reference

func (*Stack) Method

func (s *Stack) Method() ir.Method

func (*Stack) PC

func (s *Stack) PC() *ir.ICNode

func (*Stack) Peek

func (s *Stack) Peek() uint32

func (*Stack) Peek64

func (s *Stack) Peek64() uint64

func (*Stack) PeekFloat32

func (s *Stack) PeekFloat32() float32

func (*Stack) PeekFloat64

func (s *Stack) PeekFloat64() float64

func (*Stack) PeekInt16

func (s *Stack) PeekInt16() int16

func (*Stack) PeekInt32

func (s *Stack) PeekInt32() int32

func (*Stack) PeekInt64

func (s *Stack) PeekInt64() int64

func (*Stack) PeekInt8

func (s *Stack) PeekInt8() int8

func (*Stack) PeekPointer

func (s *Stack) PeekPointer() unsafe.Pointer

func (*Stack) PeekRef

func (s *Stack) PeekRef() ir.Ref

func (*Stack) Pop

func (s *Stack) Pop() uint32

func (*Stack) Pop64

func (s *Stack) Pop64() uint64

func (*Stack) PopFloat32

func (s *Stack) PopFloat32() float32

func (*Stack) PopFloat64

func (s *Stack) PopFloat64() float64

func (*Stack) PopInt16

func (s *Stack) PopInt16() int16

func (*Stack) PopInt32

func (s *Stack) PopInt32() int32

func (*Stack) PopInt64

func (s *Stack) PopInt64() int64

func (*Stack) PopInt8

func (s *Stack) PopInt8() int8

func (*Stack) PopPointer

func (s *Stack) PopPointer() unsafe.Pointer

func (*Stack) PopRef

func (s *Stack) PopRef() ir.Ref

func (*Stack) Prev

func (s *Stack) Prev() ir.Stack

func (*Stack) Push

func (s *Stack) Push(v uint32)

func (*Stack) Push64

func (s *Stack) Push64(v uint64)

func (*Stack) PushFloat32

func (s *Stack) PushFloat32(v float32)

func (*Stack) PushFloat64

func (s *Stack) PushFloat64(v float64)

func (*Stack) PushInt16

func (s *Stack) PushInt16(v int16)

func (*Stack) PushInt32

func (s *Stack) PushInt32(v int32)

func (*Stack) PushInt64

func (s *Stack) PushInt64(v int64)

func (*Stack) PushInt8

func (s *Stack) PushInt8(v int8)

func (*Stack) PushPointer

func (s *Stack) PushPointer(v unsafe.Pointer)

func (*Stack) PushRef

func (s *Stack) PushRef(v ir.Ref)

func (*Stack) SetVar

func (s *Stack) SetVar(i uint16, v uint32)

func (*Stack) SetVar64

func (s *Stack) SetVar64(i uint16, v uint64)

func (*Stack) SetVarFloat32

func (s *Stack) SetVarFloat32(i uint16, v float32)

func (*Stack) SetVarFloat64

func (s *Stack) SetVarFloat64(i uint16, v float64)

func (*Stack) SetVarInt16

func (s *Stack) SetVarInt16(i uint16, v int16)

func (*Stack) SetVarInt32

func (s *Stack) SetVarInt32(i uint16, v int32)

func (*Stack) SetVarInt64

func (s *Stack) SetVarInt64(i uint16, v int64)

func (*Stack) SetVarInt8

func (s *Stack) SetVarInt8(i uint16, v int8)

func (*Stack) SetVarPointer

func (s *Stack) SetVarPointer(i uint16, v unsafe.Pointer)

func (*Stack) SetVarRef

func (s *Stack) SetVarRef(i uint16, v ir.Ref)

type StackFrameInfo

type StackFrameInfo struct {
	Method *Method
	PC     *ir.ICNode
}

func (*StackFrameInfo) String

func (fi *StackFrameInfo) String() string

type StackInfo

type StackInfo struct {
	Frames     []StackFrameInfo
	TotalDepth int
}

func NewStackInfo

func NewStackInfo(stack ir.Stack, depth int) *StackInfo

func (*StackInfo) String

func (s *StackInfo) String() string

type ThreadUserData

type ThreadUserData struct {
	VM       *VM
	Name     string
	Priority int32

	ScopedValueCache ir.Ref
}

type VM

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

func NewVM

func NewVM(opts *Options) *VM

func (*VM) ClearInterrupt

func (vm *VM) ClearInterrupt()

func (*VM) FillThrowableStackTrace

func (vm *VM) FillThrowableStackTrace(throwable ir.Ref)

func (*VM) GetAndClearInterrupt

func (vm *VM) GetAndClearInterrupt() bool

func (*VM) GetCarrierThread

func (vm *VM) GetCarrierThread() ir.Ref

func (*VM) GetClass

func (vm *VM) GetClass(r ir.Ref) ir.Class

func (*VM) GetClassByIndex

func (vm *VM) GetClassByIndex(i uint16) (ir.Class, error)

func (*VM) GetClassFromDesc

func (vm *VM) GetClassFromDesc(dc *desc.Desc) (*Class, error)

func (*VM) GetClassLoader

func (vm *VM) GetClassLoader() ir.ClassLoader

func (*VM) GetClassRef

func (vm *VM) GetClassRef(cls ir.Class) ir.Ref

func (*VM) GetCurrentClass

func (vm *VM) GetCurrentClass() ir.Class

func (*VM) GetCurrentMethod

func (vm *VM) GetCurrentMethod() ir.Method

func (*VM) GetCurrentThread

func (vm *VM) GetCurrentThread() ir.Ref

func (*VM) GetDesc

func (vm *VM) GetDesc(i uint16) *desc.Desc

func (*VM) GetMethodDesc

func (vm *VM) GetMethodDesc(i uint16) *desc.MethodDesc

func (*VM) GetObjectClass

func (vm *VM) GetObjectClass() ir.Class

func (*VM) GetStack

func (vm *VM) GetStack() ir.Stack

func (*VM) GetString

func (vm *VM) GetString(ref ir.Ref) string

func (*VM) GetStringClass

func (vm *VM) GetStringClass() ir.Class

func (*VM) GetStringIntern

func (vm *VM) GetStringIntern(ref ir.Ref) ir.Ref

func (*VM) GetStringInternOrNew

func (vm *VM) GetStringInternOrNew(str string) ir.Ref

func (*VM) GetThrowableClass

func (vm *VM) GetThrowableClass() ir.Class

func (*VM) Goto

func (vm *VM) Goto(n *ir.ICNode)

func (*VM) Interrupt

func (vm *VM) Interrupt(thread ir.Ref)

func (*VM) Invoke

func (vm *VM) Invoke(method ir.Method)

func (*VM) InvokeDynamic

func (vm *VM) InvokeDynamic(ind uint16) error

func (*VM) InvokeStatic

func (vm *VM) InvokeStatic(method ir.Method)

func (*VM) InvokeVirtual

func (vm *VM) InvokeVirtual(method ir.Method)

func (*VM) LoadNativeMethod

func (vm *VM) LoadNativeMethod(method ir.Method, native NativeMethodCallback)

func (*VM) MarkInterrupt

func (vm *VM) MarkInterrupt()

func (*VM) New

func (vm *VM) New(cls ir.Class) ir.Ref

func (*VM) NewArray

func (vm *VM) NewArray(dc *desc.Desc, length int32) ir.Ref

func (*VM) NewArrayByClass

func (vm *VM) NewArrayByClass(cls ir.Class, length int32) ir.Ref

func (*VM) NewArrayMultiDim

func (vm *VM) NewArrayMultiDim(dc *desc.Desc, lengths []int32) ir.Ref

func (*VM) NewLookup

func (vm *VM) NewLookup() ir.Ref

func (*VM) NewMethodHandle

func (vm *VM) NewMethodHandle(method *jcls.ConstantMethodHandle) ir.Ref

func (*VM) NewMethodType

func (vm *VM) NewMethodType(dc string) ir.Ref

func (*VM) NewString

func (vm *VM) NewString(str string) ir.Ref

func (*VM) PtrToRef

func (vm *VM) PtrToRef(ptr unsafe.Pointer) ir.Ref

func (*VM) RefToPtr

func (vm *VM) RefToPtr(ref ir.Ref) unsafe.Pointer

func (*VM) Return

func (vm *VM) Return()

func (*VM) Root

func (vm *VM) Root() *VM

func (*VM) RunStack

func (vm *VM) RunStack() error

RunStack steps the VM until the current stack pops

func (*VM) Running

func (vm *VM) Running() bool

func (*VM) SetCurrentThread

func (vm *VM) SetCurrentThread(thread ir.Ref)

func (*VM) SetupEntryMethod

func (vm *VM) SetupEntryMethod()

func (*VM) Step

func (vm *VM) Step() error

func (*VM) Throw

func (vm *VM) Throw(r ir.Ref)

Jump to

Keyboard shortcuts

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