-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add support for extracting from Tasty #1606
Conversation
The CI does not run on Draft PR :) |
Is this anywhere close to working with so few changes? This would be exciting. |
I'm in favor of mergning early and continue experimenting. |
46e3dcd
to
81f18e9
Compare
Tasty files don't need to/cannot be passed explicitly. Instead, they are loaded from the class path lazily by Dotty when needed. In this POC, this is triggered by calling stainless/frontends/dotty/src/main/scala/stainless/frontends/dotc/StainlessExtraction.scala Lines 110 to 122 in 46e3dcd
4c908a8 enables to separately compile
given: // a.scala
package liba
object A:
def f(x: Int): Int =
require(x > 0)
x and: // b.scala
package libb
object B:
def g() =
val x = -1
liba.A.f(x) |
@samuelchassot: the bug I was chasing yesterday was due to the
which is used only from the
not being correctly computed: stainless/frontends/dotty/src/main/scala/stainless/frontends/dotc/StainlessExtraction.scala Lines 71 to 72 in fdf67d4
as it was only |
81f18e9
to
7f6d7cd
Compare
Comparing the last successful CI run on
Runtimes are 55 minutes for However, there is at least one thing wrong:
I need to check what's going there. My guess would be that the detected class path for the Stainless standard library is invalid there. It's strange that it is not detected as an error. Edit: this comes from the setup of Edit 2: fixed. The list of library files now needs to be passed explicitly. |
Nightly failing for |
@mbovel this class wraps existing Scala classes into Stainless ones. I don't know how to do it otherwise in Stainless and it's important functionality. So, we need to avoid triggering the warning and just silently ignore types that are annotated as @extern. The error message actually links to the documentation: https://epfl-lara.github.io/stainless/wrap.html So, we would like this to continue to work as we move to tasty. |
I don't know why the problem is triggered now, but not in the existing solution. I can confirm that replacing val content = new Array[T](size) with val content = (??? : Array[T]) makes it pass. Hence, it appers that |
For now, I have committed a workaround in uarray by putting the problematic |
33b4500
to
fd1a5bd
Compare
symbolMapping | ||
.popUsedTastyUnits() | ||
.filterNot((tree, _) => extractedTastyUnits.contains(tree)) | ||
.filterNot((tree, _) => tree.symbol.ownersIterator.exists(unextractedPackages)) |
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.
For now, I have committed a workaround in uarray by putting the problematic
new Array[T]
in a method marked by @ignore, so the bolts should work ; you can rebase and we can merge.
This is not needed anymore. I am now avoiding to extract Tasty units under scala
and java
to avoid triggering these issues later in the pipeline.
However, this is not a general fix. A similar situation could happen for non-library files: extracting the Tasty unit of a symbol accessed only from within an @exern
method could yield failures when extracting the unit is not required in the first place. This is quite an edge case, I think it could be fixed later.
I should add a comment here.
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.
Done 👍
8bf5f37
to
cf78885
Compare
I rebased on top of The CI passes. |
cf78885
to
a960203
Compare
This PR enables loading trees from Tasty files located on the class path. This feature:
--classpath
option,Implementation
.rootTree
on the unit’s class symbol, which works because the-Yretain-trees
compiler option instructs Dotty to keep Tasty trees.StainlessExtraction.extractTastyUnits
. This method is invoked fromDottyCompiler.runOn
, which runs after all source compilation units have been processed.SymbolMapping
. It can be retrieved withSymbolMapping.popUsedTastyUnits()
. Symbols are added to this set wheneverSymbolMapping.fetch
is called and the fetched symbol has corresponding Tasty information.Performance
For a file that only uses
stainless.lang.{Option,None,Some}
for example, this PR reduces the time for a Stainless compilation cycle from ~7 seconds, to ~0.1 second, both in watch mode and in normal mode.It also reduces the CI time from ~55 minutes to ~32 minutes.