Skip to content

Commit

Permalink
[dev.boringcrypto] all: merge go1.10beta1 into dev.boringcrypto
Browse files Browse the repository at this point in the history
Change-Id: I413306229201e13121fa57463eae0da07a1f396f
  • Loading branch information
rsc committed Dec 13, 2017
2 parents 3e52f22 + 9ce6b5c commit f62a243
Show file tree
Hide file tree
Showing 27 changed files with 1,298 additions and 767 deletions.
645 changes: 645 additions & 0 deletions api/go1.10.txt

Large diffs are not rendered by default.

641 changes: 0 additions & 641 deletions api/next.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/contribute.html
Expand Up @@ -187,7 +187,7 @@ <h3 id="git-codereview_install">Install the git-codereview command</h3>
On Windows, when using git-bash you must make sure that
<code>git-codereview.exe</code> is in your git exec-path.
Run <code>git --exec-path</code> to discover the right location then create a
symbolic link or simply copy the executible from $GOPATH/bin to this directory.
symbolic link or simply copy the executable from $GOPATH/bin to this directory.
</p>

<p>
Expand Down Expand Up @@ -386,7 +386,7 @@ <h3 id="copyright">Copyright</h3>
<a href="https://golang.org/change">change log</a> and in the <a
href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
href="/AUTHORS"><code>AUTHORS</code></a> file.
These files are automatically generated from the commit logs perodically.
These files are automatically generated from the commit logs periodically.
The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who &ldquo;The Go
Authors&rdquo;&mdash;the copyright holders&mdash;are.
</p>
Expand Down
8 changes: 4 additions & 4 deletions doc/editors.html
Expand Up @@ -58,7 +58,7 @@ <h2 id="options">Options</h2>
<td class="yes">Yes</td>
</tr>
<tr>
<td>Autocompletion of identifers (variable, method, and function names)</td>
<td>Autocompletion of identifiers (variable, method, and function names)</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
<td class="yes">Yes</td>
Expand Down Expand Up @@ -178,9 +178,9 @@ <h2 id="options">Options</h2>
</tr>
<tr class="download">
<td></td>
<td><a href="https://github.com/fatih/vim-go">Install<a/></td>
<td><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Install<a/></td>
<td><a href="https://www.jetbrains.com/go">Install<a/></td>
<td><a href="https://github.com/fatih/vim-go">Install</a></td>
<td><a href="https://marketplace.visualstudio.com/items?itemName=lukehoban.Go">Install</a></td>
<td><a href="https://www.jetbrains.com/go">Install</a></td>
<td><a href="https://atom.io/packages/go-plus">Install</a></td>
</tr>
</table>
Expand Down
282 changes: 214 additions & 68 deletions doc/go1.10.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/go_faq.html
Expand Up @@ -1152,7 +1152,7 @@ <h3 id="get_version">
Work is underway on an experimental package management tool,
<a href="https://github.com/golang/dep"><code>dep</code></a>, to learn
more about how tooling can help package management. More information can be found in
<a href="https://github.com/golang/dep/blob/master/FAQ.md">the <code>dep</code> FAQ</a>.
<a href="https://github.com/golang/dep/blob/master/docs/FAQ.md">the <code>dep</code> FAQ</a>.
</p>

<h2 id="Pointers">Pointers and Allocation</h2>
Expand Down
4 changes: 2 additions & 2 deletions lib/time/update.bash
Expand Up @@ -8,8 +8,8 @@
# Consult http://www.iana.org/time-zones for the latest versions.

# Versions to use.
CODE=2017b
DATA=2017b
CODE=2017c
DATA=2017c

set -e
rm -rf work
Expand Down
Binary file modified lib/time/zoneinfo.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions misc/cgo/testplugin/test.bash
Expand Up @@ -14,9 +14,6 @@ fi
goos=$(go env GOOS)
goarch=$(go env GOARCH)

echo SKIP: golang.org/issue/22571.
exit 0

function cleanup() {
rm -f plugin*.so unnamed*.so iface*.so issue*
rm -rf host pkg sub iface
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/api/run.go
Expand Up @@ -39,7 +39,7 @@ func main() {
}

out, err := exec.Command(goCmd(), "tool", "api",
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9"),
"-c", file("go1", "go1.1", "go1.2", "go1.3", "go1.4", "go1.5", "go1.6", "go1.7", "go1.8", "go1.9", "go1.10"),
"-next", file("next"),
"-except", file("except")).CombinedOutput()
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions src/cmd/compile/internal/gc/dwinl.go
Expand Up @@ -14,6 +14,7 @@ import (

// To identify variables by original source position.
type varPos struct {
DeclName string
DeclFile string
DeclLine uint
DeclCol uint
Expand Down Expand Up @@ -96,14 +97,19 @@ func assembleInlines(fnsym *obj.LSym, fn *Node, dwVars []*dwarf.Var) dwarf.InlCa
n := dcl[i]
pos := Ctxt.InnermostPos(n.Pos)
vp := varPos{
DeclName: n.Sym.Name,
DeclFile: pos.Base().SymFilename(),
DeclLine: pos.Line(),
DeclCol: pos.Col(),
}
if _, found := m[vp]; found {
Fatalf("child dcl collision on symbol %s within %v\n", n.Sym.Name, fnsym.Name)
}
m[vp] = i
}
for j := 0; j < len(sl); j++ {
vp := varPos{
DeclName: sl[j].Name,
DeclFile: sl[j].DeclFile,
DeclLine: sl[j].DeclLine,
DeclCol: sl[j].DeclCol,
Expand Down
59 changes: 58 additions & 1 deletion src/cmd/dist/test.go
Expand Up @@ -583,7 +583,7 @@ func (t *tester) registerTests() {
},
})
}
if swig, _ := exec.LookPath("swig"); swig != "" && goos != "android" {
if t.hasSwig() && goos != "android" {
t.tests = append(t.tests, distTest{
name: "swig_stdio",
heading: "../misc/swig/stdio",
Expand Down Expand Up @@ -1197,6 +1197,63 @@ func (t *tester) hasBash() bool {
return true
}

func (t *tester) hasSwig() bool {
swig, err := exec.LookPath("swig")
if err != nil {
return false
}
out, err := exec.Command(swig, "-version").CombinedOutput()
if err != nil {
return false
}

re := regexp.MustCompile(`[vV]ersion +([\d]+)([.][\d]+)?([.][\d]+)?`)
matches := re.FindSubmatch(out)
if matches == nil {
// Can't find version number; hope for the best.
return true
}

major, err := strconv.Atoi(string(matches[1]))
if err != nil {
// Can't find version number; hope for the best.
return true
}
if major < 3 {
return false
}
if major > 3 {
// 4.0 or later
return true
}

// We have SWIG version 3.x.
if len(matches[2]) > 0 {
minor, err := strconv.Atoi(string(matches[2][1:]))
if err != nil {
return true
}
if minor > 0 {
// 3.1 or later
return true
}
}

// We have SWIG version 3.0.x.
if len(matches[3]) > 0 {
patch, err := strconv.Atoi(string(matches[3][1:]))
if err != nil {
return true
}
if patch < 6 {
// Before 3.0.6.
return false
}
}

return true
}

func (t *tester) raceDetectorSupported() bool {
switch gohostos {
case "linux", "darwin", "freebsd", "windows":
Expand Down
95 changes: 89 additions & 6 deletions src/cmd/go/internal/cache/cache.go
Expand Up @@ -178,9 +178,7 @@ func (c *Cache) get(id ActionID) (Entry, error) {

fmt.Fprintf(c.log, "%d get %x\n", c.now().Unix(), id)

// Best-effort attempt to update mtime on file,
// so that mtime reflects cache access time.
os.Chtimes(c.fileName(id, "a"), c.now(), c.now())
c.used(c.fileName(id, "a"))

return Entry{buf, size, time.Unix(0, tm)}, nil
}
Expand All @@ -203,12 +201,95 @@ func (c *Cache) GetBytes(id ActionID) ([]byte, Entry, error) {
// OutputFile returns the name of the cache file storing output with the given OutputID.
func (c *Cache) OutputFile(out OutputID) string {
file := c.fileName(out, "d")
c.used(file)
return file
}

// Best-effort attempt to update mtime on file,
// so that mtime reflects cache access time.
// Time constants for cache expiration.
//
// We set the mtime on a cache file on each use, but at most one per mtimeInterval (1 hour),
// to avoid causing many unnecessary inode updates. The mtimes therefore
// roughly reflect "time of last use" but may in fact be older by at most an hour.
//
// We scan the cache for entries to delete at most once per trimInterval (1 day).
//
// When we do scan the cache, we delete entries that have not been used for
// at least trimLimit (5 days). Statistics gathered from a month of usage by
// Go developers found that essentially all reuse of cached entries happened
// within 5 days of the previous reuse. See golang.org/issue/22990.
const (
mtimeInterval = 1 * time.Hour
trimInterval = 24 * time.Hour
trimLimit = 5 * 24 * time.Hour
)

// used makes a best-effort attempt to update mtime on file,
// so that mtime reflects cache access time.
//
// Because the reflection only needs to be approximate,
// and to reduce the amount of disk activity caused by using
// cache entries, used only updates the mtime if the current
// mtime is more than an hour old. This heuristic eliminates
// nearly all of the mtime updates that would otherwise happen,
// while still keeping the mtimes useful for cache trimming.
func (c *Cache) used(file string) {
info, err := os.Stat(file)
if err == nil && c.now().Sub(info.ModTime()) < mtimeInterval {
return
}
os.Chtimes(file, c.now(), c.now())
}

return file
// Trim removes old cache entries that are likely not to be reused.
func (c *Cache) Trim() {
now := c.now()

// We maintain in dir/trim.txt the time of the last completed cache trim.
// If the cache has been trimmed recently enough, do nothing.
// This is the common case.
data, _ := ioutil.ReadFile(filepath.Join(c.dir, "trim.txt"))
t, err := strconv.ParseInt(strings.TrimSpace(string(data)), 10, 64)
if err == nil && now.Sub(time.Unix(t, 0)) < trimInterval {
return
}

// Trim each of the 256 subdirectories.
// We subtract an additional mtimeInterval
// to account for the imprecision of our "last used" mtimes.
cutoff := now.Add(-trimLimit - mtimeInterval)
for i := 0; i < 256; i++ {
subdir := filepath.Join(c.dir, fmt.Sprintf("%02x", i))
c.trimSubdir(subdir, cutoff)
}

ioutil.WriteFile(filepath.Join(c.dir, "trim.txt"), []byte(fmt.Sprintf("%d", now.Unix())), 0666)
}

// trimSubdir trims a single cache subdirectory.
func (c *Cache) trimSubdir(subdir string, cutoff time.Time) {
// Read all directory entries from subdir before removing
// any files, in case removing files invalidates the file offset
// in the directory scan. Also, ignore error from f.Readdirnames,
// because we don't care about reporting the error and we still
// want to process any entries found before the error.
f, err := os.Open(subdir)
if err != nil {
return
}
names, _ := f.Readdirnames(-1)
f.Close()

for _, name := range names {
// Remove only cache entries (xxxx-a and xxxx-d).
if !strings.HasSuffix(name, "-a") && !strings.HasSuffix(name, "-d") {
continue
}
entry := filepath.Join(subdir, name)
info, err := os.Stat(entry)
if err == nil && info.ModTime().Before(cutoff) {
os.Remove(entry)
}
}
}

// putIndexEntry adds an entry to the cache recording that executing the action
Expand Down Expand Up @@ -239,6 +320,7 @@ func (c *Cache) putIndexEntry(id ActionID, out OutputID, size int64, allowVerify
os.Remove(file)
return err
}
os.Chtimes(file, c.now(), c.now()) // mainly for tests

fmt.Fprintf(c.log, "%d put %x %x %d\n", c.now().Unix(), id, out, size)
return nil
Expand Down Expand Up @@ -365,6 +447,7 @@ func (c *Cache) copyFile(file io.ReadSeeker, out OutputID, size int64) error {
os.Remove(name)
return err
}
os.Chtimes(name, c.now(), c.now()) // mainly for tests

return nil
}

0 comments on commit f62a243

Please sign in to comment.