bumpallocator

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WasmPageSize = 1 << 16 // 64Kb
	MaxPages     = 4 * 1024 * 1024 * 1024 / WasmPageSize
	Alignment    = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BumpAllocator

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

func New

func New(heapBase uint32, info MemInfo) *BumpAllocator

func (*BumpAllocator) Alloc

func (b *BumpAllocator) Alloc(mem Memory, size uint32) (ptr uint32, err error)

func (*BumpAllocator) Free

func (b *BumpAllocator) Free(_ Memory, _ uint32) error

func (*BumpAllocator) HeapBase

func (b *BumpAllocator) HeapBase() uint32

type MemDefinition

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

func (MemDefinition) Max

func (i MemDefinition) Max() (uint32, bool)

type MemInfo

type MemInfo interface {
	Max() (uint32, bool)
}

type Memory

type Memory interface {
	Size() uint32
	Read(offset, cnt uint32) ([]byte, bool)
	Write(offset uint32, data []byte) bool
	Grow(deltaPages uint32) (previousPages uint32, ok bool)
}

type MemoryMockup

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

func NewMemoryMock

func NewMemoryMock(t *testing.T, pages uint32) *MemoryMockup

func NewMemoryMockWithLimit

func NewMemoryMockWithLimit(t *testing.T, pages, pageLimit uint32) *MemoryMockup

func (*MemoryMockup) Definition

func (m *MemoryMockup) Definition() *MemDefinition

func (*MemoryMockup) Grow

func (m *MemoryMockup) Grow(pages uint32) (uint32, bool)

func (*MemoryMockup) Read

func (m *MemoryMockup) Read(offset, cnt uint32) ([]byte, bool)

func (*MemoryMockup) Size

func (m *MemoryMockup) Size() uint32

func (*MemoryMockup) Write

func (m *MemoryMockup) Write(offset uint32, data []byte) bool

Jump to

Keyboard shortcuts

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