Repository navigation
Port oracle/graal#14787: @Value.Optimized allocation-free interface proxies (GR-79503) - #171
Closed
Sam Gammon (sgammon) wants to merge 1 commit into
Closed
Sam Gammon (sgammon) wants to merge 1 commit into
Sam Gammon (sgammon) wants to merge 1 commit into
Conversation
(cherry picked from commit 4cc4d1f)
Member
Author
Open
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
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.
Ports oracle#14787 "[WIP] [GR-79503] Add allocation-free functional interface proxies" (Christian Humer), stacked on #170 (wave 15).
Upstream head at port time:
c5471a1a85e(commits4cc4d1f727aAdd optimized Value interface proxies,c5471a1a85eTarget optimized Value proxies for 25.6), based on upstream49add4294bb. The upstream PR is WIP and may be force-pushed; compare against these SHAs.What it adds
@Value.Optimized: annotating an interface makesValue.as(Interface.class)return a generated proxy class (PolyglotGeneratedProxysubclasses, generated with the Truffle ASM copy,PolyglotProxyGenerator/PolyglotProxyClass) instead of ajava.lang.reflect.Proxy. Each method gets its own call target with typed arguments, so in Native Image with runtime compilation the Java-to-guest call carries noObject[]/boxing:TypedEntrySupportgets exact-entry graph builder plugins for generated proxy entries (with an AOT fallback address when no compiled code exists), the typed return kinds are extended to all primitives (byte, short, char, float added), andPolyglotProxyFeatureregisters annotated interfaces at image build time. Also: host stack traces through generated proxies,HostAccessFromModuleTestcoverage, a JMHFunctionProxyBenchmark, docs inembed-languages.md.Port
4cc4d1f727acherry-picked with-x. One conflict:TruffleFeatureimports (the fork'sSubstrateOptions/SubstrateTargetimports next to the newParsingReason).c5471a1a85enot picked: it only retargets the API to 25.6 (@since 25.6, a new "Version 25.6" CHANGELOG section). The fork is 25.5.5, and4cc4d1f727aalready says@since 25.5with the CHANGELOG entry in the top "Version 25.5" section ofsdk/CHANGELOG.md, which is where the fork wants it. No other adaptation.EE
The typed-entry and proxy code is all CE code (
com.oracle.svm.truffle,org.graalvm.truffle) that the EE hybrid gets from the fork's jars;TruffleFeature(which registers the exact-entry plugin) is required by Oracle'sEnterpriseTruffleFeature. The removedTypedEntrySupport.lookupInterpreterEntryAddress/unspecializedInterpreterEntryAddressare not referenced by ea.05's enterprise jars. Checked on the top of the stack (with oracle#14788): LinkCheck clean, and a native image on the EE home with an@Value.Optimizedinterface over an SL function uses the generated proxy and runs compiled (numbers below).Results (LabsJDK
labsjdk-ce-latest-jvmci-25.5-b24, linux-amd64)mx build --warning-as-error --force-javacin substratevm, truffle and compiler: OK.mx checkstyle --primaryin truffle, sdk, substratevm, compiler: clean.mx sigtest --check allin truffle and sdk: OK.mx -p truffle unittest GuestFunctionToHostInterfaceProxyTest HostAccessFromModuleTest HostStackTraceTest GeneratedProxyNativeImageTest: OK (60 tests).mx -p compiler unittest GenericFunctionProxyCompilationTest: OK (1 test).mx native-truffle-unittest com.oracle.truffle.api.test.polyglot.GeneratedProxyNativeImageTestwith the Truffle native-unittest gate's build args (incl. the new--add-exports=org.graalvm.truffle/com.oracle.truffle.polyglot=ALL-UNNAMED): 13 passed, 1 skipped by its ownassumeFalse(TruffleOptions.AOT).mx -p truffle unittest com.oracle.truffle.api.test.polyglot com.oracle.truffle.api.modularized.test: OK (2376 tests).add(a, b)called 2M times per round through an@Value.Optimizedinterface vs the same interface without the annotation: generated proxy$GeneratedProxy$…(superclassPolyglotGeneratedProxy), engine implementation "Oracle GraalVM", ~9.3 ns/call optimized vs ~18.3 ns/call genericjava.lang.reflect.Proxy, identical sums; no compilation failures withTraceCompilation. CE home: ~9.7 vs ~18.3 ns/call.