]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.typeparams] all: merge dev.regabi (063c72f) into dev.typeparams
authorMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 01:36:59 +0000 (17:36 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 01:37:23 +0000 (17:37 -0800)
Eager re-sync-branch to keep Git history reasonably accurate, since
Git lacks a better way of encoding partial merges like CL 286172.

Conflicts:

- src/cmd/compile/internal/inline/inl.go
- src/cmd/compile/internal/noder/import.go
- src/cmd/compile/internal/noder/noder.go

Merge List:

+ 2021-01-25 063c72f06d [dev.regabi] cmd/compile: backport changes from dev.typeparams (9456804)
+ 2021-01-23 d05d6fab32 [dev.regabi] cmd/compile: replace ir.Name map with ir.NameSet for SSA 2
+ 2021-01-23 48badc5fa8 [dev.regabi] cmd/compile: fix escape analysis problem with closures
+ 2021-01-23 51e1819a8d [dev.regabi] cmd/compile: scan body of closure in tooHairy to check for disallowed nodes

Change-Id: I48c0435f7aaf56f4aec26518a7459e9d95a51e9c

1  2 
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/noder/import.go

index f0be169f561deb84513c46fe0eec7b4aebf27fe1,9f9bb87dd5397217f49d23d5c3bc99f1f374d3f4..bbbdaa63d4b3448e8ad53d5bf93537420dc89aeb
@@@ -354,17 -354,16 +354,23 @@@ func (v *hairyVisitor) doNode(n ir.Node
                return true
  
        case ir.OCLOSURE:
-               // TODO(danscales) - fix some bugs when budget is lowered below 30
 +              // TODO(danscales,mdempsky): Get working with -G.
 +              // Probably after #43818 is fixed.
 +              if base.Flag.G > 0 {
 +                      v.reason = "inlining closures not yet working with -G"
 +                      return true
 +              }
 +
+               // TODO(danscales) - fix some bugs when budget is lowered below 15
                // Maybe make budget proportional to number of closure variables, e.g.:
                //v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3)
-               v.budget -= 30
+               v.budget -= 15
+               // Scan body of closure (which DoChildren doesn't automatically
+               // do) to check for disallowed ops in the body and include the
+               // body in the budget.
+               if doList(n.(*ir.ClosureExpr).Func.Body, v.do) {
+                       return true
+               }
  
        case ir.ORANGE,
                ir.OSELECT,
index aa02c01cff9acdf39e98aec2e510ad40aa2ef041,747c30e6ff1031b2cb39ec8ee830ec1db538aca5..89a2598833f47e13d515c2464b17d21badc6ebf0
@@@ -7,7 -7,6 +7,7 @@@ package node
  import (
        "errors"
        "fmt"
 +      "io"
        "os"
        pathpkg "path"
        "runtime"
        "unicode/utf8"
  
        "cmd/compile/internal/base"
 +      "cmd/compile/internal/importer"
        "cmd/compile/internal/ir"
        "cmd/compile/internal/syntax"
        "cmd/compile/internal/typecheck"
        "cmd/compile/internal/types"
 +      "cmd/compile/internal/types2"
        "cmd/internal/archive"
        "cmd/internal/bio"
        "cmd/internal/goobj"
        "cmd/internal/src"
  )
  
 +// Temporary import helper to get type2-based type-checking going.
 +type gcimports struct {
 +      packages map[string]*types2.Package
 +}
 +
 +func (m *gcimports) Import(path string) (*types2.Package, error) {
 +      return m.ImportFrom(path, "" /* no vendoring */, 0)
 +}
 +
 +func (m *gcimports) ImportFrom(path, srcDir string, mode types2.ImportMode) (*types2.Package, error) {
 +      if mode != 0 {
 +              panic("mode must be 0")
 +      }
 +
 +      path, err := resolveImportPath(path)
 +      if err != nil {
 +              return nil, err
 +      }
 +
 +      lookup := func(path string) (io.ReadCloser, error) { return openPackage(path) }
 +      return importer.Import(m.packages, path, srcDir, lookup)
 +}
 +
  func isDriveLetter(b byte) bool {
        return 'a' <= b && b <= 'z' || 'A' <= b && b <= 'Z'
  }
@@@ -176,6 -150,11 +176,11 @@@ func resolveImportPath(path string) (st
  
  // TODO(mdempsky): Return an error instead.
  func importfile(decl *syntax.ImportDecl) *types.Pkg {
+       if decl.Path.Kind != syntax.StringLit {
+               base.Errorf("import path must be a string")
+               return nil
+       }
        path, err := strconv.Unquote(decl.Path.Value)
        if err != nil {
                base.Errorf("import path must be a string")