aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/FuncallExpression.java
Commit message (Collapse)AuthorAge
* [Skylark] Avoid unnecessary subList invocations.Gravatar Taras Tsugrii2018-08-14
| | | | | | | | | | It's better to not add `self` positional argument if it's not needed, instead of adding it and removing it laster on. `subList` invoaction results in more allocations and CPU overhead when using positional args. Closes #5812. PiperOrigin-RevId: 208687360
* Don't convert InterruptException to EvalException in struct field call ↵Gravatar Benjamin Peterson2018-08-08
| | | | | | | | | | | expressions. This is probably only a theoretical problem, since a blocking struct field is probably a very bad idea. Closes #5132. Change-Id: Ie84a78ab4d9ce215f2806ac49bf8911de6959930 PiperOrigin-RevId: 207902766
* [Skylark] Improve Skylark interpreter performance.Gravatar Taras Tsugrii2018-08-02
| | | | | | | | | | | | | According to JMH and JIT assembly generated for iterators and index accesses, iterator methods like `hasNext` and `next` are not optimized away and result in 3-4X slower execution. Not using an iterator reduces Buck parse time for FB's internal Android apps by 7%+. Closes #5735. PiperOrigin-RevId: 207073078
* [Skylark] Avoid unnecessary allocations.Gravatar Taras Tsugrii2018-08-01
| | | | | | | | | Since this happens only every single Skylark method invocation CPU and memory usage quickly adds up and shows up on profiler samples a lot. Closes #5656. PiperOrigin-RevId: 206935520
* [Skylark] Move method invocation logic to MethodDescriptor.Gravatar Taras Tsugrii2018-07-31
| | | | | | | | | | | | | | | | | | This serves 2 purposes: - better encapsulation and domain model. - opens the door to optimizations like using `MethodHandle` instead of `Method` and caching. - performs one of the optimizations mentioned above - perform `setAccessible` only once instead of on every method invocation. JMH suggests that this saves ~5% of CPU time. Next steps are: - evaluate peformance improvements for some of the optimizations listed above - make PRs to apply optimizations that seem beneficial. Closes #5704. PiperOrigin-RevId: 206805670
* [Skylark] Cache isParamNamed computation.Gravatar Taras Tsugrii2018-07-31
| | | | | | | | | | When `isLegacyNamed` is `true`, `named` is considered to be `true` as well, so instead of going through an extra indirection and computation, just use `named` field to store combined result. Closes #5701. PiperOrigin-RevId: 206800781
* [Skylark] Size argument list builder to avoid allocations.Gravatar Taras Tsugrii2018-07-30
| | | | | | | | | | | This change is focused on 2 things: - avoid creating builders in case they don't end up being used - create builders using the maximum expected size to avoid intermediate allocations to accommodate more elements Closes #5694. PiperOrigin-RevId: 206636046
* [Skylark] Use POJOs instead of dynamic proxies.Gravatar Taras Tsugrii2018-07-30
| | | | | | | | | | | | | | Java uses dynamically generated proxy classes to access annotation properties and their methods are ~7X slower than plain getters. According to async-profiler 50%+ of `convertArgumentList` method time is spent in dynamic proxy methods, so optimizing their performance makes sense. This also makes the model less anemic, since POJOs can actually provide business methods. Closes #5666. PiperOrigin-RevId: 206608812
* Cache default parameter values for skylark methods, and compute types of ↵Gravatar cparsons2018-07-25
| | | | | | | | | Param annotations only once. This change has been manually verified to greatly reduce analysis time (~50%) on very large builds, as it mitigates a previous regression brought on by the migration of @SkylarkSignature to @SkylarkCallable. RELNOTES: None. PiperOrigin-RevId: 206063684
* [Perf] Remove unnecessary ImmutableMap.copyOf invocation.Gravatar Taras Tsugrii2018-07-25
| | | | | | | | | `keyWordArgs` is already `ImmutableMap<String, Object>` and `copyOf` contains enough overhead to show up on parse profiles. Closes #5651. PiperOrigin-RevId: 206051798
* Remove SkylarkCallable.mandatoryPositionalsGravatar cparsons2018-07-13
| | | | | RELNOTES: None. PiperOrigin-RevId: 204505003
* Make @SkylarkCallable.name mandatory.Gravatar cparsons2018-06-22
| | | | | RELNOTES: None. PiperOrigin-RevId: 201748802
* Allow structField callables to specify useSkylarkSemantics, useLocation, and ↵Gravatar cparsons2018-06-20
| | | | | | | | | | useEnvironment Unfortunately this doesn't work for all callers, namely NativeInfo objects, as they may have structField callables invoked from contexts that have no environment available. RELNOTES[INC]: Skylark structs (using struct()) may no longer have to_json and to_proto overridden. PiperOrigin-RevId: 201376969
* Introduce @SkylarkCallable.selfCall, to signify the containing class should ↵Gravatar cparsons2018-04-24
| | | | | | | | | | | | be treated as a callable skylark object. This will allow Skylark Provider objects to be better specified. For example, "JavaInfo" can have a fully-documented, fully-specified @SkylarkCallable method with selfCall=true to represent the method JavaInfo(), instead of being a subclass of BaseFunction and requiring a @SkylarkSignature annotation. There are no usages of this pattern introduced in this CL, and also no updates to docgen to support the new pattern. These will be introduced in another CL. RELNOTES: None. PiperOrigin-RevId: 194088227
* Handle InterruptedException thrown from @SkylarkCallable methods appropriately.Gravatar cparsons2018-04-18
| | | | | RELNOTES: None. PiperOrigin-RevId: 193370435
* Migrate StringModule methods to SkylarkCallable from SkylarkSignature.Gravatar cparsons2018-04-11
| | | | | | | StringModule is a special case in a number of places because it represents effectively methods which should be annotated on String.class. However, String may not be subclassed in Java. StringModule thus serves as a proxy module for String. RELNOTES: None. PiperOrigin-RevId: 192508607
* Introduce Param.legacyNamed() to handle migration from @SkylarkSignature to ↵Gravatar cparsons2018-04-11
| | | | | | | | | | @SkylarkCallable. @SkylarkSignature.parameters() treat named()=true for parameters regardless of whether named() was actually set to true, and thus for ease of migration we mark migrated parameters as legacyNamed() = true, which is currently semantically equivalent to named() = true. We make a distinction so that it's easier to bulk fix these later. RELNOTES: None. PiperOrigin-RevId: 192477405
* Introduce extraPositonals and extraArguments to SkylarkCallable, to have ↵Gravatar cparsons2018-04-09
| | | | | | | | | parity with @SkylarkSignature. This is necessary for several builtin functions that still use @SkylarkSignature, such as string format. These will be migrated in a future CL. RELNOTES: None. PiperOrigin-RevId: 192200282
* Cleanup @SkylarkCallable parameters and their error handling.Gravatar cparsons2018-04-06
| | | | | | | This involves enforcing additional compiletime restrictions on Param ordering and semantics. RELNOTES: None. PiperOrigin-RevId: 191927206
* Migrate SkylarkNativeModule methods to use @SkylarkCallable instead of ↵Gravatar cparsons2018-04-04
| | | | | | | | | @SkylarkSignature Most notably, this involves introduction of a new function abstraction, BuiltinMethod, which can wrap a {objc, SkylarkCallable} pair into a BaseFunction for later calling. (This is required due to the current layer of indirection on the end "native" module) RELNOTES: None. PiperOrigin-RevId: 191642467
* Replaces JavaSerializableCodec with DynamicCodec as the defaultGravatar shahan2018-04-04
| | | | | | | | | * Skylark serialization was previously dropping location in error, which this fixes. * Deletes a lot of codecs with fidelity issues (DynamicCodec has full fidelity). * Deletes EnumRuntimeCodec which can now be replaced with the superior EnumCodec. * This should eventually allow us to delete Serializable from all Blaze. The remaining blocker is NoSuchPackageExceptionCodec. PiperOrigin-RevId: 191603929
* Don't bound the method and field name caches in FuncallExpression.Gravatar nharmata2018-03-23
| | | | | | | | | | | The number of *unique* Class instances that will be used as keys in these caches over the lifetime of a Bazel server is small-ish, and bounded by the size of the set of unique Classes used as the Java runtime representation of Skylark objects. The bookkeeping done by LocalCache when the cache's size is bounded is therefore pure CPU overhead. While we're here, just use the default capacity (16); a smaller initial capacity seems silly considering these caches are live for the duration of the Bazel server. RELNOTES: None PiperOrigin-RevId: 190238099
* Create useSkylarkSemantics for @SkylarkCallable, so annotated methods can ↵Gravatar cparsons2018-03-22
| | | | | | | | | | | specifically get a semantics object This is slightly redundant with useEnvironment, yes (as one can easily obtain the semantics object with Environment), but we intend on restricting useEnvironment so that structField=true methods cannot specify useEnvironment, but *can* specify useSkylarkSemantics. In general, we can also ween off non structField methods to use useSkylarkSemantics instead of useEnvironment in cases where this is feasible. RELNOTES: None. PiperOrigin-RevId: 190082547
* Change error messaging of @SkylarkCallable invocations to match ↵Gravatar cparsons2018-03-21
| | | | | | | | | @SkylarkSignature more closely. Also clarify the method representation in these error messages is for the attempted method *call*, not the actual method signature. RELNOTES: None. PiperOrigin-RevId: 189935148
* Allow passing location, ast, and environment to @SkylarkCallable methodsGravatar cparsons2018-03-07
| | | | | RELNOTES: None. PiperOrigin-RevId: 188201686
* 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
* 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
* Create a basic annotation processor for validating SkylarkCallable uses at ↵Gravatar cparsons2018-02-12
| | | | | | | compile time. RELNOTES: None. PiperOrigin-RevId: 185432867
* Expose structField callable methods of skylark objects to dir() and str() callsGravatar cparsons2018-02-05
| | | | | RELNOTES: None. PiperOrigin-RevId: 184498836
* Register builtins with RuntimeGravatar brandjon2017-12-07
| | | | | | | | | | | This covers all builtins in classes that use SkylarkSignatureProcessor#configureSkylarkFunctions. Generally this means things you define with @SkylarkSignature. It is now an error to call configureSkylarkFunctions multiple times for the same class. It should only be called in static initializers. Runtime's static knowledge of builtins has been factored into Runtime.BuiltinRegistry. RELNOTES: None PiperOrigin-RevId: 178295926
* 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
* Reduce iterator usage on hot code pathsGravatar michajlo2017-10-07
| | | | | | | | Micro-optimize a few hot code paths which have a habit of iterating over short O(1)-access lists. RELNOTES: None PiperOrigin-RevId: 171347524
* Skylark Documentation: sort methods by method signatureGravatar dmarting2017-10-06
| | | | | | | getMethods ordering is not guaranteed and actually change depending on minor difference in the class path. PiperOrigin-RevId: 171093246
* Check parameter types for methods when multiple types are allowed.Gravatar Dmitry Lomov2017-09-25
| | | | | | | | | | | | | | | Relanding https://github.com/bazelbuild/bazel/commit/17214ac78ffaec369d5d5bafe62a39730473cfaa with fixes to 'repository_ctx.download()' and 'repository_ctx.download_and_extract()'. I reviewed other usages of @ParamType annotation - I do not think there are more issues. Fixes #3714. Change-Id: I17087ef3fc2d28ab99224740a2164675a49847d3 PiperOrigin-RevId: 169896223
* Remove wasteful function.toString() call in evalArgs. Also remove functions ↵Gravatar shreyax2017-09-25
| | | | | | that were public because of skylark compilation. PiperOrigin-RevId: 169739373
* Automated rollback of commit 17214ac78ffaec369d5d5bafe62a39730473cfaa.Gravatar dslomov2017-09-22
| | | | | | | | | | | | | | | | | | *** Reason for rollback *** Rolled back commit enforces stricter parameter checks. Will fix and roll forward This creates several failures on the nightly build of Bazel: ERROR: /home/ci/workspace/Global/rules_closure-node=linux-x86_64/closure/protobuf/test/BUILD:23:1: no such package '@com_google_protobuf_protoc//': Cannot convert parameter 'url' to type string or sequence of strings, in method download_and_extract(List, string, string, string, string) of 'repository_ctx' and referenced by '//closure/protobuf/test:example_proto_gen'. ERROR: Analysis of target '//closure/protobuf/test:example_lib' failed; build aborted: no such package '@com_google_protobuf_protoc//': Cannot convert parameter 'url' to type string or sequence of strings, in method download_and_extract(List, string, string, string, string) of 'repository_ctx'. *** Original change description *** Check parameter types for methods when multiple types are allowed. Fixes #3714 RELNOTES: None. PiperOrigin-RevId: 169669802
* Check parameter types for methods when multiple types are allowed.Gravatar dslomov2017-09-20
| | | | | | Fixes #3714 RELNOTES: None. PiperOrigin-RevId: 169382686
* Introduce enum to quickly discriminate AST nodes.Gravatar laurentlb2017-08-25
| | | | | RELNOTES: None. PiperOrigin-RevId: 166370036
* Remove validate() methods in the AST, use a visitor instead.Gravatar laurentlb2017-08-18
| | | | | | | This is a simple refactoring, no change in behavior. RELNOTES: None. PiperOrigin-RevId: 165572028
* Remove methods that shouldn't belong to FuncallExprGravatar fzaiser2017-08-17
| | | | | RELNOTES: None PiperOrigin-RevId: 165419360
* Fix Skylark parsing of call expressions.Gravatar fzaiser2017-08-14
| | | | | | | | This allows more complex expressions to be called, not just identifiers. For example, "x[0]()" is not a syntax error anymore. RELNOTES: None PiperOrigin-RevId: 165157981
* Refactor FuncallExpression to allow for complex function terms later.Gravatar fzaiser2017-08-14
| | | | | RELNOTES: None. PiperOrigin-RevId: 164981071
* Misc cleanups of AST node APIGravatar brandjon2017-07-12
| | | | | | | | | - changed field names and a couple accessors to consistently use full words ("statement" instead of "stmt") - applied several local analyzers (from IntelliJ) to remove redundant modifiers, unnecessary explicit types (yay Java 8), etc. RELNOTES: None PiperOrigin-RevId: 161551096
* Clean up string representations for labelsGravatar vladmos2017-07-05
| | | | | | | | | | | If --incompatible_descriptive_string_representations is passed, labels are converted to strings using `repr` differently: `Label("//package:name")` instead of `"//package:name"` This CL doesn't affect representations of other object types but provides the necessary infrastructure for it. PiperOrigin-RevId: 160955284
* Migrate tests to ctx.actions.run/run_shell.Gravatar dslomov2017-07-05
| | | | | RELNOTES: None. PiperOrigin-RevId: 160817326
* 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
* Enable SkylarkCallable methods to be used on ClassObjects.Gravatar Michael Staib2017-03-22
| | | | | | | | | | | | | | | Previously, ClassObjects' SkylarkCallable struct fields worked as expected (with values of the struct taking precedence), but calling methods annotated with SkylarkCallable did not work at all; methods were treated as if they were not present in the struct. This adds some tests for the various ways of looking up fields and methods, and rearranges the logic in FuncallExpression to allow for callable methods on SkylarkClassObject's descendants. -- PiperOrigin-RevId: 150876181 MOS_MIGRATED_REVID=150876181
* Raise error in function calls when star argument is not iterableGravatar Laurent Le Brun2017-02-20
| | | | | | | | This was a bug, f(*4) was silently handled as f(). -- PiperOrigin-RevId: 148017021 MOS_MIGRATED_REVID=148017021
* Delete the bytecode compiler experiment.Gravatar Laurent Le Brun2017-01-23
| | | | | | | | | The code has been untouched and unused for over a year (it's very likely broken) and we have other priorities for now. -- PiperOrigin-RevId: 145087310 MOS_MIGRATED_REVID=145087310