This adds the experimental support of the file system compilation cache. Notably, experimental.WithCompilationCacheDirName allows users to configure where the compiler writes the cache into. Versioning/validation of binary compatibility has been done via the release tag (which will be created from the end of this month). More specifically, the cache file starts with a header with the hardcoded wazero version. Fixes #618 Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io> Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com>
21 lines
621 B
Go
21 lines
621 B
Go
package platform
|
|
|
|
// bufWriter implements io.Writer.
|
|
//
|
|
// This is implemented because bytes.Buffer cannot write from the beginning of the underlying buffer
|
|
// without changing the memory location. In this case, the underlying buffer is memory-mapped region,
|
|
// and we have to write into that region via io.Copy since sometimes the original native code exists
|
|
// as a file for external-cached cases.
|
|
type bufWriter struct {
|
|
underlying []byte
|
|
pos int
|
|
}
|
|
|
|
// Write implements io.Writer Write.
|
|
func (b *bufWriter) Write(p []byte) (n int, err error) {
|
|
copy(b.underlying[b.pos:], p)
|
|
n = len(p)
|
|
b.pos += n
|
|
return
|
|
}
|