-
Notifications
You must be signed in to change notification settings - Fork 29
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
Viper data collection changes #751
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ import scalaz.Scalaz.futureInstance | |
import viper.gobra.ast.internal.Program | ||
import viper.gobra.ast.internal.transform.{CGEdgesTerminationTransform, ConstantPropagation, InternalTransform, OverflowChecksTransform} | ||
import viper.gobra.backend.BackendVerifier | ||
import viper.gobra.backend.ViperBackends.{CarbonBackend, SiliconBackend} | ||
import viper.gobra.frontend.PackageResolver.{AbstractPackage, RegularPackage} | ||
import viper.gobra.frontend.Parser.ParseResult | ||
import viper.gobra.frontend.info.{Info, TypeInfo} | ||
|
@@ -26,7 +27,11 @@ import viper.gobra.translator.Translator | |
import viper.gobra.util.Violation.{KnownZ3BugException, LogicException, UglyErrorMessage} | ||
import viper.gobra.util.{DefaultGobraExecutionContext, GobraExecutionContext} | ||
import viper.silicon.BuildInfo | ||
import viper.silver.ast.pretty.FastPrettyPrinter | ||
import viper.silver.utility.ManualProgramSubmitter | ||
import viper.silver.{ast => vpr} | ||
import viper.silver.ast.pretty.FastPrettyPrinter | ||
import viper.silver.utility.ManualProgramSubmitter | ||
|
||
import java.time.format.DateTimeFormatter | ||
import java.time.LocalTime | ||
|
@@ -51,6 +56,8 @@ object GoVerifier { | |
|
||
trait GoVerifier extends StrictLogging { | ||
|
||
protected var submitters: Map[String, ManualProgramSubmitter] = Map() | ||
|
||
def name: String = { | ||
this.getClass.getSimpleName | ||
} | ||
|
@@ -82,9 +89,18 @@ trait GoVerifier extends StrictLogging { | |
} | ||
}) | ||
|
||
val viperBackendName: String = config.backend match { | ||
case CarbonBackend => "Carbon" | ||
case SiliconBackend => "Silicon" | ||
Comment on lines
+93
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not exhaustive. What if we have a viper server with silicon or carbon? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, we should extend the trait |
||
} | ||
|
||
val timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); | ||
config.packageInfoInputMap.keys.foreach(pkgInfo => { | ||
val pkgId = pkgInfo.id | ||
|
||
//adds a submitter for this package to submitters if config.submitForEvaluation is set, key is pkgId | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like the wrong place for this comment. Sth like this should be in |
||
createSubmitter(config.submitForEvaluation, pkgId, viperBackendName) | ||
|
||
logger.info(s"Verifying package $pkgId [${LocalTime.now().format(timeFormatter)}]") | ||
val future = verify(pkgInfo, config.copy(reporter = statsCollector, taskName = pkgId))(executor) | ||
.map(result => { | ||
|
@@ -95,6 +111,12 @@ trait GoVerifier extends StrictLogging { | |
warningCount += warnings.size | ||
warnings.foreach(w => logger.debug(w)) | ||
|
||
submitters.get(pkgId).foreach(s => { | ||
s.setSuccess(result == VerifierResult.Success) | ||
s.submit()} | ||
) | ||
submitters = submitters.removed(pkgId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we removing this here? |
||
|
||
result match { | ||
case VerifierResult.Success => logger.info(s"$name found no errors") | ||
case VerifierResult.Failure(errors) => | ||
|
@@ -143,6 +165,13 @@ trait GoVerifier extends StrictLogging { | |
if (allErrors.isEmpty) VerifierResult.Success else VerifierResult.Failure(allErrors) | ||
} | ||
|
||
private def createSubmitter(allowSubmission: Boolean, id: String, verifier: String): Unit = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should make the signature of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a better name would be |
||
if (allowSubmission) { | ||
val submitter = new ManualProgramSubmitter(true, "", "Gobra", verifier, Array()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we actually submitting anything if the second parameter is always There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, I find it a bit odd that we have a flag |
||
submitters = submitters + (id -> submitter) | ||
} | ||
} | ||
|
||
protected[this] def verify(pkgInfo: PackageInfo, config: Config)(implicit executor: GobraExecutionContext): Future[VerifierResult] | ||
} | ||
|
||
|
@@ -163,6 +192,10 @@ class Gobra extends GoVerifier with GoIdeVerifier { | |
viperTask <- performViperEncoding(finalConfig, pkgInfo, program) | ||
} yield (viperTask, finalConfig) | ||
|
||
submitters.get(pkgInfo.id).foreach(s => task.bimap( | ||
_ => s.setAllowSubmission(false), //don't submit since no viper program could be produced | ||
{ case (job, _) => s.setProgram(FastPrettyPrinter.pretty(job.program)) })) | ||
|
||
task.foldM({ | ||
case Vector() => Future(VerifierResult.Success) | ||
case errors => Future(VerifierResult.Failure(errors)) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -77,6 +77,7 @@ object ConfigDefaults { | |||||
val DefaultDisableCheckTerminationPureFns: Boolean = false | ||||||
val DefaultUnsafeWildcardOptimization: Boolean = false | ||||||
val DefaultEnableMoreJoins: Boolean = false | ||||||
val DefaultSubmitForEvaluation = false | ||||||
} | ||||||
|
||||||
// More-complete exhale modes | ||||||
|
@@ -145,6 +146,7 @@ case class Config( | |||||
requireTriggers: Boolean = ConfigDefaults.DefaultRequireTriggers, | ||||||
disableSetAxiomatization: Boolean = ConfigDefaults.DefaultDisableSetAxiomatization, | ||||||
disableCheckTerminationPureFns: Boolean = ConfigDefaults.DefaultDisableCheckTerminationPureFns, | ||||||
submitForEvaluation: Boolean = ConfigDefaults.DefaultSubmitForEvaluation, | ||||||
unsafeWildcardOptimization: Boolean = ConfigDefaults.DefaultUnsafeWildcardOptimization, | ||||||
enableMoreJoins: Boolean = ConfigDefaults.DefaultEnableMoreJoins, | ||||||
|
||||||
|
@@ -200,6 +202,7 @@ case class Config( | |||||
requireTriggers = requireTriggers || other.requireTriggers, | ||||||
disableSetAxiomatization = disableSetAxiomatization || other.disableSetAxiomatization, | ||||||
disableCheckTerminationPureFns = disableCheckTerminationPureFns || other.disableCheckTerminationPureFns, | ||||||
submitForEvaluation = submitForEvaluation || other.submitForEvaluation, | ||||||
unsafeWildcardOptimization = unsafeWildcardOptimization && other.unsafeWildcardOptimization, | ||||||
enableMoreJoins = enableMoreJoins || other.enableMoreJoins, | ||||||
) | ||||||
|
@@ -258,6 +261,7 @@ case class BaseConfig(gobraDirectory: Path = ConfigDefaults.DefaultGobraDirector | |||||
requireTriggers: Boolean = ConfigDefaults.DefaultRequireTriggers, | ||||||
disableSetAxiomatization: Boolean = ConfigDefaults.DefaultDisableSetAxiomatization, | ||||||
disableCheckTerminationPureFns: Boolean = ConfigDefaults.DefaultDisableCheckTerminationPureFns, | ||||||
submitForEvaluation: Boolean = ConfigDefaults.DefaultSubmitForEvaluation, | ||||||
unsafeWildcardOptimization: Boolean = ConfigDefaults.DefaultUnsafeWildcardOptimization, | ||||||
enableMoreJoins: Boolean = ConfigDefaults.DefaultEnableMoreJoins, | ||||||
) { | ||||||
|
@@ -275,6 +279,7 @@ case class BaseConfig(gobraDirectory: Path = ConfigDefaults.DefaultGobraDirector | |||||
case _ => Some(positions.toVector) | ||||||
} | ||||||
} | ||||||
def allowSubmission: Boolean = submitForEvaluation && !shouldChop | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why can't we submit chopped programs? |
||||||
} | ||||||
|
||||||
trait RawConfig { | ||||||
|
@@ -320,6 +325,7 @@ trait RawConfig { | |||||
requireTriggers = baseConfig.requireTriggers, | ||||||
disableSetAxiomatization = baseConfig.disableSetAxiomatization, | ||||||
disableCheckTerminationPureFns = baseConfig.disableCheckTerminationPureFns, | ||||||
submitForEvaluation = baseConfig.allowSubmission, | ||||||
unsafeWildcardOptimization = baseConfig.unsafeWildcardOptimization, | ||||||
enableMoreJoins = baseConfig.enableMoreJoins, | ||||||
) | ||||||
|
@@ -765,6 +771,13 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals | |||||
default = Some(ConfigDefaults.DefaultDisableSetAxiomatization), | ||||||
noshort = true, | ||||||
) | ||||||
|
||||||
val submitForEvaluation = opt[Boolean](name = "submitForEvaluation", | ||||||
descr = "Whether to allow storing the current program for future evaluation.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(I think there is already a variable for the tool name, we can use that directly instead of hardcoding "Gobra") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding a sentence saying that we collect only the program and no other information would also be important. |
||||||
default = Some(false), | ||||||
noshort = true | ||||||
) | ||||||
|
||||||
/** | ||||||
* Exception handling | ||||||
*/ | ||||||
|
@@ -964,6 +977,7 @@ class ScallopGobraConfig(arguments: Seq[String], isInputOptional: Boolean = fals | |||||
requireTriggers = requireTriggers(), | ||||||
disableSetAxiomatization = disableSetAxiomatization(), | ||||||
disableCheckTerminationPureFns = disableCheckTerminationPureFns(), | ||||||
submitForEvaluation = submitForEvaluation(), | ||||||
unsafeWildcardOptimization = unsafeWildcardOptimization(), | ||||||
enableMoreJoins = enableMoreJoins(), | ||||||
) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add some documentation on this? what is the purpose of this field? what are the keys and the values?