diff options
author | Dmitry Petrashko <dark@d-d.me> | 2015-10-31 12:33:01 +0100 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2015-10-31 12:33:01 +0100 |
commit | c5fedba675ce958715d1ff35a78a3e71f9a55d97 (patch) | |
tree | 46b6d5521993d0c245a56d35f2651270f71a7db9 /src | |
parent | cdfcbc166a331421eaf9a4e9bf64f5c885da19a4 (diff) | |
parent | 5b2d94a274abe82d26687f1c6ef19fb1d57df2dd (diff) | |
download | dotty-c5fedba675ce958715d1ff35a78a3e71f9a55d97.tar.gz dotty-c5fedba675ce958715d1ff35a78a3e71f9a55d97.tar.bz2 dotty-c5fedba675ce958715d1ff35a78a3e71f9a55d97.zip |
Merge pull request #894 from dotty-staging/check-singlethreaded
Check that access to context base is singlethreaded.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index 114f994be..ba86e3e70 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -50,6 +50,7 @@ class Run(comp: Compiler)(implicit ctx: Context) { } protected def compileUnits() = Stats.monitorHeartBeat { + ctx.checkSingleThreaded() val phases = ctx.squashPhases(ctx.phasePlan, ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, ctx.settings.YstopAfter.value, ctx.settings.Ycheck.value) ctx.usePhases(phases) diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index f9d64b2cc..d5fdba1af 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -611,6 +611,16 @@ object Contexts { superIdOfClass.clear() lastSuperId = -1 } + + // Test that access is single threaded + + /** The thread on which `checkSingleThreaded was invoked last */ + @sharable private var thread: Thread = null + + /** Check that we are on the same thread as before */ + def checkSingleThreaded() = + if (thread == null) thread = Thread.currentThread() + else assert(thread == Thread.currentThread(), "illegal multithreaded access to ContextBase") } object Context { |