github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/experimental/opt/opt.go (about)

     1  package opt
     2  
     3  import (
     4  	"runtime"
     5  
     6  	"github.com/bananabytelabs/wazero"
     7  )
     8  
     9  type enabler interface {
    10  	// EnableOptimizingCompiler enables the optimizing compiler.
    11  	// This is only implemented the internal type of wazero.runtimeConfig.
    12  	EnableOptimizingCompiler()
    13  }
    14  
    15  // NewRuntimeConfigOptimizingCompiler returns a new RuntimeConfig with the optimizing compiler enabled.
    16  func NewRuntimeConfigOptimizingCompiler() wazero.RuntimeConfig {
    17  	if runtime.GOARCH != "arm64" {
    18  		panic("UseOptimizingCompiler is only supported on arm64")
    19  	}
    20  	c := wazero.NewRuntimeConfig()
    21  	c.(enabler).EnableOptimizingCompiler()
    22  	return c
    23  }