Skip to content

Commit 43afcb5

Browse files
committed
cmd/compile: define roles for ssa.Func, ssa.Config, and ssa.Cache
The line between ssa.Func and ssa.Config has blurred. Concurrent compilation in the backend will require more precision. This CL lays out an (aspirational) organization. The implementation will come in follow-up CLs, once the organization is settled. ssa.Config holds basic compiler configuration, mostly arch-specific information. It is configured once, early on, and is readonly, so it is safe for concurrent use. ssa.Func is a single-shot object used for compiling a single Func. It is not concurrency-safe and not re-usable. ssa.Cache is a multi-use object used to avoid expensive allocations during compilation. Each ssa.Func is given an ssa.Cache to use. ssa.Cache is not concurrency-safe. Change-Id: Id02809b6f3541541cac6c27bbb598834888ce1cc Reviewed-on: https://go-review.googlesource.com/38160 Reviewed-by: Keith Randall <[email protected]>
1 parent 886e9e6 commit 43afcb5

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/cmd/compile/internal/ssa/cache.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package ssa
6+
7+
// A Cache holds reusable compiler state.
8+
// It is intended to be re-used for multiple Func compilations.
9+
type Cache struct {
10+
}

src/cmd/compile/internal/ssa/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import (
1414
"strings"
1515
)
1616

17+
// A Config holds readonly compilation information.
18+
// It is created once, early during compilation,
19+
// and shared across all compilations.
1720
type Config struct {
1821
arch string // "amd64", etc.
1922
IntSize int64 // 4 or 8

src/cmd/compile/internal/ssa/func.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
"strings"
1212
)
1313

14-
// A Func represents a Go func declaration (or function literal) and
15-
// its body. This package compiles each Func independently.
14+
// A Func represents a Go func declaration (or function literal) and its body.
15+
// This package compiles each Func independently.
16+
// Funcs are single-use; a new Func must be created for every compiled function.
1617
type Func struct {
1718
Config *Config // architecture information
1819
pass *pass // current pass information (name, options, etc.)

0 commit comments

Comments
 (0)