-
Notifications
You must be signed in to change notification settings - Fork 266
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
Implement lazy sequence concatenation in remaining backends #2390
Comments
Implementation strategy is as described in #1775 |
Here are more details on the implementation strategy: Sequences are currently implemented in each runtime via one or more target language classes or similar datatypes, such as ISequence, Sequence, ArraySequence, ConcatSequence etc. in C#. I have a similar common implementation in Dafny code, which will be compiled to each target language as externs with similar names. Then it is only a matter of tweaking code generation for each language to target the Dafny-generated types instead. The remaining challenges that must be addressed are:
The features used to solve 2. and 3. will likely be enabled through CLI options marked as experimental, to avoid too much scope creep. |
What's the long term setup you envision for this? Would it be something like: DafnyPipeline:, has the ability for runtimes to be injected, but does not reference DafnyRuntime |
Yup, something like that, once we break the hard We probably want to make the driver fetch the required runtime from nuget/maven/npm/etc rather than packaging them all inside Dafny itself, but have |
Isn't that dependency spurious, at the moment? Things build fine for me if I just remove it. |
Semi-spurious, yes :) It's a packaging dependency rather than a true build dependency, because ultimately As I'm implementing I'm realizing it makes sense to clean up this dependency as a separate initial change first. We need to also break the assumption in some compilers that the runtime is a single source file like |
Factors out two new projects that don't depend on the `DafnyRuntime` project or `DafnyRuntime.*` runtime artifacts, and removes the DLL-level dependencies on `DafnyRuntime.dll`. It also has the happy side-effect of making directory, csproj, and assembly names consistent. The four main changes are: * Rename `Dafny` folder/`DafnyPipeline` project to `DafnyCore`, remove reference to `DafnyRuntime` and `DafnyRuntime.*` embedded resources * Create new `DafnyPipeline` folder/project, referencing `DafnyCore` and adding `DafnyRuntime.*` embedded resources * Note `DafnyPipeline.dll` does NOT depend on `DafnyRuntime.dll`, however! It has a project-level dependency to ensure `DafnyRuntime` is built first, but only embeds the runtime artifacts. * Relabel `DafnyDriver` as `DafnyDriver.dll` instead of `Dafny.dll`, remove reference to `DafnyRuntime` * I'll be able to use this entry point to build Dafny source code into the runtimes when implementing #2390 * Create new `Dafny` folder/project, referencing `DafnyDriver` and `DafnyPipeline` (and hence pulling in embedded runtimes) Note that we are still only publishing `Dafny.dll` and `DafnyPipeline.dll` as Nuget packages, and they still transitively contain the same content. We could publish `DafnyDriver` and/or `DafnyCore` in the future as well. Removing `DafnyRuntime` as a DLL dependency from all of these projects initially caused the `Test/dafny0/DafnyLibClient.dfy` test to break. This is because the driver was attempting to `Assembly.Load` each DLL passed to it, in order to read any `DafnySourceAttribute` value out of it if present. This has never been a good idea, since an arbitrary DLL will have dependencies not satisfied by the invoking context, and not finding `DafnyRuntime.dll` was just one potential error this could cause. I had previously used [Cecil](https://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cecil/) to read DLL files without loading them, but this was lost when we moved to .NET Core v2 since that library was not supported. This time I've used the built-in `System.Reflection.Metadata.MetadataReader` and related types to decode enough of the DLL to read this attribute.
…untime (#3167) Addresses #2390 for Go, via the strategy described in #1775. ~The only outstanding TODO I'm concerned with is the special-casing in the Go compiler needed to allow `Sequence<T>` to specify a custom equality predicate. I'm open to suggestions on how to improve that: at a minimum it should be checking the full type names, so that we can safely use the fact that the top-level `dafny` module is reserved, but I'm hoping there's a cleaner solution.~ Adds an internal `--bootstrapping` option only for use when compiling Dafny source used in the Dafny implementation itself. Also adds a `--platform` option to `package.py`: while debugging earlier attempts to change the build process, I realized that packaging for Mac OS was often picking the wrong platform. <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>
This is currently only implemented for C# and Java, but is a pretty critical optimization.
I believe it is feasible to implement this logic once in Dafny code instead of N times in each target language.
The text was updated successfully, but these errors were encountered: