Skip to content
Permalink
Browse files
8264774: Implementation of Foreign Function and Memory API (Incubator)
Co-authored-by: Paul Sandoz <psandoz@openjdk.org>
Co-authored-by: Jorn Vernee <jvernee@openjdk.org>
Co-authored-by: Vladimir Ivanov <vlivanov@openjdk.org>
Co-authored-by: Athijegannathan Sundararajan <sundar@openjdk.org>
Co-authored-by: Chris Hegarty <chegar@openjdk.org>
Reviewed-by: psandoz, chegar, mchung, vlivanov
  • Loading branch information
6 people committed Jun 2, 2021
1 parent 71425dd commit a223189b069a7cfe49511d49b5b09e7107cb3cab
Showing with 10,889 additions and 5,648 deletions.
  1. +5 −0 src/hotspot/cpu/aarch64/foreign_globals_aarch64.cpp
  2. +10 −0 src/hotspot/cpu/aarch64/frame_aarch64.cpp
  3. +4 −4 src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
  4. +9 −0 src/hotspot/cpu/aarch64/universalUpcallHandler_aarch64.cpp
  5. +29 −0 src/hotspot/cpu/x86/foreign_globals_x86.cpp
  6. +33 −2 src/hotspot/cpu/x86/frame_x86.cpp
  7. +0 −2 src/hotspot/cpu/x86/javaFrameAnchor_x86.hpp
  8. +3 −3 src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp
  9. +18 −8 src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
  10. +9 −0 src/hotspot/cpu/x86/universalUpcallHandler_x86_32.cpp
  11. +707 −0 src/hotspot/cpu/x86/universalUpcallHandler_x86_64.cpp
  12. +1 −6 src/hotspot/share/ci/ciNativeEntryPoint.cpp
  13. +1 −2 src/hotspot/share/ci/ciNativeEntryPoint.hpp
  14. +0 −6 src/hotspot/share/classfile/javaClasses.cpp
  15. +0 −3 src/hotspot/share/classfile/javaClasses.hpp
  16. +1 −1 src/hotspot/share/classfile/vmSymbols.hpp
  17. +27 −0 src/hotspot/share/code/codeBlob.cpp
  18. +35 −0 src/hotspot/share/code/codeBlob.hpp
  19. +1 −0 src/hotspot/share/logging/logTag.hpp
  20. +17 −12 src/hotspot/share/opto/callGenerator.cpp
  21. +6 −0 src/hotspot/share/opto/callnode.cpp
  22. +8 −4 src/hotspot/share/opto/graphKit.cpp
  23. +1 −1 src/hotspot/share/opto/graphKit.hpp
  24. +1 −1 src/hotspot/share/opto/lcm.cpp
  25. +47 −5 src/hotspot/share/prims/foreign_globals.cpp
  26. +19 −0 src/hotspot/share/prims/foreign_globals.hpp
  27. +2 −1 src/hotspot/share/prims/nativeEntryPoint.cpp
  28. +2 −1 src/hotspot/share/prims/universalNativeInvoker.cpp
  29. +51 −9 src/hotspot/share/prims/universalUpcallHandler.cpp
  30. +6 −0 src/hotspot/share/prims/universalUpcallHandler.hpp
  31. +8 −2 src/hotspot/share/prims/upcallStubs.cpp
  32. +3 −3 src/hotspot/share/prims/whitebox.cpp
  33. +9 −1 src/hotspot/share/runtime/arguments.cpp
  34. +8 −2 src/hotspot/share/runtime/frame.cpp
  35. +2 −0 src/hotspot/share/runtime/frame.hpp
  36. +4 −0 src/hotspot/share/runtime/frame.inline.hpp
  37. +3 −0 src/hotspot/share/runtime/globals.hpp
  38. +0 −1 src/hotspot/share/runtime/reflection.cpp
  39. +6 −2 src/hotspot/share/runtime/sharedRuntime.cpp
  40. +11 −0 src/hotspot/share/runtime/sharedRuntime.hpp
  41. +30 −0 src/java.base/share/classes/java/lang/Module.java
  42. +9 −1 src/java.base/share/classes/java/lang/System.java
  43. +5 −0 src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
  44. +2 −2 src/java.base/share/classes/java/lang/invoke/NativeMethodHandle.java
  45. +14 −1 src/java.base/share/classes/java/nio/Buffer.java
  46. +15 −0 src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java
  47. +7 −0 src/java.base/share/classes/jdk/internal/access/JavaLangInvokeAccess.java
  48. +10 −1 src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java
  49. +6 −8 src/java.base/share/classes/jdk/internal/invoke/NativeEntryPoint.java
  50. +3 −1 src/java.base/share/classes/jdk/internal/loader/BootLoader.java
  51. +13 −2 src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
  52. +49 −2 src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
  53. +7 −0 src/java.base/share/classes/jdk/internal/reflect/Reflection.java
  54. +4 −2 src/java.base/share/classes/module-info.java
  55. +3 −0 src/java.base/share/classes/sun/launcher/resources/launcher.properties
  56. +186 −30 src/java.base/share/classes/sun/nio/ch/IOUtil.java
  57. +2 −0 src/java.base/share/native/libjli/java.c
  58. +15 −9 src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
  59. +11 −5 src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
  60. +7 −7 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/AbstractLayout.java
  61. +1 −6 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/Addressable.java
  62. +209 −176 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CLinker.java
  63. +5 −5 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/GroupLayout.java
  64. +61 −41 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java
  65. +0 −167 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MappedMemorySegments.java
  66. +84 −60 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryAddress.java
  67. +6 −6 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryHandles.java
  68. +83 −40 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayout.java
  69. +20 −20 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java
  70. +325 −492 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemorySegment.java
  71. +0 −472 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/NativeScope.java
  72. +285 −0 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/ResourceScope.java
  73. +466 −0 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SegmentAllocator.java
  74. +12 −13 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SequenceLayout.java
  75. +56 −55 src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/package-info.java
  76. +55 −0 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractCLinker.java
  77. +67 −151 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java
  78. +0 −172 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/AbstractNativeScope.java
  79. +124 −0 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/ArenaAllocator.java
  80. +133 −0 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/ConfinedScope.java
  81. +40 −47 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/HeapMemorySegmentImpl.java
  82. +24 −6 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/LayoutPath.java
  83. +46 −44 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/LibrariesHelper.java
  84. +24 −20 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java
  85. +62 −21 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryAddressImpl.java
  86. +0 −307 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java
  87. +31 −15 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/NativeMemorySegmentImpl.java
  88. +9 −10 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/PlatformLayouts.java
  89. +322 −0 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/ResourceScopeImpl.java
  90. +196 −0 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/SharedScope.java
  91. +0 −26 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java
  92. +123 −57 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/Binding.java
  93. +4 −4 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/BindingInterpreter.java
  94. +10 −1 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/BufferLayout.java
  95. +82 −106 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableInvoker.java
  96. +226 −56 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/ProgrammableUpcallHandler.java
  97. +201 −94 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java
  98. +5 −7 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/UpcallStubs.java
  99. +20 −18 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64Linker.java
  100. +54 −88 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64VaList.java
  101. +15 −16 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java
  102. +9 −9 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java
  103. +44 −72 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVVaList.java
  104. +21 −19 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java
  105. +7 −12 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java
  106. +32 −57 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/WinVaList.java
  107. +20 −18 src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java
  108. +1 −1 test/hotspot/jtreg/gc/shenandoah/compiler/TestLinkToNativeRBP.java
  109. +2 −1 test/jdk/TEST.groups
  110. +18 −15 test/jdk/java/foreign/CallGeneratorHelper.java
  111. +37 −0 test/jdk/java/foreign/NativeTestHelper.java
  112. +81 −0 test/jdk/java/foreign/SafeFunctionAccessTest.java
  113. +44 −40 test/jdk/java/foreign/StdLibTest.java
  114. +10 −10 test/jdk/java/foreign/TestAdaptVarHandles.java
  115. +4 −2 test/jdk/java/foreign/TestAddressHandle.java
  116. +23 −39 test/jdk/java/foreign/TestArrays.java
  117. +181 −134 test/jdk/java/foreign/TestByteBuffer.java
  118. +0 −185 test/jdk/java/foreign/TestCleaner.java
  119. +4 −4 test/jdk/java/foreign/TestCondy.java
  120. +57 −28 test/jdk/java/foreign/TestDowncall.java
  121. +8 −6 test/jdk/java/foreign/TestFree.java
  122. +28 −22 test/jdk/java/foreign/TestHandshake.java
  123. +3 −3 test/jdk/java/foreign/TestIllegalLink.java
  124. +33 −33 test/jdk/java/foreign/TestIntrinsics.java
  125. +16 −16 test/jdk/java/foreign/TestLayoutConstants.java
  126. +1 −1 test/jdk/java/foreign/TestLayoutEquality.java
  127. +135 −64 test/jdk/java/foreign/TestLayoutPaths.java
  128. +46 −43 test/jdk/java/foreign/TestLayouts.java
  129. +36 −7 test/jdk/java/foreign/TestLibraryLookup.java
  130. +259 −0 test/jdk/java/foreign/TestMatrix.java
  131. +22 −18 test/jdk/java/foreign/TestMemoryAccess.java
  132. +13 −8 test/jdk/java/foreign/TestMemoryAlignment.java
  133. +2 −1 test/jdk/java/foreign/TestMemoryCopy.java
  134. +17 −11 test/jdk/java/foreign/TestMemoryHandleAsUnsigned.java
  135. +47 −53 test/jdk/java/foreign/TestMismatch.java
  136. +32 −27 test/jdk/java/foreign/TestNative.java
  137. +0 −536 test/jdk/java/foreign/TestNativeScope.java
  138. +8 −17 test/jdk/java/foreign/TestNoForeignUnsafeOverride.java
  139. +18 −10 test/jdk/java/foreign/TestNulls.java
  140. +2 −3 test/jdk/java/foreign/TestRebase.java
  141. +9 −9 test/jdk/java/foreign/TestReshape.java
  142. +306 −0 test/jdk/java/foreign/TestResourceScope.java
  143. +74 −0 test/jdk/java/foreign/TestRestricted.java
  144. +273 −0 test/jdk/java/foreign/TestScopedOperations.java
  145. +502 −0 test/jdk/java/foreign/TestSegmentAllocators.java
  146. +104 −271 test/jdk/java/foreign/TestSegments.java
  147. +10 −62 test/jdk/java/foreign/TestSharedAccess.java
  148. +5 −4 test/jdk/java/foreign/TestSlices.java
  149. +57 −75 test/jdk/java/foreign/TestSpliterator.java
  150. +13 −8 test/jdk/java/foreign/TestTypeAccess.java
  151. +1 −10 test/jdk/java/foreign/TestUnsupportedPlatform.java
  152. +47 −41 test/jdk/java/foreign/TestUpcall.java
  153. +14 −25 test/jdk/java/foreign/TestUpcallHighArity.java
  154. +107 −0 test/jdk/java/foreign/TestUpcallStructScope.java
  155. +0 −96 test/jdk/java/foreign/TestUpcallStubs.java
  156. +9 −7 test/jdk/java/foreign/TestVarArgs.java
  157. +4 −3 test/jdk/java/foreign/TestVarHandleCombinators.java
  158. +31 −31 test/jdk/java/foreign/callarranger/TestAarch64CallArranger.java
  159. +43 −19 test/jdk/java/foreign/callarranger/TestSysVCallArranger.java
  160. +6 −6 test/jdk/java/foreign/callarranger/TestWindowsCallArranger.java
  161. +208 −0 test/jdk/java/foreign/channels/AbstractChannelsTest.java
  162. +387 −0 test/jdk/java/foreign/channels/TestAsyncSocketChannels.java
  163. +238 −0 test/jdk/java/foreign/channels/TestSocketChannels.java
  164. +119 −0 test/jdk/java/foreign/enablenativeaccess/TestDriver.java
  165. +57 −0 test/jdk/java/foreign/enablenativeaccess/org/openjdk/foreigntest/PanamaMainUnnamedModule.java
  166. +27 −0 test/jdk/java/foreign/enablenativeaccess/panama_module/module-info.java
  167. +34 −0 test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/PanamaMain.java
  168. +35 −0 test/jdk/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/PanamaMainInvoke.java
  169. +34 −0 ...k/java/foreign/enablenativeaccess/panama_module/org/openjdk/foreigntest/PanamaMainReflection.java
  170. +30 −0 test/jdk/java/foreign/handles/Driver.java
  171. +96 −0 test/jdk/java/foreign/handles/invoker_module/handle/invoker/MethodHandleInvoker.java
  172. +27 −0 test/jdk/java/foreign/handles/invoker_module/module-info.java
  173. +100 −0 test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java
  174. +29 −0 test/jdk/java/foreign/handles/lookup_module/module-info.java
  175. +1 −0 test/jdk/java/foreign/libLookupTest.c
  176. +38 −0 test/jdk/java/foreign/libSafeAccess.c
  177. +34 −0 test/jdk/java/foreign/libTestUpcallStructScope.c
  178. +7 −4 test/jdk/java/foreign/stackwalk/TestStackWalk.java
  179. +142 −173 test/jdk/java/foreign/valist/VaListTest.java
  180. +73 −0 test/jdk/java/foreign/virtual/TestVirtualCalls.java
  181. +41 −0 test/jdk/java/foreign/virtual/libVirtual.c
  182. +3 −2 test/jdk/java/lang/invoke/VarHandles/VarHandleTestExact.java
  183. +7 −7 test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/SegmentTestDataProvider.java
  184. +3 −1 test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/SpliteratorTest.java
  185. +2 −0 test/jdk/jdk/nio/zipfs/LargeEntriesTest.java
  186. +2 −0 test/jdk/tools/jar/modularJar/Basic.java
  187. +1 −1 test/lib/sun/hotspot/WhiteBox.java
  188. +173 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkMismatchAcquire.java
  189. +6 −5 test/micro/org/openjdk/bench/jdk/incubator/foreign/BulkOps.java
  190. +0 −161 test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverhead.java
  191. +118 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverheadConstant.java
  192. +166 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverheadHelper.java
  193. +119 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverheadVirtual.java
  194. +3 −3 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverConstant.java
  195. +56 −8 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNew.java
  196. +5 −5 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstant.java
  197. +5 −7 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantFP.java
  198. +11 −16 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantHeap.java
  199. +5 −4 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantMapped.java
  200. +5 −4 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverNonConstantShared.java
  201. +4 −3 test/micro/org/openjdk/bench/jdk/incubator/foreign/LoopOverPollutedSegments.java
  202. +14 −19 test/micro/org/openjdk/bench/jdk/incubator/foreign/ParallelSum.java
  203. +132 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/ResourceScopeClose.java
  204. +180 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/StrLenTest.java
  205. +1 −2 test/micro/org/openjdk/bench/jdk/incubator/foreign/TestAdaptVarHandles.java
  206. +3 −5 test/micro/org/openjdk/bench/jdk/incubator/foreign/UnrolledAccess.java
  207. +87 −19 test/micro/org/openjdk/bench/jdk/incubator/foreign/Upcalls.java
  208. +9 −8 test/micro/org/openjdk/bench/jdk/incubator/foreign/VaList.java
  209. +3 −2 test/micro/org/openjdk/bench/jdk/incubator/foreign/VarHandleExact.java
  210. +5 −1 test/micro/org/openjdk/bench/jdk/incubator/foreign/libCallOverhead.c
  211. +5 −9 test/micro/org/openjdk/bench/jdk/incubator/foreign/libCallOverheadJNI.c
  212. +35 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/libStrLen.c
  213. +12 −0 test/micro/org/openjdk/bench/jdk/incubator/foreign/libUpcalls.c
  214. +17 −8 test/micro/org/openjdk/bench/jdk/incubator/foreign/libUpcallsJNI.c
  215. +1 −1 test/micro/org/openjdk/bench/jdk/incubator/foreign/points/PointsAccess.java
  216. +1 −1 test/micro/org/openjdk/bench/jdk/incubator/foreign/points/PointsAlloc.java
  217. +1 −1 test/micro/org/openjdk/bench/jdk/incubator/foreign/points/PointsDistance.java
  218. +1 −1 test/micro/org/openjdk/bench/jdk/incubator/foreign/points/PointsFree.java
  219. +4 −3 test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java
@@ -84,3 +84,8 @@ const BufferLayout ForeignGlobals::parse_buffer_layout_impl(jobject jlayout) con

return layout;
}

const CallRegs ForeignGlobals::parse_call_regs_impl(jobject jconv) const {
ShouldNotCallThis();
return {};
}
@@ -359,6 +359,16 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}

JavaFrameAnchor* OptimizedEntryBlob::jfa_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}

frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
ShouldNotCallThis();
return {};
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
@@ -878,7 +878,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
// 64 bits items (Aarch64 abi) even though java would only store
// 32bits for a parameter. On 32bit it will simply be 32 bits
// So this routine will do 32->32 on 32bit and 32->64 on 64bit
static void move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
if (src.first()->is_stack()) {
if (dst.first()->is_stack()) {
// stack to stack
@@ -979,7 +979,7 @@ static void object_move(MacroAssembler* masm,
}

// A float arg may have to do float reg int reg conversion
static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
assert(src.first()->is_stack() && dst.first()->is_stack() ||
src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
if (src.first()->is_stack()) {
@@ -998,7 +998,7 @@ static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
}

// A long move
static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
if (src.first()->is_stack()) {
if (dst.first()->is_stack()) {
// stack to stack
@@ -1022,7 +1022,7 @@ static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {


// A double move
static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
assert(src.first()->is_stack() && dst.first()->is_stack() ||
src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error");
if (src.first()->is_stack()) {
@@ -99,3 +99,12 @@ address ProgrammableUpcallHandler::generate_upcall_stub(jobject rec, jobject jab

return blob->code_begin();
}

address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject mh, Method* entry, jobject jabi, jobject jconv) {
ShouldNotCallThis();
return nullptr;
}

bool ProgrammableUpcallHandler::supports_optimized_upcalls() {
return false;
}
@@ -87,3 +87,32 @@ const BufferLayout ForeignGlobals::parse_buffer_layout_impl(jobject jlayout) con

return layout;
}

const CallRegs ForeignGlobals::parse_call_regs_impl(jobject jconv) const {
oop conv_oop = JNIHandles::resolve_non_null(jconv);
objArrayOop arg_regs_oop = cast<objArrayOop>(conv_oop->obj_field(CallConvOffsets.arg_regs_offset));
objArrayOop ret_regs_oop = cast<objArrayOop>(conv_oop->obj_field(CallConvOffsets.ret_regs_offset));

CallRegs result;
result._args_length = arg_regs_oop->length();
result._arg_regs = NEW_RESOURCE_ARRAY(VMReg, result._args_length);

result._rets_length = ret_regs_oop->length();
result._ret_regs = NEW_RESOURCE_ARRAY(VMReg, result._rets_length);

for (int i = 0; i < result._args_length; i++) {
oop storage = arg_regs_oop->obj_at(i);
jint index = storage->int_field(VMS.index_offset);
jint type = storage->int_field(VMS.type_offset);
result._arg_regs[i] = VMRegImpl::vmStorageToVMReg(type, index);
}

for (int i = 0; i < result._rets_length; i++) {
oop storage = ret_regs_oop->obj_at(i);
jint index = storage->int_field(VMS.index_offset);
jint type = storage->int_field(VMS.type_offset);
result._ret_regs[i] = VMRegImpl::vmStorageToVMReg(type, index);
}

return result;
}
@@ -102,6 +102,8 @@ bool frame::safe_for_sender(JavaThread *thread) {
if (is_entry_frame()) {
// an entry frame must have a valid fp.
return fp_safe && is_entry_frame_valid(thread);
} else if (is_optimized_entry_frame()) {
return fp_safe;
}

intptr_t* sender_sp = NULL;
@@ -199,6 +201,8 @@ bool frame::safe_for_sender(JavaThread *thread) {
address jcw = (address)sender.entry_frame_call_wrapper();

return thread->is_in_stack_range_excl(jcw, (address)sender.fp());
} else if (sender_blob->is_optimized_entry_blob()) {
return false;
}

CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
@@ -349,6 +353,32 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}

JavaFrameAnchor* OptimizedEntryBlob::jfa_for_frame(const frame& frame) const {
// need unextended_sp here, since normal sp is wrong for interpreter callees
return reinterpret_cast<JavaFrameAnchor*>(reinterpret_cast<char*>(frame.unextended_sp()) + in_bytes(jfa_sp_offset()));
}

frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
assert(map != NULL, "map must be set");
OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
// Java frame called from C; skip all C frames and return top C
// frame of that chunk as the sender
JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
// Since we are walking the stack now this nested anchor is obviously walkable
// even if it wasn't when it was stacked.
if (!jfa->walkable()) {
// Capture _last_Java_pc (if needed) and mark anchor walkable.
jfa->capture_last_Java_pc();
}
map->clear();
assert(map->include_argument_oops(), "should be set by clear");
vmassert(jfa->last_Java_pc() != NULL, "not walkable");
frame fr(jfa->last_Java_sp(), jfa->last_Java_fp(), jfa->last_Java_pc());

return fr;
}

//------------------------------------------------------------------------------
// frame::verify_deopt_original_pc
//
@@ -478,8 +508,9 @@ frame frame::sender_raw(RegisterMap* map) const {
// update it accordingly
map->set_include_argument_oops(false);

if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_optimized_entry_frame()) return sender_for_optimized_entry_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
assert(_cb == CodeCache::find_blob(pc()),"Must be the same");

if (_cb != NULL) {
@@ -70,8 +70,6 @@

address last_Java_pc(void) { return _last_Java_pc; }

private:

static ByteSize last_Java_fp_offset() { return byte_offset_of(JavaFrameAnchor, _last_Java_fp); }

public:
@@ -1124,7 +1124,7 @@ static void object_move(MacroAssembler* masm,
}

// A float arg may have to do float reg int reg conversion
static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
assert(!src.second()->is_valid() && !dst.second()->is_valid(), "bad float_move");

// Because of the calling convention we know that src is either a stack location
@@ -1142,7 +1142,7 @@ static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
}

// A long move
static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {

// The only legal possibility for a long_move VMRegPair is:
// 1: two stack slots (possibly unaligned)
@@ -1161,7 +1161,7 @@ static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
}

// A double move
static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {

// The only legal possibilities for a double_move VMRegPair are:
// The painful thing here is that like long_move a VMRegPair might be
@@ -1167,7 +1167,7 @@ int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
// 64 bits items (x86_32/64 abi) even though java would only store
// 32bits for a parameter. On 32bit it will simply be 32 bits
// So this routine will do 32->32 on 32bit and 32->64 on 64bit
static void move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
if (src.first()->is_stack()) {
if (dst.first()->is_stack()) {
// stack to stack
@@ -1285,7 +1285,7 @@ static void object_move(MacroAssembler* masm,
}

// A float arg may have to do float reg int reg conversion
static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
assert(!src.second()->is_valid() && !dst.second()->is_valid(), "bad float_move");

// The calling conventions assures us that each VMregpair is either
@@ -1314,7 +1314,7 @@ static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
}

// A long move
static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {

// The calling conventions assures us that each VMregpair is either
// all really one physical register or adjacent stack slots.
@@ -1339,7 +1339,7 @@ static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
}

// A double move
static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
void SharedRuntime::double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {

// The calling conventions assures us that each VMregpair is either
// all really one physical register or adjacent stack slots.
@@ -1448,13 +1448,13 @@ static void unpack_array_argument(MacroAssembler* masm, VMRegPair reg, BasicType
// load the length relative to the body.
__ movl(tmp_reg, Address(tmp_reg, arrayOopDesc::length_offset_in_bytes() -
arrayOopDesc::base_offset_in_bytes(in_elem_type)));
move32_64(masm, tmp, length_arg);
SharedRuntime::move32_64(masm, tmp, length_arg);
__ jmpb(done);
__ bind(is_null);
// Pass zeros
__ xorptr(tmp_reg, tmp_reg);
move_ptr(masm, tmp, body_arg);
move32_64(masm, tmp, length_arg);
SharedRuntime::move32_64(masm, tmp, length_arg);
__ bind(done);

__ block_comment("} unpack_array_argument");
@@ -1541,8 +1541,8 @@ class ComputeMoveOrder: public StackObj {
GrowableArray<MoveOperation*> edges;

public:
ComputeMoveOrder(int total_in_args, VMRegPair* in_regs, int total_c_args, VMRegPair* out_regs,
BasicType* in_sig_bt, GrowableArray<int>& arg_order, VMRegPair tmp_vmreg) {
ComputeMoveOrder(int total_in_args, const VMRegPair* in_regs, int total_c_args, VMRegPair* out_regs,
const BasicType* in_sig_bt, GrowableArray<int>& arg_order, VMRegPair tmp_vmreg) {
// Move operations where the dest is the stack can all be
// scheduled first since they can't interfere with the other moves.
for (int i = total_in_args - 1, c_arg = total_c_args - 1; i >= 0; i--, c_arg--) {
@@ -4087,3 +4087,13 @@ void OptoRuntime::generate_exception_blob() {
_exception_blob = ExceptionBlob::create(&buffer, oop_maps, SimpleRuntimeFrame::framesize >> 1);
}
#endif // COMPILER2

void SharedRuntime::compute_move_order(const BasicType* in_sig_bt,
int total_in_args, const VMRegPair* in_regs,
int total_out_args, VMRegPair* out_regs,
GrowableArray<int>& arg_order,
VMRegPair tmp_vmreg) {
ComputeMoveOrder order(total_in_args, in_regs,
total_out_args, out_regs,
in_sig_bt, arg_order, tmp_vmreg);
}
@@ -28,3 +28,12 @@ address ProgrammableUpcallHandler::generate_upcall_stub(jobject rec, jobject jab
Unimplemented();
return nullptr;
}

address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject mh, Method* entry, jobject jabi, jobject jconv) {
ShouldNotCallThis();
return nullptr;
}

bool ProgrammableUpcallHandler::supports_optimized_upcalls() {
return false;
}
Loading

1 comment on commit a223189

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on a223189 Jun 2, 2021

Please sign in to comment.