Skip to content

Commit

Permalink
compiler/natives/src/math/big: Use math_big_pure_go build tag.
Browse files Browse the repository at this point in the history
Give the *build.Context variable a shorter, more common name "bctx".

Resolves the following TODO comment:

	// TODO: Consider using math_big_pure_go build tag for this package, instead of
	//       defining all these pure Go low level operators ourselves.
  • Loading branch information
dmitshur committed Jul 25, 2017
1 parent ed57caa commit 8e80e53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 44 deletions.
19 changes: 12 additions & 7 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,20 @@ func Import(path string, mode build.ImportMode, installSuffix string, buildTags
}

func importWithSrcDir(path string, srcDir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) {
buildContext := NewBuildContext(installSuffix, buildTags)
if path == "syscall" { // syscall needs to use a typical GOARCH like amd64 to pick up definitions for _Socklen, BpfInsn, IFNAMSIZ, Timeval, BpfStat, SYS_FCNTL, Flock_t, etc.
buildContext.GOARCH = runtime.GOARCH
buildContext.InstallSuffix = "js"
bctx := NewBuildContext(installSuffix, buildTags)
switch path {
case "syscall":
// syscall needs to use a typical GOARCH like amd64 to pick up definitions for _Socklen, BpfInsn, IFNAMSIZ, Timeval, BpfStat, SYS_FCNTL, Flock_t, etc.
bctx.GOARCH = runtime.GOARCH
bctx.InstallSuffix = "js"
if installSuffix != "" {
buildContext.InstallSuffix += "_" + installSuffix
bctx.InstallSuffix += "_" + installSuffix
}
case "math/big":
// Use pure Go version of math/big; we don't want non-Go assembly versions.
bctx.BuildTags = append(bctx.BuildTags, "math_big_pure_go")
}
pkg, err := buildContext.Import(path, srcDir, mode)
pkg, err := bctx.Import(path, srcDir, mode)
if err != nil {
return nil, err
}
Expand All @@ -97,7 +102,7 @@ func importWithSrcDir(path string, srcDir string, mode build.ImportMode, install
case "runtime":
pkg.GoFiles = []string{"error.go"}
case "runtime/internal/sys":
pkg.GoFiles = []string{fmt.Sprintf("zgoos_%s.go", buildContext.GOOS), "zversion.go"}
pkg.GoFiles = []string{fmt.Sprintf("zgoos_%s.go", bctx.GOOS), "zversion.go"}
case "runtime/pprof":
pkg.GoFiles = nil
case "internal/poll":
Expand Down
37 changes: 0 additions & 37 deletions compiler/natives/src/math/big/big.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,3 @@ package big
// TODO: This is a workaround for https://github.com/gopherjs/gopherjs/issues/652.
// Remove after that issue is resolved.
type Word uintptr

// TODO: Consider using math_big_pure_go build tag for this package, instead of
// defining all these pure Go low level operators ourselves.

func mulWW(x, y Word) (z1, z0 Word) {
return mulWW_g(x, y)
}
func divWW(x1, x0, y Word) (q, r Word) {
return divWW_g(x1, x0, y)
}
func addVV(z, x, y []Word) (c Word) {
return addVV_g(z, x, y)
}
func subVV(z, x, y []Word) (c Word) {
return subVV_g(z, x, y)
}
func addVW(z, x []Word, y Word) (c Word) {
return addVW_g(z, x, y)
}
func subVW(z, x []Word, y Word) (c Word) {
return subVW_g(z, x, y)
}
func shlVU(z, x []Word, s uint) (c Word) {
return shlVU_g(z, x, s)
}
func shrVU(z, x []Word, s uint) (c Word) {
return shrVU_g(z, x, s)
}
func mulAddVWW(z, x []Word, y, r Word) (c Word) {
return mulAddVWW_g(z, x, y, r)
}
func addMulVVW(z, x []Word, y Word) (c Word) {
return addMulVVW_g(z, x, y)
}
func divWVW(z []Word, xn Word, x []Word, y Word) (r Word) {
return divWVW_g(z, xn, x, y)
}

0 comments on commit 8e80e53

Please sign in to comment.