aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/type.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/type.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/type.go')
-rw-r--r--src/runtime/type.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go
index cacf880e9e..a3a19b9be0 100644
--- a/src/runtime/type.go
+++ b/src/runtime/type.go
@@ -471,9 +471,9 @@ func typelinksinit() {
}
typehash := make(map[uint32][]*_type, len(firstmoduledata.typelinks))
- prev := &firstmoduledata
- md := firstmoduledata.next
- for md != nil {
+ modules := activeModules()
+ prev := modules[0]
+ for _, md := range modules[1:] {
// Collect types from the previous module into typehash.
collect:
for _, tl := range prev.typelinks {
@@ -513,7 +513,6 @@ func typelinksinit() {
}
prev = md
- md = md.next
}
}