aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/plugin.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-10-30 20:30:38 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-11-01 16:04:12 +0000
commit54ec7b072e017f7351f889f9f5b31bbf53a44119 (patch)
tree8e1520eca08765335b77ef904f4ad0f9a2d865b8 /src/runtime/plugin.go
parent807a7ebd5107b44ca93849f2b12b61bc4cacca10 (diff)
downloadgo-54ec7b072e017f7351f889f9f5b31bbf53a44119.tar.gz
go-54ec7b072e017f7351f889f9f5b31bbf53a44119.zip
runtime: access modules via a slice
The introduction of -buildmode=plugin means modules can be added to a Go program while it is running. This means there exists some time while the program is running with the module is on the moduledata linked list, but it has not been initialized to the satisfaction of other parts of the runtime. Notably, the GC. This CL adds a new way of access modules, an activeModules function. It returns a slice of modules that is built in the background and atomically swapped in. The parts of the runtime that need to wait on module initialization can use this slice instead of the linked list. Fixes #17455 Change-Id: I04790fd07e40c7295beb47cea202eb439206d33d Reviewed-on: https://go-review.googlesource.com/32357 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/plugin.go')
-rw-r--r--src/runtime/plugin.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/runtime/plugin.go b/src/runtime/plugin.go
index 91fc275a65..7907936e14 100644
--- a/src/runtime/plugin.go
+++ b/src/runtime/plugin.go
@@ -19,7 +19,7 @@ func plugin_lastmoduleinit() (path string, syms map[string]interface{}) {
throw("runtime: plugin already initialized")
}
- for pmd := &firstmoduledata; pmd != md; pmd = pmd.next {
+ for _, pmd := range activeModules() {
if pmd.pluginpath == md.pluginpath {
println("plugin: plugin", md.pluginpath, "already loaded")
throw("plugin: plugin already loaded")
@@ -43,9 +43,8 @@ func plugin_lastmoduleinit() (path string, syms map[string]interface{}) {
}
// Initialize the freshly loaded module.
+ modulesinit()
typelinksinit()
- md.gcdatamask = progToPointerMask((*byte)(unsafe.Pointer(md.gcdata)), md.edata-md.data)
- md.gcbssmask = progToPointerMask((*byte)(unsafe.Pointer(md.gcbss)), md.ebss-md.bss)
lock(&ifaceLock)
for _, i := range md.itablinks {