]> Cypherpunks repositories - gostls13.git/commit
go/token: use fine-grained locking in FileSet
authorAlan Donovan <adonovan@google.com>
Fri, 16 Dec 2016 18:44:14 +0000 (13:44 -0500)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Jun 2017 06:05:05 +0000 (06:05 +0000)
commit17ba830f4663816c3270860fad96373a833a3b26
tree8a6f8ce2611aae9330f1ee474fadaba4b71d78c6
parent76319222f271a3ed4695466c1bb46dbd0a7885b1
go/token: use fine-grained locking in FileSet

Before, all accesses to the lines and infos tables of each File were
serialized by the lock of the owning FileSet, causing parsers running
in parallel to contend.  Now, each File has its own mutex.

This fixes a data race in (*File).PositionFor, which used to call
f.position then f.unpack without holding the mutex's lock.

Fixes golang/go#18348

Change-Id: Iaa5989b2eba88a7fb2e91c1a0a8bc1e7f6497f2b
Reviewed-on: https://go-review.googlesource.com/34591
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/go/token/position.go
src/go/token/serialize.go