-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor the expressions compiler to use official ClassData BSM with indexed lookup #14602
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
Merged
uschindler
merged 2 commits into
apache:main
from
uschindler:dev/expressionsUseDefaultIndexedBSM
May 1, 2025
Merged
Refactor the expressions compiler to use official ClassData BSM with indexed lookup #14602
uschindler
merged 2 commits into
apache:main
from
uschindler:dev/expressionsUseDefaultIndexedBSM
May 1, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…for indexed lookup
Contributor
Author
|
I also added a new test to make sure that using the same function two times works correct. public void testSameFunctionTwoTimes() throws Exception {
Expression expr = compile("sqrt(20)+abs(-7)+sqrt(30)");
assertEquals(Math.sqrt(20) + 7 + Math.sqrt(30), expr.evaluate(null), DELTA);
}I also verified the bytecode, now looks like this: As you see the default bootstrap method |
asfgit
pushed a commit
that referenced
this pull request
May 1, 2025
… BSM with indexed lookup (#14602) # Conflicts: # lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java
Contributor
Author
|
The backport is the following commit: 6fb9dee |
asfgit
pushed a commit
that referenced
this pull request
May 1, 2025
asfgit
pushed a commit
that referenced
this pull request
May 1, 2025
asfgit
pushed a commit
that referenced
this pull request
May 2, 2025
weizijun
added a commit
to weizijun/lucene
that referenced
this pull request
May 7, 2025
* main: (27 commits) deps(java): bump com.github.luben:zstd-jni from 1.5.7-2 to 1.5.7-3 (apache#14621) Improve user-facing docs for geo package (apache#14534) Enabling histogram collection for PointRangeQuery (apache#14560) Move sloppySin into SloppyMath from GeoUtils (apache#14516) Rewrite APIJAR extractor to use Java 24 classfile API and kill ASM dependency also for build system (apache#14613) CHANGES entry for apache#14226 (optimistic KNN Query) OptimisticKnnVectorQuery (apache#14226) Fix for Windows (spaces in paths) apache#14608 Update jdk requirements in README to OpenJDK 24 (apache#14610) Always check gradle wrapper sha checksum and download if necessary (apache#14608) Fix changelog verifier (apache#14606) MultiRange query for SortedNumeric DocValues (apache#14404) Remove RANDOM_PRELOAD read advice, which is not actually used (apache#14593) Remove duplicate test (apache#14602) Refactor the expressions compiler to use official ClassData BSM with indexed lookup (apache#14602) Disallow EA versions to run Gradle (apache#14601) Add back-compat indices for 10.2.1 Add Lucene 10.2.1 version constant DOAP changes for release 10.2.1 Revert "An attempt to make jenkins pass with the currently installed jdk24-ea. To be reverted later. apache#14600" ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With more review of the code, I thought that it would be better to use one of the default Bootstrap methods available for ClassData. This allows to get rid of our custom BSM method and just use one of the defaults (
MethodHandles#classDataAt()). By default it is possible to supply aListas ClassData and the bootstrap gets the MethodHandle by index. The code for that index was already there and is now reused. Like for the variables, the index is incremented on each new constant (like on each variable) and the index used for lookup.As this change is simple it can also be backported, in the backport I just need to adapt the ASM 'Handle` to point to the default ClassData bootstrap method.