2014-09-03 22:54:06 -06:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
package runtime
|
|
|
|
|
2015-11-02 12:09:24 -07:00
|
|
|
import (
|
|
|
|
"runtime/internal/atomic"
|
|
|
|
_ "unsafe" // for go:linkname
|
|
|
|
)
|
2014-12-22 11:27:53 -07:00
|
|
|
|
2014-12-05 14:24:20 -07:00
|
|
|
//go:generate go run wincallback.go
|
2015-03-31 10:19:10 -06:00
|
|
|
//go:generate go run mkduff.go
|
2015-09-14 15:03:45 -06:00
|
|
|
//go:generate go run mkfastlog2table.go
|
2014-12-05 14:24:20 -07:00
|
|
|
|
2014-09-03 22:54:06 -06:00
|
|
|
var ticks struct {
|
|
|
|
lock mutex
|
2015-01-29 09:54:45 -07:00
|
|
|
pad uint32 // ensure 8-byte alignment of val on 386
|
2014-09-03 22:54:06 -06:00
|
|
|
val uint64
|
|
|
|
}
|
|
|
|
|
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
In linker, refuse to write conservative (array of pointers) as the
garbage collection type for any variable in the data/bss GC program.
In the linker, attach the Go type to an already-read C declaration
during dedup. This gives us Go types for C globals for free as long
as the cmd/dist-generated Go code contains the declaration.
(Most runtime C declarations have a corresponding Go declaration.
Both are bss declarations and so the linker dedups them.)
In cmd/dist, add a few more C files to the auto-Go-declaration list
in order to get Go type information for the C declarations into the linker.
In C compiler, mark all non-pointer-containing global declarations
and all string data as NOPTR. This allows them to exist in C files
without any corresponding Go declaration. Count C function pointers
as "non-pointer-containing", since we have no heap-allocated C functions.
In runtime, add NOPTR to the remaining pointer-containing declarations,
none of which refer to Go heap objects.
In runtime, also move os.Args and syscall.envs data into runtime-owned
variables. Otherwise, in programs that do not import os or syscall, the
runtime variables named os.Args and syscall.envs will be missing type
information.
I believe that this CL eliminates the final source of conservative GC scanning
in non-SWIG Go programs, and therefore...
Fixes #909.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149770043
2014-09-24 14:55:26 -06:00
|
|
|
var tls0 [8]uintptr // available storage for m0's TLS; not necessarily used; opaque to GC
|
|
|
|
|
2014-09-03 22:54:06 -06:00
|
|
|
// Note: Called by runtime/pprof in addition to runtime code.
|
|
|
|
func tickspersecond() int64 {
|
2015-11-02 12:09:24 -07:00
|
|
|
r := int64(atomic.Load64(&ticks.val))
|
2014-09-03 22:54:06 -06:00
|
|
|
if r != 0 {
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
lock(&ticks.lock)
|
|
|
|
r = int64(ticks.val)
|
|
|
|
if r == 0 {
|
|
|
|
t0 := nanotime()
|
|
|
|
c0 := cputicks()
|
|
|
|
usleep(100 * 1000)
|
|
|
|
t1 := nanotime()
|
|
|
|
c1 := cputicks()
|
|
|
|
if t1 == t0 {
|
|
|
|
t1++
|
|
|
|
}
|
|
|
|
r = (c1 - c0) * 1000 * 1000 * 1000 / (t1 - t0)
|
|
|
|
if r == 0 {
|
|
|
|
r++
|
|
|
|
}
|
2015-11-02 12:09:24 -07:00
|
|
|
atomic.Store64(&ticks.val, uint64(r))
|
2014-09-03 22:54:06 -06:00
|
|
|
}
|
|
|
|
unlock(&ticks.lock)
|
|
|
|
return r
|
|
|
|
}
|
2014-09-12 14:12:39 -06:00
|
|
|
|
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
In linker, refuse to write conservative (array of pointers) as the
garbage collection type for any variable in the data/bss GC program.
In the linker, attach the Go type to an already-read C declaration
during dedup. This gives us Go types for C globals for free as long
as the cmd/dist-generated Go code contains the declaration.
(Most runtime C declarations have a corresponding Go declaration.
Both are bss declarations and so the linker dedups them.)
In cmd/dist, add a few more C files to the auto-Go-declaration list
in order to get Go type information for the C declarations into the linker.
In C compiler, mark all non-pointer-containing global declarations
and all string data as NOPTR. This allows them to exist in C files
without any corresponding Go declaration. Count C function pointers
as "non-pointer-containing", since we have no heap-allocated C functions.
In runtime, add NOPTR to the remaining pointer-containing declarations,
none of which refer to Go heap objects.
In runtime, also move os.Args and syscall.envs data into runtime-owned
variables. Otherwise, in programs that do not import os or syscall, the
runtime variables named os.Args and syscall.envs will be missing type
information.
I believe that this CL eliminates the final source of conservative GC scanning
in non-SWIG Go programs, and therefore...
Fixes #909.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149770043
2014-09-24 14:55:26 -06:00
|
|
|
var envs []string
|
|
|
|
var argslice []string
|
|
|
|
|
2014-12-22 11:27:53 -07:00
|
|
|
//go:linkname syscall_runtime_envs syscall.runtime_envs
|
2015-03-03 11:55:22 -07:00
|
|
|
func syscall_runtime_envs() []string { return append([]string{}, envs...) }
|
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
In linker, refuse to write conservative (array of pointers) as the
garbage collection type for any variable in the data/bss GC program.
In the linker, attach the Go type to an already-read C declaration
during dedup. This gives us Go types for C globals for free as long
as the cmd/dist-generated Go code contains the declaration.
(Most runtime C declarations have a corresponding Go declaration.
Both are bss declarations and so the linker dedups them.)
In cmd/dist, add a few more C files to the auto-Go-declaration list
in order to get Go type information for the C declarations into the linker.
In C compiler, mark all non-pointer-containing global declarations
and all string data as NOPTR. This allows them to exist in C files
without any corresponding Go declaration. Count C function pointers
as "non-pointer-containing", since we have no heap-allocated C functions.
In runtime, add NOPTR to the remaining pointer-containing declarations,
none of which refer to Go heap objects.
In runtime, also move os.Args and syscall.envs data into runtime-owned
variables. Otherwise, in programs that do not import os or syscall, the
runtime variables named os.Args and syscall.envs will be missing type
information.
I believe that this CL eliminates the final source of conservative GC scanning
in non-SWIG Go programs, and therefore...
Fixes #909.
LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149770043
2014-09-24 14:55:26 -06:00
|
|
|
|
2014-12-22 11:27:53 -07:00
|
|
|
//go:linkname os_runtime_args os.runtime_args
|
2015-03-03 11:55:22 -07:00
|
|
|
func os_runtime_args() []string { return append([]string{}, argslice...) }
|