[invocation-overhead] Fix; .NET Core support #800
Merged
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.
tests/invocation-overheadpartially bitrot since it was lasttouched in 8602581: it insta-crashes:
The primary "cause" is d1cce19: it was never a good idea to P/Invoke
into
jvm.dll, as:The name for
jvm.dlldiffers between platforms! It'sjvmsome places,
jreothers, andjliin still others!If we want (eventual) .NET Framework/.NET Core support, this
is a non-starter.
The actual on-disk path is also highly variable.
The solution to this conundrum was to update the
java-interopnative library to have a new
java_interop_jvm_load()export, anduse that to load the JVM. (Actual determination of which file
to load is left "elsewhere"; once the JVM to load is found, then
we can sanely P/Invoke into
java_interop_jvm_load().)This change never made it to
tests/invocation-overhead.Rework
tests/invocation-overheadso that it's less "stand-alone":it now uses
JreRuntimefromJava.Runtime.Environment.dlltocreate an in-process JVM, using the
$JI_JVM_PATHenvironment variableto determine which JVM to load. (This is how
tests/TestJVMworks.)This change requires "re-structuring" how certain types such as
JniObjectReferencework, as it means we must now referenceJava.Interop.dll, which also definesJniObjectReference/etc.Square this circle by moving various types into the appropriate
sub-namespaces, e.g.
Java.Interop.SafeHandleshas its own specialJniObjectReferencedeclaration."While we're at it", what's .NET Core's JNI invocation performance
look like?
Update
invocation-overheadto multitarget net472 and netcoreapp3.1.Update
src/java-interopso that thejava-interopnative librarycan be built as a netcoreapp3.1 library. (This involves removing
all mention of Mono.)
Update
Java.Runtime.Environmentso thatMonoRuntimeValueManagerdisposes the GC Bridge, not
JreRuntime. This avoids anEntryPointNotFoundException, as thejava-interopnative libdoesn't provide
java_interop_gc_bridge_get_current().Add a new
msbuild /t:Runtarget which runsinvocation-overheadunder both the desktop
$(Runtime)& .NET Core.NET Core is faster than Mono for this particular benchmark:
SafeTimingtiming:XAIntPtrTimingtiming:JIIntPtrTimingtiming:JIPinvokeTimingtiming: