diff options
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r-- | libgo/go/runtime/chan_defs.go | 56 | ||||
-rw-r--r-- | libgo/go/runtime/debug.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/extern.go | 51 | ||||
-rw-r--r-- | libgo/go/runtime/hashmap_defs.go | 51 | ||||
-rw-r--r-- | libgo/go/runtime/iface_defs.go | 18 | ||||
-rw-r--r-- | libgo/go/runtime/malloc_defs.go | 130 | ||||
-rw-r--r-- | libgo/go/runtime/mheapmap32_defs.go | 23 | ||||
-rw-r--r-- | libgo/go/runtime/mheapmap64_defs.go | 31 | ||||
-rw-r--r-- | libgo/go/runtime/pprof/pprof.go | 1 | ||||
-rw-r--r-- | libgo/go/runtime/runtime_defs.go | 200 | ||||
-rw-r--r-- | libgo/go/runtime/type.go | 15 |
11 files changed, 50 insertions, 530 deletions
diff --git a/libgo/go/runtime/chan_defs.go b/libgo/go/runtime/chan_defs.go deleted file mode 100644 index 5cfea6e..0000000 --- a/libgo/go/runtime/chan_defs.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2010 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. - -// Go definitions of internal structures. Master is chan.c - -package runtime - -type sudoG struct { - g *g_ - selgen uint32 - offset int16 - isfree int8 - link *sudoG - elem [8]byte -} - -type waitQ struct { - first *sudoG - last *sudoG -} - -type hChan struct { - qcount uint32 - dataqsiz uint32 - elemsize uint16 - closed uint16 - elemalign uint8 - elemalg *alg - senddataq *link - recvdataq *link - recvq waitQ - sendq waitQ - free sudoG - lock -} - -type link struct { - link *link - elem [8]byte -} - -type scase struct { - chan_ *hChan - pc *byte - send uint16 - so uint16 - elemp *byte // union elem [8]byte -} - -type select_ struct { - tcase uint16 - ncase uint16 - link *select_ - scase [1]*scase -} diff --git a/libgo/go/runtime/debug.go b/libgo/go/runtime/debug.go index 803ea49..74010b3 100644 --- a/libgo/go/runtime/debug.go +++ b/libgo/go/runtime/debug.go @@ -57,7 +57,6 @@ type MemStatsType struct { MSpanSys uint64 MCacheInuse uint64 // mcache structures MCacheSys uint64 - MHeapMapSys uint64 // heap map BuckHashSys uint64 // profiling bucket hash table // Garbage collector statistics. @@ -70,7 +69,8 @@ type MemStatsType struct { // Per-size allocation statistics. // Not locked during update; approximate. - BySize [67]struct { + // 61 is NumSizeClasses in the C code. + BySize [61]struct { Size uint32 Mallocs uint64 Frees uint64 diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index 77c3e8e..c6e664a 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -31,6 +31,19 @@ func Caller(skip int) (pc uintptr, file string, line int, ok bool) // It returns the number of entries written to pc. func Callers(skip int, pc []uintptr) int +type Func struct { // Keep in sync with runtime.h:struct Func + name string + typ string // go type string + src string // src file name + pcln []byte // pc/ln tab for this func + entry uintptr // entry pc + pc0 uintptr // starting pc, ln for table + ln0 int32 + frame int32 // stack frame size + args int32 // number of 32-bit in/out args + locals int32 // number of 32-bit locals +} + // FuncForPC returns a *Func describing the function that contains the // given program counter address, or else nil. func FuncForPC(pc uintptr) *Func @@ -47,31 +60,47 @@ func (f *Func) Entry() uintptr { return f.entry } // counter within f. func (f *Func) FileLine(pc uintptr) (file string, line int) { // NOTE(rsc): If you edit this function, also edit - // symtab.c:/^funcline. + // symtab.c:/^funcline. That function also has the + // comments explaining the logic. + targetpc := pc + var pcQuant uintptr = 1 if GOARCH == "arm" { pcQuant = 4 } - targetpc := pc p := f.pcln pc = f.pc0 line = int(f.ln0) - file = f.src - for i := 0; i < len(p) && pc <= targetpc; i++ { - switch { - case p[i] == 0: + i := 0 + //print("FileLine start pc=", pc, " targetpc=", targetpc, " line=", line, + // " tab=", p, " ", p[0], " quant=", pcQuant, " GOARCH=", GOARCH, "\n") + for { + for i < len(p) && p[i] > 128 { + pc += pcQuant * uintptr(p[i]-128) + i++ + } + //print("pc<", pc, " targetpc=", targetpc, " line=", line, "\n") + if pc > targetpc || i >= len(p) { + break + } + if p[i] == 0 { + if i+5 > len(p) { + break + } line += int(p[i+1]<<24) | int(p[i+2]<<16) | int(p[i+3]<<8) | int(p[i+4]) - i += 4 - case p[i] <= 64: + i += 5 + } else if p[i] <= 64 { line += int(p[i]) - case p[i] <= 128: + i++ + } else { line -= int(p[i] - 64) - default: - pc += pcQuant * uintptr(p[i]-129) + i++ } + //print("pc=", pc, " targetpc=", targetpc, " line=", line, "\n") pc += pcQuant } + file = f.src return } diff --git a/libgo/go/runtime/hashmap_defs.go b/libgo/go/runtime/hashmap_defs.go deleted file mode 100644 index 57780df..0000000 --- a/libgo/go/runtime/hashmap_defs.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2010 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. - -// Go definitions of internal structures. Master is hashmap.[c,h] - -package runtime - -type hash_hash uintptr - -type hash_entry struct { - hash hash_hash - key byte // dwarf.c substitutes the real type - val byte // for key and val -} - -type hash_subtable struct { - power uint8 - used uint8 - datasize uint8 - max_probes uint8 - limit_bytes int16 - end *hash_entry - entry hash_entry // TODO: [0]hash_entry -} - -type hash struct { - count uint32 - datasize uint8 - max_power uint8 - max_probes uint8 - indirectval uint8 - changes int32 - data_hash func(uint32, uintptr) hash_hash - data_eq func(uint32, uintptr, uintptr) uint32 - data_del func(uint32, uintptr, uintptr) - st *hash_subtable - keysize uint32 - valsize uint32 - datavo uint32 - ko0 uint32 - vo0 uint32 - ko1 uint32 - vo1 uint32 - po1 uint32 - ko2 uint32 - vo2 uint32 - po2 uint32 - keyalg *alg - valalg *alg -} diff --git a/libgo/go/runtime/iface_defs.go b/libgo/go/runtime/iface_defs.go deleted file mode 100644 index 69d52ef..0000000 --- a/libgo/go/runtime/iface_defs.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2010 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 runtime - -/* - * Must match iface.c:/Itable and compilers. - * NOTE: type.go has an Itable, that is the version of Itab used by the reflection code. - */ -type itab struct { - Itype *Type - Type *Type - link *itab - bad int32 - unused int32 - Fn func() // TODO: [0]func() -} diff --git a/libgo/go/runtime/malloc_defs.go b/libgo/go/runtime/malloc_defs.go deleted file mode 100644 index 11d6627..0000000 --- a/libgo/go/runtime/malloc_defs.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2010 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. - -// Go definitions of internal structures. Master is malloc.h - -package runtime - -import "unsafe" - -const ( - pageShift = 12 - pageSize = 1 << pageShift - pageMask = pageSize - 1 -) - -type pageID uintptr - -const ( - numSizeClasses = 67 - maxSmallSize = 32 << 10 - fixAllocChunk = 128 << 10 - maxMCacheListLen = 256 - maxMCacheSize = 2 << 20 - maxMHeapList = 1 << 8 // 1 << (20 - pageShift) - heapAllocChunk = 1 << 20 -) - -type mLink struct { - next *mLink -} - -type fixAlloc struct { - size uintptr - alloc func(uintptr) - first func(unsafe.Pointer, *byte) - arg unsafe.Pointer - list *mLink - chunk *byte - nchunk uint32 - inuse uintptr - sys uintptr -} - - -// MStats? used to be in extern.go - -type mCacheList struct { - list *mLink - nlist uint32 - nlistmin uint32 -} - -type mCache struct { - list [numSizeClasses]mCacheList - size uint64 - local_alloc int64 - local_objects int64 - next_sample int32 -} - -type mSpan struct { - next *mSpan - prev *mSpan - allnext *mSpan - start pageID - npages uintptr - freelist *mLink - ref uint32 - sizeclass uint32 - state uint32 - // union { - gcref *uint32 // sizeclass > 0 - // gcref0 uint32; // sizeclass == 0 - // } -} - -type mCentral struct { - // lock - sizeclass int32 - nonempty mSpan - empty mSpan - nfree int32 -} - -type mHeap struct { - // lock - free [maxMHeapList]mSpan - large mSpan - allspans *mSpan - // map_ mHeapMap - min *byte - max *byte - closure_min *byte - closure_max *byte - - central [numSizeClasses]struct { - pad [64]byte - // union: mCentral - } - - spanalloc fixAlloc - cachealloc fixAlloc -} - -const ( - refFree = iota - refStack - refNone - refSome - refcountOverhead = 4 - refNoPointers = 0x80000000 - refHasFinalizer = 0x40000000 - refProfiled = 0x20000000 - refNoProfiling = 0x10000000 - refFlags = 0xFFFF0000 -) - -const ( - mProf_None = iota - mProf_Sample - mProf_All -) - -type finalizer struct { - next *finalizer - fn func(unsafe.Pointer) - arg unsafe.Pointer - nret int32 -} diff --git a/libgo/go/runtime/mheapmap32_defs.go b/libgo/go/runtime/mheapmap32_defs.go deleted file mode 100644 index 755725b..0000000 --- a/libgo/go/runtime/mheapmap32_defs.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2010 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 runtime - -const ( - mHeapMap_Level1Bits = 10 - mHeapMap_Level2Bits = 10 - mHeapMap_TotalBits = mHeapMap_Level1Bits + mHeapMap_Level2Bits - - mHeapMap_Level1Mask = (1 << mHeapMap_Level1Bits) - 1 - mHeapMap_Level2Mask = (1 << mHeapMap_Level2Bits) - 1 -) - -type mHeapMap struct { - allocator func(uintptr) - p [1 << mHeapMap_Level1Bits]*mHeapMapNode2 -} - -type mHeapMapNode2 struct { - s [1 << mHeapMap_Level2Bits]*mSpan -} diff --git a/libgo/go/runtime/mheapmap64_defs.go b/libgo/go/runtime/mheapmap64_defs.go deleted file mode 100644 index d7ba2b4..0000000 --- a/libgo/go/runtime/mheapmap64_defs.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2010 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 runtime - -const ( - mHeapMap_Level1Bits = 18 - mHeapMap_Level2Bits = 18 - mHeapMap_Level3Bits = 16 - mHeapMap_TotalBits = mHeapMap_Level1Bits + mHeapMap_Level2Bits + mHeapMap_Level3Bits - - mHeapMap_Level1Mask = (1 << mHeapMap_Level1Bits) - 1 - mHeapMap_Level2Mask = (1 << mHeapMap_Level2Bits) - 1 - mHeapMap_Level3Mask = (1 << mHeapMap_Level3Bits) - 1 -) - -type mHeapMap struct { - allocator func(uintptr) - p [1 << mHeapMap_Level1Bits]*mHeapMapNode2 -} - - -type mHeapMapNode2 struct { - p [1 << mHeapMap_Level2Bits]*mHeapMapNode3 -} - - -type mHeapMapNode3 struct { - s [1 << mHeapMap_Level3Bits]*mSpan -} diff --git a/libgo/go/runtime/pprof/pprof.go b/libgo/go/runtime/pprof/pprof.go index d0cc730..9bee511 100644 --- a/libgo/go/runtime/pprof/pprof.go +++ b/libgo/go/runtime/pprof/pprof.go @@ -88,7 +88,6 @@ func WriteHeapProfile(w io.Writer) os.Error { fmt.Fprintf(b, "# Stack = %d / %d\n", s.StackInuse, s.StackSys) fmt.Fprintf(b, "# MSpan = %d / %d\n", s.MSpanInuse, s.MSpanSys) fmt.Fprintf(b, "# MCache = %d / %d\n", s.MCacheInuse, s.MCacheSys) - fmt.Fprintf(b, "# MHeapMapSys = %d\n", s.MHeapMapSys) fmt.Fprintf(b, "# BuckHashSys = %d\n", s.BuckHashSys) fmt.Fprintf(b, "# NextGC = %d\n", s.NextGC) diff --git a/libgo/go/runtime/runtime_defs.go b/libgo/go/runtime/runtime_defs.go deleted file mode 100644 index deea320..0000000 --- a/libgo/go/runtime/runtime_defs.go +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2010 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. - -// Go definitions of internal structures. Master is runtime.h - -// TODO(lvd): automate conversion to all the _defs.go files - -package runtime - -import "unsafe" - -const ( - gidle = iota - grunnable - grunning - gsyscall - gwaiting - gmoribund - gdead - grecovery -) - -// const ( Structrnd = sizeof(uintptr) ) - -type string_ struct { - str *byte - len int32 -} - -type iface struct { - // tab *itab - data unsafe.Pointer -} - -type eface struct { - type_ *Type - data unsafe.Pointer -} - -type complex64 struct { - real float32 - imag float32 -} - -type complex128 struct { - real float64 - imag float64 -} - -type slice struct { - array *byte - len uint32 - cap uint32 -} - -type gobuf struct { - sp unsafe.Pointer - pc unsafe.Pointer - g *g_ -} - -type g_ struct { - stackguard unsafe.Pointer - stackbase unsafe.Pointer - defer_ *defer_ - panic_ *panic_ - sched gobuf - stack0 unsafe.Pointer - entry unsafe.Pointer - alllink *g_ - param unsafe.Pointer - status int16 - goid int32 - selgen uint32 - schedlink *g_ - readyonstop bool - ispanic bool - m *m_ - lockedm *m_ - sig int32 - sigcode0 uintptr - sigcode1 uintptr -} - -type m_ struct { - g0 *g_ - morepc unsafe.Pointer - moreargp unsafe.Pointer - morebuf gobuf - moreframesize uint32 - moreargsize uint32 - cret uintptr - procid uint64 - gsignal *g_ - tls [8]uint32 - sched gobuf - curg *g_ - id int32 - mallocing int32 - gcing int32 - locks int32 - nomemprof int32 - waitnextg int32 - // havenextg note - nextg *g_ - alllink *m_ - schedlink *m_ - machport uint32 - mcache *mCache - lockedg *g_ - freg [8]uint64 - // gostack unsafe.Pointer // __WINDOWS__ -} - -type stktop struct { - stackguard *uint8 - stackbase *uint8 - gobuf gobuf - args uint32 - fp *uint8 - free bool - panic_ bool -} - -type alg struct { - hash func(uint32, unsafe.Pointer) uintptr - equal func(uint32, unsafe.Pointer, unsafe.Pointer) uint32 - print func(uint32, unsafe.Pointer) - copy func(uint32, unsafe.Pointer, unsafe.Pointer) -} - -type sigtab struct { - flags int32 - name *int8 -} - -const ( - sigCatch = (1 << iota) - sigIgnore - sigRestart - sigQueue - sigPanic -) - -type Func struct { - name string - typ string - src string - pcln []byte - entry uintptr - pc0 uintptr - ln0 int32 - frame int32 - args int32 - locals int32 -} - -const ( - aMEM = iota - aNOEQ - aSTRING - aINTER - aNILINTER - aMEMWORD - amax -) - -type defer_ struct { - siz int32 - sp unsafe.Pointer - pc unsafe.Pointer - fn unsafe.Pointer - link *defer_ - args [8]byte // padded to actual size -} - -type panic_ struct { - arg eface - stackbase unsafe.Pointer - link *panic_ - recovered bool -} - -/* - * External data. - */ - -var ( - algarray [amax]alg - emptystring string - allg *g_ - allm *m_ - goidgen int32 - gomaxprocs int32 - panicking int32 - fd int32 - gcwaiting int32 - goos *int8 -) diff --git a/libgo/go/runtime/type.go b/libgo/go/runtime/type.go index 645e364..f5f3ef1 100644 --- a/libgo/go/runtime/type.go +++ b/libgo/go/runtime/type.go @@ -9,7 +9,7 @@ * data structures and must be kept in sync with this file: * * ../../cmd/gc/reflect.c - * ../../cmd/ld/dwarf.c + * ../../cmd/ld/dwarf.c decodetype_* * ../reflect/type.go * type.h */ @@ -32,6 +32,7 @@ type commonType struct { string *string // string form; unnecessary but undeniably useful *uncommonType // (relatively) uncommon fields + ptrToThis *Type // pointer to this type, if used in binary or has methods } // Values for commonType.kind. @@ -71,7 +72,7 @@ const ( type Type commonType // Method on non-interface type -type method struct { +type _method struct { // underscore is to avoid collision with C name *string // name of method pkgPath *string // nil for exported Names; otherwise import path mtyp *Type // method type (without receiver) @@ -84,9 +85,9 @@ type method struct { // Using a pointer to this struct reduces the overall size required // to describe an unnamed type with no methods. type uncommonType struct { - name *string // name of type - pkgPath *string // import path; nil for built-in types like int, string - methods []method // methods associated with type + name *string // name of type + pkgPath *string // import path; nil for built-in types like int, string + methods []_method // methods associated with type } // BoolType represents a boolean type. @@ -151,7 +152,7 @@ type FuncType struct { } // Method on interface type -type imethod struct { +type _imethod struct { // underscore is to avoid collision with C name *string // name of method pkgPath *string // nil for exported Names; otherwise import path typ *Type // .(*FuncType) underneath @@ -160,7 +161,7 @@ type imethod struct { // InterfaceType represents an interface type. type InterfaceType struct { commonType - methods []imethod // sorted by hash + methods []_imethod // sorted by hash } // MapType represents a map type. |