Commit Graph

50 Commits

Author SHA1 Message Date
eugene yokota 7df9802f0c Merge pull request #1714 from sbt/wip/bytecode-enhancement
Expose mechanism whereby bytecode enhancement can be run *before* saving incremental compiler hashes.
2014-12-03 08:46:52 -05:00
Josh Suereth 067479f59e Debug issues with implicit usage for CompileSetup.
* Force CompileSetup Equiv typeclass to use Equiv relations defined locally.
* Add toString methods on many of the incremental compiler datatypes.
* Remove remaining binary compatibility issues in Defaults.scala.
2014-12-01 13:35:51 -05:00
Martin Duhem deda8eee70 Remove trait `DependencyContext` in favor of enum
Since `DependencyContext` is needed in the compiler interface
subproject, it has to be defined in this same subproject.

`DependencyContext` is needed in this subproject because the
`AnalysisCallback` interface uses it.
2014-11-19 10:35:07 +01:00
Martin Duhem c09a3912d1 Implement abstraction over dependency kinds
This commit implements the abstraction over the dependency kinds and
deprecates the methods that were used to register files and their
dependencies.

Dependencies are now divided into two categories : Internal and
External dependencies. Moreover, each internal or external dependency
has a Context, which describes what introduced the dependency (for
instance, a dependency may be introduced by member reference or by
inheritance).

Dependencies must now be registered using the method `addSource` in
`Analysis` and in `Relations`. This method has the advantage of being
independent from the existing dependency contexts. That is, its
signature does not need to be modified whenever a new dependency
context is introduced.
2014-11-18 13:07:58 +01:00
Martin Duhem 82152b8905 Don't hardcode existing relations in TextAnalysisFormat
The previous implementation of TextAnalysisFormat contained the list
of all the existing relations that sbt knew of, and used this
information to write to and read from the disk the persisted analyses.

In this knew implementation, TextAnalysisFormat gets from the
Relations object what are the existing relations, and then persists
them to disk.

The previous situation was not optimal since it meant that, in order
to add a new dependency kind, one had to modify both the Relations
and TextAnalysisFormat.

Using this new implementation, no change to TextAnalysisFormat is
required whenever a new dependency kind is added.
2014-09-11 14:45:47 +02:00
Martin Duhem efa71548d1 Add unit tests for TextAnalysisFormat
Those tests use the random Analysis generator that is used in the
unit tests for the subproject `incremental-compiler`.

Random Analyses are serialized and then constructed back from this
representation.
2014-09-03 23:24:08 +02:00
Benjy 00f12c6046 Ensure sequences in analysis files are read in order.
For various reasons, we serialize sequences as:

0 -> foo
1 -> bar
...

Until now we were implicitly relying on the sequences being in order.
However external code may end up (due to bugs or otherwise) messing
with the ordering:

1 -> bar
0 -> foo
...

This change ensures that we don't get confused by that. Although
it's best if external code doesn't mess up the ordering, it's still
a good idea to be defensive about this.

Note that the sequences we serialize are short, so the extra sort
is not a performance concern.
2014-05-17 01:04:14 +00:00
Eugene Yokota adb41611cf added scalariform 2014-05-01 12:50:07 -04:00
Grzegorz Kossakowski c7f435026f Include value of `nameHashing` flag in `CompileSetup`.
The CompileSetup class is being used to detect changes to arguments of
incremental compiler that affect result of compilation and trigger
recompilation. Examples of such arguments include, the target (output)
directory, Scala compiler options, Scala compiler version, etc.

By adding `nameHashing` to CompileSetup we have a chance to handle change
to that flag smoothly by throwing away old Analysis object and starting
with an empty one. That's implemented in AggressiveComile by extending
the logic that was responsible for detection of changes to CompileSetup
values. Thanks to this change we fix #1081.

Analysis formats has been updated to support persisting of newly added
value in CompileSetup. We used to not store the value of `nameHashing`
flag in persisted Analysis file and infer it from contents of relations
but that leads to issue #1071 when empty relations are involved. Given
the fact that CompileSetup stores `nameHashing` value now, we can just
use it when reading relations and fix #1071. This requires reading/writing
compile setup before reading relations. I decided to make that change even
if there's a comment saying that reading/writing relations first was done
intentionally.
2014-02-17 17:00:19 +01:00
Grzegorz Kossakowski 668ae8d8b1 Fix typo in assertion message in TextAnalysisFormat
Add missing string interpolation indicator in assertion message.
2014-01-27 19:41:04 +01:00
Josh Suereth b9489c6035 Fix compilation failure due to missing type annotation. 2014-01-07 21:42:24 -05:00
Benjy 2e1809e17e Make analysis file portable.
Serializes CompileSetup as text instead of base64-encoded
binary-serialized object.

This is necessary so that file paths in the CompileSetup can be
rebased when porting analysis files between systems.
2014-01-07 22:39:47 +00:00
Grzegorz Kossakowski 993aa5b26f Access `Relations.names` conditionally in TextAnalysisFormat
The `Relations.name` is available only when name hashing flag is enabled.

This fixes a regression introduced in
304796bb7a.
2013-12-05 07:49:14 +01:00
Grzegorz Kossakowski 304796bb7a Add support for tracking names used in Scala source files.
Tracking of used names is a component needed by the name hashing
algorithm. The extraction and storage of used names is active only when
`AnalysisCallback.nameHashing` flag is enabled and it's disabled by
default.

This change constists of two parts:

  1. Modification of Relations to include a new `names` relation
     that allows us to track used names in Scala source files
  2. Implementation of logic that extracts used names from Scala
     compilation units (that correspond to Scala source files)

The first part is straightforward: add standard set of methods in
Relations (along with their implementation) and update the logic which
serializes and deserializes Relations.

The second part is implemented as tree walk that collects all symbols
associated with trees. For each symbol we extract a simple, decoded name
and add it to a set of extracted names. Check documentation of
`ExtractUsedNames` for discussion of implementation details.

The `ExtractUsedNames` comes with unit tests grouped in
`ExtractUsedNamesSpecification`. Check that class for details.

Given the fact that we fork while running tests in `compiler-interface`
subproject and tests are ran in parallel which involves allocating
multiple Scala compiler instances we had to bump the default memory limit.

This commit contains fixes for gkossakowski/sbt#3, gkossakowski/sbt#5 and
gkossakowski/sbt#6 issues.
2013-12-03 12:27:29 +01:00
Grzegorz Kossakowski 2a3a3d0d7a Rename Relations.{memberRefAndInheritanceDeps => nameHashing}
The previous name of the flag was rather specific: it indicated
whether the new source dependency tracking is supported by given Relations
object. However, there will be more functionality added to Relations that
is specific to name hashing algorithm. Therefore it makes sense to name
the flag as just `nameHashing`.

I decided to rename Relations implementation classes to be more
consistent with the name of the flag and with the purpose they serve.

The flag in AnalysisCallback (and classes implementing it) has been
renamed as well.
2013-11-28 13:42:39 +01:00
Grzegorz Kossakowski b8371691f2 Introduce `memberRef` and `inheritance` relations.
Introduce an alternative source dependency tracking mechanism that is
needed by upcoming name hashing algorithm. This new mechanism is
implemented by introducing two new source dependency relations called
`memberRef` and `inheritance`.

Those relations are very similar to existing `direct` and
`publicInherited` relations in some subtle ways. Those differences
will be highlighted in the description below.

Dependencies between source files are tracked in two distinct
categories:

  * dependencies introduced by inheriting from a class/trait
    defined in other source file
  * dependencies introduced by referring (selecting) a member
    defined in other source file (that covers all other
    kinds of dependencies)

Due to invalidation algorithm implementation details sbt would need to
track inheritance dependencies of public classes only. Thus, we had
relation called `publicInherited`. The name hashing algorithm which
improves invalidation logic will need more precise information about
dependencies introduced by inheritance including dependencies of non-public
classes. That's one difference between `inheritance` and `publicInherited`
relations.

One surprising (to me) thing about `publicInherited` is that it includes
all base classes of a given class and not just parents. In that sense
`publicInherited` is transitive. This is a bit irregular because
everything else in Relations doesn't include transitive dependencies.

Since we are introducing new relations we have an excellent chance to
make things more regular. Therefore `inheritance` relation is
non-transitive and includes only extracted parent classes.

The access to `direct`, `publicInherited`, `memberRef` and `inheritance`
relations is dependent upon the value of `memberRefAndInheritanceDeps`
flag. Check documentation of that flag for details.

The two alternatives for source dependency tracking are implemented by
introduction of two subclasses that implement Relations trait and one
abstract class that contains some common logic shared between those two
subclasses. The two new subclasses are needed for the time being when we
are slowly migrating to the name hashing algorithm which requires
subtle changes to dependency tracking as explained above. For some time we
plan to keep both algorithms side-by-side and have a runtime switch which
allows to pick one. So we need logic for both old and new dependency
tracking to be available. That's exactly what two subclasses of
MRelationsCommon implement. Once name hashing is proven to be stable and
reliable we'll phase out the old algorithm and the old dependency tracking
logic.
2013-11-26 18:39:13 +01:00
Benjy e6bf85a30b Replace binary Analysis format with a text-based one.
Reads/writes are a little faster with the text format,
and it's far more useful. E.g., it allows external manipulation
and inspection of the analysis.

We don't gzip the output. It does greatly shrink the files,
however it makes reads and writes 1.5x-2x slower, and we're
optimizing for speed over compactness.
2013-11-16 13:59:02 -08:00
Benjy 8779409605 Allow zinc to use InternedAnalysisFormats. 2013-11-04 09:30:28 -05:00
Benjy 3d5a348e1a Deprecate AnalysisFormats. 2013-10-23 11:17:51 -04:00
Benjy 8046ad7eec Added some modifiers, per code review comments. 2013-10-23 10:58:44 -04:00
Benjy 0b033337df Interned serialization format for Analysis objects. 2013-10-22 13:02:53 -04:00
Mark Harrah 49f2f9fe1a Merge remote-tracking branch 'benjy/internpool2' into 0.13 2013-10-17 15:17:43 -04:00
Mark Harrah 4506c8b877 remove dead APIFormats code 2013-10-16 19:26:26 -04:00
Benjy 9c380a9f1f An intern pool implementation, and associated serialization formats. 2013-10-15 13:26:20 -07:00
Mark Harrah 4dc75343ae Record and persist public inheritance dependencies.
Includes placeholders for adding public inherited dependencies for Java classes.
2013-04-26 22:35:27 -04:00
Grzegorz Kossakowski 78b0f485fa Add `compilations` field to `Analysis`.
We store `Seq[xsbt.api.Compilation]` in `Analysis`. Compilation are
being appended to sequence for every iteration of the incremental
compiler.

Note that `Compilation`s are never removed from the sequence unless
you start from scratch with empty `Analysis`. You can do that by using
sbt's `clean` command.

The main use-case for using `compilations` field is to determine how
many iterations it took to compilen give code. The `Compilation` object
are also stored in `Source` objects so there's an indirect way to recover
information about files being recompiled in every iteration.

Since `Analysis` is persisted you can use this mechanism to track entire
sessions spanning multiple `compile` commands.
2012-12-10 09:15:52 -05:00
Grzegorz Kossakowski ef39aeb9c1 Follow source layout convention supported by Eclipse.
Moved source files so directory structure follow package
structure. That makes it possible to use Scala Eclipse plugin
with sbt's source code.
2012-12-07 10:27:08 -08:00
Mark Harrah 18a03f0e25 API extraction: handle any type that is annotated, not just the spec'd simple type. Fixes #559. 2012-10-05 09:06:35 -04:00
Eugene Vigdorchik b5a29987e6 Changes required to use sbt as-is from Scala-IDE. 2012-07-13 14:33:26 -04:00
Eugene Vigdorchik e23df839b7 Make compiler projects compilable with 2.10 2012-07-13 14:33:26 -04:00
Mark Harrah 864580aae1 approximate type parameters and references by name
not as accurate, but simpler.
2012-05-12 23:12:29 -04:00
Mark Harrah 99a04466f1 move to revised warning interface in the compiler 2012-05-06 14:15:03 -04:00
Mark Harrah d837f869bd using some of the embedding interfaces 2012-04-18 11:02:52 -04:00
Mark Harrah 1cbb7ce93c print-warnings task for Scala 2.10+ to avoid needing to rerun 'compile' to see deprecation/unchecked warnings 2012-03-17 19:31:55 -04:00
Mark Harrah 0b3ec05a81 support incremental recompilation when using exportJars. fixes #108 2011-07-18 17:14:22 -04:00
Mark Harrah c0a21c1524 implement shortcut for API equality checking, fixes #18 2011-06-01 02:19:46 -04:00
Mark Harrah 24dfb69400 an annotation can reference a non-simple type, fixes #24 2011-05-23 18:40:03 -04:00
Mark Harrah 06ec88af3d build sxr, api docs and use sbinary 0.4.0 2011-05-17 20:09:20 -04:00
Mark Harrah bf013d2b3f trap all exceptions when restoring cache 2011-04-19 17:54:03 -04:00
Mark Harrah b7f92ae07f 2.9 compatibility fixes 2011-03-04 06:16:35 -05:00
Mark Harrah cc06667f3e handle constant types 2011-02-14 18:59:54 -05:00
Mark Harrah ccf0508ce6 cleanup, small fixes 2010-11-24 14:08:20 -05:00
Mark Harrah 1795ddadb3 Format wrapper for timing read/writes 2010-10-30 15:53:32 -04:00
Mark Harrah aa90051338 go back to using basic Java serialization for API persistence
Java serialization is a bit slower (by 0.15 s for reading scalaz core),
  but it is simpler and more lightweight than using sbinary
still use sbinary Formats for other Analysis data structures
2010-10-30 15:49:18 -04:00
Mark Harrah 9135a26fb3 buffer before gzip when writing analysis data
there were already buffered streams between the gzip streams
  and the file streams; however, the performance improved after
  putting a buffer on top of the gzip streams
2010-10-30 15:46:44 -04:00
Mark Harrah 5ed8f3c042 improving incremental compilation
support lazy arguments in data type generator
SafeLazy implementation that explicitly clears the reference to the thunk
in API representation, drop synthetic modifier and merge deferred into abstract
handle cyclic structures in API generation, display, comparison, persistence
gzip compile cache file
bump to 2.8.1.RC3, project definition cleanup
fix main method detection to check for the right name
properly view inherited definitions
exclude constructors of ancestors
2010-10-22 21:55:16 -04:00
Mark Harrah 0d5814e2b3 Rework external dependency tracking and multi-projects
Reduce AnalysisCallback interface:
  remove discovery
  simplify dependency notification methods
Use map of classpath entry to Analysis for locating
  source API for external dependencies
Handle classpath changes by locating class
  on classpath and either locating Analysis/Source
  as above or comparing Stamp.  This requires storing
  the class name of a binary dependency now.
Make this process aware of full classpath, including
  boot classpath
2010-09-17 21:59:43 -04:00
Mark Harrah d0fa1eb461 * move Environment classes to util/env module
* move TrapExit, SelectMainClass to run module
* rearrange some compilation-related code
* Jetty-related code moved to web module
2010-07-14 19:24:50 -04:00
Mark Harrah 6f3c699435 - Stuart's improvements to triggered execution
- continue splitting original sbt module
 * separated process, testing modules
 * various IO, logging, classpath migration
 * split out javac interface
2010-07-05 12:53:37 -04:00
Mark Harrah 37185c0fb6 discovery, persistence, frontend, and various fixes to incremental 2010-07-02 06:57:03 -04:00