diff options
author | Russ Cox <rsc@golang.org> | 2020-12-23 00:41:49 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-23 06:38:26 +0000 |
commit | b9693d7627089204e6c2448f543c3512d86dae70 (patch) | |
tree | 0f869f5abb58568525f47d330e93ef36e1467bf2 /src/cmd/compile/internal/typecheck/builtin | |
parent | dac0de3748cc816352da56f516506f80c33db4a5 (diff) | |
download | go-b9693d7627089204e6c2448f543c3512d86dae70.tar.gz go-b9693d7627089204e6c2448f543c3512d86dae70.zip |
[dev.regabi] cmd/compile: split out package typecheck [generated]
This commit splits the typechecking logic into its own package,
the first of a sequence of CLs to break package gc into more
manageable units.
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# The binary import/export has to be part of typechecking,
# because we load inlined function bodies lazily, but "exporter"
# should not be. Move that out of bexport.go.
mv exporter exporter.markObject exporter.markType export.go
# Use the typechecking helpers, so that the calls left behind
# in package gc do not need access to ctxExpr etc.
ex {
import "cmd/compile/internal/ir"
# TODO(rsc): Should not be necessary.
avoid TypecheckExpr
avoid TypecheckStmt
avoid TypecheckExprs
avoid TypecheckStmts
avoid TypecheckAssignExpr
avoid TypecheckCallee
var n ir.Node
var ns []ir.Node
typecheck(n, ctxExpr) -> TypecheckExpr(n)
typecheck(n, ctxStmt) -> TypecheckStmt(n)
typecheckslice(ns, ctxExpr) -> TypecheckExprs(ns)
typecheckslice(ns, ctxStmt) -> TypecheckStmts(ns)
typecheck(n, ctxExpr|ctxAssign) -> TypecheckAssignExpr(n)
typecheck(n, ctxExpr|ctxCallee) -> TypecheckCallee(n)
}
# Move some typechecking API to typecheck.
mv syslook LookupRuntime
mv substArgTypes SubstArgTypes
mv LookupRuntime SubstArgTypes syms.go
mv conv Conv
mv convnop ConvNop
mv Conv ConvNop typecheck.go
mv colasdefn AssignDefn
mv colasname assignableName
mv Target target.go
mv initname autoexport exportsym dcl.go
mv exportsym Export
# Export API to be called from outside typecheck.
# The ones with "Typecheck" prefixes will be renamed later to drop the prefix.
mv adddot AddImplicitDots
mv assignconv AssignConv
mv expandmeth CalcMethods
mv capturevarscomplete CaptureVarsComplete
mv checkMapKeys CheckMapKeys
mv checkreturn CheckReturn
mv dclcontext DeclContext
mv dclfunc DeclFunc
mv declare Declare
mv dotImportRefs DotImportRefs
mv declImporter DeclImporter
mv variter DeclVars
mv defaultlit DefaultLit
mv evalConst EvalConst
mv expandInline ImportBody
mv finishUniverse declareUniverse
mv funcbody FinishFuncBody
mv funchdr StartFuncBody
mv indexconst IndexConst
mv initTodo InitTodoFunc
mv lookup Lookup
mv resolve Resolve
mv lookupN LookupNum
mv nodAddr NodAddr
mv nodAddrAt NodAddrAt
mv nodnil NodNil
mv origBoolConst OrigBool
mv origConst OrigConst
mv origIntConst OrigInt
mv redeclare Redeclared
mv tostruct NewStructType
mv functype NewFuncType
mv methodfunc NewMethodType
mv structargs NewFuncParams
mv temp Temp
mv tempAt TempAt
mv typecheckok TypecheckAllowed
mv typecheck _typecheck # make room for typecheck pkg
mv typecheckinl TypecheckImportedBody
mv typecheckFunc TypecheckFunc
mv iimport ReadImports
mv iexport WriteExports
mv sysfunc LookupRuntimeFunc
mv sysvar LookupRuntimeVar
# Move function constructors to typecheck.
mv mkdotargslice MakeDotArgs
mv fixVariadicCall FixVariadicCall
mv closureType ClosureType
mv partialCallType PartialCallType
mv capturevars CaptureVars
mv MakeDotArgs FixVariadicCall ClosureType PartialCallType CaptureVars typecheckclosure func.go
mv autolabel AutoLabel
mv AutoLabel syms.go
mv Dlist dlist
mv Symlink symlink
mv \
AssignDefn assignableName \
AssignConv \
CaptureVarsComplete \
DeclContext \
DeclFunc \
DeclImporter \
DeclVars \
Declare \
DotImportRefs \
Export \
InitTodoFunc \
Lookup \
LookupNum \
LookupRuntimeFunc \
LookupRuntimeVar \
NewFuncParams \
NewName \
NodAddr \
NodAddrAt \
NodNil \
Redeclared \
StartFuncBody \
FinishFuncBody \
TypecheckImportedBody \
AddImplicitDots \
CalcMethods \
CheckFuncStack \
NewFuncType \
NewMethodType \
NewStructType \
TypecheckAllowed \
Temp \
TempAt \
adddot1 \
dotlist \
addmethod \
assignconvfn \
assignop \
autotmpname \
autoexport \
bexport.go \
checkdupfields \
checkembeddedtype \
closurename \
convertop \
declare_typegen \
decldepth \
dlist \
dotpath \
expand0 \
expand1 \
expandDecl \
fakeRecvField \
fnpkg \
funcStack \
funcStackEnt \
funcarg \
funcarg2 \
funcargs \
funcargs2 \
globClosgen \
ifacelookdot \
implements \
importalias \
importconst \
importfunc \
importobj \
importsym \
importtype \
importvar \
inimport \
initname \
isptrto \
loadsys \
lookdot0 \
lookdot1 \
makepartialcall \
okfor \
okforlen \
operandType \
slist \
symlink \
tointerface \
typeSet \
typeSet.add \
typeSetEntry \
typecheckExprSwitch \
typecheckTypeSwitch \
typecheckpartialcall \
typecheckrange \
typecheckrangeExpr \
typecheckselect \
typecheckswitch \
vargen \
builtin.go \
builtin_test.go \
const.go \
func.go \
iexport.go \
iimport.go \
mapfile_mmap.go \
syms.go \
target.go \
typecheck.go \
unsafe.go \
universe.go \
cmd/compile/internal/typecheck
'
rm gen.go types.go types_acc.go
sed -i '' 's/package gc/package typecheck/' mapfile_read.go mkbuiltin.go
mv mapfile_read.go ../typecheck # not part of default build
mv mkbuiltin.go ../typecheck # package main helper
mv builtin ../typecheck
cd ../typecheck
mv dcl.go dcl1.go
mv typecheck.go typecheck1.go
mv universe.go universe1.go
rf '
# Sweep some small files into larger ones.
# "mv sym... file1.go file.go" (after the mv file1.go file.go above)
# lets us insert sym... at the top of file.go.
mv okfor okforeq universe1.go universe.go
mv DeclContext vargen dcl1.go Temp TempAt autotmpname NewMethodType dcl.go
mv InitTodoFunc inimport decldepth TypecheckAllowed typecheck1.go typecheck.go
mv inl.go closure.go func.go
mv range.go select.go swt.go stmt.go
mv Lookup loadsys LookupRuntimeFunc LookupRuntimeVar syms.go
mv unsafe.go const.go
mv TypecheckAssignExpr AssignExpr
mv TypecheckExpr Expr
mv TypecheckStmt Stmt
mv TypecheckExprs Exprs
mv TypecheckStmts Stmts
mv TypecheckCall Call
mv TypecheckCallee Callee
mv _typecheck check
mv TypecheckFunc Func
mv TypecheckFuncBody FuncBody
mv TypecheckImports AllImportedBodies
mv TypecheckImportedBody ImportedBody
mv TypecheckInit Init
mv TypecheckPackage Package
'
rm gen.go go.go init.go main.go reflect.go
Change-Id: Iea6a7aaf6407d690670ec58aeb36cc0b280f80b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/279236
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/builtin')
-rw-r--r-- | src/cmd/compile/internal/typecheck/builtin/runtime.go | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/builtin/runtime.go b/src/cmd/compile/internal/typecheck/builtin/runtime.go new file mode 100644 index 0000000000..acb69c7b28 --- /dev/null +++ b/src/cmd/compile/internal/typecheck/builtin/runtime.go @@ -0,0 +1,259 @@ +// Copyright 2009 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. + +// NOTE: If you change this file you must run "go generate" +// to update builtin.go. This is not done automatically +// to avoid depending on having a working compiler binary. + +// +build ignore + +package runtime + +// emitted by compiler, not referred to by go programs + +import "unsafe" + +func newobject(typ *byte) *any +func mallocgc(size uintptr, typ *byte, needszero bool) unsafe.Pointer +func panicdivide() +func panicshift() +func panicmakeslicelen() +func panicmakeslicecap() +func throwinit() +func panicwrap() + +func gopanic(interface{}) +func gorecover(*int32) interface{} +func goschedguarded() + +// Note: these declarations are just for wasm port. +// Other ports call assembly stubs instead. +func goPanicIndex(x int, y int) +func goPanicIndexU(x uint, y int) +func goPanicSliceAlen(x int, y int) +func goPanicSliceAlenU(x uint, y int) +func goPanicSliceAcap(x int, y int) +func goPanicSliceAcapU(x uint, y int) +func goPanicSliceB(x int, y int) +func goPanicSliceBU(x uint, y int) +func goPanicSlice3Alen(x int, y int) +func goPanicSlice3AlenU(x uint, y int) +func goPanicSlice3Acap(x int, y int) +func goPanicSlice3AcapU(x uint, y int) +func goPanicSlice3B(x int, y int) +func goPanicSlice3BU(x uint, y int) +func goPanicSlice3C(x int, y int) +func goPanicSlice3CU(x uint, y int) + +func printbool(bool) +func printfloat(float64) +func printint(int64) +func printhex(uint64) +func printuint(uint64) +func printcomplex(complex128) +func printstring(string) +func printpointer(any) +func printuintptr(uintptr) +func printiface(any) +func printeface(any) +func printslice(any) +func printnl() +func printsp() +func printlock() +func printunlock() + +func concatstring2(*[32]byte, string, string) string +func concatstring3(*[32]byte, string, string, string) string +func concatstring4(*[32]byte, string, string, string, string) string +func concatstring5(*[32]byte, string, string, string, string, string) string +func concatstrings(*[32]byte, []string) string + +func cmpstring(string, string) int +func intstring(*[4]byte, int64) string +func slicebytetostring(buf *[32]byte, ptr *byte, n int) string +func slicebytetostringtmp(ptr *byte, n int) string +func slicerunetostring(*[32]byte, []rune) string +func stringtoslicebyte(*[32]byte, string) []byte +func stringtoslicerune(*[32]rune, string) []rune +func slicecopy(toPtr *any, toLen int, fromPtr *any, fromLen int, wid uintptr) int + +func decoderune(string, int) (retv rune, retk int) +func countrunes(string) int + +// Non-empty-interface to non-empty-interface conversion. +func convI2I(typ *byte, elem any) (ret any) + +// Specialized type-to-interface conversion. +// These return only a data pointer. +func convT16(val any) unsafe.Pointer // val must be uint16-like (same size and alignment as a uint16) +func convT32(val any) unsafe.Pointer // val must be uint32-like (same size and alignment as a uint32) +func convT64(val any) unsafe.Pointer // val must be uint64-like (same size and alignment as a uint64 and contains no pointers) +func convTstring(val any) unsafe.Pointer // val must be a string +func convTslice(val any) unsafe.Pointer // val must be a slice + +// Type to empty-interface conversion. +func convT2E(typ *byte, elem *any) (ret any) +func convT2Enoptr(typ *byte, elem *any) (ret any) + +// Type to non-empty-interface conversion. +func convT2I(tab *byte, elem *any) (ret any) +func convT2Inoptr(tab *byte, elem *any) (ret any) + +// interface type assertions x.(T) +func assertE2I(typ *byte, iface any) (ret any) +func assertE2I2(typ *byte, iface any) (ret any, b bool) +func assertI2I(typ *byte, iface any) (ret any) +func assertI2I2(typ *byte, iface any) (ret any, b bool) +func panicdottypeE(have, want, iface *byte) +func panicdottypeI(have, want, iface *byte) +func panicnildottype(want *byte) + +// interface equality. Type/itab pointers are already known to be equal, so +// we only need to pass one. +func ifaceeq(tab *uintptr, x, y unsafe.Pointer) (ret bool) +func efaceeq(typ *uintptr, x, y unsafe.Pointer) (ret bool) + +func fastrand() uint32 + +// *byte is really *runtime.Type +func makemap64(mapType *byte, hint int64, mapbuf *any) (hmap map[any]any) +func makemap(mapType *byte, hint int, mapbuf *any) (hmap map[any]any) +func makemap_small() (hmap map[any]any) +func mapaccess1(mapType *byte, hmap map[any]any, key *any) (val *any) +func mapaccess1_fast32(mapType *byte, hmap map[any]any, key any) (val *any) +func mapaccess1_fast64(mapType *byte, hmap map[any]any, key any) (val *any) +func mapaccess1_faststr(mapType *byte, hmap map[any]any, key any) (val *any) +func mapaccess1_fat(mapType *byte, hmap map[any]any, key *any, zero *byte) (val *any) +func mapaccess2(mapType *byte, hmap map[any]any, key *any) (val *any, pres bool) +func mapaccess2_fast32(mapType *byte, hmap map[any]any, key any) (val *any, pres bool) +func mapaccess2_fast64(mapType *byte, hmap map[any]any, key any) (val *any, pres bool) +func mapaccess2_faststr(mapType *byte, hmap map[any]any, key any) (val *any, pres bool) +func mapaccess2_fat(mapType *byte, hmap map[any]any, key *any, zero *byte) (val *any, pres bool) +func mapassign(mapType *byte, hmap map[any]any, key *any) (val *any) +func mapassign_fast32(mapType *byte, hmap map[any]any, key any) (val *any) +func mapassign_fast32ptr(mapType *byte, hmap map[any]any, key any) (val *any) +func mapassign_fast64(mapType *byte, hmap map[any]any, key any) (val *any) +func mapassign_fast64ptr(mapType *byte, hmap map[any]any, key any) (val *any) +func mapassign_faststr(mapType *byte, hmap map[any]any, key any) (val *any) +func mapiterinit(mapType *byte, hmap map[any]any, hiter *any) +func mapdelete(mapType *byte, hmap map[any]any, key *any) +func mapdelete_fast32(mapType *byte, hmap map[any]any, key any) +func mapdelete_fast64(mapType *byte, hmap map[any]any, key any) +func mapdelete_faststr(mapType *byte, hmap map[any]any, key any) +func mapiternext(hiter *any) +func mapclear(mapType *byte, hmap map[any]any) + +// *byte is really *runtime.Type +func makechan64(chanType *byte, size int64) (hchan chan any) +func makechan(chanType *byte, size int) (hchan chan any) +func chanrecv1(hchan <-chan any, elem *any) +func chanrecv2(hchan <-chan any, elem *any) bool +func chansend1(hchan chan<- any, elem *any) +func closechan(hchan any) + +var writeBarrier struct { + enabled bool + pad [3]byte + needed bool + cgo bool + alignme uint64 +} + +// *byte is really *runtime.Type +func typedmemmove(typ *byte, dst *any, src *any) +func typedmemclr(typ *byte, dst *any) +func typedslicecopy(typ *byte, dstPtr *any, dstLen int, srcPtr *any, srcLen int) int + +func selectnbsend(hchan chan<- any, elem *any) bool +func selectnbrecv(elem *any, hchan <-chan any) bool +func selectnbrecv2(elem *any, received *bool, hchan <-chan any) bool + +func selectsetpc(pc *uintptr) +func selectgo(cas0 *byte, order0 *byte, pc0 *uintptr, nsends int, nrecvs int, block bool) (int, bool) +func block() + +func makeslice(typ *byte, len int, cap int) unsafe.Pointer +func makeslice64(typ *byte, len int64, cap int64) unsafe.Pointer +func makeslicecopy(typ *byte, tolen int, fromlen int, from unsafe.Pointer) unsafe.Pointer +func growslice(typ *byte, old []any, cap int) (ary []any) +func memmove(to *any, frm *any, length uintptr) +func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) +func memclrHasPointers(ptr unsafe.Pointer, n uintptr) + +func memequal(x, y *any, size uintptr) bool +func memequal0(x, y *any) bool +func memequal8(x, y *any) bool +func memequal16(x, y *any) bool +func memequal32(x, y *any) bool +func memequal64(x, y *any) bool +func memequal128(x, y *any) bool +func f32equal(p, q unsafe.Pointer) bool +func f64equal(p, q unsafe.Pointer) bool +func c64equal(p, q unsafe.Pointer) bool +func c128equal(p, q unsafe.Pointer) bool +func strequal(p, q unsafe.Pointer) bool +func interequal(p, q unsafe.Pointer) bool +func nilinterequal(p, q unsafe.Pointer) bool + +func memhash(p unsafe.Pointer, h uintptr, size uintptr) uintptr +func memhash0(p unsafe.Pointer, h uintptr) uintptr +func memhash8(p unsafe.Pointer, h uintptr) uintptr +func memhash16(p unsafe.Pointer, h uintptr) uintptr +func memhash32(p unsafe.Pointer, h uintptr) uintptr +func memhash64(p unsafe.Pointer, h uintptr) uintptr +func memhash128(p unsafe.Pointer, h uintptr) uintptr +func f32hash(p unsafe.Pointer, h uintptr) uintptr +func f64hash(p unsafe.Pointer, h uintptr) uintptr +func c64hash(p unsafe.Pointer, h uintptr) uintptr +func c128hash(p unsafe.Pointer, h uintptr) uintptr +func strhash(a unsafe.Pointer, h uintptr) uintptr +func interhash(p unsafe.Pointer, h uintptr) uintptr +func nilinterhash(p unsafe.Pointer, h uintptr) uintptr + +// only used on 32-bit +func int64div(int64, int64) int64 +func uint64div(uint64, uint64) uint64 +func int64mod(int64, int64) int64 +func uint64mod(uint64, uint64) uint64 +func float64toint64(float64) int64 +func float64touint64(float64) uint64 +func float64touint32(float64) uint32 +func int64tofloat64(int64) float64 +func uint64tofloat64(uint64) float64 +func uint32tofloat64(uint32) float64 + +func complex128div(num complex128, den complex128) (quo complex128) + +// race detection +func racefuncenter(uintptr) +func racefuncenterfp() +func racefuncexit() +func raceread(uintptr) +func racewrite(uintptr) +func racereadrange(addr, size uintptr) +func racewriterange(addr, size uintptr) + +// memory sanitizer +func msanread(addr, size uintptr) +func msanwrite(addr, size uintptr) +func msanmove(dst, src, size uintptr) + +func checkptrAlignment(unsafe.Pointer, *byte, uintptr) +func checkptrArithmetic(unsafe.Pointer, []unsafe.Pointer) + +func libfuzzerTraceCmp1(uint8, uint8) +func libfuzzerTraceCmp2(uint16, uint16) +func libfuzzerTraceCmp4(uint32, uint32) +func libfuzzerTraceCmp8(uint64, uint64) +func libfuzzerTraceConstCmp1(uint8, uint8) +func libfuzzerTraceConstCmp2(uint16, uint16) +func libfuzzerTraceConstCmp4(uint32, uint32) +func libfuzzerTraceConstCmp8(uint64, uint64) + +// architecture variants +var x86HasPOPCNT bool +var x86HasSSE41 bool +var x86HasFMA bool +var armHasVFPv4 bool +var arm64HasATOMICS bool |