compile

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package compile implements a WebAssembly compiler.

Index

Constants

View Source
const (
	DefaultMaxTextSize = 0x7fff0000 // below 2 GB to mitigate address calculation bugs

)
View Source
const ObjectVersion = 0

ABI version of generated machine code.

Variables

This section is empty.

Functions

func LoadCodeSection added in v0.5.0

func LoadCodeSection(config *CodeConfig, r Reader, mod *Module) (err error)

LoadCodeSection reads a WebAssembly module's code section and generates machine code.

If CodeBuffer panics with an error, it will be returned by this function.

func LoadCustomSections added in v0.8.0

func LoadCustomSections(config *Config, r Reader) (err error)

LoadCustomSections reads a WebAssembly module's extension sections which follow standard sections.

func LoadDataSection added in v0.5.0

func LoadDataSection(config *DataConfig, r Reader, mod *Module) (err error)

LoadDataSection reads a WebAssembly module's data section and generates initial contents of mutable program state (globals and linear memory).

If DataBuffer panics with an error, it will be returned by this function.

func ValidateDataSection added in v0.8.0

func ValidateDataSection(config *Config, r Reader, mod *Module) (err error)

ValidateDataSection reads a WebAssembly module's data section.

Types

type CodeBuffer added in v0.5.0

type CodeBuffer = code.Buffer

type CodeConfig added in v0.5.0

type CodeConfig struct {
	MaxTextSize  int        // Effective if Text is nil; defaults to DefaultMaxTextSize.
	Text         CodeBuffer // Initialized with default implementation if nil.
	Mapper       ObjectMapper
	EventHandler func(event.Event)
	LastInitFunc uint32
	Config
}

CodeConfig for a single compiler invocation. Either MaxTextSize or Text should be specified, but not both.

type Config added in v0.6.0

type Config struct {
	// SectionMapper is invoked for every section (standard or custom), just
	// after the section id byte.  It must read and return the payload length
	// (varuint32), but not the payload itself.
	SectionMapper func(sectionId byte, r Reader) (payloadLen uint32, err error)

	// CustomSectionLoader is invoked for every custom section.  It must read
	// exactly payloadLen bytes, or return an error.  SectionMapper (if
	// configured) has been invoked just before it.
	CustomSectionLoader func(r Reader, payloadLen uint32) error
}

Config for loading WebAssembly module sections.

type DataBuffer

type DataBuffer = data.Buffer

type DataConfig added in v0.5.0

type DataConfig struct {
	GlobalsMemory   DataBuffer // Initialized with default implementation if nil.
	MemoryAlignment int        // Initialized with minimal value if zero.
	Config
}

DataConfig for a single compiler invocation.

type Module

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

Module contains a WebAssembly module specification without code or data.

func LoadInitialSections added in v0.6.0

func LoadInitialSections(config *ModuleConfig, r Reader) (m *Module, err error)

LoadInitialSections reads module header and all sections preceding code and data.

func (*Module) ExportFunc added in v0.8.0

func (m *Module) ExportFunc(field string) (funcIndex uint32, sig wa.FuncType, found bool)

func (*Module) ExportFuncs added in v0.8.0

func (m *Module) ExportFuncs() map[string]uint32

func (*Module) FuncTypeIndexes added in v0.8.0

func (m *Module) FuncTypeIndexes() []uint32

func (*Module) FuncTypes added in v0.5.0

func (m *Module) FuncTypes() []wa.FuncType

func (*Module) GlobalTypes added in v0.12.0

func (m *Module) GlobalTypes() []wa.GlobalType

func (*Module) GlobalsSize

func (m *Module) GlobalsSize() int

func (*Module) ImportFunc added in v0.5.0

func (m *Module) ImportFunc(i int) (module, field string, sig wa.FuncType)

func (*Module) ImportGlobal added in v0.5.0

func (m *Module) ImportGlobal(i int) (module, field string, t wa.Type)

func (*Module) InitialMemorySize added in v0.7.0

func (m *Module) InitialMemorySize() int

func (*Module) MemorySizeLimit added in v0.7.0

func (m *Module) MemorySizeLimit() int

func (*Module) NumImportFuncs added in v0.7.0

func (m *Module) NumImportFuncs() int

func (*Module) NumImportGlobals added in v0.7.0

func (m *Module) NumImportGlobals() int

func (*Module) SetImportFunc added in v0.7.0

func (m *Module) SetImportFunc(i int, vecIndex int)

func (*Module) SetImportGlobal added in v0.7.0

func (m *Module) SetImportGlobal(i int, init uint64)

func (*Module) Types added in v0.5.0

func (m *Module) Types() []wa.FuncType

type ModuleConfig added in v0.6.0

type ModuleConfig struct {
	Config
}

ModuleConfig for a single compiler invocation.

type ObjectMapper added in v0.8.0

type ObjectMapper = obj.ObjectMapper

type Reader

type Reader = reader.R

Reader is a subset of bufio.Reader, bytes.Buffer and bytes.Reader.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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