Commit 4ee4607c authored by LE Manh Cuong's avatar LE Manh Cuong Committed by Brad Fitzpatrick

cmd/compile: use internal/race

CL 14870 added internal/race to factor out duplicated race thunks,
we should use it.

No signification changes in compile time and compile binary size.

Change-Id: I786af44dd5bb0f4ab6709432eeb603f27a5b6c63
Reviewed-on: https://go-review.googlesource.com/c/go/+/178118
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent c6f9321b
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !race
package gc
const raceEnabled = false
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"cmd/internal/src" "cmd/internal/src"
"cmd/internal/sys" "cmd/internal/sys"
"fmt" "fmt"
"internal/race"
"math/rand" "math/rand"
"sort" "sort"
"sync" "sync"
...@@ -325,7 +326,7 @@ func compileSSA(fn *Node, worker int) { ...@@ -325,7 +326,7 @@ func compileSSA(fn *Node, worker int) {
} }
func init() { func init() {
if raceEnabled { if race.Enabled {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
} }
} }
...@@ -336,7 +337,7 @@ func init() { ...@@ -336,7 +337,7 @@ func init() {
func compileFunctions() { func compileFunctions() {
if len(compilequeue) != 0 { if len(compilequeue) != 0 {
sizeCalculationDisabled = true // not safe to calculate sizes concurrently sizeCalculationDisabled = true // not safe to calculate sizes concurrently
if raceEnabled { if race.Enabled {
// Randomize compilation order to try to shake out races. // Randomize compilation order to try to shake out races.
tmp := make([]*Node, len(compilequeue)) tmp := make([]*Node, len(compilequeue))
perm := rand.Perm(len(compilequeue)) perm := rand.Perm(len(compilequeue))
......
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build race
package gc
const raceEnabled = true
...@@ -90,6 +90,7 @@ var bootstrapDirs = []string{ ...@@ -90,6 +90,7 @@ var bootstrapDirs = []string{
"debug/macho", "debug/macho",
"debug/pe", "debug/pe",
"internal/goversion", "internal/goversion",
"internal/race",
"internal/xcoff", "internal/xcoff",
"math/big", "math/big",
"math/bits", "math/bits",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment