Skip to content

Check that access to context base is singlethreaded. #894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down