Skip to content
Snippets Groups Projects
Commit 622632df authored by Nicolas Voirol's avatar Nicolas Voirol Committed by Ravi
Browse files

synchronized evaluator invariant cache & small fix in codegen

parent e04ac67a
No related branches found
No related tags found
No related merge requests found
...@@ -213,9 +213,13 @@ class CompilationUnit(val ctx: LeonContext, ...@@ -213,9 +213,13 @@ class CompilationUnit(val ctx: LeonContext,
case CaseClass(cct, args) => case CaseClass(cct, args) =>
caseClassConstructor(cct.classDef) match { caseClassConstructor(cct.classDef) match {
case Some(cons) => case Some(cons) =>
val tpeParam = if (cct.tps.isEmpty) Seq() else Seq(cct.tps.map(registerType).toArray) try {
val jvmArgs = monitor +: (tpeParam ++ args.map(valueToJVM)) val tpeParam = if (cct.tps.isEmpty) Seq() else Seq(cct.tps.map(registerType).toArray)
cons.newInstance(jvmArgs.toArray : _*).asInstanceOf[AnyRef] val jvmArgs = monitor +: (tpeParam ++ args.map(valueToJVM))
cons.newInstance(jvmArgs.toArray : _*).asInstanceOf[AnyRef]
} catch {
case e : java.lang.reflect.InvocationTargetException => throw e.getCause
}
case None => case None =>
ctx.reporter.fatalError("Case class constructor not found?!?") ctx.reporter.fatalError("Case class constructor not found?!?")
} }
......
...@@ -138,14 +138,15 @@ object Evaluator { ...@@ -138,14 +138,15 @@ object Evaluator {
case object Pending extends CheckStatus case object Pending extends CheckStatus
case object NoCheck extends CheckStatus case object NoCheck extends CheckStatus
def invariantCheck(cc: CaseClass): CheckStatus = def invariantCheck(cc: CaseClass): CheckStatus = synchronized {
if (!cc.ct.classDef.hasInvariant) Complete(true) if (!cc.ct.classDef.hasInvariant) Complete(true)
else checkCache.get(cc).getOrElse { else checkCache.get(cc).getOrElse {
checkCache(cc) = Pending checkCache(cc) = Pending
NoCheck NoCheck
} }
}
def invariantResult(cc: CaseClass, success: Boolean): Unit = { def invariantResult(cc: CaseClass, success: Boolean): Unit = synchronized {
checkCache(cc) = Complete(success) checkCache(cc) = Complete(success)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment