Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from hensur/re-extract-2020-10-08
Browse files Browse the repository at this point in the history
re-extract 2020-10-08
  • Loading branch information
Pete Wagner committed Oct 13, 2020
2 parents a51f4c8 + 0150f6a commit eb59109
Show file tree
Hide file tree
Showing 116 changed files with 9,430 additions and 6,668 deletions.
64 changes: 64 additions & 0 deletions _internal_/cfg/cfg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2019 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.

// Package cfg holds configuration shared by the Go command and internal/testenv.
// Definitions that don't need to be exposed outside of cmd/go should be in
// cmd/go/internal/cfg instead of this package.
package cfg

// KnownEnv is a list of environment variables that affect the operation
// of the Go command.
const KnownEnv = `
AR
CC
CGO_CFLAGS
CGO_CFLAGS_ALLOW
CGO_CFLAGS_DISALLOW
CGO_CPPFLAGS
CGO_CPPFLAGS_ALLOW
CGO_CPPFLAGS_DISALLOW
CGO_CXXFLAGS
CGO_CXXFLAGS_ALLOW
CGO_CXXFLAGS_DISALLOW
CGO_ENABLED
CGO_FFLAGS
CGO_FFLAGS_ALLOW
CGO_FFLAGS_DISALLOW
CGO_LDFLAGS
CGO_LDFLAGS_ALLOW
CGO_LDFLAGS_DISALLOW
CXX
FC
GCCGO
GO111MODULE
GO386
GOARCH
GOARM
GOBIN
GOCACHE
GOENV
GOEXE
GOFLAGS
GOGCCFLAGS
GOHOSTARCH
GOHOSTOS
GOINSECURE
GOMIPS
GOMIPS64
GOMODCACHE
GONOPROXY
GONOSUMDB
GOOS
GOPATH
GOPPC64
GOPRIVATE
GOPROXY
GOROOT
GOSUMDB
GOTMPDIR
GOTOOLDIR
GOWASM
GO_EXTLINK_ENABLED
PKG_CONFIG
`
15 changes: 3 additions & 12 deletions _internal_/goroot/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,9 @@ func (gd *gccgoDirs) isStandard(path string) bool {
}

for _, dir := range gd.dirs {
full := filepath.Join(dir, path)
pkgdir, pkg := filepath.Split(full)
for _, p := range [...]string{
full,
full + ".gox",
pkgdir + "lib" + pkg + ".so",
pkgdir + "lib" + pkg + ".a",
full + ".o",
} {
if fi, err := os.Stat(p); err == nil && !fi.IsDir() {
return true
}
full := filepath.Join(dir, path) + ".gox"
if fi, err := os.Stat(full); err == nil && !fi.IsDir() {
return true
}
}

Expand Down
78 changes: 78 additions & 0 deletions _internal_/lazyregexp/lazyre.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright 2018 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.

// Package lazyregexp is a thin wrapper over regexp, allowing the use of global
// regexp variables without forcing them to be compiled at init.
package lazyregexp

import (
"os"
"regexp"
"strings"
"sync"
)

// Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be
// compiled the first time it is needed.
type Regexp struct {
str string
once sync.Once
rx *regexp.Regexp
}

func (r *Regexp) re() *regexp.Regexp {
r.once.Do(r.build)
return r.rx
}

func (r *Regexp) build() {
r.rx = regexp.MustCompile(r.str)
r.str = ""
}

func (r *Regexp) FindSubmatch(s []byte) [][]byte {
return r.re().FindSubmatch(s)
}

func (r *Regexp) FindStringSubmatch(s string) []string {
return r.re().FindStringSubmatch(s)
}

func (r *Regexp) FindStringSubmatchIndex(s string) []int {
return r.re().FindStringSubmatchIndex(s)
}

func (r *Regexp) ReplaceAllString(src, repl string) string {
return r.re().ReplaceAllString(src, repl)
}

func (r *Regexp) FindString(s string) string {
return r.re().FindString(s)
}

func (r *Regexp) FindAllString(s string, n int) []string {
return r.re().FindAllString(s, n)
}

func (r *Regexp) MatchString(s string) bool {
return r.re().MatchString(s)
}

func (r *Regexp) SubexpNames() []string {
return r.re().SubexpNames()
}

var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test")

// New creates a new lazy regexp, delaying the compiling work until it is first
// needed. If the code is being run as part of tests, the regexp compiling will
// happen immediately.
func New(str string) *Regexp {
lr := &Regexp{str: str}
if inTest {
// In tests, always compile the regexps early.
lr.re()
}
return lr
}
52 changes: 52 additions & 0 deletions _internal_/lazytemplate/lazytemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2019 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.

// Package lazytemplate is a thin wrapper over text/template, allowing the use
// of global template variables without forcing them to be parsed at init.
package lazytemplate

import (
"io"
"os"
"strings"
"sync"
"text/template"
)

// Template is a wrapper around text/template.Template, where the underlying
// template will be parsed the first time it is needed.
type Template struct {
name, text string

once sync.Once
tmpl *template.Template
}

func (r *Template) tp() *template.Template {
r.once.Do(r.build)
return r.tmpl
}

func (r *Template) build() {
r.tmpl = template.Must(template.New(r.name).Parse(r.text))
r.name, r.text = "", ""
}

func (r *Template) Execute(w io.Writer, data interface{}) error {
return r.tp().Execute(w, data)
}

var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test")

// New creates a new lazy template, delaying the parsing work until it is first
// needed. If the code is being run as part of tests, the template parsing will
// happen immediately.
func New(name, text string) *Template {
lt := &Template{name: name, text: text}
if inTest {
// In tests, always parse the templates early.
lt.tp()
}
return lt
}
12 changes: 6 additions & 6 deletions _internal_/xcoff/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ func NewFile(r io.ReaderAt) (*File, error) {

// If this symbol is a function, it must retrieve its size from
// its AUX_FCN entry.
// It can happend that a function symbol doesn't have any AUX_FCN.
// In this case, needAuxFcn is false and their size will be set to 0
// It can happen that a function symbol doesn't have any AUX_FCN.
// In this case, needAuxFcn is false and their size will be set to 0.
if needAuxFcn {
switch f.TargetMachine {
case U802TOCMAGIC:
Expand Down Expand Up @@ -412,10 +412,10 @@ func NewFile(r io.ReaderAt) (*File, error) {
sect.Relocs[i].Type = rel.Rtype
sect.Relocs[i].Length = rel.Rsize&0x3F + 1

if rel.Rsize&0x80 == 1 {
if rel.Rsize&0x80 != 0 {
sect.Relocs[i].Signed = true
}
if rel.Rsize&0x40 == 1 {
if rel.Rsize&0x40 != 0 {
sect.Relocs[i].InstructionFixed = true
}

Expand All @@ -428,10 +428,10 @@ func NewFile(r io.ReaderAt) (*File, error) {
sect.Relocs[i].Symbol = idxToSym[int(rel.Rsymndx)]
sect.Relocs[i].Type = rel.Rtype
sect.Relocs[i].Length = rel.Rsize&0x3F + 1
if rel.Rsize&0x80 == 1 {
if rel.Rsize&0x80 != 0 {
sect.Relocs[i].Signed = true
}
if rel.Rsize&0x40 == 1 {
if rel.Rsize&0x40 != 0 {
sect.Relocs[i].InstructionFixed = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/_internal_/objabi/autotype.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Derived from Inferno utils/6l/l.h and related files.
// https://bitbucket.org/inferno-os/inferno-os/src/default/utils/6l/l.h
// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/6l/l.h
//
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
Expand Down
6 changes: 4 additions & 2 deletions cmd/_internal_/objabi/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
//
// The file format is:
//
// - magic header: "\x00go112ld"
// - magic header: "\x00go114ld"
// - byte 1 - version number
// - sequence of strings giving dependencies (imported packages)
// - empty string (marks end of sequence)
// - number of entries in the following sequence
// - sequence of filename strings to generate debug information
// - sequence of symbol references used by the defined symbols
// - byte 0xff (marks end of sequence)
// - sequence of integer lengths:
Expand All @@ -38,7 +40,7 @@
// - data, the content of the defined symbols
// - sequence of defined symbols
// - byte 0xff (marks end of sequence)
// - magic footer: "\xffgo112ld"
// - magic footer: "\xffgo114ld"
//
// All integers are stored in a zigzag varint format.
// See golang.org/s/go12symtab for a definition.
Expand Down
10 changes: 4 additions & 6 deletions cmd/_internal_/objabi/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (versionFlag) Set(s string) error {
name = name[strings.LastIndex(name, `/`)+1:]
name = name[strings.LastIndex(name, `\`)+1:]
name = strings.TrimSuffix(name, ".exe")

// If there's an active experiment, include that,
// to distinguish go1.10.2 with an experiment
// from go1.10.2 without an experiment.
p := Expstring()
if p == DefaultExpstring() {
p = ""
Expand All @@ -101,12 +105,6 @@ func (versionFlag) Set(s string) error {
// build ID of the binary, so that if the compiler is changed and
// rebuilt, we notice and rebuild all packages.
if s == "full" {
// If there's an active experiment, include that,
// to distinguish go1.10.2 with an experiment
// from go1.10.2 without an experiment.
if x := Expstring(); x != "" {
p += " " + x
}
if strings.HasPrefix(Version, "devel") {
p += " buildID=" + buildID
}
Expand Down
38 changes: 32 additions & 6 deletions cmd/_internal_/objabi/funcdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,44 @@ package objabi
// ../../../runtime/symtab.go.

const (
PCDATA_StackMapIndex = 0
PCDATA_InlTreeIndex = 1
PCDATA_RegMapIndex = 2
PCDATA_RegMapIndex = 0 // if !go115ReduceLiveness
PCDATA_UnsafePoint = 0 // if go115ReduceLiveness
PCDATA_StackMapIndex = 1
PCDATA_InlTreeIndex = 2

FUNCDATA_ArgsPointerMaps = 0
FUNCDATA_LocalsPointerMaps = 1
FUNCDATA_InlTree = 2
FUNCDATA_RegPointerMaps = 3
FUNCDATA_StackObjects = 4
FUNCDATA_RegPointerMaps = 2 // if !go115ReduceLiveness
FUNCDATA_StackObjects = 3
FUNCDATA_InlTree = 4
FUNCDATA_OpenCodedDeferInfo = 5

// ArgsSizeUnknown is set in Func.argsize to mark all functions
// whose argument size is unknown (C vararg functions, and
// assembly code without an explicit specification).
// This value is generated by the compiler, assembler, or linker.
ArgsSizeUnknown = -0x80000000
)

// Special PCDATA values.
const (
// PCDATA_RegMapIndex values.
//
// Only if !go115ReduceLiveness.
PCDATA_RegMapUnsafe = -2 // Unsafe for async preemption

// PCDATA_UnsafePoint values.
PCDATA_UnsafePointSafe = -1 // Safe for async preemption
PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption

// PCDATA_Restart1(2) apply on a sequence of instructions, within
// which if an async preemption happens, we should back off the PC
// to the start of the sequence when resuming.
// We need two so we can distinguish the start/end of the sequence
// in case that two sequences are next to each other.
PCDATA_Restart1 = -3
PCDATA_Restart2 = -4

// Like PCDATA_Restart1, but back to function entry if async preempted.
PCDATA_RestartAtEntry = -5
)
15 changes: 15 additions & 0 deletions cmd/_internal_/objabi/funcid.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const (
FuncID_debugCallV1
FuncID_gopanic
FuncID_panicwrap
FuncID_handleAsyncEvent
FuncID_asyncPreempt
FuncID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
)

Expand Down Expand Up @@ -82,6 +84,19 @@ func GetFuncID(name, file string) FuncID {
return FuncID_gopanic
case "runtime.panicwrap":
return FuncID_panicwrap
case "runtime.handleAsyncEvent":
return FuncID_handleAsyncEvent
case "runtime.asyncPreempt":
return FuncID_asyncPreempt
case "runtime.deferreturn":
// Don't show in the call stack (used when invoking defer functions)
return FuncID_wrapper
case "runtime.runOpenDeferFrame":
// Don't show in the call stack (used when invoking defer functions)
return FuncID_wrapper
case "runtime.reflectcallSave":
// Don't show in the call stack (used when invoking defer functions)
return FuncID_wrapper
}
if file == "<autogenerated>" {
return FuncID_wrapper
Expand Down

0 comments on commit eb59109

Please sign in to comment.