aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/Environment.java
Commit message (Collapse)AuthorAge
* Moves the decision to enable memoization from codecs to the top-level ↵Gravatar shahan2018-04-02
| | | | | | | | invocation. Also, makes it benign to registerInitialValue when memoization is disabled. PiperOrigin-RevId: 191338253
* Automated rollback of commit 316cd7da6f6b003b853ccf7d144f395a9a557400.Gravatar janakr2018-03-26
| | | | | | | | *** Reason for rollback *** Roll-forward with fix (equality and hashcode for relevant classes). Also add a bit more debugging info in case of failure. PiperOrigin-RevId: 190492934
* Use an immutable Attribute factory in objects that are persisted to ↵Gravatar janakr2018-03-22
| | | | | | Skyframe, rather than the potentially mutable builder, and @AutoCodec SkylarkAttr.Descriptor. PiperOrigin-RevId: 190118565
* @AutoCodec some expressions that show up in Java configured targets.Gravatar janakr2018-03-16
| | | | PiperOrigin-RevId: 189419493
* Integrate memoization into standard serialization. This involves a number of ↵Gravatar janakr2018-03-13
| | | | | | | | | | | | | | | | large changes: 1. SerializationContext and DeserializationContext become the owners of the Memoizer if requested. They produce new versions of themselves on demand that are memoization-aware. Because of intricacies of Skylark that I do not fully understand, we inject a Mutability object when starting memoization, and so to be conservative, that injection starts up a new memoization frame, nested if we were already memoizing, just like before. It would be nice to decouple this injection from memoization in the future. 2. MemoizingCodec is deleted, but really ObjectCodec becomes MemoizingCodec, so it lives on. BaseCodec is deleted since it now has only one implementation. 3. The simplified model of registering MemoizingCodecs is adopted for ObjectCodecs: all codecs are registered based on their #getEncodedClass and #additionalEncodedSubclasses. This also allows us to register codecs that are defined using tricky parameter types, since we're no longer trying to reflectively examine them. This required a clean-up of such codecs, and the addition of ArrayListCodec to stop NullableListCodec from making lists unmodifiable when they shouldn't be. 4. @AutoCodec is extended to allow users to specify that memoization should start with this codec. To ensure bit-equivalence, SkyKeySerializer disables memoization. PiperOrigin-RevId: 188918251
* Optimize GC churn of parameter bindings performed before each user defined ↵Gravatar nharmata2018-03-08
| | | | | | | | | | | | | | | function call. This is the 2nd attempt at this commit. The first attempt (https://github.com/bazelbuild/bazel/commit/f1013485d41efd8503f9d4f937e17d1b4bc91ed3) was rolled back because it introduced the following two bugs: (1) The side effects of Environment#enterScope are relevant: it creates and stores a new Continuation that has a reference to the set currently referenced by 'knownGlobalVariables', and then overwrites the value of the variable. When there are e.g. nested function calls, 'knownGlobalVariables' will be wrong in the Environment used to stage the inner call (see the added test for an example). (2) The finally block in UserDefinedFunction#call assumes the env.enterScope was called. Because of the EvalException (incorrectly) thrown due to (1), this is no longer true. I restructured the code such that (2) isn't possible and I also added a unit test that would have caught the two bugs. In my first attempt, I was doing too much - I was also trying to save the CPU-costs in the env.update call (dispatches to the just-created lexical frame, and calls LexicalFrame#put, which does an unnecessary mutability sanity check, etc) and in doing so completely missed the above bugs. Sorry. RELNOTES: None PiperOrigin-RevId: 188411737
* Automated rollback of commit f1013485d41efd8503f9d4f937e17d1b4bc91ed3.Gravatar nharmata2018-03-07
| | | | | | | | | | | | | *** Reason for rollback *** Introduced a bug in skylark that caused intellij TAP test to fail. The bug was not caught by any skylark/blaze/bazel tests. *** Original change description *** Optimize GC churn of parameter bindings performed before each user defined function call. RELNOTES: None PiperOrigin-RevId: 188249713
* Optimize GC churn of parameter bindings performed before each user defined ↵Gravatar nharmata2018-03-07
| | | | | | | function call. RELNOTES: None PiperOrigin-RevId: 188199514
* Remove hacky cast now that Copybara is updated to use GlobalFrameGravatar nharmata2018-03-01
| | | | | | | (https://github.com/google/copybara/commit/77a0e68eb0b044449b412e939ad25d500d2c12d3). RELNOTES: None PiperOrigin-RevId: 187525928
* Make the distinction between "global frame" and "lexical frame" explicit. As ↵Gravatar nharmata2018-03-01
| | | | | | | a nice consequence, this lets us reduce GC churn since we no longer need to create a frame instance for the lexical frame at a callsite of either a function when the environment is frozen or a builtin function (since builtins cannot modify bindings in their lexical frame). RELNOTES: None PiperOrigin-RevId: 187495787
* Environment guarantees determinism when retrieving its bindingsGravatar brandjon2018-02-13
| | | | | | | Added a little javadoc and tests. RELNOTES: None PiperOrigin-RevId: 185569985
* Add debugging helper to Environment.Extension to say why something's unequalGravatar brandjon2018-02-06
| | | | | RELNOTES: None PiperOrigin-RevId: 184649483
* Replace all usages of Blaze's Preconditions class with guava.Gravatar tomlu2017-11-09
| | | | | | | | Blaze had its own class to avoid GC from varargs array creation for the precondition happy path. Guava now (mostly) implements these, making it unnecessary to maintain our own. This change was almost entirely automated by search-and-replace. A few BUILD files needed fixing up since I removed an export of preconditions from lib:util, which was all done by add_deps. There was one incorrect usage of Preconditions that was caught by error prone (which checks Guava's version of Preconditions) that I had to change manually. PiperOrigin-RevId: 175033526
* Optimize recursive call detectionGravatar michajlo2017-10-24
| | | | | | | No need to contruct a list for each function call RELNOTES: None PiperOrigin-RevId: 173144689
* Require semantics field for Environment.BuilderGravatar brandjon2017-10-23
| | | | | | | Follow-up of unknown commit. RELNOTES: None PiperOrigin-RevId: 172922507
* Be explicit about semantics of Skylark environmentsGravatar brandjon2017-10-23
| | | | | | | | | All callers that do not use Environment.Builder#setSemantics should call #useDefaultSemantics. A follow-up CL will enforce this requirement. Motivation: It's more important that we are strict about semantics than about the other builder args. It's too easy for a mistake in semantics to go unnoticed. RELNOTES: None PiperOrigin-RevId: 172912829
* Add useDefaultSemantics() to Enviornment.BuilderGravatar brandjon2017-10-20
| | | | | RELNOTES: None PiperOrigin-RevId: 172801656
* Pass SkylarkSemantics through Skyframe instead of the options classGravatar brandjon2017-10-06
| | | | | | | Also remove the use of the @UsesOnlyCoreTypes annotation on SkylarkSemanticsOptions. It was only there to help mark that the options class was safe to put in Skyframe. RELNOTES: None PiperOrigin-RevId: 171248504
* Use SkylarkSemantics in place of options class in the interpreterGravatar brandjon2017-10-06
| | | | | | | Mainly this just means using getters instead of fields to access option values. RELNOTES: None PiperOrigin-RevId: 171101597
* Clarify Mutability invariants, refactor some testsGravatar brandjon2017-09-29
| | | | | RELNOTES: None PiperOrigin-RevId: 170343759
* Add a way to construct Frames in a two-step processGravatar brandjon2017-08-29
| | | | | RELNOTES: None PiperOrigin-RevId: 166857589
* Cleanup javadoc around Mutability / SkylarkMutableGravatar brandjon2017-08-03
| | | | | | | | | Also throw IllegalArgumentException instead of AssertionError. A follow-up CL will look to eliminate the SkylarkMutable#checkMutable(Location, Environment) override in favor of checkMutable(Location, Mutability). This will make it easier to manipulate Skylark values in specialized contexts aside from normal evaluation. RELNOTES: None PiperOrigin-RevId: 163978262
* Clean up a few Skylark-Skyframe structuresGravatar brandjon2017-07-19
| | | | | | | Add value-class methods to SkylarkFileDependency and SkylarkImportLookupValue. Remove Java serialization hack from Extension. RELNOTES: None PiperOrigin-RevId: 162383283
* Fix crash when unioning depsets with different ordersGravatar brandjon2017-07-14
| | | | | | | Also refactor FAIL_FAST_HANDLER to throw something more specific than IllegalArgumentException. This bug was masked because the test assertion that would've caught it considered IllegalArgumentException to be an expected error, the same as EvalException. RELNOTES: None PiperOrigin-RevId: 161809957
* Misc cleanups of syntax dirGravatar brandjon2017-07-12
| | | | | RELNOTES: None PiperOrigin-RevId: 161560683
* Refactor PrinterGravatar vladmos2017-07-03
| | | | | | | It's now easier to customize Printer if in different situations objects should be printed differently. Also its API is cleaner now. Names of methods of SkylarkValue objects now reflect names of Skylark functions: SkylarkValue#repr and SkylarkPrintableValue#str. PiperOrigin-RevId: 160635154
* Add a pretty printer for Skylark ASTsGravatar brandjon2017-06-28
| | | | | | | This can be used to canonically compare ASTs for equality, e.g. in tests. RELNOTES: None PiperOrigin-RevId: 160283160
* Introduce --incompatible_comprehension_variables_do_not_leakGravatar laurentlb2017-06-14
| | | | | | | | | | | | | When the flag is activated, variables in list comprehensions do not leak anymore. Even if a variable was defined before the loop, it's not accessible after the loop. This change allows us to detect any breakage and ensures that no user is accessing loop variables after the loop. This will make possible for us to change the behavior and follow Python 3 semantics in the future. RELNOTES: None. PiperOrigin-RevId: 158895514
* Clean up API for the Extension classGravatar brandjon2017-05-09
| | | | | RELNOTES: None PiperOrigin-RevId: 155507750
* Clean up Environment.FrameGravatar brandjon2017-05-09
| | | | | | | | | Make fields visibility/accessors more idiomatic. Prefer accessors that give a full map of the bindings and inherited bindings, rather than just the keys. Also increase visibility of some accessors on Mutability. RELNOTES: None PiperOrigin-RevId: 155393780
* Refactor "isMutable" -> "isFrozen"Gravatar brandjon2017-05-04
| | | | | | | | | This helps readability, particularly since we also have "isImmutable" for SkylarkValues and in EvalUtils. I considered changing those to isFrozen as well, but we can leave it as-is since the terminology of freezing doesn't necessarily apply to non-Freezable things. Also rephrased some javadoc. RELNOTES: None PiperOrigin-RevId: 155090987
* Make Skylark interpreter read Skylark command-line flagsGravatar brandjon2017-04-30
| | | | | | | | | | | This is the second of two CLs for making command line options able to affect the Skylark interpreter. For the main kinds of evaluation contexts -- package loading, .bzl loading, rule analysis, aspect analysis, and computed defaults -- the SkylarkSemanticsOptions object is retrieved from Skyframe and passed along to the Environment builder. For other contexts such as tests, default values of builtin functions, and standalone Skylark, flags are currently not processed. In the future, we may want to split into separate files the options that affect "pure" Skylark vs the options that affect Bazel-flavored Skylark. One possibility is to subclass SkylarkSemanticsOptions into SkylarkBazelSemanticsOptions, and go through an indirection in SkylarkUtils. We could also pass SkylarkSemanticsOptions to the parser, to support --incompatible_* changes that alter Skylark's syntax. I don't think that's needed at the moment. RELNOTES: None PiperOrigin-RevId: 154628391
* Make frame bindings use LinkedHashMap for determinismGravatar Jon Brandvein2017-01-19
| | | | | | | | | This matters when the same rule (or other exportable) is bound to multiple variables, since the identifier of the first variable will become its name. -- PiperOrigin-RevId: 144881310 MOS_MIGRATED_REVID=144881310
* Add 'did you mean' suggestion for load() statements.Gravatar Laurent Le Brun2017-01-03
| | | | | | -- PiperOrigin-RevId: 143381556 MOS_MIGRATED_REVID=143381556
* Add 'did you mean' suggestion when accessing an undefined variable.Gravatar Laurent Le Brun2017-01-03
| | | | | | -- PiperOrigin-RevId: 143373605 MOS_MIGRATED_REVID=143373605
* Rollback of commit 7c4a8093da6272969c86f22a08c72ddbbf6e8274.Gravatar Kristina Chodorow2016-12-02
| | | | | | | | | | | | | | | | | *** Reason for rollback *** Broke //src/test/shell/bazel:external_skylark_load_test See http://ci.bazel.io/job/bazel-tests/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/370/console, for example. *** Original change description *** Remove callerLabel from Environment. It is a Bazel-specific information. -- MOS_MIGRATED_REVID=140742037
* Remove callerLabel from Environment.Gravatar Laurent Le Brun2016-12-01
| | | | | | | It is a Bazel-specific information. -- MOS_MIGRATED_REVID=140719791
* Remove isSkylark and eval from Environment.Gravatar Laurent Le Brun2016-11-29
| | | | | -- MOS_MIGRATED_REVID=140371603
* Remove Environment.parseFileGravatar Laurent Le Brun2016-11-23
| | | | | -- MOS_MIGRATED_REVID=140037282
* Minor refactoring in SkylarkUtilsGravatar Laurent Le Brun2016-11-22
| | | | | | | Next step will be to move Environment.Phase to SkylarkUtils.BazelInfo -- MOS_MIGRATED_REVID=139902745
* Fix a bunch of typosGravatar Jon Brandvein2016-11-10
| | | | | -- MOS_MIGRATED_REVID=138757881
* Move ToolsRepository out of EnvironmentGravatar Laurent Le Brun2016-10-27
| | | | | | | | | Other fields will follow (is_skylark, phase, callerLabel). The goal is to make Environment (and more generally Skylark) less dependent on Bazel. -- MOS_MIGRATED_REVID=137386248
* Cleanup: remove isSkylark in Environment ContinuationGravatar Laurent Le Brun2016-10-27
| | | | | -- MOS_MIGRATED_REVID=137272887
* Cleanup in Environment, remove unused lookup functionGravatar Laurent Le Brun2016-10-27
| | | | | -- MOS_MIGRATED_REVID=137266170
* Cleanup, remove differences between Build and Skylark environments.Gravatar Laurent Le Brun2016-10-14
| | | | | | | | | | | | | The only visible difference for users is that a few more functions are available in BUILD files. That's fine, this difference was not even documented. RELNOTES: A few functions are added to BUILD files for consistency (hash, dir, hasattr, getattr) with .bzl files, although they are not very useful. -- MOS_MIGRATED_REVID=136151633
* Automated cleanupGravatar Laurent Le Brun2016-10-12
| | | | | -- MOS_MIGRATED_REVID=135816105
* Remove support for "Python" parsing mode.Gravatar Laurent Le Brun2016-10-07
| | | | | | | It was unused in Bazel. -- MOS_MIGRATED_REVID=135483937
* Deprecation warnings for deprecated syntaxGravatar Vladimir Moskva2016-09-16
| | | | | | | | | RELNOTES: Global varaiables HOST_CFG and DATA_CFG are deprecated in favor of strings "host" and "data. Argument `cfg = "host"` or `cfg = "data"` is mandatory if `executable = True` is provided for a label. -- MOS_MIGRATED_REVID=133285197
* Move SkylarkImport from LoadStatement to BuildFileASTGravatar Miguel Alcon Pinto2016-08-22
| | | | | | | This allow us to skip the import validation in non-build usages. -- MOS_MIGRATED_REVID=130936612
* Roll forward fix of global var shadow detectionGravatar Jon Brandvein2016-08-12
| | | | | | | RELNOTES[INC]: Skylark: It is an error to shadow a global variable with a local variable after the global has already been accessed in the function. -- MOS_MIGRATED_REVID=130014492