Documentation
¶
Index ¶
- Constants
- type Config
- type Heap
- func (p *Heap) DotString() string
- func (p *Heap) Free(ptr int32)
- func (p *Heap) Global__heap_base() int32
- func (p *Heap) Global__heap_l128_freep() int32
- func (p *Heap) Global__heap_lfixed_cap() int32
- func (p *Heap) Global__heap_ptr() int32
- func (p *Heap) Global__heap_top() int32
- func (p *Heap) Global__stack_ptr() int32
- func (p *Heap) L128HeaderAddr() int32
- func (p *Heap) L24HeaderAddr() int32
- func (p *Heap) L32HeaderAddr() int32
- func (p *Heap) L48HeaderAddr() int32
- func (p *Heap) L80HeaderAddr() int32
- func (p *Heap) Malloc(size int32) int32
- func (p *Heap) ReadBlock(offset int32) HeapBlock
- func (p *Heap) ReadL128Header() HeapBlock
- func (p *Heap) ReadL24Header() HeapBlock
- func (p *Heap) ReadL32Header() HeapBlock
- func (p *Heap) ReadL48Header() HeapBlock
- func (p *Heap) ReadL80Header() HeapBlock
- func (p *Heap) ReadMemoryI32(offset int32) int32
- func (p *Heap) String() string
- func (p *Heap) WasmBytes() []byte
- type HeapBlock
- type HeapFreeList
- type HeapInfo
Constants ¶
View Source
const ( KPageBytes = 64 << 10 // 一个内存页大小 DefaultMemoryPages int32 = 1 // 内存页数 DefaultMemoryPagesMax int32 = 10 // 内存最大页数 DefaultStackPtr int32 = 8 << 12 // 栈指针 DefaultHeapBase int32 = 10 << 12 // 实际需要编译根据静态数据大小计算 DefaultHeapLFixedCap int32 = 100 // 固定大小的空闲链表最大长度 )
默认值
View Source
const ( KBlockHeadSize = 8 // 块头大小 KFreeListHeadSize = 6 * KBlockHeadSize // 全部空闲链表头大小 )
内部常量
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { MemoryPages int32 // 内存页数 MemoryPagesMax int32 // 内存最大页数 StackPtr int32 // 栈指针(仅用于辅助检查) HeapBase int32 // 启始地址(8字节对齐) HeapLFixedCap int32 // 固定大小空闲链表最大长度 }
Heap配置
type Heap ¶
type Heap struct {
// contains filtered or unexported fields
}
封装的Heap, 便于测试
func (*Heap) Global__heap_base ¶
func (*Heap) Global__heap_l128_freep ¶
func (*Heap) Global__heap_lfixed_cap ¶
func (*Heap) Global__heap_ptr ¶
func (*Heap) Global__heap_top ¶
func (*Heap) L128HeaderAddr ¶
func (*Heap) L32HeaderAddr ¶
func (*Heap) L48HeaderAddr ¶
func (*Heap) L80HeaderAddr ¶
func (*Heap) ReadL128Header ¶
func (*Heap) ReadL32Header ¶
func (*Heap) ReadL48Header ¶
func (*Heap) ReadL80Header ¶
type HeapFreeList ¶
空闲链表
func (*HeapFreeList) Cap ¶
func (p *HeapFreeList) Cap() int32
func (*HeapFreeList) Len ¶
func (p *HeapFreeList) Len() int32
func (*HeapFreeList) Next ¶
func (p *HeapFreeList) Next(iter *HeapBlock) *HeapBlock
func (*HeapFreeList) String ¶
func (p *HeapFreeList) String() string
type HeapInfo ¶
type HeapInfo struct { Heap *Heap Pages int32 HeapBase int32 HeapPtr int32 HeapTop int32 // 空闲链表头 L24, L32, L48, L80, L128 HeapBlock // 固定大小的容量 LfixedCap int32 // L128当前位置 L128FreePtr int32 // 已经分配的块 UseBlocks []HeapBlock // 空闲内存块节点 FreeBlocks []HeapBlock FreeBlockMap map[int32]HeapBlock // 节点的关系 Edges map[string]string }
func (*HeapInfo) LoadFreeBlocks ¶
Click to show internal directories.
Click to hide internal directories.