aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax
Commit message (Collapse)AuthorAge
* 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
* Remove all dynamic type checking overhead for struct field accesses. These ↵Gravatar nharmata2018-03-08
| | | | | | | checks are unnecessary by construction; see the codepaths that construct SkylarkInfo instances. RELNOTES: None PiperOrigin-RevId: 188373688
* Tag SkylarkType with @AutoCodec.Gravatar mjhalupka2018-03-08
| | | | PiperOrigin-RevId: 188367672
* As a micro-optimization, inline the "Callstack.enabled" guard. The java-land ↵Gravatar nharmata2018-03-08
| | | | | | | | | function call overhead of the morally no-op Callstack#push/pop was profiled to be ~1.4% CPU in a benchmark of loading a BUILD file that was particularly heavy in Skylark function calls. Alternatives considered: writing code that I hoped would be more amenable to the JIT choosing to inline the function call. I couldn't get this to work. RELNOTES: None PiperOrigin-RevId: 188350132
* 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
* Allow passing location, ast, and environment to @SkylarkCallable methodsGravatar cparsons2018-03-07
| | | | | RELNOTES: None. PiperOrigin-RevId: 188201686
* Optimize GC churn of parameter bindings performed before each user defined ↵Gravatar nharmata2018-03-07
| | | | | | | function call. RELNOTES: None PiperOrigin-RevId: 188199514
* Make the builtins registry thread-safeGravatar brandjon2018-03-06
| | | | | | | | | | | | | | It was previously assumed that safety wasn't needed because 1) all builtins should be registered in static initializer blocks, and 2) all retrievals should occur during Skylark evaluation, after static initialization completes. It turns out these assumptions aren't actually true (Who would've thunk it!). SkylarkActionFactory has been observed to be initialized as late as analysis time, and retrievals occur as early as constructing a PackageFactory (when scanning the native module). The failure mode is particularly ugly: Random Skylark method lookups will fail non-deterministically. This change guards against this by making the builtins registry implement a form of freezing. Before freezing, reads and writes are allowed and are synchronized. After freezing, only reads are allowed and they are unsynchronized for performance. BlazeRuntime is responsible for flipping the bit, and for ensuring classes like SkylarkActionFactory run their initialization by that point. Unit tests don't need to worry, since they just stay unfrozen and synchronized throughout. RELNOTES: None PiperOrigin-RevId: 188080136
* Add a command line option to disallow vardef()s with three arguments.Gravatar lberki2018-03-06
| | | | | RELNOTES: None. PiperOrigin-RevId: 188038131
* @AutoCodec for TypeGravatar shahan2018-03-05
| | | | | | Needed for Attribute serialization. PiperOrigin-RevId: 187907727
* Get rid of almost all Skylark codecs. We need to introduce a wrapper to turn ↵Gravatar janakr2018-03-03
| | | | | | | | ObjectCodec into a MEMOIZE_AFTER MemoizingCodec. I think that this is safe, because all the codecs that are being wrapped this way weren't memoizing anything internally that I could see. In order to @AutoCodec the WithValue type, which is generic and can have null elements in lists, add functionality to @AutoCodec to deal with generic type static instantiators, matching generic type arguments (although I'm not sure why that wasn't already working), and null elements in lists. PiperOrigin-RevId: 187740461
* Create --incompatible_disable_objc_provider_resources to disable deprecated ↵Gravatar cparsons2018-03-01
| | | | | | | | | objc provider skylark fields. This flag is not fully implemented -- there should also be a way to disable the provider getters using this flag, but, since @SkylarkCallable does not allow for evaluation of SkylarkSemantics, this is not yet possible. RELNOTES: None. PiperOrigin-RevId: 187542004
* Migrate a few trivial uses of @SkylarkSignature to use @SkylarkCallable insteadGravatar cparsons2018-03-01
| | | | | RELNOTES: None. PiperOrigin-RevId: 187531006
* 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
* Remove --incompatible_load_argument_is_label flagGravatar laurentlb2018-03-01
| | | | | | RELNOTES: Removed flag `--incompatible_load_argument_is_label`. PiperOrigin-RevId: 187479614
* Deprecate native git_repositoryGravatar Klaus Aehlig2018-03-01
| | | | | | | | | | | | | | The skylark implementation of git_repository is a drop-in replacement for the native workspace rule. So deprecate the latter to avoid having two implementations of the same. Also, the native rule pulls in quite some dependencies. RELNOTES: The native git_repository rule is deprecated. Use the Skylark version available via load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") instead. Change-Id: Id75d8e7b7377acd1092c4ba993f488be86c03fa0 PiperOrigin-RevId: 187466931
* Correct docstring for skylark string.split().Gravatar Googler2018-03-01
| | | | | RELNOTES: None. PiperOrigin-RevId: 187453379
* Deletes CODEC fields now that they are no longer needed.Gravatar shahan2018-02-28
| | | | PiperOrigin-RevId: 187397314
* Deprecate and remove several uses of the 'values' map in NativeInfo subclasses.Gravatar cparsons2018-02-28
| | | | | | | | | | These subclasses should be using @SkylarkCallable(structField = true) instead This is a bit of a memory win, as there is now no need to store field information twice. There are still a couple of stragglers that are more difficult, namely ToolchainInfo and DefaultInfo. Their APIs will likely need some more extensive revamping before proceeding. RELNOTES: None. PiperOrigin-RevId: 187364392
* Optimize GC churn of funcall evaluation for the common-case where there are noGravatar nharmata2018-02-27
| | | | | | | duplicate named arguments. RELNOTES: None PiperOrigin-RevId: 187236124
* Optimize format string parsingGravatar michajlo2018-02-27
| | | | | | | | Avoid throwing an execption if we don't have to, stack traces are expensive to fill in. RELNOTES: None PiperOrigin-RevId: 187199392
* Optimize LValue#boundIdentifiers for common caseGravatar michajlo2018-02-26
| | | | | | | | | | I'm assuming most of the time folks are only assigning one variable, which doesn't require an ImmutableSet.Builder and the garbage it comes with. Also took the liberty of removing some unused InterruptedException declarations. PiperOrigin-RevId: 187068400
* Optimize SkylarkNestedSet constructionGravatar michajlo2018-02-26
| | | | | | | | | | | | | | Only check/update type if the types of elements that we're adding changes. In particular, the "is DICT/LIST" check can get expensive when run on every single inserted element. According to a hacky unit test (create 10M element SkylarkNestedSet 10x over) this is ~60% faster (~18s -> ~7s). This change is intended to be a quick fix, there's surely a more principled way to make skylark's type checking more efficient... PiperOrigin-RevId: 187062547
* Micro-optimize if-block evaluationGravatar michajlo2018-02-26
| | | | | | Most of the time there's only one, doesn't justify the iterator overhead. PiperOrigin-RevId: 187031802
* Keep the order of select branches the same as it was in the BUILD file.Gravatar lberki2018-02-26
| | | | | | | This is a change from behavior introduced in unknown commit, which was added to preserve determinism even though the ordering of dicts in Python is non-deterministic. Now that we don't call into Python anymore, this is not necessary. RELNOTES: None (select branches are mutually exclusive, so this is a no-op) PiperOrigin-RevId: 187022575
* Keep order of dict attributes the same as it was in the BUILD file.Gravatar lberki2018-02-26
| | | | | | | | This is a change from behavior introduced in unknown commit, which was added to preserve determinism even though the ordering of dicts in Python is non-deterministic. Now that we don't call into Python anymore, this is not necessary. RELNOTES[INC]: The order of dict-valued attributes is now the order in the BUILD file (or in the Skylark dict they were created from) and not lexicographically sorted. PiperOrigin-RevId: 187003317
* Clarify parser error for load() statementsGravatar brandjon2018-02-22
| | | | | RELNOTES: None PiperOrigin-RevId: 186693205
* Define the dict iteration orderGravatar vladmos2018-02-22
| | | | PiperOrigin-RevId: 186616752
* Set default of --incompatible_disable_glob_tracking to trueGravatar laurentlb2018-02-21
| | | | | RELNOTES: None. PiperOrigin-RevId: 186470386
* Deletes POLYMORPHIC strategy. ObjectCodec now uses runtime type information ↵Gravatar shahan2018-02-20
| | | | | | to select a codec. PiperOrigin-RevId: 186378153
* Decprecate native http_archiveGravatar Klaus Aehlig2018-02-20
| | | | | | | | | | | | | | | Since the skylark implementation of http_archive provides all the features available in the native http_archive and a few more (patching), there is no need to have to rule implementations doing the same thing. Hence deprecate the native one as part of our plan of moving more functionality to skylark. RELNOTES: The native http_archive rule is deprecated. Use the Skylark version available via load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") instead. Change-Id: I107c2f25f5a37c67f56b4362e7c9d9ade8428c16 PiperOrigin-RevId: 186314624
* Change Skylark's print() on a rule target to print the Skylark-exposed ↵Gravatar cparsons2018-02-16
| | | | | | | | | provider keys. This change only affects printing a rule target directly -- it intentionally does not affect the behavior of str(target), as we want to avoid skylark code being able to parse potentially-private provider keys. RELNOTES: In skylark, print(target) now shows the provider keys of a target, as debug information. PiperOrigin-RevId: 186046226
* Remove old flags.Gravatar laurentlb2018-02-16
| | | | | | RELNOTES: Removed flags `--incompatible_checked_arithmetic`, `--incompatible_dict_literal_has_no_duplicates`, `--incompatible_disallow_keyword_only_args`, and ` --incompatible_comprehension_variables_do_not_leak`. PiperOrigin-RevId: 185977740
* Remove unused LineNumberTable.HashLine class.Gravatar laurentlb2018-02-15
| | | | | RELNOTES: None. PiperOrigin-RevId: 185838543
* Environment guarantees determinism when retrieving its bindingsGravatar brandjon2018-02-13
| | | | | | | Added a little javadoc and tests. RELNOTES: None PiperOrigin-RevId: 185569985
* Create a basic annotation processor for validating SkylarkCallable uses at ↵Gravatar cparsons2018-02-12
| | | | | | | compile time. RELNOTES: None. PiperOrigin-RevId: 185432867
* Skylark: SlicingExpression: do not create new nodes for optional expressionsGravatar laurentlb2018-02-12
| | | | | RELNOTES: None. PiperOrigin-RevId: 185353994
* Replace path implementation.Gravatar tomlu2018-02-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Path and PathFragment have been replaced with String-based implementations. They are pretty similar, but each method is dissimilar enough that I did not feel sharing code was appropriate. A summary of changes: PATH ==== * Subsumes LocalPath (deleted, its tests repurposed) * Use a simple string to back Path * Path instances are no longer interned; Reference equality will no longer work * Always normalized (same as before) * Some operations will now be slower, like instance compares (which were previously just a reference check) * Multiple identical paths will now consume more memory since they are not interned PATH FRAGMENT ============= * Use a simple string to back PathFragment * No more segment arrays with interned strings * Always normalized * Remove isNormalized * Replace some isNormalizied uses with containsUpLevelReferences() to check if path fragments try to escape their scope * To check if user input is normalized, supply static methods on PathFragment to validate the string before constructing a PathFragment * Because PathFragments are always normalized, we have to replace checks for literal "." from PathFragment#getPathString to PathFragment#getSafePathString. The latter returns "." for the empty string. * The previous implementation supported efficient segment semantics (segment count, iterating over segments). This is now expensive since we do longer have a segment array. ARTIFACT ======== * Remove Path instance. It is instead dynamically constructed on request. This is necessary to avoid this CL becoming a memory regression. RELNOTES: None PiperOrigin-RevId: 185062932
* Add debugging helper to Environment.Extension to say why something's unequalGravatar brandjon2018-02-06
| | | | | RELNOTES: None PiperOrigin-RevId: 184649483
* Expose structField callable methods of skylark objects to dir() and str() callsGravatar cparsons2018-02-05
| | | | | RELNOTES: None. PiperOrigin-RevId: 184498836
* Fix string_list_dict values to be skylark lists in all casesGravatar cparsons2018-01-31
| | | | | RELNOTES: None. PiperOrigin-RevId: 184016150
* Remove Skylark ConfigurationTransition.DATA references.Gravatar gregce2018-01-29
| | | | PiperOrigin-RevId: 183733621
* Allows @AutoCodec to use factory methods.Gravatar shahan2018-01-29
| | | | | | Generalizes @AutoCodec.Constructor to @AutoCodec.Instantiator. PiperOrigin-RevId: 183702768
* Improve documentation for the select functionGravatar vladmos2018-01-22
| | | | PiperOrigin-RevId: 182796843
* Improve documentation for depsets.Gravatar Googler2018-01-22
| | | | PiperOrigin-RevId: 182767783
* Add serialization codec for SkylarkImports. This is needed to serialize ↵Gravatar janakr2018-01-18
| | | | | | | | SkylarkAspectLoadingKey. Also add a @VisibleForSerialization annotation to @AutoCodec, since we're going to need to increase serialization visibility a lot here, and clean up some unnecessary modifiers. PiperOrigin-RevId: 182389162
* Fix forbidding of If statements in BUILD filesGravatar brandjon2018-01-17
| | | | | | | | | The bug also permitted For statements in BUILD files so long as they were contained within an If statement (i.e. not at the top level). Also add minor guidance to error messages. RELNOTES: None PiperOrigin-RevId: 182236172
* Codec for Location.Gravatar shahan2018-01-16
| | | | | | * Moves SingletonCodec to third_party. PiperOrigin-RevId: 182143153
* Fix value collision in builtins registryGravatar brandjon2018-01-16
| | | | | | | If two values compared equal (e.g., MethodLibrary#bool and SkylarkAttr#bool), we were dropping one of them in favor of the other. RELNOTES: None PiperOrigin-RevId: 182057611