From 2acf0dc98a8caacbdae72e801d500def9efbeabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Tue, 26 May 2026 16:34:02 +0000 Subject: [PATCH] 8382582: Remove the experimental JVMCI feature Co-authored-by: Tobias Hartmann Co-authored-by: Mikael Vidstedt Reviewed-by: kvn, thartmann, liach, stefank, coleenp, erikj, vlivanov, cjplummer, alanb --- .github/workflows/main.yml | 4 +- make/Bundles.gmk | 26 +- make/GraalBuilderImage.gmk | 52 - make/Main.gmk | 20 +- make/StaticLibsImage.gmk | 5 +- make/autoconf/jvm-features.m4 | 44 +- make/autoconf/spec.gmk.template | 10 - make/common/Modules.gmk | 9 +- make/conf/build-module-sets.conf | 3 +- make/conf/module-loader-map.conf | 6 +- make/hotspot/lib/CompileJvm.gmk | 1 - make/hotspot/lib/JvmFeatures.gmk | 8 +- make/hotspot/lib/JvmOverrideFiles.gmk | 9 +- .../visualstudio/hotspot/CreateVSProject.gmk | 3 +- make/modules/jdk.internal.vm.ci/Java.gmk | 38 - src/hotspot/cpu/aarch64/frame_aarch64.cpp | 6 +- .../gc/shared/barrierSetNMethod_aarch64.cpp | 49 +- src/hotspot/cpu/aarch64/globals_aarch64.hpp | 2 +- .../aarch64/jvmciCodeInstaller_aarch64.cpp | 217 -- .../cpu/aarch64/macroAssembler_aarch64.cpp | 15 - .../cpu/aarch64/macroAssembler_aarch64.hpp | 1 - .../cpu/aarch64/nativeInst_aarch64.cpp | 27 - .../cpu/aarch64/nativeInst_aarch64.hpp | 6 - .../cpu/aarch64/sharedRuntime_aarch64.cpp | 97 +- .../cpu/aarch64/stubGenerator_aarch64.cpp | 9 +- .../cpu/aarch64/stubRoutines_aarch64.hpp | 5 +- .../templateInterpreterGenerator_aarch64.cpp | 26 +- .../cpu/aarch64/templateTable_aarch64.cpp | 6 +- .../cpu/aarch64/vm_version_aarch64.hpp | 1 - src/hotspot/cpu/arm/compiledIC_arm.cpp | 6 +- .../cpu/arm/jvmciCodeInstaller_arm.cpp | 70 - src/hotspot/cpu/arm/vm_version_arm.hpp | 4 +- src/hotspot/cpu/ppc/globals_ppc.hpp | 2 +- .../cpu/ppc/jvmciCodeInstaller_ppc.cpp | 69 - src/hotspot/cpu/ppc/stubGenerator_ppc.cpp | 8 +- .../gc/shared/barrierSetNMethod_riscv.cpp | 56 +- src/hotspot/cpu/riscv/globals_riscv.hpp | 2 +- .../cpu/riscv/jvmciCodeInstaller_riscv.cpp | 127 - src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp | 83 +- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 4 +- src/hotspot/cpu/riscv/stubRoutines_riscv.hpp | 5 +- src/hotspot/cpu/s390/globals_s390.hpp | 2 +- .../cpu/s390/jvmciCodeInstaller_s390.cpp | 87 - src/hotspot/cpu/s390/stubGenerator_s390.cpp | 8 +- src/hotspot/cpu/x86/frame_x86.cpp | 6 +- .../x86/gc/shared/barrierSetNMethod_x86.cpp | 24 +- src/hotspot/cpu/x86/globals_x86.hpp | 6 +- .../cpu/x86/jvmciCodeInstaller_x86.cpp | 257 -- src/hotspot/cpu/x86/macroAssembler_x86.cpp | 8 +- src/hotspot/cpu/x86/macroAssembler_x86.hpp | 4 +- src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp | 110 +- src/hotspot/cpu/x86/stubGenerator_x86_64.cpp | 9 +- src/hotspot/cpu/x86/stubGenerator_x86_64.hpp | 4 +- .../x86/stubGenerator_x86_64_arraycopy.cpp | 45 +- .../x86/templateInterpreterGenerator_x86.cpp | 30 +- src/hotspot/cpu/x86/vmStructs_x86.hpp | 5 +- src/hotspot/cpu/x86/vm_version_x86.cpp | 10 +- src/hotspot/cpu/x86/vm_version_x86.hpp | 4 - .../bsd_aarch64/javaThread_bsd_aarch64.cpp | 8 +- .../os_cpu/bsd_x86/javaThread_bsd_x86.cpp | 8 +- .../os_cpu/linux_x86/javaThread_linux_x86.cpp | 8 +- .../javaThread_windows_aarch64.cpp | 6 +- .../windows_x86/javaThread_windows_x86.cpp | 8 +- src/hotspot/share/c1/c1_Compilation.hpp | 4 +- src/hotspot/share/c1/c1_LIRGenerator.cpp | 6 +- src/hotspot/share/cds/filemap.cpp | 18 - src/hotspot/share/cds/filemap.hpp | 1 - src/hotspot/share/classfile/classLoader.cpp | 14 - src/hotspot/share/classfile/classLoader.hpp | 4 - src/hotspot/share/classfile/javaClasses.cpp | 66 - src/hotspot/share/classfile/javaClasses.hpp | 34 - .../share/classfile/metadataOnStackMark.cpp | 8 +- src/hotspot/share/classfile/modules.cpp | 4 +- src/hotspot/share/classfile/vmSymbols.hpp | 11 - src/hotspot/share/code/aotCodeCache.cpp | 4 - src/hotspot/share/code/aotCodeCache.hpp | 9 - src/hotspot/share/code/codeBlob.hpp | 28 +- src/hotspot/share/code/codeCache.cpp | 18 +- src/hotspot/share/code/codeCache.hpp | 3 +- src/hotspot/share/code/codeHeapState.cpp | 23 +- src/hotspot/share/code/codeHeapState.hpp | 3 +- src/hotspot/share/code/compiledIC.hpp | 3 +- src/hotspot/share/code/debugInfo.cpp | 10 +- src/hotspot/share/code/dependencies.cpp | 221 -- src/hotspot/share/code/dependencies.hpp | 104 - .../share/code/exceptionHandlerTable.hpp | 9 +- src/hotspot/share/code/nmethod.cpp | 279 +- src/hotspot/share/code/nmethod.hpp | 92 +- src/hotspot/share/code/scopeDesc.cpp | 8 +- .../share/compiler/abstractCompiler.hpp | 18 +- .../share/compiler/compilationPolicy.cpp | 96 +- .../share/compiler/compilationPolicy.hpp | 5 +- src/hotspot/share/compiler/compileBroker.cpp | 354 +- src/hotspot/share/compiler/compileBroker.hpp | 13 +- src/hotspot/share/compiler/compileTask.cpp | 2 - src/hotspot/share/compiler/compileTask.hpp | 29 - .../share/compiler/compilerDefinitions.cpp | 99 +- .../share/compiler/compilerDefinitions.hpp | 42 +- .../compiler/compilerDefinitions.inline.hpp | 69 +- .../share/compiler/compilerDirectives.cpp | 6 +- src/hotspot/share/compiler/compilerOracle.cpp | 2 +- src/hotspot/share/compiler/compilerThread.cpp | 13 +- src/hotspot/share/compiler/compilerThread.hpp | 12 +- .../share/compiler/compiler_globals.hpp | 9 +- .../share/compiler/compiler_globals_pd.hpp | 13 +- src/hotspot/share/compiler/oopMap.cpp | 13 +- src/hotspot/share/compiler/oopMap.hpp | 6 +- src/hotspot/share/compiler/oopMap.inline.hpp | 13 +- src/hotspot/share/gc/g1/g1CollectedHeap.cpp | 4 +- src/hotspot/share/gc/g1/g1FullCollector.cpp | 16 +- src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp | 10 +- src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp | 6 +- .../share/gc/g1/g1ParallelCleaning.cpp | 29 - .../share/gc/g1/g1ParallelCleaning.hpp | 20 - src/hotspot/share/gc/g1/g1YoungCollector.cpp | 4 +- .../gc/g1/g1YoungGCPostEvacuateTasks.cpp | 8 +- .../gc/g1/g1YoungGCPostEvacuateTasks.hpp | 6 +- .../share/gc/parallel/psParallelCompact.cpp | 23 +- src/hotspot/share/gc/parallel/psScavenge.cpp | 10 +- src/hotspot/share/gc/serial/serialFullGC.cpp | 12 +- src/hotspot/share/gc/serial/serialHeap.cpp | 15 +- .../share/gc/shared/barrierSetNMethod.cpp | 5 +- .../share/gc/shared/barrierSetNMethod.hpp | 6 +- .../share/gc/shared/cardTableBarrierSet.cpp | 4 +- src/hotspot/share/gc/shared/collectedHeap.hpp | 1 - .../share/gc/shared/referenceProcessor.cpp | 4 +- .../gc/shared/threadLocalAllocBuffer.hpp | 1 - .../gc/shenandoah/shenandoahBarrierSet.cpp | 4 +- .../share/gc/shenandoah/shenandoahFullGC.cpp | 10 +- .../share/gc/shenandoah/shenandoahGC.cpp | 8 +- .../share/gc/shenandoah/shenandoahHeap.cpp | 8 +- src/hotspot/share/gc/z/zBarrierSet.cpp | 4 +- .../share/interpreter/abstractInterpreter.cpp | 6 +- .../share/interpreter/interpreterRuntime.cpp | 20 +- .../share/interpreter/invocationCounter.hpp | 3 +- .../share/interpreter/linkResolver.hpp | 4 +- src/hotspot/share/jfr/jfr.cpp | 6 - .../jfr/leakprofiler/utilities/rootType.cpp | 6 +- .../jfr/leakprofiler/utilities/rootType.hpp | 3 +- .../share/jfr/support/jfrResolution.cpp | 21 +- .../share/jfr/support/jfrResolution.hpp | 3 +- .../share/jfr/support/jfrThreadLocal.hpp | 3 +- .../share/jvmci/jniAccessMark.inline.hpp | 53 - src/hotspot/share/jvmci/jvmci.cpp | 396 -- src/hotspot/share/jvmci/jvmci.hpp | 236 -- .../share/jvmci/jvmciCodeInstaller.cpp | 1369 ------- .../share/jvmci/jvmciCodeInstaller.hpp | 432 -- src/hotspot/share/jvmci/jvmciCompiler.cpp | 266 -- src/hotspot/share/jvmci/jvmciCompiler.hpp | 166 - src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 3467 ----------------- src/hotspot/share/jvmci/jvmciCompilerToVM.hpp | 187 - .../share/jvmci/jvmciCompilerToVMInit.cpp | 573 --- src/hotspot/share/jvmci/jvmciEnv.cpp | 2015 ---------- src/hotspot/share/jvmci/jvmciEnv.hpp | 554 --- src/hotspot/share/jvmci/jvmciExceptions.hpp | 85 - src/hotspot/share/jvmci/jvmciJavaClasses.cpp | 725 ---- src/hotspot/share/jvmci/jvmciJavaClasses.hpp | 542 --- src/hotspot/share/jvmci/jvmciObject.hpp | 94 - src/hotspot/share/jvmci/jvmciRuntime.cpp | 2256 ----------- src/hotspot/share/jvmci/jvmciRuntime.hpp | 594 --- src/hotspot/share/jvmci/jvmci_globals.cpp | 243 -- src/hotspot/share/jvmci/jvmci_globals.hpp | 228 -- src/hotspot/share/jvmci/metadataHandles.cpp | 171 - src/hotspot/share/jvmci/metadataHandles.hpp | 195 - src/hotspot/share/jvmci/vmStructs_jvmci.cpp | 1209 ------ src/hotspot/share/jvmci/vmStructs_jvmci.hpp | 70 - src/hotspot/share/jvmci/vmSymbols_jvmci.hpp | 109 - src/hotspot/share/logging/logTag.hpp | 1 - src/hotspot/share/nmt/memTag.hpp | 3 +- src/hotspot/share/oops/annotations.hpp | 3 +- src/hotspot/share/oops/array.hpp | 1 - src/hotspot/share/oops/bsmAttribute.hpp | 1 - src/hotspot/share/oops/constMethod.hpp | 3 +- src/hotspot/share/oops/constMethodFlags.hpp | 3 +- src/hotspot/share/oops/constantPool.hpp | 1 - src/hotspot/share/oops/fieldInfo.hpp | 1 - src/hotspot/share/oops/instanceKlass.hpp | 1 - src/hotspot/share/oops/instanceKlassFlags.hpp | 3 +- src/hotspot/share/oops/klass.hpp | 7 +- src/hotspot/share/oops/klassFlags.hpp | 3 +- src/hotspot/share/oops/klassVtable.hpp | 3 +- src/hotspot/share/oops/method.hpp | 5 +- src/hotspot/share/oops/method.inline.hpp | 6 +- src/hotspot/share/oops/methodCounters.cpp | 6 +- src/hotspot/share/oops/methodCounters.hpp | 13 +- src/hotspot/share/oops/methodData.cpp | 168 +- src/hotspot/share/oops/methodData.hpp | 87 +- src/hotspot/share/oops/methodFlags.hpp | 3 +- src/hotspot/share/oops/objArrayKlass.hpp | 3 +- src/hotspot/share/oops/oop.hpp | 4 +- src/hotspot/share/oops/symbol.hpp | 3 +- src/hotspot/share/opto/c2compiler.cpp | 4 +- src/hotspot/share/prims/jni.cpp | 20 - src/hotspot/share/prims/jvm.cpp | 2 - src/hotspot/share/prims/nativeLookup.cpp | 12 +- src/hotspot/share/prims/whitebox.cpp | 42 - .../share/runtime/abstract_vm_version.hpp | 1 - src/hotspot/share/runtime/arguments.cpp | 76 +- src/hotspot/share/runtime/arguments.hpp | 13 +- src/hotspot/share/runtime/basicLock.hpp | 3 +- .../share/runtime/continuationEntry.hpp | 3 +- src/hotspot/share/runtime/deoptimization.cpp | 542 +-- src/hotspot/share/runtime/deoptimization.hpp | 49 +- src/hotspot/share/runtime/escapeBarrier.cpp | 6 +- src/hotspot/share/runtime/escapeBarrier.hpp | 24 +- src/hotspot/share/runtime/flags/allFlags.hpp | 12 +- src/hotspot/share/runtime/flags/jvmFlag.cpp | 24 +- src/hotspot/share/runtime/flags/jvmFlag.hpp | 5 +- src/hotspot/share/runtime/frame.cpp | 12 +- src/hotspot/share/runtime/frame.hpp | 8 +- src/hotspot/share/runtime/init.cpp | 10 +- src/hotspot/share/runtime/java.cpp | 19 - src/hotspot/share/runtime/javaCalls.cpp | 23 +- src/hotspot/share/runtime/javaCalls.hpp | 16 +- src/hotspot/share/runtime/javaFrameAnchor.hpp | 3 +- src/hotspot/share/runtime/javaThread.cpp | 148 - src/hotspot/share/runtime/javaThread.hpp | 113 - src/hotspot/share/runtime/lockStack.hpp | 1 - src/hotspot/share/runtime/mutexLocker.cpp | 16 +- src/hotspot/share/runtime/mutexLocker.hpp | 7 +- src/hotspot/share/runtime/objectMonitor.hpp | 1 - src/hotspot/share/runtime/os.hpp | 1 - src/hotspot/share/runtime/osThreadBase.hpp | 3 +- src/hotspot/share/runtime/sharedRuntime.cpp | 61 +- src/hotspot/share/runtime/stackOverflow.hpp | 3 +- src/hotspot/share/runtime/stubInfo.hpp | 11 +- src/hotspot/share/runtime/stubRoutines.hpp | 5 +- src/hotspot/share/runtime/thread.hpp | 1 - src/hotspot/share/runtime/threads.cpp | 55 +- src/hotspot/share/runtime/vframe.hpp | 4 +- src/hotspot/share/runtime/vframe.inline.hpp | 10 - src/hotspot/share/runtime/vframeArray.cpp | 3 - src/hotspot/share/runtime/vframeArray.hpp | 8 +- src/hotspot/share/runtime/vmOperation.hpp | 8 +- src/hotspot/share/runtime/vmOperations.cpp | 13 - src/hotspot/share/runtime/vmStructs.cpp | 15 +- src/hotspot/share/utilities/exceptions.hpp | 1 - src/hotspot/share/utilities/macros.hpp | 29 - src/hotspot/share/utilities/vmError.cpp | 18 +- .../jdk/internal/vm/TranslatedException.java | 306 -- .../classes/jdk/internal/vm/VMSupport.java | 494 +-- src/java.base/share/classes/module-info.java | 8 +- .../AnnotationInvocationHandler.java | 9 +- .../reflect/annotation/AnnotationParser.java | 4 +- .../reflect/annotation/AnnotationSupport.java | 11 +- .../data/symbols/jdk.graal.compiler-M.sym.txt | 31 - .../jdk.graal.compiler.management-M.sym.txt | 31 - .../data/symbols/jdk.internal.vm.ci-M.sym.txt | 31 - .../share/classes/module-info.java | 41 - .../share/classes/module-info.java | 41 - .../sun/jvm/hotspot/CommandProcessor.java | 1 - .../jvm/hotspot/runtime/CompilerThread.java | 64 - .../sun/jvm/hotspot/runtime/Threads.java | 4 +- .../classes/jdk/vm/ci/aarch64/AArch64.java | 249 -- .../jdk/vm/ci/aarch64/AArch64Kind.java | 153 - .../jdk/vm/ci/aarch64/package-info.java | 27 - .../share/classes/jdk/vm/ci/amd64/AMD64.java | 389 -- .../classes/jdk/vm/ci/amd64/AMD64Kind.java | 218 -- .../classes/jdk/vm/ci/amd64/package-info.java | 27 - .../classes/jdk/vm/ci/code/Architecture.java | 245 -- .../jdk/vm/ci/code/BailoutException.java | 76 - .../classes/jdk/vm/ci/code/BytecodeFrame.java | 397 -- .../jdk/vm/ci/code/BytecodePosition.java | 130 - .../jdk/vm/ci/code/CPUFeatureName.java | 40 - .../jdk/vm/ci/code/CallingConvention.java | 132 - .../jdk/vm/ci/code/CodeCacheProvider.java | 148 - .../classes/jdk/vm/ci/code/CodeUtil.java | 440 --- .../jdk/vm/ci/code/CompilationRequest.java | 78 - .../vm/ci/code/CompilationRequestResult.java | 37 - .../classes/jdk/vm/ci/code/CompiledCode.java | 31 - .../classes/jdk/vm/ci/code/DebugInfo.java | 143 - .../classes/jdk/vm/ci/code/InstalledCode.java | 164 - .../code/InvalidInstalledCodeException.java | 38 - .../classes/jdk/vm/ci/code/Location.java | 81 - .../jdk/vm/ci/code/MemoryBarriers.java | 121 - .../classes/jdk/vm/ci/code/ReferenceMap.java | 31 - .../classes/jdk/vm/ci/code/Register.java | 194 - .../jdk/vm/ci/code/RegisterAttributes.java | 103 - .../jdk/vm/ci/code/RegisterConfig.java | 122 - .../jdk/vm/ci/code/RegisterSaveLayout.java | 139 - .../classes/jdk/vm/ci/code/RegisterValue.java | 65 - .../jdk/vm/ci/code/StackLockValue.java | 86 - .../classes/jdk/vm/ci/code/StackSlot.java | 135 - .../jdk/vm/ci/code/SuppressFBWarnings.java | 40 - .../jdk/vm/ci/code/TargetDescription.java | 125 - .../jdk/vm/ci/code/ValueKindFactory.java | 34 - .../classes/jdk/vm/ci/code/ValueUtil.java | 111 - .../classes/jdk/vm/ci/code/VirtualObject.java | 322 -- .../classes/jdk/vm/ci/code/package-info.java | 28 - .../classes/jdk/vm/ci/code/site/Call.java | 87 - .../vm/ci/code/site/ConstantReference.java | 66 - .../jdk/vm/ci/code/site/DataPatch.java | 73 - .../vm/ci/code/site/DataSectionReference.java | 77 - .../jdk/vm/ci/code/site/ExceptionHandler.java | 56 - .../code/site/ImplicitExceptionDispatch.java | 79 - .../jdk/vm/ci/code/site/Infopoint.java | 113 - .../jdk/vm/ci/code/site/InfopointReason.java | 36 - .../classes/jdk/vm/ci/code/site/Mark.java | 74 - .../jdk/vm/ci/code/site/Reference.java | 35 - .../classes/jdk/vm/ci/code/site/Site.java | 53 - .../jdk/vm/ci/code/site/package-info.java | 27 - .../jdk/vm/ci/code/stack/InspectedFrame.java | 76 - .../ci/code/stack/InspectedFrameVisitor.java | 34 - .../vm/ci/code/stack/StackIntrospection.java | 54 - .../jdk/vm/ci/code/stack/package-info.java | 26 - .../classes/jdk/vm/ci/common/InitTimer.java | 94 - .../classes/jdk/vm/ci/common/JVMCIError.java | 118 - .../jdk/vm/ci/common/SuppressFBWarnings.java | 40 - .../jdk/vm/ci/common/package-info.java | 27 - .../vm/ci/hotspot/AnnotationDataDecoder.java | 73 - .../classes/jdk/vm/ci/hotspot/Cleaner.java | 129 - .../CompilerThreadCanCallJavaScope.java | 84 - .../jdk/vm/ci/hotspot/CompilerToVM.java | 1558 -------- .../DirectHotSpotObjectConstantImpl.java | 72 - .../jdk/vm/ci/hotspot/EmptyEventProvider.java | 124 - .../jdk/vm/ci/hotspot/EventProvider.java | 130 - .../jdk/vm/ci/hotspot/HandleCleaner.java | 83 - .../hotspot/HotSpotCallingConventionType.java | 55 - .../ci/hotspot/HotSpotCodeCacheProvider.java | 212 - .../ci/hotspot/HotSpotCompilationRequest.java | 95 - .../HotSpotCompilationRequestResult.java | 97 - .../vm/ci/hotspot/HotSpotCompiledCode.java | 275 -- .../ci/hotspot/HotSpotCompiledCodeStream.java | 1291 ------ .../vm/ci/hotspot/HotSpotCompiledNmethod.java | 161 - .../HotSpotCompressedNullConstant.java | 123 - .../jdk/vm/ci/hotspot/HotSpotConstant.java | 58 - .../vm/ci/hotspot/HotSpotConstantPool.java | 991 ----- .../HotSpotConstantReflectionProvider.java | 193 - .../ci/hotspot/HotSpotForeignCallTarget.java | 38 - .../vm/ci/hotspot/HotSpotInstalledCode.java | 85 - .../vm/ci/hotspot/HotSpotJDKReflection.java | 332 -- .../hotspot/HotSpotJVMCIBackendFactory.java | 87 - .../hotspot/HotSpotJVMCICompilerConfig.java | 178 - .../vm/ci/hotspot/HotSpotJVMCIReflection.java | 105 - .../vm/ci/hotspot/HotSpotJVMCIRuntime.java | 1486 ------- ...HotSpotJVMCIUnsupportedOperationError.java | 55 - .../jdk/vm/ci/hotspot/HotSpotJavaType.java | 42 - .../hotspot/HotSpotMemoryAccessProvider.java | 45 - .../HotSpotMemoryAccessProviderImpl.java | 177 - .../ci/hotspot/HotSpotMetaAccessProvider.java | 347 -- .../ci/hotspot/HotSpotMetaspaceConstant.java | 32 - .../hotspot/HotSpotMetaspaceConstantImpl.java | 126 - .../jdk/vm/ci/hotspot/HotSpotMethod.java | 81 - .../jdk/vm/ci/hotspot/HotSpotMethodData.java | 837 ---- .../ci/hotspot/HotSpotMethodDataAccessor.java | 153 - .../HotSpotMethodHandleAccessProvider.java | 198 - .../jdk/vm/ci/hotspot/HotSpotModifiers.java | 66 - .../jdk/vm/ci/hotspot/HotSpotNmethod.java | 245 -- .../vm/ci/hotspot/HotSpotObjectConstant.java | 117 - .../ci/hotspot/HotSpotObjectConstantImpl.java | 207 - .../hotspot/HotSpotObjectConstantScope.java | 122 - .../vm/ci/hotspot/HotSpotProfilingInfo.java | 46 - .../ci/hotspot/HotSpotProfilingInfoImpl.java | 243 -- .../vm/ci/hotspot/HotSpotReferenceMap.java | 79 - .../ci/hotspot/HotSpotResolvedJavaField.java | 45 - .../hotspot/HotSpotResolvedJavaFieldImpl.java | 261 -- .../ci/hotspot/HotSpotResolvedJavaMethod.java | 145 - .../HotSpotResolvedJavaMethodImpl.java | 813 ---- .../ci/hotspot/HotSpotResolvedJavaType.java | 89 - .../ci/hotspot/HotSpotResolvedObjectType.java | 117 - .../HotSpotResolvedObjectTypeImpl.java | 1148 ------ .../hotspot/HotSpotResolvedPrimitiveType.java | 357 -- .../jdk/vm/ci/hotspot/HotSpotRuntimeStub.java | 62 - .../jdk/vm/ci/hotspot/HotSpotSignature.java | 230 -- .../hotspot/HotSpotSpeculationEncoding.java | 224 -- .../vm/ci/hotspot/HotSpotSpeculationLog.java | 402 -- .../hotspot/HotSpotStackFrameReference.java | 97 - .../ci/hotspot/HotSpotStackIntrospection.java | 48 - .../jdk/vm/ci/hotspot/HotSpotVMConfig.java | 389 -- .../vm/ci/hotspot/HotSpotVMConfigAccess.java | 409 -- .../vm/ci/hotspot/HotSpotVMConfigStore.java | 220 -- .../vm/ci/hotspot/HotSpotVMEventListener.java | 54 - .../IndirectHotSpotObjectConstantImpl.java | 193 - .../share/classes/jdk/vm/ci/hotspot/JFR.java | 97 - .../vm/ci/hotspot/MetaspaceHandleObject.java | 40 - .../jdk/vm/ci/hotspot/MetaspaceObject.java | 36 - .../hotspot/SharedHotSpotSpeculationLog.java | 42 - .../hotspot/SharedLibraryJVMCIReflection.java | 312 -- .../jdk/vm/ci/hotspot/SuppressFBWarnings.java | 40 - .../jdk/vm/ci/hotspot/UnsafeAccess.java | 33 - .../jdk/vm/ci/hotspot/VMEntryPoint.java | 33 - .../classes/jdk/vm/ci/hotspot/VMField.java | 82 - .../classes/jdk/vm/ci/hotspot/VMFlag.java | 56 - .../jdk/vm/ci/hotspot/VMIntrinsicMethod.java | 112 - .../AArch64HotSpotJVMCIBackendFactory.java | 130 - .../aarch64/AArch64HotSpotRegisterConfig.java | 330 -- .../aarch64/AArch64HotSpotVMConfig.java | 41 - .../vm/ci/hotspot/aarch64/package-info.java | 27 - .../AMD64HotSpotJVMCIBackendFactory.java | 142 - .../amd64/AMD64HotSpotRegisterConfig.java | 319 -- .../hotspot/amd64/AMD64HotSpotVMConfig.java | 41 - .../jdk/vm/ci/hotspot/amd64/package-info.java | 27 - .../jdk/vm/ci/hotspot/package-info.java | 27 - .../RISCV64HotSpotJVMCIBackendFactory.java | 126 - .../riscv64/RISCV64HotSpotRegisterConfig.java | 301 -- .../riscv64/RISCV64HotSpotVMConfig.java | 41 - .../vm/ci/hotspot/riscv64/package-info.java | 27 - .../jdk/vm/ci/meta/AbstractJavaProfile.java | 164 - .../jdk/vm/ci/meta/AbstractProfiledItem.java | 95 - .../jdk/vm/ci/meta/AllocatableValue.java | 36 - .../classes/jdk/vm/ci/meta/Annotated.java | 72 - .../jdk/vm/ci/meta/AnnotationData.java | 161 - .../classes/jdk/vm/ci/meta/Assumptions.java | 401 -- .../classes/jdk/vm/ci/meta/Constant.java | 33 - .../classes/jdk/vm/ci/meta/ConstantPool.java | 304 -- .../ci/meta/ConstantReflectionProvider.java | 119 - .../jdk/vm/ci/meta/DefaultProfilingInfo.java | 116 - .../jdk/vm/ci/meta/DeoptimizationAction.java | 70 - .../jdk/vm/ci/meta/DeoptimizationReason.java | 45 - .../vm/ci/meta/EncodedSpeculationReason.java | 137 - .../classes/jdk/vm/ci/meta/EnumData.java | 78 - .../classes/jdk/vm/ci/meta/ErrorData.java | 63 - .../jdk/vm/ci/meta/ExceptionHandler.java | 121 - .../classes/jdk/vm/ci/meta/InvokeTarget.java | 29 - .../classes/jdk/vm/ci/meta/JavaConstant.java | 390 -- .../classes/jdk/vm/ci/meta/JavaField.java | 125 - .../classes/jdk/vm/ci/meta/JavaKind.java | 478 --- .../classes/jdk/vm/ci/meta/JavaMethod.java | 135 - .../jdk/vm/ci/meta/JavaMethodProfile.java | 60 - .../classes/jdk/vm/ci/meta/JavaType.java | 161 - .../jdk/vm/ci/meta/JavaTypeProfile.java | 196 - .../classes/jdk/vm/ci/meta/JavaValue.java | 29 - .../jdk/vm/ci/meta/LineNumberTable.java | 75 - .../share/classes/jdk/vm/ci/meta/Local.java | 91 - .../jdk/vm/ci/meta/LocalVariableTable.java | 88 - .../jdk/vm/ci/meta/MemoryAccessProvider.java | 54 - .../jdk/vm/ci/meta/MetaAccessProvider.java | 127 - .../classes/jdk/vm/ci/meta/MetaUtil.java | 286 -- .../ci/meta/MethodHandleAccessProvider.java | 88 - .../jdk/vm/ci/meta/ModifiersProvider.java | 149 - .../classes/jdk/vm/ci/meta/NullConstant.java | 97 - .../classes/jdk/vm/ci/meta/PlatformKind.java | 83 - .../jdk/vm/ci/meta/PrimitiveConstant.java | 186 - .../classes/jdk/vm/ci/meta/ProfilingInfo.java | 199 - .../classes/jdk/vm/ci/meta/RawConstant.java | 30 - .../jdk/vm/ci/meta/ResolvedJavaField.java | 81 - .../jdk/vm/ci/meta/ResolvedJavaMethod.java | 489 --- .../jdk/vm/ci/meta/ResolvedJavaType.java | 428 -- .../jdk/vm/ci/meta/SerializableConstant.java | 42 - .../classes/jdk/vm/ci/meta/Signature.java | 136 - .../jdk/vm/ci/meta/SpeculationLog.java | 173 - .../jdk/vm/ci/meta/SuppressFBWarnings.java | 40 - .../classes/jdk/vm/ci/meta/TriState.java | 77 - .../jdk/vm/ci/meta/UnresolvedJavaField.java | 101 - .../jdk/vm/ci/meta/UnresolvedJavaMethod.java | 88 - .../jdk/vm/ci/meta/UnresolvedJavaType.java | 112 - .../classes/jdk/vm/ci/meta/VMConstant.java | 29 - .../share/classes/jdk/vm/ci/meta/Value.java | 109 - .../classes/jdk/vm/ci/meta/ValueKind.java | 103 - .../classes/jdk/vm/ci/meta/package-info.java | 29 - .../classes/jdk/vm/ci/riscv64/RISCV64.java | 217 -- .../jdk/vm/ci/riscv64/RISCV64Kind.java | 118 - .../jdk/vm/ci/riscv64/package-info.java | 27 - .../classes/jdk/vm/ci/runtime/JVMCI.java | 81 - .../jdk/vm/ci/runtime/JVMCIBackend.java | 69 - .../jdk/vm/ci/runtime/JVMCICompiler.java | 58 - .../vm/ci/runtime/JVMCICompilerFactory.java | 57 - .../jdk/vm/ci/runtime/JVMCIRuntime.java | 48 - .../jdk/vm/ci/runtime/package-info.java | 27 - .../jdk/vm/ci/services/JVMCIPermission.java | 37 - .../vm/ci/services/JVMCIServiceLocator.java | 101 - .../classes/jdk/vm/ci/services/Services.java | 279 -- .../vm/ci/services/SuppressFBWarnings.java | 40 - .../jdk/vm/ci/services/SystemProperties.java | 180 - .../jdk/vm/ci/services/VMEntryPoint.java | 33 - .../jdk/vm/ci/services/package-info.java | 27 - .../share/classes/module-info.java | 44 - .../classes/jdk/jfr/internal/TypeLibrary.java | 9 +- .../sun/hotspot/tools/compiler/LogParser.java | 4 +- .../src/test/resources/8314319.xml | 26 +- .../jtreg/ProblemList-jvmti-stress-agent.txt | 4 - test/hotspot/jtreg/ProblemList-zgc.txt | 8 - test/hotspot/jtreg/ProblemList.txt | 9 - test/hotspot/jtreg/TEST.ROOT | 5 - test/hotspot/jtreg/TEST.groups | 1 - .../applications/ctw/modules/generate.bash | 4 +- .../ctw/modules/jdk_internal_vm_ci.java | 38 - .../BMICommandLineOptionTestBase.java | 4 +- .../arguments/BMISupportedCPUTest.java | 4 +- .../arguments/BMIUnsupportedCPUTest.java | 4 +- .../arraycopy/TestArrayCopyNoInitDeopt.java | 4 +- .../compiler/arraycopy/TestCloneAccess.java | 4 +- .../arraycopy/TestCloneAccessStressGCM.java | 4 +- .../jtreg/compiler/c2/Test8004741.java | 3 +- .../compiler/c2/aarch64/TestVolatilesG1.java | 3 +- .../c2/aarch64/TestVolatilesParallel.java | 3 +- .../c2/aarch64/TestVolatilesSerial.java | 3 +- .../compiler/cha/AbstractRootMethod.java | 3 +- .../jtreg/compiler/cha/DefaultRootMethod.java | 3 +- .../cha/StrengthReduceInterfaceCall.java | 3 +- .../TestOverloadCompileQueues.java | 3 +- .../jtreg/compiler/codegen/TestCharVect2.java | 4 +- .../jcmd/PrintDirectivesTest.java | 4 +- .../logcompilation/LogTest.java | 3 +- .../TestAESIntrinsicsOnSupportedConfig.java | 2 +- .../TestAESIntrinsicsOnUnsupportedConfig.java | 3 +- .../TestEliminateLocksOffCrash.java | 2 +- .../floatingpoint/TestFloatJNIArgs.java | 1 - ...estVerifyStackWithUnreachableBytecode.java | 4 +- ...erifyStackWithUnreachableBytecodeImpl.jasm | 4 +- .../intrinsics/IntrinsicAvailableTest.java | 7 +- .../intrinsics/IntrinsicDisabledTest.java | 3 +- .../intrinsics/bmi/verifycode/AndnTestI.java | 4 +- .../intrinsics/bmi/verifycode/AndnTestL.java | 4 +- .../intrinsics/bmi/verifycode/BlsiTestI.java | 4 +- .../intrinsics/bmi/verifycode/BlsiTestL.java | 4 +- .../bmi/verifycode/BlsmskTestI.java | 4 +- .../bmi/verifycode/BlsmskTestL.java | 4 +- .../intrinsics/bmi/verifycode/BlsrTestI.java | 4 +- .../intrinsics/bmi/verifycode/BlsrTestL.java | 4 +- .../bmi/verifycode/BzhiTestI2L.java | 4 +- .../intrinsics/bmi/verifycode/LZcntTestI.java | 4 +- .../intrinsics/bmi/verifycode/LZcntTestL.java | 4 +- .../intrinsics/bmi/verifycode/TZcntTestI.java | 4 +- .../intrinsics/bmi/verifycode/TZcntTestL.java | 4 +- .../klass/CastNullCheckDroppingsTest.java | 2 +- .../jvmci/JVM_GetJVMCIRuntimeTest.java | 93 - .../jvmci/TestEnableJVMCIProduct.java | 123 - .../jvmci/TestInvalidJVMCIOption.java | 60 - .../jvmci/TestJVMCIPrintProperties.java | 56 - .../jvmci/TestJVMCISavedProperties.java | 65 - .../TestUncaughtErrorInCompileMethod.config | 1 - .../TestUncaughtErrorInCompileMethod.java | 234 -- .../compiler/jvmci/TestValidateModules.java | 48 - .../compiler/jvmci/common/CTVMUtilities.java | 123 - .../jvmci/common/CodeInstallerTest.java | 129 - .../compiler/jvmci/common/JVMCIHelpers.java | 81 - .../jdk/vm/ci/hotspot/CompilerToVMHelper.java | 314 -- .../HotSpotResolvedJavaFieldHelper.java | 37 - .../jdk/vm/ci/hotspot/MetaAccessWrapper.java | 40 - .../hotspot/PublicMetaspaceWrapperObject.java | 29 - .../jvmci/common/testcases/AbstractClass.java | 29 - .../testcases/AbstractClassExtender.java | 37 - .../testcases/AnotherSingleImplementer.java | 42 - .../AnotherSingleImplementerInterface.java | 36 - .../common/testcases/DoNotExtendClass.java | 28 - .../testcases/DoNotImplementInterface.java | 28 - ...icateSimpleSingleImplementerInterface.java | 28 - .../testcases/MultiSubclassedClass.java | 28 - .../MultiSubclassedClassSubclass1.java | 28 - .../MultiSubclassedClassSubclass2.java | 28 - .../MultipleAbstractImplementer.java | 116 - .../testcases/MultipleImplementer1.java | 43 - .../testcases/MultipleImplementer2.java | 118 - .../MultipleImplementersInterface.java | 79 - ...MultipleImplementersInterfaceExtender.java | 33 - .../testcases/MultipleSuperImplementers.java | 30 - .../common/testcases/PackagePrivateClass.java | 28 - .../jvmci/common/testcases/SimpleClass.java | 32 - .../SimpleSingleImplementerInterface.java | 28 - .../common/testcases/SingleImplementer.java | 42 - .../testcases/SingleImplementerInterface.java | 36 - .../common/testcases/SingleSubclass.java | 51 - .../testcases/SingleSubclassedClass.java | 34 - .../jvmci/common/testcases/TestCase.java | 71 - .../compilerToVM/AllocateCompileIdTest.java | 162 - .../AsResolvedJavaMethodTest.java | 113 - .../compilerToVM/CollectCountersTest.java | 63 - .../compilerToVM/CompileCodeTestCase.java | 272 -- .../compilerToVM/ConstantPoolTestCase.java | 266 -- .../compilerToVM/ConstantPoolTestsHelper.java | 570 --- .../compilerToVM/DisassembleCodeBlobTest.java | 134 - .../DoNotInlineOrCompileTest.java | 88 - .../compilerToVM/DummyAbstractClass.java | 28 - .../jvmci/compilerToVM/DummyClass.java | 83 - .../jvmci/compilerToVM/DummyInterface.java | 33 - .../ExecuteInstalledCodeTest.java | 137 - .../FindUniqueConcreteMethodTest.java | 164 - .../jvmci/compilerToVM/GetBytecodeTest.java | 99 - .../compilerToVM/GetClassInitializerTest.java | 115 - .../compilerToVM/GetConstantPoolTest.java | 103 - .../compilerToVM/GetExceptionTableTest.java | 142 - .../jvmci/compilerToVM/GetFlagValueTest.java | 95 - .../compilerToVM/GetImplementorTest.java | 144 - .../compilerToVM/GetLineNumberTableTest.java | 91 - .../GetLocalVariableTableTest.java | 122 - .../GetMaxCallTargetOffsetTest.java | 61 - .../GetResolvedJavaMethodTest.java | 193 - .../compilerToVM/GetResolvedJavaTypeTest.java | 219 -- .../GetStackTraceElementTest.java | 151 - .../jvmci/compilerToVM/GetSymbolTest.java | 135 - .../GetVtableIndexForInterfaceTest.java | 200 - .../HasCompiledCodeForOSRTest.java | 137 - .../HasFinalizableSubclassTest.java | 109 - .../HasNeverInlineDirectiveTest.java | 93 - .../jvmci/compilerToVM/IsCompilableTest.java | 109 - .../jvmci/compilerToVM/IsMatureTest.java | 88 - .../compilerToVM/IsMatureVsReprofileTest.java | 100 - .../compilerToVM/IterateFramesNative.java | 184 - .../JVM_RegisterJVMCINatives.java | 102 - .../LookupConstantInPoolTest.java | 150 - .../compilerToVM/LookupKlassInPoolTest.java | 109 - .../LookupKlassRefIndexInPoolTest.java | 104 - .../compilerToVM/LookupMethodInPoolTest.java | 127 - .../LookupNameAndTypeRefIndexInPoolTest.java | 106 - .../compilerToVM/LookupNameInPoolTest.java | 106 - .../LookupSignatureInPoolTest.java | 106 - .../jvmci/compilerToVM/LookupTypeTest.java | 188 - .../MaterializeVirtualObjectTest.java | 351 -- ...ethodIsIgnoredBySecurityStackWalkTest.java | 104 - .../compilerToVM/ReadConfigurationTest.java | 87 - .../jvmci/compilerToVM/ReprofileTest.java | 118 - .../compilerToVM/ResolveFieldInPoolTest.java | 166 - .../jvmci/compilerToVM/ResolveMethodTest.java | 188 - .../compilerToVM/ResolveTypeInPoolTest.java | 105 - .../ShouldDebugNonSafepointsTest.java | 62 - .../compilerToVM/ShouldInlineMethodTest.java | 94 - .../compilerToVM/libIterateFramesNative.c | 44 - .../errors/TestInvalidCompilationResult.java | 201 - .../jvmci/errors/TestInvalidDebugInfo.java | 245 -- .../jvmci/errors/TestInvalidOopMap.java | 115 - .../errors/TestInvalidTieredStopAtLevel.java | 46 - .../JvmciCreateMetaAccessContextTest.config | 1 - ...mciNotifyBootstrapFinishedEventTest.config | 2 - ...JvmciNotifyBootstrapFinishedEventTest.java | 95 - .../events/JvmciShutdownEventListener.java | 56 - .../events/JvmciShutdownEventTest.config | 2 - .../jvmci/events/JvmciShutdownEventTest.java | 82 - .../jdk.vm.ci.code.test/libNativeCallTest.c | 228 -- .../vm/ci/code/test/CodeInstallationTest.java | 124 - .../code/test/CodeInvalidationReasonTest.java | 77 - .../jdk/vm/ci/code/test/DataPatchTest.java | 157 - .../jdk/vm/ci/code/test/DebugInfoTest.java | 103 - .../vm/ci/code/test/InstalledCodeTest.java | 57 - .../code/test/InterpreterFrameSizeTest.java | 83 - .../code/test/MaxOopMapStackOffsetTest.java | 91 - .../jdk/vm/ci/code/test/NativeCallTest.java | 294 -- .../code/test/RuntimeStubAllocFailTest.java | 86 - .../code/test/SimpleCodeInstallationTest.java | 85 - .../vm/ci/code/test/SimpleDebugInfoTest.java | 203 - .../jdk/vm/ci/code/test/TestAssembler.java | 485 --- .../vm/ci/code/test/TestHotSpotVMConfig.java | 85 - .../code/test/VirtualObjectDebugInfoTest.java | 198 - .../test/VirtualObjectFormattingTest.java | 48 - .../ci/code/test/VirtualObjectTestBase.java | 230 -- .../test/aarch64/AArch64TestAssembler.java | 666 ---- .../code/test/amd64/AMD64TestAssembler.java | 523 --- .../test/riscv64/RISCV64TestAssembler.java | 541 --- .../hotspot/test/AsJavaTypeDataProvider.java | 59 - .../test/BoxPrimitiveDataProvider.java | 88 - .../test/ConstantEqualsDataProvider.java | 94 - .../jdk/vm/ci/hotspot/test/DummyClass.java | 164 - .../hotspot/test/ForObjectDataProvider.java | 55 - .../hotspot/test/ForStringDataProvider.java | 38 - ...HotSpotConstantReflectionProviderTest.java | 133 - .../test/HotSpotResolvedJavaFieldTest.java | 139 - .../test/IsEmbeddableDataProvider.java | 46 - .../test/MemoryAccessProviderData.java | 212 - .../test/MemoryAccessProviderTest.java | 136 - .../test/MethodHandleAccessProviderData.java | 217 -- .../test/MethodHandleAccessProviderTest.java | 137 - .../test/ReadArrayElementDataProvider.java | 102 - .../test/ReadArrayLengthDataProvider.java | 74 - .../test/ReadFieldValueDataProvider.java | 128 - .../ci/hotspot/test/TestDynamicConstant.java | 562 --- .../jdk/vm/ci/hotspot/test/TestHelper.java | 436 --- .../hotspot/test/TestHotSpotJVMCIRuntime.java | 191 - .../test/TestHotSpotResolvedJavaField.java | 66 - .../test/TestHotSpotSpeculationLog.java | 129 - .../test/UnboxPrimitiveDataProvider.java | 100 - .../hotspot/test/VirtualObjectLayoutTest.java | 77 - .../vm/ci/runtime/test/ConstantPoolTest.java | 328 -- .../jdk/vm/ci/runtime/test/ConstantTest.java | 51 - .../jdk/vm/ci/runtime/test/FieldUniverse.java | 46 - .../vm/ci/runtime/test/MethodUniverse.java | 51 - .../vm/ci/runtime/test/NameAndSignature.java | 90 - .../vm/ci/runtime/test/RedefineClassTest.java | 182 - ...lvedJavaTypeResolveConcreteMethodTest.java | 185 - .../ResolvedJavaTypeResolveMethodTest.java | 205 - .../vm/ci/runtime/test/TestBytecodeFrame.java | 115 - .../test/TestConstantReflectionProvider.java | 175 - .../jdk/vm/ci/runtime/test/TestJavaField.java | 91 - .../vm/ci/runtime/test/TestJavaMethod.java | 76 - .../jdk/vm/ci/runtime/test/TestJavaType.java | 59 - .../runtime/test/TestMetaAccessProvider.java | 294 -- .../runtime/test/TestResolvedJavaField.java | 376 -- .../runtime/test/TestResolvedJavaMethod.java | 855 ---- .../ci/runtime/test/TestResolvedJavaType.java | 1478 ------- .../runtime/test/TestSingleImplementor.java | 102 - .../ci/runtime/test/TestSpeculationLog.java | 170 - .../jdk/vm/ci/runtime/test/TypeUniverse.java | 252 -- .../jvmci/meta/ProfilingInfoTest.java | 386 -- .../compiler/jvmci/meta/StableFieldTest.java | 62 - .../compiler/lib/ir_framework/IRNode.java | 12 - .../loopopts/LoopRotateBadNodeBudget.java | 4 +- .../loopopts/LoopUnrollBadNodeBudget.java | 4 +- .../LoopUnswitchingBadNodeBudget.java | 4 +- .../loopopts/TestDivZeroCheckControl.java | 11 +- .../UseCountedLoopSafepointsTest.java | 3 +- .../TestNoWarningLoopStripMiningIterSet.java | 8 +- .../compiler/profiling/TestTypeProfiling.java | 4 +- .../rangechecks/TestRangeCheckSmearing.java | 4 +- .../jtreg/compiler/runtime/Test6859338.java | 3 +- .../sharedstubs/SharedStubToInterpTest.java | 1 - .../compiler/tiered/TieredModesTest.java | 5 +- .../compiler/uncommontrap/Decompile.java | 6 +- .../compiler/uncommontrap/Test8009761.java | 4 +- .../compiler/uncommontrap/TestDeoptOOM.java | 5 +- .../uncommontrap/TestUnstableIfTrap.java | 4 +- .../unsafe/UnsafeGetStableArrayElement.java | 9 +- .../whitebox/BlockingCompilation.java | 1 - .../whitebox/ForceNMethodSweepTest.java | 4 +- .../TestTargetSurvivorRatioFlag.java | 3 +- .../TestUseCompressedOopsFlagsWithUlimit.java | 6 +- .../jtreg/gc/g1/TestGCLogMessages.java | 10 +- .../jtreg/gc/g1/ihop/TestIHOPStatic.java | 1 - test/hotspot/jtreg/gc/z/TestNoUncommit.java | 4 +- .../TestOptionsWithRanges.java | 8 +- .../optionsvalidation/JVMOptionsUtils.java | 12 +- ...essedCPUSpecificClassSpaceReservation.java | 4 +- .../CompressedClassPointers.java | 2 +- ...CompressedClassPointersEncodingScheme.java | 4 +- .../runtime/ErrorHandling/TestDwarf.java | 2 +- .../runtime/NMT/MallocSiteTypeChange.java | 4 +- .../jtreg/runtime/cds/BootAppendTests.java | 4 +- .../appcds/dynamicArchive/MainModuleOnly.java | 39 +- .../dynamicArchive/NoClassToArchive.java | 11 +- .../cds/appcds/jigsaw/JigsawOptionsCombo.java | 4 +- .../appcds/jigsaw/addmods/AddmodsOption.java | 29 - .../classpathtests/BootAppendTests.java | 4 +- .../jigsaw/classpathtests/ClassPathTests.java | 4 +- .../EmptyClassInBootClassPath.java | 4 +- .../jigsaw/modulepath/MainModuleOnly.java | 37 +- .../jigsaw/modulepath/ModulePathAndFMG.java | 4 +- .../OptimizeModuleHandlingTest.java | 4 +- .../ParallelLoadAndTransformTest.java | 3 +- .../TransformInterfaceImplementorAppCDS.java | 3 +- .../TransformSuperSubAppCDS.java | 3 +- .../methodHandles/CDSMHTest_generate.sh | 5 +- .../ReplaceCriticalClassesForSubgraphs.java | 3 +- .../TransformInterfaceAndImplementor.java | 3 +- .../TransformSuperAndSubClasses.java | 3 +- .../TransformSuperSubTwoPckgs.java | 3 +- .../runtime/clinit/ClassInitBarrier.java | 4 +- .../AbstractMethodErrorTest.java | 4 +- .../ArrayIndexOutOfBoundsExceptionTest.java | 6 +- .../IncompatibleClassChangeErrorTest.java | 4 +- .../JvmtiGetAllModulesTest.java | 6 +- .../HeapMonitor/MyPackage/HeapMonitor.java | 54 +- .../MyPackage/HeapMonitorVMEventsTest.java | 5 +- .../jvmti/HeapMonitor/libHeapMonitorTest.cpp | 37 +- .../RedefineClasses/TestRedefineObject.java | 3 +- .../jtreg/serviceability/sa/TestUniverse.java | 10 +- .../ir_framework/tests/TestIRMatching.java | 21 +- .../referringObjects001.java | 3 +- .../referringObjects003.java | 3 +- .../instances/instances001/instances001.java | 3 +- .../VMOutOfMemoryException001.java | 3 +- .../allThreads/allthreads001.java | 6 +- .../instancecounts001/instancecounts001.java | 3 +- .../referringObjects001.java | 3 +- .../Instances/instances001/instances001.java | 3 +- .../instanceCounts001/instanceCounts001.java | 3 +- .../nsk/jvmti/Allocate/alloc001/alloc001.java | 4 +- .../resexhausted002/TestDescription.java | 3 +- .../GF08/gf08t001/TestDriver.java | 7 +- .../nsk/share/jvmti/jvmti_tools.cpp | 4 +- .../nsk/share/jvmti/jvmti_tools.hpp | 4 +- test/jdk/ProblemList-Virtual.txt | 2 +- test/jdk/TEST.ROOT | 3 - test/jdk/com/sun/jdi/EATests.java | 131 +- test/jdk/com/sun/jdi/ExceptionEvents.java | 3 +- .../com/sun/tools/attach/modules/Driver.java | 3 +- .../Class/GetPackageBootLoaderChildLayer.java | 3 +- .../FieldSetAccessibleTest.java | 66 +- .../lang/StackWalker/LocalsAndOperands.java | 3 +- .../LoggerFinderAPI/LoggerFinderAPI.java | 3 +- .../instrument/TestAgentWithLimitMods.java | 3 +- .../DefaultManagementProviderTest.java | 3 +- .../management/ThreadMXBean/ThreadLists.java | 4 +- .../java/net/SocketOption/OptionsTest.java | 3 +- .../SocketOption/UnsupportedOptionsTest.java | 3 +- .../DatagramChannel/SocketOptionTests.java | 3 +- .../SocketOptionTests.java | 3 +- .../SocketChannel/SocketOptionTests.java | 5 +- .../util/concurrent/locks/Lock/OOMEInAQS.java | 3 +- .../locks/StampedLock/OOMEInStampedLock.java | 3 +- .../management/generified/GenericTest.java | 6 +- .../management/query/CustomQueryTest.java | 4 +- .../AnnotationTestInput.java | 375 -- .../MemberDeleted.java | 33 - .../MemberTypeChanged.java | 33 - .../TestAnnotationEncodingDecoding.java | 257 -- .../alt/MemberDeleted.java | 32 - .../alt/MemberTypeChanged.java | 33 - .../internal/vm/TestTranslatedException.java | 205 - .../event/compiler/TestDeoptimization.java | 11 +- .../event/runtime/TestDeprecatedEvent.java | 8 +- .../jfr/event/runtime/TestModuleEvents.java | 3 +- .../runtime/TestNativeMemoryUsageEvents.java | 3 +- test/jdk/jdk/jfr/jvm/TestGetEventWriter.java | 88 +- .../modules/etc/JdkQualifiedExportTest.java | 9 +- .../jdk/modules/etc/UpgradeableModules.java | 7 +- .../plugins/SaveJlinkArgfilesPluginTest.java | 9 +- .../modules/limitmods/LimitModsTest.java | 3 +- .../modules/listmods/ListModsTest.java | 3 +- .../ShowModuleResolutionTest.java | 3 +- test/jtreg-ext/requires/VMProps.java | 73 - .../testSearchScript/TestSearchScript.java | 9 +- test/lib/jdk/test/lib/jvmti/jvmti_common.hpp | 14 +- test/lib/jdk/test/whitebox/WhiteBox.java | 6 - test/lib/jdk/test/whitebox/code/Compiler.java | 82 +- test/lib/jdk/test/whitebox/gc/GC.java | 9 +- 803 files changed, 872 insertions(+), 82291 deletions(-) delete mode 100644 make/GraalBuilderImage.gmk delete mode 100644 make/modules/jdk.internal.vm.ci/Java.gmk delete mode 100644 src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp delete mode 100644 src/hotspot/cpu/arm/jvmciCodeInstaller_arm.cpp delete mode 100644 src/hotspot/cpu/ppc/jvmciCodeInstaller_ppc.cpp delete mode 100644 src/hotspot/cpu/riscv/jvmciCodeInstaller_riscv.cpp delete mode 100644 src/hotspot/cpu/s390/jvmciCodeInstaller_s390.cpp delete mode 100644 src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp delete mode 100644 src/hotspot/share/jvmci/jniAccessMark.inline.hpp delete mode 100644 src/hotspot/share/jvmci/jvmci.cpp delete mode 100644 src/hotspot/share/jvmci/jvmci.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciCodeInstaller.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciCodeInstaller.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciCompiler.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciCompiler.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciCompilerToVM.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciCompilerToVM.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciEnv.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciEnv.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciExceptions.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciJavaClasses.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciJavaClasses.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciObject.hpp delete mode 100644 src/hotspot/share/jvmci/jvmciRuntime.cpp delete mode 100644 src/hotspot/share/jvmci/jvmciRuntime.hpp delete mode 100644 src/hotspot/share/jvmci/jvmci_globals.cpp delete mode 100644 src/hotspot/share/jvmci/jvmci_globals.hpp delete mode 100644 src/hotspot/share/jvmci/metadataHandles.cpp delete mode 100644 src/hotspot/share/jvmci/metadataHandles.hpp delete mode 100644 src/hotspot/share/jvmci/vmStructs_jvmci.cpp delete mode 100644 src/hotspot/share/jvmci/vmStructs_jvmci.hpp delete mode 100644 src/hotspot/share/jvmci/vmSymbols_jvmci.hpp delete mode 100644 src/java.base/share/classes/jdk/internal/vm/TranslatedException.java delete mode 100644 src/jdk.compiler/share/data/symbols/jdk.graal.compiler-M.sym.txt delete mode 100644 src/jdk.compiler/share/data/symbols/jdk.graal.compiler.management-M.sym.txt delete mode 100644 src/jdk.compiler/share/data/symbols/jdk.internal.vm.ci-M.sym.txt delete mode 100644 src/jdk.graal.compiler.management/share/classes/module-info.java delete mode 100644 src/jdk.graal.compiler/share/classes/module-info.java delete mode 100644 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64Kind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64Kind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Architecture.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BailoutException.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodeFrame.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodePosition.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CPUFeatureName.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CallingConvention.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeCacheProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequest.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequestResult.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompiledCode.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/DebugInfo.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InvalidInstalledCodeException.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Location.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/MemoryBarriers.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ReferenceMap.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterAttributes.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterSaveLayout.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterValue.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackLockValue.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackSlot.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/SuppressFBWarnings.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueKindFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueUtil.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Call.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ConstantReference.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataPatch.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataSectionReference.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ExceptionHandler.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ImplicitExceptionDispatch.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/InfopointReason.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Mark.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Reference.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Site.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrameVisitor.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/InitTimer.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/JVMCIError.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/SuppressFBWarnings.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/AnnotationDataDecoder.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/Cleaner.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerThreadCanCallJavaScope.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EmptyEventProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EventProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HandleCleaner.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCode.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPool.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotInstalledCode.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIUnsupportedOperationError.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJavaType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotModifiers.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotNmethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantScope.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfoImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotReferenceMap.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSignature.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMEventListener.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/JFR.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceHandleObject.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceObject.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedHotSpotSpeculationLog.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SuppressFBWarnings.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/UnsafeAccess.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMEntryPoint.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMField.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMFlag.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMIntrinsicMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotJVMCIBackendFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotRegisterConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotVMConfig.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractJavaProfile.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AllocatableValue.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Annotated.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AnnotationData.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Constant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantPool.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantReflectionProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DefaultProfilingInfo.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationAction.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationReason.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EncodedSpeculationReason.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EnumData.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ErrorData.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ExceptionHandler.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/InvokeTarget.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaField.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaKind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethodProfile.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaTypeProfile.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaValue.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LineNumberTable.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LocalVariableTable.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MemoryAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaUtil.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MethodHandleAccessProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/NullConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PlatformKind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PrimitiveConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ProfilingInfo.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/RawConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SerializableConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Signature.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SpeculationLog.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SuppressFBWarnings.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/TriState.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaField.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaMethod.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaType.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/VMConstant.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ValueKind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64Kind.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCI.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIBackend.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompiler.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompilerFactory.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIRuntime.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIPermission.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SuppressFBWarnings.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SystemProperties.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/VMEntryPoint.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/package-info.java delete mode 100644 src/jdk.internal.vm.ci/share/classes/module-info.java delete mode 100644 test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/CTVMUtilities.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/CodeInstallerTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/JVMCIHelpers.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldHelper.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/MetaAccessWrapper.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClassExtender.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementer.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementerInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotExtendClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotImplementInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/DuplicateSimpleSingleImplementerInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass1.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass2.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleAbstractImplementer.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer1.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer2.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterfaceExtender.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleSuperImplementers.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/PackagePrivateClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleSingleImplementerInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementer.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementerInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclassedClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/common/testcases/TestCase.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/CollectCountersTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/CompileCodeTestCase.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyAbstractClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyInterface.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetBytecodeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetClassInitializerTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetConstantPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetExceptionTableTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetImplementorTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetSymbolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasNeverInlineDirectiveTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupConstantInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupTypeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReadConfigurationTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReprofileTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/compilerToVM/libIterateFramesNative.c delete mode 100644 test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidCompilationResult.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidDebugInfo.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidOopMap.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidTieredStopAtLevel.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.config delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventListener.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.config delete mode 100644 test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInvalidationReasonTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/RuntimeStubAllocFailTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectFormattingTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectTestBase.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/riscv64/RISCV64TestAssembler.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/AsJavaTypeDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/BoxPrimitiveDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ConstantEqualsDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/DummyClass.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForObjectDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForStringDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/IsEmbeddableDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderData.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayElementDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayLengthDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadFieldValueDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestDynamicConstant.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHelper.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotResolvedJavaField.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/UnboxPrimitiveDataProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantPoolTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/FieldUniverse.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/MethodUniverse.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/NameAndSignature.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestBytecodeFrame.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSingleImplementor.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSpeculationLog.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/meta/ProfilingInfoTest.java delete mode 100644 test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/TestAnnotationEncodingDecoding.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java delete mode 100644 test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java delete mode 100644 test/jdk/jdk/internal/vm/TestTranslatedException.java diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3cd8904868..44eb5b48a9a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -311,7 +311,7 @@ jobs: dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }} # Upload static libs bundles separately to avoid interference with normal linux-x64 bundle. # This bundle is not used by testing jobs, but downstreams use it to check that - # dependent projects, e.g. libgraal, builds fine. + # dependent projects build fine. bundle-suffix: "-static-libs" if: needs.prepare.outputs.linux-x64-variants == 'true' diff --git a/make/Bundles.gmk b/make/Bundles.gmk index 0b324e7e3f3..925149d4cc7 100644 --- a/make/Bundles.gmk +++ b/make/Bundles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -410,27 +410,6 @@ endif ################################################################################ -ifneq ($(filter static-libs-graal-bundles, $(MAKECMDGOALS)), ) - STATIC_LIBS_GRAAL_BUNDLE_FILES := $(call FindFiles, $(STATIC_LIBS_GRAAL_IMAGE_DIR)) - - ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) - STATIC_LIBS_GRAAL_BUNDLE_SUBDIR := $(JDK_MACOSX_CONTENTS_SUBDIR)/Home - else - STATIC_LIBS_GRAAL_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR) - endif - - $(eval $(call SetupBundleFile, BUILD_STATIC_LIBS_GRAAL_BUNDLE, \ - BUNDLE_NAME := $(STATIC_LIBS_GRAAL_BUNDLE_NAME), \ - FILES := $(STATIC_LIBS_GRAAL_BUNDLE_FILES), \ - BASE_DIRS := $(STATIC_LIBS_GRAAL_IMAGE_DIR), \ - SUBDIR := $(STATIC_LIBS_GRAAL_BUNDLE_SUBDIR), \ - )) - - STATIC_LIBS_GRAAL_TARGETS += $(BUILD_STATIC_LIBS_GRAAL_BUNDLE) -endif - -################################################################################# - ifneq ($(filter static-jdk-bundles, $(MAKECMDGOALS)), ) STATIC_JDK_BUNDLE_FILES := $(call FindFiles, $(STATIC_JDK_IMAGE_DIR)) @@ -453,13 +432,12 @@ docs-jdk-bundles: $(DOCS_JDK_TARGETS) docs-javase-bundles: $(DOCS_JAVASE_TARGETS) docs-reference-bundles: $(DOCS_REFERENCE_TARGETS) static-libs-bundles: $(STATIC_LIBS_TARGETS) -static-libs-graal-bundles: $(STATIC_LIBS_GRAAL_TARGETS) static-jdk-bundles: $(STATIC_JDK_TARGETS) jcov-bundles: $(JCOV_TARGETS) .PHONY: product-bundles test-bundles \ docs-jdk-bundles docs-javase-bundles docs-reference-bundles \ - static-libs-bundles static-libs-graal-bundles static-jdk-bundles jcov-bundles + static-libs-bundles static-jdk-bundles jcov-bundles ################################################################################ diff --git a/make/GraalBuilderImage.gmk b/make/GraalBuilderImage.gmk deleted file mode 100644 index d707e067a55..00000000000 --- a/make/GraalBuilderImage.gmk +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2020, Red Hat Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -include MakeFileStart.gmk - -################################################################################ -# This makefile creates a jdk image overlaid with statically linked core -# libraries. -################################################################################ - -include CopyFiles.gmk - -$(eval $(call SetupCopyFiles, COPY_JDK_IMG, \ - SRC := $(JDK_IMAGE_DIR)/, \ - DEST := $(GRAAL_BUILDER_IMAGE_DIR)/, \ - FILES := $(call FindFiles, $(JDK_IMAGE_DIR)/), \ -)) -TARGETS += $(COPY_JDK_IMG) - -$(eval $(call SetupCopyFiles, COPY_STATIC_LIBS, \ - SRC := $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib, \ - DEST := $(GRAAL_BUILDER_IMAGE_DIR)/lib, \ - FILES := $(filter %$(STATIC_LIBRARY_SUFFIX), \ - $(call FindFiles, $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib)), \ -)) -TARGETS += $(COPY_STATIC_LIBS) - -################################################################################ - -include MakeFileEnd.gmk diff --git a/make/Main.gmk b/make/Main.gmk index 22302cdea46..172cee697ad 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -478,11 +478,6 @@ $(eval $(call SetupTarget, static-libs-image, \ TARGET := static-libs-image, \ )) -$(eval $(call SetupTarget, static-libs-graal-image, \ - MAKEFILE := StaticLibsImage, \ - TARGET := static-libs-graal-image, \ -)) - $(eval $(call SetupTarget, mac-jdk-bundle, \ MAKEFILE := MacBundles, \ TARGET := jdk-bundle, \ @@ -506,11 +501,6 @@ $(eval $(call SetupTarget, exploded-image-optimize, \ buildtools-modules, \ )) -$(eval $(call SetupTarget, graal-builder-image, \ - MAKEFILE := GraalBuilderImage, \ - DEPS := jdk-image static-libs-graal-image, \ -)) - ifeq ($(JCOV_ENABLED), true) $(eval $(call SetupTarget, jcov-image, \ MAKEFILE := Coverage, \ @@ -877,12 +867,6 @@ $(eval $(call SetupTarget, static-libs-bundles, \ DEPS := static-libs-image, \ )) -$(eval $(call SetupTarget, static-libs-graal-bundles, \ - MAKEFILE := Bundles, \ - TARGET := static-libs-graal-bundles, \ - DEPS := static-libs-graal-image, \ -)) - $(eval $(call SetupTarget, static-jdk-bundles, \ MAKEFILE := Bundles, \ TARGET := static-jdk-bundles, \ @@ -1124,8 +1108,6 @@ else static-libs-image: hotspot-static-libs static-libs - static-libs-graal-image: static-libs - bootcycle-images: jdk-image docs-jdk-api-javadoc: $(GENSRC_TARGETS) diff --git a/make/StaticLibsImage.gmk b/make/StaticLibsImage.gmk index 1f50c5b7f1b..6e00a39977b 100644 --- a/make/StaticLibsImage.gmk +++ b/make/StaticLibsImage.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,6 @@ ALL_MODULES = $(call FindAllModules) ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) IMAGE_DEST_DIR = $(STATIC_LIBS_IMAGE_DIR)/lib -else ifneq ($(filter static-libs-graal-image, $(MAKECMDGOALS)), ) - IMAGE_DEST_DIR = $(STATIC_LIBS_GRAAL_IMAGE_DIR)/lib endif # Copy JDK static libs to the image. @@ -70,7 +68,6 @@ ifneq ($(filter static-libs-image, $(MAKECMDGOALS)), ) endif static-libs-image: $(HOTSPOT_VARIANT_STATIC_LIBS_TARGETS) $(STATIC_LIBS_TARGETS) -static-libs-graal-image: $(STATIC_LIBS_TARGETS) ################################################################################ diff --git a/make/autoconf/jvm-features.m4 b/make/autoconf/jvm-features.m4 index 234d7b74268..0696c4f1199 100644 --- a/make/autoconf/jvm-features.m4 +++ b/make/autoconf/jvm-features.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ m4_define(jvm_features_valid, m4_normalize( \ ifdef([custom_jvm_features_valid], custom_jvm_features_valid) \ \ cds compiler1 compiler2 dtrace epsilongc g1gc jfr jni-check \ - jvmci jvmti link-time-opt management minimal opt-size parallelgc \ + jvmti link-time-opt management minimal opt-size parallelgc \ serialgc services shenandoahgc vm-structs zero zgc \ )) @@ -62,7 +62,6 @@ m4_define(jvm_feature_desc_epsilongc, [include the epsilon (no-op) garbage colle m4_define(jvm_feature_desc_g1gc, [include the G1 garbage collector]) m4_define(jvm_feature_desc_jfr, [enable JDK Flight Recorder (JFR)]) m4_define(jvm_feature_desc_jni_check, [enable -Xcheck:jni support]) -m4_define(jvm_feature_desc_jvmci, [enable JVM Compiler Interface (JVMCI)]) m4_define(jvm_feature_desc_jvmti, [enable Java Virtual Machine Tool Interface (JVM TI)]) m4_define(jvm_feature_desc_link_time_opt, [enable link time optimization]) m4_define(jvm_feature_desc_management, [enable java.lang.management API support]) @@ -269,26 +268,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_CHECK_DTRACE], ]) ]) -################################################################################ -# Check if the feature 'jvmci' is available on this platform. -# -AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JVMCI], -[ - JVM_FEATURES_CHECK_AVAILABILITY(jvmci, [ - AC_MSG_CHECKING([if platform is supported by JVMCI]) - if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then - AC_MSG_RESULT([yes]) - elif test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then - AC_MSG_RESULT([yes]) - elif test "x$OPENJDK_TARGET_CPU" = "xriscv64"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU]) - AVAILABLE=false - fi - ]) -]) - ################################################################################ # Check if the feature 'shenandoahgc' is available on this platform. # @@ -376,7 +355,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_PREPARE_PLATFORM], JVM_FEATURES_CHECK_CDS JVM_FEATURES_CHECK_DTRACE - JVM_FEATURES_CHECK_JVMCI JVM_FEATURES_CHECK_SHENANDOAHGC JVM_FEATURES_CHECK_ZGC @@ -401,17 +379,17 @@ AC_DEFUN([JVM_FEATURES_PREPARE_VARIANT], JVM_FEATURES_VARIANT_UNAVAILABLE="cds minimal zero" elif test "x$variant" = "xzero"; then JVM_FEATURES_VARIANT_UNAVAILABLE="compiler1 compiler2 \ - jvmci minimal zgc" + minimal zgc" else JVM_FEATURES_VARIANT_UNAVAILABLE="minimal zero" fi # Check which features should be off by default for this JVM variant. if test "x$variant" = "xclient"; then - JVM_FEATURES_VARIANT_FILTER="compiler2 jvmci link-time-opt opt-size" + JVM_FEATURES_VARIANT_FILTER="compiler2 link-time-opt opt-size" elif test "x$variant" = "xminimal"; then JVM_FEATURES_VARIANT_FILTER="cds compiler2 dtrace epsilongc g1gc \ - jfr jni-check jvmci jvmti management parallelgc services \ + jfr jni-check jvmti management parallelgc services \ shenandoahgc vm-structs zgc" if test "x$OPENJDK_TARGET_CPU" = xarm ; then JVM_FEATURES_VARIANT_FILTER="$JVM_FEATURES_VARIANT_FILTER opt-size" @@ -421,7 +399,7 @@ AC_DEFUN([JVM_FEATURES_PREPARE_VARIANT], link-time-opt" fi elif test "x$variant" = "xcore"; then - JVM_FEATURES_VARIANT_FILTER="compiler1 compiler2 jvmci \ + JVM_FEATURES_VARIANT_FILTER="compiler1 compiler2 \ link-time-opt opt-size" elif test "x$variant" = "xzero"; then JVM_FEATURES_VARIANT_FILTER="jfr link-time-opt opt-size" @@ -517,11 +495,6 @@ AC_DEFUN([JVM_FEATURES_VERIFY], AC_MSG_ERROR([Specified JVM feature 'jfr' requires feature 'services' for variant '$variant']) fi - if JVM_FEATURES_IS_ACTIVE(jvmci) && ! (JVM_FEATURES_IS_ACTIVE(compiler1) || \ - JVM_FEATURES_IS_ACTIVE(compiler2)); then - AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1' for variant '$variant']) - fi - if JVM_FEATURES_IS_ACTIVE(jvmti) && ! JVM_FEATURES_IS_ACTIVE(services); then AC_MSG_ERROR([Specified JVM feature 'jvmti' requires feature 'services' for variant '$variant']) fi @@ -531,9 +504,6 @@ AC_DEFUN([JVM_FEATURES_VERIFY], if ! JVM_FEATURES_IS_ACTIVE(cds); then ENABLE_CDS="false" fi - if ! JVM_FEATURES_IS_ACTIVE(jvmci); then - INCLUDE_JVMCI="false" - fi if JVM_FEATURES_IS_ACTIVE(compiler2); then INCLUDE_COMPILER2="true" fi @@ -559,7 +529,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_SETUP], # and disable them in JVM_FEATURES_VERIFY if a variant is found that are # missing any of them. ENABLE_CDS="true" - INCLUDE_JVMCI="true" INCLUDE_COMPILER2="false" for variant in $JVM_VARIANTS; do @@ -599,7 +568,6 @@ AC_DEFUN_ONCE([JVM_FEATURES_SETUP], AC_SUBST(JVM_FEATURES_zero) AC_SUBST(JVM_FEATURES_custom) - AC_SUBST(INCLUDE_JVMCI) AC_SUBST(INCLUDE_COMPILER2) ]) diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index 15cd5c22d6d..ecfd5dd0a92 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -844,7 +844,6 @@ PNG_CFLAGS := @PNG_CFLAGS@ # Misc INCLUDE_SA := @INCLUDE_SA@ -INCLUDE_JVMCI := @INCLUDE_JVMCI@ INCLUDE_COMPILER2 := @INCLUDE_COMPILER2@ OS_VERSION_MAJOR := @OS_VERSION_MAJOR@ @@ -892,14 +891,6 @@ DOCS_OUTPUTDIR := $(DOCS_JDK_IMAGE_DIR) STATIC_LIBS_IMAGE_SUBDIR := static-libs STATIC_LIBS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_IMAGE_SUBDIR) -# Graal static libs image -STATIC_LIBS_GRAAL_IMAGE_SUBDIR := static-libs-graal -STATIC_LIBS_GRAAL_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(STATIC_LIBS_GRAAL_IMAGE_SUBDIR) - -# Graal builder image -GRAAL_BUILDER_IMAGE_SUBDIR := graal-builder-jdk -GRAAL_BUILDER_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(GRAAL_BUILDER_IMAGE_SUBDIR) - # Macosx bundles directory definitions JDK_MACOSX_BUNDLE_SUBDIR := jdk-bundle JRE_MACOSX_BUNDLE_SUBDIR := jre-bundle @@ -944,7 +935,6 @@ DOCS_JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz DOCS_JAVASE_BUNDLE_NAME := javase-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz DOCS_REFERENCE_BUNDLE_NAME := jdk-reference-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz STATIC_LIBS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-static-libs$(DEBUG_PART).tar.gz -STATIC_LIBS_GRAAL_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-static-libs-graal$(DEBUG_PART).tar.gz STATIC_JDK_BUNDLE_NAME := static-jdk-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION) JCOV_BUNDLE_NAME := jdk-jcov-$(BASE_NAME)_bin$(DEBUG_PART).$(JDK_BUNDLE_EXTENSION) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index 2880504676a..1ec7bef6f98 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -54,13 +54,6 @@ ifeq ($(INCLUDE_SA), false) MODULES_FILTER += jdk.hotspot.agent endif -# Filter out jvmci specific modules if jvmci is disabled -ifeq ($(INCLUDE_JVMCI), false) - MODULES_FILTER += jdk.internal.vm.ci - MODULES_FILTER += jdk.graal.compiler - MODULES_FILTER += jdk.graal.compiler.management -endif - # jpackage is only on windows, macosx, and linux ifeq ($(call isTargetOs, windows macosx linux), false) MODULES_FILTER += jdk.jpackage diff --git a/make/conf/build-module-sets.conf b/make/conf/build-module-sets.conf index 06c879659d1..b7608279553 100644 --- a/make/conf/build-module-sets.conf +++ b/make/conf/build-module-sets.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -45,5 +45,4 @@ LANGTOOLS_MODULES= \ # These models require buildtools-hotspot to process for gensrc HOTSPOT_MODULES= \ jdk.hotspot.agent \ - jdk.internal.vm.ci \ # diff --git a/make/conf/module-loader-map.conf b/make/conf/module-loader-map.conf index 65101af2b8a..35b9345ed8f 100644 --- a/make/conf/module-loader-map.conf +++ b/make/conf/module-loader-map.conf @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,6 @@ BOOT_MODULES= \ java.security.sasl \ java.xml \ jdk.incubator.vector \ - jdk.internal.vm.ci \ jdk.jfr \ jdk.management \ jdk.management.jfr \ @@ -60,8 +59,6 @@ BOOT_MODULES= \ # should carefully be considered if it should be upgradeable or not. UPGRADEABLE_PLATFORM_MODULES= \ java.compiler \ - jdk.graal.compiler \ - jdk.graal.compiler.management \ # PLATFORM_MODULES= \ @@ -107,7 +104,6 @@ NATIVE_ACCESS_MODULES= \ jdk.crypto.mscapi \ jdk.hotspot.agent \ jdk.internal.le \ - jdk.internal.vm.ci \ jdk.jdi \ jdk.jfr \ jdk.jpackage \ diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index e8db4888d3a..66ba18f2775 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -204,7 +204,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ DISABLED_WARNINGS_gcc_jfrChunkWriter.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jfrMemorySizer.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jfrTraceIdKlassQueue.cpp := unused-const-variable, \ - DISABLED_WARNINGS_gcc_jvmciCodeInstaller.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_jvmFlag.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jvmtiTagMap.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_macroAssembler_ppc_sha.cpp := unused-const-variable, \ diff --git a/make/hotspot/lib/JvmFeatures.gmk b/make/hotspot/lib/JvmFeatures.gmk index 90ea8a985e3..9477b0925d2 100644 --- a/make/hotspot/lib/JvmFeatures.gmk +++ b/make/hotspot/lib/JvmFeatures.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -96,12 +96,6 @@ ifneq ($(call check-jvm-feature, jvmti), true) jvmtiAgentList.cpp jfrJvmtiAgent.cpp endif -ifneq ($(call check-jvm-feature, jvmci), true) - JVM_CFLAGS_FEATURES += -DINCLUDE_JVMCI=0 - JVM_EXCLUDES += jvmci - JVM_EXCLUDE_FILES += jvmciCodeInstaller_$(HOTSPOT_TARGET_CPU_ARCH).cpp -endif - ifneq ($(call check-jvm-feature, vm-structs), true) JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0 JVM_EXCLUDE_FILES += vmStructs.cpp diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk index 3eedb64a597..80f3582043c 100644 --- a/make/hotspot/lib/JvmOverrideFiles.gmk +++ b/make/hotspot/lib/JvmOverrideFiles.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -33,8 +33,6 @@ ifeq ($(INCLUDE), true) ifeq ($(TOOLCHAIN_TYPE), gcc) BUILD_LIBJVM_vmStructs.cpp_CXXFLAGS := -fno-var-tracking-assignments - BUILD_LIBJVM_jvmciCompilerToVM.cpp_CXXFLAGS := -fno-var-tracking-assignments - BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_CXXFLAGS := -fno-var-tracking-assignments ifeq ($(DEBUG_LEVEL), release) # Need extra inlining to collapse shared marking code into the hot marking loop BUILD_LIBJVM_shenandoahMark.cpp_CXXFLAGS := --param inline-unit-growth=1000 @@ -104,7 +102,6 @@ else ifeq ($(call isTargetOs, macosx), true) sharedRuntimeTrig.cpp \ sharedRuntimeTrans.cpp \ loopTransform.cpp \ - jvmciCompilerToVM.cpp \ $(OPT_SPEED_SRC) \ # endif @@ -140,13 +137,9 @@ else ifeq ($(call isTargetOs, windows), true) os_windows.cpp \ os_windows_x86.cpp \ osThread_windows.cpp \ - jvmciCompilerToVMInit.cpp \ $(OPT_SPEED_SRC) \ # - # Workaround for jvmciCompilerToVM.cpp long compilation time - BUILD_LIBJVM_jvmciCompilerToVMInit.cpp_OPTIMIZATION := NONE - endif ################################################################################ diff --git a/make/ide/visualstudio/hotspot/CreateVSProject.gmk b/make/ide/visualstudio/hotspot/CreateVSProject.gmk index b2afbe2b9bc..8cf26d9cab8 100644 --- a/make/ide/visualstudio/hotspot/CreateVSProject.gmk +++ b/make/ide/visualstudio/hotspot/CreateVSProject.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -111,7 +111,6 @@ ifeq ($(call isTargetOs, windows), true) -hidePath .hg \ -hidePath .jcheck \ -hidePath jdk.hotspot.agent \ - -hidePath jdk.internal.vm.ci \ -hidePath jdk.jfr \ -compiler VC10 \ -jdkTargetRoot $(call FixPath, $(JDK_OUTPUTDIR)) \ diff --git a/make/modules/jdk.internal.vm.ci/Java.gmk b/make/modules/jdk.internal.vm.ci/Java.gmk deleted file mode 100644 index 75a52a3128d..00000000000 --- a/make/modules/jdk.internal.vm.ci/Java.gmk +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -################################################################################ - -DISABLED_WARNINGS_java += dangling-doc-comments this-escape - -# -parameters provides method's parameters information in class file, -# JVMCI compilers make use of that information for various sanity checks. -# Don't use Indy strings concatenation to have good JVMCI startup performance. - -JAVAC_FLAGS += -parameters -XDstringConcat=inline - -TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK) - -################################################################################ diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.cpp b/src/hotspot/cpu/aarch64/frame_aarch64.cpp index bdbef53bfdb..c3bbc540ed4 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -464,11 +464,11 @@ frame frame::sender_for_interpreter_frame(RegisterMap* map) const { intptr_t* unextended_sp = interpreter_frame_sender_sp(); intptr_t* sender_fp = link(); -#if defined(COMPILER1) || COMPILER2_OR_JVMCI +#if COMPILER1_OR_COMPILER2 if (map->update_map()) { update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset)); } -#endif // defined(COMPILER1) || COMPILER1_OR_COMPILER2 +#endif // COMPILER1_OR_COMPILER2 // For ROP protection, Interpreter will have signed the sender_pc, // but there is no requirement to authenticate it here. diff --git a/src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp index 3d5261c31d1..bb93cd9a9d6 100644 --- a/src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/gc/shared/barrierSetNMethod_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,9 +36,6 @@ #include "utilities/align.hpp" #include "utilities/debug.hpp" #include "utilities/formatBuffer.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciRuntime.hpp" -#endif static int slow_path_size(nmethod* nm) { // The slow path code is out of line with C2 @@ -81,34 +78,21 @@ class NativeNMethodBarrier { public: NativeNMethodBarrier(nmethod* nm): _nm(nm) { -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - address pc = nm->code_begin() + nm->jvmci_nmethod_data()->nmethod_entry_patch_offset(); - RelocIterator iter(nm, pc, pc + 4); - guarantee(iter.next(), "missing relocs"); - guarantee(iter.type() == relocInfo::section_word_type, "unexpected reloc"); - - _guard_addr = (int*) iter.section_word_reloc()->target(); - _instruction_address = pc; - } else -#endif - { - _instruction_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); - if (nm->is_compiled_by_c2()) { - // With c2 compiled code, the guard is out-of-line in a stub - // We find it using the RelocIterator. - RelocIterator iter(nm); - while (iter.next()) { - if (iter.type() == relocInfo::entry_guard_type) { - entry_guard_Relocation* const reloc = iter.entry_guard_reloc(); - _guard_addr = reinterpret_cast(reloc->addr()); - return; - } + _instruction_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); + if (nm->is_compiled_by_c2()) { + // With c2 compiled code, the guard is out-of-line in a stub + // We find it using the RelocIterator. + RelocIterator iter(nm); + while (iter.next()) { + if (iter.type() == relocInfo::entry_guard_type) { + entry_guard_Relocation* const reloc = iter.entry_guard_reloc(); + _guard_addr = reinterpret_cast(reloc->addr()); + return; } - ShouldNotReachHere(); } - _guard_addr = reinterpret_cast(instruction_address() + local_guard_offset(nm)); + ShouldNotReachHere(); } + _guard_addr = reinterpret_cast(instruction_address() + local_guard_offset(nm)); } int get_value() { @@ -225,10 +209,3 @@ int BarrierSetNMethod::guard_value(nmethod* nm) { NativeNMethodBarrier barrier(nm); return barrier.get_value(); } - -#if INCLUDE_JVMCI -bool BarrierSetNMethod::verify_barrier(nmethod* nm, err_msg& msg) { - NativeNMethodBarrier barrier(nm); - return barrier.check_barrier(msg); -} -#endif diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp index dfeba73bede..59c7e44b0e5 100644 --- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -36,7 +36,7 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for im define_pd_global(bool, TrapBasedNullChecks, false); define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls past to check cast -define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); +define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_PRESENT(true) NOT_COMPILER2(false)); define_pd_global(size_t, CodeCacheSegmentSize, 64); define_pd_global(uint, CodeEntryAlignment, 64); diff --git a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp deleted file mode 100644 index 071dd2c4179..00000000000 --- a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "asm/macroAssembler.hpp" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/compressedKlass.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/jniHandles.hpp" -#include "runtime/sharedRuntime.hpp" -#include "vmreg_aarch64.inline.hpp" -#if INCLUDE_ZGC -#include "gc/z/zBarrierSetAssembler.hpp" -#endif - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS) { - if (inst->is_call() || inst->is_jump() || inst->is_blr()) { - return pc_offset + NativeCall::instruction_size; - } else if (inst->is_general_jump()) { - return pc_offset + NativeGeneralJump::instruction_size; - } else if (NativeInstruction::is_adrp_at((address)inst)) { - // adrp; add; blr - return pc_offset + 3 * NativeInstruction::instruction_size; - } else { - JVMCI_ERROR_0("unsupported type of instruction for call site"); - } -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; -#ifdef ASSERT - { - NativeInstruction *insn = nativeInstruction_at(pc); - if (compressed) { - // Mov narrow constant: movz n << 16, movk - assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 && - nativeInstruction_at(pc+4)->is_movk(), "wrong insn in patch"); - } else { - // Move wide constant: movz n, movk, movk. - assert(nativeInstruction_at(pc+4)->is_movk() - && nativeInstruction_at(pc+8)->is_movk(), "wrong insn in patch"); - } - } -#endif // ASSERT - jobject value = JNIHandles::make_local(obj()); - MacroAssembler::patch_oop(pc, cast_from_oop
(obj())); - int oop_index = _oop_recorder->find_index(value); - RelocationHolder rspec = oop_Relocation::spec(oop_index); - _instructions->relocate(pc, rspec); -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - if (tag == PATCH_NARROW_KLASS) { - narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK); - MacroAssembler::patch_narrow_klass(pc, narrowOop); - JVMCI_event_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); - } else { - NativeMovConstReg* move = nativeMovConstReg_at(pc); - void* reference = record_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK); - move->set_data((intptr_t) reference); - JVMCI_event_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); - } -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - NativeInstruction* inst = nativeInstruction_at(pc); - if (inst->is_adr_aligned() || inst->is_ldr_literal() - || (NativeInstruction::maybe_cpool_ref(pc))) { - address dest = _constants->start() + data_offset; - _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS)); - JVMCI_event_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset); - } else { - JVMCI_ERROR("unknown load or move instruction at " PTR_FORMAT, p2i(pc)); - } -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, JVMCI_TRAPS) { - address pc = (address) inst; - if (inst->is_call()) { - NativeCall* call = nativeCall_at(pc); - call->set_destination((address) foreign_call_destination); - _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); - } else if (inst->is_jump()) { - NativeJump* jump = nativeJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); - } else if (inst->is_general_jump()) { - NativeGeneralJump* jump = nativeGeneralJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); - } else if (NativeInstruction::is_adrp_at((address)inst)) { - // adrp; add; blr - MacroAssembler::pd_patch_instruction_size((address)inst, - (address)foreign_call_destination); - } else { - JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)); - } - JVMCI_event_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst)); -} - -void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS) { - NativeCall* call = nullptr; - switch (_next_call_type) { - case INLINE_INVOKE: - return; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: { - assert(!method->is_static(), "cannot call static method with invokeinterface"); - call = nativeCall_at(_instructions->start() + pc_offset); - _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub(), JVMCI_CHECK); - break; - } - case INVOKESTATIC: { - assert(method->is_static(), "cannot call non-static method with invokestatic"); - call = nativeCall_at(_instructions->start() + pc_offset); - _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub(), JVMCI_CHECK); - break; - } - case INVOKESPECIAL: { - assert(!method->is_static(), "cannot call static method with invokespecial"); - call = nativeCall_at(_instructions->start() + pc_offset); - _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); - call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub(), JVMCI_CHECK); - break; - } - default: - JVMCI_ERROR("invalid _next_call_type value"); - break; - } - if (Continuations::enabled()) { - // Check for proper post_call_nop - NativePostCallNop* nop = nativePostCallNop_at(call->next_instruction_address()); - if (nop == nullptr) { - JVMCI_ERROR("missing post call nop at offset %d", pc_offset); - } else { - _instructions->relocate(call->next_instruction_address(), relocInfo::post_call_nop_type); - } - } -} - -bool CodeInstaller::pd_relocate(address pc, jint mark) { - switch (mark) { - case POLL_NEAR: - // This is unhandled and will be reported by the caller - return false; - case POLL_FAR: - _instructions->relocate(pc, relocInfo::poll_type); - return true; - case POLL_RETURN_NEAR: - // This is unhandled and will be reported by the caller - return false; - case POLL_RETURN_FAR: - _instructions->relocate(pc, relocInfo::poll_return_type); - return true; -#if INCLUDE_ZGC - case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_TB_X: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeTbX); - return true; - case Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_BEFORE_MOV: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatMarkBadBeforeMov); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_BEFORE_MOV: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodBeforeMov); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_BEFORE_MOV: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreBadBeforeMov); - return true; -#endif - - } - return false; -} - -// convert JVMCI register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, JVMCI_TRAPS) { - if (jvmci_reg < Register::number_of_registers) { - return as_Register(jvmci_reg)->as_VMReg(); - } else { - jint floatRegisterNumber = jvmci_reg - Register::number_of_declared_registers; - if (floatRegisterNumber >= 0 && floatRegisterNumber < FloatRegister::number_of_registers) { - return as_FloatRegister(floatRegisterNumber)->as_VMReg(); - } - JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg); - } -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return !hotspotRegister->is_FloatRegister(); -} diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 7d920704131..a52ad112560 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -505,21 +505,6 @@ int MacroAssembler::patch_oop(address insn_addr, address o) { return instructions * NativeInstruction::instruction_size; } -int MacroAssembler::patch_narrow_klass(address insn_addr, narrowKlass n) { - // Metadata pointers are either narrow (32 bits) or wide (48 bits). - // We encode narrow ones by setting the upper 16 bits in the first - // instruction. - NativeInstruction *insn = nativeInstruction_at(insn_addr); - assert(Instruction_aarch64::extract(insn->encoding(), 31, 21) == 0b11010010101 && - nativeInstruction_at(insn_addr+4)->is_movk(), "wrong insns in patch"); - - MACOS_AARCH64_ONLY(os::thread_wx_enable_write()); - - Instruction_aarch64::patch(insn_addr, 20, 5, n >> 16); - Instruction_aarch64::patch(insn_addr+4, 20, 5, n & 0xffff); - return 2 * NativeInstruction::instruction_size; -} - void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp) { ldr(tmp, Address(rthread, JavaThread::polling_word_offset())); if (at_return) { diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index a338098cb53..ad8827bd9c0 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -693,7 +693,6 @@ public: #endif static int patch_oop(address insn_addr, address o); - static int patch_narrow_klass(address insn_addr, narrowKlass n); // Return whether code is emitted to a scratch blob. virtual bool in_scratch_emit_size() { diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp index 8b76b96d345..2ddea2fdcb5 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp @@ -37,9 +37,6 @@ #ifdef COMPILER1 #include "c1/c1_Runtime1.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmciEnv.hpp" -#endif void NativeCall::verify() { assert(NativeCall::is_call_at((address)this), "unexpected code at call site"); @@ -363,30 +360,6 @@ void NativeCallTrampolineStub::set_destination(address new_destination) { OrderAccess::release(); } -#if INCLUDE_JVMCI -// Generate a trampoline for a branch to dest. If there's no need for a -// trampoline, simply patch the call directly to dest. -void NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS) { - MacroAssembler a(&cbuf); - - if (!a.far_branches()) { - // If not using far branches, patch this call directly to dest. - set_destination(dest); - } else if (!is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { - // If we want far branches and there isn't a trampoline stub, emit one. - address stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); - if (stub == nullptr) { - JVMCI_ERROR("could not emit trampoline stub - code cache is full"); - } - // The relocation created while emitting the stub will ensure this - // call instruction is subsequently patched to call the stub. - } else { - // Not sure how this can be happen but be defensive - JVMCI_ERROR("single-use stub should not exist"); - } -} -#endif - void NativePostCallNop::make_deopt() { NativeDeoptInstruction::insert(addr_at(0)); } diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp index ab9896fa426..4bccbc59582 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp @@ -30,9 +30,6 @@ #include "runtime/icache.hpp" #include "runtime/os.hpp" #include "runtime/os.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciExceptions.hpp" -#endif // We have interfaces for the following instructions: @@ -215,9 +212,6 @@ public: void set_destination_mt_safe(address dest); address get_trampoline(); -#if INCLUDE_JVMCI - void trampoline_jump(CodeBuffer &cbuf, address dest, JVMCI_TRAPS); -#endif }; inline NativeCall* nativeCall_at(address address) { diff --git a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp index 73b631029a0..0e3d9d76b94 100644 --- a/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp @@ -61,9 +61,6 @@ #include "adfiles/ad_aarch64.hpp" #include "opto/runtime.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmciJavaClasses.hpp" -#endif #define __ masm-> @@ -120,17 +117,14 @@ int RegisterSaver::reg_offset_in_bytes(Register r) { int slots_per_vect = FloatRegister::save_slots_per_register; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (_save_vectors) { slots_per_vect = FloatRegister::slots_per_neon_register; - -#ifdef COMPILER2 if (Matcher::supports_scalable_vector()) { slots_per_vect = Matcher::scalable_vector_reg_size(T_FLOAT); } -#endif } -#endif +#endif // COMPILER2 int r0_offset = v0_offset_in_bytes() + (slots_per_vect * FloatRegister::number_of_registers) * BytesPerInt; return r0_offset + r->encoding() * wordSize; @@ -170,7 +164,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ } #endif -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (_save_vectors) { int extra_save_slots_per_register = 0; // Save upper half of vector registers @@ -185,8 +179,8 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ additional_frame_words += ((extra_vector_bytes + total_predicate_in_bytes) / wordSize); } #else - assert(!_save_vectors, "vectors are generated only by C2 and JVMCI"); -#endif + assert(!_save_vectors, "vectors are generated only by C2"); +#endif // COMPILER2 int frame_size_in_bytes = align_up(additional_frame_words * wordSize + reg_save_size * BytesPerInt, 16); @@ -241,9 +235,7 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm) { __ pop_CPU_state(_save_vectors, Matcher::supports_scalable_vector(), Matcher::scalable_vector_reg_size(T_BYTE), total_sve_predicate_in_bytes()); #else -#if !INCLUDE_JVMCI - assert(!_save_vectors, "vectors are generated only by C2 and JVMCI"); -#endif + assert(!_save_vectors, "vectors are generated only by C2"); __ pop_CPU_state(_save_vectors); #endif __ ldp(rfp, lr, Address(__ post(sp, 2 * wordSize))); @@ -569,18 +561,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm, // Pre-load the register-jump target early, to schedule it better. __ ldr(rscratch1, Address(rmethod, in_bytes(Method::from_compiled_offset()))); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - // check if this call should be routed towards a specific entry point - __ ldr(rscratch2, Address(rthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); - Label no_alternative_target; - __ cbz(rscratch2, no_alternative_target); - __ mov(rscratch1, rscratch2); - __ str(zr, Address(rthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); - __ bind(no_alternative_target); - } -#endif // INCLUDE_JVMCI - // Now generate the shuffle code. for (int i = 0; i < total_args_passed; i++) { if (sig_bt[i] == T_VOID) { @@ -2076,11 +2056,6 @@ void SharedRuntime::generate_deopt_blob() { ResourceMark rm; // Setup code generation tools int pad = 0; -#if INCLUDE_JVMCI - if (EnableJVMCI) { - pad += 512; // Increase the buffer size when compiling for JVMCI - } -#endif const char* name = SharedRuntime::stub_name(StubId::shared_deopt_id); CodeBlob* blob = AOTCodeCache::load_code_blob(AOTCodeEntry::SharedBlob, BlobId::shared_deopt_id); if (blob != nullptr) { @@ -2093,7 +2068,7 @@ void SharedRuntime::generate_deopt_blob() { int frame_size_in_words; OopMap* map = nullptr; OopMapSet *oop_maps = new OopMapSet(); - RegisterSaver reg_save(COMPILER2_OR_JVMCI != 0); + RegisterSaver reg_save(COMPILER2_PRESENT(true) NOT_COMPILER2(false)); // ------------- // This code enters when returning to a de-optimized nmethod. A return @@ -2138,13 +2113,6 @@ void SharedRuntime::generate_deopt_blob() { __ b(cont); int reexecute_offset = __ pc() - start; -#if INCLUDE_JVMCI && !defined(COMPILER1) - if (UseJVMCICompiler) { - // JVMCI does not use this kind of deoptimization - __ should_not_reach_here(); - } -#endif - // Reexecute case // return address is the pc describes what bci to do re-execute at @@ -2154,45 +2122,6 @@ void SharedRuntime::generate_deopt_blob() { __ movw(rcpool, Deoptimization::Unpack_reexecute); // callee-saved __ b(cont); -#if INCLUDE_JVMCI - Label after_fetch_unroll_info_call; - int implicit_exception_uncommon_trap_offset = 0; - int uncommon_trap_offset = 0; - - if (EnableJVMCI) { - implicit_exception_uncommon_trap_offset = __ pc() - start; - - __ ldr(lr, Address(rthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); - __ str(zr, Address(rthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); - - uncommon_trap_offset = __ pc() - start; - - // Save everything in sight. - reg_save.save_live_registers(masm, 0, &frame_size_in_words); - // fetch_unroll_info needs to call last_java_frame() - Label retaddr; - __ set_last_Java_frame(sp, noreg, retaddr, rscratch1); - - __ ldrw(c_rarg1, Address(rthread, in_bytes(JavaThread::pending_deoptimization_offset()))); - __ movw(rscratch1, -1); - __ strw(rscratch1, Address(rthread, in_bytes(JavaThread::pending_deoptimization_offset()))); - - __ movw(rcpool, (int32_t)Deoptimization::Unpack_reexecute); - __ mov(c_rarg0, rthread); - __ movw(c_rarg2, rcpool); // exec mode - __ lea(rscratch1, - RuntimeAddress(CAST_FROM_FN_PTR(address, - Deoptimization::uncommon_trap))); - __ blr(rscratch1); - __ bind(retaddr); - oop_maps->add_gc_map( __ pc()-start, map->deep_copy()); - - __ reset_last_Java_frame(false); - - __ b(after_fetch_unroll_info_call); - } // EnableJVMCI -#endif // INCLUDE_JVMCI - int exception_offset = __ pc() - start; // Prolog for exception case @@ -2283,12 +2212,6 @@ void SharedRuntime::generate_deopt_blob() { __ reset_last_Java_frame(false); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - __ bind(after_fetch_unroll_info_call); - } -#endif - // Load UnrollBlock* into r5 __ mov(r5, r0); @@ -2445,12 +2368,6 @@ void SharedRuntime::generate_deopt_blob() { _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); - _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); - } -#endif AOTCodeCache::store_code_blob(*_deopt_blob, AOTCodeEntry::SharedBlob, BlobId::shared_deopt_id); } diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index fddb37b7b8d..46849b329cb 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2025, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -12636,7 +12636,7 @@ class StubGenerator: public StubCodeGenerator { } void generate_compiler_stubs() { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (UseSVE == 0) { generate_iota_indices(StubId::stubgen_vector_iota_indices_id); @@ -12664,7 +12664,6 @@ class StubGenerator: public StubCodeGenerator { generate_string_indexof_stubs(); -#ifdef COMPILER2 if (UseMultiplyToLenIntrinsic) { StubRoutines::_multiplyToLen = generate_multiplyToLen(); } @@ -12712,8 +12711,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_montgomerySquare = start; } -#endif // COMPILER2 - if (UseChaCha20Intrinsics) { StubRoutines::_chacha20Block = generate_chacha20Block_blockpar(); } @@ -12795,7 +12792,7 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32(); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } public: diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp index 6067408ef13..97bdf5055c4 100644 --- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -48,9 +48,6 @@ enum platform_dependent_constants { class aarch64 { friend class StubGenerator; friend class StubRoutines; -#if INCLUDE_JVMCI - friend class JVMCIVMStructs; -#endif // declare fields for arch-specific entries diff --git a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp index dd70c98797f..fd6247bf362 100644 --- a/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -524,30 +524,6 @@ address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, // null last_sp until next java call __ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize)); -#if INCLUDE_JVMCI - // Check if we need to take lock at entry of synchronized method. This can - // only occur on method entry so emit it only for vtos with step 0. - if (EnableJVMCI && state == vtos && step == 0) { - Label L; - __ ldrb(rscratch1, Address(rthread, JavaThread::pending_monitorenter_offset())); - __ cbz(rscratch1, L); - // Clear flag. - __ strb(zr, Address(rthread, JavaThread::pending_monitorenter_offset())); - // Take lock. - lock_method(); - __ bind(L); - } else { -#ifdef ASSERT - if (EnableJVMCI) { - Label L; - __ ldrb(rscratch1, Address(rthread, JavaThread::pending_monitorenter_offset())); - __ cbz(rscratch1, L); - __ stop("unexpected pending monitor in deopt entry"); - __ bind(L); - } -#endif - } -#endif // handle exceptions { Label L; diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index 4c64b265d92..b6cf58d6062 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -2622,7 +2622,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr // membar it's possible for a simple Dekker test to fail if loads // use LDR;DMB but stores use STLR. This can happen if C2 compiles // the stores in one method and we interpret the loads in another. - if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()){ + if (!CompilerConfig::is_c1_or_interpreter_only()){ Label notVolatile; __ tbz(flags, ResolvedFieldEntry::is_volatile_shift, notVolatile); __ membar(MacroAssembler::AnyAny); @@ -3200,7 +3200,7 @@ void TemplateTable::fast_accessfield(TosState state) // membar it's possible for a simple Dekker test to fail if loads // use LDR;DMB but stores use STLR. This can happen if C2 compiles // the stores in one method and we interpret the loads in another. - if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()) { + if (!CompilerConfig::is_c1_or_interpreter_only()) { Label notVolatile; __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); __ membar(MacroAssembler::AnyAny); @@ -3263,7 +3263,7 @@ void TemplateTable::fast_xaccess(TosState state) // membar it's possible for a simple Dekker test to fail if loads // use LDR;DMB but stores use STLR. This can happen if C2 compiles // the stores in one method and we interpret the loads in another. - if (!CompilerConfig::is_c1_or_interpreter_only_no_jvmci()) { + if (!CompilerConfig::is_c1_or_interpreter_only()) { Label notVolatile; __ load_unsigned_byte(r3, Address(r2, in_bytes(ResolvedFieldEntry::flags_offset()))); __ tbz(r3, ResolvedFieldEntry::is_volatile_shift, notVolatile); diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp index c67455e6b79..1096a1b0fc6 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.hpp @@ -38,7 +38,6 @@ class stringStream; class VM_Version : public Abstract_VM_Version { friend class VMStructs; - friend class JVMCIVMStructs; protected: static int _cpu; diff --git a/src/hotspot/cpu/arm/compiledIC_arm.cpp b/src/hotspot/cpu/arm/compiledIC_arm.cpp index 86927cd24ab..eb035e54faa 100644 --- a/src/hotspot/cpu/arm/compiledIC_arm.cpp +++ b/src/hotspot/cpu/arm/compiledIC_arm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ #include "runtime/safepoint.hpp" // ---------------------------------------------------------------------------- -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 #define __ masm-> // emit call stub, compiled java to interpreter address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address mark) { @@ -86,7 +86,7 @@ address CompiledDirectCall::emit_to_interp_stub(MacroAssembler *masm, address ma int CompiledDirectCall::reloc_to_interp_stub() { return 10; // 4 in emit_to_interp_stub + 1 in Java_Static_Call } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 int CompiledDirectCall::to_trampoline_stub_size() { // ARM doesn't use trampolines. diff --git a/src/hotspot/cpu/arm/jvmciCodeInstaller_arm.cpp b/src/hotspot/cpu/arm/jvmciCodeInstaller_arm.cpp deleted file mode 100644 index 5b480afb1fe..00000000000 --- a/src/hotspot/cpu/arm/jvmciCodeInstaller_arm.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/sharedRuntime.hpp" -#include "vmreg_arm.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) { - Unimplemented(); - return 0; -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle hotspot_method, jint pc_offset, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) { - Unimplemented(); -} - -// convert JVMCI register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) { - return nullptr; -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return false; -} diff --git a/src/hotspot/cpu/arm/vm_version_arm.hpp b/src/hotspot/cpu/arm/vm_version_arm.hpp index 11c89da2005..c400cad24b4 100644 --- a/src/hotspot/cpu/arm/vm_version_arm.hpp +++ b/src/hotspot/cpu/arm/vm_version_arm.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,8 +29,6 @@ #include "runtime/globals_extension.hpp" class VM_Version: public Abstract_VM_Version { - friend class JVMCIVMStructs; - static bool _has_simd; static bool _has_mp_ext; diff --git a/src/hotspot/cpu/ppc/globals_ppc.hpp b/src/hotspot/cpu/ppc/globals_ppc.hpp index d46bb733ea7..aba3a99b0d8 100644 --- a/src/hotspot/cpu/ppc/globals_ppc.hpp +++ b/src/hotspot/cpu/ppc/globals_ppc.hpp @@ -36,7 +36,7 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for impli define_pd_global(bool, TrapBasedNullChecks, true); define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls passed to check cast. -define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); +define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_PRESENT(true) NOT_COMPILER2(false)); #define DEFAULT_STACK_YELLOW_PAGES (2) #define DEFAULT_STACK_RED_PAGES (1) diff --git a/src/hotspot/cpu/ppc/jvmciCodeInstaller_ppc.cpp b/src/hotspot/cpu/ppc/jvmciCodeInstaller_ppc.cpp deleted file mode 100644 index 923a5fd9da9..00000000000 --- a/src/hotspot/cpu/ppc/jvmciCodeInstaller_ppc.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/sharedRuntime.hpp" -#include "vmreg_ppc.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, Handle method, TRAPS) { - Unimplemented(); - return 0; -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_poll(address pc, jint mark, TRAPS) { - Unimplemented(); -} - -// convert JVMCI register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, TRAPS) { - return nullptr; -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return false; -} diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index f528587a8bb..4d3b99afa1c 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2025 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -5038,9 +5038,8 @@ void generate_lookup_secondary_supers_table_stub() { } void generate_compiler_stubs() { -#if COMPILER2_OR_JVMCI - #ifdef COMPILER2 + if (UseMultiplyToLenIntrinsic) { StubRoutines::_multiplyToLen = generate_multiplyToLen(); } @@ -5058,7 +5057,6 @@ void generate_lookup_secondary_supers_table_stub() { StubRoutines::_montgomerySquare = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square); } -#endif // data cache line writeback if (VM_Version::supports_data_cache_line_flush()) { @@ -5091,7 +5089,7 @@ void generate_lookup_secondary_supers_table_stub() { StubRoutines::_base64_encodeBlock = generate_base64_encodeBlock(); } #endif -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } public: diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp index 9b318dbe579..ff15a0c6937 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp @@ -35,9 +35,6 @@ #include "runtime/sharedRuntime.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciRuntime.hpp" -#endif static int slow_path_size(nmethod* nm) { // The slow path code is out of line with C2. @@ -74,38 +71,26 @@ class NativeNMethodBarrier { public: NativeNMethodBarrier(nmethod* nm): _nm(nm) { -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - address pc = nm->code_begin() + nm->jvmci_nmethod_data()->nmethod_entry_patch_offset(); - RelocIterator iter(nm, pc, pc + 4); - guarantee(iter.next(), "missing relocs"); - guarantee(iter.type() == relocInfo::section_word_type, "unexpected reloc"); - - _guard_addr = (int*) iter.section_word_reloc()->target(); - _instruction_address = pc; - } else -#endif - { - _instruction_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); - if (nm->is_compiled_by_c2()) { - // With c2 compiled code, the guard is out-of-line in a stub - // We find it using the RelocIterator. - RelocIterator iter(nm); - while (iter.next()) { - if (iter.type() == relocInfo::entry_guard_type) { - entry_guard_Relocation* const reloc = iter.entry_guard_reloc(); - _guard_addr = reinterpret_cast(reloc->addr()); - return; - } - } - ShouldNotReachHere(); + _instruction_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); + if (nm->is_compiled_by_c2()) { + // With c2 compiled code, the guard is out-of-line in a stub + // We find it using the RelocIterator. + RelocIterator iter(nm); + while (iter.next()) { + if (iter.type() == relocInfo::entry_guard_type) { + entry_guard_Relocation* const reloc = iter.entry_guard_reloc(); + _guard_addr = reinterpret_cast(reloc->addr()); + return; } - _guard_addr = reinterpret_cast(instruction_address() + local_guard_offset(nm)); } - // Perform the checking as verification. - err_msg msg("%s", ""); - assert(check_barrier(msg), "%s", msg.buffer()); + ShouldNotReachHere(); + } + _guard_addr = reinterpret_cast(instruction_address() + local_guard_offset(nm)); + + // Perform the checking as verification. + err_msg msg("%s", ""); + assert(check_barrier(msg), "%s", msg.buffer()); } int get_value() { @@ -234,10 +219,3 @@ int BarrierSetNMethod::guard_value(nmethod* nm) { NativeNMethodBarrier barrier(nm); return barrier.get_value(); } - -#if INCLUDE_JVMCI -bool BarrierSetNMethod::verify_barrier(nmethod* nm, err_msg& msg) { - NativeNMethodBarrier barrier(nm); - return barrier.check_barrier(msg); -} -#endif diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index 21b119266e2..18ca120bdfa 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -36,7 +36,7 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for im define_pd_global(bool, TrapBasedNullChecks, false); define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls past to check cast -define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); +define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_PRESENT(true) NOT_COMPILER2(false)); define_pd_global(size_t, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment. define_pd_global(uint, CodeEntryAlignment, 64); diff --git a/src/hotspot/cpu/riscv/jvmciCodeInstaller_riscv.cpp b/src/hotspot/cpu/riscv/jvmciCodeInstaller_riscv.cpp deleted file mode 100644 index cbe387eed14..00000000000 --- a/src/hotspot/cpu/riscv/jvmciCodeInstaller_riscv.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "asm/macroAssembler.hpp" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/compressedKlass.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/jniHandles.hpp" -#include "runtime/sharedRuntime.hpp" -#include "vmreg_riscv.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS) { - address pc = (address) inst; - if (inst->is_call()) { - return pc_offset + NativeCall::byte_size(); - } else if (inst->is_jump()) { - return pc_offset + NativeJump::instruction_size; - } else if (inst->is_movptr1()) { - return pc_offset + NativeMovConstReg::movptr1_instruction_size; - } else if (inst->is_movptr2()) { - return pc_offset + NativeMovConstReg::movptr2_instruction_size; - } else { - JVMCI_ERROR_0("unsupported type of instruction for call site"); - } -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - jobject value = JNIHandles::make_local(obj()); - MacroAssembler::patch_oop(pc, cast_from_oop
(obj())); - int oop_index = _oop_recorder->find_index(value); - RelocationHolder rspec = oop_Relocation::spec(oop_index); - _instructions->relocate(pc, rspec); -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - if (tag == PATCH_NARROW_KLASS) { - narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK); - MacroAssembler::pd_patch_instruction_size(pc, (address) (long) narrowOop); - JVMCI_event_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); - } else { - NativeMovConstReg* move = nativeMovConstReg_at(pc); - void* reference = record_metadata_reference(_instructions, pc, stream, tag, JVMCI_CHECK); - move->set_data((intptr_t) reference); - JVMCI_event_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); - } -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - address dest = _constants->start() + data_offset; - _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS)); - JVMCI_event_3("relocating at " PTR_FORMAT " (+%d) with destination at %d", p2i(pc), pc_offset, data_offset); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, JVMCI_TRAPS) { - address pc = (address) inst; - if (inst->is_jal()) { - NativeCall* call = nativeCall_at(pc); - call->set_destination((address) foreign_call_destination); - _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); - } else if (inst->is_jump()) { - NativeJump* jump = nativeJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); - } else if (inst->is_movptr()) { - NativeMovConstReg* movptr = nativeMovConstReg_at(pc); - movptr->set_data((intptr_t) foreign_call_destination); - _instructions->relocate(movptr->instruction_address(), runtime_call_Relocation::spec()); - } else { - JVMCI_ERROR("unknown call or jump instruction at " PTR_FORMAT, p2i(pc)); - } - JVMCI_event_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst)); -} - -void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS) { - Unimplemented(); -} - -bool CodeInstaller::pd_relocate(address pc, jint mark) { - Unimplemented(); - return false; -} - -// convert JVMCI register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, JVMCI_TRAPS) { - if (jvmci_reg < Register::number_of_registers) { - return as_Register(jvmci_reg)->as_VMReg(); - } else { - jint floatRegisterNumber = jvmci_reg - Register::number_of_registers; - if (floatRegisterNumber >= 0 && floatRegisterNumber < FloatRegister::number_of_registers) { - return as_FloatRegister(floatRegisterNumber)->as_VMReg(); - } - JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg); - } -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return !(hotspotRegister->is_FloatRegister() || hotspotRegister->is_VectorRegister()); -} diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index 8c343f6ab2b..9ad6663d0fa 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -59,9 +59,6 @@ #include "adfiles/ad_riscv.hpp" #include "opto/runtime.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmciJavaClasses.hpp" -#endif #define __ masm-> @@ -202,11 +199,9 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm) { #ifdef COMPILER2 __ pop_CPU_state(_save_vectors, Matcher::scalable_vector_reg_size(T_BYTE)); #else -#if !INCLUDE_JVMCI - assert(!_save_vectors, "vectors are generated only by C2 and JVMCI"); -#endif + assert(!_save_vectors, "vectors are generated only by C2"); __ pop_CPU_state(_save_vectors); -#endif +#endif // COMPILER2 __ leave(); } @@ -492,18 +487,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm, // Pre-load the register-jump target early, to schedule it better. __ ld(t1, Address(xmethod, in_bytes(Method::from_compiled_offset()))); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - // check if this call should be routed towards a specific entry point - __ ld(t0, Address(xthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); - Label no_alternative_target; - __ beqz(t0, no_alternative_target); - __ mv(t1, t0); - __ sd(zr, Address(xthread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); - __ bind(no_alternative_target); - } -#endif // INCLUDE_JVMCI - // Now generate the shuffle code. for (int i = 0; i < total_args_passed; i++) { if (sig_bt[i] == T_VOID) { @@ -1995,11 +1978,6 @@ void SharedRuntime::generate_deopt_blob() { ResourceMark rm; // Setup code generation tools int pad = 0; -#if INCLUDE_JVMCI - if (EnableJVMCI) { - pad += 512; // Increase the buffer size when compiling for JVMCI - } -#endif const char* name = SharedRuntime::stub_name(StubId::shared_deopt_id); CodeBuffer buffer(name, 2048 + pad, 1024); MacroAssembler* masm = new MacroAssembler(&buffer); @@ -2007,7 +1985,7 @@ void SharedRuntime::generate_deopt_blob() { OopMap* map = nullptr; OopMapSet *oop_maps = new OopMapSet(); assert_cond(masm != nullptr && oop_maps != nullptr); - RegisterSaver reg_saver(COMPILER2_OR_JVMCI != 0); + RegisterSaver reg_saver(COMPILER2_PRESENT(true) NOT_COMPILER2(false)); // ------------- // This code enters when returning to a de-optimized nmethod. A return @@ -2052,13 +2030,6 @@ void SharedRuntime::generate_deopt_blob() { __ j(cont); int reexecute_offset = __ pc() - start; -#if INCLUDE_JVMCI && !defined(COMPILER1) - if (UseJVMCICompiler) { - // JVMCI does not use this kind of deoptimization - __ should_not_reach_here(); - } -#endif - // Reexecute case // return address is the pc describes what bci to do re-execute at @@ -2068,42 +2039,6 @@ void SharedRuntime::generate_deopt_blob() { __ mv(xcpool, Deoptimization::Unpack_reexecute); // callee-saved __ j(cont); -#if INCLUDE_JVMCI - Label after_fetch_unroll_info_call; - int implicit_exception_uncommon_trap_offset = 0; - int uncommon_trap_offset = 0; - - if (EnableJVMCI) { - implicit_exception_uncommon_trap_offset = __ pc() - start; - - __ ld(ra, Address(xthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); - __ sd(zr, Address(xthread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); - - uncommon_trap_offset = __ pc() - start; - - // Save everything in sight. - reg_saver.save_live_registers(masm, 0, &frame_size_in_words); - // fetch_unroll_info needs to call last_java_frame() - Label retaddr; - __ set_last_Java_frame(sp, noreg, retaddr, t0); - - __ lw(c_rarg1, Address(xthread, in_bytes(JavaThread::pending_deoptimization_offset()))); - __ mv(t0, -1); - __ sw(t0, Address(xthread, in_bytes(JavaThread::pending_deoptimization_offset()))); - - __ mv(xcpool, Deoptimization::Unpack_reexecute); - __ mv(c_rarg0, xthread); - __ orrw(c_rarg2, zr, xcpool); // exec mode - __ rt_call(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap)); - __ bind(retaddr); - oop_maps->add_gc_map( __ pc()-start, map->deep_copy()); - - __ reset_last_Java_frame(false); - - __ j(after_fetch_unroll_info_call); - } // EnableJVMCI -#endif // INCLUDE_JVMCI - int exception_offset = __ pc() - start; // Prolog for exception case @@ -2195,12 +2130,6 @@ void SharedRuntime::generate_deopt_blob() { __ reset_last_Java_frame(false); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - __ bind(after_fetch_unroll_info_call); - } -#endif - // Load UnrollBlock* into x15 __ mv(x15, x10); @@ -2354,12 +2283,6 @@ void SharedRuntime::generate_deopt_blob() { _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); assert(_deopt_blob != nullptr, "create deoptimization blob fail!"); _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); - _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); - } -#endif } // Number of stack slots between incoming argument block and the start of diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 4656b5c0d41..13f3ed4de89 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -4754,7 +4754,7 @@ class StubGenerator: public StubCodeGenerator { return start; } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 #undef __ #define __ this-> @@ -6782,7 +6782,7 @@ class StubGenerator: public StubCodeGenerator { return start; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // x10 = input (float16) // f10 = result (float) diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp index ec67a338052..b230c2657de 100644 --- a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp +++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,9 +49,6 @@ enum platform_dependent_constants { class riscv { friend class StubGenerator; friend class StubRoutines; -#if INCLUDE_JVMCI - friend class JVMCIVMStructs; -#endif // declare fields for arch-specific entries diff --git a/src/hotspot/cpu/s390/globals_s390.hpp b/src/hotspot/cpu/s390/globals_s390.hpp index d110443adf8..80ed6d1acc8 100644 --- a/src/hotspot/cpu/s390/globals_s390.hpp +++ b/src/hotspot/cpu/s390/globals_s390.hpp @@ -36,7 +36,7 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code fo define_pd_global(bool, TrapBasedNullChecks, true); define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls passed to check cast. -define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); +define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_PRESENT(true) NOT_COMPILER2(false)); define_pd_global(size_t, CodeCacheSegmentSize, 256); // This shall be at least 32 for proper branch target alignment. diff --git a/src/hotspot/cpu/s390/jvmciCodeInstaller_s390.cpp b/src/hotspot/cpu/s390/jvmciCodeInstaller_s390.cpp deleted file mode 100644 index 4318703ad38..00000000000 --- a/src/hotspot/cpu/s390/jvmciCodeInstaller_s390.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2016 SAP SE. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -// JVMCI (JEP 243): -// So far, the JVMCI is not supported/implemented on SAP platforms. -// This file just serves as a placeholder which may be filled with life -// should the JVMCI ever be implemented. -#if INCLUDE_JVMCI - -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/sharedRuntime.hpp" -#include "vmreg_s390.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { - Unimplemented(); - return 0; -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle& constant) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { - Unimplemented(); -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { - Unimplemented(); -} - -void CodeInstaller::pd_relocate_poll(address pc, jint mark) { - Unimplemented(); -} - -// Convert JVMCI register indices (as used in oop maps) to HotSpot registers. -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) { - return nullptr; -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return false; -} - -#endif // INLCUDE_JVMCI diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index 3f16312eb48..5309158fc74 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2024 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -3361,7 +3361,7 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::zarch::_partial_subtype_check = generate_partial_subtype_check(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Generate AES intrinsics code. if (UseAESIntrinsics) { if (VM_Version::has_Crypto_AES()) { @@ -3405,7 +3405,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_sha512_implCompressMB = generate_SHA512_stub(StubId::stubgen_sha512_implCompressMB_id); } -#ifdef COMPILER2 if (UseMultiplyToLenIntrinsic) { StubRoutines::_multiplyToLen = generate_multiplyToLen(); } @@ -3417,8 +3416,7 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_montgomerySquare = CAST_FROM_FN_PTR(address, SharedRuntime::montgomery_square); } -#endif -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } public: diff --git a/src/hotspot/cpu/x86/frame_x86.cpp b/src/hotspot/cpu/x86/frame_x86.cpp index 1ff28516307..27741ee3bb1 100644 --- a/src/hotspot/cpu/x86/frame_x86.cpp +++ b/src/hotspot/cpu/x86/frame_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -453,11 +453,11 @@ frame frame::sender_for_interpreter_frame(RegisterMap* map) const { intptr_t* unextended_sp = interpreter_frame_sender_sp(); intptr_t* sender_fp = link(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (map->update_map()) { update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset)); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 address sender_pc = this->sender_pc(); diff --git a/src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp b/src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp index 40311f746ea..7ebc90b9f71 100644 --- a/src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp +++ b/src/hotspot/cpu/x86/gc/shared/barrierSetNMethod_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,6 @@ #include "utilities/debug.hpp" #include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciRuntime.hpp" -#endif class NativeNMethodCmpBarrier: public NativeInstruction { public: @@ -167,16 +164,7 @@ static int entry_barrier_offset(nmethod* nm) { } static NativeNMethodCmpBarrier* native_nmethod_barrier(nmethod* nm) { - address barrier_address; -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - barrier_address = nm->code_begin() + nm->jvmci_nmethod_data()->nmethod_entry_patch_offset(); - } else -#endif - { - barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); - } - + address barrier_address = nm->code_begin() + nm->frame_complete_offset() + entry_barrier_offset(nm); NativeNMethodCmpBarrier* barrier = reinterpret_cast(barrier_address); barrier->verify(); return barrier; @@ -199,11 +187,3 @@ int BarrierSetNMethod::guard_value(nmethod* nm) { NativeNMethodCmpBarrier* cmp = native_nmethod_barrier(nm); return cmp->get_immediate(); } - - -#if INCLUDE_JVMCI -bool BarrierSetNMethod::verify_barrier(nmethod* nm, err_msg& msg) { - NativeNMethodCmpBarrier* barrier = native_nmethod_barrier(nm); - return barrier->check_barrier(msg); -} -#endif diff --git a/src/hotspot/cpu/x86/globals_x86.hpp b/src/hotspot/cpu/x86/globals_x86.hpp index c00cfba698f..936a994ed8b 100644 --- a/src/hotspot/cpu/x86/globals_x86.hpp +++ b/src/hotspot/cpu/x86/globals_x86.hpp @@ -35,7 +35,7 @@ define_pd_global(bool, ImplicitNullChecks, true); // Generate code for im define_pd_global(bool, TrapBasedNullChecks, false); // Not needed on x86. define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls passed to check cast -define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); +define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_PRESENT(true) NOT_COMPILER2(false)); define_pd_global(size_t, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment. // See 4827828 for this change. There is no globals_core_i486.hpp. I can't @@ -45,11 +45,11 @@ define_pd_global(size_t, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRES // the vep is aligned at CodeEntryAlignment whereas c2 only aligns // the uep and the vep doesn't get real alignment but just slops on by // only assured that the entry instruction meets the 5 byte size requirement. -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 define_pd_global(uint, CodeEntryAlignment, 32); #else define_pd_global(uint, CodeEntryAlignment, 16); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 define_pd_global(intx, OptoLoopAlignment, 16); define_pd_global(intx, InlineSmallCode, 1000); diff --git a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp deleted file mode 100644 index b9a66907e3b..00000000000 --- a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "compiler/disassembler.hpp" -#include "oops/compressedKlass.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/handles.inline.hpp" -#include "runtime/javaCalls.hpp" -#include "runtime/jniHandles.hpp" -#include "runtime/sharedRuntime.hpp" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "asm/register.hpp" -#include "classfile/vmSymbols.hpp" -#include "code/vmreg.hpp" -#include "vmreg_x86.inline.hpp" -#if INCLUDE_ZGC -#include "gc/z/zBarrierSetAssembler.hpp" -#endif - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS) { - if (inst->is_call() || inst->is_jump()) { - assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size"); - return (pc_offset + NativeCall::instruction_size); - } else if (inst->is_mov_literal64()) { - // mov+call instruction pair - jint offset = pc_offset + ((NativeMovConstReg*)inst)->instruction_size(); - u_char* call = (u_char*) (_instructions->start() + offset); - if (call[0] == Assembler::REX_B) { - offset += 1; /* prefix byte for extended register R8-R15 */ - call++; - } - if (call[0] == Assembler::REX2) { - offset += 2; /* prefix byte for APX extended GPR register R16-R31 */ - call+=2; - } - // Register indirect call. - assert(call[0] == 0xFF, "expected call"); - offset += 2; /* opcode byte + modrm byte */ - return (offset); - } else if (inst->is_call_reg()) { - // the inlined vtable stub contains a "call register" instruction - return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset()); - } else if (inst->is_cond_jump()) { - address pc = (address) (inst); - return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc); - } else { - JVMCI_ERROR_0("unsupported type of instruction for call site"); - } -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - jobject value = JNIHandles::make_local(obj()); - if (compressed) { - address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); - int oop_index = _oop_recorder->find_index(value); - _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); - JVMCI_event_3("relocating (narrow oop constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); - } else { - address operand = Assembler::locate_operand(pc, Assembler::imm_operand); - *((jobject*) operand) = value; - _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); - JVMCI_event_3("relocating (oop constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); - } -} - -void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - if (tag == PATCH_NARROW_KLASS) { - address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); - *((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, stream, tag, JVMCI_CHECK); - JVMCI_event_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); - } else { - address operand = Assembler::locate_operand(pc, Assembler::imm_operand); - *((void**) operand) = record_metadata_reference(_instructions, operand, stream, tag, JVMCI_CHECK); - JVMCI_event_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); - } -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset, JVMCI_TRAPS) { - address pc = _instructions->start() + pc_offset; - - address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); - address next_instruction = Assembler::locate_next_instruction(pc); - address dest = _constants->start() + data_offset; - - long disp = dest - next_instruction; - assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); - *((jint*) operand) = (jint) disp; - - _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); - JVMCI_event_3("relocating at " PTR_FORMAT "/" PTR_FORMAT " with destination at " PTR_FORMAT " (%d)", p2i(pc), p2i(operand), p2i(dest), data_offset); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, JVMCI_TRAPS) { - address pc = (address) inst; - if (inst->is_call()) { - // NOTE: for call without a mov, the offset must fit a 32-bit immediate - // see also CompilerToVM.getMaxCallTargetOffset() - NativeCall* call = nativeCall_at(pc); - call->set_destination((address) foreign_call_destination); - _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); - } else if (inst->is_mov_literal64()) { - NativeMovConstReg* mov = nativeMovConstReg_at(pc); - mov->set_data((intptr_t) foreign_call_destination); - _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand); - } else if (inst->is_jump()) { - NativeJump* jump = nativeJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); - } else if (inst->is_cond_jump()) { - address old_dest = nativeGeneralJump_at(pc)->jump_destination(); - address disp = Assembler::locate_operand(pc, Assembler::call32_operand); - *(jint*) disp += ((address) foreign_call_destination) - old_dest; - _instructions->relocate(pc, runtime_call_Relocation::spec(), Assembler::call32_operand); - } else { - JVMCI_ERROR("unsupported relocation for foreign call"); - } - - JVMCI_event_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst)); -} - -void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, methodHandle& method, jint pc_offset, JVMCI_TRAPS) { - NativeCall* call = nullptr; - switch (_next_call_type) { - case INLINE_INVOKE: - return; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: { - assert(!method->is_static(), "cannot call static method with invokeinterface"); - - call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), - virtual_call_Relocation::spec(_invoke_mark_pc), - Assembler::call32_operand); - break; - } - case INVOKESTATIC: { - assert(method->is_static(), "cannot call non-static method with invokestatic"); - - call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_static_call_stub()); - _instructions->relocate(call->instruction_address(), - relocInfo::static_call_type, Assembler::call32_operand); - break; - } - case INVOKESPECIAL: { - assert(!method->is_static(), "cannot call static method with invokespecial"); - call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), - relocInfo::opt_virtual_call_type, Assembler::call32_operand); - break; - } - default: - JVMCI_ERROR("invalid _next_call_type value: %d", _next_call_type); - return; - } - if (!call->is_displacement_aligned()) { - JVMCI_ERROR("unaligned displacement for call at offset %d", pc_offset); - } - if (Continuations::enabled()) { - // Check for proper post_call_nop - NativePostCallNop* nop = nativePostCallNop_at(call->next_instruction_address()); - if (nop == nullptr) { - JVMCI_ERROR("missing post call nop at offset %d", pc_offset); - } else { - _instructions->relocate(call->next_instruction_address(), relocInfo::post_call_nop_type); - } - } -} - -bool CodeInstaller::pd_relocate(address pc, jint mark) { - switch (mark) { - case POLL_NEAR: - case POLL_FAR: - // This is a load from a register so there is no relocatable operand. - // We just have to ensure that the format is not disp32_operand - // so that poll_Relocation::fix_relocation_after_move does the right - // thing (i.e. ignores this relocation record) - _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand); - return true; - case POLL_RETURN_NEAR: - case POLL_RETURN_FAR: - // see comment above for POLL_FAR - _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand); - return true; -#if INCLUDE_ZGC - case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadGoodBeforeShl); - return true; - case Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatLoadBadAfterTest); - return true; - case Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_AFTER_TEST: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatMarkBadAfterTest); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_CMP: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterCmp); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_AFTER_TEST: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreBadAfterTest); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_OR: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterOr); - return true; - case Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_MOV: - _instructions->relocate(pc, barrier_Relocation::spec(), ZBarrierRelocationFormatStoreGoodAfterMov); - return true; -#endif - default: - return false; - } -} - -// convert JVMCI register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg, JVMCI_TRAPS) { - if (jvmci_reg < Register::number_of_registers) { - return as_Register(jvmci_reg)->as_VMReg(); - } else { - jint floatRegisterNumber = jvmci_reg - Register::number_of_registers; - if (floatRegisterNumber < XMMRegister::number_of_registers) { - return as_XMMRegister(floatRegisterNumber)->as_VMReg(); - } - JVMCI_ERROR_NULL("invalid register number: %d", jvmci_reg); - } -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return !(hotspotRegister->is_FloatRegister() || hotspotRegister->is_XMMRegister()); -} diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index b250073be7c..398617cf7e0 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -5848,7 +5848,7 @@ void MacroAssembler::reinit_heapbase() { } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // clear memory of size 'cnt' qwords, starting at 'base' using XMM/YMM/ZMM registers void MacroAssembler::xmm_clear_mem(Register base, Register cnt, Register rtmp, XMMRegister xtmp, KRegister mask) { @@ -6052,7 +6052,7 @@ void MacroAssembler::clear_mem(Register base, Register cnt, Register tmp, XMMReg BIND(DONE); } -#endif //COMPILER2_OR_JVMCI +#endif //COMPILER2 void MacroAssembler::generate_fill(BasicType t, bool aligned, @@ -9444,7 +9444,7 @@ void MacroAssembler::vpternlogq(XMMRegister dst, int imm8, XMMRegister src2, Add } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 void MacroAssembler::fill_masked(BasicType bt, Address dst, XMMRegister xmm, KRegister mask, Register length, Register temp, int vec_enc) { @@ -9679,7 +9679,7 @@ void MacroAssembler::generate_fill_avx3(BasicType type, Register to, Register va } bind(L_exit); } -#endif //COMPILER2_OR_JVMCI +#endif //COMPILER2 void MacroAssembler::convert_f2i(Register dst, XMMRegister src) { diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp index b73339c217f..89dca547727 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -2071,10 +2071,10 @@ public: void cache_wb(Address line); void cache_wbsync(bool is_pre); -#ifdef COMPILER2_OR_JVMCI +#ifdef COMPILER2 void generate_fill_avx3(BasicType type, Register to, Register value, Register count, Register rtmp, XMMRegister xtmp); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 void vallones(XMMRegister dst, int vector_len); diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index bbd43c1a0e8..8bb9982a820 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -65,9 +65,6 @@ #ifdef COMPILER2 #include "opto/runtime.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmciJavaClasses.hpp" -#endif #define __ masm-> @@ -182,14 +179,14 @@ class RegisterSaver { OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words, bool save_wide_vectors) { int off = 0; int num_xmm_regs = XMMRegister::available_xmm_registers(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (save_wide_vectors && UseAVX == 0) { save_wide_vectors = false; // vectors larger than 16 byte long are supported only with AVX } assert(!save_wide_vectors || MaxVectorSize <= 64, "Only up to 64 byte long vectors are supported"); #else - save_wide_vectors = false; // vectors are generated only by C2 and JVMCI -#endif + save_wide_vectors = false; // vectors are generated only by C2 +#endif // COMPILER2 // Always make the frame size 16-byte aligned, both vector and non vector stacks are always allocated int frame_size_in_bytes = align_up(reg_save_size*BytesPerInt, num_xmm_regs); @@ -234,13 +231,13 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ for (int n = 16; n < num_xmm_regs; n++) { __ evmovdqul(Address(rsp, base_addr+(off++*64)), as_XMMRegister(n), vector_len); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 base_addr = XSAVE_AREA_OPMASK_BEGIN; off = 0; for(int n = 0; n < KRegister::number_of_registers; n++) { __ kmov(Address(rsp, base_addr+(off++*8)), as_KRegister(n)); } -#endif +#endif // COMPILER2 } } else { if (VM_Version::supports_evex()) { @@ -251,17 +248,17 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ for (int n = 16; n < num_xmm_regs; n++) { __ evmovdqul(Address(rsp, base_addr+(off++*64)), as_XMMRegister(n), vector_len); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 base_addr = XSAVE_AREA_OPMASK_BEGIN; off = 0; for(int n = 0; n < KRegister::number_of_registers; n++) { __ kmov(Address(rsp, base_addr+(off++*8)), as_KRegister(n)); } -#endif +#endif // COMPILER2 } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (UseAPX) { int base_addr = XSAVE_AREA_EGPRS; off = 0; @@ -269,7 +266,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ __ movq(Address(rsp, base_addr+(off++*8)), as_Register(n)); } } -#endif +#endif // COMPILER2 __ vzeroupper(); if (frame::arg_reg_save_area_bytes != 0) { @@ -342,7 +339,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (save_wide_vectors) { // Save upper half of YMM registers(0..15) off = ymm0_off; @@ -363,7 +360,7 @@ OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_ } } } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // %%% These should all be a waste but we'll keep things as they were for now if (true) { @@ -431,14 +428,14 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wi __ addptr(rsp, frame::arg_reg_save_area_bytes); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (restore_wide_vectors) { assert(UseAVX > 0, "Vectors larger than 16 byte long are supported only with AVX"); assert(MaxVectorSize <= 64, "Only up to 64 byte long vectors are supported"); } #else assert(!restore_wide_vectors, "vectors are generated only by C2"); -#endif +#endif // COMPILER2 __ vzeroupper(); @@ -462,13 +459,13 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wi for (int n = 16; n < num_xmm_regs; n++) { __ evmovdqul(as_XMMRegister(n), Address(rsp, base_addr+(off++*64)), vector_len); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 base_addr = XSAVE_AREA_OPMASK_BEGIN; off = 0; for (int n = 0; n < KRegister::number_of_registers; n++) { __ kmov(as_KRegister(n), Address(rsp, base_addr+(off++*8))); } -#endif +#endif // COMPILER2 } } else { if (VM_Version::supports_evex()) { @@ -479,17 +476,17 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wi for (int n = 16; n < num_xmm_regs; n++) { __ evmovdqul(as_XMMRegister(n), Address(rsp, base_addr+(off++*64)), vector_len); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 base_addr = XSAVE_AREA_OPMASK_BEGIN; off = 0; for (int n = 0; n < KRegister::number_of_registers; n++) { __ kmov(as_KRegister(n), Address(rsp, base_addr+(off++*8))); } -#endif +#endif // COMPILER2 } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (UseAPX) { int base_addr = XSAVE_AREA_EGPRS; int off = 0; @@ -497,7 +494,7 @@ void RegisterSaver::restore_live_registers(MacroAssembler* masm, bool restore_wi __ movq(as_Register(n), Address(rsp, base_addr+(off++*8))); } } -#endif +#endif // COMPILER2 // Recover CPU state __ pop_FPU_state(); @@ -887,18 +884,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm, // Pre-load the register-jump target early, to schedule it better. __ movptr(r11, Address(rbx, in_bytes(Method::from_compiled_offset()))); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - // check if this call should be routed towards a specific entry point - __ cmpptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); - Label no_alternative_target; - __ jcc(Assembler::equal, no_alternative_target); - __ movptr(r11, Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); - __ movptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); - __ bind(no_alternative_target); - } -#endif // INCLUDE_JVMCI - // Now generate the shuffle code. Pick up all register args and move the // rest through the floating point stack top. for (int i = 0; i < total_args_passed; i++) { @@ -2492,11 +2477,6 @@ void SharedRuntime::generate_deopt_blob() { if (UseAPX) { pad += 1024; } -#if INCLUDE_JVMCI - if (EnableJVMCI) { - pad += 512; // Increase the buffer size when compiling for JVMCI - } -#endif const char* name = SharedRuntime::stub_name(StubId::shared_deopt_id); CodeBlob* blob = AOTCodeCache::load_code_blob(AOTCodeEntry::SharedBlob, BlobId::shared_deopt_id); if (blob != nullptr) { @@ -2553,13 +2533,6 @@ void SharedRuntime::generate_deopt_blob() { __ jmp(cont); int reexecute_offset = __ pc() - start; -#if INCLUDE_JVMCI && !defined(COMPILER1) - if (UseJVMCICompiler) { - // JVMCI does not use this kind of deoptimization - __ should_not_reach_here(); - } -#endif - // Reexecute case // return address is the pc describes what bci to do re-execute at @@ -2569,39 +2542,6 @@ void SharedRuntime::generate_deopt_blob() { __ movl(r14, Deoptimization::Unpack_reexecute); // callee-saved __ jmp(cont); -#if INCLUDE_JVMCI - Label after_fetch_unroll_info_call; - int implicit_exception_uncommon_trap_offset = 0; - int uncommon_trap_offset = 0; - - if (EnableJVMCI) { - implicit_exception_uncommon_trap_offset = __ pc() - start; - - __ pushptr(Address(r15_thread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); - __ movptr(Address(r15_thread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset())), NULL_WORD); - - uncommon_trap_offset = __ pc() - start; - - // Save everything in sight. - RegisterSaver::save_live_registers(masm, 0, &frame_size_in_words, /*save_wide_vectors*/ true); - // fetch_unroll_info needs to call last_java_frame() - __ set_last_Java_frame(noreg, noreg, nullptr, rscratch1); - - __ movl(c_rarg1, Address(r15_thread, in_bytes(JavaThread::pending_deoptimization_offset()))); - __ movl(Address(r15_thread, in_bytes(JavaThread::pending_deoptimization_offset())), -1); - - __ movl(r14, Deoptimization::Unpack_reexecute); - __ mov(c_rarg0, r15_thread); - __ movl(c_rarg2, r14); // exec mode - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, Deoptimization::uncommon_trap))); - oop_maps->add_gc_map( __ pc()-start, map->deep_copy()); - - __ reset_last_Java_frame(false); - - __ jmp(after_fetch_unroll_info_call); - } // EnableJVMCI -#endif // INCLUDE_JVMCI - int exception_offset = __ pc() - start; // Prolog for exception case @@ -2686,12 +2626,6 @@ void SharedRuntime::generate_deopt_blob() { __ reset_last_Java_frame(false); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - __ bind(after_fetch_unroll_info_call); - } -#endif - // Load UnrollBlock* into rdi __ mov(rdi, rax); @@ -2849,12 +2783,6 @@ void SharedRuntime::generate_deopt_blob() { _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); - _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); - } -#endif AOTCodeCache::store_code_blob(*_deopt_blob, AOTCodeEntry::SharedBlob, BlobId::shared_deopt_id); } diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index b0612d21437..b64943fc4de 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -43,9 +43,6 @@ #include "opto/runtime.hpp" #include "opto/c2_globals.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci_globals.hpp" -#endif // For a more detailed description of the stub routine structure // see the comment in stubRoutines.hpp @@ -4832,7 +4829,7 @@ void StubGenerator::generate_final_stubs() { } void StubGenerator::generate_compiler_stubs() { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Entry points that are C2 compiler specific. @@ -4890,11 +4887,9 @@ void StubGenerator::generate_compiler_stubs() { StubRoutines::_data_cache_writeback = generate_data_cache_writeback(); StubRoutines::_data_cache_writeback_sync = generate_data_cache_writeback_sync(); -#ifdef COMPILER2 if ((UseAVX == 2) && EnableX86ECoreOpts && UseCountTrailingZerosInstruction) { generate_string_indexof(StubRoutines::_string_indexof_array); } -#endif if (UseAdler32Intrinsics) { StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32(); @@ -4973,7 +4968,6 @@ void StubGenerator::generate_compiler_stubs() { StubRoutines::_base64_decodeBlock = generate_base64_decodeBlock(); } -#ifdef COMPILER2 if (UseMultiplyToLenIntrinsic) { StubRoutines::_multiplyToLen = generate_multiplyToLen(); } @@ -5018,7 +5012,6 @@ void StubGenerator::generate_compiler_stubs() { } #endif // COMPILER2 -#endif // COMPILER2_OR_JVMCI } StubGenerator::StubGenerator(CodeBuffer* code, BlobId blob_id, AOTStubData* stub_data) : StubCodeGenerator(code, blob_id, stub_data) { diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp index d3823cb559f..360b0329d95 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp @@ -161,7 +161,7 @@ class StubGenerator: public StubCodeGenerator { void restore_argument_regs(BasicType type); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Following rules apply to AVX3 optimized arraycopy stubs: // - If target supports AVX3 features (BW+VL+F) then implementation uses 32 byte vectors (YMMs) // for both special cases (various small block sizes) and aligned copy loop. This is the @@ -216,7 +216,7 @@ class StubGenerator: public StubCodeGenerator { void copy32_masked_avx(Register dst, Register src, XMMRegister xmm, KRegister mask, Register length, Register index, Register temp, int shift = Address::times_1, int offset = 0); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 address generate_disjoint_byte_copy(address* entry); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp index 5530e5325de..e7dc416a961 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,9 +32,6 @@ #ifdef COMPILER2 #include "opto/c2_globals.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci_globals.hpp" -#endif #define __ _masm-> @@ -59,7 +56,7 @@ static void inc_counter_np(MacroAssembler* _masm, uint& counter, Register rscrat __ incrementl(ExternalAddress((address)&counter), rscratch); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 static uint& get_profile_ctr(int shift) { if (shift == 0) { return SharedRuntime::_jbyte_array_copy_ctr; @@ -72,7 +69,7 @@ static uint& get_profile_ctr(int shift) { return SharedRuntime::_jlong_array_copy_ctr; } } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 #endif // !PRODUCT void StubGenerator::generate_arraycopy_stubs() { @@ -505,7 +502,7 @@ void StubGenerator::copy_bytes_backward(Register from, Register dest, __ jcc(Assembler::greater, L_copy_8_bytes); // Copy trailing qwords } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Note: Following rules apply to AVX3 optimized arraycopy stubs:- // - If target supports AVX3 features (BW+VL+F) then implementation uses 32 byte vectors (YMMs) @@ -1459,7 +1456,7 @@ void StubGenerator::copy64_avx(Register dst, Register src, Register index, XMMRe } } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // Arguments: @@ -1483,11 +1480,11 @@ address StubGenerator::generate_disjoint_byte_copy(address* entry) { StubId stub_id = StubId::stubgen_jbyte_disjoint_arraycopy_id; // aligned is always false -- x86_64 always uses the unaligned code const bool aligned = false; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_disjoint_copy_avx3_masked(stub_id, entry); } -#endif +#endif // COMPILER2 GrowableArray
entries; GrowableArray
extras; int expected_entry_count = (entry != nullptr ? 2 : 1); @@ -1633,11 +1630,11 @@ address StubGenerator::generate_conjoint_byte_copy(address nooverlap_target, add StubId stub_id = StubId::stubgen_jbyte_arraycopy_id; // aligned is always false -- x86_64 always uses the unaligned code const bool aligned = false; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_conjoint_copy_avx3_masked(stub_id, entry, nooverlap_target); } -#endif +#endif // COMPILER2 GrowableArray
entries; GrowableArray
extras; int expected_entry_count = (entry != nullptr ? 2 : 1); @@ -1777,11 +1774,11 @@ address StubGenerator::generate_disjoint_short_copy(address *entry) { StubId stub_id = StubId::stubgen_jshort_disjoint_arraycopy_id; // aligned is always false -- x86_64 always uses the unaligned code const bool aligned = false; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_disjoint_copy_avx3_masked(stub_id, entry); } -#endif +#endif // COMPILER2 GrowableArray
entries; GrowableArray
extras; int expected_entry_count = (entry != nullptr ? 2 : 1); @@ -2004,11 +2001,11 @@ address StubGenerator::generate_conjoint_short_copy(address nooverlap_target, ad StubId stub_id = StubId::stubgen_jshort_arraycopy_id; // aligned is always false -- x86_64 always uses the unaligned code const bool aligned = false; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_conjoint_copy_avx3_masked(stub_id, entry, nooverlap_target); } -#endif +#endif // COMPILER2 GrowableArray
entries; GrowableArray
extras; int expected_entry_count = (entry != nullptr ? 2 : 1); @@ -2162,11 +2159,11 @@ address StubGenerator::generate_disjoint_int_oop_copy(StubId stub_id, address* e } BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if ((!is_oop || bs->supports_avx3_masked_arraycopy()) && VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_disjoint_copy_avx3_masked(stub_id, entry); } -#endif +#endif // COMPILER2 GrowableArray
entries; GrowableArray
extras; bool add_handlers = !is_oop && !aligned; @@ -2344,11 +2341,11 @@ address StubGenerator::generate_conjoint_int_oop_copy(StubId stub_id, address no } BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if ((!is_oop || bs->supports_avx3_masked_arraycopy()) && VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_conjoint_copy_avx3_masked(stub_id, entry, nooverlap_target); } -#endif +#endif // COMPILER2 bool add_handlers = !is_oop && !aligned; bool add_relocs = UseZGC && is_oop; bool add_extras = add_handlers || add_relocs; @@ -2527,11 +2524,11 @@ address StubGenerator::generate_disjoint_long_oop_copy(StubId stub_id, address * } BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if ((!is_oop || bs->supports_avx3_masked_arraycopy()) && VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_disjoint_copy_avx3_masked(stub_id, entry); } -#endif +#endif // COMPILER2 bool add_handlers = !is_oop && !aligned; bool add_relocs = UseZGC && is_oop; bool add_extras = add_handlers || add_relocs; @@ -2710,11 +2707,11 @@ address StubGenerator::generate_conjoint_long_oop_copy(StubId stub_id, address n } BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if ((!is_oop || bs->supports_avx3_masked_arraycopy()) && VM_Version::supports_avx512vlbw() && VM_Version::supports_bmi2() && MaxVectorSize >= 32) { return generate_conjoint_copy_avx3_masked(stub_id, entry, nooverlap_target); } -#endif +#endif // COMPILER2 bool add_handlers = !is_oop && !aligned; bool add_relocs = UseZGC && is_oop; bool add_extras = add_handlers || add_relocs; diff --git a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp index 47ef0aef2bb..2edd9706272 100644 --- a/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp +++ b/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,7 @@ // if too small. // Run with +PrintInterpreter to get the VM to print out the size. // Max size with JVMTI -int TemplateInterpreter::InterpreterCodeSize = JVMCI_ONLY(268) NOT_JVMCI(256) * 1024; +int TemplateInterpreter::InterpreterCodeSize = 256 * 1024; // Global Register Names static const Register rbcp = r13; @@ -224,32 +224,6 @@ address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, i __ restore_bcp(); __ restore_locals(); const Register thread = r15_thread; -#if INCLUDE_JVMCI - // Check if we need to take lock at entry of synchronized method. This can - // only occur on method entry so emit it only for vtos with step 0. - if (EnableJVMCI && state == vtos && step == 0) { - Label L; - __ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0); - __ jcc(Assembler::zero, L); - // Clear flag. - __ movb(Address(thread, JavaThread::pending_monitorenter_offset()), 0); - // Satisfy calling convention for lock_method(). - __ get_method(rbx); - // Take lock. - lock_method(); - __ bind(L); - } else { -#ifdef ASSERT - if (EnableJVMCI) { - Label L; - __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0); - __ jcc(Assembler::zero, L); - __ stop("unexpected pending monitor in deopt entry"); - __ bind(L); - } -#endif - } -#endif // handle exceptions { Label L; diff --git a/src/hotspot/cpu/x86/vmStructs_x86.hpp b/src/hotspot/cpu/x86/vmStructs_x86.hpp index e0fcc7d375a..33b1f3c5e57 100644 --- a/src/hotspot/cpu/x86/vmStructs_x86.hpp +++ b/src/hotspot/cpu/x86/vmStructs_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,8 +32,7 @@ #define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field) \ volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*) \ static_field(VM_Version, _features, VM_Version::VM_Features) \ - nonstatic_field(VM_Version::VM_Features, _features_bitmap[0], uint64_t) \ - static_field(VM_Version::VM_Features, _features_bitmap_size, int) + nonstatic_field(VM_Version::VM_Features, _features_bitmap[0], uint64_t) #define VM_TYPES_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type) \ declare_toplevel_type(VM_Version::VM_Features) diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index 3b99b5355f1..615e892cd0b 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -65,8 +65,6 @@ address VM_Version::_cpuinfo_cont_addr_apx = nullptr; static BufferBlob* stub_blob; static const int stub_size = 2550; -int VM_Version::VM_Features::_features_bitmap_size = sizeof(VM_Version::VM_Features::_features_bitmap) / BytesPerLong; - VM_Version::VM_Features VM_Version::_features; VM_Version::VM_Features VM_Version::_cpu_features; @@ -1336,7 +1334,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 int max_vector_size = 0; if (UseAVX == 0 || !os_supports_avx_vectors()) { // 16 byte vectors (in XMM) are supported with SSE2+ @@ -1369,7 +1367,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(MaxVectorSize, max_vector_size); } -#if defined(COMPILER2) && defined(ASSERT) +#ifdef ASSERT if (MaxVectorSize > 0) { if (supports_avx() && PrintMiscellaneous && Verbose && TraceNewVectors) { tty->print_cr("State of YMM registers after signal handle:"); @@ -1384,7 +1382,7 @@ void VM_Version::get_processor_features() { } } } -#endif // COMPILER2 && ASSERT +#endif // ASSERT if ((supports_avx512ifma() && supports_avx512vlbw()) || supports_avxifma()) { if (FLAG_IS_DEFAULT(UsePoly1305Intrinsics)) { @@ -1423,7 +1421,7 @@ void VM_Version::get_processor_features() { if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) { UseMontgomerySquareIntrinsic = true; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // On new cpus instructions which update whole XMM register should be used // to prevent partial register stall due to dependencies on high half. diff --git a/src/hotspot/cpu/x86/vm_version_x86.hpp b/src/hotspot/cpu/x86/vm_version_x86.hpp index c1269015408..895987b56ce 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.hpp +++ b/src/hotspot/cpu/x86/vm_version_x86.hpp @@ -34,7 +34,6 @@ class stringStream; class VM_Version : public Abstract_VM_Version { friend class VMStructs; - friend class JVMCIVMStructs; public: // cpuid result register layouts. These are all unions of a uint32_t @@ -373,7 +372,6 @@ protected: /* * Update following files when declaring new flags: * test/lib-test/jdk/test/whitebox/CPUInfoTest.java - * src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java */ enum Feature_Flag { #define CPU_FEATURE_FLAGS(decl) \ @@ -449,7 +447,6 @@ protected: class VM_Features { friend class VMStructs; - friend class JVMCIVMStructs; private: uint64_t _features_bitmap[(MAX_CPU_FEATURES / BitsPerLong) + 1]; @@ -479,7 +476,6 @@ protected: return (1ULL << (feature & features_bitmap_element_mask())); } - static int _features_bitmap_size; // for JVMCI purposes public: VM_Features() { for (int i = 0; i < features_bitmap_element_count(); i++) { diff --git a/src/hotspot/os_cpu/bsd_aarch64/javaThread_bsd_aarch64.cpp b/src/hotspot/os_cpu/bsd_aarch64/javaThread_bsd_aarch64.cpp index 982605bbed4..c0634a379b8 100644 --- a/src/hotspot/os_cpu/bsd_aarch64/javaThread_bsd_aarch64.cpp +++ b/src/hotspot/os_cpu/bsd_aarch64/javaThread_bsd_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -72,8 +72,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) frame ret_frame(ret_sp, ret_fp, addr); if (!ret_frame.safe_for_sender(this)) { -#if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if null fp helps +#ifdef COMPILER2 + // C2 uses ebp as a general register see if null fp helps frame ret_frame2(ret_sp, nullptr, addr); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good @@ -83,7 +83,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) #else // nothing else to try if the frame isn't good return false; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } *fr_addr = ret_frame; return true; diff --git a/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp b/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp index 0b5e5b6e7bd..08288f940fa 100644 --- a/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp +++ b/src/hotspot/os_cpu/bsd_x86/javaThread_bsd_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,8 +67,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) frame ret_frame(ret_sp, ret_fp, addr); if (!ret_frame.safe_for_sender(this)) { -#if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if null fp helps +#ifdef COMPILER2 + // C2 uses ebp as a general register see if null fp helps frame ret_frame2(ret_sp, nullptr, addr); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good @@ -78,7 +78,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) #else // nothing else to try if the frame isn't good return false; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } *fr_addr = ret_frame; return true; diff --git a/src/hotspot/os_cpu/linux_x86/javaThread_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/javaThread_linux_x86.cpp index 6f0cd49951d..71498ce2e62 100644 --- a/src/hotspot/os_cpu/linux_x86/javaThread_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/javaThread_linux_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,8 +68,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) frame ret_frame(ret_sp, ret_fp, addr); if (!ret_frame.safe_for_sender(this)) { -#if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if null fp helps +#ifdef COMPILER2 + // C2 uses ebp as a general register see if null fp helps frame ret_frame2(ret_sp, nullptr, addr); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good @@ -79,7 +79,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) #else // nothing else to try if the frame isn't good return false; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } *fr_addr = ret_frame; return true; diff --git a/src/hotspot/os_cpu/windows_aarch64/javaThread_windows_aarch64.cpp b/src/hotspot/os_cpu/windows_aarch64/javaThread_windows_aarch64.cpp index 3f77a27f051..97b6d6812e5 100644 --- a/src/hotspot/os_cpu/windows_aarch64/javaThread_windows_aarch64.cpp +++ b/src/hotspot/os_cpu/windows_aarch64/javaThread_windows_aarch64.cpp @@ -72,8 +72,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) } if (!ret_frame.safe_for_sender(this)) { -#if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if null fp helps +#ifdef COMPILER2 + // C2 uses ebp as a general register see if null fp helps frame ret_frame2(ret_frame.sp(), nullptr, ret_frame.pc()); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good @@ -83,7 +83,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) #else // nothing else to try if the frame isn't good return false; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } *fr_addr = ret_frame; return true; diff --git a/src/hotspot/os_cpu/windows_x86/javaThread_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/javaThread_windows_x86.cpp index 63edd9d8eda..40f2fb3b64c 100644 --- a/src/hotspot/os_cpu/windows_x86/javaThread_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/javaThread_windows_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,8 +63,8 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) } if (!ret_frame.safe_for_sender(this)) { -#if COMPILER2_OR_JVMCI - // C2 and JVMCI use ebp as a general register see if null fp helps +#ifdef COMPILER2 + // C2 uses ebp as a general register see if null fp helps frame ret_frame2(ret_frame.sp(), nullptr, ret_frame.pc()); if (!ret_frame2.safe_for_sender(this)) { // nothing else to try if the frame isn't good @@ -74,7 +74,7 @@ bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) #else // nothing else to try if the frame isn't good return false; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } *fr_addr = ret_frame; return true; diff --git a/src/hotspot/share/c1/c1_Compilation.hpp b/src/hotspot/share/c1/c1_Compilation.hpp index 5125e0bbe0a..5de201592f9 100644 --- a/src/hotspot/share/c1/c1_Compilation.hpp +++ b/src/hotspot/share/c1/c1_Compilation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -256,7 +256,7 @@ class Compilation: public StackObj { // will compilation make optimistic assumptions that might lead to // deoptimization and that the runtime will account for? bool is_optimistic() { - return CompilerConfig::is_c1_only_no_jvmci() && !is_profiling() && + return CompilerConfig::is_c1_only() && !is_profiling() && (RangeCheckElimination || UseLoopInvariantCodeMotion) && method()->method_data()->trap_count(Deoptimization::Reason_none) == 0; } diff --git a/src/hotspot/share/c1/c1_LIRGenerator.cpp b/src/hotspot/share/c1/c1_LIRGenerator.cpp index f6807abcd7a..de3b08e08e8 100644 --- a/src/hotspot/share/c1/c1_LIRGenerator.cpp +++ b/src/hotspot/share/c1/c1_LIRGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -478,7 +478,7 @@ void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitI /* C2 relies on constant pool entries being resolved (ciTypeFlow), so if tiered compilation * is active and the class hasn't yet been resolved we need to emit a patch that resolves * the class. */ - if ((!CompilerConfig::is_c1_only_no_jvmci() && need_resolve) || !obj->is_loaded() || PatchALot) { + if ((!CompilerConfig::is_c1_only() && need_resolve) || !obj->is_loaded() || PatchALot) { assert(info != nullptr, "info must be set if class is not loaded"); __ klass2reg_patch(nullptr, r, info); } else { @@ -644,7 +644,7 @@ void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, L void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) { if (PrintNotLoaded && !new_instance->klass()->is_loaded()) { tty->print_cr(" ###class not loaded at new bci %d", new_instance->printable_bci()); - } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only_no_jvmci() && new_instance->is_unresolved())) { + } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only() && new_instance->is_unresolved())) { tty->print_cr(" ###class not resolved at new bci %d", new_instance->printable_bci()); } } diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 1c136ac61a8..c2b321f3c0a 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -230,7 +230,6 @@ void FileMapHeader::populate(FileMapInfo *info, size_t core_region_alignment, _narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift(); // Which JIT compier is used - _compiler_type = (u1)CompilerConfig::compiler_type(); _type_profile_level = TypeProfileLevel; _type_profile_args_limit = TypeProfileArgsLimit; _type_profile_parms_limit = TypeProfileParmsLimit; @@ -1819,23 +1818,6 @@ bool FileMapHeader::validate() { CompactStrings ? "enabled" : "disabled"); return false; } - bool jvmci_compiler_is_enabled = CompilerConfig::is_jvmci_compiler_enabled(); - CompilerType compiler_type = CompilerConfig::compiler_type(); - CompilerType archive_compiler_type = CompilerType(_compiler_type); - // JVMCI compiler does different type profiling settigns and generate - // different code. We can't use archive which was produced - // without it and reverse. - // Only allow mix when JIT compilation is disabled. - // Interpreter is used by default when dumping archive. - bool intepreter_is_used = (archive_compiler_type == CompilerType::compiler_none) || - (compiler_type == CompilerType::compiler_none); - if (!intepreter_is_used && - jvmci_compiler_is_enabled != (archive_compiler_type == CompilerType::compiler_jvmci)) { - AOTMetaspace::report_loading_error("The %s's JIT compiler setting (%s)" - " does not equal the current setting (%s).", file_type, - compilertype2name(archive_compiler_type), compilertype2name(compiler_type)); - return false; - } if (TrainingData::have_data()) { if (_type_profile_level != TypeProfileLevel) { AOTMetaspace::report_loading_error("The %s's TypeProfileLevel setting (%d)" diff --git a/src/hotspot/share/cds/filemap.hpp b/src/hotspot/share/cds/filemap.hpp index 4ade7d03b65..f5f6ee235a4 100644 --- a/src/hotspot/share/cds/filemap.hpp +++ b/src/hotspot/share/cds/filemap.hpp @@ -151,7 +151,6 @@ private: AOTStreamedHeapHeader _streamed_heap_header; // The following are parameters that affect MethodData layout. - u1 _compiler_type; uint _type_profile_level; int _type_profile_args_limit; int _type_profile_parms_limit; diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index bf00185ffa9..221875e29d0 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -1476,20 +1476,6 @@ void ClassLoader::set_preview_mode(bool enable_preview) { Preview_mode = enable_preview ? PREVIEW_MODE_ENABLE_PREVIEW : PREVIEW_MODE_DEFAULT; } -bool ClassLoader::is_module_observable(const char* module_name) { - assert(JImageOpen != nullptr, "jimage library should have been opened"); - if (!jimage_is_open()) { - struct stat st; - const char *path = get_exploded_module_path(module_name, true); - bool res = os::stat(path, &st) == 0; - FREE_C_HEAP_ARRAY(path); - return res; - } - // We don't expect preview mode (i.e. --enable-preview) to affect module visibility. - jlong size; - return jimage_find_resource(module_name, "module-info.class", /* is_preview */ false, &size) != 0; -} - jlong ClassLoader::classloader_time_ms() { return UsePerfData ? Management::ticks_to_ms(_perf_accumulated_time->get_value()) : -1; diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index ff7e8999688..b750a2daf68 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -366,10 +366,6 @@ class ClassLoader: AllStatic { // JImage resource lookups or access will fail. static void set_preview_mode(bool enable_preview); - // Determines if the named module is present in the - // modules jimage file or in the exploded modules directory. - static bool is_module_observable(const char* module_name); - static void trace_class_path(const char* msg, const char* name = nullptr); // VM monitoring and management support diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index ef1eeec14dd..e656dc7c42d 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -89,9 +89,6 @@ #include "utilities/growableArray.hpp" #include "utilities/preserveException.hpp" #include "utilities/utf8.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciJavaClasses.hpp" -#endif #define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java) \ { VM_CLASS_ID(klass), VM_SYMBOL_ENUM_NAME(name##_name), VM_SYMBOL_ENUM_NAME(signature), may_be_java }, @@ -3154,23 +3151,6 @@ void java_lang_StackTraceElement::decode_file_and_line(Handle java_class, line_number = Backtrace::get_line_number(method(), bci); } -#if INCLUDE_JVMCI -void java_lang_StackTraceElement::decode(const methodHandle& method, int bci, - Symbol*& filename, int& line_number, TRAPS) { - ResourceMark rm(THREAD); - HandleMark hm(THREAD); - - filename = nullptr; - line_number = -1; - - oop source_file; - int version = method->constants()->version(); - InstanceKlass* holder = method->method_holder(); - Handle java_class(THREAD, holder->java_mirror()); - decode_file_and_line(java_class, holder, version, method, bci, filename, source_file, line_number, CHECK); -} -#endif // INCLUDE_JVMCI - // java_lang_ClassFrameInfo int java_lang_ClassFrameInfo::_classOrMemberName_offset; @@ -5102,12 +5082,6 @@ void java_lang_Integer_IntegerCache::serialize_offsets(SerializeClosure* f) { #endif #undef INTEGER_CACHE_FIELDS_DO -jint java_lang_Integer::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.i; -} - #define LONG_CACHE_FIELDS_DO(macro) \ macro(_static_cache_offset, k, "cache", java_lang_Long_array_signature, true) @@ -5132,12 +5106,6 @@ void java_lang_Long_LongCache::serialize_offsets(SerializeClosure* f) { #endif #undef LONG_CACHE_FIELDS_DO -jlong java_lang_Long::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.j; -} - #define CHARACTER_CACHE_FIELDS_DO(macro) \ macro(_static_cache_offset, k, "cache", java_lang_Character_array_signature, true) @@ -5162,12 +5130,6 @@ void java_lang_Character_CharacterCache::serialize_offsets(SerializeClosure* f) #endif #undef CHARACTER_CACHE_FIELDS_DO -jchar java_lang_Character::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.c; -} - #define SHORT_CACHE_FIELDS_DO(macro) \ macro(_static_cache_offset, k, "cache", java_lang_Short_array_signature, true) @@ -5192,12 +5154,6 @@ void java_lang_Short_ShortCache::serialize_offsets(SerializeClosure* f) { #endif #undef SHORT_CACHE_FIELDS_DO -jshort java_lang_Short::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.s; -} - #define BYTE_CACHE_FIELDS_DO(macro) \ macro(_static_cache_offset, k, "cache", java_lang_Byte_array_signature, true) @@ -5222,12 +5178,6 @@ void java_lang_Byte_ByteCache::serialize_offsets(SerializeClosure* f) { #endif #undef BYTE_CACHE_FIELDS_DO -jbyte java_lang_Byte::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.b; -} - int java_lang_Boolean::_static_TRUE_offset; int java_lang_Boolean::_static_FALSE_offset; @@ -5241,16 +5191,6 @@ void java_lang_Boolean::compute_offsets(InstanceKlass *k) { BOOLEAN_FIELDS_DO(FIELD_COMPUTE_OFFSET); } -oop java_lang_Boolean::get_TRUE(InstanceKlass *ik) { - oop base = ik->static_field_base_raw(); - return base->obj_field(_static_TRUE_offset); -} - -oop java_lang_Boolean::get_FALSE(InstanceKlass *ik) { - oop base = ik->static_field_base_raw(); - return base->obj_field(_static_FALSE_offset); -} - Symbol* java_lang_Boolean::symbol() { return vmSymbols::java_lang_Boolean(); } @@ -5262,12 +5202,6 @@ void java_lang_Boolean::serialize_offsets(SerializeClosure* f) { #endif #undef BOOLEAN_CACHE_FIELDS_DO -jboolean java_lang_Boolean::value(oop obj) { - jvalue v; - java_lang_boxing_object::get_value(obj, &v); - return v.z; -} - // java_lang_reflect_RecordComponent int java_lang_reflect_RecordComponent::_clazz_offset; diff --git a/src/hotspot/share/classfile/javaClasses.hpp b/src/hotspot/share/classfile/javaClasses.hpp index 3276d398faf..34fe1fe07b1 100644 --- a/src/hotspot/share/classfile/javaClasses.hpp +++ b/src/hotspot/share/classfile/javaClasses.hpp @@ -233,7 +233,6 @@ class java_lang_String : AllStatic { class java_lang_Class : AllStatic { friend class VMStructs; - friend class JVMCIVMStructs; friend class HeapShared; private: @@ -381,7 +380,6 @@ class java_lang_Class : AllStatic { class java_lang_Thread : AllStatic { friend class java_lang_VirtualThread; - friend class JVMCIVMStructs; private: // Note that for this class the layout changed between JDK1.2 and JDK1.3, // so we compute the offsets at startup rather than hard-wiring them. @@ -1573,10 +1571,6 @@ class java_lang_StackTraceElement: AllStatic { static void compute_offsets(); static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN; -#if INCLUDE_JVMCI - static void decode(const methodHandle& method, int bci, Symbol*& fileName, int& lineNumber, TRAPS); -#endif - // Debugging friend class JavaClasses; }; @@ -1770,31 +1764,6 @@ class vector_VectorPayload : AllStatic { static bool is_instance(oop obj); }; -class java_lang_Integer : AllStatic { -public: - static jint value(oop obj); -}; - -class java_lang_Long : AllStatic { -public: - static jlong value(oop obj); -}; - -class java_lang_Character : AllStatic { -public: - static jchar value(oop obj); -}; - -class java_lang_Short : AllStatic { -public: - static jshort value(oop obj); -}; - -class java_lang_Byte : AllStatic { -public: - static jbyte value(oop obj); -}; - class java_lang_Boolean : AllStatic { private: static int _static_TRUE_offset; @@ -1802,10 +1771,7 @@ class java_lang_Boolean : AllStatic { public: static Symbol* symbol(); static void compute_offsets(InstanceKlass* k); - static oop get_TRUE(InstanceKlass *k); - static oop get_FALSE(InstanceKlass *k); static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN; - static jboolean value(oop obj); }; class java_lang_Integer_IntegerCache : AllStatic { diff --git a/src/hotspot/share/classfile/metadataOnStackMark.cpp b/src/hotspot/share/classfile/metadataOnStackMark.cpp index 51ce2c263a3..a397774484b 100644 --- a/src/hotspot/share/classfile/metadataOnStackMark.cpp +++ b/src/hotspot/share/classfile/metadataOnStackMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,6 @@ #include "runtime/synchronizer.hpp" #include "services/threadService.hpp" #include "utilities/chunkedList.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif MetadataOnStackBuffer* MetadataOnStackMark::_used_buffers = nullptr; MetadataOnStackBuffer* MetadataOnStackMark::_free_buffers = nullptr; @@ -70,9 +67,6 @@ MetadataOnStackMark::MetadataOnStackMark(bool walk_all_metadata, bool redefiniti } CompileBroker::mark_on_stack(); ThreadService::metadata_do(Metadata::mark_on_stack); -#if INCLUDE_JVMCI - JVMCI::metadata_do(Metadata::mark_on_stack); -#endif } } diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index 51d09d9c47f..2ab3078c1c3 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -453,7 +453,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, ClassLoader::add_to_exploded_build_list(THREAD, module_symbol); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Special handling of jdk.incubator.vector if (strcmp(module_name, "jdk.incubator.vector") == 0) { if (FLAG_IS_DEFAULT(EnableVectorSupport)) { @@ -469,7 +469,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, log_info(compilation)("EnableVectorReboxing=%s", (EnableVectorReboxing ? "true" : "false")); log_info(compilation)("EnableVectorAggressiveReboxing=%s", (EnableVectorAggressiveReboxing ? "true" : "false")); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } #if INCLUDE_CDS_JAVA_HEAP diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 33d00b93365..0348fae28b0 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -26,7 +26,6 @@ #define SHARE_CLASSFILE_VMSYMBOLS_HPP #include "classfile/vmIntrinsics.hpp" -#include "jvmci/vmSymbols_jvmci.hpp" #include "memory/iterator.hpp" #include "oops/symbol.hpp" #include "utilities/enumIterator.hpp" @@ -356,9 +355,6 @@ class SerializeClosure; \ template(jdk_internal_foreign_NativeMemorySegmentImpl, "jdk/internal/foreign/NativeMemorySegmentImpl") \ \ - /* Support for JVMCI */ \ - JVMCI_VM_SYMBOLS_DO(template, do_alias) \ - \ template(java_lang_ClassFrameInfo, "java/lang/ClassFrameInfo") \ template(java_lang_StackWalker, "java/lang/StackWalker") \ template(java_lang_StackFrameInfo, "java/lang/StackFrameInfo") \ @@ -704,12 +700,6 @@ class SerializeClosure; template(serializePropertiesToByteArray_name, "serializePropertiesToByteArray") \ template(serializeSecurityPropertiesToByteArray_name, "serializeSecurityPropertiesToByteArray") \ template(serializeAgentPropertiesToByteArray_name, "serializeAgentPropertiesToByteArray") \ - template(encodeThrowable_name, "encodeThrowable") \ - template(encodeThrowable_signature, "(Ljava/lang/Throwable;JI)I") \ - template(decodeAndThrowThrowable_name, "decodeAndThrowThrowable") \ - template(encodeAnnotations_name, "encodeAnnotations") \ - template(encodeAnnotations_signature, "([BLjava/lang/Class;Ljdk/internal/reflect/ConstantPool;Z[Ljava/lang/Class;)[B")\ - template(decodeAndThrowThrowable_signature, "(IJZZ)V") \ template(classRedefinedCount_name, "classRedefinedCount") \ template(classLoader_name, "classLoader") \ template(componentType_name, "componentType") \ @@ -784,7 +774,6 @@ ENUMERATOR_RANGE(vmSymbolID, vmSymbolID::FIRST_SID, vmSymbolID::LAST_SID) class vmSymbols: AllStatic { friend class vmIntrinsics; friend class VMStructs; - friend class JVMCIVMStructs; static const int NO_SID = static_cast(vmSymbolID::NO_SID); // exclusive lower limit static const int FIRST_SID = static_cast(vmSymbolID::FIRST_SID); // inclusive lower limit diff --git a/src/hotspot/share/code/aotCodeCache.cpp b/src/hotspot/share/code/aotCodeCache.cpp index 4cc91208dcd..6a66468299d 100644 --- a/src/hotspot/share/code/aotCodeCache.cpp +++ b/src/hotspot/share/code/aotCodeCache.cpp @@ -1576,10 +1576,6 @@ void AOTCodeCache::publish_stub_addresses(CodeBlob &code_blob, BlobId blob_id, A addresses.append(deopt_blob->unpack_with_exception()); addresses.append(deopt_blob->unpack_with_reexecution()); addresses.append(deopt_blob->unpack_with_exception_in_tls()); -#if INCLUDE_JVMCI - addresses.append(deopt_blob->uncommon_trap()); - addresses.append(deopt_blob->implicit_exception_uncommon_trap()); -#endif // INCLUDE_JVMCI cache()->add_stub_entries(stub_id, start, &addresses, 0); } } diff --git a/src/hotspot/share/code/aotCodeCache.hpp b/src/hotspot/share/code/aotCodeCache.hpp index 66ffb09c54e..777ada59a0b 100644 --- a/src/hotspot/share/code/aotCodeCache.hpp +++ b/src/hotspot/share/code/aotCodeCache.hpp @@ -320,14 +320,6 @@ public: #define AOTCODECACHE_CONFIGS_COMPILER2_DO(do_var, do_fun) #endif -#if INCLUDE_JVMCI -#define AOTCODECACHE_CONFIGS_JVMCI_DO(do_var, do_fun) \ - do_var(bool, EnableJVMCI) /* adapters and nmethods */ \ - // END -#else -#define AOTCODECACHE_CONFIGS_JVMCI_DO(do_var, do_fun) -#endif - #if defined(AARCH64) && !defined(ZERO) #define AOTCODECACHE_CONFIGS_AARCH64_DO(do_var, do_fun) \ do_var(intx, BlockZeroingLowLimit) /* array fill stubs */ \ @@ -359,7 +351,6 @@ public: #define AOTCODECACHE_CONFIGS_DO(do_var, do_fun) \ AOTCODECACHE_CONFIGS_GENERIC_DO(do_var, do_fun) \ AOTCODECACHE_CONFIGS_COMPILER2_DO(do_var, do_fun) \ - AOTCODECACHE_CONFIGS_JVMCI_DO(do_var, do_fun) \ AOTCODECACHE_CONFIGS_AARCH64_DO(do_var, do_fun) \ AOTCODECACHE_CONFIGS_X86_DO(do_var, do_fun) \ // END diff --git a/src/hotspot/share/code/codeBlob.hpp b/src/hotspot/share/code/codeBlob.hpp index 709623de308..30e264fbd57 100644 --- a/src/hotspot/share/code/codeBlob.hpp +++ b/src/hotspot/share/code/codeBlob.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,7 +109,6 @@ class UncommonTrapBlob; class CodeBlob { friend class VMStructs; - friend class JVMCIVMStructs; protected: // order fields from large to small to minimize padding between fields @@ -578,7 +577,7 @@ class SingletonBlob: public RuntimeBlob { class DeoptimizationBlob: public SingletonBlob { friend class VMStructs; - friend class JVMCIVMStructs; + private: int _unpack_offset; int _unpack_with_exception; @@ -586,12 +585,6 @@ class DeoptimizationBlob: public SingletonBlob { int _unpack_with_exception_in_tls; -#if INCLUDE_JVMCI - // Offsets when JVMCI calls uncommon_trap. - int _uncommon_trap_offset; - int _implicit_exception_uncommon_trap_offset; -#endif - // Creation support DeoptimizationBlob( CodeBuffer* cb, @@ -604,7 +597,7 @@ class DeoptimizationBlob: public SingletonBlob { ); public: - static const int ENTRY_COUNT = 4 JVMCI_ONLY(+ 2); + static const int ENTRY_COUNT = 4; // Creation static DeoptimizationBlob* create( CodeBuffer* cb, @@ -630,21 +623,6 @@ class DeoptimizationBlob: public SingletonBlob { } address unpack_with_exception_in_tls() const { return code_begin() + _unpack_with_exception_in_tls; } -#if INCLUDE_JVMCI - // Offsets when JVMCI calls uncommon_trap. - void set_uncommon_trap_offset(int offset) { - _uncommon_trap_offset = offset; - assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob"); - } - address uncommon_trap() const { return (EnableJVMCI ? code_begin() + _uncommon_trap_offset : nullptr); } - - void set_implicit_exception_uncommon_trap_offset(int offset) { - _implicit_exception_uncommon_trap_offset = offset; - assert(contains(code_begin() + _implicit_exception_uncommon_trap_offset), "must be PC inside codeblob"); - } - address implicit_exception_uncommon_trap() const { return (EnableJVMCI ? code_begin() + _implicit_exception_uncommon_trap_offset : nullptr); } -#endif // INCLUDE_JVMCI - void post_restore_impl() { trace_new_stub(this, "DeoptimizationBlob"); } diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index ffa88a88b29..dd51db321b1 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -1916,13 +1916,8 @@ void CodeCache::print_codelist(outputStream* st) { nmethod* nm = iter.method(); ResourceMark rm; char* method_name = nm->method()->name_and_sig_as_C_string(); - const char* jvmci_name = nullptr; -#if INCLUDE_JVMCI - jvmci_name = nm->jvmci_name(); -#endif - st->print_cr("%d %d %d %s%s%s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]", - nm->compile_id(), nm->comp_level(), nm->get_state(), - method_name, jvmci_name ? " jvmci_name=" : "", jvmci_name ? jvmci_name : "", + st->print_cr("%d %d %d %s [" INTPTR_FORMAT ", " INTPTR_FORMAT " - " INTPTR_FORMAT "]", + nm->compile_id(), nm->comp_level(), nm->get_state(), method_name, (intptr_t)nm->header_begin(), (intptr_t)nm->code_begin(), (intptr_t)nm->code_end()); } } @@ -1965,19 +1960,14 @@ void CodeCache::write_perf_map(const char* filename, outputStream* st) { CodeBlob *cb = iter.method(); ResourceMark rm; const char* method_name = nullptr; - const char* jvmci_name = nullptr; if (cb->is_nmethod()) { nmethod* nm = cb->as_nmethod(); method_name = nm->method()->external_name(); -#if INCLUDE_JVMCI - jvmci_name = nm->jvmci_name(); -#endif } else { method_name = cb->name(); } - fs.print_cr(INTPTR_FORMAT " " INTPTR_FORMAT " %s%s%s", - (intptr_t)cb->code_begin(), (intptr_t)cb->code_size(), - method_name, jvmci_name ? " jvmci_name=" : "", jvmci_name ? jvmci_name : ""); + fs.print_cr(INTPTR_FORMAT " " INTPTR_FORMAT " %s", + (intptr_t)cb->code_begin(), (intptr_t)cb->code_size(), method_name); } } #endif // LINUX diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp index 6384cb397b8..3b8aa5b2e58 100644 --- a/src/hotspot/share/code/codeCache.hpp +++ b/src/hotspot/share/code/codeCache.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,6 @@ class ReservedSpace; class CodeCache : AllStatic { friend class VMStructs; - friend class JVMCIVMStructs; template friend class CodeBlobIterator; friend class WhiteBox; friend class ShenandoahParallelCodeHeapIterator; diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index ea4a1519f79..a545285d1da 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -226,7 +226,7 @@ const char* blobTypeName[] = {"noType" , "buffer blob" , "lastType" }; -const char* compTypeName[] = { "none", "c1", "c2", "jvmci" }; +const char* compTypeName[] = { "none", "c1", "c2" }; // Be prepared for ten different CodeHeap segments. Should be enough for a few years. const unsigned int nSizeDistElements = 31; // logarithmic range growth, max size: 2**32 @@ -734,16 +734,6 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular } else { blob_name = os::strdup(cb->name()); } -#if INCLUDE_JVMCI - const char* jvmci_name = nm->jvmci_name(); - if (jvmci_name != nullptr) { - size_t size = ::strlen(blob_name) + ::strlen(" jvmci_name=") + ::strlen(jvmci_name) + 1; - char* new_blob_name = (char*)os::malloc(size, mtInternal); - os::snprintf_checked(new_blob_name, size, "%s jvmci_name=%s", blob_name, jvmci_name); - os::free((void*)blob_name); - blob_name = new_blob_name; - } -#endif nm_size = nm->total_size(); compile_id = nm->compile_id(); comp_lvl = (CompLevel)(nm->comp_level()); @@ -753,9 +743,6 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular if (nm->is_compiled_by_c2()) { cType = c2; } - if (nm->is_compiled_by_jvmci()) { - cType = jvmci; - } switch (cbType) { case nMethod_inuse: { // only for executable methods!!! // space for these cbs is accounted for later. @@ -2192,12 +2179,6 @@ void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) { ast->print("%s.", classNameS); ast->print("%s", methNameS); ast->print("%s", methSigS); -#if INCLUDE_JVMCI - const char* jvmci_name = nm->jvmci_name(); - if (jvmci_name != nullptr) { - ast->print(" jvmci_name=%s", jvmci_name); - } -#endif } else { ast->print("%s", blob_name); } diff --git a/src/hotspot/share/code/codeHeapState.hpp b/src/hotspot/share/code/codeHeapState.hpp index f30e492d7a5..cf0aef8d6e5 100644 --- a/src/hotspot/share/code/codeHeapState.hpp +++ b/src/hotspot/share/code/codeHeapState.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -38,7 +38,6 @@ class CodeHeapState : public CHeapObj { noComp = 0, // must be! due to initialization by memset to zero c1, c2, - jvmci, lastComp }; diff --git a/src/hotspot/share/code/compiledIC.hpp b/src/hotspot/share/code/compiledIC.hpp index f60ed93aa97..a42e09dc821 100644 --- a/src/hotspot/share/code/compiledIC.hpp +++ b/src/hotspot/share/code/compiledIC.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,6 @@ public: class CompiledICData : public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; Method* volatile _speculated_method; uintptr_t volatile _speculated_klass; diff --git a/src/hotspot/share/code/debugInfo.cpp b/src/hotspot/share/code/debugInfo.cpp index b6f58908c2c..6b9c668f997 100644 --- a/src/hotspot/share/code/debugInfo.cpp +++ b/src/hotspot/share/code/debugInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -345,9 +345,7 @@ void ConstantDoubleValue::print_on(outputStream* st) const { void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { #ifdef ASSERT { - // cannot use ThreadInVMfromNative here since in case of JVMCI compiler, - // thread is already in VM state. - ThreadInVMfromUnknown tiv; + ThreadInVMfromNative tiv(JavaThread::current()); assert(JNIHandles::resolve(value()) == nullptr || Universe::heap()->is_in(JNIHandles::resolve(value())), "Should be in heap"); @@ -358,9 +356,7 @@ void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { } void ConstantOopWriteValue::print_on(outputStream* st) const { - // using ThreadInVMfromUnknown here since in case of JVMCI compiler, - // thread is already in VM state. - ThreadInVMfromUnknown tiv; + ThreadInVMfromNative tiv(JavaThread::current()); JNIHandles::resolve(value())->print_value_on(st); } diff --git a/src/hotspot/share/code/dependencies.cpp b/src/hotspot/share/code/dependencies.cpp index dbfe1cd884e..16717984b01 100644 --- a/src/hotspot/share/code/dependencies.cpp +++ b/src/hotspot/share/code/dependencies.cpp @@ -65,9 +65,6 @@ void Dependencies::initialize(ciEnv* env) { _oop_recorder = env->oop_recorder(); _log = env->log(); _dep_seen = new(arena) GrowableArray(arena, 500, 0, 0); -#if INCLUDE_JVMCI - _using_dep_values = false; -#endif DEBUG_ONLY(_deps[end_marker] = nullptr); for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { _deps[i] = new(arena) GrowableArray(arena, 10, 0, nullptr); @@ -129,74 +126,6 @@ void Dependencies::assert_call_site_target_value(ciCallSite* call_site, ciMethod assert_common_2(call_site_target_value, call_site, method_handle); } -#if INCLUDE_JVMCI - -Dependencies::Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log) { - _oop_recorder = oop_recorder; - _log = log; - _dep_seen = new(arena) GrowableArray(arena, 500, 0, 0); - _using_dep_values = true; - DEBUG_ONLY(_dep_values[end_marker] = nullptr); - for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { - _dep_values[i] = new(arena) GrowableArray(arena, 10, 0, DepValue()); - } - _content_bytes = nullptr; - _size_in_bytes = (size_t)-1; - - assert(TYPE_LIMIT <= (1<is_array_klass()) { - // As a special case, support this assertion on an array type, - // which reduces to an assertion on its element type. - // Note that this cannot be done with assertions that - // relate to concreteness or abstractness. - BasicType elemt = ArrayKlass::cast(ctxk)->element_type(); - if (is_java_primitive(elemt)) return; // Ex: int[][] - ctxk = ObjArrayKlass::cast(ctxk)->bottom_klass(); - //if (ctxk->is_final()) return; // Ex: String[][] - } - check_ctxk(ctxk); - assert_common_1(leaf_type, DepValue(_oop_recorder, ctxk)); -} - -void Dependencies::assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck) { - check_ctxk_abstract(ctxk); - DepValue ctxk_dv(_oop_recorder, ctxk); - DepValue conck_dv(_oop_recorder, conck, &ctxk_dv); - assert_common_2(abstract_with_unique_concrete_subtype, ctxk_dv, conck_dv); -} - -void Dependencies::assert_unique_implementor(InstanceKlass* ctxk, InstanceKlass* uniqk) { - check_ctxk(ctxk); - assert(ctxk->is_interface(), "not an interface"); - assert(ctxk->implementor() == uniqk, "not a unique implementor"); - assert_common_2(unique_implementor, DepValue(_oop_recorder, ctxk), DepValue(_oop_recorder, uniqk)); -} - -void Dependencies::assert_unique_concrete_method(Klass* ctxk, Method* uniqm) { - check_ctxk(ctxk); - check_unique_method(ctxk, uniqm); - assert_common_2(unique_concrete_method_2, DepValue(_oop_recorder, ctxk), DepValue(_oop_recorder, uniqm)); -} - -void Dependencies::assert_call_site_target_value(oop call_site, oop method_handle) { - assert_common_2(call_site_target_value, DepValue(_oop_recorder, JNIHandles::make_local(call_site)), DepValue(_oop_recorder, JNIHandles::make_local(method_handle))); -} - -#endif // INCLUDE_JVMCI - - // Helper function. If we are adding a new dep. under ctxk2, // try to find an old dep. under a broader* ctxk1. If there is // @@ -303,79 +232,6 @@ void Dependencies::assert_common_4(DepType dept, deps->append(x3); } -#if INCLUDE_JVMCI -bool Dependencies::maybe_merge_ctxk(GrowableArray* deps, - int ctxk_i, DepValue ctxk2_dv) { - Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); - Klass* ctxk2 = ctxk2_dv.as_klass(_oop_recorder); - if (ctxk2->is_subtype_of(ctxk1)) { - return true; // success, and no need to change - } else if (ctxk1->is_subtype_of(ctxk2)) { - // new context class fully subsumes previous one - deps->at_put(ctxk_i, ctxk2_dv); - return true; - } else { - return false; - } -} - -void Dependencies::assert_common_1(DepType dept, DepValue x) { - assert(dep_args(dept) == 1, "sanity"); - //log_dependency(dept, x); - GrowableArray* deps = _dep_values[dept]; - - // see if the same (or a similar) dep is already recorded - if (note_dep_seen(dept, x)) { - assert(deps->find(x) >= 0, "sanity"); - } else { - deps->append(x); - } -} - -void Dependencies::assert_common_2(DepType dept, - DepValue x0, DepValue x1) { - assert(dep_args(dept) == 2, "sanity"); - //log_dependency(dept, x0, x1); - GrowableArray* deps = _dep_values[dept]; - - // see if the same (or a similar) dep is already recorded - bool has_ctxk = has_explicit_context_arg(dept); - if (has_ctxk) { - assert(dep_context_arg(dept) == 0, "sanity"); - if (note_dep_seen(dept, x1)) { - // look in this bucket for redundant assertions - const int stride = 2; - for (int i = deps->length(); (i -= stride) >= 0; ) { - DepValue y1 = deps->at(i+1); - if (x1 == y1) { // same subject; check the context - if (maybe_merge_ctxk(deps, i+0, x0)) { - return; - } - } - } - } - } else { - bool dep_seen_x0 = note_dep_seen(dept, x0); // records x0 for future queries - bool dep_seen_x1 = note_dep_seen(dept, x1); // records x1 for future queries - if (dep_seen_x0 && dep_seen_x1) { - // look in this bucket for redundant assertions - const int stride = 2; - for (int i = deps->length(); (i -= stride) >= 0; ) { - DepValue y0 = deps->at(i+0); - DepValue y1 = deps->at(i+1); - if (x0 == y0 && x1 == y1) { - return; - } - } - } - } - - // append the assertion in the correct bucket: - deps->append(x0); - deps->append(x1); -} -#endif // INCLUDE_JVMCI - /// Support for encoding dependencies into an nmethod: void Dependencies::copy_to(nmethod* nm) { @@ -402,40 +258,7 @@ static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) static int sort_dep_arg_4(ciBaseObject** p1, ciBaseObject** p2) { return sort_dep(p1, p2, 4); } -#if INCLUDE_JVMCI -// metadata deps are sorted before object deps -static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { - for (int i = 0; i < narg; i++) { - int diff = p1[i].sort_key() - p2[i].sort_key(); - if (diff != 0) return diff; - } - return 0; -} -static int sort_dep_value_arg_1(Dependencies::DepValue* p1, Dependencies::DepValue* p2) -{ return sort_dep_value(p1, p2, 1); } -static int sort_dep_value_arg_2(Dependencies::DepValue* p1, Dependencies::DepValue* p2) -{ return sort_dep_value(p1, p2, 2); } -static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) -{ return sort_dep_value(p1, p2, 3); } -#endif // INCLUDE_JVMCI - void Dependencies::sort_all_deps() { -#if INCLUDE_JVMCI - if (_using_dep_values) { - for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { - DepType dept = (DepType)deptv; - GrowableArray* deps = _dep_values[dept]; - if (deps->length() <= 1) continue; - switch (dep_args(dept)) { - case 1: deps->sort(sort_dep_value_arg_1, 1); break; - case 2: deps->sort(sort_dep_value_arg_2, 2); break; - case 3: deps->sort(sort_dep_value_arg_3, 3); break; - default: ShouldNotReachHere(); break; - } - } - return; - } -#endif // INCLUDE_JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray* deps = _deps[dept]; @@ -452,16 +275,6 @@ void Dependencies::sort_all_deps() { size_t Dependencies::estimate_size_in_bytes() { size_t est_size = 100; -#if INCLUDE_JVMCI - if (_using_dep_values) { - for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { - DepType dept = (DepType)deptv; - GrowableArray* deps = _dep_values[dept]; - est_size += deps->length() * 2; // tags and argument(s) - } - return est_size; - } -#endif // INCLUDE_JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray* deps = _deps[dept]; @@ -498,37 +311,6 @@ void Dependencies::encode_content_bytes() { // cast is safe, no deps can overflow INT_MAX CompressedWriteStream bytes((int)estimate_size_in_bytes()); -#if INCLUDE_JVMCI - if (_using_dep_values) { - for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { - DepType dept = (DepType)deptv; - GrowableArray* deps = _dep_values[dept]; - if (deps->length() == 0) continue; - int stride = dep_args(dept); - int ctxkj = dep_context_arg(dept); // -1 if no context arg - assert(stride > 0, "sanity"); - for (int i = 0; i < deps->length(); i += stride) { - jbyte code_byte = (jbyte)dept; - int skipj = -1; - if (ctxkj >= 0 && ctxkj+1 < stride) { - Klass* ctxk = deps->at(i+ctxkj+0).as_klass(_oop_recorder); - DepValue x = deps->at(i+ctxkj+1); // following argument - if (ctxk == ctxk_encoded_as_null(dept, x.as_metadata(_oop_recorder))) { - skipj = ctxkj; // we win: maybe one less oop to keep track of - code_byte |= default_context_type_bit; - } - } - bytes.write_byte(code_byte); - for (int j = 0; j < stride; j++) { - if (j == skipj) continue; - DepValue v = deps->at(i+j); - int idx = v.index(); - bytes.write_int(idx); - } - } - } - } else { -#endif // INCLUDE_JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray* deps = _deps[dept]; @@ -562,9 +344,6 @@ void Dependencies::encode_content_bytes() { } } } -#if INCLUDE_JVMCI - } -#endif // write a sentinel byte to mark the end bytes.write_byte(end_marker); diff --git a/src/hotspot/share/code/dependencies.hpp b/src/hotspot/share/code/dependencies.hpp index 582a08183f9..0eb0c1d8fe4 100644 --- a/src/hotspot/share/code/dependencies.hpp +++ b/src/hotspot/share/code/dependencies.hpp @@ -195,69 +195,10 @@ class Dependencies: public ResourceObj { static void check_valid_dependency_type(DepType dept); -#if INCLUDE_JVMCI - // A Metadata* or object value recorded in an OopRecorder - class DepValue { - private: - // Unique identifier of the value within the associated OopRecorder that - // encodes both the category of the value (0: invalid, positive: metadata, negative: object) - // and the index within a category specific array (metadata: index + 1, object: -(index + 1)) - int _id; - - public: - DepValue() : _id(0) {} - DepValue(OopRecorder* rec, Metadata* metadata, DepValue* candidate = nullptr) { - assert(candidate == nullptr || candidate->is_metadata(), "oops"); - if (candidate != nullptr && candidate->as_metadata(rec) == metadata) { - _id = candidate->_id; - } else { - _id = rec->find_index(metadata) + 1; - } - } - DepValue(OopRecorder* rec, jobject obj, DepValue* candidate = nullptr) { - assert(candidate == nullptr || candidate->is_object(), "oops"); - if (candidate != nullptr && candidate->as_object(rec) == obj) { - _id = candidate->_id; - } else { - _id = -(rec->find_index(obj) + 1); - } - } - - // Used to sort values in ascending order of index() with metadata values preceding object values - int sort_key() const { return -_id; } - - bool operator == (const DepValue& other) const { return other._id == _id; } - - bool is_valid() const { return _id != 0; } - int index() const { assert(is_valid(), "oops"); return _id < 0 ? -(_id + 1) : _id - 1; } - bool is_metadata() const { assert(is_valid(), "oops"); return _id > 0; } - bool is_object() const { assert(is_valid(), "oops"); return _id < 0; } - - Metadata* as_metadata(OopRecorder* rec) const { assert(is_metadata(), "oops"); return rec->metadata_at(index()); } - Klass* as_klass(OopRecorder* rec) const { - Metadata* m = as_metadata(rec); - assert(m != nullptr, "as_metadata returned nullptr"); - assert(m->is_klass(), "oops"); - return (Klass*) m; - } - Method* as_method(OopRecorder* rec) const { - Metadata* m = as_metadata(rec); - assert(m != nullptr, "as_metadata returned nullptr"); - assert(m->is_method(), "oops"); - return (Method*) m; - } - jobject as_object(OopRecorder* rec) const { assert(is_object(), "oops"); return rec->oop_at(index()); } - }; -#endif // INCLUDE_JVMCI - private: // State for writing a new set of dependencies: GrowableArray* _dep_seen; // (seen[h->ident] & (1<* _deps[TYPE_LIMIT]; -#if INCLUDE_JVMCI - bool _using_dep_values; - GrowableArray* _dep_values[TYPE_LIMIT]; -#endif static const char* _dep_name[TYPE_LIMIT]; static int _dep_args[TYPE_LIMIT]; @@ -276,25 +217,8 @@ class Dependencies: public ResourceObj { return (seen & (1<at_grow(x_id, 0); - _dep_seen->at_put(x_id, seen | (1<* deps, int ctxk_i, ciKlass* ctxk); -#if INCLUDE_JVMCI - bool maybe_merge_ctxk(GrowableArray* deps, - int ctxk_i, DepValue ctxk); -#endif void sort_all_deps(); size_t estimate_size_in_bytes(); @@ -316,9 +240,6 @@ class Dependencies: public ResourceObj { Dependencies(ciEnv* env) { initialize(env); } -#if INCLUDE_JVMCI - Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log); -#endif private: // Check for a valid context type. @@ -354,31 +275,6 @@ class Dependencies: public ResourceObj { void assert_unique_implementor(ciInstanceKlass* ctxk, ciInstanceKlass* uniqk); void assert_has_no_finalizable_subclasses(ciKlass* ctxk); void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle); -#if INCLUDE_JVMCI - private: - static void check_ctxk(Klass* ctxk) { - assert(ctxk->is_instance_klass(), "java types only"); - } - static void check_ctxk_abstract(Klass* ctxk) { - check_ctxk(ctxk); - assert(ctxk->is_abstract(), "must be abstract"); - } - static void check_unique_method(Klass* ctxk, Method* m) { - assert(!m->can_be_statically_bound(InstanceKlass::cast(ctxk)), "redundant"); - } - - void assert_common_1(DepType dept, DepValue x); - void assert_common_2(DepType dept, DepValue x0, DepValue x1); - - public: - void assert_evol_method(Method* m); - void assert_has_no_finalizable_subclasses(Klass* ctxk); - void assert_leaf_type(Klass* ctxk); - void assert_unique_implementor(InstanceKlass* ctxk, InstanceKlass* uniqk); - void assert_unique_concrete_method(Klass* ctxk, Method* uniqm); - void assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck); - void assert_call_site_target_value(oop callSite, oop methodHandle); -#endif // INCLUDE_JVMCI // Define whether a given method or type is concrete. // These methods define the term "concrete" as used in this module. diff --git a/src/hotspot/share/code/exceptionHandlerTable.hpp b/src/hotspot/share/code/exceptionHandlerTable.hpp index 9d7981f392c..1dfab530dad 100644 --- a/src/hotspot/share/code/exceptionHandlerTable.hpp +++ b/src/hotspot/share/code/exceptionHandlerTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,13 +155,6 @@ public: void set_size( uint size ); void append( uint exec_off, uint cont_off ); -#if INCLUDE_JVMCI - void add_deoptimize(uint exec_off) { - // Use the same offset as a marker value for deoptimization - append(exec_off, exec_off); - } -#endif - // Returns the offset to continue execution at. If the returned // value equals exec_off then the dispatch is expected to be a // deoptimization instead. diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 3a449c747ca..27f01797d39 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -86,9 +86,6 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/hashTable.hpp" #include "utilities/xmlstream.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciRuntime.hpp" -#endif #ifdef DTRACE_ENABLED @@ -144,10 +141,6 @@ struct java_nmethod_stats_struct { uint handler_table_size; uint scopes_pcs_size; uint scopes_data_size; -#if INCLUDE_JVMCI - uint speculations_size; - uint jvmci_data_size; -#endif void note_nmethod(nmethod* nm) { nmethod_count += 1; @@ -165,10 +158,6 @@ struct java_nmethod_stats_struct { dependencies_size += nm->dependencies_size(); handler_table_size += nm->handler_table_size(); nul_chk_table_size += nm->nul_chk_table_size(); -#if INCLUDE_JVMCI - speculations_size += nm->speculations_size(); - jvmci_data_size += nm->jvmci_data_size(); -#endif } void print_nmethod_stats(const char* name) { if (nmethod_count == 0) return; @@ -203,11 +192,6 @@ struct java_nmethod_stats_struct { if (metadata_size != 0) { tty->print_cr(" metadata = %u (%f%%)", metadata_size, (metadata_size * 100.0f)/total_mut_size); } -#if INCLUDE_JVMCI - if (jvmci_data_size != 0) { - tty->print_cr(" JVMCI data = %u (%f%%)", jvmci_data_size, (jvmci_data_size * 100.0f)/total_mut_size); - } -#endif if (total_immut_size != 0) { tty->print_cr(" immutable data = %u (%f%%)", total_immut_size, (total_immut_size * 100.0f)/total_size); } @@ -226,11 +210,6 @@ struct java_nmethod_stats_struct { if (scopes_data_size != 0) { tty->print_cr(" scopes data = %u (%f%%)", scopes_data_size, (scopes_data_size * 100.0f)/total_immut_size); } -#if INCLUDE_JVMCI - if (speculations_size != 0) { - tty->print_cr(" speculations = %u (%f%%)", speculations_size, (speculations_size * 100.0f)/total_immut_size); - } -#endif } }; @@ -289,9 +268,6 @@ static java_nmethod_stats_struct c1_java_nmethod_stats; #ifdef COMPILER2 static java_nmethod_stats_struct c2_java_nmethod_stats; #endif -#if INCLUDE_JVMCI -static java_nmethod_stats_struct jvmci_java_nmethod_stats; -#endif static java_nmethod_stats_struct unknown_java_nmethod_stats; static native_nmethod_stats_struct native_nmethod_stats; @@ -307,11 +283,6 @@ static void note_java_nmethod(nmethod* nm) { if (nm->is_compiled_by_c2()) { c2_java_nmethod_stats.note_nmethod(nm); } else -#endif -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - jvmci_java_nmethod_stats.note_nmethod(nm); - } else #endif { unknown_java_nmethod_stats.note_nmethod(nm); @@ -926,7 +897,7 @@ void nmethod::cleanup_inline_caches_impl(bool unloading_occurred, bool clean_all } } -address nmethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { +address nmethod::continuation_for_implicit_exception(address pc) { // Exception happened outside inline-cache check code => we are inside // an active nmethod => use cpc to determine a return address int exception_offset = int(pc - code_begin()); @@ -953,18 +924,7 @@ address nmethod::continuation_for_implicit_exception(address pc, bool for_div0_c // Let the normal error handling report the exception return nullptr; } - if (cont_offset == exception_offset) { -#if INCLUDE_JVMCI - Deoptimization::DeoptReason deopt_reason = for_div0_check ? Deoptimization::Reason_div0_check : Deoptimization::Reason_null_check; - JavaThread *thread = JavaThread::current(); - thread->set_jvmci_implicit_exception_pc(pc); - thread->set_pending_deoptimization(Deoptimization::make_trap_request(deopt_reason, - Deoptimization::Action_reinterpret)); - return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); -#else - ShouldNotReachHere(); -#endif - } + guarantee(cont_offset != exception_offset, "continuation offset and exception offset must be different"); return code_begin() + cont_offset; } @@ -1062,11 +1022,9 @@ static void assert_no_oops_or_metadata(nmethod* nm) { } #endif -static int required_mutable_data_size(CodeBuffer* code_buffer, - int jvmci_data_size = 0) { +static int required_mutable_data_size(CodeBuffer* code_buffer) { return align_up(code_buffer->total_relocation_size(), oopSize) + - align_up(code_buffer->total_metadata_size(), oopSize) + - align_up(jvmci_data_size, oopSize); + align_up(code_buffer->total_metadata_size(), oopSize); } nmethod* nmethod::new_native_nmethod(const methodHandle& method, @@ -1131,13 +1089,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, CompLevel comp_level, - Flags flags -#if INCLUDE_JVMCI - , char* speculations, - int speculations_len, - JVMCINMethodData* jvmci_data -#endif -) + Flags flags) { assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); code_buffer->finalize_oop_references(method); @@ -1150,9 +1102,6 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, + align_up((int)dependencies->size_in_bytes(), oopSize) + align_up(handler_table->size_in_bytes() , oopSize) + align_up(nul_chk_table->size_in_bytes() , oopSize) -#if INCLUDE_JVMCI - + align_up(speculations_len , oopSize) -#endif + align_up(debug_info->data_size() , oopSize); // First, allocate space for immutable data in C heap. @@ -1166,8 +1115,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, } } - int mutable_data_size = required_mutable_data_size(code_buffer - JVMCI_ONLY(COMMA (compiler->is_jvmci() ? jvmci_data->size() : 0))); + int mutable_data_size = required_mutable_data_size(code_buffer); { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); @@ -1176,14 +1124,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, nmethod(method(), compiler->type(), nmethod_size, immutable_data_size, mutable_data_size, compile_id, entry_bci, immutable_data, offsets, orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, oop_maps, - handler_table, nul_chk_table, compiler, comp_level, - flags -#if INCLUDE_JVMCI - , speculations, - speculations_len, - jvmci_data -#endif - ); + handler_table, nul_chk_table, compiler, comp_level, flags); if (nm != nullptr) { // To make dependency checking during class loading fast, record @@ -1317,7 +1258,6 @@ nmethod::nmethod( _unwind_handler_offset = 0; int metadata_size = align_up(code_buffer->total_metadata_size(), wordSize); - JVMCI_ONLY( _metadata_size = metadata_size; ) assert(_mutable_data_size == _relocation_size + metadata_size, "wrong mutable data size: %d != %d + %d", _mutable_data_size, _relocation_size, metadata_size); @@ -1329,9 +1269,6 @@ nmethod::nmethod( _handler_table_offset = 0; _scopes_pcs_offset = 0; _scopes_data_offset = 0; -#if INCLUDE_JVMCI - _speculations_offset = 0; -#endif _immutable_data_ref_count_offset = 0; code_buffer->copy_code_and_locs_to(this); @@ -1455,16 +1392,10 @@ nmethod::nmethod(const nmethod &nm) : CodeBlob(nm._name, nm._kind, nm._size, nm. _deopt_handler_entry_offset = nm._deopt_handler_entry_offset; _unwind_handler_offset = nm._unwind_handler_offset; _num_stack_arg_slots = nm._num_stack_arg_slots; -#if INCLUDE_JVMCI - _metadata_size = nm._metadata_size; -#endif _nul_chk_table_offset = nm._nul_chk_table_offset; _handler_table_offset = nm._handler_table_offset; _scopes_pcs_offset = nm._scopes_pcs_offset; _scopes_data_offset = nm._scopes_data_offset; -#if INCLUDE_JVMCI - _speculations_offset = nm._speculations_offset; -#endif _immutable_data_ref_count_offset = nm._immutable_data_ref_count_offset; // Increment number of references to immutable data to share it between nmethods @@ -1626,12 +1557,6 @@ bool nmethod::is_relocatable() { return false; } -#if INCLUDE_JVMCI - if (jvmci_nmethod_data() != nullptr && jvmci_nmethod_data()->has_mirror()) { - return false; - } -#endif - if (is_unloading()) { return false; } @@ -1680,13 +1605,7 @@ nmethod::nmethod( ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, CompLevel comp_level, - Flags flags -#if INCLUDE_JVMCI - , char* speculations, - int speculations_len, - JVMCINMethodData* jvmci_data -#endif - ) + Flags flags) : CodeBlob("nmethod", CodeBlobKind::Nmethod, code_buffer, nmethod_size, sizeof(nmethod), offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, mutable_data_size), _deoptimization_generation(0), @@ -1713,36 +1632,20 @@ nmethod::nmethod( set_ctable_begin(header_begin() + content_offset()); -#if INCLUDE_JVMCI - if (compiler->is_jvmci()) { - // JVMCI might not produce any stub sections - if (offsets->value(CodeOffsets::Exceptions) != -1) { - _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions); - } else { - _exception_offset = -1; - } - if (offsets->value(CodeOffsets::Deopt) != -1) { - _deopt_handler_entry_offset = code_offset() + offsets->value(CodeOffsets::Deopt); - } else { - _deopt_handler_entry_offset = -1; - } - } else -#endif - { - // Exception handler and deopt handler are in the stub section - assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set"); + // Exception handler and deopt handler are in the stub section + assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set"); - bool has_exception_handler = (offsets->value(CodeOffsets::Exceptions) != -1); - assert(has_exception_handler == (compiler->type() != compiler_c2), - "C2 compiler doesn't provide exception handler stub code."); - if (has_exception_handler) { - _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); - } else { - _exception_offset = -1; - } - - _deopt_handler_entry_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); + bool has_exception_handler = (offsets->value(CodeOffsets::Exceptions) != -1); + assert(has_exception_handler == (compiler->type() != compiler_c2), + "C2 compiler doesn't provide exception handler stub code."); + if (has_exception_handler) { + _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); + } else { + _exception_offset = -1; } + + _deopt_handler_entry_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); + if (offsets->value(CodeOffsets::UnwindHandler) != -1) { // C1 generates UnwindHandler at the end of instructions section. // Calculate positive offset as distance between the start of stubs section @@ -1754,11 +1657,9 @@ nmethod::nmethod( } int metadata_size = align_up(code_buffer->total_metadata_size(), wordSize); - JVMCI_ONLY( _metadata_size = metadata_size; ) - int jvmci_data_size = 0 JVMCI_ONLY( + align_up(compiler->is_jvmci() ? jvmci_data->size() : 0, oopSize)); - assert(_mutable_data_size == _relocation_size + metadata_size + jvmci_data_size, - "wrong mutable data size: %d != %d + %d + %d", - _mutable_data_size, _relocation_size, metadata_size, jvmci_data_size); + assert(_mutable_data_size == _relocation_size + metadata_size, + "wrong mutable data size: %d != %d + %d", + _mutable_data_size, _relocation_size, metadata_size); assert(nmethod_size == data_end() - header_begin(), "wrong nmethod size: %d != %d", nmethod_size, (int)(code_end() - header_begin())); @@ -1775,12 +1676,7 @@ nmethod::nmethod( _scopes_pcs_offset = _handler_table_offset + align_up(handler_table->size_in_bytes(), oopSize); _scopes_data_offset = _scopes_pcs_offset + adjust_pcs_size(debug_info->pcs_size()); -#if INCLUDE_JVMCI - _speculations_offset = _scopes_data_offset + align_up(debug_info->data_size(), oopSize); - _immutable_data_ref_count_offset = _speculations_offset + align_up(speculations_len, oopSize); -#else _immutable_data_ref_count_offset = _scopes_data_offset + align_up(debug_info->data_size(), oopSize); -#endif DEBUG_ONLY( int immutable_data_end_offset = _immutable_data_ref_count_offset + ImmutableDataRefCountSize; ) assert(immutable_data_end_offset <= immutable_data_size, "wrong read-only data size: %d > %d", immutable_data_end_offset, immutable_data_size); @@ -1796,30 +1692,17 @@ nmethod::nmethod( // Create cache after PcDesc data is copied - it will be used to initialize cache _pc_desc_container = new PcDescContainer(scopes_pcs_begin()); -#if INCLUDE_JVMCI - if (compiler->is_jvmci()) { - // Initialize the JVMCINMethodData object inlined into nm - jvmci_nmethod_data()->copy(jvmci_data); - } -#endif - // Copy contents of ExceptionHandlerTable to nmethod handler_table->copy_to(this); nul_chk_table->copy_to(this); -#if INCLUDE_JVMCI - // Copy speculations to nmethod - if (speculations_size() != 0) { - memcpy(speculations_begin(), speculations, speculations_len); - } -#endif init_immutable_data_ref_count(); post_init(); // we use the information of entry points to find out if a method is // static or non static - assert(compiler->is_c2() || compiler->is_jvmci() || + assert(compiler->is_c2() || _method->is_static() == (entry_point() == verified_entry_point()), " entry points must be same for static methods and vice versa"); } @@ -1835,16 +1718,6 @@ void nmethod::log_identity(xmlStream* log) const { if (TieredCompilation) { log->print(" level='%d'", comp_level()); } -#if INCLUDE_JVMCI - if (jvmci_nmethod_data() != nullptr) { - const char* jvmci_name = jvmci_nmethod_data()->name(); - if (jvmci_name != nullptr) { - log->print(" jvmci_mirror_name='"); - log->text("%s", jvmci_name); - log->print("'"); - } - } -#endif } @@ -1953,10 +1826,6 @@ void nmethod::print_nmethod(bool printmethod) { tty->cr(); tty->print_cr("============================= C1-compiled nmethod =============================="); } - if (is_compiled_by_jvmci()) { - tty->cr(); - tty->print_cr("=========================== JVMCI-compiled nmethod ============================="); - } tty->print_cr("----------------------------------- Assembly -----------------------------------"); decode2(tty); #if defined(SUPPORT_DATA_STRUCTS) @@ -2248,13 +2117,10 @@ bool nmethod::is_maybe_on_stack() { } void nmethod::inc_decompile_count() { - if (!is_compiled_by_c2() && !is_compiled_by_jvmci()) return; - // Could be gated by ProfileTraps, but do not bother... -#if INCLUDE_JVMCI - if (jvmci_skip_profile_deopt()) { + if (!is_compiled_by_c2()) { return; } -#endif + // Could be gated by ProfileTraps, but do not bother... Method* m = method(); if (m == nullptr) return; MethodData* mdo = m->method_data(); @@ -2378,14 +2244,6 @@ bool nmethod::make_not_entrant(InvalidationReason invalidation_reason) { } // leave critical region under NMethodState_lock -#if INCLUDE_JVMCI - // Invalidate can't occur while holding the NMethodState_lock - JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); - if (nmethod_data != nullptr) { - nmethod_data->invalidate_nmethod_mirror(this, invalidation_reason); - } -#endif - #ifdef ASSERT if (is_osr_method() && method() != nullptr) { // Make sure osr nmethod is invalidated, i.e. not on the list @@ -2416,16 +2274,6 @@ void nmethod::unlink() { invalidate_osr_method(); } -#if INCLUDE_JVMCI - // Clear the link between this nmethod and a HotSpotNmethod mirror - JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); - if (nmethod_data != nullptr) { - nmethod_data->invalidate_nmethod_mirror(this, is_cold() ? - nmethod::InvalidationReason::UNLOADING_COLD : - nmethod::InvalidationReason::UNLOADING); - } -#endif - // Post before flushing as jmethodID is being used post_compiled_method_unload(); @@ -2488,7 +2336,6 @@ void nmethod::purge(bool unregister_nmethod) { CodeCache::unregister_old_nmethod(this); - JVMCI_ONLY( _metadata_size = 0; ) CodeBlob::purge(); } @@ -3305,30 +3152,6 @@ void nmethod::verify() { } } -#ifdef ASSERT -#if INCLUDE_JVMCI - { - // Verify that implicit exceptions that deoptimize have a PcDesc and OopMap - ImmutableOopMapSet* oms = oop_maps(); - ImplicitExceptionTable implicit_table(this); - for (uint i = 0; i < implicit_table.len(); i++) { - int exec_offset = (int) implicit_table.get_exec_offset(i); - if (implicit_table.get_exec_offset(i) == implicit_table.get_cont_offset(i)) { - assert(pc_desc_at(code_begin() + exec_offset) != nullptr, "missing PcDesc"); - bool found = false; - for (int i = 0, imax = oms->count(); i < imax; i++) { - if (oms->pair_at(i)->pc_offset() == exec_offset) { - found = true; - break; - } - } - assert(found, "missing oopmap"); - } - } - } -#endif -#endif - VerifyOopsClosure voc(this); oops_do(&voc); assert(voc.ok(), "embedded oops must be OK"); @@ -3422,8 +3245,6 @@ void nmethod::print_on_impl(outputStream* st) const { st->print("(c1) "); } else if (is_compiled_by_c2()) { st->print("(c2) "); - } else if (is_compiled_by_jvmci()) { - st->print("(JVMCI) "); } else { st->print("(n/a) "); } @@ -3469,12 +3290,6 @@ void nmethod::print_on_impl(outputStream* st) const { p2i(metadata_begin()), p2i(metadata_end()), metadata_size()); -#if INCLUDE_JVMCI - if (jvmci_data_size () > 0) st->print_cr(" JVMCI data [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d", - p2i(jvmci_data_begin()), - p2i(jvmci_data_end()), - jvmci_data_size()); -#endif if (immutable_data_size() > 0) st->print_cr(" immutable data [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d", p2i(immutable_data_begin()), p2i(immutable_data_end()), @@ -3499,12 +3314,6 @@ void nmethod::print_on_impl(outputStream* st) const { p2i(scopes_data_begin()), p2i(scopes_data_end()), scopes_data_size()); -#if INCLUDE_JVMCI - if (speculations_size () > 0) st->print_cr(" speculations [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d", - p2i(speculations_begin()), - p2i(speculations_end()), - speculations_size()); -#endif } void nmethod::print_code() { @@ -4077,8 +3886,8 @@ const char* nmethod::nmethod_section_label(address pos) const { if (pos == consts_begin() && pos != insts_begin()) label = "[Constants]"; // Check stub_code before checking exception_handler or deopt_handler. if (pos == this->stub_begin()) label = "[Stub Code]"; - if (JVMCI_ONLY(_exception_offset >= 0 &&) pos == exception_begin()) label = "[Exception Handler]"; - if (JVMCI_ONLY(_deopt_handler_entry_offset != -1 &&) pos == deopt_handler_entry()) label = "[Deopt Handler Entry Point]"; + if (pos == exception_begin()) label = "[Exception Handler]"; + if (pos == deopt_handler_entry()) label = "[Deopt Handler Entry Point]"; return label; } @@ -4229,12 +4038,7 @@ void nmethod::print_code_comment_on(outputStream* st, int column, address begin, const ImmutableOopMap* om = pair->get_from(oms); address pc = base + pair->pc_offset(); if (pc >= begin) { -#if INCLUDE_JVMCI - bool is_implicit_deopt = implicit_table.continuation_offset(pair->pc_offset()) == (uint) pair->pc_offset(); -#else - bool is_implicit_deopt = false; -#endif - if (is_implicit_deopt ? pc == begin : pc > begin && pc <= end) { + if (pc > begin && pc <= end) { st->move_to(column, 6, 0); st->print("; "); om->print_on(st); @@ -4428,9 +4232,6 @@ void nmethod::print_statistics() { #endif #ifdef COMPILER2 c2_java_nmethod_stats.print_nmethod_stats("C2"); -#endif -#if INCLUDE_JVMCI - jvmci_java_nmethod_stats.print_nmethod_stats("JVMCI"); #endif unknown_java_nmethod_stats.print_nmethod_stats("Unknown"); DebugInformationRecorder::print_statistics(); @@ -4441,25 +4242,3 @@ void nmethod::print_statistics() { } #endif // !PRODUCT - -#if INCLUDE_JVMCI -void nmethod::update_speculation(JavaThread* thread) { - jlong speculation = thread->pending_failed_speculation(); - if (speculation != 0) { - guarantee(jvmci_nmethod_data() != nullptr, "failed speculation in nmethod without failed speculation list"); - jvmci_nmethod_data()->add_failed_speculation(this, speculation); - thread->set_pending_failed_speculation(0); - } -} - -const char* nmethod::jvmci_name() { - if (jvmci_nmethod_data() != nullptr) { - return jvmci_nmethod_data()->name(); - } - return nullptr; -} - -bool nmethod::jvmci_skip_profile_deopt() const { - return jvmci_nmethod_data() != nullptr && !jvmci_nmethod_data()->profile_deopt(); -} -#endif diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index 540b24f5c78..86db3603966 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,7 +146,6 @@ public: // As a CodeBlob, an nmethod references [mutable data] allocated on the C heap: // - CodeBlob relocation data // - Metainfo -// - JVMCI data // // An nmethod references [immutable data] allocated on C heap: // - Dependency assertions data @@ -155,19 +154,11 @@ public: // - Debugging information: // - Scopes data array // - Scopes pcs array -// - JVMCI speculations array // - Nmethod reference counter -#if INCLUDE_JVMCI -class FailedSpeculation; -class JVMCINMethodData; -#endif - class nmethod : public CodeBlob { friend class VMStructs; - friend class JVMCIVMStructs; friend class CodeCache; // scavengable oops - friend class JVMCINMethodData; friend class DeoptimizationScope; #define ImmutableDataRefCountSize ((int)sizeof(int)) @@ -236,21 +227,12 @@ class nmethod : public CodeBlob { // Number of arguments passed on the stack uint16_t _num_stack_arg_slots; -#if INCLUDE_JVMCI - // _metadata_size is not specific to JVMCI. In the non-JVMCI case, it can be derived as: - // _metadata_size = mutable_data_size - relocation_size - int _metadata_size; -#endif - // Offset in immutable data section // _dependencies_offset == 0 uint16_t _nul_chk_table_offset; uint16_t _handler_table_offset; // This table could be big in C1 code int _scopes_pcs_offset; int _scopes_data_offset; -#if INCLUDE_JVMCI - int _speculations_offset; -#endif int _immutable_data_ref_count_offset; // location in frame (offset for sp) that deopt can store the original @@ -364,13 +346,7 @@ private: ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, CompLevel comp_level, - Flags flags -#if INCLUDE_JVMCI - , char* speculations = nullptr, - int speculations_len = 0, - JVMCINMethodData* jvmci_data = nullptr -#endif - ); + Flags flags); nmethod(const nmethod &nm); @@ -511,8 +487,6 @@ private: void oops_do_set_strong_done(nmethod* old_head); public: - // If you change anything in this enum please patch - // vmStructs_jvmci.cpp accordingly. enum class InvalidationReason : s1 { NOT_INVALIDATED = -1, C1_CODEPATCH, @@ -522,10 +496,6 @@ public: CI_REPLAY, UNLOADING, UNLOADING_COLD, - JVMCI_INVALIDATE, - JVMCI_MATERIALIZE_VIRTUAL_OBJECT, - JVMCI_REPLACED_WITH_NEW_CODE, - JVMCI_REPROFILE, MARKED_FOR_DEOPTIMIZATION, MISSING_EXCEPTION_HANDLER, NOT_USED, @@ -553,14 +523,6 @@ public: return "C1 predicate failed trap"; case InvalidationReason::CI_REPLAY: return "CI replay"; - case InvalidationReason::JVMCI_INVALIDATE: - return "JVMCI invalidate"; - case InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT: - return "JVMCI materialize virtual object"; - case InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE: - return "JVMCI replaced with new code"; - case InvalidationReason::JVMCI_REPROFILE: - return "JVMCI reprofile"; case InvalidationReason::MARKED_FOR_DEOPTIMIZATION: return "marked for deoptimization"; case InvalidationReason::MISSING_EXCEPTION_HANDLER: @@ -605,13 +567,7 @@ public: ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, CompLevel comp_level, - Flags flags -#if INCLUDE_JVMCI - , char* speculations = nullptr, - int speculations_len = 0, - JVMCINMethodData* jvmci_data = nullptr -#endif - ); + Flags flags); // Relocate the nmethod to the code heap identified by code_blob_type. // Returns nullptr if the code heap does not have enough space, the @@ -646,7 +602,6 @@ public: inline bool is_compiled_by_c1 () const { return _compiler_type == compiler_c1; } inline bool is_compiled_by_c2 () const { return _compiler_type == compiler_c2; } - inline bool is_compiled_by_jvmci() const { return _compiler_type == compiler_jvmci; } CompilerType compiler_type () const { return _compiler_type; } const char* compiler_name () const; @@ -665,13 +620,7 @@ public: // mutable data Metadata** metadata_begin () const { return (Metadata**) (mutable_data_begin() + _relocation_size); } -#if INCLUDE_JVMCI - Metadata** metadata_end () const { return (Metadata**) (mutable_data_begin() + _relocation_size + _metadata_size); } - address jvmci_data_begin () const { return mutable_data_begin() + _relocation_size + _metadata_size; } - address jvmci_data_end () const { return mutable_data_end(); } -#else Metadata** metadata_end () const { return (Metadata**) mutable_data_end(); } -#endif // immutable data address immutable_data_begin () const { return _immutable_data; } @@ -686,13 +635,7 @@ public: PcDesc* scopes_pcs_end () const { return (PcDesc*)(_immutable_data + _scopes_data_offset) ; } address scopes_data_begin () const { return _immutable_data + _scopes_data_offset ; } -#if INCLUDE_JVMCI - address scopes_data_end () const { return _immutable_data + _speculations_offset ; } - address speculations_begin () const { return _immutable_data + _speculations_offset ; } - address speculations_end () const { return _immutable_data + _immutable_data_ref_count_offset ; } -#else address scopes_data_end () const { return _immutable_data + _immutable_data_ref_count_offset ; } -#endif address immutable_data_ref_count_begin () const { return _immutable_data + _immutable_data_ref_count_offset ; } // Sizes @@ -707,10 +650,6 @@ public: int dependencies_size () const { return int( dependencies_end () - dependencies_begin ()); } int handler_table_size () const { return int( handler_table_end() - handler_table_begin()); } int nul_chk_table_size () const { return int( nul_chk_table_end() - nul_chk_table_begin()); } -#if INCLUDE_JVMCI - int speculations_size () const { return int( speculations_end () - speculations_begin ()); } - int jvmci_data_size () const { return int( jvmci_data_end () - jvmci_data_begin ()); } -#endif int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; } int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; } @@ -879,15 +818,12 @@ public: void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f); // implicit exceptions support - address continuation_for_implicit_div0_exception(address pc) { return continuation_for_implicit_exception(pc, true); } - address continuation_for_implicit_null_exception(address pc) { return continuation_for_implicit_exception(pc, false); } + address continuation_for_implicit_exception(address pc); // Inline cache support for class unloading and nmethod unloading private: void cleanup_inline_caches_impl(bool unloading_occurred, bool clean_all); - address continuation_for_implicit_exception(address pc, bool for_div0_check); - public: // Serial version used by whitebox test void cleanup_inline_caches_whitebox(); @@ -938,26 +874,6 @@ public: // Evolution support. We make old (discarded) compiled methods point to new Method*s. void set_method(Method* method) { _method = method; } -#if INCLUDE_JVMCI - // Gets the JVMCI name of this nmethod. - const char* jvmci_name(); - - // Records the pending failed speculation in the - // JVMCI speculation log associated with this nmethod. - void update_speculation(JavaThread* thread); - - // Gets the data specific to a JVMCI compiled method. - // This returns a non-nullptr value iff this nmethod was - // compiled by the JVMCI compiler. - JVMCINMethodData* jvmci_nmethod_data() const { - return jvmci_data_size() == 0 ? nullptr : (JVMCINMethodData*) jvmci_data_begin(); - } - - // Returns true if the runtime should NOT collect deoptimization profile for a JVMCI - // compiled method - bool jvmci_skip_profile_deopt() const; -#endif - void oops_do(OopClosure* f); // All-in-one claiming of nmethods: returns true if the caller successfully claimed that diff --git a/src/hotspot/share/code/scopeDesc.cpp b/src/hotspot/share/code/scopeDesc.cpp index d3e08a886e6..5038cd282e2 100644 --- a/src/hotspot/share/code/scopeDesc.cpp +++ b/src/hotspot/share/code/scopeDesc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -263,8 +263,8 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { } } -#if COMPILER2_OR_JVMCI - if (NOT_JVMCI(DoEscapeAnalysis &&) is_top() && _objects != nullptr) { +#ifdef COMPILER2 + if (DoEscapeAnalysis && is_top() && _objects != nullptr) { st->print_cr(" Objects"); for (int i = 0; i < _objects->length(); i++) { ObjectValue* sv = (ObjectValue*) _objects->at(i); @@ -278,7 +278,7 @@ void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { st->cr(); } } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } #endif diff --git a/src/hotspot/share/compiler/abstractCompiler.hpp b/src/hotspot/share/compiler/abstractCompiler.hpp index 5b97feb1a49..5ed256d640c 100644 --- a/src/hotspot/share/compiler/abstractCompiler.hpp +++ b/src/hotspot/share/compiler/abstractCompiler.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,12 +146,8 @@ class AbstractCompiler : public CHeapObj { // Compiler type queries. bool is_c1() const { return _type == compiler_c1; } bool is_c2() const { return _type == compiler_c2; } - bool is_jvmci() const { return _type == compiler_jvmci; } CompilerType type() const { return _type; } - // Compiler threads are hidden by default. - virtual bool is_hidden_from_external_view() const { return true; } - // Customization virtual void initialize () = 0; @@ -168,18 +164,6 @@ class AbstractCompiler : public CHeapObj { ShouldNotReachHere(); } - // Notifies this compiler that the current thread (`current`) is about to stop. - // The current thread currently holds the CompileThread_lock. - virtual void stopping_compiler_thread(CompilerThread* current) { - // Do nothing - } - - // Notifies this compiler that queue is empty just prior to waiting on - // MethodCompileQueue_lock which is held by the current thread (`thread`). - virtual void on_empty_queue(CompileQueue* queue, CompilerThread* thread) { - // Do nothing - } - // Print compilation timers and statistics virtual void print_timers() { ShouldNotReachHere(); diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index e69480560ae..94e734aaad5 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -48,9 +48,6 @@ #ifdef COMPILER2 #include "opto/c2compiler.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif int64_t CompilationPolicy::_start_time = 0; int CompilationPolicy::_c1_count = 0; @@ -194,7 +191,7 @@ static inline CompLevel adjust_level_for_compilability_query(CompLevel comp_leve if (comp_level == CompLevel_any) { if (CompilerConfig::is_c1_only()) { comp_level = CompLevel_simple; - } else if (CompilerConfig::is_c2_or_jvmci_compiler_only()) { + } else if (CompilerConfig::is_c2_only()) { comp_level = CompLevel_full_optimization; } } @@ -240,34 +237,6 @@ bool CompilationPolicy::is_compilation_enabled() { return CompileBroker::should_compile_new_jobs(); } -CompileTask* CompilationPolicy::select_task_helper(CompileQueue* compile_queue) { - // Remove unloaded methods from the queue - for (CompileTask* task = compile_queue->first(); task != nullptr; ) { - CompileTask* next = task->next(); - if (task->is_unloaded()) { - compile_queue->remove_and_mark_stale(task); - } - task = next; - } -#if INCLUDE_JVMCI - if (UseJVMCICompiler && !BackgroundCompilation) { - /* - * In blocking compilation mode, the CompileBroker will make - * compilations submitted by a JVMCI compiler thread non-blocking. These - * compilations should be scheduled after all blocking compilations - * to service non-compiler related compilations sooner and reduce the - * chance of such compilations timing out. - */ - for (CompileTask* task = compile_queue->first(); task != nullptr; task = task->next()) { - if (task->is_blocking()) { - return task; - } - } - } -#endif - return compile_queue->first(); -} - // Simple methods are as good being compiled with C1 as C2. // Determine if a given method is such a case. bool CompilationPolicy::is_trivial(const methodHandle& method) { @@ -278,20 +247,6 @@ bool CompilationPolicy::is_trivial(const methodHandle& method) { return false; } -bool CompilationPolicy::force_comp_at_level_simple(const methodHandle& method) { - if (CompilationModeFlag::quick_internal()) { -#if INCLUDE_JVMCI - if (UseJVMCICompiler) { - AbstractCompiler* comp = CompileBroker::compiler(CompLevel_full_optimization); - if (comp != nullptr && comp->is_jvmci() && ((JVMCICompiler*) comp)->force_comp_at_level_simple(method)) { - return true; - } - } -#endif - } - return false; -} - CompLevel CompilationPolicy::comp_level(Method* method) { nmethod *nm = method->code(); if (nm != nullptr && nm->is_in_use()) { @@ -559,7 +514,7 @@ void CompilationPolicy::initialize() { if (!CompilerConfig::is_interpreter_only()) { int count = CICompilerCount; bool c1_only = CompilerConfig::is_c1_only(); - bool c2_only = CompilerConfig::is_c2_or_jvmci_compiler_only(); + bool c2_only = CompilerConfig::is_c2_only(); int min_count = (c1_only || c2_only) ? 1 : 2; #ifdef _LP64 @@ -617,18 +572,8 @@ void CompilationPolicy::initialize() { // No C1 compiler threads are needed set_c2_count(count); } else { -#if INCLUDE_JVMCI - if (UseJVMCICompiler && UseJVMCINativeLibrary) { - int libjvmci_count = MAX2((int) (count * JVMCINativeLibraryThreadFraction), 1); - int c1_count = MAX2(count - libjvmci_count, 1); - set_c2_count(libjvmci_count); - set_c1_count(c1_count); - } else -#endif - { - set_c1_count(MAX2(count / 3, 1)); - set_c2_count(MAX2(count - c1_count(), 1)); - } + set_c1_count(MAX2(count / 3, 1)); + set_c2_count(MAX2(count - c1_count(), 1)); } assert(count == c1_count() + c2_count(), "inconsistent compiler thread count"); set_increase_threshold_at_ratio(); @@ -649,7 +594,7 @@ bool CompilationPolicy::verify_level(CompLevel level) { if (!CompilerConfig::is_c1_enabled() && is_c1_compile(level)) { return false; } - if (!CompilerConfig::is_c2_or_jvmci_compiler_enabled() && is_c2_compile(level)) { + if (!CompilerConfig::is_c2_enabled() && is_c2_compile(level)) { return false; } @@ -663,8 +608,6 @@ bool CompilationPolicy::verify_level(CompLevel level) { return level == CompLevel_simple; } else if (CompilationModeFlag::high_only()) { return level == CompLevel_full_optimization; - } else if (CompilationModeFlag::high_only_quick_internal()) { - return level == CompLevel_full_optimization || level == CompLevel_simple; } return false; } @@ -675,7 +618,7 @@ CompLevel CompilationPolicy::highest_compile_level() { CompLevel level = CompLevel_none; // Setup the maximum level available for the current compiler configuration. if (!CompilerConfig::is_interpreter_only()) { - if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) { + if (CompilerConfig::is_c2_enabled()) { level = CompLevel_full_optimization; } else if (CompilerConfig::is_c1_enabled()) { if (CompilerConfig::is_c1_simple_only()) { @@ -696,7 +639,6 @@ CompLevel CompilationPolicy::highest_compile_level() { if (!CompilationModeFlag::normal()) { // a) quick_only - levels 2,3,4 are invalid; levels -1,0,1 are valid; // b) high_only - levels 1,2,3 are invalid; levels -1,0,4 are valid; - // c) high_only_quick_internal - levels 2,3 are invalid; levels -1,0,1,4 are valid. if (CompilationModeFlag::quick_only()) { if (level == CompLevel_limited_profile || level == CompLevel_full_profile || level == CompLevel_full_optimization) { level = CompLevel_simple; @@ -705,10 +647,6 @@ CompLevel CompilationPolicy::highest_compile_level() { if (level == CompLevel_simple || level == CompLevel_limited_profile || level == CompLevel_full_profile) { level = CompLevel_none; } - } else if (CompilationModeFlag::high_only_quick_internal()) { - if (level == CompLevel_limited_profile || level == CompLevel_full_profile) { - level = CompLevel_simple; - } } } @@ -730,12 +668,6 @@ CompLevel CompilationPolicy::initial_compile_level(const methodHandle& method) { level = CompLevel_simple; } else if (CompilationModeFlag::high_only()) { level = CompLevel_full_optimization; - } else if (CompilationModeFlag::high_only_quick_internal()) { - if (force_comp_at_level_simple(method)) { - level = CompLevel_simple; - } else { - level = CompLevel_full_optimization; - } } assert(level != CompLevel_any, "Unhandled compilation mode"); return limit_level(level); @@ -805,11 +737,6 @@ CompileTask* CompilationPolicy::select_task(CompileQueue* compile_queue, JavaThr } if (max_blocking_task != nullptr) { - // In blocking compilation mode, the CompileBroker will make - // compilations submitted by a JVMCI compiler thread non-blocking. These - // compilations should be scheduled after all blocking compilations - // to service non-compiler related compilations sooner and reduce the - // chance of such compilations timing out. max_task = max_blocking_task; max_method = max_task->method(); } @@ -1075,7 +1002,7 @@ bool CompilationPolicy::is_mature(MethodData* mdo) { // start profiling without waiting for the compiled method to arrive. // We also take the load on compilers into the account. bool CompilationPolicy::should_create_mdo(const methodHandle& method, CompLevel cur_level) { - if (cur_level != CompLevel_none || force_comp_at_level_simple(method) || CompilationModeFlag::quick_only() || !ProfileInterpreter) { + if (cur_level != CompLevel_none || CompilationModeFlag::quick_only() || !ProfileInterpreter) { return false; } @@ -1258,9 +1185,6 @@ CompLevel CompilationPolicy::trained_transition(const methodHandle& method, Comp } // We don't have any special strategies for the C2-only compilation modes, so just fix up the levels for now. - if (CompilationModeFlag::high_only_quick_internal() && CompLevel_simple < next_level && next_level < CompLevel_full_optimization) { - return CompLevel_none; - } if (CompilationModeFlag::high_only() && next_level < CompLevel_full_optimization) { return CompLevel_none; } @@ -1273,7 +1197,7 @@ CompLevel CompilationPolicy::trained_transition(const methodHandle& method, Comp * 1 - pure C1 (CompLevel_simple) * 2 - C1 with invocation and backedge counting (CompLevel_limited_profile) * 3 - C1 with full profiling (CompLevel_full_profile) - * 4 - C2 or Graal (CompLevel_full_optimization) + * 4 - C2 (CompLevel_full_optimization) * * Common state transition patterns: * a. 0 -> 3 -> 4. @@ -1310,9 +1234,7 @@ template CompLevel CompilationPolicy::common(const methodHandle& method, CompLevel cur_level, JavaThread* THREAD, bool disable_feedback) { CompLevel next_level = cur_level; - if (force_comp_at_level_simple(method)) { - next_level = CompLevel_simple; - } else if (is_trivial(method) || method->is_native()) { + if (is_trivial(method) || method->is_native()) { // We do not care if there is profiling data for these methods, throw them to compiler. next_level = CompilationModeFlag::disable_intermediate() ? CompLevel_full_optimization : CompLevel_simple; } else if (MethodTrainingData::have_data()) { diff --git a/src/hotspot/share/compiler/compilationPolicy.hpp b/src/hotspot/share/compiler/compilationPolicy.hpp index 3efc374d998..e9a2de076ff 100644 --- a/src/hotspot/share/compiler/compilationPolicy.hpp +++ b/src/hotspot/share/compiler/compilationPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -322,8 +322,6 @@ class CompilationPolicy : AllStatic { // Simple methods are as good being compiled with C1 as C2. // This function tells if it's such a function. inline static bool is_trivial(const methodHandle& method); - // Force method to be compiled at CompLevel_simple? - inline static bool force_comp_at_level_simple(const methodHandle& method); // Get a compilation level for a given method. static CompLevel comp_level(Method* method); @@ -358,7 +356,6 @@ class CompilationPolicy : AllStatic { static bool can_be_osr_compiled(const methodHandle& m, int comp_level = CompLevel_any); static bool is_compilation_enabled(); - static CompileTask* select_task_helper(CompileQueue* compile_queue); // Return initial compile level to use with Xcomp (depends on compilation mode). static void reprofile(ScopeDesc* trap_scope, bool is_osr); static nmethod* event(const methodHandle& method, const methodHandle& inlinee, diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index ddd3f8ae5f8..099f29f96bf 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -81,10 +81,6 @@ #ifdef COMPILER2 #include "opto/c2compiler.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/jvmciRuntime.hpp" -#endif #ifdef DTRACE_ENABLED @@ -238,15 +234,6 @@ CompileTaskWrapper::~CompileTaskWrapper() { { MutexLocker notifier(thread, CompileTaskWait_lock); task->mark_complete(); -#if INCLUDE_JVMCI - if (CompileBroker::compiler(task->comp_level())->is_jvmci()) { - if (!task->has_waiter()) { - // The waiting thread timed out and thus did not delete the task. - free_task = true; - } - task->set_blocking_jvmci_compile_state(nullptr); - } -#endif if (!free_task) { // Notify the waiting thread that the compilation has completed // so that it can free the task. @@ -283,18 +270,6 @@ bool CompileBroker::can_remove(CompilerThread *ct, bool do_it) { // Keep thread alive for at least some time. if (ct->idle_time_millis() < (c1 ? 500 : 100)) return false; -#if INCLUDE_JVMCI - if (compiler->is_jvmci() && !UseJVMCINativeLibrary) { - // Handles for JVMCI thread objects may get released concurrently. - if (do_it) { - assert(CompileThread_lock->owner() == ct, "must be holding lock"); - } else { - // Skip check if it's the last thread and let caller check again. - return true; - } - } -#endif - // We only allow the last compiler thread of each type to get removed. jobject last_compiler = c1 ? compiler1_object(compiler_count - 1) : compiler2_object(compiler_count - 1); @@ -302,13 +277,6 @@ bool CompileBroker::can_remove(CompilerThread *ct, bool do_it) { if (do_it) { assert_locked_or_safepoint(CompileThread_lock); // Update must be consistent. compiler->set_num_compiler_threads(compiler_count - 1); -#if INCLUDE_JVMCI - if (compiler->is_jvmci() && !UseJVMCINativeLibrary) { - // Old j.l.Thread object can die when no longer referenced elsewhere. - JNIHandles::destroy_global(compiler2_object(compiler_count - 1)); - _compiler2_objects[compiler_count - 1] = nullptr; - } -#endif } return true; } @@ -424,15 +392,6 @@ CompileTask* CompileQueue::get(CompilerThread* thread) { return nullptr; } - AbstractCompiler* compiler = thread->compiler(); - guarantee(compiler != nullptr, "Compiler object must exist"); - compiler->on_empty_queue(this, thread); - if (_first != nullptr) { - // The call to on_empty_queue may have temporarily unlocked the MCQ lock - // so check again whether any tasks were added to the queue. - break; - } - // If there are no compilation tasks and we can compile new jobs // (i.e., there is enough free space in the code cache) there is // no need to invoke the GC. @@ -600,31 +559,21 @@ CompilerCounters::CompilerCounters() { _compile_type = CompileBroker::no_compile; } -#if INCLUDE_JFR && COMPILER2_OR_JVMCI +#if INCLUDE_JFR && defined(COMPILER2) // It appends new compiler phase names to growable array phase_names(a new CompilerPhaseType mapping // in compiler/compilerEvent.cpp) and registers it with its serializer. // // c2 uses explicit CompilerPhaseType idToPhase mapping in opto/phasetype.hpp, // so if c2 is used, it should be always registered first. // This function is called during vm initialization. -static void register_jfr_phasetype_serializer(CompilerType compiler_type) { +static void register_jfr_phasetype_serializer() { ResourceMark rm; - static bool first_registration = true; - if (compiler_type == compiler_jvmci) { - CompilerEvent::PhaseEvent::get_phase_id("NOT_A_PHASE_NAME", false, false, false); - first_registration = false; -#ifdef COMPILER2 - } else if (compiler_type == compiler_c2) { - assert(first_registration, "invariant"); // c2 must be registered first. - for (int i = 0; i < PHASE_NUM_TYPES; i++) { - const char* phase_name = CompilerPhaseTypeHelper::to_description((CompilerPhaseType) i); - CompilerEvent::PhaseEvent::get_phase_id(phase_name, false, false, false); - } - first_registration = false; -#endif // COMPILER2 + for (int i = 0; i < PHASE_NUM_TYPES; i++) { + const char* phase_name = CompilerPhaseTypeHelper::to_description((CompilerPhaseType) i); + CompilerEvent::PhaseEvent::get_phase_id(phase_name, false, false, false); } } -#endif // INCLUDE_JFR && COMPILER2_OR_JVMCI +#endif // INCLUDE_JFR && defined(COMPILER2) // ------------------------------------------------------------------ // CompileBroker::compilation_init @@ -639,31 +588,6 @@ void CompileBroker::compilation_init(JavaThread* THREAD) { _c1_count = CompilationPolicy::c1_count(); _c2_count = CompilationPolicy::c2_count(); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - // This is creating a JVMCICompiler singleton. - JVMCICompiler* jvmci = new JVMCICompiler(); - - if (UseJVMCICompiler) { - _compilers[1] = jvmci; - if (FLAG_IS_DEFAULT(JVMCIThreads)) { - if (BootstrapJVMCI) { - // JVMCI will bootstrap so give it more threads - _c2_count = MIN2(32, os::active_processor_count()); - } - } else { - _c2_count = JVMCIThreads; - } - if (FLAG_IS_DEFAULT(JVMCIHostThreads)) { - } else { -#ifdef COMPILER1 - _c1_count = JVMCIHostThreads; -#endif // COMPILER1 - } - } - } -#endif // INCLUDE_JVMCI - #ifdef COMPILER1 if (_c1_count > 0) { _compilers[0] = new Compiler(); @@ -671,24 +595,14 @@ void CompileBroker::compilation_init(JavaThread* THREAD) { #endif // COMPILER1 #ifdef COMPILER2 - if (true JVMCI_ONLY( && !UseJVMCICompiler)) { - if (_c2_count > 0) { - _compilers[1] = new C2Compiler(); - // Register c2 first as c2 CompilerPhaseType idToPhase mapping is explicit. - // idToPhase mapping for c2 is in opto/phasetype.hpp - JFR_ONLY(register_jfr_phasetype_serializer(compiler_c2);) - } + if (_c2_count > 0) { + _compilers[1] = new C2Compiler(); + // Register c2 as c2 CompilerPhaseType idToPhase mapping is explicit. + // idToPhase mapping for c2 is in opto/phasetype.hpp + JFR_ONLY(register_jfr_phasetype_serializer();) } #endif // COMPILER2 -#if INCLUDE_JVMCI - // Register after c2 registration. - // JVMCI CompilerPhaseType idToPhase mapping is dynamic. - if (EnableJVMCI) { - JFR_ONLY(register_jfr_phasetype_serializer(compiler_jvmci);) - } -#endif // INCLUDE_JVMCI - if (CompilerOracle::should_collect_memstat()) { CompilationMemoryStatistic::initialize(); } @@ -801,7 +715,7 @@ void TrainingReplayThread::training_replay_thread_entry(JavaThread* thread, TRAP CompilationPolicy::replay_training_at_init_loop(thread); } -#if defined(ASSERT) && COMPILER2_OR_JVMCI +#if defined(ASSERT) && defined(COMPILER2) // Entry for DeoptimizeObjectsALotThread. The threads are started in // CompileBroker::init_compiler_threads() iff DeoptimizeObjectsALot is enabled void DeoptimizeObjectsALotThread::deopt_objs_alot_thread_entry(JavaThread* thread, TRAPS) { @@ -852,7 +766,7 @@ void DeoptimizeObjectsALotThread::deoptimize_objects_alot_loop_all() { sleep(DeoptimizeObjectsALotInterval); } } -#endif // defined(ASSERT) && COMPILER2_OR_JVMCI +#endif // defined(ASSERT) && defined(COMPILER2) JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, JavaThread* THREAD) { @@ -873,11 +787,11 @@ JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, C new_thread = new CompilerThread(queue, counters); } break; -#if defined(ASSERT) && COMPILER2_OR_JVMCI +#if defined(ASSERT) && defined(COMPILER2) case deoptimizer_t: new_thread = new DeoptimizeObjectsALotThread(); break; -#endif // ASSERT +#endif // defined(ASSERT) && defined(COMPILER2) case training_replay_t: new_thread = new TrainingReplayThread(); break; @@ -968,7 +882,7 @@ void CompileBroker::init_compiler_threads() { #endif // !ZERO // Initialize the compilation queue if (_c2_count > 0) { - const char* name = JVMCI_ONLY(UseJVMCICompiler ? "JVMCI compile queue" :) "C2 compile queue"; + const char* name = "C2 compile queue"; _c2_compile_queue = new CompileQueue(name); _compiler2_objects = NEW_C_HEAP_ARRAY(jobject, _c2_count, mtCompiler); _compiler2_logs = NEW_C_HEAP_ARRAY(CompileLog*, _c2_count, mtCompiler); @@ -1025,7 +939,7 @@ void CompileBroker::init_compiler_threads() { PerfDataManager::create_constant(SUN_CI, "threads", PerfData::U_Bytes, _c1_count + _c2_count, CHECK); } -#if defined(ASSERT) && COMPILER2_OR_JVMCI +#if defined(ASSERT) && defined(COMPILER2) if (DeoptimizeObjectsALot) { // Initialize and start the object deoptimizer threads const int total_count = DeoptimizeObjectsALotThreadCountSingle + DeoptimizeObjectsALotThreadCountAll; @@ -1035,7 +949,7 @@ void CompileBroker::init_compiler_threads() { make_thread(deoptimizer_t, thread_handle, nullptr, nullptr, THREAD); } } -#endif // defined(ASSERT) && COMPILER2_OR_JVMCI +#endif // defined(ASSERT) && defined(COMPILER2) } void CompileBroker::init_training_replay() { @@ -1084,43 +998,6 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) { (int)(available_cc_np / (128*K))); for (int i = old_c2_count; i < new_c2_count; i++) { -#if INCLUDE_JVMCI - if (UseJVMCICompiler && !UseJVMCINativeLibrary && _compiler2_objects[i] == nullptr) { - // Native compiler threads as used in C1/C2 can reuse the j.l.Thread objects as their - // existence is completely hidden from the rest of the VM (and those compiler threads can't - // call Java code to do the creation anyway). - // - // For pure Java JVMCI we have to create new j.l.Thread objects as they are visible and we - // can see unexpected thread lifecycle transitions if we bind them to new JavaThreads. For - // native library JVMCI it's preferred to use the C1/C2 strategy as this avoids unnecessary - // coupling with Java. - if (!THREAD->can_call_java()) break; - char name_buffer[256]; - os::snprintf_checked(name_buffer, sizeof(name_buffer), "%s CompilerThread%d", _compilers[1]->name(), i); - Handle thread_oop; - { - // We have to give up the lock temporarily for the Java calls. - MutexUnlocker mu(CompileThread_lock); - thread_oop = JavaThread::create_system_thread_object(name_buffer, THREAD); - } - if (HAS_PENDING_EXCEPTION) { - if (trace_compiler_threads()) { - ResourceMark rm; - stringStream msg; - msg.print_cr("JVMCI compiler thread creation failed:"); - PENDING_EXCEPTION->print_on(&msg); - print_compiler_threads(msg); - } - CLEAR_PENDING_EXCEPTION; - break; - } - // Check if another thread has beaten us during the Java calls. - if (get_c2_thread_count() != i) break; - jobject thread_handle = JNIHandles::make_global(thread_oop); - assert(compiler2_object(i) == nullptr, "Old one must be released!"); - _compiler2_objects[i] = thread_handle; - } -#endif guarantee(compiler2_object(i) != nullptr, "Thread oop must exist"); JavaThread *ct = make_thread(compiler_t, compiler2_object(i), _c2_compile_queue, _compilers[1], THREAD); if (ct == nullptr) break; @@ -1276,42 +1153,6 @@ void CompileBroker::compile_method_base(const methodHandle& method, return; } -#if INCLUDE_JVMCI - if (UseJVMCICompiler && blocking) { - // Don't allow blocking compiles for requests triggered by JVMCI. - if (thread->is_Compiler_thread()) { - blocking = false; - } - - // In libjvmci, JVMCI initialization should not deadlock with other threads - if (!UseJVMCINativeLibrary) { - // Don't allow blocking compiles if inside a class initializer or while performing class loading - vframeStream vfst(JavaThread::cast(thread)); - for (; !vfst.at_end(); vfst.next()) { - if (vfst.method()->is_static_initializer() || - (vfst.method()->method_holder()->is_subclass_of(vmClasses::ClassLoader_klass()) && - vfst.method()->name() == vmSymbols::loadClass_name())) { - blocking = false; - break; - } - } - - // Don't allow blocking compilation requests to JVMCI - // if JVMCI itself is not yet initialized - if (!JVMCI::is_compiler_initialized() && compiler(comp_level)->is_jvmci()) { - blocking = false; - } - } - - // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown - // to avoid deadlock between compiler thread(s) and threads run at shutdown - // such as the DestroyJavaVM thread. - if (JVMCI::in_shutdown()) { - blocking = false; - } - } -#endif // INCLUDE_JVMCI - // We will enter the compilation in the queue. // 14012000: Note that this sets the queued_for_compile bits in // the target method. We can now reason that a method cannot be @@ -1375,13 +1216,6 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, AbstractCompiler *comp = CompileBroker::compiler(comp_level); assert(comp != nullptr, "Ensure we have a compiler"); -#if INCLUDE_JVMCI - if (comp->is_jvmci() && !JVMCI::can_initialize_JVMCI()) { - // JVMCI compilation is not yet initializable. - return nullptr; - } -#endif - CompilerDirectiveMatcher matcher(method, comp_level); // CompileBroker::compile_method can trap and can have pending async exception. nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_count, compile_reason, matcher.directive_set(), THREAD); @@ -1430,7 +1264,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, assert(!HAS_PENDING_EXCEPTION, "No exception should be present"); // some prerequisites that are compiler specific - if (comp->is_c2() || comp->is_jvmci()) { + if (comp->is_c2()) { InternalOOMEMark iom(THREAD); method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NONASYNC_NULL); // Resolve all classes seen in the signature of the method @@ -1642,68 +1476,6 @@ CompileTask* CompileBroker::create_compile_task(CompileQueue* queue, return new_task; } -#if INCLUDE_JVMCI -// The number of milliseconds to wait before checking if -// JVMCI compilation has made progress. -static const long JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE = 1000; - -// The number of JVMCI compilation progress checks that must fail -// before unblocking a thread waiting for a blocking compilation. -static const int JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS = 10; - -/** - * Waits for a JVMCI compiler to complete a given task. This thread - * waits until either the task completes or it sees no JVMCI compilation - * progress for N consecutive milliseconds where N is - * JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE * - * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. - * - * @return true if this thread needs to delete the task - */ -bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { - assert(UseJVMCICompiler, "sanity"); - MonitorLocker ml(thread, CompileTaskWait_lock); - int progress_wait_attempts = 0; - jint thread_jvmci_compilation_ticks = 0; - jint global_jvmci_compilation_ticks = jvmci->global_compilation_ticks(); - while (!task->is_complete() && !is_compilation_disabled_forever() && - ml.wait(JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { - JVMCICompileState* jvmci_compile_state = task->blocking_jvmci_compile_state(); - - bool progress; - if (jvmci_compile_state != nullptr) { - jint ticks = jvmci_compile_state->compilation_ticks(); - progress = (ticks - thread_jvmci_compilation_ticks) != 0; - JVMCI_event_1("waiting on compilation %d [ticks=%d]", task->compile_id(), ticks); - thread_jvmci_compilation_ticks = ticks; - } else { - // Still waiting on JVMCI compiler queue. This thread may be holding a lock - // that all JVMCI compiler threads are blocked on. We use the global JVMCI - // compilation ticks to determine whether JVMCI compilation - // is still making progress through the JVMCI compiler queue. - jint ticks = jvmci->global_compilation_ticks(); - progress = (ticks - global_jvmci_compilation_ticks) != 0; - JVMCI_event_1("waiting on compilation %d to be queued [ticks=%d]", task->compile_id(), ticks); - global_jvmci_compilation_ticks = ticks; - } - - if (!progress) { - if (++progress_wait_attempts == JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS) { - if (PrintCompilation) { - task->print(tty, "wait for blocking compilation timed out"); - } - JVMCI_event_1("waiting on compilation %d timed out", task->compile_id()); - break; - } - } else { - progress_wait_attempts = 0; - } - } - task->clear_waiter(); - return task->is_complete(); -} -#endif - /** * Wait for the compilation task to complete. */ @@ -1718,19 +1490,8 @@ void CompileBroker::wait_for_completion(CompileTask* task) { JavaThread* thread = JavaThread::current(); methodHandle method(thread, task->method()); - bool free_task; -#if INCLUDE_JVMCI - AbstractCompiler* comp = compiler(task->comp_level()); - if (!UseJVMCINativeLibrary && comp->is_jvmci() && !task->should_wait_for_compilation()) { - // It may return before compilation is completed. - // Note that libjvmci should not pre-emptively unblock - // a thread waiting for a compilation as it does not call - // Java code and so is not deadlock prone like jarjvmci. - free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread); - } else -#endif + bool free_task = true; { - free_task = true; // Wait until the task is complete or compilation is shut down. MonitorLocker ml(thread, CompileTaskWait_lock); while (!task->is_complete() && !is_compilation_disabled_forever()) { @@ -1968,9 +1729,6 @@ void CompileBroker::compiler_thread_loop() { print_compiler_threads(msg); } - // Notify compiler that the compiler thread is about to stop - thread->compiler()->stopping_compiler_thread(thread); - free_buffer_blob_if_allocated(thread); return; // Stop this thread. } @@ -2244,69 +2002,6 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { bool failure_reason_on_C_heap = false; const char* retry_message = nullptr; -#if INCLUDE_JVMCI - if (UseJVMCICompiler && comp != nullptr && comp->is_jvmci()) { - JVMCICompiler* jvmci = (JVMCICompiler*) comp; - - TraceTime t1("compilation", &time); - EventCompilation event; - JVMCICompileState compile_state(task, jvmci); - JVMCIRuntime *runtime = nullptr; - - if (JVMCI::in_shutdown()) { - failure_reason = "in JVMCI shutdown"; - retry_message = "not retryable"; - compilable = ciEnv::MethodCompilable_never; - } else if (compile_state.target_method_is_old()) { - // Skip redefined methods - failure_reason = "redefined method"; - retry_message = "not retryable"; - compilable = ciEnv::MethodCompilable_never; - } else { - JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__); - if (env.init_error() != JNI_OK) { - const char* msg = env.init_error_msg(); - failure_reason = os::strdup(err_msg("Error attaching to libjvmci (err: %d, %s)", - env.init_error(), msg == nullptr ? "unknown" : msg), mtJVMCI); - bool reason_on_C_heap = true; - // In case of JNI_ENOMEM, there's a good chance a subsequent attempt to create libjvmci or attach to it - // might succeed. Other errors most likely indicate a non-recoverable error in the JVMCI runtime. - bool retryable = env.init_error() == JNI_ENOMEM; - compile_state.set_failure(retryable, failure_reason, reason_on_C_heap); - } - if (failure_reason == nullptr) { - if (WhiteBoxAPI && WhiteBox::compilation_locked) { - // Must switch to native to block - ThreadToNativeFromVM ttn(thread); - whitebox_lock_compilation(); - } - methodHandle method(thread, target_handle); - runtime = env.runtime(); - runtime->compile_method(&env, jvmci, method, osr_bci); - - failure_reason = compile_state.failure_reason(); - failure_reason_on_C_heap = compile_state.failure_reason_on_C_heap(); - if (!compile_state.retryable()) { - retry_message = "not retryable"; - compilable = ciEnv::MethodCompilable_not_at_tier; - } - if (!task->is_success()) { - assert(failure_reason != nullptr, "must specify failure_reason"); - } - } - } - if (!task->is_success() && !JVMCI::in_shutdown()) { - handle_compile_error(thread, task, nullptr, compilable, failure_reason); - } - if (event.should_commit()) { - post_compilation_event(event, task); - } - - if (runtime != nullptr) { - runtime->post_compile(thread); - } - } else -#endif // INCLUDE_JVMCI { NoHandleMark nhm; ThreadToNativeFromVM ttn(thread); @@ -2767,15 +2462,6 @@ void CompileBroker::print_times(bool per_compiler, bool aggregate) { tty->cr(); comp->print_timers(); } -#if INCLUDE_JVMCI - if (EnableJVMCI) { - JVMCICompiler *jvmci_comp = JVMCICompiler::instance(false, JavaThread::current_or_null()); - if (jvmci_comp != nullptr && jvmci_comp != comp) { - tty->cr(); - jvmci_comp->print_timers(); - } - } -#endif tty->cr(); tty->print_cr(" Total compiled methods : %8u methods", total_compile_count); diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index cb657b7b601..f1d69c8c0bf 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,13 +33,10 @@ #include "runtime/atomicAccess.hpp" #include "runtime/perfDataTypes.hpp" #include "utilities/stack.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciCompiler.hpp" -#endif class nmethod; -#if defined(ASSERT) && COMPILER2_OR_JVMCI +#if defined(ASSERT) && defined(COMPILER2) // Stress testing. Dedicated threads revert optimizations based on escape analysis concurrently to // the running java application. Configured with vm options DeoptimizeObjectsALot*. class DeoptimizeObjectsALotThread : public JavaThread { @@ -53,7 +50,7 @@ public: bool is_hidden_from_external_view() const { return true; } }; -#endif +#endif // defined(ASSERT) && defined(COMPILER2) // CompilerCounters // @@ -273,10 +270,6 @@ class CompileBroker: AllStatic { CompileTask::CompileReason compile_reason, bool blocking); static void wait_for_completion(CompileTask* task); -#if INCLUDE_JVMCI - static bool wait_for_jvmci_completion(JVMCICompiler* comp, CompileTask* task, JavaThread* thread); -#endif - static void free_buffer_blob_if_allocated(CompilerThread* thread); static void invoke_compiler_on_method(CompileTask* task); diff --git a/src/hotspot/share/compiler/compileTask.cpp b/src/hotspot/share/compiler/compileTask.cpp index b22aa4466a4..6a5f706ec7a 100644 --- a/src/hotspot/share/compiler/compileTask.cpp +++ b/src/hotspot/share/compiler/compileTask.cpp @@ -58,8 +58,6 @@ CompileTask::CompileTask(int compile_id, _comp_level(comp_level), _compiler(CompileBroker::compiler(comp_level)), _comp_directive_matcher(method, static_cast(comp_level)), - JVMCI_ONLY(_has_waiter(_compiler->is_jvmci()) COMMA) - JVMCI_ONLY(_blocking_jvmci_compile_state(nullptr) COMMA) _num_inlined_bytecodes(0), _next(nullptr), _prev(nullptr), diff --git a/src/hotspot/share/compiler/compileTask.hpp b/src/hotspot/share/compiler/compileTask.hpp index b6174af72eb..155dc4d139b 100644 --- a/src/hotspot/share/compiler/compileTask.hpp +++ b/src/hotspot/share/compiler/compileTask.hpp @@ -35,8 +35,6 @@ class CompileTrainingData; -JVMCI_ONLY(class JVMCICompileState;) - enum class InliningResult { SUCCESS, FAILURE }; inline InliningResult inlining_result_of(bool success) { @@ -50,7 +48,6 @@ inline InliningResult inlining_result_of(bool success) { class CompileTask : public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; public: // Different reasons for a compilation @@ -63,7 +60,6 @@ class CompileTask : public CHeapObj { Reason_Replay, // ciReplay Reason_Whitebox, // Whitebox API Reason_MustBeCompiled, // Used for -Xcomp or AlwaysCompileLoopMethods (see CompilationPolicy::must_be_compiled()) - Reason_Bootstrap, // JVMCI bootstrap Reason_Count }; @@ -96,11 +92,6 @@ class CompileTask : public CHeapObj { int _comp_level; AbstractCompiler* _compiler; CompilerDirectiveMatcher _comp_directive_matcher; -#if INCLUDE_JVMCI - bool _has_waiter; - // Compilation state for a blocking JVMCI compilation - JVMCICompileState* _blocking_jvmci_compile_state; -#endif int _num_inlined_bytecodes; CompileTask* _next; CompileTask* _prev; @@ -149,26 +140,6 @@ class CompileTask : public CHeapObj { return false; } } -#if INCLUDE_JVMCI - bool should_wait_for_compilation() const { - // Wait for blocking compilation to finish. - switch (_compile_reason) { - case Reason_Replay: - case Reason_Whitebox: - case Reason_Bootstrap: - return _is_blocking; - default: - return false; - } - } - - bool has_waiter() const { return _has_waiter; } - void clear_waiter() { _has_waiter = false; } - JVMCICompileState* blocking_jvmci_compile_state() const { return _blocking_jvmci_compile_state; } - void set_blocking_jvmci_compile_state(JVMCICompileState* state) { - _blocking_jvmci_compile_state = state; - } -#endif void mark_complete() { _is_complete = true; } void mark_success() { _is_success = true; } diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index cf7744cfe03..69c9bc585f7 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -39,8 +39,7 @@ const char* compilertype2name_tab[compiler_number_of_types] = { "", "c1", - "c2", - "jvmci" + "c2" }; CompilationModeFlag::Mode CompilationModeFlag::_mode = CompilationModeFlag::Mode::NORMAL; @@ -63,17 +62,11 @@ bool CompilationModeFlag::initialize() { _mode = Mode::QUICK_ONLY; } } else if (strcmp(CompilationMode, "high-only") == 0) { - if (!CompilerConfig::has_c2() && !CompilerConfig::is_jvmci_compiler()) { - print_mode_unavailable("high-only", "there is no c2 or jvmci compiler present"); + if (!CompilerConfig::has_c2()) { + print_mode_unavailable("high-only", "there is no c2 compiler present"); } else { _mode = Mode::HIGH_ONLY; } - } else if (strcmp(CompilationMode, "high-only-quick-internal") == 0) { - if (!CompilerConfig::has_c1() || !CompilerConfig::is_jvmci_compiler()) { - print_mode_unavailable("high-only-quick-internal", "there is no c1 and jvmci compiler present"); - } else { - _mode = Mode::HIGH_ONLY_QUICK_INTERNAL; - } } else { print_error(); return false; @@ -84,12 +77,8 @@ bool CompilationModeFlag::initialize() { if (normal()) { if (CompilerConfig::is_c1_simple_only()) { _mode = Mode::QUICK_ONLY; - } else if (CompilerConfig::is_c2_or_jvmci_compiler_only()) { + } else if (CompilerConfig::is_c2_only()) { _mode = Mode::HIGH_ONLY; - } else if (CompilerConfig::is_jvmci_compiler_enabled() && CompilerConfig::is_c1_enabled() && !TieredCompilation) { - warning("Disabling tiered compilation with non-native JVMCI compiler is not recommended, " - "disabling intermediate compilation levels instead. "); - _mode = Mode::HIGH_ONLY_QUICK_INTERNAL; } } return true; @@ -102,14 +91,10 @@ void CompilationModeFlag::print_error() { jio_fprintf(defaultStream::error_stream(), "%s quick-only", comma ? "," : ""); comma = true; } - if (CompilerConfig::has_c2() || CompilerConfig::has_jvmci()) { + if (CompilerConfig::has_c2()) { jio_fprintf(defaultStream::error_stream(), "%s high-only", comma ? "," : ""); comma = true; } - if (CompilerConfig::has_c1() && CompilerConfig::has_jvmci()) { - jio_fprintf(defaultStream::error_stream(), "%s high-only-quick-internal", comma ? "," : ""); - comma = true; - } jio_fprintf(defaultStream::error_stream(), "\n"); } @@ -206,7 +191,7 @@ void CompilerConfig::set_legacy_emulation_flags() { if (!FLAG_IS_DEFAULT(CompileThreshold) || !FLAG_IS_DEFAULT(OnStackReplacePercentage) || !FLAG_IS_DEFAULT(InterpreterProfilePercentage)) { - if (CompilerConfig::is_c1_only() || CompilerConfig::is_c2_or_jvmci_compiler_only()) { + if (CompilerConfig::is_c1_only() || CompilerConfig::is_c2_only()) { // This function is called before these flags are validated. In order to not confuse the user with extraneous // error messages, we check the validity of these flags here and bail out if any of them are invalid. if (!check_legacy_flags()) { @@ -238,7 +223,7 @@ void CompilerConfig::set_legacy_emulation_flags() { FLAG_SET_ERGO(Tier3MinInvocationThreshold, threshold); FLAG_SET_ERGO(Tier3CompileThreshold, threshold); FLAG_SET_ERGO(Tier3BackEdgeThreshold, osr_threshold); - if (CompilerConfig::is_c2_or_jvmci_compiler_only()) { + if (CompilerConfig::is_c2_only()) { FLAG_SET_ERGO(Tier4InvocationThreshold, threshold); FLAG_SET_ERGO(Tier4MinInvocationThreshold, threshold); FLAG_SET_ERGO(Tier4CompileThreshold, threshold); @@ -401,54 +386,6 @@ void CompilerConfig::set_compilation_policy_flags() { } -#if INCLUDE_JVMCI -void CompilerConfig::set_jvmci_specific_flags() { - if (UseJVMCICompiler) { - if (FLAG_IS_DEFAULT(TypeProfileWidth)) { - FLAG_SET_DEFAULT(TypeProfileWidth, 8); - } - if (FLAG_IS_DEFAULT(TypeProfileLevel)) { - FLAG_SET_DEFAULT(TypeProfileLevel, 0); - } - - if (UseJVMCINativeLibrary) { - // SVM compiled code requires more stack space - if (FLAG_IS_DEFAULT(CompilerThreadStackSize)) { - // Duplicate logic in the implementations of os::create_thread - // so that we can then double the computed stack size. Once - // the stack size requirements of SVM are better understood, - // this logic can be pushed down into os::create_thread. - int stack_size = CompilerThreadStackSize; - if (stack_size == 0) { - stack_size = VMThreadStackSize; - } - if (stack_size != 0) { - FLAG_SET_DEFAULT(CompilerThreadStackSize, stack_size * 2); - } - } - } else { - // JVMCI needs values not less than defaults - if (FLAG_IS_DEFAULT(ReservedCodeCacheSize)) { - FLAG_SET_DEFAULT(ReservedCodeCacheSize, MAX2(64*M, ReservedCodeCacheSize)); - } - if (FLAG_IS_DEFAULT(InitialCodeCacheSize)) { - FLAG_SET_DEFAULT(InitialCodeCacheSize, MAX2(16*M, InitialCodeCacheSize)); - } - if (FLAG_IS_DEFAULT(Tier3DelayOn)) { - // This effectively prevents the compile broker scheduling tier 2 - // (i.e., limited C1 profiling) compilations instead of tier 3 - // (i.e., full C1 profiling) compilations when the tier 4 queue - // backs up (which is quite likely when using a non-AOT compiled JVMCI - // compiler). The observation based on jargraal is that the downside - // of skipping full profiling is much worse for performance than the - // queue backing up. - FLAG_SET_DEFAULT(Tier3DelayOn, 100000); - } - } // !UseJVMCINativeLibrary - } // UseJVMCICompiler -} -#endif // INCLUDE_JVMCI - bool CompilerConfig::check_args_consistency(bool status) { // Check lower bounds of the code cache // Template Interpreter code is approximately 3X larger in debug builds. @@ -512,19 +449,6 @@ bool CompilerConfig::check_args_consistency(bool status) { warning("SegmentedCodeCache has no meaningful effect with -Xint"); FLAG_SET_DEFAULT(SegmentedCodeCache, false); } -#if INCLUDE_JVMCI - if (EnableJVMCI || UseJVMCICompiler) { - if (!FLAG_IS_DEFAULT(EnableJVMCI) || !FLAG_IS_DEFAULT(UseJVMCICompiler)) { - warning("JVMCI Compiler disabled due to -Xint."); - } - FLAG_SET_CMDLINE(EnableJVMCI, false); - FLAG_SET_CMDLINE(UseJVMCICompiler, false); - } -#endif - } else { -#if INCLUDE_JVMCI - status = status && JVMCIGlobals::check_jvmci_flags_are_consistent(); -#endif } return status; @@ -538,15 +462,6 @@ void CompilerConfig::ergo_initialize() { set_legacy_emulation_flags(); set_compilation_policy_flags(); -#if INCLUDE_JVMCI - // Check that JVMCI supports selected GC. - // Should be done after GCConfig::initialize() was called. - JVMCIGlobals::check_jvmci_supported_gc(); - - // Do JVMCI specific settings - set_jvmci_specific_flags(); -#endif - if (UseOnStackReplacement && !UseLoopCounter) { warning("On-stack-replacement requires loop counters; enabling loop counters"); FLAG_SET_DEFAULT(UseLoopCounter, true); diff --git a/src/hotspot/share/compiler/compilerDefinitions.hpp b/src/hotspot/share/compiler/compilerDefinitions.hpp index e8ba977f705..e086fc8add6 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.hpp +++ b/src/hotspot/share/compiler/compilerDefinitions.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ enum CompilerType : u1 { compiler_none, compiler_c1, compiler_c2, - compiler_jvmci, compiler_number_of_types }; @@ -59,7 +58,7 @@ enum CompLevel : s1 { CompLevel_simple = 1, // C1 CompLevel_limited_profile = 2, // C1, invocation & backedge counters CompLevel_full_profile = 3, // C1, invocation & backedge counters + mdo - CompLevel_full_optimization = 4, // C2 or JVMCI + CompLevel_full_optimization = 4, // C2 CompLevel_count = 5 }; @@ -67,24 +66,17 @@ class CompilationModeFlag : AllStatic { enum class Mode { NORMAL, QUICK_ONLY, - HIGH_ONLY, - HIGH_ONLY_QUICK_INTERNAL + HIGH_ONLY }; static Mode _mode; static void print_error(); public: static bool initialize(); - static bool normal() { return _mode == Mode::NORMAL; } - static bool quick_only() { return _mode == Mode::QUICK_ONLY; } - static bool high_only() { return _mode == Mode::HIGH_ONLY; } - static bool high_only_quick_internal() { return _mode == Mode::HIGH_ONLY_QUICK_INTERNAL; } + static bool normal() { return _mode == Mode::NORMAL; } + static bool quick_only() { return _mode == Mode::QUICK_ONLY; } + static bool high_only() { return _mode == Mode::HIGH_ONLY; } - static bool disable_intermediate() { return high_only() || high_only_quick_internal(); } - static bool quick_internal() { return !high_only(); } - - static void set_high_only_quick_internal() { _mode = Mode::HIGH_ONLY_QUICK_INTERNAL; } - static void set_quick_only() { _mode = Mode::QUICK_ONLY; } - static void set_high_only() { _mode = Mode::HIGH_ONLY; } + static bool disable_intermediate() { return high_only(); } }; inline bool is_c1_compile(int comp_level) { @@ -119,41 +111,27 @@ public: // Which compilers are baked in? constexpr static bool has_c1() { return COMPILER1_PRESENT(true) NOT_COMPILER1(false); } constexpr static bool has_c2() { return COMPILER2_PRESENT(true) NOT_COMPILER2(false); } - constexpr static bool has_jvmci() { return JVMCI_ONLY(true) NOT_JVMCI(false); } - constexpr static bool has_tiered() { return has_c1() && (has_c2() || has_jvmci()); } + constexpr static bool has_tiered() { return has_c1() && has_c2(); } - inline static bool is_jvmci_compiler(); - inline static bool is_jvmci(); inline static bool is_interpreter_only(); // is_*_only() functions describe situations in which the JVM is in one way or another - // forced to use a particular compiler or their combination. The constraint functions - // deliberately ignore the fact that there may also be methods installed - // through JVMCI (where the JVMCI compiler was invoked not through the broker). Be sure - // to check for those (using is_jvmci()) in situations where it matters. + // forced to use a particular compiler or their combination. inline static bool is_tiered(); inline static bool is_c1_enabled(); inline static bool is_c1_only(); inline static bool is_c1_simple_only(); - inline static bool is_c1_or_interpreter_only_no_jvmci(); - inline static bool is_c1_only_no_jvmci(); + inline static bool is_c1_or_interpreter_only(); inline static bool is_c1_profiling(); - inline static bool is_jvmci_compiler_enabled(); - inline static bool is_jvmci_compiler_only(); inline static bool is_c2_only(); inline static bool is_c2_enabled(); - inline static bool is_c2_or_jvmci_compiler_only(); - inline static bool is_c2_or_jvmci_compiler_enabled(); - - inline static CompilerType compiler_type(); private: static void set_compilation_policy_flags(); - static void set_jvmci_specific_flags(); static void set_legacy_emulation_flags(); }; diff --git a/src/hotspot/share/compiler/compilerDefinitions.inline.hpp b/src/hotspot/share/compiler/compilerDefinitions.inline.hpp index 8bf70477cb3..e9f164fa7f0 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.inline.hpp +++ b/src/hotspot/share/compiler/compilerDefinitions.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,20 +35,13 @@ inline bool CompilerConfig::is_interpreter_only() { return Arguments::is_interpreter_only() || TieredStopAtLevel == CompLevel_none; } -inline bool CompilerConfig::is_jvmci_compiler() { return JVMCI_ONLY(has_jvmci() && UseJVMCICompiler) NOT_JVMCI(false); } -inline bool CompilerConfig::is_jvmci() { return JVMCI_ONLY(has_jvmci() && EnableJVMCI ) NOT_JVMCI(false); } - // is_*_only() functions describe situations in which the JVM is in one way or another -// forced to use a particular compiler or their combination. The constraint functions -// deliberately ignore the fact that there may also be methods installed -// through JVMCI (where the JVMCI compiler was invoked not through the broker). Be sure -// to check for those (using is_jvmci()) in situations where it matters. -// +// forced to use a particular compiler or their combination. // Is the JVM in a configuration that permits only c1-compiled methods (level 1,2,3)? inline bool CompilerConfig::is_c1_only() { if (!is_interpreter_only() && has_c1()) { - const bool c1_only = !has_c2() && !is_jvmci_compiler(); + const bool c1_only = !has_c2(); const bool tiered_degraded_to_c1_only = TieredCompilation && TieredStopAtLevel >= CompLevel_simple && TieredStopAtLevel < CompLevel_full_optimization; const bool c1_only_compilation_mode = CompilationModeFlag::quick_only(); return c1_only || tiered_degraded_to_c1_only || c1_only_compilation_mode; @@ -56,13 +49,8 @@ inline bool CompilerConfig::is_c1_only() { return false; } -inline bool CompilerConfig::is_c1_or_interpreter_only_no_jvmci() { - assert(!is_jvmci_compiler() || is_jvmci(), "JVMCI compiler implies enabled JVMCI"); - return !is_jvmci() && (is_interpreter_only() || is_c1_only()); -} - -inline bool CompilerConfig::is_c1_only_no_jvmci() { - return is_c1_only() && !is_jvmci(); +inline bool CompilerConfig::is_c1_or_interpreter_only() { + return is_interpreter_only() || is_c1_only(); } // Is the JVM in a configuration that permits only c1-compiled methods at level 1? @@ -77,18 +65,14 @@ inline bool CompilerConfig::is_c1_simple_only() { } inline bool CompilerConfig::is_c2_enabled() { - return has_c2() && !is_interpreter_only() && !is_c1_only() && !is_jvmci_compiler(); + return has_c2() && !is_interpreter_only() && !is_c1_only(); } -inline bool CompilerConfig::is_jvmci_compiler_enabled() { - return is_jvmci_compiler() && !is_interpreter_only() && !is_c1_only(); -} // Is the JVM in a configuration that permits only c2-compiled methods? inline bool CompilerConfig::is_c2_only() { if (is_c2_enabled()) { const bool c2_only = !has_c1(); - // There is no JVMCI compiler to replace C2 in the broker, and the user (or ergonomics) - // is forcing C1 off. + // The user (or ergonomics) is forcing C1 off. const bool c2_only_compilation_mode = CompilationModeFlag::high_only(); const bool tiered_off = !TieredCompilation; return c2_only || c2_only_compilation_mode || tiered_off; @@ -96,30 +80,14 @@ inline bool CompilerConfig::is_c2_only() { return false; } -// Is the JVM in a configuration that permits only jvmci-compiled methods? -inline bool CompilerConfig::is_jvmci_compiler_only() { - if (is_jvmci_compiler_enabled()) { - const bool jvmci_compiler_only = !has_c1(); - // JVMCI compiler replaced C2 and the user (or ergonomics) is forcing C1 off. - const bool jvmci_only_compilation_mode = CompilationModeFlag::high_only(); - const bool tiered_off = !TieredCompilation; - return jvmci_compiler_only || jvmci_only_compilation_mode || tiered_off; - } - return false; -} - -inline bool CompilerConfig::is_c2_or_jvmci_compiler_only() { - return is_c2_only() || is_jvmci_compiler_only(); -} - -// Tiered is basically C1 & (C2 | JVMCI) minus all the odd cases with restrictions. +// Tiered is basically C1 & C2 minus all the odd cases with restrictions. inline bool CompilerConfig::is_tiered() { assert(!is_c1_simple_only() || is_c1_only(), "c1 simple mode must imply c1-only mode"); - return has_tiered() && !is_interpreter_only() && !is_c1_only() && !is_c2_or_jvmci_compiler_only(); + return has_tiered() && !is_interpreter_only() && !is_c1_only() && !is_c2_only(); } inline bool CompilerConfig::is_c1_enabled() { - return has_c1() && !is_interpreter_only() && !is_c2_or_jvmci_compiler_only(); + return has_c1() && !is_interpreter_only() && !is_c2_only(); } inline bool CompilerConfig::is_c1_profiling() { @@ -128,21 +96,4 @@ inline bool CompilerConfig::is_c1_profiling() { return c1_only_profiling || tiered; } -inline bool CompilerConfig::is_c2_or_jvmci_compiler_enabled() { - return is_c2_enabled() || is_jvmci_compiler_enabled(); -} - -// Return type of most optimizing compiler which is used -inline CompilerType CompilerConfig::compiler_type() { - CompilerType compiler_type = CompilerType::compiler_none; // Interpreter only - if (CompilerConfig::is_c2_enabled()) { - compiler_type = CompilerType::compiler_c2; - } else if (CompilerConfig::is_jvmci_compiler_enabled()) { - compiler_type = CompilerType::compiler_jvmci; - } else if (CompilerConfig::is_c1_enabled()) { - compiler_type = CompilerType::compiler_c1; - } - return compiler_type; -} - #endif // SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP diff --git a/src/hotspot/share/compiler/compilerDirectives.cpp b/src/hotspot/share/compiler/compilerDirectives.cpp index f61aa111e65..1b0bdc99f08 100644 --- a/src/hotspot/share/compiler/compilerDirectives.cpp +++ b/src/hotspot/share/compiler/compilerDirectives.cpp @@ -191,7 +191,7 @@ DirectiveSet* CompilerDirectives::get_for(AbstractCompiler *comp) { return _c2_store; } else { // use c1_store as default - assert(comp->is_c1() || comp->is_jvmci(), ""); + assert(comp->is_c1(), ""); return _c1_store; } } @@ -671,9 +671,9 @@ void DirectivesStack::init() { char str[] = "*.*"; const char* error_msg = nullptr; _default_directives->add_match(str, error_msg); -#if defined(COMPILER1) || INCLUDE_JVMCI +#ifdef COMPILER1 _default_directives->_c1_store->EnableOption = true; -#endif +#endif // COMPILER1 #ifdef COMPILER2 if (CompilerConfig::is_c2_enabled()) { _default_directives->_c2_store->EnableOption = true; diff --git a/src/hotspot/share/compiler/compilerOracle.cpp b/src/hotspot/share/compiler/compilerOracle.cpp index 241d27eb6be..7d2b4de1182 100644 --- a/src/hotspot/share/compiler/compilerOracle.cpp +++ b/src/hotspot/share/compiler/compilerOracle.cpp @@ -66,7 +66,7 @@ static const char* const default_compile_commands[] = { // 1 (C1) | 1 // 2 (C1 + counters) | 10 // 3 (C1 + counters + mdo) | 100 -// 4 (C2/JVMCI) | 1000 +// 4 (C2) | 1000 // All C1 levels | 111 // All levels | 1111 diff --git a/src/hotspot/share/compiler/compilerThread.cpp b/src/hotspot/share/compiler/compilerThread.cpp index 7cf494aad56..0139f864e12 100644 --- a/src/hotspot/share/compiler/compilerThread.cpp +++ b/src/hotspot/share/compiler/compilerThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ CompilerThread::CompilerThread(CompileQueue* queue, _queue = queue; _counters = counters; _buffer_blob = nullptr; - _can_call_java = false; _compiler = nullptr; _arena_stat = nullptr; _timeout = nullptr; @@ -56,11 +55,6 @@ CompilerThread::~CompilerThread() { } void CompilerThread::set_compiler(AbstractCompiler* c) { - /* - * Compiler threads need to make Java upcalls to the jargraal compiler. - * Java upcalls are also needed by the InterpreterRuntime when using jargraal. - */ - _can_call_java = c != nullptr && c->is_jvmci() JVMCI_ONLY(&& !UseJVMCINativeLibrary); _compiler = c; } @@ -68,8 +62,3 @@ void CompilerThread::thread_entry(JavaThread* thread, TRAPS) { assert(thread->is_Compiler_thread(), "must be compiler thread"); CompileBroker::compiler_thread_loop(); } - -// Hide native compiler threads from external view. -bool CompilerThread::is_hidden_from_external_view() const { - return _compiler == nullptr || _compiler->is_hidden_from_external_view(); -} diff --git a/src/hotspot/share/compiler/compilerThread.hpp b/src/hotspot/share/compiler/compilerThread.hpp index e5b14560872..255b1dc0a37 100644 --- a/src/hotspot/share/compiler/compilerThread.hpp +++ b/src/hotspot/share/compiler/compilerThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,6 @@ class CompilerThreadTimeoutGeneric : public CHeapObj { // A thread used for Compilation. class CompilerThread : public JavaThread { friend class VMStructs; - JVMCI_ONLY(friend class CompilerThreadCanCallJava;) #ifdef LINUX typedef CompilerThreadTimeoutLinux Timeout; @@ -75,7 +74,6 @@ class CompilerThread : public JavaThread { CompileTask* volatile _task; // print_threads_compiling can read this concurrently. CompileQueue* _queue; BufferBlob* _buffer_blob; - bool _can_call_java; AbstractCompiler* _compiler; TimeStamp _idle_time; @@ -99,11 +97,9 @@ class CompilerThread : public JavaThread { bool is_Compiler_thread() const { return true; } - virtual bool can_call_java() const { return _can_call_java; } - - // Returns true if this CompilerThread is hidden from JVMTI and FlightRecorder. C1 and C2 are - // always hidden but JVMCI compiler threads might be hidden. - virtual bool is_hidden_from_external_view() const; + // Compiler threads are hidden by default. + virtual bool is_hidden_from_external_view() const { return true; } + virtual bool can_call_java() const { return false; } void set_compiler(AbstractCompiler* c); AbstractCompiler* compiler() const { return _compiler; } diff --git a/src/hotspot/share/compiler/compiler_globals.hpp b/src/hotspot/share/compiler/compiler_globals.hpp index 98590abc15f..e1f8d9f8922 100644 --- a/src/hotspot/share/compiler/compiler_globals.hpp +++ b/src/hotspot/share/compiler/compiler_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,6 @@ #ifdef COMPILER2 #include "opto/c2_globals.hpp" #endif // COMPILER2 -#if INCLUDE_JVMCI -#include "jvmci/jvmci_globals.hpp" -#endif // TODO -- currently, even if all JIT compilers are disabled, the following flags // are still available in HotSpot. This should eventually be fixed ... @@ -279,9 +276,7 @@ "Compilation modes: " \ "default: normal tiered compilation; " \ "quick-only: C1-only mode; " \ - "high-only: C2/JVMCI-only mode; " \ - "high-only-quick-internal: C2/JVMCI-only mode, " \ - "with JVMCI compiler compiled with C1.") \ + "high-only: C2-only mode.") \ \ product(bool, PrintTieredEvents, false, \ "Print tiered events notifications") \ diff --git a/src/hotspot/share/compiler/compiler_globals_pd.hpp b/src/hotspot/share/compiler/compiler_globals_pd.hpp index 8ac4b53d6cd..55a3855f7f0 100644 --- a/src/hotspot/share/compiler/compiler_globals_pd.hpp +++ b/src/hotspot/share/compiler/compiler_globals_pd.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,12 +39,7 @@ #include "opto/c2_globals.hpp" #endif // COMPILER2 -// JVMCI has no platform-specific global definitions -//#if INCLUDE_JVMCI -//#include "jvmci/jvmci_globals_pd.hpp" -//#endif - -#if !defined(COMPILER1) && !defined(COMPILER2) && !INCLUDE_JVMCI +#if !defined(COMPILER1) && !defined(COMPILER2) define_pd_global(bool, BackgroundCompilation, false); define_pd_global(bool, CICompileOSR, false); define_pd_global(bool, UseTypeProfile, false); @@ -72,11 +67,11 @@ define_pd_global(size_t, CodeCacheMinimumUseSpace, 200*K); #define CI_COMPILER_COUNT 0 #else -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 #define CI_COMPILER_COUNT 2 #else #define CI_COMPILER_COUNT 1 -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 #endif // no compilers diff --git a/src/hotspot/share/compiler/oopMap.cpp b/src/hotspot/share/compiler/oopMap.cpp index c8d0c5d22ba..a447f59b2cd 100644 --- a/src/hotspot/share/compiler/oopMap.cpp +++ b/src/hotspot/share/compiler/oopMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +47,6 @@ #ifdef COMPILER2 #include "opto/optoreg.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci_globals.hpp" -#endif static_assert(sizeof(oop) == sizeof(intptr_t), "Derived pointer sanity check"); @@ -395,9 +392,9 @@ class AddDerivedOop : public DerivedOopClosure { }; virtual void do_derived_oop(derived_base* base, derived_pointer* derived) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::add(derived, base); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } }; @@ -874,7 +871,7 @@ void ImmutableOopMapSet::operator delete(void* p) { //------------------------------DerivedPointerTable--------------------------- -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 class DerivedPointerTable::Entry : public CHeapObj { derived_pointer* _location; // Location of derived pointer, also pointing to base @@ -973,4 +970,4 @@ void DerivedPointerTable::update_pointers() { _active = false; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 diff --git a/src/hotspot/share/compiler/oopMap.hpp b/src/hotspot/share/compiler/oopMap.hpp index 0d9dbc188e8..04abcc54fc6 100644 --- a/src/hotspot/share/compiler/oopMap.hpp +++ b/src/hotspot/share/compiler/oopMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -479,7 +479,7 @@ private: // oops, it is filled in with references to all locations that contains a // derived oop (assumed to be very few). When the GC is complete, the derived // pointers are updated based on their base pointers new value and an offset. -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 class DerivedPointerTable : public AllStatic { private: class Entry; @@ -515,6 +515,6 @@ class DerivedPointerTableDeactivate: public StackObj { } } }; -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 #endif // SHARE_COMPILER_OOPMAP_HPP diff --git a/src/hotspot/share/compiler/oopMap.inline.hpp b/src/hotspot/share/compiler/oopMap.inline.hpp index 327c2ebaa3f..1542eb2571d 100644 --- a/src/hotspot/share/compiler/oopMap.inline.hpp +++ b/src/hotspot/share/compiler/oopMap.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,10 +32,6 @@ #include "runtime/globals.hpp" #include "utilities/ostream.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci_globals.hpp" -#endif - inline const ImmutableOopMap* ImmutableOopMapSet::find_map_at_slot(int slot, int pc_offset) const { assert(slot >= 0 && slot < _count, "bounds count: %d slot: %d", _count, slot); ImmutableOopMapPair* pairs = get_pairs(); @@ -66,13 +62,6 @@ void OopMapDo::iterate_oops_do(const frame if (omv.type() != OopMapValue::derived_oop_value) continue; - #ifndef COMPILER2 - #if INCLUDE_JVMCI - if (!EnableJVMCI) - #endif - ShouldNotReachHere(); - #endif // !COMPILER2 - address loc = fr->oopmapreg_to_location(omv.reg(), reg_map); DEBUG_ONLY(if (loc == nullptr && reg_map->should_skip_missing()) continue;) diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 307f287a815..d0e549c9b11 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -2489,9 +2489,9 @@ void G1CollectedHeap::gc_epilogue(bool full) { increment_old_marking_cycles_completed(false /* concurrent */, true /* liveness_completed */); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 assert(DerivedPointerTable::is_empty(), "derived pointer present"); -#endif +#endif // COMPILER2 // We have just completed a GC. Update the soft reference // policy with the new heap occupancy diff --git a/src/hotspot/share/gc/g1/g1FullCollector.cpp b/src/hotspot/share/gc/g1/g1FullCollector.cpp index 8b38509d1d8..cf153226920 100644 --- a/src/hotspot/share/gc/g1/g1FullCollector.cpp +++ b/src/hotspot/share/gc/g1/g1FullCollector.cpp @@ -48,21 +48,21 @@ #include "utilities/debug.hpp" static void clear_and_activate_derived_pointers() { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 } static void deactivate_derived_pointers() { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::set_active(false); -#endif +#endif // COMPILER2 } static void update_derived_pointers() { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::update_pointers(); -#endif +#endif // COMPILER2 } G1CMBitMap* G1FullCollector::mark_bitmap() { @@ -542,9 +542,9 @@ void G1FullCollector::verify_after_marking() { return; } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTableDeactivate dpt_deact; -#endif +#endif // COMPILER2 _heap->prepare_for_verify(); // Note: we can verify only the heap here. When an object is // marked, the previous value of the mark word (including diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp index e13b9d91bc5..a04b50ec1e7 100644 --- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp +++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -99,9 +99,9 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) : _gc_par_phases[RemoveSelfForwards] = new WorkerDataArray("RemoveSelfForwards", "Remove Self Forwards (ms):", max_gc_threads); _gc_par_phases[ClearCardTable] = new WorkerDataArray("ClearPendingCards", "Clear Pending Cards (ms):", max_gc_threads); _gc_par_phases[RecalculateUsed] = new WorkerDataArray("RecalculateUsed", "Recalculate Used Memory (ms):", max_gc_threads); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 _gc_par_phases[UpdateDerivedPointers] = new WorkerDataArray("UpdateDerivedPointers", "Update Derived Pointers (ms):", max_gc_threads); -#endif +#endif // COMPILER2 _gc_par_phases[EagerlyReclaimHumongousObjects] = new WorkerDataArray("EagerlyReclaimHumongousObjects", "Eagerly Reclaim Humongous Objects (ms):", max_gc_threads); _gc_par_phases[ResetPartialArrayStateManager] = new WorkerDataArray("ResetPartialArrayStateManager", "Reset Partial Array State Manager (ms):", max_gc_threads); _gc_par_phases[ProcessEvacuationFailedRegions] = new WorkerDataArray("ProcessEvacuationFailedRegions", "Process Evacuation Failed Regions (ms):", max_gc_threads); @@ -508,9 +508,9 @@ double G1GCPhaseTimes::print_post_evacuate_collection_set(bool evacuation_failed debug_phase(_gc_par_phases[RecalculateUsed], 1); debug_phase(_gc_par_phases[ProcessEvacuationFailedRegions], 1); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 debug_phase(_gc_par_phases[UpdateDerivedPointers], 1); -#endif +#endif // COMPILER2 debug_phase(_gc_par_phases[EagerlyReclaimHumongousObjects], 1); trace_phase(_gc_par_phases[ResetPartialArrayStateManager]); diff --git a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp index eb51b340da3..31bfd38ddb9 100644 --- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp +++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,9 +81,9 @@ class G1GCPhaseTimes : public CHeapObj { RemoveSelfForwards, ClearCardTable, RecalculateUsed, -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 UpdateDerivedPointers, -#endif +#endif // COMPILER2 EagerlyReclaimHumongousObjects, ResetPartialArrayStateManager, ProcessEvacuationFailedRegions, diff --git a/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp b/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp index e3eabff5a50..80e26a3411e 100644 --- a/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp +++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.cpp @@ -24,45 +24,16 @@ #include "gc/g1/g1ParallelCleaning.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif - -#if INCLUDE_JVMCI -JVMCICleaningTask::JVMCICleaningTask() : - _cleaning_claimed(false) { -} - -bool JVMCICleaningTask::claim_cleaning_task() { - if (_cleaning_claimed.load_relaxed()) { - return false; - } - - return _cleaning_claimed.compare_set(false, true); -} - -void JVMCICleaningTask::work(bool unloading_occurred) { - // One worker will clean JVMCI metadata handles. - if (unloading_occurred && EnableJVMCI && claim_cleaning_task()) { - JVMCI::do_unloading(unloading_occurred); - } -} -#endif // INCLUDE_JVMCI G1ParallelCleaningTask::G1ParallelCleaningTask(bool unloading_occurred) : WorkerTask("G1 Parallel Cleaning"), _unloading_occurred(unloading_occurred), _code_cache_task(unloading_occurred), - JVMCI_ONLY(_jvmci_cleaning_task() COMMA) _klass_cleaning_task() { } // The parallel work done by all worker threads. void G1ParallelCleaningTask::work(uint worker_id) { - // Clean JVMCI metadata handles. - // Execute this task first because it is serial task. - JVMCI_ONLY(_jvmci_cleaning_task.work(_unloading_occurred);) - // Do first pass of code cache cleaning. _code_cache_task.work(worker_id); diff --git a/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp b/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp index 815b0883e16..a0d60306147 100644 --- a/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp +++ b/src/hotspot/share/gc/g1/g1ParallelCleaning.hpp @@ -26,23 +26,6 @@ #define SHARE_GC_G1_G1PARALLELCLEANING_HPP #include "gc/shared/parallelCleaning.hpp" -#if INCLUDE_JVMCI -#include "runtime/atomic.hpp" -#endif - -#if INCLUDE_JVMCI -class JVMCICleaningTask : public StackObj { - Atomic _cleaning_claimed; - -public: - JVMCICleaningTask(); - // Clean JVMCI metadata handles. - void work(bool unloading_occurred); - -private: - bool claim_cleaning_task(); -}; -#endif // Do cleanup of some weakly held data in the same parallel task. // Assumes a non-moving context. @@ -50,9 +33,6 @@ class G1ParallelCleaningTask : public WorkerTask { private: bool _unloading_occurred; CodeCacheUnloadingTask _code_cache_task; -#if INCLUDE_JVMCI - JVMCICleaningTask _jvmci_cleaning_task; -#endif KlassCleaningTask _klass_cleaning_task; public: diff --git a/src/hotspot/share/gc/g1/g1YoungCollector.cpp b/src/hotspot/share/gc/g1/g1YoungCollector.cpp index 41060b0e2e5..810b54ec587 100644 --- a/src/hotspot/share/gc/g1/g1YoungCollector.cpp +++ b/src/hotspot/share/gc/g1/g1YoungCollector.cpp @@ -558,9 +558,9 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info) assert(_g1h->verifier()->check_region_attr_table(), "Inconsistency in the region attributes table."); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 allocation_failure_injector()->arm_if_needed(); } diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp index 11da3cb8263..d0c843aa5d6 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp @@ -444,7 +444,7 @@ public: } }; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 class G1PostEvacuateCollectionSetCleanupTask2::UpdateDerivedPointersTask : public G1AbstractSubTask { public: UpdateDerivedPointersTask() : G1AbstractSubTask(G1GCPhaseTimes::UpdateDerivedPointers) { } @@ -452,7 +452,7 @@ public: double worker_cost() const override { return 1.0; } void do_work(uint worker_id) override { DerivedPointerTable::update_pointers(); } }; -#endif +#endif // COMPILER2 class G1PostEvacuateCollectionSetCleanupTask2::EagerlyReclaimHumongousObjectsTask : public G1AbstractSubTask { uint _humongous_regions_reclaimed; @@ -888,9 +888,9 @@ G1PostEvacuateCollectionSetCleanupTask2::G1PostEvacuateCollectionSetCleanupTask2 G1EvacFailureRegions* evac_failure_regions) : G1BatchedTask("Post Evacuate Cleanup 2", G1CollectedHeap::heap()->phase_times()) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 add_serial_task(new UpdateDerivedPointersTask()); -#endif +#endif // COMPILER2 if (G1CollectedHeap::heap()->has_humongous_reclaim_candidates()) { add_serial_task(new EagerlyReclaimHumongousObjectsTask()); } diff --git a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp index bc3a08e2080..557ce454c78 100644 --- a/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp +++ b/src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,9 +60,9 @@ public: // - Reset the reusable PartialArrayStateManager. class G1PostEvacuateCollectionSetCleanupTask2 : public G1BatchedTask { class EagerlyReclaimHumongousObjectsTask; -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 class UpdateDerivedPointersTask; -#endif +#endif // COMPILER2 class ProcessEvacuationFailedRegionsTask; class FreeCollectionSetTask; diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index fa54c3e8668..a4a2bfe72c2 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -96,9 +96,6 @@ #include "utilities/formatBuffer.hpp" #include "utilities/macros.hpp" #include "utilities/stack.inline.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif #include @@ -701,9 +698,9 @@ void PSParallelCompact::post_compact() heap->prune_scavengable_nmethods(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::update_pointers(); -#endif +#endif // COMPILER2 // Signal that we have completed a visit to all live objects. Universe::heap()->record_whole_heap_examined_timestamp(); @@ -977,9 +974,9 @@ bool PSParallelCompact::invoke(bool clear_all_soft_refs, bool should_do_max_comp // Let the size policy know we're starting size_policy->major_collection_begin(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 ref_processor()->start_discovery(clear_all_soft_refs); @@ -987,10 +984,10 @@ bool PSParallelCompact::invoke(bool clear_all_soft_refs, bool should_do_max_comp summary_phase(should_do_max_compaction); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 assert(DerivedPointerTable::is_active(), "Sanity"); DerivedPointerTable::set_active(false); -#endif +#endif // COMPILER2 forward_to_new_addr(); @@ -1171,14 +1168,6 @@ public: _klass_cleaning_task() {} void work(uint worker_id) { -#if INCLUDE_JVMCI - if (EnableJVMCI && worker_id == 0) { - // Serial work; only first worker. - // Clean JVMCI metadata handles. - JVMCI::do_unloading(_unloading_occurred); - } -#endif - // Do first pass of code cache cleaning. _code_cache_task.work(worker_id); diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index e8d5b2ca552..8dbd2485e76 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -355,9 +355,9 @@ bool PSScavenge::invoke(bool clear_soft_refs) { // Let the size policy know we're starting size_policy->minor_collection_begin(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 reference_processor()->start_discovery(clear_soft_refs); @@ -462,9 +462,9 @@ bool PSScavenge::invoke(bool clear_soft_refs) { heap->gc_epilogue(false); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::update_pointers(); -#endif +#endif // COMPILER2 size_policy->record_gc_pause_end_instant(); diff --git a/src/hotspot/share/gc/serial/serialFullGC.cpp b/src/hotspot/share/gc/serial/serialFullGC.cpp index 0c8ca51fc99..13532dea07d 100644 --- a/src/hotspot/share/gc/serial/serialFullGC.cpp +++ b/src/hotspot/share/gc/serial/serialFullGC.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,9 +70,6 @@ #include "utilities/copy.hpp" #include "utilities/events.hpp" #include "utilities/stack.inline.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif Stack SerialFullGC::_marking_stack; Stack SerialFullGC::_objarray_stack; @@ -553,9 +550,6 @@ void SerialFullGC::phase1_mark(bool clear_all_softrefs) { // Prune dead klasses from subklass/sibling/implementor lists. Klass::clean_weak_klass_links(unloading_occurred); - - // Clean JVMCI metadata handles. - JVMCI_ONLY(JVMCI::do_unloading(unloading_occurred)); } { @@ -726,10 +720,10 @@ void SerialFullGC::invoke_at_safepoint(bool clear_all_softrefs) { } // Don't add any more derived pointers during phase3 -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 assert(DerivedPointerTable::is_active(), "Sanity"); DerivedPointerTable::set_active(false); -#endif +#endif // COMPILER2 { // Adjust the pointers to reflect the new locations diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 8eafdfdcc82..5d068ff67e0 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -80,9 +80,6 @@ #include "utilities/macros.hpp" #include "utilities/stack.inline.hpp" #include "utilities/vmError.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif SerialHeap* SerialHeap::heap() { return named_heap(CollectedHeap::Serial); @@ -394,13 +391,13 @@ bool SerialHeap::do_young_collection(bool clear_soft_refs) { Universe::verify("Before GC"); } gc_prologue(); - COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::clear()); + COMPILER2_PRESENT(DerivedPointerTable::clear()); save_marks(); bool result = _young_gen->collect(clear_soft_refs); - COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::update_pointers()); + COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); // Only update stats for successful young-gc if (result) { @@ -573,7 +570,7 @@ void SerialHeap::do_full_collection(bool clear_all_soft_refs) { } gc_prologue(); - COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::clear()); + COMPILER2_PRESENT(DerivedPointerTable::clear()); CodeCache::on_gc_marking_cycle_start(); STWGCTimer* gc_timer = SerialFullGC::gc_timer(); @@ -593,7 +590,7 @@ void SerialHeap::do_full_collection(bool clear_all_soft_refs) { gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions()); CodeCache::on_gc_marking_cycle_finish(); CodeCache::arm_all_nmethods(); - COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::update_pointers()); + COMPILER2_PRESENT(DerivedPointerTable::update_pointers()); // Adjust generation sizes. _old_gen->compute_new_size(); @@ -784,9 +781,9 @@ void SerialHeap::gc_prologue() { }; void SerialHeap::gc_epilogue(bool full) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 assert(DerivedPointerTable::is_empty(), "derived pointer present"); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 resize_all_tlabs(); diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp index a1f03a4bf50..2f7b79beab0 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.cpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.cpp @@ -39,9 +39,6 @@ #include "runtime/threads.hpp" #include "runtime/threadWXSetters.inline.hpp" #include "utilities/debug.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciRuntime.hpp" -#endif int BarrierSetNMethod::disarmed_guard_value() const { return *disarmed_guard_value_address(); @@ -65,7 +62,7 @@ bool BarrierSetNMethod::supports_entry_barrier(nmethod* nm) { return false; } - if (nm->is_native_method() || nm->is_compiled_by_c2() || nm->is_compiled_by_c1() || nm->is_compiled_by_jvmci()) { + if (nm->is_native_method() || nm->is_compiled_by_c2() || nm->is_compiled_by_c1()) { return true; } diff --git a/src/hotspot/share/gc/shared/barrierSetNMethod.hpp b/src/hotspot/share/gc/shared/barrierSetNMethod.hpp index 88bae4d5c1c..812763e429d 100644 --- a/src/hotspot/share/gc/shared/barrierSetNMethod.hpp +++ b/src/hotspot/share/gc/shared/barrierSetNMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,10 +73,6 @@ public: virtual oop oop_load_no_keepalive(const nmethod* nm, int index); virtual oop oop_load_phantom(const nmethod* nm, int index); - -#if INCLUDE_JVMCI - bool verify_barrier(nmethod* nm, FormatBuffer<>& msg); -#endif }; diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp index d6541198858..28bdaa80a27 100644 --- a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp +++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp @@ -112,7 +112,7 @@ void CardTableBarrierSet::print_on(outputStream* st) const { // that specific collector in mind, and the documentation above suitably // extended and updated. void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (!ReduceInitialCardMarks) { return; } @@ -124,5 +124,5 @@ void CardTableBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop ne // Do the card mark write_region(mr); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } diff --git a/src/hotspot/share/gc/shared/collectedHeap.hpp b/src/hotspot/share/gc/shared/collectedHeap.hpp index 100866bb528..0cf47b5fafb 100644 --- a/src/hotspot/share/gc/shared/collectedHeap.hpp +++ b/src/hotspot/share/gc/shared/collectedHeap.hpp @@ -91,7 +91,6 @@ public: class CollectedHeap : public CHeapObj { friend class CPUTimeUsage::GC; friend class VMStructs; - friend class JVMCIVMStructs; friend class IsSTWGCActiveMark; // Block structured external access to _is_stw_gc_active friend class MemAllocator; diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp index b82db08ecbd..342fd16d588 100644 --- a/src/hotspot/share/gc/shared/referenceProcessor.cpp +++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ void ReferenceProcessor::init_statics() { java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock); _always_clear_soft_ref_policy = new AlwaysClearPolicy(); - if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) { + if (CompilerConfig::is_c2_enabled()) { _default_soft_ref_policy = new LRUMaxHeapPolicy(); } else { _default_soft_ref_policy = new LRUCurrentHeapPolicy(); diff --git a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp index 67bc149013e..b2bef8acd46 100644 --- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp +++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp @@ -44,7 +44,6 @@ class ThreadLocalAllocStats; // trip the return and sample the allocation. class ThreadLocalAllocBuffer: public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; private: HeapWord* _start; // address of TLAB HeapWord* _top; // address after last allocation diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp index 0949959b042..d9084ff71ce 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.cpp @@ -100,7 +100,7 @@ bool ShenandoahBarrierSet::need_card_barrier(DecoratorSet decorators, BasicType } void ShenandoahBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (ReduceInitialCardMarks && ShenandoahCardBarrier && !ShenandoahHeap::heap()->is_in_young(new_obj)) { log_debug(gc)("Newly allocated object (" PTR_FORMAT ") is not in the young generation", p2i(new_obj)); // This can happen when an object is newly allocated, but we come to a safepoint before returning @@ -114,7 +114,7 @@ void ShenandoahBarrierSet::on_slowpath_allocation_exit(JavaThread* thread, oop n cast_from_oop(new_obj), new_obj->size() ); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 } void ShenandoahBarrierSet::on_thread_create(Thread* thread) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp index 365226a054c..cd04db383ed 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2014, 2021, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -855,15 +855,15 @@ void ShenandoahFullGC::phase3_update_references() { WorkerThreads* workers = heap->workers(); uint nworkers = workers->active_workers(); { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 ShenandoahRootAdjuster rp(nworkers, ShenandoahPhaseTimings::full_gc_adjust_roots); ShenandoahAdjustRootPointersTask task(&rp, _preserved_marks); workers->run_task(&task); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::update_pointers(); -#endif +#endif // COMPILER2 } ShenandoahAdjustPointersTask adjust_pointers_task; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp index 5a1e8b67694..6c6207e1618 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp @@ -90,9 +90,9 @@ void ShenandoahGC::update_roots(bool full_gc) { ShenandoahPhaseTimings::degen_gc_update_roots; ShenandoahGCPhase phase(p); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::clear(); -#endif +#endif // COMPILER2 ShenandoahHeap* const heap = ShenandoahHeap::heap(); WorkerThreads* workers = heap->workers(); @@ -102,7 +102,7 @@ void ShenandoahGC::update_roots(bool full_gc) { ShenandoahUpdateRootsTask update_roots(&root_updater, check_alive); workers->run_task(&update_roots); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerTable::update_pointers(); -#endif +#endif // COMPILER2 } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index bc48543d113..3e295a6cda4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2022, Red Hat, Inc. All rights reserved. * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -101,9 +101,6 @@ #include "utilities/events.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/powerOfTwo.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif #if INCLUDE_JFR #include "gc/shenandoah/shenandoahJfrSupport.hpp" #endif @@ -2342,9 +2339,6 @@ void ShenandoahHeap::stw_unload_classes(bool full_gc) { ShenandoahGCWorkerPhase worker_phase(phase); bool unloading_occurred = SystemDictionary::do_unloading(gc_timer()); - // Clean JVMCI metadata handles. - JVMCI_ONLY(JVMCI::do_unloading(unloading_occurred)); - ShenandoahClassUnloadingTask unlink_task(phase, unloading_occurred); _workers->run_task(&unlink_task); } diff --git a/src/hotspot/share/gc/z/zBarrierSet.cpp b/src/hotspot/share/gc/z/zBarrierSet.cpp index 15b694b2ecc..5a7e4aa6511 100644 --- a/src/hotspot/share/gc/z/zBarrierSet.cpp +++ b/src/hotspot/share/gc/z/zBarrierSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -208,7 +208,7 @@ static void deoptimize_allocation(JavaThread* thread) { assert(caller_frame.is_compiled_frame(), "must be compiled"); const nmethod* const nm = caller_frame.cb()->as_nmethod(); - if ((nm->is_compiled_by_c2() || nm->is_compiled_by_jvmci()) && !caller_frame.is_deoptimized_frame()) { + if (nm->is_compiled_by_c2() && !caller_frame.is_deoptimized_frame()) { // The JIT might have elided barriers on this object so deoptimize the frame and let the // interpreter deal with it. Deoptimization::deoptimize_frame(thread, caller_frame.id()); diff --git a/src/hotspot/share/interpreter/abstractInterpreter.cpp b/src/hotspot/share/interpreter/abstractInterpreter.cpp index b6a2255b468..5aea7122fab 100644 --- a/src/hotspot/share/interpreter/abstractInterpreter.cpp +++ b/src/hotspot/share/interpreter/abstractInterpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -425,11 +425,11 @@ address AbstractInterpreter::deopt_continue_after_entry(Method* method, address address AbstractInterpreter::deopt_reexecute_entry(Method* method, address bcp) { assert(method->contains(bcp), "just checkin'"); Bytecodes::Code code = Bytecodes::java_code_at(method, bcp); -#if defined(COMPILER1) || INCLUDE_JVMCI +#if defined(COMPILER1) if(code == Bytecodes::_athrow ) { return Interpreter::rethrow_exception_entry(); } -#endif /* COMPILER1 || INCLUDE_JVMCI */ +#endif // COMPILER1 return Interpreter::deopt_entry(vtos, 0); } diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index 375cb402892..0e7ddb0f317 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -533,22 +533,6 @@ JRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea } } while (should_repeat == true); -#if INCLUDE_JVMCI - if (EnableJVMCI && h_method->method_data() != nullptr) { - ResourceMark rm(current); - MethodData* mdo = h_method->method_data(); - - // Lock to read ProfileData, and ensure lock is not broken by a safepoint - MutexLocker ml(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); - - ProfileData* pdata = mdo->allocate_bci_to_data(current_bci, nullptr); - if (pdata != nullptr && pdata->is_BitData()) { - BitData* bit_data = (BitData*) pdata; - bit_data->set_exception_seen(); - } - } -#endif - // notify JVMTI of an exception throw; JVMTI will detect if this is a first // time throw or a stack unwinding throw and accordingly notify the debugger if (JvmtiExport::can_post_on_exceptions()) { @@ -562,10 +546,10 @@ JRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThrea // handler in this method, or (b) after a stack overflow there is not yet // enough stack space available to reprotect the stack. continuation = Interpreter::remove_activation_entry(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Count this for compilation purposes h_method->interpreter_throwout_increment(THREAD); -#endif +#endif // COMPILER2 } else { // handler in this method => change bci/bcp to handler bci/bcp and continue there handler_pc = h_method->code_base() + handler_bci; diff --git a/src/hotspot/share/interpreter/invocationCounter.hpp b/src/hotspot/share/interpreter/invocationCounter.hpp index 3578f2ed777..8803942a9e9 100644 --- a/src/hotspot/share/interpreter/invocationCounter.hpp +++ b/src/hotspot/share/interpreter/invocationCounter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ class InvocationCounter { friend class VMStructs; - friend class JVMCIVMStructs; friend class ciReplay; private: // bit no: |31 1| 0 | uint _counter; // format: [count|carry| diff --git a/src/hotspot/share/interpreter/linkResolver.hpp b/src/hotspot/share/interpreter/linkResolver.hpp index 6308e0e09ad..56d26cb8567 100644 --- a/src/hotspot/share/interpreter/linkResolver.hpp +++ b/src/hotspot/share/interpreter/linkResolver.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,11 +214,9 @@ class LinkResolver: AllStatic { static Method* lookup_polymorphic_method(const LinkInfo& link_info, Handle *appendix_result_or_null, TRAPS); - JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod() // Not Linktime so doesn't take LinkInfo static Method* lookup_instance_method_in_klasses (Klass* klass, Symbol* name, Symbol* signature, Klass::PrivateLookupMode private_mode); - JVMCI_ONLY(private:) // Similar loader constraint checking functions that throw // LinkageError with descriptive message. diff --git a/src/hotspot/share/jfr/jfr.cpp b/src/hotspot/share/jfr/jfr.cpp index d9892f80b6f..b30f80d23b7 100644 --- a/src/hotspot/share/jfr/jfr.cpp +++ b/src/hotspot/share/jfr/jfr.cpp @@ -149,12 +149,6 @@ void Jfr::on_resolution(const Parse* parse, const ciKlass* holder, const ciMetho } #endif -#if INCLUDE_JVMCI -void Jfr::on_resolution(const Method* caller, const Method* target, TRAPS) { - JfrResolution::on_jvmci_resolution(caller, target, CHECK); -} -#endif - void Jfr::on_vm_shutdown(bool exception_handler /* false */, bool halt /* false */, bool oom /* false */) { if (!halt && JfrRecorder::is_recording()) { JfrEmergencyDump::on_vm_shutdown(exception_handler, oom); diff --git a/src/hotspot/share/jfr/leakprofiler/utilities/rootType.cpp b/src/hotspot/share/jfr/leakprofiler/utilities/rootType.cpp index 9b06caae555..d777ce961af 100644 --- a/src/hotspot/share/jfr/leakprofiler/utilities/rootType.cpp +++ b/src/hotspot/share/jfr/leakprofiler/utilities/rootType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,10 +56,6 @@ const char* OldObjectRoot::system_description(System system) { return "Class Loader Data"; case _code_cache: return "Code Cache"; -#if INCLUDE_JVMCI - case _jvmci: - return "JVMCI"; -#endif default: ShouldNotReachHere(); } diff --git a/src/hotspot/share/jfr/leakprofiler/utilities/rootType.hpp b/src/hotspot/share/jfr/leakprofiler/utilities/rootType.hpp index ce975e9b802..cff981d2f35 100644 --- a/src/hotspot/share/jfr/leakprofiler/utilities/rootType.hpp +++ b/src/hotspot/share/jfr/leakprofiler/utilities/rootType.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ class OldObjectRoot : public AllStatic { _strong_oop_storage_set_last = _strong_oop_storage_set_first + EnumRange().size() - 1, _class_loader_data, _code_cache, - JVMCI_ONLY(_jvmci COMMA) _number_of_systems }; diff --git a/src/hotspot/share/jfr/support/jfrResolution.cpp b/src/hotspot/share/jfr/support/jfrResolution.cpp index 3a00d24d455..eee3b110c95 100644 --- a/src/hotspot/share/jfr/support/jfrResolution.cpp +++ b/src/hotspot/share/jfr/support/jfrResolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,14 +214,6 @@ void JfrResolution::on_runtime_resolution(const CallInfo & info, TRAPS) { if (IS_METHOD_BLESSED(sender)) { return; } -#if INCLUDE_JVMCI - // JVMCI compiler is doing linktime resolution - if (sender->method_holder()->name() == vmSymbols::jdk_vm_ci_hotspot_CompilerToVM()) { - if (sender->name()->equals("lookupMethodInPool")) { - return; - } - } -#endif THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), link_error_msg); } @@ -280,14 +272,3 @@ void JfrResolution::on_c2_resolution(const Parse * parse, const ciKlass * holder } } #endif - -#if INCLUDE_JVMCI -// JVMCI -void JfrResolution::on_jvmci_resolution(const Method* caller, const Method* target, TRAPS) { - if (is_compiler_linking_event_writer(target->method_holder()->name(), target->name())) { - if (caller == nullptr || !IS_METHOD_BLESSED(caller)) { - THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), link_error_msg); - } - } -} -#endif diff --git a/src/hotspot/share/jfr/support/jfrResolution.hpp b/src/hotspot/share/jfr/support/jfrResolution.hpp index 8051262653f..740ba01dd35 100644 --- a/src/hotspot/share/jfr/support/jfrResolution.hpp +++ b/src/hotspot/share/jfr/support/jfrResolution.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ class JfrResolution : AllStatic { static void on_runtime_resolution(const CallInfo & info, TRAPS); static void on_c1_resolution(const GraphBuilder * builder, const ciKlass * holder, const ciMethod * target); static void on_c2_resolution(const Parse * parse, const ciKlass * holder, const ciMethod * target); - static void on_jvmci_resolution(const Method* caller, const Method* target, TRAPS); static void on_backpatching(const Method* callee_method, JavaThread* jt); }; diff --git a/src/hotspot/share/jfr/support/jfrThreadLocal.hpp b/src/hotspot/share/jfr/support/jfrThreadLocal.hpp index 5fff03d4408..fc3b06d979a 100644 --- a/src/hotspot/share/jfr/support/jfrThreadLocal.hpp +++ b/src/hotspot/share/jfr/support/jfrThreadLocal.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ class JfrThreadLocal { friend class Jfr; friend class JfrIntrinsicSupport; friend class JfrJavaSupport; - friend class JVMCIVMStructs; private: mutable JfrSampleRequest _sample_request; JfrSampleRequestQueue _sample_request_queue; diff --git a/src/hotspot/share/jvmci/jniAccessMark.inline.hpp b/src/hotspot/share/jvmci/jniAccessMark.inline.hpp deleted file mode 100644 index a4b92bdc5c1..00000000000 --- a/src/hotspot/share/jvmci/jniAccessMark.inline.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP -#define SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP - -// No jniAccessMark.hpp - -#include "code/nmethod.hpp" -#include "jvmci/jvmciEnv.hpp" -#include "runtime/interfaceSupport.inline.hpp" - -// Wrapper for a JNI call into the JVMCI shared library. -// This performs a ThreadToNativeFromVM transition so that the VM -// will not be blocked if the call takes a long time (e.g., due -// to a GC in the shared library). -class JNIAccessMark : public StackObj { - private: - ThreadToNativeFromVM _ttnfv; - HandleMark _hm; - JNIEnv* _env; - public: - inline JNIAccessMark(JVMCIEnv* jvmci_env, JavaThread* thread=JavaThread::current()) : - _ttnfv(thread), _hm(thread) { - _env = jvmci_env->_env; - guarantee(jvmci_env->init_error() == JNI_OK, "invalid JVMCIEnv (err: %d)", jvmci_env->init_error()); - } - JNIEnv* env() const { return _env; } - JNIEnv* operator () () const { return _env; } -}; - -#endif // SHARE_JVMCI_JNIACCESSMARK_INLINE_HPP diff --git a/src/hotspot/share/jvmci/jvmci.cpp b/src/hotspot/share/jvmci/jvmci.cpp deleted file mode 100644 index e9f247f4f02..00000000000 --- a/src/hotspot/share/jvmci/jvmci.cpp +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/systemDictionary.hpp" -#include "compiler/abstractCompiler.hpp" -#include "compiler/compilerThread.hpp" -#include "compiler/compileTask.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/metadataHandles.hpp" -#include "memory/resourceArea.hpp" -#include "memory/universe.hpp" -#include "runtime/arguments.hpp" -#include "runtime/atomicAccess.hpp" -#include "runtime/javaThread.inline.hpp" -#include "runtime/os.hpp" -#include "utilities/events.hpp" - -JVMCIRuntime* JVMCI::_compiler_runtimes = nullptr; -JVMCIRuntime* JVMCI::_java_runtime = nullptr; -JVMCIRuntime* JVMCI::_shutdown_compiler_runtime = nullptr; -volatile bool JVMCI::_is_initialized = false; -bool JVMCI::_box_caches_initialized = false; -void* JVMCI::_shared_library_handle = nullptr; -char* JVMCI::_shared_library_path = nullptr; -volatile bool JVMCI::_in_shutdown = false; -StringEventLog* JVMCI::_events = nullptr; -StringEventLog* JVMCI::_verbose_events = nullptr; -volatile intx JVMCI::_first_error_tid = -1; -volatile int JVMCI::_fatal_log_fd = -1; -const char* JVMCI::_fatal_log_filename = nullptr; - -CompilerThread* CompilerThreadCanCallJava::update(JavaThread* current, bool new_state) { - if (current->is_Compiler_thread()) { - CompilerThread* ct = CompilerThread::cast(current); - if (ct->_can_call_java != new_state && - ct->_compiler != nullptr && - ct->_compiler->is_jvmci()) - { - // Only update the state if the ability of the - // current thread to call Java actually changes - ct->_can_call_java = new_state; - return ct; - } - } - return nullptr; -} - -CompilerThreadCanCallJava::CompilerThreadCanCallJava(JavaThread* current, bool new_state) { - _current = CompilerThreadCanCallJava::update(current, new_state); -} - -CompilerThreadCanCallJava::~CompilerThreadCanCallJava() { - if (_current != nullptr) { - _current->_can_call_java = !_current->_can_call_java; - } -} - -void jvmci_vmStructs_init() NOT_DEBUG_RETURN; - -bool JVMCI::can_initialize_JVMCI() { - if (UseJVMCINativeLibrary) { - // Initializing libjvmci does not execute Java code so - // can be done any time. - return true; - } - // Initializing JVMCI requires the module system to be initialized past phase 3. - // The JVMCI API itself isn't available until phase 2 and ServiceLoader (which - // JVMCI initialization requires) isn't usable until after phase 3. Testing - // whether the system loader is initialized satisfies all these invariants. - if (SystemDictionary::java_system_loader() == nullptr) { - return false; - } - assert(Universe::is_module_initialized(), "must be"); - return true; -} - -bool JVMCI::get_shared_library_path(char* pathbuf, size_t pathlen, bool fail_is_fatal) { - if (JVMCILibPath != nullptr) { - if (!os::dll_locate_lib(pathbuf, pathlen, JVMCILibPath, JVMCI_SHARED_LIBRARY_NAME)) { - if (!fail_is_fatal) { - return false; - } - fatal("Unable to create path to JVMCI shared library based on value of JVMCILibPath (%s)", JVMCILibPath); - } - } else { - if (!os::dll_locate_lib(pathbuf, pathlen, Arguments::get_dll_dir(), JVMCI_SHARED_LIBRARY_NAME)) { - if (!fail_is_fatal) { - return false; - } - fatal("Unable to create path to JVMCI shared library"); - } - } - return true; -} - -bool JVMCI::shared_library_exists() { - if (_shared_library_handle != nullptr) { - return true; - } - char path[JVM_MAXPATHLEN]; - return get_shared_library_path(path, sizeof(path), false); -} - -void* JVMCI::get_shared_library(char*& path, bool load) { - void* sl_handle = _shared_library_handle; - if (sl_handle != nullptr || !load) { - path = _shared_library_path; - return sl_handle; - } - MutexLocker locker(JVMCI_lock); - path = nullptr; - if (_shared_library_handle == nullptr) { - char path[JVM_MAXPATHLEN]; - char ebuf[1024]; - get_shared_library_path(path, sizeof(path), true); - - void* handle = os::dll_load(path, ebuf, sizeof ebuf); - if (handle == nullptr) { - fatal("Unable to load JVMCI shared library from %s: %s", path, ebuf); - } - _shared_library_handle = handle; - _shared_library_path = os::strdup(path); - - JVMCI_event_1("loaded JVMCI shared library from %s", path); - } - path = _shared_library_path; - return _shared_library_handle; -} - -void JVMCI::initialize_compiler_in_create_vm(TRAPS) { - if (JVMCILibDumpJNIConfig) { - JNIJVMCI::initialize_ids(nullptr); - ShouldNotReachHere(); - } - JVMCIRuntime* runtime; - if (UseJVMCINativeLibrary) { - runtime = JVMCI::compiler_runtime(THREAD); - } else { - runtime = JVMCI::java_runtime(); - } - - JVMCIENV_FROM_THREAD(THREAD); - JVMCIENV->check_init(CHECK); - JVMCIObject jvmciRuntime = runtime->get_HotSpotJVMCIRuntime(JVMCI_CHECK); - runtime->initialize(JVMCI_CHECK); - JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK); -} - -void JVMCI::initialize_globals() { - jvmci_vmStructs_init(); - if (LogEvents) { - if (JVMCIEventLogLevel > 0) { - _events = new StringEventLog("JVMCI Events", "jvmci"); - if (JVMCIEventLogLevel > 1) { - int count = LogEventsBufferEntries; - for (int i = 1; i < JVMCIEventLogLevel && i < max_EventLog_level; i++) { - // Expand event buffer by 10x for each level above 1 - count = count * 10; - } - _verbose_events = new StringEventLog("Verbose JVMCI Events", "verbose-jvmci", count); - } - } - } - _java_runtime = new JVMCIRuntime(nullptr, -1, false); - if (using_singleton_shared_library_runtime()) { - JVMCI::_compiler_runtimes = new JVMCIRuntime(nullptr, 0, true); - } -} - -void JVMCI::ensure_box_caches_initialized(TRAPS) { - if (_box_caches_initialized) { - return; - } - - // While multiple threads may reach here, that's fine - // since class initialization is synchronized. - Symbol* box_classes[] = { - java_lang_Boolean::symbol(), - java_lang_Byte_ByteCache::symbol(), - java_lang_Short_ShortCache::symbol(), - java_lang_Character_CharacterCache::symbol(), - java_lang_Integer_IntegerCache::symbol(), - java_lang_Long_LongCache::symbol() - }; - - // Class resolution and initialization below - // requires calling into Java - CompilerThreadCanCallJava ccj(THREAD, true); - - for (unsigned i = 0; i < sizeof(box_classes) / sizeof(Symbol*); i++) { - Klass* k = SystemDictionary::resolve_or_fail(box_classes[i], true, CHECK); - InstanceKlass* ik = InstanceKlass::cast(k); - if (ik->is_not_initialized()) { - ik->initialize(CHECK); - } - } - _box_caches_initialized = true; -} - -JVMCIRuntime* JVMCI::compiler_runtime(JavaThread* thread, bool create) { - assert(thread->is_Java_thread(), "must be") ; - assert(UseJVMCINativeLibrary, "must be"); - JVMCIRuntime* runtime = thread->libjvmci_runtime(); - if (runtime == nullptr && create) { - runtime = JVMCIRuntime::for_thread(thread); - } - return runtime; -} - -JavaThread* JVMCI::compilation_tick(JavaThread* thread) { - if (thread->is_Compiler_thread()) { - CompileTask *task = CompilerThread::cast(thread)->task(); - if (task != nullptr) { - JVMCICompileState *state = task->blocking_jvmci_compile_state(); - if (state != nullptr) { - state->inc_compilation_ticks(); - } - } - } - return thread; -} - -void JVMCI::metadata_do(void f(Metadata*)) { - if (_java_runtime != nullptr) { - _java_runtime->_metadata_handles->metadata_do(f); - } - for (JVMCIRuntime* runtime = _compiler_runtimes; runtime != nullptr; runtime = runtime->_next) { - runtime->_metadata_handles->metadata_do(f); - } - if (_shutdown_compiler_runtime != nullptr) { - _shutdown_compiler_runtime->_metadata_handles->metadata_do(f); - } -} - -void JVMCI::do_unloading(bool unloading_occurred) { - if (unloading_occurred) { - if (_java_runtime != nullptr) { - _java_runtime->_metadata_handles->do_unloading(); - } - for (JVMCIRuntime* runtime = _compiler_runtimes; runtime != nullptr; runtime = runtime->_next) { - runtime->_metadata_handles->do_unloading(); - } - if (_shutdown_compiler_runtime != nullptr) { - _shutdown_compiler_runtime->_metadata_handles->do_unloading(); - } - } -} - -bool JVMCI::is_compiler_initialized() { - return _is_initialized; -} - -void JVMCI::vlog(int level, const char* format, va_list ap) { - if (LogEvents && JVMCIEventLogLevel >= level) { - StringEventLog* events = level == 1 ? _events : _verbose_events; - guarantee(events != nullptr, "JVMCI event log not yet initialized"); - Thread* thread = Thread::current_or_null_safe(); - if (thread != nullptr) { - events->logv(thread, format, ap); - } - } -} - -void JVMCI::vtrace(int level, const char* format, va_list ap) { - if (JVMCITraceLevel >= level) { - Thread* thread = Thread::current_or_null_safe(); - if (thread != nullptr && thread->is_Java_thread()) { - ResourceMark rm(thread); - JavaThreadState state = JavaThread::cast(thread)->thread_state(); - if (state == _thread_in_vm || state == _thread_in_Java || state == _thread_new) { - tty->print("JVMCITrace-%d[" PTR_FORMAT " \"%s\"]:%*c", level, p2i(thread), thread->name(), level, ' '); - } else { - // According to check_access_thread_state, it's unsafe to - // resolve the j.l.Thread object unless the thread is in - // one of the states above. - tty->print("JVMCITrace-%d[" PTR_FORMAT " <%s>]:%*c", level, p2i(thread), thread->type_name(), level, ' '); - } - } else { - tty->print("JVMCITrace-%d[?]:%*c", level, level, ' '); - } - tty->vprint_cr(format, ap); - } -} - -#define LOG_TRACE(level) { va_list ap; \ - va_start(ap, format); vlog(level, format, ap); va_end(ap); \ - va_start(ap, format); vtrace(level, format, ap); va_end(ap); \ -} - -void JVMCI::event(int level, const char* format, ...) LOG_TRACE(level) -void JVMCI::event1(const char* format, ...) LOG_TRACE(1) -void JVMCI::event2(const char* format, ...) LOG_TRACE(2) -void JVMCI::event3(const char* format, ...) LOG_TRACE(3) -void JVMCI::event4(const char* format, ...) LOG_TRACE(4) - -#undef LOG_TRACE - -void JVMCI::shutdown(JavaThread* thread) { - ResourceMark rm; - { - MutexLocker locker(JVMCI_lock); - _in_shutdown = true; - JVMCI_event_1("shutting down JVMCI"); - } - JVMCIRuntime* java_runtime = _java_runtime; - if (java_runtime != nullptr) { - java_runtime->shutdown(); - } - JVMCIRuntime* runtime = thread->libjvmci_runtime(); - if (runtime != nullptr) { - runtime->detach_thread(thread, "JVMCI shutdown"); - } - { - // Attach to JVMCI initialized runtimes that are not already shutting down - // and shut them down. This ensures HotSpotJVMCIRuntime.shutdown() is called - // for each JVMCI runtime. - MutexLocker locker(JVMCI_lock); - for (JVMCIRuntime* rt = JVMCI::_compiler_runtimes; rt != nullptr; rt = rt->_next) { - if (rt->is_HotSpotJVMCIRuntime_initialized() && rt->_num_attached_threads != JVMCIRuntime::cannot_be_attached) { - rt->_num_attached_threads++; - { - MutexUnlocker unlocker(JVMCI_lock); - rt->attach_thread(thread); - rt->shutdown(); - rt->detach_thread(thread, "JVMCI shutdown"); - } - } - } - } -} - -bool JVMCI::in_shutdown() { - return _in_shutdown; -} - -void JVMCI::fatal_log(const char* buf, size_t count) { - intx current_thread_id = os::current_thread_id(); - intx invalid_id = -1; - int log_fd; - if (_first_error_tid == invalid_id && AtomicAccess::cmpxchg(&_first_error_tid, invalid_id, current_thread_id) == invalid_id) { - if (ErrorFileToStdout) { - log_fd = 1; - } else if (ErrorFileToStderr) { - log_fd = 2; - } else { - static char name_buffer[O_BUFLEN]; - log_fd = VMError::prepare_log_file(JVMCINativeLibraryErrorFile, LIBJVMCI_ERR_FILE, true, name_buffer, sizeof(name_buffer)); - if (log_fd != -1) { - _fatal_log_filename = name_buffer; - } else { - int e = errno; - tty->print("Can't open JVMCI shared library error report file. Error: "); - tty->print_raw_cr(os::strerror(e)); - tty->print_cr("JVMCI shared library error report will be written to console."); - - // See notes in VMError::report_and_die about hard coding tty to 1 - log_fd = 1; - } - } - _fatal_log_fd = log_fd; - } else if (_first_error_tid != current_thread_id) { - // This is not the first thread reporting a libjvmci error - tty->print_cr("[thread %zd also had an error in the JVMCI native library]", - current_thread_id); - - // Fatal error reporting is single threaded so just block this thread. - os::infinite_sleep(); - } - fdStream log(_fatal_log_fd); - log.write(buf, count); - log.flush(); -} diff --git a/src/hotspot/share/jvmci/jvmci.hpp b/src/hotspot/share/jvmci/jvmci.hpp deleted file mode 100644 index 02609fb6bb9..00000000000 --- a/src/hotspot/share/jvmci/jvmci.hpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCI_HPP -#define SHARE_JVMCI_JVMCI_HPP - -#include "compiler/compiler_globals.hpp" -#include "compiler/compilerDefinitions.hpp" -#include "utilities/exceptions.hpp" - -class BoolObjectClosure; -class CompilerThread; -class constantPoolHandle; -class JavaThread; -class JVMCIEnv; -class JVMCIRuntime; -class Metadata; -class MetadataHandleBlock; -class OopClosure; -class OopStorage; - -template -class FormatStringEventLog; - -typedef FormatStringEventLog<256> StringEventLog; - -struct _jmetadata; -typedef struct _jmetadata *jmetadata; - -// A stack object that manages a scope in which the current thread, if -// it's a CompilerThread, can have its CompilerThread::_can_call_java -// field changed. This allows restricting libjvmci better in terms -// of when it can make Java calls. If a Java call on a CompilerThread -// reaches a clinit, there's a risk of dead-lock when async compilation -// is disabled (e.g. -Xbatch or -Xcomp) as the non-CompilerThread thread -// waiting for the blocking compilation may hold the clinit lock. -// -// This scope is primarily used to disable Java calls when libjvmci enters -// the VM via a C2V (i.e. CompilerToVM) native method. -class CompilerThreadCanCallJava : StackObj { - private: - CompilerThread* _current; // Only non-null if state of thread changed -public: - // If the current thread is a CompilerThread associated with - // a JVMCI compiler where CompilerThread::_can_call_java != new_state, - // then _can_call_java is set to `new_state` - // Returns nullptr if no change was made, otherwise the current CompilerThread - static CompilerThread* update(JavaThread* current, bool new_state); - - CompilerThreadCanCallJava(JavaThread* current, bool new_state); - - // Resets CompilerThread::_can_call_java of the current thread if the - // constructor changed it. - ~CompilerThreadCanCallJava(); -}; - -class JVMCI : public AllStatic { - friend class JVMCIRuntime; - friend class JVMCIEnv; - - private: - // List of libjvmci based JVMCIRuntimes. - // Should only be accessed under JVMCI_lock. - static JVMCIRuntime* _compiler_runtimes; - - // Special libjvmci based JVMCIRuntime reserved for - // threads trying to attach when in JVMCI shutdown. - // This preserves the invariant that JVMCIRuntime::for_thread() - // never returns null. - static JVMCIRuntime* _shutdown_compiler_runtime; - - // True when at least one JVMCIRuntime::initialize_HotSpotJVMCIRuntime() - // execution has completed successfully. - static volatile bool _is_initialized; - - // True once boxing cache classes are guaranteed to be initialized. - static bool _box_caches_initialized; - - // Handle created when loading the JVMCI shared library with os::dll_load. - // Must hold JVMCI_lock when initializing. - static void* _shared_library_handle; - - // Argument to os::dll_load when loading JVMCI shared library - static char* _shared_library_path; - - // Records whether JVMCI::shutdown has been called. - static volatile bool _in_shutdown; - - // Access to the HotSpot heap based JVMCIRuntime - static JVMCIRuntime* _java_runtime; - - // The file descriptor to which fatal_log() writes. Initialized on - // first call to fatal_log(). - static volatile int _fatal_log_fd; - - // The path of the file underlying _fatal_log_fd if it is a normal file. - static const char* _fatal_log_filename; - - // Thread id of the first thread reporting a libjvmci error. - static volatile intx _first_error_tid; - - // JVMCI event log (shows up in hs_err crash logs). - static StringEventLog* _events; - static StringEventLog* _verbose_events; - enum { - max_EventLog_level = 4 - }; - - // Gets the Thread* value for the current thread or null if it's not available. - static Thread* current_thread_or_null(); - - // Writes into `pathbuf` the path to the existing JVMCI shared library file. - // If the file cannot be found and `fail_is_fatal` is true, then - // a fatal error occurs. - // Returns whether the path to an existing file was written into `pathbuf`. - static bool get_shared_library_path(char* pathbuf, size_t pathlen, bool fail_is_fatal); - - public: - - enum CodeInstallResult { - ok, - dependencies_failed, - cache_full, - nmethod_reclaimed, - code_too_large, - first_permanent_bailout = code_too_large - }; - - // Returns true iff JVMCIThreadsPerNativeLibraryRuntime == 0. - static bool using_singleton_shared_library_runtime() { - return JVMCIThreadsPerNativeLibraryRuntime == 0; - } - - // Returns true iff there is a new shared library JavaVM per compilation. - static bool one_shared_library_javavm_per_compilation() { - return JVMCIThreadsPerNativeLibraryRuntime == 1 && JVMCICompilerIdleDelay == 0; - } - - // Determines if the JVMCI shared library exists. This does not - // take into account whether loading the library would succeed - // if it's not already loaded. - static bool shared_library_exists(); - - // Gets the handle to the loaded JVMCI shared library, loading it - // first if not yet loaded and `load` is true. The path from - // which the library is loaded is returned in `path`. - static void* get_shared_library(char*& path, bool load); - - // Logs the fatal crash data in `buf` to the appropriate stream. - static void fatal_log(const char* buf, size_t count); - - // Gets the name of the opened JVMCI shared library crash data file or null - // if this file has not been created. - static const char* fatal_log_filename() { return _fatal_log_filename; } - - static void do_unloading(bool unloading_occurred); - - static void metadata_do(void f(Metadata*)); - - static void shutdown(JavaThread* thread); - - // Returns whether JVMCI::shutdown has been called. - static bool in_shutdown(); - - static bool is_compiler_initialized(); - - /** - * Determines if the VM is sufficiently booted to initialize JVMCI. - */ - static bool can_initialize_JVMCI(); - - static void initialize_globals(); - - // Initializes the JVMCI compiler during VM startup. - static void initialize_compiler_in_create_vm(TRAPS); - - // Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized. - static void ensure_box_caches_initialized(TRAPS); - - // Increments a value indicating some JVMCI compilation activity - // happened on `thread` if it is a CompilerThread. - // Returns `thread`. - static JavaThread* compilation_tick(JavaThread* thread); - - // Gets the single runtime for JVMCI on the Java heap. This is the only - // JVMCI runtime available when !UseJVMCINativeLibrary. - static JVMCIRuntime* java_runtime() { return _java_runtime; } - - // Gets the JVMCI shared library runtime associated with `thread`. - // This must only be called when UseJVMCINativeLibrary is true. - // If `create` is true and there is no runtime currently associated with - // `thread`, this method creates one. - static JVMCIRuntime* compiler_runtime(JavaThread* thread, bool create=true); - - // Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level` - static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - - // Traces an event to tty if JVMCITraceLevel >= `level` - static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); - - public: - // Log/trace a JVMCI event - static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3); - static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); - static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); -}; - -// JVMCI event macros. -#define JVMCI_event_1 if (JVMCITraceLevel < 1 && JVMCIEventLogLevel < 1) ; else ::JVMCI::event1 -#define JVMCI_event_2 if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2 -#define JVMCI_event_3 if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3 -#define JVMCI_event_4 if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4 - -#endif // SHARE_JVMCI_JVMCI_HPP diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp deleted file mode 100644 index 6043b400e3b..00000000000 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ /dev/null @@ -1,1369 +0,0 @@ -/* - * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/javaClasses.inline.hpp" -#include "code/compiledIC.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/compilerThread.hpp" -#include "compiler/oopMap.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "memory/universe.hpp" -#include "oops/compressedKlass.inline.hpp" -#include "oops/klass.inline.hpp" -#include "prims/jvmtiExport.hpp" -#include "prims/methodHandles.hpp" -#include "runtime/arguments.hpp" -#include "runtime/interfaceSupport.inline.hpp" -#include "runtime/jniHandles.inline.hpp" -#include "runtime/os.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/align.hpp" - -// frequently used constants -// Allocate them with new so they are never destroyed (otherwise, a -// forced exit could destroy these objects while they are still in -// use). -ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (mtJVMCI) ConstantOopWriteValue(nullptr); -ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (mtJVMCI) ConstantIntValue(-1); -ConstantIntValue* CodeInstaller::_int_0_scope_value = new (mtJVMCI) ConstantIntValue((jint)0); -ConstantIntValue* CodeInstaller::_int_1_scope_value = new (mtJVMCI) ConstantIntValue(1); -ConstantIntValue* CodeInstaller::_int_2_scope_value = new (mtJVMCI) ConstantIntValue(2); -LocationValue* CodeInstaller::_illegal_value = new (mtJVMCI) LocationValue(Location()); -MarkerValue* CodeInstaller::_virtual_byte_array_marker = new (mtJVMCI) MarkerValue(); - -static bool is_set(u1 flags, u1 bit) { - return flags & bit; -} - -oop HotSpotCompiledCodeStream::get_oop(int id, JVMCI_TRAPS) const { - if (_object_pool.is_null()) { - JVMCI_ERROR_NULL("object pool is null%s", context()); - } - if (!_object_pool.is_null() && 0 <= id && id < _object_pool->length()) { - return _object_pool->obj_at(id); - } - JVMCI_ERROR_NULL("unknown direct object id %d%s", id, context()); -} - -u4 HotSpotCompiledCodeStream::offset() const { - u4 res = 0; - for (Chunk* c = _head; c != nullptr; c = c->next()) { - if (c == _chunk) { - res += _pos - c->data(); - break; - } else { - res += c->size(); - } - } - return res; -} - -bool HotSpotCompiledCodeStream::available() const { - u4 rem = _chunk->data_end() - _pos; - for (Chunk* c = _chunk->next(); c != nullptr; c = c->next()) { - rem += c->size(); - } - return rem; -} - -void HotSpotCompiledCodeStream::dump_buffer(outputStream* st) const { - st->print_cr("HotSpotCompiledCode stream for %s:", code_desc()); - int chunk_index = 0; - for (Chunk* c = _head; c != nullptr; c = c->next()) { - const u1* data = c->data(); - const u1* data_end = c->data_end(); - - int to_dump = data_end - data; - st->print_cr("# chunk %d, %d bytes", chunk_index, to_dump); - st->print_data((void*) data, to_dump, true, false); - chunk_index++; - } -} - -void HotSpotCompiledCodeStream::dump_buffer_tail(int len, outputStream* st) const { - const u1* start; - int avail = _pos - _chunk->data(); - if (len >= avail) { - len = avail; - start = _chunk->data(); - } else { - start = _pos - len; - - // Ensure start is 16-byte aligned wrt chunk start - int start_offset = start - _chunk->data(); - start -= (start_offset % 16); - len = _pos - start; - } - - st->print_cr("Last %d bytes up to current read position " INTPTR_FORMAT " in HotSpotCompiledCode stream for %s:", len, p2i(_pos), code_desc()); - st->print_data((void*) start, len, true, false); -} - -const char* HotSpotCompiledCodeStream::context() const { - stringStream st; - st.cr(); - st.print_cr("at " INTPTR_FORMAT " in HotSpotCompiledCode stream", p2i(_pos)); - dump_buffer_tail(100, &st); - return st.as_string(); -} - -void HotSpotCompiledCodeStream::before_read(u1 size) { - if (_pos + size > _chunk->data_end()) { - Chunk* next = _chunk->next(); - if (next == nullptr || size > next->size()) { - dump_buffer(); - fatal("%s: reading %d bytes overflows buffer at " INTPTR_FORMAT, code_desc(), size, p2i(_pos)); - } - _chunk = next; - _pos = _chunk->data(); - } -} - -// Reads a size followed by an ascii string from the stream and -// checks that they match `expect_size` and `expect_name` respectively. This -// implements a rudimentary type checking of the stream between the stream producer -// (Java) and the consumer (C++). -void HotSpotCompiledCodeStream::check_data(u2 expect_size, const char* expect_name) { - u2 actual_size = get_u1(); - u2 ascii_len = get_u1(); - const char* actual_name = (const char*) _pos; - char* end = (char*) _pos + ascii_len; - _pos = (const u1*) end; - if (strlen(expect_name) != ascii_len || strncmp(expect_name, actual_name, ascii_len) != 0) { - dump_buffer(); - fatal("%s: expected \"%s\" at " INTPTR_FORMAT ", got \"%.*s\" (len: %d)", - code_desc(), expect_name, p2i(actual_name), ascii_len, actual_name, ascii_len); - } - if (actual_size != expect_size) { - dump_buffer(); - fatal("%s: expected \"%s\" at " INTPTR_FORMAT " to have size %u, got %u", - code_desc(), expect_name, p2i(actual_name), expect_size, actual_size); - } -} - -const char* HotSpotCompiledCodeStream::read_utf8(const char* name, JVMCI_TRAPS) { - jint utf_len = read_s4(name); - if (utf_len == -1) { - return nullptr; - } - guarantee(utf_len >= 0, "bad utf_len: %d", utf_len); - - const char* utf = (const char*) _pos; - char* end = (char*) _pos + utf_len; - _pos = (const u1*) (end + 1); - if (*end != '\0') { - JVMCI_ERROR_NULL("UTF8 string at " INTPTR_FORMAT " of length %d missing 0 terminator: \"%.*s\"%s", - p2i(utf), utf_len, utf_len, utf, context()); - } - return utf; -} - -Method* HotSpotCompiledCodeStream::read_method(const char* name) { - return (Method*) read_u8(name); -} - -Klass* HotSpotCompiledCodeStream::read_klass(const char* name) { - return (Klass*) read_u8(name); -} - -ScopeValue* HotSpotCompiledCodeStream::virtual_object_at(int id, JVMCI_TRAPS) const { - if (_virtual_objects == nullptr) { - JVMCI_ERROR_NULL("virtual object id %d read outside scope of decoding DebugInfo%s", id, context()); - } - if (id < 0 || id >= _virtual_objects->length()) { - JVMCI_ERROR_NULL("invalid virtual object id %d%s", id, context()); - } - return _virtual_objects->at(id); -} - -#ifndef PRODUCT -void CodeInstaller::verify_bci_constants(JVMCIEnv* env) { -#define CHECK_IN_SYNC(name) do { \ - int expect = env->get_BytecodeFrame_ ## name ##_BCI(); \ - int actual = name##_BCI; \ - if (expect != actual) fatal("CodeInstaller::" #name "_BCI(%d) != BytecodeFrame." #name "_BCI(%d)", expect, actual); \ -} while(0) - - CHECK_IN_SYNC(UNWIND); - CHECK_IN_SYNC(BEFORE); - CHECK_IN_SYNC(AFTER); - CHECK_IN_SYNC(AFTER_EXCEPTION); - CHECK_IN_SYNC(UNKNOWN); - CHECK_IN_SYNC(INVALID_FRAMESTATE); -#undef CHECK_IN_SYNC -} -#endif - -VMReg CodeInstaller::getVMRegFromLocation(HotSpotCompiledCodeStream* stream, int total_frame_size, JVMCI_TRAPS) { - u2 reg = stream->read_u2("register"); - u2 offset = stream->read_u2("offset"); - - if (reg != NO_REGISTER) { - VMReg vmReg = CodeInstaller::get_hotspot_reg(reg, JVMCI_CHECK_NULL); - if (offset % 4 == 0) { - return vmReg->next(offset / 4); - } else { - JVMCI_ERROR_NULL("unaligned subregister offset %d in oop map%s", offset, stream->context()); - } - } else { - if (offset % 4 == 0) { - VMReg vmReg = VMRegImpl::stack2reg(offset / 4); - if (!OopMapValue::legal_vm_reg_name(vmReg)) { - // This restriction only applies to VMRegs that are used in OopMap but - // since that's the only use of VMRegs it's simplest to put this test - // here. This test should also be equivalent legal_vm_reg_name but JVMCI - // clients can use max_oop_map_stack_stack_offset to detect this problem - // directly. The asserts just ensure that the tests are in agreement. - assert(offset > CompilerToVM::Data::max_oop_map_stack_offset(), "illegal VMReg"); - JVMCI_ERROR_NULL("stack offset %d is too large to be encoded in OopMap (max %d)%s", - offset, CompilerToVM::Data::max_oop_map_stack_offset(), stream->context()); - } - assert(OopMapValue::legal_vm_reg_name(vmReg), "illegal VMReg"); - return vmReg; - } else { - JVMCI_ERROR_NULL("unaligned stack offset %d in oop map%s", offset, stream->context()); - } - } -} - -OopMap* CodeInstaller::create_oop_map(HotSpotCompiledCodeStream* stream, u1 debug_info_flags, JVMCI_TRAPS) { - assert(is_set(debug_info_flags, DI_HAS_REFERENCE_MAP), "must be"); - u2 max_register_size = stream->read_u2("maxRegisterSize"); - if (!_has_wide_vector && SharedRuntime::is_wide_vector(max_register_size)) { - if (SharedRuntime::polling_page_vectors_safepoint_handler_blob() == nullptr) { - JVMCI_ERROR_NULL("JVMCI is producing code using vectors larger than the runtime supports%s", stream->context()); - } - _has_wide_vector = true; - } - u2 length = stream->read_u2("referenceMap:length"); - - OopMap* map = new OopMap(_total_frame_size, _parameter_count); - for (int i = 0; i < length; i++) { - bool has_derived = stream->read_bool("hasDerived"); - u2 bytes = stream->read_u2("sizeInBytes"); - VMReg vmReg = getVMRegFromLocation(stream, _total_frame_size, JVMCI_CHECK_NULL); - if (has_derived) { - // derived oop - if (bytes == LP64_ONLY(8) NOT_LP64(4)) { - VMReg baseReg = getVMRegFromLocation(stream, _total_frame_size, JVMCI_CHECK_NULL); - map->set_derived_oop(vmReg, baseReg); - } else { - JVMCI_ERROR_NULL("invalid derived oop size in ReferenceMap: %d%s", bytes, stream->context()); - } -#ifdef _LP64 - } else if (bytes == 8) { - // wide oop - map->set_oop(vmReg); - } else if (bytes == 4) { - // narrow oop - map->set_narrowoop(vmReg); -#else - } else if (bytes == 4) { - map->set_oop(vmReg); -#endif - } else { - JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d%s", bytes, stream->context()); - } - } - - if (is_set(debug_info_flags, DI_HAS_CALLEE_SAVE_INFO)) { - length = stream->read_u2("calleeSaveInfo:length"); - for (jint i = 0; i < length; i++) { - u2 jvmci_reg_number = stream->read_u2("register"); - VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, JVMCI_CHECK_NULL); - // HotSpot stack slots are 4 bytes - u2 jvmci_slot = stream->read_u2("slot"); - jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; - VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); - map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); -#ifdef _LP64 - // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) - VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); - map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); -#endif - } - } - return map; -} - -void* CodeInstaller::record_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - /* - * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base - * class is in general not equal to the pointer of the subclass. When patching metaspace pointers, - * the compiler expects a direct pointer to the subclass (Klass* or Method*), not a pointer to the - * base class (Metadata* or MetaspaceObj*). - */ - if (tag == PATCH_KLASS) { - Klass* klass = stream->read_klass("patch:klass"); - int index = _oop_recorder->find_index(klass); - section->relocate(dest, metadata_Relocation::spec(index)); - JVMCI_event_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); - return klass; - } else if (tag == PATCH_METHOD) { - Method* method = stream->read_method("patch:method"); - int index = _oop_recorder->find_index(method); - section->relocate(dest, metadata_Relocation::spec(index)); - JVMCI_event_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); - return method; - } else { - JVMCI_ERROR_NULL("unexpected metadata reference tag: %d%s", tag, stream->context()); - } -} - -#ifdef _LP64 -narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - if (tag != PATCH_NARROW_KLASS) { - JVMCI_ERROR_0("unexpected compressed pointer tag %d%s", tag, stream->context()); - } - Klass* klass = stream->read_klass("patch:klass"); - int index = _oop_recorder->find_index(klass); - section->relocate(dest, metadata_Relocation::spec(index)); - JVMCI_event_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); - guarantee(CompressedKlassPointers::is_encodable(klass), "klass cannot be compressed: %s", klass->external_name()); - return CompressedKlassPointers::encode(klass); -} -#endif - -ScopeValue* CodeInstaller::to_primitive_value(HotSpotCompiledCodeStream* stream, jlong raw, BasicType type, ScopeValue* &second, JVMCI_TRAPS) { - if (type == T_INT || type == T_FLOAT) { - jint prim = (jint) raw; - switch (prim) { - case -1: return _int_m1_scope_value; - case 0: return _int_0_scope_value; - case 1: return _int_1_scope_value; - case 2: return _int_2_scope_value; - default: return new ConstantIntValue(prim); - } - } else if (type == T_LONG || type == T_DOUBLE) { - jlong prim = raw; - second = _int_1_scope_value; - return new ConstantLongValue(prim); - } else { - JVMCI_ERROR_NULL("unexpected primitive constant type %s%s", basictype_to_str(type), stream->context()); - } -} - -Handle CodeInstaller::read_oop(HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - oop obj; - if (tag == OBJECT_ID) { - obj = stream->get_oop(stream->read_u1("id"), JVMCI_CHECK_(Handle())); - } else if (tag == OBJECT_ID2) { - obj = stream->get_oop(stream->read_u2("id:2"), JVMCI_CHECK_(Handle())); - } else if (tag == JOBJECT) { - jlong object_handle = stream->read_u8("jobject"); - obj = jvmci_env()->resolve_oop_handle(object_handle); - } else { - JVMCI_ERROR_(Handle(), "unexpected oop tag: %d", tag) - } - if (obj == nullptr) { - JVMCI_THROW_MSG_(InternalError, "Constant was unexpectedly null", Handle()); - } else { - guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj)); - } - return Handle(stream->thread(), obj); -} - -ScopeValue* CodeInstaller::get_scope_value(HotSpotCompiledCodeStream* stream, u1 tag, BasicType type, ScopeValue* &second, JVMCI_TRAPS) { - second = nullptr; - bool stack_slot_is_s2 = true; - switch (tag) { - case ILLEGAL: { - if (type != T_ILLEGAL) { - JVMCI_ERROR_NULL("unexpected illegal value, expected %s%s", basictype_to_str(type), stream->context()); - } - return _illegal_value; - } - case REGISTER_PRIMITIVE: - case REGISTER_NARROW_OOP: - case REGISTER_OOP: - case REGISTER_VECTOR: { - u2 number = stream->read_u2("register"); - VMReg hotspotRegister = get_hotspot_reg(number, JVMCI_CHECK_NULL); - if (is_general_purpose_reg(hotspotRegister)) { - Location::Type locationType; - if (type == T_OBJECT) { - locationType = tag == REGISTER_NARROW_OOP ? Location::narrowoop : Location::oop; - } else if (type == T_LONG) { - locationType = Location::lng; - } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { - locationType = Location::int_in_long; - } else { - JVMCI_ERROR_NULL("unexpected type %s in CPU register%s", basictype_to_str(type), stream->context()); - } - ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); - if (type == T_LONG) { - second = value; - } - return value; - } else { - Location::Type locationType; - if (type == T_FLOAT) { - // this seems weird, but the same value is used in c1_LinearScan - locationType = Location::normal; - } else if (type == T_DOUBLE) { - locationType = Location::dbl; - } else if (type == T_OBJECT && tag == REGISTER_VECTOR) { - locationType = Location::vector; - } else { - JVMCI_ERROR_NULL("unexpected type %s in floating point register%s", basictype_to_str(type), stream->context()); - } - ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); - if (type == T_DOUBLE) { - second = value; - } - return value; - } - } - case STACK_SLOT4_PRIMITIVE: - case STACK_SLOT4_NARROW_OOP: - case STACK_SLOT4_OOP: - case STACK_SLOT4_VECTOR: - stack_slot_is_s2 = false; - // fall through - case STACK_SLOT_PRIMITIVE: - case STACK_SLOT_NARROW_OOP: - case STACK_SLOT_OOP: - case STACK_SLOT_VECTOR: { - jint offset = stack_slot_is_s2 ? (jshort) stream->read_s2("offset") : stream->read_s4("offset4"); - if (stream->read_bool("addRawFrameSize")) { - offset += _total_frame_size; - } - Location::Type locationType; - if (type == T_OBJECT) { - locationType = tag == STACK_SLOT_VECTOR ? Location::vector : tag == STACK_SLOT_NARROW_OOP ? Location::narrowoop : Location::oop; - } else if (type == T_LONG) { - locationType = Location::lng; - } else if (type == T_DOUBLE) { - locationType = Location::dbl; - } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { - locationType = Location::normal; - } else { - JVMCI_ERROR_NULL("unexpected type %s in stack slot%s", basictype_to_str(type), stream->context()); - } - ScopeValue* value = new LocationValue(Location::new_stk_loc(locationType, offset)); - if (type == T_DOUBLE || type == T_LONG) { - second = value; - } - return value; - } - case NULL_CONSTANT: { return _oop_null_scope_value; } - case RAW_CONSTANT: { return new ConstantLongValue(stream->read_u8("primitive")); } - case PRIMITIVE_0: { ScopeValue* v = to_primitive_value(stream, 0, type, second, JVMCI_CHECK_NULL); return v; } - case PRIMITIVE4: { ScopeValue* v = to_primitive_value(stream, stream->read_s4("primitive4"), type, second, JVMCI_CHECK_NULL); return v; } - case PRIMITIVE8: { ScopeValue* v = to_primitive_value(stream, stream->read_s8("primitive8"), type, second, JVMCI_CHECK_NULL); return v; } - case VIRTUAL_OBJECT_ID: { ScopeValue* v = stream->virtual_object_at(stream->read_u1("id"), JVMCI_CHECK_NULL); return v; } - case VIRTUAL_OBJECT_ID2: { ScopeValue* v = stream->virtual_object_at(stream->read_u2("id:2"), JVMCI_CHECK_NULL); return v; } - - case OBJECT_ID: - case OBJECT_ID2: - case JOBJECT: { - Handle obj = read_oop(stream, tag, JVMCI_CHECK_NULL); - return new ConstantOopWriteValue(JNIHandles::make_local(obj())); - } - default: { - JVMCI_ERROR_NULL("unexpected tag in scope: %d%s", tag, stream->context()) - } - } -} - -void CodeInstaller::record_object_value(ObjectValue* sv, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - oop javaMirror = JNIHandles::resolve(sv->klass()->as_ConstantOopWriteValue()->value()); - Klass* klass = java_lang_Class::as_Klass(javaMirror); - bool isLongArray = klass == Universe::longArrayKlass(); - bool isByteArray = klass == Universe::byteArrayKlass(); - - u2 length = stream->read_u2("values:length"); - for (jint i = 0; i < length; i++) { - ScopeValue* cur_second = nullptr; - BasicType type = (BasicType) stream->read_u1("basicType"); - ScopeValue* value; - u1 tag = stream->read_u1("tag"); - if (tag == ILLEGAL) { - if (isByteArray && type == T_ILLEGAL) { - /* - * The difference between a virtualized large access and a deferred write is the kind stored in the slotKinds - * of the virtual object: in the virtualization case, the kind is illegal, in the deferred write case, the kind - * is access stack kind (an int). - */ - value = _virtual_byte_array_marker; - } else { - value = _illegal_value; - if (type == T_DOUBLE || type == T_LONG) { - cur_second = _illegal_value; - } - } - } else { - value = get_scope_value(stream, tag, type, cur_second, JVMCI_CHECK); - } - - if (isLongArray && cur_second == nullptr) { - // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. - // add an int 0 constant - cur_second = _int_0_scope_value; - } - - if (isByteArray && cur_second != nullptr && (type == T_DOUBLE || type == T_LONG)) { - // we are trying to write a long in a byte Array. We will need to count the illegals to restore the type of - // the thing we put inside. - cur_second = nullptr; - } - - if (cur_second != nullptr) { - sv->field_values()->append(cur_second); - } - assert(value != nullptr, "missing value"); - sv->field_values()->append(value); - } -} - -GrowableArray* CodeInstaller::read_local_or_stack_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, bool is_locals, JVMCI_TRAPS) { - u2 length; - if (is_locals) { - if (!is_set(frame_flags, DIF_HAS_LOCALS)) { - return nullptr; - } - length = stream->read_u2("numLocals"); - } else { - if (!is_set(frame_flags, DIF_HAS_STACK)) { - return nullptr; - } - length = stream->read_u2("numStack"); - } - GrowableArray* values = new GrowableArray (length); - for (int i = 0; i < length; i++) { - ScopeValue* second = nullptr; - BasicType type = (BasicType) stream->read_u1("basicType"); - u1 tag = stream->read_u1("tag"); - ScopeValue* first = get_scope_value(stream, tag, type, second, JVMCI_CHECK_NULL); - if (second != nullptr) { - if (i == length) { - JVMCI_ERROR_NULL("double-slot value not followed by Value.ILLEGAL%s", stream->context()); - } - i++; - stream->read_u1("basicType"); - tag = stream->read_u1("tag"); - if (tag != ILLEGAL) { - JVMCI_ERROR_NULL("double-slot value not followed by Value.ILLEGAL%s", stream->context()); - } - values->append(second); - } - values->append(first); - } - return values; -} - -GrowableArray* CodeInstaller::read_monitor_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, JVMCI_TRAPS) { - if (!is_set(frame_flags, DIF_HAS_LOCKS)) { - return nullptr; - } - if (!_has_monitors) { - _has_monitors = true; - } - u2 length = stream->read_u2("numLocks"); - GrowableArray* monitors = new GrowableArray(length); - for (int i = 0; i < length; i++) { - bool eliminated = stream->read_bool("isEliminated"); - ScopeValue* second = nullptr; - ScopeValue* owner_value = get_scope_value(stream, stream->read_u1("tag"), T_OBJECT, second, JVMCI_CHECK_NULL); - assert(second == nullptr, "monitor cannot occupy two stack slots"); - - ScopeValue* lock_data_value = get_scope_value(stream, stream->read_u1("tag"), T_LONG, second, JVMCI_CHECK_NULL); - assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); - assert(lock_data_value->is_location(), "invalid monitor location"); - Location lock_data_loc = ((LocationValue*) lock_data_value)->location(); - - monitors->append(new MonitorValue(owner_value, lock_data_loc, eliminated)); - } - return monitors; -} - -void CodeInstaller::initialize_dependencies(HotSpotCompiledCodeStream* stream, u1 code_flags, OopRecorder* oop_recorder, JVMCI_TRAPS) { - JavaThread* thread = stream->thread(); - CompilerThread* compilerThread = thread->is_Compiler_thread() ? CompilerThread::cast(thread) : nullptr; - _oop_recorder = oop_recorder; - _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != nullptr ? compilerThread->log() : nullptr); - if (is_set(code_flags, HCC_HAS_ASSUMPTIONS)) { - u2 length = stream->read_u2("assumptions:length"); - for (int i = 0; i < length; ++i) { - u1 tag = stream->read_u1("tag"); - switch (tag) { - case NO_FINALIZABLE_SUBCLASS: { - Klass* receiver_type = stream->read_klass("receiverType"); - _dependencies->assert_has_no_finalizable_subclasses(receiver_type); - break; - } - case CONCRETE_SUBTYPE: { - Klass* context = stream->read_klass("context"); - Klass* subtype = stream->read_klass("subtype"); - assert(context->is_abstract(), "must be"); - _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); - break; - } - case LEAF_TYPE: { - Klass* context = stream->read_klass("context"); - _dependencies->assert_leaf_type(context); - break; - } - case CONCRETE_METHOD: { - Klass* context = stream->read_klass("context"); - Method* impl = stream->read_method("impl"); - _dependencies->assert_unique_concrete_method(context, impl); - break; - } - case CALLSITE_TARGET_VALUE: { - u1 obj_tag = stream->read_u1("tag"); - Handle callSite = read_oop(stream, obj_tag, JVMCI_CHECK); - obj_tag = stream->read_u1("tag"); - Handle methodHandle = read_oop(stream, obj_tag, JVMCI_CHECK); - _dependencies->assert_call_site_target_value(callSite(), methodHandle()); - break; - } - default: { - JVMCI_ERROR("unexpected assumption tag %d%s", tag, stream->context()); - } - } - } - } - if (is_set(code_flags, HCC_HAS_METHODS)) { - u2 length = stream->read_u2("methods:length"); - for (int i = 0; i < length; ++i) { - Method* method = stream->read_method("method"); - if (JvmtiExport::can_hotswap_or_post_breakpoint()) { - _dependencies->assert_evol_method(method); - } - } - } -} - -JVMCI::CodeInstallResult CodeInstaller::install_runtime_stub(CodeBlob*& cb, - const char* name, - CodeBuffer* buffer, - int stack_slots, - JVMCI_TRAPS) { - if (name == nullptr) { - JVMCI_ERROR_OK("stub should have a name"); - } - - name = os::strdup(name); - GrowableArray *stubs_to_free = nullptr; -#ifdef ASSERT - const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.forceRuntimeStubAllocFail"); - if (val != nullptr && strstr(name , val) != nullptr) { - stubs_to_free = new GrowableArray(); - JVMCI_event_1("forcing allocation of %s in code cache to fail", name); - } -#endif - - do { - RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, - buffer, - _offsets.value(CodeOffsets::Frame_Complete), - stack_slots, - _debug_recorder->_oopmaps, - /* caller_must_gc_arguments */ false, - /* alloc_fail_is_fatal */ false); - cb = stub; - if (stub == nullptr) { - // Allocation failed -#ifdef ASSERT - if (stubs_to_free != nullptr) { - JVMCI_event_1("allocation of %s in code cache failed, freeing %d stubs", name, stubs_to_free->length()); - for (GrowableArrayIterator iter = stubs_to_free->begin(); iter != stubs_to_free->end(); ++iter) { - RuntimeStub::free(*iter); - } - } -#endif - return JVMCI::cache_full; - } - if (stubs_to_free == nullptr) { - return JVMCI::ok; - } - stubs_to_free->append(stub); - } while (true); -} - -JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, - jlong compiled_code_buffer, - bool with_type_info, - JVMCIObject compiled_code, - objArrayHandle object_pool, - CodeBlob*& cb, - JVMCINMethodHandle& nmethod_handle, - JVMCIObject installed_code, - FailedSpeculation** failed_speculations, - char* speculations, - int speculations_len, - JVMCI_TRAPS) { - - JavaThread* thread = JavaThread::current(); - HotSpotCompiledCodeStream* stream = new HotSpotCompiledCodeStream(thread, (const u1*) compiled_code_buffer, with_type_info, object_pool); - - u1 code_flags = stream->read_u1("code:flags"); - bool is_nmethod = is_set(code_flags, HCC_IS_NMETHOD); - const char* name = stream->read_utf8("name", JVMCI_CHECK_OK); - - methodHandle method; - jint entry_bci = -1; - JVMCICompileState* compile_state = nullptr; - bool has_unsafe_access = false; - bool has_scoped_access = false; - jint id = -1; - - if (is_nmethod) { - method = methodHandle(thread, stream->read_method("method")); - entry_bci = is_nmethod ? stream->read_s4("entryBCI") : -1; - compile_state = (JVMCICompileState*) stream->read_u8("compileState"); - has_unsafe_access = stream->read_bool("hasUnsafeAccess"); - has_scoped_access = stream->read_bool("hasScopedAccess"); - id = stream->read_s4("id"); - } - stream->set_code_desc(name, method); - - CodeBuffer buffer("JVMCI Compiler CodeBuffer"); - OopRecorder* recorder = new OopRecorder(&_arena, true); - initialize_dependencies(stream, code_flags, recorder, JVMCI_CHECK_OK); - - // Get instructions and constants CodeSections early because we need it. - _instructions = buffer.insts(); - _constants = buffer.consts(); - - initialize_fields(stream, code_flags, method, buffer, JVMCI_CHECK_OK); - JVMCI::CodeInstallResult result = initialize_buffer(compiled_code, buffer, stream, code_flags, JVMCI_CHECK_OK); - - u4 available = stream->available(); - if (result == JVMCI::ok && available != 0) { - JVMCI_ERROR_OK("%d bytes remaining in stream%s", available, stream->context()); - } - - if (result != JVMCI::ok) { - return result; - } - - int stack_slots = _total_frame_size / HeapWordSize; // conversion to words - - if (!is_nmethod) { - return install_runtime_stub(cb, name, &buffer, stack_slots, JVMCI_CHECK_OK); - } else { - if (compile_state != nullptr) { - jvmci_env()->set_compile_state(compile_state); - } - - if (id == -1) { - // Make sure a valid compile_id is associated with every compile - id = CompileBroker::assign_compile_id_unlocked(thread, method, entry_bci); - jvmci_env()->set_HotSpotCompiledNmethod_id(compiled_code, id); - } - if (!jvmci_env()->isa_HotSpotNmethod(installed_code)) { - JVMCI_THROW_MSG_(IllegalArgumentException, "InstalledCode object must be a HotSpotNmethod when installing a HotSpotCompiledNmethod", JVMCI::ok); - } - - // Enforce that compiled methods have an nmethod barrier. - if (_nmethod_entry_patch_offset == -1) { - JVMCI_THROW_MSG_(IllegalArgumentException, "nmethod entry barrier is missing", JVMCI::ok); - } - - JVMCIObject mirror = installed_code; - nmethod* nm = nullptr; // nm is an out parameter of register_method - result = runtime()->register_method(jvmci_env(), - method, - nm, - entry_bci, - &_offsets, - _orig_pc_offset, - &buffer, - stack_slots, - _debug_recorder->_oopmaps, - &_exception_handler_table, - &_implicit_exception_table, - compiler, - _debug_recorder, - _dependencies, - id, - _has_monitors, - has_unsafe_access, - has_scoped_access, - _has_wide_vector, - compiled_code, - mirror, - failed_speculations, - speculations, - speculations_len, - _nmethod_entry_patch_offset); - if (result == JVMCI::ok) { - guarantee(nm != nullptr, "successful compile must produce an nmethod"); - nmethod_handle.set_nmethod(nm); - cb = nm; - if (compile_state == nullptr) { - // This compile didn't come through the CompileBroker so perform the printing here - CompilerDirectiveMatcher matcher(method, CompLevel_full_optimization); - nm->maybe_print_nmethod(matcher.directive_set()); - - // Since this compilation didn't pass through the broker it wasn't logged yet. - if (PrintCompilation) { - ttyLocker ttyl; - if (name != nullptr) { - stringStream st; - st.print_cr("(hosted JVMCI compilation: %s)", name); - CompileTask::print(tty, nm, st.as_string()); - } else { - CompileTask::print(tty, nm, "(hosted JVMCI compilation)"); - } - } - } - - BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - - // an empty error buffer for use by the verify_barrier code - err_msg msg(""); - if (!bs_nm->verify_barrier(nm, msg)) { - JVMCI_THROW_MSG_(IllegalArgumentException, err_msg("nmethod entry barrier is malformed: %s", msg.buffer()), JVMCI::ok); - } - } - } - - if (cb != nullptr) { - // Make sure the pre-calculated constants section size was correct. - guarantee((cb->code_begin() - cb->content_begin()) >= _constants_size, "%d < %d", (int)(cb->code_begin() - cb->content_begin()), _constants_size); - } - return result; -} - -void CodeInstaller::initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, CodeBuffer& buffer, JVMCI_TRAPS) { - if (!method.is_null()) { - _parameter_count = method->size_of_parameters(); - JVMCI_event_2("installing code for %s", method->name_and_sig_as_C_string()); - } else { - // Must be a HotSpotCompiledCode for a stub. - // Only used in OopMap constructor for non-product builds - _parameter_count = 0; - } - _sites_count = stream->read_s4("sites:length"); - _code_size = stream->read_s4("targetCodeSize"); - _total_frame_size = stream->read_s4("totalFrameSize"); - if (!is_set(code_flags, HCC_HAS_DEOPT_RESCUE_SLOT)) { - _orig_pc_offset = -1; - } else { - _orig_pc_offset = stream->read_s4("offset"); - if (stream->read_bool("addRawFrameSize")) { - _orig_pc_offset += _total_frame_size; - } - if (_orig_pc_offset < 0) { - JVMCI_ERROR("invalid deopt rescue slot: %d%s", _orig_pc_offset, stream->context()); - } - } - - // Pre-calculate the constants section size. This is required for PC-relative addressing. - u4 data_section_size = stream->read_u4("dataSectionSize"); - u1 data_section_alignment = stream->read_u1("dataSectionAlignment"); - buffer.set_const_section_alignment(data_section_alignment); - if ((_constants->alignment() % data_section_alignment) != 0) { - JVMCI_ERROR("invalid data section alignment: %d [constants alignment: %d]%s", - data_section_alignment, _constants->alignment(), stream->context()); - } - _constants_size = data_section_size; - _next_call_type = INVOKE_INVALID; - _has_monitors = false; - _has_wide_vector = false; - _nmethod_entry_patch_offset = -1; -} - -u1 CodeInstaller::as_read_oop_tag(HotSpotCompiledCodeStream* stream, u1 patch_object_tag, JVMCI_TRAPS) { - switch (patch_object_tag) { - case PATCH_OBJECT_ID: - case PATCH_NARROW_OBJECT_ID: { - return OBJECT_ID; - } - case PATCH_OBJECT_ID2: - case PATCH_NARROW_OBJECT_ID2: { - return OBJECT_ID2; - } - case PATCH_NARROW_JOBJECT: - case PATCH_JOBJECT: { - return JOBJECT; - } - default: { - JVMCI_ERROR_0("unknown object patch tag: %d%s", patch_object_tag, stream->context()); - } - } -} - -int CodeInstaller::estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - // Estimate the number of static call stubs that might be emitted. - u2 static_call_stubs = stream->read_u2("numStaticCallStubs"); - u2 trampoline_stubs = stream->read_u2("numTrampolineStubs"); - int size = static_call_stubs * CompiledDirectCall::to_interp_stub_size(); - size += trampoline_stubs * CompiledDirectCall::to_trampoline_stub_size(); - return size; -} - -// perform data and call relocation on the CodeBuffer -JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(JVMCIObject compiled_code, CodeBuffer& buffer, HotSpotCompiledCodeStream* stream, u1 code_flags, JVMCI_TRAPS) { - JavaThread* thread = stream->thread(); - HandleMark hm(thread); - int locs_buffer_size = _sites_count * (relocInfo::length_limit + sizeof(relocInfo)); - - - // Allocate enough space in the stub section for the static call - // stubs. Stubs have extra relocs but they are managed by the stub - // section itself so they don't need to be accounted for in the - // locs_buffer above. - int stubs_size = estimate_stubs_size(stream, JVMCI_CHECK_OK); - - assert((CodeBuffer::SECT_INSTS == CodeBuffer::SECT_STUBS - 1) && - (CodeBuffer::SECT_CONSTS == CodeBuffer::SECT_INSTS - 1), "sections order: consts, insts, stubs"); - // buffer content: [constants + code_align] + [code + stubs_align] + [stubs] - int total_size = align_up(_constants_size, buffer.insts()->alignment()) + - align_up(_code_size, buffer.stubs()->alignment()) + - stubs_size; - - if (total_size > JVMCINMethodSizeLimit) { - return JVMCI::code_too_large; - } - - buffer.initialize(total_size, locs_buffer_size); - if (buffer.blob() == nullptr) { - return JVMCI::cache_full; - } - buffer.initialize_stubs_size(stubs_size); - buffer.initialize_consts_size(_constants_size); - - _debug_recorder = new DebugInformationRecorder(_oop_recorder); - _debug_recorder->set_oopmaps(new OopMapSet()); - - buffer.initialize_oop_recorder(_oop_recorder); - - // copy the constant data into the newly created CodeBuffer - address end_data = _constants->start() + _constants_size; - JVMCIObject data_section = jvmci_env()->get_HotSpotCompiledCode_dataSection(compiled_code); - JVMCIENV->copy_bytes_to(data_section, (jbyte*) _constants->start(), 0, _constants_size); - _constants->set_end(end_data); - - // copy the code into the newly created CodeBuffer - address end_pc = _instructions->start() + _code_size; - guarantee(_instructions->allocates2(end_pc), "initialize should have reserved enough space for all the code"); - - JVMCIPrimitiveArray code = jvmci_env()->get_HotSpotCompiledCode_targetCode(compiled_code); - JVMCIENV->copy_bytes_to(code, (jbyte*) _instructions->start(), 0, _code_size); - _instructions->set_end(end_pc); - - - u2 length = stream->read_u2("dataSectionPatches:length"); - for (int i = 0; i < length; i++) { - address dest = _constants->start() + stream->read_u4("patch:pcOffset"); - u1 tag = stream->read_u1("tag"); - - switch (tag) { - case PATCH_METHOD: - case PATCH_KLASS: { - *((void**) dest) = record_metadata_reference(_constants, dest, stream, tag, JVMCI_CHECK_OK); - break; - } - case PATCH_NARROW_KLASS: { -#ifdef _LP64 - *((narrowKlass*) dest) = record_narrow_metadata_reference(_constants, dest, stream, tag, JVMCI_CHECK_OK); -#else - JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode"); -#endif - break; - } - case PATCH_OBJECT_ID: - case PATCH_OBJECT_ID2: - case PATCH_NARROW_OBJECT_ID: - case PATCH_NARROW_OBJECT_ID2: - case PATCH_JOBJECT: - case PATCH_NARROW_JOBJECT: { - bool narrow = tag == PATCH_NARROW_OBJECT_ID || tag == PATCH_NARROW_OBJECT_ID2 || tag == PATCH_NARROW_JOBJECT; - u1 read_tag = as_read_oop_tag(stream, tag, JVMCI_CHECK_OK); - record_oop_patch(stream, dest, read_tag, narrow, JVMCI_CHECK_OK); - break; - } - default: { - JVMCI_ERROR_OK("invalid constant tag: %d%s", tag, stream->context()); - break; - } - } - } - - jint last_pc_offset = -1; - for (int i = 0; i < _sites_count; i++) { - u4 pc_offset = stream->read_s4("site:pcOffset"); - u1 tag = stream->read_u1("tag"); - switch (tag) { - case SITE_FOREIGN_CALL: - case SITE_FOREIGN_CALL_NO_DEBUG_INFO: - case SITE_CALL: { - site_Call(buffer, tag, pc_offset, stream, JVMCI_CHECK_OK); - break; - } - case SITE_SAFEPOINT: - case SITE_IMPLICIT_EXCEPTION: - case SITE_IMPLICIT_EXCEPTION_DISPATCH: { - site_Safepoint(buffer, pc_offset, stream, tag, JVMCI_CHECK_OK); - break; - } - case SITE_INFOPOINT: { - site_Infopoint(buffer, pc_offset, stream, JVMCI_CHECK_OK); - break; - } - case SITE_MARK: { - site_Mark(buffer, pc_offset, stream, JVMCI_CHECK_OK); - break; - } - case SITE_DATA_PATCH: { - site_DataPatch(buffer, pc_offset, stream, JVMCI_CHECK_OK); - break; - } - case SITE_EXCEPTION_HANDLER: { - site_ExceptionHandler(pc_offset, stream); - break; - } - default: { - JVMCI_ERROR_OK("unexpected site tag at " INTPTR_FORMAT ": %d", p2i(stream->pos() - 1), tag); - } - } - - last_pc_offset = pc_offset; - - if ((i % 32 == 0) && SafepointMechanism::should_process(thread)) { - // Force a safepoint to mitigate pause time installing large code - ThreadToNativeFromVM ttnfv(thread); - } - } - - if (is_set(code_flags, HCC_HAS_COMMENTS)) { - u2 length = stream->read_u2("comments:length"); - for (int i = 0; i < length; i++) { - u4 pc_offset = stream->read_u4("comment:pcOffset"); - const char* text = stream->read_utf8("comment:text", JVMCI_CHECK_OK); -#ifndef PRODUCT - buffer.block_comment(pc_offset, text); -#endif - } - } - if (_has_auto_box) { - JavaThread* THREAD = thread; // For exception macros. - JVMCI::ensure_box_caches_initialized(CHECK_(JVMCI::ok)); - } - return JVMCI::ok; -} - -void CodeInstaller::record_oop_patch(HotSpotCompiledCodeStream* stream, address dest, u1 read_tag, bool narrow, JVMCI_TRAPS) { - Handle obj = read_oop(stream, read_tag, JVMCI_CHECK); - jobject value = JNIHandles::make_local(obj()); - int oop_index = _oop_recorder->find_index(value); - if (narrow) { -#ifdef _LP64 - _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); -#else - JVMCI_ERROR("unexpected compressed oop in 32-bit mode"); -#endif - } else { - _constants->relocate(dest, oop_Relocation::spec(oop_index)); - } -} - -void CodeInstaller::site_ExceptionHandler(jint pc_offset, HotSpotCompiledCodeStream* stream) { - u4 handler_offset = stream->read_u4("site:handlerPos"); - - // Subtable header - _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0)); - - // Subtable entry - _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); -} - -void CodeInstaller::read_virtual_objects(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - u2 length = stream->read_u2("virtualObjects:length"); - if (length == 0) { - return; - } - GrowableArray *objects = new GrowableArray(length, length, nullptr); - stream->set_virtual_objects(objects); - // Create the unique ObjectValues - JavaThread* thread = stream->thread(); - for (int id = 0; id < length; id++) { - Klass* klass = stream->read_klass("type"); - bool is_auto_box = stream->read_bool("isAutoBox"); - if (is_auto_box) { - _has_auto_box = true; - } - oop javaMirror = klass->java_mirror(); - ScopeValue *klass_sv = new ConstantOopWriteValue(JNIHandles::make_local(javaMirror)); - ObjectValue* sv = is_auto_box ? new AutoBoxObjectValue(id, klass_sv) : new ObjectValue(id, klass_sv); - objects->at_put(id, sv); - } - // All the values which could be referenced by the VirtualObjects - // exist, so now describe all the VirtualObjects themselves. - for (int id = 0; id < length; id++) { - record_object_value(objects->at(id)->as_ObjectValue(), stream, JVMCI_CHECK); - } - _debug_recorder->dump_object_pool(objects); - - stream->set_virtual_objects(objects); -} - -int CodeInstaller::map_jvmci_bci(int bci) { - if (bci < 0) { - switch (bci) { - case BEFORE_BCI: return BeforeBci; - case AFTER_BCI: return AfterBci; - case UNWIND_BCI: return UnwindBci; - case AFTER_EXCEPTION_BCI: return AfterExceptionBci; - case UNKNOWN_BCI: return UnknownBci; - case INVALID_FRAMESTATE_BCI: return InvalidFrameStateBci; - } - ShouldNotReachHere(); - } - return bci; -} - -void CodeInstaller::record_scope(jint pc_offset, HotSpotCompiledCodeStream* stream, u1 debug_info_flags, bool full_info, bool return_oop, JVMCI_TRAPS) { - if (full_info) { - read_virtual_objects(stream, JVMCI_CHECK); - } - if (is_set(debug_info_flags, DI_HAS_FRAMES)) { - u2 depth = stream->read_u2("depth"); - for (int i = 0; i < depth; i++) { - Thread* thread = Thread::current(); - methodHandle method(thread, stream->read_method("method")); - jint bci = map_jvmci_bci(stream->read_s4("bci")); - if (bci == BEFORE_BCI) { - bci = SynchronizationEntryBCI; - } - - JVMCI_event_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); - - bool reexecute = false; - bool rethrow_exception = false; - - DebugToken* locals_token = nullptr; - DebugToken* stack_token = nullptr; - DebugToken* monitors_token = nullptr; - - if (full_info) { - u1 frame_flags = stream->read_u1("flags"); - rethrow_exception = is_set(frame_flags, DIF_RETHROW_EXCEPTION); - - if (bci >= 0) { - reexecute = !is_set(frame_flags, DIF_DURING_CALL); - } - - GrowableArray* locals = read_local_or_stack_values(stream, frame_flags, true, JVMCI_CHECK); - GrowableArray* stack = read_local_or_stack_values(stream, frame_flags, false, JVMCI_CHECK); - GrowableArray* monitors = read_monitor_values(stream, frame_flags, JVMCI_CHECK); - - locals_token = _debug_recorder->create_scope_values(locals); - stack_token = _debug_recorder->create_scope_values(stack); - monitors_token = _debug_recorder->create_monitor_values(monitors); - } - - // has_ea_local_in_scope and arg_escape should be added to JVMCI - const bool has_ea_local_in_scope = false; - const bool arg_escape = false; - _debug_recorder->describe_scope(pc_offset, method, nullptr, bci, reexecute, rethrow_exception, return_oop, - has_ea_local_in_scope, arg_escape, - locals_token, stack_token, monitors_token); - } - } - if (full_info) { - // Clear the virtual objects as they are specific to one DebugInfo - stream->set_virtual_objects(nullptr); - } -} - -void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) { - u1 flags = stream->read_u1("debugInfo:flags"); - OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK); - _debug_recorder->add_safepoint(pc_offset, map); - record_scope(pc_offset, stream, flags, true, JVMCI_CHECK); - _debug_recorder->end_safepoint(pc_offset); - if (_orig_pc_offset < 0) { - JVMCI_ERROR("method contains safepoint, but has no deopt rescue slot"); - } - if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) { - jint dispatch_offset = stream->read_s4("dispatchOffset"); - _implicit_exception_table.append(pc_offset, dispatch_offset); - } else if (tag == SITE_IMPLICIT_EXCEPTION) { - _implicit_exception_table.add_deoptimize(pc_offset); - } -} - -void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - u1 flags = stream->read_u1("debugInfo:flags"); - _debug_recorder->add_non_safepoint(pc_offset); - record_scope(pc_offset, stream, flags, false, JVMCI_CHECK); - _debug_recorder->end_non_safepoint(pc_offset); -} - -void CodeInstaller::site_Call(CodeBuffer& buffer, u1 tag, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - JavaThread* thread = stream->thread(); - jlong target = stream->read_u8("target"); - methodHandle method; - bool direct_call = false; - if (tag == SITE_CALL) { - method = methodHandle(thread, (Method*) target); - assert(Method::is_valid_method(method()), "invalid method"); - direct_call = stream->read_bool("direct"); - if (method.is_null()) { - JVMCI_THROW(NullPointerException); - } - } - - NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); - jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, JVMCI_CHECK); - - if (tag != SITE_FOREIGN_CALL_NO_DEBUG_INFO) { - u1 flags = stream->read_u1("debugInfo:flags"); - OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK); - _debug_recorder->add_safepoint(next_pc_offset, map); - - if (!method.is_null()) { - bool return_oop = method->is_returning_oop(); - record_scope(next_pc_offset, stream, flags, true, return_oop, JVMCI_CHECK); - } else { - record_scope(next_pc_offset, stream, flags, true, JVMCI_CHECK); - } - } - - if (tag != SITE_CALL) { - jlong foreign_call_destination = target; - CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, JVMCI_CHECK); - } else { - CodeInstaller::pd_relocate_JavaMethod(buffer, method, pc_offset, JVMCI_CHECK); - if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { - // Need a static call stub for transitions from compiled to interpreted. - MacroAssembler masm(&buffer); - if (CompiledDirectCall::emit_to_interp_stub(&masm, _instructions->start() + pc_offset) == nullptr) { - JVMCI_ERROR("could not emit to_interp stub - code cache is full"); - } - } - } - - _next_call_type = INVOKE_INVALID; - - if (tag != SITE_FOREIGN_CALL_NO_DEBUG_INFO) { - _debug_recorder->end_safepoint(next_pc_offset); - } -} - -void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - u1 tag = stream->read_u1("tag"); - switch (tag) { - case PATCH_OBJECT_ID: - case PATCH_OBJECT_ID2: - case PATCH_NARROW_OBJECT_ID: - case PATCH_NARROW_OBJECT_ID2: - case PATCH_JOBJECT: - case PATCH_NARROW_JOBJECT: { - bool narrow = tag == PATCH_NARROW_OBJECT_ID || tag == PATCH_NARROW_OBJECT_ID2 || tag == PATCH_NARROW_JOBJECT; - u1 read_tag = as_read_oop_tag(stream, tag, JVMCI_CHECK); - Handle obj = read_oop(stream, read_tag, JVMCI_CHECK); - pd_patch_OopConstant(pc_offset, obj, narrow, JVMCI_CHECK); - break; - } - case PATCH_METHOD: - case PATCH_KLASS: - case PATCH_NARROW_KLASS: { - pd_patch_MetaspaceConstant(pc_offset, stream, tag, JVMCI_CHECK); - break; - } - case PATCH_DATA_SECTION_REFERENCE: { - int data_offset = stream->read_u4("data:offset"); - if (0 <= data_offset && data_offset < _constants_size) { - if (!is_aligned(data_offset, CompilerToVM::Data::get_data_section_item_alignment())) { - JVMCI_ERROR("data offset 0x%x is not %d-byte aligned%s", data_offset, relocInfo::addr_unit(), stream->context()); - } - pd_patch_DataSectionReference(pc_offset, data_offset, JVMCI_CHECK); - } else { - JVMCI_ERROR("data offset 0x%x points outside data section (size 0x%x)%s", data_offset, _constants_size, stream->context()); - } - break; - } - default: { - JVMCI_ERROR("unknown data patch tag: %d%s", tag, stream->context()); - } - } -} - -void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) { - u1 id = stream->read_u1("mark:id"); - address pc = _instructions->start() + pc_offset; - - if (pd_relocate(pc, id)) { - return; - } - - switch (id) { - case UNVERIFIED_ENTRY: - _offsets.set_value(CodeOffsets::Entry, pc_offset); - break; - case VERIFIED_ENTRY: - _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset); - break; - case OSR_ENTRY: - _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset); - break; - case EXCEPTION_HANDLER_ENTRY: - _offsets.set_value(CodeOffsets::Exceptions, pc_offset); - break; - case DEOPT_HANDLER_ENTRY: - _offsets.set_value(CodeOffsets::Deopt, pc_offset); - break; - case FRAME_COMPLETE: - _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset); - break; - case ENTRY_BARRIER_PATCH: - _nmethod_entry_patch_offset = pc_offset; - break; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: - case INLINE_INVOKE: - case INVOKESTATIC: - case INVOKESPECIAL: - _next_call_type = (MarkId) id; - _invoke_mark_pc = pc; - break; - case CARD_TABLE_SHIFT: - case CARD_TABLE_ADDRESS: - case HEAP_TOP_ADDRESS: - case HEAP_END_ADDRESS: - case NARROW_KLASS_BASE_ADDRESS: - case NARROW_OOP_BASE_ADDRESS: - case CRC_TABLE_ADDRESS: - case LOG_OF_HEAP_REGION_GRAIN_BYTES: - case INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED: - case VERIFY_OOPS: - case VERIFY_OOP_BITS: - case VERIFY_OOP_MASK: - case VERIFY_OOP_COUNT_ADDRESS: - case DEOPT_MH_HANDLER_ENTRY: - break; - - default: - JVMCI_ERROR("invalid mark id: %d%s", id, stream->context()); - break; - } -} diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp deleted file mode 100644 index bdebed2d9e8..00000000000 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCICODEINSTALLER_HPP -#define SHARE_JVMCI_JVMCICODEINSTALLER_HPP - -#include "classfile/classFileStream.hpp" -#include "code/debugInfoRec.hpp" -#include "code/exceptionHandlerTable.hpp" -#include "code/nativeInst.hpp" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciEnv.hpp" - -// Object for decoding a serialized HotSpotCompiledCode object. -// Encoding is done by jdk.vm.ci.hotspot.HotSpotCompiledCodeStream. -class HotSpotCompiledCodeStream : public ResourceObj { - private: - class Chunk { - private: - Chunk* _next; - u4 _size; - - public: - u4 size() const { return _size; } - const u1* data() const { return ((const u1*)this) + HEADER; } - const u1* data_end() const { return data() + _size; } - Chunk* next() const { return _next; } - }; - - // Mirrors jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.HEADER - static const int HEADER = sizeof(Chunk*) + sizeof(u4); - - Chunk* _head; // First chunk in buffer - Chunk* _chunk; // Chunk currently being read - mutable const u1* _pos; // Read position in _chunk - const bool _with_type_info; - objArrayHandle _object_pool; // Pool for objects in Java heap (ignored if libjvmci) - JavaThread* _thread; // Current thread - - // Virtual objects in DebugInfo currently being decoded - GrowableArray* _virtual_objects; - - // HotSpotCompiledCode.name or HotSpotCompiledNmethod.method - const char* _code_desc; - -#define checked_read(value, name, type) do { \ - if (_with_type_info) { check_data(sizeof(type), name); } \ - return (type) value; \ -} while (0) - - void before_read(u1 size); - - u1 get_u1() { before_read(1); u1 res = *_pos; _pos += 1; return res; } - u2 get_u2() { before_read(2); u2 res = *((u2*) _pos); _pos += 2; return res; } - u4 get_u4() { before_read(4); u4 res = *((u4*) _pos); _pos += 4; return res; } - u8 get_u8() { before_read(8); u8 res = *((u8*) _pos); _pos += 8; return res; } - - void check_data(u2 expect_size, const char *expect_name); - - public: - HotSpotCompiledCodeStream(JavaThread* thread, const u1* buffer, bool with_type_info, objArrayHandle& object_pool) : - _head((Chunk*) buffer), - _chunk((Chunk*) buffer), - _pos(_chunk->data()), - _with_type_info(with_type_info), - _object_pool(object_pool), - _thread(thread), - _virtual_objects(nullptr), - _code_desc("") - {} - - // Dump complete buffer to `st`. - void dump_buffer(outputStream* st=tty) const; - - // Dump last `len` bytes of current buffer chunk to `st` - void dump_buffer_tail(int len, outputStream* st=tty) const; - - // Gets a string containing code_desc() followed by a hexdump - // of about 100 bytes in the stream up to the current read position. - const char* context() const; - - // Gets HotSpotCompiledCode.name or HotSpotCompiledNmethod.method.name_and_sig_as_C_string(). - const char* code_desc() const { return _code_desc; } - - void set_code_desc(const char* name, methodHandle& method) { - if (name != nullptr) { - _code_desc = name; - } else if (!method.is_null()) { - _code_desc = method->name_and_sig_as_C_string(); - } - } - - // Current read address. - address pos() const { return (address) _pos; } - - // Offset of current read position from start of buffer. - u4 offset() const; - - // Gets the number of remaining bytes in the stream. - bool available() const; - - oop get_oop(int id, JVMCI_TRAPS) const; - JavaThread* thread() const { return _thread; } - - void set_virtual_objects(GrowableArray* objs) { _virtual_objects = objs; } - ScopeValue* virtual_object_at(int id, JVMCI_TRAPS) const; - - u1 read_u1(const char* name) { checked_read(get_u1(), name, u1); } - u2 read_u2(const char* name) { checked_read(get_u2(), name, u2); } - u4 read_u4(const char* name) { checked_read(get_u4(), name, u4); } - u8 read_u8(const char* name) { checked_read(get_u8(), name, u8); } - s2 read_s2(const char* name) { checked_read(get_u2(), name, s2); } - s4 read_s4(const char* name) { checked_read(get_u4(), name, s4); } - s8 read_s8(const char* name) { checked_read(get_u8(), name, s8); } - - bool read_bool(const char* name) { checked_read((get_u1() != 0), name, bool); } - Method* read_method(const char* name); - Klass* read_klass(const char* name); - const char* read_utf8(const char* name, JVMCI_TRAPS); -#undef checked_read -}; - -// Converts a HotSpotCompiledCode to a CodeBlob or an nmethod. -class CodeInstaller : public StackObj { - friend class JVMCIVMStructs; -private: - enum MarkId { - INVALID_MARK, - VERIFIED_ENTRY, - UNVERIFIED_ENTRY, - OSR_ENTRY, - EXCEPTION_HANDLER_ENTRY, - DEOPT_HANDLER_ENTRY, - FRAME_COMPLETE, - ENTRY_BARRIER_PATCH, - INVOKEINTERFACE, - INVOKEVIRTUAL, - INVOKESTATIC, - INVOKESPECIAL, - INLINE_INVOKE, - POLL_NEAR, - POLL_RETURN_NEAR, - POLL_FAR, - POLL_RETURN_FAR, - CARD_TABLE_ADDRESS, - CARD_TABLE_SHIFT, - HEAP_TOP_ADDRESS, - HEAP_END_ADDRESS, - NARROW_KLASS_BASE_ADDRESS, - NARROW_OOP_BASE_ADDRESS, - CRC_TABLE_ADDRESS, - LOG_OF_HEAP_REGION_GRAIN_BYTES, - INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED, - DEOPT_MH_HANDLER_ENTRY, - VERIFY_OOPS, - VERIFY_OOP_BITS, - VERIFY_OOP_MASK, - VERIFY_OOP_COUNT_ADDRESS, - -#ifdef X86 - Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL, - Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST, - Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_AFTER_TEST, - Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_CMP, - Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_AFTER_TEST, - Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_OR, - Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_MOV, -#endif -#ifdef AARCH64 - Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_TB_X, - Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_BEFORE_MOV, - Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_BEFORE_MOV, - Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_BEFORE_MOV, -#endif - - INVOKE_INVALID = -1 - }; - - // Mirrors jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag - enum Tag { - ILLEGAL, - REGISTER_PRIMITIVE, - REGISTER_OOP, - REGISTER_NARROW_OOP, - REGISTER_VECTOR, - STACK_SLOT_PRIMITIVE, - STACK_SLOT_OOP, - STACK_SLOT_NARROW_OOP, - STACK_SLOT_VECTOR, - STACK_SLOT4_PRIMITIVE, - STACK_SLOT4_OOP, - STACK_SLOT4_NARROW_OOP, - STACK_SLOT4_VECTOR, - VIRTUAL_OBJECT_ID, - VIRTUAL_OBJECT_ID2, - NULL_CONSTANT, - RAW_CONSTANT, - PRIMITIVE_0, - PRIMITIVE4, - PRIMITIVE8, - JOBJECT, - OBJECT_ID, - OBJECT_ID2, - - NO_FINALIZABLE_SUBCLASS, - CONCRETE_SUBTYPE, - LEAF_TYPE, - CONCRETE_METHOD, - CALLSITE_TARGET_VALUE, - - PATCH_OBJECT_ID, - PATCH_OBJECT_ID2, - PATCH_NARROW_OBJECT_ID, - PATCH_NARROW_OBJECT_ID2, - PATCH_JOBJECT, - PATCH_NARROW_JOBJECT, - PATCH_KLASS, - PATCH_NARROW_KLASS, - PATCH_METHOD, - PATCH_DATA_SECTION_REFERENCE, - - SITE_CALL, - SITE_FOREIGN_CALL, - SITE_FOREIGN_CALL_NO_DEBUG_INFO, - SITE_SAFEPOINT, - SITE_INFOPOINT, - SITE_IMPLICIT_EXCEPTION, - SITE_IMPLICIT_EXCEPTION_DISPATCH, - SITE_MARK, - SITE_DATA_PATCH, - SITE_EXCEPTION_HANDLER, - }; - - // Mirrors constants from jdk.vm.ci.code.BytecodeFrame. - enum BytecodeFrameBCI { - UNWIND_BCI = -1, - BEFORE_BCI = -2, - AFTER_BCI = -3, - AFTER_EXCEPTION_BCI = -4, - UNKNOWN_BCI = -5, - INVALID_FRAMESTATE_BCI = -6 - }; - - // Mirrors HotSpotCompiledCode flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream. - enum HotSpotCompiledCodeFlags { - HCC_IS_NMETHOD = 0x01, - HCC_HAS_ASSUMPTIONS = 0x02, - HCC_HAS_METHODS = 0x04, - HCC_HAS_DEOPT_RESCUE_SLOT = 0x08, - HCC_HAS_COMMENTS = 0x10 - }; - - // Mirrors DebugInfo flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream. - enum DebugInfoFlags { - DI_HAS_REFERENCE_MAP = 0x01, - DI_HAS_CALLEE_SAVE_INFO = 0x02, - DI_HAS_FRAMES = 0x04 - }; - - // Mirrors BytecodeFrame flags from jdk.vm.ci.hotspot.HotSpotCompiledCodeStream. - enum DebugInfoFrameFlags { - DIF_HAS_LOCALS = 0x01, - DIF_HAS_STACK = 0x02, - DIF_HAS_LOCKS = 0x04, - DIF_DURING_CALL = 0x08, - DIF_RETHROW_EXCEPTION = 0x10 - }; - - // Sentinel value in a DebugInfo stream denoting no register. - static const int NO_REGISTER = 0xFFFF; - - Arena _arena; - JVMCIEnv* _jvmci_env; - - jint _sites_count; - - CodeOffsets _offsets; - int _nmethod_entry_patch_offset; - - jint _code_size; - jint _total_frame_size; - jint _orig_pc_offset; - jint _parameter_count; - jint _constants_size; - - bool _has_monitors; - bool _has_wide_vector; - - MarkId _next_call_type; - address _invoke_mark_pc; - - CodeSection* _instructions; - CodeSection* _constants; - - OopRecorder* _oop_recorder; - DebugInformationRecorder* _debug_recorder; - Dependencies* _dependencies; - ExceptionHandlerTable _exception_handler_table; - ImplicitExceptionTable _implicit_exception_table; - bool _has_auto_box; - - static ConstantOopWriteValue* _oop_null_scope_value; - static ConstantIntValue* _int_m1_scope_value; - static ConstantIntValue* _int_0_scope_value; - static ConstantIntValue* _int_1_scope_value; - static ConstantIntValue* _int_2_scope_value; - static LocationValue* _illegal_value; - static MarkerValue* _virtual_byte_array_marker; - - jint pd_next_offset(NativeInstruction* inst, jint pc_offset, JVMCI_TRAPS); - void pd_patch_OopConstant(int pc_offset, Handle& obj, bool compressed, JVMCI_TRAPS); - void pd_patch_MetaspaceConstant(int pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS); - void pd_patch_DataSectionReference(int pc_offset, int data_offset, JVMCI_TRAPS); - void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, JVMCI_TRAPS); - void pd_relocate_JavaMethod(CodeBuffer &cbuf, methodHandle& method, jint pc_offset, JVMCI_TRAPS); - bool pd_relocate(address pc, jint mark); - -public: - -#ifndef PRODUCT - // Verifies the enum mirroring BCI constants in BytecodeFrame is in sync. - static void verify_bci_constants(JVMCIEnv* env); -#endif - - CodeInstaller(JVMCIEnv* jvmci_env) : - _arena(mtJVMCI), - _jvmci_env(jvmci_env), - _has_auto_box(false) {} - - JVMCI::CodeInstallResult install(JVMCICompiler* compiler, - jlong compiled_code_buffer, - bool with_type_info, - JVMCIObject compiled_code, - objArrayHandle object_pool, - CodeBlob*& cb, - JVMCINMethodHandle& nmethod_handle, - JVMCIObject installed_code, - FailedSpeculation** failed_speculations, - char* speculations, - int speculations_len, - JVMCI_TRAPS); - - JVMCIEnv* jvmci_env() { return _jvmci_env; } - JVMCIRuntime* runtime() { return _jvmci_env->runtime(); } - - static address runtime_call_target_address(oop runtime_call); - static VMReg get_hotspot_reg(jint jvmciRegisterNumber, JVMCI_TRAPS); - static bool is_general_purpose_reg(VMReg hotspotRegister); - static ScopeValue* to_primitive_value(HotSpotCompiledCodeStream* stream, jlong raw, BasicType type, ScopeValue* &second, JVMCI_TRAPS); - - const OopMapSet* oopMapSet() const { return _debug_recorder->_oopmaps; } - - // Gets the tag to be used with `read_oop()` corresponding to `patch_object_tag`. - static u1 as_read_oop_tag(HotSpotCompiledCodeStream* stream, u1 patch_object_tag, JVMCI_TRAPS); - -protected: - Handle read_oop(HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS); - - ScopeValue* get_scope_value(HotSpotCompiledCodeStream* stream, u1 tag, BasicType type, ScopeValue* &second, JVMCI_TRAPS); - - GrowableArray* read_local_or_stack_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, bool is_locals, JVMCI_TRAPS); - - void* record_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS); -#ifdef _LP64 - narrowKlass record_narrow_metadata_reference(CodeSection* section, address dest, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS); -#endif - GrowableArray* read_monitor_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, JVMCI_TRAPS); - - // extract the fields of the HotSpotCompiledCode - void initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, CodeBuffer& buffer, JVMCI_TRAPS); - void initialize_dependencies(HotSpotCompiledCodeStream* stream, u1 code_flags, OopRecorder* oop_recorder, JVMCI_TRAPS); - - int estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - - // perform data and call relocation on the CodeBuffer - JVMCI::CodeInstallResult initialize_buffer(JVMCIObject compiled_code, CodeBuffer& buffer, HotSpotCompiledCodeStream* stream, u1 code_flags, JVMCI_TRAPS); - - void site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS); - void site_Infopoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - void site_Call(CodeBuffer& buffer, u1 tag, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - void site_DataPatch(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - void site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - void site_ExceptionHandler(jint pc_offset, HotSpotCompiledCodeStream* stream); - - OopMap* create_oop_map(HotSpotCompiledCodeStream* stream, u1 debug_info_flags, JVMCI_TRAPS); - - VMReg getVMRegFromLocation(HotSpotCompiledCodeStream* stream, int total_frame_size, JVMCI_TRAPS); - - int map_jvmci_bci(int bci); - - void record_oop_patch(HotSpotCompiledCodeStream* stream, address dest, u1 read_tag, bool narrow, JVMCI_TRAPS); - - // full_info: if false, only BytecodePosition is in stream otherwise all DebugInfo is in stream - void record_scope(jint pc_offset, HotSpotCompiledCodeStream* stream, u1 debug_info_flags, bool full_info, bool return_oop, JVMCI_TRAPS); - - void record_scope(jint pc_offset, HotSpotCompiledCodeStream* stream, u1 debug_info_flags, bool full_info, JVMCI_TRAPS) { - record_scope(pc_offset, stream, debug_info_flags, full_info, false /* return_oop */, JVMCIENV); - } - void record_object_value(ObjectValue* sv, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - - void read_virtual_objects(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS); - - int estimateStubSpace(int static_call_stubs); - - JVMCI::CodeInstallResult install_runtime_stub(CodeBlob*& cb, - const char* name, - CodeBuffer* buffer, - int stack_slots, - JVMCI_TRAPS); -}; - -#endif // SHARE_JVMCI_JVMCICODEINSTALLER_HPP diff --git a/src/hotspot/share/jvmci/jvmciCompiler.cpp b/src/hotspot/share/jvmci/jvmciCompiler.cpp deleted file mode 100644 index 2e84f6830b8..00000000000 --- a/src/hotspot/share/jvmci/jvmciCompiler.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/moduleEntry.hpp" -#include "classfile/vmClasses.hpp" -#include "classfile/vmSymbols.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/compilerDefinitions.inline.hpp" -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "oops/objArrayOop.inline.hpp" -#include "runtime/arguments.hpp" -#include "runtime/handles.inline.hpp" - -JVMCICompiler* JVMCICompiler::_instance = nullptr; - -JVMCICompiler::JVMCICompiler() : AbstractCompiler(compiler_jvmci) { - _bootstrapping = false; - _bootstrap_compilation_request_handled = false; - _methods_compiled = 0; - _ok_upcalls = 0; - _err_upcalls = 0; - _disabled = false; - _global_compilation_ticks = 0; - assert(_instance == nullptr, "only one instance allowed"); - _instance = this; -} - -JVMCICompiler* JVMCICompiler::instance(bool require_non_null, TRAPS) { - if (!EnableJVMCI) { - THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), JVMCI_NOT_ENABLED_ERROR_MESSAGE) - } - if (_instance == nullptr && require_non_null) { - THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "The JVMCI compiler instance has not been created"); - } - return _instance; -} - -void compiler_stubs_init(bool in_compiler_thread); - -// Initialization -void JVMCICompiler::initialize() { - assert(!CompilerConfig::is_c1_or_interpreter_only_no_jvmci(), "JVMCI is launched, it's not c1/interpreter only mode"); - if (!UseCompiler || !EnableJVMCI || !UseJVMCICompiler || !should_perform_init()) { - return; - } - compiler_stubs_init(true /* in_compiler_thread */); // generate compiler's intrinsics stubs - set_state(initialized); -} - -void JVMCICompiler::bootstrap(TRAPS) { - if (Arguments::mode() == Arguments::_int) { - // Nothing to do in -Xint mode - return; - } - _bootstrapping = true; - ResourceMark rm(THREAD); - HandleMark hm(THREAD); - if (PrintBootstrap) { - tty->print("Bootstrapping JVMCI"); - } - jlong start = os::javaTimeNanos(); - - Array* objectMethods = vmClasses::Object_klass()->methods(); - // Initialize compile queue with a selected set of methods. - int len = objectMethods->length(); - for (int i = 0; i < len; i++) { - methodHandle mh(THREAD, objectMethods->at(i)); - if (!mh->is_native() && !mh->is_static() && !mh->is_object_initializer() && !mh->is_static_initializer()) { - ResourceMark rm; - int hot_count = 10; // TODO: what's the appropriate value? - CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, hot_count, CompileTask::Reason_Bootstrap, CHECK); - } - } - - int qsize; - bool first_round = true; - int z = 0; - do { - // Loop until there is something in the queue. - do { - THREAD->sleep(100); - qsize = CompileBroker::queue_size(CompLevel_full_optimization); - } while (!_bootstrap_compilation_request_handled && first_round && qsize == 0); - first_round = false; - if (PrintBootstrap) { - while (z < (_methods_compiled / 100)) { - ++z; - tty->print_raw("."); - } - } - } while (qsize != 0); - - if (PrintBootstrap) { - tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", - (jlong)nanos_to_millis(os::javaTimeNanos() - start), _methods_compiled); - } - _bootstrapping = false; - JVMCI::java_runtime()->bootstrap_finished(CHECK); -} - -bool JVMCICompiler::force_comp_at_level_simple(const methodHandle& method) { - if (_disabled) { - return true; - } - if (_bootstrapping) { - // When bootstrapping, the JVMCI compiler can compile its own methods. - return false; - } - if (UseJVMCINativeLibrary) { - // This mechanism exists to force compilation of a JVMCI compiler by C1 - // to reduce the compilation time spent on the JVMCI compiler itself. In - // +UseJVMCINativeLibrary mode, the JVMCI compiler is AOT compiled. - return false; - } else { - JVMCIRuntime* runtime = JVMCI::java_runtime(); - if (runtime != nullptr) { - JVMCIObject receiver = runtime->probe_HotSpotJVMCIRuntime(); - if (receiver.is_null()) { - return false; - } - JVMCIEnv* ignored_env = nullptr; - objArrayHandle excludeModules(JavaThread::current(), HotSpotJVMCI::HotSpotJVMCIRuntime::excludeFromJVMCICompilation(ignored_env, HotSpotJVMCI::resolve(receiver))); - if (excludeModules.not_null()) { - ModuleEntry* moduleEntry = method->method_holder()->module(); - for (int i = 0; i < excludeModules->length(); i++) { - if (excludeModules->obj_at(i) == moduleEntry->module_oop()) { - return true; - } - } - } - } - return false; - } -} - -// Compilation entry point for methods -void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive) { - ShouldNotReachHere(); -} - -void JVMCICompiler::stopping_compiler_thread(CompilerThread* current) { - if (UseJVMCINativeLibrary) { - JVMCIRuntime* runtime = JVMCI::compiler_runtime(current, false); - if (runtime != nullptr) { - MutexUnlocker unlock(CompileThread_lock); - runtime->detach_thread(current, "stopping idle compiler thread"); - } - } -} - -void JVMCICompiler::on_empty_queue(CompileQueue* queue, CompilerThread* thread) { - if (UseJVMCINativeLibrary) { - int delay = JVMCICompilerIdleDelay; - JVMCIRuntime* runtime = JVMCI::compiler_runtime(thread, false); - // Don't detach JVMCI compiler threads from their JVMCI - // runtime during the VM startup grace period - if (runtime != nullptr && delay > 0 && tty->time_stamp().milliseconds() > DEFAULT_COMPILER_IDLE_DELAY) { - bool timeout = MethodCompileQueue_lock->wait(delay); - // Unlock as detaching or repacking can result in a JNI call to shutdown a JavaVM - // and locks cannot be held when making a VM to native transition. - MutexUnlocker unlock(MethodCompileQueue_lock); - if (timeout) { - runtime->detach_thread(thread, "releasing idle compiler thread"); - } else { - runtime->repack(thread); - } - } - } -} - -// Print compilation timers -void JVMCICompiler::print_timers() { - tty->print_cr(" JVMCI CompileBroker Time:"); - tty->print_cr(" Compile: %7.3f s", stats()->total_time()); - _jit_code_installs.print_on(tty, " Install Code: "); - tty->cr(); - tty->print_cr(" JVMCI Hosted Time:"); - _hosted_code_installs.print_on(tty, " Install Code: "); -} - -bool JVMCICompiler::is_intrinsic_supported(const methodHandle& method) { - vmIntrinsics::ID id = method->intrinsic_id(); - assert(id != vmIntrinsics::_none, "must be a VM intrinsic"); - JavaThread* thread = JavaThread::current(); - JVMCIEnv jvmciEnv(thread, __FILE__, __LINE__); - JVMCIRuntime* runtime = JVMCI::compiler_runtime(thread, false); - return runtime->is_intrinsic_supported(&jvmciEnv, (jint) id); -} - -void JVMCICompiler::CodeInstallStats::print_on(outputStream* st, const char* prefix) const { - double time = _timer.seconds(); - st->print_cr("%s%7.3f s (installs: %d, CodeBlob total size: %d, CodeBlob code size: %d)", - prefix, time, _count, _codeBlobs_size, _codeBlobs_code_size); -} - -void JVMCICompiler::CodeInstallStats::on_install(CodeBlob* cb) { - AtomicAccess::inc(&_count); - AtomicAccess::add(&_codeBlobs_size, cb->size()); - AtomicAccess::add(&_codeBlobs_code_size, cb->code_size()); -} - -void JVMCICompiler::inc_methods_compiled() { - AtomicAccess::inc(&_methods_compiled); - AtomicAccess::inc(&_global_compilation_ticks); -} - -void JVMCICompiler::on_upcall(const char* error, JVMCICompileState* compile_state) { - if (error != nullptr) { - - AtomicAccess::inc(&_err_upcalls); - int ok = _ok_upcalls; - int err = _err_upcalls; - // If there have been at least 10 upcalls with an error - // and the number of error upcalls is 10% or more of the - // number of non-error upcalls, disable JVMCI compilation. - if (err > 10 && err * 10 > ok && !_disabled) { - _disabled = true; - int total = err + ok; - // Using stringStream instead of err_msg to avoid truncation - stringStream st; - st.print("JVMCI compiler disabled " - "after %d of %d upcalls had errors (Last error: \"%s\"). " - "Use -Xlog:jit+compilation for more detail.", err, total, error); - const char* disable_msg = st.freeze(); - log_warning(jit,compilation)("%s", disable_msg); - if (compile_state != nullptr) { - const char* disable_error = os::strdup(disable_msg); - if (disable_error != nullptr) { - compile_state->set_failure(true, disable_error, true); - JVMCI_event_1("%s", disable_error); - return; - } else { - // Leave failure reason as set by caller when strdup fails - } - } - } - JVMCI_event_1("JVMCI upcall had an error: %s", error); - } else { - AtomicAccess::inc(&_ok_upcalls); - } -} - -void JVMCICompiler::inc_global_compilation_ticks() { - AtomicAccess::inc(&_global_compilation_ticks); -} diff --git a/src/hotspot/share/jvmci/jvmciCompiler.hpp b/src/hotspot/share/jvmci/jvmciCompiler.hpp deleted file mode 100644 index 11427b975f3..00000000000 --- a/src/hotspot/share/jvmci/jvmciCompiler.hpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCICOMPILER_HPP -#define SHARE_JVMCI_JVMCICOMPILER_HPP - -#include "compiler/abstractCompiler.hpp" -#include "compiler/compiler_globals.hpp" -#include "runtime/atomicAccess.hpp" - -class JVMCICompileState; - -class JVMCICompiler : public AbstractCompiler { - public: - // Code installation specific statistics. - class CodeInstallStats { - private: - elapsedTimer _timer; - volatile int _count; - volatile int _codeBlobs_size; - volatile int _codeBlobs_code_size; - public: - CodeInstallStats() : - _count(0), - _codeBlobs_size(0), - _codeBlobs_code_size(0) - {} - - elapsedTimer* timer() { return &_timer; } - void print_on(outputStream* st, const char* prefix) const; - - // Notifies this object that `cb` has just been - // installed in the code cache. - void on_install(CodeBlob* cb); - }; - - private: - bool _bootstrapping; - - /** - * True if we have seen a bootstrap compilation request. - */ - volatile bool _bootstrap_compilation_request_handled; - - /** - * Number of methods successfully compiled by a call to - * JVMCIRuntime::compile_method(). - */ - volatile int _methods_compiled; - - // Tracks upcalls that should only fail under severe conditions (e.g. - // memory pressure) and disables JVMCI compilation if too many fail - // with an error. A good example is an OOME thrown - // when libgraal calls into the HotSpot heap to get a copy - // of the system properties or to translate an exception from - // the HotSpot heap to the libgraal heap. - volatile int _ok_upcalls; - volatile int _err_upcalls; - bool _disabled; - - // Incremented periodically by JVMCI compiler threads - // to indicate JVMCI compilation activity. - volatile int _global_compilation_ticks; - - static JVMCICompiler* _instance; - - CodeInstallStats _jit_code_installs; // CompileBroker compilations - CodeInstallStats _hosted_code_installs; // Non-CompileBroker compilations - - /** - * Exits the VM due to an unexpected exception. - */ - static void exit_on_pending_exception(oop exception, const char* message); - -public: - JVMCICompiler(); - - static JVMCICompiler* instance(bool require_non_null, TRAPS); - - virtual const char* name() { return UseJVMCINativeLibrary ? "JVMCI-native" : "JVMCI"; } - - bool is_jvmci() { return true; } - bool is_c1 () { return false; } - bool is_c2 () { return false; } - - virtual bool is_hidden_from_external_view() const { return UseJVMCINativeLibrary && LibJVMCICompilerThreadHidden; } - - - bool needs_stubs () { return false; } - - // Initialization - virtual void initialize(); - - /** - * Initialize the compile queue with the methods in java.lang.Object and - * then wait until the queue is empty. - */ - void bootstrap(TRAPS); - - // Should force compilation of method at CompLevel_simple? - bool force_comp_at_level_simple(const methodHandle& method); - - bool is_bootstrapping() const { return _bootstrapping; } - - void set_bootstrap_compilation_request_handled() { - _instance->_bootstrap_compilation_request_handled = true; - } - - // Compilation entry point for methods - virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive); - - virtual void stopping_compiler_thread(CompilerThread* current); - - virtual void on_empty_queue(CompileQueue* queue, CompilerThread* thread); - - // Print compilation timers and statistics - virtual void print_timers(); - - virtual bool is_intrinsic_supported(const methodHandle& method); - - // Gets the number of methods that have been successfully compiled by - // a call to JVMCICompiler::compile_method(). - int methods_compiled() { return _methods_compiled; } - void inc_methods_compiled(); - - // Called after a JVMCI upcall whose success is a measure of the - // JVMCI compiler's health. The value of `error` describes - // an error during the upcall, null if no error. - void on_upcall(const char* error, JVMCICompileState* compile_state=nullptr); - - // Gets a value indicating JVMCI compilation activity on any thread. - // If successive calls to this method return a different value, then - // some degree of JVMCI compilation occurred between the calls. - int global_compilation_ticks() const { return _global_compilation_ticks; } - void inc_global_compilation_ticks(); - - CodeInstallStats* code_install_stats(bool hosted) { - if (!hosted) { - return &_jit_code_installs; - } else { - return &_hosted_code_installs; - } - } -}; - -#endif // SHARE_JVMCI_JVMCICOMPILER_HPP diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp deleted file mode 100644 index 5d0d2aedc62..00000000000 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ /dev/null @@ -1,3467 +0,0 @@ -/* - * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/classLoaderData.inline.hpp" -#include "classfile/javaClasses.inline.hpp" -#include "classfile/stringTable.hpp" -#include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" -#include "classfile/vmClasses.hpp" -#include "code/nmethod.hpp" -#include "code/scopeDesc.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/compilerEvent.hpp" -#include "compiler/compilerOracle.hpp" -#include "compiler/disassembler.hpp" -#include "compiler/oopMap.hpp" -#include "interpreter/bytecodeStream.hpp" -#include "interpreter/linkResolver.hpp" -#include "interpreter/oopMapCache.hpp" -#include "jfr/jfrEvents.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "logging/log.hpp" -#include "logging/logTag.hpp" -#include "memory/oopFactory.hpp" -#include "memory/universe.hpp" -#include "oops/constantPool.inline.hpp" -#include "oops/instanceKlass.inline.hpp" -#include "oops/instanceMirrorKlass.hpp" -#include "oops/method.inline.hpp" -#include "oops/objArrayKlass.inline.hpp" -#include "oops/trainingData.hpp" -#include "oops/typeArrayOop.inline.hpp" -#include "prims/jvmtiExport.hpp" -#include "prims/methodHandles.hpp" -#include "prims/nativeLookup.hpp" -#include "runtime/arguments.hpp" -#include "runtime/atomicAccess.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/fieldDescriptor.inline.hpp" -#include "runtime/frame.inline.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/interfaceSupport.inline.hpp" -#include "runtime/jniHandles.inline.hpp" -#include "runtime/keepStackGCProcessed.hpp" -#include "runtime/reflection.hpp" -#include "runtime/stackFrameStream.inline.hpp" -#include "runtime/timerTrace.hpp" -#include "runtime/vframe.inline.hpp" -#include "runtime/vframe_hp.hpp" -#if INCLUDE_JFR -#include "jfr/jfr.hpp" -#endif - -JVMCIKlassHandle::JVMCIKlassHandle(Thread* thread, Klass* klass) { - _thread = thread; - _klass = klass; - if (klass != nullptr) { - _holder = Handle(_thread, klass->klass_holder()); - } -} - -JVMCIKlassHandle& JVMCIKlassHandle::operator=(Klass* klass) { - _klass = klass; - if (klass != nullptr) { - _holder = Handle(_thread, klass->klass_holder()); - } - return *this; -} - -static void requireInHotSpot(const char* caller, JVMCI_TRAPS) { - if (!JVMCIENV->is_hotspot()) { - JVMCI_THROW_MSG(IllegalStateException, err_msg("Cannot call %s from JVMCI shared library", caller)); - } -} - -static void requireNotInHotSpot(const char* caller, JVMCI_TRAPS) { - if (JVMCIENV->is_hotspot()) { - JVMCI_THROW_MSG(IllegalStateException, err_msg("Cannot call %s from HotSpot", caller)); - } -} - -class JVMCITraceMark : public StackObj { - const char* _msg; - public: - JVMCITraceMark(const char* msg) { - _msg = msg; - JVMCI_event_2("Enter %s", _msg); - } - ~JVMCITraceMark() { - JVMCI_event_2(" Exit %s", _msg); - } -}; - -class JavaArgumentUnboxer : public SignatureIterator { - protected: - JavaCallArguments* _jca; - arrayOop _args; - int _index; - - Handle next_arg(BasicType expectedType); - - public: - JavaArgumentUnboxer(Symbol* signature, - JavaCallArguments* jca, - arrayOop args, - bool is_static) - : SignatureIterator(signature) - { - this->_return_type = T_ILLEGAL; - _jca = jca; - _index = 0; - _args = args; - if (!is_static) { - _jca->push_oop(next_arg(T_OBJECT)); - } - do_parameters_on(this); - assert(_index == args->length(), "arg count mismatch with signature"); - } - - private: - friend class SignatureIterator; // so do_parameters_on can call do_type - void do_type(BasicType type) { - if (is_reference_type(type)) { - _jca->push_oop(next_arg(T_OBJECT)); - return; - } - Handle arg = next_arg(type); - int box_offset = java_lang_boxing_object::value_offset(type); - switch (type) { - case T_BOOLEAN: _jca->push_int(arg->bool_field(box_offset)); break; - case T_CHAR: _jca->push_int(arg->char_field(box_offset)); break; - case T_SHORT: _jca->push_int(arg->short_field(box_offset)); break; - case T_BYTE: _jca->push_int(arg->byte_field(box_offset)); break; - case T_INT: _jca->push_int(arg->int_field(box_offset)); break; - case T_LONG: _jca->push_long(arg->long_field(box_offset)); break; - case T_FLOAT: _jca->push_float(arg->float_field(box_offset)); break; - case T_DOUBLE: _jca->push_double(arg->double_field(box_offset)); break; - default: ShouldNotReachHere(); - } - } -}; - -Handle JavaArgumentUnboxer::next_arg(BasicType expectedType) { - assert(_index < _args->length(), "out of bounds"); - oop arg=((objArrayOop) (_args))->obj_at(_index++); - assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch"); - return Handle(Thread::current(), arg); -} - -// Bring the JVMCI compiler thread into the VM state. -#define JVMCI_VM_ENTRY_MARK \ - MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, thread)); \ - ThreadInVMfromNative __tiv(thread); \ - HandleMarkCleaner __hm(thread); \ - JavaThread* THREAD = thread; \ - DEBUG_ONLY(VMNativeEntryWrapper __vew;) - -// Native method block that transitions current thread to '_thread_in_vm'. -// Note: CompilerThreadCanCallJava must precede JVMCIENV_FROM_JNI so that -// the translation of an uncaught exception in the JVMCIEnv does not make -// a Java call when __is_hotspot == false. -#define C2V_BLOCK(result_type, name, signature) \ - JVMCI_VM_ENTRY_MARK; \ - ResourceMark rm; \ - bool __is_hotspot = env == thread->jni_environment(); \ - bool __block_can_call_java = __is_hotspot || !thread->is_Compiler_thread() || CompilerThread::cast(thread)->can_call_java(); \ - CompilerThreadCanCallJava ccj(thread, __block_can_call_java); \ - JVMCIENV_FROM_JNI(JVMCI::compilation_tick(thread), env); \ - -// Entry to native method implementation that transitions -// current thread to '_thread_in_vm'. -#define C2V_VMENTRY(result_type, name, signature) \ - result_type JNICALL c2v_ ## name signature { \ - JavaThread* thread = JavaThread::current_or_null(); \ - if (thread == nullptr) { \ - env->ThrowNew(JNIJVMCI::InternalError::clazz(), \ - err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \ - return; \ - } \ - C2V_BLOCK(result_type, name, signature) \ - JVMCITraceMark jtm("CompilerToVM::" #name); - -#define C2V_VMENTRY_(result_type, name, signature, result) \ - result_type JNICALL c2v_ ## name signature { \ - JavaThread* thread = JavaThread::current_or_null(); \ - if (thread == nullptr) { \ - env->ThrowNew(JNIJVMCI::InternalError::clazz(), \ - err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \ - return result; \ - } \ - C2V_BLOCK(result_type, name, signature) \ - JVMCITraceMark jtm("CompilerToVM::" #name); - -#define C2V_VMENTRY_NULL(result_type, name, signature) C2V_VMENTRY_(result_type, name, signature, nullptr) -#define C2V_VMENTRY_0(result_type, name, signature) C2V_VMENTRY_(result_type, name, signature, 0) - -// Entry to native method implementation that does not transition -// current thread to '_thread_in_vm'. -#define C2V_VMENTRY_PREFIX(result_type, name, signature) \ - result_type JNICALL c2v_ ## name signature { \ - JavaThread* thread = JavaThread::current_or_null(); - -#define C2V_END } - -#define JNI_THROW(caller, name, msg) do { \ - jint __throw_res = env->ThrowNew(JNIJVMCI::name::clazz(), msg); \ - if (__throw_res != JNI_OK) { \ - JVMCI_event_1("Throwing " #name " in " caller " returned %d", __throw_res); \ - } \ - return; \ - } while (0); - -#define JNI_THROW_(caller, name, msg, result) do { \ - jint __throw_res = env->ThrowNew(JNIJVMCI::name::clazz(), msg); \ - if (__throw_res != JNI_OK) { \ - JVMCI_event_1("Throwing " #name " in " caller " returned %d", __throw_res); \ - } \ - return result; \ - } while (0) - -jobjectArray readConfiguration0(JNIEnv *env, JVMCI_TRAPS); - -C2V_VMENTRY_NULL(jobjectArray, readConfiguration, (JNIEnv* env)) - jobjectArray config = readConfiguration0(env, JVMCI_CHECK_NULL); - return config; -} - -C2V_VMENTRY_NULL(jobject, getFlagValue, (JNIEnv* env, jobject c2vm, jobject name_handle)) -#define RETURN_BOXED_LONG(value) jvalue p; p.j = (jlong) (value); JVMCIObject box = JVMCIENV->create_box(T_LONG, &p, JVMCI_CHECK_NULL); return box.as_jobject(); -#define RETURN_BOXED_DOUBLE(value) jvalue p; p.d = (jdouble) (value); JVMCIObject box = JVMCIENV->create_box(T_DOUBLE, &p, JVMCI_CHECK_NULL); return box.as_jobject(); - JVMCIObject name = JVMCIENV->wrap(name_handle); - if (name.is_null()) { - JVMCI_THROW_NULL(NullPointerException); - } - const char* cstring = JVMCIENV->as_utf8_string(name); - const JVMFlag* flag = JVMFlag::find_declared_flag(cstring); - if (flag == nullptr) { - return c2vm; - } - if (flag->is_bool()) { - jvalue prim; - prim.z = flag->get_bool(); - JVMCIObject box = JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(box); - } else if (flag->is_ccstr()) { - JVMCIObject value = JVMCIENV->create_string(flag->get_ccstr(), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(value); - } else if (flag->is_intx()) { - RETURN_BOXED_LONG(flag->get_intx()); - } else if (flag->is_int()) { - RETURN_BOXED_LONG(flag->get_int()); - } else if (flag->is_uint()) { - RETURN_BOXED_LONG(flag->get_uint()); - } else if (flag->is_uint64_t()) { - RETURN_BOXED_LONG(flag->get_uint64_t()); - } else if (flag->is_size_t()) { - RETURN_BOXED_LONG(flag->get_size_t()); - } else if (flag->is_uintx()) { - RETURN_BOXED_LONG(flag->get_uintx()); - } else if (flag->is_double()) { - RETURN_BOXED_DOUBLE(flag->get_double()); - } else { - JVMCI_ERROR_NULL("VM flag %s has unsupported type %s", flag->name(), flag->type_string()); - } -#undef RETURN_BOXED_LONG -#undef RETURN_BOXED_DOUBLE -C2V_END - -// Macros for argument pairs representing a wrapper object and its wrapped VM pointer -#define ARGUMENT_PAIR(name) jobject name ## _obj, jlong name ## _pointer -#define UNPACK_PAIR(type, name) ((type*) name ## _pointer) - -C2V_VMENTRY_NULL(jbyteArray, getBytecode, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - - int code_size = method->code_size(); - jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size); - - guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten"); - // iterate over all bytecodes and replace non-Java bytecodes - - for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) { - Bytecodes::Code code = s.code(); - Bytecodes::Code raw_code = s.raw_code(); - int bci = s.bci(); - int len = s.instruction_size(); - - // Restore original byte code. - reconstituted_code[bci] = (jbyte) (s.is_wide()? Bytecodes::_wide : code); - if (len > 1) { - memcpy(reconstituted_code + (bci + 1), s.bcp()+1, len-1); - } - - if (len > 1) { - // Restore the big-endian constant pool indexes. - // Cf. Rewriter::scan_method - switch (code) { - case Bytecodes::_getstatic: - case Bytecodes::_putstatic: - case Bytecodes::_getfield: - case Bytecodes::_putfield: - case Bytecodes::_invokevirtual: - case Bytecodes::_invokespecial: - case Bytecodes::_invokestatic: - case Bytecodes::_invokeinterface: - case Bytecodes::_invokehandle: { - int cp_index = Bytes::get_native_u2((address) reconstituted_code + (bci + 1)); - Bytes::put_Java_u2((address) reconstituted_code + (bci + 1), (u2) cp_index); - break; - } - - case Bytecodes::_invokedynamic: { - int cp_index = Bytes::get_native_u4((address) reconstituted_code + (bci + 1)); - Bytes::put_Java_u4((address) reconstituted_code + (bci + 1), (u4) cp_index); - break; - } - - default: - break; - } - - // Not all ldc byte code are rewritten. - switch (raw_code) { - case Bytecodes::_fast_aldc: { - int cpc_index = reconstituted_code[bci + 1] & 0xff; - int cp_index = method->constants()->object_to_cp_index(cpc_index); - assert(cp_index < method->constants()->length(), "sanity check"); - reconstituted_code[bci + 1] = (jbyte) cp_index; - break; - } - - case Bytecodes::_fast_aldc_w: { - int cpc_index = Bytes::get_native_u2((address) reconstituted_code + (bci + 1)); - int cp_index = method->constants()->object_to_cp_index(cpc_index); - assert(cp_index < method->constants()->length(), "sanity check"); - Bytes::put_Java_u2((address) reconstituted_code + (bci + 1), (u2) cp_index); - break; - } - - default: - break; - } - } - } - - JVMCIPrimitiveArray result = JVMCIENV->new_byteArray(code_size, JVMCI_CHECK_NULL); - JVMCIENV->copy_bytes_from(reconstituted_code, result, 0, code_size); - return JVMCIENV->get_jbyteArray(result); -C2V_END - -C2V_VMENTRY_0(jint, getExceptionTableLength, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - return method->exception_table_length(); -C2V_END - -C2V_VMENTRY_0(jlong, getExceptionTableStart, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - if (method->exception_table_length() == 0) { - return 0L; - } - return (jlong) (address) method->exception_table_start(); -C2V_END - -C2V_VMENTRY_NULL(jobject, asResolvedJavaMethod, (JNIEnv* env, jobject, jobject executable_handle)) - requireInHotSpot("asResolvedJavaMethod", JVMCI_CHECK_NULL); - oop executable = JNIHandles::resolve(executable_handle); - oop mirror = nullptr; - int slot = 0; - - if (executable->klass() == vmClasses::reflect_Constructor_klass()) { - mirror = java_lang_reflect_Constructor::clazz(executable); - slot = java_lang_reflect_Constructor::slot(executable); - } else { - assert(executable->klass() == vmClasses::reflect_Method_klass(), "wrong type"); - mirror = java_lang_reflect_Method::clazz(executable); - slot = java_lang_reflect_Method::slot(executable); - } - Klass* holder = java_lang_Class::as_Klass(mirror); - methodHandle method (THREAD, InstanceKlass::cast(holder)->method_with_idnum(slot)); - JVMCIObject result = JVMCIENV->get_jvmci_method(method, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -} - -C2V_VMENTRY_PREFIX(jboolean, updateCompilerThreadCanCallJava, (JNIEnv* env, jobject, jboolean newState)) - return CompilerThreadCanCallJava::update(thread, newState) != nullptr; -C2V_END - - -C2V_VMENTRY_NULL(jobject, getResolvedJavaMethod, (JNIEnv* env, jobject, jobject base, jlong offset)) - Method* method = nullptr; - JVMCIObject base_object = JVMCIENV->wrap(base); - if (base_object.is_null()) { - method = *((Method**)(offset)); - } else { - Handle obj = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL); - if (obj->is_a(vmClasses::ResolvedMethodName_klass())) { - method = (Method*) (intptr_t) obj->long_field(offset); - } else { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", obj->klass()->external_name())); - } - } - if (method == nullptr) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", JVMCIENV->klass_name(base_object))); - } - assert (method->is_method(), "invalid read"); - JVMCIObject result = JVMCIENV->get_jvmci_method(methodHandle(THREAD, method), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -} - -C2V_VMENTRY_NULL(jobject, getConstantPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass_or_method), jboolean is_klass)) - ConstantPool* cp = nullptr; - if (UNPACK_PAIR(address, klass_or_method) == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - if (!is_klass) { - cp = (UNPACK_PAIR(Method, klass_or_method))->constMethod()->constants(); - } else { - cp = InstanceKlass::cast(UNPACK_PAIR(Klass, klass_or_method))->constants(); - } - - JVMCIObject result = JVMCIENV->get_jvmci_constant_pool(constantPoolHandle(THREAD, cp), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -} - -C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject base, jlong offset, jboolean compressed)) - JVMCIObject base_object = JVMCIENV->wrap(base); - if (base_object.is_null()) { - JVMCI_THROW_MSG_NULL(NullPointerException, "base object is null"); - } - - const char* base_desc = nullptr; - JVMCIKlassHandle klass(THREAD); - if (offset == oopDesc::klass_offset_in_bytes()) { - if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) { - Handle base_oop = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL); - klass = base_oop->klass(); - } else { - goto unexpected; - } - } else if (!compressed) { - if (JVMCIENV->isa_HotSpotConstantPool(base_object)) { - ConstantPool* cp = JVMCIENV->asConstantPool(base_object); - if (offset == in_bytes(ConstantPool::pool_holder_offset())) { - klass = cp->pool_holder(); - } else { - base_desc = FormatBufferResource("[constant pool for %s]", cp->pool_holder()->signature_name()); - goto unexpected; - } - } else if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(base_object)) { - Klass* base_klass = JVMCIENV->asKlass(base_object); - if (offset == in_bytes(Klass::subklass_offset())) { - klass = base_klass->subklass(); - } else if (offset == in_bytes(Klass::super_offset())) { - klass = base_klass->super(); - } else if (offset == in_bytes(Klass::next_sibling_offset())) { - klass = base_klass->next_sibling(); - } else if (offset == in_bytes(ObjArrayKlass::element_klass_offset()) && base_klass->is_objArray_klass()) { - klass = ObjArrayKlass::cast(base_klass)->element_klass(); - } else if (offset >= in_bytes(Klass::primary_supers_offset()) && - offset < in_bytes(Klass::primary_supers_offset()) + (int) (sizeof(Klass*) * Klass::primary_super_limit()) && - offset % sizeof(Klass*) == 0) { - // Offset is within the primary supers array - int index = (int) ((offset - in_bytes(Klass::primary_supers_offset())) / sizeof(Klass*)); - klass = base_klass->primary_super_of_depth(index); - } else { - base_desc = FormatBufferResource("[%s]", base_klass->signature_name()); - goto unexpected; - } - } else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) { - Handle base_oop = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL); - if (base_oop->is_a(vmClasses::Class_klass())) { - if (offset == java_lang_Class::klass_offset()) { - klass = java_lang_Class::as_Klass(base_oop()); - } else if (offset == java_lang_Class::array_klass_offset()) { - klass = java_lang_Class::array_klass_acquire(base_oop()); - } else { - base_desc = FormatBufferResource("[Class=%s]", java_lang_Class::as_Klass(base_oop())->signature_name()); - goto unexpected; - } - } else { - if (!base_oop.is_null()) { - base_desc = FormatBufferResource("[%s]", base_oop()->klass()->signature_name()); - } - goto unexpected; - } - } else if (JVMCIENV->isa_HotSpotMethodData(base_object)) { - jlong base_address = (intptr_t) JVMCIENV->asMethodData(base_object); - Klass* k = *((Klass**) (intptr_t) (base_address + offset)); - if (k == nullptr || k->class_loader_data() == nullptr || !TrainingData::is_klass_loaded(k)) { - return nullptr; - } - if (!k->is_loader_alive()) { - // Klasses in methodData might be concurrently unloading so return null in that case. - return nullptr; - } - klass = k; - } else { - goto unexpected; - } - } else { - goto unexpected; - } - - { - if (klass == nullptr) { - return nullptr; - } - JVMCIObject result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); - } - -unexpected: - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - err_msg("Unexpected arguments: %s%s " JLONG_FORMAT " %s", - JVMCIENV->klass_name(base_object), base_desc == nullptr ? "" : base_desc, - offset, compressed ? "true" : "false")); -} - -C2V_VMENTRY_NULL(jobject, findUniqueConcreteMethod, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), ARGUMENT_PAIR(method))) - methodHandle method (THREAD, UNPACK_PAIR(Method, method)); - InstanceKlass* holder = InstanceKlass::cast(UNPACK_PAIR(Klass, klass)); - if (holder->is_interface()) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Interface %s should be handled in Java code", holder->external_name())); - } - if (method->can_be_statically_bound()) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Effectively static method %s.%s should be handled in Java code", method->method_holder()->external_name(), method->external_name())); - } - - methodHandle ucm; - { - MutexLocker locker(Compile_lock); - ucm = methodHandle(THREAD, Dependencies::find_unique_concrete_method(holder, method())); - } - JVMCIObject result = JVMCIENV->get_jvmci_method(ucm, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, getImplementor, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (!klass->is_interface()) { - THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), - err_msg("Expected interface type, got %s", klass->external_name())); - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - JVMCIKlassHandle handle(THREAD, iklass->implementor()); - JVMCIObject implementor = JVMCIENV->get_jvmci_type(handle, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(implementor); -C2V_END - -C2V_VMENTRY_0(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - return method->is_ignored_by_security_stack_walk(); -C2V_END - -C2V_VMENTRY_0(jboolean, isCompilable,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - // Skip redefined methods - if (method->is_old()) { - return false; - } - return !method->is_not_compilable(CompLevel_full_optimization); -C2V_END - -C2V_VMENTRY_0(jboolean, hasNeverInlineDirective,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method (THREAD, UNPACK_PAIR(Method, method)); - return !Inline || CompilerOracle::should_not_inline(method, CompLevel_full_optimization) || method->dont_inline(); -C2V_END - -C2V_VMENTRY_0(jboolean, shouldInlineMethod,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method (THREAD, UNPACK_PAIR(Method, method)); - return CompilerOracle::should_inline(method) || method->force_inline(); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, ARGUMENT_PAIR(accessing_klass), jint accessing_klass_loader, jboolean resolve)) - CompilerThreadCanCallJava canCallJava(thread, resolve); // Resolution requires Java calls - JVMCIObject name = JVMCIENV->wrap(jname); - const char* str = JVMCIENV->as_utf8_string(name); - TempNewSymbol class_name = SymbolTable::new_symbol(str); - - if (class_name->utf8_length() <= 1) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Primitive type %s should be handled in Java code", str)); - } - -#ifdef ASSERT - const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.lookupTypeException"); - if (val != nullptr) { - if (strstr(val, "") != nullptr) { - tty->print_cr("CompilerToVM.lookupType: %s", str); - } else if (strstr(str, val) != nullptr) { - THROW_MSG_NULL(vmSymbols::java_lang_Exception(), - err_msg("lookupTypeException: %s", str)); - } - } -#endif - - JVMCIKlassHandle resolved_klass(THREAD); - Klass* accessing_klass = UNPACK_PAIR(Klass, accessing_klass); - Handle class_loader; - if (accessing_klass != nullptr) { - class_loader = Handle(THREAD, accessing_klass->class_loader()); - } else { - switch (accessing_klass_loader) { - case 0: break; // class_loader is already null, the boot loader - case 1: class_loader = Handle(THREAD, SystemDictionary::java_platform_loader()); break; - case 2: class_loader = Handle(THREAD, SystemDictionary::java_system_loader()); break; - default: - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Illegal class loader value: %d", accessing_klass_loader)); - } - JVMCIENV->runtime()->initialize(JVMCI_CHECK_NULL); - } - - if (resolve) { - resolved_klass = SystemDictionary::resolve_or_fail(class_name, class_loader, true, CHECK_NULL); - } else { - if (Signature::has_envelope(class_name)) { - // This is a name from a signature. Strip off the trimmings. - // Call recursive to keep scope of strippedsym. - TempNewSymbol strippedsym = Signature::strip_envelope(class_name); - resolved_klass = SystemDictionary::find_instance_klass(THREAD, strippedsym, - class_loader); - } else if (Signature::is_array(class_name)) { - SignatureStream ss(class_name, false); - int ndim = ss.skip_array_prefix(); - if (ss.type() == T_OBJECT) { - Symbol* strippedsym = ss.as_symbol(); - resolved_klass = SystemDictionary::find_instance_klass(THREAD, strippedsym, - class_loader); - if (!resolved_klass.is_null()) { - resolved_klass = resolved_klass->array_klass(ndim, CHECK_NULL); - } - } else { - resolved_klass = Universe::typeArrayKlass(ss.type())->array_klass(ndim, CHECK_NULL); - } - } else { - resolved_klass = SystemDictionary::find_instance_klass(THREAD, class_name, - class_loader); - } - } - JVMCIObject result = JVMCIENV->get_jvmci_type(resolved_klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, getArrayType, (JNIEnv* env, jobject, jchar type_char, ARGUMENT_PAIR(klass))) - JVMCIKlassHandle array_klass(THREAD); - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - BasicType type = JVMCIENV->typeCharToBasicType(type_char, JVMCI_CHECK_NULL); - if (type == T_VOID) { - return nullptr; - } - array_klass = Universe::typeArrayKlass(type); - if (array_klass == nullptr) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("No array klass for primitive type %s", type2name(type))); - } - } else { - array_klass = klass->array_klass(CHECK_NULL); - } - JVMCIObject result = JVMCIENV->get_jvmci_type(array_klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupClass, (JNIEnv* env, jobject, jclass mirror)) - requireInHotSpot("lookupClass", JVMCI_CHECK_NULL); - if (mirror == nullptr) { - return nullptr; - } - JVMCIKlassHandle klass(THREAD); - klass = java_lang_Class::as_Klass(JNIHandles::resolve(mirror)); - if (klass == nullptr) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "Primitive classes are unsupported"); - } - JVMCIObject result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupJClass, (JNIEnv* env, jobject, jlong jclass_value)) - if (jclass_value == 0L) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "jclass must not be zero"); - } - jclass mirror = reinterpret_cast(jclass_value); - // Since the jclass_value is passed as a jlong, we perform additional checks to prevent the caller from accidentally - // sending a value that is not a JNI handle. - if (JNIHandles::handle_type(thread, mirror) == JNIInvalidRefType) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "jclass is not a valid JNI reference"); - } - oop obj = JNIHandles::resolve(mirror); - if (!java_lang_Class::is_instance(obj)) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "jclass must be a reference to the Class object"); - } - JVMCIKlassHandle klass(THREAD, java_lang_Class::as_Klass(obj)); - JVMCIObject result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_0(jlong, getJObjectValue, (JNIEnv* env, jobject, jobject constant_jobject)) - requireNotInHotSpot("getJObjectValue", JVMCI_CHECK_0); - // Ensure that current JNI handle scope is not the top-most JNIHandleBlock as handles - // in that scope are only released when the thread exits. - if (!THREAD->has_last_Java_frame() && THREAD->active_handles()->pop_frame_link() == nullptr) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot call getJObjectValue without Java frame anchor or a pushed JNI handle block")); - } - JVMCIObject constant = JVMCIENV->wrap(constant_jobject); - Handle constant_value = JVMCIENV->asConstant(constant, JVMCI_CHECK_0); - jobject jni_handle = JNIHandles::make_local(THREAD, constant_value()); - return reinterpret_cast(jni_handle); -C2V_END - -C2V_VMENTRY_NULL(jobject, getUncachedStringInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - constantTag tag = cp->tag_at(index); - if (!tag.is_string()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected constant pool tag at index %d: %d", index, tag.value())); - } - oop obj = cp->uncached_string_at(index, CHECK_NULL); - return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(obj)); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupConstantInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint cp_index, bool resolve)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - oop obj; - if (!resolve) { - bool found_it; - obj = cp->find_cached_constant_at(cp_index, found_it, CHECK_NULL); - if (!found_it) { - return nullptr; - } - } else { - obj = cp->resolve_possibly_cached_constant_at(cp_index, CHECK_NULL); - } - constantTag tag = cp->tag_at(cp_index); - if (tag.is_dynamic_constant()) { - if (obj == nullptr) { - return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_NULL_POINTER()); - } - BasicType bt = Signature::basic_type(cp->uncached_signature_ref_at(cp_index)); - if (!is_reference_type(bt)) { - if (!is_java_primitive(bt)) { - return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_ILLEGAL()); - } - - // Convert standard box (e.g. java.lang.Integer) to JVMCI box (e.g. jdk.vm.ci.meta.PrimitiveConstant) - jvalue value; - jlong raw_value; - jchar type_char; - BasicType bt2 = java_lang_boxing_object::get_value(obj, &value); - assert(bt2 == bt, ""); - switch (bt2) { - case T_LONG: type_char = 'J'; raw_value = value.j; break; - case T_DOUBLE: type_char = 'D'; raw_value = value.j; break; - case T_FLOAT: type_char = 'F'; raw_value = value.i; break; - case T_INT: type_char = 'I'; raw_value = value.i; break; - case T_SHORT: type_char = 'S'; raw_value = value.s; break; - case T_BYTE: type_char = 'B'; raw_value = value.b; break; - case T_CHAR: type_char = 'C'; raw_value = value.c; break; - case T_BOOLEAN: type_char = 'Z'; raw_value = value.z; break; - default: return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_ILLEGAL()); - } - - JVMCIObject result = JVMCIENV->call_JavaConstant_forPrimitive(type_char, raw_value, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); - } - } -#ifdef ASSERT - // Support for testing an OOME raised in a context where the current thread cannot call Java - // 1. Put -Dtest.jvmci.oome_in_lookupConstantInPool= on the command line to - // discover possible values for step 2. - // Example output: - // - // CompilerToVM.lookupConstantInPool: "Overflow: String length out of range"{0x00000007ffeb2960} - // CompilerToVM.lookupConstantInPool: "null"{0x00000007ffebdfe8} - // CompilerToVM.lookupConstantInPool: "Maximum lock count exceeded"{0x00000007ffec4f90} - // CompilerToVM.lookupConstantInPool: "Negative length"{0x00000007ffec4468} - // - // 2. Choose a value shown in step 1. - // Example: -Dtest.jvmci.oome_in_lookupConstantInPool=Negative - const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.oome_in_lookupConstantInPool"); - if (val != nullptr) { - const char* str = obj->print_value_string(); - if (strstr(val, "") != nullptr) { - tty->print_cr("CompilerToVM.lookupConstantInPool: %s", str); - } else if (strstr(str, val) != nullptr) { - Handle garbage; - while (true) { - // Trigger an OutOfMemoryError - objArrayOop next = oopFactory::new_objectArray(0x7FFFFFFF, CHECK_NULL); - next->obj_at_put(0, garbage()); - garbage = Handle(THREAD, next); - } - } - } -#endif - return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(obj)); -C2V_END - -C2V_VMENTRY_0(jint, getNumIndyEntries, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp))) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - if (cp->cache()->resolved_indy_entries() == nullptr) { - return 0; - } - return cp->resolved_indy_entries_length(); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, resolveBootstrapMethod, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - constantTag tag = cp->tag_at(index); - bool is_indy = tag.is_invoke_dynamic(); - bool is_condy = tag.is_dynamic_constant(); - if (!(is_condy || is_indy)) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected constant pool tag at index %d: %d", index, tag.value())); - } - // Get the indy entry based on CP index - int indy_index = -1; - if (is_indy) { - for (int i = 0; i < cp->resolved_indy_entries_length(); i++) { - if (cp->resolved_indy_entry_at(i)->constant_pool_index() == index) { - indy_index = i; - } - } - } - // Resolve the bootstrap specifier, its name, type, and static arguments - BootstrapInfo bootstrap_specifier(cp, index, indy_index); - Handle bsm = bootstrap_specifier.resolve_bsm(CHECK_NULL); - - // call java.lang.invoke.MethodHandle::asFixedArity() -> MethodHandle - // to get a DirectMethodHandle from which we can then extract a Method* - JavaValue result(T_OBJECT); - JavaCalls::call_virtual(&result, - bsm, - vmClasses::MethodHandle_klass(), - vmSymbols::asFixedArity_name(), - vmSymbols::asFixedArity_signature(), - CHECK_NULL); - bsm = Handle(THREAD, result.get_oop()); - - // Check assumption about getting a DirectMethodHandle - if (!java_lang_invoke_DirectMethodHandle::is_instance(bsm())) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Unexpected MethodHandle subclass: %s", bsm->klass()->external_name())); - } - // Create return array describing the bootstrap method invocation (BSMI) - JVMCIObjectArray bsmi = JVMCIENV->new_Object_array(4, JVMCI_CHECK_NULL); - - // Extract Method* and wrap it in a ResolvedJavaMethod - Handle member = Handle(THREAD, java_lang_invoke_DirectMethodHandle::member(bsm())); - JVMCIObject bsmi_method = JVMCIENV->get_jvmci_method(methodHandle(THREAD, java_lang_invoke_MemberName::vmtarget(member())), JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(bsmi, 0, bsmi_method); - - JVMCIObject bsmi_name = JVMCIENV->create_string(bootstrap_specifier.name(), JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(bsmi, 1, bsmi_name); - - Handle type_arg = bootstrap_specifier.type_arg(); - JVMCIObject bsmi_type = JVMCIENV->get_object_constant(type_arg()); - JVMCIENV->put_object_at(bsmi, 2, bsmi_type); - - Handle arg_values = bootstrap_specifier.arg_values(); - if (arg_values.not_null()) { - if (!arg_values->is_array()) { - JVMCIENV->put_object_at(bsmi, 3, JVMCIENV->get_object_constant(arg_values())); - } else if (arg_values->is_objArray()) { - objArrayHandle args_array = objArrayHandle(THREAD, (objArrayOop) arg_values()); - int len = args_array->length(); - JVMCIObjectArray arguments = JVMCIENV->new_JavaConstant_array(len, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(bsmi, 3, arguments); - for (int i = 0; i < len; i++) { - oop x = args_array->obj_at(i); - if (x != nullptr) { - JVMCIENV->put_object_at(arguments, i, JVMCIENV->get_object_constant(x)); - } else { - JVMCIENV->put_object_at(arguments, i, JVMCIENV->get_JavaConstant_NULL_POINTER()); - } - } - } else if (arg_values->is_typeArray()) { - typeArrayHandle bsci = typeArrayHandle(THREAD, (typeArrayOop) arg_values()); - JVMCIPrimitiveArray arguments = JVMCIENV->new_intArray(bsci->length(), JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(bsmi, 3, arguments); - for (int i = 0; i < bsci->length(); i++) { - JVMCIENV->put_int_at(arguments, i, bsci->int_at(i)); - } - } - } - return JVMCIENV->get_jobjectArray(bsmi); -C2V_END - -C2V_VMENTRY_0(jint, bootstrapArgumentIndexAt, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint cpi, jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - return cp->bootstrap_argument_index_at(cpi, index); -C2V_END - -C2V_VMENTRY_0(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - return cp->name_and_type_ref_index_at(index, (Bytecodes::Code)opcode); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupNameInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - JVMCIObject sym = JVMCIENV->create_string(cp->name_ref_at(which, (Bytecodes::Code)opcode), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(sym); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupSignatureInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - JVMCIObject sym = JVMCIENV->create_string(cp->signature_ref_at(which, (Bytecodes::Code)opcode), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(sym); -C2V_END - -C2V_VMENTRY_0(jint, lookupKlassRefIndexInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - return cp->klass_ref_index_at(index, (Bytecodes::Code)opcode); -C2V_END - -C2V_VMENTRY_NULL(jobject, resolveTypeInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - Klass* klass = cp->klass_at(index, CHECK_NULL); - JVMCIKlassHandle resolved_klass(THREAD, klass); - if (resolved_klass->is_instance_klass()) { - InstanceKlass::cast(resolved_klass())->link_class(CHECK_NULL); - if (!InstanceKlass::cast(resolved_klass())->is_linked()) { - // link_class() should not return here if there is an issue. - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Class %s must be linked", resolved_klass()->external_name())); - } - } - JVMCIObject klassObject = JVMCIENV->get_jvmci_type(resolved_klass, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(klassObject); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupKlassInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - Klass* loading_klass = cp->pool_holder(); - bool is_accessible = false; - JVMCIKlassHandle klass(THREAD, JVMCIRuntime::get_klass_by_index(cp, index, is_accessible, loading_klass)); - Symbol* symbol = nullptr; - if (klass.is_null()) { - constantTag tag = cp->tag_at(index); - if (tag.is_klass()) { - // The klass has been inserted into the constant pool - // very recently. - klass = cp->resolved_klass_at(index); - } else if (tag.is_symbol()) { - symbol = cp->symbol_at(index); - } else { - if (!tag.is_unresolved_klass()) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Expected %d at index %d, got %d", JVM_CONSTANT_UnresolvedClassInError, index, tag.value())); - } - symbol = cp->klass_name_at(index); - } - } - JVMCIObject result; - if (!klass.is_null()) { - result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); - } else { - result = JVMCIENV->create_string(symbol, JVMCI_CHECK_NULL); - } - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupAppendixInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint which, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, which, Bytecodes::Code(opcode)); - return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(appendix_oop)); -C2V_END - -C2V_VMENTRY_NULL(jobject, lookupMethodInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jbyte opcode, ARGUMENT_PAIR(caller))) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - methodHandle caller(THREAD, UNPACK_PAIR(Method, caller)); - InstanceKlass* pool_holder = cp->pool_holder(); - Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); - methodHandle method(THREAD, JVMCIRuntime::get_method_by_index(cp, index, bc, pool_holder)); - JFR_ONLY(if (method.not_null()) Jfr::on_resolution(caller(), method(), CHECK_NULL);) - JVMCIObject result = JVMCIENV->get_jvmci_method(method, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, resolveFieldInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, ARGUMENT_PAIR(method), jbyte opcode, jintArray info_handle)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); - fieldDescriptor fd; - methodHandle mh(THREAD, UNPACK_PAIR(Method, method)); - - Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); - int holder_index = cp->klass_ref_index_at(index, bc); - if (!cp->tag_at(holder_index).is_klass() && !THREAD->can_call_java()) { - // If the holder is not resolved in the constant pool and the current - // thread cannot call Java, return null. This avoids a Java call - // in LinkInfo to load the holder. - Symbol* klass_name = cp->klass_ref_at_noresolve(index, bc); - return nullptr; - } - - LinkInfo link_info(cp, index, mh, code, CHECK_NULL); - LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), ClassInitMode::dont_init, CHECK_NULL); - JVMCIPrimitiveArray info = JVMCIENV->wrap(info_handle); - if (info.is_null() || JVMCIENV->get_length(info) != 4) { - JVMCI_ERROR_NULL("info must not be null and have a length of 4"); - } - JVMCIENV->put_int_at(info, 0, fd.access_flags().as_field_flags()); - JVMCIENV->put_int_at(info, 1, fd.offset()); - JVMCIENV->put_int_at(info, 2, fd.index()); - JVMCIENV->put_int_at(info, 3, fd.field_flags().as_uint()); - JVMCIKlassHandle handle(THREAD, fd.field_holder()); - JVMCIObject field_holder = JVMCIENV->get_jvmci_type(handle, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(field_holder); -C2V_END - -C2V_VMENTRY_0(jint, getVtableIndexForInterfaceMethod, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), ARGUMENT_PAIR(method))) - Klass* klass = UNPACK_PAIR(Klass, klass); - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - InstanceKlass* holder = method->method_holder(); - if (klass->is_interface()) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Interface %s should be handled in Java code", klass->external_name())); - } - if (!holder->is_interface()) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string())); - } - if (!klass->is_instance_klass()) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be instance klass", klass->external_name())); - } - if (!InstanceKlass::cast(klass)->is_linked()) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be linked", klass->external_name())); - } - if (!klass->is_subtype_of(holder)) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s does not implement interface %s", klass->external_name(), holder->external_name())); - } - return LinkResolver::vtable_index_of_interface_method(klass, method); -C2V_END - -C2V_VMENTRY_NULL(jobject, resolveMethod, (JNIEnv* env, jobject, ARGUMENT_PAIR(receiver), ARGUMENT_PAIR(method), ARGUMENT_PAIR(caller))) - Klass* recv_klass = UNPACK_PAIR(Klass, receiver); - Klass* caller_klass = UNPACK_PAIR(Klass, caller); - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - - Klass* resolved = method->method_holder(); - Symbol* h_name = method->name(); - Symbol* h_signature = method->signature(); - - if (MethodHandles::is_signature_polymorphic_method(method())) { - // Signature polymorphic methods are already resolved, JVMCI just returns null in this case. - return nullptr; - } - - if (method->name() == vmSymbols::clone_name() && - resolved == vmClasses::Object_klass() && - recv_klass->is_array_klass()) { - // Resolution of the clone method on arrays always returns Object.clone even though that method - // has protected access. There's some trickery in the access checking to make this all work out - // so it's necessary to pass in the array class as the resolved class to properly trigger this. - // Otherwise it's impossible to resolve the array clone methods through JVMCI. See - // LinkResolver::check_method_accessability for the matching logic. - resolved = recv_klass; - } - - LinkInfo link_info(resolved, h_name, h_signature, caller_klass); - Method* m = nullptr; - // Only do exact lookup if receiver klass has been linked. Otherwise, - // the vtable has not been setup, and the LinkResolver will fail. - if (recv_klass->is_array_klass() || - (InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface())) { - if (resolved->is_interface()) { - m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); - } else { - m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); - } - } - - if (m == nullptr) { - // Return null if there was a problem with lookup (uninitialized class, etc.) - return nullptr; - } - - JVMCIObject result = JVMCIENV->get_jvmci_method(methodHandle(THREAD, m), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_0(jboolean, hasFinalizableSubclass,(JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - assert(klass != nullptr, "method must not be called for primitive types"); - if (!klass->is_instance_klass()) { - return false; - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - return Dependencies::find_finalizable_subclass(iklass) != nullptr; -C2V_END - -C2V_VMENTRY_NULL(jobject, getClassInitializer, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (!klass->is_instance_klass()) { - return nullptr; - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - methodHandle clinit(THREAD, iklass->class_initializer()); - JVMCIObject result = JVMCIENV->get_jvmci_method(clinit, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_0(jlong, getMaxCallTargetOffset, (JNIEnv* env, jobject, jlong addr)) - address target_addr = (address) addr; - if (target_addr != nullptr) { - int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); - int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); - return MAX2(ABS(off_low), ABS(off_high)); - } - return -1; -C2V_END - -C2V_VMENTRY(void, setNotInlinableOrCompilable,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - method->set_is_not_c1_compilable(); - method->set_is_not_c2_compilable(); - method->set_dont_inline(true); -C2V_END - -C2V_VMENTRY_0(jint, getInstallCodeFlags, (JNIEnv *env, jobject)) - int flags = 0; -#ifndef PRODUCT - flags |= 0x0001; // VM will install block comments - flags |= 0x0004; // Enable HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo if not explicitly set -#endif - if (JvmtiExport::can_hotswap_or_post_breakpoint()) { - // VM needs to track method dependencies - flags |= 0x0002; - } - return flags; -C2V_END - -C2V_VMENTRY_0(jint, installCode0, (JNIEnv *env, jobject, - jlong compiled_code_buffer, - jlong serialization_ns, - bool with_type_info, - jobject compiled_code, - jobjectArray object_pool, - jobject installed_code, - jlong failed_speculations_address, - jbyteArray speculations_obj)) - HandleMark hm(THREAD); - JNIHandleMark jni_hm(thread); - - JVMCIObject compiled_code_handle = JVMCIENV->wrap(compiled_code); - objArrayHandle object_pool_handle(thread, JVMCIENV->is_hotspot() ? (objArrayOop) JNIHandles::resolve(object_pool) : nullptr); - - CodeBlob* cb = nullptr; - JVMCIObject installed_code_handle = JVMCIENV->wrap(installed_code); - JVMCIPrimitiveArray speculations_handle = JVMCIENV->wrap(speculations_obj); - - int speculations_len = JVMCIENV->get_length(speculations_handle); - char* speculations = NEW_RESOURCE_ARRAY(char, speculations_len); - JVMCIENV->copy_bytes_to(speculations_handle, (jbyte*) speculations, 0, speculations_len); - - JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK_JNI_ERR); - JVMCICompiler::CodeInstallStats* stats = compiler->code_install_stats(!thread->is_Compiler_thread()); - elapsedTimer *timer = stats->timer(); - timer->add_nanoseconds(serialization_ns); - TraceTime install_time("installCode", timer); - - CodeInstaller installer(JVMCIENV); - JVMCINMethodHandle nmethod_handle(THREAD); - - JVMCI::CodeInstallResult result = installer.install(compiler, - compiled_code_buffer, - with_type_info, - compiled_code_handle, - object_pool_handle, - cb, - nmethod_handle, - installed_code_handle, - (FailedSpeculation**)(address) failed_speculations_address, - speculations, - speculations_len, - JVMCI_CHECK_0); - - if (PrintCodeCacheOnCompilation) { - stringStream s; - // Dump code cache into a buffer before locking the tty, - { - MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - CodeCache::print_summary(&s, false); - } - ttyLocker ttyl; - tty->print_raw_cr(s.freeze()); - } - - if (result != JVMCI::ok) { - assert(cb == nullptr, "should be"); - } else { - stats->on_install(cb); - if (installed_code_handle.is_non_null()) { - if (cb->is_nmethod()) { - assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type"); - // Clear the link to an old nmethod first - JVMCIObject nmethod_mirror = installed_code_handle; - JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, true, nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE, JVMCI_CHECK_0); - } else { - assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type"); - } - // Initialize the link to the new code blob - JVMCIENV->initialize_installed_code(installed_code_handle, cb, JVMCI_CHECK_0); - } - } - return result; -C2V_END - -C2V_VMENTRY_NULL(jobject, getInvalidationReasonDescription, (JNIEnv *env, jobject, jint invalidation_reason)) - HandleMark hm(THREAD); - JNIHandleMark jni_hm(thread); - nmethod::InvalidationReason reason = static_cast(invalidation_reason); - JVMCIObject desc = JVMCIENV->create_string(nmethod::invalidation_reason_to_string(reason), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(desc); -C2V_END - -C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv* env, jobject)) - JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK); - CompilerStatistics* stats = compiler->stats(); - stats->_standard.reset(); - stats->_osr.reset(); -C2V_END - -C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject installedCode)) - HandleMark hm(THREAD); - - if (installedCode == nullptr) { - JVMCI_THROW_MSG_NULL(NullPointerException, "installedCode is null"); - } - - JVMCIObject installedCodeObject = JVMCIENV->wrap(installedCode); - CodeBlob* cb = JVMCIENV->get_code_blob(installedCodeObject); - if (cb == nullptr) { - return nullptr; - } - - // We don't want the stringStream buffer to resize during disassembly as it - // uses scoped resource memory. If a nested function called during disassembly uses - // a ResourceMark and the buffer expands within the scope of the mark, - // the buffer becomes garbage when that scope is exited. Experience shows that - // the disassembled code is typically about 10x the code size so a fixed buffer - // sized to 20x code size plus a fixed amount for header info should be sufficient. - int bufferSize = cb->code_size() * 20 + 1024; - char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize); - stringStream st(buffer, bufferSize); - Disassembler::decode(cb, &st); - if (st.size() <= 0) { - return nullptr; - } - - JVMCIObject result = JVMCIENV->create_string(st.as_string(), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, getStackTraceElement, (JNIEnv* env, jobject, ARGUMENT_PAIR(method), int bci)) - HandleMark hm(THREAD); - - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - JVMCIObject element = JVMCIENV->new_StackTraceElement(method, bci, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(element); -C2V_END - -C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject args, jobject hs_nmethod)) - // The incoming arguments array would have to contain JavaConstants instead of regular objects - // and the return value would have to be wrapped as a JavaConstant. - requireInHotSpot("executeHotSpotNmethod", JVMCI_CHECK_NULL); - - HandleMark hm(THREAD); - - JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod); - methodHandle mh; - { - // Reduce the scope of JVMCINMethodHandle so that it isn't alive across the Java call. Once the - // nmethod has been validated and the method is fetched from the nmethod it's fine for the - // nmethod to be reclaimed if necessary. - JVMCINMethodHandle nmethod_handle(THREAD); - nmethod* nm = JVMCIENV->get_nmethod(nmethod_mirror, nmethod_handle); - if (nm == nullptr || !nm->is_in_use()) { - JVMCI_THROW_NULL(InvalidInstalledCodeException); - } - methodHandle nmh(THREAD, nm->method()); - mh = nmh; - } - Symbol* signature = mh->signature(); - JavaCallArguments jca(mh->size_of_parameters()); - - JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); - JavaValue result(jap.return_type()); - jca.set_alternative_target(Handle(THREAD, JNIHandles::resolve(nmethod_mirror.as_jobject()))); - JavaCalls::call(&result, mh, &jca, CHECK_NULL); - - if (jap.return_type() == T_VOID) { - return nullptr; - } else if (is_reference_type(jap.return_type())) { - return JNIHandles::make_local(THREAD, result.get_oop()); - } else { - jvalue *value = (jvalue *) result.get_value_addr(); - // Narrow the value down if required (Important on big endian machines) - switch (jap.return_type()) { - case T_BOOLEAN: - value->z = (jboolean) value->i; - break; - case T_BYTE: - value->b = (jbyte) value->i; - break; - case T_CHAR: - value->c = (jchar) value->i; - break; - case T_SHORT: - value->s = (jshort) value->i; - break; - default: - break; - } - JVMCIObject o = JVMCIENV->create_box(jap.return_type(), value, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(o); - } -C2V_END - -C2V_VMENTRY_NULL(jlongArray, getLineNumberTable, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - if (!method->has_linenumber_table()) { - return nullptr; - } - u2 num_entries = 0; - CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); - while (streamForSize.read_pair()) { - num_entries++; - } - - CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); - JVMCIPrimitiveArray result = JVMCIENV->new_longArray(2 * num_entries, JVMCI_CHECK_NULL); - - int i = 0; - jlong value; - while (stream.read_pair()) { - value = ((jlong) stream.bci()); - JVMCIENV->put_long_at(result, i, value); - value = ((jlong) stream.line()); - JVMCIENV->put_long_at(result, i + 1, value); - i += 2; - } - - return (jlongArray) JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_0(jlong, getLocalVariableTableStart, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - if (!method->has_localvariable_table()) { - return 0; - } - return (jlong) (address) method->localvariable_table_start(); -C2V_END - -C2V_VMENTRY_0(jint, getLocalVariableTableLength, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - Method* method = UNPACK_PAIR(Method, method); - return method->localvariable_table_length(); -C2V_END - -static MethodData* get_profiling_method_data(const methodHandle& method, TRAPS) { - MethodData* method_data = method->method_data(); - if (method_data == nullptr) { - method->build_profiling_method_data(method, CHECK_NULL); - method_data = method->method_data(); - if (method_data == nullptr) { - THROW_MSG_NULL(vmSymbols::java_lang_OutOfMemoryError(), "cannot allocate MethodData") - } - } - return method_data; -} - -C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - MethodCounters* mcs = method->method_counters(); - if (mcs != nullptr) { - mcs->clear_counters(); - } - NOT_PRODUCT(method->set_compiled_invocation_count(0)); - - nmethod* code = method->code(); - if (code != nullptr) { - code->make_not_entrant(nmethod::InvalidationReason::JVMCI_REPROFILE); - } - - MethodData* method_data = method->method_data(); - if (method_data == nullptr) { - method_data = get_profiling_method_data(method, CHECK); - } else { - CompilerThreadCanCallJava canCallJava(THREAD, true); - method_data->reinitialize(); - } -C2V_END - - -C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod, jboolean deoptimize, jint invalidation_reason)) - int first = static_cast(nmethod::InvalidationReason::C1_CODEPATCH); - int last = static_cast(nmethod::InvalidationReason::INVALIDATION_REASONS_COUNT); - if (invalidation_reason < first || invalidation_reason >= last) { - JVMCI_THROW_MSG(IllegalArgumentException, err_msg("Invalid invalidation_reason: %d", invalidation_reason)); - } - JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod); - JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, deoptimize, static_cast(invalidation_reason), JVMCI_CHECK); -C2V_END - -C2V_VMENTRY_NULL(jlongArray, collectCounters, (JNIEnv* env, jobject)) - // Returns a zero length array if counters aren't enabled - JVMCIPrimitiveArray array = JVMCIENV->new_longArray(JVMCICounterSize, JVMCI_CHECK_NULL); - if (JVMCICounterSize > 0) { - jlong* temp_array = NEW_RESOURCE_ARRAY(jlong, JVMCICounterSize); - JavaThread::collect_counters(temp_array, JVMCICounterSize); - JVMCIENV->copy_longs_from(temp_array, array, 0, JVMCICounterSize); - } - return (jlongArray) JVMCIENV->get_jobject(array); -C2V_END - -C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject)) - return (jint) JVMCICounterSize; -C2V_END - -C2V_VMENTRY_0(jboolean, setCountersSize, (JNIEnv* env, jobject, jint new_size)) - return JavaThread::resize_all_jvmci_counters(new_size); -C2V_END - -C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, ARGUMENT_PAIR(method), int entry_bci)) - HandleMark hm(THREAD); - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - if (method.is_null()) { - JVMCI_THROW_0(NullPointerException); - } - if (entry_bci >= method->code_size() || entry_bci < -1) { - JVMCI_THROW_MSG_0(IllegalArgumentException, err_msg("Unexpected bci %d", entry_bci)); - } - return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); -C2V_END - - -C2V_VMENTRY_0(jboolean, isMature, (JNIEnv* env, jobject, jlong method_data_pointer)) - MethodData* mdo = (MethodData*) method_data_pointer; - return mdo != nullptr && mdo->is_mature(); -C2V_END - -C2V_VMENTRY_0(jboolean, hasCompiledCodeForOSR, (JNIEnv* env, jobject, ARGUMENT_PAIR(method), int entry_bci, int comp_level)) - Method* method = UNPACK_PAIR(Method, method); - return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != nullptr; -C2V_END - -C2V_VMENTRY_NULL(jobject, getSymbol, (JNIEnv* env, jobject, jlong symbol)) - JVMCIObject sym = JVMCIENV->create_string((Symbol*)(address)symbol, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(sym); -C2V_END - -C2V_VMENTRY_NULL(jobject, getSignatureName, (JNIEnv* env, jobject, jlong klass_pointer)) - Klass* klass = UNPACK_PAIR(Klass, klass); - JVMCIObject signature = JVMCIENV->create_string(klass->signature_name(), JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(signature); -C2V_END - -/* - * Used by matches() to convert a ResolvedJavaMethod[] to an array of Method*. - */ -static GrowableArray* init_resolved_methods(jobjectArray methods, JVMCIEnv* JVMCIENV) { - objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods); - GrowableArray* resolved_methods = new GrowableArray(methods_oop->length()); - for (int i = 0; i < methods_oop->length(); i++) { - oop resolved = methods_oop->obj_at(i); - Method* resolved_method = nullptr; - if (resolved->klass() == HotSpotJVMCI::HotSpotResolvedJavaMethodImpl::klass()) { - resolved_method = HotSpotJVMCI::asMethod(JVMCIENV, resolved); - } - resolved_methods->append(resolved_method); - } - return resolved_methods; -} - -/* - * Used by c2v_iterateFrames to check if `method` matches one of the ResolvedJavaMethods in the `methods` array. - * The ResolvedJavaMethod[] array is converted to a Method* array that is then cached in the resolved_methods_ref in/out parameter. - * In case of a match, the matching ResolvedJavaMethod is returned in matched_jvmci_method_ref. - */ -static bool matches(jobjectArray methods, Method* method, GrowableArray** resolved_methods_ref, Handle* matched_jvmci_method_ref, Thread* THREAD, JVMCIEnv* JVMCIENV) { - GrowableArray* resolved_methods = *resolved_methods_ref; - if (resolved_methods == nullptr) { - resolved_methods = init_resolved_methods(methods, JVMCIENV); - *resolved_methods_ref = resolved_methods; - } - assert(method != nullptr, "method should not be null"); - assert(resolved_methods->length() == ((objArrayOop) JNIHandles::resolve(methods))->length(), "arrays must have the same length"); - for (int i = 0; i < resolved_methods->length(); i++) { - Method* m = resolved_methods->at(i); - if (m == method) { - *matched_jvmci_method_ref = Handle(THREAD, ((objArrayOop) JNIHandles::resolve(methods))->obj_at(i)); - return true; - } - } - return false; -} - -/* - * Resolves an interface call to a concrete method handle. - */ -static methodHandle resolve_interface_call(Klass* spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) { - CallInfo callinfo; - Handle receiver = args->receiver(); - Klass* recvrKlass = receiver.is_null() ? (Klass*)nullptr : receiver->klass(); - LinkInfo link_info(spec_klass, name, signature); - LinkResolver::resolve_interface_call( - callinfo, receiver, recvrKlass, link_info, true, CHECK_(methodHandle())); - methodHandle method(THREAD, callinfo.selected_method()); - assert(method.not_null(), "should have thrown exception"); - return method; -} - -/* - * Used by c2v_iterateFrames to make a new vframeStream at the given compiled frame id (stack pointer) and vframe id. - */ -static void resync_vframestream_to_compiled_frame(vframeStream& vfst, intptr_t* stack_pointer, int vframe_id, JavaThread* thread, TRAPS) { - vfst = vframeStream(thread); - while (vfst.frame_id() != stack_pointer && !vfst.at_end()) { - vfst.next(); - } - if (vfst.frame_id() != stack_pointer) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found after deopt") - } - if (vfst.is_interpreted_frame()) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected") - } - while (vfst.vframe_id() != vframe_id) { - if (vfst.at_end()) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "vframe not found after deopt") - } - vfst.next(); - assert(!vfst.is_interpreted_frame(), "Wrong frame type"); - } -} - -/* - * Used by c2v_iterateFrames. Returns an array of any unallocated scope objects or null if none. - */ -static GrowableArray* get_unallocated_objects_or_null(GrowableArray* scope_objects) { - GrowableArray* unallocated = nullptr; - for (int i = 0; i < scope_objects->length(); i++) { - ObjectValue* sv = (ObjectValue*) scope_objects->at(i); - if (sv->value().is_null()) { - if (unallocated == nullptr) { - unallocated = new GrowableArray(scope_objects->length()); - } - unallocated->append(sv); - } - } - return unallocated; -} - -C2V_VMENTRY_NULL(jobject, iterateFrames, (JNIEnv* env, jobject compilerToVM, jobjectArray initial_methods, jobjectArray match_methods, jint initialSkip, jobject visitor_handle)) - - if (!thread->has_last_Java_frame()) { - return nullptr; - } - Handle visitor(THREAD, JNIHandles::resolve_non_null(visitor_handle)); - KeepStackGCProcessedMark keep_stack(THREAD); - - requireInHotSpot("iterateFrames", JVMCI_CHECK_NULL); - - HotSpotJVMCI::HotSpotStackFrameReference::klass()->initialize(CHECK_NULL); - - vframeStream vfst(thread); - jobjectArray methods = initial_methods; - methodHandle visitor_method; - GrowableArray* resolved_methods = nullptr; - - while (!vfst.at_end()) { // frame loop - bool realloc_called = false; - intptr_t* frame_id = vfst.frame_id(); - - // Previous compiledVFrame of this frame; use with at_scope() to reuse scope object pool. - compiledVFrame* prev_cvf = nullptr; - - for (; !vfst.at_end() && vfst.frame_id() == frame_id; vfst.next()) { // vframe loop - int frame_number = 0; - Method *method = vfst.method(); - int bci = vfst.bci(); - - Handle matched_jvmci_method; - if (methods == nullptr || matches(methods, method, &resolved_methods, &matched_jvmci_method, THREAD, JVMCIENV)) { - if (initialSkip > 0) { - initialSkip--; - continue; - } - javaVFrame* vf; - if (prev_cvf != nullptr && prev_cvf->frame_pointer()->id() == frame_id) { - assert(prev_cvf->is_compiled_frame(), "expected compiled Java frame"); - vf = prev_cvf->at_scope(vfst.decode_offset(), vfst.vframe_id()); - } else { - vf = vfst.asJavaVFrame(); - } - - StackValueCollection* locals = nullptr; - typeArrayHandle localIsVirtual_h; - if (vf->is_compiled_frame()) { - // compiled method frame - compiledVFrame* cvf = compiledVFrame::cast(vf); - - ScopeDesc* scope = cvf->scope(); - // native wrappers do not have a scope - if (scope != nullptr && scope->objects() != nullptr) { - prev_cvf = cvf; - - GrowableArray* objects = nullptr; - if (!realloc_called) { - objects = scope->objects(); - } else { - // some object might already have been re-allocated, only reallocate the non-allocated ones - objects = get_unallocated_objects_or_null(scope->objects()); - } - - if (objects != nullptr) { - RegisterMap reg_map(vf->register_map()); - bool realloc_failures = Deoptimization::realloc_objects(thread, vf->frame_pointer(), ®_map, objects, CHECK_NULL); - Deoptimization::reassign_fields(vf->frame_pointer(), ®_map, objects, realloc_failures, false); - realloc_called = true; - } - - GrowableArray* local_values = scope->locals(); - for (int i = 0; i < local_values->length(); i++) { - ScopeValue* value = local_values->at(i); - assert(!value->is_object_merge(), "Should not be."); - if (value->is_object()) { - if (localIsVirtual_h.is_null()) { - typeArrayOop array_oop = oopFactory::new_boolArray(local_values->length(), CHECK_NULL); - localIsVirtual_h = typeArrayHandle(THREAD, array_oop); - } - localIsVirtual_h->bool_at_put(i, true); - } - } - } - - locals = cvf->locals(); - frame_number = cvf->vframe_id(); - } else { - // interpreted method frame - interpretedVFrame* ivf = interpretedVFrame::cast(vf); - - locals = ivf->locals(); - } - assert(bci == vf->bci(), "wrong bci"); - assert(method == vf->method(), "wrong method"); - - Handle frame_reference = HotSpotJVMCI::HotSpotStackFrameReference::klass()->allocate_instance_handle(CHECK_NULL); - HotSpotJVMCI::HotSpotStackFrameReference::set_bci(JVMCIENV, frame_reference(), bci); - if (matched_jvmci_method.is_null()) { - methodHandle mh(THREAD, method); - JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL); - matched_jvmci_method = Handle(THREAD, JNIHandles::resolve(jvmci_method.as_jobject())); - } - HotSpotJVMCI::HotSpotStackFrameReference::set_method(JVMCIENV, frame_reference(), matched_jvmci_method()); - HotSpotJVMCI::HotSpotStackFrameReference::set_localIsVirtual(JVMCIENV, frame_reference(), localIsVirtual_h()); - - HotSpotJVMCI::HotSpotStackFrameReference::set_compilerToVM(JVMCIENV, frame_reference(), JNIHandles::resolve(compilerToVM)); - HotSpotJVMCI::HotSpotStackFrameReference::set_stackPointer(JVMCIENV, frame_reference(), (jlong) frame_id); - HotSpotJVMCI::HotSpotStackFrameReference::set_frameNumber(JVMCIENV, frame_reference(), frame_number); - - // initialize the locals array - objArrayOop array_oop = oopFactory::new_objectArray(locals->size(), CHECK_NULL); - objArrayHandle array(THREAD, array_oop); - for (int i = 0; i < locals->size(); i++) { - StackValue* var = locals->at(i); - if (var->type() == T_OBJECT) { - array->obj_at_put(i, locals->at(i)->get_obj()()); - } - } - HotSpotJVMCI::HotSpotStackFrameReference::set_locals(JVMCIENV, frame_reference(), array()); - HotSpotJVMCI::HotSpotStackFrameReference::set_objectsMaterialized(JVMCIENV, frame_reference(), JNI_FALSE); - - JavaValue result(T_OBJECT); - JavaCallArguments args(visitor); - if (visitor_method.is_null()) { - visitor_method = resolve_interface_call(HotSpotJVMCI::InspectedFrameVisitor::klass(), vmSymbols::visitFrame_name(), vmSymbols::visitFrame_signature(), &args, CHECK_NULL); - } - - args.push_oop(frame_reference); - JavaCalls::call(&result, visitor_method, &args, CHECK_NULL); - if (result.get_oop() != nullptr) { - return JNIHandles::make_local(thread, result.get_oop()); - } - if (methods == initial_methods) { - methods = match_methods; - if (resolved_methods != nullptr && JNIHandles::resolve(match_methods) != JNIHandles::resolve(initial_methods)) { - resolved_methods = nullptr; - } - } - assert(initialSkip == 0, "There should be no match before initialSkip == 0"); - if (HotSpotJVMCI::HotSpotStackFrameReference::objectsMaterialized(JVMCIENV, frame_reference()) == JNI_TRUE) { - // the frame has been deoptimized, we need to re-synchronize the frame and vframe - prev_cvf = nullptr; - intptr_t* stack_pointer = (intptr_t*) HotSpotJVMCI::HotSpotStackFrameReference::stackPointer(JVMCIENV, frame_reference()); - resync_vframestream_to_compiled_frame(vfst, stack_pointer, frame_number, thread, CHECK_NULL); - } - } - } // end of vframe loop - } // end of frame loop - - // the end was reached without finding a matching method - return nullptr; -C2V_END - -C2V_VMENTRY_0(int, decodeIndyIndexToCPIndex, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint indy_index, jboolean resolve)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - CallInfo callInfo; - if (resolve) { - LinkResolver::resolve_invoke(callInfo, Handle(), cp, indy_index, Bytecodes::_invokedynamic, CHECK_0); - cp->cache()->set_dynamic_call(callInfo, indy_index); - } - return cp->resolved_indy_entry_at(indy_index)->constant_pool_index(); -C2V_END - -C2V_VMENTRY_0(int, decodeFieldIndexToCPIndex, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint field_index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - if (field_index < 0 || field_index >= cp->resolved_field_entries_length()) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("invalid field index %d", field_index)); - } - return cp->resolved_field_entry_at(field_index)->constant_pool_index(); -C2V_END - -C2V_VMENTRY_0(int, decodeMethodIndexToCPIndex, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint method_index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - if (method_index < 0 || method_index >= cp->resolved_method_entries_length()) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("invalid method index %d", method_index)); - } - return cp->resolved_method_entry_at(method_index)->constant_pool_index(); -C2V_END - -C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - Klass* holder = cp->klass_ref_at(index, Bytecodes::_invokehandle, CHECK); - Symbol* name = cp->name_ref_at(index, Bytecodes::_invokehandle); - if (MethodHandles::is_signature_polymorphic_name(holder, name)) { - CallInfo callInfo; - LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK); - cp->cache()->set_method_handle(index, callInfo); - } -C2V_END - -C2V_VMENTRY_0(jint, isResolvedInvokeHandleInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, jint opcode)) - constantPoolHandle cp(THREAD, UNPACK_PAIR(ConstantPool, cp)); - ResolvedMethodEntry* entry = cp->cache()->resolved_method_entry_at(index); - if (entry->is_resolved(Bytecodes::_invokehandle)) { - // MethodHandle.invoke* --> LambdaForm? - ResourceMark rm; - - LinkInfo link_info(cp, index, Bytecodes::_invokehandle, CATCH); - - Klass* resolved_klass = link_info.resolved_klass(); - - Symbol* name_sym = cp->name_ref_at(index, Bytecodes::_invokehandle); - - vmassert(MethodHandles::is_method_handle_invoke_name(resolved_klass, name_sym), "!"); - vmassert(MethodHandles::is_signature_polymorphic_name(resolved_klass, name_sym), "!"); - - methodHandle adapter_method(THREAD, entry->method()); - - methodHandle resolved_method(adapter_method); - - // Can we treat it as a regular invokevirtual? - if (resolved_method->method_holder() == resolved_klass && resolved_method->name() == name_sym) { - vmassert(!resolved_method->is_static(),"!"); - vmassert(MethodHandles::is_signature_polymorphic_method(resolved_method()),"!"); - vmassert(!MethodHandles::is_signature_polymorphic_static(resolved_method->intrinsic_id()), "!"); - vmassert(cp->cache()->appendix_if_resolved(entry) == nullptr, "!"); - - methodHandle m(THREAD, LinkResolver::linktime_resolve_virtual_method_or_null(link_info)); - vmassert(m == resolved_method, "!!"); - return -1; - } - - return Bytecodes::_invokevirtual; - } - if ((Bytecodes::Code)opcode == Bytecodes::_invokedynamic) { - if (cp->resolved_indy_entry_at(index)->is_resolved()) { - return Bytecodes::_invokedynamic; - } - } - return -1; -C2V_END - - -C2V_VMENTRY_NULL(jobject, getSignaturePolymorphicHolders, (JNIEnv* env, jobject)) - JVMCIObjectArray holders = JVMCIENV->new_String_array(2, JVMCI_CHECK_NULL); - JVMCIObject mh = JVMCIENV->create_string("Ljava/lang/invoke/MethodHandle;", JVMCI_CHECK_NULL); - JVMCIObject vh = JVMCIENV->create_string("Ljava/lang/invoke/VarHandle;", JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(holders, 0, mh); - JVMCIENV->put_object_at(holders, 1, vh); - return JVMCIENV->get_jobject(holders); -C2V_END - -C2V_VMENTRY_0(jboolean, shouldDebugNonSafepoints, (JNIEnv* env, jobject)) - //see compute_recording_non_safepoints in debugInfroRec.cpp - if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { - return true; - } - return DebugNonSafepoints; -C2V_END - -// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); -C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_frame, bool invalidate)) - JVMCIObject hs_frame = JVMCIENV->wrap(_hs_frame); - if (hs_frame.is_null()) { - JVMCI_THROW_MSG(NullPointerException, "stack frame is null"); - } - - requireInHotSpot("materializeVirtualObjects", JVMCI_CHECK); - - JVMCIENV->HotSpotStackFrameReference_initialize(JVMCI_CHECK); - - // look for the given stack frame - StackFrameStream fst(thread, false /* update */, true /* process_frames */); - intptr_t* stack_pointer = (intptr_t*) JVMCIENV->get_HotSpotStackFrameReference_stackPointer(hs_frame); - while (fst.current()->id() != stack_pointer && !fst.is_done()) { - fst.next(); - } - if (fst.current()->id() != stack_pointer) { - JVMCI_THROW_MSG(IllegalStateException, "stack frame not found"); - } - - if (invalidate) { - if (!fst.current()->is_compiled_frame()) { - JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected"); - } - fst.current()->cb()->as_nmethod()->make_not_entrant(nmethod::InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT); - } - Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none); - // look for the frame again as it has been updated by deopt (pc, deopt state...) - StackFrameStream fstAfterDeopt(thread, true /* update */, true /* process_frames */); - while (fstAfterDeopt.current()->id() != stack_pointer && !fstAfterDeopt.is_done()) { - fstAfterDeopt.next(); - } - if (fstAfterDeopt.current()->id() != stack_pointer) { - JVMCI_THROW_MSG(IllegalStateException, "stack frame not found after deopt"); - } - - vframe* vf = vframe::new_vframe(fstAfterDeopt.current(), fstAfterDeopt.register_map(), thread); - if (!vf->is_compiled_frame()) { - JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected"); - } - - GrowableArray* virtualFrames = new GrowableArray(10); - while (true) { - assert(vf->is_compiled_frame(), "Wrong frame type"); - virtualFrames->push(compiledVFrame::cast(vf)); - if (vf->is_top()) { - break; - } - vf = vf->sender(); - } - - int last_frame_number = JVMCIENV->get_HotSpotStackFrameReference_frameNumber(hs_frame); - if (last_frame_number >= virtualFrames->length()) { - JVMCI_THROW_MSG(IllegalStateException, "invalid frame number"); - } - - // Reallocate the non-escaping objects and restore their fields. - assert (virtualFrames->at(last_frame_number)->scope() != nullptr,"invalid scope"); - GrowableArray* objects = virtualFrames->at(last_frame_number)->scope()->objects(); - - if (objects == nullptr) { - // no objects to materialize - return; - } - - bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, CHECK); - Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false); - - for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) { - compiledVFrame* cvf = virtualFrames->at(frame_index); - - GrowableArray* scopedValues = cvf->scope()->locals(); - StackValueCollection* locals = cvf->locals(); - if (locals != nullptr) { - for (int i2 = 0; i2 < locals->size(); i2++) { - StackValue* var = locals->at(i2); - assert(!scopedValues->at(i2)->is_object_merge(), "Should not be."); - if (var->type() == T_OBJECT && scopedValues->at(i2)->is_object()) { - jvalue val; - val.l = cast_from_oop(locals->at(i2)->get_obj()()); - cvf->update_local(T_OBJECT, i2, val); - } - } - } - - GrowableArray* scopeExpressions = cvf->scope()->expressions(); - StackValueCollection* expressions = cvf->expressions(); - if (expressions != nullptr) { - for (int i2 = 0; i2 < expressions->size(); i2++) { - StackValue* var = expressions->at(i2); - assert(!scopeExpressions->at(i2)->is_object_merge(), "Should not be."); - if (var->type() == T_OBJECT && scopeExpressions->at(i2)->is_object()) { - jvalue val; - val.l = cast_from_oop(expressions->at(i2)->get_obj()()); - cvf->update_stack(T_OBJECT, i2, val); - } - } - } - - GrowableArray* scopeMonitors = cvf->scope()->monitors(); - GrowableArray* monitors = cvf->monitors(); - if (monitors != nullptr) { - for (int i2 = 0; i2 < monitors->length(); i2++) { - cvf->update_monitor(i2, monitors->at(i2)); - } - } - } - - // all locals are materialized by now - JVMCIENV->set_HotSpotStackFrameReference_localIsVirtual(hs_frame, nullptr); - // update the locals array - JVMCIObjectArray array = JVMCIENV->get_HotSpotStackFrameReference_locals(hs_frame); - StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals(); - for (int i = 0; i < locals->size(); i++) { - StackValue* var = locals->at(i); - if (var->type() == T_OBJECT) { - JVMCIENV->put_object_at(array, i, HotSpotJVMCI::wrap(locals->at(i)->get_obj()())); - } - } - HotSpotJVMCI::HotSpotStackFrameReference::set_objectsMaterialized(JVMCIENV, hs_frame, JNI_TRUE); -C2V_END - -// Use of tty does not require the current thread to be attached to the VM -// so no need for a full C2V_VMENTRY transition. -C2V_VMENTRY_PREFIX(void, writeDebugOutput, (JNIEnv* env, jobject, jlong buffer, jint length, bool flush)) - if (length <= 8) { - tty->write((char*) &buffer, length); - } else { - tty->write((char*) buffer, length); - } - if (flush) { - tty->flush(); - } -C2V_END - -// Use of tty does not require the current thread to be attached to the VM -// so no need for a full C2V_VMENTRY transition. -C2V_VMENTRY_PREFIX(void, flushDebugOutput, (JNIEnv* env, jobject)) - tty->flush(); -C2V_END - -C2V_VMENTRY_0(jint, methodDataProfileDataSize, (JNIEnv* env, jobject, jlong method_data_pointer, jint position)) - MethodData* mdo = (MethodData*) method_data_pointer; - ProfileData* profile_data = mdo->data_at(position); - if (mdo->is_valid(profile_data)) { - return profile_data->size_in_bytes(); - } - // Java code should never directly access the extra data section - JVMCI_THROW_MSG_0(IllegalArgumentException, err_msg("Invalid profile data position %d", position)); -C2V_END - -C2V_VMENTRY_0(jint, methodDataExceptionSeen, (JNIEnv* env, jobject, jlong method_data_pointer, jint bci)) - MethodData* mdo = (MethodData*) method_data_pointer; - - // Lock to read ProfileData, and ensure lock is not broken by a safepoint - MutexLocker mu(mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); - - DataLayout* data = mdo->extra_data_base(); - DataLayout* end = mdo->args_data_limit(); - for (;; data = mdo->next_extra(data)) { - assert(data < end, "moved past end of extra data"); - int tag = data->tag(); - switch(tag) { - case DataLayout::bit_data_tag: { - BitData* bit_data = (BitData*) data->data_in(); - if (bit_data->bci() == bci) { - return bit_data->exception_seen() ? 1 : 0; - } - break; - } - case DataLayout::no_tag: - // There is a free slot so return false since a BitData would have been allocated to record - // true if it had been seen. - return 0; - case DataLayout::arg_info_data_tag: - // The bci wasn't found and there are no free slots to record a trap for this location, so always - // return unknown. - return -1; - } - } - ShouldNotReachHere(); - return -1; -C2V_END - -C2V_VMENTRY_NULL(jobject, getInterfaces, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - - if (!klass->is_instance_klass()) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Class %s must be instance klass", klass->external_name())); - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - - // Regular instance klass, fill in all local interfaces - int size = iklass->local_interfaces()->length(); - JVMCIObjectArray interfaces = JVMCIENV->new_HotSpotResolvedObjectTypeImpl_array(size, JVMCI_CHECK_NULL); - for (int index = 0; index < size; index++) { - JVMCIKlassHandle klass(THREAD); - InstanceKlass* k = iklass->local_interfaces()->at(index); - klass = k; - JVMCIObject type = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(interfaces, index, type); - } - return JVMCIENV->get_jobject(interfaces); -C2V_END - -C2V_VMENTRY_NULL(jobject, getComponentType, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - - if (!klass->is_array_klass()) { - return nullptr; - } - oop mirror = klass->java_mirror(); - oop component_mirror = java_lang_Class::component_mirror(mirror); - if (component_mirror == nullptr) { - JVMCI_THROW_MSG_NULL(NullPointerException, - err_msg("Component mirror for array class %s is null", klass->external_name())) - } - - Klass* component_klass = java_lang_Class::as_Klass(component_mirror); - if (component_klass != nullptr) { - JVMCIKlassHandle klass_handle(THREAD, component_klass); - JVMCIObject result = JVMCIENV->get_jvmci_type(klass_handle, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); - } - BasicType type = java_lang_Class::primitive_type(component_mirror); - JVMCIObject result = JVMCIENV->get_jvmci_primitive_type(type); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY(void, ensureInitialized, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW(NullPointerException); - } - if (klass->should_be_initialized()) { - InstanceKlass* k = InstanceKlass::cast(klass); - k->initialize(CHECK); - } -C2V_END - -C2V_VMENTRY(void, ensureLinked, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - CompilerThreadCanCallJava canCallJava(thread, true); // Linking requires Java calls - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW(NullPointerException); - } - if (klass->is_instance_klass()) { - InstanceKlass* k = InstanceKlass::cast(klass); - k->link_class(CHECK); - } -C2V_END - -C2V_VMENTRY_0(jint, interpreterFrameSize, (JNIEnv* env, jobject, jobject bytecode_frame_handle)) - if (bytecode_frame_handle == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - - JVMCIObject top_bytecode_frame = JVMCIENV->wrap(bytecode_frame_handle); - JVMCIObject bytecode_frame = top_bytecode_frame; - int size = 0; - int callee_parameters = 0; - int callee_locals = 0; - Method* method = JVMCIENV->asMethod(JVMCIENV->get_BytecodePosition_method(bytecode_frame)); - int extra_args = method->max_stack() - JVMCIENV->get_BytecodeFrame_numStack(bytecode_frame); - - while (bytecode_frame.is_non_null()) { - int locks = JVMCIENV->get_BytecodeFrame_numLocks(bytecode_frame); - int temps = JVMCIENV->get_BytecodeFrame_numStack(bytecode_frame); - bool is_top_frame = (JVMCIENV->equals(bytecode_frame, top_bytecode_frame)); - Method* method = JVMCIENV->asMethod(JVMCIENV->get_BytecodePosition_method(bytecode_frame)); - - int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(), - temps + callee_parameters, - extra_args, - locks, - callee_parameters, - callee_locals, - is_top_frame); - size += frame_size; - - callee_parameters = method->size_of_parameters(); - callee_locals = method->max_locals(); - extra_args = 0; - bytecode_frame = JVMCIENV->get_BytecodePosition_caller(bytecode_frame); - } - return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord; -C2V_END - -C2V_VMENTRY(void, compileToBytecode, (JNIEnv* env, jobject, jobject lambda_form_handle)) - Handle lambda_form = JVMCIENV->asConstant(JVMCIENV->wrap(lambda_form_handle), JVMCI_CHECK); - if (lambda_form->is_a(vmClasses::LambdaForm_klass())) { - TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode"); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, lambda_form, vmClasses::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK); - } else { - JVMCI_THROW_MSG(IllegalArgumentException, - err_msg("Unexpected type: %s", lambda_form->klass()->external_name())) - } -C2V_END - -C2V_VMENTRY_0(jint, getIdentityHashCode, (JNIEnv* env, jobject, jobject object)) - Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0); - return obj->identity_hash(); -C2V_END - -C2V_VMENTRY_0(jboolean, isInternedString, (JNIEnv* env, jobject, jobject object)) - Handle str = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0); - if (!java_lang_String::is_instance(str())) { - return false; - } - int len; - jchar* name = java_lang_String::as_unicode_string(str(), len, CHECK_false); - return (StringTable::lookup(name, len) != nullptr); -C2V_END - - -C2V_VMENTRY_NULL(jobject, unboxPrimitive, (JNIEnv* env, jobject, jobject object)) - if (object == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Handle box = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL); - BasicType type = java_lang_boxing_object::basic_type(box()); - jvalue result; - if (java_lang_boxing_object::get_value(box(), &result) == T_ILLEGAL) { - return nullptr; - } - JVMCIObject boxResult = JVMCIENV->create_box(type, &result, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(boxResult); -C2V_END - -C2V_VMENTRY_NULL(jobject, boxPrimitive, (JNIEnv* env, jobject, jobject object)) - if (object == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - JVMCIObject box = JVMCIENV->wrap(object); - BasicType type = JVMCIENV->get_box_type(box); - if (type == T_ILLEGAL) { - return nullptr; - } - jvalue value = JVMCIENV->get_boxed_value(type, box); - JavaValue box_result(T_OBJECT); - JavaCallArguments jargs; - Klass* box_klass = nullptr; - Symbol* box_signature = nullptr; -#define BOX_CASE(bt, v, argtype, name) \ - case bt: \ - jargs.push_##argtype(value.v); \ - box_klass = vmClasses::name##_klass(); \ - box_signature = vmSymbols::name##_valueOf_signature(); \ - break - - switch (type) { - BOX_CASE(T_BOOLEAN, z, int, Boolean); - BOX_CASE(T_BYTE, b, int, Byte); - BOX_CASE(T_CHAR, c, int, Character); - BOX_CASE(T_SHORT, s, int, Short); - BOX_CASE(T_INT, i, int, Integer); - BOX_CASE(T_LONG, j, long, Long); - BOX_CASE(T_FLOAT, f, float, Float); - BOX_CASE(T_DOUBLE, d, double, Double); - default: - ShouldNotReachHere(); - } -#undef BOX_CASE - - JavaCalls::call_static(&box_result, - box_klass, - vmSymbols::valueOf_name(), - box_signature, &jargs, CHECK_NULL); - oop hotspot_box = box_result.get_oop(); - JVMCIObject result = JVMCIENV->get_object_constant(hotspot_box, false); - return JVMCIENV->get_jobject(result); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, getDeclaredConstructors, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - if (!klass->is_instance_klass()) { - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(0, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobjectArray(methods); - } - - InstanceKlass* iklass = InstanceKlass::cast(klass); - GrowableArray constructors_array; - for (int i = 0; i < iklass->methods()->length(); i++) { - Method* m = iklass->methods()->at(i); - if (m->is_object_initializer()) { - constructors_array.append(m); - } - } - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(constructors_array.length(), JVMCI_CHECK_NULL); - for (int i = 0; i < constructors_array.length(); i++) { - methodHandle ctor(THREAD, constructors_array.at(i)); - JVMCIObject method = JVMCIENV->get_jvmci_method(ctor, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(methods, i, method); - } - return JVMCIENV->get_jobjectArray(methods); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - if (!klass->is_instance_klass()) { - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(0, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobjectArray(methods); - } - - InstanceKlass* iklass = InstanceKlass::cast(klass); - GrowableArray methods_array; - for (int i = 0; i < iklass->methods()->length(); i++) { - Method* m = iklass->methods()->at(i); - if (!m->is_object_initializer() && !m->is_static_initializer() && !m->is_overpass()) { - methods_array.append(m); - } - } - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(methods_array.length(), JVMCI_CHECK_NULL); - for (int i = 0; i < methods_array.length(); i++) { - methodHandle mh(THREAD, methods_array.at(i)); - JVMCIObject method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(methods, i, method); - } - return JVMCIENV->get_jobjectArray(methods); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, getAllMethods, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - if (!klass->is_instance_klass()) { - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(0, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobjectArray(methods); - } - - InstanceKlass* iklass = InstanceKlass::cast(klass); - JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(iklass->methods()->length(), JVMCI_CHECK_NULL); - for (int i = 0; i < iklass->methods()->length(); i++) { - methodHandle mh(THREAD, iklass->methods()->at(i)); - JVMCIObject method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(methods, i, method); - } - return JVMCIENV->get_jobjectArray(methods); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, getDeclaredFieldsInfo, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - if (!klass->is_instance_klass()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "not an InstanceKlass"); - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - int java_fields, injected_fields; - GrowableArray* fields = FieldInfoStream::create_FieldInfoArray(iklass->fieldinfo_stream(), &java_fields, &injected_fields); - JVMCIObjectArray array = JVMCIENV->new_FieldInfo_array(fields->length(), JVMCI_CHECK_NULL); - for (int i = 0; i < fields->length(); i++) { - JVMCIObject field_info = JVMCIENV->new_FieldInfo(fields->adr_at(i), JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(array, i, field_info); - } - return array.as_jobject(); -C2V_END - -static jobject read_field_value(Handle obj, long displacement, jchar type_char, bool is_static, Thread* THREAD, JVMCIEnv* JVMCIENV) { - - BasicType basic_type = JVMCIENV->typeCharToBasicType(type_char, JVMCI_CHECK_NULL); - int basic_type_elemsize = type2aelembytes(basic_type); - if (displacement < 0 || ((size_t) displacement + basic_type_elemsize > HeapWordSize * obj->size())) { - // Reading outside of the object bounds - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading outside object bounds"); - } - - // Perform basic sanity checks on the read. Primitive reads are permitted to read outside the - // bounds of their fields but object reads must map exactly onto the underlying oop slot. - bool aligned = (displacement % basic_type_elemsize) == 0; - if (!aligned) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "read is unaligned"); - } - if (obj->is_array()) { - // Disallow reading after the last element of an array - size_t array_length = arrayOop(obj())->length(); - int lh = obj->klass()->layout_helper(); - size_t size_in_bytes = array_length << Klass::layout_helper_log2_element_size(lh); - size_in_bytes += Klass::layout_helper_header_size(lh); - if ((size_t) displacement + basic_type_elemsize > size_in_bytes) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading after last array element"); - } - } - if (basic_type == T_OBJECT) { - if (obj->is_objArray()) { - if (displacement < arrayOopDesc::base_offset_in_bytes(T_OBJECT)) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading from array header"); - } - if (((displacement - arrayOopDesc::base_offset_in_bytes(T_OBJECT)) % heapOopSize) != 0) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "misaligned object read from array"); - } - } else if (obj->is_instance()) { - InstanceKlass* klass = InstanceKlass::cast(is_static ? java_lang_Class::as_Klass(obj()) : obj->klass()); - fieldDescriptor fd; - if (!klass->find_field_from_offset(displacement, is_static, &fd)) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Can't find field at displacement %d in object of type %s", (int) displacement, klass->external_name())); - } - if (fd.field_type() != T_OBJECT && fd.field_type() != T_ARRAY) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Field at displacement %d in object of type %s is %s but expected %s", (int) displacement, - klass->external_name(), type2name(fd.field_type()), type2name(basic_type))); - } - } else if (obj->is_typeArray()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "Can't read objects from primitive array"); - } else { - ShouldNotReachHere(); - } - } else { - if (obj->is_objArray()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "Reading primitive from object array"); - } else if (obj->is_typeArray()) { - if (displacement < arrayOopDesc::base_offset_in_bytes(ArrayKlass::cast(obj->klass())->element_type())) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "reading from array header"); - } - } - } - - jlong value = 0; - - // Treat all reads as volatile for simplicity as this function can be used - // both for reading Java fields declared as volatile as well as for constant - // folding Unsafe.get* methods with volatile semantics. - - switch (basic_type) { - case T_BOOLEAN: value = HeapAccess::load(obj->field_addr(displacement)); break; - case T_BYTE: value = HeapAccess::load(obj->field_addr(displacement)); break; - case T_SHORT: value = HeapAccess::load(obj->field_addr(displacement)); break; - case T_CHAR: value = HeapAccess::load(obj->field_addr(displacement)); break; - case T_FLOAT: - case T_INT: value = HeapAccess::load(obj->field_addr(displacement)); break; - case T_DOUBLE: - case T_LONG: value = HeapAccess::load(obj->field_addr(displacement)); break; - - case T_OBJECT: { - if (displacement == java_lang_Class::component_mirror_offset() && java_lang_Class::is_instance(obj()) && - (java_lang_Class::as_Klass(obj()) == nullptr || !java_lang_Class::as_Klass(obj())->is_array_klass())) { - // Class.componentType for non-array classes can transiently contain an int[] that's - // used for locking so always return null to mimic Class.getComponentType() - return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_NULL_POINTER()); - } - - // Perform the read including any barriers required to make the reference strongly reachable - // since it will be wrapped as a JavaConstant. - oop value = obj->obj_field_access(displacement); - - if (value == nullptr) { - return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_NULL_POINTER()); - } else { - if (value != nullptr && !oopDesc::is_oop(value)) { - // Throw an exception to improve debuggability. This check isn't totally reliable because - // is_oop doesn't try to be completety safe but for most invalid values it provides a good - // enough answer. It possible to crash in the is_oop call but that just means the crash happens - // closer to where things went wrong. - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Read bad oop " INTPTR_FORMAT " at offset " JLONG_FORMAT " in object " INTPTR_FORMAT " of type %s", - p2i(value), displacement, p2i(obj()), obj->klass()->external_name())); - } - - JVMCIObject result = JVMCIENV->get_object_constant(value); - return JVMCIENV->get_jobject(result); - } - } - - default: - ShouldNotReachHere(); - } - JVMCIObject result = JVMCIENV->call_JavaConstant_forPrimitive(type_char, value, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -} - -C2V_VMENTRY_NULL(jobject, readStaticFieldValue, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), long displacement, jchar type_char)) - Klass* klass = UNPACK_PAIR(Klass, klass); - Handle obj(THREAD, klass->java_mirror()); - return read_field_value(obj, displacement, type_char, true, THREAD, JVMCIENV); -C2V_END - -C2V_VMENTRY_NULL(jobject, readFieldValue, (JNIEnv* env, jobject, jobject object, ARGUMENT_PAIR(expected_type), long displacement, jchar type_char)) - if (object == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - - // asConstant will throw an NPE if a constant contains null - Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL); - - Klass* expected_klass = UNPACK_PAIR(Klass, expected_type); - if (expected_klass != nullptr) { - InstanceKlass* expected_iklass = InstanceKlass::cast(expected_klass); - if (!obj->is_a(expected_iklass)) { - // Not of the expected type - return nullptr; - } - } - bool is_static = expected_klass == nullptr && java_lang_Class::is_instance(obj()) && displacement >= InstanceMirrorKlass::offset_of_static_fields(); - return read_field_value(obj, displacement, type_char, is_static, THREAD, JVMCIENV); -C2V_END - -C2V_VMENTRY_0(jboolean, isInstance, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), jobject object)) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (object == nullptr || klass == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0); - return obj->is_a(klass); -C2V_END - -C2V_VMENTRY_0(jboolean, isAssignableFrom, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), ARGUMENT_PAIR(subklass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - Klass* subklass = UNPACK_PAIR(Klass, subklass); - if (klass == nullptr || subklass == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - return subklass->is_subtype_of(klass); -C2V_END - -C2V_VMENTRY_0(jboolean, isTrustedForIntrinsics, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - InstanceKlass* ik = InstanceKlass::cast(klass); - if (ik->class_loader_data()->is_boot_class_loader_data() || ik->class_loader_data()->is_platform_class_loader_data()) { - return true; - } - return false; -C2V_END - -C2V_VMENTRY_NULL(jobject, asJavaType, (JNIEnv* env, jobject, jobject object)) - if (object == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL); - if (java_lang_Class::is_instance(obj())) { - if (java_lang_Class::is_primitive(obj())) { - JVMCIObject type = JVMCIENV->get_jvmci_primitive_type(java_lang_Class::primitive_type(obj())); - return JVMCIENV->get_jobject(type); - } - Klass* klass = java_lang_Class::as_Klass(obj()); - JVMCIKlassHandle klass_handle(THREAD); - klass_handle = klass; - JVMCIObject type = JVMCIENV->get_jvmci_type(klass_handle, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(type); - } - return nullptr; -C2V_END - - -C2V_VMENTRY_NULL(jobject, asString, (JNIEnv* env, jobject, jobject object)) - if (object == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL); - const char* str = java_lang_String::as_utf8_string(obj()); - JVMCIObject result = JVMCIENV->create_string(str, JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(result); -C2V_END - - -C2V_VMENTRY_0(jboolean, equals, (JNIEnv* env, jobject, jobject x, jlong xHandle, jobject y, jlong yHandle)) - if (x == nullptr || y == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - return JVMCIENV->resolve_oop_handle(xHandle) == JVMCIENV->resolve_oop_handle(yHandle); -C2V_END - -C2V_VMENTRY_NULL(jobject, getJavaMirror, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass))) - Klass* klass = UNPACK_PAIR(Klass, klass); - if (klass == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Handle mirror(THREAD, klass->java_mirror()); - JVMCIObject result = JVMCIENV->get_object_constant(mirror()); - return JVMCIENV->get_jobject(result); -C2V_END - - -C2V_VMENTRY_0(jint, getArrayLength, (JNIEnv* env, jobject, jobject x)) - if (x == nullptr) { - JVMCI_THROW_0(NullPointerException); - } - Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0); - if (xobj->klass()->is_array_klass()) { - return arrayOop(xobj())->length(); - } - return -1; - C2V_END - - -C2V_VMENTRY_NULL(jobject, readArrayElement, (JNIEnv* env, jobject, jobject x, int index)) - if (x == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_NULL); - if (xobj->klass()->is_array_klass()) { - arrayOop array = arrayOop(xobj()); - BasicType element_type = ArrayKlass::cast(array->klass())->element_type(); - if (index < 0 || index >= array->length()) { - return nullptr; - } - JVMCIObject result; - - if (element_type == T_OBJECT) { - result = JVMCIENV->get_object_constant(objArrayOop(xobj())->obj_at(index)); - if (result.is_null()) { - result = JVMCIENV->get_JavaConstant_NULL_POINTER(); - } - } else { - jvalue value; - switch (element_type) { - case T_DOUBLE: value.d = typeArrayOop(xobj())->double_at(index); break; - case T_FLOAT: value.f = typeArrayOop(xobj())->float_at(index); break; - case T_LONG: value.j = typeArrayOop(xobj())->long_at(index); break; - case T_INT: value.i = typeArrayOop(xobj())->int_at(index); break; - case T_SHORT: value.s = typeArrayOop(xobj())->short_at(index); break; - case T_CHAR: value.c = typeArrayOop(xobj())->char_at(index); break; - case T_BYTE: value.b = typeArrayOop(xobj())->byte_at(index); break; - case T_BOOLEAN: value.z = typeArrayOop(xobj())->byte_at(index) & 1; break; - default: ShouldNotReachHere(); - } - result = JVMCIENV->create_box(element_type, &value, JVMCI_CHECK_NULL); - } - assert(!result.is_null(), "must have a value"); - return JVMCIENV->get_jobject(result); - } - return nullptr;; -C2V_END - - -C2V_VMENTRY_0(jint, arrayBaseOffset, (JNIEnv* env, jobject, jchar type_char)) - BasicType type = JVMCIENV->typeCharToBasicType(type_char, JVMCI_CHECK_0); - return arrayOopDesc::base_offset_in_bytes(type); -C2V_END - -C2V_VMENTRY_0(jint, arrayIndexScale, (JNIEnv* env, jobject, jchar type_char)) - BasicType type = JVMCIENV->typeCharToBasicType(type_char, JVMCI_CHECK_0); - return type2aelembytes(type); -C2V_END - -C2V_VMENTRY(void, clearOopHandle, (JNIEnv* env, jobject, jlong oop_handle)) - if (oop_handle == 0L) { - JVMCI_THROW(NullPointerException); - } - // Assert before nulling out, for better debugging. - assert(JVMCIRuntime::is_oop_handle(oop_handle), "precondition"); - oop* oop_ptr = (oop*) oop_handle; - NativeAccess<>::oop_store(oop_ptr, (oop) nullptr); -C2V_END - -C2V_VMENTRY(void, releaseClearedOopHandles, (JNIEnv* env, jobject)) - JVMCIENV->runtime()->release_cleared_oop_handles(); -C2V_END - -static void requireJVMCINativeLibrary(JVMCI_TRAPS) { - if (!UseJVMCINativeLibrary) { - JVMCI_THROW_MSG(UnsupportedOperationException, "JVMCI shared library is not enabled (requires -XX:+UseJVMCINativeLibrary)"); - } -} - -C2V_VMENTRY_NULL(jlongArray, registerNativeMethods, (JNIEnv* env, jobject, jclass mirror)) - requireJVMCINativeLibrary(JVMCI_CHECK_NULL); - requireInHotSpot("registerNativeMethods", JVMCI_CHECK_NULL); - char* sl_path; - void* sl_handle; - JVMCIRuntime* runtime; - { - // Ensure the JVMCI shared library runtime is initialized. - PEER_JVMCIENV_FROM_THREAD(THREAD, false); - PEER_JVMCIENV->check_init(JVMCI_CHECK_NULL); - - HandleMark hm(THREAD); - runtime = JVMCI::compiler_runtime(thread); - if (PEER_JVMCIENV->has_pending_exception()) { - PEER_JVMCIENV->describe_pending_exception(tty); - } - sl_handle = JVMCI::get_shared_library(sl_path, false); - if (sl_handle == nullptr) { - JVMCI_THROW_MSG_NULL(InternalError, err_msg("Error initializing JVMCI runtime %d", runtime->id())); - } - } - - if (mirror == nullptr) { - JVMCI_THROW_NULL(NullPointerException); - } - Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve(mirror)); - if (klass == nullptr || !klass->is_instance_klass()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, "clazz is for primitive type"); - } - - InstanceKlass* iklass = InstanceKlass::cast(klass); - for (int i = 0; i < iklass->methods()->length(); i++) { - methodHandle method(THREAD, iklass->methods()->at(i)); - if (method->is_native()) { - - // Compute argument size - int args_size = 1 // JNIEnv - + (method->is_static() ? 1 : 0) // class for static methods - + method->size_of_parameters(); // actual parameters - - // 1) Try JNI short style - stringStream st; - char* pure_name = NativeLookup::pure_jni_name(method); - guarantee(pure_name != nullptr, "Illegal native method name encountered"); - st.print_raw(pure_name); - char* jni_name = st.as_string(); - - address entry = (address) os::dll_lookup(sl_handle, jni_name); - if (entry == nullptr) { - // 2) Try JNI long style - st.reset(); - char* long_name = NativeLookup::long_jni_name(method); - guarantee(long_name != nullptr, "Illegal native method name encountered"); - st.print_raw(pure_name); - st.print_raw(long_name); - char* jni_long_name = st.as_string(); - entry = (address) os::dll_lookup(sl_handle, jni_long_name); - if (entry == nullptr) { - JVMCI_THROW_MSG_NULL(UnsatisfiedLinkError, err_msg("%s [neither %s nor %s exist in %s]", - method->name_and_sig_as_C_string(), - jni_name, jni_long_name, sl_path)); - } - } - - if (method->has_native_function() && entry != method->native_function()) { - JVMCI_THROW_MSG_NULL(UnsatisfiedLinkError, err_msg("%s [cannot re-link from " PTR_FORMAT " to " PTR_FORMAT "]", - method->name_and_sig_as_C_string(), p2i(method->native_function()), p2i(entry))); - } - method->set_native_function(entry, Method::native_bind_event_is_interesting); - log_debug(jni, resolve)("[Dynamic-linking native method %s.%s ... JNI] @ " PTR_FORMAT, - method->method_holder()->external_name(), - method->name()->as_C_string(), - p2i((void*) entry)); - } - } - - typeArrayOop info_oop = oopFactory::new_longArray(4, CHECK_NULL); - jlongArray info = (jlongArray) JNIHandles::make_local(THREAD, info_oop); - runtime->init_JavaVM_info(info, JVMCI_CHECK_NULL); - return info; -C2V_END - -C2V_VMENTRY_PREFIX(jboolean, isCurrentThreadAttached, (JNIEnv* env, jobject c2vm)) - if (thread == nullptr || thread->libjvmci_runtime() == nullptr) { - // Called from unattached JVMCI shared library thread - return false; - } - if (thread->jni_environment() == env) { - C2V_BLOCK(jboolean, isCurrentThreadAttached, (JNIEnv* env, jobject)) - JVMCITraceMark jtm("isCurrentThreadAttached"); - requireJVMCINativeLibrary(JVMCI_CHECK_0); - JVMCIRuntime* runtime = thread->libjvmci_runtime(); - if (runtime == nullptr || !runtime->has_shared_library_javavm()) { - JVMCI_THROW_MSG_0(IllegalStateException, "Require JVMCI shared library JavaVM to be initialized in isCurrentThreadAttached"); - } - JNIEnv* peerEnv; - return runtime->GetEnv(thread, (void**) &peerEnv, JNI_VERSION_1_2) == JNI_OK; - } - return true; -C2V_END - -C2V_VMENTRY_PREFIX(jlong, getCurrentJavaThread, (JNIEnv* env, jobject c2vm)) - if (thread == nullptr) { - // Called from unattached JVMCI shared library thread - return 0L; - } - return (jlong) p2i(thread); -C2V_END - -// Attaches a thread started in a JVMCI shared library to a JavaThread and JVMCI runtime. -static void attachSharedLibraryThread(JNIEnv* env, jbyteArray name, jboolean as_daemon) { - JavaVM* javaVM = nullptr; - jint res = env->GetJavaVM(&javaVM); - if (res != JNI_OK) { - JNI_THROW("attachSharedLibraryThread", InternalError, err_msg("Error getting shared library JavaVM from shared library JNIEnv: %d", res)); - } - extern struct JavaVM_ main_vm; - JNIEnv* hotspotEnv; - - int name_len = env->GetArrayLength(name); - char name_buf[64]; // Cannot use Resource heap as it requires a current thread - int to_copy = MIN2(name_len, (int) sizeof(name_buf) - 1); - env->GetByteArrayRegion(name, 0, to_copy, (jbyte*) name_buf); - name_buf[to_copy] = '\0'; - JavaVMAttachArgs attach_args; - attach_args.version = JNI_VERSION_1_2; - attach_args.name = name_buf; - attach_args.group = nullptr; - res = as_daemon ? main_vm.AttachCurrentThreadAsDaemon((void**)&hotspotEnv, &attach_args) : - main_vm.AttachCurrentThread((void**)&hotspotEnv, &attach_args); - if (res != JNI_OK) { - JNI_THROW("attachSharedLibraryThread", InternalError, err_msg("Trying to attach thread returned %d", res)); - } - JavaThread* thread = JavaThread::thread_from_jni_environment(hotspotEnv); - const char* attach_error; - { - // Transition to VM - JVMCI_VM_ENTRY_MARK - attach_error = JVMCIRuntime::attach_shared_library_thread(thread, javaVM); - // Transition back to Native - } - if (attach_error != nullptr) { - JNI_THROW("attachCurrentThread", InternalError, attach_error); - } -} - -C2V_VMENTRY_PREFIX(jboolean, attachCurrentThread, (JNIEnv* env, jobject c2vm, jbyteArray name, jboolean as_daemon, jlongArray javaVM_info)) - if (thread == nullptr) { - attachSharedLibraryThread(env, name, as_daemon); - return true; - } - if (thread->jni_environment() == env) { - // Called from HotSpot - C2V_BLOCK(jboolean, attachCurrentThread, (JNIEnv* env, jobject, jboolean)) - JVMCITraceMark jtm("attachCurrentThread"); - requireJVMCINativeLibrary(JVMCI_CHECK_0); - - JVMCIRuntime* runtime = JVMCI::compiler_runtime(thread); - JNIEnv* peerJNIEnv; - if (runtime->has_shared_library_javavm()) { - if (runtime->GetEnv(thread, (void**)&peerJNIEnv, JNI_VERSION_1_2) == JNI_OK) { - // Already attached - runtime->init_JavaVM_info(javaVM_info, JVMCI_CHECK_0); - return false; - } - } - - { - // Ensure the JVMCI shared library runtime is initialized. - PEER_JVMCIENV_FROM_THREAD(THREAD, false); - PEER_JVMCIENV->check_init(JVMCI_CHECK_0); - - HandleMark hm(thread); - JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(PEER_JVMCIENV); - if (PEER_JVMCIENV->has_pending_exception()) { - PEER_JVMCIENV->describe_pending_exception(tty); - } - char* sl_path; - if (JVMCI::get_shared_library(sl_path, false) == nullptr) { - JVMCI_THROW_MSG_0(InternalError, "Error initializing JVMCI runtime"); - } - } - - JavaVMAttachArgs attach_args; - attach_args.version = JNI_VERSION_1_2; - attach_args.name = const_cast(thread->name()); - attach_args.group = nullptr; - if (runtime->GetEnv(thread, (void**) &peerJNIEnv, JNI_VERSION_1_2) == JNI_OK) { - return false; - } - jint res = as_daemon ? runtime->AttachCurrentThreadAsDaemon(thread, (void**) &peerJNIEnv, &attach_args) : - runtime->AttachCurrentThread(thread, (void**) &peerJNIEnv, &attach_args); - - if (res == JNI_OK) { - guarantee(peerJNIEnv != nullptr, "must be"); - runtime->init_JavaVM_info(javaVM_info, JVMCI_CHECK_0); - JVMCI_event_1("attached to JavaVM[" JLONG_FORMAT "] for JVMCI runtime %d", runtime->get_shared_library_javavm_id(), runtime->id()); - return true; - } - JVMCI_THROW_MSG_0(InternalError, err_msg("Error %d while attaching %s", res, attach_args.name)); - } - // Called from JVMCI shared library - return false; -C2V_END - -C2V_VMENTRY_PREFIX(jboolean, detachCurrentThread, (JNIEnv* env, jobject c2vm, jboolean release)) - if (thread == nullptr) { - // Called from unattached JVMCI shared library thread - JNI_THROW_("detachCurrentThread", IllegalStateException, "Cannot detach non-attached thread", false); - } - if (thread->jni_environment() == env) { - // Called from HotSpot - C2V_BLOCK(void, detachCurrentThread, (JNIEnv* env, jobject)) - JVMCITraceMark jtm("detachCurrentThread"); - requireJVMCINativeLibrary(JVMCI_CHECK_0); - requireInHotSpot("detachCurrentThread", JVMCI_CHECK_0); - JVMCIRuntime* runtime = thread->libjvmci_runtime(); - if (runtime == nullptr || !runtime->has_shared_library_javavm()) { - JVMCI_THROW_MSG_0(IllegalStateException, "Require JVMCI shared library JavaVM to be initialized in detachCurrentThread"); - } - JNIEnv* peerEnv; - - if (runtime->GetEnv(thread, (void**) &peerEnv, JNI_VERSION_1_2) != JNI_OK) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot detach non-attached thread: %s", thread->name())); - } - jint res = runtime->DetachCurrentThread(thread); - if (res != JNI_OK) { - JVMCI_THROW_MSG_0(InternalError, err_msg("Error %d while attaching %s", res, thread->name())); - } - JVMCI_event_1("detached from JavaVM[" JLONG_FORMAT "] for JVMCI runtime %d", - runtime->get_shared_library_javavm_id(), runtime->id()); - if (release) { - return runtime->detach_thread(thread, "user thread detach"); - } - } else { - // Called from attached JVMCI shared library thread - if (release) { - JNI_THROW_("detachCurrentThread", InternalError, "JVMCI shared library thread cannot release JVMCI shared library JavaVM", false); - } - JVMCIRuntime* runtime = thread->libjvmci_runtime(); - if (runtime == nullptr) { - JNI_THROW_("detachCurrentThread", InternalError, "JVMCI shared library thread should have a JVMCI runtime", false); - } - { - // Transition to VM - C2V_BLOCK(jboolean, detachCurrentThread, (JNIEnv* env, jobject)) - // Cannot destroy shared library JavaVM as we're about to return to it. - runtime->detach_thread(thread, "shared library thread detach", false); - JVMCI_event_1("detaching JVMCI shared library thread from HotSpot JavaVM"); - // Transition back to Native - } - extern struct JavaVM_ main_vm; - jint res = main_vm.DetachCurrentThread(); - if (res != JNI_OK) { - JNI_THROW_("detachCurrentThread", InternalError, "Cannot detach non-attached thread", false); - } - } - return false; -C2V_END - -C2V_VMENTRY_0(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle, jboolean callPostTranslation)) - requireJVMCINativeLibrary(JVMCI_CHECK_0); - if (obj_handle == nullptr) { - return 0L; - } - PEER_JVMCIENV_FROM_THREAD(THREAD, !JVMCIENV->is_hotspot()); - CompilerThreadCanCallJava canCallJava(thread, PEER_JVMCIENV->is_hotspot()); - PEER_JVMCIENV->check_init(JVMCI_CHECK_0); - - JVMCIEnv* thisEnv = JVMCIENV; - JVMCIObject obj = thisEnv->wrap(obj_handle); - JVMCIObject result; - if (thisEnv->isa_HotSpotResolvedJavaMethodImpl(obj)) { - methodHandle method(THREAD, thisEnv->asMethod(obj)); - result = PEER_JVMCIENV->get_jvmci_method(method, JVMCI_CHECK_0); - } else if (thisEnv->isa_HotSpotResolvedObjectTypeImpl(obj)) { - Klass* klass = thisEnv->asKlass(obj); - JVMCIKlassHandle klass_handle(THREAD); - klass_handle = klass; - result = PEER_JVMCIENV->get_jvmci_type(klass_handle, JVMCI_CHECK_0); - } else if (thisEnv->isa_HotSpotResolvedPrimitiveType(obj)) { - BasicType type = JVMCIENV->kindToBasicType(JVMCIENV->get_HotSpotResolvedPrimitiveType_kind(obj), JVMCI_CHECK_0); - result = PEER_JVMCIENV->get_jvmci_primitive_type(type); - } else if (thisEnv->isa_IndirectHotSpotObjectConstantImpl(obj) || - thisEnv->isa_DirectHotSpotObjectConstantImpl(obj)) { - Handle constant = thisEnv->asConstant(obj, JVMCI_CHECK_0); - result = PEER_JVMCIENV->get_object_constant(constant()); - } else if (thisEnv->isa_HotSpotNmethod(obj)) { - if (PEER_JVMCIENV->is_hotspot()) { - JVMCINMethodHandle nmethod_handle(THREAD); - nmethod* nm = JVMCIENV->get_nmethod(obj, nmethod_handle); - if (nm != nullptr) { - JVMCINMethodData* data = nm->jvmci_nmethod_data(); - if (data != nullptr) { - // Only the mirror in the HotSpot heap is accessible - // through JVMCINMethodData - oop nmethod_mirror = data->get_nmethod_mirror(nm); - if (nmethod_mirror != nullptr) { - result = HotSpotJVMCI::wrap(nmethod_mirror); - } - } - } - } - - if (result.is_null()) { - JVMCIObject methodObject = thisEnv->get_HotSpotNmethod_method(obj); - methodHandle mh(THREAD, thisEnv->asMethod(methodObject)); - jboolean isDefault = thisEnv->get_HotSpotNmethod_isDefault(obj); - jboolean profileDeopt = thisEnv->get_HotSpotNmethod_profileDeopt(obj); - jlong compileIdSnapshot = thisEnv->get_HotSpotNmethod_compileIdSnapshot(obj); - JVMCIObject name_string = thisEnv->get_InstalledCode_name(obj); - const char* cstring = name_string.is_null() ? nullptr : thisEnv->as_utf8_string(name_string); - // Create a new HotSpotNmethod instance in the peer runtime - result = PEER_JVMCIENV->new_HotSpotNmethod(mh, cstring, isDefault, profileDeopt, compileIdSnapshot, JVMCI_CHECK_0); - JVMCINMethodHandle nmethod_handle(THREAD); - nmethod* nm = JVMCIENV->get_nmethod(obj, nmethod_handle); - if (result.is_null()) { - // exception occurred (e.g. OOME) creating a new HotSpotNmethod - } else if (nm == nullptr) { - // nmethod must have been unloaded - } else { - // Link the new HotSpotNmethod to the nmethod - PEER_JVMCIENV->initialize_installed_code(result, nm, JVMCI_CHECK_0); - // Only non-default HotSpotNmethod instances in the HotSpot heap are tracked directly by the runtime. - if (!isDefault && PEER_JVMCIENV->is_hotspot()) { - JVMCINMethodData* data = nm->jvmci_nmethod_data(); - if (data == nullptr) { - JVMCI_THROW_MSG_0(IllegalArgumentException, "Missing HotSpotNmethod data"); - } - if (data->get_nmethod_mirror(nm) != nullptr) { - JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot overwrite existing HotSpotNmethod mirror for nmethod"); - } - oop nmethod_mirror = HotSpotJVMCI::resolve(result); - data->set_nmethod_mirror(nm, nmethod_mirror); - } - } - } - } else { - JVMCI_THROW_MSG_0(IllegalArgumentException, - err_msg("Cannot translate object of type: %s", thisEnv->klass_name(obj))); - } - if (callPostTranslation) { - PEER_JVMCIENV->call_HotSpotJVMCIRuntime_postTranslation(result, JVMCI_CHECK_0); - } - // Propagate any exception that occurred while creating the translated object - if (PEER_JVMCIENV->transfer_pending_exception(thread, thisEnv)) { - return 0L; - } - return (jlong) PEER_JVMCIENV->make_global(result).as_jobject(); -C2V_END - -C2V_VMENTRY_NULL(jobject, unhand, (JNIEnv* env, jobject, jlong obj_handle)) - requireJVMCINativeLibrary(JVMCI_CHECK_NULL); - if (obj_handle == 0L) { - return nullptr; - } - jobject global_handle = (jobject) obj_handle; - JVMCIObject global_handle_obj = JVMCIENV->wrap(global_handle); - jobject result = JVMCIENV->make_local(global_handle_obj).as_jobject(); - - JVMCIENV->destroy_global(global_handle_obj); - return result; -C2V_END - -C2V_VMENTRY(void, updateHotSpotNmethod, (JNIEnv* env, jobject, jobject code_handle)) - JVMCIObject code = JVMCIENV->wrap(code_handle); - // Execute this operation for the side effect of updating the InstalledCode state - JVMCINMethodHandle nmethod_handle(THREAD); - JVMCIENV->get_nmethod(code, nmethod_handle); -C2V_END - -C2V_VMENTRY_NULL(jbyteArray, getCode, (JNIEnv* env, jobject, jobject code_handle)) - JVMCIObject code = JVMCIENV->wrap(code_handle); - CodeBlob* cb = JVMCIENV->get_code_blob(code); - if (cb == nullptr) { - return nullptr; - } - // Make a resource copy of code before the allocation causes a safepoint - int code_size = cb->code_size(); - jbyte* code_bytes = NEW_RESOURCE_ARRAY(jbyte, code_size); - memcpy(code_bytes, (jbyte*) cb->code_begin(), code_size); - - JVMCIPrimitiveArray result = JVMCIENV->new_byteArray(code_size, JVMCI_CHECK_NULL); - JVMCIENV->copy_bytes_from(code_bytes, result, 0, code_size); - return JVMCIENV->get_jbyteArray(result); -C2V_END - -C2V_VMENTRY_NULL(jobject, asReflectionExecutable, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - requireInHotSpot("asReflectionExecutable", JVMCI_CHECK_NULL); - methodHandle m(THREAD, UNPACK_PAIR(Method, method)); - oop executable; - if (m->is_object_initializer()) { - executable = Reflection::new_constructor(m, CHECK_NULL); - } else if (m->is_static_initializer()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - "Cannot create java.lang.reflect.Method for class initializer"); - } else { - executable = Reflection::new_method(m, false, CHECK_NULL); - } - return JNIHandles::make_local(THREAD, executable); -C2V_END - -// Checks that `index` denotes a non-injected field in `klass` -static InstanceKlass* check_field(Klass* klass, jint index, JVMCI_TRAPS) { - if (!klass->is_instance_klass()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - err_msg("Expected non-primitive type, got %s", klass->external_name())); - } - InstanceKlass* iklass = InstanceKlass::cast(klass); - if (index < 0 || index >= iklass->java_fields_count()) { - if (index >= 0 && index < iklass->total_fields_count()) { - fieldDescriptor fd(iklass, index); - if (fd.is_injected()) { - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - err_msg("Cannot get Field for injected %s.%s", klass->external_name(), fd.name()->as_C_string())); - } - } - JVMCI_THROW_MSG_NULL(IllegalArgumentException, - err_msg("Field index %d out of bounds for %s", index, klass->external_name())); - } - return iklass; -} - -C2V_VMENTRY_NULL(jobject, asReflectionField, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), jint index)) - requireInHotSpot("asReflectionField", JVMCI_CHECK_NULL); - Klass* klass = UNPACK_PAIR(Klass, klass); - InstanceKlass* iklass = check_field(klass, index, JVMCI_CHECK_NULL); - fieldDescriptor fd(iklass, index); - oop reflected = Reflection::new_field(&fd, CHECK_NULL); - return JNIHandles::make_local(THREAD, reflected); -C2V_END - -static jbyteArray get_encoded_annotation_data(InstanceKlass* holder, AnnotationArray* annotations_array, bool for_class, - jint filter_length, jlong filter_klass_pointers, - JavaThread* THREAD, JVMCI_TRAPS) { - // Get a ConstantPool object for annotation parsing - Handle jcp = reflect_ConstantPool::create(CHECK_NULL); - reflect_ConstantPool::set_cp(jcp(), holder->constants()); - - // load VMSupport - Symbol* klass = vmSymbols::jdk_internal_vm_VMSupport(); - Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK_NULL); - - InstanceKlass* vm_support = InstanceKlass::cast(k); - if (vm_support->should_be_initialized()) { - vm_support->initialize(CHECK_NULL); - } - - typeArrayOop annotations_oop = Annotations::make_java_array(annotations_array, CHECK_NULL); - typeArrayHandle annotations = typeArrayHandle(THREAD, annotations_oop); - - InstanceKlass** filter = filter_length == 1 ? - (InstanceKlass**) &filter_klass_pointers: - (InstanceKlass**) filter_klass_pointers; - objArrayOop filter_oop = oopFactory::new_objArray(vmClasses::Class_klass(), filter_length, CHECK_NULL); - objArrayHandle filter_classes(THREAD, filter_oop); - for (int i = 0; i < filter_length; i++) { - filter_classes->obj_at_put(i, filter[i]->java_mirror()); - } - - // invoke VMSupport.encodeAnnotations - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_oop(annotations); - args.push_oop(Handle(THREAD, holder->java_mirror())); - args.push_oop(jcp); - args.push_int(for_class); - args.push_oop(filter_classes); - Symbol* signature = vmSymbols::encodeAnnotations_signature(); - JavaCalls::call_static(&result, - vm_support, - vmSymbols::encodeAnnotations_name(), - signature, - &args, - CHECK_NULL); - - oop res = result.get_oop(); - if (JVMCIENV->is_hotspot()) { - return (jbyteArray) JNIHandles::make_local(THREAD, res); - } - - typeArrayOop ba = typeArrayOop(res); - int ba_len = ba->length(); - jbyte* ba_buf = NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(THREAD, jbyte, ba_len); - if (ba_buf == nullptr) { - JVMCI_THROW_MSG_NULL(InternalError, - err_msg("could not allocate %d bytes", ba_len)); - - } - memcpy(ba_buf, ba->byte_at_addr(0), ba_len); - JVMCIPrimitiveArray ba_dest = JVMCIENV->new_byteArray(ba_len, JVMCI_CHECK_NULL); - JVMCIENV->copy_bytes_from(ba_buf, ba_dest, 0, ba_len); - return JVMCIENV->get_jbyteArray(ba_dest); -} - -C2V_VMENTRY_NULL(jbyteArray, getEncodedClassAnnotationData, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), - jobject filter, jint filter_length, jlong filter_klass_pointers)) - CompilerThreadCanCallJava canCallJava(thread, true); // Requires Java support - InstanceKlass* holder = InstanceKlass::cast(UNPACK_PAIR(Klass, klass)); - return get_encoded_annotation_data(holder, holder->class_annotations(), true, filter_length, filter_klass_pointers, THREAD, JVMCIENV); -C2V_END - -C2V_VMENTRY_NULL(jbyteArray, getEncodedExecutableAnnotationData, (JNIEnv* env, jobject, ARGUMENT_PAIR(method), - jobject filter, jint filter_length, jlong filter_klass_pointers)) - CompilerThreadCanCallJava canCallJava(thread, true); // Requires Java support - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - return get_encoded_annotation_data(method->method_holder(), method->annotations(), false, filter_length, filter_klass_pointers, THREAD, JVMCIENV); -C2V_END - -C2V_VMENTRY_NULL(jbyteArray, getEncodedFieldAnnotationData, (JNIEnv* env, jobject, ARGUMENT_PAIR(klass), jint index, - jobject filter, jint filter_length, jlong filter_klass_pointers)) - CompilerThreadCanCallJava canCallJava(thread, true); // Requires Java support - InstanceKlass* holder = check_field(InstanceKlass::cast(UNPACK_PAIR(Klass, klass)), index, JVMCI_CHECK_NULL); - fieldDescriptor fd(holder, index); - return get_encoded_annotation_data(holder, fd.annotations(), false, filter_length, filter_klass_pointers, THREAD, JVMCIENV); -C2V_END - -C2V_VMENTRY_NULL(jobjectArray, getFailedSpeculations, (JNIEnv* env, jobject, jlong failed_speculations_address, jobjectArray current)) - FailedSpeculation* head = *((FailedSpeculation**)(address) failed_speculations_address); - int result_length = 0; - for (FailedSpeculation* fs = head; fs != nullptr; fs = fs->next()) { - result_length++; - } - int current_length = 0; - JVMCIObjectArray current_array = nullptr; - if (current != nullptr) { - current_array = JVMCIENV->wrap(current); - current_length = JVMCIENV->get_length(current_array); - if (current_length == result_length) { - // No new failures - return current; - } - } - JVMCIObjectArray result = JVMCIENV->new_byte_array_array(result_length, JVMCI_CHECK_NULL); - int result_index = 0; - for (FailedSpeculation* fs = head; result_index < result_length; fs = fs->next()) { - assert(fs != nullptr, "npe"); - JVMCIPrimitiveArray entry; - if (result_index < current_length) { - entry = (JVMCIPrimitiveArray) JVMCIENV->get_object_at(current_array, result_index); - } else { - entry = JVMCIENV->new_byteArray(fs->data_len(), JVMCI_CHECK_NULL); - JVMCIENV->copy_bytes_from((jbyte*) fs->data(), entry, 0, fs->data_len()); - } - JVMCIENV->put_object_at(result, result_index++, entry); - } - return JVMCIENV->get_jobjectArray(result); -C2V_END - -C2V_VMENTRY_0(jlong, getFailedSpeculationsAddress, (JNIEnv* env, jobject, ARGUMENT_PAIR(method))) - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - MethodData* method_data = get_profiling_method_data(method, CHECK_0); - return (jlong) method_data->get_failed_speculations_address(); -C2V_END - -C2V_VMENTRY(void, releaseFailedSpeculations, (JNIEnv* env, jobject, jlong failed_speculations_address)) - FailedSpeculation::free_failed_speculations((FailedSpeculation**)(address) failed_speculations_address); -C2V_END - -C2V_VMENTRY_0(jboolean, addFailedSpeculation, (JNIEnv* env, jobject, jlong failed_speculations_address, jbyteArray speculation_obj)) - JVMCIPrimitiveArray speculation_handle = JVMCIENV->wrap(speculation_obj); - int speculation_len = JVMCIENV->get_length(speculation_handle); - char* speculation = NEW_RESOURCE_ARRAY(char, speculation_len); - JVMCIENV->copy_bytes_to(speculation_handle, (jbyte*) speculation, 0, speculation_len); - return FailedSpeculation::add_failed_speculation(nullptr, (FailedSpeculation**)(address) failed_speculations_address, (address) speculation, speculation_len); -C2V_END - -C2V_VMENTRY(void, callSystemExit, (JNIEnv* env, jobject, jint status)) - if (!JVMCIENV->is_hotspot()) { - // It's generally not safe to call Java code before the module system is initialized - if (!Universe::is_module_initialized()) { - JVMCI_event_1("callSystemExit(%d) before Universe::is_module_initialized() -> direct VM exit", status); - vm_exit_during_initialization(); - } - } - CompilerThreadCanCallJava canCallJava(thread, true); - JavaValue result(T_VOID); - JavaCallArguments jargs(1); - jargs.push_int(status); - JavaCalls::call_static(&result, - vmClasses::System_klass(), - vmSymbols::exit_method_name(), - vmSymbols::int_void_signature(), - &jargs, - CHECK); -C2V_END - -C2V_VMENTRY_0(jlong, ticksNow, (JNIEnv* env, jobject)) - return CompilerEvent::ticksNow(); -C2V_END - -C2V_VMENTRY_0(jint, registerCompilerPhase, (JNIEnv* env, jobject, jstring jphase_name)) -#if INCLUDE_JFR - JVMCIObject phase_name = JVMCIENV->wrap(jphase_name); - const char *name = JVMCIENV->as_utf8_string(phase_name); - return CompilerEvent::PhaseEvent::get_phase_id(name, true, true, true); -#else - return -1; -#endif // !INCLUDE_JFR -C2V_END - -C2V_VMENTRY(void, notifyCompilerPhaseEvent, (JNIEnv* env, jobject, jlong startTime, jint phase, jint compileId, jint level)) - EventCompilerPhase event(UNTIMED); - if (event.should_commit()) { - CompilerEvent::PhaseEvent::post(event, startTime, phase, compileId, level); - } -C2V_END - -C2V_VMENTRY(void, notifyCompilerInliningEvent, (JNIEnv* env, jobject, jint compileId, ARGUMENT_PAIR(caller), ARGUMENT_PAIR(callee), jboolean succeeded, jstring jmessage, jint bci)) - EventCompilerInlining event; - if (event.should_commit()) { - Method* caller = UNPACK_PAIR(Method, caller); - Method* callee = UNPACK_PAIR(Method, callee); - JVMCIObject message = JVMCIENV->wrap(jmessage); - CompilerEvent::InlineEvent::post(event, compileId, caller, callee, succeeded, JVMCIENV->as_utf8_string(message), bci); - } -C2V_END - -C2V_VMENTRY(void, setThreadLocalObject, (JNIEnv* env, jobject, jint id, jobject value)) - requireInHotSpot("setThreadLocalObject", JVMCI_CHECK); - if (id == 0) { - thread->set_jvmci_reserved_oop0(JNIHandles::resolve(value)); - return; - } - THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), - err_msg("%d is not a valid thread local id", id)); -C2V_END - -C2V_VMENTRY_NULL(jobject, getThreadLocalObject, (JNIEnv* env, jobject, jint id)) - requireInHotSpot("getThreadLocalObject", JVMCI_CHECK_NULL); - if (id == 0) { - return JNIHandles::make_local(thread->get_jvmci_reserved_oop0()); - } - THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), - err_msg("%d is not a valid thread local id", id)); -C2V_END - -C2V_VMENTRY(void, setThreadLocalLong, (JNIEnv* env, jobject, jint id, jlong value)) - requireInHotSpot("setThreadLocalLong", JVMCI_CHECK); - if (id == 0) { - thread->set_jvmci_reserved0(value); - } else if (id == 1) { - thread->set_jvmci_reserved1(value); - } else { - THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), - err_msg("%d is not a valid thread local id", id)); - } -C2V_END - -C2V_VMENTRY_0(jlong, getThreadLocalLong, (JNIEnv* env, jobject, jint id)) - requireInHotSpot("getThreadLocalLong", JVMCI_CHECK_0); - if (id == 0) { - return thread->get_jvmci_reserved0(); - } else if (id == 1) { - return thread->get_jvmci_reserved1(); - } else { - THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), - err_msg("%d is not a valid thread local id", id)); - } -C2V_END - -C2V_VMENTRY(void, getOopMapAt, (JNIEnv* env, jobject, ARGUMENT_PAIR(method), - jint bci, jlongArray oop_map_handle)) - methodHandle method(THREAD, UNPACK_PAIR(Method, method)); - if (bci < 0 || bci >= method->code_size()) { - JVMCI_THROW_MSG(IllegalArgumentException, - err_msg("bci %d is out of bounds [0 .. %d)", bci, method->code_size())); - } - InterpreterOopMap mask; - OopMapCache::compute_one_oop_map(method, bci, &mask); - if (!mask.has_valid_mask()) { - JVMCI_THROW_MSG(IllegalArgumentException, err_msg("bci %d is not valid", bci)); - } - if (mask.number_of_entries() == 0) { - return; - } - - int nslots = method->max_locals() + method->max_stack(); - int nwords = ((nslots - 1) / 64) + 1; - JVMCIPrimitiveArray oop_map = JVMCIENV->wrap(oop_map_handle); - int oop_map_len = JVMCIENV->get_length(oop_map); - if (nwords > oop_map_len) { - JVMCI_THROW_MSG(IllegalArgumentException, - err_msg("oop map too short: %d > %d", nwords, oop_map_len)); - } - - jlong* oop_map_buf = NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(THREAD, jlong, nwords); - if (oop_map_buf == nullptr) { - JVMCI_THROW_MSG(InternalError, err_msg("could not allocate %d longs", nwords)); - } - for (int i = 0; i < nwords; i++) { - oop_map_buf[i] = 0L; - } - - BitMapView oop_map_view = BitMapView((BitMap::bm_word_t*) oop_map_buf, nwords * BitsPerLong); - for (int i = 0; i < nslots; i++) { - if (mask.is_oop(i)) { - oop_map_view.set_bit(i); - } - } - JVMCIENV->copy_longs_from((jlong*)oop_map_buf, oop_map, 0, nwords); -C2V_END - -C2V_VMENTRY_0(jint, getCompilationActivityMode, (JNIEnv* env, jobject)) - return CompileBroker::get_compilation_activity_mode(); -C2V_END - -C2V_VMENTRY_0(jboolean, isCompilerThread, (JNIEnv* env, jobject)) - return thread->is_Compiler_thread(); -C2V_END - -#define CC (char*) /*cast a literal from (const char*)*/ -#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) - -#define STRING "Ljava/lang/String;" -#define OBJECT "Ljava/lang/Object;" -#define CLASS "Ljava/lang/Class;" -#define OBJECTCONSTANT "Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;" -#define EXECUTABLE "Ljava/lang/reflect/Executable;" -#define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" -#define INSTALLED_CODE "Ljdk/vm/ci/code/InstalledCode;" -#define BYTECODE_FRAME "Ljdk/vm/ci/code/BytecodeFrame;" -#define JAVACONSTANT "Ljdk/vm/ci/meta/JavaConstant;" -#define INSPECTED_FRAME_VISITOR "Ljdk/vm/ci/code/stack/InspectedFrameVisitor;" -#define RESOLVED_METHOD "Ljdk/vm/ci/meta/ResolvedJavaMethod;" -#define FIELDINFO "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl$FieldInfo;" -#define HS_RESOLVED_TYPE "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaType;" -#define HS_INSTALLED_CODE "Ljdk/vm/ci/hotspot/HotSpotInstalledCode;" -#define HS_NMETHOD "Ljdk/vm/ci/hotspot/HotSpotNmethod;" -#define HS_COMPILED_CODE "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;" -#define HS_CONFIG "Ljdk/vm/ci/hotspot/HotSpotVMConfig;" -#define HS_STACK_FRAME_REF "Ljdk/vm/ci/hotspot/HotSpotStackFrameReference;" -#define HS_SPECULATION_LOG "Ljdk/vm/ci/hotspot/HotSpotSpeculationLog;" -#define REFLECTION_EXECUTABLE "Ljava/lang/reflect/Executable;" -#define REFLECTION_FIELD "Ljava/lang/reflect/Field;" - -// Types wrapping VM pointers. The ...2 macro is for a pair: (wrapper, pointer) -#define HS_METHOD "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;" -#define HS_METHOD2 "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;J" -#define HS_KLASS "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;" -#define HS_KLASS2 "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;J" -#define HS_CONSTANT_POOL "Ljdk/vm/ci/hotspot/HotSpotConstantPool;" -#define HS_CONSTANT_POOL2 "Ljdk/vm/ci/hotspot/HotSpotConstantPool;J" - -JNINativeMethod CompilerToVM::methods[] = { - {CC "getBytecode", CC "(" HS_METHOD2 ")[B", FN_PTR(getBytecode)}, - {CC "getExceptionTableStart", CC "(" HS_METHOD2 ")J", FN_PTR(getExceptionTableStart)}, - {CC "getExceptionTableLength", CC "(" HS_METHOD2 ")I", FN_PTR(getExceptionTableLength)}, - {CC "findUniqueConcreteMethod", CC "(" HS_KLASS2 HS_METHOD2 ")" HS_METHOD, FN_PTR(findUniqueConcreteMethod)}, - {CC "getImplementor", CC "(" HS_KLASS2 ")" HS_KLASS, FN_PTR(getImplementor)}, - {CC "getStackTraceElement", CC "(" HS_METHOD2 "I)" STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, - {CC "methodIsIgnoredBySecurityStackWalk", CC "(" HS_METHOD2 ")Z", FN_PTR(methodIsIgnoredBySecurityStackWalk)}, - {CC "setNotInlinableOrCompilable", CC "(" HS_METHOD2 ")V", FN_PTR(setNotInlinableOrCompilable)}, - {CC "isCompilable", CC "(" HS_METHOD2 ")Z", FN_PTR(isCompilable)}, - {CC "hasNeverInlineDirective", CC "(" HS_METHOD2 ")Z", FN_PTR(hasNeverInlineDirective)}, - {CC "shouldInlineMethod", CC "(" HS_METHOD2 ")Z", FN_PTR(shouldInlineMethod)}, - {CC "lookupType", CC "(" STRING HS_KLASS2 "IZ)" HS_RESOLVED_TYPE, FN_PTR(lookupType)}, - {CC "lookupJClass", CC "(J)" HS_RESOLVED_TYPE, FN_PTR(lookupJClass)}, - {CC "getJObjectValue", CC "(" OBJECTCONSTANT ")J", FN_PTR(getJObjectValue)}, - {CC "getArrayType", CC "(C" HS_KLASS2 ")" HS_KLASS, FN_PTR(getArrayType)}, - {CC "lookupClass", CC "(" CLASS ")" HS_RESOLVED_TYPE, FN_PTR(lookupClass)}, - {CC "lookupNameInPool", CC "(" HS_CONSTANT_POOL2 "II)" STRING, FN_PTR(lookupNameInPool)}, - {CC "lookupNameAndTypeRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, - {CC "lookupSignatureInPool", CC "(" HS_CONSTANT_POOL2 "II)" STRING, FN_PTR(lookupSignatureInPool)}, - {CC "lookupKlassRefIndexInPool", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(lookupKlassRefIndexInPool)}, - {CC "lookupKlassInPool", CC "(" HS_CONSTANT_POOL2 "I)Ljava/lang/Object;", FN_PTR(lookupKlassInPool)}, - {CC "lookupAppendixInPool", CC "(" HS_CONSTANT_POOL2 "II)" OBJECTCONSTANT, FN_PTR(lookupAppendixInPool)}, - {CC "lookupMethodInPool", CC "(" HS_CONSTANT_POOL2 "IB" HS_METHOD2 ")" HS_METHOD, FN_PTR(lookupMethodInPool)}, - {CC "lookupConstantInPool", CC "(" HS_CONSTANT_POOL2 "IZ)" JAVACONSTANT, FN_PTR(lookupConstantInPool)}, - {CC "getNumIndyEntries", CC "(" HS_CONSTANT_POOL2 ")I", FN_PTR(getNumIndyEntries)}, - {CC "resolveBootstrapMethod", CC "(" HS_CONSTANT_POOL2 "I)[" OBJECT, FN_PTR(resolveBootstrapMethod)}, - {CC "bootstrapArgumentIndexAt", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(bootstrapArgumentIndexAt)}, - {CC "getUncachedStringInPool", CC "(" HS_CONSTANT_POOL2 "I)" JAVACONSTANT, FN_PTR(getUncachedStringInPool)}, - {CC "resolveTypeInPool", CC "(" HS_CONSTANT_POOL2 "I)" HS_KLASS, FN_PTR(resolveTypeInPool)}, - {CC "resolveFieldInPool", CC "(" HS_CONSTANT_POOL2 "I" HS_METHOD2 "B[I)" HS_KLASS, FN_PTR(resolveFieldInPool)}, - {CC "decodeFieldIndexToCPIndex", CC "(" HS_CONSTANT_POOL2 "I)I", FN_PTR(decodeFieldIndexToCPIndex)}, - {CC "decodeMethodIndexToCPIndex", CC "(" HS_CONSTANT_POOL2 "I)I", FN_PTR(decodeMethodIndexToCPIndex)}, - {CC "decodeIndyIndexToCPIndex", CC "(" HS_CONSTANT_POOL2 "IZ)I", FN_PTR(decodeIndyIndexToCPIndex)}, - {CC "resolveInvokeHandleInPool", CC "(" HS_CONSTANT_POOL2 "I)V", FN_PTR(resolveInvokeHandleInPool)}, - {CC "isResolvedInvokeHandleInPool", CC "(" HS_CONSTANT_POOL2 "II)I", FN_PTR(isResolvedInvokeHandleInPool)}, - {CC "resolveMethod", CC "(" HS_KLASS2 HS_METHOD2 HS_KLASS2 ")" HS_METHOD, FN_PTR(resolveMethod)}, - {CC "getSignaturePolymorphicHolders", CC "()[" STRING, FN_PTR(getSignaturePolymorphicHolders)}, - {CC "getVtableIndexForInterfaceMethod", CC "(" HS_KLASS2 HS_METHOD2 ")I", FN_PTR(getVtableIndexForInterfaceMethod)}, - {CC "getClassInitializer", CC "(" HS_KLASS2 ")" HS_METHOD, FN_PTR(getClassInitializer)}, - {CC "hasFinalizableSubclass", CC "(" HS_KLASS2 ")Z", FN_PTR(hasFinalizableSubclass)}, - {CC "getMaxCallTargetOffset", CC "(J)J", FN_PTR(getMaxCallTargetOffset)}, - {CC "asResolvedJavaMethod", CC "(" EXECUTABLE ")" HS_METHOD, FN_PTR(asResolvedJavaMethod)}, - {CC "getResolvedJavaMethod", CC "(" OBJECTCONSTANT "J)" HS_METHOD, FN_PTR(getResolvedJavaMethod)}, - {CC "getConstantPool", CC "(" OBJECT "JZ)" HS_CONSTANT_POOL, FN_PTR(getConstantPool)}, - {CC "getResolvedJavaType0", CC "(Ljava/lang/Object;JZ)" HS_KLASS, FN_PTR(getResolvedJavaType0)}, - {CC "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)}, - {CC "installCode0", CC "(JJZ" HS_COMPILED_CODE "[" OBJECT INSTALLED_CODE "J[B)I", FN_PTR(installCode0)}, - {CC "getInvalidationReasonDescription", CC "(I)" STRING, FN_PTR(getInvalidationReasonDescription)}, - {CC "getInstallCodeFlags", CC "()I", FN_PTR(getInstallCodeFlags)}, - {CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)}, - {CC "disassembleCodeBlob", CC "(" INSTALLED_CODE ")" STRING, FN_PTR(disassembleCodeBlob)}, - {CC "executeHotSpotNmethod", CC "([" OBJECT HS_NMETHOD ")" OBJECT, FN_PTR(executeHotSpotNmethod)}, - {CC "getLineNumberTable", CC "(" HS_METHOD2 ")[J", FN_PTR(getLineNumberTable)}, - {CC "getLocalVariableTableStart", CC "(" HS_METHOD2 ")J", FN_PTR(getLocalVariableTableStart)}, - {CC "getLocalVariableTableLength", CC "(" HS_METHOD2 ")I", FN_PTR(getLocalVariableTableLength)}, - {CC "reprofile", CC "(" HS_METHOD2 ")V", FN_PTR(reprofile)}, - {CC "invalidateHotSpotNmethod", CC "(" HS_NMETHOD "ZI)V", FN_PTR(invalidateHotSpotNmethod)}, - {CC "collectCounters", CC "()[J", FN_PTR(collectCounters)}, - {CC "getCountersSize", CC "()I", FN_PTR(getCountersSize)}, - {CC "setCountersSize", CC "(I)Z", FN_PTR(setCountersSize)}, - {CC "allocateCompileId", CC "(" HS_METHOD2 "I)I", FN_PTR(allocateCompileId)}, - {CC "isMature", CC "(J)Z", FN_PTR(isMature)}, - {CC "hasCompiledCodeForOSR", CC "(" HS_METHOD2 "II)Z", FN_PTR(hasCompiledCodeForOSR)}, - {CC "getSymbol", CC "(J)" STRING, FN_PTR(getSymbol)}, - {CC "getSignatureName", CC "(J)" STRING, FN_PTR(getSignatureName)}, - {CC "iterateFrames", CC "([" RESOLVED_METHOD "[" RESOLVED_METHOD "I" INSPECTED_FRAME_VISITOR ")" OBJECT, FN_PTR(iterateFrames)}, - {CC "materializeVirtualObjects", CC "(" HS_STACK_FRAME_REF "Z)V", FN_PTR(materializeVirtualObjects)}, - {CC "shouldDebugNonSafepoints", CC "()Z", FN_PTR(shouldDebugNonSafepoints)}, - {CC "writeDebugOutput", CC "(JIZ)V", FN_PTR(writeDebugOutput)}, - {CC "flushDebugOutput", CC "()V", FN_PTR(flushDebugOutput)}, - {CC "methodDataProfileDataSize", CC "(JI)I", FN_PTR(methodDataProfileDataSize)}, - {CC "methodDataExceptionSeen", CC "(JI)I", FN_PTR(methodDataExceptionSeen)}, - {CC "interpreterFrameSize", CC "(" BYTECODE_FRAME ")I", FN_PTR(interpreterFrameSize)}, - {CC "compileToBytecode", CC "(" OBJECTCONSTANT ")V", FN_PTR(compileToBytecode)}, - {CC "getFlagValue", CC "(" STRING ")" OBJECT, FN_PTR(getFlagValue)}, - {CC "getInterfaces", CC "(" HS_KLASS2 ")[" HS_KLASS, FN_PTR(getInterfaces)}, - {CC "getComponentType", CC "(" HS_KLASS2 ")" HS_RESOLVED_TYPE, FN_PTR(getComponentType)}, - {CC "ensureInitialized", CC "(" HS_KLASS2 ")V", FN_PTR(ensureInitialized)}, - {CC "ensureLinked", CC "(" HS_KLASS2 ")V", FN_PTR(ensureLinked)}, - {CC "getIdentityHashCode", CC "(" OBJECTCONSTANT ")I", FN_PTR(getIdentityHashCode)}, - {CC "isInternedString", CC "(" OBJECTCONSTANT ")Z", FN_PTR(isInternedString)}, - {CC "unboxPrimitive", CC "(" OBJECTCONSTANT ")" OBJECT, FN_PTR(unboxPrimitive)}, - {CC "boxPrimitive", CC "(" OBJECT ")" OBJECTCONSTANT, FN_PTR(boxPrimitive)}, - {CC "getDeclaredConstructors", CC "(" HS_KLASS2 ")[" RESOLVED_METHOD, FN_PTR(getDeclaredConstructors)}, - {CC "getDeclaredMethods", CC "(" HS_KLASS2 ")[" RESOLVED_METHOD, FN_PTR(getDeclaredMethods)}, - {CC "getAllMethods", CC "(" HS_KLASS2 ")[" RESOLVED_METHOD, FN_PTR(getAllMethods)}, - {CC "getDeclaredFieldsInfo", CC "(" HS_KLASS2 ")[" FIELDINFO, FN_PTR(getDeclaredFieldsInfo)}, - {CC "readStaticFieldValue", CC "(" HS_KLASS2 "JC)" JAVACONSTANT, FN_PTR(readStaticFieldValue)}, - {CC "readFieldValue", CC "(" OBJECTCONSTANT HS_KLASS2 "JC)" JAVACONSTANT, FN_PTR(readFieldValue)}, - {CC "isInstance", CC "(" HS_KLASS2 OBJECTCONSTANT ")Z", FN_PTR(isInstance)}, - {CC "isAssignableFrom", CC "(" HS_KLASS2 HS_KLASS2 ")Z", FN_PTR(isAssignableFrom)}, - {CC "isTrustedForIntrinsics", CC "(" HS_KLASS2 ")Z", FN_PTR(isTrustedForIntrinsics)}, - {CC "asJavaType", CC "(" OBJECTCONSTANT ")" HS_RESOLVED_TYPE, FN_PTR(asJavaType)}, - {CC "asString", CC "(" OBJECTCONSTANT ")" STRING, FN_PTR(asString)}, - {CC "equals", CC "(" OBJECTCONSTANT "J" OBJECTCONSTANT "J)Z", FN_PTR(equals)}, - {CC "getJavaMirror", CC "(" HS_KLASS2 ")" OBJECTCONSTANT, FN_PTR(getJavaMirror)}, - {CC "getArrayLength", CC "(" OBJECTCONSTANT ")I", FN_PTR(getArrayLength)}, - {CC "readArrayElement", CC "(" OBJECTCONSTANT "I)Ljava/lang/Object;", FN_PTR(readArrayElement)}, - {CC "arrayBaseOffset", CC "(C)I", FN_PTR(arrayBaseOffset)}, - {CC "arrayIndexScale", CC "(C)I", FN_PTR(arrayIndexScale)}, - {CC "clearOopHandle", CC "(J)V", FN_PTR(clearOopHandle)}, - {CC "releaseClearedOopHandles", CC "()V", FN_PTR(releaseClearedOopHandles)}, - {CC "registerNativeMethods", CC "(" CLASS ")[J", FN_PTR(registerNativeMethods)}, - {CC "isCurrentThreadAttached", CC "()Z", FN_PTR(isCurrentThreadAttached)}, - {CC "getCurrentJavaThread", CC "()J", FN_PTR(getCurrentJavaThread)}, - {CC "attachCurrentThread", CC "([BZ[J)Z", FN_PTR(attachCurrentThread)}, - {CC "detachCurrentThread", CC "(Z)Z", FN_PTR(detachCurrentThread)}, - {CC "translate", CC "(" OBJECT "Z)J", FN_PTR(translate)}, - {CC "unhand", CC "(J)" OBJECT, FN_PTR(unhand)}, - {CC "updateHotSpotNmethod", CC "(" HS_NMETHOD ")V", FN_PTR(updateHotSpotNmethod)}, - {CC "getCode", CC "(" HS_INSTALLED_CODE ")[B", FN_PTR(getCode)}, - {CC "asReflectionExecutable", CC "(" HS_METHOD2 ")" REFLECTION_EXECUTABLE, FN_PTR(asReflectionExecutable)}, - {CC "asReflectionField", CC "(" HS_KLASS2 "I)" REFLECTION_FIELD, FN_PTR(asReflectionField)}, - {CC "getEncodedClassAnnotationData", CC "(" HS_KLASS2 OBJECT "IJ)[B", FN_PTR(getEncodedClassAnnotationData)}, - {CC "getEncodedExecutableAnnotationData", CC "(" HS_METHOD2 OBJECT "IJ)[B", FN_PTR(getEncodedExecutableAnnotationData)}, - {CC "getEncodedFieldAnnotationData", CC "(" HS_KLASS2 "I" OBJECT "IJ)[B", FN_PTR(getEncodedFieldAnnotationData)}, - {CC "getFailedSpeculations", CC "(J[[B)[[B", FN_PTR(getFailedSpeculations)}, - {CC "getFailedSpeculationsAddress", CC "(" HS_METHOD2 ")J", FN_PTR(getFailedSpeculationsAddress)}, - {CC "releaseFailedSpeculations", CC "(J)V", FN_PTR(releaseFailedSpeculations)}, - {CC "addFailedSpeculation", CC "(J[B)Z", FN_PTR(addFailedSpeculation)}, - {CC "callSystemExit", CC "(I)V", FN_PTR(callSystemExit)}, - {CC "ticksNow", CC "()J", FN_PTR(ticksNow)}, - {CC "getThreadLocalObject", CC "(I)" OBJECT, FN_PTR(getThreadLocalObject)}, - {CC "setThreadLocalObject", CC "(I" OBJECT ")V", FN_PTR(setThreadLocalObject)}, - {CC "getThreadLocalLong", CC "(I)J", FN_PTR(getThreadLocalLong)}, - {CC "setThreadLocalLong", CC "(IJ)V", FN_PTR(setThreadLocalLong)}, - {CC "registerCompilerPhase", CC "(" STRING ")I", FN_PTR(registerCompilerPhase)}, - {CC "notifyCompilerPhaseEvent", CC "(JIII)V", FN_PTR(notifyCompilerPhaseEvent)}, - {CC "notifyCompilerInliningEvent", CC "(I" HS_METHOD2 HS_METHOD2 "ZLjava/lang/String;I)V", FN_PTR(notifyCompilerInliningEvent)}, - {CC "getOopMapAt", CC "(" HS_METHOD2 "I[J)V", FN_PTR(getOopMapAt)}, - {CC "updateCompilerThreadCanCallJava", CC "(Z)Z", FN_PTR(updateCompilerThreadCanCallJava)}, - {CC "getCompilationActivityMode", CC "()I", FN_PTR(getCompilationActivityMode)}, - {CC "isCompilerThread", CC "()Z", FN_PTR(isCompilerThread)}, -}; - -int CompilerToVM::methods_count() { - return sizeof(methods) / sizeof(JNINativeMethod); -} diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp deleted file mode 100644 index f06ee667ff2..00000000000 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCICOMPILERTOVM_HPP -#define SHARE_JVMCI_JVMCICOMPILERTOVM_HPP - -#include "gc/shared/barrierSetAssembler.hpp" -#include "gc/shared/cardTable.hpp" -#include "jvmci/jvmciExceptions.hpp" -#include "runtime/javaCalls.hpp" -#include "runtime/signature.hpp" - -class CollectedHeap; -class JVMCIObjectArray; - -class CompilerToVM { - public: - class Data { - friend class JVMCIVMStructs; - - private: - static int oopDesc_klass_offset_in_bytes; - static int arrayOopDesc_length_offset_in_bytes; - - static int Klass_vtable_start_offset; - static int Klass_vtable_length_offset; - - static int Method_extra_stack_entries; - - static address SharedRuntime_ic_miss_stub; - static address SharedRuntime_handle_wrong_method_stub; - static address SharedRuntime_deopt_blob_unpack; - static address SharedRuntime_deopt_blob_unpack_with_exception_in_tls; - static address SharedRuntime_deopt_blob_uncommon_trap; - static address SharedRuntime_polling_page_return_handler; - static address SharedRuntime_throw_delayed_StackOverflowError_entry; - - static address nmethod_entry_barrier; - static int thread_disarmed_guard_value_offset; - static int thread_address_bad_mask_offset; -#ifdef AARCH64 - static int BarrierSetAssembler_nmethod_patching_type; - static address BarrierSetAssembler_patching_epoch_addr; -#endif - - static address ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded; - static address ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded; - static address ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded; - static address ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded; - static address ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded; - static address ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded; - static address ZBarrierSetRuntime_load_barrier_on_oop_array; - static address ZBarrierSetRuntime_clone; - - static address ZPointerVectorLoadBadMask_address; - static address ZPointerVectorStoreBadMask_address; - static address ZPointerVectorStoreGoodMask_address; - - static bool continuations_enabled; - - static size_t ThreadLocalAllocBuffer_alignment_reserve; - - static CollectedHeap* Universe_collectedHeap; - static int Universe_base_vtable_size; - static address Universe_narrow_oop_base; - static int Universe_narrow_oop_shift; - static address Universe_narrow_klass_base; - static int Universe_narrow_klass_shift; - static uintptr_t Universe_verify_oop_mask; - static uintptr_t Universe_verify_oop_bits; - static void* Universe_non_oop_bits; - - static bool _supports_inline_contig_alloc; - static HeapWord** _heap_end_addr; - static HeapWord* volatile* _heap_top_addr; - static int _max_oop_map_stack_offset; - static int _fields_annotations_base_offset; - - static CardTable::CardValue* cardtable_start_address; - static int cardtable_shift; - - static size_t vm_page_size; - - static int sizeof_vtableEntry; - static int sizeof_ExceptionTableElement; - static int sizeof_LocalVariableTableElement; - static int sizeof_ConstantPool; - static int sizeof_narrowKlass; - static int sizeof_arrayOopDesc; - static int sizeof_BasicLock; -#if INCLUDE_ZGC - static int sizeof_ZStoreBarrierEntry; -#endif -#if INCLUDE_SHENANDOAHGC - static address shenandoah_in_cset_fast_test_addr; - static int shenandoah_region_size_bytes_shift; -#endif - -#ifdef X86 - static int L1_line_size; - static bool supports_avx512_simd_sort; -#endif - - static address dsin; - static address dcos; - static address dtan; - static address dsinh; - static address dtanh; - static address dcbrt; - static address dexp; - static address dlog; - static address dlog10; - static address dpow; - - static address crc_table_addr; - - static address symbol_init; - static address symbol_clinit; - - // Minimum alignment of an offset into CodeBuffer::SECT_CONSTS - static int data_section_item_alignment; - -#if INCLUDE_JVMTI - /* - * Pointer to JvmtiExport::_should_notify_object_alloc. - * Exposed as an int* instead of an address so the - * underlying type is part of the JVMCIVMStructs definition. - */ - static int* _should_notify_object_alloc; -#endif - - public: - static void initialize(JVMCI_TRAPS); - - static int max_oop_map_stack_offset() { - assert(_max_oop_map_stack_offset > 0, "must be initialized"); - return Data::_max_oop_map_stack_offset; - } - - static int get_data_section_item_alignment() { - return data_section_item_alignment; - } - }; - - static bool cstring_equals(const char* const& s0, const char* const& s1) { - return strcmp(s0, s1) == 0; - } - - static unsigned cstring_hash(const char* const& s) { - unsigned h = 0; - const char* p = s; - while (*p != '\0') { - h = 31 * h + *p; - p++; - } - return h; - } - - static JNINativeMethod methods[]; - static JNINativeMethod jni_methods[]; - - static JVMCIObjectArray initialize_intrinsics(JVMCI_TRAPS); - public: - static int methods_count(); - -}; -#endif // SHARE_JVMCI_JVMCICOMPILERTOVM_HPP diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp deleted file mode 100644 index 6048c19d911..00000000000 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* - * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifdef COMPILER1 -#include "c1/c1_Compiler.hpp" -#endif -#include "ci/ciUtilities.hpp" -#include "compiler/compiler_globals.hpp" -#include "compiler/oopMap.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/barrierSetAssembler.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "gc/shared/cardTable.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/tlab_globals.hpp" -#if INCLUDE_ZGC -#include "gc/z/zBarrierSetRuntime.hpp" -#include "gc/z/zThreadLocalData.hpp" -#endif -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/vmStructs_jvmci.hpp" -#include "memory/universe.hpp" -#include "oops/compressedOops.hpp" -#include "oops/klass.inline.hpp" -#include "prims/jvmtiExport.hpp" -#ifdef COMPILER2 -#include "opto/c2compiler.hpp" -#endif -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/sharedRuntime.hpp" -#include "runtime/stubRoutines.hpp" -#include "utilities/hashTable.hpp" -#if INCLUDE_SHENANDOAHGC -#include "gc/shenandoah/shenandoahHeap.hpp" -#include "gc/shenandoah/shenandoahHeapRegion.hpp" -#endif - -int CompilerToVM::Data::oopDesc_klass_offset_in_bytes; -int CompilerToVM::Data::arrayOopDesc_length_offset_in_bytes; - -int CompilerToVM::Data::Klass_vtable_start_offset; -int CompilerToVM::Data::Klass_vtable_length_offset; - -int CompilerToVM::Data::Method_extra_stack_entries; - -address CompilerToVM::Data::SharedRuntime_ic_miss_stub; -address CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub; -address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack; -address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack_with_exception_in_tls; -address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap; -address CompilerToVM::Data::SharedRuntime_polling_page_return_handler; -address CompilerToVM::Data::SharedRuntime_throw_delayed_StackOverflowError_entry; - -address CompilerToVM::Data::nmethod_entry_barrier; -int CompilerToVM::Data::thread_disarmed_guard_value_offset; -int CompilerToVM::Data::thread_address_bad_mask_offset; - -address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded; -address CompilerToVM::Data::ZBarrierSetRuntime_load_barrier_on_oop_array; -address CompilerToVM::Data::ZBarrierSetRuntime_clone; - -address CompilerToVM::Data::ZPointerVectorLoadBadMask_address; -address CompilerToVM::Data::ZPointerVectorStoreBadMask_address; -address CompilerToVM::Data::ZPointerVectorStoreGoodMask_address; - -#if INCLUDE_SHENANDOAHGC -address CompilerToVM::Data::shenandoah_in_cset_fast_test_addr; -int CompilerToVM::Data::shenandoah_region_size_bytes_shift; -#endif - -bool CompilerToVM::Data::continuations_enabled; - -#ifdef AARCH64 -int CompilerToVM::Data::BarrierSetAssembler_nmethod_patching_type; -address CompilerToVM::Data::BarrierSetAssembler_patching_epoch_addr; -#endif - -size_t CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve; - -CollectedHeap* CompilerToVM::Data::Universe_collectedHeap; -int CompilerToVM::Data::Universe_base_vtable_size; -address CompilerToVM::Data::Universe_narrow_oop_base; -int CompilerToVM::Data::Universe_narrow_oop_shift; -address CompilerToVM::Data::Universe_narrow_klass_base; -int CompilerToVM::Data::Universe_narrow_klass_shift; -void* CompilerToVM::Data::Universe_non_oop_bits; -uintptr_t CompilerToVM::Data::Universe_verify_oop_mask; -uintptr_t CompilerToVM::Data::Universe_verify_oop_bits; - -bool CompilerToVM::Data::_supports_inline_contig_alloc; -HeapWord** CompilerToVM::Data::_heap_end_addr; -HeapWord* volatile* CompilerToVM::Data::_heap_top_addr; -int CompilerToVM::Data::_max_oop_map_stack_offset; -int CompilerToVM::Data::_fields_annotations_base_offset; - -CardTable::CardValue* CompilerToVM::Data::cardtable_start_address; -int CompilerToVM::Data::cardtable_shift; - -#ifdef X86 -int CompilerToVM::Data::L1_line_size; -bool CompilerToVM::Data::supports_avx512_simd_sort; -#endif - -size_t CompilerToVM::Data::vm_page_size; - -int CompilerToVM::Data::sizeof_vtableEntry = sizeof(vtableEntry); -int CompilerToVM::Data::sizeof_ExceptionTableElement = sizeof(ExceptionTableElement); -int CompilerToVM::Data::sizeof_LocalVariableTableElement = sizeof(LocalVariableTableElement); -int CompilerToVM::Data::sizeof_ConstantPool = sizeof(ConstantPool); -int CompilerToVM::Data::sizeof_narrowKlass = sizeof(narrowKlass); -int CompilerToVM::Data::sizeof_arrayOopDesc = sizeof(arrayOopDesc); -int CompilerToVM::Data::sizeof_BasicLock = sizeof(BasicLock); -#if INCLUDE_ZGC -int CompilerToVM::Data::sizeof_ZStoreBarrierEntry = sizeof(ZStoreBarrierEntry); -#endif - -address CompilerToVM::Data::dsin; -address CompilerToVM::Data::dcos; -address CompilerToVM::Data::dtan; -address CompilerToVM::Data::dsinh; -address CompilerToVM::Data::dtanh; -address CompilerToVM::Data::dcbrt; -address CompilerToVM::Data::dexp; -address CompilerToVM::Data::dlog; -address CompilerToVM::Data::dlog10; -address CompilerToVM::Data::dpow; - -address CompilerToVM::Data::crc_table_addr; - -address CompilerToVM::Data::symbol_init; -address CompilerToVM::Data::symbol_clinit; - -int CompilerToVM::Data::data_section_item_alignment; - -JVMTI_ONLY( int* CompilerToVM::Data::_should_notify_object_alloc; ) - -void CompilerToVM::Data::initialize(JVMCI_TRAPS) { - oopDesc_klass_offset_in_bytes = oopDesc::klass_offset_in_bytes(); - arrayOopDesc_length_offset_in_bytes = arrayOopDesc::length_offset_in_bytes(); - - Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset()); - Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset()); - - Method_extra_stack_entries = Method::extra_stack_entries(); - - SharedRuntime_ic_miss_stub = SharedRuntime::get_ic_miss_stub(); - SharedRuntime_handle_wrong_method_stub = SharedRuntime::get_handle_wrong_method_stub(); - SharedRuntime_deopt_blob_unpack = SharedRuntime::deopt_blob()->unpack(); - SharedRuntime_deopt_blob_unpack_with_exception_in_tls = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - SharedRuntime_deopt_blob_uncommon_trap = SharedRuntime::deopt_blob()->uncommon_trap(); - SharedRuntime_polling_page_return_handler = SharedRuntime::polling_page_return_handler_blob()->entry_point(); - SharedRuntime_throw_delayed_StackOverflowError_entry = SharedRuntime::throw_delayed_StackOverflowError_entry(); - - BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - thread_disarmed_guard_value_offset = in_bytes(bs_nm->thread_disarmed_guard_value_offset()); - nmethod_entry_barrier = StubRoutines::method_entry_barrier(); - BarrierSetAssembler* bs_asm = BarrierSet::barrier_set()->barrier_set_assembler(); - AARCH64_ONLY(BarrierSetAssembler_nmethod_patching_type = (int) bs_asm->nmethod_patching_type()); - AARCH64_ONLY(BarrierSetAssembler_patching_epoch_addr = bs_asm->patching_epoch_addr()); - -#if INCLUDE_ZGC - if (UseZGC) { - ZPointerVectorLoadBadMask_address = (address) &ZPointerVectorLoadBadMask; - ZPointerVectorStoreBadMask_address = (address) &ZPointerVectorStoreBadMask; - ZPointerVectorStoreGoodMask_address = (address) &ZPointerVectorStoreGoodMask; - } -#endif - - continuations_enabled = Continuations::enabled(); - - ThreadLocalAllocBuffer_alignment_reserve = ThreadLocalAllocBuffer::alignment_reserve(); - - Universe_collectedHeap = Universe::heap(); - Universe_base_vtable_size = Universe::base_vtable_size(); - if (UseCompressedOops) { - Universe_narrow_oop_base = CompressedOops::base(); - Universe_narrow_oop_shift = CompressedOops::shift(); - } else { - Universe_narrow_oop_base = nullptr; - Universe_narrow_oop_shift = 0; - } - Universe_narrow_klass_base = CompressedKlassPointers::base(); - Universe_narrow_klass_shift = CompressedKlassPointers::shift(); - Universe_non_oop_bits = Universe::non_oop_word(); - Universe_verify_oop_mask = Universe::verify_oop_mask(); - Universe_verify_oop_bits = Universe::verify_oop_bits(); - - _supports_inline_contig_alloc = false; - _heap_end_addr = (HeapWord**) -1; - _heap_top_addr = (HeapWord* volatile*) -1; - - _max_oop_map_stack_offset = (OopMapValue::register_mask - VMRegImpl::stack2reg(0)->value()) * VMRegImpl::stack_slot_size; - int max_oop_map_stack_index = _max_oop_map_stack_offset / VMRegImpl::stack_slot_size; - assert(OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index)), "should be valid"); - assert(!OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index + 1)), "should be invalid"); - - symbol_init = (address) vmSymbols::object_initializer_name(); - symbol_clinit = (address) vmSymbols::class_initializer_name(); - - _fields_annotations_base_offset = Array::base_offset_in_bytes(); - - data_section_item_alignment = relocInfo::addr_unit(); - - JVMTI_ONLY( _should_notify_object_alloc = &JvmtiExport::_should_notify_object_alloc; ) - - BarrierSet* bs = BarrierSet::barrier_set(); -#if INCLUDE_G1GC - if (bs->is_a(BarrierSet::G1BarrierSet)) { - cardtable_start_address = nullptr; - cardtable_shift = CardTable::card_shift(); - } else -#endif -#if INCLUDE_SHENANDOAHGC - if (bs->is_a(BarrierSet::ShenandoahBarrierSet)) { - cardtable_start_address = nullptr; - cardtable_shift = CardTable::card_shift(); - } else -#endif - if (bs->is_a(BarrierSet::CardTableBarrierSet)) { - CardTable::CardValue* base = ci_card_table_address_const(); - assert(base != nullptr, "unexpected byte_map_base"); - cardtable_start_address = base; - cardtable_shift = CardTable::card_shift(); - } else { - // No card mark barriers - cardtable_start_address = nullptr; - cardtable_shift = 0; - } - -#if INCLUDE_SHENANDOAHGC - if (UseShenandoahGC) { - shenandoah_in_cset_fast_test_addr = ShenandoahHeap::in_cset_fast_test_addr(); - shenandoah_region_size_bytes_shift = ShenandoahHeapRegion::region_size_bytes_shift_jint(); - } -#endif - -#ifdef X86 - L1_line_size = VM_Version::L1_line_size(); - supports_avx512_simd_sort = VM_Version::supports_avx512_simd_sort(); -#endif - - vm_page_size = os::vm_page_size(); - -#define SET_TRIGFUNC(name) \ - if (StubRoutines::name() != nullptr) { \ - name = StubRoutines::name(); \ - } else { \ - name = CAST_FROM_FN_PTR(address, SharedRuntime::name); \ - } - - SET_TRIGFUNC(dsin); - SET_TRIGFUNC(dcos); - SET_TRIGFUNC(dtan); - SET_TRIGFUNC(dexp); - SET_TRIGFUNC(dlog10); - SET_TRIGFUNC(dlog); - SET_TRIGFUNC(dpow); - -#undef SET_TRIGFUNC - -#define SET_TRIGFUNC_OR_NULL(name) \ - if (StubRoutines::name() != nullptr) { \ - name = StubRoutines::name(); \ - } else { \ - name = nullptr; \ - } - - SET_TRIGFUNC_OR_NULL(dsinh); - SET_TRIGFUNC_OR_NULL(dtanh); - SET_TRIGFUNC_OR_NULL(dcbrt); - SET_TRIGFUNC_OR_NULL(crc_table_addr); - -#undef SET_TRIGFUNC_OR_NULL - - -} - -static jboolean is_c1_supported(vmIntrinsics::ID id){ - jboolean supported = false; -#ifdef COMPILER1 - supported = (jboolean) Compiler::is_intrinsic_supported(id); -#endif - return supported; -} - -static jboolean is_c2_supported(vmIntrinsics::ID id){ - jboolean supported = false; -#ifdef COMPILER2 - supported = (jboolean) C2Compiler::is_intrinsic_supported(id); -#endif - return supported; -} - -JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) { - int len = vmIntrinsics::number_of_intrinsics() - 1; // Exclude vmIntrinsics::_none, which is 0 - JVMCIObjectArray vmIntrinsics = JVMCIENV->new_VMIntrinsicMethod_array(len, JVMCI_CHECK_NULL); - int index = 0; - vmSymbolID kls_sid = vmSymbolID::NO_SID; - JVMCIObject kls_str; -#define VM_SYMBOL_TO_STRING(s) \ - JVMCIENV->create_string(vmSymbols::symbol_at(VM_SYMBOL_ENUM_NAME(s)), JVMCI_CHECK_NULL) -#define VM_INTRINSIC_INFO(id, kls, name, sig, ignore_fcode) { \ - vmSymbolID sid = VM_SYMBOL_ENUM_NAME(kls); \ - if (kls_sid != sid) { \ - kls_str = VM_SYMBOL_TO_STRING(kls); \ - kls_sid = sid; \ - } \ - JVMCIObject name_str = VM_SYMBOL_TO_STRING(name); \ - JVMCIObject sig_str = VM_SYMBOL_TO_STRING(sig); \ - JVMCIObject vmIntrinsicMethod = JVMCIENV->new_VMIntrinsicMethod(kls_str, name_str, sig_str, (jint) vmIntrinsics::id, \ - (jboolean) vmIntrinsics::is_intrinsic_available(vmIntrinsics::id), \ - is_c1_supported(vmIntrinsics::id), \ - is_c2_supported(vmIntrinsics::id), JVMCI_CHECK_NULL); \ - JVMCIENV->put_object_at(vmIntrinsics, index++, vmIntrinsicMethod); \ - } - - // VM_INTRINSICS_DO does *not* iterate over vmIntrinsics::_none - VM_INTRINSICS_DO(VM_INTRINSIC_INFO, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_ALIAS_IGNORE) -#undef VM_SYMBOL_TO_STRING -#undef VM_INTRINSIC_INFO - - assert(index == len, "must be"); - return vmIntrinsics; -} - -#define PREDEFINED_CONFIG_FLAGS(do_bool_flag, do_uint_flag, do_int_flag, do_size_t_flag, do_intx_flag, do_uintx_flag) \ - do_int_flag(AllocateInstancePrefetchLines) \ - do_int_flag(AllocatePrefetchDistance) \ - do_intx_flag(AllocatePrefetchInstr) \ - do_int_flag(AllocatePrefetchLines) \ - do_int_flag(AllocatePrefetchStepSize) \ - do_int_flag(AllocatePrefetchStyle) \ - do_intx_flag(BciProfileWidth) \ - do_bool_flag(BootstrapJVMCI) \ - do_bool_flag(CITime) \ - do_bool_flag(CITimeEach) \ - do_size_t_flag(CodeCacheSegmentSize) \ - do_uint_flag(CodeEntryAlignment) \ - do_int_flag(ContendedPaddingWidth) \ - do_bool_flag(DontCompileHugeMethods) \ - do_bool_flag(EagerJVMCI) \ - do_bool_flag(EnableContended) \ - do_bool_flag(FoldStableValues) \ - do_bool_flag(ForceUnreachable) \ - do_intx_flag(HugeMethodLimit) \ - do_bool_flag(Inline) \ - do_intx_flag(JVMCICounterSize) \ - do_bool_flag(JVMCIPrintProperties) \ - do_int_flag(ObjectAlignmentInBytes) \ - do_bool_flag(PrintInlining) \ - do_bool_flag(ReduceInitialCardMarks) \ - do_bool_flag(RestrictContended) \ - do_intx_flag(StackReservedPages) \ - do_intx_flag(StackShadowPages) \ - do_uintx_flag(TLABWasteIncrement) \ - do_intx_flag(TypeProfileWidth) \ - do_bool_flag(UseAESIntrinsics) \ - X86_ONLY(do_int_flag(UseAVX)) \ - do_bool_flag(UseCRC32Intrinsics) \ - do_bool_flag(UseAdler32Intrinsics) \ - do_bool_flag(UseCompressedOops) \ - X86_ONLY(do_bool_flag(UseCountLeadingZerosInstruction)) \ - X86_ONLY(do_bool_flag(UseCountTrailingZerosInstruction)) \ - do_bool_flag(UseG1GC) \ - do_bool_flag(UseParallelGC) \ - do_bool_flag(UseSerialGC) \ - do_bool_flag(UseZGC) \ - do_bool_flag(UseEpsilonGC) \ - COMPILER2_PRESENT(do_bool_flag(UseMontgomeryMultiplyIntrinsic)) \ - COMPILER2_PRESENT(do_bool_flag(UseMontgomerySquareIntrinsic)) \ - COMPILER2_PRESENT(do_bool_flag(UseMulAddIntrinsic)) \ - COMPILER2_PRESENT(do_bool_flag(UseMultiplyToLenIntrinsic)) \ - do_bool_flag(UsePopCountInstruction) \ - do_bool_flag(UseSHA1Intrinsics) \ - do_bool_flag(UseSHA256Intrinsics) \ - do_bool_flag(UseSHA512Intrinsics) \ - X86_ONLY(do_int_flag(UseSSE)) \ - COMPILER2_PRESENT(do_bool_flag(UseSquareToLenIntrinsic)) \ - do_bool_flag(UseTLAB) \ - do_bool_flag(VerifyOops) \ - -#define BOXED_BOOLEAN(name, value) name = ((jboolean)(value) ? boxedTrue : boxedFalse) -#define BOXED_DOUBLE(name, value) do { jvalue p; p.d = (jdouble) (value); name = JVMCIENV->create_box(T_DOUBLE, &p, JVMCI_CHECK_NULL);} while(0) -#define BOXED_LONG(name, value) \ - do { \ - jvalue p; p.j = (jlong) (value); \ - JVMCIObject* e = longs.get(p.j); \ - if (e == nullptr) { \ - JVMCIObject h = JVMCIENV->create_box(T_LONG, &p, JVMCI_CHECK_NULL); \ - longs.put(p.j, h); \ - name = h; \ - } else { \ - name = (*e); \ - } \ - } while (0) - -#define CSTRING_TO_JSTRING(name, value) \ - JVMCIObject name; \ - do { \ - if (value != nullptr) { \ - JVMCIObject* e = strings.get(value); \ - if (e == nullptr) { \ - JVMCIObject h = JVMCIENV->create_string(value, JVMCI_CHECK_NULL); \ - strings.put(value, h); \ - name = h; \ - } else { \ - name = (*e); \ - } \ - } \ - } while (0) - -jobjectArray readConfiguration0(JNIEnv *env, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - HashTable longs; - HashTable strings; - - jvalue prim; - prim.z = true; JVMCIObject boxedTrue = JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL); - prim.z = false; JVMCIObject boxedFalse = JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL); - - CompilerToVM::Data::initialize(JVMCI_CHECK_NULL); - - JVMCIENV->VMField_initialize(JVMCI_CHECK_NULL); - JVMCIENV->VMFlag_initialize(JVMCI_CHECK_NULL); - JVMCIENV->VMIntrinsicMethod_initialize(JVMCI_CHECK_NULL); - - int len = JVMCIVMStructs::localHotSpotVMStructs_count(); - JVMCIObjectArray vmFields = JVMCIENV->new_VMField_array(len, JVMCI_CHECK_NULL); - for (int i = 0; i < len ; i++) { - VMStructEntry vmField = JVMCIVMStructs::localHotSpotVMStructs[i]; - const size_t name_buf_size = strlen(vmField.typeName) + strlen(vmField.fieldName) + 2 + 1 /* "::" */; - char* name_buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, name_buf_size); - os::snprintf_checked(name_buf, name_buf_size, "%s::%s", vmField.typeName, vmField.fieldName); - CSTRING_TO_JSTRING(name, name_buf); - CSTRING_TO_JSTRING(type, vmField.typeString); - JVMCIObject box; - if (vmField.isStatic && vmField.typeString != nullptr) { - if (strcmp(vmField.typeString, "bool") == 0) { - BOXED_BOOLEAN(box, *(jbyte*) vmField.address); - assert(box.is_non_null(), "must have a box"); - } else if (strcmp(vmField.typeString, "int") == 0 || - strcmp(vmField.typeString, "jint") == 0 || - strcmp(vmField.typeString, "uint") == 0 || - strcmp(vmField.typeString, "uint32_t") == 0) { - BOXED_LONG(box, *(jint*) vmField.address); - assert(box.is_non_null(), "must have a box"); - } else if (strcmp(vmField.typeString, "uint64_t") == 0) { - BOXED_LONG(box, *(uint64_t*) vmField.address); - assert(box.is_non_null(), "must have a box"); - } else if (strcmp(vmField.typeString, "address") == 0 || - strcmp(vmField.typeString, "intptr_t") == 0 || - strcmp(vmField.typeString, "uintptr_t") == 0 || - strcmp(vmField.typeString, "OopHandle") == 0 || - strcmp(vmField.typeString, "VM_Version::VM_Features") == 0 || - strcmp(vmField.typeString, "size_t") == 0 || - // All foo* types are addresses. - vmField.typeString[strlen(vmField.typeString) - 1] == '*') { - BOXED_LONG(box, *((address*) vmField.address)); - assert(box.is_non_null(), "must have a box"); - } else { - JVMCI_ERROR_NULL("VM field %s has unsupported type %s", name_buf, vmField.typeString); - } - } - JVMCIObject vmFieldObj = JVMCIENV->new_VMField(name, type, vmField.offset, (jlong) vmField.address, box, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(vmFields, i, vmFieldObj); - } - - int ints_len = JVMCIVMStructs::localHotSpotVMIntConstants_count(); - int longs_len = JVMCIVMStructs::localHotSpotVMLongConstants_count(); - len = ints_len + longs_len; - JVMCIObjectArray vmConstants = JVMCIENV->new_Object_array(len * 2, JVMCI_CHECK_NULL); - int insert = 0; - for (int i = 0; i < ints_len ; i++) { - VMIntConstantEntry c = JVMCIVMStructs::localHotSpotVMIntConstants[i]; - CSTRING_TO_JSTRING(name, c.name); - JVMCIObject value; - BOXED_LONG(value, c.value); - JVMCIENV->put_object_at(vmConstants, insert++, name); - JVMCIENV->put_object_at(vmConstants, insert++, value); - } - for (int i = 0; i < longs_len ; i++) { - VMLongConstantEntry c = JVMCIVMStructs::localHotSpotVMLongConstants[i]; - CSTRING_TO_JSTRING(name, c.name); - JVMCIObject value; - BOXED_LONG(value, c.value); - JVMCIENV->put_object_at(vmConstants, insert++, name); - JVMCIENV->put_object_at(vmConstants, insert++, value); - } - assert(insert == len * 2, "must be"); - - len = JVMCIVMStructs::localHotSpotVMAddresses_count(); - JVMCIObjectArray vmAddresses = JVMCIENV->new_Object_array(len * 2, JVMCI_CHECK_NULL); - for (int i = 0; i < len ; i++) { - VMAddressEntry a = JVMCIVMStructs::localHotSpotVMAddresses[i]; - CSTRING_TO_JSTRING(name, a.name); - JVMCIObject value; - BOXED_LONG(value, a.value); - JVMCIENV->put_object_at(vmAddresses, i * 2, name); - JVMCIENV->put_object_at(vmAddresses, i * 2 + 1, value); - } - -#define COUNT_FLAG(ignore) +1 -#ifdef ASSERT -#define CHECK_FLAG(type, name) { \ - const JVMFlag* flag = JVMFlag::find_declared_flag(#name); \ - assert(flag != nullptr, "No such flag named " #name); \ - assert(flag->is_##type(), "JVMFlag " #name " is not of type " #type); \ -} -#else -#define CHECK_FLAG(type, name) -#endif - -#define ADD_FLAG(type, name, convert) { \ - CHECK_FLAG(type, name) \ - CSTRING_TO_JSTRING(fname, #name); \ - CSTRING_TO_JSTRING(ftype, #type); \ - convert(value, name); \ - JVMCIObject vmFlagObj = JVMCIENV->new_VMFlag(fname, ftype, value, JVMCI_CHECK_NULL); \ - JVMCIENV->put_object_at(vmFlags, i++, vmFlagObj); \ -} -#define ADD_BOOL_FLAG(name) ADD_FLAG(bool, name, BOXED_BOOLEAN) -#define ADD_UINT_FLAG(name) ADD_FLAG(uint, name, BOXED_LONG) -#define ADD_INT_FLAG(name) ADD_FLAG(int, name, BOXED_LONG) -#define ADD_SIZE_T_FLAG(name) ADD_FLAG(size_t, name, BOXED_LONG) -#define ADD_INTX_FLAG(name) ADD_FLAG(intx, name, BOXED_LONG) -#define ADD_UINTX_FLAG(name) ADD_FLAG(uintx, name, BOXED_LONG) - - len = 0 + PREDEFINED_CONFIG_FLAGS(COUNT_FLAG, COUNT_FLAG, COUNT_FLAG, COUNT_FLAG, COUNT_FLAG, COUNT_FLAG); - JVMCIObjectArray vmFlags = JVMCIENV->new_VMFlag_array(len, JVMCI_CHECK_NULL); - int i = 0; - JVMCIObject value; - PREDEFINED_CONFIG_FLAGS(ADD_BOOL_FLAG, ADD_UINT_FLAG, ADD_INT_FLAG, ADD_SIZE_T_FLAG, ADD_INTX_FLAG, ADD_UINTX_FLAG) - - JVMCIObjectArray vmIntrinsics = CompilerToVM::initialize_intrinsics(JVMCI_CHECK_NULL); - - JVMCIObjectArray data = JVMCIENV->new_Object_array(5, JVMCI_CHECK_NULL); - JVMCIENV->put_object_at(data, 0, vmFields); - JVMCIENV->put_object_at(data, 1, vmConstants); - JVMCIENV->put_object_at(data, 2, vmAddresses); - JVMCIENV->put_object_at(data, 3, vmFlags); - JVMCIENV->put_object_at(data, 4, vmIntrinsics); - - return JVMCIENV->get_jobjectArray(data); -} diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp deleted file mode 100644 index d8287dad198..00000000000 --- a/src/hotspot/share/jvmci/jvmciEnv.cpp +++ /dev/null @@ -1,2015 +0,0 @@ -/* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "classfile/stringTable.hpp" -#include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" -#include "code/codeCache.hpp" -#include "compiler/compilerOracle.hpp" -#include "compiler/compileTask.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "jvm_io.h" -#include "jvmci/jniAccessMark.inline.hpp" -#include "jvmci/jvmciCompiler.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "memory/oopFactory.hpp" -#include "memory/resourceArea.hpp" -#include "memory/universe.hpp" -#include "oops/objArrayKlass.hpp" -#include "oops/typeArrayOop.inline.hpp" -#include "prims/jvmtiExport.hpp" -#include "runtime/arguments.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/fieldDescriptor.inline.hpp" -#include "runtime/javaCalls.hpp" -#include "runtime/jniHandles.inline.hpp" -#include "runtime/os.hpp" -#include "utilities/permitForbiddenFunctions.hpp" - -JVMCICompileState::JVMCICompileState(CompileTask* task, JVMCICompiler* compiler): - _task(task), - _compiler(compiler), - _retryable(true), - _failure_reason(nullptr), - _failure_reason_on_C_heap(false) { - // Get Jvmti capabilities under lock to get consistent values. - MutexLocker mu(JvmtiThreadState_lock); - _jvmti_redefinition_count = JvmtiExport::redefinition_count(); - _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint() ? 1 : 0; - _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables() ? 1 : 0; - _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions() ? 1 : 0; - _jvmti_can_pop_frame = JvmtiExport::can_pop_frame() ? 1 : 0; - _target_method_is_old = _task != nullptr && _task->method()->is_old(); - if (task->is_blocking()) { - task->set_blocking_jvmci_compile_state(this); - } -} - -void JVMCICompileState::set_failure(bool retryable, const char* reason, bool reason_on_C_heap) { - if (_failure_reason != nullptr && _failure_reason_on_C_heap) { - os::free((void*) _failure_reason); - } - _failure_reason = reason; - _failure_reason_on_C_heap = reason_on_C_heap; - _retryable = retryable; -} - -void JVMCICompileState::notify_libjvmci_oome() { - const char* msg = "Out of memory initializing libjvmci or attaching it to the current thread"; - set_failure(true, msg); - _compiler->on_upcall(msg); -} - -// Update global JVMCI compilation ticks after 512 thread-local JVMCI compilation ticks. -// This mitigates the overhead of the atomic operation used for the global update. -#define THREAD_TICKS_PER_GLOBAL_TICKS (2 << 9) -#define THREAD_TICKS_PER_GLOBAL_TICKS_MASK (THREAD_TICKS_PER_GLOBAL_TICKS - 1) - -void JVMCICompileState::inc_compilation_ticks() { - if ((++_compilation_ticks & THREAD_TICKS_PER_GLOBAL_TICKS_MASK) == 0) { - _compiler->inc_global_compilation_ticks(); - } -} - -bool JVMCICompileState::jvmti_state_changed() const { - // Some classes were redefined - if (jvmti_redefinition_count() != JvmtiExport::redefinition_count()) { - return true; - } - if (!jvmti_can_access_local_variables() && - JvmtiExport::can_access_local_variables()) { - return true; - } - if (!jvmti_can_hotswap_or_post_breakpoint() && - JvmtiExport::can_hotswap_or_post_breakpoint()) { - return true; - } - if (!jvmti_can_post_on_exceptions() && - JvmtiExport::can_post_on_exceptions()) { - return true; - } - if (!jvmti_can_pop_frame() && - JvmtiExport::can_pop_frame()) { - return true; - } - return false; -} - -void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) { - assert(thread != nullptr, "npe"); - _env = nullptr; - _pop_frame_on_close = false; - _detach_on_close = false; - if (!UseJVMCINativeLibrary) { - // In HotSpot mode, JNI isn't used at all. - _runtime = JVMCI::java_runtime(); - _is_hotspot = true; - return; - } - - if (parent_env != nullptr) { - // If the parent JNI environment is non-null then figure out whether it - // is a HotSpot or shared library JNIEnv and set the state appropriately. - _is_hotspot = thread->jni_environment() == parent_env; - if (_is_hotspot) { - // Select the Java runtime - _runtime = JVMCI::java_runtime(); - return; - } - _runtime = thread->libjvmci_runtime(); - assert(_runtime != nullptr, "npe"); - _env = parent_env; - return; - } - - // Running in JVMCI shared library mode so ensure the shared library - // is loaded and initialized and get a shared library JNIEnv - _is_hotspot = false; - - _runtime = JVMCI::compiler_runtime(thread); - _env = _runtime->init_shared_library_javavm(&_init_error, &_init_error_msg); - if (_env != nullptr) { - // Creating the JVMCI shared library VM also attaches the current thread - _detach_on_close = true; - } else if (_init_error != JNI_OK) { - // Caller creating this JVMCIEnv must handle the error. - JVMCI_event_1("[%s:%d] Error creating libjvmci (err: %d, %s)", _file, _line, - _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg); - return; - } else { - _runtime->GetEnv(thread, (void**)&parent_env, JNI_VERSION_1_2); - if (parent_env != nullptr) { - // Even though there's a parent JNI env, there's no guarantee - // it was opened by a JVMCIEnv scope and thus may not have - // pushed a local JNI frame. As such, we use a new JNI local - // frame in this scope to ensure local JNI refs are collected - // in a timely manner after leaving this scope. - _env = parent_env; - } else { - ResourceMark rm; // Thread name is resource allocated - JavaVMAttachArgs attach_args; - attach_args.version = JNI_VERSION_1_2; - attach_args.name = const_cast(thread->name()); - attach_args.group = nullptr; - _init_error = _runtime->AttachCurrentThread(thread, (void**) &_env, &attach_args); - if (_init_error == JNI_OK) { - _detach_on_close = true; - } else { - // Caller creating this JVMCIEnv must handle the error. - _env = nullptr; - JVMCI_event_1("[%s:%d] Error attaching to libjvmci (err: %d)", _file, _line, _init_error); - return; - } - } - } - - assert(_env != nullptr, "missing env"); - assert(_throw_to_caller == false, "must be"); - - JNIAccessMark jni(this, thread); - jint result = _env->PushLocalFrame(32); - if (result != JNI_OK) { - JVMCI_event_1("[%s:%d] Error pushing local JNI frame (err: %d)", _file, _line, result); - return; - } - _pop_frame_on_close = true; -} - -JVMCIEnv::JVMCIEnv(JavaThread* thread, JVMCICompileState* compile_state, const char* file, int line): - _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(compile_state) { - init_env_mode_runtime(thread, nullptr); -} - -JVMCIEnv::JVMCIEnv(JavaThread* thread, const char* file, int line): - _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) { - init_env_mode_runtime(thread, nullptr); -} - -JVMCIEnv::JVMCIEnv(JavaThread* thread, JNIEnv* parent_env, const char* file, int line): - _throw_to_caller(true), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) { - assert(parent_env != nullptr, "npe"); - init_env_mode_runtime(thread, parent_env); - assert(_env == nullptr || parent_env == _env, "mismatched JNIEnvironment"); - assert(_init_error == JNI_OK, "err: %d", _init_error); -} - -void JVMCIEnv::init(JavaThread* thread, bool is_hotspot, const char* file, int line) { - _compile_state = nullptr; - _throw_to_caller = false; - _file = file; - _line = line; - _init_error = JNI_OK; - _init_error_msg = nullptr; - if (is_hotspot) { - _env = nullptr; - _pop_frame_on_close = false; - _detach_on_close = false; - _is_hotspot = true; - _runtime = JVMCI::java_runtime(); - } else { - init_env_mode_runtime(thread, nullptr); - } -} - -void JVMCIEnv::check_init(JVMCI_TRAPS) { - guarantee(JVMCIENV != this, "must be"); - if (_init_error == JNI_OK) { - return; - } - if (_init_error == JNI_ENOMEM) { - JVMCI_THROW_MSG(OutOfMemoryError, "JNI_ENOMEM creating or attaching to libjvmci"); - } - stringStream st; - st.print("Error creating or attaching to libjvmci (err: %d, description: %s)", - _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg); - JVMCI_THROW_MSG(InternalError, st.freeze()); -} - -void JVMCIEnv::check_init(TRAPS) { - if (_init_error == JNI_OK) { - return; - } - stringStream st; - st.print("Error creating or attaching to libjvmci (err: %d, description: %s)", - _init_error, _init_error_msg != nullptr ? _init_error_msg : (_init_error == JNI_ENOMEM ? "JNI_ENOMEM" : "none")); - THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), st.freeze()); -} - -// Prints a pending exception (if any) and its stack trace to st. -// Also partially logs the stack trace to the JVMCI event log. -void JVMCIEnv::describe_pending_exception(outputStream* st) { - ResourceMark rm; - char* stack_trace = nullptr; - if (pending_exception_as_string(nullptr, (const char**) &stack_trace)) { - st->print_raw_cr(stack_trace); - - // Use up to half the lines of the JVMCI event log to - // show the stack trace. - char* cursor = stack_trace; - int line = 0; - const int max_lines = LogEventsBufferEntries / 2; - char* last_line = nullptr; - while (*cursor != '\0') { - char* eol = strchr(cursor, '\n'); - if (eol == nullptr) { - if (line == max_lines - 1) { - last_line = cursor; - } else if (line < max_lines) { - JVMCI_event_1("%s", cursor); - } - cursor = cursor + strlen(cursor); - } else { - *eol = '\0'; - if (line == max_lines - 1) { - last_line = cursor; - } else if (line < max_lines) { - JVMCI_event_1("%s", cursor); - } - cursor = eol + 1; - } - line++; - } - if (last_line != nullptr) { - if (line > max_lines) { - JVMCI_event_1("%s [elided %d more stack trace lines]", last_line, line - max_lines); - } else { - JVMCI_event_1("%s", last_line); - } - } - } -} - -bool JVMCIEnv::pending_exception_as_string(const char** to_string, const char** stack_trace) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - JVMCIObject to_string_obj; - JVMCIObject stack_trace_obj; - bool had_nested_exception = false; - if (!is_hotspot()) { - JNIAccessMark jni(this, THREAD); - jthrowable ex = jni()->ExceptionOccurred(); - if (ex != nullptr) { - jni()->ExceptionClear(); - jobjectArray pair = (jobjectArray) jni()->CallStaticObjectMethod( - JNIJVMCI::HotSpotJVMCIRuntime::clazz(), - JNIJVMCI::HotSpotJVMCIRuntime::exceptionToString_method(), - ex, to_string != nullptr, stack_trace != nullptr); - if (jni()->ExceptionCheck()) { - // As last resort, dump nested exception - jni()->ExceptionDescribe(); - had_nested_exception = true; - } else { - guarantee(pair != nullptr, "pair is null"); - int len = jni()->GetArrayLength(pair); - guarantee(len == 2, "bad len is %d", len); - if (to_string != nullptr) { - to_string_obj = JVMCIObject::create(jni()->GetObjectArrayElement(pair, 0), false); - } - if (stack_trace != nullptr) { - stack_trace_obj = JVMCIObject::create(jni()->GetObjectArrayElement(pair, 1), false); - } - } - } else { - return false; - } - } else { - if (HAS_PENDING_EXCEPTION) { - Handle exception(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - JavaCallArguments jargs; - jargs.push_oop(exception); - jargs.push_int(to_string != nullptr); - jargs.push_int(stack_trace != nullptr); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, - HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), - vmSymbols::exceptionToString_name(), - vmSymbols::exceptionToString_signature(), &jargs, THREAD); - if (HAS_PENDING_EXCEPTION) { - Handle nested_exception(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - java_lang_Throwable::print_stack_trace(nested_exception, tty); - // Clear and ignore any exceptions raised during printing - CLEAR_PENDING_EXCEPTION; - had_nested_exception = true; - } else { - oop pair = result.get_oop(); - guarantee(pair->is_objArray(), "must be"); - objArrayOop pair_arr = objArrayOop(pair); - int len = pair_arr->length(); - guarantee(len == 2, "bad len is %d", len); - if (to_string != nullptr) { - to_string_obj = HotSpotJVMCI::wrap(pair_arr->obj_at(0)); - } - if (stack_trace != nullptr) { - stack_trace_obj = HotSpotJVMCI::wrap(pair_arr->obj_at(1)); - } - } - } else { - return false; - } - } - if (had_nested_exception) { - if (to_string != nullptr) { - *to_string = "nested exception occurred converting exception to string"; - } - if (stack_trace != nullptr) { - *stack_trace = "nested exception occurred converting exception stack to string"; - } - } else { - if (to_string_obj.is_non_null()) { - *to_string = as_utf8_string(to_string_obj); - } - if (stack_trace_obj.is_non_null()) { - *stack_trace = as_utf8_string(stack_trace_obj); - } - } - return true; -} - - -// Shared code for translating an exception from HotSpot to libjvmci or vice versa. -class ExceptionTranslation: public StackObj { - protected: - enum DecodeFormat { - _encoded_ok = 0, // exception was successfully encoded into buffer - _buffer_alloc_fail = 1, // native memory for buffer could not be allocated - _encode_oome_fail = 2, // OutOfMemoryError thrown during encoding - _encode_fail = 3, // some other problem occured during encoding. If buffer != 0, - // buffer contains a `struct { u4 len; char[len] desc}` - // describing the problem - _encode_oome_in_vm = 4 // an OutOfMemoryError thrown from within VM code on a - // thread that cannot call Java (OOME has no stack trace) - }; - - JVMCIEnv* _from_env; // Source of translation. Can be null. - JVMCIEnv* _to_env; // Destination of translation. Never null. - - ExceptionTranslation(JVMCIEnv* from_env, JVMCIEnv* to_env) : _from_env(from_env), _to_env(to_env) {} - - // Encodes the exception in `_from_env` into `buffer`. - // Where N is the number of bytes needed for the encoding, returns N if N <= `buffer_size` - // and the encoding was written to `buffer` otherwise returns -N. - virtual int encode(JavaThread* THREAD, jlong buffer, int buffer_size) = 0; - - // Decodes the exception in `buffer` in `_to_env` and throws it. - virtual void decode(JavaThread* THREAD, DecodeFormat format, jlong buffer) = 0; - - static bool debug_translated_exception() { - const char* prop_value = Arguments::get_property("jdk.internal.vm.TranslatedException.debug"); - return prop_value != nullptr && strcmp("true", prop_value) == 0; - } - - public: - void doit(JavaThread* THREAD) { - int buffer_size = 2048; - while (true) { - ResourceMark rm; - jlong buffer = (jlong) NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(THREAD, jbyte, buffer_size); - if (buffer == 0L) { - JVMCI_event_1("error translating exception: translation buffer allocation failed"); - decode(THREAD, _buffer_alloc_fail, 0L); - return; - } - int res = encode(THREAD, buffer, buffer_size); - if (_to_env->has_pending_exception()) { - // Propagate pending exception - return; - } - if (res < 0) { - int required_buffer_size = -res; - if (required_buffer_size > buffer_size) { - buffer_size = required_buffer_size; - } - } else { - decode(THREAD, _encoded_ok, buffer); - if (!_to_env->has_pending_exception()) { - _to_env->throw_InternalError("decodeAndThrowThrowable should have thrown an exception"); - } - return; - } - } - } -}; - -// Translates an exception on the HotSpot heap to an exception on the shared library heap. -class HotSpotToSharedLibraryExceptionTranslation : public ExceptionTranslation { - private: - const Handle& _throwable; - - char* print_throwable_to_buffer(Handle throwable, jlong buffer, int buffer_size) { - char* char_buffer = (char*) buffer + 4; - stringStream st(char_buffer, (size_t) buffer_size - 4); - java_lang_Throwable::print_stack_trace(throwable, &st); - u4 len = (u4) st.size(); - *((u4*) buffer) = len; - return char_buffer; - } - - bool handle_pending_exception(JavaThread* THREAD, jlong buffer, int buffer_size) { - if (HAS_PENDING_EXCEPTION) { - Handle throwable = Handle(THREAD, PENDING_EXCEPTION); - Symbol *ex_name = throwable->klass()->name(); - CLEAR_PENDING_EXCEPTION; - if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { - JVMCI_event_1("error translating exception: OutOfMemoryError"); - decode(THREAD, _encode_oome_fail, 0L); - } else { - char* char_buffer = print_throwable_to_buffer(throwable, buffer, buffer_size); - JVMCI_event_1("error translating exception: %s", char_buffer); - decode(THREAD, _encode_fail, buffer); - } - return true; - } - return false; - } - - int encode(JavaThread* THREAD, jlong buffer, int buffer_size) { - if (!THREAD->can_call_java()) { - Symbol *ex_name = _throwable->klass()->name(); - if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { - JVMCI_event_1("translating exception: OutOfMemoryError within VM code"); - decode(THREAD, _encode_oome_in_vm, 0L); - return 0; - } - char* char_buffer = print_throwable_to_buffer(_throwable, buffer, buffer_size); - const char* detail = log_is_enabled(Info, exceptions) ? "" : " (-Xlog:exceptions may give more detail)"; - JVMCI_event_1("cannot call Java to translate exception%s: %s", detail, char_buffer); - decode(THREAD, _encode_fail, buffer); - return 0; - } - Klass* vmSupport = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_VMSupport(), true, THREAD); - if (handle_pending_exception(THREAD, buffer, buffer_size)) { - return 0; - } - JavaCallArguments jargs; - jargs.push_oop(_throwable); - jargs.push_long(buffer); - jargs.push_int(buffer_size); - JavaValue result(T_INT); - JavaCalls::call_static(&result, - vmSupport, - vmSymbols::encodeThrowable_name(), - vmSymbols::encodeThrowable_signature(), &jargs, THREAD); - if (handle_pending_exception(THREAD, buffer, buffer_size)) { - return 0; - } - return result.get_jint(); - } - - void decode(JavaThread* THREAD, DecodeFormat format, jlong buffer) { - JVMCI_event_1("decoding exception from JVM heap (format: %d, buffer[%d]) ", format, buffer == 0L ? -1 : *((u4*) buffer)); - JNIAccessMark jni(_to_env, THREAD); - jni()->CallStaticVoidMethod(JNIJVMCI::VMSupport::clazz(), - JNIJVMCI::VMSupport::decodeAndThrowThrowable_method(), - format, buffer, false, debug_translated_exception()); - } - public: - HotSpotToSharedLibraryExceptionTranslation(JVMCIEnv* hotspot_env, JVMCIEnv* jni_env, const Handle& throwable) : - ExceptionTranslation(hotspot_env, jni_env), _throwable(throwable) {} -}; - -// Translates an exception on the shared library heap to an exception on the HotSpot heap. -class SharedLibraryToHotSpotExceptionTranslation : public ExceptionTranslation { - private: - jthrowable _throwable; - - int encode(JavaThread* THREAD, jlong buffer, int buffer_size) { - JNIAccessMark jni(_from_env, THREAD); - int res = jni()->CallStaticIntMethod(JNIJVMCI::VMSupport::clazz(), - JNIJVMCI::VMSupport::encodeThrowable_method(), - _throwable, buffer, buffer_size); - if (jni()->ExceptionCheck()) { - // Cannot get name of exception thrown as that can raise another exception. - jni()->ExceptionClear(); - JVMCI_event_1("error translating exception: unknown error"); - decode(THREAD, _encode_fail, 0L); - return 0; - } - return res; - } - - void decode(JavaThread* THREAD, DecodeFormat format, jlong buffer) { - JVMCI_event_1("decoding exception to JVM heap (format: %d, buffer[%d]) ", format, buffer == 0L ? -1 : *((u4*) buffer)); - Klass* vmSupport = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_VMSupport(), true, CHECK); - JavaCallArguments jargs; - jargs.push_int(format); - jargs.push_long(buffer); - jargs.push_int(true); - jargs.push_int(debug_translated_exception()); - JavaValue result(T_VOID); - JavaCalls::call_static(&result, - vmSupport, - vmSymbols::decodeAndThrowThrowable_name(), - vmSymbols::decodeAndThrowThrowable_signature(), &jargs, THREAD); - } - public: - SharedLibraryToHotSpotExceptionTranslation(JVMCIEnv* hotspot_env, JVMCIEnv* jni_env, jthrowable throwable) : - ExceptionTranslation(jni_env, hotspot_env), _throwable(throwable) {} -}; - -void JVMCIEnv::translate_to_jni_exception(JavaThread* THREAD, const Handle& throwable, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env) { - HotSpotToSharedLibraryExceptionTranslation(hotspot_env, jni_env, throwable).doit(THREAD); -} - -void JVMCIEnv::translate_from_jni_exception(JavaThread* THREAD, jthrowable throwable, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env) { - SharedLibraryToHotSpotExceptionTranslation(hotspot_env, jni_env, throwable).doit(THREAD); -} - -jboolean JVMCIEnv::transfer_pending_exception_to_jni(JavaThread* THREAD, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env) { - if (HAS_PENDING_EXCEPTION) { - Handle throwable = Handle(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - translate_to_jni_exception(THREAD, throwable, hotspot_env, jni_env); - return true; - } - return false; -} - -jboolean JVMCIEnv::transfer_pending_exception(JavaThread* THREAD, JVMCIEnv* peer_env) { - if (is_hotspot()) { - return transfer_pending_exception_to_jni(THREAD, this, peer_env); - } - jthrowable ex = nullptr; - { - JNIAccessMark jni(this, THREAD); - ex = jni()->ExceptionOccurred(); - if (ex != nullptr) { - jni()->ExceptionClear(); - } - } - if (ex != nullptr) { - translate_from_jni_exception(THREAD, ex, peer_env, this); - return true; - } - return false; -} - -JVMCIEnv::~JVMCIEnv() { - if (_init_error_msg != nullptr) { - // The memory allocated in libjvmci was not allocated with os::malloc - // so must not be freed with os::free. - permit_forbidden_function::free((void*)_init_error_msg); - } - if (_init_error != JNI_OK) { - return; - } - if (_throw_to_caller) { - if (is_hotspot()) { - // Nothing to do - } else { - Thread* thread = Thread::current(); - if (thread->is_Java_thread()) { - JavaThread* THREAD = JavaThread::cast(thread); // For exception macros. - if (HAS_PENDING_EXCEPTION) { - Handle throwable = Handle(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - translate_to_jni_exception(THREAD, throwable, nullptr, this); - } - } - } - } else { - if (_pop_frame_on_close) { - // Pop the JNI local frame that was pushed when entering this JVMCIEnv scope. - JNIAccessMark jni(this); - jni()->PopLocalFrame(nullptr); - } - - if (has_pending_exception()) { - char message[256]; - jio_snprintf(message, 256, "Uncaught exception exiting %s JVMCIEnv scope entered at %s:%d", - is_hotspot() ? "HotSpot" : "libjvmci", _file, _line); - JVMCIRuntime::fatal_exception(this, message); - } - - if (_detach_on_close) { - _runtime->DetachCurrentThread(JavaThread::current()); - } - } -} - -jboolean JVMCIEnv::has_pending_exception() { - if (is_hotspot()) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - return HAS_PENDING_EXCEPTION; - } else { - JNIAccessMark jni(this); - return jni()->ExceptionCheck(); - } -} - -void JVMCIEnv::clear_pending_exception() { - if (is_hotspot()) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - CLEAR_PENDING_EXCEPTION; - } else { - JNIAccessMark jni(this); - jni()->ExceptionClear(); - } -} - -int JVMCIEnv::get_length(JVMCIArray array) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(array)->length(); - } else { - JNIAccessMark jni(this); - return jni()->GetArrayLength(get_jarray(array)); - } -} - -JVMCIObject JVMCIEnv::get_object_at(JVMCIObjectArray array, int index) { - if (is_hotspot()) { - oop result = HotSpotJVMCI::resolve(array)->obj_at(index); - return wrap(result); - } else { - JNIAccessMark jni(this); - jobject result = jni()->GetObjectArrayElement(get_jobjectArray(array), index); - return wrap(result); - } -} - -void JVMCIEnv::put_object_at(JVMCIObjectArray array, int index, JVMCIObject value) { - if (is_hotspot()) { - HotSpotJVMCI::resolve(array)->obj_at_put(index, HotSpotJVMCI::resolve(value)); - } else { - JNIAccessMark jni(this); - jni()->SetObjectArrayElement(get_jobjectArray(array), index, get_jobject(value)); - } -} - -jboolean JVMCIEnv::get_bool_at(JVMCIPrimitiveArray array, int index) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(array)->bool_at(index); - } else { - JNIAccessMark jni(this); - jboolean result; - jni()->GetBooleanArrayRegion(array.as_jbooleanArray(), index, 1, &result); - return result; - } -} -void JVMCIEnv::put_bool_at(JVMCIPrimitiveArray array, int index, jboolean value) { - if (is_hotspot()) { - HotSpotJVMCI::resolve(array)->bool_at_put(index, value); - } else { - JNIAccessMark jni(this); - jni()->SetBooleanArrayRegion(array.as_jbooleanArray(), index, 1, &value); - } -} - -jbyte JVMCIEnv::get_byte_at(JVMCIPrimitiveArray array, int index) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(array)->byte_at(index); - } else { - JNIAccessMark jni(this); - jbyte result; - jni()->GetByteArrayRegion(array.as_jbyteArray(), index, 1, &result); - return result; - } -} -void JVMCIEnv::put_byte_at(JVMCIPrimitiveArray array, int index, jbyte value) { - if (is_hotspot()) { - HotSpotJVMCI::resolve(array)->byte_at_put(index, value); - } else { - JNIAccessMark jni(this); - jni()->SetByteArrayRegion(array.as_jbyteArray(), index, 1, &value); - } -} - -jint JVMCIEnv::get_int_at(JVMCIPrimitiveArray array, int index) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(array)->int_at(index); - } else { - JNIAccessMark jni(this); - jint result; - jni()->GetIntArrayRegion(array.as_jintArray(), index, 1, &result); - return result; - } -} -void JVMCIEnv::put_int_at(JVMCIPrimitiveArray array, int index, jint value) { - if (is_hotspot()) { - HotSpotJVMCI::resolve(array)->int_at_put(index, value); - } else { - JNIAccessMark jni(this); - jni()->SetIntArrayRegion(array.as_jintArray(), index, 1, &value); - } -} - -jlong JVMCIEnv::get_long_at(JVMCIPrimitiveArray array, int index) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(array)->long_at(index); - } else { - JNIAccessMark jni(this); - jlong result; - jni()->GetLongArrayRegion(array.as_jlongArray(), index, 1, &result); - return result; - } -} -void JVMCIEnv::put_long_at(JVMCIPrimitiveArray array, int index, jlong value) { - if (is_hotspot()) { - HotSpotJVMCI::resolve(array)->long_at_put(index, value); - } else { - JNIAccessMark jni(this); - jni()->SetLongArrayRegion(array.as_jlongArray(), index, 1, &value); - } -} - -void JVMCIEnv::copy_bytes_to(JVMCIPrimitiveArray src, jbyte* dest, int offset, jsize length) { - if (length == 0) { - return; - } - if (is_hotspot()) { - memcpy(dest, HotSpotJVMCI::resolve(src)->byte_at_addr(offset), length); - } else { - JNIAccessMark jni(this); - jni()->GetByteArrayRegion(src.as_jbyteArray(), offset, length, dest); - } -} -void JVMCIEnv::copy_bytes_from(jbyte* src, JVMCIPrimitiveArray dest, int offset, jsize length) { - if (length == 0) { - return; - } - if (is_hotspot()) { - memcpy(HotSpotJVMCI::resolve(dest)->byte_at_addr(offset), src, length); - } else { - JNIAccessMark jni(this); - jni()->SetByteArrayRegion(dest.as_jbyteArray(), offset, length, src); - } -} - -void JVMCIEnv::copy_longs_from(jlong* src, JVMCIPrimitiveArray dest, int offset, jsize length) { - if (length == 0) { - return; - } - if (is_hotspot()) { - memcpy(HotSpotJVMCI::resolve(dest)->long_at_addr(offset), src, length * sizeof(jlong)); - } else { - JNIAccessMark jni(this); - jni()->SetLongArrayRegion(dest.as_jlongArray(), offset, length, src); - } -} - -jboolean JVMCIEnv::is_boxing_object(BasicType type, JVMCIObject object) { - if (is_hotspot()) { - return java_lang_boxing_object::is_instance(HotSpotJVMCI::resolve(object), type); - } else { - JNIAccessMark jni(this); - return jni()->IsInstanceOf(get_jobject(object), JNIJVMCI::box_class(type)); - } -} - -// Get the primitive value from a Java boxing object. It's hard error to -// pass a non-primitive BasicType. -jvalue JVMCIEnv::get_boxed_value(BasicType type, JVMCIObject object) { - jvalue result; - if (is_hotspot()) { - if (java_lang_boxing_object::get_value(HotSpotJVMCI::resolve(object), &result) == T_ILLEGAL) { - ShouldNotReachHere(); - } - } else { - JNIAccessMark jni(this); - jfieldID field = JNIJVMCI::box_field(type); - switch (type) { - case T_BOOLEAN: result.z = jni()->GetBooleanField(get_jobject(object), field); break; - case T_BYTE: result.b = jni()->GetByteField(get_jobject(object), field); break; - case T_SHORT: result.s = jni()->GetShortField(get_jobject(object), field); break; - case T_CHAR: result.c = jni()->GetCharField(get_jobject(object), field); break; - case T_INT: result.i = jni()->GetIntField(get_jobject(object), field); break; - case T_LONG: result.j = jni()->GetLongField(get_jobject(object), field); break; - case T_FLOAT: result.f = jni()->GetFloatField(get_jobject(object), field); break; - case T_DOUBLE: result.d = jni()->GetDoubleField(get_jobject(object), field); break; - default: - ShouldNotReachHere(); - } - } - return result; -} - -// Return the BasicType of the object if it's a boxing object, otherwise return T_ILLEGAL. -BasicType JVMCIEnv::get_box_type(JVMCIObject object) { - if (is_hotspot()) { - return java_lang_boxing_object::basic_type(HotSpotJVMCI::resolve(object)); - } else { - JNIAccessMark jni(this); - jclass clazz = jni()->GetObjectClass(get_jobject(object)); - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_BOOLEAN))) return T_BOOLEAN; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_BYTE))) return T_BYTE; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_SHORT))) return T_SHORT; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_CHAR))) return T_CHAR; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_INT))) return T_INT; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_LONG))) return T_LONG; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_FLOAT))) return T_FLOAT; - if (jni()->IsSameObject(clazz, JNIJVMCI::box_class(T_DOUBLE))) return T_DOUBLE; - return T_ILLEGAL; - } -} - -// Create a boxing object of the appropriate primitive type. -JVMCIObject JVMCIEnv::create_box(BasicType type, jvalue* value, JVMCI_TRAPS) { - switch (type) { - case T_BOOLEAN: - case T_BYTE: - case T_CHAR: - case T_SHORT: - case T_INT: - case T_LONG: - case T_FLOAT: - case T_DOUBLE: - break; - default: - JVMCI_THROW_MSG_(IllegalArgumentException, "Only boxes for primitive values can be created", JVMCIObject()); - } - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - oop box = java_lang_boxing_object::create(type, value, CHECK_(JVMCIObject())); - return HotSpotJVMCI::wrap(box); - } else { - JNIAccessMark jni(this, THREAD); - jobject box = jni()->NewObjectA(JNIJVMCI::box_class(type), JNIJVMCI::box_constructor(type), value); - assert(box != nullptr, ""); - return wrap(box); - } -} - -const char* JVMCIEnv::as_utf8_string(JVMCIObject str) { - if (is_hotspot()) { - return java_lang_String::as_utf8_string(HotSpotJVMCI::resolve(str)); - } else { - JNIAccessMark jni(this); - jstring jstr = str.as_jstring(); - int length = jni()->GetStringLength(jstr); - int utf8_length = jni()->GetStringUTFLength(jstr); - char* result = NEW_RESOURCE_ARRAY(char, utf8_length + 1); - jni()->GetStringUTFRegion(jstr, 0, length, result); - return result; - } -} - -#define DO_THROW(name) \ -void JVMCIEnv::throw_##name(const char* msg) { \ - if (is_hotspot()) { \ - JavaThread* THREAD = JavaThread::current(); \ - THROW_MSG(HotSpotJVMCI::name::symbol(), msg); \ - } else { \ - JNIAccessMark jni(this); \ - jni()->ThrowNew(JNIJVMCI::name::clazz(), msg); \ - } \ -} - -DO_THROW(InternalError) -DO_THROW(ArrayIndexOutOfBoundsException) -DO_THROW(IllegalStateException) -DO_THROW(NullPointerException) -DO_THROW(IllegalArgumentException) -DO_THROW(InvalidInstalledCodeException) -DO_THROW(UnsatisfiedLinkError) -DO_THROW(UnsupportedOperationException) -DO_THROW(OutOfMemoryError) -DO_THROW(NoClassDefFoundError) - -#undef DO_THROW - -void JVMCIEnv::fthrow_error(const char* file, int line, const char* format, ...) { - const int max_msg_size = 1024; - va_list ap; - va_start(ap, format); - char msg[max_msg_size]; - (void) os::vsnprintf(msg, max_msg_size, format, ap); - va_end(ap); - JavaThread* THREAD = JavaThread::current(); - if (is_hotspot()) { - Handle h_loader; - Exceptions::_throw_msg(THREAD, file, line, vmSymbols::jdk_vm_ci_common_JVMCIError(), msg, h_loader ); - } else { - JNIAccessMark jni(this, THREAD); - jni()->ThrowNew(JNIJVMCI::JVMCIError::clazz(), msg); - } -} - -jboolean JVMCIEnv::call_HotSpotJVMCIRuntime_isGCSupported (JVMCIObject runtime, jint gcIdentifier) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - jargs.push_int(gcIdentifier); - JavaValue result(T_BOOLEAN); - JavaCalls::call_special(&result, - HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), - vmSymbols::isGCSupported_name(), - vmSymbols::int_bool_signature(), &jargs, CHECK_0); - return result.get_jboolean(); - } else { - JNIAccessMark jni(this, THREAD); - jboolean result = jni()->CallNonvirtualBooleanMethod(runtime.as_jobject(), - JNIJVMCI::HotSpotJVMCIRuntime::clazz(), - JNIJVMCI::HotSpotJVMCIRuntime::isGCSupported_method(), - gcIdentifier); - if (jni()->ExceptionCheck()) { - return false; - } - return result; - } -} - -jboolean JVMCIEnv::call_HotSpotJVMCIRuntime_isIntrinsicSupported (JVMCIObject runtime, jint intrinsicIdentifier) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - jargs.push_int(intrinsicIdentifier); - JavaValue result(T_BOOLEAN); - JavaCalls::call_special(&result, - HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), - vmSymbols::isIntrinsicSupported_name(), - vmSymbols::int_bool_signature(), &jargs, CHECK_0); - return result.get_jboolean(); - } else { - JNIAccessMark jni(this, THREAD); - jboolean result = jni()->CallNonvirtualBooleanMethod(runtime.as_jobject(), - JNIJVMCI::HotSpotJVMCIRuntime::clazz(), - JNIJVMCI::HotSpotJVMCIRuntime::isIntrinsicSupported_method(), - intrinsicIdentifier); - if (jni()->ExceptionCheck()) { - return false; - } - return result; - } -} - -JVMCIObject JVMCIEnv::call_HotSpotJVMCIRuntime_compileMethod (JVMCIObject runtime, JVMCIObject method, int entry_bci, - jlong compile_state, int id) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(method))); - jargs.push_int(entry_bci); - jargs.push_long(compile_state); - jargs.push_int(id); - JavaValue result(T_OBJECT); - JavaCalls::call_special(&result, - HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), - vmSymbols::compileMethod_name(), - vmSymbols::compileMethod_signature(), &jargs, CHECK_(JVMCIObject())); - return wrap(result.get_oop()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->CallNonvirtualObjectMethod(runtime.as_jobject(), - JNIJVMCI::HotSpotJVMCIRuntime::clazz(), - JNIJVMCI::HotSpotJVMCIRuntime::compileMethod_method(), - method.as_jobject(), entry_bci, compile_state, id); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return wrap(result); - } -} - -void JVMCIEnv::call_HotSpotJVMCIRuntime_bootstrapFinished (JVMCIObject runtime, JVMCIEnv* JVMCIENV) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), vmSymbols::bootstrapFinished_name(), vmSymbols::void_method_signature(), &jargs, CHECK); - } else { - JNIAccessMark jni(this, THREAD); - jni()->CallNonvirtualVoidMethod(runtime.as_jobject(), JNIJVMCI::HotSpotJVMCIRuntime::clazz(), JNIJVMCI::HotSpotJVMCIRuntime::bootstrapFinished_method()); - - } -} - -void JVMCIEnv::call_HotSpotJVMCIRuntime_shutdown (JVMCIObject runtime) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - HandleMark hm(THREAD); - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), vmSymbols::shutdown_name(), vmSymbols::void_method_signature(), &jargs, THREAD); - } else { - JNIAccessMark jni(this, THREAD); - jni()->CallNonvirtualVoidMethod(runtime.as_jobject(), JNIJVMCI::HotSpotJVMCIRuntime::clazz(), JNIJVMCI::HotSpotJVMCIRuntime::shutdown_method()); - } - if (has_pending_exception()) { - // This should never happen as HotSpotJVMCIRuntime.shutdown() should - // handle all exceptions. - describe_pending_exception(tty); - } -} - -JVMCIObject JVMCIEnv::call_HotSpotJVMCIRuntime_runtime (JVMCIEnv* JVMCIENV) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), vmSymbols::runtime_name(), vmSymbols::runtime_signature(), &jargs, CHECK_(JVMCIObject())); - return wrap(result.get_oop()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotJVMCIRuntime::clazz(), JNIJVMCI::HotSpotJVMCIRuntime::runtime_method()); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::call_JVMCI_getRuntime (JVMCIEnv* JVMCIENV) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, HotSpotJVMCI::JVMCI::klass(), vmSymbols::getRuntime_name(), vmSymbols::getRuntime_signature(), &jargs, CHECK_(JVMCIObject())); - return wrap(result.get_oop()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->CallStaticObjectMethod(JNIJVMCI::JVMCI::clazz(), JNIJVMCI::JVMCI::getRuntime_method()); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::call_HotSpotJVMCIRuntime_getCompiler (JVMCIObject runtime, JVMCIEnv* JVMCIENV) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(runtime))); - JavaValue result(T_OBJECT); - JavaCalls::call_virtual(&result, HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), vmSymbols::getCompiler_name(), vmSymbols::getCompiler_signature(), &jargs, CHECK_(JVMCIObject())); - return wrap(result.get_oop()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->CallObjectMethod(runtime.as_jobject(), JNIJVMCI::HotSpotJVMCIRuntime::getCompiler_method()); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return wrap(result); - } -} - -void JVMCIEnv::call_HotSpotJVMCIRuntime_postTranslation(JVMCIObject object, JVMCIEnv* JVMCIENV) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(object))); - JavaValue result(T_VOID); - JavaCalls::call_static(&result, - HotSpotJVMCI::HotSpotJVMCIRuntime::klass(), - vmSymbols::postTranslation_name(), - vmSymbols::object_void_signature(), &jargs, CHECK); - } else { - JNIAccessMark jni(this, THREAD); - jni()->CallStaticVoidMethod(JNIJVMCI::HotSpotJVMCIRuntime::clazz(), - JNIJVMCI::HotSpotJVMCIRuntime::postTranslation_method(), - object.as_jobject()); - } -} - -JVMCIObject JVMCIEnv::call_JavaConstant_forPrimitive(jchar type_char, jlong value, JVMCI_TRAPS) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaCallArguments jargs; - jargs.push_int(type_char); - jargs.push_long(value); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, - HotSpotJVMCI::JavaConstant::klass(), - vmSymbols::forPrimitive_name(), - vmSymbols::forPrimitive_signature(), &jargs, CHECK_(JVMCIObject())); - return wrap(result.get_oop()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = (jstring) jni()->CallStaticObjectMethod(JNIJVMCI::JavaConstant::clazz(), - JNIJVMCI::JavaConstant::forPrimitive_method(), - type_char, value); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::get_jvmci_primitive_type(BasicType type) { - JVMCIObjectArray primitives = get_HotSpotResolvedPrimitiveType_primitives(); - JVMCIObject result = get_object_at(primitives, type); - return result; -} - -JVMCIObject JVMCIEnv::new_StackTraceElement(const methodHandle& method, int bci, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - Symbol* file_name_sym; - int line_number; - java_lang_StackTraceElement::decode(method, bci, file_name_sym, line_number, CHECK_(JVMCIObject())); - - Symbol* method_name_sym = method->name(); - InstanceKlass* holder = method->method_holder(); - const char* declaring_class_str = holder->external_name(); - - if (is_hotspot()) { - HotSpotJVMCI::StackTraceElement::klass()->initialize(CHECK_(JVMCIObject())); - oop objOop = HotSpotJVMCI::StackTraceElement::klass()->allocate_instance(CHECK_(JVMCIObject())); - Handle obj = Handle(THREAD, objOop); - - oop declaring_class = StringTable::intern((char*) declaring_class_str, CHECK_(JVMCIObject())); - HotSpotJVMCI::StackTraceElement::set_declaringClass(this, obj(), declaring_class); - - oop method_name = StringTable::intern(method_name_sym, CHECK_(JVMCIObject())); - HotSpotJVMCI::StackTraceElement::set_methodName(this, obj(), method_name); - - if (file_name_sym != nullptr) { - oop file_name = StringTable::intern(file_name_sym, CHECK_(JVMCIObject())); - HotSpotJVMCI::StackTraceElement::set_fileName(this, obj(), file_name); - } - HotSpotJVMCI::StackTraceElement::set_lineNumber(this, obj(), line_number); - return wrap(obj()); - } else { - JNIAccessMark jni(this, THREAD); - jobject declaring_class = jni()->NewStringUTF(declaring_class_str); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - jobject method_name = jni()->NewStringUTF(method_name_sym->as_C_string()); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - jobject file_name = nullptr; - if (file_name_sym != nullptr) { - file_name = jni()->NewStringUTF(file_name_sym->as_C_string()); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - } - - jobject result = jni()->NewObject(JNIJVMCI::StackTraceElement::clazz(), - JNIJVMCI::StackTraceElement::constructor(), - declaring_class, method_name, file_name, line_number); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::new_HotSpotNmethod(const methodHandle& method, const char* name, jboolean isDefault, jboolean profileDeopt, jlong compileId, JVMCI_TRAPS) { - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - - JVMCIObject methodObject = get_jvmci_method(method, JVMCI_CHECK_(JVMCIObject())); - - if (is_hotspot()) { - InstanceKlass* ik = InstanceKlass::cast(HotSpotJVMCI::HotSpotNmethod::klass()); - if (ik->should_be_initialized()) { - ik->initialize(CHECK_(JVMCIObject())); - } - oop obj = ik->allocate_instance(CHECK_(JVMCIObject())); - Handle obj_h(THREAD, obj); - Handle nameStr = java_lang_String::create_from_str(name, CHECK_(JVMCIObject())); - - // Call constructor - JavaCallArguments jargs; - jargs.push_oop(obj_h); - jargs.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(methodObject))); - jargs.push_oop(nameStr); - jargs.push_int(isDefault); - jargs.push_int(profileDeopt); - jargs.push_long(compileId); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, ik, - vmSymbols::object_initializer_name(), - vmSymbols::method_string_bool_bool_long_signature(), - &jargs, CHECK_(JVMCIObject())); - return wrap(obj_h()); - } else { - JNIAccessMark jni(this, THREAD); - jobject nameStr = name == nullptr ? nullptr : jni()->NewStringUTF(name); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - - jobject result = jni()->NewObject(JNIJVMCI::HotSpotNmethod::clazz(), - JNIJVMCI::HotSpotNmethod::constructor(), - methodObject.as_jobject(), nameStr, isDefault); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::make_local(JVMCIObject object) { - if (object.is_null()) { - return JVMCIObject(); - } - if (is_hotspot()) { - return wrap(JNIHandles::make_local(HotSpotJVMCI::resolve(object))); - } else { - JNIAccessMark jni(this); - return wrap(jni()->NewLocalRef(object.as_jobject())); - } -} - -JVMCIObject JVMCIEnv::make_global(JVMCIObject object) { - if (object.is_null()) { - return JVMCIObject(); - } - if (is_hotspot()) { - return wrap(JNIHandles::make_global(Handle(Thread::current(), HotSpotJVMCI::resolve(object)))); - } else { - JNIAccessMark jni(this); - return wrap(jni()->NewGlobalRef(object.as_jobject())); - } -} - -void JVMCIEnv::destroy_local(JVMCIObject object) { - if (is_hotspot()) { - JNIHandles::destroy_local(object.as_jobject()); - } else { - JNIAccessMark jni(this); - jni()->DeleteLocalRef(object.as_jobject()); - } -} - -void JVMCIEnv::destroy_global(JVMCIObject object) { - if (is_hotspot()) { - JNIHandles::destroy_global(object.as_jobject()); - } else { - JNIAccessMark jni(this); - jni()->DeleteGlobalRef(object.as_jobject()); - } -} - -const char* JVMCIEnv::klass_name(JVMCIObject object) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(object)->klass()->signature_name(); - } else { - JVMCIObject name; - { - JNIAccessMark jni(this); - jclass jcl = jni()->GetObjectClass(object.as_jobject()); - jobject result = jni()->CallObjectMethod(jcl, JNIJVMCI::Class_getName_method()); - name = JVMCIObject::create(result, is_hotspot()); - } - return as_utf8_string(name); - } -} - -JVMCIObject JVMCIEnv::get_jvmci_method(const methodHandle& method, JVMCI_TRAPS) { - JVMCIObject method_object; - if (method() == nullptr) { - return method_object; - } - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - JVMCIKlassHandle holder_klass(THREAD, method->method_holder()); - JVMCIObject holder = get_jvmci_type(holder_klass, JVMCI_CHECK_(JVMCIObject())); - - CompilerOracle::tag_blackhole_if_possible(method); - - jmetadata handle = _runtime->allocate_handle(method); - jboolean exception = false; - if (is_hotspot()) { - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_long((jlong) handle); - args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(holder))); - JavaCalls::call_static(&result, HotSpotJVMCI::HotSpotResolvedJavaMethodImpl::klass(), - vmSymbols::fromMetaspace_name(), - vmSymbols::method_fromMetaspace_signature(), &args, THREAD); - if (HAS_PENDING_EXCEPTION) { - exception = true; - } else { - method_object = wrap(result.get_oop()); - } - } else { - JNIAccessMark jni(this, THREAD); - method_object = JNIJVMCI::wrap(jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotResolvedJavaMethodImpl::clazz(), - JNIJVMCI::HotSpotResolvedJavaMethodImpl_fromMetaspace_method(), - (jlong) handle, holder.as_jobject())); - exception = jni()->ExceptionCheck(); - } - - if (exception) { - _runtime->release_handle(handle); - return JVMCIObject(); - } - - assert(asMethod(method_object) == method(), "must be"); - if (get_HotSpotResolvedJavaMethodImpl_methodHandle(method_object) != (jlong) handle) { - _runtime->release_handle(handle); - } - assert(!method_object.is_null(), "must be"); - return method_object; -} - -JVMCIObject JVMCIEnv::get_jvmci_type(const JVMCIKlassHandle& klass, JVMCI_TRAPS) { - JVMCIObject type; - if (klass.is_null()) { - return type; - } - - guarantee(klass->is_klass(), "must be valid klass"); - guarantee(klass->is_loader_alive(), "klass must be alive"); - - jlong pointer = (jlong) klass(); - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - jboolean exception = false; - if (is_hotspot()) { - CompilerThreadCanCallJava ccj(THREAD, true); - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_long(pointer); - JavaCalls::call_static(&result, - HotSpotJVMCI::HotSpotResolvedObjectTypeImpl::klass(), - vmSymbols::fromMetaspace_name(), - vmSymbols::klass_fromMetaspace_signature(), &args, THREAD); - - if (HAS_PENDING_EXCEPTION) { - exception = true; - } else { - type = wrap(result.get_oop()); - } - } else { - JNIAccessMark jni(this, THREAD); - - HandleMark hm(THREAD); - type = JNIJVMCI::wrap(jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotResolvedObjectTypeImpl::clazz(), - JNIJVMCI::HotSpotResolvedObjectTypeImpl_fromMetaspace_method(), - pointer)); - exception = jni()->ExceptionCheck(); - } - if (exception) { - return JVMCIObject(); - } - - assert(type.is_non_null(), "must have result"); - return type; -} - -JVMCIObject JVMCIEnv::get_jvmci_constant_pool(const constantPoolHandle& cp, JVMCI_TRAPS) { - JVMCIObject cp_object; - jmetadata handle = _runtime->allocate_handle(cp); - jboolean exception = false; - JavaThread* THREAD = JVMCI::compilation_tick(JavaThread::current()); // For exception macros. - if (is_hotspot()) { - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_long((jlong) handle); - JavaCalls::call_static(&result, - HotSpotJVMCI::HotSpotConstantPool::klass(), - vmSymbols::fromMetaspace_name(), - vmSymbols::constantPool_fromMetaspace_signature(), &args, THREAD); - if (HAS_PENDING_EXCEPTION) { - exception = true; - } else { - cp_object = wrap(result.get_oop()); - } - } else { - JNIAccessMark jni(this, THREAD); - cp_object = JNIJVMCI::wrap(jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotConstantPool::clazz(), - JNIJVMCI::HotSpotConstantPool_fromMetaspace_method(), - (jlong) handle)); - exception = jni()->ExceptionCheck(); - } - - if (exception) { - _runtime->release_handle(handle); - return JVMCIObject(); - } - - assert(!cp_object.is_null(), "must be"); - // Constant pools aren't cached so this is always a newly created object using the handle - assert(get_HotSpotConstantPool_constantPoolHandle(cp_object) == (jlong) handle, "must use same handle"); - return cp_object; -} - -JVMCIPrimitiveArray JVMCIEnv::new_booleanArray(int length, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - typeArrayOop result = oopFactory::new_boolArray(length, CHECK_(JVMCIObject())); - return wrap(result); - } else { - JNIAccessMark jni(this, THREAD); - jbooleanArray result = jni()->NewBooleanArray(length); - return wrap(result); - } -} - -JVMCIPrimitiveArray JVMCIEnv::new_byteArray(int length, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - typeArrayOop result = oopFactory::new_byteArray(length, CHECK_(JVMCIObject())); - return wrap(result); - } else { - JNIAccessMark jni(this, THREAD); - jbyteArray result = jni()->NewByteArray(length); - return wrap(result); - } -} - -JVMCIObjectArray JVMCIEnv::new_byte_array_array(int length, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - objArrayOop result = oopFactory::new_objArray(Universe::byteArrayKlass(), length, CHECK_(JVMCIObject())); - return wrap(result); - } else { - JNIAccessMark jni(this, THREAD); - jobjectArray result = jni()->NewObjectArray(length, JNIJVMCI::byte_array(), nullptr); - return wrap(result); - } -} - -JVMCIPrimitiveArray JVMCIEnv::new_intArray(int length, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - typeArrayOop result = oopFactory::new_intArray(length, CHECK_(JVMCIObject())); - return wrap(result); - } else { - JNIAccessMark jni(this, THREAD); - jintArray result = jni()->NewIntArray(length); - return wrap(result); - } -} - -JVMCIPrimitiveArray JVMCIEnv::new_longArray(int length, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - typeArrayOop result = oopFactory::new_longArray(length, CHECK_(JVMCIObject())); - return wrap(result); - } else { - JNIAccessMark jni(this, THREAD); - jlongArray result = jni()->NewLongArray(length); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::new_VMField(JVMCIObject name, JVMCIObject type, jlong offset, jlong address, JVMCIObject value, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - HotSpotJVMCI::VMField::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::VMField::klass()->allocate_instance(CHECK_(JVMCIObject())); - HotSpotJVMCI::VMField::set_name(this, obj, HotSpotJVMCI::resolve(name)); - HotSpotJVMCI::VMField::set_type(this, obj, HotSpotJVMCI::resolve(type)); - HotSpotJVMCI::VMField::set_offset(this, obj, offset); - HotSpotJVMCI::VMField::set_address(this, obj, address); - HotSpotJVMCI::VMField::set_value(this, obj, HotSpotJVMCI::resolve(value)); - return wrap(obj); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->NewObject(JNIJVMCI::VMField::clazz(), - JNIJVMCI::VMField::constructor(), - get_jobject(name), get_jobject(type), offset, address, get_jobject(value)); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::new_VMFlag(JVMCIObject name, JVMCIObject type, JVMCIObject value, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - HotSpotJVMCI::VMFlag::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::VMFlag::klass()->allocate_instance(CHECK_(JVMCIObject())); - HotSpotJVMCI::VMFlag::set_name(this, obj, HotSpotJVMCI::resolve(name)); - HotSpotJVMCI::VMFlag::set_type(this, obj, HotSpotJVMCI::resolve(type)); - HotSpotJVMCI::VMFlag::set_value(this, obj, HotSpotJVMCI::resolve(value)); - return wrap(obj); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->NewObject(JNIJVMCI::VMFlag::clazz(), - JNIJVMCI::VMFlag::constructor(), - get_jobject(name), get_jobject(type), get_jobject(value)); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, jboolean isAvailable, jboolean c1Supported, jboolean c2Supported, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - HotSpotJVMCI::VMIntrinsicMethod::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::VMIntrinsicMethod::klass()->allocate_instance(CHECK_(JVMCIObject())); - HotSpotJVMCI::VMIntrinsicMethod::set_declaringClass(this, obj, HotSpotJVMCI::resolve(declaringClass)); - HotSpotJVMCI::VMIntrinsicMethod::set_name(this, obj, HotSpotJVMCI::resolve(name)); - HotSpotJVMCI::VMIntrinsicMethod::set_descriptor(this, obj, HotSpotJVMCI::resolve(descriptor)); - HotSpotJVMCI::VMIntrinsicMethod::set_id(this, obj, id); - HotSpotJVMCI::VMIntrinsicMethod::set_isAvailable(this, obj, isAvailable); - HotSpotJVMCI::VMIntrinsicMethod::set_c1Supported(this, obj, c1Supported); - HotSpotJVMCI::VMIntrinsicMethod::set_c2Supported(this, obj, c2Supported); - return wrap(obj); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->NewObject(JNIJVMCI::VMIntrinsicMethod::clazz(), - JNIJVMCI::VMIntrinsicMethod::constructor(), - get_jobject(declaringClass), get_jobject(name), get_jobject(descriptor), id, isAvailable, c1Supported, c2Supported); - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::new_HotSpotStackFrameReference(JVMCI_TRAPS) { - if (is_hotspot()) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - HotSpotJVMCI::HotSpotStackFrameReference::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::HotSpotStackFrameReference::klass()->allocate_instance(CHECK_(JVMCIObject())); - return wrap(obj); - } else { - ShouldNotReachHere(); - return JVMCIObject(); - } -} -JVMCIObject JVMCIEnv::new_JVMCIError(JVMCI_TRAPS) { - if (is_hotspot()) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - HotSpotJVMCI::JVMCIError::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::JVMCIError::klass()->allocate_instance(CHECK_(JVMCIObject())); - return wrap(obj); - } else { - ShouldNotReachHere(); - return JVMCIObject(); - } -} - -JVMCIObject JVMCIEnv::new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - HotSpotJVMCI::FieldInfo::klass()->initialize(CHECK_(JVMCIObject())); - oop obj = HotSpotJVMCI::FieldInfo::klass()->allocate_instance(CHECK_(JVMCIObject())); - Handle obj_h(THREAD, obj); - HotSpotJVMCI::FieldInfo::set_nameIndex(JVMCIENV, obj_h(), (jint)fieldinfo->name_index()); - HotSpotJVMCI::FieldInfo::set_signatureIndex(JVMCIENV, obj_h(), (jint)fieldinfo->signature_index()); - HotSpotJVMCI::FieldInfo::set_offset(JVMCIENV, obj_h(), (jint)fieldinfo->offset()); - HotSpotJVMCI::FieldInfo::set_classfileFlags(JVMCIENV, obj_h(), (jint)fieldinfo->access_flags().as_field_flags()); - HotSpotJVMCI::FieldInfo::set_internalFlags(JVMCIENV, obj_h(), (jint)fieldinfo->field_flags().as_uint()); - HotSpotJVMCI::FieldInfo::set_initializerIndex(JVMCIENV, obj_h(), (jint)fieldinfo->initializer_index()); - return wrap(obj_h()); - } else { - JNIAccessMark jni(this, THREAD); - jobject result = jni()->NewObject(JNIJVMCI::FieldInfo::clazz(), - JNIJVMCI::FieldInfo::constructor(), - (jint)fieldinfo->name_index(), - (jint)fieldinfo->signature_index(), - (jint)fieldinfo->offset(), - (jint)fieldinfo->access_flags().as_field_flags(), - (jint)fieldinfo->field_flags().as_uint(), - (jint)fieldinfo->initializer_index()); - - return wrap(result); - } -} - -JVMCIObject JVMCIEnv::get_object_constant(oop objOop, bool compressed, bool dont_register) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - Handle obj = Handle(THREAD, objOop); - if (obj.is_null()) { - return JVMCIObject(); - } - if (is_hotspot()) { - HotSpotJVMCI::DirectHotSpotObjectConstantImpl::klass()->initialize(CHECK_(JVMCIObject())); - oop constant = HotSpotJVMCI::DirectHotSpotObjectConstantImpl::klass()->allocate_instance(CHECK_(JVMCIObject())); - HotSpotJVMCI::DirectHotSpotObjectConstantImpl::set_object(this, constant, obj()); - HotSpotJVMCI::HotSpotObjectConstantImpl::set_compressed(this, constant, compressed); - return wrap(constant); - } else { - jlong handle = make_oop_handle(obj); - JNIAccessMark jni(this, THREAD); - jobject result = jni()->NewObject(JNIJVMCI::IndirectHotSpotObjectConstantImpl::clazz(), - JNIJVMCI::IndirectHotSpotObjectConstantImpl::constructor(), - handle, compressed, dont_register); - return wrap(result); - } -} - - -Handle JVMCIEnv::asConstant(JVMCIObject constant, JVMCI_TRAPS) { - if (constant.is_null()) { - return Handle(); - } - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - assert(HotSpotJVMCI::DirectHotSpotObjectConstantImpl::is_instance(this, constant), "wrong type"); - oop obj = HotSpotJVMCI::DirectHotSpotObjectConstantImpl::object(this, HotSpotJVMCI::resolve(constant)); - return Handle(THREAD, obj); - } else if (isa_IndirectHotSpotObjectConstantImpl(constant)) { - jlong object_handle = get_IndirectHotSpotObjectConstantImpl_objectHandle(constant); - if (object_handle == 0L) { - JVMCI_THROW_MSG_(NullPointerException, "Foreign object reference has been cleared", Handle()); - } - oop result = resolve_oop_handle(object_handle); - if (result == nullptr) { - JVMCI_THROW_MSG_(InternalError, "Constant was unexpectedly null", Handle()); - } - return Handle(THREAD, result); - } else { - JVMCI_THROW_MSG_(IllegalArgumentException, "DirectHotSpotObjectConstantImpl shouldn't reach JVMCI in SVM mode", Handle()); - } -} - -JVMCIObject JVMCIEnv::wrap(jobject object) { - return JVMCIObject::create(object, is_hotspot()); -} - -jlong JVMCIEnv::make_oop_handle(const Handle& obj) { - assert(!obj.is_null(), "should only create handle for non-null oops"); - return _runtime->make_oop_handle(obj); -} - -oop JVMCIEnv::resolve_oop_handle(jlong oopHandle) { - assert(oopHandle != 0, "should be a valid handle"); - oop obj = NativeAccess<>::oop_load(reinterpret_cast(oopHandle)); - if (obj != nullptr) { - guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj)); - } - return obj; -} - -JVMCIObject JVMCIEnv::create_string(const char* str, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - if (is_hotspot()) { - Handle result = java_lang_String::create_from_str(str, CHECK_(JVMCIObject())); - return HotSpotJVMCI::wrap(result()); - } else { - jobject result; - jboolean exception = false; - { - JNIAccessMark jni(this, THREAD); - result = jni()->NewStringUTF(str); - exception = jni()->ExceptionCheck(); - } - return wrap(result); - } -} - -bool JVMCIEnv::equals(JVMCIObject a, JVMCIObject b) { - if (is_hotspot()) { - return HotSpotJVMCI::resolve(a) == HotSpotJVMCI::resolve(b); - } else { - JNIAccessMark jni(this); - return jni()->IsSameObject(a.as_jobject(), b.as_jobject()) != 0; - } -} - -BasicType JVMCIEnv::typeCharToBasicType(jchar ch, JVMCI_TRAPS) { - switch(ch) { - case 'Z': return T_BOOLEAN; - case 'B': return T_BYTE; - case 'S': return T_SHORT; - case 'C': return T_CHAR; - case 'I': return T_INT; - case 'F': return T_FLOAT; - case 'J': return T_LONG; - case 'D': return T_DOUBLE; - case 'A': return T_OBJECT; - case '-': return T_ILLEGAL; - default: - JVMCI_ERROR_(T_ILLEGAL, "unexpected type char: %c", ch); - } -} - -BasicType JVMCIEnv::kindToBasicType(JVMCIObject kind, JVMCI_TRAPS) { - if (kind.is_null()) { - JVMCI_THROW_(NullPointerException, T_ILLEGAL); - } - jchar ch = get_JavaKind_typeChar(kind); - BasicType bt = typeCharToBasicType(ch, JVMCI_CHECK_(T_ILLEGAL)); - return bt; -} - -void JVMCIEnv::initialize_installed_code(JVMCIObject installed_code, CodeBlob* cb, JVMCI_TRAPS) { - // Ensure that all updates to the InstalledCode fields are consistent. - if (get_InstalledCode_address(installed_code) != 0) { - JVMCI_THROW_MSG(InternalError, "InstalledCode instance already in use"); - } - if (!isa_HotSpotInstalledCode(installed_code)) { - JVMCI_THROW_MSG(InternalError, "InstalledCode instance must be a subclass of HotSpotInstalledCode"); - } - - // Ignore the version which can stay at 0 - if (cb->is_nmethod()) { - nmethod* nm = cb->as_nmethod_or_null(); - if (nm->is_in_use()) { - set_InstalledCode_entryPoint(installed_code, (jlong) nm->verified_entry_point()); - } - } else { - set_InstalledCode_entryPoint(installed_code, (jlong) cb->code_begin()); - } - set_InstalledCode_address(installed_code, (jlong) cb); - set_HotSpotInstalledCode_size(installed_code, cb->size()); - set_HotSpotInstalledCode_codeStart(installed_code, (jlong) cb->code_begin()); - set_HotSpotInstalledCode_codeSize(installed_code, cb->code_size()); -} - - -void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nmethod::InvalidationReason invalidation_reason, JVMCI_TRAPS) { - if (mirror.is_null()) { - JVMCI_THROW(NullPointerException); - } - - Thread* current = Thread::current(); - if (!mirror.is_hotspot() && !current->is_Java_thread()) { - // Calling back into native might cause the execution to block, so only allow this when calling - // from a JavaThread, which is the normal case anyway. - JVMCI_THROW_MSG(IllegalArgumentException, - "Cannot invalidate HotSpotNmethod object in shared library VM heap from non-JavaThread"); - } - - JavaThread* thread = JavaThread::cast(current); - JVMCINMethodHandle nmethod_handle(thread); - nmethod* nm = JVMCIENV->get_nmethod(mirror, nmethod_handle); - if (nm == nullptr) { - // Nothing to do - return; - } - - if (!deoptimize) { - // Prevent future executions of the nmethod but let current executions complete. - nm->make_not_entrant(invalidation_reason); - - // Do not clear the address field here as the Java code may still - // want to later call this method with deoptimize == true. That requires - // the address field to still be pointing at the nmethod. - } else { - // Deoptimize the nmethod immediately. - DeoptimizationScope deopt_scope; - deopt_scope.mark(nm); - nm->make_not_entrant(invalidation_reason); - nm->make_deoptimized(); - deopt_scope.deoptimize_marked(); - - // A HotSpotNmethod instance can only reference a single nmethod - // during its lifetime so simply clear it here. - set_InstalledCode_address(mirror, 0); - } -} - -Klass* JVMCIEnv::asKlass(JVMCIObject obj) { - return (Klass*) get_HotSpotResolvedObjectTypeImpl_klassPointer(obj); -} - -Method* JVMCIEnv::asMethod(JVMCIObject obj) { - Method** methodHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_methodHandle(obj); - return *methodHandle; -} - -ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) { - ConstantPool** constantPoolHandle = (ConstantPool**) get_HotSpotConstantPool_constantPoolHandle(obj); - return *constantPoolHandle; -} - -MethodData* JVMCIEnv::asMethodData(JVMCIObject obj) { - return (MethodData*) get_HotSpotMethodData_methodDataPointer(obj); -} - -// Lookup an nmethod with a matching base and compile id -nmethod* JVMCIEnv::lookup_nmethod(address code, jlong compile_id_snapshot) { - if (code == nullptr) { - return nullptr; - } - - CodeBlob* cb = CodeCache::find_blob(code); - if (cb == (CodeBlob*) code) { - nmethod* nm = cb->as_nmethod_or_null(); - if (nm != nullptr && (compile_id_snapshot == 0 || nm->compile_id() == compile_id_snapshot)) { - return nm; - } - } - return nullptr; -} - - -CodeBlob* JVMCIEnv::get_code_blob(JVMCIObject obj) { - address code = (address) get_InstalledCode_address(obj); - if (code == nullptr) { - return nullptr; - } - if (isa_HotSpotNmethod(obj)) { - jlong compile_id_snapshot = get_HotSpotNmethod_compileIdSnapshot(obj); - nmethod* nm = lookup_nmethod(code, compile_id_snapshot); - if (nm != nullptr && compile_id_snapshot != 0L && nm->is_not_entrant()) { - // Zero the entry point so that the nmethod - // cannot be invoked by the mirror but can - // still be deoptimized. - set_InstalledCode_entryPoint(obj, 0); - // Refetch the nmethod since the previous call will be a safepoint in libjvmci - nm = lookup_nmethod(code, compile_id_snapshot); - } - - if (nm == nullptr) { - // The HotSpotNmethod was pointing at some nmethod but the nmethod is no longer valid, so - // clear the InstalledCode fields of this HotSpotNmethod so that it no longer refers to a - // nmethod in the code cache. - set_InstalledCode_address(obj, 0); - set_InstalledCode_entryPoint(obj, 0); - set_HotSpotInstalledCode_codeStart(obj, 0); - } - return nm; - } - - CodeBlob* cb = (CodeBlob*) code; - assert(!cb->is_nmethod(), "unexpected nmethod"); - return cb; -} - -void JVMCINMethodHandle::set_nmethod(nmethod* nm) { - BarrierSetNMethod* bs_nm = BarrierSet::barrier_set()->barrier_set_nmethod(); - bs_nm->nmethod_entry_barrier(nm); - _thread->set_live_nmethod(nm); -} - -nmethod* JVMCIEnv::get_nmethod(JVMCIObject obj, JVMCINMethodHandle& nmethod_handle) { - CodeBlob* cb = get_code_blob(obj); - if (cb != nullptr) { - nmethod* nm = cb->as_nmethod_or_null(); - if (nm != nullptr) { - nmethod_handle.set_nmethod(nm); - return nm; - } - } - return nullptr; -} - -// Generate implementations for the initialize, new, isa, get and set methods for all the types and -// fields declared in the JVMCI_CLASSES_DO macro. - -#define START_CLASS(className, fullClassName) \ - void JVMCIEnv::className##_initialize(JVMCI_TRAPS) { \ - if (is_hotspot()) { \ - HotSpotJVMCI::className::initialize(JVMCI_CHECK); \ - } else { \ - JNIJVMCI::className::initialize(JVMCI_CHECK); \ - } \ - } \ - JVMCIObjectArray JVMCIEnv::new_##className##_array(int length, JVMCI_TRAPS) { \ - if (is_hotspot()) { \ - JavaThread* THREAD = JavaThread::current(); /* For exception macros. */ \ - objArrayOop array = oopFactory::new_objArray(HotSpotJVMCI::className::klass(), length, CHECK_(JVMCIObject())); \ - return (JVMCIObjectArray) wrap(array); \ - } else { \ - JNIAccessMark jni(this); \ - jobjectArray result = jni()->NewObjectArray(length, JNIJVMCI::className::clazz(), nullptr); \ - return wrap(result); \ - } \ - } \ - bool JVMCIEnv::isa_##className(JVMCIObject object) { \ - if (is_hotspot()) { \ - return HotSpotJVMCI::className::is_instance(this, object); \ - } else { \ - return JNIJVMCI::className::is_instance(this, object); \ - } \ - } - -#define END_CLASS - -#define FIELD(className, name, type, accessor, cast) \ - type JVMCIEnv::get_##className##_##name(JVMCIObject obj) { \ - if (is_hotspot()) { \ - return HotSpotJVMCI::className::get_##name(this, obj); \ - } else { \ - return JNIJVMCI::className::get_##name(this, obj); \ - } \ - } \ - void JVMCIEnv::set_##className##_##name(JVMCIObject obj, type x) { \ - if (is_hotspot()) { \ - HotSpotJVMCI::className::set_##name(this, obj, x); \ - } else { \ - JNIJVMCI::className::set_##name(this, obj, x); \ - } \ - } - -#define EMPTY_CAST -#define CHAR_FIELD(className, name) FIELD(className, name, jchar, Char, EMPTY_CAST) -#define INT_FIELD(className, name) FIELD(className, name, jint, Int, EMPTY_CAST) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, Boolean, EMPTY_CAST) -#define LONG_FIELD(className, name) FIELD(className, name, jlong, Long, EMPTY_CAST) -#define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, Float, EMPTY_CAST) - -#define OBJECT_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObject, Object, EMPTY_CAST) -#define OBJECTARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) -#define PRIMARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIPrimitiveArray, Object, (JVMCIPrimitiveArray)) - -#define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObject, Object, (JVMCIObject)) -#define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) - -#define OOPISH_FIELD(className, name, type, accessor, cast) \ - type JVMCIEnv::get_##className##_##name(JVMCIObject obj) { \ - if (is_hotspot()) { \ - return HotSpotJVMCI::className::get_##name(this, obj); \ - } else { \ - return JNIJVMCI::className::get_##name(this, obj); \ - } \ - } \ - void JVMCIEnv::set_##className##_##name(JVMCIObject obj, type x) { \ - if (is_hotspot()) { \ - HotSpotJVMCI::className::set_##name(this, obj, x); \ - } else { \ - JNIJVMCI::className::set_##name(this, obj, x); \ - } \ - } - -#define STATIC_OOPISH_FIELD(className, name, type, accessor, cast) \ - type JVMCIEnv::get_##className##_##name() { \ - if (is_hotspot()) { \ - return HotSpotJVMCI::className::get_##name(this); \ - } else { \ - return JNIJVMCI::className::get_##name(this); \ - } \ - } \ - void JVMCIEnv::set_##className##_##name(type x) { \ - if (is_hotspot()) { \ - HotSpotJVMCI::className::set_##name(this, x); \ - } else { \ - JNIJVMCI::className::set_##name(this, x); \ - } \ - } - -#define STATIC_PRIMITIVE_FIELD(className, name, type, accessor, cast) \ - type JVMCIEnv::get_##className##_##name() { \ - if (is_hotspot()) { \ - return HotSpotJVMCI::className::get_##name(this); \ - } else { \ - return JNIJVMCI::className::get_##name(this); \ - } \ - } \ - void JVMCIEnv::set_##className##_##name(type x) { \ - if (is_hotspot()) { \ - HotSpotJVMCI::className::set_##name(this, x); \ - } else { \ - JNIJVMCI::className::set_##name(this, x); \ - } \ - } -#define STATIC_INT_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jint, Int, EMPTY_CAST) -#define STATIC_BOOLEAN_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jboolean, Boolean, EMPTY_CAST) -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) - -JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) - -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef STATIC_OOPISH_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef EMPTY_CAST diff --git a/src/hotspot/share/jvmci/jvmciEnv.hpp b/src/hotspot/share/jvmci/jvmciEnv.hpp deleted file mode 100644 index 82d9fe1d56c..00000000000 --- a/src/hotspot/share/jvmci/jvmciEnv.hpp +++ /dev/null @@ -1,554 +0,0 @@ -/* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_JVMCI_JVMCIENV_HPP -#define SHARE_JVMCI_JVMCIENV_HPP - -#include "classfile/javaClasses.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "oops/klass.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/jniHandles.hpp" - -class CompileTask; -class JVMCIObject; -class JVMCIObjectArray; -class JVMCIPrimitiveArray; -class JVMCICompiler; -class JVMCIRuntime; - -#define JVMCI_EXCEPTION_CONTEXT \ - JavaThread* thread = JavaThread::current(); \ - JavaThread* THREAD = thread; // For exception macros. - -// Helper to log more context on a JNI exception -#define JVMCI_EXCEPTION_CHECK(env, ...) \ - do { \ - if (env->ExceptionCheck()) { \ - if (env != JavaThread::current()->jni_environment()) { \ - char* sl_path; \ - if (::JVMCI::get_shared_library(sl_path, false) != nullptr) { \ - tty->print_cr("In JVMCI shared library (%s):", sl_path); \ - } \ - } \ - tty->print_cr(__VA_ARGS__); \ - return; \ - } \ - } while(0) - -// Helper class to ensure that references to Klass* are kept alive for G1 -class JVMCIKlassHandle : public StackObj { - private: - Klass* _klass; - Handle _holder; - Thread* _thread; - - Klass* klass() const { return _klass; } - Klass* non_null_klass() const { assert(_klass != nullptr, "resolving null _klass"); return _klass; } - - public: - /* Constructors */ - JVMCIKlassHandle (Thread* thread) : _klass(nullptr), _thread(thread) {} - JVMCIKlassHandle (Thread* thread, Klass* klass); - - JVMCIKlassHandle (const JVMCIKlassHandle &h): _klass(h._klass), _holder(h._holder), _thread(h._thread) {} - JVMCIKlassHandle& operator=(const JVMCIKlassHandle &s); - JVMCIKlassHandle& operator=(Klass* klass); - - /* Operators for ease of use */ - Klass* operator () () const { return klass(); } - Klass* operator -> () const { return non_null_klass(); } - - bool operator == (Klass* o) const { return klass() == o; } - bool operator == (const JVMCIKlassHandle& h) const { return klass() == h.klass(); } - - /* Null checks */ - bool is_null() const { return _klass == nullptr; } - bool not_null() const { return _klass != nullptr; } -}; - -// A helper class to main a strong link to an nmethod that might not otherwise be referenced. Only -// one nmethod can be kept alive in this manner. -class JVMCINMethodHandle : public StackObj { - JavaThread* _thread; - - public: - JVMCINMethodHandle(JavaThread* thread): _thread(thread) {} - - void set_nmethod(nmethod* nm); - - ~JVMCINMethodHandle() { - _thread->clear_live_nmethod(); - } -}; - -// A class that maintains the state needed for compilations requested -// by the CompileBroker. It is created in the broker and passed through -// into the code installation step. -class JVMCICompileState : public ResourceObj { - friend class JVMCIVMStructs; - private: - CompileTask* _task; - JVMCICompiler* _compiler; - - // Cache JVMTI state. Defined as bytes so that reading them from Java - // via Unsafe is well defined (the C++ type for bool is implementation - // defined and may not be the same as a Java boolean). - uint64_t _jvmti_redefinition_count; - jbyte _jvmti_can_hotswap_or_post_breakpoint; - jbyte _jvmti_can_access_local_variables; - jbyte _jvmti_can_post_on_exceptions; - jbyte _jvmti_can_pop_frame; - bool _target_method_is_old; - - // Compilation result values. - bool _retryable; - const char* _failure_reason; - - // Specifies if _failure_reason is on the C heap. If so, it is allocated - // with the mtJVMCI NMT flag. - bool _failure_reason_on_C_heap; - - // A value indicating compilation activity during the compilation. - // If successive calls to this method return a different value, then - // some degree of JVMCI compilation occurred between the calls. - jint _compilation_ticks; - - public: - JVMCICompileState(CompileTask* task, JVMCICompiler* compiler); - - CompileTask* task() { return _task; } - - bool jvmti_state_changed() const; - uint64_t jvmti_redefinition_count() const { return _jvmti_redefinition_count; } - bool jvmti_can_hotswap_or_post_breakpoint() const { return _jvmti_can_hotswap_or_post_breakpoint != 0; } - bool jvmti_can_access_local_variables() const { return _jvmti_can_access_local_variables != 0; } - bool jvmti_can_post_on_exceptions() const { return _jvmti_can_post_on_exceptions != 0; } - bool jvmti_can_pop_frame() const { return _jvmti_can_pop_frame != 0; } - bool target_method_is_old() const { return _target_method_is_old; } - - const char* failure_reason() { return _failure_reason; } - bool failure_reason_on_C_heap() { return _failure_reason_on_C_heap; } - bool retryable() { return _retryable; } - - void set_failure(bool retryable, const char* reason, bool reason_on_C_heap = false); - - // Called when creating or attaching to a libjvmci isolate failed - // due to an out of memory condition. - void notify_libjvmci_oome(); - - jint compilation_ticks() const { return _compilation_ticks; } - void inc_compilation_ticks(); -}; - -// This class is a top level wrapper around interactions between HotSpot -// and the JVMCI Java code. It supports both a HotSpot heap based -// runtime with HotSpot oop based accessors as well as a shared library -// based runtime that is accessed through JNI. It abstracts away all -// interactions with JVMCI objects so that a single version of the -// HotSpot C++ code can can work with either runtime. -class JVMCIEnv : public ResourceObj { - friend class JNIAccessMark; - - // Initializes the _env, _mode and _runtime fields. - void init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env); - - void init(JavaThread* thread, bool is_hotspot, const char* file, int line); - - JNIEnv* _env; // JNI env for calling into shared library - bool _pop_frame_on_close; // Must pop frame on close? - bool _detach_on_close; // Must detach on close? - JVMCIRuntime* _runtime; // Access to a HotSpotJVMCIRuntime - bool _is_hotspot; // Which heap is the HotSpotJVMCIRuntime in - bool _throw_to_caller; // Propagate an exception raised in this env to the caller? - const char* _file; // The file and ... - int _line; // ... line where this JNIEnv was created - int _init_error; // JNI code returned when creating or attaching to a libjvmci isolate. - // If not JNI_OK, the JVMCIEnv is invalid and should not be used apart from - // calling init_error(). - const char* _init_error_msg; // Message for _init_error if available. C heap allocated. - - // Translates an exception on the HotSpot heap (i.e., hotspot_env) to an exception on - // the shared library heap (i.e., jni_env). The translation includes the stack and cause(s) of `throwable`. - // The translated exception is pending in jni_env upon returning. - static void translate_to_jni_exception(JavaThread* THREAD, const Handle& throwable, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env); - - // Translates an exception on the shared library heap (i.e., jni_env) to an exception on - // the HotSpot heap (i.e., hotspot_env). The translation includes the stack and cause(s) of `throwable`. - // The translated exception is pending in hotspot_env upon returning. - static void translate_from_jni_exception(JavaThread* THREAD, jthrowable throwable, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env); - -public: - // Opens a JVMCIEnv scope for a Java to VM call (e.g., via CompilerToVM). - // The `parent_env` argument must not be null. - // An exception occurring within the scope is left pending when the - // scope closes so that it will be propagated back to Java. - // The JVMCIEnv destructor translates the exception object for the - // Java runtime if necessary. - JVMCIEnv(JavaThread* thread, JNIEnv* parent_env, const char* file, int line); - - // Opens a JVMCIEnv scope for a compilation scheduled by the CompileBroker. - // An exception occurring within the scope must not be propagated back to - // the CompileBroker. - JVMCIEnv(JavaThread* thread, JVMCICompileState* compile_state, const char* file, int line); - - // Opens a JNIEnv scope for a call from within the VM. An exception occurring - // within the scope must not be propagated back to the caller. - JVMCIEnv(JavaThread* env, const char* file, int line); - - // Opens a JNIEnv scope for the HotSpot runtime if `is_hotspot` is true - // otherwise for the shared library runtime. An exception occurring - // within the scope must not be propagated back to the caller. - JVMCIEnv(JavaThread* thread, bool is_hotspot, const char* file, int line) { - init(thread, is_hotspot, file, line); - } - - ~JVMCIEnv(); - - // Gets the JNI result code returned when creating or attaching to a libjvmci isolate. - // If not JNI_OK, the JVMCIEnv is invalid and the caller must abort the operation - // this JVMCIEnv context was created for. - int init_error() { - return _init_error; - } - - // Gets a message describing a non-zero init_error(). - // Valid as long as this JVMCIEnv is valid. - const char* init_error_msg() { - return _init_error_msg; - } - - // Checks the value of init_error() and throws an exception in `JVMCI_TRAPS` - // (which must not be this) if it is not JNI_OK. - void check_init(JVMCI_TRAPS); - - // Checks the value of init_error() and throws an exception in `TRAPS` - // if it is not JNI_OK. - void check_init(TRAPS); - - JVMCIRuntime* runtime() { - guarantee(_init_error == 0, "invalid JVMCIEnv: %d", _init_error); - return _runtime; - } - - jboolean has_pending_exception(); - void clear_pending_exception(); - - // If this env has a pending exception, it is translated to be a pending - // exception in `peer_env` and is cleared from this env. Returns true - // if a pending exception was transferred, false otherwise. - jboolean transfer_pending_exception(JavaThread* THREAD, JVMCIEnv* peer_env); - - // If there is a pending HotSpot exception, clears it and translates it to the shared library heap. - // The translated exception is pending in the shared library upon returning. - // Returns true if a pending exception was transferred, false otherwise. - static jboolean transfer_pending_exception_to_jni(JavaThread* THREAD, JVMCIEnv* hotspot_env, JVMCIEnv* jni_env); - - // Prints the stack trace of a pending exception to `st` and clears the exception. - // If there is no pending exception, this is a nop. - void describe_pending_exception(outputStream* st); - - // Gets the output of calling toString and/or printStactTrace on the pending exception. - // If to_string is not null, the output of toString is returned in it. - // If stack_trace is not null, the output of printStackTrace is returned in it. - // Returns false if there is no pending exception otherwise clears the pending - // exception and returns true. - bool pending_exception_as_string(const char** to_string, const char** stack_trace); - - int get_length(JVMCIArray array); - - JVMCIObject get_object_at(JVMCIObjectArray array, int index); - void put_object_at(JVMCIObjectArray array, int index, JVMCIObject value); - - jboolean get_bool_at(JVMCIPrimitiveArray array, int index); - void put_bool_at(JVMCIPrimitiveArray array, int index, jboolean value); - - jbyte get_byte_at(JVMCIPrimitiveArray array, int index); - void put_byte_at(JVMCIPrimitiveArray array, int index, jbyte value); - - jint get_int_at(JVMCIPrimitiveArray array, int index); - void put_int_at(JVMCIPrimitiveArray array, int index, jint value); - - jlong get_long_at(JVMCIPrimitiveArray array, int index); - void put_long_at(JVMCIPrimitiveArray array, int index, jlong value); - - void copy_bytes_to(JVMCIPrimitiveArray src, jbyte* dest, int offset, jsize length); - void copy_bytes_from(jbyte* src, JVMCIPrimitiveArray dest, int offset, jsize length); - - void copy_longs_from(jlong* src, JVMCIPrimitiveArray dest, int offset, jsize length); - - JVMCIObjectArray initialize_intrinsics(JVMCI_TRAPS); - - jboolean is_boxing_object(BasicType type, JVMCIObject object); - - // Get the primitive value from a Java boxing object. It's hard error to - // pass a non-primitive BasicType. - jvalue get_boxed_value(BasicType type, JVMCIObject object); - - // Return the BasicType of the object if it's a boxing object, otherwise return T_ILLEGAL. - BasicType get_box_type(JVMCIObject object); - - // Create a boxing object of the appropriate primitive type. - JVMCIObject create_box(BasicType type, jvalue* value, JVMCI_TRAPS); - - const char* as_utf8_string(JVMCIObject str); - - JVMCIObject create_string(Symbol* str, JVMCI_TRAPS) { - JVMCIObject s = create_string(str->as_C_string(), JVMCI_CHECK_(JVMCIObject())); - return s; - } - - JVMCIObject create_string(const char* str, JVMCI_TRAPS); - - bool equals(JVMCIObject a, JVMCIObject b); - - // Convert into a JNI handle for the appropriate runtime - jobject get_jobject(JVMCIObject object) { assert(object.as_jobject() == nullptr || is_hotspot() == object.is_hotspot(), "mismatch"); return object.as_jobject(); } - jarray get_jarray(JVMCIArray array) { assert(array.as_jobject() == nullptr || is_hotspot() == array.is_hotspot(), "mismatch"); return array.as_jobject(); } - jobjectArray get_jobjectArray(JVMCIObjectArray objectArray) { assert(objectArray.as_jobject() == nullptr || is_hotspot() == objectArray.is_hotspot(), "mismatch"); return objectArray.as_jobject(); } - jbyteArray get_jbyteArray(JVMCIPrimitiveArray primitiveArray) { assert(primitiveArray.as_jobject() == nullptr || is_hotspot() == primitiveArray.is_hotspot(), "mismatch"); return primitiveArray.as_jbyteArray(); } - - JVMCIObject wrap(jobject obj); - JVMCIObjectArray wrap(jobjectArray obj) { return (JVMCIObjectArray) wrap((jobject) obj); } - JVMCIPrimitiveArray wrap(jintArray obj) { return (JVMCIPrimitiveArray) wrap((jobject) obj); } - JVMCIPrimitiveArray wrap(jbooleanArray obj) { return (JVMCIPrimitiveArray) wrap((jobject) obj); } - JVMCIPrimitiveArray wrap(jbyteArray obj) { return (JVMCIPrimitiveArray) wrap((jobject) obj); } - JVMCIPrimitiveArray wrap(jlongArray obj) { return (JVMCIPrimitiveArray) wrap((jobject) obj); } - - nmethod* lookup_nmethod(address code, jlong compile_id_snapshot); - - private: - JVMCIObject wrap(oop obj) { assert(is_hotspot(), "must be"); return wrap(JNIHandles::make_local(obj)); } - JVMCIObjectArray wrap(objArrayOop obj) { assert(is_hotspot(), "must be"); return (JVMCIObjectArray) wrap(JNIHandles::make_local(obj)); } - JVMCIPrimitiveArray wrap(typeArrayOop obj) { assert(is_hotspot(), "must be"); return (JVMCIPrimitiveArray) wrap(JNIHandles::make_local(obj)); } - - public: - // Compiles a method with the JVMCI compiler. - // Caller must handle pending exception. - JVMCIObject call_HotSpotJVMCIRuntime_compileMethod(JVMCIObject runtime, JVMCIObject method, int entry_bci, - jlong compile_state, int id); - - void call_HotSpotJVMCIRuntime_bootstrapFinished(JVMCIObject runtime, JVMCI_TRAPS); - void call_HotSpotJVMCIRuntime_shutdown(JVMCIObject runtime); - JVMCIObject call_HotSpotJVMCIRuntime_runtime(JVMCI_TRAPS); - JVMCIObject call_JVMCI_getRuntime(JVMCI_TRAPS); - JVMCIObject call_HotSpotJVMCIRuntime_getCompiler(JVMCIObject runtime, JVMCI_TRAPS); - - JVMCIObject call_JavaConstant_forPrimitive(jchar type_char, jlong value, JVMCI_TRAPS); - - jboolean call_HotSpotJVMCIRuntime_isGCSupported(JVMCIObject runtime, jint gcIdentifier); - - jboolean call_HotSpotJVMCIRuntime_isIntrinsicSupported(JVMCIObject runtime, jint intrinsicIdentifier); - - void call_HotSpotJVMCIRuntime_postTranslation(JVMCIObject object, JVMCI_TRAPS); - - // Converts the JavaKind.typeChar value in `ch` to a BasicType - BasicType typeCharToBasicType(jchar ch, JVMCI_TRAPS); - - // Converts the JavaKind value in `kind` to a BasicType - BasicType kindToBasicType(JVMCIObject kind, JVMCI_TRAPS); - -#define DO_THROW(name) \ - void throw_##name(const char* msg = nullptr); - - DO_THROW(InternalError) - DO_THROW(ArrayIndexOutOfBoundsException) - DO_THROW(IllegalStateException) - DO_THROW(NullPointerException) - DO_THROW(IllegalArgumentException) - DO_THROW(InvalidInstalledCodeException) - DO_THROW(UnsatisfiedLinkError) - DO_THROW(UnsupportedOperationException) - DO_THROW(OutOfMemoryError) - DO_THROW(NoClassDefFoundError) - -#undef DO_THROW - - void fthrow_error(const char* file, int line, const char* format, ...) ATTRIBUTE_PRINTF(4, 5); - - // Given an instance of HotSpotInstalledCode, return the corresponding CodeBlob*. - CodeBlob* get_code_blob(JVMCIObject code); - - // Given an instance of HotSpotInstalledCode, return the corresponding nmethod. - nmethod* get_nmethod(JVMCIObject code, JVMCINMethodHandle& nmethod_handle); - - const char* klass_name(JVMCIObject object); - - // Unpack an instance of HotSpotResolvedJavaMethodImpl into the original Method* - Method* asMethod(JVMCIObject jvmci_method); - - // Unpack an instance of HotSpotResolvedObjectTypeImpl into the original Klass* - Klass* asKlass(JVMCIObject jvmci_type); - - // Unpack an instance of HotSpotMethodData into the original MethodData* - MethodData* asMethodData(JVMCIObject jvmci_method_data); - - JVMCIObject get_jvmci_method(const methodHandle& method, JVMCI_TRAPS); - - JVMCIObject get_jvmci_type(const JVMCIKlassHandle& klass, JVMCI_TRAPS); - - // Unpack an instance of HotSpotConstantPool into the original ConstantPool* - ConstantPool* asConstantPool(JVMCIObject constant_pool); - ConstantPool* asConstantPool(jobject constant_pool) { return asConstantPool(wrap(constant_pool)); } - - JVMCIObject get_jvmci_constant_pool(const constantPoolHandle& cp, JVMCI_TRAPS); - JVMCIObject get_jvmci_primitive_type(BasicType type); - - Handle asConstant(JVMCIObject object, JVMCI_TRAPS); - JVMCIObject get_object_constant(oop objOop, bool compressed = false, bool dont_register = false); - - JVMCIPrimitiveArray new_booleanArray(int length, JVMCI_TRAPS); - JVMCIPrimitiveArray new_byteArray(int length, JVMCI_TRAPS); - JVMCIPrimitiveArray new_intArray(int length, JVMCI_TRAPS); - JVMCIPrimitiveArray new_longArray(int length, JVMCI_TRAPS); - - JVMCIObjectArray new_byte_array_array(int length, JVMCI_TRAPS); - - JVMCIObject new_StackTraceElement(const methodHandle& method, int bci, JVMCI_TRAPS); - JVMCIObject new_HotSpotNmethod(const methodHandle& method, const char* name, jboolean isDefault, jboolean profileDeopt, jlong compileId, JVMCI_TRAPS); - JVMCIObject new_VMField(JVMCIObject name, JVMCIObject type, jlong offset, jlong address, JVMCIObject value, JVMCI_TRAPS); - JVMCIObject new_VMFlag(JVMCIObject name, JVMCIObject type, JVMCIObject value, JVMCI_TRAPS); - JVMCIObject new_VMIntrinsicMethod(JVMCIObject declaringClass, JVMCIObject name, JVMCIObject descriptor, int id, jboolean isAvailable, jboolean c1Supported, jboolean c2Supported, JVMCI_TRAPS); - JVMCIObject new_HotSpotStackFrameReference(JVMCI_TRAPS); - JVMCIObject new_JVMCIError(JVMCI_TRAPS); - JVMCIObject new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS); - - // Makes a handle to a HotSpot heap object. These handles are - // individually reclaimed by JVMCIRuntime::destroy_oop_handle and - // bulk reclaimed by JVMCIRuntime::release_and_clear_globals. - jlong make_oop_handle(const Handle& obj); - oop resolve_oop_handle(jlong oopHandle); - - // These are analogous to the JNI routines - JVMCIObject make_local(JVMCIObject object); - void destroy_local(JVMCIObject object); - - // Makes a JNI global handle that is not scoped by the - // lifetime of a JVMCIRuntime (cf JVMCIRuntime::make_global). - // These JNI handles are used when translating an object - // between the HotSpot and JVMCI shared library heap via - // HotSpotJVMCIRuntime.translate(Object) and - // HotSpotJVMCIRuntime.unhand(Class, long). Translation - // can happen in either direction so the referenced object - // can reside in either heap which is why JVMCIRuntime scoped - // handles cannot be used (they are specific to HotSpot heap objects). - JVMCIObject make_global(JVMCIObject object); - - // Destroys a JNI global handle created by JVMCIEnv::make_global. - void destroy_global(JVMCIObject object); - - // Updates the nmethod (if any) in the HotSpotNmethod.address - // field of `mirror` to prevent it from being called. - // If `deoptimize` is true, the nmethod is immediately deoptimized. - // The HotSpotNmethod.address field is zero upon returning. - void invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimze, nmethod::InvalidationReason invalidation_reason, JVMCI_TRAPS); - - void initialize_installed_code(JVMCIObject installed_code, CodeBlob* cb, JVMCI_TRAPS); - - private: - JVMCICompileState* _compile_state; - - public: - - // Determines if this is for the JVMCI runtime in the HotSpot - // heap (true) or the shared library heap (false). - bool is_hotspot() { return _is_hotspot; } - - JVMCICompileState* compile_state() { return _compile_state; } - void set_compile_state(JVMCICompileState* compile_state) { - assert(_compile_state == nullptr, "set only once"); - _compile_state = compile_state; - } - // Generate declarations for the initialize, new, isa, get and set methods for all the types and - // fields declared in the JVMCI_CLASSES_DO macro. - -#define START_CLASS(className, fullClassName) \ - void className##_initialize(JVMCI_TRAPS); \ - JVMCIObjectArray new_##className##_array(int length, JVMCI_TRAPS); \ - bool isa_##className(JVMCIObject object); - -#define END_CLASS - -#define FIELD(className, name, type, accessor) \ - type get_ ## className ## _ ## name(JVMCIObject obj); \ - void set_ ## className ## _ ## name(JVMCIObject obj, type x); - -#define OOPISH_FIELD(className, name, type, hstype, accessor) \ - FIELD(className, name, type, accessor) - -#define STATIC_FIELD(className, name, type) \ - type get_ ## className ## _ ## name(); \ - void set_ ## className ## _ ## name(type x); - -#define STATIC_OOPISH_FIELD(className, name, type, hstype) \ - STATIC_FIELD(className, name, type) - -#define EMPTY_CAST -#define CHAR_FIELD(className, name) FIELD(className, name, jchar, char_field) -#define INT_FIELD(className, name) FIELD(className, name, jint, int_field) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, bool_field) -#define LONG_FIELD(className, name) FIELD(className, name, jlong, long_field) -#define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, float_field) -#define OBJECT_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObject, oop, obj_field) -#define OBJECTARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObjectArray, objArrayOop, obj_field) -#define PRIMARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIPrimitiveArray, typeArrayOop, obj_field) - -#define STATIC_INT_FIELD(className, name) STATIC_FIELD(className, name, jint) -#define STATIC_BOOLEAN_FIELD(className, name) STATIC_FIELD(className, name, jboolean) -#define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObject, oop) -#define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObjectArray, objArrayOop) -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) - - JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) - -#undef JNI_START_CLASS -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef FIELD -#undef OOPISH_FIELD -#undef STATIC_FIELD -#undef STATIC_OOPISH_FIELD -#undef STATIC_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef EMPTY_CAST - - // End of JVMCIEnv -}; - -#endif // SHARE_JVMCI_JVMCIENV_HPP diff --git a/src/hotspot/share/jvmci/jvmciExceptions.hpp b/src/hotspot/share/jvmci/jvmciExceptions.hpp deleted file mode 100644 index 2fd50c92486..00000000000 --- a/src/hotspot/share/jvmci/jvmciExceptions.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_JVMCI_JVMCIEXCEPTIONS_HPP -#define SHARE_JVMCI_JVMCIEXCEPTIONS_HPP - -class JVMCIEnv; - -// JVMCIEnv exception utility macros. Analogous to the regular CHECK, TRAP and THREAD macros. - -#define JVMCIENV __jvmci_env__ -#define JVMCI_TRAPS JVMCIEnv* JVMCIENV -#define PEER_JVMCIENV __peer_jvmci_env__ - -#define JVMCIENV_FROM_JNI(thread, env) \ - JVMCIEnv __stack_jvmci_env__(thread, env, __FILE__, __LINE__); \ - JVMCIEnv* JVMCIENV = &__stack_jvmci_env__ - -#define JVMCIENV_FROM_THREAD(thread) \ - JVMCIEnv __stack_jvmci_env__(thread, __FILE__, __LINE__); \ - JVMCIEnv* JVMCIENV = &__stack_jvmci_env__ - -#define PEER_JVMCIENV_FROM_THREAD(thread, is_hotspot) \ - JVMCIEnv __peer_stack_jvmci_env__(thread, is_hotspot, __FILE__, __LINE__); \ - JVMCIEnv* PEER_JVMCIENV = &__peer_stack_jvmci_env__ - - -#define JVMCI_PENDING_EXCEPTION (JVMCIENV->pending_exception()) -#define JVMCI_HAS_PENDING_EXCEPTION (JVMCIENV->has_pending_exception()) -#define JVMCI_CLEAR_PENDING_EXCEPTION (JVMCIENV->clear_pending_exception()) - -#define JVMCI_CHECK JVMCIENV); if (JVMCI_HAS_PENDING_EXCEPTION) return ; (void)(0 -#define JVMCI_CHECK_(result) JVMCIENV); if (JVMCI_HAS_PENDING_EXCEPTION) return result; (void)(0 -#define JVMCI_CHECK_0 JVMCI_CHECK_(0) -#define JVMCI_CHECK_NULL JVMCI_CHECK_(nullptr) -#define JVMCI_CHECK_false JVMCI_CHECK_(false) -#define JVMCI_CHECK_OK JVMCI_CHECK_(JVMCI::ok) - -#define JVMCI_ERROR(...) \ - { JVMCIENV->fthrow_error(__FILE__, __LINE__, __VA_ARGS__); return; } - -#define JVMCI_ERROR_(ret, ...) \ - { JVMCIENV->fthrow_error( __FILE__, __LINE__, __VA_ARGS__); return ret; } - -#define JVMCI_ERROR_0(...) JVMCI_ERROR_(0, __VA_ARGS__) -#define JVMCI_ERROR_NULL(...) JVMCI_ERROR_(nullptr, __VA_ARGS__) -#define JVMCI_ERROR_OK(...) JVMCI_ERROR_(JVMCI::ok, __VA_ARGS__) - -#define JVMCI_THROW(name) { JVMCIENV->throw_##name(); return; } -#define JVMCI_THROW_NULL(name) { JVMCIENV->throw_##name(); return nullptr; } -#define JVMCI_THROW_0(name) { JVMCIENV->throw_##name(); return 0; } -#define JVMCI_THROW_MSG_NULL(name, msg) { JVMCIENV->throw_##name(msg); return nullptr; } -#define JVMCI_THROW_MSG_(name, msg, value) { JVMCIENV->throw_##name(msg); return (value); } -#define JVMCI_THROW_MSG_0(name, msg) { JVMCIENV->throw_##name(msg); return 0; } -#define JVMCI_THROW_MSG(name, msg) { JVMCIENV->throw_##name(msg); return; } -#define JVMCI_THROW_(name, value) { JVMCIENV->throw_##name(); return (value); } - -#define JVMCI_CATCH \ - JVMCIENV); if (JVMCI_HAS_PENDING_EXCEPTION) { \ - JVMCIENV->describe_pending_exception(tty); \ - ShouldNotReachHere(); \ - } (void)(0 - -#endif // SHARE_JVMCI_JVMCIEXCEPTIONS_HPP diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp b/src/hotspot/share/jvmci/jvmciJavaClasses.cpp deleted file mode 100644 index e5c0017129c..00000000000 --- a/src/hotspot/share/jvmci/jvmciJavaClasses.cpp +++ /dev/null @@ -1,725 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" -#include "classfile/vmClasses.hpp" -#include "interpreter/linkResolver.hpp" -#include "jvmci/jniAccessMark.inline.hpp" -#include "jvmci/jvmciJavaClasses.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "memory/resourceArea.hpp" -#include "oops/instanceKlass.inline.hpp" -#include "runtime/fieldDescriptor.inline.hpp" -#include "runtime/java.hpp" -#include "runtime/jniHandles.inline.hpp" - -// ------------------------------------------------------------------ - -oop HotSpotJVMCI::resolve(JVMCIObject obj) { - return JNIHandles::resolve(obj.as_jobject()); -} - -arrayOop HotSpotJVMCI::resolve(JVMCIArray obj) { - return (arrayOop) JNIHandles::resolve(obj.as_jobject()); -} - -objArrayOop HotSpotJVMCI::resolve(JVMCIObjectArray obj) { - return (objArrayOop) JNIHandles::resolve(obj.as_jobject()); -} - -typeArrayOop HotSpotJVMCI::resolve(JVMCIPrimitiveArray obj) { - return (typeArrayOop) JNIHandles::resolve(obj.as_jobject()); -} - -JVMCIObject HotSpotJVMCI::wrap(oop obj) { - assert(Thread::current()->is_Java_thread(), "must be"); - return JVMCIObject(JNIHandles::make_local(obj), true); -} - -/** - * Computes the field offset of a static or instance field. - * It looks up the name and signature symbols without creating new ones; - * all the symbols of these classes need to be already loaded. - */ -void HotSpotJVMCI::compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) { - InstanceKlass* ik = InstanceKlass::cast(klass); - Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); - Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); - if (name_symbol == nullptr || signature_symbol == nullptr) { -#ifndef PRODUCT - ik->print_on(tty); -#endif - fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string()); - } - - fieldDescriptor fd; - if (!ik->find_field(name_symbol, signature_symbol, &fd)) { - ResourceMark rm; - fatal("Could not find field %s.%s with signature %s", ik->external_name(), name, signature); - } - guarantee(fd.is_static() == static_field, "static/instance mismatch"); - assert(fd.offset() != 0, "must be valid offset"); - if (dest_offset != fd.offset()) { - if (dest_offset != 0) { - fatal("offset for %s %s.%s re-initialized: %d -> %d", signature, ik->external_name(), name, dest_offset, fd.offset()); - } - dest_offset = fd.offset(); - if (static_field) { - // Must ensure classes for static fields are initialized as the - // accessor itself does not include a class initialization check. - ik->initialize(CHECK); - } - JVMCI_event_2(" field offset for %s %s.%s = %d", signature, ik->external_name(), name, dest_offset); - } -} - -#ifndef PRODUCT -static void check_resolve_method(const char* call_type, Klass* resolved_klass, Symbol* method_name, Symbol* method_signature, TRAPS) { - Method* method = nullptr; - LinkInfo link_info(resolved_klass, method_name, method_signature, nullptr, LinkInfo::AccessCheck::skip, LinkInfo::LoaderConstraintCheck::skip); - if (strcmp(call_type, "call_static") == 0) { - method = LinkResolver::resolve_static_call_or_null(link_info); - } else if (strcmp(call_type, "call_virtual") == 0) { - method = LinkResolver::resolve_virtual_call_or_null(resolved_klass, link_info); - } else if (strcmp(call_type, "call_special") == 0) { - method = LinkResolver::resolve_special_call_or_null(link_info); - } else { - fatal("Unknown or unsupported call type: %s", call_type); - } - if (method == nullptr) { - fatal("Could not resolve %s.%s%s", resolved_klass->external_name(), method_name->as_C_string(), method_signature->as_C_string()); - } -} -#endif - -jclass JNIJVMCI::_box_classes[T_CONFLICT+1]; -jclass JNIJVMCI::_byte_array; -jfieldID JNIJVMCI::_box_fields[T_CONFLICT+1]; -jmethodID JNIJVMCI::_box_constructors[T_CONFLICT+1]; -jmethodID JNIJVMCI::_Class_getName_method; - -jmethodID JNIJVMCI::_HotSpotResolvedJavaMethodImpl_fromMetaspace_method; -jmethodID JNIJVMCI::_HotSpotConstantPool_fromMetaspace_method; -jmethodID JNIJVMCI::_HotSpotResolvedObjectTypeImpl_fromMetaspace_method; -jmethodID JNIJVMCI::_HotSpotResolvedPrimitiveType_fromMetaspace_method; - -#define START_CLASS(className, fullClassName) { \ - Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::fullClassName(), true, CHECK); \ - InstanceKlass* current = className::_klass; \ - if (current != InstanceKlass::cast(k)) { \ - if (current != nullptr) { \ - fatal("klass for %s re-initialized: " PTR_FORMAT " -> " PTR_FORMAT, \ - k->external_name(), p2i(current), p2i(k)); \ - } \ - JVMCI_event_2(" klass for %s = " PTR_FORMAT, k->external_name(), p2i(k)); \ - className::_klass = InstanceKlass::cast(k); \ - className::_klass->initialize(CHECK); \ - } - -#define END_CLASS } - -#define FIELD(className, name, signature, static_field) compute_offset(className::_##name##_offset, className::_klass, #name, signature, static_field, CHECK); -#define CHAR_FIELD(className, name) FIELD(className, name, "C", false) -#define INT_FIELD(className, name) FIELD(className, name, "I", false) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", false) -#define LONG_FIELD(className, name) FIELD(className, name, "J", false) -#define FLOAT_FIELD(className, name) FIELD(className, name, "F", false) -#define OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, false) -#define STATIC_OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, true) -#define STATIC_INT_FIELD(className, name) FIELD(className, name, "I", true) -#define STATIC_BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", true) -#ifdef PRODUCT -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) -#else -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) \ - check_resolve_method(#hsCallType, k, vmSymbols::methodName##_name(), vmSymbols::signatureSymbolName(), CHECK); -#define CONSTRUCTOR(className, signature) { \ - TempNewSymbol sig = SymbolTable::new_symbol(signature); \ - check_resolve_method("call_special", k, vmSymbols::object_initializer_name(), sig, CHECK); \ - } -#endif -/** - * Computes and initializes the offsets used by HotSpotJVMCI. - */ -void HotSpotJVMCI::compute_offsets(TRAPS) { - JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) -} - -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef STATIC_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef EMPTY_CAST - -// ------------------------------------------------------------------ - -#define START_CLASS(className, fullClassName) \ - void HotSpotJVMCI::className::initialize(JVMCI_TRAPS) { \ - JavaThread* THREAD = JavaThread::current(); /* For exception macros. */ \ - className::klass()->initialize(CHECK); \ - } \ - bool HotSpotJVMCI::className::is_instance(JVMCIEnv* env, JVMCIObject object) { \ - return resolve(object)->is_a(className::klass()); \ - } \ - void HotSpotJVMCI::className::check(oop obj, const char* field_name, int offset) { \ - assert(obj != nullptr, "null field access of %s.%s", #className, field_name); \ - assert(obj->is_a(className::klass()), "wrong class, " #className " expected, found %s", obj->klass()->external_name()); \ - assert(offset != 0, "must be valid offset"); \ - } \ - InstanceKlass* HotSpotJVMCI::className::_klass = nullptr; - -#define END_CLASS - -#define FIELD(className, name, type, accessor, cast) \ - type HotSpotJVMCI::className::name(JVMCIEnv* env, oop obj) { className::check(obj, #name, className::_##name##_offset); return cast obj->accessor(className::_##name##_offset); } \ - void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, oop obj, type x) { className::check(obj, #name, className::_##name##_offset); obj->accessor##_put(className::_##name##_offset, x); } - -#define EMPTY_CAST -#define CHAR_FIELD(className, name) FIELD(className, name, jchar, char_field, EMPTY_CAST) -#define INT_FIELD(className, name) FIELD(className, name, jint, int_field, EMPTY_CAST) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, bool_field, EMPTY_CAST) -#define LONG_FIELD(className, name) FIELD(className, name, jlong, long_field, EMPTY_CAST) -#define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, float_field, EMPTY_CAST) - -#define OBJECT_FIELD(className, name, signature) FIELD(className, name, oop, obj_field, EMPTY_CAST) -#define OBJECTARRAY_FIELD(className, name, signature) FIELD(className, name, objArrayOop, obj_field, (objArrayOop)) -#define PRIMARRAY_FIELD(className, name, signature) FIELD(className, name, typeArrayOop, obj_field, (typeArrayOop)) -#define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, oop) -#define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, objArrayOop) -#define STATIC_OOPISH_FIELD(className, name, type) \ - type HotSpotJVMCI::className::name(JVMCIEnv* env) { \ - assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className); \ - InstanceKlass* ik = className::klass(); \ - oop base = ik->static_field_base_raw(); \ - oop result = HeapAccess<>::oop_load_at(base, className::_##name##_offset); \ - return type(result); \ - } \ - void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, type x) { \ - assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className); \ - assert(className::klass() != nullptr, "Class not yet loaded: " #className); \ - InstanceKlass* ik = className::klass(); \ - oop base = ik->static_field_base_raw(); \ - HeapAccess<>::oop_store_at(base, className::_##name##_offset, x); \ - } -#define STATIC_PRIMITIVE_FIELD(className, name, jtypename) \ - jtypename HotSpotJVMCI::className::get_##name(JVMCIEnv* env) { \ - assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className); \ - InstanceKlass* ik = className::klass(); \ - oop base = ik->static_field_base_raw(); \ - return *base->field_addr(className::_##name##_offset); \ - } \ - void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, jtypename x) { \ - assert(className::klass() != nullptr && className::klass()->is_linked(), "Class not yet linked: " #className); \ - InstanceKlass* ik = className::klass(); \ - oop base = ik->static_field_base_raw(); \ - *base->field_addr(className::_##name##_offset) = x; \ - } - -#define STATIC_INT_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jint) -#define STATIC_BOOLEAN_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jboolean) -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) - -/** - * Generates the method and field definitions for the classes in HotSpotJVMCI. For example: - * - * void HotSpotJVMCI::Architecture::initialize(JVMCIEnv* env) { ... } - * bool HotSpotJVMCI::Architecture::is_instance(JVMCIEnv* env, JVMCIObject object) { ... } - * void HotSpotJVMCI::Architecture::check(oop obj, const char* field_name, int offset) { ... } - * oop HotSpotJVMCI::Architecture::wordKind(JVMCIEnv* env, oop obj) { ... } - * void HotSpotJVMCI::Architecture::set_wordKind(JVMCIEnv* env, oop obj, oop x) { ... } - * - * InstanceKlass *HotSpotJVMCI::Architecture::_klass = nullptr; - */ -JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) - -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef STATIC_OOPISH_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef STATIC_PRIMITIVE_FIELD -#undef EMPTY_CAST - -/** - * Initializes the JNI id of a field. As per the JNI specification, - * this ensures the declaring class is initialized. - */ -void JNIJVMCI::initialize_field_id(JNIEnv* env, jfieldID &fieldid, jclass clazz, const char* class_name, const char* name, const char* signature, bool static_field) { - if (JVMCILibDumpJNIConfig != nullptr) { - fileStream* st = JVMCIGlobals::get_jni_config_file(); - st->print_cr("field %s %s %s", class_name, name, signature); - return; - } - if (env->ExceptionCheck()) { - return; - } - jfieldID current = fieldid; - if (static_field) { - // Class initialization barrier - fieldid = env->GetStaticFieldID(clazz, name, signature); - } else { - // Class initialization barrier - fieldid = env->GetFieldID(clazz, name, signature); - } - // SVM guarantees that jfieldIDs for fields in the native image are also - // in the image and thus always have the same address. - if (current != fieldid) { - if (current != nullptr) { - fatal("jfieldID for %s %s.%s re-initialized: " PTR_FORMAT " -> " PTR_FORMAT, - signature, class_name, name, p2i(current), p2i(fieldid)); - } - JVMCI_event_2(" jfieldID for %s %s.%s = " PTR_FORMAT, signature, class_name, name, p2i(fieldid)); - } - - - if (env->ExceptionCheck()) { - env->ExceptionDescribe(); - env->ExceptionClear(); - ResourceMark rm; - fatal("Could not find field %s.%s with signature %s", class_name, name, signature); - } -} - -#define START_CLASS(className, fullClassName) { \ - current_class_name = vmSymbols::fullClassName()->as_C_string(); \ - if (JVMCILibDumpJNIConfig != nullptr) { \ - fileStream* st = JVMCIGlobals::get_jni_config_file(); \ - st->print_cr("class %s", current_class_name); \ - } else { \ - jclass k = env->FindClass(current_class_name); \ - JVMCI_EXCEPTION_CHECK(env, "FindClass(%s)", current_class_name); \ - assert(k != nullptr, #fullClassName " not initialized"); \ - k = (jclass) env->NewGlobalRef(k); \ - jclass current = className::_class; \ - if (current != k) { \ - JVMCI_event_2(" jclass for %s = " PTR_FORMAT, current_class_name, p2i(k)); \ - /* SVM guarantees that jclass handles to classes in a native image are also */ \ - /* in the image. Further calling NewGlobalRef on such a handle returns a stable */ \ - /* value across all JavaVMs executing on the same native image. */ \ - if (current != nullptr) { \ - fatal("jclass for %s re-initialized: " PTR_FORMAT " -> " PTR_FORMAT, \ - current_class_name, p2i(current), p2i(k)); \ - } \ - className::_class = k; \ - } \ - } - -#define END_CLASS current_class_name = nullptr; } - -#define FIELD(className, name, signature, static_field) initialize_field_id(env, className::_##name##_field_id, className::_class, current_class_name, #name, signature, static_field); -#define CHAR_FIELD(className, name) FIELD(className, name, "C", false) -#define INT_FIELD(className, name) FIELD(className, name, "I", false) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", false) -#define LONG_FIELD(className, name) FIELD(className, name, "J", false) -#define FLOAT_FIELD(className, name) FIELD(className, name, "F", false) -#define OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, false) -#define STATIC_OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, true) -#define STATIC_INT_FIELD(className, name) FIELD(className, name, "I", true) -#define STATIC_BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", true) - -#define GET_JNI_METHOD(jniGetMethod, dst, clazz, methodName, signature) \ - if (JVMCILibDumpJNIConfig != nullptr) { \ - fileStream* st = JVMCIGlobals::get_jni_config_file(); \ - st->print_cr("method %s %s %s", current_class_name, methodName, signature); \ - } else { \ - jmethodID current = dst; \ - dst = env->jniGetMethod(clazz, methodName, signature); \ - assert(dst != nullptr, "uninitialized"); \ - if (current != dst) { \ - JVMCI_event_2(" jmethodID for %s.%s%s = " PTR_FORMAT, \ - current_class_name, methodName, signature, p2i(dst)); \ - /* SVM guarantees that jmethodIDs for methods in the native image are also */ \ - /* in the image and thus always have the same address. */ \ - if (current != nullptr) { \ - fatal("jmethod for %s.%s%s re-initialized: " PTR_FORMAT " -> " PTR_FORMAT, \ - current_class_name, methodName, signature, p2i(current), p2i(dst)); \ - } \ - JVMCI_EXCEPTION_CHECK(env, #jniGetMethod "(%s.%s%s)", \ - current_class_name, methodName, signature); \ - } \ - } - -#define GET_JNI_CONSTRUCTOR(clazz, signature) \ - GET_JNI_METHOD(GetMethodID, JNIJVMCI::clazz::_constructor, clazz::_class, "", signature) \ - -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) \ - GET_JNI_METHOD(jniGetMethod, \ - className::_##methodName##_method, \ - className::clazz(), \ - vmSymbols::methodName##_name()->as_C_string(), \ - vmSymbols::signatureSymbolName()->as_C_string()) - -#define CONSTRUCTOR(className, signature) \ - GET_JNI_CONSTRUCTOR(className, signature) - -extern "C" { - void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass); - jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); - jlong JNICALL JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets_handle); -} - -// Dumps symbols for public () and (String) methods of -// non-abstract Throwable subtypes known by the VM. This is to -// support the use of reflection in jdk.vm.ci.hotspot.TranslatedException.create(). -class ThrowableInitDumper : public SymbolClosure { - private: - fileStream* _st; - public: - ThrowableInitDumper(fileStream* st) { _st = st; } - void do_symbol(Symbol** p) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - Symbol* name = *p; - if (name == nullptr) { - return; - } - Klass* k = SystemDictionary::resolve_or_null(name, CHECK_EXIT); - if (k != nullptr && k->is_instance_klass()) { - InstanceKlass* iklass = InstanceKlass::cast(k); - if (iklass->is_subclass_of(vmClasses::Throwable_klass()) && iklass->is_public() && !iklass->is_abstract()) { - const char* class_name = nullptr; - Array* methods = iklass->methods(); - for (int i = 0; i < methods->length(); i++) { - Method* m = methods->at(i); - if (m->name() == vmSymbols::object_initializer_name() && - m->is_public() && - (m->signature() == vmSymbols::void_method_signature() || m->signature() == vmSymbols::string_void_signature())) { - if (class_name == nullptr) { - class_name = name->as_C_string(); - _st->print_cr("class %s", class_name); - } - _st->print_cr("method %s %s %s", class_name, m->name()->as_C_string(), m->signature()->as_C_string()); - } - } - } - } - } -}; - -#define IN_CLASS(fullClassName) current_class_name = vmSymbols::fullClassName()->as_C_string() -/** - * Initializes the JNI method and field ids used in JNIJVMCI. - */ -void JNIJVMCI::initialize_ids(JNIEnv* env) { - ResourceMark rm; - const char* current_class_name = nullptr; - JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) - - IN_CLASS(java_lang_Class); - GET_JNI_METHOD(GetMethodID, _Class_getName_method, Class::_class, "getName", "()Ljava/lang/String;"); - - IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType); - GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedPrimitiveType_fromMetaspace_method, HotSpotResolvedPrimitiveType::_class, - vmSymbols::fromMetaspace_name()->as_C_string(), - vmSymbols::primitive_fromMetaspace_signature()->as_C_string()); - IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl); - GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedObjectTypeImpl_fromMetaspace_method, HotSpotResolvedObjectTypeImpl::_class, - vmSymbols::fromMetaspace_name()->as_C_string(), - vmSymbols::klass_fromMetaspace_signature()->as_C_string()); - IN_CLASS(jdk_vm_ci_hotspot_HotSpotConstantPool); - GET_JNI_METHOD(GetStaticMethodID, _HotSpotConstantPool_fromMetaspace_method, HotSpotConstantPool::_class, - vmSymbols::fromMetaspace_name()->as_C_string(), - vmSymbols::constantPool_fromMetaspace_signature()->as_C_string()); - IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl); - GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedJavaMethodImpl_fromMetaspace_method, HotSpotResolvedJavaMethodImpl::_class, - vmSymbols::fromMetaspace_name()->as_C_string(), - vmSymbols::method_fromMetaspace_signature()->as_C_string()); - -#define BOX_CLASSES(generate) \ - generate(Boolean, T_BOOLEAN, Z) \ - generate(Byte, T_BYTE, B) \ - generate(Character, T_CHAR, C) \ - generate(Short, T_SHORT, S) \ - generate(Integer, T_INT, I) \ - generate(Long, T_LONG, J) \ - generate(Float, T_FLOAT, F) \ - generate(Double, T_DOUBLE, D) \ - -#define DO_BOX_CLASS(klass, basicType, type) \ - current_class_name = "java/lang/" #klass; \ - if (JVMCILibDumpJNIConfig == nullptr) { \ - _box_classes[basicType] = env->FindClass("java/lang/" #klass); \ - JVMCI_EXCEPTION_CHECK(env, "FindClass(%s)", #klass); \ - _box_classes[basicType] = (jclass) env->NewGlobalRef(_box_classes[basicType]); \ - assert(_box_classes[basicType] != nullptr, "uninitialized"); \ - _box_fields[basicType] = env->GetFieldID(_box_classes[basicType], "value", #type); \ - JVMCI_EXCEPTION_CHECK(env, "GetFieldID(%s, value, %s)", #klass, #type); \ - GET_JNI_METHOD(GetMethodID, _box_constructors[basicType], _box_classes[basicType], "", "(" #type ")V"); \ - } else { \ - fileStream* st = JVMCIGlobals::get_jni_config_file(); \ - st->print_cr("field %s value %s", current_class_name, #type); \ - st->print_cr("method %s (%s)V", current_class_name, #type); \ - } - - BOX_CLASSES(DO_BOX_CLASS); - - if (JVMCILibDumpJNIConfig == nullptr) { - _byte_array = env->FindClass("[B"); - JVMCI_EXCEPTION_CHECK(env, "FindClass([B)"); - _byte_array = (jclass) env->NewGlobalRef(_byte_array); - assert(_byte_array != nullptr, "uninitialized"); - } else { - fileStream* st = JVMCIGlobals::get_jni_config_file(); - st->print_cr("class [B"); - } - -#define DUMP_ALL_NATIVE_METHODS(class_symbol) do { \ - current_class_name = class_symbol->as_C_string(); \ - Klass* k = SystemDictionary::resolve_or_fail(class_symbol, true, CHECK_EXIT); \ - InstanceKlass* iklass = InstanceKlass::cast(k); \ - Array* methods = iklass->methods(); \ - for (int i = 0; i < methods->length(); i++) { \ - Method* m = methods->at(i); \ - if (m->is_native()) { \ - st->print_cr("method %s %s %s", current_class_name, m->name()->as_C_string(), m->signature()->as_C_string()); \ - } \ - } \ -} while(0) - - if (JVMCILibDumpJNIConfig != nullptr) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - fileStream* st = JVMCIGlobals::get_jni_config_file(); - - DUMP_ALL_NATIVE_METHODS(vmSymbols::jdk_vm_ci_hotspot_CompilerToVM()); - ThrowableInitDumper dumper(st); - vmSymbols::symbols_do(&dumper); - - st->flush(); - tty->print_cr("Dumped JVMCI shared library JNI configuration to %s", JVMCILibDumpJNIConfig); - vm_exit(0); - } - -#undef DUMP_ALL_NATIVE_METHODS -#undef DO_BOX_CLASS -#undef BOX_CLASSES -#undef IN_CLASS - -#define CC (char*) /*cast a literal from (const char*)*/ -#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f)) -} - -static void register_natives_for_class(JNIEnv* env, jclass clazz, const char* name, const JNINativeMethod *methods, jint nMethods) { - if (clazz == nullptr) { - clazz = env->FindClass(name); - if (env->ExceptionCheck()) { - env->ExceptionDescribe(); - fatal("Could not find class %s", name); - } - } - env->RegisterNatives(clazz, methods, nMethods); - if (env->ExceptionCheck()) { - env->ExceptionDescribe(); - fatal("Failure registering natives for %s", name); - } -} - -void JNIJVMCI::register_natives(JNIEnv* env) { - if (env != JavaThread::current()->jni_environment()) { - JNINativeMethod CompilerToVM_nmethods[] = {{ CC"registerNatives", CC"()V", FN_PTR(JVM_RegisterJVMCINatives) }}; - JNINativeMethod JVMCI_nmethods[] = {{ CC"initializeRuntime", CC"()Ljdk/vm/ci/runtime/JVMCIRuntime;", FN_PTR(JVM_GetJVMCIRuntime) }}; - JNINativeMethod Services_nmethods[] = {{ CC"readSystemPropertiesInfo", CC"([I)J", FN_PTR(JVM_ReadSystemPropertiesInfo) }}; - - register_natives_for_class(env, nullptr, "jdk/vm/ci/hotspot/CompilerToVM", CompilerToVM_nmethods, 1); - register_natives_for_class(env, JVMCI::clazz(), "jdk/vm/ci/runtime/JVMCI", JVMCI_nmethods, 1); - register_natives_for_class(env, Services::clazz(), "jdk/vm/ci/services/Services", Services_nmethods, 1); - } -} - -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD2 - -#define EMPTY0 -#define EMPTY1(x) -#define EMPTY2(x,y) -#define FIELD3(className, name, sig) FIELD2(className, name) -#define FIELD2(className, name) \ - jfieldID JNIJVMCI::className::_##name##_field_id = nullptr; \ - int HotSpotJVMCI::className::_##name##_offset = 0; -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) - -// Generates the definitions of static fields used by the accessors. For example: -// jfieldID JNIJVMCI::Architecture::_wordKind_field_id = 0; -// jfieldID HotSpotJVMCI::Architecture::_wordKind_offset = 0; -JVMCI_CLASSES_DO(EMPTY2, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2, METHOD, CONSTRUCTOR) - -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef STATIC_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef EMPTY_CAST - - -#define START_CLASS(className, fullClassName) \ - void JNIJVMCI::className::initialize(JVMCI_TRAPS) { \ - /* should already be initialized */ \ - } \ - bool JNIJVMCI::className::is_instance(JVMCIEnv* jvmciEnv, JVMCIObject object) { \ - JNIAccessMark jni(jvmciEnv); \ - return jni()->IsInstanceOf(object.as_jobject(), className::clazz()) != 0; \ - } \ - void JNIJVMCI::className::check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset) { \ - assert(obj.is_non_null(), "null field access of %s.%s", #className, field_name); \ - assert(jvmciEnv->isa_##className(obj), "wrong class, " #className " expected, found %s", jvmciEnv->klass_name(obj)); \ - assert(offset != nullptr, "must be valid offset"); \ - } \ - jclass JNIJVMCI::className::_class = nullptr; - -#define END_CLASS - -#define FIELD(className, name, type, accessor, cast) \ - type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj) { \ - className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ - JNIAccessMark jni(jvmciEnv); \ - return cast jni()->Get##accessor##Field(resolve_handle(obj), className::_##name##_field_id); \ - } \ - void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x) { \ - className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ - JNIAccessMark jni(jvmciEnv); \ - jni()->Set##accessor##Field(resolve_handle(obj), className::_##name##_field_id, x); \ - } \ - -#define EMPTY_CAST -#define CHAR_FIELD(className, name) FIELD(className, name, jchar, Char, EMPTY_CAST) -#define INT_FIELD(className, name) FIELD(className, name, jint, Int, EMPTY_CAST) -#define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, Boolean, EMPTY_CAST) -#define LONG_FIELD(className, name) FIELD(className, name, jlong, Long, EMPTY_CAST) -#define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, Float, EMPTY_CAST) - -#define OBJECT_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObject, Object, EMPTY_CAST) -#define OBJECTARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) -#define PRIMARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIPrimitiveArray, Object, (JVMCIPrimitiveArray)) - -#define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObject, Object, (JVMCIObject)) -#define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) - -#define OOPISH_FIELD(className, name, type, accessor, cast) \ - type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj) { \ - className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ - JNIAccessMark jni(jvmciEnv); \ - return cast wrap(jni()->Get##accessor##Field(resolve_handle(obj), className::_##name##_field_id)); \ - } \ - void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x) { \ - className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ - JNIAccessMark jni(jvmciEnv); \ - jni()->Set##accessor##Field(resolve_handle(obj), className::_##name##_field_id, resolve_handle(x)); \ - } - -#define STATIC_OOPISH_FIELD(className, name, type, accessor, cast) \ - type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv) { \ - JNIAccessMark jni(jvmciEnv); \ - return cast wrap(jni()->GetStatic##accessor##Field(className::clazz(), className::_##name##_field_id)); \ - } \ - void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, type x) { \ - JNIAccessMark jni(jvmciEnv); \ - jni()->SetStatic##accessor##Field(className::clazz(), className::_##name##_field_id, resolve_handle(x)); \ - } - -#define STATIC_PRIMITIVE_FIELD(className, name, type, accessor, cast) \ - type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv) { \ - JNIAccessMark jni(jvmciEnv); \ - return cast jni()->GetStatic##accessor##Field(className::clazz(), className::_##name##_field_id); \ - } \ - void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, type x) { \ - JNIAccessMark jni(jvmciEnv); \ - jni()->SetStatic##accessor##Field(className::clazz(), className::_##name##_field_id, x); \ - } - -#define STATIC_INT_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jint, Int, EMPTY_CAST) -#define STATIC_BOOLEAN_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jboolean, Boolean, EMPTY_CAST) -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) \ - jmethodID JNIJVMCI::className::_##methodName##_method; - -#define CONSTRUCTOR(className, signature) \ - jmethodID JNIJVMCI::className::_constructor; - -/** - * Generates the method definitions for the classes in HotSpotJVMCI. - */ -JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) - -#undef METHOD -#undef CONSTRUCTOR -#undef START_CLASS -#undef END_CLASS -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef STATIC_OOPISH_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef STATIC_PRIMITIVE_FIELD -#undef OOPISH_FIELD -#undef EMPTY_CAST diff --git a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp deleted file mode 100644 index 8bd34f52def..00000000000 --- a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCIJAVACLASSES_HPP -#define SHARE_JVMCI_JVMCIJAVACLASSES_HPP - -#include "classfile/vmSymbols.hpp" -#include "jvmci/jvmciExceptions.hpp" -#include "jvmci/jvmciObject.hpp" - -/* - * This macro defines the structure of the JVMCI classes accessed from VM code. It is used to - * generate accessors similar to javaClasses.hpp, but with specializations for HotSpot and JNI based - * access. - * - * HotSpotJVMCI: This class contains accessors based on the VM internal - * interface to Java. It is used for JVMCI Java code executing on the HotSpot heap. - * - * JNIJVMCI: This class contains JNI based accessors and is used for JVMCI - * Java code executing in the JVMCI shared library. - */ - -#define JVMCI_CLASSES_DO(start_class, \ - end_class, \ - char_field, \ - int_field, \ - boolean_field, \ - long_field, \ - float_field, \ - object_field, \ - primarray_field, \ - objectarray_field, \ - static_object_field, \ - static_objectarray_field, \ - static_int_field, \ - static_boolean_field, \ - jvmci_method, \ - jvmci_constructor) \ - start_class(Architecture, jdk_vm_ci_code_Architecture) \ - object_field(Architecture, wordKind, "Ljdk/vm/ci/meta/PlatformKind;") \ - end_class \ - start_class(HotSpotResolvedObjectTypeImpl, jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) \ - long_field(HotSpotResolvedObjectTypeImpl, klassPointer) \ - end_class \ - start_class(HotSpotResolvedPrimitiveType, jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType) \ - object_field(HotSpotResolvedPrimitiveType, mirror, "Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;") \ - object_field(HotSpotResolvedPrimitiveType, kind, "Ljdk/vm/ci/meta/JavaKind;") \ - static_objectarray_field(HotSpotResolvedPrimitiveType, primitives, "[Ljdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType;") \ - end_class \ - start_class(HotSpotResolvedJavaFieldImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaFieldImpl) \ - object_field(HotSpotResolvedJavaFieldImpl, type, "Ljdk/vm/ci/meta/JavaType;") \ - object_field(HotSpotResolvedJavaFieldImpl, holder, "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;") \ - int_field(HotSpotResolvedJavaFieldImpl, offset) \ - end_class \ - start_class(FieldInfo, jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl_FieldInfo) \ - int_field(FieldInfo, nameIndex) \ - int_field(FieldInfo, signatureIndex) \ - int_field(FieldInfo, offset) \ - int_field(FieldInfo, classfileFlags) \ - int_field(FieldInfo, internalFlags) \ - int_field(FieldInfo, initializerIndex) \ - jvmci_constructor(FieldInfo, "(IIIIII)V") \ - end_class \ - start_class(HotSpotResolvedJavaMethodImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) \ - long_field(HotSpotResolvedJavaMethodImpl, methodHandle) \ - end_class \ - start_class(HotSpotMethodData, jdk_vm_ci_hotspot_HotSpotMethodData) \ - long_field(HotSpotMethodData, methodDataPointer) \ - end_class \ - start_class(InstalledCode, jdk_vm_ci_code_InstalledCode) \ - long_field(InstalledCode, address) \ - long_field(InstalledCode, entryPoint) \ - long_field(InstalledCode, version) \ - object_field(InstalledCode, name, "Ljava/lang/String;") \ - end_class \ - start_class(HotSpotInstalledCode, jdk_vm_ci_hotspot_HotSpotInstalledCode) \ - int_field(HotSpotInstalledCode, size) \ - long_field(HotSpotInstalledCode, codeStart) \ - int_field(HotSpotInstalledCode, codeSize) \ - end_class \ - start_class(HotSpotNmethod, jdk_vm_ci_hotspot_HotSpotNmethod) \ - boolean_field(HotSpotNmethod, isDefault) \ - boolean_field(HotSpotNmethod, profileDeopt) \ - long_field(HotSpotNmethod, compileIdSnapshot) \ - object_field(HotSpotNmethod, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;") \ - int_field(HotSpotNmethod, invalidationReason) \ - jvmci_constructor(HotSpotNmethod, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;Ljava/lang/String;ZZJ)V") \ - end_class \ - start_class(HotSpotCompiledCode, jdk_vm_ci_hotspot_HotSpotCompiledCode) \ - primarray_field(HotSpotCompiledCode, targetCode, "[B") \ - primarray_field(HotSpotCompiledCode, dataSection, "[B") \ - end_class \ - start_class(HotSpotCompiledNmethod, jdk_vm_ci_hotspot_HotSpotCompiledNmethod) \ - object_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \ - int_field(HotSpotCompiledNmethod, id) \ - end_class \ - start_class(VMField, jdk_vm_ci_hotspot_VMField) \ - object_field(VMField, name, "Ljava/lang/String;") \ - object_field(VMField, type, "Ljava/lang/String;") \ - long_field(VMField, offset) \ - long_field(VMField, address) \ - object_field(VMField, value, "Ljava/lang/Object;") \ - jvmci_constructor(VMField, "(Ljava/lang/String;Ljava/lang/String;JJLjava/lang/Object;)V") \ - end_class \ - start_class(VMFlag, jdk_vm_ci_hotspot_VMFlag) \ - object_field(VMFlag, name, "Ljava/lang/String;") \ - object_field(VMFlag, type, "Ljava/lang/String;") \ - object_field(VMFlag, value, "Ljava/lang/Object;") \ - jvmci_constructor(VMFlag, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V") \ - end_class \ - start_class(VMIntrinsicMethod, jdk_vm_ci_hotspot_VMIntrinsicMethod) \ - object_field(VMIntrinsicMethod, declaringClass, "Ljava/lang/String;") \ - object_field(VMIntrinsicMethod, name, "Ljava/lang/String;") \ - object_field(VMIntrinsicMethod, descriptor, "Ljava/lang/String;") \ - int_field(VMIntrinsicMethod, id) \ - boolean_field(VMIntrinsicMethod, isAvailable) \ - boolean_field(VMIntrinsicMethod, c1Supported) \ - boolean_field(VMIntrinsicMethod, c2Supported) \ - jvmci_constructor(VMIntrinsicMethod, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZZ)V") \ - end_class \ - start_class(HotSpotCompilationRequestResult, jdk_vm_ci_hotspot_HotSpotCompilationRequestResult) \ - object_field(HotSpotCompilationRequestResult, failureMessage, "Ljava/lang/String;") \ - boolean_field(HotSpotCompilationRequestResult, retry) \ - int_field(HotSpotCompilationRequestResult, inlinedBytecodes) \ - end_class \ - start_class(BytecodeFrame, jdk_vm_ci_code_BytecodeFrame) \ - int_field(BytecodeFrame, numLocals) \ - int_field(BytecodeFrame, numStack) \ - int_field(BytecodeFrame, numLocks) \ - static_int_field(BytecodeFrame, UNKNOWN_BCI) \ - static_int_field(BytecodeFrame, UNWIND_BCI) \ - static_int_field(BytecodeFrame, BEFORE_BCI) \ - static_int_field(BytecodeFrame, AFTER_BCI) \ - static_int_field(BytecodeFrame, AFTER_EXCEPTION_BCI) \ - static_int_field(BytecodeFrame, INVALID_FRAMESTATE_BCI) \ - end_class \ - start_class(BytecodePosition, jdk_vm_ci_code_BytecodePosition) \ - object_field(BytecodePosition, caller, "Ljdk/vm/ci/code/BytecodePosition;") \ - object_field(BytecodePosition, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \ - int_field(BytecodePosition, bci) \ - end_class \ - start_class(JavaConstant, jdk_vm_ci_meta_JavaConstant) \ - static_object_field(JavaConstant, ILLEGAL, "Ljdk/vm/ci/meta/PrimitiveConstant;") \ - static_object_field(JavaConstant, NULL_POINTER, "Ljdk/vm/ci/meta/JavaConstant;") \ - jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JavaConstant, forPrimitive, forPrimitive_signature) \ - end_class \ - start_class(ResolvedJavaMethod, jdk_vm_ci_meta_ResolvedJavaMethod) \ - end_class \ - start_class(PrimitiveConstant, jdk_vm_ci_meta_PrimitiveConstant) \ - object_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;") \ - long_field(PrimitiveConstant, primitive) \ - end_class \ - start_class(HotSpotObjectConstantImpl, jdk_vm_ci_hotspot_HotSpotObjectConstantImpl) \ - boolean_field(HotSpotObjectConstantImpl, compressed) \ - end_class \ - start_class(DirectHotSpotObjectConstantImpl, jdk_vm_ci_hotspot_DirectHotSpotObjectConstantImpl) \ - object_field(DirectHotSpotObjectConstantImpl, object, "Ljava/lang/Object;") \ - jvmci_constructor(DirectHotSpotObjectConstantImpl, "(Ljava/lang/Object;Z)V") \ - end_class \ - start_class(IndirectHotSpotObjectConstantImpl, jdk_vm_ci_hotspot_IndirectHotSpotObjectConstantImpl) \ - long_field(IndirectHotSpotObjectConstantImpl, objectHandle) \ - jvmci_constructor(IndirectHotSpotObjectConstantImpl, "(JZZ)V") \ - end_class \ - start_class(JavaKind, jdk_vm_ci_meta_JavaKind) \ - char_field(JavaKind, typeChar) \ - end_class \ - start_class(ValueKind, jdk_vm_ci_meta_ValueKind) \ - object_field(ValueKind, platformKind, "Ljdk/vm/ci/meta/PlatformKind;") \ - end_class \ - start_class(HotSpotStackFrameReference, jdk_vm_ci_hotspot_HotSpotStackFrameReference) \ - object_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/vm/ci/hotspot/CompilerToVM;") \ - boolean_field(HotSpotStackFrameReference, objectsMaterialized) \ - long_field(HotSpotStackFrameReference, stackPointer) \ - int_field(HotSpotStackFrameReference, frameNumber) \ - int_field(HotSpotStackFrameReference, bci) \ - object_field(HotSpotStackFrameReference, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \ - objectarray_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \ - primarray_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \ - end_class \ - start_class(HotSpotConstantPool, jdk_vm_ci_hotspot_HotSpotConstantPool) \ - long_field(HotSpotConstantPool, constantPoolHandle) \ - end_class \ - start_class(HotSpotJVMCIRuntime, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime) \ - objectarray_field(HotSpotJVMCIRuntime, excludeFromJVMCICompilation, "[Ljava/lang/Module;") \ - jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, compileMethod, compileMethod_signature) \ - jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, isGCSupported, int_bool_signature) \ - jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, isIntrinsicSupported, int_bool_signature) \ - jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, bootstrapFinished, void_method_signature) \ - jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, shutdown, void_method_signature) \ - jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, runtime, runtime_signature) \ - jvmci_method(CallObjectMethod, GetMethodID, call_virtual, JVMCIObject, HotSpotJVMCIRuntime, getCompiler, getCompiler_signature) \ - jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, exceptionToString, exceptionToString_signature) \ - jvmci_method(CallStaticVoidMethod, GetStaticMethodID, call_static, void, HotSpotJVMCIRuntime, postTranslation, object_void_signature) \ - end_class \ - start_class(JVMCIError, jdk_vm_ci_common_JVMCIError) \ - jvmci_constructor(JVMCIError, "(Ljava/lang/String;)V") \ - end_class \ - start_class(InspectedFrameVisitor, jdk_vm_ci_code_stack_InspectedFrameVisitor) \ - end_class \ - start_class(Services, jdk_vm_ci_services_Services) \ - end_class \ - start_class(JVMCI, jdk_vm_ci_runtime_JVMCI) \ - jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JVMCI, getRuntime, getRuntime_signature) \ - jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JVMCI, initializeRuntime, initializeRuntime_signature) \ - end_class \ - start_class(Object, java_lang_Object) \ - end_class \ - start_class(String, java_lang_String) \ - end_class \ - start_class(Class, java_lang_Class) \ - jvmci_method(CallObjectMethod, GetMethodID, call_virtual, JVMCIObject, Class, getName, void_string_signature) \ - end_class \ - start_class(VMSupport, jdk_internal_vm_VMSupport) \ - jvmci_method(CallStaticIntMethod, GetStaticMethodID, call_static, int, VMSupport, encodeThrowable, encodeThrowable_signature) \ - jvmci_method(CallStaticVoidMethod, GetStaticMethodID, call_static, void, VMSupport, decodeAndThrowThrowable, decodeAndThrowThrowable_signature) \ - end_class \ - start_class(ArrayIndexOutOfBoundsException, java_lang_ArrayIndexOutOfBoundsException) \ - jvmci_constructor(ArrayIndexOutOfBoundsException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(IllegalStateException, java_lang_IllegalStateException) \ - jvmci_constructor(IllegalStateException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(NullPointerException, java_lang_NullPointerException) \ - jvmci_constructor(NullPointerException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(IllegalArgumentException, java_lang_IllegalArgumentException) \ - jvmci_constructor(IllegalArgumentException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(InternalError, java_lang_InternalError) \ - jvmci_constructor(InternalError, "(Ljava/lang/String;)V") \ - end_class \ - start_class(OutOfMemoryError, java_lang_OutOfMemoryError) \ - jvmci_constructor(OutOfMemoryError, "(Ljava/lang/String;)V") \ - end_class \ - start_class(NoClassDefFoundError, java_lang_NoClassDefFoundError) \ - jvmci_constructor(NoClassDefFoundError, "(Ljava/lang/String;)V") \ - end_class \ - start_class(InvalidInstalledCodeException, jdk_vm_ci_code_InvalidInstalledCodeException) \ - jvmci_constructor(InvalidInstalledCodeException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(UnsatisfiedLinkError, java_lang_UnsatisfiedLinkError) \ - jvmci_constructor(UnsatisfiedLinkError, "(Ljava/lang/String;)V") \ - end_class \ - start_class(UnsupportedOperationException, java_lang_UnsupportedOperationException) \ - jvmci_constructor(UnsupportedOperationException, "(Ljava/lang/String;)V") \ - end_class \ - start_class(StackTraceElement, java_lang_StackTraceElement) \ - object_field(StackTraceElement, declaringClass, "Ljava/lang/String;") \ - object_field(StackTraceElement, methodName, "Ljava/lang/String;") \ - object_field(StackTraceElement, fileName, "Ljava/lang/String;") \ - int_field(StackTraceElement, lineNumber) \ - jvmci_constructor(StackTraceElement, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V") \ - end_class \ - start_class(Throwable, java_lang_Throwable) \ - object_field(Throwable, detailMessage, "Ljava/lang/String;") \ - end_class \ - /* end*/ - -class JVMCICompiler; -class JVMCIEnv; - -#define START_CLASS(simpleClassName, fullClassName) \ - class simpleClassName { \ - friend class JVMCIEnv; \ - static void initialize(JVMCI_TRAPS); \ - static bool is_instance(JVMCIEnv* jvmciEnv, JVMCIObject object); \ - -#define END_CLASS }; - -#define EMPTY_CAST -#define CHAR_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jchar) -#define INT_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jint) -#define BOOLEAN_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jboolean) -#define LONG_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jlong) -#define FLOAT_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jfloat) - -#define OBJECT_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIObject, oop) -#define OBJECTARRAY_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIObjectArray, objArrayOop) -#define PRIMARRAY_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIPrimitiveArray, typeArrayOop) - -#define STATIC_INT_FIELD(simpleClassName, name) STATIC_FIELD(simpleClassName, name, jint) -#define STATIC_BOOLEAN_FIELD(simpleClassName, name) STATIC_FIELD(simpleClassName, name, jboolean) -#define STATIC_OBJECT_FIELD(simpleClassName, name, signature) STATIC_OOPISH_FIELD(simpleClassName, name, JVMCIObject, oop) -#define STATIC_OBJECTARRAY_FIELD(simpleClassName, name, signature) STATIC_OOPISH_FIELD(simpleClassName, name, JVMCIObjectArray, objArrayOop) - -#define HS_START_CLASS(simpleClassName, fullClassName) \ - START_CLASS(simpleClassName, fullClassName) \ - friend class HotSpotJVMCI; \ - private: \ - static void check(oop obj, const char* field_name, int offset); \ - static InstanceKlass* _klass; \ - public: \ - static InstanceKlass* klass() { assert(_klass != nullptr, "uninit"); return _klass; } \ - static Symbol* symbol() { return vmSymbols::fullClassName(); } - -#define FIELD(simpleClassName, name, type) \ - private: \ - static int _##name##_offset; \ - public: \ - static type get_ ## name(JVMCIEnv* env, JVMCIObject obj) { return name(env, resolve(obj)); } \ - static void set_ ## name(JVMCIEnv* env, JVMCIObject obj, type x) { set_ ## name(env, resolve(obj), x); } \ - static type name(JVMCIEnv* env, oop obj); \ - static void set_ ## name(JVMCIEnv* env, oop obj, type x); - -#define OOPISH_FIELD(simpleClassName, name, type, hstype) \ - private: \ - static int _##name##_offset; \ - public: \ - static type get_ ## name(JVMCIEnv* env, JVMCIObject obj) { return (type) wrap(name(env, resolve(obj))); } \ - static void set_ ## name(JVMCIEnv* env, JVMCIObject obj, type x) { set_ ## name(env, resolve(obj), (hstype) resolve(x)); } \ - static hstype name(JVMCIEnv* env, oop obj); \ - static void set_ ## name(JVMCIEnv* env, oop obj, hstype x); - -#define STATIC_FIELD(simpleClassName, name, type) \ - private: \ - static int _##name##_offset; \ - public: \ - static type get_ ## name(JVMCIEnv* env); \ - static void set_ ## name(JVMCIEnv* env, type x); - -#define STATIC_OOPISH_FIELD(simpleClassName, name, type, hstype) \ - private: \ - static int _##name##_offset; \ - public: \ - static type get_ ## name(JVMCIEnv* env) { return (type) wrap(name(env)); } \ - static void set_ ## name(JVMCIEnv* env, type x) { set_ ## name(env, (hstype) resolve(x)); } \ - static hstype name(JVMCIEnv* env); \ - static void set_ ## name(JVMCIEnv* env, hstype hstype); - -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, simpleClassName, methodName, signatureSymbolName) -#define CONSTRUCTOR(className, signature) - -/** - * VM internal interface to Java classes, methods and objects. For example: - * - * class HotSpotJVMCI { - * ... - * class Architecture { - * static void initialize(JVMCIEnv* env); - * static bool is_instance(JVMCIEnv* env, JVMCIObject object); - * private: - * static void check(oop obj, const char *field_name, int offset); - * public: - * static InstanceKlass *klass() { ... } - * static Symbol *symbol() { return vmSymbols::jdk_vm_ci_code_Architecture(); } - * private: - * static int _wordKind_offset; - * public: - * static JVMCIObject get_wordKind(JVMCIEnv *env, JVMCIObject obj) { ... } - * static void set_wordKind(JVMCIEnv *env, JVMCIObject obj, JVMCIObject x) { ... } - * static oop wordKind(JVMCIEnv *env, oop obj); - * static void set_wordKind(JVMCIEnv *env, oop obj, oop x); - * } - * ... - * }; - */ -class HotSpotJVMCI { - friend class JVMCIEnv; - - public: - - static oop resolve(JVMCIObject obj); - - static arrayOop resolve(JVMCIArray obj); - static objArrayOop resolve(JVMCIObjectArray obj); - static typeArrayOop resolve(JVMCIPrimitiveArray obj); - - static JVMCIObject wrap(jobject obj) { return JVMCIObject(obj, true); } - static JVMCIObject wrap(oop obj); - - static inline Method* asMethod(JVMCIEnv* env, oop jvmci_method) { - return *(Method**) HotSpotResolvedJavaMethodImpl::methodHandle(env, jvmci_method); - } - static inline ConstantPool* asConstantPool(JVMCIEnv* env, oop jvmci_constant_pool) { - return *(ConstantPool**) HotSpotConstantPool::constantPoolHandle(env, jvmci_constant_pool); - } - - static void compute_offsets(TRAPS); - static void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS); - - JVMCI_CLASSES_DO(HS_START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) -}; - -#undef HS_START_CLASS - -#define JNI_START_CLASS(simpleClassName, fullClassName) \ - START_CLASS(simpleClassName, fullClassName) \ - friend class JNIJVMCI; \ - private: \ - static void check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset); \ - static jclass _class; \ -public: \ - static jclass clazz() { assert(_class != nullptr, #fullClassName " uninitialized"); return _class; } \ - static jclass fullClassName ##_class() { assert(_class != nullptr, "uninit"); return _class; } - -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef OOPISH_FIELD -#undef STATIC_FIELD -#undef STATIC_OOPISH_FIELD - -#define FIELD(simpleClassName, name, type) \ - private: \ - static jfieldID _##name##_field_id; \ - public: \ - static type get_ ## name(JVMCIEnv* jvmciEnv, JVMCIObject obj); \ - static void set_ ## name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x); - -#define OOPISH_FIELD(simpleClassName, name, type, hstype) \ - FIELD(simpleClassName, name, type) - -#define STATIC_FIELD(simpleClassName, name, type) \ - private: \ - static jfieldID _##name##_field_id; \ - public: \ - static type get_ ## name(JVMCIEnv* jvmciEnv); \ - static void set_ ## name(JVMCIEnv* jvmciEnv, type x); - -#define STATIC_OOPISH_FIELD(simpleClassName, name, type, hstype) \ - STATIC_FIELD(simpleClassName, name, type) - -#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName) \ - public: \ - static jmethodID methodName##_method() { return _##methodName##_method; } \ - private: \ - static jmethodID _##methodName##_method; - -#define CONSTRUCTOR(className, signature) \ - public: \ - static jmethodID constructor() { return _constructor; } \ - private: \ - static jmethodID _constructor; - -/** - * JNI based interface to Java classes, methods and objects. For example: - * - * class JNIJVMCI { - * ... - * class Architecture { - * static void initialize(JVMCIEnv* env); - * static bool is_instance(JVMCIEnv* env, JVMCIObject object); - * private: - * static void check(oop obj, const char *field_name, int offset); - * static jclass _class; - * public: - * static jclass clazz() { return _class; } - * static jclass jdk_vm_ci_code_Architecture_class() { return _class; } - * private: - * static jfieldID _wordKind_field_id; - * public: - * static JVMCIObject get_wordKind(JVMCIEnv *env, JVMCIObject obj) { ... } - * static void set_wordKind(JVMCIEnv *env, JVMCIObject obj, JVMCIObject x) { ... } - * } - * ... - * }; - */ -class JNIJVMCI { - friend class JVMCIEnv; - - static jclass _byte_array; - static jclass _box_classes[T_CONFLICT+1]; - static jfieldID _box_fields[T_CONFLICT+1]; - static jmethodID _box_constructors[T_CONFLICT+1]; - static jmethodID _Class_getName_method; - - static jmethodID _HotSpotResolvedJavaMethodImpl_fromMetaspace_method; - static jmethodID _HotSpotConstantPool_fromMetaspace_method; - static jmethodID _HotSpotResolvedObjectTypeImpl_fromMetaspace_method; - static jmethodID _HotSpotResolvedPrimitiveType_fromMetaspace_method; - - public: - static jmethodID Class_getName_method() { return _Class_getName_method; } - - static jclass byte_array() { assert(_byte_array != nullptr, "uninit"); return _byte_array; } - - static jclass box_class(BasicType type) { assert(_box_classes[type]!= nullptr, "uninit"); return _box_classes[type]; } - static jfieldID box_field(BasicType type) { assert(_box_fields[type]!= nullptr, "uninit"); return _box_fields[type]; } - static jmethodID box_constructor(BasicType type) { assert(_box_constructors[type]!= nullptr, "uninit"); return _box_constructors[type]; } - - static jmethodID HotSpotResolvedJavaMethodImpl_fromMetaspace_method() { assert(_HotSpotResolvedJavaMethodImpl_fromMetaspace_method != nullptr, "uninit"); return _HotSpotResolvedJavaMethodImpl_fromMetaspace_method; } - static jmethodID HotSpotConstantPool_fromMetaspace_method() { assert(_HotSpotConstantPool_fromMetaspace_method != nullptr, "uninit"); return _HotSpotConstantPool_fromMetaspace_method; } - static jmethodID HotSpotResolvedObjectTypeImpl_fromMetaspace_method() { assert(_HotSpotResolvedObjectTypeImpl_fromMetaspace_method != nullptr, "uninit"); return _HotSpotResolvedObjectTypeImpl_fromMetaspace_method; } - static jmethodID HotSpotResolvedPrimitiveType_fromMetaspace_method() { assert(_HotSpotResolvedPrimitiveType_fromMetaspace_method != nullptr, "uninit"); return _HotSpotResolvedPrimitiveType_fromMetaspace_method; } - - static void initialize_ids(JNIEnv* env); - static void initialize_field_id(JNIEnv* env, jfieldID &dest_offset, jclass klass, const char* klass_name, const char* name, const char* signature, bool static_field); - static void register_natives(JNIEnv* env); - - static jobject resolve_handle(JVMCIObject obj) { return obj.as_jobject(); } - static JVMCIObject wrap(jobject obj) { return JVMCIObject(obj, false); } - - JVMCI_CLASSES_DO(JNI_START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) -}; - -#undef JNI_START_CLASS -#undef START_CLASS -#undef END_CLASS -#undef METHOD -#undef CONSTRUCTOR -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OBJECT_FIELD -#undef PRIMARRAY_FIELD -#undef OBJECTARRAY_FIELD -#undef FIELD -#undef OOPISH_FIELD -#undef STATIC_FIELD -#undef STATIC_OOPISH_FIELD -#undef STATIC_FIELD -#undef STATIC_OBJECT_FIELD -#undef STATIC_OBJECTARRAY_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef STATIC_PRIMITIVE_FIELD -#undef EMPTY_CAST - -#endif // SHARE_JVMCI_JVMCIJAVACLASSES_HPP diff --git a/src/hotspot/share/jvmci/jvmciObject.hpp b/src/hotspot/share/jvmci/jvmciObject.hpp deleted file mode 100644 index 44efb5bfcf3..00000000000 --- a/src/hotspot/share/jvmci/jvmciObject.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCIOBJECT_HPP -#define SHARE_JVMCI_JVMCIOBJECT_HPP - -#include "jni.h" -#include "utilities/debug.hpp" - -class JVMCIArray; -class JVMCIPrimitiveArray; -class JVMCIObjectArray; - -class JVMCIObject { - - private: - jobject _object; - bool _is_hotspot; - - public: - JVMCIObject(): _object(nullptr), _is_hotspot(false) {} - JVMCIObject(jobject o, bool is_hotspot): _object(o), _is_hotspot(is_hotspot) { } - - static JVMCIObject create(jobject o, bool is_hotspot) { JVMCIObject r(o, is_hotspot); return r; } - jobject as_jobject() { return _object; } - jobject as_jweak() { return (jweak) _object; } - jstring as_jstring() { return (jstring) _object; } - bool is_hotspot() { return _is_hotspot; } - - bool is_null() const { return _object == nullptr; } - bool is_non_null() const { return _object != nullptr; } - - operator JVMCIArray(); - operator JVMCIPrimitiveArray(); - operator JVMCIObjectArray(); -}; - -class JVMCIArray : public JVMCIObject { - public: - JVMCIArray() {} - JVMCIArray(jobject o, bool is_hotspot): JVMCIObject(o, is_hotspot) {} - jarray as_jobject() { return (jarray) JVMCIObject::as_jobject(); } -}; - -class JVMCIObjectArray : public JVMCIArray { - public: - JVMCIObjectArray() {} - JVMCIObjectArray(void* v): JVMCIArray() { assert(v == nullptr, "must be null"); } - JVMCIObjectArray(jobject o, bool is_hotspot): JVMCIArray(o, is_hotspot) {} - - jobjectArray as_jobject() { return (jobjectArray) JVMCIArray::as_jobject(); } -}; - -class JVMCIPrimitiveArray : public JVMCIArray { - public: - JVMCIPrimitiveArray() {} - JVMCIPrimitiveArray(void* v): JVMCIArray() { assert(v == nullptr, "must be null"); } - JVMCIPrimitiveArray(jobject o, bool is_hotspot): JVMCIArray(o, is_hotspot) {} - - jbooleanArray as_jbooleanArray() { return (jbooleanArray) as_jobject(); } - jbyteArray as_jbyteArray() { return (jbyteArray) as_jobject(); } - jcharArray as_jcharArray() { return (jcharArray) as_jobject(); } - jshortArray as_jshortArray() { return (jshortArray) as_jobject(); } - jintArray as_jintArray() { return (jintArray) as_jobject(); } - jfloatArray as_jfloatArray() { return (jfloatArray) as_jobject(); } - jlongArray as_jlongArray() { return (jlongArray) as_jobject(); } - jdoubleArray as_jdoubleArray() { return (jdoubleArray) as_jobject(); } -}; - -inline JVMCIObject::operator JVMCIArray() { return JVMCIArray(_object, _is_hotspot); } -inline JVMCIObject::operator JVMCIPrimitiveArray() { return JVMCIPrimitiveArray(_object, _is_hotspot); } -inline JVMCIObject::operator JVMCIObjectArray() { return JVMCIObjectArray(_object, _is_hotspot); } - -#endif // SHARE_JVMCI_JVMCIOBJECT_HPP diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp deleted file mode 100644 index 05e8188283d..00000000000 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ /dev/null @@ -1,2256 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/javaClasses.inline.hpp" -#include "classfile/symbolTable.hpp" -#include "classfile/systemDictionary.hpp" -#include "classfile/vmClasses.hpp" -#include "compiler/compileBroker.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/memAllocator.hpp" -#include "gc/shared/oopStorage.inline.hpp" -#include "jvmci/jniAccessMark.inline.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/metadataHandles.hpp" -#include "logging/log.hpp" -#include "logging/logStream.hpp" -#include "memory/oopFactory.hpp" -#include "memory/universe.hpp" -#include "oops/constantPool.inline.hpp" -#include "oops/klass.inline.hpp" -#include "oops/method.inline.hpp" -#include "oops/objArrayKlass.hpp" -#include "oops/oop.inline.hpp" -#include "oops/typeArrayOop.inline.hpp" -#include "prims/jvmtiExport.hpp" -#include "prims/methodHandles.hpp" -#include "runtime/arguments.hpp" -#include "runtime/atomicAccess.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/fieldDescriptor.inline.hpp" -#include "runtime/frame.inline.hpp" -#include "runtime/java.hpp" -#include "runtime/jniHandles.inline.hpp" -#include "runtime/mutex.hpp" -#include "runtime/reflection.hpp" -#include "runtime/sharedRuntime.hpp" -#include "runtime/synchronizer.hpp" -#if INCLUDE_G1GC -#include "gc/g1/g1BarrierSetRuntime.hpp" -#endif // INCLUDE_G1GC - -// Simple helper to see if the caller of a runtime stub which -// entered the VM has been deoptimized - -static bool caller_is_deopted() { - JavaThread* thread = JavaThread::current(); - RegisterMap reg_map(thread, - RegisterMap::UpdateMap::skip, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - frame runtime_frame = thread->last_frame(); - frame caller_frame = runtime_frame.sender(®_map); - assert(caller_frame.is_compiled_frame(), "must be compiled"); - return caller_frame.is_deoptimized_frame(); -} - -// Stress deoptimization -static void deopt_caller() { - if ( !caller_is_deopted()) { - JavaThread* thread = JavaThread::current(); - RegisterMap reg_map(thread, - RegisterMap::UpdateMap::skip, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - frame runtime_frame = thread->last_frame(); - frame caller_frame = runtime_frame.sender(®_map); - Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); - assert(caller_is_deopted(), "Must be deoptimized"); - } -} - -// Manages a scope for a JVMCI runtime call that attempts a heap allocation. -// If there is a pending OutOfMemoryError upon closing the scope and the runtime -// call is of the variety where allocation failure returns null without an -// exception, the following action is taken: -// 1. The pending OutOfMemoryError is cleared -// 2. null is written to JavaThread::_vm_result_oop -class RetryableAllocationMark { - private: - InternalOOMEMark _iom; - public: - RetryableAllocationMark(JavaThread* thread) : _iom(thread) {} - ~RetryableAllocationMark() { - JavaThread* THREAD = _iom.thread(); // For exception macros. - if (THREAD != nullptr) { - if (HAS_PENDING_EXCEPTION) { - oop ex = PENDING_EXCEPTION; - THREAD->set_vm_result_oop(nullptr); - if (ex->is_a(vmClasses::OutOfMemoryError_klass())) { - CLEAR_PENDING_EXCEPTION; - } - } - } - } -}; - -JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance_or_null(JavaThread* current, Klass* klass)) - JRT_BLOCK; - assert(klass->is_klass(), "not a class"); - Handle holder(current, klass->klass_holder()); // keep the klass alive - InstanceKlass* h = InstanceKlass::cast(klass); - { - RetryableAllocationMark ram(current); - h->check_valid_for_instantiation(true, CHECK); - if (!h->is_initialized()) { - // Cannot re-execute class initialization without side effects - // so return without attempting the initialization - current->set_vm_result_oop(nullptr); - return; - } - // allocate instance and return via TLS - oop obj = h->allocate_instance(CHECK); - current->set_vm_result_oop(obj); - } - JRT_BLOCK_END; - SharedRuntime::on_slowpath_allocation_exit(current); -JRT_END - -JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array_or_null(JavaThread* current, Klass* array_klass, jint length)) - JRT_BLOCK; - // Note: no handle for klass needed since they are not used - // anymore after new_objArray() and no GC can happen before. - // (This may have to change if this code changes!) - assert(array_klass->is_klass(), "not a class"); - oop obj; - if (array_klass->is_typeArray_klass()) { - BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); - RetryableAllocationMark ram(current); - obj = oopFactory::new_typeArray(elt_type, length, CHECK); - } else { - Handle holder(current, array_klass->klass_holder()); // keep the klass alive - Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); - RetryableAllocationMark ram(current); - obj = oopFactory::new_objArray(elem_klass, length, CHECK); - } - // This is pretty rare but this runtime patch is stressful to deoptimization - // if we deoptimize here so force a deopt to stress the path. - if (DeoptimizeALot) { - static int deopts = 0; - if (deopts++ % 2 == 0) { - // Drop the allocation - obj = nullptr; - } else { - deopt_caller(); - } - } - current->set_vm_result_oop(obj); - JRT_BLOCK_END; - SharedRuntime::on_slowpath_allocation_exit(current); -JRT_END - -JRT_ENTRY(void, JVMCIRuntime::new_multi_array_or_null(JavaThread* current, Klass* klass, int rank, jint* dims)) - assert(klass->is_klass(), "not a class"); - assert(rank >= 1, "rank must be nonzero"); - Handle holder(current, klass->klass_holder()); // keep the klass alive - RetryableAllocationMark ram(current); - oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); - current->set_vm_result_oop(obj); -JRT_END - -JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array_or_null(JavaThread* current, oopDesc* element_mirror, jint length)) - RetryableAllocationMark ram(current); - oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); - current->set_vm_result_oop(obj); -JRT_END - -JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance_or_null(JavaThread* current, oopDesc* type_mirror)) - InstanceKlass* klass = java_lang_Class::as_InstanceKlass(type_mirror); - - if (klass == nullptr) { - ResourceMark rm(current); - THROW(vmSymbols::java_lang_InstantiationException()); - } - RetryableAllocationMark ram(current); - - // Create new instance (the receiver) - klass->check_valid_for_instantiation(false, CHECK); - - if (!klass->is_initialized()) { - // Cannot re-execute class initialization without side effects - // so return without attempting the initialization - current->set_vm_result_oop(nullptr); - return; - } - - oop obj = klass->allocate_instance(CHECK); - current->set_vm_result_oop(obj); -JRT_END - -extern void vm_exit(int code); - -// Enter this method from compiled code handler below. This is where we transition -// to VM mode. This is done as a helper routine so that the method called directly -// from compiled code does not have to transition to VM. This allows the entry -// method to see if the nmethod that we have just looked up a handler for has -// been deoptimized while we were in the vm. This simplifies the assembly code -// cpu directories. -// -// We are entering here from exception stub (via the entry method below) -// If there is a compiled exception handler in this method, we will continue there; -// otherwise we will unwind the stack and continue at the caller of top frame method -// Note: we enter in Java using a special JRT wrapper. This wrapper allows us to -// control the area where we can allow a safepoint. After we exit the safepoint area we can -// check to see if the handler we are going to return is now in a nmethod that has -// been deoptimized. If that is the case we return the deopt blob -// unpack_with_exception entry instead. This makes life for the exception blob easier -// because making that same check and diverting is painful from assembly language. -JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* current, oopDesc* ex, address pc, nmethod*& nm)) - Handle exception(current, ex); - - // The frame we rethrow the exception to might not have been processed by the GC yet. - // The stack watermark barrier takes care of detecting that and ensuring the frame - // has updated oops. - StackWatermarkSet::after_unwind(current); - - nm = CodeCache::find_nmethod(pc); - assert(nm != nullptr, "did not find nmethod"); - // Adjust the pc as needed/ - if (nm->is_deopt_pc(pc)) { - RegisterMap map(current, - RegisterMap::UpdateMap::skip, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - frame exception_frame = current->last_frame().sender(&map); - // if the frame isn't deopted then pc must not correspond to the caller of last_frame - assert(exception_frame.is_deoptimized_frame(), "must be deopted"); - pc = exception_frame.pc(); - } - assert(exception.not_null(), "null exceptions should be handled by throw_exception"); - assert(oopDesc::is_oop(exception()), "just checking"); - // Check that exception is a subclass of Throwable - assert(exception->is_a(vmClasses::Throwable_klass()), - "Exception not subclass of Throwable"); - - // debugging support - // tracing - if (log_is_enabled(Info, exceptions)) { - ResourceMark rm; - stringStream tempst; - assert(nm->method() != nullptr, "Unexpected null method()"); - tempst.print("JVMCI compiled method <%s>\n" - " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, - nm->method()->print_value_string(), p2i(pc), p2i(current)); - Exceptions::log_exception(exception, tempst.as_string()); - } - // for AbortVMOnException flag - Exceptions::debug_check_abort(exception); - - // Check the stack guard pages and re-enable them if necessary and there is - // enough space on the stack to do so. Use fast exceptions only if the guard - // pages are enabled. - bool guard_pages_enabled = current->stack_overflow_state()->reguard_stack_if_needed(); - - if (JvmtiExport::can_post_on_exceptions()) { - // To ensure correct notification of exception catches and throws - // we have to deoptimize here. If we attempted to notify the - // catches and throws during this exception lookup it's possible - // we could deoptimize on the way out of the VM and end back in - // the interpreter at the throw site. This would result in double - // notifications since the interpreter would also notify about - // these same catches and throws as it unwound the frame. - - RegisterMap reg_map(current, - RegisterMap::UpdateMap::include, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); - frame stub_frame = current->last_frame(); - frame caller_frame = stub_frame.sender(®_map); - - // We don't really want to deoptimize the nmethod itself since we - // can actually continue in the exception handler ourselves but I - // don't see an easy way to have the desired effect. - Deoptimization::deoptimize_frame(current, caller_frame.id(), Deoptimization::Reason_constraint); - assert(caller_is_deopted(), "Must be deoptimized"); - - return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - } - - // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions - if (guard_pages_enabled) { - address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); - if (fast_continuation != nullptr) { - return fast_continuation; - } - } - - // If the stack guard pages are enabled, check whether there is a handler in - // the current method. Otherwise (guard pages disabled), force an unwind and - // skip the exception cache update (i.e., just leave continuation==nullptr). - address continuation = nullptr; - if (guard_pages_enabled) { - - // New exception handling mechanism can support inlined methods - // with exception handlers since the mappings are from PC to PC - - // Clear out the exception oop and pc since looking up an - // exception handler can cause class loading, which might throw an - // exception and those fields are expected to be clear during - // normal bytecode execution. - current->clear_exception_oop_and_pc(); - - bool recursive_exception = false; - continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false, recursive_exception); - // If an exception was thrown during exception dispatch, the exception oop may have changed - current->set_exception_oop(exception()); - current->set_exception_pc(pc); - - // The exception cache is used only for non-implicit exceptions - // Update the exception cache only when another exception did - // occur during the computation of the compiled exception handler - // (e.g., when loading the class of the catch type). - // Checking for exception oop equality is not - // sufficient because some exceptions are pre-allocated and reused. - if (continuation != nullptr && !recursive_exception && !SharedRuntime::deopt_blob()->contains(continuation)) { - nm->add_handler_for_exception_and_pc(exception, pc, continuation); - } - } - - if (log_is_enabled(Info, exceptions)) { - ResourceMark rm; - log_info(exceptions)("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT - " for exception thrown at PC " PTR_FORMAT, - p2i(current), p2i(continuation), p2i(pc)); - } - - return continuation; -JRT_END - -// Enter this method from compiled code only if there is a Java exception handler -// in the method handling the exception. -// We are entering here from exception stub. We don't do a normal VM transition here. -// We do it in a helper. This is so we can check to see if the nmethod we have just -// searched for an exception handler has been deoptimized in the meantime. -address JVMCIRuntime::exception_handler_for_pc(JavaThread* current) { - oop exception = current->exception_oop(); - address pc = current->exception_pc(); - // Still in Java mode - DEBUG_ONLY(NoHandleMark nhm); - nmethod* nm = nullptr; - address continuation = nullptr; - { - // Enter VM mode by calling the helper - ResetNoHandleMark rnhm; - continuation = exception_handler_for_pc_helper(current, exception, pc, nm); - } - // Back in JAVA, use no oops DON'T safepoint - - // Now check to see if the compiled method we were called from is now deoptimized. - // If so we must return to the deopt blob and deoptimize the nmethod - if (nm != nullptr && caller_is_deopted()) { - continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - } - - assert(continuation != nullptr, "no handler found"); - return continuation; -} - -JRT_BLOCK_ENTRY(void, JVMCIRuntime::monitorenter(JavaThread* current, oopDesc* obj, BasicLock* lock)) - SharedRuntime::monitor_enter_helper(obj, lock, current); -JRT_END - -JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* current, oopDesc* obj, BasicLock* lock)) - assert(current == JavaThread::current(), "pre-condition"); - assert(current->last_Java_sp(), "last_Java_sp must be set"); - assert(oopDesc::is_oop(obj), "invalid lock object pointer dected"); - SharedRuntime::monitor_exit_helper(obj, lock, current); -JRT_END - -// Object.notify() fast path, caller does slow path -JRT_LEAF(jboolean, JVMCIRuntime::object_notify(JavaThread* current, oopDesc* obj)) - assert(current == JavaThread::current(), "pre-condition"); - - // Very few notify/notifyAll operations find any threads on the waitset, so - // the dominant fast-path is to simply return. - // Relatedly, it's critical that notify/notifyAll be fast in order to - // reduce lock hold times. - if (!SafepointSynchronize::is_synchronizing()) { - if (ObjectSynchronizer::quick_notify(obj, current, false)) { - return true; - } - } - return false; // caller must perform slow path - -JRT_END - -// Object.notifyAll() fast path, caller does slow path -JRT_LEAF(jboolean, JVMCIRuntime::object_notifyAll(JavaThread* current, oopDesc* obj)) - assert(current == JavaThread::current(), "pre-condition"); - - if (!SafepointSynchronize::is_synchronizing() ) { - if (ObjectSynchronizer::quick_notify(obj, current, true)) { - return true; - } - } - return false; // caller must perform slow path - -JRT_END - -JRT_BLOCK_ENTRY(int, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* current, const char* exception, const char* message)) - JRT_BLOCK; - TempNewSymbol symbol = SymbolTable::new_symbol(exception); - SharedRuntime::throw_and_post_jvmti_exception(current, symbol, message); - JRT_BLOCK_END; - return caller_is_deopted(); -JRT_END - -JRT_BLOCK_ENTRY(int, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* current, const char* exception, Klass* klass)) - JRT_BLOCK; - ResourceMark rm(current); - TempNewSymbol symbol = SymbolTable::new_symbol(exception); - SharedRuntime::throw_and_post_jvmti_exception(current, symbol, klass->external_name()); - JRT_BLOCK_END; - return caller_is_deopted(); -JRT_END - -JRT_BLOCK_ENTRY(int, JVMCIRuntime::throw_class_cast_exception(JavaThread* current, const char* exception, Klass* caster_klass, Klass* target_klass)) - JRT_BLOCK; - ResourceMark rm(current); - const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass); - TempNewSymbol symbol = SymbolTable::new_symbol(exception); - SharedRuntime::throw_and_post_jvmti_exception(current, symbol, message); - JRT_BLOCK_END; - return caller_is_deopted(); -JRT_END - -class ArgumentPusher : public SignatureIterator { - protected: - JavaCallArguments* _jca; - jlong _argument; - bool _pushed; - - jlong next_arg() { - guarantee(!_pushed, "one argument"); - _pushed = true; - return _argument; - } - - float next_float() { - guarantee(!_pushed, "one argument"); - _pushed = true; - jvalue v; - v.i = (jint) _argument; - return v.f; - } - - double next_double() { - guarantee(!_pushed, "one argument"); - _pushed = true; - jvalue v; - v.j = _argument; - return v.d; - } - - Handle next_object() { - guarantee(!_pushed, "one argument"); - _pushed = true; - return Handle(Thread::current(), cast_to_oop(_argument)); - } - - public: - ArgumentPusher(Symbol* signature, JavaCallArguments* jca, jlong argument) : SignatureIterator(signature) { - this->_return_type = T_ILLEGAL; - _jca = jca; - _argument = argument; - _pushed = false; - do_parameters_on(this); - } - - void do_type(BasicType type) { - switch (type) { - case T_OBJECT: - case T_ARRAY: _jca->push_oop(next_object()); break; - case T_BOOLEAN: _jca->push_int((jboolean) next_arg()); break; - case T_CHAR: _jca->push_int((jchar) next_arg()); break; - case T_SHORT: _jca->push_int((jint) next_arg()); break; - case T_BYTE: _jca->push_int((jbyte) next_arg()); break; - case T_INT: _jca->push_int((jint) next_arg()); break; - case T_LONG: _jca->push_long((jlong) next_arg()); break; - case T_FLOAT: _jca->push_float(next_float()); break; - case T_DOUBLE: _jca->push_double(next_double()); break; - default: fatal("Unexpected type %s", type2name(type)); - } - } -}; - - -JRT_ENTRY(jlong, JVMCIRuntime::invoke_static_method_one_arg(JavaThread* current, Method* method, jlong argument)) - ResourceMark rm; - HandleMark hm(current); - - methodHandle mh(current, method); - if (mh->size_of_parameters() > 1 && !mh->is_static()) { - THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Invoked method must be static and take at most one argument"); - } - - Symbol* signature = mh->signature(); - JavaCallArguments jca(mh->size_of_parameters()); - ArgumentPusher jap(signature, &jca, argument); - BasicType return_type = jap.return_type(); - JavaValue result(return_type); - JavaCalls::call(&result, mh, &jca, CHECK_0); - - if (return_type == T_VOID) { - return 0; - } else if (return_type == T_OBJECT || return_type == T_ARRAY) { - current->set_vm_result_oop(result.get_oop()); - return 0; - } else { - jvalue *value = (jvalue *) result.get_value_addr(); - // Narrow the value down if required (Important on big endian machines) - switch (return_type) { - case T_BOOLEAN: - return (jboolean) value->i; - case T_BYTE: - return (jbyte) value->i; - case T_CHAR: - return (jchar) value->i; - case T_SHORT: - return (jshort) value->i; - case T_INT: - case T_FLOAT: - return value->i; - case T_LONG: - case T_DOUBLE: - return value->j; - default: - fatal("Unexpected type %s", type2name(return_type)); - return 0; - } - } -JRT_END - -JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline)) - ttyLocker ttyl; - - if (obj == nullptr) { - tty->print("null"); - } else if (oopDesc::is_oop_or_null(obj) && (!as_string || !java_lang_String::is_instance(obj))) { - if (oopDesc::is_oop_or_null(obj)) { - char buf[O_BUFLEN]; - tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj)); - } else { - tty->print(INTPTR_FORMAT, p2i(obj)); - } - } else { - ResourceMark rm; - assert(obj != nullptr && java_lang_String::is_instance(obj), "must be"); - char *buf = java_lang_String::as_utf8_string(obj); - tty->print_raw(buf); - } - if (newline) { - tty->cr(); - } -JRT_END - -#if INCLUDE_G1GC - -void JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj) { - G1BarrierSetRuntime::write_ref_field_pre_entry(obj, thread); -} - -#endif // INCLUDE_G1GC - -JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) - bool ret = true; - if(!Universe::heap()->is_in(parent)) { - tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent)); - parent->print(); - ret=false; - } - if(!Universe::heap()->is_in(child)) { - tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child)); - child->print(); - ret=false; - } - return (jint)ret; -JRT_END - -JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* current, jlong where, jlong format, jlong value)) - ResourceMark rm(current); - const char *error_msg = where == 0L ? "" : (char*) (address) where; - char *detail_msg = nullptr; - if (format != 0L) { - const char* buf = (char*) (address) format; - size_t detail_msg_length = strlen(buf) * 2; - detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); - jio_snprintf(detail_msg, detail_msg_length, buf, value); - } - report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg); -JRT_END - -JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread)) - oop exception = thread->exception_oop(); - assert(exception != nullptr, "npe"); - thread->set_exception_oop(nullptr); - thread->set_exception_pc(nullptr); - return exception; -JRT_END - -PRAGMA_DIAG_PUSH -PRAGMA_FORMAT_NONLITERAL_IGNORED -JRT_LEAF(void, JVMCIRuntime::log_printf(JavaThread* thread, const char* format, jlong v1, jlong v2, jlong v3)) - ResourceMark rm; - tty->print(format, v1, v2, v3); -JRT_END -PRAGMA_DIAG_POP - -static void decipher(jlong v, bool ignoreZero) { - if (v != 0 || !ignoreZero) { - void* p = (void *)(address) v; - CodeBlob* cb = CodeCache::find_blob(p); - if (cb) { - if (cb->is_nmethod()) { - char buf[O_BUFLEN]; - tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin())); - return; - } - cb->print_value_on(tty); - return; - } - if (Universe::heap()->is_in(p)) { - oop obj = cast_to_oop(p); - obj->print_value_on(tty); - return; - } - tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v); - } -} - -PRAGMA_DIAG_PUSH -PRAGMA_FORMAT_NONLITERAL_IGNORED -JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) - ResourceMark rm; - const char *buf = (const char*) (address) format; - if (vmError) { - if (buf != nullptr) { - fatal(buf, v1, v2, v3); - } else { - fatal(""); - } - } else if (buf != nullptr) { - tty->print(buf, v1, v2, v3); - } else { - assert(v2 == 0, "v2 != 0"); - assert(v3 == 0, "v3 != 0"); - decipher(v1, false); - } -JRT_END -PRAGMA_DIAG_POP - -JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) - union { - jlong l; - jdouble d; - jfloat f; - } uu; - uu.l = value; - switch (typeChar) { - case 'Z': tty->print(value == 0 ? "false" : "true"); break; - case 'B': tty->print("%d", (jbyte) value); break; - case 'C': tty->print("%c", (jchar) value); break; - case 'S': tty->print("%d", (jshort) value); break; - case 'I': tty->print("%d", (jint) value); break; - case 'F': tty->print("%f", uu.f); break; - case 'J': tty->print(JLONG_FORMAT, value); break; - case 'D': tty->print("%lf", uu.d); break; - default: assert(false, "unknown typeChar"); break; - } - if (newline) { - tty->cr(); - } -JRT_END - -JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* current, oopDesc* obj)) - return (jint) obj->identity_hash(); -JRT_END - -JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* current, int value)) - deopt_caller(); - return (jint) value; -JRT_END - - -// Implementation of JVMCI.initializeRuntime() -// When called from libjvmci, `libjvmciOrHotspotEnv` is a libjvmci env so use JVM_ENTRY_NO_ENV. -JVM_ENTRY_NO_ENV(jobject, JVM_GetJVMCIRuntime(JNIEnv *libjvmciOrHotspotEnv, jclass c)) - JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); - if (!EnableJVMCI) { - JVMCI_THROW_MSG_NULL(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); - } - JVMCIENV->runtime()->initialize_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); - JVMCIObject runtime = JVMCIENV->runtime()->get_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL); - return JVMCIENV->get_jobject(runtime); -JVM_END - -// Implementation of Services.readSystemPropertiesInfo(int[] offsets) -// When called from libjvmci, `env` is a libjvmci env so use JVM_ENTRY_NO_ENV. -JVM_ENTRY_NO_ENV(jlong, JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets_handle)) - JVMCIENV_FROM_JNI(thread, env); - if (!EnableJVMCI) { - JVMCI_THROW_MSG_0(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); - } - JVMCIPrimitiveArray offsets = JVMCIENV->wrap(offsets_handle); - JVMCIENV->put_int_at(offsets, 0, SystemProperty::next_offset_in_bytes()); - JVMCIENV->put_int_at(offsets, 1, SystemProperty::key_offset_in_bytes()); - JVMCIENV->put_int_at(offsets, 2, PathString::value_offset_in_bytes()); - - return (jlong) Arguments::system_properties(); -JVM_END - - -void JVMCINMethodData::initialize(int nmethod_mirror_index, - int nmethod_entry_patch_offset, - const char* nmethod_mirror_name, - bool is_default, - bool profile_deopt, - FailedSpeculation** failed_speculations) -{ - _failed_speculations = failed_speculations; - _nmethod_mirror_index = nmethod_mirror_index; - guarantee(nmethod_entry_patch_offset != -1, "missing entry barrier"); - _nmethod_entry_patch_offset = nmethod_entry_patch_offset; - if (nmethod_mirror_name != nullptr) { - _properties.bits._has_name = 1; - char* dest = (char*) name(); - strcpy(dest, nmethod_mirror_name); - } else { - _properties.bits._has_name = 0; - } - _properties.bits._is_default = is_default; - _properties.bits._profile_deopt = profile_deopt; -} - -void JVMCINMethodData::copy(JVMCINMethodData* data) { - initialize(data->_nmethod_mirror_index, data->_nmethod_entry_patch_offset, data->name(), data->_properties.bits._is_default, - data->_properties.bits._profile_deopt, data->_failed_speculations); -} - -void JVMCINMethodData::add_failed_speculation(nmethod* nm, jlong speculation) { - jlong index = speculation >> JVMCINMethodData::SPECULATION_LENGTH_BITS; - guarantee(index >= 0 && index <= max_jint, "Encoded JVMCI speculation index is not a positive Java int: " INTPTR_FORMAT, index); - int length = speculation & JVMCINMethodData::SPECULATION_LENGTH_MASK; - if (index + length > (uint) nm->speculations_size()) { - fatal(INTPTR_FORMAT "[index: " JLONG_FORMAT ", length: %d out of bounds wrt encoded speculations of length %u", speculation, index, length, nm->speculations_size()); - } - address data = nm->speculations_begin() + index; - FailedSpeculation::add_failed_speculation(nm, _failed_speculations, data, length); -} - -oop JVMCINMethodData::get_nmethod_mirror(nmethod* nm) { - if (_nmethod_mirror_index == -1) { - return nullptr; - } - return nm->oop_at(_nmethod_mirror_index); -} - -void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) { - guarantee(_nmethod_mirror_index != -1, "cannot set JVMCI mirror for nmethod"); - oop* addr = nm->oop_addr_at(_nmethod_mirror_index); - guarantee(new_mirror != nullptr, "use clear_nmethod_mirror to clear the mirror"); - guarantee(*addr == nullptr, "cannot overwrite non-null mirror"); - - *addr = new_mirror; - - // Since we've patched some oops in the nmethod, - // (re)register it with the heap. - MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag); - Universe::heap()->register_nmethod(nm); -} - -void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm, nmethod::InvalidationReason invalidation_reason) { - oop nmethod_mirror = get_nmethod_mirror(nm); - if (nmethod_mirror == nullptr) { - return; - } - - // Update the values in the mirror if it still refers to nm. - // We cannot use JVMCIObject to wrap the mirror as this is called - // during GC, forbidding the creation of JNIHandles. - JVMCIEnv* jvmciEnv = nullptr; - nmethod* current = (nmethod*) HotSpotJVMCI::InstalledCode::address(jvmciEnv, nmethod_mirror); - if (nm == current) { - if (nm->is_unloading()) { - // Break the link from the mirror to nm such that - // future invocations via the mirror will result in - // an InvalidInstalledCodeException. - HotSpotJVMCI::InstalledCode::set_address(jvmciEnv, nmethod_mirror, 0); - HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0); - HotSpotJVMCI::HotSpotInstalledCode::set_codeStart(jvmciEnv, nmethod_mirror, 0); - if (HotSpotJVMCI::HotSpotNmethod::invalidationReason(jvmciEnv, nmethod_mirror) == - static_cast(nmethod::InvalidationReason::NOT_INVALIDATED)) { - HotSpotJVMCI::HotSpotNmethod::set_invalidationReason(jvmciEnv, nmethod_mirror, static_cast(invalidation_reason)); - } - } else if (nm->is_not_entrant()) { - // Zero the entry point so any new invocation will fail but keep - // the address link around that so that existing activations can - // be deoptimized via the mirror (i.e. JVMCIEnv::invalidate_installed_code). - HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0); - HotSpotJVMCI::HotSpotInstalledCode::set_codeStart(jvmciEnv, nmethod_mirror, 0); - if (HotSpotJVMCI::HotSpotNmethod::invalidationReason(jvmciEnv, nmethod_mirror) == - static_cast(nmethod::InvalidationReason::NOT_INVALIDATED)) { - HotSpotJVMCI::HotSpotNmethod::set_invalidationReason(jvmciEnv, nmethod_mirror, static_cast(invalidation_reason)); - } - } - } - - if (_nmethod_mirror_index != -1 && nm->is_unloading()) { - // Drop the reference to the nmethod mirror object but don't clear the actual oop reference. Otherwise - // it would appear that the nmethod didn't need to be unloaded in the first place. - _nmethod_mirror_index = -1; - } -} - -// Handles to objects in the Hotspot heap. -static OopStorage* object_handles() { - return Universe::vm_global(); -} - -jlong JVMCIRuntime::make_oop_handle(const Handle& obj) { - assert(!Universe::heap()->is_stw_gc_active(), "can't extend the root set during GC pause"); - assert(oopDesc::is_oop(obj()), "not an oop"); - - oop* ptr = OopHandle(object_handles(), obj()).ptr_raw(); - MutexLocker ml(_lock); - _oop_handles.append(ptr); - return reinterpret_cast(ptr); -} - -#ifdef ASSERT -bool JVMCIRuntime::is_oop_handle(jlong handle) { - const oop* ptr = (oop*) handle; - return object_handles()->allocation_status(ptr) == OopStorage::ALLOCATED_ENTRY; -} -#endif - -int JVMCIRuntime::release_and_clear_oop_handles() { - guarantee(_num_attached_threads == cannot_be_attached, "only call during JVMCI runtime shutdown"); - int released = release_cleared_oop_handles(); - if (_oop_handles.length() != 0) { - for (int i = 0; i < _oop_handles.length(); i++) { - oop* oop_ptr = _oop_handles.at(i); - guarantee(oop_ptr != nullptr, "release_cleared_oop_handles left null entry in _oop_handles"); - guarantee(NativeAccess<>::oop_load(oop_ptr) != nullptr, "unexpected cleared handle"); - // Satisfy OopHandles::release precondition that all - // handles being released are null. - NativeAccess<>::oop_store(oop_ptr, (oop) nullptr); - } - - // Do the bulk release - object_handles()->release(_oop_handles.adr_at(0), _oop_handles.length()); - released += _oop_handles.length(); - } - _oop_handles.clear(); - return released; -} - -static bool is_referent_non_null(oop* handle) { - return handle != nullptr && NativeAccess<>::oop_load(handle) != nullptr; -} - -// Swaps the elements in `array` at index `a` and index `b` -static void swap(GrowableArray* array, int a, int b) { - oop* tmp = array->at(a); - array->at_put(a, array->at(b)); - array->at_put(b, tmp); -} - -int JVMCIRuntime::release_cleared_oop_handles() { - // Despite this lock, it's possible for another thread - // to clear a handle's referent concurrently (e.g., a thread - // executing IndirectHotSpotObjectConstantImpl.clear()). - // This is benign - it means there can still be cleared - // handles in _oop_handles when this method returns. - MutexLocker ml(_lock); - - int next = 0; - if (_oop_handles.length() != 0) { - // Key for _oop_handles contents in example below: - // H: handle with non-null referent - // h: handle with clear (i.e., null) referent - // -: null entry - - // Shuffle all handles with non-null referents to the front of the list - // Example: Before: 0HHh-Hh- - // After: HHHh--h- - for (int i = 0; i < _oop_handles.length(); i++) { - oop* handle = _oop_handles.at(i); - if (is_referent_non_null(handle)) { - if (i != next && !is_referent_non_null(_oop_handles.at(next))) { - // Swap elements at index `next` and `i` - swap(&_oop_handles, next, i); - } - next++; - } - } - - // `next` is now the index of the first null handle or handle with a null referent - int num_alive = next; - - // Shuffle all null handles to the end of the list - // Example: Before: HHHh--h- - // After: HHHhh--- - // num_alive: 3 - for (int i = next; i < _oop_handles.length(); i++) { - oop* handle = _oop_handles.at(i); - if (handle != nullptr) { - if (i != next && _oop_handles.at(next) == nullptr) { - // Swap elements at index `next` and `i` - swap(&_oop_handles, next, i); - } - next++; - } - } - if (next != num_alive) { - int to_release = next - num_alive; - - // `next` is now the index of the first null handle - // Example: to_release: 2 - - // Bulk release the handles with a null referent - object_handles()->release(_oop_handles.adr_at(num_alive), to_release); - - // Truncate oop handles to only those with a non-null referent - JVMCI_event_2("compacted oop handles in JVMCI runtime %d from %d to %d", _id, _oop_handles.length(), num_alive); - _oop_handles.trunc_to(num_alive); - // Example: HHH - - return to_release; - } - } - return 0; -} - -jmetadata JVMCIRuntime::allocate_handle(const methodHandle& handle) { - MutexLocker ml(_lock); - return _metadata_handles->allocate_handle(handle); -} - -jmetadata JVMCIRuntime::allocate_handle(const constantPoolHandle& handle) { - MutexLocker ml(_lock); - return _metadata_handles->allocate_handle(handle); -} - -void JVMCIRuntime::release_handle(jmetadata handle) { - MutexLocker ml(_lock); - _metadata_handles->chain_free_list(handle); -} - -// Function for redirecting shared library JavaVM output to tty -static void _log(const char* buf, size_t count) { - tty->write((char*) buf, count); -} - -// Function for redirecting shared library JavaVM fatal error data to a log file. -// The log file is opened on first call to this function. -static void _fatal_log(const char* buf, size_t count) { - JVMCI::fatal_log(buf, count); -} - -// Function for shared library JavaVM to flush tty -static void _flush_log() { - tty->flush(); -} - -// Function for shared library JavaVM to exit HotSpot on a fatal error -static void _fatal() { - Thread* thread = Thread::current_or_null_safe(); - if (thread != nullptr && thread->is_Java_thread()) { - JavaThread* jthread = JavaThread::cast(thread); - JVMCIRuntime* runtime = jthread->libjvmci_runtime(); - if (runtime != nullptr) { - int javaVM_id = runtime->get_shared_library_javavm_id(); - fatal("Fatal error in JVMCI shared library JavaVM[%d] owned by JVMCI runtime %d", javaVM_id, runtime->id()); - } - } - intx current_thread_id = os::current_thread_id(); - fatal("thread %zd: Fatal error in JVMCI shared library", current_thread_id); -} - -JVMCIRuntime::JVMCIRuntime(JVMCIRuntime* next, int id, bool for_compile_broker) : - _init_state(uninitialized), - _shared_library_javavm(nullptr), - _shared_library_javavm_id(0), - _id(id), - _next(next), - _metadata_handles(new MetadataHandles()), - _oop_handles(100, mtJVMCI), - _num_attached_threads(0), - _for_compile_broker(for_compile_broker) -{ - if (id == -1) { - _lock = JVMCIRuntime_lock; - } else { - stringStream lock_name; - lock_name.print("%s@%d", JVMCIRuntime_lock->name(), id); - Mutex::Rank lock_rank = DEBUG_ONLY(JVMCIRuntime_lock->rank()) NOT_DEBUG(Mutex::safepoint); - _lock = new PaddedMonitor(lock_rank, lock_name.as_string(/*c_heap*/true)); - } - JVMCI_event_1("created new %s JVMCI runtime %d (" PTR_FORMAT ")", - id == -1 ? "Java" : for_compile_broker ? "CompileBroker" : "Compiler", id, p2i(this)); -} - -JVMCIRuntime* JVMCIRuntime::select_runtime_in_shutdown(JavaThread* thread) { - assert(JVMCI_lock->owner() == thread, "must be"); - // When shutting down, use the first available runtime. - for (JVMCIRuntime* runtime = JVMCI::_compiler_runtimes; runtime != nullptr; runtime = runtime->_next) { - if (runtime->_num_attached_threads != cannot_be_attached) { - runtime->pre_attach_thread(thread); - JVMCI_event_1("using pre-existing JVMCI runtime %d in shutdown", runtime->id()); - return runtime; - } - } - // Lazily initialize JVMCI::_shutdown_compiler_runtime. Safe to - // do here since JVMCI_lock is locked. - if (JVMCI::_shutdown_compiler_runtime == nullptr) { - JVMCI::_shutdown_compiler_runtime = new JVMCIRuntime(nullptr, -2, true); - } - JVMCIRuntime* runtime = JVMCI::_shutdown_compiler_runtime; - JVMCI_event_1("using reserved shutdown JVMCI runtime %d", runtime->id()); - return runtime; -} - -JVMCIRuntime* JVMCIRuntime::select_runtime(JavaThread* thread, JVMCIRuntime* skip, int* count) { - assert(JVMCI_lock->owner() == thread, "must be"); - bool for_compile_broker = thread->is_Compiler_thread(); - for (JVMCIRuntime* runtime = JVMCI::_compiler_runtimes; runtime != nullptr; runtime = runtime->_next) { - if (count != nullptr) { - (*count)++; - } - if (for_compile_broker == runtime->_for_compile_broker) { - int count = runtime->_num_attached_threads; - if (count == cannot_be_attached || runtime == skip) { - // Cannot attach to rt - continue; - } - // If selecting for repacking, ignore a runtime without an existing JavaVM - if (skip != nullptr && !runtime->has_shared_library_javavm()) { - continue; - } - - // Select first runtime with sufficient capacity - if (count < (int) JVMCIThreadsPerNativeLibraryRuntime) { - runtime->pre_attach_thread(thread); - return runtime; - } - } - } - return nullptr; -} - -JVMCIRuntime* JVMCIRuntime::select_or_create_runtime(JavaThread* thread) { - assert(JVMCI_lock->owner() == thread, "must be"); - int id = 0; - JVMCIRuntime* runtime; - if (JVMCI::using_singleton_shared_library_runtime()) { - runtime = JVMCI::_compiler_runtimes; - guarantee(runtime != nullptr, "must be"); - while (runtime->_num_attached_threads == cannot_be_attached) { - // Since there is only a singleton JVMCIRuntime, we - // need to wait for it to be available for attaching. - JVMCI_lock->wait(); - } - runtime->pre_attach_thread(thread); - } else { - runtime = select_runtime(thread, nullptr, &id); - } - if (runtime == nullptr) { - runtime = new JVMCIRuntime(JVMCI::_compiler_runtimes, id, thread->is_Compiler_thread()); - JVMCI::_compiler_runtimes = runtime; - runtime->pre_attach_thread(thread); - } - return runtime; -} - -JVMCIRuntime* JVMCIRuntime::for_thread(JavaThread* thread) { - assert(thread->libjvmci_runtime() == nullptr, "must be"); - // Find the runtime with fewest attached threads - JVMCIRuntime* runtime = nullptr; - { - MutexLocker locker(JVMCI_lock); - runtime = JVMCI::in_shutdown() ? select_runtime_in_shutdown(thread) : select_or_create_runtime(thread); - } - runtime->attach_thread(thread); - return runtime; -} - -const char* JVMCIRuntime::attach_shared_library_thread(JavaThread* thread, JavaVM* javaVM) { - MutexLocker locker(JVMCI_lock); - for (JVMCIRuntime* runtime = JVMCI::_compiler_runtimes; runtime != nullptr; runtime = runtime->_next) { - if (runtime->_shared_library_javavm == javaVM) { - if (runtime->_num_attached_threads == cannot_be_attached) { - return "Cannot attach to JVMCI runtime that is shutting down"; - } - runtime->pre_attach_thread(thread); - runtime->attach_thread(thread); - return nullptr; - } - } - return "Cannot find JVMCI runtime"; -} - -void JVMCIRuntime::pre_attach_thread(JavaThread* thread) { - assert(JVMCI_lock->owner() == thread, "must be"); - _num_attached_threads++; -} - -void JVMCIRuntime::attach_thread(JavaThread* thread) { - assert(thread->libjvmci_runtime() == nullptr, "must be"); - thread->set_libjvmci_runtime(this); - guarantee(this == JVMCI::_shutdown_compiler_runtime || - _num_attached_threads > 0, - "missing reservation in JVMCI runtime %d: _num_attached_threads=%d", _id, _num_attached_threads); - JVMCI_event_1("attached to JVMCI runtime %d%s", _id, JVMCI::in_shutdown() ? " [in JVMCI shutdown]" : ""); -} - -void JVMCIRuntime::repack(JavaThread* thread) { - JVMCIRuntime* new_runtime = nullptr; - { - MutexLocker locker(JVMCI_lock); - if (JVMCI::using_singleton_shared_library_runtime() || _num_attached_threads != 1 || JVMCI::in_shutdown()) { - return; - } - new_runtime = select_runtime(thread, this, nullptr); - } - if (new_runtime != nullptr) { - JVMCI_event_1("Moving thread from JVMCI runtime %d to JVMCI runtime %d (%d attached)", _id, new_runtime->_id, new_runtime->_num_attached_threads - 1); - detach_thread(thread, "moving thread to another JVMCI runtime"); - new_runtime->attach_thread(thread); - } -} - -bool JVMCIRuntime::detach_thread(JavaThread* thread, const char* reason, bool can_destroy_javavm) { - if (this == JVMCI::_shutdown_compiler_runtime || JVMCI::in_shutdown()) { - // Do minimal work when shutting down JVMCI - thread->set_libjvmci_runtime(nullptr); - return false; - } - bool should_shutdown; - bool destroyed_javavm = false; - { - MutexLocker locker(JVMCI_lock); - _num_attached_threads--; - JVMCI_event_1("detaching from JVMCI runtime %d: %s (%d other threads still attached)", _id, reason, _num_attached_threads); - should_shutdown = _num_attached_threads == 0 && !JVMCI::in_shutdown(); - if (should_shutdown && !can_destroy_javavm) { - // If it's not possible to destroy the JavaVM on this thread then the VM must - // not be shutdown. This can happen when a shared library thread is the last - // thread to detach from a shared library JavaVM (e.g. GraalServiceThread). - JVMCI_event_1("Cancelled shut down of JVMCI runtime %d", _id); - should_shutdown = false; - } - if (should_shutdown) { - // Prevent other threads from attaching to this runtime - // while it is shutting down and destroying its JavaVM - _num_attached_threads = cannot_be_attached; - } - } - if (should_shutdown) { - // Release the JavaVM resources associated with this - // runtime once there are no threads attached to it. - shutdown(); - if (can_destroy_javavm) { - destroyed_javavm = destroy_shared_library_javavm(); - if (destroyed_javavm) { - // Can release all handles now that there's no code executing - // that could be using them. Handles for the Java JVMCI runtime - // are never released as we cannot guarantee all compiler threads - // using it have been stopped. - int released = release_and_clear_oop_handles(); - JVMCI_event_1("releasing handles for JVMCI runtime %d: oop handles=%d, metadata handles={total=%d, live=%d, blocks=%d}", - _id, - released, - _metadata_handles->num_handles(), - _metadata_handles->num_handles() - _metadata_handles->num_free_handles(), - _metadata_handles->num_blocks()); - - // No need to acquire _lock since this is the only thread accessing this runtime - _metadata_handles->clear(); - } - } - // Allow other threads to attach to this runtime now - MutexLocker locker(JVMCI_lock); - _num_attached_threads = 0; - if (JVMCI::using_singleton_shared_library_runtime()) { - // Notify any thread waiting to attach to the - // singleton JVMCIRuntime - JVMCI_lock->notify(); - } - } - thread->set_libjvmci_runtime(nullptr); - JVMCI_event_1("detached from JVMCI runtime %d", _id); - return destroyed_javavm; -} - -JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err, const char** err_msg) { - MutexLocker locker(_lock); - JavaVM* javaVM = _shared_library_javavm; - if (javaVM == nullptr) { -#ifdef ASSERT - const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.forceEnomemOnLibjvmciInit"); - if (val != nullptr && strcmp(val, "true") == 0) { - *create_JavaVM_err = JNI_ENOMEM; - return nullptr; - } -#endif - - char* sl_path; - void* sl_handle = JVMCI::get_shared_library(sl_path, true); - - jint (*JNI_CreateJavaVM)(JavaVM **pvm, void **penv, void *args); - typedef jint (*JNI_CreateJavaVM_t)(JavaVM **pvm, void **penv, void *args); - - JNI_CreateJavaVM = CAST_TO_FN_PTR(JNI_CreateJavaVM_t, os::dll_lookup(sl_handle, "JNI_CreateJavaVM")); - if (JNI_CreateJavaVM == nullptr) { - fatal("Unable to find JNI_CreateJavaVM in %s", sl_path); - } - - ResourceMark rm; - JavaVMInitArgs vm_args; - vm_args.version = JNI_VERSION_1_2; - vm_args.ignoreUnrecognized = JNI_TRUE; - JavaVMOption options[6]; - jlong javaVM_id = 0; - - // Protocol: JVMCI shared library JavaVM should support a non-standard "_javavm_id" - // option whose extraInfo info field is a pointer to which a unique id for the - // JavaVM should be written. - options[0].optionString = (char*) "_javavm_id"; - options[0].extraInfo = &javaVM_id; - - options[1].optionString = (char*) "_log"; - options[1].extraInfo = (void*) _log; - options[2].optionString = (char*) "_flush_log"; - options[2].extraInfo = (void*) _flush_log; - options[3].optionString = (char*) "_fatal"; - options[3].extraInfo = (void*) _fatal; - options[4].optionString = (char*) "_fatal_log"; - options[4].extraInfo = (void*) _fatal_log; - options[5].optionString = (char*) "_createvm_errorstr"; - options[5].extraInfo = (void*) err_msg; - - vm_args.version = JNI_VERSION_1_2; - vm_args.options = options; - vm_args.nOptions = sizeof(options) / sizeof(JavaVMOption); - - JNIEnv* env = nullptr; - int result = (*JNI_CreateJavaVM)(&javaVM, (void**) &env, &vm_args); - if (result == JNI_OK) { - guarantee(env != nullptr, "missing env"); - _shared_library_javavm_id = javaVM_id; - _shared_library_javavm = javaVM; - JVMCI_event_1("created JavaVM[%ld]@" PTR_FORMAT " for JVMCI runtime %d", javaVM_id, p2i(javaVM), _id); - return env; - } else { - *create_JavaVM_err = result; - } - } - return nullptr; -} - -void JVMCIRuntime::init_JavaVM_info(jlongArray info, JVMCI_TRAPS) { - if (info != nullptr) { - typeArrayOop info_oop = (typeArrayOop) JNIHandles::resolve(info); - if (info_oop->length() < 4) { - JVMCI_THROW_MSG(ArrayIndexOutOfBoundsException, err_msg("%d < 4", info_oop->length())); - } - JavaVM* javaVM = _shared_library_javavm; - info_oop->long_at_put(0, (jlong) (address) javaVM); - info_oop->long_at_put(1, (jlong) (address) javaVM->functions->reserved0); - info_oop->long_at_put(2, (jlong) (address) javaVM->functions->reserved1); - info_oop->long_at_put(3, (jlong) (address) javaVM->functions->reserved2); - } -} - -#define JAVAVM_CALL_BLOCK \ - guarantee(thread != nullptr && _shared_library_javavm != nullptr, "npe"); \ - ThreadToNativeFromVM ttnfv(thread); \ - JavaVM* javavm = _shared_library_javavm; - -jint JVMCIRuntime::AttachCurrentThread(JavaThread* thread, void **penv, void *args) { - JAVAVM_CALL_BLOCK - return javavm->AttachCurrentThread(penv, args); -} - -jint JVMCIRuntime::AttachCurrentThreadAsDaemon(JavaThread* thread, void **penv, void *args) { - JAVAVM_CALL_BLOCK - return javavm->AttachCurrentThreadAsDaemon(penv, args); -} - -jint JVMCIRuntime::DetachCurrentThread(JavaThread* thread) { - JAVAVM_CALL_BLOCK - return javavm->DetachCurrentThread(); -} - -jint JVMCIRuntime::GetEnv(JavaThread* thread, void **penv, jint version) { - JAVAVM_CALL_BLOCK - return javavm->GetEnv(penv, version); -} -#undef JAVAVM_CALL_BLOCK \ - -void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS) { - if (is_HotSpotJVMCIRuntime_initialized()) { - if (JVMCIENV->is_hotspot() && UseJVMCINativeLibrary) { - JVMCI_THROW_MSG(InternalError, "JVMCI has already been enabled in the JVMCI shared library"); - } - } - - initialize(JVMCI_CHECK); - - // This should only be called in the context of the JVMCI class being initialized - JVMCIObject result = JVMCIENV->call_HotSpotJVMCIRuntime_runtime(JVMCI_CHECK); - result = JVMCIENV->make_global(result); - - OrderAccess::storestore(); // Ensure handle is fully constructed before publishing - _HotSpotJVMCIRuntime_instance = result; - - JVMCI::_is_initialized = true; -} - -JVMCIRuntime::InitState JVMCIRuntime::_shared_library_javavm_refs_init_state = JVMCIRuntime::uninitialized; -JVMCIRuntime::InitState JVMCIRuntime::_hotspot_javavm_refs_init_state = JVMCIRuntime::uninitialized; - -class JavaVMRefsInitialization: public StackObj { - JVMCIRuntime::InitState *_state; - int _id; - public: - JavaVMRefsInitialization(JVMCIRuntime::InitState *state, int id) { - _state = state; - _id = id; - // All classes, methods and fields in the JVMCI shared library - // are in the read-only part of the image. As such, these - // values (and any global handle derived from them via NewGlobalRef) - // are the same for all JavaVM instances created in the - // shared library which means they only need to be initialized - // once. In non-product mode, we check this invariant. - // See com.oracle.svm.jni.JNIImageHeapHandles. - // The same is true for Klass* and field offsets in HotSpotJVMCI. - if (*state == JVMCIRuntime::uninitialized DEBUG_ONLY( || true)) { - *state = JVMCIRuntime::being_initialized; - JVMCI_event_1("initializing JavaVM references in JVMCI runtime %d", id); - } else { - while (*state != JVMCIRuntime::fully_initialized) { - JVMCI_event_1("waiting for JavaVM references initialization in JVMCI runtime %d", id); - JVMCI_lock->wait(); - } - JVMCI_event_1("done waiting for JavaVM references initialization in JVMCI runtime %d", id); - } - } - - ~JavaVMRefsInitialization() { - if (*_state == JVMCIRuntime::being_initialized) { - *_state = JVMCIRuntime::fully_initialized; - JVMCI_event_1("initialized JavaVM references in JVMCI runtime %d", _id); - JVMCI_lock->notify_all(); - } - } - - bool should_init() { - return *_state == JVMCIRuntime::being_initialized; - } -}; - -void JVMCIRuntime::initialize(JVMCI_TRAPS) { - // Check first without _lock - if (_init_state == fully_initialized) { - return; - } - - JavaThread* THREAD = JavaThread::current(); - - MutexLocker locker(_lock); - // Check again under _lock - if (_init_state == fully_initialized) { - return; - } - - while (_init_state == being_initialized) { - JVMCI_event_1("waiting for initialization of JVMCI runtime %d", _id); - _lock->wait(); - if (_init_state == fully_initialized) { - JVMCI_event_1("done waiting for initialization of JVMCI runtime %d", _id); - return; - } - } - - JVMCI_event_1("initializing JVMCI runtime %d", _id); - _init_state = being_initialized; - - { - MutexUnlocker unlock(_lock); - - HandleMark hm(THREAD); - ResourceMark rm(THREAD); - { - MutexLocker lock_jvmci(JVMCI_lock); - if (JVMCIENV->is_hotspot()) { - JavaVMRefsInitialization initialization(&_hotspot_javavm_refs_init_state, _id); - if (initialization.should_init()) { - MutexUnlocker unlock_jvmci(JVMCI_lock); - HotSpotJVMCI::compute_offsets(CHECK_EXIT); - } - } else { - JavaVMRefsInitialization initialization(&_shared_library_javavm_refs_init_state, _id); - if (initialization.should_init()) { - MutexUnlocker unlock_jvmci(JVMCI_lock); - JNIAccessMark jni(JVMCIENV, THREAD); - - JNIJVMCI::initialize_ids(jni.env()); - if (jni()->ExceptionCheck()) { - jni()->ExceptionDescribe(); - fatal("JNI exception during init"); - } - // _lock is re-locked at this point - } - } - } - - if (!JVMCIENV->is_hotspot()) { - JNIAccessMark jni(JVMCIENV, THREAD); - JNIJVMCI::register_natives(jni.env()); - } - create_jvmci_primitive_type(T_BOOLEAN, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_BYTE, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_CHAR, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_SHORT, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_INT, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_LONG, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_FLOAT, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_DOUBLE, JVMCI_CHECK_EXIT_((void)0)); - create_jvmci_primitive_type(T_VOID, JVMCI_CHECK_EXIT_((void)0)); - - DEBUG_ONLY(CodeInstaller::verify_bci_constants(JVMCIENV);) - } - - _init_state = fully_initialized; - JVMCI_event_1("initialized JVMCI runtime %d", _id); - _lock->notify_all(); -} - -JVMCIObject JVMCIRuntime::create_jvmci_primitive_type(BasicType type, JVMCI_TRAPS) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - // These primitive types are long lived and are created before the runtime is fully set up - // so skip registering them for scanning. - JVMCIObject mirror = JVMCIENV->get_object_constant(java_lang_Class::primitive_mirror(type), false, true); - if (JVMCIENV->is_hotspot()) { - JavaValue result(T_OBJECT); - JavaCallArguments args; - args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(mirror))); - args.push_int(type2char(type)); - JavaCalls::call_static(&result, HotSpotJVMCI::HotSpotResolvedPrimitiveType::klass(), vmSymbols::fromMetaspace_name(), vmSymbols::primitive_fromMetaspace_signature(), &args, CHECK_(JVMCIObject())); - - return JVMCIENV->wrap(JNIHandles::make_local(result.get_oop())); - } else { - JNIAccessMark jni(JVMCIENV); - jobject result = jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotResolvedPrimitiveType::clazz(), - JNIJVMCI::HotSpotResolvedPrimitiveType_fromMetaspace_method(), - mirror.as_jobject(), type2char(type)); - if (jni()->ExceptionCheck()) { - return JVMCIObject(); - } - return JVMCIENV->wrap(result); - } -} - -void JVMCIRuntime::initialize_JVMCI(JVMCI_TRAPS) { - if (!is_HotSpotJVMCIRuntime_initialized()) { - initialize(JVMCI_CHECK); - JVMCIENV->call_JVMCI_getRuntime(JVMCI_CHECK); - guarantee(_HotSpotJVMCIRuntime_instance.is_non_null(), "NPE in JVMCI runtime %d", _id); - } -} - -JVMCIObject JVMCIRuntime::get_HotSpotJVMCIRuntime(JVMCI_TRAPS) { - initialize(JVMCI_CHECK_(JVMCIObject())); - initialize_JVMCI(JVMCI_CHECK_(JVMCIObject())); - return _HotSpotJVMCIRuntime_instance; -} - -// Implementation of CompilerToVM.registerNatives() -// When called from libjvmci, `libjvmciOrHotspotEnv` is a libjvmci env so use JVM_ENTRY_NO_ENV. -JVM_ENTRY_NO_ENV(void, JVM_RegisterJVMCINatives(JNIEnv *libjvmciOrHotspotEnv, jclass c2vmClass)) - JVMCIENV_FROM_JNI(thread, libjvmciOrHotspotEnv); - - if (!EnableJVMCI) { - JVMCI_THROW_MSG(InternalError, JVMCI_NOT_ENABLED_ERROR_MESSAGE); - } - - JVMCIENV->runtime()->initialize(JVMCIENV); - - { - ResourceMark rm(thread); - HandleMark hm(thread); - ThreadToNativeFromVM trans(thread); - - // Ensure _non_oop_bits is initialized - Universe::non_oop_word(); - JNIEnv *env = libjvmciOrHotspotEnv; - if (JNI_OK != env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count())) { - if (!env->ExceptionCheck()) { - for (int i = 0; i < CompilerToVM::methods_count(); i++) { - if (JNI_OK != env->RegisterNatives(c2vmClass, CompilerToVM::methods + i, 1)) { - guarantee(false, "Error registering JNI method %s%s", CompilerToVM::methods[i].name, CompilerToVM::methods[i].signature); - break; - } - } - } else { - env->ExceptionDescribe(); - } - guarantee(false, "Failed registering CompilerToVM native methods"); - } - } -JVM_END - - -void JVMCIRuntime::shutdown() { - if (_HotSpotJVMCIRuntime_instance.is_non_null()) { - JVMCI_event_1("shutting down HotSpotJVMCIRuntime for JVMCI runtime %d", _id); - JVMCIEnv __stack_jvmci_env__(JavaThread::current(), _HotSpotJVMCIRuntime_instance.is_hotspot(),__FILE__, __LINE__); - JVMCIEnv* JVMCIENV = &__stack_jvmci_env__; - if (JVMCIENV->init_error() == JNI_OK) { - JVMCIENV->call_HotSpotJVMCIRuntime_shutdown(_HotSpotJVMCIRuntime_instance); - } else { - JVMCI_event_1("Error in JVMCIEnv for shutdown (err: %d)", JVMCIENV->init_error()); - } - if (_num_attached_threads == cannot_be_attached) { - // Only when no other threads are attached to this runtime - // is it safe to reset these fields. - _HotSpotJVMCIRuntime_instance = JVMCIObject(); - _init_state = uninitialized; - JVMCI_event_1("shut down JVMCI runtime %d", _id); - } - } -} - -bool JVMCIRuntime::destroy_shared_library_javavm() { - guarantee(_num_attached_threads == cannot_be_attached, - "cannot destroy JavaVM for JVMCI runtime %d with %d attached threads", _id, _num_attached_threads); - JavaVM* javaVM; - jlong javaVM_id = _shared_library_javavm_id; - { - // Exactly one thread can destroy the JavaVM - // and release the handle to it. - MutexLocker only_one(_lock); - javaVM = _shared_library_javavm; - if (javaVM != nullptr) { - _shared_library_javavm = nullptr; - _shared_library_javavm_id = 0; - } - } - if (javaVM != nullptr) { - int result; - { - // Must transition into native before calling into libjvmci - ThreadToNativeFromVM ttnfv(JavaThread::current()); - result = javaVM->DestroyJavaVM(); - } - if (result == JNI_OK) { - JVMCI_event_1("destroyed JavaVM[" JLONG_FORMAT "]@" PTR_FORMAT " for JVMCI runtime %d", javaVM_id, p2i(javaVM), _id); - } else { - warning("Non-zero result (%d) when calling JNI_DestroyJavaVM on JavaVM[" JLONG_FORMAT "]@" PTR_FORMAT, result, javaVM_id, p2i(javaVM)); - } - return true; - } - return false; -} - -void JVMCIRuntime::bootstrap_finished(TRAPS) { - if (_HotSpotJVMCIRuntime_instance.is_non_null()) { - JVMCIENV_FROM_THREAD(THREAD); - JVMCIENV->check_init(CHECK); - JVMCIENV->call_HotSpotJVMCIRuntime_bootstrapFinished(_HotSpotJVMCIRuntime_instance, JVMCIENV); - } -} - -void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD) { - if (HAS_PENDING_EXCEPTION) { - Handle exception(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - java_lang_Throwable::print_stack_trace(exception, tty); - - // Clear and ignore any exceptions raised during printing - CLEAR_PENDING_EXCEPTION; - } -} - - -void JVMCIRuntime::fatal_exception(JVMCIEnv* JVMCIENV, const char* message) { - JavaThread* THREAD = JavaThread::current(); // For exception macros. - - static volatile int report_error = 0; - if (!report_error && AtomicAccess::cmpxchg(&report_error, 0, 1) == 0) { - // Only report an error once - tty->print_raw_cr(message); - if (JVMCIENV != nullptr) { - JVMCIENV->describe_pending_exception(tty); - } else { - describe_pending_hotspot_exception(THREAD); - } - } else { - // Allow error reporting thread time to print the stack trace. - THREAD->sleep(200); - } - fatal("Fatal JVMCI exception (see JVMCI Events for stack trace): %s", message); -} - -// ------------------------------------------------------------------ -// Note: the logic of this method should mirror the logic of -// constantPoolOopDesc::verify_constant_pool_resolve. -bool JVMCIRuntime::check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass) { - if (accessing_klass->is_objArray_klass()) { - accessing_klass = ObjArrayKlass::cast(accessing_klass)->bottom_klass(); - } - if (!accessing_klass->is_instance_klass()) { - return true; - } - - if (resolved_klass->is_objArray_klass()) { - // Find the element klass, if this is an array. - resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass(); - } - if (resolved_klass->is_instance_klass()) { - Reflection::VerifyClassAccessResults result = - Reflection::verify_class_access(accessing_klass, InstanceKlass::cast(resolved_klass), true); - return result == Reflection::ACCESS_OK; - } - return true; -} - -// ------------------------------------------------------------------ -Klass* JVMCIRuntime::get_klass_by_name_impl(Klass*& accessing_klass, - const constantPoolHandle& cpool, - Symbol* sym, - bool require_local) { - JVMCI_EXCEPTION_CONTEXT; - - // Now we need to check the SystemDictionary - if (sym->char_at(0) == JVM_SIGNATURE_CLASS && - sym->char_at(sym->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) { - // This is a name from a signature. Strip off the trimmings. - // Call recursive to keep scope of strippedsym. - TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, - sym->utf8_length()-2); - return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); - } - - Handle loader; - if (accessing_klass != nullptr) { - loader = Handle(THREAD, accessing_klass->class_loader()); - } - - Klass* found_klass = require_local ? - SystemDictionary::find_instance_or_array_klass(THREAD, sym, loader) : - SystemDictionary::find_constrained_instance_or_array_klass(THREAD, sym, loader); - - // If we fail to find an array klass, look again for its element type. - // The element type may be available either locally or via constraints. - // In either case, if we can find the element type in the system dictionary, - // we must build an array type around it. The CI requires array klasses - // to be loaded if their element klasses are loaded, except when memory - // is exhausted. - if (sym->char_at(0) == JVM_SIGNATURE_ARRAY && - (sym->char_at(1) == JVM_SIGNATURE_ARRAY || sym->char_at(1) == JVM_SIGNATURE_CLASS)) { - // We have an unloaded array. - // Build it on the fly if the element class exists. - TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, - sym->utf8_length()-1); - - // Get element Klass recursively. - Klass* elem_klass = - get_klass_by_name_impl(accessing_klass, - cpool, - elem_sym, - require_local); - if (elem_klass != nullptr) { - // Now make an array for it - return elem_klass->array_klass(THREAD); - } - } - - if (found_klass == nullptr && !cpool.is_null() && cpool->has_preresolution()) { - // Look inside the constant pool for pre-resolved class entries. - for (int i = cpool->length() - 1; i >= 1; i--) { - if (cpool->tag_at(i).is_klass()) { - Klass* kls = cpool->resolved_klass_at(i); - if (kls->name() == sym) { - return kls; - } - } - } - } - - return found_klass; -} - -// ------------------------------------------------------------------ -Klass* JVMCIRuntime::get_klass_by_name(Klass* accessing_klass, - Symbol* klass_name, - bool require_local) { - ResourceMark rm; - constantPoolHandle cpool; - return get_klass_by_name_impl(accessing_klass, - cpool, - klass_name, - require_local); -} - -// ------------------------------------------------------------------ -// Implementation of get_klass_by_index. -Klass* JVMCIRuntime::get_klass_by_index_impl(const constantPoolHandle& cpool, - int index, - bool& is_accessible, - Klass* accessor) { - JVMCI_EXCEPTION_CONTEXT; - Klass* klass = ConstantPool::klass_at_if_loaded(cpool, index); - Symbol* klass_name = nullptr; - if (klass == nullptr) { - klass_name = cpool->klass_name_at(index); - } - - if (klass == nullptr) { - // Not found in constant pool. Use the name to do the lookup. - Klass* k = get_klass_by_name_impl(accessor, - cpool, - klass_name, - false); - // Calculate accessibility the hard way. - if (k == nullptr) { - is_accessible = false; - } else if (k->class_loader() != accessor->class_loader() && - get_klass_by_name_impl(accessor, cpool, k->name(), true) == nullptr) { - // Loaded only remotely. Not linked yet. - is_accessible = false; - } else { - // Linked locally, and we must also check public/private, etc. - is_accessible = check_klass_accessibility(accessor, k); - } - if (!is_accessible) { - return nullptr; - } - return k; - } - - // It is known to be accessible, since it was found in the constant pool. - is_accessible = true; - return klass; -} - -// ------------------------------------------------------------------ -// Get a klass from the constant pool. -Klass* JVMCIRuntime::get_klass_by_index(const constantPoolHandle& cpool, - int index, - bool& is_accessible, - Klass* accessor) { - ResourceMark rm; - Klass* result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); - return result; -} - -// ------------------------------------------------------------------ -// Perform an appropriate method lookup based on accessor, holder, -// name, signature, and bytecode. -Method* JVMCIRuntime::lookup_method(InstanceKlass* accessor, - Klass* holder, - Symbol* name, - Symbol* sig, - Bytecodes::Code bc, - constantTag tag) { - // Accessibility checks are performed in JVMCIEnv::get_method_by_index_impl(). - assert(check_klass_accessibility(accessor, holder), "holder not accessible"); - - LinkInfo link_info(holder, name, sig, accessor, - LinkInfo::AccessCheck::required, - LinkInfo::LoaderConstraintCheck::required, - tag); - switch (bc) { - case Bytecodes::_invokestatic: - return LinkResolver::resolve_static_call_or_null(link_info); - case Bytecodes::_invokespecial: - return LinkResolver::resolve_special_call_or_null(link_info); - case Bytecodes::_invokeinterface: - return LinkResolver::linktime_resolve_interface_method_or_null(link_info); - case Bytecodes::_invokevirtual: - return LinkResolver::linktime_resolve_virtual_method_or_null(link_info); - default: - fatal("Unhandled bytecode: %s", Bytecodes::name(bc)); - return nullptr; // silence compiler warnings - } -} - - -// ------------------------------------------------------------------ -Method* JVMCIRuntime::get_method_by_index_impl(const constantPoolHandle& cpool, - int index, Bytecodes::Code bc, - InstanceKlass* accessor) { - if (bc == Bytecodes::_invokedynamic) { - if (cpool->resolved_indy_entry_at(index)->is_resolved()) { - return cpool->resolved_indy_entry_at(index)->method(); - } - - return nullptr; - } - - int holder_index = cpool->klass_ref_index_at(index, bc); - bool holder_is_accessible; - Klass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); - - // Get the method's name and signature. - Symbol* name_sym = cpool->name_ref_at(index, bc); - Symbol* sig_sym = cpool->signature_ref_at(index, bc); - - if (cpool->has_preresolution() - || ((holder == vmClasses::MethodHandle_klass() || holder == vmClasses::VarHandle_klass()) && - MethodHandles::is_signature_polymorphic_name(holder, name_sym))) { - // Short-circuit lookups for JSR 292-related call sites. - // That is, do not rely only on name-based lookups, because they may fail - // if the names are not resolvable in the boot class loader (7056328). - switch (bc) { - case Bytecodes::_invokevirtual: - case Bytecodes::_invokeinterface: - case Bytecodes::_invokespecial: - case Bytecodes::_invokestatic: - { - Method* m = ConstantPool::method_at_if_loaded(cpool, index); - if (m != nullptr) { - return m; - } - } - break; - default: - break; - } - } - - if (holder_is_accessible) { // Our declared holder is loaded. - constantTag tag = cpool->tag_ref_at(index, bc); - Method* m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag); - if (m != nullptr) { - // We found the method. - return m; - } - } - - // Either the declared holder was not loaded, or the method could - // not be found. - - return nullptr; -} - -// ------------------------------------------------------------------ -InstanceKlass* JVMCIRuntime::get_instance_klass_for_declared_method_holder(Klass* method_holder) { - // For the case of .clone(), the method holder can be an ArrayKlass* - // instead of an InstanceKlass*. For that case simply pretend that the - // declared holder is Object.clone since that's where the call will bottom out. - if (method_holder->is_instance_klass()) { - return InstanceKlass::cast(method_holder); - } else if (method_holder->is_array_klass()) { - return vmClasses::Object_klass(); - } else { - ShouldNotReachHere(); - } - return nullptr; -} - - -// ------------------------------------------------------------------ -Method* JVMCIRuntime::get_method_by_index(const constantPoolHandle& cpool, - int index, Bytecodes::Code bc, - InstanceKlass* accessor) { - ResourceMark rm; - return get_method_by_index_impl(cpool, index, bc, accessor); -} - -// ------------------------------------------------------------------ -// Check for changes to the system dictionary during compilation -// class loads, evolution, breakpoints -JVMCI::CodeInstallResult JVMCIRuntime::validate_compile_task_dependencies(Dependencies* dependencies, - JVMCICompileState* compile_state, - char** failure_detail, - bool& failing_dep_is_call_site) -{ - failing_dep_is_call_site = false; - // If JVMTI capabilities were enabled during compile, the compilation is invalidated. - if (compile_state != nullptr && compile_state->jvmti_state_changed()) { - *failure_detail = (char*) "Jvmti state change during compilation invalidated dependencies"; - return JVMCI::dependencies_failed; - } - - CompileTask* task = compile_state == nullptr ? nullptr : compile_state->task(); - Dependencies::DepType result = dependencies->validate_dependencies(task, failure_detail); - - if (result == Dependencies::end_marker) { - return JVMCI::ok; - } - if (result == Dependencies::call_site_target_value) { - failing_dep_is_call_site = true; - } - return JVMCI::dependencies_failed; -} - -// Called after an upcall to `function` while compiling `method`. -// If an exception occurred, it is cleared, the compilation state -// is updated with the failure and this method returns true. -// Otherwise, it returns false. -static bool after_compiler_upcall(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, const char* function) { - if (JVMCIENV->has_pending_exception()) { - ResourceMark rm; - bool reason_on_C_heap = true; - const char* pending_string = nullptr; - const char* pending_stack_trace = nullptr; - JVMCIENV->pending_exception_as_string(&pending_string, &pending_stack_trace); - if (pending_string == nullptr) pending_string = "null"; - // Using stringStream instead of err_msg to avoid truncation - stringStream st; - st.print("uncaught exception in %s [%s]", function, pending_string); - const char* failure_reason = os::strdup(st.freeze(), mtJVMCI); - if (failure_reason == nullptr) { - failure_reason = "uncaught exception"; - reason_on_C_heap = false; - } - JVMCI_event_1("%s", failure_reason); - Log(jit, compilation) log; - if (log.is_info()) { - log.info("%s while compiling %s", failure_reason, method->name_and_sig_as_C_string()); - if (pending_stack_trace != nullptr) { - LogStream ls(log.info()); - ls.print_raw_cr(pending_stack_trace); - } - } - JVMCICompileState* compile_state = JVMCIENV->compile_state(); - compile_state->set_failure(true, failure_reason, reason_on_C_heap); - compiler->on_upcall(failure_reason, compile_state); - return true; - } - return false; -} - -void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) { - JVMCI_EXCEPTION_CONTEXT - - JVMCICompileState* compile_state = JVMCIENV->compile_state(); - - bool is_osr = entry_bci != InvocationEntryBci; - if (compiler->is_bootstrapping() && is_osr) { - // no OSR compilations during bootstrap - the compiler is just too slow at this point, - // and we know that there are no endless loops - compile_state->set_failure(true, "No OSR during bootstrap"); - return; - } - if (JVMCI::in_shutdown()) { - if (UseJVMCINativeLibrary) { - JVMCIRuntime *runtime = JVMCI::compiler_runtime(thread, false); - if (runtime != nullptr) { - runtime->detach_thread(thread, "JVMCI shutdown pre-empted compilation"); - } - } - compile_state->set_failure(false, "Avoiding compilation during shutdown"); - return; - } - - HandleMark hm(thread); - JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV); - if (after_compiler_upcall(JVMCIENV, compiler, method, "get_HotSpotJVMCIRuntime")) { - return; - } - JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV); - if (after_compiler_upcall(JVMCIENV, compiler, method, "get_jvmci_method")) { - return; - } - - JVMCIObject result_object = JVMCIENV->call_HotSpotJVMCIRuntime_compileMethod(receiver, jvmci_method, entry_bci, - (jlong) compile_state, compile_state->task()->compile_id()); -#ifdef ASSERT - if (JVMCIENV->has_pending_exception()) { - const char* val = Arguments::PropertyList_get_value(Arguments::system_properties(), "test.jvmci.compileMethodExceptionIsFatal"); - if (val != nullptr && strcmp(val, "true") == 0) { - fatal_exception(JVMCIENV, "testing JVMCI fatal exception handling"); - } - } -#endif - - if (after_compiler_upcall(JVMCIENV, compiler, method, "call_HotSpotJVMCIRuntime_compileMethod")) { - return; - } - compiler->on_upcall(nullptr); - guarantee(result_object.is_non_null(), "call_HotSpotJVMCIRuntime_compileMethod returned null"); - JVMCIObject failure_message = JVMCIENV->get_HotSpotCompilationRequestResult_failureMessage(result_object); - if (failure_message.is_non_null()) { - // Copy failure reason into resource memory first ... - const char* failure_reason = JVMCIENV->as_utf8_string(failure_message); - // ... and then into the C heap. - failure_reason = os::strdup(failure_reason, mtJVMCI); - bool retryable = JVMCIENV->get_HotSpotCompilationRequestResult_retry(result_object) != 0; - compile_state->set_failure(retryable, failure_reason, true); - } else { - if (!compile_state->task()->is_success()) { - compile_state->set_failure(true, "no nmethod produced"); - } else { - compile_state->task()->set_num_inlined_bytecodes(JVMCIENV->get_HotSpotCompilationRequestResult_inlinedBytecodes(result_object)); - compiler->inc_methods_compiled(); - } - } - if (compiler->is_bootstrapping()) { - compiler->set_bootstrap_compilation_request_handled(); - } -} - -bool JVMCIRuntime::is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name) { - JVMCI_EXCEPTION_CONTEXT - - JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV); - if (JVMCIENV->has_pending_exception()) { - fatal_exception(JVMCIENV, "Exception during HotSpotJVMCIRuntime initialization"); - } - return JVMCIENV->call_HotSpotJVMCIRuntime_isGCSupported(receiver, (int) name); -} - -bool JVMCIRuntime::is_intrinsic_supported(JVMCIEnv* JVMCIENV, jint id) { - JVMCI_EXCEPTION_CONTEXT - - JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV); - if (JVMCIENV->has_pending_exception()) { - fatal_exception(JVMCIENV, "Exception during HotSpotJVMCIRuntime initialization"); - } - return JVMCIENV->call_HotSpotJVMCIRuntime_isIntrinsicSupported(receiver, id); -} - -// ------------------------------------------------------------------ -JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, - const methodHandle& method, - nmethod*& nm, - int entry_bci, - CodeOffsets* offsets, - int orig_pc_offset, - CodeBuffer* code_buffer, - int frame_words, - OopMapSet* oop_map_set, - ExceptionHandlerTable* handler_table, - ImplicitExceptionTable* implicit_exception_table, - AbstractCompiler* compiler, - DebugInformationRecorder* debug_info, - Dependencies* dependencies, - int compile_id, - bool has_monitors, - bool has_unsafe_access, - bool has_scoped_access, - bool has_wide_vector, - JVMCIObject compiled_code, - JVMCIObject nmethod_mirror, - FailedSpeculation** failed_speculations, - char* speculations, - int speculations_len, - int nmethod_entry_patch_offset) { - JVMCI_EXCEPTION_CONTEXT; - CompLevel comp_level = CompLevel_full_optimization; - char* failure_detail = nullptr; - - bool install_default = JVMCIENV->get_HotSpotNmethod_isDefault(nmethod_mirror) != 0; - bool profile_deopt = JVMCIENV->get_HotSpotNmethod_profileDeopt(nmethod_mirror) != 0; - assert(JVMCIENV->isa_HotSpotNmethod(nmethod_mirror), "must be"); - JVMCIObject name = JVMCIENV->get_InstalledCode_name(nmethod_mirror); - const char* nmethod_mirror_name = name.is_null() ? nullptr : JVMCIENV->as_utf8_string(name); - int nmethod_mirror_index; - if (!install_default) { - // Reserve or initialize mirror slot in the oops table. - OopRecorder* oop_recorder = debug_info->oop_recorder(); - nmethod_mirror_index = oop_recorder->allocate_oop_index(nmethod_mirror.is_hotspot() ? nmethod_mirror.as_jobject() : nullptr); - } else { - // A default HotSpotNmethod mirror is never tracked by the nmethod - nmethod_mirror_index = -1; - } - - JVMCI::CodeInstallResult result(JVMCI::ok); - - // We require method counters to store some method state (max compilation levels) required by the compilation policy. - if (method->get_method_counters(THREAD) == nullptr) { - result = JVMCI::cache_full; - failure_detail = (char*) "can't create method counters"; - } - - if (result == JVMCI::ok) { - // Check if memory should be freed before allocation - CodeCache::gc_on_allocation(); - - // To prevent compile queue updates. - MutexLocker locker(THREAD, MethodCompileQueue_lock); - - // Prevent InstanceKlass::add_to_hierarchy from running - // and invalidating our dependencies until we install this method. - MutexLocker ml(Compile_lock); - - // Encode the dependencies now, so we can check them right away. - dependencies->encode_content_bytes(); - - // Record the dependencies for the current compile in the log - if (LogCompilation) { - for (Dependencies::DepStream deps(dependencies); deps.next(); ) { - deps.log_dependency(); - } - } - - // Check for {class loads, evolution, breakpoints} during compilation - JVMCICompileState* compile_state = JVMCIENV->compile_state(); - bool failing_dep_is_call_site; - result = validate_compile_task_dependencies(dependencies, compile_state, &failure_detail, failing_dep_is_call_site); - if (install_default && result != JVMCI::ok) { - // While not a true deoptimization, it is a preemptive decompile. - MethodData* mdp = method()->method_data(); - if (mdp != nullptr && !failing_dep_is_call_site) { - mdp->inc_decompile_count(); -#ifdef ASSERT - if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) { - ResourceMark m; - tty->print_cr("WARN: endless recompilation of %s. Method was set to not compilable.", method()->name_and_sig_as_C_string()); - } -#endif - } - - // All buffers in the CodeBuffer are allocated in the CodeCache. - // If the code buffer is created on each compile attempt - // as in C2, then it must be freed. - //code_buffer->free_blob(); - } else { - JVMCINMethodData* data = JVMCINMethodData::create(nmethod_mirror_index, - nmethod_entry_patch_offset, - nmethod_mirror_name, - install_default, - profile_deopt, - failed_speculations); - nm = nmethod::new_nmethod(method, - compile_id, - entry_bci, - offsets, - orig_pc_offset, - debug_info, dependencies, code_buffer, - frame_words, oop_map_set, - handler_table, implicit_exception_table, - compiler, comp_level, - nmethod::Flags(has_unsafe_access, has_wide_vector, has_monitors, has_scoped_access), - speculations, speculations_len, data); - - - // Free codeBlobs - if (nm == nullptr) { - // The CodeCache is full. Print out warning and disable compilation. - { - MutexUnlocker ml(Compile_lock); - MutexUnlocker locker(MethodCompileQueue_lock); - CompileBroker::handle_full_code_cache(CodeCache::get_code_blob_type(comp_level)); - } - result = JVMCI::cache_full; - } else { - JVMCINMethodData* data = nm->jvmci_nmethod_data(); - assert(data != nullptr, "must be"); - if (install_default) { - assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == nullptr, "must be"); - if (entry_bci == InvocationEntryBci) { - // If there is an old version we're done with it - nmethod* old = method->code(); - if (TraceMethodReplacement && old != nullptr) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - tty->print_cr("Replacing method %s", method_name); - } - if (old != nullptr) { - old->make_not_entrant(nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE); - } - - LogTarget(Info, nmethod, install) lt; - if (lt.is_enabled()) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - lt.print("Installing method (%d) %s [entry point: %p]", - comp_level, method_name, nm->entry_point()); - } - // Allow the code to be executed - MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); - if (nm->make_in_use()) { - method->set_code(method, nm); - } else { - result = JVMCI::nmethod_reclaimed; - } - } else { - LogTarget(Info, nmethod, install) lt; - if (lt.is_enabled()) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - lt.print("Installing osr method (%d) %s @ %d", - comp_level, method_name, entry_bci); - } - MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); - if (nm->make_in_use()) { - InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); - } else { - result = JVMCI::nmethod_reclaimed; - } - } - } else { - assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == HotSpotJVMCI::resolve(nmethod_mirror), "must be"); - MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); - if (!nm->make_in_use()) { - result = JVMCI::nmethod_reclaimed; - } - } - } - } - } - - // String creation must be done outside lock - if (failure_detail != nullptr) { - // A failure to allocate the string is silently ignored. - JVMCIObject message = JVMCIENV->create_string(failure_detail, JVMCIENV); - JVMCIENV->set_HotSpotCompiledNmethod_installationFailureMessage(compiled_code, message); - } - - if (result == JVMCI::ok) { - JVMCICompileState* state = JVMCIENV->compile_state(); - if (state != nullptr) { - // Compilation succeeded, post what we know about it - nm->post_compiled_method(state->task()); - } - } - - return result; -} - -void JVMCIRuntime::post_compile(JavaThread* thread) { - if (UseJVMCINativeLibrary && JVMCI::one_shared_library_javavm_per_compilation()) { - if (thread->libjvmci_runtime() != nullptr) { - detach_thread(thread, "single use JavaVM"); - } else { - // JVMCI shutdown may have already detached the thread - } - } -} diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp deleted file mode 100644 index 885ff0dbf9b..00000000000 --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp +++ /dev/null @@ -1,594 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_JVMCIRUNTIME_HPP -#define SHARE_JVMCI_JVMCIRUNTIME_HPP - -#include "code/nmethod.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "jvm_io.h" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciExceptions.hpp" -#include "jvmci/jvmciObject.hpp" -#include "utilities/linkedlist.hpp" -#if INCLUDE_G1GC -#include "gc/g1/g1CardTable.hpp" -#endif // INCLUDE_G1GC - -#define JVMCI_NOT_ENABLED_ERROR_MESSAGE "JVMCI is not enabled. Must specify '-XX:+EnableJVMCI' or '--add-modules=jdk.internal.vm.ci' to the java launcher." - -class JVMCIEnv; -class JVMCICompiler; -class JVMCICompileState; -class MetadataHandles; - -// Encapsulates the JVMCI metadata for an nmethod. JVMCINMethodData objects are normally inlined -// into nmethods at nmethod::_jvmci_data_offset but during construction of the nmethod they are -// resource allocated so they can be passed into the nmethod constructor. -class JVMCINMethodData : public ResourceObj { - friend class JVMCIVMStructs; - - union JVMCINMethodProperties { - uint8_t value; - struct { - // Is HotSpotNmethod.name non-null? If so, the value is - // embedded in the end of this object. - uint8_t _has_name : 1, - // HotSpotNmethod.isDefault (e.g., compilation scheduled by CompileBroker) - _is_default : 1, - // HotSpotNmethod.profileDeopt - _profile_deopt : 1, - : 5; - } bits; - }; - - JVMCINMethodProperties _properties; - - // Index for the HotSpotNmethod mirror in the nmethod's oops table. - // This is -1 if there is no mirror in the oops table. - int _nmethod_mirror_index; - - // This is the offset of the patchable part of the nmethod entry barrier sequence. The meaning is - // somewhat platform dependent as the way patching is done varies by architecture. - int _nmethod_entry_patch_offset; - - // Address of the failed speculations list to which a speculation - // is appended when it causes a deoptimization. - FailedSpeculation** _failed_speculations; - - // A speculation id is a length (low 5 bits) and an index into - // a jbyte array (i.e. 31 bits for a positive Java int). - enum { - // Keep in sync with HotSpotSpeculationEncoding. - SPECULATION_LENGTH_BITS = 5, - SPECULATION_LENGTH_MASK = (1 << SPECULATION_LENGTH_BITS) - 1 - }; - - // Allocate a temporary data object for use during installation - void initialize(int nmethod_mirror_index, - int nmethod_entry_patch_offset, - const char* nmethod_mirror_name, - bool is_default, - bool profile_deopt, - FailedSpeculation** failed_speculations); - - void* operator new(size_t size, const char* nmethod_mirror_name) { - assert(size == sizeof(JVMCINMethodData), "must agree"); - size_t total_size = compute_size(nmethod_mirror_name); - return (address)resource_allocate_bytes(total_size); - } - -public: - static JVMCINMethodData* create(int nmethod_mirror_index, - int nmethod_entry_patch_offset, - const char* nmethod_mirror_name, - bool is_default, - bool profile_deopt, - FailedSpeculation** failed_speculations) { - JVMCINMethodData* result = new (nmethod_mirror_name) JVMCINMethodData(); - result->initialize(nmethod_mirror_index, - nmethod_entry_patch_offset, - nmethod_mirror_name, - is_default, - profile_deopt, - failed_speculations); - return result; - } - - // Computes the size of a JVMCINMethodData object - static int compute_size(const char* nmethod_mirror_name) { - int size = sizeof(JVMCINMethodData); - if (nmethod_mirror_name != nullptr) { - size += (int) strlen(nmethod_mirror_name) + 1; - } - return size; - } - - int size() { - return compute_size(name()); - } - - // Copy the contents of this object into data which is normally the storage allocated in the nmethod. - void copy(JVMCINMethodData* data); - - // Adds `speculation` to the failed speculations list. - void add_failed_speculation(nmethod* nm, jlong speculation); - - // Gets the JVMCI name of the nmethod (which may be null). - const char* name() { return has_name() ? (char*)(((address) this) + sizeof(JVMCINMethodData)) : nullptr; } - - // Returns true if this nmethod has a mirror - bool has_mirror() const { - return _nmethod_mirror_index != -1; - } - - // Clears the HotSpotNmethod.address field in the mirror. If nm - // is dead, the HotSpotNmethod.entryPoint field is also cleared. - void invalidate_nmethod_mirror(nmethod* nm, nmethod::InvalidationReason invalidation_reason); - - // Gets the mirror from nm's oops table. - oop get_nmethod_mirror(nmethod* nm); - - // Sets the mirror in nm's oops table. - void set_nmethod_mirror(nmethod* nm, oop mirror); - - int nmethod_entry_patch_offset() { - return _nmethod_entry_patch_offset; - } - - bool has_name() { - return _properties.bits._has_name; - } - - bool is_default() { - return _properties.bits._is_default; - } - - bool profile_deopt() { - return _properties.bits._profile_deopt; - } -}; - -// A top level class that represents an initialized JVMCI runtime. -// There is one instance of this class per HotSpotJVMCIRuntime object. -class JVMCIRuntime: public CHeapObj { - friend class JVMCI; - friend class JavaVMRefsInitialization; - public: - // Constants describing whether JVMCI wants to be able to adjust the compilation - // level selected for a method by the VM compilation policy and if so, based on - // what information about the method being schedule for compilation. - enum CompLevelAdjustment { - none = 0, // no adjustment - by_holder = 1, // adjust based on declaring class of method - by_full_signature = 2 // adjust based on declaring class, name and signature of method - }; - - private: - - enum InitState { - uninitialized, - being_initialized, - fully_initialized - }; - - // Initialization state of this JVMCIRuntime. - InitState _init_state; - - // Initialization state of the references to classes, methods - // and fields in the JVMCI shared library. - static InitState _shared_library_javavm_refs_init_state; - - // Initialization state of the references to classes, methods - // and fields in HotSpot metadata. - static InitState _hotspot_javavm_refs_init_state; - - // A wrapper for a VM scoped JNI global handle (i.e. JVMCIEnv::make_global) - // to a HotSpotJVMCIRuntime instance. This JNI global handle must never - // be explicitly destroyed as it can be accessed in a racy way during - // JVMCI shutdown. Furthermore, it will be reclaimed when - // the VM or shared library JavaVM managing the handle dies. - JVMCIObject _HotSpotJVMCIRuntime_instance; - - // Lock for operations that may be performed by - // any thread attached this runtime. To avoid deadlock, - // this lock must always be acquired before JVMCI_lock. - Monitor* _lock; - - // Result of calling JNI_CreateJavaVM in the JVMCI shared library. - // Must only be mutated under _lock. - JavaVM* _shared_library_javavm; - - // Id for _shared_library_javavm. - jlong _shared_library_javavm_id; - - // Position and link in global list of JVMCI shared library runtimes. - // The HotSpot heap based runtime will have an id of -1 and the - // runtime reserved for threads attaching during JVMCI shutdown - // will have an id of -2. - int _id; - JVMCIRuntime* _next; - - // Handles to Metadata objects. - MetadataHandles* _metadata_handles; - - // List of oop handles allocated via make_oop_handle. This is to support - // destroying remaining oop handles when the JavaVM associated - // with this runtime is shutdown. - GrowableArray _oop_handles; - - // Number of threads attached or about to be attached to this runtime. - // Must only be mutated under JVMCI_lock to facilitate safely moving - // threads between JVMCI runtimes. A value of -1 implies this runtime is - // not available to be attached to another thread because it is in the - // process of shutting down and destroying its JavaVM. - int _num_attached_threads; - static const int cannot_be_attached = -1; - - // Is this runtime for threads managed by the CompileBroker? - // Examples of non-CompileBroker threads are CompileTheWorld threads - // or Truffle compilation threads. - bool _for_compile_broker; - - JVMCIObject create_jvmci_primitive_type(BasicType type, JVMCI_TRAPS); - - // Implementation methods for loading and constant pool access. - static Klass* get_klass_by_name_impl(Klass*& accessing_klass, - const constantPoolHandle& cpool, - Symbol* klass_name, - bool require_local); - static Klass* get_klass_by_index_impl(const constantPoolHandle& cpool, - int klass_index, - bool& is_accessible, - Klass* loading_klass); - static Method* get_method_by_index_impl(const constantPoolHandle& cpool, - int method_index, Bytecodes::Code bc, - InstanceKlass* loading_klass); - - // Helper methods - static bool check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass); - static Method* lookup_method(InstanceKlass* accessor, - Klass* holder, - Symbol* name, - Symbol* sig, - Bytecodes::Code bc, - constantTag tag); - - // Helpers for `for_thread`. - - // Selects an existing runtime (except for `skip`) that has - // fewer than JVMCI::max_threads_per_runtime() attached threads. - // If such a runtime exists, its _num_attached_threads is incremented - // and the caller must subsequently attach `thread` to it. - // JVMCI_lock must be held by current thread. - // If null is returned, then `*count` contains the number of JVMCIRuntimes - // currently allocated. - static JVMCIRuntime* select_runtime(JavaThread* thread, JVMCIRuntime* skip, int* count); - - // Selects an existing runtime for `thread` or creates a new one if - // no applicable runtime exists. - // JVMCI_lock must be held by current thread - static JVMCIRuntime* select_or_create_runtime(JavaThread* thread); - - // Selects an existing runtime for `thread` when in JVMCI shutdown. - // JVMCI_lock must be held by current thread - static JVMCIRuntime* select_runtime_in_shutdown(JavaThread* thread); - - // Releases all the non-null entries in _oop_handles and then clears - // the list. Returns the number released handles. - int release_and_clear_oop_handles(); - - public: - JVMCIRuntime(JVMCIRuntime* next, int id, bool for_compile_broker); - - int id() const { return _id; } - Monitor* lock() const { return _lock; } - - // Ensures that a JVMCI shared library JavaVM exists for this runtime. - // If the JavaVM was created by this call, then the thread-local JNI - // interface pointer for the JavaVM is returned otherwise null is returned. - // If this method tried to create the JavaVM but failed, the error code returned - // by JNI_CreateJavaVM is returned in create_JavaVM_err and, if available, an - // error message is malloc'ed and assigned to err_msg. The caller is responsible - // for freeing err_msg. - JNIEnv* init_shared_library_javavm(int* create_JavaVM_err, const char** err_msg); - - // Determines if the JVMCI shared library JavaVM exists for this runtime. - bool has_shared_library_javavm() { return _shared_library_javavm != nullptr; } - - // Gets an ID for the JVMCI shared library JavaVM associated with this runtime. - jlong get_shared_library_javavm_id() { return _shared_library_javavm_id; } - - // Copies info about the JVMCI shared library JavaVM associated with this - // runtime into `info` as follows: - // { - // javaVM, // the {@code JavaVM*} value - // javaVM->functions->reserved0, - // javaVM->functions->reserved1, - // javaVM->functions->reserved2 - // } - void init_JavaVM_info(jlongArray info, JVMCI_TRAPS); - - // Wrappers for calling Invocation Interface functions on the - // JVMCI shared library JavaVM associated with this runtime. - // These wrappers ensure all required thread state transitions are performed. - jint AttachCurrentThread(JavaThread* thread, void **penv, void *args); - jint AttachCurrentThreadAsDaemon(JavaThread* thread, void **penv, void *args); - jint DetachCurrentThread(JavaThread* thread); - jint GetEnv(JavaThread* thread, void **penv, jint version); - - // Compute offsets and construct any state required before executing JVMCI code. - void initialize(JVMCIEnv* jvmciEnv); - - // Allocation and management of handles to HotSpot heap objects - // whose lifetime is scoped by this JVMCIRuntime. The max lifetime - // of these handles is the same as the JVMCI shared library JavaVM - // associated with this JVMCIRuntime. These JNI handles are - // used when creating an IndirectHotSpotObjectConstantImpl in the - // shared library JavaVM. - jlong make_oop_handle(const Handle& obj); -#ifdef ASSERT - static bool is_oop_handle(jlong handle); -#endif - - // Releases all the non-null entries in _oop_handles whose referent is null. - // Returns the number of handles released by this call. - int release_cleared_oop_handles(); - - // Allocation and management of metadata handles. - jmetadata allocate_handle(const methodHandle& handle); - jmetadata allocate_handle(const constantPoolHandle& handle); - void release_handle(jmetadata handle); - - // Finds a JVMCI runtime for `thread`. A new JVMCI runtime is created if - // there are none currently available with JVMCI::max_threads_per_runtime() - // or fewer attached threads. - static JVMCIRuntime* for_thread(JavaThread* thread); - - // Finds the JVMCI runtime owning `javavm` and attaches `thread` to it. - // Returns an error message if attaching fails. - static const char* attach_shared_library_thread(JavaThread* thread, JavaVM* javaVM); - - // Reserves a slot in this runtime for `thread` to prevent it being - // shutdown before `thread` is attached. JVMCI_lock must be held - // and the caller must call `attach_thread` upon releasing it. - void pre_attach_thread(JavaThread* thread); - - // Attaches `thread` to this runtime. - void attach_thread(JavaThread* thread); - - // Detaches `thread` from this runtime. - // Returns whether DestroyJavaVM was called on the JavaVM associated - // with this runtime as a result of detaching. - // The `can_destroy_javavm` is false when in the scope of - // a down call from the JVMCI shared library JavaVM. Since the scope - // will return to the shared library JavaVM, the JavaVM must not be destroyed. - bool detach_thread(JavaThread* thread, const char* reason, bool can_destroy_javavm=true); - - // If `thread` is the last thread attached to this runtime, - // move it to another runtime with an existing JavaVM and available capacity - // if possible, thus allowing this runtime to release its JavaVM. - void repack(JavaThread* thread); - - // Gets the HotSpotJVMCIRuntime instance for this runtime, - // initializing it first if necessary. - JVMCIObject get_HotSpotJVMCIRuntime(JVMCI_TRAPS); - - bool is_HotSpotJVMCIRuntime_initialized() { - return _HotSpotJVMCIRuntime_instance.is_non_null(); - } - - // Gets the current HotSpotJVMCIRuntime instance for this runtime which - // may be a "null" JVMCIObject value. - JVMCIObject probe_HotSpotJVMCIRuntime() { - return _HotSpotJVMCIRuntime_instance; - } - - // Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime() - void initialize_JVMCI(JVMCI_TRAPS); - - // Explicitly initialize HotSpotJVMCIRuntime itself - void initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS); - - // Shuts down this runtime by calling HotSpotJVMCIRuntime.shutdown(). - // If this is the last thread attached to this runtime, then - // `_HotSpotJVMCIRuntime_instance` is set to null and `_init_state` - // to uninitialized. - void shutdown(); - - // Destroys the JVMCI shared library JavaVM attached to this runtime. - // Return true iff DestroyJavaVM was called on the JavaVM. - bool destroy_shared_library_javavm(); - - void bootstrap_finished(TRAPS); - - // Look up a klass by name from a particular class loader (the accessor's). - // If require_local, result must be defined in that class loader, or null. - // If !require_local, a result from remote class loader may be reported, - // if sufficient class loader constraints exist such that initiating - // a class loading request from the given loader is bound to return - // the class defined in the remote loader (or throw an error). - // - // Return an unloaded klass if !require_local and no class at all is found. - // - // The CI treats a klass as loaded if it is consistently defined in - // another loader, even if it hasn't yet been loaded in all loaders - // that could potentially see it via delegation. - static Klass* get_klass_by_name(Klass* accessing_klass, - Symbol* klass_name, - bool require_local); - - // Constant pool access. - static Klass* get_klass_by_index(const constantPoolHandle& cpool, - int klass_index, - bool& is_accessible, - Klass* loading_klass); - static Method* get_method_by_index(const constantPoolHandle& cpool, - int method_index, Bytecodes::Code bc, - InstanceKlass* loading_klass); - - // converts the Klass* representing the holder of a method into a - // InstanceKlass*. This is needed since the holder of a method in - // the bytecodes could be an array type. Basically this converts - // array types into java/lang/Object and other types stay as they are. - static InstanceKlass* get_instance_klass_for_declared_method_holder(Klass* klass); - - // Helper routine for determining the validity of a compilation - // with respect to concurrent class loading. - static JVMCI::CodeInstallResult validate_compile_task_dependencies(Dependencies* target, - JVMCICompileState* task, - char** failure_detail, - bool& failing_dep_is_call_site); - - // Compiles `target` with the JVMCI compiler. - void compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& target, int entry_bci); - - // Determines if the GC identified by `name` is supported by the JVMCI compiler. - bool is_gc_supported(JVMCIEnv* JVMCIENV, CollectedHeap::Name name); - - // Determines if the intrinsic identified by `id` is supported by the JVMCI compiler. - bool is_intrinsic_supported(JVMCIEnv* JVMCIENV, jint id); - - // Register the result of a compilation. - JVMCI::CodeInstallResult register_method(JVMCIEnv* JVMCIENV, - const methodHandle& target, - nmethod*& nm, - int entry_bci, - CodeOffsets* offsets, - int orig_pc_offset, - CodeBuffer* code_buffer, - int frame_words, - OopMapSet* oop_map_set, - ExceptionHandlerTable* handler_table, - ImplicitExceptionTable* implicit_exception_table, - AbstractCompiler* compiler, - DebugInformationRecorder* debug_info, - Dependencies* dependencies, - int compile_id, - bool has_monitors, - bool has_unsafe_access, - bool has_scoped_access, - bool has_wide_vector, - JVMCIObject compiled_code, - JVMCIObject nmethod_mirror, - FailedSpeculation** failed_speculations, - char* speculations, - int speculations_len, - int nmethod_entry_patch_offset); - - // Detach `thread` from this runtime and destroy this runtime's JavaVM - // if using one JavaVM per JVMCI compilation . - void post_compile(JavaThread* thread); - - // Reports an unexpected exception and exits the VM with a fatal error. - static void fatal_exception(JVMCIEnv* JVMCIENV, const char* message); - - static void describe_pending_hotspot_exception(JavaThread* THREAD); - -#define CHECK_EXIT THREAD); \ - if (HAS_PENDING_EXCEPTION) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - JVMCIRuntime::fatal_exception(nullptr, buf); \ - return; \ - } \ - (void)(0 - -#define CHECK_EXIT_(v) THREAD); \ - if (HAS_PENDING_EXCEPTION) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - JVMCIRuntime::fatal_exception(nullptr, buf); \ - return v; \ - } \ - (void)(0 - -#define JVMCI_CHECK_EXIT JVMCIENV); \ - if (JVMCIENV->has_pending_exception()) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - JVMCIRuntime::fatal_exception(JVMCIENV, buf); \ - return; \ - } \ - (void)(0 - -#define JVMCI_CHECK_EXIT_(result) JVMCIENV); \ - if (JVMCIENV->has_pending_exception()) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - JVMCIRuntime::fatal_exception(JVMCIENV, buf); \ - return result; \ - } \ - (void)(0 - - static BasicType kindToBasicType(const Handle& kind, TRAPS); - - // The following routines are called from compiled JVMCI code - - // When allocation fails, these stubs return null and have no pending OutOfMemoryError exception. - // Compiled code can use these stubs if a failed allocation will be retried (e.g., by deoptimizing - // and re-executing in the interpreter). - static void new_instance_or_null(JavaThread* thread, Klass* klass); - static void new_array_or_null(JavaThread* thread, Klass* klass, jint length); - static void new_multi_array_or_null(JavaThread* thread, Klass* klass, int rank, jint* dims); - static void dynamic_new_array_or_null(JavaThread* thread, oopDesc* element_mirror, jint length); - static void dynamic_new_instance_or_null(JavaThread* thread, oopDesc* type_mirror); - - static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3); - static jint identity_hash_code(JavaThread* current, oopDesc* obj); - static address exception_handler_for_pc(JavaThread* current); - static void monitorenter(JavaThread* current, oopDesc* obj, BasicLock* lock); - static void monitorexit (JavaThread* current, oopDesc* obj, BasicLock* lock); - static jboolean object_notify(JavaThread* current, oopDesc* obj); - static jboolean object_notifyAll(JavaThread* current, oopDesc* obj); - static void vm_error(JavaThread* current, jlong where, jlong format, jlong value); - static oopDesc* load_and_clear_exception(JavaThread* thread); - static void log_printf(JavaThread* thread, const char* format, jlong v1, jlong v2, jlong v3); - static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); - // Print the passed in object, optionally followed by a newline. If - // as_string is true and the object is a java.lang.String then it - // printed as a string, otherwise the type of the object is printed - // followed by its address. - static void log_object(JavaThread* thread, oopDesc* object, bool as_string, bool newline); -#if INCLUDE_G1GC - using CardValue = G1CardTable::CardValue; - static void write_barrier_pre(JavaThread* thread, oopDesc* obj); - static void write_barrier_post(JavaThread* thread, volatile CardValue* card); -#endif - static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child); - - // used to throw exceptions from compiled JVMCI code - static int throw_and_post_jvmti_exception(JavaThread* current, const char* exception, const char* message); - // helper methods to throw exception with complex messages - static int throw_klass_external_name_exception(JavaThread* current, const char* exception, Klass* klass); - static int throw_class_cast_exception(JavaThread* current, const char* exception, Klass* caster_klass, Klass* target_klass); - - // A helper to allow invocation of an arbitrary Java method. For simplicity the method is - // restricted to a static method that takes at most one argument. For calling convention - // simplicity all types are passed by being converted into a jlong - static jlong invoke_static_method_one_arg(JavaThread* current, Method* method, jlong argument); - - // Test only function - static jint test_deoptimize_call_int(JavaThread* current, int value); -}; -#endif // SHARE_JVMCI_JVMCIRUNTIME_HPP diff --git a/src/hotspot/share/jvmci/jvmci_globals.cpp b/src/hotspot/share/jvmci/jvmci_globals.cpp deleted file mode 100644 index f68515e3be9..00000000000 --- a/src/hotspot/share/jvmci/jvmci_globals.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "compiler/compilerDefinitions.hpp" -#include "gc/shared/gcConfig.hpp" -#include "jvm.h" -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmci_globals.hpp" -#include "logging/log.hpp" -#include "runtime/arguments.hpp" -#include "runtime/flags/jvmFlagAccess.hpp" -#include "runtime/globals_extension.hpp" -#include "utilities/defaultStream.hpp" -#include "utilities/ostream.hpp" - -fileStream* JVMCIGlobals::_jni_config_file = nullptr; - -// Return true if jvmci flags are consistent. -bool JVMCIGlobals::check_jvmci_flags_are_consistent() { - -#ifndef PRODUCT -#define APPLY_JVMCI_FLAGS(params3, params4) \ - JVMCI_FLAGS(params4, params3, params4, params3, IGNORE_RANGE, IGNORE_CONSTRAINT) -#define JVMCI_DECLARE_CHECK4(type, name, value, ...) bool name##checked = false; -#define JVMCI_DECLARE_CHECK3(type, name, ...) bool name##checked = false; -#define JVMCI_FLAG_CHECKED(name) name##checked = true; - APPLY_JVMCI_FLAGS(JVMCI_DECLARE_CHECK3, JVMCI_DECLARE_CHECK4) -#else -#define JVMCI_FLAG_CHECKED(name) -#endif - - // Checks that a given flag is not set if a given guard flag is false. -#define CHECK_NOT_SET(FLAG, GUARD) \ - JVMCI_FLAG_CHECKED(FLAG) \ - if (!GUARD && !FLAG_IS_DEFAULT(FLAG)) { \ - jio_fprintf(defaultStream::error_stream(), \ - "Improperly specified VM option '%s': '%s' must be enabled\n", #FLAG, #GUARD); \ - return false; \ - } - - if (EnableJVMCIProduct) { - if (FLAG_IS_DEFAULT(EnableJVMCI)) { - FLAG_SET_DEFAULT(EnableJVMCI, true); - } - if (EnableJVMCI && FLAG_IS_DEFAULT(UseJVMCICompiler)) { - FLAG_SET_DEFAULT(UseJVMCICompiler, true); - } - } - - JVMCI_FLAG_CHECKED(UseJVMCICompiler) - JVMCI_FLAG_CHECKED(EnableJVMCI) - JVMCI_FLAG_CHECKED(EnableJVMCIProduct) - JVMCI_FLAG_CHECKED(UseGraalJIT) - - CHECK_NOT_SET(BootstrapJVMCI, UseJVMCICompiler) - CHECK_NOT_SET(PrintBootstrap, UseJVMCICompiler) - CHECK_NOT_SET(JVMCIThreads, UseJVMCICompiler) - CHECK_NOT_SET(JVMCIHostThreads, UseJVMCICompiler) - CHECK_NOT_SET(LibJVMCICompilerThreadHidden, UseJVMCICompiler) - - if (UseJVMCICompiler) { - if (!FLAG_IS_DEFAULT(EnableJVMCI) && !EnableJVMCI) { - jio_fprintf(defaultStream::error_stream(), - "Improperly specified VM option UseJVMCICompiler: EnableJVMCI cannot be disabled\n"); - return false; - } - FLAG_SET_DEFAULT(EnableJVMCI, true); - FLAG_SET_ERGO_IF_DEFAULT(EagerJVMCI, true); - } - - if (EnableJVMCI) { - if (FLAG_IS_DEFAULT(UseJVMCINativeLibrary) && !UseJVMCINativeLibrary) { - if (JVMCI::shared_library_exists()) { - // If a JVMCI native library is present, - // we enable UseJVMCINativeLibrary by default. - FLAG_SET_DEFAULT(UseJVMCINativeLibrary, true); - } - } - } - - if (UseJVMCICompiler) { - if (BootstrapJVMCI && UseJVMCINativeLibrary) { - jio_fprintf(defaultStream::error_stream(), "-XX:+BootstrapJVMCI is not compatible with -XX:+UseJVMCINativeLibrary\n"); - return false; - } - if (BootstrapJVMCI && (TieredStopAtLevel < CompLevel_full_optimization)) { - jio_fprintf(defaultStream::error_stream(), - "-XX:+BootstrapJVMCI is not compatible with -XX:TieredStopAtLevel=%zd\n", TieredStopAtLevel); - return false; - } - } - - if (!EnableJVMCI) { - // Switch off eager JVMCI initialization if JVMCI is disabled. - // Don't throw error if EagerJVMCI is set to allow testing. - if (EagerJVMCI) { - FLAG_SET_DEFAULT(EagerJVMCI, false); - } - } - JVMCI_FLAG_CHECKED(EagerJVMCI) - - CHECK_NOT_SET(JVMCIEventLogLevel, EnableJVMCI) - CHECK_NOT_SET(JVMCITraceLevel, EnableJVMCI) - CHECK_NOT_SET(JVMCICounterSize, EnableJVMCI) - CHECK_NOT_SET(JVMCICountersExcludeCompiler, EnableJVMCI) - CHECK_NOT_SET(JVMCINMethodSizeLimit, EnableJVMCI) - CHECK_NOT_SET(JVMCIPrintProperties, EnableJVMCI) - CHECK_NOT_SET(JVMCIThreadsPerNativeLibraryRuntime, EnableJVMCI) - CHECK_NOT_SET(JVMCICompilerIdleDelay, EnableJVMCI) - CHECK_NOT_SET(UseJVMCINativeLibrary, EnableJVMCI) - CHECK_NOT_SET(JVMCINativeLibraryThreadFraction, EnableJVMCI) - CHECK_NOT_SET(JVMCILibPath, EnableJVMCI) - CHECK_NOT_SET(JVMCINativeLibraryErrorFile, EnableJVMCI) - CHECK_NOT_SET(JVMCILibDumpJNIConfig, EnableJVMCI) - -#ifndef COMPILER2 - JVMCI_FLAG_CHECKED(EnableVectorAggressiveReboxing) - JVMCI_FLAG_CHECKED(EnableVectorReboxing) - JVMCI_FLAG_CHECKED(EnableVectorSupport) - JVMCI_FLAG_CHECKED(MaxVectorSize) - JVMCI_FLAG_CHECKED(ReduceInitialCardMarks) - JVMCI_FLAG_CHECKED(UseMultiplyToLenIntrinsic) - JVMCI_FLAG_CHECKED(UseSquareToLenIntrinsic) - JVMCI_FLAG_CHECKED(UseMulAddIntrinsic) - JVMCI_FLAG_CHECKED(UseMontgomeryMultiplyIntrinsic) - JVMCI_FLAG_CHECKED(UseMontgomerySquareIntrinsic) -#endif // !COMPILER2 - // - JVMCI_FLAG_CHECKED(UseVectorStubs) - -#ifndef PRODUCT -#define JVMCI_CHECK4(type, name, value, ...) assert(name##checked, #name " flag not checked"); -#define JVMCI_CHECK3(type, name, ...) assert(name##checked, #name " flag not checked"); - // Ensures that all JVMCI flags are checked by this method. - APPLY_JVMCI_FLAGS(JVMCI_CHECK3, JVMCI_CHECK4) -#undef APPLY_JVMCI_FLAGS -#undef JVMCI_DECLARE_CHECK3 -#undef JVMCI_DECLARE_CHECK4 -#undef JVMCI_CHECK3 -#undef JVMCI_CHECK4 -#undef JVMCI_FLAG_CHECKED -#endif // PRODUCT -#undef CHECK_NOT_SET - - if (JVMCILibDumpJNIConfig != nullptr) { - _jni_config_file = new(mtJVMCI) fileStream(JVMCILibDumpJNIConfig); - if (_jni_config_file == nullptr || !_jni_config_file->is_open()) { - jio_fprintf(defaultStream::error_stream(), - "Could not open file for dumping JVMCI shared library JNI config: %s\n", JVMCILibDumpJNIConfig); - return false; - } - } - - return true; -} - -// Convert JVMCI flags from experimental to product -bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graal_jit) { - const char *JVMCIFlags[] = { - "EnableJVMCI", - "EnableJVMCIProduct", - "UseJVMCICompiler", - "JVMCIThreadsPerNativeLibraryRuntime", - "JVMCICompilerIdleDelay", - "JVMCIPrintProperties", - "EagerJVMCI", - "JVMCIThreads", - "JVMCICounterSize", - "JVMCICountersExcludeCompiler", - "JVMCINMethodSizeLimit", - "JVMCIEventLogLevel", - "JVMCITraceLevel", - "JVMCILibPath", - "JVMCILibDumpJNIConfig", - "UseJVMCINativeLibrary", - "JVMCINativeLibraryThreadFraction", - "JVMCINativeLibraryErrorFile", - "LibJVMCICompilerThreadHidden", - nullptr - }; - - for (int i = 0; JVMCIFlags[i] != nullptr; i++) { - JVMFlag *jvmciFlag = (JVMFlag *)JVMFlag::find_declared_flag(JVMCIFlags[i]); - if (jvmciFlag == nullptr) { - return false; - } - jvmciFlag->clear_experimental(); - jvmciFlag->set_product(); - } - - bool value = true; - JVMFlag *jvmciEnableFlag = JVMFlag::find_flag("EnableJVMCIProduct"); - if (JVMFlagAccess::set_bool(jvmciEnableFlag, &value, origin) != JVMFlag::SUCCESS) { - return false; - } - if (use_graal_jit) { - JVMFlag *useGraalJITFlag = JVMFlag::find_flag("UseGraalJIT"); - if (JVMFlagAccess::set_bool(useGraalJITFlag, &value, origin) != JVMFlag::SUCCESS) { - return false; - } - } - - // Effect of EnableJVMCIProduct on changing defaults of EnableJVMCI - // and UseJVMCICompiler is deferred to check_jvmci_flags_are_consistent - // so that setting these flags explicitly (e.g. on the command line) - // takes precedence. - - return true; -} - -bool JVMCIGlobals::gc_supports_jvmci() { - return UseSerialGC || UseParallelGC || UseG1GC || UseZGC || UseShenandoahGC || UseEpsilonGC; -} - -void JVMCIGlobals::check_jvmci_supported_gc() { - if (EnableJVMCI) { - // Check if selected GC is supported by JVMCI and Java compiler - if (!gc_supports_jvmci()) { - fatal("JVMCI does not support the selected GC"); - } - } -} diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp deleted file mode 100644 index 730d223e74e..00000000000 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_JVMCI_JVMCI_GLOBALS_HPP -#define SHARE_JVMCI_JVMCI_GLOBALS_HPP - -#include "runtime/globals_shared.hpp" -#include "utilities/vmEnums.hpp" - -class fileStream; - -#define LIBJVMCI_ERR_FILE "hs_err_pid%p_libjvmci.log" -#define DEFAULT_COMPILER_IDLE_DELAY 1000 - -// -// Declare all global flags used by the JVMCI compiler. Only flags that need -// to be accessible to the JVMCI C++ code should be defined here. -// -#define JVMCI_FLAGS(develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) \ - \ - product(bool, EnableJVMCI, false, EXPERIMENTAL, \ - "Enable JVMCI support in the VM. " \ - "Defaults to true if UseJVMCICompiler is true or " \ - "--add-modules=jdk.internal.vm.ci was specified. " \ - "The behavior of --add-modules=jdk.internal.vm.ci is triggered " \ - "if any of the following is true: " \ - "1. -XX:+EnableJVMCI is set to true on the command line. " \ - "2. -XX:+EnableJVMCI is set to true by jdk/internal/vm/options " \ - " in the java.base module. " \ - "3. EnableJVMCI is defaulted to true by UseJVMCICompiler and " \ - " libjvmci is not enabled") \ - \ - product(bool, UseGraalJIT, false, EXPERIMENTAL, \ - "Select the Graal JVMCI compiler. This is an alias for: " \ - " -XX:+EnableJVMCIProduct " \ - " -Djvmci.Compiler=graal ") \ - \ - product(bool, EnableJVMCIProduct, false, EXPERIMENTAL, \ - "Allow JVMCI to be used in product mode. This alters a subset of "\ - "JVMCI flags to be non-experimental, defaults UseJVMCICompiler " \ - "and EnableJVMCI to true and defaults UseJVMCINativeLibrary " \ - "to true if a JVMCI native library is available.") \ - \ - product(bool, UseJVMCICompiler, false, EXPERIMENTAL, \ - "Use JVMCI as the default compiler. Defaults to true if " \ - "EnableJVMCIProduct is true.") \ - \ - product(uint, JVMCIThreadsPerNativeLibraryRuntime, 1, EXPERIMENTAL, \ - "Max number of threads per JVMCI native runtime. " \ - "Specify 0 to force use of a single JVMCI native runtime. " \ - "Specify 1 to force a single JVMCI native runtime per thread. ") \ - range(0, max_jint) \ - \ - product(uint, JVMCICompilerIdleDelay, DEFAULT_COMPILER_IDLE_DELAY, EXPERIMENTAL, \ - "Number of milliseconds a JVMCI compiler queue should wait for " \ - "a compilation task before being considered idle. When a JVMCI " \ - "compiler queue becomes idle, it is detached from its JVMCIRuntime. "\ - "Once the last thread is detached from a JVMCIRuntime, all " \ - "resources associated with the runtime are reclaimed. To use a " \ - "new runtime for every JVMCI compilation, set this value to 0 " \ - "and set JVMCIThreadsPerNativeLibraryRuntime to 1.") \ - range(0, max_jint) \ - \ - product(bool, JVMCIPrintProperties, false, EXPERIMENTAL, \ - "Prints properties used by the JVMCI compiler and exits") \ - \ - product(bool, BootstrapJVMCI, false, EXPERIMENTAL, \ - "Bootstrap JVMCI before running Java main method. This " \ - "initializes the compile queue with a small set of methods " \ - "and processes the queue until it is empty. Combining this with " \ - "-XX:-TieredCompilation makes JVMCI compile more of itself.") \ - \ - product(bool, EagerJVMCI, false, EXPERIMENTAL, \ - "Force eager JVMCI initialization. Defaults to true if " \ - "UseJVMCICompiler is true.") \ - \ - product(bool, PrintBootstrap, true, EXPERIMENTAL, \ - "Print JVMCI bootstrap progress and summary") \ - \ - product(intx, JVMCIThreads, 1, EXPERIMENTAL, \ - "Force number of JVMCI compiler threads to use. Ignored if " \ - "UseJVMCICompiler is false.") \ - range(1, max_jint) \ - \ - product(intx, JVMCIHostThreads, 1, EXPERIMENTAL, \ - "Force number of C1 compiler threads. Ignored if " \ - "UseJVMCICompiler is false.") \ - range(1, max_jint) \ - \ - NOT_COMPILER2(product(intx, MaxVectorSize, 64, \ - "Max vector size in bytes, " \ - "actual size could be less depending on elements type") \ - range(0, max_jint)) \ - \ - NOT_COMPILER2(product(bool, ReduceInitialCardMarks, true, \ - "Defer write barriers of young objects")) \ - \ - product(intx, JVMCIEventLogLevel, 1, EXPERIMENTAL, \ - "Event log level for JVMCI") \ - range(0, 4) \ - \ - product(intx, JVMCITraceLevel, 0, EXPERIMENTAL, \ - "Trace level for JVMCI") \ - range(0, 4) \ - \ - product(intx, JVMCICounterSize, 0, EXPERIMENTAL, \ - "Reserved size for benchmark counters") \ - range(0, 1000000) \ - \ - product(bool, JVMCICountersExcludeCompiler, true, EXPERIMENTAL, \ - "Exclude JVMCI compiler threads from benchmark counters") \ - \ - product(intx, JVMCINMethodSizeLimit, (80*K)*wordSize, EXPERIMENTAL, \ - "Maximum size of a compiled method.") \ - range(0, max_jint) \ - \ - product(ccstr, JVMCILibPath, nullptr, EXPERIMENTAL, \ - "LD path for loading the JVMCI shared library") \ - \ - product(ccstr, JVMCILibDumpJNIConfig, nullptr, EXPERIMENTAL, \ - "Dumps to the given file a description of the classes, fields " \ - "and methods the JVMCI shared library must provide") \ - \ - product(bool, UseJVMCINativeLibrary, false, EXPERIMENTAL, \ - "Execute JVMCI Java code from a shared library (\"libjvmci\") " \ - "instead of loading it from class files and executing it " \ - "on the HotSpot heap. Defaults to true if UseJVMCICompiler or " \ - "EnableJVMCI is true and a JVMCI native library is available.") \ - \ - product(double, JVMCINativeLibraryThreadFraction, 0.66, EXPERIMENTAL, \ - "The fraction of compiler threads used by libjvmci. " \ - "The remaining compiler threads are used by C1. " \ - "Reducing this value could reduce the max RSS but " \ - "also increase the warmup time.") \ - range(0.0, 1.0) \ - \ - product(ccstr, JVMCINativeLibraryErrorFile, nullptr, EXPERIMENTAL, \ - "If an error in the JVMCI native library occurs, save the " \ - "error data to this file" \ - "[default: ./" LIBJVMCI_ERR_FILE "] (%p replaced with pid)") \ - \ - product(bool, LibJVMCICompilerThreadHidden, true, EXPERIMENTAL, \ - "If true then native JVMCI compiler threads are hidden from " \ - "JVMTI and FlightRecorder. This must be set to false if you " \ - "wish to use a Java debugger against JVMCI threads.") \ - \ - NOT_COMPILER2(product(bool, UseMultiplyToLenIntrinsic, false, DIAGNOSTIC, \ - "Enables intrinsification of BigInteger.multiplyToLen()")) \ - \ - NOT_COMPILER2(product(bool, UseSquareToLenIntrinsic, false, DIAGNOSTIC, \ - "Enables intrinsification of BigInteger.squareToLen()")) \ - \ - NOT_COMPILER2(product(bool, UseMulAddIntrinsic, false, DIAGNOSTIC, \ - "Enables intrinsification of BigInteger.mulAdd()")) \ - \ - NOT_COMPILER2(product(bool, UseMontgomeryMultiplyIntrinsic, false, DIAGNOSTIC, \ - "Enables intrinsification of BigInteger.montgomeryMultiply()")) \ - \ - NOT_COMPILER2(product(bool, UseMontgomerySquareIntrinsic, false, DIAGNOSTIC, \ - "Enables intrinsification of BigInteger.montgomerySquare()")) \ - \ - NOT_COMPILER2(product(bool, EnableVectorSupport, false, EXPERIMENTAL, \ - "Enables VectorSupport intrinsics")) \ - \ - NOT_COMPILER2(product(bool, EnableVectorReboxing, false, EXPERIMENTAL, \ - "Enables reboxing of vectors")) \ - \ - NOT_COMPILER2(product(bool, EnableVectorAggressiveReboxing, false, EXPERIMENTAL, \ - "Enables aggressive reboxing of vectors")) \ - \ - product(bool, UseVectorStubs, false, EXPERIMENTAL, \ - "Use stubs for vector transcendental operations") \ - -// end of JVMCI_FLAGS - -DECLARE_FLAGS(JVMCI_FLAGS) - -// The base name for the shared library containing the JVMCI based compiler -#define JVMCI_SHARED_LIBRARY_NAME "jvmcicompiler" - -class JVMCIGlobals { - private: - static fileStream* _jni_config_file; - public: - - // Returns true if jvmci flags are consistent. If not consistent, - // an error message describing the inconsistency is printed before - // returning false. - static bool check_jvmci_flags_are_consistent(); - - // Convert JVMCI experimental flags to product - static bool enable_jvmci_product_mode(JVMFlagOrigin origin, bool use_graal_jit); - - // Returns true iff the GC fully supports JVMCI. - static bool gc_supports_jvmci(); - - // Check and turn off EnableJVMCI if selected GC does not support JVMCI. - static void check_jvmci_supported_gc(); - - static fileStream* get_jni_config_file() { return _jni_config_file; } -}; -#endif // SHARE_JVMCI_JVMCI_GLOBALS_HPP diff --git a/src/hotspot/share/jvmci/metadataHandles.cpp b/src/hotspot/share/jvmci/metadataHandles.cpp deleted file mode 100644 index fe4a49a8536..00000000000 --- a/src/hotspot/share/jvmci/metadataHandles.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "classfile/classLoaderData.hpp" -#include "jvmci/metadataHandles.hpp" -#include "runtime/atomicAccess.hpp" - -jmetadata MetadataHandles::allocate_metadata_handle(Metadata* obj) { - assert(obj->is_valid() && obj->is_metadata(), "must be"); - - if (_head == nullptr) { - // This is the first allocation. - _head = new MetadataHandleBlock(); - _last = _head; - _num_blocks++; - } - - HandleRecord* handle = get_handle(); - - if (handle != nullptr) { - handle->set_value(obj); -#ifdef METADATA_TRACK_NAMES - handle->set_name(obj->print_value_string()); -#endif - return (jmetadata) handle; - } - - // Check if an unused block follows last - if (_last->_next != nullptr) { - // update last and retry - _last = _last->_next; - return allocate_metadata_handle(obj); - } - - // No space available, we have to rebuild free list or expand - if (_allocate_before_rebuild == 0) { - rebuild_free_list(); // updates _allocate_before_rebuild counter - } else { - // Append new block - _last->_next = new MetadataHandleBlock(); - _last = _last->_next; - _allocate_before_rebuild--; - _num_blocks++; - } - return allocate_metadata_handle(obj); // retry -} - - -void MetadataHandles::rebuild_free_list() { - assert(_allocate_before_rebuild == 0 && _free_list == 0, "just checking"); - int free = 0; - int blocks = 0; - for (MetadataHandleBlock* current = _head; current != nullptr; current = current->_next) { - for (int index = 0; index < current->_top; index++) { - HandleRecord* handle = &(current->_handles)[index]; - if (handle->value() == nullptr) { - // this handle was cleared out by a delete call, reuse it - chain_free_list(handle); - free++; - } - } - // we should not rebuild free list if there are unused handles at the end - assert(current->_top == MetadataHandleBlock::block_size_in_handles, "just checking"); - blocks++; - } - assert(_num_blocks == blocks, "%d != %d", _num_blocks, blocks); - assert(_num_free_handles == free, "%d != %d", _num_free_handles, free); - // Heuristic: if more than half of the handles are NOT free we rebuild next time - // as well, otherwise we append a corresponding number of new blocks before - // attempting a free list rebuild again. - int total = blocks * MetadataHandleBlock::block_size_in_handles; - int extra = total - 2*free; - if (extra > 0) { - // Not as many free handles as we would like - compute number of new blocks to append - _allocate_before_rebuild = (extra + MetadataHandleBlock::block_size_in_handles - 1) / MetadataHandleBlock::block_size_in_handles; - } -} - -void MetadataHandles::clear() { - _free_list = 0; - _last = _head; - if (_head != nullptr) { - for (MetadataHandleBlock* block = _head; block != nullptr; block = block->_next) { - block->_top = 0; - } - } - _num_handles = 0; - _num_free_handles = 0; -} - -void MetadataHandles::metadata_do(void f(Metadata*)) { - for (MetadataHandleBlock* current = _head; current != nullptr; current = current->_next) { - for (int index = 0; index < current->_top; index++) { - HandleRecord* root = &(current->_handles)[index]; - Metadata* value = root->value(); - // traverse heap pointers only, not deleted handles or free list - // pointers - if (value != nullptr && ((intptr_t) value & ptr_tag) == 0) { - assert(value->is_valid(), "invalid metadata %s", current->get_name(index)); - f(value); - } - } - // the next handle block is valid only if current block is full - if (current->_top < MetadataHandleBlock::block_size_in_handles) { - break; - } - } -} - -// Visit any live metadata handles and clean them up. Since clearing of these handles is driven by -// weak references they will be cleared at some point in the future when the reference cleaning logic is run. -void MetadataHandles::do_unloading() { - for (MetadataHandleBlock* current = _head; current != nullptr; current = current->_next) { - for (int index = 0; index < current->_top; index++) { - HandleRecord* handle = &(current->_handles)[index]; - Metadata* value = handle->value(); - // traverse heap pointers only, not deleted handles or free list - // pointers - if (value != nullptr && ((intptr_t) value & ptr_tag) == 0) { - Klass* klass = nullptr; - if (value->is_klass()) { - klass = (Klass*)value; - } else if (value->is_method()) { - Method* m = (Method*)value; - klass = m->method_holder(); - } else if (value->is_constantPool()) { - ConstantPool* cp = (ConstantPool*)value; - klass = cp->pool_holder(); - } else { - ShouldNotReachHere(); - } - if (klass->class_loader_data()->is_unloading()) { - // This needs to be marked so that it's no longer scanned - // but can't be put on the free list yet. The - // HandleCleaner will set this to null and - // put it on the free list. - jlong old_value = AtomicAccess::cmpxchg((jlong*)handle, (jlong) value, (jlong) (ptr_tag)); - if (old_value == (jlong) value) { - // Success - } else { - guarantee(old_value == 0, "only other possible value"); - } - } - } - } - // the next handle block is valid only if current block is full - if (current->_top < MetadataHandleBlock::block_size_in_handles) { - break; - } - } -} diff --git a/src/hotspot/share/jvmci/metadataHandles.hpp b/src/hotspot/share/jvmci/metadataHandles.hpp deleted file mode 100644 index c28296d5a03..00000000000 --- a/src/hotspot/share/jvmci/metadataHandles.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_METADATAHANDLES_HPP -#define SHARE_JVMCI_METADATAHANDLES_HPP - -#include "oops/constantPool.hpp" -#include "oops/metadata.hpp" -#include "oops/method.hpp" -#include "runtime/handles.hpp" -#include "runtime/os.hpp" - -#ifdef ASSERT -#define METADATA_TRACK_NAMES -#endif - -struct _jmetadata { - private: - Metadata* _value; -#ifdef METADATA_TRACK_NAMES - // Debug data for tracking stale metadata - const char* _name; -#endif - - public: - Metadata* value() { return _value; } - -#ifdef METADATA_TRACK_NAMES - void initialize() { - _value = nullptr; - _name = nullptr; - } -#endif - - void set_value(Metadata* value) { - _value = value; - } - -#ifdef METADATA_TRACK_NAMES - const char* name() { return _name; } - void set_name(const char* name) { - if (_name != nullptr) { - os::free((void*) _name); - _name = nullptr; - } - if (name != nullptr) { - _name = os::strdup(name); - } - } -#endif -}; - -typedef struct _jmetadata HandleRecord; -typedef struct _jmetadata *jmetadata; -class MetadataHandles; - -class MetadataHandleBlock : public CHeapObj { - friend class MetadataHandles; - private: - enum SomeConstants { - block_size_in_handles = 32 // Number of handles per handle block - }; - - // Free handles always have their low bit set so those pointers can - // be distinguished from handles which are in use. The last handle - // on the free list has a null pointer with the tag bit set, so it's - // clear that the handle has been reclaimed. The _free_list is - // always a real pointer to a handle. - - HandleRecord _handles[block_size_in_handles]; // The handles - int _top; // Index of next unused handle - MetadataHandleBlock* _next; // Link to next block - - MetadataHandleBlock() { - _top = 0; - _next = nullptr; -#ifdef METADATA_TRACK_NAMES - for (int i = 0; i < block_size_in_handles; i++) { - _handles[i].initialize(); - } -#endif - } - - const char* get_name(int index) { -#ifdef METADATA_TRACK_NAMES - return _handles[index].name(); -#else - return ""; -#endif - } -}; - -// JVMCI maintains direct references to metadata. To make these references safe in the face of -// class redefinition, they are held in handles so they can be scanned during GC. They are -// managed in a cooperative way between the Java code and HotSpot. A handle is filled in and -// passed back to the Java code which is responsible for setting the handle to null when it -// is no longer in use. This is done by jdk.vm.ci.hotspot.HandleCleaner. The -// rebuild_free_list function notices when the handle is clear and reclaims it for re-use. -class MetadataHandles : public CHeapObj { - private: - enum SomeConstants { - ptr_tag = 1, - ptr_mask = ~((intptr_t)ptr_tag) - }; - - MetadataHandleBlock* _head; // First block - MetadataHandleBlock* _last; // Last block in use - intptr_t _free_list; // Handle free list - int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list - int _num_blocks; // Number of blocks - int _num_handles; - int _num_free_handles; - - HandleRecord* get_free_handle() { - HandleRecord* handle = (HandleRecord*) (_free_list & ptr_mask); - _free_list = (ptr_mask & (intptr_t) (handle->value())); - assert(_free_list != ptr_tag, "should be null"); - _num_free_handles--; - return handle; - } - - HandleRecord* get_handle() { - assert(_last != nullptr, "sanity"); - // Try last block - if (_last->_top < MetadataHandleBlock::block_size_in_handles) { - _num_handles++; - return &(_last->_handles)[_last->_top++]; - } else if (_free_list != 0) { - // Try free list - return get_free_handle(); - } - return nullptr; - } - - void rebuild_free_list(); - - jmetadata allocate_metadata_handle(Metadata* metadata); - - public: - MetadataHandles() { - _head = nullptr; - _last = nullptr; - _free_list = 0; - _allocate_before_rebuild = 0; - _num_blocks = 0; - _num_handles = 0; - _num_free_handles = 0; - } - - int num_handles() const { return _num_handles; } - int num_free_handles() const { return _num_free_handles; } - int num_blocks() const { return _num_blocks; } - - jmetadata allocate_handle(const methodHandle& handle) { return allocate_metadata_handle(handle()); } - jmetadata allocate_handle(const constantPoolHandle& handle) { return allocate_metadata_handle(handle()); } - - // Adds `handle` to the free list - void chain_free_list(HandleRecord* handle) { - handle->set_value((Metadata*) (ptr_tag | _free_list)); -#ifdef METADATA_TRACK_NAMES - handle->set_name(nullptr); -#endif - _free_list = (intptr_t) handle; - _num_free_handles++; - } - - // Clears all handles without releasing any handle memory. - void clear(); - - void metadata_do(void f(Metadata*)); - - void do_unloading(); -}; - -#endif // SHARE_JVMCI_METADATAHANDLES_HPP diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp deleted file mode 100644 index 4a1ddf13d60..00000000000 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ /dev/null @@ -1,1209 +0,0 @@ -/* - * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "code/codeCache.hpp" -#include "code/compiledIC.hpp" -#include "compiler/compileBroker.hpp" -#include "gc/shared/collectedHeap.hpp" -#include "jvmci/jvmciCodeInstaller.hpp" -#include "jvmci/jvmciCompilerToVM.hpp" -#include "jvmci/jvmciRuntime.hpp" -#include "jvmci/vmStructs_jvmci.hpp" -#include "oops/klassVtable.hpp" -#include "oops/methodCounters.hpp" -#include "oops/objArrayKlass.hpp" -#include "prims/jvmtiThreadState.hpp" -#include "runtime/continuationEntry.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/flags/jvmFlag.hpp" -#include "runtime/mountUnmountDisabler.hpp" -#include "runtime/objectMonitor.hpp" -#include "runtime/osThread.hpp" -#include "runtime/sharedRuntime.hpp" -#include "runtime/stubRoutines.hpp" -#include "runtime/vm_version.hpp" -#if INCLUDE_G1GC -#include "gc/g1/g1BarrierSetRuntime.hpp" -#include "gc/g1/g1CardTable.hpp" -#include "gc/g1/g1HeapRegion.hpp" -#include "gc/g1/g1ThreadLocalData.hpp" -#endif -#if INCLUDE_ZGC -#include "gc/z/zBarrierSetAssembler.hpp" -#include "gc/z/zBarrierSetRuntime.hpp" -#include "gc/z/zThreadLocalData.hpp" -#endif -#if INCLUDE_SHENANDOAHGC -#include "gc/shenandoah/shenandoahHeap.hpp" -#include "gc/shenandoah/shenandoahRuntime.hpp" -#include "gc/shenandoah/shenandoahThreadLocalData.hpp" -#endif - -#define VM_STRUCTS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field) \ - static_field(CompilerToVM::Data, oopDesc_klass_offset_in_bytes, int) \ - static_field(CompilerToVM::Data, arrayOopDesc_length_offset_in_bytes, int) \ - \ - static_field(CompilerToVM::Data, Klass_vtable_start_offset, int) \ - static_field(CompilerToVM::Data, Klass_vtable_length_offset, int) \ - \ - static_field(CompilerToVM::Data, Method_extra_stack_entries, int) \ - \ - static_field(CompilerToVM::Data, SharedRuntime_ic_miss_stub, address) \ - static_field(CompilerToVM::Data, SharedRuntime_handle_wrong_method_stub, address) \ - static_field(CompilerToVM::Data, SharedRuntime_deopt_blob_unpack, address) \ - static_field(CompilerToVM::Data, SharedRuntime_deopt_blob_unpack_with_exception_in_tls, \ - address) \ - static_field(CompilerToVM::Data, SharedRuntime_deopt_blob_uncommon_trap, address) \ - static_field(CompilerToVM::Data, SharedRuntime_polling_page_return_handler, \ - address) \ - static_field(CompilerToVM::Data, SharedRuntime_throw_delayed_StackOverflowError_entry, \ - address) \ - \ - static_field(CompilerToVM::Data, nmethod_entry_barrier, address) \ - static_field(CompilerToVM::Data, thread_disarmed_guard_value_offset, int) \ - static_field(CompilerToVM::Data, thread_address_bad_mask_offset, int) \ - AARCH64_ONLY(static_field(CompilerToVM::Data, BarrierSetAssembler_nmethod_patching_type, int)) \ - AARCH64_ONLY(static_field(CompilerToVM::Data, BarrierSetAssembler_patching_epoch_addr, address)) \ - \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_load_barrier_on_oop_array, address) \ - static_field(CompilerToVM::Data, ZBarrierSetRuntime_clone, address) \ - \ - static_field(CompilerToVM::Data, ZPointerVectorLoadBadMask_address, address) \ - static_field(CompilerToVM::Data, ZPointerVectorStoreBadMask_address, address) \ - static_field(CompilerToVM::Data, ZPointerVectorStoreGoodMask_address, address) \ - \ - static_field(CompilerToVM::Data, continuations_enabled, bool) \ - \ - static_field(CompilerToVM::Data, ThreadLocalAllocBuffer_alignment_reserve, size_t) \ - \ - static_field(CompilerToVM::Data, Universe_collectedHeap, CollectedHeap*) \ - static_field(CompilerToVM::Data, Universe_base_vtable_size, int) \ - static_field(CompilerToVM::Data, Universe_narrow_oop_base, address) \ - static_field(CompilerToVM::Data, Universe_narrow_oop_shift, int) \ - static_field(CompilerToVM::Data, Universe_narrow_klass_base, address) \ - static_field(CompilerToVM::Data, Universe_narrow_klass_shift, int) \ - static_field(CompilerToVM::Data, Universe_non_oop_bits, void*) \ - static_field(CompilerToVM::Data, Universe_verify_oop_mask, uintptr_t) \ - static_field(CompilerToVM::Data, Universe_verify_oop_bits, uintptr_t) \ - \ - static_field(CompilerToVM::Data, _supports_inline_contig_alloc, bool) \ - static_field(CompilerToVM::Data, _heap_end_addr, HeapWord**) \ - static_field(CompilerToVM::Data, _heap_top_addr, HeapWord* volatile*) \ - \ - static_field(CompilerToVM::Data, _max_oop_map_stack_offset, int) \ - static_field(CompilerToVM::Data, _fields_annotations_base_offset, int) \ - \ - static_field(CompilerToVM::Data, cardtable_start_address, CardTable::CardValue*) \ - static_field(CompilerToVM::Data, cardtable_shift, int) \ - \ - X86_ONLY(static_field(CompilerToVM::Data, L1_line_size, int)) \ - X86_ONLY(static_field(CompilerToVM::Data, supports_avx512_simd_sort, bool)) \ - \ - static_field(CompilerToVM::Data, vm_page_size, size_t) \ - \ - static_field(CompilerToVM::Data, sizeof_vtableEntry, int) \ - static_field(CompilerToVM::Data, sizeof_ExceptionTableElement, int) \ - static_field(CompilerToVM::Data, sizeof_LocalVariableTableElement, int) \ - static_field(CompilerToVM::Data, sizeof_ConstantPool, int) \ - static_field(CompilerToVM::Data, sizeof_narrowKlass, int) \ - static_field(CompilerToVM::Data, sizeof_arrayOopDesc, int) \ - static_field(CompilerToVM::Data, sizeof_BasicLock, int) \ - ZGC_ONLY(static_field(CompilerToVM::Data, sizeof_ZStoreBarrierEntry, int)) \ - SHENANDOAHGC_ONLY(static_field(CompilerToVM::Data, shenandoah_in_cset_fast_test_addr, address)) \ - SHENANDOAHGC_ONLY(static_field(CompilerToVM::Data, shenandoah_region_size_bytes_shift,int)) \ - \ - static_field(CompilerToVM::Data, dsin, address) \ - static_field(CompilerToVM::Data, dcos, address) \ - static_field(CompilerToVM::Data, dtan, address) \ - static_field(CompilerToVM::Data, dsinh, address) \ - static_field(CompilerToVM::Data, dtanh, address) \ - static_field(CompilerToVM::Data, dcbrt, address) \ - static_field(CompilerToVM::Data, dexp, address) \ - static_field(CompilerToVM::Data, dlog, address) \ - static_field(CompilerToVM::Data, dlog10, address) \ - static_field(CompilerToVM::Data, dpow, address) \ - static_field(CompilerToVM::Data, crc_table_addr, address) \ - \ - static_field(CompilerToVM::Data, symbol_init, address) \ - static_field(CompilerToVM::Data, symbol_clinit, address) \ - \ - static_field(CompilerToVM::Data, data_section_item_alignment, int) \ - \ - JVMTI_ONLY(static_field(CompilerToVM::Data, _should_notify_object_alloc, int*)) \ - \ - static_field(Abstract_VM_Version, _features, uint64_t) \ - \ - nonstatic_field(Annotations, _class_annotations, AnnotationArray*) \ - nonstatic_field(Annotations, _fields_annotations, Array*) \ - \ - nonstatic_field(Array, _length, int) \ - unchecked_nonstatic_field(Array, _data, sizeof(u1)) \ - unchecked_nonstatic_field(Array, _data, sizeof(u2)) \ - nonstatic_field(Array, _length, int) \ - nonstatic_field(Array, _data[0], Klass*) \ - \ - volatile_nonstatic_field(BasicLock, _monitor, ObjectMonitor*) \ - \ - static_field(CodeCache, _low_bound, address) \ - static_field(CodeCache, _high_bound, address) \ - \ - nonstatic_field(CollectedHeap, _total_collections, unsigned int) \ - \ - nonstatic_field(CompileTask, _num_inlined_bytecodes, int) \ - \ - volatile_nonstatic_field(CompiledICData, _speculated_method, Method*) \ - volatile_nonstatic_field(CompiledICData, _speculated_klass, uintptr_t) \ - nonstatic_field(CompiledICData, _itable_defc_klass, Klass*) \ - nonstatic_field(CompiledICData, _itable_refc_klass, Klass*) \ - \ - nonstatic_field(ConstantPool, _tags, Array*) \ - nonstatic_field(ConstantPool, _pool_holder, InstanceKlass*) \ - nonstatic_field(ConstantPool, _length, int) \ - nonstatic_field(ConstantPool, _flags, u2) \ - nonstatic_field(ConstantPool, _source_file_name_index, u2) \ - \ - nonstatic_field(ConstMethod, _constants, ConstantPool*) \ - nonstatic_field(ConstMethod, _flags._flags, u4) \ - nonstatic_field(ConstMethod, _code_size, u2) \ - nonstatic_field(ConstMethod, _name_index, u2) \ - nonstatic_field(ConstMethod, _signature_index, u2) \ - nonstatic_field(ConstMethod, _method_idnum, u2) \ - nonstatic_field(ConstMethod, _max_stack, u2) \ - nonstatic_field(ConstMethod, _max_locals, u2) \ - \ - nonstatic_field(DataLayout, _header._struct._tag, u1) \ - nonstatic_field(DataLayout, _header._struct._flags, u1) \ - nonstatic_field(DataLayout, _header._struct._bci, u2) \ - nonstatic_field(DataLayout, _header._struct._traps, u4) \ - nonstatic_field(DataLayout, _cells[0], intptr_t) \ - \ - nonstatic_field(Deoptimization::UnrollBlock, _size_of_deoptimized_frame, int) \ - nonstatic_field(Deoptimization::UnrollBlock, _caller_adjustment, int) \ - nonstatic_field(Deoptimization::UnrollBlock, _number_of_frames, int) \ - nonstatic_field(Deoptimization::UnrollBlock, _total_frame_sizes, int) \ - nonstatic_field(Deoptimization::UnrollBlock, _frame_sizes, intptr_t*) \ - nonstatic_field(Deoptimization::UnrollBlock, _frame_pcs, address*) \ - nonstatic_field(Deoptimization::UnrollBlock, _initial_info, intptr_t) \ - nonstatic_field(Deoptimization::UnrollBlock, _unpack_kind, int) \ - \ - nonstatic_field(ExceptionTableElement, start_pc, u2) \ - nonstatic_field(ExceptionTableElement, end_pc, u2) \ - nonstatic_field(ExceptionTableElement, handler_pc, u2) \ - nonstatic_field(ExceptionTableElement, catch_type_index, u2) \ - \ - nonstatic_field(InstanceKlass, _fieldinfo_stream, Array*) \ - nonstatic_field(InstanceKlass, _constants, ConstantPool*) \ - volatile_nonstatic_field(InstanceKlass, _init_state, InstanceKlass::ClassState) \ - volatile_nonstatic_field(InstanceKlass, _init_thread, JavaThread*) \ - nonstatic_field(InstanceKlass, _misc_flags._flags, u2) \ - nonstatic_field(InstanceKlass, _access_flags, AccessFlags) \ - nonstatic_field(InstanceKlass, _annotations, Annotations*) \ - \ - volatile_nonstatic_field(JavaFrameAnchor, _last_Java_sp, intptr_t*) \ - volatile_nonstatic_field(JavaFrameAnchor, _last_Java_pc, address) \ - \ - nonstatic_field(JVMCICompileState, _jvmti_can_hotswap_or_post_breakpoint, jbyte) \ - nonstatic_field(JVMCICompileState, _jvmti_can_access_local_variables, jbyte) \ - nonstatic_field(JVMCICompileState, _jvmti_can_post_on_exceptions, jbyte) \ - nonstatic_field(JVMCICompileState, _jvmti_can_pop_frame, jbyte) \ - nonstatic_field(JVMCICompileState, _compilation_ticks, jint) \ - \ - nonstatic_field(JavaThread, _threadObj, OopHandle) \ - nonstatic_field(JavaThread, _vthread, OopHandle) \ - nonstatic_field(JavaThread, _scopedValueCache, OopHandle) \ - nonstatic_field(JavaThread, _anchor, JavaFrameAnchor) \ - nonstatic_field(JavaThread, _monitor_owner_id, int64_t) \ - nonstatic_field(JavaThread, _vm_result_oop, oop) \ - nonstatic_field(JavaThread, _stack_overflow_state._stack_overflow_limit, address) \ - volatile_nonstatic_field(JavaThread, _exception_oop, oop) \ - volatile_nonstatic_field(JavaThread, _exception_pc, address) \ - volatile_nonstatic_field(JavaThread, _doing_unsafe_access, bool) \ - nonstatic_field(JavaThread, _osthread, OSThread*) \ - nonstatic_field(JavaThread, _saved_exception_pc, address) \ - nonstatic_field(JavaThread, _pending_deoptimization, int) \ - nonstatic_field(JavaThread, _pending_failed_speculation, jlong) \ - nonstatic_field(JavaThread, _pending_transfer_to_interpreter, bool) \ - nonstatic_field(JavaThread, _jvmci_counters, jlong*) \ - nonstatic_field(JavaThread, _jvmci_reserved0, jlong) \ - nonstatic_field(JavaThread, _jvmci_reserved1, jlong) \ - nonstatic_field(JavaThread, _jvmci_reserved_oop0, oop) \ - nonstatic_field(JavaThread, _should_post_on_exceptions_flag, int) \ - nonstatic_field(JavaThread, _jni_environment, JNIEnv) \ - nonstatic_field(JavaThread, _stack_overflow_state._reserved_stack_activation, address) \ - nonstatic_field(JavaThread, _lock_stack, LockStack) \ - nonstatic_field(JavaThread, _om_cache, OMCache) \ - nonstatic_field(JavaThread, _cont_entry, ContinuationEntry*) \ - nonstatic_field(JavaThread, _unlocked_inflated_monitor, ObjectMonitor*) \ - nonstatic_field(JavaThread, _is_in_vthread_transition, bool) \ - JVMTI_ONLY(nonstatic_field(JavaThread, _is_disable_suspend, bool)) \ - \ - nonstatic_field(ContinuationEntry, _pin_count, uint32_t) \ - nonstatic_field(LockStack, _top, uint32_t) \ - \ - static_field(MountUnmountDisabler, _notify_jvmti_events, bool) \ - \ - static_field(java_lang_Class, _klass_offset, int) \ - static_field(java_lang_Class, _array_klass_offset, int) \ - \ - nonstatic_field(InvocationCounter, _counter, unsigned int) \ - \ - nonstatic_field(Klass, _secondary_super_cache, Klass*) \ - nonstatic_field(Klass, _secondary_supers, Array*) \ - nonstatic_field(Klass, _super, Klass*) \ - nonstatic_field(Klass, _super_check_offset, juint) \ - volatile_nonstatic_field(Klass, _subklass, Klass*) \ - nonstatic_field(Klass, _layout_helper, jint) \ - nonstatic_field(Klass, _name, Symbol*) \ - volatile_nonstatic_field(Klass, _next_sibling, Klass*) \ - nonstatic_field(Klass, _java_mirror, OopHandle) \ - nonstatic_field(Klass, _class_loader_data, ClassLoaderData*) \ - nonstatic_field(Klass, _secondary_supers_bitmap, uintx) \ - nonstatic_field(Klass, _hash_slot, uint8_t) \ - nonstatic_field(Klass, _misc_flags._flags, u1) \ - nonstatic_field(Klass, _prototype_header, markWord) \ - \ - nonstatic_field(LocalVariableTableElement, start_bci, u2) \ - nonstatic_field(LocalVariableTableElement, length, u2) \ - nonstatic_field(LocalVariableTableElement, name_cp_index, u2) \ - nonstatic_field(LocalVariableTableElement, descriptor_cp_index, u2) \ - nonstatic_field(LocalVariableTableElement, signature_cp_index, u2) \ - nonstatic_field(LocalVariableTableElement, slot, u2) \ - \ - nonstatic_field(Method, _constMethod, ConstMethod*) \ - nonstatic_field(Method, _method_data, MethodData*) \ - nonstatic_field(Method, _method_counters, MethodCounters*) \ - nonstatic_field(Method, _access_flags, AccessFlags) \ - nonstatic_field(Method, _vtable_index, int) \ - nonstatic_field(Method, _intrinsic_id, u2) \ - nonstatic_field(Method, _flags._status, u4) \ - volatile_nonstatic_field(Method, _code, nmethod*) \ - volatile_nonstatic_field(Method, _from_compiled_entry, address) \ - \ - nonstatic_field(MethodCounters, _invoke_mask, int) \ - nonstatic_field(MethodCounters, _backedge_mask, int) \ - nonstatic_field(MethodCounters, _interpreter_throwout_count, u2) \ - JVMTI_ONLY(nonstatic_field(MethodCounters, _number_of_breakpoints, u2)) \ - nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \ - nonstatic_field(MethodCounters, _backedge_counter, InvocationCounter) \ - \ - nonstatic_field(MethodData, _size, int) \ - nonstatic_field(MethodData, _method, Method*) \ - nonstatic_field(MethodData, _data_size, int) \ - nonstatic_field(MethodData, _data[0], intptr_t) \ - nonstatic_field(MethodData, _parameters_type_data_di, int) \ - nonstatic_field(MethodData, _compiler_counters._nof_decompiles, uint) \ - nonstatic_field(MethodData, _compiler_counters._nof_overflow_recompiles, uint) \ - nonstatic_field(MethodData, _compiler_counters._nof_overflow_traps, uint) \ - nonstatic_field(MethodData, _compiler_counters._trap_hist._array[0], u1) \ - nonstatic_field(MethodData, _eflags, intx) \ - nonstatic_field(MethodData, _arg_local, intx) \ - nonstatic_field(MethodData, _arg_stack, intx) \ - nonstatic_field(MethodData, _arg_returned, intx) \ - nonstatic_field(MethodData, _tenure_traps, uint) \ - nonstatic_field(MethodData, _invoke_mask, int) \ - nonstatic_field(MethodData, _backedge_mask, int) \ - nonstatic_field(MethodData, _jvmci_ir_size, int) \ - \ - nonstatic_field(nmethod, _verified_entry_offset, u2) \ - nonstatic_field(nmethod, _comp_level, CompLevel) \ - \ - nonstatic_field(ObjArrayKlass, _element_klass, Klass*) \ - \ - volatile_nonstatic_field(ObjectMonitor, _owner, int64_t) \ - volatile_nonstatic_field(ObjectMonitor, _recursions, intptr_t) \ - volatile_nonstatic_field(ObjectMonitor, _entry_list, ObjectWaiter*) \ - volatile_nonstatic_field(ObjectMonitor, _succ, int64_t) \ - \ - volatile_nonstatic_field(oopDesc, _mark, markWord) \ - volatile_nonstatic_field(oopDesc, _compressed_klass, narrowKlass) \ - \ - static_field(StubRoutines, _verify_oop_count, jint) \ - \ - static_field(StubRoutines, _jbyte_arraycopy, address) \ - static_field(StubRoutines, _jshort_arraycopy, address) \ - static_field(StubRoutines, _jint_arraycopy, address) \ - static_field(StubRoutines, _jlong_arraycopy, address) \ - static_field(StubRoutines, _oop_arraycopy, address) \ - static_field(StubRoutines, _oop_arraycopy_uninit, address) \ - static_field(StubRoutines, _jbyte_disjoint_arraycopy, address) \ - static_field(StubRoutines, _jshort_disjoint_arraycopy, address) \ - static_field(StubRoutines, _jint_disjoint_arraycopy, address) \ - static_field(StubRoutines, _jlong_disjoint_arraycopy, address) \ - static_field(StubRoutines, _oop_disjoint_arraycopy, address) \ - static_field(StubRoutines, _oop_disjoint_arraycopy_uninit, address) \ - static_field(StubRoutines, _arrayof_jbyte_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jshort_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jlong_arraycopy, address) \ - static_field(StubRoutines, _arrayof_oop_arraycopy, address) \ - static_field(StubRoutines, _arrayof_oop_arraycopy_uninit, address) \ - static_field(StubRoutines, _arrayof_jbyte_disjoint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jshort_disjoint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jint_disjoint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_jlong_disjoint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_oop_disjoint_arraycopy, address) \ - static_field(StubRoutines, _arrayof_oop_disjoint_arraycopy_uninit, address) \ - static_field(StubRoutines, _checkcast_arraycopy, address) \ - static_field(StubRoutines, _checkcast_arraycopy_uninit, address) \ - static_field(StubRoutines, _unsafe_arraycopy, address) \ - static_field(StubRoutines, _generic_arraycopy, address) \ - static_field(StubRoutines, _array_sort, address) \ - static_field(StubRoutines, _array_partition, address) \ - static_field(StubRoutines, _unsafe_setmemory, address) \ - \ - static_field(StubRoutines, _aescrypt_encryptBlock, address) \ - static_field(StubRoutines, _aescrypt_decryptBlock, address) \ - static_field(StubRoutines, _cipherBlockChaining_encryptAESCrypt, address) \ - static_field(StubRoutines, _cipherBlockChaining_decryptAESCrypt, address) \ - static_field(StubRoutines, _electronicCodeBook_encryptAESCrypt, address) \ - static_field(StubRoutines, _electronicCodeBook_decryptAESCrypt, address) \ - static_field(StubRoutines, _counterMode_AESCrypt, address) \ - static_field(StubRoutines, _galoisCounterMode_AESCrypt, address) \ - static_field(StubRoutines, _base64_encodeBlock, address) \ - static_field(StubRoutines, _base64_decodeBlock, address) \ - static_field(StubRoutines, _ghash_processBlocks, address) \ - static_field(StubRoutines, _md5_implCompress, address) \ - static_field(StubRoutines, _md5_implCompressMB, address) \ - static_field(StubRoutines, _chacha20Block, address) \ - static_field(StubRoutines, _poly1305_processBlocks, address) \ - static_field(StubRoutines, _intpoly_montgomeryMult_P256, address) \ - static_field(StubRoutines, _intpoly_assign, address) \ - static_field(StubRoutines, _sha1_implCompress, address) \ - static_field(StubRoutines, _sha1_implCompressMB, address) \ - static_field(StubRoutines, _sha256_implCompress, address) \ - static_field(StubRoutines, _sha256_implCompressMB, address) \ - static_field(StubRoutines, _sha512_implCompress, address) \ - static_field(StubRoutines, _sha512_implCompressMB, address) \ - static_field(StubRoutines, _sha3_implCompress, address) \ - static_field(StubRoutines, _double_keccak, address) \ - static_field(StubRoutines, _sha3_implCompressMB, address) \ - static_field(StubRoutines, _kyberNtt, address) \ - static_field(StubRoutines, _kyberInverseNtt, address) \ - static_field(StubRoutines, _kyberNttMult, address) \ - static_field(StubRoutines, _kyberAddPoly_2, address) \ - static_field(StubRoutines, _kyberAddPoly_3, address) \ - static_field(StubRoutines, _kyber12To16, address) \ - static_field(StubRoutines, _kyberBarrettReduce, address) \ - static_field(StubRoutines, _dilithiumAlmostNtt, address) \ - static_field(StubRoutines, _dilithiumAlmostInverseNtt, address) \ - static_field(StubRoutines, _dilithiumNttMult, address) \ - static_field(StubRoutines, _dilithiumMontMulByConstant, address) \ - static_field(StubRoutines, _dilithiumDecomposePoly, address) \ - static_field(StubRoutines, _updateBytesCRC32, address) \ - static_field(StubRoutines, _updateBytesCRC32C, address) \ - static_field(StubRoutines, _updateBytesAdler32, address) \ - static_field(StubRoutines, _multiplyToLen, address) \ - static_field(StubRoutines, _squareToLen, address) \ - static_field(StubRoutines, _mulAdd, address) \ - static_field(StubRoutines, _montgomeryMultiply, address) \ - static_field(StubRoutines, _montgomerySquare, address) \ - static_field(StubRoutines, _vectorizedMismatch, address) \ - static_field(StubRoutines, _bigIntegerRightShiftWorker, address) \ - static_field(StubRoutines, _bigIntegerLeftShiftWorker, address) \ - static_field(StubRoutines, _cont_thaw, address) \ - static_field(StubRoutines, _lookup_secondary_supers_table_slow_path_stub, address) \ - \ - nonstatic_field(Thread, _poll_data, SafepointMechanism::ThreadData) \ - nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \ - nonstatic_field(Thread, _allocated_bytes, uint64_t) \ - JFR_ONLY(nonstatic_field(Thread, _jfr_thread_local, JfrThreadLocal)) \ - \ - static_field(java_lang_Thread, _tid_offset, int) \ - static_field(java_lang_Thread, _is_in_vthread_transition_offset, int) \ - JFR_ONLY(static_field(java_lang_Thread, _jfr_epoch_offset, int)) \ - \ - JFR_ONLY(nonstatic_field(JfrThreadLocal, _vthread_id, traceid)) \ - JFR_ONLY(nonstatic_field(JfrThreadLocal, _vthread_epoch, u2)) \ - JFR_ONLY(nonstatic_field(JfrThreadLocal, _vthread_excluded, bool)) \ - JFR_ONLY(nonstatic_field(JfrThreadLocal, _vthread, bool)) \ - \ - nonstatic_field(ThreadLocalAllocBuffer, _start, HeapWord*) \ - nonstatic_field(ThreadLocalAllocBuffer, _top, HeapWord*) \ - nonstatic_field(ThreadLocalAllocBuffer, _end, HeapWord*) \ - nonstatic_field(ThreadLocalAllocBuffer, _pf_top, HeapWord*) \ - nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \ - nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \ - nonstatic_field(ThreadLocalAllocBuffer, _num_refills, unsigned) \ - nonstatic_field(ThreadLocalAllocBuffer, _num_slow_allocations, unsigned) \ - \ - nonstatic_field(SafepointMechanism::ThreadData, _polling_word, volatile uintptr_t) \ - nonstatic_field(SafepointMechanism::ThreadData, _polling_page, volatile uintptr_t) \ - \ - nonstatic_field(ThreadShadow, _pending_exception, oop) \ - \ - static_field(Symbol, _vm_symbols[0], Symbol*) \ - \ - nonstatic_field(vtableEntry, _method, Method*) \ - -#define VM_TYPES(declare_type, declare_toplevel_type, declare_integer_type, declare_unsigned_integer_type) \ - declare_integer_type(bool) \ - declare_unsigned_integer_type(size_t) \ - declare_integer_type(intx) \ - declare_unsigned_integer_type(uintx) \ - declare_integer_type(CompLevel) \ - \ - declare_toplevel_type(BasicLock) \ - declare_toplevel_type(CompilerToVM) \ - declare_toplevel_type(ExceptionTableElement) \ - declare_toplevel_type(JVMFlag) \ - declare_toplevel_type(JVMFlag*) \ - declare_toplevel_type(InvocationCounter) \ - declare_toplevel_type(JVMCICompileState) \ - declare_toplevel_type(JVMCIEnv) \ - declare_toplevel_type(LocalVariableTableElement) \ - declare_toplevel_type(narrowKlass) \ - declare_toplevel_type(ObjectWaiter) \ - declare_toplevel_type(Symbol*) \ - declare_toplevel_type(vtableEntry) \ - \ - declare_toplevel_type(oopDesc) \ - declare_type(arrayOopDesc, oopDesc) \ - \ - declare_toplevel_type(CompiledICData) \ - declare_toplevel_type(MetaspaceObj) \ - declare_type(Metadata, MetaspaceObj) \ - declare_type(Klass, Metadata) \ - declare_type(InstanceKlass, Klass) \ - declare_type(ConstantPool, Metadata) \ - -#define VM_INT_CONSTANTS(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \ - declare_preprocessor_constant("ASSERT", DEBUG_ONLY(1) NOT_DEBUG(0)) \ - \ - declare_preprocessor_constant("INCLUDE_SERIALGC", INCLUDE_SERIALGC) \ - declare_preprocessor_constant("INCLUDE_PARALLELGC", INCLUDE_PARALLELGC) \ - declare_preprocessor_constant("INCLUDE_G1GC", INCLUDE_G1GC) \ - declare_preprocessor_constant("INCLUDE_ZGC", INCLUDE_ZGC) \ - declare_preprocessor_constant("INCLUDE_SHENANDOAHGC", INCLUDE_SHENANDOAHGC) \ - \ - declare_constant(CompLevel_none) \ - declare_constant(CompLevel_simple) \ - declare_constant(CompLevel_limited_profile) \ - declare_constant(CompLevel_full_profile) \ - declare_constant(CompLevel_full_optimization) \ - declare_constant(HeapWordSize) \ - declare_constant(InvocationEntryBci) \ - declare_constant(JVMCINMethodData::SPECULATION_LENGTH_BITS) \ - \ - declare_constant(FieldInfo::FieldFlags::_ff_injected) \ - declare_constant(FieldInfo::FieldFlags::_ff_stable) \ - declare_preprocessor_constant("JVM_ACC_VARARGS", JVM_ACC_VARARGS) \ - declare_preprocessor_constant("JVM_ACC_BRIDGE", JVM_ACC_BRIDGE) \ - declare_preprocessor_constant("JVM_ACC_ANNOTATION", JVM_ACC_ANNOTATION) \ - declare_preprocessor_constant("JVM_ACC_ENUM", JVM_ACC_ENUM) \ - declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC) \ - declare_preprocessor_constant("JVM_ACC_INTERFACE", JVM_ACC_INTERFACE) \ - \ - declare_constant(JVM_CONSTANT_Utf8) \ - declare_constant(JVM_CONSTANT_Unicode) \ - declare_constant(JVM_CONSTANT_Integer) \ - declare_constant(JVM_CONSTANT_Float) \ - declare_constant(JVM_CONSTANT_Long) \ - declare_constant(JVM_CONSTANT_Double) \ - declare_constant(JVM_CONSTANT_Class) \ - declare_constant(JVM_CONSTANT_String) \ - declare_constant(JVM_CONSTANT_Fieldref) \ - declare_constant(JVM_CONSTANT_Methodref) \ - declare_constant(JVM_CONSTANT_InterfaceMethodref) \ - declare_constant(JVM_CONSTANT_NameAndType) \ - declare_constant(JVM_CONSTANT_MethodHandle) \ - declare_constant(JVM_CONSTANT_MethodType) \ - declare_constant(JVM_CONSTANT_InvokeDynamic) \ - declare_constant(JVM_CONSTANT_Dynamic) \ - declare_constant(JVM_CONSTANT_Module) \ - declare_constant(JVM_CONSTANT_Package) \ - declare_constant(JVM_CONSTANT_ExternalMax) \ - \ - declare_constant(JVM_CONSTANT_Invalid) \ - declare_constant(JVM_CONSTANT_InternalMin) \ - declare_constant(JVM_CONSTANT_UnresolvedClass) \ - declare_constant(JVM_CONSTANT_ClassIndex) \ - declare_constant(JVM_CONSTANT_StringIndex) \ - declare_constant(JVM_CONSTANT_UnresolvedClassInError) \ - declare_constant(JVM_CONSTANT_MethodHandleInError) \ - declare_constant(JVM_CONSTANT_MethodTypeInError) \ - declare_constant(JVM_CONSTANT_DynamicInError) \ - declare_constant(JVM_CONSTANT_InternalMax) \ - \ - declare_constant(ArrayData::array_len_off_set) \ - declare_constant(ArrayData::array_start_off_set) \ - \ - declare_constant(BitData::exception_seen_flag) \ - declare_constant(BitData::null_seen_flag) \ - declare_constant(BranchData::not_taken_off_set) \ - \ - declare_constant_with_value("CardTable::dirty_card", CardTable::dirty_card_val()) \ - declare_constant_with_value("CardTable::clean_card", CardTable::clean_card_val()) \ - declare_constant_with_value("LockStack::_end_offset", LockStack::end_offset()) \ - declare_constant_with_value("OMCache::oop_to_oop_difference", OMCache::oop_to_oop_difference()) \ - declare_constant_with_value("OMCache::oop_to_monitor_difference", OMCache::oop_to_monitor_difference()) \ - \ - declare_constant(nmethod::InvalidationReason::NOT_INVALIDATED) \ - declare_constant(nmethod::InvalidationReason::C1_CODEPATCH) \ - declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE) \ - declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING) \ - declare_constant(nmethod::InvalidationReason::C1_PREDICATE_FAILED_TRAP) \ - declare_constant(nmethod::InvalidationReason::CI_REPLAY) \ - declare_constant(nmethod::InvalidationReason::UNLOADING) \ - declare_constant(nmethod::InvalidationReason::UNLOADING_COLD) \ - declare_constant(nmethod::InvalidationReason::JVMCI_INVALIDATE) \ - declare_constant(nmethod::InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT) \ - declare_constant(nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE) \ - declare_constant(nmethod::InvalidationReason::JVMCI_REPROFILE) \ - declare_constant(nmethod::InvalidationReason::MARKED_FOR_DEOPTIMIZATION) \ - declare_constant(nmethod::InvalidationReason::MISSING_EXCEPTION_HANDLER) \ - declare_constant(nmethod::InvalidationReason::NOT_USED) \ - declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH) \ - declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1) \ - declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL) \ - declare_constant(nmethod::InvalidationReason::SET_NATIVE_FUNCTION) \ - declare_constant(nmethod::InvalidationReason::UNCOMMON_TRAP) \ - declare_constant(nmethod::InvalidationReason::WHITEBOX_DEOPTIMIZATION) \ - declare_constant(nmethod::InvalidationReason::ZOMBIE) \ - declare_constant(nmethod::InvalidationReason::RELOCATED) \ - \ - declare_constant(CodeInstaller::VERIFIED_ENTRY) \ - declare_constant(CodeInstaller::UNVERIFIED_ENTRY) \ - declare_constant(CodeInstaller::OSR_ENTRY) \ - declare_constant(CodeInstaller::EXCEPTION_HANDLER_ENTRY) \ - declare_constant(CodeInstaller::DEOPT_HANDLER_ENTRY) \ - declare_constant(CodeInstaller::FRAME_COMPLETE) \ - declare_constant(CodeInstaller::ENTRY_BARRIER_PATCH) \ - declare_constant(CodeInstaller::INVOKEINTERFACE) \ - declare_constant(CodeInstaller::INVOKEVIRTUAL) \ - declare_constant(CodeInstaller::INVOKESTATIC) \ - declare_constant(CodeInstaller::INVOKESPECIAL) \ - declare_constant(CodeInstaller::INLINE_INVOKE) \ - declare_constant(CodeInstaller::POLL_NEAR) \ - declare_constant(CodeInstaller::POLL_RETURN_NEAR) \ - declare_constant(CodeInstaller::POLL_FAR) \ - declare_constant(CodeInstaller::POLL_RETURN_FAR) \ - declare_constant(CodeInstaller::CARD_TABLE_SHIFT) \ - declare_constant(CodeInstaller::CARD_TABLE_ADDRESS) \ - declare_constant(CodeInstaller::HEAP_TOP_ADDRESS) \ - declare_constant(CodeInstaller::HEAP_END_ADDRESS) \ - declare_constant(CodeInstaller::NARROW_KLASS_BASE_ADDRESS) \ - declare_constant(CodeInstaller::NARROW_OOP_BASE_ADDRESS) \ - declare_constant(CodeInstaller::CRC_TABLE_ADDRESS) \ - declare_constant(CodeInstaller::LOG_OF_HEAP_REGION_GRAIN_BYTES) \ - declare_constant(CodeInstaller::INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED) \ - declare_constant(CodeInstaller::DEOPT_MH_HANDLER_ENTRY) \ - declare_constant(CodeInstaller::VERIFY_OOP_COUNT_ADDRESS) \ - declare_constant(CodeInstaller::VERIFY_OOPS) \ - declare_constant(CodeInstaller::VERIFY_OOP_BITS) \ - declare_constant(CodeInstaller::VERIFY_OOP_MASK) \ - declare_constant(CodeInstaller::INVOKE_INVALID) \ - \ - declare_constant(CodeInstaller::ILLEGAL) \ - declare_constant(CodeInstaller::REGISTER_PRIMITIVE) \ - declare_constant(CodeInstaller::REGISTER_OOP) \ - declare_constant(CodeInstaller::REGISTER_NARROW_OOP) \ - declare_constant(CodeInstaller::REGISTER_VECTOR) \ - declare_constant(CodeInstaller::STACK_SLOT_PRIMITIVE) \ - declare_constant(CodeInstaller::STACK_SLOT_OOP) \ - declare_constant(CodeInstaller::STACK_SLOT_NARROW_OOP) \ - declare_constant(CodeInstaller::STACK_SLOT_VECTOR) \ - declare_constant(CodeInstaller::STACK_SLOT4_PRIMITIVE) \ - declare_constant(CodeInstaller::STACK_SLOT4_OOP) \ - declare_constant(CodeInstaller::STACK_SLOT4_NARROW_OOP) \ - declare_constant(CodeInstaller::STACK_SLOT4_VECTOR) \ - declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID) \ - declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID2) \ - declare_constant(CodeInstaller::NULL_CONSTANT) \ - declare_constant(CodeInstaller::RAW_CONSTANT) \ - declare_constant(CodeInstaller::PRIMITIVE_0) \ - declare_constant(CodeInstaller::PRIMITIVE4) \ - declare_constant(CodeInstaller::PRIMITIVE8) \ - declare_constant(CodeInstaller::JOBJECT) \ - declare_constant(CodeInstaller::OBJECT_ID) \ - declare_constant(CodeInstaller::OBJECT_ID2) \ - \ - declare_constant(CodeInstaller::NO_FINALIZABLE_SUBCLASS) \ - declare_constant(CodeInstaller::CONCRETE_SUBTYPE) \ - declare_constant(CodeInstaller::LEAF_TYPE) \ - declare_constant(CodeInstaller::CONCRETE_METHOD) \ - declare_constant(CodeInstaller::CALLSITE_TARGET_VALUE) \ - \ - declare_constant(CodeInstaller::PATCH_OBJECT_ID) \ - declare_constant(CodeInstaller::PATCH_OBJECT_ID2) \ - declare_constant(CodeInstaller::PATCH_NARROW_OBJECT_ID) \ - declare_constant(CodeInstaller::PATCH_NARROW_OBJECT_ID2) \ - declare_constant(CodeInstaller::PATCH_JOBJECT) \ - declare_constant(CodeInstaller::PATCH_NARROW_JOBJECT) \ - declare_constant(CodeInstaller::PATCH_KLASS) \ - declare_constant(CodeInstaller::PATCH_NARROW_KLASS) \ - declare_constant(CodeInstaller::PATCH_METHOD) \ - declare_constant(CodeInstaller::PATCH_DATA_SECTION_REFERENCE) \ - \ - declare_constant(CodeInstaller::SITE_CALL) \ - declare_constant(CodeInstaller::SITE_FOREIGN_CALL) \ - declare_constant(CodeInstaller::SITE_FOREIGN_CALL_NO_DEBUG_INFO) \ - declare_constant(CodeInstaller::SITE_SAFEPOINT) \ - declare_constant(CodeInstaller::SITE_INFOPOINT) \ - declare_constant(CodeInstaller::SITE_IMPLICIT_EXCEPTION) \ - declare_constant(CodeInstaller::SITE_IMPLICIT_EXCEPTION_DISPATCH) \ - declare_constant(CodeInstaller::SITE_MARK) \ - declare_constant(CodeInstaller::SITE_DATA_PATCH) \ - declare_constant(CodeInstaller::SITE_EXCEPTION_HANDLER) \ - \ - declare_constant(CodeInstaller::DI_HAS_REFERENCE_MAP) \ - declare_constant(CodeInstaller::DI_HAS_CALLEE_SAVE_INFO) \ - declare_constant(CodeInstaller::DI_HAS_FRAMES) \ - \ - declare_constant(CodeInstaller::DIF_HAS_LOCALS) \ - declare_constant(CodeInstaller::DIF_HAS_STACK) \ - declare_constant(CodeInstaller::DIF_HAS_LOCKS) \ - declare_constant(CodeInstaller::DIF_DURING_CALL) \ - declare_constant(CodeInstaller::DIF_RETHROW_EXCEPTION) \ - \ - declare_constant(CodeInstaller::HCC_IS_NMETHOD) \ - declare_constant(CodeInstaller::HCC_HAS_ASSUMPTIONS) \ - declare_constant(CodeInstaller::HCC_HAS_METHODS) \ - declare_constant(CodeInstaller::HCC_HAS_DEOPT_RESCUE_SLOT) \ - declare_constant(CodeInstaller::HCC_HAS_COMMENTS) \ - \ - declare_constant(CodeInstaller::NO_REGISTER) \ - \ - declare_constant(CollectedHeap::None) \ - declare_constant(CollectedHeap::Serial) \ - declare_constant(CollectedHeap::Parallel) \ - declare_constant(CollectedHeap::G1) \ - declare_constant(CollectedHeap::Epsilon) \ - declare_constant(CollectedHeap::Z) \ - declare_constant(CollectedHeap::Shenandoah) \ - \ - declare_constant(vmIntrinsics::FIRST_MH_SIG_POLY) \ - declare_constant(vmIntrinsics::LAST_MH_SIG_POLY) \ - declare_constant(vmIntrinsics::_invokeGeneric) \ - declare_constant(vmIntrinsics::_compiledLambdaForm) \ - \ - declare_constant(ConstantPool::_has_dynamic_constant) \ - \ - declare_constant(ConstMethodFlags::_misc_has_linenumber_table) \ - declare_constant(ConstMethodFlags::_misc_has_localvariable_table) \ - declare_constant(ConstMethodFlags::_misc_has_exception_table) \ - declare_constant(ConstMethodFlags::_misc_has_method_annotations) \ - declare_constant(ConstMethodFlags::_misc_has_parameter_annotations) \ - declare_constant(ConstMethodFlags::_misc_caller_sensitive) \ - declare_constant(ConstMethodFlags::_misc_is_hidden) \ - declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \ - declare_constant(ConstMethodFlags::_misc_reserved_stack_access) \ - declare_constant(ConstMethodFlags::_misc_changes_current_thread) \ - declare_constant(ConstMethodFlags::_misc_is_scoped) \ - declare_constant(ConstMethodFlags::_misc_is_overpass) \ - \ - declare_constant(CounterData::count_off) \ - \ - declare_constant(DataLayout::cell_size) \ - declare_constant(DataLayout::no_tag) \ - declare_constant(DataLayout::bit_data_tag) \ - declare_constant(DataLayout::counter_data_tag) \ - declare_constant(DataLayout::jump_data_tag) \ - declare_constant(DataLayout::receiver_type_data_tag) \ - declare_constant(DataLayout::virtual_call_data_tag) \ - declare_constant(DataLayout::ret_data_tag) \ - declare_constant(DataLayout::branch_data_tag) \ - declare_constant(DataLayout::multi_branch_data_tag) \ - declare_constant(DataLayout::arg_info_data_tag) \ - declare_constant(DataLayout::call_type_data_tag) \ - declare_constant(DataLayout::virtual_call_type_data_tag) \ - declare_constant(DataLayout::parameters_type_data_tag) \ - declare_constant(DataLayout::speculative_trap_data_tag) \ - \ - declare_constant(Deoptimization::Unpack_deopt) \ - declare_constant(Deoptimization::Unpack_exception) \ - declare_constant(Deoptimization::Unpack_uncommon_trap) \ - declare_constant(Deoptimization::Unpack_reexecute) \ - \ - declare_constant(Deoptimization::_action_bits) \ - declare_constant(Deoptimization::_reason_bits) \ - declare_constant(Deoptimization::_debug_id_bits) \ - declare_constant(Deoptimization::_action_shift) \ - declare_constant(Deoptimization::_reason_shift) \ - declare_constant(Deoptimization::_debug_id_shift) \ - \ - declare_constant(Deoptimization::Action_none) \ - declare_constant(Deoptimization::Action_maybe_recompile) \ - declare_constant(Deoptimization::Action_reinterpret) \ - declare_constant(Deoptimization::Action_make_not_entrant) \ - declare_constant(Deoptimization::Action_make_not_compilable) \ - \ - declare_constant(Deoptimization::Reason_none) \ - declare_constant(Deoptimization::Reason_null_check) \ - declare_constant(Deoptimization::Reason_range_check) \ - declare_constant(Deoptimization::Reason_class_check) \ - declare_constant(Deoptimization::Reason_array_check) \ - declare_constant(Deoptimization::Reason_unreached0) \ - declare_constant(Deoptimization::Reason_constraint) \ - declare_constant(Deoptimization::Reason_div0_check) \ - declare_constant(Deoptimization::Reason_loop_limit_check) \ - declare_constant(Deoptimization::Reason_short_running_long_loop) \ - declare_constant(Deoptimization::Reason_auto_vectorization_check) \ - declare_constant(Deoptimization::Reason_type_checked_inlining) \ - declare_constant(Deoptimization::Reason_optimized_type_check) \ - declare_constant(Deoptimization::Reason_aliasing) \ - declare_constant(Deoptimization::Reason_transfer_to_interpreter) \ - declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \ - declare_constant(Deoptimization::Reason_unresolved) \ - declare_constant(Deoptimization::Reason_jsr_mismatch) \ - declare_constant(Deoptimization::Reason_TRAP_HISTORY_LENGTH) \ - declare_constant(Deoptimization::_support_large_access_byte_array_virtualization) \ - \ - \ - declare_constant(InstanceKlass::linked) \ - declare_constant(InstanceKlass::being_initialized) \ - declare_constant(InstanceKlass::fully_initialized) \ - \ - /*********************************/ \ - /* InstanceKlass _misc_flags */ \ - /*********************************/ \ - \ - declare_constant(InstanceKlassFlags::_misc_has_nonstatic_concrete_methods) \ - declare_constant(InstanceKlassFlags::_misc_declares_nonstatic_concrete_methods) \ - declare_constant(KlassFlags::_misc_is_hidden_class) \ - declare_constant(KlassFlags::_misc_is_value_based_class) \ - declare_constant(KlassFlags::_misc_has_finalizer) \ - declare_constant(KlassFlags::_misc_is_cloneable_fast) \ - \ - declare_constant(JumpData::taken_off_set) \ - declare_constant(JumpData::displacement_off_set) \ - \ - declare_preprocessor_constant("JVMCI::ok", JVMCI::ok) \ - declare_preprocessor_constant("JVMCI::dependencies_failed", JVMCI::dependencies_failed) \ - declare_preprocessor_constant("JVMCI::cache_full", JVMCI::cache_full) \ - declare_preprocessor_constant("JVMCI::code_too_large", JVMCI::code_too_large) \ - declare_preprocessor_constant("JVMCI::nmethod_reclaimed", JVMCI::nmethod_reclaimed) \ - declare_preprocessor_constant("JVMCI::first_permanent_bailout", JVMCI::first_permanent_bailout) \ - \ - declare_constant(JVMCIRuntime::none) \ - declare_constant(JVMCIRuntime::by_holder) \ - declare_constant(JVMCIRuntime::by_full_signature) \ - \ - declare_constant(Klass::_lh_neutral_value) \ - declare_constant(Klass::_lh_instance_slow_path_bit) \ - declare_constant(Klass::_lh_log2_element_size_shift) \ - declare_constant(Klass::_lh_log2_element_size_mask) \ - declare_constant(Klass::_lh_element_type_shift) \ - declare_constant(Klass::_lh_element_type_mask) \ - declare_constant(Klass::_lh_header_size_shift) \ - declare_constant(Klass::_lh_header_size_mask) \ - declare_constant(Klass::_lh_array_tag_shift) \ - declare_constant(Klass::_lh_array_tag_type_value) \ - declare_constant(Klass::_lh_array_tag_obj_value) \ - \ - declare_constant(markWord::no_hash) \ - \ - declare_constant(MethodFlags::_misc_force_inline) \ - declare_constant(MethodFlags::_misc_dont_inline) \ - \ - declare_constant(Method::nonvirtual_vtable_index) \ - declare_constant(Method::invalid_vtable_index) \ - \ - declare_constant(MultiBranchData::per_case_cell_count) \ - \ - AARCH64_ONLY(declare_constant(NMethodPatchingType::stw_instruction_and_data_patch)) \ - AARCH64_ONLY(declare_constant(NMethodPatchingType::conc_instruction_and_data_patch)) \ - \ - declare_constant(ObjectMonitor::NO_OWNER) \ - declare_constant(ObjectMonitor::ANONYMOUS_OWNER) \ - declare_constant(ObjectMonitor::DEFLATER_MARKER) \ - \ - declare_constant(ReceiverTypeData::receiver_type_row_cell_count) \ - declare_constant(ReceiverTypeData::receiver0_offset) \ - declare_constant(ReceiverTypeData::count0_offset) \ - \ - declare_constant(vmIntrinsics::_invokeBasic) \ - declare_constant(vmIntrinsics::_linkToVirtual) \ - declare_constant(vmIntrinsics::_linkToStatic) \ - declare_constant(vmIntrinsics::_linkToSpecial) \ - declare_constant(vmIntrinsics::_linkToInterface) \ - declare_constant(vmIntrinsics::_linkToNative) \ - \ - declare_constant(vmSymbols::FIRST_SID) \ - declare_constant(vmSymbols::SID_LIMIT) \ - -#define VM_LONG_CONSTANTS(declare_constant, declare_preprocessor_constant) \ - declare_constant(InvocationCounter::count_increment) \ - declare_constant(InvocationCounter::count_shift) \ - \ - declare_constant(markWord::klass_shift) \ - declare_constant(markWord::hash_shift) \ - declare_constant(markWord::monitor_value) \ - \ - declare_constant(markWord::lock_mask_in_place) \ - declare_constant(markWord::age_mask_in_place) \ - declare_constant(markWord::hash_mask) \ - declare_constant(markWord::hash_mask_in_place) \ - \ - declare_constant(markWord::unlocked_value) \ - declare_constant(markWord::marked_value) \ - \ - declare_constant(markWord::no_hash_in_place) \ - declare_constant(markWord::no_lock_in_place) \ - -// Helper macro to support ZGC pattern where the function itself isn't exported -#define DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, name) \ - declare_function_with_value(name, name##_addr()) - - -#define VM_ADDRESSES(declare_address, declare_preprocessor_address, declare_function, declare_function_with_value) \ - declare_function(SharedRuntime::register_finalizer) \ - declare_function(SharedRuntime::exception_handler_for_return_address) \ - declare_function(SharedRuntime::OSR_migration_end) \ - declare_function(SharedRuntime::enable_stack_reserved_zone) \ - declare_function(SharedRuntime::frem) \ - declare_function(SharedRuntime::drem) \ - \ - declare_function(os::dll_load) \ - declare_function(os::dll_lookup) \ - declare_function(os::javaTimeMillis) \ - declare_function(os::javaTimeNanos) \ - \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded_store_good)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::no_keepalive_load_barrier_on_weak_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::no_keepalive_load_barrier_on_phantom_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::no_keepalive_store_barrier_on_oop_field_without_healing)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::store_barrier_on_native_oop_field_without_healing)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::store_barrier_on_oop_field_with_healing)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::store_barrier_on_oop_field_without_healing)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_oop_array)) \ - \ - declare_function(Deoptimization::fetch_unroll_info) \ - declare_function(Deoptimization::uncommon_trap) \ - declare_function(Deoptimization::unpack_frames) \ - \ - declare_function(JVMCIRuntime::new_instance_or_null) \ - declare_function(JVMCIRuntime::new_array_or_null) \ - declare_function(JVMCIRuntime::new_multi_array_or_null) \ - declare_function(JVMCIRuntime::dynamic_new_array_or_null) \ - declare_function(JVMCIRuntime::dynamic_new_instance_or_null) \ - \ - declare_function(JVMCIRuntime::invoke_static_method_one_arg) \ - \ - declare_function(JVMCIRuntime::vm_message) \ - declare_function(JVMCIRuntime::identity_hash_code) \ - declare_function(JVMCIRuntime::exception_handler_for_pc) \ - declare_function(JVMCIRuntime::monitorenter) \ - declare_function(JVMCIRuntime::monitorexit) \ - declare_function(JVMCIRuntime::object_notify) \ - declare_function(JVMCIRuntime::object_notifyAll) \ - declare_function(JVMCIRuntime::throw_and_post_jvmti_exception) \ - declare_function(JVMCIRuntime::throw_klass_external_name_exception) \ - declare_function(JVMCIRuntime::throw_class_cast_exception) \ - declare_function(JVMCIRuntime::log_primitive) \ - declare_function(JVMCIRuntime::log_object) \ - declare_function(JVMCIRuntime::log_printf) \ - declare_function(JVMCIRuntime::vm_error) \ - declare_function(JVMCIRuntime::load_and_clear_exception) \ - G1GC_ONLY(declare_function(JVMCIRuntime::write_barrier_pre)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_strong)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_strong_narrow)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_weak)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_weak_narrow)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_phantom)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::load_reference_barrier_phantom_narrow)) \ - SHENANDOAHGC_ONLY(declare_function(ShenandoahRuntime::write_barrier_pre)) \ - declare_function(JVMCIRuntime::validate_object) \ - \ - declare_function(JVMCIRuntime::test_deoptimize_call_int) - - -#if INCLUDE_G1GC - -#define VM_STRUCTS_JVMCI_G1GC(nonstatic_field, static_field) \ - static_field(G1HeapRegion, LogOfHRGrainBytes, uint) - -#define VM_INT_CONSTANTS_JVMCI_G1GC(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \ - declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_active_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset())) \ - declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_index_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_index_offset())) \ - declare_constant_with_value("G1ThreadLocalData::satb_mark_queue_buffer_offset", in_bytes(G1ThreadLocalData::satb_mark_queue_buffer_offset())) \ - declare_constant_with_value("G1ThreadLocalData::card_table_base_offset", in_bytes(G1ThreadLocalData::card_table_base_offset())) \ - -#endif // INCLUDE_G1GC - - -#if INCLUDE_ZGC - -#define VM_INT_CONSTANTS_JVMCI_ZGC(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \ - declare_constant_with_value("ZThreadLocalData::store_good_mask_offset" , in_bytes(ZThreadLocalData::store_good_mask_offset())) \ - declare_constant_with_value("ZThreadLocalData::store_bad_mask_offset" , in_bytes(ZThreadLocalData::store_bad_mask_offset())) \ - declare_constant_with_value("ZThreadLocalData::store_barrier_buffer_offset" , in_bytes(ZThreadLocalData::store_barrier_buffer_offset())) \ - declare_constant_with_value("ZStoreBarrierBuffer::current_offset" , in_bytes(ZStoreBarrierBuffer::current_offset())) \ - declare_constant_with_value("ZStoreBarrierBuffer::buffer_offset" , in_bytes(ZStoreBarrierBuffer::buffer_offset())) \ - declare_constant_with_value("ZStoreBarrierEntry::p_offset" , in_bytes(ZStoreBarrierEntry::p_offset())) \ - declare_constant_with_value("ZStoreBarrierEntry::prev_offset" , in_bytes(ZStoreBarrierEntry::prev_offset())) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_LOAD_BAD_AFTER_TEST)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_AFTER_TEST)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_CMP)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_AFTER_TEST)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_OR)) \ - AMD64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_AFTER_MOV)) \ - AARCH64_ONLY(declare_constant(ZPointerLoadShift)) \ - AARCH64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_TB_X)) \ - AARCH64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_MARK_BAD_BEFORE_MOV)) \ - AARCH64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_GOOD_BEFORE_MOV)) \ - AARCH64_ONLY(declare_constant(CodeInstaller::Z_BARRIER_RELOCATION_FORMAT_STORE_BAD_BEFORE_MOV)) - -#endif // INCLUDE_ZGC - -#if INCLUDE_SHENANDOAHGC - -#define VM_INT_CONSTANTS_JVMCI_SHENANDOAH(declare_constant, declare_constant_with_value, declare_preprocessor_constant) \ - declare_constant_with_value("ShenandoahThreadLocalData::gc_state_offset", in_bytes(ShenandoahThreadLocalData::gc_state_offset())) \ - declare_constant_with_value("ShenandoahThreadLocalData::satb_mark_queue_index_offset", in_bytes(ShenandoahThreadLocalData::satb_mark_queue_index_offset())) \ - declare_constant_with_value("ShenandoahThreadLocalData::satb_mark_queue_buffer_offset", in_bytes(ShenandoahThreadLocalData::satb_mark_queue_buffer_offset())) \ - declare_constant_with_value("ShenandoahThreadLocalData::card_table_offset", in_bytes(ShenandoahThreadLocalData::card_table_offset())) \ - declare_constant_with_value("ShenandoahHeap::HAS_FORWARDED", ShenandoahHeap::HAS_FORWARDED) \ - declare_constant_with_value("ShenandoahHeap::MARKING", ShenandoahHeap::MARKING) \ - declare_constant_with_value("ShenandoahHeap::EVACUATION", ShenandoahHeap::EVACUATION) \ - declare_constant_with_value("ShenandoahHeap::UPDATE_REFS", ShenandoahHeap::UPDATE_REFS) \ - declare_constant_with_value("ShenandoahHeap::WEAK_ROOTS", ShenandoahHeap::WEAK_ROOTS) \ - declare_constant_with_value("ShenandoahHeap::YOUNG_MARKING", ShenandoahHeap::YOUNG_MARKING) \ - declare_constant_with_value("ShenandoahHeap::OLD_MARKING", ShenandoahHeap::OLD_MARKING) \ - -#endif - -#ifdef LINUX - -#define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function, declare_function_with_value) \ - declare_preprocessor_address("RTLD_DEFAULT", RTLD_DEFAULT) - -#endif - - -#ifdef BSD - -#define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function, declare_function_with_value) \ - declare_preprocessor_address("RTLD_DEFAULT", RTLD_DEFAULT) - -#endif - -#ifdef AARCH64 - -#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field) \ - static_field(VM_Version, _zva_length, int) \ - static_field(StubRoutines::aarch64, _count_positives, address) \ - static_field(StubRoutines::aarch64, _count_positives_long, address) \ - static_field(VM_Version, _rop_protection, bool) \ - volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*) - -#define DECLARE_INT_CPU_FEATURE_CONSTANT(id, name) GENERATE_VM_INT_CONSTANT_ENTRY(VM_Version::CPU_##id) -#define VM_INT_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_INT_CPU_FEATURE_CONSTANT) - -#endif - -#ifdef X86 - -#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field) \ - volatile_nonstatic_field(JavaFrameAnchor, _last_Java_fp, intptr_t*) \ - static_field(VM_Version, _features, VM_Version::VM_Features) \ - \ - nonstatic_field(VM_Version::VM_Features, _features_bitmap[0], uint64_t) \ - static_field(VM_Version::VM_Features, _features_bitmap_size, int) \ - static_field(VM_Version, _has_intel_jcc_erratum, bool) - -#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant) \ - LP64_ONLY(declare_constant(frame::arg_reg_save_area_bytes)) \ - declare_constant(frame::interpreter_frame_sender_sp_offset) \ - declare_constant(frame::interpreter_frame_last_sp_offset) - -#define DECLARE_LONG_CPU_FEATURE_CONSTANT(id, name) GENERATE_VM_LONG_CONSTANT_ENTRY(VM_Version::CPU_##id) -#define VM_LONG_CPU_FEATURE_CONSTANTS \ - CPU_FEATURE_FLAGS(DECLARE_LONG_CPU_FEATURE_CONSTANT) - -#endif - -/* - * Dummy defines for architectures that don't use these. - */ -#ifndef VM_STRUCTS_CPU -#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field) -#endif - -#ifndef VM_INT_CONSTANTS_CPU -#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant) -#endif - -#ifndef VM_LONG_CONSTANTS_CPU -#define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant) -#endif - -#ifndef VM_ADDRESSES_OS -#define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function, declare_function_with_value) -#endif - -// -// Instantiation of VMStructEntries, VMTypeEntries and VMIntConstantEntries -// - -#define GENERATE_VM_FUNCTION_WITH_VALUE_ENTRY(name, value) \ - { QUOTE(name), CAST_FROM_FN_PTR(void*, value) }, - - -// These initializers are allowed to access private fields in classes -// as long as class VMStructs is a friend -VMStructEntry JVMCIVMStructs::localHotSpotVMStructs[] = { - VM_STRUCTS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_STATIC_VM_STRUCT_ENTRY, - GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_NONSTATIC_VM_STRUCT_ENTRY) - - VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_STATIC_VM_STRUCT_ENTRY, - GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY) - -#if INCLUDE_G1GC - VM_STRUCTS_JVMCI_G1GC(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, - GENERATE_STATIC_VM_STRUCT_ENTRY) -#endif - - GENERATE_VM_STRUCT_LAST_ENTRY() -}; - -VMTypeEntry JVMCIVMStructs::localHotSpotVMTypes[] = { - VM_TYPES(GENERATE_VM_TYPE_ENTRY, - GENERATE_TOPLEVEL_VM_TYPE_ENTRY, - GENERATE_INTEGER_VM_TYPE_ENTRY, - GENERATE_UNSIGNED_INTEGER_VM_TYPE_ENTRY) - - GENERATE_VM_TYPE_LAST_ENTRY() -}; - -VMIntConstantEntry JVMCIVMStructs::localHotSpotVMIntConstants[] = { - VM_INT_CONSTANTS(GENERATE_VM_INT_CONSTANT_ENTRY, - GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY, - GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) - - VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY, - GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) - -#if INCLUDE_G1GC - VM_INT_CONSTANTS_JVMCI_G1GC(GENERATE_VM_INT_CONSTANT_ENTRY, - GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY, - GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) -#endif -#if INCLUDE_ZGC - VM_INT_CONSTANTS_JVMCI_ZGC(GENERATE_VM_INT_CONSTANT_ENTRY, - GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY, - GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) -#endif -#if INCLUDE_SHENANDOAHGC - VM_INT_CONSTANTS_JVMCI_SHENANDOAH(GENERATE_VM_INT_CONSTANT_ENTRY, - GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY, - GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) -#endif -#ifdef VM_INT_CPU_FEATURE_CONSTANTS - VM_INT_CPU_FEATURE_CONSTANTS -#endif - GENERATE_VM_INT_CONSTANT_LAST_ENTRY() -}; - -VMLongConstantEntry JVMCIVMStructs::localHotSpotVMLongConstants[] = { - VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY, - GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY) - - VM_LONG_CONSTANTS_CPU(GENERATE_VM_LONG_CONSTANT_ENTRY, - GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY) -#ifdef VM_LONG_CPU_FEATURE_CONSTANTS - VM_LONG_CPU_FEATURE_CONSTANTS -#endif - GENERATE_VM_LONG_CONSTANT_LAST_ENTRY() -}; - -VMAddressEntry JVMCIVMStructs::localHotSpotVMAddresses[] = { - VM_ADDRESSES(GENERATE_VM_ADDRESS_ENTRY, - GENERATE_PREPROCESSOR_VM_ADDRESS_ENTRY, - GENERATE_VM_FUNCTION_ENTRY, - GENERATE_VM_FUNCTION_WITH_VALUE_ENTRY) - VM_ADDRESSES_OS(GENERATE_VM_ADDRESS_ENTRY, - GENERATE_PREPROCESSOR_VM_ADDRESS_ENTRY, - GENERATE_VM_FUNCTION_ENTRY, - GENERATE_VM_FUNCTION_WITH_VALUE_ENTRY) - - GENERATE_VM_ADDRESS_LAST_ENTRY() -}; - -int JVMCIVMStructs::localHotSpotVMStructs_count() { - // Ignore sentinel entry at the end - return (sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry)) - 1; -} -int JVMCIVMStructs::localHotSpotVMTypes_count() { - // Ignore sentinel entry at the end - return (sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry)) - 1; -} -int JVMCIVMStructs::localHotSpotVMIntConstants_count() { - // Ignore sentinel entry at the end - return (sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry)) - 1; -} -int JVMCIVMStructs::localHotSpotVMLongConstants_count() { - // Ignore sentinel entry at the end - return (sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry)) - 1; -} -int JVMCIVMStructs::localHotSpotVMAddresses_count() { - // Ignore sentinel entry at the end - return (sizeof(localHotSpotVMAddresses) / sizeof(VMAddressEntry)) - 1; -} - -#ifdef ASSERT -// This is used both to check the types of referenced fields and -// to ensure that all of the field types are present. -void JVMCIVMStructs::init() { - VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY, - CHECK_STATIC_VM_STRUCT_ENTRY, - CHECK_NO_OP, - CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY); - - - VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY, - CHECK_STATIC_VM_STRUCT_ENTRY, - CHECK_NO_OP, - CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY, - CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY) - -#if INCLUDE_G1GC - VM_STRUCTS_JVMCI_G1GC(CHECK_NONSTATIC_VM_STRUCT_ENTRY, - CHECK_STATIC_VM_STRUCT_ENTRY) -#endif - - VM_TYPES(CHECK_VM_TYPE_ENTRY, - CHECK_SINGLE_ARG_VM_TYPE_NO_OP, - CHECK_SINGLE_ARG_VM_TYPE_NO_OP, - CHECK_SINGLE_ARG_VM_TYPE_NO_OP); -} - -void jvmci_vmStructs_init() { - JVMCIVMStructs::init(); -} -#endif // ASSERT diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.hpp b/src/hotspot/share/jvmci/vmStructs_jvmci.hpp deleted file mode 100644 index 584491f0907..00000000000 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_JVMCI_VMSTRUCTS_JVMCI_HPP -#define SHARE_JVMCI_VMSTRUCTS_JVMCI_HPP - -#include "runtime/vmStructs.hpp" - -class JVMCIVMStructs { -public: - /** - * The last entry has a null fieldName. - */ - static VMStructEntry localHotSpotVMStructs[]; - - /** - * The last entry has a null typeName. - */ - static VMTypeEntry localHotSpotVMTypes[]; - - /** - * Table of integer constants. - * The last entry has a null typeName. - */ - static VMIntConstantEntry localHotSpotVMIntConstants[]; - - /** - * Table of long constants. - * The last entry has a null typeName. - */ - static VMLongConstantEntry localHotSpotVMLongConstants[]; - - /** - * Table of addresses. - */ - static VMAddressEntry localHotSpotVMAddresses[]; - - static int localHotSpotVMStructs_count(); - static int localHotSpotVMTypes_count(); - static int localHotSpotVMIntConstants_count(); - static int localHotSpotVMLongConstants_count(); - static int localHotSpotVMAddresses_count(); - - // This is used to run any checking code necessary for validation of - // the data structure (debug build only) - static void init() NOT_DEBUG_RETURN; -}; - -#endif // SHARE_JVMCI_VMSTRUCTS_JVMCI_HPP diff --git a/src/hotspot/share/jvmci/vmSymbols_jvmci.hpp b/src/hotspot/share/jvmci/vmSymbols_jvmci.hpp deleted file mode 100644 index 5948951ecd7..00000000000 --- a/src/hotspot/share/jvmci/vmSymbols_jvmci.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_JVMCI_VMSYMBOLS_JVMCI_HPP -#define SHARE_JVMCI_VMSYMBOLS_JVMCI_HPP - - -#if !INCLUDE_JVMCI -#define JVMCI_VM_SYMBOLS_DO(template, do_alias) -#else -#define JVMCI_VM_SYMBOLS_DO(template, do_alias) \ - template(jdk_vm_ci_services_Services, "jdk/vm/ci/services/Services") \ - template(jdk_vm_ci_runtime_JVMCI, "jdk/vm/ci/runtime/JVMCI") \ - template(jdk_vm_ci_hotspot_HotSpotCompiledCode, "jdk/vm/ci/hotspot/HotSpotCompiledCode") \ - template(jdk_vm_ci_hotspot_HotSpotCompiledNmethod, "jdk/vm/ci/hotspot/HotSpotCompiledNmethod") \ - template(jdk_vm_ci_hotspot_CompilerToVM, "jdk/vm/ci/hotspot/CompilerToVM") \ - template(jdk_vm_ci_hotspot_HotSpotInstalledCode, "jdk/vm/ci/hotspot/HotSpotInstalledCode") \ - template(jdk_vm_ci_hotspot_HotSpotNmethod, "jdk/vm/ci/hotspot/HotSpotNmethod") \ - template(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl, "jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl") \ - template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl") \ - template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl_FieldInfo, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl$FieldInfo") \ - template(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType, "jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType") \ - template(jdk_vm_ci_hotspot_HotSpotResolvedJavaFieldImpl, "jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl") \ - template(jdk_vm_ci_hotspot_HotSpotCompressedNullConstant, "jdk/vm/ci/hotspot/HotSpotCompressedNullConstant") \ - template(jdk_vm_ci_hotspot_HotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/HotSpotObjectConstantImpl") \ - template(jdk_vm_ci_hotspot_HotSpotMethodData, "jdk/vm/ci/hotspot/HotSpotMethodData") \ - template(jdk_vm_ci_hotspot_DirectHotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl") \ - template(jdk_vm_ci_hotspot_IndirectHotSpotObjectConstantImpl, "jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl") \ - template(jdk_vm_ci_hotspot_HotSpotStackFrameReference, "jdk/vm/ci/hotspot/HotSpotStackFrameReference") \ - template(jdk_vm_ci_hotspot_HotSpotConstantPool, "jdk/vm/ci/hotspot/HotSpotConstantPool") \ - template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime") \ - template(jdk_vm_ci_hotspot_HotSpotSpeculationLog, "jdk/vm/ci/hotspot/HotSpotSpeculationLog") \ - template(jdk_vm_ci_hotspot_HotSpotCompilationRequestResult, "jdk/vm/ci/hotspot/HotSpotCompilationRequestResult") \ - template(jdk_vm_ci_hotspot_VMField, "jdk/vm/ci/hotspot/VMField") \ - template(jdk_vm_ci_hotspot_VMFlag, "jdk/vm/ci/hotspot/VMFlag") \ - template(jdk_vm_ci_hotspot_VMIntrinsicMethod, "jdk/vm/ci/hotspot/VMIntrinsicMethod") \ - template(jdk_vm_ci_meta_ResolvedJavaMethod, "jdk/vm/ci/meta/ResolvedJavaMethod") \ - template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \ - template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \ - template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \ - template(jdk_vm_ci_meta_NullConstant, "jdk/vm/ci/meta/NullConstant") \ - template(jdk_vm_ci_meta_ExceptionHandler, "jdk/vm/ci/meta/ExceptionHandler") \ - template(jdk_vm_ci_meta_JavaKind, "jdk/vm/ci/meta/JavaKind") \ - template(jdk_vm_ci_meta_ValueKind, "jdk/vm/ci/meta/ValueKind") \ - template(jdk_vm_ci_meta_Value, "jdk/vm/ci/meta/Value") \ - template(jdk_vm_ci_meta_Assumptions_ConcreteSubtype, "jdk/vm/ci/meta/Assumptions$ConcreteSubtype") \ - template(jdk_vm_ci_meta_Assumptions_LeafType, "jdk/vm/ci/meta/Assumptions$LeafType") \ - template(jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass, "jdk/vm/ci/meta/Assumptions$NoFinalizableSubclass") \ - template(jdk_vm_ci_meta_Assumptions_ConcreteMethod, "jdk/vm/ci/meta/Assumptions$ConcreteMethod") \ - template(jdk_vm_ci_meta_Assumptions_CallSiteTargetValue, "jdk/vm/ci/meta/Assumptions$CallSiteTargetValue") \ - template(jdk_vm_ci_code_Architecture, "jdk/vm/ci/code/Architecture") \ - template(jdk_vm_ci_code_BytecodeFrame, "jdk/vm/ci/code/BytecodeFrame") \ - template(jdk_vm_ci_code_BytecodePosition, "jdk/vm/ci/code/BytecodePosition") \ - template(jdk_vm_ci_code_InstalledCode, "jdk/vm/ci/code/InstalledCode") \ - template(jdk_vm_ci_code_InvalidInstalledCodeException, "jdk/vm/ci/code/InvalidInstalledCodeException") \ - template(jdk_vm_ci_code_stack_InspectedFrameVisitor, "jdk/vm/ci/code/stack/InspectedFrameVisitor") \ - template(jdk_vm_ci_common_JVMCIError, "jdk/vm/ci/common/JVMCIError") \ - \ - template(visitFrame_name, "visitFrame") \ - template(visitFrame_signature, "(Ljdk/vm/ci/code/stack/InspectedFrame;)Ljava/lang/Object;") \ - template(compileMethod_name, "compileMethod") \ - template(compileMethod_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;IJI)Ljdk/vm/ci/hotspot/HotSpotCompilationRequestResult;") \ - template(isGCSupported_name, "isGCSupported") \ - template(isIntrinsicSupported_name, "isIntrinsicSupported") \ - template(fromMetaspace_name, "fromMetaspace") \ - template(method_fromMetaspace_signature, "(JLjdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;)Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \ - template(constantPool_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotConstantPool;") \ - template(klass_fromMetaspace_signature, "(J)Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;") \ - template(primitive_fromMetaspace_signature, "(Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;C)Ljdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType;") \ - template(getRuntime_name, "getRuntime") \ - template(getRuntime_signature, "()Ljdk/vm/ci/runtime/JVMCIRuntime;") \ - template(initializeRuntime_name, "initializeRuntime") \ - do_alias(initializeRuntime_signature, getRuntime_signature) \ - template(runtime_name, "runtime") \ - template(runtime_signature, "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;") \ - template(getCompiler_name, "getCompiler") \ - template(getCompiler_signature, "()Ljdk/vm/ci/runtime/JVMCICompiler;") \ - template(exceptionToString_name, "exceptionToString") \ - template(exceptionToString_signature, "(Ljava/lang/Throwable;ZZ)[Ljava/lang/String;") \ - template(postTranslation_name, "postTranslation") \ - template(getName_name, "getName") \ - template(bootstrapFinished_name, "bootstrapFinished") \ - template(forPrimitive_name, "forPrimitive") \ - template(forPrimitive_signature, "(CJ)Ljdk/vm/ci/meta/PrimitiveConstant;") \ - template(method_string_bool_bool_long_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;Ljava/lang/String;ZZJ)V") \ - -#endif - -#endif // SHARE_JVMCI_VMSYMBOLS_JVMCI_HPP diff --git a/src/hotspot/share/logging/logTag.hpp b/src/hotspot/share/logging/logTag.hpp index 2b8d6a72be4..848ff78678a 100644 --- a/src/hotspot/share/logging/logTag.hpp +++ b/src/hotspot/share/logging/logTag.hpp @@ -111,7 +111,6 @@ class outputStream; LOG_TAG(jit) \ LOG_TAG(jmethod) \ LOG_TAG(jni) \ - LOG_TAG(jvmci) \ LOG_TAG(jvmti) \ LOG_TAG(lambda) \ LOG_TAG(library) \ diff --git a/src/hotspot/share/nmt/memTag.hpp b/src/hotspot/share/nmt/memTag.hpp index b1b59c9151a..0f70b7ccc12 100644 --- a/src/hotspot/share/nmt/memTag.hpp +++ b/src/hotspot/share/nmt/memTag.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ f(mtGC, "GC") \ f(mtGCCardSet, "GCCardSet") /* G1 card set remembered set */ \ f(mtCompiler, "Compiler") \ - f(mtJVMCI, "JVMCI") \ f(mtInternal, "Internal") /* memory used by VM, but does not belong to */ \ /* any of above categories, and not used by */ \ /* NMT */ \ diff --git a/src/hotspot/share/oops/annotations.hpp b/src/hotspot/share/oops/annotations.hpp index 4e9fa56ace9..51f6198ff68 100644 --- a/src/hotspot/share/oops/annotations.hpp +++ b/src/hotspot/share/oops/annotations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,6 @@ typedef Array AnnotationArray; class Annotations: public MetaspaceObj { friend class VMStructs; - friend class JVMCIVMStructs; // If you add a new field that points to any metaspace object, you // must add this field to Annotations::metaspace_pointers_do(). diff --git a/src/hotspot/share/oops/array.hpp b/src/hotspot/share/oops/array.hpp index 0c720c85478..cc7c6c763dd 100644 --- a/src/hotspot/share/oops/array.hpp +++ b/src/hotspot/share/oops/array.hpp @@ -41,7 +41,6 @@ class Array: public MetaspaceObj { friend class ArchiveBuilder; friend class MetadataFactory; friend class VMStructs; - friend class JVMCIVMStructs; friend class MethodHandleCompiler; // special case friend class WhiteBox; friend class FieldInfoStream; diff --git a/src/hotspot/share/oops/bsmAttribute.hpp b/src/hotspot/share/oops/bsmAttribute.hpp index dba00395c30..535821d539e 100644 --- a/src/hotspot/share/oops/bsmAttribute.hpp +++ b/src/hotspot/share/oops/bsmAttribute.hpp @@ -86,7 +86,6 @@ public: // The BSMAttributeEntries stores the state of the BootstrapMethods attribute. class BSMAttributeEntries { friend class VMStructs; - friend class JVMCIVMStructs; public: class InsertionIterator { diff --git a/src/hotspot/share/oops/constMethod.hpp b/src/hotspot/share/oops/constMethod.hpp index 47fcb0d5572..ad9f0770e0f 100644 --- a/src/hotspot/share/oops/constMethod.hpp +++ b/src/hotspot/share/oops/constMethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -169,7 +169,6 @@ class InlineTableSizes : StackObj { class ConstMethod : public MetaspaceObj { friend class VMStructs; - friend class JVMCIVMStructs; public: typedef enum { NORMAL, OVERPASS } MethodType; diff --git a/src/hotspot/share/oops/constMethodFlags.hpp b/src/hotspot/share/oops/constMethodFlags.hpp index 03d82cd5c74..765890757ef 100644 --- a/src/hotspot/share/oops/constMethodFlags.hpp +++ b/src/hotspot/share/oops/constMethodFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ class outputStream; class ConstMethodFlags { friend class VMStructs; - friend class JVMCIVMStructs; #define CM_FLAGS_DO(flag) \ flag(has_linenumber_table , 1 << 0) \ diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index dcc3fa7e22e..97dc91aaeac 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -80,7 +80,6 @@ public: class ConstantPool : public Metadata { friend class VMStructs; - friend class JVMCIVMStructs; friend class BytecodeInterpreter; // Directly extracts a klass in the pool for fast instanceof/checkcast friend class Universe; // For null constructor friend class AOTConstantPoolResolver; diff --git a/src/hotspot/share/oops/fieldInfo.hpp b/src/hotspot/share/oops/fieldInfo.hpp index 88c982e9d1f..b6330e77f72 100644 --- a/src/hotspot/share/oops/fieldInfo.hpp +++ b/src/hotspot/share/oops/fieldInfo.hpp @@ -66,7 +66,6 @@ class FieldInfo { class FieldFlags { friend class VMStructs; - friend class JVMCIVMStructs; // The ordering of this enum is totally internal. More frequent // flags should come earlier than less frequent ones, because diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index 983f0f91699..41f176330fa 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -133,7 +133,6 @@ struct JvmtiCachedClassFileData; class InstanceKlass: public Klass { friend class VMStructs; - friend class JVMCIVMStructs; friend class ClassFileParser; friend class CompileReplay; diff --git a/src/hotspot/share/oops/instanceKlassFlags.hpp b/src/hotspot/share/oops/instanceKlassFlags.hpp index d576805b30f..1709c02a171 100644 --- a/src/hotspot/share/oops/instanceKlassFlags.hpp +++ b/src/hotspot/share/oops/instanceKlassFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ class ClassLoaderData; class InstanceKlassFlags { friend class VMStructs; - friend class JVMCIVMStructs; #define IK_FLAGS_DO(flag) \ flag(rewritten , 1 << 0) /* methods rewritten. */ \ diff --git a/src/hotspot/share/oops/klass.hpp b/src/hotspot/share/oops/klass.hpp index 1c6b28127b8..3b8c7a0ce29 100644 --- a/src/hotspot/share/oops/klass.hpp +++ b/src/hotspot/share/oops/klass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,6 @@ class vtableEntry; class Klass : public Metadata { friend class VMStructs; - friend class JVMCIVMStructs; public: // Klass Kinds for all subclasses of Klass enum KlassKind : u2 { @@ -451,10 +450,6 @@ protected: static ByteSize java_mirror_offset() { return byte_offset_of(Klass, _java_mirror); } static ByteSize class_loader_data_offset() { return byte_offset_of(Klass, _class_loader_data); } static ByteSize layout_helper_offset() { return byte_offset_of(Klass, _layout_helper); } -#if INCLUDE_JVMCI - static ByteSize subklass_offset() { return byte_offset_of(Klass, _subklass); } - static ByteSize next_sibling_offset() { return byte_offset_of(Klass, _next_sibling); } -#endif static ByteSize secondary_supers_bitmap_offset() { return byte_offset_of(Klass, _secondary_supers_bitmap); } static ByteSize hash_slot_offset() { return byte_offset_of(Klass, _hash_slot); } diff --git a/src/hotspot/share/oops/klassFlags.hpp b/src/hotspot/share/oops/klassFlags.hpp index 3e71bb3c1b3..bb56b2564ee 100644 --- a/src/hotspot/share/oops/klassFlags.hpp +++ b/src/hotspot/share/oops/klassFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ using klass_flags_t = u1; class KlassFlags { friend class VMStructs; - friend class JVMCIVMStructs; public: #define KLASS_FLAGS_DO(flag) \ diff --git a/src/hotspot/share/oops/klassVtable.hpp b/src/hotspot/share/oops/klassVtable.hpp index b8635e7f14b..0aa293cc54d 100644 --- a/src/hotspot/share/oops/klassVtable.hpp +++ b/src/hotspot/share/oops/klassVtable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -181,7 +181,6 @@ class klassVtable { // from_interpreter_entry_point -> i2cadapter class vtableEntry { friend class VMStructs; - friend class JVMCIVMStructs; public: // size in words diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index 5ef23595037..9001193f318 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -67,7 +67,6 @@ class InterpreterOopMap; class Method : public Metadata { friend class VMStructs; - friend class JVMCIVMStructs; friend class MethodTest; private: // If you add a new field that points to any metaspace object, you @@ -261,10 +260,10 @@ class Method : public Metadata { int highest_osr_comp_level() const; void set_highest_osr_comp_level(int level); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Count of times method was exited via exception while interpreting inline void interpreter_throwout_increment(Thread* current); -#endif +#endif // COMPILER2 inline int interpreter_throwout_count() const; diff --git a/src/hotspot/share/oops/method.inline.hpp b/src/hotspot/share/oops/method.inline.hpp index 95398643ca1..82dce518245 100644 --- a/src/hotspot/share/oops/method.inline.hpp +++ b/src/hotspot/share/oops/method.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -136,14 +136,14 @@ inline void Method::clear_number_of_breakpoints() { } #endif // INCLUDE_JVMTI -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 inline void Method::interpreter_throwout_increment(Thread* current) { MethodCounters* mcs = get_method_counters(current); if (mcs != nullptr) { mcs->interpreter_throwout_increment(); } } -#endif +#endif // COMPILER2 inline int Method::interpreter_throwout_count() const { MethodCounters* mcs = method_counters(); diff --git a/src/hotspot/share/oops/methodCounters.cpp b/src/hotspot/share/oops/methodCounters.cpp index 8f29f9b7bbd..8735758819f 100644 --- a/src/hotspot/share/oops/methodCounters.cpp +++ b/src/hotspot/share/oops/methodCounters.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,9 +110,9 @@ void MethodCounters::print_data_on(outputStream* st) const { st->print_cr(" - invoke_mask: %d", _invoke_mask); st->print_cr(" - backedge_mask: %d", _backedge_mask); st->print_cr(" - prev_event_count: %d", _prev_event_count); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 st->print_cr(" - interpreter_throwout_count: %u", _interpreter_throwout_count); -#endif +#endif // COMPILER2 #if INCLUDE_JVMTI st->print_cr(" - number_of_breakpoints: %u", _number_of_breakpoints); #endif diff --git a/src/hotspot/share/oops/methodCounters.hpp b/src/hotspot/share/oops/methodCounters.hpp index 5733e6e61f0..4e5ce51b7c1 100644 --- a/src/hotspot/share/oops/methodCounters.hpp +++ b/src/hotspot/share/oops/methodCounters.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ class MethodTrainingData; class MethodCounters : public Metadata { friend class VMStructs; - friend class JVMCIVMStructs; // Used by CDS. These classes need to access the private default constructor. template friend class CppVtableTesterA; @@ -54,9 +53,9 @@ class MethodCounters : public Metadata { int _invoke_mask; // per-method Tier0InvokeNotifyFreqLog int _backedge_mask; // per-method Tier0BackedgeNotifyFreqLog int _prev_event_count; // Total number of events saved at previous callback -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting -#endif +#endif // COMPILER2 #if INCLUDE_JVMTI u2 _number_of_breakpoints; // fullspeed debugging support #endif @@ -86,7 +85,7 @@ class MethodCounters : public Metadata { void clear_counters(); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 void interpreter_throwout_increment() { if (_interpreter_throwout_count < 65534) { _interpreter_throwout_count++; @@ -98,14 +97,14 @@ class MethodCounters : public Metadata { void set_interpreter_throwout_count(u2 count) { _interpreter_throwout_count = count; } -#else // COMPILER2_OR_JVMCI +#else // COMPILER2 u2 interpreter_throwout_count() const { return 0; } void set_interpreter_throwout_count(u2 count) { assert(count == 0, "count must be 0"); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 #if INCLUDE_JVMTI u2 number_of_breakpoints() const { return _number_of_breakpoints; } diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index dc0b8fa9f81..4e9836c2b32 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,14 +61,9 @@ bool DataLayout::needs_array_len(u1 tag) { // Perform generic initialization of the data. More specific // initialization occurs in overrides of ProfileData::post_initialize. void DataLayout::initialize(u1 tag, u2 bci, int cell_count) { - DataLayout temp; - temp._header._bits = (intptr_t)0; - temp._header._struct._tag = tag; - temp._header._struct._bci = bci; - // Write the header using a single intptr_t write. This ensures that if the layout is - // reinitialized readers will never see the transient state where the header is 0. - _header = temp._header; - + _header._bits = (intptr_t)0; + _header._struct._tag = tag; + _header._struct._bci = bci; for (int i = 0; i < cell_count; i++) { set_cell_at(i, (intptr_t)0); } @@ -858,117 +853,7 @@ bool MethodData::is_speculative_trap_bytecode(Bytecodes::Code code) { return false; } -#if INCLUDE_JVMCI - -void* FailedSpeculation::operator new(size_t size, size_t fs_size) throw() { - return CHeapObj::operator new(fs_size, std::nothrow); -} - -FailedSpeculation::FailedSpeculation(address speculation, int speculation_len) : _data_len(speculation_len), _next(nullptr) { - memcpy(data(), speculation, speculation_len); -} - -// A heuristic check to detect nmethods that outlive a failed speculations list. -static void guarantee_failed_speculations_alive(nmethod* nm, FailedSpeculation** failed_speculations_address) { - jlong head = (jlong)(address) *failed_speculations_address; - if ((head & 0x1) == 0x1) { - stringStream st; - if (nm != nullptr) { - st.print("%d", nm->compile_id()); - Method* method = nm->method(); - st.print_raw("{"); - if (method != nullptr) { - method->print_name(&st); - } else { - const char* jvmci_name = nm->jvmci_name(); - if (jvmci_name != nullptr) { - st.print_raw(jvmci_name); - } - } - st.print_raw("}"); - } else { - st.print(""); - } - fatal("Adding to failed speculations list that appears to have been freed. Source: %s", st.as_string()); - } -} - -bool FailedSpeculation::add_failed_speculation(nmethod* nm, FailedSpeculation** failed_speculations_address, address speculation, int speculation_len) { - assert(failed_speculations_address != nullptr, "must be"); - size_t fs_size = sizeof(FailedSpeculation) + speculation_len; - - guarantee_failed_speculations_alive(nm, failed_speculations_address); - - FailedSpeculation** cursor = failed_speculations_address; - FailedSpeculation* fs = nullptr; - do { - if (*cursor == nullptr) { - if (fs == nullptr) { - // lazily allocate FailedSpeculation - fs = new (fs_size) FailedSpeculation(speculation, speculation_len); - if (fs == nullptr) { - // no memory -> ignore failed speculation - return false; - } - guarantee(is_aligned(fs, sizeof(FailedSpeculation*)), "FailedSpeculation objects must be pointer aligned"); - } - FailedSpeculation* old_fs = AtomicAccess::cmpxchg(cursor, (FailedSpeculation*) nullptr, fs); - if (old_fs == nullptr) { - // Successfully appended fs to end of the list - return true; - } - } - guarantee(*cursor != nullptr, "cursor must point to non-null FailedSpeculation"); - // check if the current entry matches this thread's failed speculation - if ((*cursor)->data_len() == speculation_len && memcmp(speculation, (*cursor)->data(), speculation_len) == 0) { - if (fs != nullptr) { - delete fs; - } - return false; - } - cursor = (*cursor)->next_adr(); - } while (true); -} - -void FailedSpeculation::free_failed_speculations(FailedSpeculation** failed_speculations_address) { - assert(failed_speculations_address != nullptr, "must be"); - FailedSpeculation* fs = *failed_speculations_address; - while (fs != nullptr) { - FailedSpeculation* next = fs->next(); - delete fs; - fs = next; - } - - // Write an unaligned value to failed_speculations_address to denote - // that it is no longer a valid pointer. This is allows for the check - // in add_failed_speculation against adding to a freed failed - // speculations list. - long* head = (long*) failed_speculations_address; - (*head) = (*head) | 0x1; -} -#endif // INCLUDE_JVMCI - int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps) { -#if INCLUDE_JVMCI - if (ProfileTraps) { - // Assume that up to 30% of the possibly trapping BCIs with no MDP will need to allocate one. - int extra_data_count = MIN2(empty_bc_count, MAX2(4, (empty_bc_count * 30) / 100)); - - // Make sure we have a minimum number of extra data slots to - // allocate SpeculativeTrapData entries. We would want to have one - // entry per compilation that inlines this method and for which - // some type speculation assumption fails. So the room we need for - // the SpeculativeTrapData entries doesn't directly depend on the - // size of the method. Because it's hard to estimate, we reserve - // space for an arbitrary number of entries. - int spec_data_count = (needs_speculative_traps ? SpecTrapLimitExtraEntries : 0) * - (SpeculativeTrapData::static_cell_count() + DataLayout::header_size_in_cells()); - - return MAX2(extra_data_count, spec_data_count); - } else { - return 0; - } -#else // INCLUDE_JVMCI if (ProfileTraps) { // Assume that up to 3% of BCIs with no MDP will need to allocate one. int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1; @@ -994,7 +879,6 @@ int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool } else { return 0; } -#endif // INCLUDE_JVMCI } // Compute the size of the MethodData* necessary to store @@ -1008,7 +892,9 @@ int MethodData::compute_allocation_size_in_bytes(const methodHandle& method) { while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; - if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; + if (size_in_bytes == 0) { + empty_bc_count += 1; + } needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } int object_size = in_bytes(data_offset()) + data_size; @@ -1296,28 +1182,6 @@ MethodData::MethodData() { } #endif -// Reinitialize the storage of an existing MDO at a safepoint. Doing it this way will ensure it's -// not being accessed while the contents are being rewritten. -class VM_ReinitializeMDO: public VM_Operation { - private: - MethodData* _mdo; - public: - VM_ReinitializeMDO(MethodData* mdo): _mdo(mdo) {} - VMOp_Type type() const { return VMOp_ReinitializeMDO; } - void doit() { - // The extra data is being zero'd, we'd like to acquire the extra_data_lock but it can't be held - // over a safepoint. This means that we don't actually need to acquire the lock. - _mdo->initialize(); - } - bool allow_nested_vm_operations() const { return true; } -}; - -void MethodData::reinitialize() { - VM_ReinitializeMDO op(this); - VMThread::execute(&op); -} - - void MethodData::initialize() { Thread* thread = Thread::current(); NoSafepointVerifier no_safepoint; // init function atomic wrt GC @@ -1336,7 +1200,9 @@ void MethodData::initialize() { while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; - if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; + if (size_in_bytes == 0) { + empty_bc_count += 1; + } needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } _data_size = data_size; @@ -1421,11 +1287,6 @@ void MethodData::init() { _num_blocks = 0; _would_profile = unknown; -#if INCLUDE_JVMCI - _jvmci_ir_size = 0; - _failed_speculations = nullptr; -#endif - // Initialize escape flags. clear_escape_info(); } @@ -1986,18 +1847,9 @@ void MethodData::deallocate_contents(ClassLoaderData* loader_data) { release_C_heap_structures(); } -void MethodData::release_C_heap_structures() { -#if INCLUDE_JVMCI - FailedSpeculation::free_failed_speculations(get_failed_speculations_address()); -#endif -} - #if INCLUDE_CDS void MethodData::remove_unshareable_info() { _extra_data_lock = nullptr; -#if INCLUDE_JVMCI - _failed_speculations = nullptr; -#endif } void MethodData::restore_unshareable_info(TRAPS) { diff --git a/src/hotspot/share/oops/methodData.hpp b/src/hotspot/share/oops/methodData.hpp index 7e5466b91a3..28733432a9d 100644 --- a/src/hotspot/share/oops/methodData.hpp +++ b/src/hotspot/share/oops/methodData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,6 @@ class ProfileData; // Overlay for generic profiling data. class DataLayout { friend class VMStructs; - friend class JVMCIVMStructs; private: // Every data layout begins with a header. This header @@ -514,7 +513,6 @@ public: // A BitData holds a flag or two in its header. class BitData : public ProfileData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum : u1 { // null_seen: @@ -522,10 +520,6 @@ protected: null_seen_flag = DataLayout::first_flag + 0, exception_handler_entered_flag = null_seen_flag + 1, deprecated_method_callsite_flag = exception_handler_entered_flag + 1 -#if INCLUDE_JVMCI - // bytecode threw any exception - , exception_seen_flag = deprecated_method_callsite_flag + 1 -#endif }; enum { bit_cell_count = 0 }; // no additional data fields needed. public: @@ -552,12 +546,6 @@ public: bool set_deprecated_method_call_site() { return data()->set_flag_at(deprecated_method_callsite_flag); } bool clear_deprecated_method_call_site() { return data()->clear_flag_at(deprecated_method_callsite_flag); } -#if INCLUDE_JVMCI - // true if an exception was thrown at the specific BCI - bool exception_seen() { return flag_at(exception_seen_flag); } - void set_exception_seen() { set_flag_at(exception_seen_flag); } -#endif - // true if a ex handler block at this bci was entered bool exception_handler_entered() { return flag_at(exception_handler_entered_flag); } void set_exception_handler_entered() { set_flag_at(exception_handler_entered_flag); } @@ -579,7 +567,6 @@ public: // A CounterData corresponds to a simple counter. class CounterData : public BitData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum { count_off, @@ -632,7 +619,6 @@ public: // the corresponding target bci. class JumpData : public ProfileData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum { taken_off_set, @@ -1153,7 +1139,6 @@ public: // class ReceiverTypeData : public CounterData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum { receiver0_offset = counter_cell_count, @@ -1284,7 +1269,6 @@ public: return cell_offset(static_cell_count()); } - void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN; void print_data_on(outputStream* st, const char* extra = nullptr) const; }; @@ -1530,7 +1514,6 @@ public: // for the taken case. class BranchData : public JumpData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum { not_taken_off_set = jump_cell_count, @@ -1594,7 +1577,6 @@ public: // and an array start. class ArrayData : public ProfileData { friend class VMStructs; - friend class JVMCIVMStructs; protected: friend class DataLayout; @@ -1655,7 +1637,6 @@ public: // case was taken and specify the data displacement for each branch target. class MultiBranchData : public ArrayData { friend class VMStructs; - friend class JVMCIVMStructs; protected: enum { default_count_off_set, @@ -1952,52 +1933,13 @@ public: virtual bool is_live(Method* m) = 0; }; - -#if INCLUDE_JVMCI -// Encapsulates an encoded speculation reason. These are linked together in -// a list that is atomically appended to during deoptimization. Entries are -// never removed from the list. -// @see jdk.vm.ci.hotspot.HotSpotSpeculationLog.HotSpotSpeculationEncoding -class FailedSpeculation: public CHeapObj { - private: - // The length of HotSpotSpeculationEncoding.toByteArray(). The data itself - // is an array embedded at the end of this object. - int _data_len; - - // Next entry in a linked list. - FailedSpeculation* _next; - - FailedSpeculation(address data, int data_len); - - FailedSpeculation** next_adr() { return &_next; } - - // Placement new operator for inlining the speculation data into - // the FailedSpeculation object. - void* operator new(size_t size, size_t fs_size) throw(); - - public: - char* data() { return (char*)(((address) this) + sizeof(FailedSpeculation)); } - int data_len() const { return _data_len; } - FailedSpeculation* next() const { return _next; } - - // Atomically appends a speculation from nm to the list whose head is at (*failed_speculations_address). - // Returns false if the FailedSpeculation object could not be allocated. - static bool add_failed_speculation(nmethod* nm, FailedSpeculation** failed_speculations_address, address speculation, int speculation_len); - - // Frees all entries in the linked list whose head is at (*failed_speculations_address). - static void free_failed_speculations(FailedSpeculation** failed_speculations_address); -}; -#endif - class ciMethodData; class MethodData : public Metadata { friend class VMStructs; - friend class JVMCIVMStructs; friend class ProfileData; friend class TypeEntriesAtCall; friend class ciMethodData; - friend class VM_ReinitializeMDO; // If you add a new field that points to any metaspace object, you // must add this field to MethodData::metaspace_pointers_do(). @@ -2014,20 +1956,13 @@ class MethodData : public Metadata { Mutex* volatile _extra_data_lock; MethodData(const methodHandle& method); - - void initialize(); - public: MethodData(); static MethodData* allocate(ClassLoaderData* loader_data, const methodHandle& method, TRAPS); virtual bool is_methodData() const { return true; } - - // Safely reinitialize the data in the MDO. This is intended as a testing facility as the - // reinitialization is performed at a safepoint so it's isn't cheap and it doesn't ensure that all - // readers will see consistent profile data. - void reinitialize(); + void initialize(); // Whole-method sticky bits and flags enum { @@ -2039,15 +1974,13 @@ public: // Compiler-related counters. class CompilerCounters { friend class VMStructs; - friend class JVMCIVMStructs; uint _nof_decompiles; // count of all nmethod removals uint _nof_overflow_recompiles; // recompile count, excluding recomp. bits uint _nof_overflow_traps; // trap count, excluding _trap_hist union { intptr_t _align; - // JVMCI separates trap history for OSR compilations from normal compilations - u1 _array[JVMCI_ONLY(2 *) MethodData::_trap_hist_limit]; + u1 _array[MethodData::_trap_hist_limit]; } _trap_hist; public: @@ -2133,12 +2066,6 @@ private: enum WouldProfile {unknown, no_profile, profile}; WouldProfile _would_profile; -#if INCLUDE_JVMCI - // Support for HotSpotMethodData.setCompiledIRSize(int) - FailedSpeculation* _failed_speculations; - int _jvmci_ir_size; -#endif - // Size of _data array in bytes. (Excludes header and extra_data fields.) int _data_size; @@ -2311,12 +2238,6 @@ public: InvocationCounter* invocation_counter() { return &_invocation_counter; } InvocationCounter* backedge_counter() { return &_backedge_counter; } -#if INCLUDE_JVMCI - FailedSpeculation** get_failed_speculations_address() { - return &_failed_speculations; - } -#endif - #if INCLUDE_CDS void remove_unshareable_info(); void restore_unshareable_info(TRAPS); @@ -2533,7 +2454,7 @@ public: // Deallocation support void deallocate_contents(ClassLoaderData* loader_data); - void release_C_heap_structures(); + void release_C_heap_structures() {} // GC support void set_size(int object_size_in_bytes) { _size = object_size_in_bytes; } diff --git a/src/hotspot/share/oops/methodFlags.hpp b/src/hotspot/share/oops/methodFlags.hpp index 8f291f3501e..cb424b3f796 100644 --- a/src/hotspot/share/oops/methodFlags.hpp +++ b/src/hotspot/share/oops/methodFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,6 @@ class outputStream; class MethodFlags { friend class VMStructs; - friend class JVMCIVMStructs; /* end of list */ #define M_STATUS_DO(status) \ diff --git a/src/hotspot/share/oops/objArrayKlass.hpp b/src/hotspot/share/oops/objArrayKlass.hpp index cdf28b883e6..2197333f40d 100644 --- a/src/hotspot/share/oops/objArrayKlass.hpp +++ b/src/hotspot/share/oops/objArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ class ClassLoaderData; class ObjArrayKlass : public ArrayKlass { friend class Deoptimization; - friend class JVMCIVMStructs; friend class oopFactory; friend class VMStructs; diff --git a/src/hotspot/share/oops/oop.hpp b/src/hotspot/share/oops/oop.hpp index daa192d5124..f89c4403410 100644 --- a/src/hotspot/share/oops/oop.hpp +++ b/src/hotspot/share/oops/oop.hpp @@ -46,7 +46,6 @@ class oopDesc { friend class VMStructs; - friend class JVMCIVMStructs; private: volatile markWord _mark; narrowKlass _compressed_klass; @@ -330,8 +329,7 @@ class oopDesc { static int klass_offset_in_bytes() { #ifdef _LP64 if (UseCompactObjectHeaders) { - // NOTE: The only places where this is used with compact headers are the C2 - // compiler and JVMCI. + // NOTE: The only place where this is used with compact headers is C2. return mark_offset_in_bytes() + markWord::klass_offset_in_bytes; } else #endif diff --git a/src/hotspot/share/oops/symbol.hpp b/src/hotspot/share/oops/symbol.hpp index 045332c7a84..c030f406b6f 100644 --- a/src/hotspot/share/oops/symbol.hpp +++ b/src/hotspot/share/oops/symbol.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -105,7 +105,6 @@ class Symbol : public MetaspaceObj { friend class VMStructs; friend class SymbolTable; friend class vmSymbols; - friend class JVMCIVMStructs; private: diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp index 5d170f919c8..4457c845e88 100644 --- a/src/hotspot/share/opto/c2compiler.cpp +++ b/src/hotspot/share/opto/c2compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -105,7 +105,7 @@ bool C2Compiler::init_c2_runtime() { } void C2Compiler::initialize() { - assert(!CompilerConfig::is_c1_or_interpreter_only_no_jvmci(), "C2 compiler is launched, it's not c1/interpreter only mode"); + assert(!CompilerConfig::is_c1_or_interpreter_only(), "C2 compiler is launched, it's not c1/interpreter only mode"); // The first compiler thread that gets here will initialize the // small amount of global state (and runtime stubs) that C2 needs. diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index 318f40374a6..483b1e4e570 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -91,9 +91,6 @@ #include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciCompiler.hpp" -#endif #if INCLUDE_JFR #include "jfr/jfr.hpp" #endif @@ -3649,23 +3646,6 @@ static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) { // mark creation complete for other JNI ops AtomicAccess::release_store(&vm_created, COMPLETE); -#if INCLUDE_JVMCI - if (EnableJVMCI) { - if (UseJVMCICompiler) { - // JVMCI is initialized on a CompilerThread - if (BootstrapJVMCI) { - JavaThread* THREAD = thread; // For exception macros. - JVMCICompiler* compiler = JVMCICompiler::instance(true, CATCH); - compiler->bootstrap(THREAD); - if (HAS_PENDING_EXCEPTION) { - HandleMark hm(THREAD); - vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); - } - } - } - } -#endif - // Notify JVMTI if (JvmtiExport::should_post_thread_life()) { JvmtiExport::post_thread_start(thread); diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 423e1a5a1f4..cc6e04a9ef0 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -388,8 +388,6 @@ JVM_ENTRY(jobjectArray, JVM_GetProperties(JNIEnv *env)) const char* compiler_name = "HotSpot " CSIZE "Client Compiler"; #elif defined(COMPILER2) const char* compiler_name = "HotSpot " CSIZE "Server Compiler"; -#elif INCLUDE_JVMCI - #error "INCLUDE_JVMCI should imply COMPILER1_OR_COMPILER2" #else const char* compiler_name = ""; #endif // compilers diff --git a/src/hotspot/share/prims/nativeLookup.cpp b/src/hotspot/share/prims/nativeLookup.cpp index 1d2c78ab3cc..2780581629a 100644 --- a/src/hotspot/share/prims/nativeLookup.cpp +++ b/src/hotspot/share/prims/nativeLookup.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,11 +207,6 @@ extern "C" { void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass); void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass); void JNICALL JVM_RegisterVectorSupportMethods(JNIEnv *env, jclass vsclass); -#if INCLUDE_JVMCI - jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); - jlong JNICALL JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets); - void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass); -#endif } #define CC (char*) /* cast a literal from (const char*) */ @@ -227,11 +222,6 @@ static JNINativeMethod lookup_special_native_methods[] = { { CC"Java_sun_hotspot_WhiteBox_registerNatives", nullptr, FN_PTR(JVM_RegisterWhiteBoxMethods) }, { CC"Java_jdk_test_whitebox_WhiteBox_registerNatives", nullptr, FN_PTR(JVM_RegisterWhiteBoxMethods) }, { CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", nullptr, FN_PTR(JVM_RegisterVectorSupportMethods)}, -#if INCLUDE_JVMCI - { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", nullptr, FN_PTR(JVM_GetJVMCIRuntime) }, - { CC"Java_jdk_vm_ci_services_Services_readSystemPropertiesInfo", nullptr, FN_PTR(JVM_ReadSystemPropertiesInfo) }, - { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives", nullptr, FN_PTR(JVM_RegisterJVMCINatives) }, -#endif #if INCLUDE_JFR { CC"Java_jdk_jfr_internal_JVM_registerNatives", nullptr, FN_PTR(jfr_register_natives) }, #endif diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 4bbaa9eda3c..b7e12fc1c92 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -123,10 +123,6 @@ #include "gc/z/zAddress.inline.hpp" #include "gc/z/zHeap.inline.hpp" #endif // INCLUDE_ZGC -#if INCLUDE_JVMCI -#include "jvmci/jvmciEnv.hpp" -#include "jvmci/jvmciRuntime.hpp" -#endif #ifdef LINUX #include "cgroupSubsystem_linux.hpp" #include "os_linux.hpp" @@ -414,24 +410,6 @@ WB_ENTRY(jboolean, WB_IsGCSupported(JNIEnv* env, jobject o, jint name)) return GCConfig::is_gc_supported((CollectedHeap::Name)name); WB_END -WB_ENTRY(jboolean, WB_HasLibgraal(JNIEnv* env, jobject o)) -#if INCLUDE_JVMCI - return JVMCI::shared_library_exists(); -#endif - return false; -WB_END - -WB_ENTRY(jboolean, WB_IsGCSupportedByJVMCICompiler(JNIEnv* env, jobject o, jint name)) -#if INCLUDE_JVMCI - if (EnableJVMCI) { - // Enter the JVMCI env that will be used by the CompileBroker. - JVMCIEnv jvmciEnv(thread, __FILE__, __LINE__); - return jvmciEnv.init_error() == JNI_OK && jvmciEnv.runtime()->is_gc_supported(&jvmciEnv, (CollectedHeap::Name)name); - } -#endif - return false; -WB_END - WB_ENTRY(jboolean, WB_IsGCSelected(JNIEnv* env, jobject o, jint name)) return GCConfig::is_gc_selected((CollectedHeap::Name)name); WB_END @@ -2239,22 +2217,6 @@ WB_ENTRY(jboolean, WB_IsCDSIncluded(JNIEnv* env)) #endif // INCLUDE_CDS WB_END -WB_ENTRY(jboolean, WB_isC2OrJVMCIIncluded(JNIEnv* env)) -#if COMPILER2_OR_JVMCI - return true; -#else - return false; -#endif -WB_END - -WB_ENTRY(jboolean, WB_IsJVMCISupportedByGC(JNIEnv* env)) -#if INCLUDE_JVMCI - return JVMCIGlobals::gc_supports_jvmci(); -#else - return false; -#endif -WB_END - static bool canWriteJavaHeapArchive() { return !CDSConfig::are_vm_options_incompatible_with_dumping_heap(); } @@ -3045,9 +3007,6 @@ static JNINativeMethod methods[] = { {CC"isCDSIncluded", CC"()Z", (void*)&WB_IsCDSIncluded }, {CC"isJFRIncluded", CC"()Z", (void*)&WB_IsJFRIncluded }, {CC"isDTraceIncluded", CC"()Z", (void*)&WB_IsDTraceIncluded }, - {CC"hasLibgraal", CC"()Z", (void*)&WB_HasLibgraal }, - {CC"isC2OrJVMCIIncluded", CC"()Z", (void*)&WB_isC2OrJVMCIIncluded }, - {CC"isJVMCISupportedByGC", CC"()Z", (void*)&WB_IsJVMCISupportedByGC}, {CC"canWriteJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteJavaHeapArchive }, {CC"canWriteMappedJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteMappedJavaHeapArchive }, {CC"canWriteStreamedJavaHeapArchive", CC"()Z", (void*)&WB_CanWriteStreamedJavaHeapArchive }, @@ -3064,7 +3023,6 @@ static JNINativeMethod methods[] = { (void*)&WB_AddCompilerDirective }, {CC"removeCompilerDirective", CC"(I)V", (void*)&WB_RemoveCompilerDirective }, {CC"isGCSupported", CC"(I)Z", (void*)&WB_IsGCSupported}, - {CC"isGCSupportedByJVMCICompiler", CC"(I)Z", (void*)&WB_IsGCSupportedByJVMCICompiler}, {CC"isGCSelected", CC"(I)Z", (void*)&WB_IsGCSelected}, {CC"isGCSelectedErgonomically", CC"()Z", (void*)&WB_IsGCSelectedErgonomically}, {CC"supportsConcurrentGCBreakpoints", CC"()Z", (void*)&WB_SupportsConcurrentGCBreakpoints}, diff --git a/src/hotspot/share/runtime/abstract_vm_version.hpp b/src/hotspot/share/runtime/abstract_vm_version.hpp index 9ad79b91871..60f36a97e24 100644 --- a/src/hotspot/share/runtime/abstract_vm_version.hpp +++ b/src/hotspot/share/runtime/abstract_vm_version.hpp @@ -67,7 +67,6 @@ enum class vmIntrinsicID; class Abstract_VM_Version: AllStatic { friend class VMStructs; - friend class JVMCIVMStructs; protected: static const char* _s_vm_release; diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index b3397067baa..a607484d02a 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -84,9 +84,6 @@ int Arguments::_num_jvm_flags = 0; char** Arguments::_jvm_args_array = nullptr; int Arguments::_num_jvm_args = 0; unsigned int Arguments::_addmods_count = 0; -#if INCLUDE_JVMCI -bool Arguments::_jvmci_module_added = false; -#endif char* Arguments::_java_command = nullptr; SystemProperty* Arguments::_system_properties = nullptr; size_t Arguments::_conservative_max_heap_alignment = 0; @@ -1582,18 +1579,6 @@ bool Arguments::check_vm_args_consistency() { bool status = true; status = CompilerConfig::check_args_consistency(status); -#if INCLUDE_JVMCI - if (status && EnableJVMCI) { - // Add the JVMCI module if not using libjvmci or EnableJVMCI - // was explicitly set on the command line or in the jimage. - if ((!UseJVMCINativeLibrary || FLAG_IS_CMDLINE(EnableJVMCI) || FLAG_IS_JIMAGE_RESOURCE(EnableJVMCI)) && ClassLoader::is_module_observable("jdk.internal.vm.ci") && !_jvmci_module_added) { - if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { - return false; - } - } - } -#endif - #if INCLUDE_JFR if (status && (FlightRecorderOptions || StartFlightRecording)) { if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", _addmods_count++)) { @@ -1983,19 +1968,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) { return JNI_ENOMEM; } -#if INCLUDE_JVMCI - if (!_jvmci_module_added) { - const char *jvmci_module = strstr(tail, "jdk.internal.vm.ci"); - if (jvmci_module != nullptr) { - char before = *(jvmci_module - 1); - char after = *(jvmci_module + strlen("jdk.internal.vm.ci")); - if ((before == '=' || before == ',') && (after == '\0' || after == ',')) { - FLAG_SET_DEFAULT(EnableJVMCI, true); - _jvmci_module_added = true; - } - } - } -#endif } else if (match_option(option, "--enable-native-access=", &tail)) { if (!create_numbered_module_property("jdk.module.enable.native.access", tail, enable_native_access_count++)) { return JNI_ENOMEM; @@ -2530,46 +2502,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin "ManagementServer is not supported in this VM.\n"); return JNI_ERR; #endif // INCLUDE_MANAGEMENT -#if INCLUDE_JVMCI - } else if (match_option(option, "-XX:-EnableJVMCIProduct") || match_option(option, "-XX:-UseGraalJIT")) { - if (EnableJVMCIProduct) { - jio_fprintf(defaultStream::error_stream(), - "-XX:-EnableJVMCIProduct or -XX:-UseGraalJIT cannot come after -XX:+EnableJVMCIProduct or -XX:+UseGraalJIT\n"); - return JNI_EINVAL; - } - } else if (match_option(option, "-XX:+EnableJVMCIProduct") || match_option(option, "-XX:+UseGraalJIT")) { - bool use_graal_jit = match_option(option, "-XX:+UseGraalJIT"); - if (use_graal_jit) { - const char* jvmci_compiler = get_property("jvmci.Compiler"); - if (jvmci_compiler != nullptr) { - if (strncmp(jvmci_compiler, "graal", strlen("graal")) != 0) { - jio_fprintf(defaultStream::error_stream(), - "Value of jvmci.Compiler incompatible with +UseGraalJIT: %s\n", jvmci_compiler); - return JNI_ERR; - } - } else if (!add_property("jvmci.Compiler=graal")) { - return JNI_ENOMEM; - } - } - - // Just continue, since "-XX:+EnableJVMCIProduct" or "-XX:+UseGraalJIT" has been specified before - if (EnableJVMCIProduct) { - continue; - } - JVMFlag *jvmciFlag = JVMFlag::find_flag("EnableJVMCIProduct"); - // Allow this flag if it has been unlocked. - if (jvmciFlag != nullptr && jvmciFlag->is_unlocked()) { - if (!JVMCIGlobals::enable_jvmci_product_mode(origin, use_graal_jit)) { - jio_fprintf(defaultStream::error_stream(), - "Unable to enable JVMCI in product mode\n"); - return JNI_ERR; - } - } - // The flag was locked so process normally to report that error - else if (!process_argument(use_graal_jit ? "UseGraalJIT" : "EnableJVMCIProduct", args->ignoreUnrecognized, origin)) { - return JNI_EINVAL; - } -#endif // INCLUDE_JVMCI #if INCLUDE_JFR } else if (match_jfr_option(&option)) { return JNI_EINVAL; @@ -2710,7 +2642,7 @@ jint Arguments::finalize_vm_init_args() { FLAG_SET_ERGO(InitialTenuringThreshold, MaxTenuringThreshold); } -#if !COMPILER2_OR_JVMCI +#ifndef COMPILER2 // Don't degrade server performance for footprint if (FLAG_IS_DEFAULT(UseLargePages) && MaxHeapSize < LargePageHeapSizeThreshold) { @@ -2721,7 +2653,7 @@ jint Arguments::finalize_vm_init_args() { } UNSUPPORTED_OPTION(ProfileInterpreter); -#endif +#endif // !COMPILER2 // Parse the CompilationMode flag if (!CompilationModeFlag::initialize()) { @@ -3614,7 +3546,7 @@ jint Arguments::apply_ergo() { JVMFlag::printSetFlags(tty); } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) { if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) { warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off."); @@ -3630,9 +3562,7 @@ jint Arguments::apply_ergo() { } FLAG_SET_DEFAULT(EnableVectorAggressiveReboxing, false); } -#endif // COMPILER2_OR_JVMCI -#ifdef COMPILER2 if (!FLAG_IS_DEFAULT(UseLoopPredicate) && !UseLoopPredicate && UseProfiledLoopPredicate) { warning("Disabling UseProfiledLoopPredicate since UseLoopPredicate is turned off."); FLAG_SET_ERGO(UseProfiledLoopPredicate, false); diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index 0c5e3b6c441..4367806a7a2 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,9 +74,6 @@ class PathString : public CHeapObj { PathString(const char* value); ~PathString(); - - // for JVM_ReadSystemPropertiesInfo - static int value_offset_in_bytes() { return (int)offset_of(PathString, _value); } }; // ModulePatchPath records the module/path pair as specified to --patch-module. @@ -138,10 +135,6 @@ class SystemProperty : public PathString { // Constructor SystemProperty(const char* key, const char* value, bool writeable, bool internal = false); - - // for JVM_ReadSystemPropertiesInfo - static int key_offset_in_bytes() { return (int)offset_of(SystemProperty, _key); } - static int next_offset_in_bytes() { return (int)offset_of(SystemProperty, _next); } }; // Helper class for controlling the lifetime of JavaVMInitArgs objects. @@ -199,10 +192,6 @@ class Arguments : AllStatic { static char* _java_command; // number of unique modules specified in the --add-modules option static unsigned int _addmods_count; -#if INCLUDE_JVMCI - // was jdk.internal.vm.ci module specified in the --add-modules option? - static bool _jvmci_module_added; -#endif // Property list static SystemProperty* _system_properties; diff --git a/src/hotspot/share/runtime/basicLock.hpp b/src/hotspot/share/runtime/basicLock.hpp index 479748f51a4..26d1c2e762a 100644 --- a/src/hotspot/share/runtime/basicLock.hpp +++ b/src/hotspot/share/runtime/basicLock.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,6 @@ class BasicLock { friend class VMStructs; - friend class JVMCIVMStructs; private: // Used as a cache of the ObjectMonitor* used when locking. Must either // be nullptr or the ObjectMonitor* used when locking. diff --git a/src/hotspot/share/runtime/continuationEntry.hpp b/src/hotspot/share/runtime/continuationEntry.hpp index 490293f5b11..de44ca54b44 100644 --- a/src/hotspot/share/runtime/continuationEntry.hpp +++ b/src/hotspot/share/runtime/continuationEntry.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ class RegisterMap; // Metadata stored in the continuation entry frame class ContinuationEntry { friend class VMStructs; - friend class JVMCIVMStructs; ContinuationEntryPD _pd; #ifdef ASSERT private: diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 9db9c676268..d5dccc820f3 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -297,7 +297,7 @@ JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info( return fetch_unroll_info_helper(current, exec_mode); JRT_END -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // print information about reallocated objects static void print_objects(JavaThread* deoptee_thread, GrowableArray* objects, bool realloc_failures) { @@ -377,8 +377,7 @@ static bool rematerialize_objects(JavaThread* thread, int exec_mode, nmethod* co JRT_END } guarantee(compiled_method != nullptr, "deopt must be associated with an nmethod"); - bool is_jvmci = compiled_method->is_compiled_by_jvmci(); - Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures, is_jvmci); + Deoptimization::reassign_fields(&deoptee, &map, objects, realloc_failures); if (TraceDeoptimization) { print_objects(deoptee_thread, objects, realloc_failures); } @@ -451,11 +450,8 @@ bool Deoptimization::deoptimize_objects_internal(JavaThread* thread, GrowableArr RegisterMap map(chunk->at(0)->register_map()); bool deoptimized_objects = false; - bool const jvmci_enabled = JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false); - // Reallocate the non-escaping objects and restore their fields. - if (jvmci_enabled COMPILER2_PRESENT(|| (DoEscapeAnalysis && EliminateAllocations) - || EliminateAutoBox || EnableVectorAggressiveReboxing)) { + if ((DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox || EnableVectorAggressiveReboxing) { realloc_failures = rematerialize_objects(thread, Unpack_none, nm, deoptee, map, chunk, deoptimized_objects); } @@ -463,12 +459,12 @@ bool Deoptimization::deoptimize_objects_internal(JavaThread* thread, GrowableArr NoSafepointVerifier no_safepoint; // Now relock objects if synchronization on them was eliminated. - if (jvmci_enabled COMPILER2_PRESENT(|| ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks))) { + if ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks) { restore_eliminated_locks(thread, chunk, realloc_failures, deoptee, Unpack_none, deoptimized_objects); } return deoptimized_objects; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // This is factored, since it is both called from a JRT_LEAF (deoptimization) and a JRT_ENTRY (uncommon_trap) Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread* current, int exec_mode) { @@ -526,17 +522,14 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread bool realloc_failures = false; -#if COMPILER2_OR_JVMCI - bool const jvmci_enabled = JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false); - +#ifdef COMPILER2 // Reallocate the non-escaping objects and restore their fields. Then // relock objects if synchronization on them was eliminated. - if (jvmci_enabled COMPILER2_PRESENT( || (DoEscapeAnalysis && EliminateAllocations) - || EliminateAutoBox || EnableVectorAggressiveReboxing )) { + if ((DoEscapeAnalysis && EliminateAllocations) || EliminateAutoBox || EnableVectorAggressiveReboxing) { bool unused; realloc_failures = rematerialize_objects(current, exec_mode, nm, deoptee, map, chunk, unused); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // Ensure that no safepoint is taken after pointers have been stored // in fields of rematerialized objects. If a safepoint occurs from here on @@ -544,13 +537,13 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread // Locks may be rebaised in a safepoint. NoSafepointVerifier no_safepoint; -#if COMPILER2_OR_JVMCI - if ((jvmci_enabled COMPILER2_PRESENT( || ((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks) )) - && !EscapeBarrier::objs_are_deoptimized(current, deoptee.id())) { +#ifdef COMPILER2 + if (((DoEscapeAnalysis || EliminateNestedLocks) && EliminateLocks) && + !EscapeBarrier::objs_are_deoptimized(current, deoptee.id())) { bool unused = false; restore_eliminated_locks(current, chunk, realloc_failures, deoptee, exec_mode, unused); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 ScopeDesc* trap_scope = chunk->at(0)->scope(); Handle exceptionObject; @@ -570,13 +563,13 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread } vframeArray* array = create_vframeArray(current, deoptee, &map, chunk, realloc_failures); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 if (realloc_failures) { // This destroys all ScopedValue bindings. current->clear_scopedValueBindings(); pop_frames_failed_reallocs(current, array); } -#endif +#endif // COMPILER2 assert(current->vframe_array_head() == nullptr, "Pending deopt!"); current->set_vframe_array_head(array); @@ -730,14 +723,6 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread assert(CodeCache::find_blob(frame_pcs[0]) != nullptr, "bad pc"); -#if INCLUDE_JVMCI - if (exceptionObject() != nullptr) { - current->set_exception_oop(exceptionObject()); - exec_mode = Unpack_exception; - assert(array->element(0)->rethrow_exception(), "must be"); - } -#endif - if (current->frames_to_pop_failed_realloc() > 0 && exec_mode != Unpack_uncommon_trap) { assert(current->has_pending_exception(), "should have thrown OOME"); current->set_exception_oop(current->pending_exception()); @@ -745,12 +730,6 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread exec_mode = Unpack_exception; } -#if INCLUDE_JVMCI - if (current->frames_to_pop_failed_realloc() > 0) { - current->set_pending_monitorenter(false); - } -#endif - int caller_actual_parameters = -1; // value not used except for interpreted frames, see below if (deopt_sender.is_interpreted_frame()) { caller_actual_parameters = callee_parameters + (caller_was_method_handle ? 1 : 0); @@ -992,11 +971,6 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m // Verify stack depth and oops in frame auto match = [&]() { int iframe_expr_ssize = iframe->interpreter_frame_expression_stack_size(); -#if INCLUDE_JVMCI - if (is_top_frame && el->rethrow_exception()) { - return iframe_expr_ssize == 1; - } -#endif // This should only be needed for C1 if (is_top_frame && exec_mode == Unpack_exception && iframe_expr_ssize == 0) { return true; @@ -1024,9 +998,6 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m tty->print_cr(" original should_reexecute = %s", el->should_reexecute() ? "true" : "false"); tty->print_cr(" reexecute = %s%s", reexecute ? "true" : "false", (reexecute != el->should_reexecute()) ? " (changed)" : ""); -#if INCLUDE_JVMCI - tty->print_cr(" rethrow_exception = %s", el->rethrow_exception() ? "true" : "false"); -#endif tty->print_cr(" cur_invoke_parameter_size = %d", cur_invoke_parameter_size); tty->print_cr(" Thread = " INTPTR_FORMAT ", thread ID = %d", p2i(thread), thread->osthread()->thread_id()); tty->print_cr(" Interpreted frames:"); @@ -1073,158 +1044,7 @@ void Deoptimization::deoptimize_all_marked() { Deoptimization::DeoptAction Deoptimization::_unloaded_action = Deoptimization::Action_reinterpret; -#if INCLUDE_JVMCI -template -class BoxCacheBase : public CHeapObj { -protected: - static InstanceKlass* find_cache_klass(Thread* thread, Symbol* klass_name) { - ResourceMark rm(thread); - char* klass_name_str = klass_name->as_C_string(); - InstanceKlass* ik = SystemDictionary::find_instance_klass(thread, klass_name, Handle()); - guarantee(ik != nullptr, "%s must be loaded", klass_name_str); - if (!ik->is_in_error_state()) { - guarantee(ik->is_initialized(), "%s must be initialized", klass_name_str); - CacheType::compute_offsets(ik); - } - return ik; - } -}; - -template class BoxCache : public BoxCacheBase { - PrimitiveType _low; - PrimitiveType _high; - jobject _cache; -protected: - static BoxCache *_singleton; - BoxCache(Thread* thread) { - InstanceKlass* ik = BoxCacheBase::find_cache_klass(thread, CacheType::symbol()); - if (ik->is_in_error_state()) { - _low = 1; - _high = 0; - _cache = nullptr; - } else { - objArrayOop cache = CacheType::cache(ik); - assert(cache->length() > 0, "Empty cache"); - _low = BoxType::value(cache->obj_at(0)); - _high = checked_cast(_low + cache->length() - 1); - _cache = JNIHandles::make_global(Handle(thread, cache)); - } - } - ~BoxCache() { - JNIHandles::destroy_global(_cache); - } -public: - static BoxCache* singleton(Thread* thread) { - if (_singleton == nullptr) { - BoxCache* s = new BoxCache(thread); - if (!AtomicAccess::replace_if_null(&_singleton, s)) { - delete s; - } - } - return _singleton; - } - oop lookup(PrimitiveType value) { - if (_low <= value && value <= _high) { - int offset = checked_cast(value - _low); - return objArrayOop(JNIHandles::resolve_non_null(_cache))->obj_at(offset); - } - return nullptr; - } - oop lookup_raw(intptr_t raw_value, bool& cache_init_error) { - if (_cache == nullptr) { - cache_init_error = true; - return nullptr; - } - // Have to cast to avoid little/big-endian problems. - if (sizeof(PrimitiveType) > sizeof(jint)) { - jlong value = (jlong)raw_value; - return lookup(value); - } - PrimitiveType value = (PrimitiveType)*((jint*)&raw_value); - return lookup(value); - } -}; - -typedef BoxCache IntegerBoxCache; -typedef BoxCache LongBoxCache; -typedef BoxCache CharacterBoxCache; -typedef BoxCache ShortBoxCache; -typedef BoxCache ByteBoxCache; - -template<> BoxCache* BoxCache::_singleton = nullptr; -template<> BoxCache* BoxCache::_singleton = nullptr; -template<> BoxCache* BoxCache::_singleton = nullptr; -template<> BoxCache* BoxCache::_singleton = nullptr; -template<> BoxCache* BoxCache::_singleton = nullptr; - -class BooleanBoxCache : public BoxCacheBase { - jobject _true_cache; - jobject _false_cache; -protected: - static BooleanBoxCache *_singleton; - BooleanBoxCache(Thread *thread) { - InstanceKlass* ik = find_cache_klass(thread, java_lang_Boolean::symbol()); - if (ik->is_in_error_state()) { - _true_cache = nullptr; - _false_cache = nullptr; - } else { - _true_cache = JNIHandles::make_global(Handle(thread, java_lang_Boolean::get_TRUE(ik))); - _false_cache = JNIHandles::make_global(Handle(thread, java_lang_Boolean::get_FALSE(ik))); - } - } - ~BooleanBoxCache() { - JNIHandles::destroy_global(_true_cache); - JNIHandles::destroy_global(_false_cache); - } -public: - static BooleanBoxCache* singleton(Thread* thread) { - if (_singleton == nullptr) { - BooleanBoxCache* s = new BooleanBoxCache(thread); - if (!AtomicAccess::replace_if_null(&_singleton, s)) { - delete s; - } - } - return _singleton; - } - oop lookup_raw(intptr_t raw_value, bool& cache_in_error) { - if (_true_cache == nullptr) { - cache_in_error = true; - return nullptr; - } - // Have to cast to avoid little/big-endian problems. - jboolean value = (jboolean)*((jint*)&raw_value); - return lookup(value); - } - oop lookup(jboolean value) { - if (value != 0) { - return JNIHandles::resolve_non_null(_true_cache); - } - return JNIHandles::resolve_non_null(_false_cache); - } -}; - -BooleanBoxCache* BooleanBoxCache::_singleton = nullptr; - -oop Deoptimization::get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, bool& cache_init_error, TRAPS) { - Klass* k = java_lang_Class::as_Klass(bv->klass()->as_ConstantOopReadValue()->value()()); - BasicType box_type = vmClasses::box_klass_type(k); - if (box_type != T_OBJECT) { - StackValue* value = StackValue::create_stack_value(fr, reg_map, bv->field_at(box_type == T_LONG ? 1 : 0)); - switch(box_type) { - case T_INT: return IntegerBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - case T_CHAR: return CharacterBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - case T_SHORT: return ShortBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - case T_BYTE: return ByteBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - case T_BOOLEAN: return BooleanBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - case T_LONG: return LongBoxCache::singleton(THREAD)->lookup_raw(value->get_intptr(), cache_init_error); - default:; - } - } - return nullptr; -} -#endif // INCLUDE_JVMCI - -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* reg_map, GrowableArray* objects, TRAPS) { Handle pending_exception(THREAD, thread->pending_exception()); const char* exception_file = thread->exception_file(); @@ -1242,22 +1062,6 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* bool cache_init_error = false; if (k->is_instance_klass()) { -#if INCLUDE_JVMCI - nmethod* nm = fr->cb()->as_nmethod_or_null(); - if (nm->is_compiled_by_jvmci() && sv->is_auto_box()) { - AutoBoxObjectValue* abv = (AutoBoxObjectValue*) sv; - obj = get_cached_box(abv, fr, reg_map, cache_init_error, THREAD); - if (obj != nullptr) { - // Set the flag to indicate the box came from a cache, so that we can skip the field reassignment for it. - abv->set_cached(true); - } else if (cache_init_error) { - // Results in an OOME which is valid (as opposed to a class initialization error) - // and is fine for the rare case a cache initialization failing. - failures = true; - } - } -#endif // INCLUDE_JVMCI - InstanceKlass* ik = InstanceKlass::cast(k); if (obj == nullptr && !cache_init_error) { InternalOOMEMark iom(THREAD); @@ -1298,66 +1102,6 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* return failures; } -#if INCLUDE_JVMCI -/** - * For primitive types whose kind gets "erased" at runtime (shorts become stack ints), - * we need to somehow be able to recover the actual kind to be able to write the correct - * amount of bytes. - * For that purpose, this method assumes that, for an entry spanning n bytes at index i, - * the entries at index n + 1 to n + i are 'markers'. - * For example, if we were writing a short at index 4 of a byte array of size 8, the - * expected form of the array would be: - * - * {b0, b1, b2, b3, INT, marker, b6, b7} - * - * Thus, in order to get back the size of the entry, we simply need to count the number - * of marked entries - * - * @param virtualArray the virtualized byte array - * @param i index of the virtual entry we are recovering - * @return The number of bytes the entry spans - */ -static int count_number_of_bytes_for_entry(ObjectValue *virtualArray, int i) { - int index = i; - while (++index < virtualArray->field_size() && - virtualArray->field_at(index)->is_marker()) {} - return index - i; -} - -/** - * If there was a guarantee for byte array to always start aligned to a long, we could - * do a simple check on the parity of the index. Unfortunately, that is not always the - * case. Thus, we check alignment of the actual address we are writing to. - * In the unlikely case index 0 is 5-aligned for example, it would then be possible to - * write a long to index 3. - */ -static jbyte* check_alignment_get_addr(typeArrayOop obj, int index, int expected_alignment) { - jbyte* res = obj->byte_at_addr(index); - assert((((intptr_t) res) % expected_alignment) == 0, "Non-aligned write"); - return res; -} - -static void byte_array_put(typeArrayOop obj, StackValue* value, int index, int byte_count) { - switch (byte_count) { - case 1: - obj->byte_at_put(index, (jbyte) value->get_jint()); - break; - case 2: - *((jshort *) check_alignment_get_addr(obj, index, 2)) = (jshort) value->get_jint(); - break; - case 4: - *((jint *) check_alignment_get_addr(obj, index, 4)) = value->get_jint(); - break; - case 8: - *((jlong *) check_alignment_get_addr(obj, index, 8)) = (jlong) value->get_intptr(); - break; - default: - ShouldNotReachHere(); - } -} -#endif // INCLUDE_JVMCI - - // restore elements of an eliminated type array void Deoptimization::reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type) { int index = 0; @@ -1380,39 +1124,7 @@ void Deoptimization::reassign_type_array_elements(frame* fr, RegisterMap* reg_ma case T_INT: case T_FLOAT: { // 4 bytes. assert(value->type() == T_INT, "Agreement."); -#if INCLUDE_JVMCI - // big_value allows encoding double/long value as e.g. [int = 0, long], and storing - // the value in two array elements. - bool big_value = false; - if (i + 1 < sv->field_size() && type == T_INT) { - if (sv->field_at(i)->is_location()) { - Location::Type type = ((LocationValue*) sv->field_at(i))->location().type(); - if (type == Location::dbl || type == Location::lng) { - big_value = true; - } - } else if (sv->field_at(i)->is_constant_int()) { - ScopeValue* next_scope_field = sv->field_at(i + 1); - if (next_scope_field->is_constant_long() || next_scope_field->is_constant_double()) { - big_value = true; - } - } - } - - if (big_value) { - StackValue* low = StackValue::create_stack_value(fr, reg_map, sv->field_at(++i)); - #ifdef _LP64 - jlong res = (jlong)low->get_intptr(); - #else - jlong res = jlong_from(value->get_jint(), low->get_jint()); - #endif - obj->int_at_put(index, *(jint*)&res); - obj->int_at_put(++index, *((jint*)&res + 1)); - } else { - obj->int_at_put(index, value->get_jint()); - } -#else // not INCLUDE_JVMCI obj->int_at_put(index, value->get_jint()); -#endif // INCLUDE_JVMCI break; } @@ -1428,19 +1140,8 @@ void Deoptimization::reassign_type_array_elements(frame* fr, RegisterMap* reg_ma case T_BYTE: { assert(value->type() == T_INT, "Agreement."); -#if INCLUDE_JVMCI - // The value we get is erased as a regular int. We will need to find its actual byte count 'by hand'. - int byte_count = count_number_of_bytes_for_entry(sv, i); - byte_array_put(obj, value, index, byte_count); - // According to byte_count contract, the values from i + 1 to i + byte_count are illegal values. Skip. - i += byte_count - 1; // Balance the loop counter. - index += byte_count; - // index has been updated so continue at top of loop - continue; -#else obj->byte_at_put(index, (jbyte)value->get_jint()); break; -#endif // INCLUDE_JVMCI } case T_BOOLEAN: { @@ -1477,13 +1178,13 @@ public: }; // Gets the fields of `klass` that are eliminated by escape analysis and need to be reassigned -static GrowableArray* get_reassigned_fields(InstanceKlass* klass, GrowableArray* fields, bool is_jvmci) { +static GrowableArray* get_reassigned_fields(InstanceKlass* klass, GrowableArray* fields) { InstanceKlass* super = klass->super(); if (super != nullptr) { - get_reassigned_fields(super, fields, is_jvmci); + get_reassigned_fields(super, fields); } for (AllFieldStream fs(klass); !fs.done(); fs.next()) { - if (!fs.access_flags().is_static() && (is_jvmci || !fs.field_flags().is_injected())) { + if (!fs.access_flags().is_static() && !fs.field_flags().is_injected()) { ReassignedField field; field._offset = fs.offset(); field._type = Signature::basic_type(fs.signature()); @@ -1494,8 +1195,8 @@ static GrowableArray* get_reassigned_fields(InstanceKlass* klas } // Restore fields of an eliminated instance object employing the same field order used by the compiler. -static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj, bool is_jvmci) { - GrowableArray* fields = get_reassigned_fields(klass, new GrowableArray(), is_jvmci); +static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj) { + GrowableArray* fields = get_reassigned_fields(klass, new GrowableArray()); for (int i = 0; i < fields->length(); i++) { ScopeValue* scope_field = sv->field_at(svIndex); StackValue* value = StackValue::create_stack_value(fr, reg_map, scope_field); @@ -1577,7 +1278,7 @@ static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap } // restore fields of all eliminated objects and arrays -void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray* objects, bool realloc_failures, bool is_jvmci) { +void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray* objects, bool realloc_failures) { for (int i = 0; i < objects->length(); i++) { assert(objects->at(i)->is_object(), "invalid debug information"); ObjectValue* sv = (ObjectValue*) objects->at(i); @@ -1594,12 +1295,6 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr continue; } -#if INCLUDE_JVMCI - // Don't reassign fields of boxes that came from a cache. Caches may be in CDS. - if (sv->is_auto_box() && ((AutoBoxObjectValue*) sv)->is_cached()) { - continue; - } -#endif // INCLUDE_JVMCI if (EnableVectorSupport && VectorSupport::is_vector(k)) { assert(sv->field_size() == 1, "%s not a vector", k->name()->as_C_string()); ScopeValue* payload = sv->field_at(0); @@ -1621,7 +1316,7 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr } if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); - reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), is_jvmci); + reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj()); } else if (k->is_typeArray_klass()) { TypeArrayKlass* ak = TypeArrayKlass::cast(k); reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); @@ -1692,7 +1387,7 @@ bool Deoptimization::relock_objects(JavaThread* thread, GrowableArray* chunk, bool realloc_failures) { Events::log_deopt_message(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(fr.pc()), p2i(fr.sp())); @@ -1744,7 +1439,7 @@ vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, Re return array; } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) { // Reallocation of some scalar replaced objects failed. Record // that we need to pop all the interpreter frames for the @@ -1767,11 +1462,11 @@ void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array->element(i)->free_monitors(); #ifdef ASSERT array->element(i)->set_removed_monitors(); -#endif +#endif // ASSERT } } } -#endif +#endif // COMPILER2 void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deoptimization::DeoptReason reason) { assert(fr.can_be_deoptimized(), "checking frame type"); @@ -1834,34 +1529,6 @@ address Deoptimization::deoptimize_for_missing_exception_handler(nmethod* nm, bo Deoptimization::deoptimize(thread, caller_frame, Deoptimization::Reason_not_compiled_exception_handler); - if (!nm->is_compiled_by_jvmci()) { - return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - } - -#if INCLUDE_JVMCI - // JVMCI support - vframe* vf = vframe::new_vframe(&caller_frame, ®_map, thread); - compiledVFrame* cvf = compiledVFrame::cast(vf); - ScopeDesc* imm_scope = cvf->scope(); - MethodData* imm_mdo = get_method_data(thread, methodHandle(thread, imm_scope->method()), true); - if (imm_mdo != nullptr) { - // Lock to read ProfileData, and ensure lock is not broken by a safepoint - MutexLocker ml(imm_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); - - ProfileData* pdata = imm_mdo->allocate_bci_to_data(imm_scope->bci(), nullptr); - if (pdata != nullptr && pdata->is_BitData()) { - BitData* bit_data = (BitData*) pdata; - bit_data->set_exception_seen(); - } - } - - - MethodData* trap_mdo = get_method_data(thread, methodHandle(thread, nm->method()), true); - if (trap_mdo != nullptr) { - trap_mdo->inc_trap_count(Deoptimization::Reason_not_compiled_exception_handler); - } -#endif - return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); } @@ -1924,7 +1591,7 @@ Deoptimization::get_method_data(JavaThread* thread, const methodHandle& m, return mdo; } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 void Deoptimization::load_class_by_index(const constantPoolHandle& constant_pool, int index, TRAPS) { // In case of an unresolved klass entry, load the class. // This path is exercised from case _ldc in Parse::do_one_bytecode, @@ -2053,18 +1720,10 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr current->inc_in_deopt_handler(); -#if INCLUDE_JVMCI - // JVMCI might need to get an exception from the stack, which in turn requires the register map to be valid - RegisterMap reg_map(current, - RegisterMap::UpdateMap::include, - RegisterMap::ProcessFrames::include, - RegisterMap::WalkContinuation::skip); -#else RegisterMap reg_map(current, RegisterMap::UpdateMap::skip, RegisterMap::ProcessFrames::include, RegisterMap::WalkContinuation::skip); -#endif frame stub_frame = current->last_frame(); frame fr = stub_frame.sender(®_map); @@ -2077,9 +1736,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr DeoptReason reason = trap_request_reason(trap_request); DeoptAction action = trap_request_action(trap_request); -#if INCLUDE_JVMCI - int debug_id = trap_request_debug_id(trap_request); -#endif jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1 vframe* vf = vframe::new_vframe(&fr, ®_map, current); @@ -2092,31 +1748,12 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr bool is_receiver_constraint_failure = COMPILER2_PRESENT(VerifyReceiverTypes &&) (reason == Deoptimization::Reason_receiver_constraint); if (is_receiver_constraint_failure) { - tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT ", method=%s" JVMCI_ONLY(", debug_id=%d"), - trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string() - JVMCI_ONLY(COMMA debug_id)); + tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT ", method=%s", trap_scope->bci(), + p2i(fr.pc()), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string()); } methodHandle trap_method(current, trap_scope->method()); int trap_bci = trap_scope->bci(); -#if INCLUDE_JVMCI - jlong speculation = current->pending_failed_speculation(); - if (nm->is_compiled_by_jvmci()) { - nm->update_speculation(current); - } else { - assert(speculation == 0, "There should not be a speculation for methods compiled by non-JVMCI compilers"); - } - - if (trap_bci == SynchronizationEntryBCI) { - trap_bci = 0; - current->set_pending_monitorenter(true); - } - - if (reason == Deoptimization::Reason_transfer_to_interpreter) { - current->set_pending_transfer_to_interpreter(true); - } -#endif - Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci); // Record this event in the histogram. gather_statistics(reason, action, trap_bc); @@ -2125,15 +1762,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr bool create_if_missing = ProfileTraps; methodHandle profiled_method; -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - profiled_method = methodHandle(current, nm->method()); - } else { - profiled_method = trap_method; - } -#else profiled_method = trap_method; -#endif MethodData* trap_mdo = get_method_data(current, profiled_method, create_if_missing); @@ -2194,11 +1823,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr xtty->begin_head("uncommon_trap thread='%zu' %s", os::current_thread_id(), format_trap_request(buf, sizeof(buf), trap_request)); -#if INCLUDE_JVMCI - if (speculation != 0) { - xtty->print(" speculation='" JLONG_FORMAT "'", speculation); - } -#endif nm->log_identity(xtty); } if (class_name != nullptr) { @@ -2237,26 +1861,15 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr if (TraceDeoptimization) { // make noise on the tty stringStream st; st.print("UNCOMMON TRAP method=%s", trap_scope->method()->name_and_sig_as_C_string()); - st.print(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT JVMCI_ONLY(", debug_id=%d"), - trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin() JVMCI_ONLY(COMMA debug_id)); + st.print(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=" INTPTR_FORMAT, + trap_scope->bci(), p2i(fr.pc()), fr.pc() - nm->code_begin()); st.print(" compiler=%s compile_id=%d", nm->compiler_name(), nm->compile_id()); -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - const char* installed_code_name = nm->jvmci_name(); - if (installed_code_name != nullptr) { - st.print(" (JVMCI: installed code name=%s) ", installed_code_name); - } - } -#endif - st.print(" (@" INTPTR_FORMAT ") thread=%zu reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"), + st.print(" (@" INTPTR_FORMAT ") thread=%zu reason=%s action=%s unloaded_class_index=%d", p2i(fr.pc()), os::current_thread_id(), trap_reason_name(reason), trap_action_name(action), unloaded_class_index -#if INCLUDE_JVMCI - , debug_id -#endif ); if (class_name != nullptr) { st.print(unresolved ? " unresolved class: " : " symbol: "); @@ -2385,14 +1998,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr ShouldNotReachHere(); } -#if INCLUDE_JVMCI - // Deoptimization count is used by the CompileBroker to reason about compilations - // it requests so do not pollute the count for deoptimizations in non-default (i.e. - // non-CompilerBroker) compilations. - if (nm->jvmci_skip_profile_deopt()) { - update_trap_state = false; - } -#endif // Setting +ProfileTraps fixes the following, on all platforms: // The result is infinite heroic-opt-uncommon-trap/deopt/recompile cycles, since the // recompile relies on a MethodData* to record heroic opt failures. @@ -2407,17 +2012,13 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr (trap_mdo != nullptr), Mutex::_no_safepoint_check_flag); ProfileData* pdata = nullptr; - if (ProfileTraps && CompilerConfig::is_c2_or_jvmci_compiler_enabled() && update_trap_state && trap_mdo != nullptr) { + if (ProfileTraps && CompilerConfig::is_c2_enabled() && update_trap_state && trap_mdo != nullptr) { assert(trap_mdo == get_method_data(current, profiled_method, false), "sanity"); uint this_trap_count = 0; bool maybe_prior_trap = false; bool maybe_prior_recompile = false; - pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, -#if INCLUDE_JVMCI - nm->is_compiled_by_jvmci() && nm->is_osr_method(), -#endif - nm->method(), + pdata = query_update_method_data(trap_mdo, trap_bci, reason, nm->method(), //outputs: this_trap_count, maybe_prior_trap, @@ -2548,10 +2149,6 @@ ProfileData* Deoptimization::query_update_method_data(MethodData* trap_mdo, int trap_bci, Deoptimization::DeoptReason reason, - bool update_total_trap_count, -#if INCLUDE_JVMCI - bool is_osr, -#endif Method* compiled_method, //outputs: uint& ret_this_trap_count, @@ -2562,31 +2159,22 @@ Deoptimization::query_update_method_data(MethodData* trap_mdo, bool maybe_prior_trap = false; bool maybe_prior_recompile = false; uint this_trap_count = 0; - if (update_total_trap_count) { - uint idx = reason; -#if INCLUDE_JVMCI - if (is_osr) { - // Upper half of history array used for traps in OSR compilations - idx += Reason_TRAP_HISTORY_LENGTH; - } -#endif - uint prior_trap_count = trap_mdo->trap_count(idx); - this_trap_count = trap_mdo->inc_trap_count(idx); + uint idx = reason; + uint prior_trap_count = trap_mdo->trap_count(idx); + this_trap_count = trap_mdo->inc_trap_count(idx); - // If the runtime cannot find a place to store trap history, - // it is estimated based on the general condition of the method. - // If the method has ever been recompiled, or has ever incurred - // a trap with the present reason , then this BCI is assumed - // (pessimistically) to be the culprit. - maybe_prior_trap = (prior_trap_count != 0); - maybe_prior_recompile = (trap_mdo->decompile_count() != 0); - } + // If the runtime cannot find a place to store trap history, + // it is estimated based on the general condition of the method. + // If the method has ever been recompiled, or has ever incurred + // a trap with the present reason , then this BCI is assumed + // (pessimistically) to be the culprit. + maybe_prior_trap = (prior_trap_count != 0); + maybe_prior_recompile = (trap_mdo->decompile_count() != 0); ProfileData* pdata = nullptr; // For reasons which are recorded per bytecode, we check per-BCI data. DeoptReason per_bc_reason = reason_recorded_per_bytecode_if_any(reason); - assert(per_bc_reason != Reason_none || update_total_trap_count, "must be"); if (per_bc_reason != Reason_none) { // Find the profile data for this BCI. If there isn't one, // try to allocate one from the MDO's set of spares. @@ -2639,18 +2227,12 @@ Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int tr bool ignore_maybe_prior_trap; bool ignore_maybe_prior_recompile; assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); - // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts - bool update_total_counts = true JVMCI_ONLY( && !UseJVMCICompiler); // Lock to read ProfileData, and ensure lock is not broken by a safepoint MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); query_update_method_data(trap_mdo, trap_bci, (DeoptReason)reason, - update_total_counts, -#if INCLUDE_JVMCI - false, -#endif nullptr, ignore_this_trap_count, ignore_maybe_prior_trap, @@ -2765,12 +2347,12 @@ const char* Deoptimization::_trap_reason_name[] = { // Note: Keep this in sync. with enum DeoptReason. "none", "null_check", - "null_assert" JVMCI_ONLY("_or_unreached0"), + "null_assert", "range_check", "class_check", "array_check", - "intrinsic" JVMCI_ONLY("_or_type_checked_inlining"), - "bimorphic" JVMCI_ONLY("_or_optimized_type_check"), + "intrinsic", + "bimorphic", "profile_predicate", "auto_vectorization_check", "unloaded", @@ -2790,12 +2372,7 @@ const char* Deoptimization::_trap_reason_name[] = { "unstable_fused_if", "receiver_constraint", "not_compiled_exception_handler", - "short_running_loop" JVMCI_ONLY("_or_aliasing"), -#if INCLUDE_JVMCI - "transfer_to_interpreter", - "unresolved", - "jsr_mismatch", -#endif + "short_running_loop", "tenured" }; const char* Deoptimization::_trap_action_name[] = { @@ -2835,24 +2412,12 @@ const char* Deoptimization::format_trap_request(char* buf, size_t buflen, jint unloaded_class_index = trap_request_index(trap_request); const char* reason = trap_reason_name(trap_request_reason(trap_request)); const char* action = trap_action_name(trap_request_action(trap_request)); -#if INCLUDE_JVMCI - int debug_id = trap_request_debug_id(trap_request); -#endif size_t len; if (unloaded_class_index < 0) { - len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" JVMCI_ONLY(" debug_id='%d'"), - reason, action -#if INCLUDE_JVMCI - ,debug_id -#endif - ); + len = jio_snprintf(buf, buflen, "reason='%s' action='%s'", reason, action); } else { - len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" JVMCI_ONLY(" debug_id='%d'"), - reason, action, unloaded_class_index -#if INCLUDE_JVMCI - ,debug_id -#endif - ); + len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'", + reason, action, unloaded_class_index); } return buf; } @@ -2965,8 +2530,7 @@ void Deoptimization::print_statistics() { } } -#else // COMPILER2_OR_JVMCI - +#else // COMPILER2 // Stubs for C1 only system. bool Deoptimization::trap_state_is_recompiled(int trap_state) { @@ -3009,4 +2573,4 @@ const char* Deoptimization::format_trap_state(char* buf, size_t buflen, return buf; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 diff --git a/src/hotspot/share/runtime/deoptimization.hpp b/src/hotspot/share/runtime/deoptimization.hpp index f42976fa5de..3da07f3f5af 100644 --- a/src/hotspot/share/runtime/deoptimization.hpp +++ b/src/hotspot/share/runtime/deoptimization.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,12 +77,6 @@ class Deoptimization : AllStatic { Reason_many = -1, // indicates presence of several reasons Reason_none = 0, // indicates absence of a relevant deopt. // Next 8 reasons are recorded per bytecode in DataLayout::trap_bits. - // This is more complicated for JVMCI as JVMCI may deoptimize to *some* bytecode before the - // bytecode that actually caused the deopt (with inlining, JVMCI may even deoptimize to a - // bytecode in another method): - // - bytecode y in method b() causes deopt - // - JVMCI deoptimizes to bytecode x in method a() - // -> the deopt reason will be recorded for method a() at bytecode x Reason_null_check, // saw unexpected null or zero divisor (@bci) Reason_null_assert, // saw unexpected non-null or non-zero (@bci) Reason_range_check, // saw unexpected array index (@bci) @@ -91,12 +85,6 @@ class Deoptimization : AllStatic { Reason_intrinsic, // saw unexpected operand to intrinsic (@bci) Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci) -#if INCLUDE_JVMCI - Reason_unreached0 = Reason_null_assert, - Reason_type_checked_inlining = Reason_intrinsic, - Reason_optimized_type_check = Reason_bimorphic, -#endif - Reason_profile_predicate, // compiler generated predicate moved from frequent branch in a loop failed Reason_auto_vectorization_check, // compiler generated (speculative) auto vectorization checks failed @@ -119,12 +107,6 @@ class Deoptimization : AllStatic { Reason_receiver_constraint, // receiver subtype check failed Reason_not_compiled_exception_handler, // missing compiled exception handler Reason_short_running_long_loop, // profile reports loop runs for small number of iterations -#if INCLUDE_JVMCI - Reason_aliasing = Reason_short_running_long_loop, // optimistic assumption about aliasing failed - Reason_transfer_to_interpreter, // explicit transferToInterpreter() - Reason_unresolved, - Reason_jsr_mismatch, -#endif // Used to define MethodData::_trap_hist_limit where Reason_tenured isn't included Reason_TRAP_HISTORY_LENGTH, @@ -154,10 +136,8 @@ class Deoptimization : AllStatic { enum { _action_bits = 3, _reason_bits = 5, - _debug_id_bits = 23, _action_shift = 0, _reason_shift = _action_shift+_action_bits, - _debug_id_shift = _reason_shift+_reason_bits, BC_CASE_LIMIT = PRODUCT_ONLY(1) NOT_PRODUCT(4) // for _deoptimization_hist }; @@ -170,11 +150,6 @@ class Deoptimization : AllStatic { Unpack_LIMIT = 5 }; -#if INCLUDE_JVMCI - // Can reconstruct virtualized unsafe large accesses to byte arrays. - static const int _support_large_access_byte_array_virtualization = 1; -#endif - // Make all nmethods that are marked_for_deoptimization not_entrant and deoptimize any live // activations using those nmethods. Scan of the code cache is done to // find all marked nmethods and they are made not_entrant. @@ -185,15 +160,12 @@ class Deoptimization : AllStatic { static void deoptimize(JavaThread* thread, frame fr, DeoptReason reason = Reason_constraint); static address deoptimize_for_missing_exception_handler(nmethod* nm, bool make_not_entrant); -#if INCLUDE_JVMCI - static oop get_cached_box(AutoBoxObjectValue* bv, frame* fr, RegisterMap* reg_map, bool& cache_init_error, TRAPS); -#endif private: // Does the actual work for deoptimizing a single frame static void deoptimize_single_frame(JavaThread* thread, frame fr, DeoptReason reason); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Deoptimize objects, that is reallocate and relock them, just before they // escape through JVMTI. The given vframes cover one physical frame. static bool deoptimize_objects_internal(JavaThread* thread, GrowableArray* chunk, @@ -205,11 +177,11 @@ class Deoptimization : AllStatic { static bool realloc_objects(JavaThread* thread, frame* fr, RegisterMap* reg_map, GrowableArray* objects, TRAPS); static void reassign_type_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, typeArrayOop obj, BasicType type); static void reassign_object_array_elements(frame* fr, RegisterMap* reg_map, ObjectValue* sv, objArrayOop obj); - static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray* objects, bool realloc_failures, bool skip_internal); + static void reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray* objects, bool realloc_failures); static bool relock_objects(JavaThread* thread, GrowableArray* monitors, JavaThread* deoptee_thread, frame& fr, int exec_mode, bool realloc_failures); static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array); -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 public: static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray* chunk, bool realloc_failures); @@ -220,7 +192,6 @@ class Deoptimization : AllStatic { // This is only a CheapObj to ease debugging after a deopt failure class UnrollBlock : public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; private: int _size_of_deoptimized_frame; // Size, in bytes, of current deoptimized frame int _caller_adjustment; // Adjustment, in bytes, to caller's SP by initial interpreted frame @@ -353,14 +324,6 @@ class Deoptimization : AllStatic { // standard action for unloaded CP entry return _unloaded_action; } - static int trap_request_debug_id(int trap_request) { - if (trap_request < 0) { - return (~(trap_request) >> _debug_id_shift) & right_n_bits(_debug_id_bits); - } else { - // standard action for unloaded CP entry - return 0; - } - } static int trap_request_index(int trap_request) { if (trap_request < 0) return -1; @@ -467,10 +430,6 @@ class Deoptimization : AllStatic { static ProfileData* query_update_method_data(MethodData* trap_mdo, int trap_bci, DeoptReason reason, - bool update_total_trap_count, -#if INCLUDE_JVMCI - bool is_osr, -#endif Method* compiled_method, //outputs: uint& ret_this_trap_count, diff --git a/src/hotspot/share/runtime/escapeBarrier.cpp b/src/hotspot/share/runtime/escapeBarrier.cpp index 2005527bb8b..9f0dae34aa6 100644 --- a/src/hotspot/share/runtime/escapeBarrier.cpp +++ b/src/hotspot/share/runtime/escapeBarrier.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -46,7 +46,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/macros.hpp" -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Returns true iff objects were reallocated and relocked because of access through JVMTI bool EscapeBarrier::objs_are_deoptimized(JavaThread* thread, intptr_t* fr_id) { @@ -373,4 +373,4 @@ bool EscapeBarrier::deoptimize_objects_internal(JavaThread* deoptee, intptr_t* f return !realloc_failures; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 diff --git a/src/hotspot/share/runtime/escapeBarrier.hpp b/src/hotspot/share/runtime/escapeBarrier.hpp index 6a1d28bfeec..f4d3144e656 100644 --- a/src/hotspot/share/runtime/escapeBarrier.hpp +++ b/src/hotspot/share/runtime/escapeBarrier.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -39,7 +39,7 @@ class JavaThread; class EscapeBarrier : StackObj { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 JavaThread* const _calling_thread; JavaThread* const _deoptee_thread; bool const _barrier_active; @@ -71,8 +71,7 @@ public: // Revert ea based optimizations for given deoptee thread EscapeBarrier(bool barrier_active, JavaThread* calling_thread, JavaThread* deoptee_thread) : _calling_thread(calling_thread), _deoptee_thread(deoptee_thread), - _barrier_active(barrier_active && (JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false) - COMPILER2_PRESENT(|| DoEscapeAnalysis))) + _barrier_active(COMPILER2_PRESENT(barrier_active && DoEscapeAnalysis) NOT_COMPILER2(false)) { if (_barrier_active) sync_and_suspend_one(); } @@ -80,8 +79,7 @@ public: // Revert ea based optimizations for all java threads EscapeBarrier(bool barrier_active, JavaThread* calling_thread) : _calling_thread(calling_thread), _deoptee_thread(nullptr), - _barrier_active(barrier_active && (JVMCI_ONLY(EnableJVMCI) NOT_JVMCI(false) - COMPILER2_PRESENT(|| DoEscapeAnalysis))) + _barrier_active(COMPILER2_PRESENT(barrier_active && DoEscapeAnalysis) NOT_COMPILER2(false)) { if (_barrier_active) sync_and_suspend_all(); } @@ -93,7 +91,7 @@ public: EscapeBarrier(bool barrier_active, JavaThread* calling_thread) { } static bool deoptimizing_objects_for_all_threads() { return false; } bool barrier_active() const { return false; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 // Deoptimize objects of frames of the target thread up to the given depth. // Deoptimize objects of caller frames if they passed references to ArgEscape objects as arguments. @@ -105,18 +103,18 @@ public: // Deoptimize objects of frames of the target thread at depth >= d1 and depth <= d2. // Deoptimize objects of caller frames if they passed references to ArgEscape objects as arguments. // Return false in the case of a reallocation failure and true otherwise. - bool deoptimize_objects(int d1, int d2) NOT_COMPILER2_OR_JVMCI_RETURN_(true); + bool deoptimize_objects(int d1, int d2) NOT_COMPILER2({ return true; }); // Find and deoptimize non escaping objects and the holding frames on all stacks. - bool deoptimize_objects_all_threads() NOT_COMPILER2_OR_JVMCI_RETURN_(true); + bool deoptimize_objects_all_threads() NOT_COMPILER2({ return true; }); // A java thread was added to the list of threads. - static void thread_added(JavaThread* jt) NOT_COMPILER2_OR_JVMCI_RETURN; + static void thread_added(JavaThread* jt) NOT_COMPILER2({}); // A java thread was removed from the list of threads. - static void thread_removed(JavaThread* jt) NOT_COMPILER2_OR_JVMCI_RETURN; + static void thread_removed(JavaThread* jt) NOT_COMPILER2({}); -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 // Returns true iff objects were reallocated and relocked because of access through JVMTI. static bool objs_are_deoptimized(JavaThread* thread, intptr_t* fr_id); @@ -141,7 +139,7 @@ public: // accessors JavaThread* calling_thread() const { return _calling_thread; } JavaThread* deoptee_thread() const { return _deoptee_thread; } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 }; #endif // SHARE_RUNTIME_ESCAPEBARRIER_HPP diff --git a/src/hotspot/share/runtime/flags/allFlags.hpp b/src/hotspot/share/runtime/flags/allFlags.hpp index edeb1cd4024..cc261bbd4b8 100644 --- a/src/hotspot/share/runtime/flags/allFlags.hpp +++ b/src/hotspot/share/runtime/flags/allFlags.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ #include "runtime/flags/debug_globals.hpp" #include "runtime/globals.hpp" -// Put LP64/ARCH/JVMCI/COMPILER1/COMPILER2 at the top, +// Put LP64/ARCH/COMPILER1/COMPILER2 at the top, // as they are processed by jvmFlag.cpp in that order. #define ALL_FLAGS( \ @@ -57,14 +57,6 @@ range, \ constraint) \ \ - JVMCI_ONLY(JVMCI_FLAGS( \ - develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint)) \ - \ COMPILER1_PRESENT(C1_FLAGS( \ develop, \ develop_pd, \ diff --git a/src/hotspot/share/runtime/flags/jvmFlag.cpp b/src/hotspot/share/runtime/flags/jvmFlag.cpp index 1c965360599..9c9965609f3 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,18 +86,6 @@ void JVMFlag::clear_diagnostic() { assert(!is_diagnostic(), "sanity"); } -void JVMFlag::clear_experimental() { - assert(is_experimental(), "sanity"); - _flags = Flags(_flags & ~KIND_EXPERIMENTAL); - assert(!is_experimental(), "sanity"); -} - -void JVMFlag::set_product() { - assert(!is_product(), "sanity"); - _flags = Flags(_flags | KIND_PRODUCT); - assert(is_product(), "sanity"); -} - // Get custom message for this locked flag, or null if // none is available. Returns message type produced. JVMFlag::MsgType JVMFlag::get_locked_message(char* buf, int buflen) const { @@ -330,7 +318,6 @@ void JVMFlag::print_kind(outputStream* st, unsigned int width) const { }; Data data[] = { - { KIND_JVMCI, "JVMCI" }, { KIND_C1, "C1" }, { KIND_C2, "C2" }, { KIND_ARCH, "ARCH" }, @@ -446,7 +433,7 @@ void JVMFlag::print_as_flag(outputStream* st) const { //---------------------------------------------------------------------- // Build flagTable[] -// Find out the number of LP64/ARCH/JVMCI/COMPILER1/COMPILER2 flags, +// Find out the number of LP64/ARCH/COMPILER1/COMPILER2 flags, // for JVMFlag::flag_group() #define ENUM_F(type, name, ...) enum_##name, @@ -455,21 +442,18 @@ void JVMFlag::print_as_flag(outputStream* st) const { // dev dev-pd pro pro-pd range constraint enum FlagCounter_LP64 { LP64_RUNTIME_FLAGS( ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F) num_flags_LP64 }; enum FlagCounter_ARCH { ARCH_FLAGS( ENUM_F, ENUM_F, IGNORE_F, IGNORE_F) num_flags_ARCH }; -enum FlagCounter_JVMCI { JVMCI_ONLY(JVMCI_FLAGS( ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_JVMCI }; enum FlagCounter_C1 { COMPILER1_PRESENT(C1_FLAGS(ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_C1 }; enum FlagCounter_C2 { COMPILER2_PRESENT(C2_FLAGS(ENUM_F, ENUM_F, ENUM_F, ENUM_F, IGNORE_F, IGNORE_F)) num_flags_C2 }; const int first_flag_enum_LP64 = 0; const int first_flag_enum_ARCH = first_flag_enum_LP64 + num_flags_LP64; -const int first_flag_enum_JVMCI = first_flag_enum_ARCH + num_flags_ARCH; -const int first_flag_enum_C1 = first_flag_enum_JVMCI + num_flags_JVMCI; +const int first_flag_enum_C1 = first_flag_enum_ARCH + num_flags_ARCH; const int first_flag_enum_C2 = first_flag_enum_C1 + num_flags_C1; const int first_flag_enum_other = first_flag_enum_C2 + num_flags_C2; static constexpr int flag_group(int flag_enum) { if (flag_enum < first_flag_enum_ARCH) return JVMFlag::KIND_LP64_PRODUCT; - if (flag_enum < first_flag_enum_JVMCI) return JVMFlag::KIND_ARCH; - if (flag_enum < first_flag_enum_C1) return JVMFlag::KIND_JVMCI; + if (flag_enum < first_flag_enum_C1) return JVMFlag::KIND_ARCH; if (flag_enum < first_flag_enum_C2) return JVMFlag::KIND_C1; if (flag_enum < first_flag_enum_other) return JVMFlag::KIND_C2; diff --git a/src/hotspot/share/runtime/flags/jvmFlag.hpp b/src/hotspot/share/runtime/flags/jvmFlag.hpp index 56122f7282c..324504099e8 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.hpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,6 @@ public: KIND_C2 = 1 << 11, KIND_ARCH = 1 << 12, KIND_LP64_PRODUCT = 1 << 13, - KIND_JVMCI = 1 << 14, // Note the difference: // f->get_origin() == COMMAND_LINE @@ -259,8 +258,6 @@ public: bool is_external() const { return is_manageable(); } void clear_diagnostic(); - void clear_experimental(); - void set_product(); JVMFlag::MsgType get_locked_message(char*, int) const; diff --git a/src/hotspot/share/runtime/frame.cpp b/src/hotspot/share/runtime/frame.cpp index 68010a17ea4..a87ee974fdd 100644 --- a/src/hotspot/share/runtime/frame.cpp +++ b/src/hotspot/share/runtime/frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -706,12 +706,6 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose } st->print(" (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]", m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin()); -#if INCLUDE_JVMCI - const char* jvmciName = nm->jvmci_name(); - if (jvmciName != nullptr) { - st->print(" (%s)", jvmciName); - } -#endif } else { st->print("J " PTR_FORMAT, p2i(pc())); } @@ -1188,9 +1182,9 @@ void frame::verify(const RegisterMap* map) const { // make sure we have the right receiver type } } -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 assert(DerivedPointerTable::is_empty(), "must be empty before verify"); -#endif +#endif // COMPILER2 if (map->update_map()) { // The map has to be up-to-date for the current frame oops_do_internal(&VerifyOopClosure::verify_oop, nullptr, nullptr, DerivedPointerIterationMode::_ignore, map, false); diff --git a/src/hotspot/share/runtime/frame.hpp b/src/hotspot/share/runtime/frame.hpp index a80d12d7853..35d73e8ef78 100644 --- a/src/hotspot/share/runtime/frame.hpp +++ b/src/hotspot/share/runtime/frame.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -478,13 +478,13 @@ class frame { public: // Memory management void oops_do(OopClosure* f, NMethodClosure* cf, const RegisterMap* map) { -#if COMPILER2_OR_JVMCI +#ifdef COMPILER2 DerivedPointerIterationMode dpim = DerivedPointerTable::is_active() ? DerivedPointerIterationMode::_with_table : DerivedPointerIterationMode::_ignore; -#else +#else // COMPILER2 DerivedPointerIterationMode dpim = DerivedPointerIterationMode::_ignore;; -#endif +#endif // COMPILER2 oops_do_internal(f, cf, nullptr, dpim, map, true); } diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index d820968495e..51de40315a9 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +47,6 @@ #include "runtime/sharedRuntime.hpp" #include "sanitizers/leak.hpp" #include "utilities/macros.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif // Initialization done by VM thread in vm_init_globals() void check_ThreadShadow(); @@ -198,11 +195,6 @@ jint init_globals2() { if (!compileBroker_init()) { return JNI_EINVAL; } -#if INCLUDE_JVMCI - if (EnableJVMCI) { - JVMCI::initialize_globals(); - } -#endif TrainingData::initialize(); diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp index e501930b3a0..776996ceb80 100644 --- a/src/hotspot/share/runtime/java.cpp +++ b/src/hotspot/share/runtime/java.cpp @@ -101,9 +101,6 @@ #if INCLUDE_JFR #include "jfr/jfr.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif GrowableArray* collected_profiled_methods; @@ -284,16 +281,6 @@ void print_statistics() { IndexSet::print_statistics(); } #endif // ASSERT -#else // COMPILER2 -#if INCLUDE_JVMCI -#ifndef COMPILER1 - if ((TraceDeoptimization || LogVMOutput || LogCompilation) && UseCompiler) { - FlagSetting fs(DisplayVMOutput, DisplayVMOutput && TraceDeoptimization); - Deoptimization::print_statistics(); - SharedRuntime::print_statistics(); - } -#endif // COMPILER1 -#endif // INCLUDE_JVMCI #endif // COMPILER2 if (PrintNMethodStatistics) { @@ -448,12 +435,6 @@ void before_exit(JavaThread* thread, bool halt) { // Actual shutdown logic begins here. -#if INCLUDE_JVMCI - if (EnableJVMCI) { - JVMCI::shutdown(thread); - } -#endif - #if INCLUDE_CDS ClassListWriter::write_resolved_constants(); diff --git a/src/hotspot/share/runtime/javaCalls.cpp b/src/hotspot/share/runtime/javaCalls.cpp index da701640006..291be708d25 100644 --- a/src/hotspot/share/runtime/javaCalls.cpp +++ b/src/hotspot/share/runtime/javaCalls.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -45,9 +45,6 @@ #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/thread.inline.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmciJavaClasses.hpp" -#endif // ----------------------------------------------------- // Implementation of JavaCallWrapper @@ -328,11 +325,11 @@ void JavaCalls::call_helper(JavaValue* result, const methodHandle& method, JavaC assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here"); // Verify the arguments - if (JVMCI_ONLY(args->alternative_target().is_null() &&) (DEBUG_ONLY(true ||) CheckJNICalls)) { + if ((DEBUG_ONLY(true ||) CheckJNICalls)) { args->verify(method, result->get_type()); } // Ignore call if method is empty - if (JVMCI_ONLY(args->alternative_target().is_null() &&) method->is_empty_method()) { + if (method->is_empty_method()) { assert(result->get_type() == T_VOID, "an empty method must return a void value"); return; } @@ -393,20 +390,6 @@ void JavaCalls::call_helper(JavaValue* result, const methodHandle& method, JavaC // Since the call stub sets up like the interpreter we call the from_interpreted_entry // so we can go compiled via a i2c. entry_point = method->from_interpreted_entry(); -#if INCLUDE_JVMCI - // Gets the alternative target (if any) that should be called - Handle alternative_target = args->alternative_target(); - if (!alternative_target.is_null()) { - // Must extract verified entry point from HotSpotNmethod after VM to Java - // transition in JavaCallWrapper constructor so that it is safe with - // respect to nmethod sweeping. - address verified_entry_point = (address) HotSpotJVMCI::InstalledCode::entryPoint(nullptr, alternative_target()); - if (verified_entry_point != nullptr) { - thread->set_jvmci_alternate_call_target(verified_entry_point); - entry_point = method->get_i2c_entry(); - } - } -#endif } } { diff --git a/src/hotspot/share/runtime/javaCalls.hpp b/src/hotspot/share/runtime/javaCalls.hpp index b0b861c4e7a..863d9a11495 100644 --- a/src/hotspot/share/runtime/javaCalls.hpp +++ b/src/hotspot/share/runtime/javaCalls.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,10 +86,6 @@ class JavaCallArguments : public StackObj { int _size; int _max_size; bool _start_at_zero; // Support late setting of receiver -#if INCLUDE_JVMCI - Handle _alternative_target; // HotSpotNmethod wrapping an nmethod whose verified entry point - // should be called instead of the normal target -#endif void initialize() { // Starts at first element to support set_receiver. @@ -126,16 +122,6 @@ class JavaCallArguments : public StackObj { } } -#if INCLUDE_JVMCI - void set_alternative_target(Handle target) { - _alternative_target = target; - } - - Handle alternative_target() { - return _alternative_target; - } -#endif - // The possible values for _value_state elements. enum { value_state_primitive, diff --git a/src/hotspot/share/runtime/javaFrameAnchor.hpp b/src/hotspot/share/runtime/javaFrameAnchor.hpp index a0636bc3d60..b2e02128255 100644 --- a/src/hotspot/share/runtime/javaFrameAnchor.hpp +++ b/src/hotspot/share/runtime/javaFrameAnchor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,6 @@ friend class StubGenerator; friend class JavaThread; friend class frame; friend class VMStructs; -friend class JVMCIVMStructs; friend class BytecodeInterpreter; friend class JavaCallWrapper; friend class UpcallLinker; diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index ec1c8f64619..2f3695202ab 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -103,10 +103,6 @@ #include "utilities/preserveException.hpp" #include "utilities/spinYield.hpp" #include "utilities/vmError.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciEnv.hpp" -#endif #if INCLUDE_JFR #include "jfr/jfr.hpp" #endif @@ -271,102 +267,6 @@ void JavaThread::allocate_threadObj(Handle thread_group, const char* thread_name // ======= JavaThread ======== -#if INCLUDE_JVMCI - -jlong* JavaThread::_jvmci_old_thread_counters; - -static bool jvmci_counters_include(JavaThread* thread) { - return !JVMCICountersExcludeCompiler || !thread->is_Compiler_thread(); -} - -void JavaThread::collect_counters(jlong* array, int length) { - assert(length == JVMCICounterSize, "wrong value"); - for (int i = 0; i < length; i++) { - array[i] = _jvmci_old_thread_counters[i]; - } - for (JavaThread* tp : ThreadsListHandle()) { - if (jvmci_counters_include(tp)) { - for (int i = 0; i < length; i++) { - array[i] += tp->_jvmci_counters[i]; - } - } - } -} - -// Attempt to enlarge the array for per thread counters. -static jlong* resize_counters_array(jlong* old_counters, int current_size, int new_size) { - jlong* new_counters = NEW_C_HEAP_ARRAY_RETURN_NULL(jlong, new_size, mtJVMCI); - if (new_counters == nullptr) { - return nullptr; - } - if (old_counters == nullptr) { - old_counters = new_counters; - memset(old_counters, 0, sizeof(jlong) * new_size); - } else { - for (int i = 0; i < MIN2((int) current_size, new_size); i++) { - new_counters[i] = old_counters[i]; - } - if (new_size > current_size) { - memset(new_counters + current_size, 0, sizeof(jlong) * (new_size - current_size)); - } - FREE_C_HEAP_ARRAY(old_counters); - } - return new_counters; -} - -// Attempt to enlarge the array for per thread counters. -bool JavaThread::resize_counters(int current_size, int new_size) { - jlong* new_counters = resize_counters_array(_jvmci_counters, current_size, new_size); - if (new_counters == nullptr) { - return false; - } else { - _jvmci_counters = new_counters; - return true; - } -} - -class VM_JVMCIResizeCounters : public VM_Operation { - private: - int _new_size; - bool _failed; - - public: - VM_JVMCIResizeCounters(int new_size) : _new_size(new_size), _failed(false) { } - VMOp_Type type() const { return VMOp_JVMCIResizeCounters; } - bool allow_nested_vm_operations() const { return true; } - void doit() { - // Resize the old thread counters array - jlong* new_counters = resize_counters_array(JavaThread::_jvmci_old_thread_counters, JVMCICounterSize, _new_size); - if (new_counters == nullptr) { - _failed = true; - return; - } else { - JavaThread::_jvmci_old_thread_counters = new_counters; - } - - // Now resize each threads array - for (JavaThread* tp : ThreadsListHandle()) { - if (!tp->resize_counters(JVMCICounterSize, _new_size)) { - _failed = true; - break; - } - } - if (!_failed) { - JVMCICounterSize = _new_size; - } - } - - bool failed() { return _failed; } -}; - -bool JavaThread::resize_all_jvmci_counters(int new_size) { - VM_JVMCIResizeCounters op(new_size); - VMThread::execute(&op); - return !op.failed(); -} - -#endif // INCLUDE_JVMCI - #ifdef ASSERT // Checks safepoint allowed and clears unhandled oops at potential safepoints. void JavaThread::check_possible_safepoint() { @@ -450,19 +350,6 @@ JavaThread::JavaThread(MemTag mem_tag) : #endif _jni_attach_state(_not_attaching_via_jni), _is_in_internal_oome_mark(false), -#if INCLUDE_JVMCI - _pending_deoptimization(-1), - _pending_monitorenter(false), - _pending_transfer_to_interpreter(false), - _pending_failed_speculation(0), - _jvmci{nullptr}, - _libjvmci_runtime(nullptr), - _jvmci_counters(nullptr), - _jvmci_reserved0(0), - _jvmci_reserved1(0), - _jvmci_reserved_oop0(nullptr), - _live_nmethod(nullptr), -#endif // INCLUDE_JVMCI _exception_oop(oop()), _exception_pc(nullptr), @@ -525,13 +412,6 @@ JavaThread::JavaThread(MemTag mem_tag) : _om_cache(this) { set_jni_functions(jni_functions()); -#if INCLUDE_JVMCI - assert(_jvmci._implicit_exception_pc == nullptr, "must be"); - if (JVMCICounterSize > 0) { - resize_counters(0, (int) JVMCICounterSize); - } -#endif // INCLUDE_JVMCI - // Setup safepoint state info for this thread ThreadSafepointState::create(this); @@ -702,11 +582,6 @@ JavaThread::~JavaThread() { ThreadSafepointState::destroy(this); if (_thread_stat != nullptr) delete _thread_stat; -#if INCLUDE_JVMCI - if (JVMCICounterSize > 0) { - FREE_C_HEAP_ARRAY(_jvmci_counters); - } -#endif // INCLUDE_JVMCI } @@ -978,16 +853,6 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { _timer_exit_phase4.start(); } -#if INCLUDE_JVMCI - if (JVMCICounterSize > 0) { - if (jvmci_counters_include(this)) { - for (int i = 0; i < JVMCICounterSize; i++) { - _jvmci_old_thread_counters[i] += _jvmci_counters[i]; - } - } - } -#endif // INCLUDE_JVMCI - // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread. // We call BarrierSet::barrier_set()->on_thread_detach() here so no touching of oops after this point. Threads::remove(this, daemon); @@ -1400,13 +1265,6 @@ void JavaThread::oops_do_no_frames(OopClosure* f, NMethodClosure* cf) { // around using this function f->do_oop((oop*) &_vm_result_oop); f->do_oop((oop*) &_exception_oop); -#if INCLUDE_JVMCI - f->do_oop((oop*) &_jvmci_reserved_oop0); - - if (_live_nmethod != nullptr && cf != nullptr) { - cf->do_nmethod(_live_nmethod); - } -#endif if (jvmti_thread_state() != nullptr) { jvmti_thread_state()->oops_do(f, cf); @@ -1460,12 +1318,6 @@ void JavaThread::nmethods_do(NMethodClosure* cf) { if (jvmti_thread_state() != nullptr) { jvmti_thread_state()->nmethods_do(cf); } - -#if INCLUDE_JVMCI - if (_live_nmethod != nullptr) { - cf->do_nmethod(_live_nmethod); - } -#endif } void JavaThread::metadata_do(MetadataClosure* f) { diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index 5dd84fcc01d..08d3cde8562 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -60,7 +60,6 @@ class AsyncExceptionHandshakeClosure; class DeoptResourceMark; class InternalOOMEMark; class JNIHandleBlock; -class JVMCIRuntime; class JvmtiDeferredUpdates; class JvmtiSampledObjectAllocEventCollector; @@ -88,7 +87,6 @@ class ThreadWXEnable; class JavaThread: public Thread { friend class VMStructs; - friend class JVMCIVMStructs; friend class WhiteBox; friend class ThreadsSMRSupport; // to access _threadObj for exiting_threads_oops_do friend class HandshakeState; @@ -358,94 +356,6 @@ class JavaThread: public Thread { // In scope of an InternalOOMEMark? bool _is_in_internal_oome_mark; -#if INCLUDE_JVMCI - // The _pending_* fields below are used to communicate extra information - // from an uncommon trap in JVMCI compiled code to the uncommon trap handler. - - // Communicates the DeoptReason and DeoptAction of the uncommon trap - int _pending_deoptimization; - - // Specifies whether the uncommon trap is to bci 0 of a synchronized method - // before the monitor has been acquired. - bool _pending_monitorenter; - - // Specifies if the DeoptReason for the last uncommon trap was Reason_transfer_to_interpreter - bool _pending_transfer_to_interpreter; - - // An id of a speculation that JVMCI compiled code can use to further describe and - // uniquely identify the speculative optimization guarded by an uncommon trap. - // See JVMCINMethodData::SPECULATION_LENGTH_BITS for further details. - jlong _pending_failed_speculation; - - // These fields are mutually exclusive in terms of live ranges. - union { - // Communicates the pc at which the most recent implicit exception occurred - // from the signal handler to a deoptimization stub. - address _implicit_exception_pc; - - // Communicates an alternative call target to an i2c stub from a JavaCall . - address _alternate_call_target; - } _jvmci; - - // The JVMCIRuntime in a JVMCI shared library - JVMCIRuntime* _libjvmci_runtime; - - // Support for high precision, thread sensitive counters in JVMCI compiled code. - jlong* _jvmci_counters; - - // Fast thread locals for use by JVMCI - jlong _jvmci_reserved0; - jlong _jvmci_reserved1; - oop _jvmci_reserved_oop0; - - // This field is used to keep an nmethod visible to the GC so that it and its contained oops can - // be kept alive - nmethod* _live_nmethod; - - public: - static jlong* _jvmci_old_thread_counters; - static void collect_counters(jlong* array, int length); - - bool resize_counters(int current_size, int new_size); - - static bool resize_all_jvmci_counters(int new_size); - - void set_jvmci_reserved_oop0(oop value) { - _jvmci_reserved_oop0 = value; - } - - oop get_jvmci_reserved_oop0() { - return _jvmci_reserved_oop0; - } - - void set_jvmci_reserved0(jlong value) { - _jvmci_reserved0 = value; - } - - jlong get_jvmci_reserved0() { - return _jvmci_reserved0; - } - - void set_jvmci_reserved1(jlong value) { - _jvmci_reserved1 = value; - } - - jlong get_jvmci_reserved1() { - return _jvmci_reserved1; - } - - void set_live_nmethod(nmethod* nm) { - assert(_live_nmethod == nullptr, "only one"); - _live_nmethod = nm; - } - - void clear_live_nmethod() { - _live_nmethod = nullptr; - } - - private: -#endif // INCLUDE_JVMCI - StackOverflow _stack_overflow_state; void pretouch_stack(); @@ -839,22 +749,6 @@ public: bool is_in_internal_oome_mark() const { return _is_in_internal_oome_mark; } void set_is_in_internal_oome_mark(bool b) { _is_in_internal_oome_mark = b; } -#if INCLUDE_JVMCI - jlong pending_failed_speculation() const { return _pending_failed_speculation; } - void set_pending_monitorenter(bool b) { _pending_monitorenter = b; } - void set_pending_deoptimization(int reason) { _pending_deoptimization = reason; } - void set_pending_failed_speculation(jlong failed_speculation) { _pending_failed_speculation = failed_speculation; } - void set_pending_transfer_to_interpreter(bool b) { _pending_transfer_to_interpreter = b; } - void set_jvmci_alternate_call_target(address a) { assert(_jvmci._alternate_call_target == nullptr, "must be"); _jvmci._alternate_call_target = a; } - void set_jvmci_implicit_exception_pc(address a) { assert(_jvmci._implicit_exception_pc == nullptr, "must be"); _jvmci._implicit_exception_pc = a; } - - JVMCIRuntime* libjvmci_runtime() const { return _libjvmci_runtime; } - void set_libjvmci_runtime(JVMCIRuntime* rt) { - assert((_libjvmci_runtime == nullptr && rt != nullptr) || (_libjvmci_runtime != nullptr && rt == nullptr), "must be"); - _libjvmci_runtime = rt; - } -#endif // INCLUDE_JVMCI - // Exception handling for compiled methods oop exception_oop() const; address exception_pc() const { return _exception_pc; } @@ -900,13 +794,6 @@ public: static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); } static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); } static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); } -#if INCLUDE_JVMCI - static ByteSize pending_deoptimization_offset() { return byte_offset_of(JavaThread, _pending_deoptimization); } - static ByteSize pending_monitorenter_offset() { return byte_offset_of(JavaThread, _pending_monitorenter); } - static ByteSize jvmci_alternate_call_target_offset() { return byte_offset_of(JavaThread, _jvmci._alternate_call_target); } - static ByteSize jvmci_implicit_exception_pc_offset() { return byte_offset_of(JavaThread, _jvmci._implicit_exception_pc); } - static ByteSize jvmci_counters_offset() { return byte_offset_of(JavaThread, _jvmci_counters); } -#endif // INCLUDE_JVMCI static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop); } static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc); } static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); } diff --git a/src/hotspot/share/runtime/lockStack.hpp b/src/hotspot/share/runtime/lockStack.hpp index a32364b1774..8d7e3644efa 100644 --- a/src/hotspot/share/runtime/lockStack.hpp +++ b/src/hotspot/share/runtime/lockStack.hpp @@ -42,7 +42,6 @@ class Thread; class LockStack { friend class LockStackTest; friend class VMStructs; - JVMCI_ONLY(friend class JVMCIVMStructs;) public: static const int CAPACITY = 8; private: diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 3dd61374d03..32e7208474d 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,11 +157,6 @@ Mutex* FinalImageRecipes_lock = nullptr; #endif // INCLUDE_CDS Mutex* Bootclasspath_lock = nullptr; -#if INCLUDE_JVMCI -Monitor* JVMCI_lock = nullptr; -Monitor* JVMCIRuntime_lock = nullptr; -#endif - // Only one RecursiveMutex RecursiveMutex* MultiArray_lock = nullptr; @@ -310,11 +305,6 @@ void mutex_init() { #endif // INCLUDE_CDS MUTEX_DEFN(Bootclasspath_lock , PaddedMutex , nosafepoint); -#if INCLUDE_JVMCI - // JVMCIRuntime::_lock must be acquired before JVMCI_lock to avoid deadlock - MUTEX_DEFN(JVMCIRuntime_lock , PaddedMonitor, safepoint, true); -#endif - MUTEX_DEFN(ThreadsLockThrottle_lock , PaddedMonitor, safepoint); // These locks have relative rankings, and inherit safepoint checking attributes from that rank. @@ -355,10 +345,6 @@ void mutex_init() { } #endif MUTEX_DEFL(SystemDictionary_lock , PaddedMonitor, Module_lock); -#if INCLUDE_JVMCI - // JVMCIRuntime_lock must be acquired before JVMCI_lock to avoid deadlock - MUTEX_DEFL(JVMCI_lock , PaddedMonitor, JVMCIRuntime_lock); -#endif MUTEX_DEFL(JvmtiThreadState_lock , PaddedMutex , VThreadTransition_lock); // Used by JvmtiThreadState/JvmtiEventController MUTEX_DEFL(SharedDecoder_lock , PaddedMutex , NmtVirtualMemory_lock); // Must be lower than NmtVirtualMemory_lock due to MemTracker::print_containing_region diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 682383de401..044fcb732af 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,11 +155,6 @@ extern Mutex* AOTCodeCStrings_lock; // used to guard access to the extern Monitor* ContinuationRelativize_lock; -#if INCLUDE_JVMCI -extern Monitor* JVMCI_lock; // protects global JVMCI critical sections -extern Monitor* JVMCIRuntime_lock; // protects critical sections for a specific JVMCIRuntime object -#endif - extern Mutex* Bootclasspath_lock; extern Mutex* tty_lock; // lock to synchronize output. diff --git a/src/hotspot/share/runtime/objectMonitor.hpp b/src/hotspot/share/runtime/objectMonitor.hpp index 3ab7b8ea519..848eae6df2a 100644 --- a/src/hotspot/share/runtime/objectMonitor.hpp +++ b/src/hotspot/share/runtime/objectMonitor.hpp @@ -146,7 +146,6 @@ class ObjectWaiter : public CHeapObj { class ObjectMonitor : public CHeapObj { friend class VMStructs; - JVMCI_ONLY(friend class JVMCIVMStructs;) static OopStorage* _oop_storage; diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index c883b828456..f6c7f03778b 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -173,7 +173,6 @@ public: }; class os: AllStatic { - friend class JVMCIVMStructs; friend class MallocTracker; #ifdef ASSERT diff --git a/src/hotspot/share/runtime/osThreadBase.hpp b/src/hotspot/share/runtime/osThreadBase.hpp index cf343355fc1..e7e09f6e53d 100644 --- a/src/hotspot/share/runtime/osThreadBase.hpp +++ b/src/hotspot/share/runtime/osThreadBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,6 @@ typedef int (*OSThreadStartFunc)(void*); class OSThreadBase: public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; private: volatile ThreadState _state; // Thread state *hint* diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 3d0ed5d2a23..b799063d58e 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -160,15 +160,15 @@ void SharedRuntime::generate_stubs() { generate_throw_exception(StubId::shared_throw_NullPointerException_at_call_id, CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); -#if COMPILER2_OR_JVMCI - // Vectors are generated only by C2 and JVMCI. +#ifdef COMPILER2 + // Vectors are generated only by C2. bool support_wide = is_wide_vector(MaxVectorSize); if (support_wide) { _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(StubId::shared_polling_page_vectors_safepoint_handler_id, CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception)); } -#endif // COMPILER2_OR_JVMCI +#endif // COMPILER2 _polling_page_safepoint_handler_blob = generate_handler_blob(StubId::shared_polling_page_safepoint_handler_id, CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception)); @@ -577,12 +577,6 @@ address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* curr assert(frame::verify_return_pc(return_address), "must be a return address: " INTPTR_FORMAT, p2i(return_address)); assert(current->frames_to_pop_failed_realloc() == 0 || Interpreter::contains(return_address), "missed frames to pop?"); -#if INCLUDE_JVMCI - // JVMCI's ExceptionHandlerStub expects the thread local exception PC to be clear - // and other exception handler continuations do not read it - current->set_exception_pc(nullptr); -#endif // INCLUDE_JVMCI - if (Continuation::is_return_barrier_entry(return_address)) { return StubRoutines::cont_returnBarrierExc(); } @@ -712,31 +706,6 @@ void SharedRuntime::throw_and_post_jvmti_exception(JavaThread* current, Handle h JvmtiExport::post_exception_throw(current, method(), bcp, h_exception()); } -#if INCLUDE_JVMCI - if (EnableJVMCI) { - vframeStream vfst(current, true); - methodHandle method = methodHandle(current, vfst.method()); - int bci = vfst.bci(); - MethodData* trap_mdo = method->method_data(); - if (trap_mdo != nullptr) { - // Set exception_seen if the exceptional bytecode is an invoke - Bytecode_invoke call = Bytecode_invoke_check(method, bci); - if (call.is_valid()) { - ResourceMark rm(current); - - // Lock to read ProfileData, and ensure lock is not broken by a safepoint - MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); - - ProfileData* pdata = trap_mdo->allocate_bci_to_data(bci, nullptr); - if (pdata != nullptr && pdata->is_BitData()) { - BitData* bit_data = (BitData*) pdata; - bit_data->set_exception_seen(); - } - } - } - } -#endif - Exceptions::_throw(current, __FILE__, __LINE__, h_exception); } @@ -770,21 +739,6 @@ address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, assert(nm != nullptr, "must exist"); ResourceMark rm; -#if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { - // lookup exception handler for this pc - int catch_pco = pointer_delta_as_int(ret_pc, nm->code_begin()); - ExceptionHandlerTable table(nm); - HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0); - if (t != nullptr) { - return nm->code_begin() + t->pco(); - } else { - bool make_not_entrant = true; - return Deoptimization::deoptimize_for_missing_exception_handler(nm, make_not_entrant); - } - } -#endif // INCLUDE_JVMCI - ScopeDesc* sd = nm->scope_desc_at(ret_pc); // determine handler bci, if any EXCEPTION_MARK; @@ -1039,7 +993,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* current, #ifndef PRODUCT _implicit_null_throws++; #endif - target_pc = nm->continuation_for_implicit_null_exception(pc); + target_pc = nm->continuation_for_implicit_exception(pc); // If there's an unexpected fault, target_pc might be null, // in which case we want to fall through into the normal // error handling code. @@ -1055,7 +1009,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* current, #ifndef PRODUCT _implicit_div0_throws++; #endif - target_pc = nm->continuation_for_implicit_div0_exception(pc); + target_pc = nm->continuation_for_implicit_exception(pc); // If there's an unexpected fault, target_pc might be null, // in which case we want to fall through into the normal // error handling code. @@ -1113,11 +1067,6 @@ address SharedRuntime::native_method_throw_unsatisfied_link_error_entry() { } JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* current, oopDesc* obj)) -#if INCLUDE_JVMCI - if (!obj->klass()->has_finalizer()) { - return; - } -#endif // INCLUDE_JVMCI assert(oopDesc::is_oop(obj), "must be a valid oop"); assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); InstanceKlass::register_finalizer(instanceOop(obj), CHECK); diff --git a/src/hotspot/share/runtime/stackOverflow.hpp b/src/hotspot/share/runtime/stackOverflow.hpp index 6238d3869c3..751fca8b205 100644 --- a/src/hotspot/share/runtime/stackOverflow.hpp +++ b/src/hotspot/share/runtime/stackOverflow.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ class JavaThread; // The state variables also record whether guard pages are enabled or disabled. class StackOverflow { - friend class JVMCIVMStructs; friend class JavaThread; public: // State of the stack guard pages for the containing thread. diff --git a/src/hotspot/share/runtime/stubInfo.hpp b/src/hotspot/share/runtime/stubInfo.hpp index 2fe503a8d0e..c56dbfed6a6 100644 --- a/src/hotspot/share/runtime/stubInfo.hpp +++ b/src/hotspot/share/runtime/stubInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2025, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -275,11 +275,10 @@ enum class StubId : int { // // - for shared stub entries we only need to allocate a single enum // tag for most blobs since they have only one entry. However, we need -// to bump up the index by an extra 3 (or 5 with JVMCI included) when -// we are generating the deoptimization blob because it has 4 -// (respectively, 6) entries. So, in that case we allocate a single -// enum tag identifying the index of the first entry and a max tag -// identifying the index of the last entry +// to bump up the index by an extra 3 when we are generating the +// deoptimization blob because it has 4 entries. So, in that case we +// allocate a single enum tag identifying the index of the first entry +// and a max tag identifying the index of the last entry // // - for stubgen stubs which employ an array of entries we allocate a // single enum tag identifying the index of the first entry and a max diff --git a/src/hotspot/share/runtime/stubRoutines.hpp b/src/hotspot/share/runtime/stubRoutines.hpp index 894bd47faab..fb1b47d2596 100644 --- a/src/hotspot/share/runtime/stubRoutines.hpp +++ b/src/hotspot/share/runtime/stubRoutines.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -165,9 +165,6 @@ public: // Dependencies friend class StubGenerator; friend class VMStructs; -#if INCLUDE_JVMCI - friend class JVMCIVMStructs; -#endif #include CPU_HEADER(stubRoutines) diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index bef31a70170..8ebedb79bfc 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -111,7 +111,6 @@ class Thread: public ThreadShadow { friend class VMError; friend class VMErrorCallbackMark; friend class VMStructs; - friend class JVMCIVMStructs; friend class JavaThread; private: diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp index 27c4c588429..30bea6b8167 100644 --- a/src/hotspot/share/runtime/threads.cpp +++ b/src/hotspot/share/runtime/threads.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2021, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -107,10 +107,6 @@ #include "utilities/events.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#include "jvmci/jvmciEnv.hpp" -#endif #ifdef COMPILER2 #include "opto/idealGraphPrinter.hpp" #include "runtime/hotCodeCollector.hpp" @@ -555,15 +551,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // Initialize global data structures and create system classes in heap vm_init_globals(); -#if INCLUDE_JVMCI - if (JVMCICounterSize > 0) { - JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtJVMCI); - memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); - } else { - JavaThread::_jvmci_old_thread_counters = nullptr; - } -#endif // INCLUDE_JVMCI - // Initialize OopStorage for threadObj JavaThread::_thread_oop_storage = OopStorageSet::create_strong("Thread OopStorage", mtThread); @@ -763,31 +750,9 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { MonitorDeflationThread::initialize(); // initialize compiler(s) -#if defined(COMPILER1) || COMPILER2_OR_JVMCI - bool init_compilation = true; -#if INCLUDE_JVMCI - bool force_JVMCI_initialization = false; - if (EnableJVMCI) { - // Initialize JVMCI eagerly when it is explicitly requested. - // Or when JVMCILibDumpJNIConfig or JVMCIPrintProperties is enabled. - force_JVMCI_initialization = EagerJVMCI || JVMCIPrintProperties || JVMCILibDumpJNIConfig; - if (!force_JVMCI_initialization && UseJVMCICompiler && !UseJVMCINativeLibrary && (!UseInterpreter || !BackgroundCompilation)) { - // Force initialization of jarjvmci otherwise requests for blocking - // compilations will not actually block until jarjvmci is initialized. - force_JVMCI_initialization = true; - } - if (JVMCIPrintProperties || JVMCILibDumpJNIConfig) { - // Both JVMCILibDumpJNIConfig and JVMCIPrintProperties exit the VM - // so compilation should be disabled. This prevents dumping or - // printing from happening more than once. - init_compilation = false; - } - } -#endif - if (init_compilation) { - CompileBroker::compilation_init(CHECK_JNI_ERR); - } -#endif +#if COMPILER1_OR_COMPILER2 + CompileBroker::compilation_init(CHECK_JNI_ERR); +#endif // COMPILER1_OR_COMPILER2 if (CDSConfig::is_using_aot_linked_classes()) { SystemDictionary::restore_archived_method_handle_intrinsics(); @@ -863,12 +828,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // Notify JVMTI agents that VM initialization is complete - nop if no agents. JvmtiExport::post_vm_initialized(); -#if INCLUDE_JVMCI - if (force_JVMCI_initialization) { - JVMCI::initialize_compiler_in_create_vm(CHECK_JNI_ERR); - } -#endif - JFR_ONLY(Jfr::on_create_vm_3();) #if INCLUDE_MANAGEMENT @@ -1060,12 +1019,6 @@ void Threads::destroy_vm() { // wait_until_not_protected() above. delete thread; -#if INCLUDE_JVMCI - if (JVMCICounterSize > 0) { - FREE_C_HEAP_ARRAY(JavaThread::_jvmci_old_thread_counters); - } -#endif - LogConfiguration::finalize(); } diff --git a/src/hotspot/share/runtime/vframe.hpp b/src/hotspot/share/runtime/vframe.hpp index 882b84e2b6f..c4c9926b2f8 100644 --- a/src/hotspot/share/runtime/vframe.hpp +++ b/src/hotspot/share/runtime/vframe.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -289,8 +289,6 @@ class vframeStreamCommon : StackObj { int bci() const { return _bci; } inline intptr_t* frame_id() const; address frame_pc() const { return _frame.pc(); } - inline int vframe_id() const; - inline int decode_offset() const; inline oop continuation() const; CodeBlob* cb() const { return _frame.cb(); } diff --git a/src/hotspot/share/runtime/vframe.inline.hpp b/src/hotspot/share/runtime/vframe.inline.hpp index 6bd83e7f7c9..b3e7b2800c5 100644 --- a/src/hotspot/share/runtime/vframe.inline.hpp +++ b/src/hotspot/share/runtime/vframe.inline.hpp @@ -62,16 +62,6 @@ inline intptr_t* vframeStreamCommon::frame_id() const { return _frame.id(); } -inline int vframeStreamCommon::vframe_id() const { - assert(_mode == compiled_mode, "unexpected mode: %d", _mode); - return _vframe_id; -} - -inline int vframeStreamCommon::decode_offset() const { - assert(_mode == compiled_mode, "unexpected mode: %d", _mode); - return _decode_offset; -} - inline bool vframeStreamCommon::is_interpreted_frame() const { return _frame.is_interpreted_frame(); } inline void vframeStreamCommon::next() { diff --git a/src/hotspot/share/runtime/vframeArray.cpp b/src/hotspot/share/runtime/vframeArray.cpp index 9f1c082ed8f..6810d7bb8d3 100644 --- a/src/hotspot/share/runtime/vframeArray.cpp +++ b/src/hotspot/share/runtime/vframeArray.cpp @@ -63,9 +63,6 @@ void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) { _method = vf->method(); _bci = vf->raw_bci(); _reexecute = vf->should_reexecute(); // initial value, updated in unpack_on_stack -#if INCLUDE_JVMCI - _rethrow = vf->scope()->rethrow_exception(); -#endif #ifdef ASSERT _removed_monitors = false; #endif diff --git a/src/hotspot/share/runtime/vframeArray.hpp b/src/hotspot/share/runtime/vframeArray.hpp index d7390bedff4..0545e33561d 100644 --- a/src/hotspot/share/runtime/vframeArray.hpp +++ b/src/hotspot/share/runtime/vframeArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,9 +56,6 @@ class vframeArrayElement { frame _frame; // the interpreter frame we will unpack into int _bci; // raw bci for this vframe bool _reexecute; // whether we should reexecute this bytecode -#if INCLUDE_JVMCI - bool _rethrow; // from ScopeDesc::rethrow_exception() -#endif Method* _method; // the method for this vframe MonitorChunk* _monitors; // active monitors for this vframe StackValueCollection* _locals; @@ -76,9 +73,6 @@ class vframeArrayElement { int raw_bci(void) const { return _bci; } bool should_reexecute(bool is_top_frame, int exec_mode) const; bool should_reexecute(void) const { return _reexecute; } -#if INCLUDE_JVMCI - bool rethrow_exception(void) const { return _rethrow; } -#endif Method* method(void) const { return _method; } diff --git a/src/hotspot/share/runtime/vmOperation.hpp b/src/hotspot/share/runtime/vmOperation.hpp index 6078600c16e..e22d11cf1a8 100644 --- a/src/hotspot/share/runtime/vmOperation.hpp +++ b/src/hotspot/share/runtime/vmOperation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,6 @@ template(Exit) \ template(LinuxDllLoad) \ template(WhiteBoxOperation) \ - template(JVMCIResizeCounters) \ template(ClassLoaderStatsOperation) \ template(ClassLoaderHierarchyOperation) \ template(DumpHashtable) \ @@ -110,9 +109,8 @@ template(GTestStopSafepoint) \ template(JFROldObject) \ template(RendezvousGCThreads) \ - template(JFRInitializeCPUTimeSampler) \ - template(JFRTerminateCPUTimeSampler) \ - template(ReinitializeMDO) + template(JFRInitializeCPUTimeSampler) \ + template(JFRTerminateCPUTimeSampler) \ class Thread; class outputStream; diff --git a/src/hotspot/share/runtime/vmOperations.cpp b/src/hotspot/share/runtime/vmOperations.cpp index c4a77ce3275..90666245c5e 100644 --- a/src/hotspot/share/runtime/vmOperations.cpp +++ b/src/hotspot/share/runtime/vmOperations.cpp @@ -509,20 +509,7 @@ int VM_Exit::wait_for_threads_in_native_to_block() { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { num_active++; if (thr->is_Compiler_thread()) { -#if INCLUDE_JVMCI - CompilerThread* ct = (CompilerThread*) thr; - if (ct->compiler() == nullptr || !ct->compiler()->is_jvmci()) { - num_active_compiler_thread++; - } else { - // A JVMCI compiler thread never accesses VM data structures - // while in _thread_in_native state so there's no need to wait - // for it and potentially add a 300 millisecond delay to VM - // shutdown. - num_active--; - } -#else num_active_compiler_thread++; -#endif } } } diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 6ae9de05518..856ff947dc4 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -235,7 +235,7 @@ nonstatic_field(MethodData, _method, Method*) \ nonstatic_field(MethodCounters, _invoke_mask, int) \ nonstatic_field(MethodCounters, _backedge_mask, int) \ - COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count, u2)) \ + COMPILER2_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count, u2)) \ JVMTI_ONLY(nonstatic_field(MethodCounters, _number_of_breakpoints, u2)) \ nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \ nonstatic_field(MethodCounters, _backedge_counter, InvocationCounter) \ @@ -1017,7 +1017,7 @@ declare_type(StringDedupThread, JavaThread) \ declare_type(AttachListenerThread, JavaThread) \ declare_type(JfrRecorderThread, JavaThread) \ - DEBUG_ONLY(COMPILER2_OR_JVMCI_PRESENT( \ + DEBUG_ONLY(COMPILER2_PRESENT( \ declare_type(DeoptimizeObjectsALotThread, JavaThread))) \ declare_toplevel_type(OSThread) \ declare_toplevel_type(JavaFrameAnchor) \ @@ -1577,9 +1577,6 @@ declare_constant(Deoptimization::Reason_unstable_fused_if) \ declare_constant(Deoptimization::Reason_receiver_constraint) \ declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \ - NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_transfer_to_interpreter))) \ - NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_unresolved))) \ - NOT_ZERO(JVMCI_ONLY(declare_constant(Deoptimization::Reason_jsr_mismatch))) \ declare_constant(Deoptimization::Reason_tenured) \ declare_constant(Deoptimization::Reason_LIMIT) \ declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ @@ -1598,10 +1595,8 @@ \ declare_constant(Deoptimization::_action_bits) \ declare_constant(Deoptimization::_reason_bits) \ - declare_constant(Deoptimization::_debug_id_bits) \ declare_constant(Deoptimization::_action_shift) \ declare_constant(Deoptimization::_reason_shift) \ - declare_constant(Deoptimization::_debug_id_shift) \ \ /******************************************/ \ /* BasicType enum (globalDefinitions.hpp) */ \ @@ -1759,12 +1754,6 @@ declare_constant(PerfData::U_Hertz) \ \ /****************/ \ - /* JVMCI */ \ - /****************/ \ - \ - declare_preprocessor_constant("INCLUDE_JVMCI", INCLUDE_JVMCI) \ - \ - /****************/ \ /* VMRegImpl */ \ /****************/ \ declare_constant(VMRegImpl::stack_slot_size) \ diff --git a/src/hotspot/share/utilities/exceptions.hpp b/src/hotspot/share/utilities/exceptions.hpp index 0299dedf2e6..b9e544b28d7 100644 --- a/src/hotspot/share/utilities/exceptions.hpp +++ b/src/hotspot/share/utilities/exceptions.hpp @@ -61,7 +61,6 @@ class methodHandle; class ThreadShadow: public CHeapObj { friend class VMStructs; - friend class JVMCIVMStructs; protected: oop _pending_exception; // Thread has gc actions. diff --git a/src/hotspot/share/utilities/macros.hpp b/src/hotspot/share/utilities/macros.hpp index 3621f675ecb..09b67a131b7 100644 --- a/src/hotspot/share/utilities/macros.hpp +++ b/src/hotspot/share/utilities/macros.hpp @@ -265,20 +265,6 @@ #define NOT_JFR_RETURN_(code) { return code; } #endif -#ifndef INCLUDE_JVMCI -#define INCLUDE_JVMCI 1 -#endif - -#if INCLUDE_JVMCI -#define JVMCI_ONLY(code) code -#define NOT_JVMCI(code) -#define NOT_JVMCI_RETURN /* next token must be ; */ -#else -#define JVMCI_ONLY(code) -#define NOT_JVMCI(code) code -#define NOT_JVMCI_RETURN {} -#endif // INCLUDE_JVMCI - // COMPILER1 variant #ifdef COMPILER1 #define COMPILER1_PRESENT(code) code @@ -297,21 +283,6 @@ #define NOT_COMPILER2(code) code #endif // COMPILER2 -// COMPILER2 or JVMCI -#if defined(COMPILER2) || INCLUDE_JVMCI -#define COMPILER2_OR_JVMCI 1 -#define COMPILER2_OR_JVMCI_PRESENT(code) code -#define NOT_COMPILER2_OR_JVMCI(code) -#define NOT_COMPILER2_OR_JVMCI_RETURN /* next token must be ; */ -#define NOT_COMPILER2_OR_JVMCI_RETURN_(code) /* next token must be ; */ -#else -#define COMPILER2_OR_JVMCI 0 -#define COMPILER2_OR_JVMCI_PRESENT(code) -#define NOT_COMPILER2_OR_JVMCI(code) code -#define NOT_COMPILER2_OR_JVMCI_RETURN {} -#define NOT_COMPILER2_OR_JVMCI_RETURN_(code) { return code; } -#endif - // COMPILER1 and COMPILER2 #if defined(COMPILER1) && defined(COMPILER2) #define COMPILER1_AND_COMPILER2 1 diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 1cecdc0cb33..045fcc23d63 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -73,9 +73,6 @@ #if INCLUDE_JFR #include "jfr/jfr.hpp" #endif -#if INCLUDE_JVMCI -#include "jvmci/jvmci.hpp" -#endif #ifndef PRODUCT #include @@ -519,19 +516,13 @@ static void report_vm_version(outputStream* st, char* buf, int buflen) { buf, jdk_debug_level, runtime_version); // This is the long version with some default settings added - st->print_cr("# Java VM: %s%s%s (%s%s, %s%s%s%s%s%s, %s, %s)", + st->print_cr("# Java VM: %s%s%s (%s%s, %s%s%s%s, %s, %s)", VM_Version::vm_name(), (*vendor_version != '\0') ? " " : "", vendor_version, jdk_debug_level, VM_Version::vm_release(), VM_Version::vm_info_string(), TieredCompilation ? ", tiered" : "", -#if INCLUDE_JVMCI - EnableJVMCI ? ", jvmci" : "", - UseJVMCICompiler ? ", jvmci compiler" : "", -#else - "", "", -#endif UseCompressedOops ? ", compressed oops" : "", UseCompactObjectHeaders ? ", compact obj headers" : "", GCConfig::hs_err_name(), @@ -1937,13 +1928,6 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt } } -#if INCLUDE_JVMCI - if (JVMCI::fatal_log_filename() != nullptr) { - out.print_raw("#\n# The JVMCI shared library error report file is saved as:\n# "); - out.print_raw_cr(JVMCI::fatal_log_filename()); - } -#endif - static bool skip_bug_url = !should_submit_bug_report(_id); if (!skip_bug_url) { skip_bug_url = true; diff --git a/src/java.base/share/classes/jdk/internal/vm/TranslatedException.java b/src/java.base/share/classes/jdk/internal/vm/TranslatedException.java deleted file mode 100644 index 366766711f8..00000000000 --- a/src/java.base/share/classes/jdk/internal/vm/TranslatedException.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm; - -import jdk.internal.misc.VM; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * Support for translating exceptions between the HotSpot heap and libjvmci heap. - * - * Successfully translated exceptions are wrapped in a TranslatedException instance. - * This allows callers to distiguish between a translated exception and an error - * that arose during translation. - */ -@SuppressWarnings("serial") -public final class TranslatedException extends Exception { - - /** - * The value returned by {@link #encodeThrowable(Throwable)} when encoding - * fails due to an {@link OutOfMemoryError}. - */ - private static final byte[] FALLBACK_ENCODED_OUTOFMEMORYERROR_BYTES; - - /** - * The value returned by {@link #encodeThrowable(Throwable)} when encoding - * fails for any reason other than {@link OutOfMemoryError}. - */ - private static final byte[] FALLBACK_ENCODED_THROWABLE_BYTES; - static { - maybeFailClinit(); - try { - FALLBACK_ENCODED_THROWABLE_BYTES = - encodeThrowable(translationFailure("error during encoding"), false); - FALLBACK_ENCODED_OUTOFMEMORYERROR_BYTES = - encodeThrowable(translationFailure("OutOfMemoryError during encoding"), false); - } catch (IOException e) { - throw new InternalError(e); - } - } - - private static InternalError translationFailure(String messageFormat, Object... messageArgs) { - return new InternalError(messageFormat.formatted(messageArgs)); - } - - /** - * Helper to test exception translation. - */ - private static void maybeFailClinit() { - String className = VM.getSavedProperty("test.jvmci.TranslatedException.clinit.throw"); - if (className != null) { - try { - throw (Throwable) Class.forName(className).getDeclaredConstructor().newInstance(); - } catch (RuntimeException | Error e) { - throw e; - } catch (Throwable e) { - throw new InternalError(e); - } - } - } - - TranslatedException(Throwable translated) { - super(translated); - } - - /** - * No need to record an initial stack trace since - * it will be manually overwritten. - */ - @SuppressWarnings("sync-override") - @Override - public Throwable fillInStackTrace() { - return this; - } - - /** - * Prints a stack trace for {@code throwable} if the system property - * {@code "jdk.internal.vm.TranslatedException.debug"} is true. - */ - private static void debugPrintStackTrace(Throwable throwable, boolean debug) { - if (debug) { - System.err.print("DEBUG: "); - throwable.printStackTrace(); - } - } - - private static Throwable initCause(Throwable throwable, Throwable cause, boolean debug) { - if (cause != null) { - try { - throwable.initCause(cause); - } catch (IllegalStateException e) { - // Cause could not be set or overwritten. - debugPrintStackTrace(e, debug); - } - } - return throwable; - } - - private static Throwable create(String className, String message, Throwable cause, boolean debug) { - // Try create with reflection first. - try { - Class cls = Class.forName(className); - if (cause != null) { - // Handle known exception types whose cause must - // be set in the constructor - if (cls == InvocationTargetException.class) { - return new InvocationTargetException(cause, message); - } - if (cls == ExceptionInInitializerError.class) { - return new ExceptionInInitializerError(cause); - } - } - if (message == null) { - Constructor cons = cls.getConstructor(); - return initCause((Throwable) cons.newInstance(), cause, debug); - } - Constructor cons = cls.getDeclaredConstructor(String.class); - return initCause((Throwable) cons.newInstance(message), cause, debug); - } catch (Throwable translationFailure) { - debugPrintStackTrace(translationFailure, debug); - return initCause(translationFailure("%s [%s]", message, className), cause, debug); - } - } - - private static String emptyIfNull(String value) { - return value == null ? "" : value; - } - - private static String emptyAsNull(String value) { - return value.isEmpty() ? null : value; - } - - /** - * Encodes {@code throwable} including its stack and causes as a {@linkplain GZIPOutputStream - * compressed} byte array that can be decoded by {@link #decodeThrowable}. - */ - static byte[] encodeThrowable(Throwable throwable) { - try { - return encodeThrowable(throwable, true); - } catch (OutOfMemoryError e) { - return FALLBACK_ENCODED_OUTOFMEMORYERROR_BYTES; - } catch (Throwable e) { - return FALLBACK_ENCODED_THROWABLE_BYTES; - } - } - - private static byte[] encodeThrowable(Throwable throwable, - boolean withCauseAndStack) throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (DataOutputStream dos = new DataOutputStream(new GZIPOutputStream(baos))) { - List throwables = new ArrayList<>(); - for (Throwable current = throwable; current != null; current = current.getCause()) { - throwables.add(current); - if (!withCauseAndStack) { - break; - } - } - - // Encode from inner most cause outwards - Collections.reverse(throwables); - - for (Throwable current : throwables) { - dos.writeUTF(current.getClass().getName()); - dos.writeUTF(emptyIfNull(current.getMessage())); - StackTraceElement[] stackTrace = withCauseAndStack ? current.getStackTrace() : null; - if (stackTrace == null) { - stackTrace = new StackTraceElement[0]; - } - dos.writeInt(stackTrace.length); - for (int i = 0; i < stackTrace.length; i++) { - StackTraceElement frame = stackTrace[i]; - if (frame != null) { - dos.writeUTF(emptyIfNull(frame.getClassLoaderName())); - dos.writeUTF(emptyIfNull(frame.getModuleName())); - dos.writeUTF(emptyIfNull(frame.getModuleVersion())); - dos.writeUTF(emptyIfNull(frame.getClassName())); - dos.writeUTF(emptyIfNull(frame.getMethodName())); - dos.writeUTF(emptyIfNull(frame.getFileName())); - dos.writeInt(frame.getLineNumber()); - } - } - } - } - return baos.toByteArray(); - } - - /** - * Gets the stack of the current thread as of the first native method. The chopped - * frames are for the VM call to {@link VMSupport#decodeAndThrowThrowable}. - */ - private static StackTraceElement[] getMyStackTrace() { - Exception ex = new Exception(); - StackTraceElement[] stack = ex.getStackTrace(); - for (int i = 0; i < stack.length; i++) { - StackTraceElement e = stack[i]; - if (e.isNativeMethod()) { - return Arrays.copyOfRange(stack, i, stack.length); - } - } - // This should never happen but since this is exception handling - // code, be defensive instead raising a nested exception. - return new StackTraceElement[0]; - } - - /** - * Decodes {@code encodedThrowable} into a {@link TranslatedException}. - * - * @param encodedThrowable an encoded exception in the format specified by - * {@link #encodeThrowable} - */ - static Throwable decodeThrowable(byte[] encodedThrowable, boolean debug) { - ByteArrayInputStream bais = new ByteArrayInputStream(encodedThrowable); - try (DataInputStream dis = new DataInputStream(new GZIPInputStream(bais))) { - Throwable cause = null; - Throwable throwable = null; - StackTraceElement[] myStack = getMyStackTrace(); - while (dis.available() != 0) { - String exceptionClassName = dis.readUTF(); - String exceptionMessage = emptyAsNull(dis.readUTF()); - throwable = create(exceptionClassName, exceptionMessage, cause, debug); - int stackTraceDepth = dis.readInt(); - StackTraceElement[] stackTrace = new StackTraceElement[stackTraceDepth + myStack.length]; - int stackTraceIndex = 0; - int myStackIndex = 0; - for (int j = 0; j < stackTraceDepth; j++) { - String classLoaderName = emptyAsNull(dis.readUTF()); - String moduleName = emptyAsNull(dis.readUTF()); - String moduleVersion = emptyAsNull(dis.readUTF()); - String className = emptyAsNull(dis.readUTF()); - String methodName = emptyAsNull(dis.readUTF()); - String fileName = emptyAsNull(dis.readUTF()); - int lineNumber = dis.readInt(); - StackTraceElement ste = new StackTraceElement(classLoaderName, - moduleName, - moduleVersion, - className, - methodName, - fileName, - lineNumber); - - if (ste.isNativeMethod()) { - // Best effort attempt to weave stack traces from two heaps into - // a single stack trace using native method frames as stitching points. - // This is not 100% reliable as there's no guarantee that native method - // frames only exist for calls between HotSpot and libjvmci. - while (myStackIndex < myStack.length) { - StackTraceElement suffixSTE = myStack[myStackIndex++]; - if (suffixSTE.isNativeMethod()) { - break; - } - stackTrace[stackTraceIndex++] = suffixSTE; - } - } - stackTrace[stackTraceIndex++] = ste; - } - while (myStackIndex < myStack.length) { - stackTrace[stackTraceIndex++] = myStack[myStackIndex++]; - } - if (stackTraceIndex != stackTrace.length) { - // Remove null entries at end of stackTrace - stackTrace = Arrays.copyOf(stackTrace, stackTraceIndex); - } - throwable.setStackTrace(stackTrace); - cause = throwable; - } - return new TranslatedException(throwable); - } catch (Throwable translationFailure) { - debugPrintStackTrace(translationFailure, debug); - return translationFailure("error decoding exception: %s", encodedThrowable); - } - } -} diff --git a/src/java.base/share/classes/jdk/internal/vm/VMSupport.java b/src/java.base/share/classes/jdk/internal/vm/VMSupport.java index 32c358340af..ef536f14e89 100644 --- a/src/java.base/share/classes/jdk/internal/vm/VMSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/VMSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,36 +24,18 @@ */ package jdk.internal.vm; -import jdk.internal.misc.Unsafe; -import jdk.internal.misc.VM; import jdk.internal.access.SharedSecrets; -import jdk.internal.access.JavaLangAccess; -import jdk.internal.reflect.ConstantPool; -import sun.reflect.annotation.AnnotationParser; -import sun.reflect.annotation.AnnotationSupport; -import sun.reflect.annotation.AnnotationType; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; -import java.lang.annotation.Annotation; -import java.lang.annotation.IncompleteAnnotationException; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.List; /* - * Support class used by JVMCI, JVMTI and VM attach mechanism. + * Support class used by JVMTI and VM attach mechanism. */ public class VMSupport { - private static final Unsafe U = Unsafe.getUnsafe(); private static Properties agentProps = null; /** @@ -116,476 +98,4 @@ public class VMSupport { * variables such as java.io.tmpdir. */ public static native String getVMTemporaryDirectory(); - - /** - * Decodes the exception described by {@code format} and {@code buffer} and throws it. - * - * @param format specifies how to interpret {@code buffer}: - *
-     *             0: {@code buffer} was created by {@link #encodeThrowable}
-     *             1: native memory for {@code buffer} could not be allocated
-     *             2: an OutOfMemoryError was thrown while encoding the exception
-     *             3: some other problem occured while encoding the exception. If {@code buffer != 0},
-     *                it contains a {@code struct { u4 len; char[len] desc}} where {@code desc} describes the problem
-     *             4: an OutOfMemoryError thrown from within VM code on a
-     *                thread that cannot call Java (OOME has no stack trace)
-     *            
- * @param buffer encoded info about the exception to throw (depends on {@code format}) - * @param inJVMHeap [@code true} if executing in the JVM heap, {@code false} otherwise - * @param debug specifies whether debug stack traces should be enabled in case of translation failure - */ - public static void decodeAndThrowThrowable(int format, long buffer, boolean inJVMHeap, boolean debug) throws Throwable { - if (format != 0) { - if (format == 4) { - throw new TranslatedException(new OutOfMemoryError("in VM code and current thread cannot call Java")); - } - String context = String.format("while encoding an exception to translate it %s the JVM heap", - inJVMHeap ? "to" : "from"); - if (format == 1) { - throw new InternalError("native buffer could not be allocated " + context); - } - if (format == 2) { - throw new OutOfMemoryError(context); - } - if (format == 3 && buffer != 0L) { - byte[] bytes = bufferToBytes(buffer); - throw new InternalError("unexpected problem occurred " + context + ": " + new String(bytes, StandardCharsets.UTF_8)); - } - throw new InternalError("unexpected problem occurred " + context); - } - throw TranslatedException.decodeThrowable(bufferToBytes(buffer), debug); - } - - private static byte[] bufferToBytes(long buffer) { - if (buffer == 0) { - return null; - } - int len = U.getInt(buffer); - byte[] bytes = new byte[len]; - U.copyMemory(null, buffer + 4, bytes, Unsafe.ARRAY_BYTE_BASE_OFFSET, len); - return bytes; - } - - /** - * If {@code bufferSize} is large enough, encodes {@code throwable} into a byte array and writes - * it to {@code buffer}. The encoding in {@code buffer} can be decoded by - * {@link #decodeAndThrowThrowable}. - * - * @param throwable the exception to encode - * @param buffer a native byte buffer - * @param bufferSize the size of {@code buffer} in bytes - * @return the number of bytes written into {@code buffer} if {@code bufferSize} is large - * enough, otherwise {@code -N} where {@code N} is the value {@code bufferSize} needs to - * be to fit the encoding - */ - public static int encodeThrowable(Throwable throwable, long buffer, int bufferSize) { - byte[] encoding = TranslatedException.encodeThrowable(throwable); - int requiredSize = 4 + encoding.length; - if (bufferSize < requiredSize) { - return -requiredSize; - } - U.putInt(buffer, encoding.length); - U.copyMemory(encoding, Unsafe.ARRAY_BYTE_BASE_OFFSET, null, buffer + 4, encoding.length); - return requiredSize; - } - - /** - * Parses {@code rawAnnotations} into a list of {@link Annotation}s and then - * serializes them to a byte array with {@link #encodeAnnotations(Collection)}. - */ - public static byte[] encodeAnnotations(byte[] rawAnnotations, - Class declaringClass, - ConstantPool cp, - boolean forClass, - Class[] selectAnnotationClasses) - { - for (Class c : selectAnnotationClasses) { - if (!c.isAnnotation()) { - throw new IllegalArgumentException(c + " is not an annotation interface"); - } - } - Map, Annotation> annotations = - AnnotationParser.parseSelectAnnotations(rawAnnotations, cp, declaringClass, selectAnnotationClasses); - if (forClass && annotations.size() != selectAnnotationClasses.length) { - Class superClass = declaringClass.getSuperclass(); - nextSuperClass: - while (superClass != null) { - JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); - Map, Annotation> superAnnotations = - AnnotationParser.parseSelectAnnotations( - jla.getRawClassAnnotations(superClass), - jla.getConstantPool(superClass), - superClass, - selectAnnotationClasses); - - for (Map.Entry, Annotation> e : superAnnotations.entrySet()) { - Class annotationClass = e.getKey(); - if (!annotations.containsKey(annotationClass) && AnnotationType.getInstance(annotationClass).isInherited()) { - if (annotations.isEmpty()) { - // An empty map might be unmodifiable (e.g. Collections.emptyMap()). - annotations = new LinkedHashMap, Annotation>(); - } - annotations.put(annotationClass, e.getValue()); - if (annotations.size() == selectAnnotationClasses.length) { - break nextSuperClass; - } - } - } - superClass = superClass.getSuperclass(); - } - } - return encodeAnnotations(annotations.values()); - } - - /** - * Encodes annotations to a byte array. The byte array can be decoded with {@link #decodeAnnotations(byte[], AnnotationDecoder)}. - */ - public static byte[] encodeAnnotations(Collection annotations) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(128); - try (DataOutputStream dos = new DataOutputStream(baos)) { - writeLength(dos, annotations.size()); - for (Annotation a : annotations) { - encodeAnnotation(dos, a); - } - } - return baos.toByteArray(); - } catch (Exception e) { - throw new InternalError(e); - } - } - - private static void encodeAnnotation(DataOutputStream dos, Annotation a) throws Exception { - Class type = a.annotationType(); - Map values = AnnotationSupport.memberValues(a); - dos.writeUTF(type.getName()); - writeLength(dos, values.size()); - for (Map.Entry e : values.entrySet()) { - Object value = e.getValue(); - if (value == null) { - // IncompleteAnnotationException - dos.writeByte('x'); - dos.writeUTF(new IncompleteAnnotationException(type, e.getKey()).toString()); - continue; - } - Class valueType = value.getClass(); - dos.writeUTF(e.getKey()); - if (valueType == Byte.class) { - dos.writeByte('B'); - dos.writeByte((byte) value); - } else if (valueType == Character.class) { - dos.writeByte('C'); - dos.writeChar((char) value); - } else if (valueType == Double.class) { - dos.writeByte('D'); - dos.writeDouble((double) value); - } else if (valueType == Float.class) { - dos.writeByte('F'); - dos.writeFloat((float) value); - } else if (valueType == Integer.class) { - dos.writeByte('I'); - dos.writeInt((int) value); - } else if (valueType == Long.class) { - dos.writeByte('J'); - dos.writeLong((long) value); - } else if (valueType == Short.class) { - dos.writeByte('S'); - dos.writeShort((short) value); - } else if (valueType == Boolean.class) { - dos.writeByte('Z'); - dos.writeBoolean((boolean) value); - } else if (valueType == String.class) { - dos.writeByte('s'); - dos.writeUTF((String) value); - } else if (valueType == Class.class) { - dos.writeByte('c'); - dos.writeUTF(((Class) value).getName()); - } else if (valueType.isEnum()) { - dos.writeByte('e'); - dos.writeUTF(valueType.getName()); - dos.writeUTF(((Enum) value).name()); - } else if (value instanceof Annotation) { - dos.writeByte('@'); - encodeAnnotation(dos, (Annotation) value); - } else if (valueType.isArray()) { - Class componentType = valueType.getComponentType(); - if (componentType == byte.class) { - byte[] array = (byte[]) value; - dos.writeByte('['); - dos.writeByte('B'); - writeLength(dos, array.length); - dos.write(array); - } else if (componentType == char.class) { - char[] array = (char[]) value; - dos.writeByte('['); - dos.writeByte('C'); - writeLength(dos, array.length); - for (char c : array) { - dos.writeChar(c); - } - } else if (componentType == double.class) { - double[] array = (double[]) value; - dos.writeByte('['); - dos.writeByte('D'); - writeLength(dos, array.length); - for (double v : array) { - dos.writeDouble(v); - } - } else if (componentType == float.class) { - float[] array = (float[]) value; - dos.writeByte('['); - dos.writeByte('F'); - writeLength(dos, array.length); - for (float v : array) { - dos.writeFloat(v); - } - } else if (componentType == int.class) { - int[] array = (int[]) value; - dos.writeByte('['); - dos.writeByte('I'); - writeLength(dos, array.length); - for (int j : array) { - dos.writeInt(j); - } - } else if (componentType == long.class) { - long[] array = (long[]) value; - dos.writeByte('['); - dos.writeByte('J'); - writeLength(dos, array.length); - for (long l : array) { - dos.writeLong(l); - } - } else if (componentType == short.class) { - short[] array = (short[]) value; - dos.writeByte('['); - dos.writeByte('S'); - writeLength(dos, array.length); - for (short item : array) { - dos.writeShort(item); - } - } else if (componentType == boolean.class) { - boolean[] array = (boolean[]) value; - dos.writeByte('['); - dos.writeByte('Z'); - writeLength(dos, array.length); - for (boolean b : array) { - dos.writeBoolean(b); - } - } else if (componentType == String.class) { - String[] array = (String[]) value; - dos.writeByte('['); - dos.writeByte('s'); - writeLength(dos, array.length); - for (String s : array) { - dos.writeUTF(s); - } - } else if (componentType == Class.class) { - Class[] array = (Class[]) value; - dos.writeByte('['); - dos.writeByte('c'); - writeLength(dos, array.length); - for (Class aClass : array) { - dos.writeUTF(aClass.getName()); - } - } else if (componentType.isEnum()) { - Enum[] array = (Enum[]) value; - dos.writeByte('['); - dos.writeByte('e'); - dos.writeUTF(componentType.getName()); - writeLength(dos, array.length); - for (Enum anEnum : array) { - dos.writeUTF(anEnum.name()); - } - } else if (componentType.isAnnotation()) { - Annotation[] array = (Annotation[]) value; - dos.writeByte('['); - dos.writeByte('@'); - writeLength(dos, array.length); - for (Annotation annotation : array) { - encodeAnnotation(dos, annotation); - } - } else { - dos.writeByte('x'); - dos.writeUTF(value.toString()); - } - - } else { - dos.writeByte('x'); - dos.writeUTF(value.toString()); - } - } - } - - /** - * Helper for {@link #decodeAnnotations(byte[], AnnotationDecoder)} to convert a byte - * array (ostensibly produced by {@link VMSupport#encodeAnnotations}) into objects. - * - * @param type to which a type name is {@linkplain #resolveType(String) resolved} - * @param type of the object representing a decoded annotation - * @param type of the object representing a decoded enum constant - * @param type of the object representing a decoded error - */ - public interface AnnotationDecoder { - /** - * Resolves a name in {@link Class#getName()} format to an object of type {@code T}. - */ - T resolveType(String name); - - /** - * Creates an object representing a decoded annotation. - * - * @param type the annotation interface of the annotation - * @param elements elements of the annotation - */ - A newAnnotation(T type, Map.Entry[] elements); - - /** - * Creates an object representing a decoded enum constant. - * - * @param enumType the enum type - * @param name the name of the enum constant - */ - E newEnumValue(T enumType, String name); - - /** - * Creates an object representing a decoded error value. - * - * @param description of the error - */ - X newErrorValue(String description); - } - - /** - * Decodes annotations serialized in {@code encoded} to objects. - * - * @param type to which a type name is resolved - * @param type of the object representing a decoded annotation - * @param type of the object representing a decoded enum constant - * @param type of the object representing a decoded error - * @return an immutable list of {@code A} objects - */ - @SuppressWarnings("unchecked") - public static List decodeAnnotations(byte[] encoded, AnnotationDecoder decoder) { - try { - ByteArrayInputStream bais = new ByteArrayInputStream(encoded); - DataInputStream dis = new DataInputStream(bais); - return (List) readArray(dis, () -> decodeAnnotation(dis, decoder)); - } catch (Exception e) { - throw new InternalError(e); - } - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private static A decodeAnnotation(DataInputStream dis, AnnotationDecoder decoder) throws IOException { - String typeName = dis.readUTF(); - T type = decoder.resolveType(typeName); - int n = readLength(dis); - Map.Entry[] elements = new Map.Entry[n]; - for (int i = 0; i < n; i++) { - String name = dis.readUTF(); - byte tag = dis.readByte(); - elements[i] = Map.entry(name, switch (tag) { - case 'B' -> dis.readByte(); - case 'C' -> dis.readChar(); - case 'D' -> dis.readDouble(); - case 'F' -> dis.readFloat(); - case 'I' -> dis.readInt(); - case 'J' -> dis.readLong(); - case 'S' -> dis.readShort(); - case 'Z' -> dis.readBoolean(); - case 's' -> dis.readUTF(); - case 'c' -> decoder.resolveType(dis.readUTF()); - case 'e' -> decoder.newEnumValue(decoder.resolveType(dis.readUTF()), dis.readUTF()); - case '@' -> decodeAnnotation(dis, decoder); - case '[' -> decodeArray(dis, decoder); - case 'x' -> decoder.newErrorValue(dis.readUTF()); - default -> throw new InternalError("Unsupported tag: " + tag); - }); - } - return decoder.newAnnotation(type, (Map.Entry[]) elements); - } - @FunctionalInterface - interface IOReader { - Object read() throws IOException; - } - - private static Object decodeArray(DataInputStream dis, AnnotationDecoder decoder) throws IOException { - byte componentTag = dis.readByte(); - return switch (componentTag) { - case 'B' -> readArray(dis, dis::readByte); - case 'C' -> readArray(dis, dis::readChar); - case 'D' -> readArray(dis, dis::readDouble); - case 'F' -> readArray(dis, dis::readFloat); - case 'I' -> readArray(dis, dis::readInt); - case 'J' -> readArray(dis, dis::readLong); - case 'S' -> readArray(dis, dis::readShort); - case 'Z' -> readArray(dis, dis::readBoolean); - case 's' -> readArray(dis, dis::readUTF); - case 'c' -> readArray(dis, () -> readClass(dis, decoder)); - case 'e' -> { - T enumType = decoder.resolveType(dis.readUTF()); - yield readArray(dis, () -> readEnum(dis, decoder, enumType)); - } - case '@' -> readArray(dis, () -> decodeAnnotation(dis, decoder)); - default -> throw new InternalError("Unsupported component tag: " + componentTag); - }; - } - - /** - * Reads an enum encoded at the current read position of {@code dis} and - * returns it as an object of type {@code E}. - */ - private static E readEnum(DataInputStream dis, AnnotationDecoder decoder, T enumType) throws IOException { - return decoder.newEnumValue(enumType, dis.readUTF()); - } - - /** - * Reads a class encoded at the current read position of {@code dis} and - * returns it as an object of type {@code T}. - */ - private static T readClass(DataInputStream dis, AnnotationDecoder decoder) throws IOException { - return decoder.resolveType(dis.readUTF()); - } - - /** - * Reads an array encoded at the current read position of {@code dis} and - * returns it in an immutable list. - * - * @param reader reads array elements from {@code dis} - * @return an immutable list of {@code A} objects - */ - private static List readArray(DataInputStream dis, IOReader reader) throws IOException { - Object[] array = new Object[readLength(dis)]; - for (int i = 0; i < array.length; i++) { - array[i] = reader.read(); - } - return List.of(array); - } - - /** - * Encodes {@code length} in 1 byte if it is less than 128. - */ - private static void writeLength(DataOutputStream dos, int length) throws IOException { - if (length < 0) { - throw new NegativeArraySizeException(); - } else if (length <= 127) { - dos.writeByte((byte) (0x80 | length)); - } else { - dos.writeInt(length); - } - } - - private static int readLength(DataInputStream dis) throws IOException { - int ch1 = dis.readByte(); - int length; - if (ch1 < 0) { - length = ch1 & 0x7F; - } else { - int ch2 = dis.read(); - int ch3 = dis.read(); - int ch4 = dis.read(); - length = (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0); - } - return length; - } } diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 2bd5cce612b..32afbc11100 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -212,9 +212,7 @@ module java.base { jdk.jfr, jdk.jshell, jdk.nio.mapmode, - jdk.unsupported, - jdk.internal.vm.ci, - jdk.graal.compiler; + jdk.unsupported; exports jdk.internal.module to java.instrument, java.management.rmi, @@ -239,18 +237,15 @@ module java.base { java.sql, java.sql.rowset, jdk.dynalink, - jdk.internal.vm.ci, jdk.unsupported; exports jdk.internal.vm to java.management, jdk.internal.jvmstat, jdk.management, jdk.management.agent, - jdk.internal.vm.ci, jdk.jfr; exports jdk.internal.vm.annotation to java.instrument, - jdk.internal.vm.ci, jdk.incubator.vector, jdk.jfr, jdk.unsupported; @@ -270,7 +265,6 @@ module java.base { java.net.http, jdk.charsets, jdk.incubator.vector, - jdk.internal.vm.ci, jdk.httpserver, jdk.jlink, jdk.jpackage, diff --git a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java index fcee641458e..ab5ec8c133d 100644 --- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java +++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -676,13 +676,6 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable { UnsafeAccessor.setMemberValues(this, mv); } - /** - * Gets an unmodifiable view on the member values. - */ - Map memberValues() { - return Collections.unmodifiableMap(memberValues); - } - private static class UnsafeAccessor { private static final jdk.internal.misc.Unsafe unsafe = jdk.internal.misc.Unsafe.getUnsafe(); diff --git a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java index 74ed1e01553..b40ed946648 100644 --- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java +++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -326,8 +326,6 @@ public class AnnotationParser { ByteBuffer buf, ConstantPool constPool, Class container) { - // Note that VMSupport.encodeAnnotation (used by JVMCI) may need to - // be updated if new annotation member types are added. Object result = null; int tag = buf.get(); switch(tag) { diff --git a/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java b/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java index fd76eedfbcd..5856711e407 100644 --- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java +++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -267,13 +267,4 @@ public final class AnnotationSupport { } } } - - /** - * Gets an unmodifiable view of {@code a}'s elements. - * - * @return a map from element names to element values - */ - public static Map memberValues(Annotation a) { - return ((AnnotationInvocationHandler) Proxy.getInvocationHandler(a)).memberValues(); - } } diff --git a/src/jdk.compiler/share/data/symbols/jdk.graal.compiler-M.sym.txt b/src/jdk.compiler/share/data/symbols/jdk.graal.compiler-M.sym.txt deleted file mode 100644 index 388d4ca64b5..00000000000 --- a/src/jdk.compiler/share/data/symbols/jdk.graal.compiler-M.sym.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# ########################################################## -# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### -# ########################################################## -# -module name jdk.graal.compiler -header requires name\u0020;java.base\u0020;flags\u0020;8000,name\u0020;jdk.internal.vm.ci\u0020;flags\u0020;0 target linux-amd64 flags 8000 - diff --git a/src/jdk.compiler/share/data/symbols/jdk.graal.compiler.management-M.sym.txt b/src/jdk.compiler/share/data/symbols/jdk.graal.compiler.management-M.sym.txt deleted file mode 100644 index a0e88dfb0a9..00000000000 --- a/src/jdk.compiler/share/data/symbols/jdk.graal.compiler.management-M.sym.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# ########################################################## -# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### -# ########################################################## -# -module name jdk.graal.compiler.management -header requires name\u0020;java.base\u0020;flags\u0020;8000,name\u0020;jdk.internal.vm.ci\u0020;flags\u0020;0 target linux-amd64 flags 8000 - diff --git a/src/jdk.compiler/share/data/symbols/jdk.internal.vm.ci-M.sym.txt b/src/jdk.compiler/share/data/symbols/jdk.internal.vm.ci-M.sym.txt deleted file mode 100644 index f4ad8cc4861..00000000000 --- a/src/jdk.compiler/share/data/symbols/jdk.internal.vm.ci-M.sym.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# ########################################################## -# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### -# ########################################################## -# -module name jdk.internal.vm.ci -header requires name\u0020;java.base\u0020;flags\u0020;8000 uses jdk/vm/ci/services/JVMCIServiceLocator,jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory provides interface\u0020;jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory\u0020;impls\u0020;jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory\u005C;u002C;jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory\u005C;u002C;jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotJVMCIBackendFactory target linux-amd64 flags 8000 - diff --git a/src/jdk.graal.compiler.management/share/classes/module-info.java b/src/jdk.graal.compiler.management/share/classes/module-info.java deleted file mode 100644 index 976bf369819..00000000000 --- a/src/jdk.graal.compiler.management/share/classes/module-info.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Registers JVMCI compiler specific management interfaces for the JVM. - * - * This is an empty and upgradeable module that is a placeholder for an - * external implementation of a JVMCI compiler. It must be upgradeable so - * that it can be replaced when jlinking a new JDK image without failing - * the hash check for the qualified exports in jdk.internal.vm.ci's - * module descriptor. - * - * @moduleGraph - * @since 22 - */ -module jdk.graal.compiler.management { - requires jdk.internal.vm.ci; -} - diff --git a/src/jdk.graal.compiler/share/classes/module-info.java b/src/jdk.graal.compiler/share/classes/module-info.java deleted file mode 100644 index f2bc1ae9842..00000000000 --- a/src/jdk.graal.compiler/share/classes/module-info.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * JVMCI compiler implementation for the JVM. - * - * This is an empty and upgradeable module that is a placeholder for an - * external implementation of a JVMCI compiler. It must be upgradeable so - * that it can be replaced when jlinking a new JDK image without failing - * the hash check for the qualified exports in jdk.internal.vm.ci's - * and java.base's module descriptors. - * - * @moduleGraph - * @since 22 - */ - -module jdk.graal.compiler { - requires jdk.internal.vm.ci; -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java index 74335f78888..06ce293fbf1 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java @@ -65,7 +65,6 @@ import sun.jvm.hotspot.oops.RawHeapVisitor; import sun.jvm.hotspot.oops.Symbol; import sun.jvm.hotspot.oops.UnknownOopException; import sun.jvm.hotspot.runtime.CompiledVFrame; -import sun.jvm.hotspot.runtime.CompilerThread; import sun.jvm.hotspot.runtime.JavaThread; import sun.jvm.hotspot.runtime.JavaVFrame; import sun.jvm.hotspot.runtime.Threads; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java deleted file mode 100644 index 7e129827c52..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompilerThread.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.runtime; - -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.Observable; -import sun.jvm.hotspot.utilities.Observer; - -public class CompilerThread extends JavaThread { - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - private static AddressField envField; - - private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { } - - public CompilerThread(Address addr) { - super(addr); - } - - @Override - public boolean isHiddenFromExternalView() { - /* - * See JDK-8348317. CompilerThreads are sometimes hidden and sometimes not. They - * are not when JVMCI is enabled and a compiler implemented in java is running - * on the CompilerThread. This is hard for SA to determine, and not something a customer - * is likely to ever run across or care about, so by default all CompilerThreads - * are considered to be hidden. However, we allow this behaviour to be overridden - * in case the user has a need to make the CompilerThreads visible. - */ - return !Boolean.getBoolean("sun.jvm.hotspot.runtime.CompilerThread.visible"); - } - -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java index 04c4c944517..b33fcb89747 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Threads.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -144,7 +144,7 @@ public class Threads { virtualConstructor.addMapping("JavaThread", JavaThread.class); if (!VM.getVM().isCore()) { - virtualConstructor.addMapping("CompilerThread", CompilerThread.class); + virtualConstructor.addMapping("CompilerThread", HiddenJavaThread.class); virtualConstructor.addMapping("TrainingReplayThread", HiddenJavaThread.class); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java deleted file mode 100644 index 7790a9abd7c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.aarch64; - -import java.nio.ByteOrder; -import java.util.EnumSet; -import java.util.List; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CPUFeatureName; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; - -/** - * Represents the AArch64 architecture. - * - * The value returned by {@code Architecture#getName} for an instance of this class is {@code "aarch64"}. - */ -public class AArch64 extends Architecture { - - public static final RegisterCategory CPU = new RegisterCategory("CPU"); - - // General purpose CPU registers - public static final Register r0 = new Register(0, 0, "r0", CPU); - public static final Register r1 = new Register(1, 1, "r1", CPU); - public static final Register r2 = new Register(2, 2, "r2", CPU); - public static final Register r3 = new Register(3, 3, "r3", CPU); - public static final Register r4 = new Register(4, 4, "r4", CPU); - public static final Register r5 = new Register(5, 5, "r5", CPU); - public static final Register r6 = new Register(6, 6, "r6", CPU); - public static final Register r7 = new Register(7, 7, "r7", CPU); - public static final Register r8 = new Register(8, 8, "r8", CPU); - public static final Register r9 = new Register(9, 9, "r9", CPU); - public static final Register r10 = new Register(10, 10, "r10", CPU); - public static final Register r11 = new Register(11, 11, "r11", CPU); - public static final Register r12 = new Register(12, 12, "r12", CPU); - public static final Register r13 = new Register(13, 13, "r13", CPU); - public static final Register r14 = new Register(14, 14, "r14", CPU); - public static final Register r15 = new Register(15, 15, "r15", CPU); - public static final Register r16 = new Register(16, 16, "r16", CPU); - public static final Register r17 = new Register(17, 17, "r17", CPU); - public static final Register r18 = new Register(18, 18, "r18", CPU); - public static final Register r19 = new Register(19, 19, "r19", CPU); - public static final Register r20 = new Register(20, 20, "r20", CPU); - public static final Register r21 = new Register(21, 21, "r21", CPU); - public static final Register r22 = new Register(22, 22, "r22", CPU); - public static final Register r23 = new Register(23, 23, "r23", CPU); - public static final Register r24 = new Register(24, 24, "r24", CPU); - public static final Register r25 = new Register(25, 25, "r25", CPU); - public static final Register r26 = new Register(26, 26, "r26", CPU); - public static final Register r27 = new Register(27, 27, "r27", CPU); - public static final Register r28 = new Register(28, 28, "r28", CPU); - public static final Register r29 = new Register(29, 29, "r29", CPU); - public static final Register r30 = new Register(30, 30, "r30", CPU); - - /* - * r31 is not a general purpose register, but represents either the stackpointer or the - * zero/discard register depending on the instruction. So we represent those two uses as two - * different registers. The register numbers are kept in sync with register_aarch64.hpp and have - * to be sequential, hence we also need a general r31 register here, which is never used. - */ - public static final Register r31 = new Register(31, 31, "r31", CPU); - public static final Register zr = new Register(32, 31, "zr", CPU); - public static final Register sp = new Register(33, 31, "sp", CPU); - - public static final Register lr = r30; - - // Used by runtime code: cannot be compiler-allocated. - public static final Register rscratch1 = r8; - public static final Register rscratch2 = r9; - - // @formatter:off - public static final List cpuRegisters = List.of( - r0, r1, r2, r3, r4, r5, r6, r7, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31, - zr, sp - ); - // @formatter:on - - public static final RegisterCategory SIMD = new RegisterCategory("SIMD"); - - // Simd registers - public static final Register v0 = new Register(34, 0, "v0", SIMD); - public static final Register v1 = new Register(35, 1, "v1", SIMD); - public static final Register v2 = new Register(36, 2, "v2", SIMD); - public static final Register v3 = new Register(37, 3, "v3", SIMD); - public static final Register v4 = new Register(38, 4, "v4", SIMD); - public static final Register v5 = new Register(39, 5, "v5", SIMD); - public static final Register v6 = new Register(40, 6, "v6", SIMD); - public static final Register v7 = new Register(41, 7, "v7", SIMD); - public static final Register v8 = new Register(42, 8, "v8", SIMD); - public static final Register v9 = new Register(43, 9, "v9", SIMD); - public static final Register v10 = new Register(44, 10, "v10", SIMD); - public static final Register v11 = new Register(45, 11, "v11", SIMD); - public static final Register v12 = new Register(46, 12, "v12", SIMD); - public static final Register v13 = new Register(47, 13, "v13", SIMD); - public static final Register v14 = new Register(48, 14, "v14", SIMD); - public static final Register v15 = new Register(49, 15, "v15", SIMD); - public static final Register v16 = new Register(50, 16, "v16", SIMD); - public static final Register v17 = new Register(51, 17, "v17", SIMD); - public static final Register v18 = new Register(52, 18, "v18", SIMD); - public static final Register v19 = new Register(53, 19, "v19", SIMD); - public static final Register v20 = new Register(54, 20, "v20", SIMD); - public static final Register v21 = new Register(55, 21, "v21", SIMD); - public static final Register v22 = new Register(56, 22, "v22", SIMD); - public static final Register v23 = new Register(57, 23, "v23", SIMD); - public static final Register v24 = new Register(58, 24, "v24", SIMD); - public static final Register v25 = new Register(59, 25, "v25", SIMD); - public static final Register v26 = new Register(60, 26, "v26", SIMD); - public static final Register v27 = new Register(61, 27, "v27", SIMD); - public static final Register v28 = new Register(62, 28, "v28", SIMD); - public static final Register v29 = new Register(63, 29, "v29", SIMD); - public static final Register v30 = new Register(64, 30, "v30", SIMD); - public static final Register v31 = new Register(65, 31, "v31", SIMD); - - // @formatter:off - public static final List simdRegisters = List.of( - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10, v11, v12, v13, v14, v15, - v16, v17, v18, v19, v20, v21, v22, v23, - v24, v25, v26, v27, v28, v29, v30, v31 - ); - // @formatter:on - - // @formatter:off - public static final List allRegisters = List.of( - r0, r1, r2, r3, r4, r5, r6, r7, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31, - zr, sp, - - v0, v1, v2, v3, v4, v5, v6, v7, - v8, v9, v10, v11, v12, v13, v14, v15, - v16, v17, v18, v19, v20, v21, v22, v23, - v24, v25, v26, v27, v28, v29, v30, v31 - ); - // @formatter:on - - /** - * Basic set of CPU features mirroring what is returned from the cpuid instruction. See: - * {@code VM_Version::cpuFeatureFlags}. - */ - public enum CPUFeature implements CPUFeatureName { - FP, - ASIMD, - EVTSTRM, - AES, - PMULL, - SHA1, - SHA2, - CRC32, - LSE, - DCPOP, - SHA3, - SHA512, - SVE, - SB, - PACA, - SVEBITPERM, - SVE2, - A53MAC, - ECV, - WFXT, - FPHP, - ASIMDHP, - } - - private final EnumSet features; - - public AArch64(EnumSet features) { - super("aarch64", AArch64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, 0, 0, 0); - this.features = features; - } - - @Override - public EnumSet getFeatures() { - return features; - } - - @Override - public PlatformKind getPlatformKind(JavaKind javaKind) { - switch (javaKind) { - case Boolean: - case Byte: - return AArch64Kind.BYTE; - case Short: - case Char: - return AArch64Kind.WORD; - case Int: - return AArch64Kind.DWORD; - case Long: - case Object: - return AArch64Kind.QWORD; - case Float: - return AArch64Kind.SINGLE; - case Double: - return AArch64Kind.DOUBLE; - default: - return null; - } - } - - @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { - AArch64Kind kind = (AArch64Kind) platformKind; - if (kind.isInteger()) { - return category.equals(CPU); - } else if (kind.isSIMD()) { - return category.equals(SIMD); - } - return false; - } - - @Override - public AArch64Kind getLargestStorableKind(RegisterCategory category) { - if (category.equals(CPU)) { - return AArch64Kind.QWORD; - } else if (category.equals(SIMD)) { - return AArch64Kind.V128_QWORD; - } else { - return null; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64Kind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64Kind.java deleted file mode 100644 index ac8f7442104..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/AArch64Kind.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.aarch64; - -import jdk.vm.ci.meta.PlatformKind; - -public enum AArch64Kind implements PlatformKind { - - // scalar - BYTE(1), - WORD(2), - DWORD(4), - QWORD(8), - SINGLE(4), - DOUBLE(8), - - // SIMD - V32_BYTE(4, BYTE), - V32_WORD(4, WORD), - V64_BYTE(8, BYTE), - V64_WORD(8, WORD), - V64_DWORD(8, DWORD), - V128_BYTE(16, BYTE), - V128_WORD(16, WORD), - V128_DWORD(16, DWORD), - V128_QWORD(16, QWORD), - V128_SINGLE(16, SINGLE), - V128_DOUBLE(16, DOUBLE); - - private final int size; - private final int vectorLength; - - private final AArch64Kind scalar; - private final EnumKey key = new EnumKey<>(this); - - AArch64Kind(int size) { - this.size = size; - this.scalar = this; - this.vectorLength = 1; - } - - AArch64Kind(int size, AArch64Kind scalar) { - this.size = size; - this.scalar = scalar; - - assert size % scalar.size == 0; - this.vectorLength = size / scalar.size; - } - - public AArch64Kind getScalar() { - return scalar; - } - - @Override - public int getSizeInBytes() { - return size; - } - - @Override - public int getVectorLength() { - return vectorLength; - } - - @Override - public Key getKey() { - return key; - } - - public boolean isInteger() { - switch (this) { - case BYTE: - case WORD: - case DWORD: - case QWORD: - return true; - default: - return false; - } - } - - public boolean isSIMD() { - switch (this) { - case SINGLE: - case DOUBLE: - case V32_BYTE: - case V32_WORD: - case V64_BYTE: - case V64_WORD: - case V64_DWORD: - case V128_BYTE: - case V128_WORD: - case V128_DWORD: - case V128_QWORD: - case V128_SINGLE: - case V128_DOUBLE: - return true; - default: - return false; - } - } - - @Override - public char getTypeChar() { - switch (this) { - case BYTE: - return 'b'; - case WORD: - return 'w'; - case DWORD: - return 'd'; - case QWORD: - return 'q'; - case SINGLE: - return 'S'; - case DOUBLE: - return 'D'; - case V32_BYTE: - case V32_WORD: - case V64_BYTE: - case V64_WORD: - case V64_DWORD: - case V128_BYTE: - case V128_WORD: - case V128_DWORD: - case V128_QWORD: - case V128_SINGLE: - case V128_DOUBLE: - return 'v'; - default: - return '-'; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/package-info.java deleted file mode 100644 index 3761c01d42f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/aarch64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The AArch64 platform independent portions of the JVMCI API. - */ -package jdk.vm.ci.aarch64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java deleted file mode 100644 index 273ada6f4bc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64.java +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.amd64; - -import static jdk.vm.ci.code.MemoryBarriers.LOAD_LOAD; -import static jdk.vm.ci.code.MemoryBarriers.LOAD_STORE; -import static jdk.vm.ci.code.MemoryBarriers.STORE_STORE; -import static jdk.vm.ci.code.Register.SPECIAL; - -import java.nio.ByteOrder; -import java.util.EnumSet; -import java.util.List; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CPUFeatureName; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; - -/** - * Represents the AMD64 architecture. - * - * The value returned by {@code Architecture#getName} for an instance of this class is {@code "AMD64"}. - */ -public class AMD64 extends Architecture { - - public static final RegisterCategory CPU = new RegisterCategory("CPU"); - - // @formatter:off - - // General purpose CPU registers - public static final Register rax = new Register(0, 0, "rax", CPU); - public static final Register rcx = new Register(1, 1, "rcx", CPU); - public static final Register rdx = new Register(2, 2, "rdx", CPU); - public static final Register rbx = new Register(3, 3, "rbx", CPU); - public static final Register rsp = new Register(4, 4, "rsp", CPU); - public static final Register rbp = new Register(5, 5, "rbp", CPU); - public static final Register rsi = new Register(6, 6, "rsi", CPU); - public static final Register rdi = new Register(7, 7, "rdi", CPU); - - public static final Register r8 = new Register(8, 8, "r8", CPU); - public static final Register r9 = new Register(9, 9, "r9", CPU); - public static final Register r10 = new Register(10, 10, "r10", CPU); - public static final Register r11 = new Register(11, 11, "r11", CPU); - public static final Register r12 = new Register(12, 12, "r12", CPU); - public static final Register r13 = new Register(13, 13, "r13", CPU); - public static final Register r14 = new Register(14, 14, "r14", CPU); - public static final Register r15 = new Register(15, 15, "r15", CPU); - - public static final Register r16 = new Register(16, 16, "r16", CPU); - public static final Register r17 = new Register(17, 17, "r17", CPU); - public static final Register r18 = new Register(18, 18, "r18", CPU); - public static final Register r19 = new Register(19, 19, "r19", CPU); - public static final Register r20 = new Register(20, 20, "r20", CPU); - public static final Register r21 = new Register(21, 21, "r21", CPU); - public static final Register r22 = new Register(22, 22, "r22", CPU); - public static final Register r23 = new Register(23, 23, "r23", CPU); - public static final Register r24 = new Register(24, 24, "r24", CPU); - public static final Register r25 = new Register(25, 25, "r25", CPU); - public static final Register r26 = new Register(26, 26, "r26", CPU); - public static final Register r27 = new Register(27, 27, "r27", CPU); - public static final Register r28 = new Register(28, 28, "r28", CPU); - public static final Register r29 = new Register(29, 29, "r29", CPU); - public static final Register r30 = new Register(30, 30, "r30", CPU); - public static final Register r31 = new Register(31, 31, "r31", CPU); - - // The set of common CPU registers available on all x64 platforms. - public static final List cpuRegisters = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15 - ); - - public static final List cpuRegistersAPX = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31 - ); - - public static final RegisterCategory XMM = new RegisterCategory("XMM"); - - // XMM registers - public static final Register xmm0 = new Register(32, 0, "xmm0", XMM); - public static final Register xmm1 = new Register(33, 1, "xmm1", XMM); - public static final Register xmm2 = new Register(34, 2, "xmm2", XMM); - public static final Register xmm3 = new Register(35, 3, "xmm3", XMM); - public static final Register xmm4 = new Register(36, 4, "xmm4", XMM); - public static final Register xmm5 = new Register(37, 5, "xmm5", XMM); - public static final Register xmm6 = new Register(38, 6, "xmm6", XMM); - public static final Register xmm7 = new Register(39, 7, "xmm7", XMM); - - public static final Register xmm8 = new Register(40, 8, "xmm8", XMM); - public static final Register xmm9 = new Register(41, 9, "xmm9", XMM); - public static final Register xmm10 = new Register(42, 10, "xmm10", XMM); - public static final Register xmm11 = new Register(43, 11, "xmm11", XMM); - public static final Register xmm12 = new Register(44, 12, "xmm12", XMM); - public static final Register xmm13 = new Register(45, 13, "xmm13", XMM); - public static final Register xmm14 = new Register(46, 14, "xmm14", XMM); - public static final Register xmm15 = new Register(47, 15, "xmm15", XMM); - - public static final Register xmm16 = new Register(48, 16, "xmm16", XMM); - public static final Register xmm17 = new Register(49, 17, "xmm17", XMM); - public static final Register xmm18 = new Register(50, 18, "xmm18", XMM); - public static final Register xmm19 = new Register(51, 19, "xmm19", XMM); - public static final Register xmm20 = new Register(52, 20, "xmm20", XMM); - public static final Register xmm21 = new Register(53, 21, "xmm21", XMM); - public static final Register xmm22 = new Register(54, 22, "xmm22", XMM); - public static final Register xmm23 = new Register(55, 23, "xmm23", XMM); - - public static final Register xmm24 = new Register(56, 24, "xmm24", XMM); - public static final Register xmm25 = new Register(57, 25, "xmm25", XMM); - public static final Register xmm26 = new Register(58, 26, "xmm26", XMM); - public static final Register xmm27 = new Register(59, 27, "xmm27", XMM); - public static final Register xmm28 = new Register(60, 28, "xmm28", XMM); - public static final Register xmm29 = new Register(61, 29, "xmm29", XMM); - public static final Register xmm30 = new Register(62, 30, "xmm30", XMM); - public static final Register xmm31 = new Register(63, 31, "xmm31", XMM); - - public static final List xmmRegistersSSE = List.of( - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 - ); - - public static final List xmmRegistersAVX512 = List.of( - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, - xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23, - xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31 - ); - - public static final RegisterCategory MASK = new RegisterCategory("MASK", false); - - public static final Register k0 = new Register(64, 0, "k0", MASK); - public static final Register k1 = new Register(65, 1, "k1", MASK); - public static final Register k2 = new Register(66, 2, "k2", MASK); - public static final Register k3 = new Register(67, 3, "k3", MASK); - public static final Register k4 = new Register(68, 4, "k4", MASK); - public static final Register k5 = new Register(69, 5, "k5", MASK); - public static final Register k6 = new Register(70, 6, "k6", MASK); - public static final Register k7 = new Register(71, 7, "k7", MASK); - - public static final List valueRegistersSSE = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 - ); - - public static final List valueRegistersAVX512 = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, - xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23, - xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31, - k0, k1, k2, k3, k4, k5, k6, k7 - ); - - public static final List valueRegistersSSEAndAPX = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31, - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 - ); - - public static final List valueRegistersAVX512AndAPX = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31, - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, - xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23, - xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31, - k0, k1, k2, k3, k4, k5, k6, k7 - ); - - /** - * Register used to construct an instruction-relative address. - */ - public static final Register rip = new Register(72, -1, "rip", SPECIAL); - - public static final List allRegisters = List.of( - rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, - r8, r9, r10, r11, r12, r13, r14, r15, - r16, r17, r18, r19, r20, r21, r22, r23, - r24, r25, r26, r27, r28, r29, r30, r31, - xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, - xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, - xmm16, xmm17, xmm18, xmm19, xmm20, xmm21, xmm22, xmm23, - xmm24, xmm25, xmm26, xmm27, xmm28, xmm29, xmm30, xmm31, - k0, k1, k2, k3, k4, k5, k6, k7, - rip - ); - - // @formatter:on - - /** - * Basic set of CPU features mirroring what is returned from the cpuid instruction. See: - * {@code VM_Version::cpuFeatureFlags}. - */ - public enum CPUFeature implements CPUFeatureName { - CX8, - CMOV, - FXSR, - HT, - MMX, - AMD_3DNOW_PREFETCH, - SSE, - SSE2, - SSE3, - SSSE3, - SSE4A, - SSE4_1, - SSE4_2, - POPCNT, - LZCNT, - TSC, - TSCINV, - TSCINV_BIT, - AVX, - AVX2, - AES, - ERMS, - CLMUL, - BMI1, - BMI2, - RTM, - ADX, - AVX512F, - AVX512DQ, - AVX512PF, - AVX512ER, - AVX512CD, - AVX512BW, - AVX512VL, - SHA, - FMA, - VZEROUPPER, - AVX512_VPOPCNTDQ, - AVX512_VPCLMULQDQ, - AVX512_VAES, - AVX512_VNNI, - FLUSH, - FLUSHOPT, - CLWB, - AVX512_VBMI2, - AVX512_VBMI, - HV, - SERIALIZE, - RDTSCP, - RDPID, - FSRM, - GFNI, - AVX512_BITALG, - F16C, - PKU, - OSPKE, - CET_IBT, - CET_SS, - AVX512_IFMA, - AVX_IFMA, - APX_F, - SHA512, - AVX512_FP16, - AVX10_1, - AVX10_2, - HYBRID - } - - private final EnumSet features; - - private final AMD64Kind largestKind; - - private final AMD64Kind largestMaskKind; - - public AMD64(EnumSet features) { - super("AMD64", AMD64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, LOAD_LOAD | LOAD_STORE | STORE_STORE, 1, 8); - this.features = features; - assert features.contains(CPUFeature.SSE2) : "minimum config for x64"; - - if (features.contains(CPUFeature.AVX512F)) { - largestKind = AMD64Kind.V512_QWORD; - if (features.contains(CPUFeature.AVX512BW)) { - largestMaskKind = AMD64Kind.MASK64; - } else { - largestMaskKind = AMD64Kind.MASK16; - } - } else if (features.contains(CPUFeature.AVX)) { - largestKind = AMD64Kind.V256_QWORD; - largestMaskKind = null; - } else { - largestKind = AMD64Kind.V128_QWORD; - largestMaskKind = null; - } - } - - @Override - public EnumSet getFeatures() { - return features; - } - - @Override - public List getAvailableValueRegisters() { - if (features.contains(CPUFeature.APX_F)) { - if (features.contains(CPUFeature.AVX512F)) { - return valueRegistersAVX512AndAPX; - } else { - return valueRegistersSSEAndAPX; - } - } else if (features.contains(CPUFeature.AVX512F)) { - return valueRegistersAVX512; - } else { - return valueRegistersSSE; - } - } - - @Override - public PlatformKind getPlatformKind(JavaKind javaKind) { - switch (javaKind) { - case Boolean: - case Byte: - return AMD64Kind.BYTE; - case Short: - case Char: - return AMD64Kind.WORD; - case Int: - return AMD64Kind.DWORD; - case Long: - case Object: - return AMD64Kind.QWORD; - case Float: - return AMD64Kind.SINGLE; - case Double: - return AMD64Kind.DOUBLE; - default: - return null; - } - } - - @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { - AMD64Kind kind = (AMD64Kind) platformKind; - if (kind.isInteger()) { - return category.equals(CPU); - } else if (kind.isXMM()) { - return category.equals(XMM); - } else { - assert kind.isMask(); - return category.equals(MASK); - } - } - - @Override - public AMD64Kind getLargestStorableKind(RegisterCategory category) { - if (category.equals(CPU)) { - return AMD64Kind.QWORD; - } else if (category.equals(XMM)) { - return largestKind; - } else if (category.equals(MASK)) { - return largestMaskKind; - } else { - return null; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64Kind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64Kind.java deleted file mode 100644 index 49cba6bac99..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/AMD64Kind.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.amd64; - -import jdk.vm.ci.meta.PlatformKind; - -public enum AMD64Kind implements PlatformKind { - - // scalar - BYTE(1), - WORD(2), - DWORD(4), - QWORD(8), - SINGLE(4), - DOUBLE(8), - - // SSE2 - V32_BYTE(4, BYTE), - V32_WORD(4, WORD), - V64_BYTE(8, BYTE), - V64_WORD(8, WORD), - V64_DWORD(8, DWORD), - V128_BYTE(16, BYTE), - V128_WORD(16, WORD), - V128_DWORD(16, DWORD), - V128_QWORD(16, QWORD), - V128_SINGLE(16, SINGLE), - V128_DOUBLE(16, DOUBLE), - - // AVX - V256_BYTE(32, BYTE), - V256_WORD(32, WORD), - V256_DWORD(32, DWORD), - V256_QWORD(32, QWORD), - V256_SINGLE(32, SINGLE), - V256_DOUBLE(32, DOUBLE), - - // AVX512 - V512_BYTE(64, BYTE), - V512_WORD(64, WORD), - V512_DWORD(64, DWORD), - V512_QWORD(64, QWORD), - V512_SINGLE(64, SINGLE), - V512_DOUBLE(64, DOUBLE), - - MASK8(1), - MASK16(2), - MASK32(4), - MASK64(8); - - private final int size; - private final int vectorLength; - - private final AMD64Kind scalar; - private final EnumKey key = new EnumKey<>(this); - - AMD64Kind(int size) { - this.size = size; - this.scalar = this; - this.vectorLength = 1; - } - - AMD64Kind(int size, AMD64Kind scalar) { - this.size = size; - this.scalar = scalar; - - assert size % scalar.size == 0; - this.vectorLength = size / scalar.size; - } - - public AMD64Kind getScalar() { - return scalar; - } - - @Override - public int getSizeInBytes() { - return size; - } - - @Override - public int getVectorLength() { - return vectorLength; - } - - @Override - public Key getKey() { - return key; - } - - public boolean isInteger() { - switch (this) { - case BYTE: - case WORD: - case DWORD: - case QWORD: - return true; - default: - return false; - } - } - - public boolean isXMM() { - switch (this) { - case SINGLE: - case DOUBLE: - case V32_BYTE: - case V32_WORD: - case V64_BYTE: - case V64_WORD: - case V64_DWORD: - case V128_BYTE: - case V128_WORD: - case V128_DWORD: - case V128_QWORD: - case V128_SINGLE: - case V128_DOUBLE: - case V256_BYTE: - case V256_WORD: - case V256_DWORD: - case V256_QWORD: - case V256_SINGLE: - case V256_DOUBLE: - case V512_BYTE: - case V512_WORD: - case V512_DWORD: - case V512_QWORD: - case V512_SINGLE: - case V512_DOUBLE: - return true; - default: - return false; - } - } - - public boolean isMask() { - switch (this) { - case MASK8: - case MASK16: - case MASK32: - case MASK64: - return true; - default: - return false; - } - } - - @Override - public char getTypeChar() { - switch (this) { - case BYTE: - return 'b'; - case WORD: - return 'w'; - case DWORD: - return 'd'; - case QWORD: - return 'q'; - case SINGLE: - return 'S'; - case DOUBLE: - return 'D'; - case V32_BYTE: - case V32_WORD: - case V64_BYTE: - case V64_WORD: - case V64_DWORD: - return 'v'; - case V128_BYTE: - case V128_WORD: - case V128_DWORD: - case V128_QWORD: - case V128_SINGLE: - case V128_DOUBLE: - return 'x'; - case V256_BYTE: - case V256_WORD: - case V256_DWORD: - case V256_QWORD: - case V256_SINGLE: - case V256_DOUBLE: - return 'y'; - case V512_BYTE: - case V512_WORD: - case V512_DWORD: - case V512_QWORD: - case V512_SINGLE: - case V512_DOUBLE: - return 'z'; - case MASK8: - case MASK16: - case MASK32: - case MASK64: - return 'k'; - default: - return '-'; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/package-info.java deleted file mode 100644 index ae4263dc381..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/amd64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The AMD64 platform independent portions of the JVMCI API. - */ -package jdk.vm.ci.amd64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Architecture.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Architecture.java deleted file mode 100644 index 187c1d72c61..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Architecture.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.nio.ByteOrder; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; - -/** - * Represents a CPU architecture, including information such as its endianness, CPU registers, word - * width, etc. - */ -public abstract class Architecture { - - /** - * The architecture specific type of a native word. - */ - private final PlatformKind wordKind; - - /** - * The name of this architecture (e.g. "AMD64"). - */ - private final String name; - - /** - * List of all available registers on this architecture. The index of each register in this list - * is equal to its {@linkplain Register#number number}. - */ - private final List registers; - - /** - * The byte ordering can be either little or big endian. - */ - private final ByteOrder byteOrder; - - /** - * Whether the architecture supports unaligned memory accesses. - */ - private final boolean unalignedMemoryAccess; - - /** - * Mask of the barrier constants denoting the barriers that are not required to be explicitly - * inserted under this architecture. - */ - private final int implicitMemoryBarriers; - - /** - * Offset in bytes from the beginning of a call instruction to the displacement. - */ - private final int machineCodeCallDisplacementOffset; - - /** - * The size of the return address pushed to the stack by a call instruction. A value of 0 - * denotes that call linkage uses registers instead (e.g. SPARC). - */ - private final int returnAddressSize; - - protected Architecture(String name, PlatformKind wordKind, ByteOrder byteOrder, boolean unalignedMemoryAccess, List registers, int implicitMemoryBarriers, - int nativeCallDisplacementOffset, - int returnAddressSize) { - // registers is expected to mention all registers in order of their encoding. - for (int i = 0; i < registers.size(); ++i) { - if (registers.get(i).number != i) { - Register reg = registers.get(i); - throw new JVMCIError("%s: %d != %d", reg, reg.number, i); - } - } - this.name = name; - this.registers = registers; - this.wordKind = wordKind; - this.byteOrder = byteOrder; - this.unalignedMemoryAccess = unalignedMemoryAccess; - this.implicitMemoryBarriers = implicitMemoryBarriers; - this.machineCodeCallDisplacementOffset = nativeCallDisplacementOffset; - this.returnAddressSize = returnAddressSize; - } - - /** - * Gets the set of CPU features supported by the current platform. - */ - public abstract Set getFeatures(); - - /** - * Converts this architecture to a string. - * - * @return a lowercase version of {@linkplain #getName name} - */ - @Override - public final String toString() { - return getName().toLowerCase(); - } - - /** - * Gets the natural size of words (typically registers and pointers) of this architecture, in - * bytes. - */ - public int getWordSize() { - return wordKind.getSizeInBytes(); - } - - public PlatformKind getWordKind() { - return wordKind; - } - - /// Gets the name of this architecture. The value returned for - /// each architecture is shown in the table below. - /// - /// | Name | Receiver type | - /// |-----------|-----------------------------| - /// | "aarch64" | [jdk.vm.ci.aarch64.AArch64] | - /// | "AMD64" | [jdk.vm.ci.amd64.AMD64] | - /// | "riscv64" | [jdk.vm.ci.riscv64.RISCV64] | - public String getName() { - return name; - } - - /** - * Gets the list of all registers that exist on this architecture. This contains all registers - * that exist in the specification of this architecture. Not all of them may be available on - * this particular architecture instance. The index of each register in this list is equal to - * its {@linkplain Register#number number}. - */ - public List getRegisters() { - return registers; - } - - /** - * Gets a list of all registers available for storing values on this architecture. This may be a - * subset of {@link #getRegisters()}, depending on the capabilities of this particular CPU. - */ - public List getAvailableValueRegisters() { - return getRegisters(); - } - - public ByteOrder getByteOrder() { - return byteOrder; - } - - /** - * @return true if the architecture supports unaligned memory accesses. - */ - public boolean supportsUnalignedMemoryAccess() { - return unalignedMemoryAccess; - } - - /** - * Gets the size of the return address pushed to the stack by a call instruction. A value of 0 - * denotes that call linkage uses registers instead. - */ - public int getReturnAddressSize() { - return returnAddressSize; - } - - /** - * Gets the offset in bytes from the beginning of a call instruction to the displacement. - */ - public int getMachineCodeCallDisplacementOffset() { - return machineCodeCallDisplacementOffset; - } - - /** - * Determines the barriers in a given barrier mask that are explicitly required on this - * architecture. - * - * @param barriers a mask of the barrier constants - * @return the value of {@code barriers} minus the barriers unnecessary on this architecture - */ - public final int requiredBarriers(int barriers) { - return barriers & ~implicitMemoryBarriers; - } - - /** - * Determine whether a kind can be stored in a register of a given category. - * - * @param category the category of the register - * @param kind the kind that should be stored in the register - */ - public abstract boolean canStoreValue(RegisterCategory category, PlatformKind kind); - - /** - * Return the largest kind that can be stored in a register of a given category. - * - * @param category the category of the register - * @return the largest kind that can be stored in a register {@code category} - */ - public abstract PlatformKind getLargestStorableKind(RegisterCategory category); - - /** - * Gets the {@link PlatformKind} that is used to store values of a given {@link JavaKind}. - * - * @return {@code null} if there no deterministic {@link PlatformKind} for {@code javaKind} - */ - public abstract PlatformKind getPlatformKind(JavaKind javaKind); - - @Override - public final boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof Architecture) { - Architecture that = (Architecture) obj; - if (this.name.equals(that.name)) { - assert this.byteOrder.equals(that.byteOrder); - assert this.implicitMemoryBarriers == that.implicitMemoryBarriers; - assert this.machineCodeCallDisplacementOffset == that.machineCodeCallDisplacementOffset; - assert this.registers.equals(that.registers); - assert this.returnAddressSize == that.returnAddressSize; - assert this.unalignedMemoryAccess == that.unalignedMemoryAccess; - assert this.wordKind == that.wordKind; - return true; - } - } - return false; - } - - @Override - public final int hashCode() { - return name.hashCode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BailoutException.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BailoutException.java deleted file mode 100644 index 5dffe052997..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BailoutException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Locale; - -/** - * Exception thrown when the compiler refuses to compile a method because of problems with the - * method. e.g. bytecode wouldn't verify, too big, JSR/ret too complicated, etc. This exception is - * not meant to indicate problems with the compiler itself. - */ -public class BailoutException extends RuntimeException { - - public static final long serialVersionUID = 8974598793458772L; - private final boolean permanent; - - /** - * Creates a new {@link BailoutException}. - * - * - * @param args parameters to the formatter - */ - public BailoutException(String format, Object... args) { - super(String.format(Locale.ENGLISH, format, args)); - this.permanent = true; - } - - /** - * Creates a new {@link BailoutException}. - * - * - * @param args parameters to the formatter - */ - public BailoutException(Throwable cause, String format, Object... args) { - super(String.format(Locale.ENGLISH, format, args), cause); - this.permanent = true; - } - - /** - * Creates a new {@link BailoutException}. - * - * @param permanent specifies whether this exception will occur again if compilation is retried - * @param args parameters to the formatter - */ - public BailoutException(boolean permanent, String format, Object... args) { - super(String.format(Locale.ENGLISH, format, args)); - this.permanent = permanent; - } - - /** - * @return whether this exception will occur again if compilation is retried - */ - public boolean isPermanent() { - return permanent; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodeFrame.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodeFrame.java deleted file mode 100644 index 7b0d3d75387..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodeFrame.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Arrays; -import java.util.Objects; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.Value; - -/** - * Represents the Java bytecode frame state(s) at a given position including {@link Value locations} - * where to find the local variables, operand stack values and locked objects of the bytecode - * frame(s). - */ -public final class BytecodeFrame extends BytecodePosition { - - /** - * An array of values representing how to reconstruct the state of the Java frame. This is array - * is partitioned as follows: - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Start index (inclusive)End index (exclusive)Description
0numLocalsLocal variables
numLocalsnumLocals + numStackOperand stack
numLocals + numStackvalues.lengthLocked objects
- *

- * Note that the number of locals and the number of stack slots may be smaller than the maximum - * number of locals and stack slots as specified in the compiled method. - * - * This field is intentionally exposed as a mutable array that a compiler may modify (e.g. - * during register allocation). - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "field is intentionally mutable")// - public final JavaValue[] values; - - /** - * An array describing the Java kinds in {@link #values}. It records a kind for the locals and - * the operand stack. - */ - private final JavaKind[] slotKinds; - - /** - * The number of locals in the values array. - */ - public final int numLocals; - - /** - * The number of stack slots in the values array. - */ - public final int numStack; - - /** - * The number of locks in the values array. - */ - public final int numLocks; - - /** - * True if this is a position inside an exception handler before the exception object has been - * consumed. In this case, {@link #numStack} {@code == 1} and {@link #getStackValue(int) - * getStackValue(0)} is the location of the exception object. If deoptimization happens at this - * position, the interpreter will rethrow the exception instead of executing the bytecode - * instruction at this position. - */ - public final boolean rethrowException; - - /** - * Specifies if this object represents a frame state in the middle of executing a call. If true, - * the arguments to the call have been popped from the stack and the return value (for a - * non-void call) has not yet been pushed. - */ - public final boolean duringCall; - - /** - * This BCI should be used for frame states that are built for code with no meaningful BCI. - */ - public static final int UNKNOWN_BCI = -5; - - /** - * The BCI for exception unwind. This is synthetic code and has no representation in bytecode. - * In contrast with {@link #AFTER_EXCEPTION_BCI}, at this point, if the method is synchronized, - * the monitor is still held. - */ - public static final int UNWIND_BCI = -1; - - /** - * The BCI for the state before starting to execute a method. Note that if the method is - * synchronized, the monitor is not yet held. - */ - public static final int BEFORE_BCI = -2; - - /** - * The BCI for the state after finishing the execution of a method and returning normally. Note - * that if the method was synchronized the monitor is already released. - */ - public static final int AFTER_BCI = -3; - - /** - * The BCI for exception unwind. This is synthetic code and has no representation in bytecode. - * In contrast with {@link #UNWIND_BCI}, at this point, if the method is synchronized, the - * monitor is already released. - */ - public static final int AFTER_EXCEPTION_BCI = -4; - - /** - * This BCI should be used for states that cannot be the target of a deoptimization, like - * snippet frame states. - */ - public static final int INVALID_FRAMESTATE_BCI = -6; - - /** - * Determines if a given BCI matches one of the placeholder BCI constants defined in this class. - */ - public static boolean isPlaceholderBci(int bci) { - return bci < 0; - } - - /** - * Gets the name of a given placeholder BCI. - */ - public static String getPlaceholderBciName(int bci) { - assert isPlaceholderBci(bci); - if (bci == BytecodeFrame.AFTER_BCI) { - return "AFTER_BCI"; - } else if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI) { - return "AFTER_EXCEPTION_BCI"; - } else if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) { - return "INVALID_FRAMESTATE_BCI"; - } else if (bci == BytecodeFrame.BEFORE_BCI) { - return "BEFORE_BCI"; - } else if (bci == BytecodeFrame.UNKNOWN_BCI) { - return "UNKNOWN_BCI"; - } else { - assert bci == BytecodeFrame.UNWIND_BCI; - return "UNWIND_BCI"; - } - } - - /** - * Creates a new frame object. A well formed frame has the following invariants: - *

    - *
  • {@code values != null}
  • - *
  • {@code slotKinds != null}
  • - *
  • {@code numLocals + numStack + numLocks == values.length}
  • - *
  • {@code numLocals + numStack + numLocks == values.length}
  • - *
  • {@code numLocals + numStack == slotKinds.length}
  • - *
  • all entries in {@code values} starting at index {@code numLocals + numStack} must be of - * type {@link StackLockValue}
  • - *
  • for each index {@code i} between 0 (inclusive) and {@code numLocals + numStack} - * (exclusive), if {@code slotKinds[i].needsTwoSlots()} then - * {@code values[i + 1] == Value.ILLEGAL}.
  • - *
- * - * These invariants are not checked in this constructor but by {@link #verifyInvariants()}. - * - * @param caller the caller frame (which may be {@code null}) - * @param method the method - * @param bci a BCI within the method - * @param rethrowException specifies if the VM should re-throw the pending exception when - * deopt'ing using this frame - * @param values the frame state {@link #values} - * @param slotKinds the kinds in {@code values}. This array is now owned by this object and must - * not be mutated by the caller. - * @param numLocals the number of local variables - * @param numStack the depth of the stack - * @param numLocks the number of locked objects - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `slotKinds`") - public BytecodeFrame(BytecodeFrame caller, - ResolvedJavaMethod method, - int bci, - boolean rethrowException, - boolean duringCall, - JavaValue[] values, - JavaKind[] slotKinds, - int numLocals, - int numStack, - int numLocks) { - super(caller, method, bci); - assert values != null; - this.rethrowException = rethrowException; - this.duringCall = duringCall; - this.values = values; - this.slotKinds = slotKinds; - this.numLocals = numLocals; - this.numStack = numStack; - this.numLocks = numLocks; - assert !rethrowException || numStack == 1 : "must have exception on top of the stack"; - } - - /** - * Checks the invariants described in {@link #BytecodeFrame}. - * - * @throws NullPointerException if {@code values == null || slotKinds == null} or any of the - * entries in {@code values} is null - * @throws JVMCIError if any of the other invariants are violated - */ - public void verifyInvariants() { - if (values.length != numLocals + numStack + numLocks) { - throw new JVMCIError("unexpected values length %d in frame (%d locals, %d stack slots, %d locks)", values.length, numLocals, numStack, numLocks); - } - if (slotKinds.length != numLocals + numStack) { - throw new JVMCIError("unexpected slotKinds length %d in frame (%d locals, %d stack slots)", values.length, numLocals, numStack); - } - for (int i = 0; i < slotKinds.length; i++) { - Objects.requireNonNull(values[i]); - JavaKind kind = slotKinds[i]; - if (kind.needsTwoSlots()) { - if (i + 1 >= values.length || values[i + 1] != Value.ILLEGAL) { - throw new JVMCIError("2 slot value at index %d not followed by Value.ILLEGAL", i); - } - } - } - for (int i = slotKinds.length; i < values.length; i++) { - JavaValue lock = values[i]; - Objects.requireNonNull(lock); - if (!(lock instanceof StackLockValue)) { - throw new JVMCIError("Lock at %d must be of type StackLockValue, got %s", i, lock.getClass().getName()); - } - } - } - - /** - * Ensure that the frame state is formatted as expected by the JVM, with null or Illegal in the - * slot following a double word item. This should really be checked in FrameState itself but - * because of Word type rewriting and alternative backends that can't be done. - */ - public boolean validateFormat() { - if (caller() != null) { - caller().validateFormat(); - } - for (int i = 0; i < numLocals + numStack; i++) { - if (values[i] != null) { - JavaKind kind = slotKinds[i]; - if (kind.needsTwoSlots()) { - assert slotKinds.length > i + 1 : String.format("missing second word %s", this); - assert slotKinds[i + 1] == JavaKind.Illegal : this; - } - } - } - return true; - } - - /** - * Gets the kind of a local variable. - * - * @param i the local variable to query - * @return the kind of local variable {@code i} - * @throw {@link IndexOutOfBoundsException} if {@code i < 0 || i >= this.numLocals} - */ - public JavaKind getLocalValueKind(int i) { - Objects.checkIndex(i, numLocals); - return slotKinds[i]; - } - - /** - * Gets the kind of a stack slot. - * - * @param i the local variable to query - * @return the kind of stack slot {@code i} - * @throw {@link IndexOutOfBoundsException} if {@code i < 0 || i >= this.numStack} - */ - public JavaKind getStackValueKind(int i) { - Objects.checkIndex(i, numStack); - return slotKinds[i + numLocals]; - } - - /** - * Gets the value representing the specified local variable. - * - * @param i the local variable index - * @return the value that can be used to reconstruct the local's current value - * @throw {@link IndexOutOfBoundsException} if {@code i < 0 || i >= this.numLocals} - */ - public JavaValue getLocalValue(int i) { - Objects.checkIndex(i, numLocals); - return values[i]; - } - - /** - * Gets the value representing the specified stack slot. - * - * @param i the stack index - * @return the value that can be used to reconstruct the stack slot's current value - * @throw {@link IndexOutOfBoundsException} if {@code i < 0 || i >= this.numStack} - */ - public JavaValue getStackValue(int i) { - Objects.checkIndex(i, numStack); - return values[i + numLocals]; - } - - /** - * Gets the value representing the specified lock. - * - * @param i the lock index - * @return the value that can be used to reconstruct the lock's current value - * @throw {@link IndexOutOfBoundsException} if {@code i < 0 || i >= this.numLocks} - */ - public JavaValue getLockValue(int i) { - Objects.checkIndex(i, numLocks); - return values[i + numLocals + numStack]; - } - - /** - * Gets the caller of this frame. - * - * @return {@code null} if this frame has no caller - */ - public BytecodeFrame caller() { - return (BytecodeFrame) getCaller(); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), - duringCall, - numLocals, - numLocks, - numStack, - rethrowException, - Arrays.hashCode(slotKinds), - Arrays.hashCode(values)); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - BytecodeFrame that = (BytecodeFrame) obj; - return duringCall == that.duringCall && - numLocals == that.numLocals && - numLocks == that.numLocks && - numStack == that.numStack && - rethrowException == that.rethrowException && - Arrays.equals(slotKinds, that.slotKinds) && - Arrays.equals(values, that.values); - } - - @Override - public String toString() { - return CodeUtil.append(new StringBuilder(100), this).toString(); - } - - /** - * Returns a copy of the array describing the Java kinds in {@link #values}. - */ - public JavaKind[] getSlotKinds() { - return (slotKinds == null) ? null : slotKinds.clone(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodePosition.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodePosition.java deleted file mode 100644 index 06a86c39356..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/BytecodePosition.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Objects; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Represents a code position, that is, a chain of inlined methods with bytecode locations, that is - * communicated from the compiler to the runtime system. A code position can be used by the runtime - * system to reconstruct a source-level stack trace for exceptions and to create - * {@linkplain BytecodeFrame frames} for deoptimization. - */ -public class BytecodePosition { - - private final BytecodePosition caller; - private final ResolvedJavaMethod method; - private final int bci; - - /** - * Constructs a new object representing a given parent/caller, a given method, and a given BCI. - * - * @param caller the parent position - * @param method the method - * @param bci a BCI such that {@code method.codeSize() == 0 || bci < method.getCodeSize()}. That - * is, if code size is 0 then allow any value, otherwise the bci must be less than - * the code size. - */ - public BytecodePosition(BytecodePosition caller, ResolvedJavaMethod method, int bci) { - assert method != null; - this.caller = caller; - this.method = method; - this.bci = bci; - int codeSize = method.getCodeSize(); - if (codeSize != 0 && bci >= codeSize) { - throw new IllegalArgumentException(String.format("bci %d is out of range for %s %d bytes", bci, method.format("%H.%n(%p)"), codeSize)); - } - } - - /** - * Converts this code position to a string representation. - * - * @return a string representation of this code position - */ - @Override - public String toString() { - return CodeUtil.append(new StringBuilder(100), this).toString(); - } - - /** - * Deep equality test. - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj != null && getClass() == obj.getClass()) { - BytecodePosition that = (BytecodePosition) obj; - if (this.bci == that.bci && Objects.equals(this.getMethod(), that.getMethod()) && Objects.equals(this.caller, that.caller)) { - return true; - } - } - return false; - } - - @Override - public int hashCode() { - int hc = method.hashCode() * 31 + bci; - if (caller != null) { - hc = (hc * 31) + caller.hashCode(); - } - return hc; - } - - /** - * @return The location within the method, as a bytecode index. The constant {@code -1} may be - * used to indicate the location is unknown, for example within code synthesized by the - * compiler. - */ - public int getBCI() { - return bci; - } - - /** - * @return The runtime interface method for this position. - */ - public ResolvedJavaMethod getMethod() { - return method; - } - - /** - * The position where this position has been called, {@code null} if none. - */ - public BytecodePosition getCaller() { - return caller; - } - - /** - * Adds a caller to the current position returning the new position. - */ - public BytecodePosition addCaller(BytecodePosition link) { - if (getCaller() == null) { - return new BytecodePosition(link, getMethod(), getBCI()); - } else { - return new BytecodePosition(getCaller().addCaller(link), getMethod(), getBCI()); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CPUFeatureName.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CPUFeatureName.java deleted file mode 100644 index 009724406a5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CPUFeatureName.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * A CPU feature identified by a name. - */ -public interface CPUFeatureName { - /** - * Gets the name of this feature. - */ - String name(); - - /** - * Determines if {@code other} equals {@link #name()}. - */ - default boolean nameEquals(String other) { - return name().equals(other); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CallingConvention.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CallingConvention.java deleted file mode 100644 index df87a5408c0..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CallingConvention.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import static jdk.vm.ci.code.ValueUtil.isAllocatableValue; -import static jdk.vm.ci.code.ValueUtil.isStackSlot; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.Value; - -import java.util.List; - -/** - * A calling convention describes the locations in which the arguments for a call are placed and the - * location in which the return value is placed if the call is not void. - */ -public class CallingConvention { - - /** - * Marker interface denoting the type of a call for which a calling convention is requested. - */ - public interface Type { - } - - /** - * The amount of stack space (in bytes) required for the stack-based arguments of the call. - */ - private final int stackSize; - - private final AllocatableValue returnLocation; - - /** - * The ordered locations in which the arguments are placed. - */ - private final List argumentLocations; - - /** - * Creates a description of the registers and stack locations used by a call. - * - * @param stackSize amount of stack space (in bytes) required for the stack-based arguments of - * the call - * @param returnLocation the location for the return value or {@link Value#ILLEGAL} if a void - * call - * @param argumentLocations the ordered locations in which the arguments are placed - */ - public CallingConvention(int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) { - assert argumentLocations != null; - assert returnLocation != null; - this.argumentLocations = List.of(argumentLocations); - this.stackSize = stackSize; - this.returnLocation = returnLocation; - assert verify(); - } - - /** - * Gets the location for the return value or {@link Value#ILLEGAL} if a void call. - */ - public AllocatableValue getReturn() { - return returnLocation; - } - - /** - * Gets the location for the {@code index}'th argument. - */ - public AllocatableValue getArgument(int index) { - return argumentLocations.get(index); - } - - /** - * Gets the amount of stack space (in bytes) required for the stack-based arguments of the call. - */ - public int getStackSize() { - return stackSize; - } - - /** - * Gets the number of locations required for the arguments. - */ - public int getArgumentCount() { - return argumentLocations.size(); - } - - /** - * Gets the locations required for the arguments. - */ - public List getArguments() { - return argumentLocations; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("CallingConvention["); - String sep = ""; - for (Value op : argumentLocations) { - sb.append(sep).append(op); - sep = ", "; - } - if (!returnLocation.equals(Value.ILLEGAL)) { - sb.append(" -> ").append(returnLocation); - } - sb.append("]"); - return sb.toString(); - } - - private boolean verify() { - for (int i = 0; i < argumentLocations.size(); i++) { - Value location = argumentLocations.get(i); - assert isStackSlot(location) || isAllocatableValue(location); - } - return true; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeCacheProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeCacheProvider.java deleted file mode 100644 index e52ffdc227c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeCacheProvider.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.code.site.Call; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.SpeculationLog; - -/** - * Access to code cache related details and requirements. - */ -public interface CodeCacheProvider { - - /** - * Installs code for a given method based on a given compilation result without making it the - * default implementation of the method. - * - * @param method a method implemented by the installed code - * @param compiledCode the compiled code to be added - * @param log the speculation log to be used - * @param installedCode a predefined {@link InstalledCode} object to use as a reference to the - * installed code. If {@code null}, a new {@link InstalledCode} object will be - * created. - * @param profileDeopt specifies if HotSpot should profile deoptimizations for the - * {@code nmethod} associated with this object. - * @return a reference to the ready-to-run code - * @throws BailoutException if the code installation failed - * @throws IllegalArgumentException if {@code installedCode != null} and this object does not - * support a predefined {@link InstalledCode} object - */ - default InstalledCode addCode(ResolvedJavaMethod method, CompiledCode compiledCode, SpeculationLog log, InstalledCode installedCode, boolean profileDeopt) { - return installCode(method, compiledCode, installedCode, log, false, profileDeopt); - } - - /** - * Installs code for a given method based on a given compilation result and makes it the default - * implementation of the method. - * - * @param method a method implemented by the installed code and for which the installed code - * becomes the default implementation - * @param compiledCode the compiled code to be added - * @return a reference to the ready-to-run code - * @throws BailoutException if the code installation failed - * @throws IllegalArgumentException if {@code installedCode != null} and this object does not - * support a predefined {@link InstalledCode} object - */ - default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompiledCode compiledCode) { - return installCode(method, compiledCode, null, null, true, true); - } - - /** - * Installs code based on a given compilation result. - * - * @param method the method compiled to produce {@code compiledCode} or {@code null} if the - * input to {@code compResult} was not a {@link ResolvedJavaMethod} - * @param compiledCode the compiled code to be added - * @param installedCode a pre-allocated {@link InstalledCode} object to use as a reference to - * the installed code. If {@code null}, a new {@link InstalledCode} object will be - * created. - * @param log the speculation log to be used - * @param isDefault specifies if the installed code should be made the default implementation of - * {@code compRequest.getMethod()}. The default implementation for a method is the - * code executed for standard calls to the method. This argument is ignored if - * {@code compRequest == null}. - * @param profileDeopt specifies if HotSpot should profile deoptimizations for the - * {@code nmethod} associated with this object. - * @return a reference to the compiled and ready-to-run installed code - * @throws BailoutException if the code installation failed - */ - InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault, boolean profileDeopt); - - /** - * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be - * raised the next time {@code installedCode} is - * {@linkplain InstalledCode#executeVarargs(Object...) executed}. - */ - void invalidateInstalledCode(InstalledCode installedCode); - - /** - * Gets a name for a {@link Mark} mark. - */ - default String getMarkName(Mark mark) { - return String.valueOf(mark.id); - } - - /** - * Gets a name for the {@linkplain Call#target target} of a {@link Call}. - */ - default String getTargetName(Call call) { - return String.valueOf(call.target); - } - - /** - * Gets the register configuration to use when compiling a given method. - */ - RegisterConfig getRegisterConfig(); - - /** - * Minimum size of the stack area reserved for outgoing parameters. This area is reserved in all - * cases, even when the compiled method has no regular call instructions. - * - * @return the minimum size of the outgoing parameter area in bytes - */ - int getMinimumOutgoingSize(); - - /** - * Gets a description of the target architecture. - */ - TargetDescription getTarget(); - - /** - * Create a new speculation log for the target runtime. - */ - SpeculationLog createSpeculationLog(); - - /** - * Returns the maximum absolute offset of a PC relative call to a given address from any - * position in the code cache or -1 when not applicable. Intended for determining the required - * size of address/offset fields. - */ - long getMaxCallTargetOffset(long address); - - /** - * Determines if debug info should also be emitted at non-safepoint locations. - */ - boolean shouldDebugNonSafepoints(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java deleted file mode 100644 index 59af250a695..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CodeUtil.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Map; - -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaUtil; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.Signature; - -/** - * Miscellaneous collection of utility methods used by {@code jdk.vm.ci.code} and its clients. - */ -public class CodeUtil { - - public static final String NEW_LINE = System.lineSeparator(); - - public static final int K = 1024; - public static final int M = 1024 * 1024; - - public static boolean isOdd(int n) { - return (n & 1) == 1; - } - - public static boolean isEven(int n) { - return (n & 1) == 0; - } - - /** - * Checks whether the specified integer is a power of two. - * - * @param val the value to check - * @return {@code true} if the value is a power of two; {@code false} otherwise - */ - public static boolean isPowerOf2(int val) { - return val > 0 && (val & val - 1) == 0; - } - - /** - * Checks whether the specified long is a power of two. - * - * @param val the value to check - * @return {@code true} if the value is a power of two; {@code false} otherwise - */ - public static boolean isPowerOf2(long val) { - return val > 0 && (val & val - 1) == 0; - } - - /** - * Computes the log (base 2) of the specified integer, rounding down. (E.g {@code log2(8) = 3}, - * {@code log2(21) = 4} ) - * - * @param val the value - * @return the log base 2 of the value - */ - public static int log2(int val) { - assert val > 0; - return (Integer.SIZE - 1) - Integer.numberOfLeadingZeros(val); - } - - /** - * Computes the log (base 2) of the specified long, rounding down. (E.g {@code log2(8) = 3}, - * {@code log2(21) = 4}) - * - * @param val the value - * @return the log base 2 of the value - */ - public static int log2(long val) { - assert val > 0; - return (Long.SIZE - 1) - Long.numberOfLeadingZeros(val); - } - - /** - * Narrow an integer value to a given bit width, and return the result as a signed long. - * - * @param value the value - * @param resultBits the result bit width - * @return {@code value} interpreted as {@code resultBits} bit number, encoded as signed long - */ - public static long narrow(long value, int resultBits) { - long ret = value & mask(resultBits); - return signExtend(ret, resultBits); - } - - /** - * Sign extend an integer. - * - * @param value the input value - * @param inputBits the bit width of the input value - * @return a signed long with the same value as the signed {@code inputBits}-bit number - * {@code value} - */ - public static long signExtend(long value, int inputBits) { - if (inputBits < 64) { - if ((value >>> (inputBits - 1) & 1) == 1) { - return value | (-1L << inputBits); - } else { - return value & ~(-1L << inputBits); - } - } else { - return value; - } - } - - /** - * Zero extend an integer. - * - * @param value the input value - * @param inputBits the bit width of the input value - * @return an unsigned long with the same value as the unsigned {@code inputBits}-bit number - * {@code value} - */ - public static long zeroExtend(long value, int inputBits) { - if (inputBits < 64) { - return value & ~(-1L << inputBits); - } else { - return value; - } - } - - /** - * Convert an integer to long. - * - * @param value the input value - * @param inputBits the bit width of the input value - * @param unsigned whether the values should be interpreted as signed or unsigned - * @return a long with the same value as the {@code inputBits}-bit number {@code value} - */ - public static long convert(long value, int inputBits, boolean unsigned) { - if (unsigned) { - return zeroExtend(value, inputBits); - } else { - return signExtend(value, inputBits); - } - } - - /** - * Get a bitmask with the low {@code bits} bit set and the high {@code 64 - bits} bit clear. - */ - public static long mask(int bits) { - assert 0 <= bits && bits <= 64; - if (bits == 64) { - return 0xffffffffffffffffL; - } else { - return (1L << bits) - 1; - } - } - - /** - * Get the minimum value representable in a {@code bits} bit signed integer. - */ - public static long minValue(int bits) { - assert 0 < bits && bits <= 64; - return -1L << (bits - 1); - } - - /** - * Get the maximum value representable in a {@code bits} bit signed integer. - */ - public static long maxValue(int bits) { - assert 0 < bits && bits <= 64; - return mask(bits - 1); - } - - /** - * Formats the values in a frame as a tabulated string. - * - * @param frame - * @return the values in {@code frame} as a tabulated string - */ - public static String tabulateValues(BytecodeFrame frame) { - int cols = Math.max(frame.numLocals, Math.max(frame.numStack, frame.numLocks)); - assert cols > 0; - ArrayList cells = new ArrayList<>(); - cells.add(""); - for (int i = 0; i < cols; i++) { - cells.add(i); - } - cols++; - if (frame.numLocals != 0) { - cells.add("locals:"); - cells.addAll(Arrays.asList(frame.values).subList(0, frame.numLocals)); - cells.addAll(Collections.nCopies(cols - frame.numLocals - 1, "")); - } - if (frame.numStack != 0) { - cells.add("stack:"); - cells.addAll(Arrays.asList(frame.values).subList(frame.numLocals, frame.numLocals + frame.numStack)); - cells.addAll(Collections.nCopies(cols - frame.numStack - 1, "")); - } - if (frame.numLocks != 0) { - cells.add("locks:"); - cells.addAll(Arrays.asList(frame.values).subList(frame.numLocals + frame.numStack, frame.values.length)); - cells.addAll(Collections.nCopies(cols - frame.numLocks - 1, "")); - } - Object[] cellArray = cells.toArray(); - for (int i = 0; i < cellArray.length; i++) { - if ((i % cols) != 0) { - cellArray[i] = "|" + cellArray[i]; - } - } - return CodeUtil.tabulate(cellArray, cols, 1, 1); - } - - /** - * Formats a given table as a string. The value of each cell is produced by - * {@link String#valueOf(Object)}. - * - * @param cells the cells of the table in row-major order - * @param cols the number of columns per row - * @param lpad the number of space padding inserted before each formatted cell value - * @param rpad the number of space padding inserted after each formatted cell value - * @return a string with one line per row and each column left-aligned - */ - public static String tabulate(Object[] cells, int cols, int lpad, int rpad) { - int rows = (cells.length + (cols - 1)) / cols; - int[] colWidths = new int[cols]; - for (int col = 0; col < cols; col++) { - for (int row = 0; row < rows; row++) { - int index = col + (row * cols); - if (index < cells.length) { - Object cell = cells[index]; - colWidths[col] = Math.max(colWidths[col], String.valueOf(cell).length()); - } - } - } - StringBuilder sb = new StringBuilder(); - String nl = NEW_LINE; - for (int row = 0; row < rows; row++) { - for (int col = 0; col < cols; col++) { - int index = col + (row * cols); - if (index < cells.length) { - for (int i = 0; i < lpad; i++) { - sb.append(' '); - } - Object cell = cells[index]; - String s = String.valueOf(cell); - int w = s.length(); - sb.append(s); - while (w < colWidths[col]) { - sb.append(' '); - w++; - } - for (int i = 0; i < rpad; i++) { - sb.append(' '); - } - } - } - sb.append(nl); - } - return sb.toString(); - } - - /** - * Appends a formatted code position to a {@link StringBuilder}. - * - * @param sb the {@link StringBuilder} to append to - * @param pos the code position to format and append to {@code sb} - * @return the value of {@code sb} - */ - public static StringBuilder append(StringBuilder sb, BytecodePosition pos) { - MetaUtil.appendLocation(sb.append("at "), pos.getMethod(), pos.getBCI()); - if (pos.getCaller() != null) { - sb.append(NEW_LINE); - append(sb, pos.getCaller()); - } - return sb; - } - - /** - * Appends a formatted frame to a {@link StringBuilder}. - * - * @param sb the {@link StringBuilder} to append to - * @param frame the frame to format and append to {@code sb} - * @return the value of {@code sb} - */ - public static StringBuilder append(StringBuilder sb, BytecodeFrame frame) { - MetaUtil.appendLocation(sb.append("at "), frame.getMethod(), frame.getBCI()); - assert sb.charAt(sb.length() - 1) == ']'; - sb.deleteCharAt(sb.length() - 1); - sb.append(", duringCall: ").append(frame.duringCall).append(", rethrow: ").append(frame.rethrowException).append(']'); - if (frame.values != null && frame.values.length > 0) { - sb.append(NEW_LINE); - String table = tabulateValues(frame); - String[] rows = table.split(NEW_LINE); - for (int i = 0; i < rows.length; i++) { - String row = rows[i]; - if (!row.trim().isEmpty()) { - sb.append(" ").append(row); - if (i != rows.length - 1) { - sb.append(NEW_LINE); - } - } - } - } - if (frame.caller() != null) { - sb.append(NEW_LINE); - append(sb, frame.caller()); - } else if (frame.getCaller() != null) { - sb.append(NEW_LINE); - append(sb, frame.getCaller()); - } - return sb; - } - - public interface RefMapFormatter { - - String formatStackSlot(int frameRefMapIndex); - } - - /** - * Formats a location present in a reference map. - */ - public static class DefaultRefMapFormatter implements RefMapFormatter { - - /** - * The size of a stack slot. - */ - public final int slotSize; - - /** - * The register used as the frame pointer. - */ - public final Register fp; - - /** - * The offset (in bytes) from the slot pointed to by {@link #fp} to the slot corresponding - * to bit 0 in the frame reference map. - */ - public final int refMapToFPOffset; - - public DefaultRefMapFormatter(int slotSize, Register fp, int refMapToFPOffset) { - this.slotSize = slotSize; - this.fp = fp; - this.refMapToFPOffset = refMapToFPOffset; - } - - @Override - public String formatStackSlot(int frameRefMapIndex) { - int refMapOffset = frameRefMapIndex * slotSize; - int fpOffset = refMapOffset + refMapToFPOffset; - if (fpOffset >= 0) { - return fp + "+" + fpOffset; - } - return fp.name + fpOffset; - } - } - - public static class NumberedRefMapFormatter implements RefMapFormatter { - - @Override - public String formatStackSlot(int frameRefMapIndex) { - return "s" + frameRefMapIndex; - } - - public String formatRegister(int regRefMapIndex) { - return "r" + regRefMapIndex; - } - } - - /** - * Appends a formatted debug info to a {@link StringBuilder}. - * - * @param sb the {@link StringBuilder} to append to - * @param info the debug info to format and append to {@code sb} - * @return the value of {@code sb} - */ - public static StringBuilder append(StringBuilder sb, DebugInfo info, RefMapFormatter formatterArg) { - RefMapFormatter formatter = formatterArg; - if (formatter == null) { - formatter = new NumberedRefMapFormatter(); - } - String nl = NEW_LINE; - ReferenceMap refMap = info.getReferenceMap(); - if (refMap != null) { - sb.append(refMap.toString()); - } - RegisterSaveLayout calleeSaveInfo = info.getCalleeSaveInfo(); - if (calleeSaveInfo != null) { - sb.append("callee-save-info:").append(nl); - Map map = calleeSaveInfo.slotsToRegisters(true); - for (Map.Entry e : map.entrySet()) { - sb.append(" ").append(e.getValue()).append(" -> ").append(formatter.formatStackSlot(e.getKey())).append(nl); - } - } - BytecodeFrame frame = info.frame(); - if (frame != null) { - append(sb, frame); - } else if (info.getBytecodePosition() != null) { - append(sb, info.getBytecodePosition()); - } - return sb; - } - - /** - * Create a calling convention from a {@link ResolvedJavaMethod}. - */ - public static CallingConvention getCallingConvention(CodeCacheProvider codeCache, CallingConvention.Type type, ResolvedJavaMethod method, ValueKindFactory valueKindFactory) { - Signature sig = method.getSignature(); - JavaType retType = sig.getReturnType(null); - int sigCount = sig.getParameterCount(false); - JavaType[] argTypes; - int argIndex = 0; - if (!method.isStatic()) { - argTypes = new JavaType[sigCount + 1]; - argTypes[argIndex++] = method.getDeclaringClass(); - } else { - argTypes = new JavaType[sigCount]; - } - for (int i = 0; i < sigCount; i++) { - argTypes[argIndex++] = sig.getParameterType(i, null); - } - - RegisterConfig registerConfig = codeCache.getRegisterConfig(); - return registerConfig.getCallingConvention(type, retType, argTypes, valueKindFactory); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequest.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequest.java deleted file mode 100644 index dabaf04f8b7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Represents a request to compile a method. - */ -public class CompilationRequest { - - private final ResolvedJavaMethod method; - - private final int entryBCI; - - /** - * Creates a request to compile a method starting at its entry point. - * - * @param method the method to be compiled - */ - public CompilationRequest(ResolvedJavaMethod method) { - this(method, -1); - } - - /** - * Creates a request to compile a method starting at a given BCI. - * - * @param method the method to be compiled - * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the - * method's entry point - */ - public CompilationRequest(ResolvedJavaMethod method, int entryBCI) { - assert method != null; - this.method = method; - this.entryBCI = entryBCI; - } - - /** - * Gets the method to be compiled. - */ - public ResolvedJavaMethod getMethod() { - return method; - } - - /** - * Gets the bytecode index (BCI) at which to start compiling where -1 denotes a non-OSR - * compilation request and all other values denote an on stack replacement (OSR) compilation - * request. - */ - public int getEntryBCI() { - return entryBCI; - } - - @Override - public String toString() { - return method.format("%H.%n(%p)@" + entryBCI); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequestResult.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequestResult.java deleted file mode 100644 index 1189e563a72..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompilationRequestResult.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Provides information about the result of a {@link CompilationRequest}. - */ -public interface CompilationRequestResult { - - /** - * Determines if the compilation was successful. - * - * @return a non-null object whose {@link Object#toString()} describes the failure or null if - * compilation was successful - */ - Object getFailure(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompiledCode.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompiledCode.java deleted file mode 100644 index 75a5429ac09..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/CompiledCode.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Marker type for an object containing the output of a compiler in a form suitable for installing - * into a managed code heap. Since the details of a code heap are specific to each runtime, this - * interface does not specify any methods. - */ -public interface CompiledCode { -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/DebugInfo.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/DebugInfo.java deleted file mode 100644 index da5a6a01313..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/DebugInfo.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Objects; - -/** - * Represents the debugging information for a particular point of execution. This information - * includes: - *
    - *
  • a {@linkplain #getBytecodePosition() bytecode position}
  • - *
  • a reference map for registers and stack slots in the current frame
  • - *
  • a map from bytecode locals and operand stack slots to their values or locations from which - * their values can be read
  • - *
  • a map from the registers (in the caller's frame) to the slots where they are saved in the - * current frame
  • - *
- */ -public final class DebugInfo { - - private final BytecodePosition bytecodePosition; - private ReferenceMap referenceMap; - private final VirtualObject[] virtualObjectMapping; - private RegisterSaveLayout calleeSaveInfo; - - /** - * Creates a new {@link DebugInfo} from the given values. - * - * @param codePos the {@linkplain BytecodePosition code position} or {@linkplain BytecodeFrame - * frame} info - * @param virtualObjectMapping the mapping of {@link VirtualObject}s to their real values. This - * array is now owned by this object and must not be mutated by the caller. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `virtualObjectMapping`") - public DebugInfo(BytecodePosition codePos, VirtualObject[] virtualObjectMapping) { - this.bytecodePosition = codePos; - this.virtualObjectMapping = virtualObjectMapping; - } - - public DebugInfo(BytecodePosition codePos) { - this(codePos, null); - } - - public void setReferenceMap(ReferenceMap referenceMap) { - this.referenceMap = referenceMap; - } - - /** - * @return {@code true} if this debug information has a frame - */ - public boolean hasFrame() { - return getBytecodePosition() instanceof BytecodeFrame; - } - - /** - * Gets the deoptimization information for each inlined frame (if available). - * - * @return {@code null} if no frame de-opt info is {@linkplain #hasFrame() available} - */ - public BytecodeFrame frame() { - if (hasFrame()) { - return (BytecodeFrame) getBytecodePosition(); - } - return null; - } - - @Override - public String toString() { - return CodeUtil.append(new StringBuilder(100), this, null).toString(); - } - - /** - * @return The code position (including all inlined methods) of this debug info. If this is a - * {@link BytecodeFrame} instance, then it is also the deoptimization information for - * each inlined frame. - */ - public BytecodePosition getBytecodePosition() { - return bytecodePosition; - } - - public ReferenceMap getReferenceMap() { - return referenceMap; - } - - public VirtualObject[] getVirtualObjectMapping() { - return virtualObjectMapping; - } - - /** - * Sets the map from the registers (in the caller's frame) to the slots where they are saved in - * the current frame. - */ - public void setCalleeSaveInfo(RegisterSaveLayout calleeSaveInfo) { - this.calleeSaveInfo = calleeSaveInfo; - } - - /** - * Gets the map from the registers (in the caller's frame) to the slots where they are saved in - * the current frame. If no such information is available, {@code null} is returned. - */ - public RegisterSaveLayout getCalleeSaveInfo() { - return calleeSaveInfo; - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException("hashCode"); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DebugInfo) { - DebugInfo that = (DebugInfo) obj; - if (Objects.equals(this.bytecodePosition, that.bytecodePosition) && Objects.equals(this.calleeSaveInfo, that.calleeSaveInfo) && Objects.equals(this.referenceMap, that.referenceMap)) { - return true; - } - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java deleted file mode 100644 index 62c0b609146..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Represents a compiled instance of a method. It may have been invalidated or removed in the - * meantime. - */ -public class InstalledCode { - - /** - * Address of the entity (e.g., HotSpot {@code nmethod} or {@code RuntimeStub}) representing - * this installed code. - */ - protected long address; - - /** - * Address of the entryPoint of this installed code. - */ - protected long entryPoint; - - /** - * Counts how often the address field was reassigned. - */ - protected long version; - - protected final String name; - - /** - * The maximum length of an InstalledCode name. This name is typically installed into - * the code cache so it should have a reasonable limit. - */ - public static final int MAX_NAME_LENGTH = 2048; - - /** - * @param name the name to be associated with the installed code. Can be null and - * must be no longer than {@link #MAX_NAME_LENGTH}. - * - * @throws IllegalArgumentException if {@code name.length >} {@link #MAX_NAME_LENGTH} - */ - public InstalledCode(String name) { - if (name != null && name.length() > MAX_NAME_LENGTH) { - String msg = String.format("name length (%d) is greater than %d (name[0:%s] = %s)", - name.length(), MAX_NAME_LENGTH, MAX_NAME_LENGTH, name.substring(0, MAX_NAME_LENGTH)); - throw new IllegalArgumentException(msg); - } - this.name = name; - } - - /** - * @return the address of entity (e.g., HotSpot {@code nmethod} or {@code RuntimeStub}) - * representing this installed code - */ - public long getAddress() { - return address; - } - - /** - * @return the address of the normal entry point of the installed code. - */ - public long getEntryPoint() { - return entryPoint; - } - - /** - * @return the version number of this installed code - */ - public final long getVersion() { - return version; - } - - /** - * Returns the name of this installed code. - */ - public String getName() { - return name; - } - - /** - * Returns the start address of this installed code if it is {@linkplain #isValid() valid}, 0 - * otherwise. - */ - public long getStart() { - return 0; - } - - /** - * @return true if the code represented by this object is still valid for invocation, false - * otherwise (may happen due to deopt, etc.) - */ - public boolean isValid() { - return entryPoint != 0; - } - - /** - * @return true if this object still points to installed code - */ - public boolean isAlive() { - return address != 0; - } - - /** - * Returns a copy of this installed code if it is {@linkplain #isValid() valid}, null otherwise. - */ - public byte[] getCode() { - return null; - } - - /** - * Equivalent to calling {@link #invalidate(boolean)} with a {@code true} argument. - */ - public void invalidate() { - invalidate(true); - } - - /** - * Invalidates this installed code such that any subsequent - * {@linkplain #executeVarargs(Object...) invocation} will throw an - * {@link InvalidInstalledCodeException}. - * - * If this installed code is already {@linkplain #isValid() invalid}, this method has no effect. - * A subsequent call to {@link #isAlive()} or {@link #isValid()} on this object will return - * {@code false}. - * - * @param deoptimize if {@code true}, all existing invocations will be immediately deoptimized. - * If {@code false}, any existing invocation will continue until it completes or - * there is a subsequent call to this method with {@code deoptimize == true} before - * the invocation completes. - */ - public void invalidate(boolean deoptimize) { - throw new UnsupportedOperationException(); - } - - /** - * Executes the installed code with a variable number of arguments. - * - * @param args the array of object arguments - * @return the value returned by the executed code - */ - @SuppressWarnings("unused") - public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - throw new UnsupportedOperationException(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InvalidInstalledCodeException.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InvalidInstalledCodeException.java deleted file mode 100644 index 7df5e2d8f18..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InvalidInstalledCodeException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Exception thrown by the runtime in case an invalidated machine code is called. - */ -public final class InvalidInstalledCodeException extends Exception { - - public InvalidInstalledCodeException() { - } - - public InvalidInstalledCodeException(String message) { - super(message); - } - - private static final long serialVersionUID = -3540232440794244844L; -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Location.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Location.java deleted file mode 100644 index 4e0c58d7208..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Location.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Represents a location where a value can be stored. This can be either a {@link Register} or a - * stack slot. - */ -public final class Location { - - public final Register reg; - public final int offset; - - private Location(Register reg, int offset) { - this.reg = reg; - this.offset = offset; - } - - /** - * Create a {@link Location} for a register. - */ - public static Location register(Register reg) { - return new Location(reg, 0); - } - - /** - * Create a {@link Location} for a vector subregister. - * - * @param reg the {@link Register vector register} - * @param offset the offset in bytes into the vector register - */ - public static Location subregister(Register reg, int offset) { - return new Location(reg, offset); - } - - /** - * Create a {@link Location} for a stack slot. - */ - public static Location stack(int offset) { - return new Location(null, offset); - } - - public boolean isRegister() { - return reg != null; - } - - public boolean isStack() { - return reg == null; - } - - @Override - public String toString() { - String regName; - if (isRegister()) { - regName = reg.name + ":"; - } else { - regName = "stack:"; - } - return regName + offset; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/MemoryBarriers.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/MemoryBarriers.java deleted file mode 100644 index 08bc0856d3e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/MemoryBarriers.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Constants and intrinsic definition for memory barriers. - * - * The documentation for each constant is taken from Doug Lea's - * The JSR-133 Cookbook for Compiler - * Writers. - *

- * The {@code JMM_*} constants capture the memory barriers necessary to implement the Java Memory - * Model with respect to volatile field accesses. Their values are explained by this comment from - * templateTable_i486.cpp in the HotSpot source code: - * - *

- * Volatile variables demand their effects be made known to all CPU's in
- * order.  Store buffers on most chips allow reads & writes to reorder; the
- * JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
- * memory barrier (i.e., it's not sufficient that the interpreter does not
- * reorder volatile references, the hardware also must not reorder them).
- *
- * According to the new Java Memory Model (JMM):
- * (1) All volatiles are serialized wrt to each other.
- * ALSO reads & writes act as acquire & release, so:
- * (2) A read cannot let unrelated NON-volatile memory refs that happen after
- * the read float up to before the read.  It's OK for non-volatile memory refs
- * that happen before the volatile read to float down below it.
- * (3) Similarly, a volatile write cannot let unrelated NON-volatile memory refs
- * that happen BEFORE the write float down to after the write.  It's OK for
- * non-volatile memory refs that happen after the volatile write to float up
- * before it.
- *
- * We only put in barriers around volatile refs (they are expensive), not
- * _between_ memory refs (which would require us to track the flavor of the
- * previous memory refs).  Requirements (2) and (3) require some barriers
- * before volatile stores and after volatile loads.  These nearly cover
- * requirement (1) but miss the volatile-store-volatile-load case.  This final
- * case is placed after volatile-stores although it could just as well go
- * before volatile-loads.
- * 
- */ -public class MemoryBarriers { - - /** - * The sequence {@code Load1; LoadLoad; Load2} ensures that {@code Load1}'s data are loaded - * before data accessed by {@code Load2} and all subsequent load instructions are loaded. In - * general, explicit {@code LoadLoad} barriers are needed on processors that perform speculative - * loads and/or out-of-order processing in which waiting load instructions can bypass waiting - * stores. On processors that guarantee to always preserve load ordering, these barriers amount - * to no-ops. - */ - public static final int LOAD_LOAD = 0x0001; - - /** - * The sequence {@code Load1; LoadStore; Store2} ensures that {@code Load1}'s data are loaded - * before all data associated with {@code Store2} and subsequent store instructions are flushed. - * {@code LoadStore} barriers are needed only on those out-of-order processors in which waiting - * store instructions can bypass loads. - */ - public static final int LOAD_STORE = 0x0002; - - /** - * The sequence {@code Store1; StoreLoad; Load2} ensures that {@code Store1}'s data are made - * visible to other processors (i.e., flushed to main memory) before data accessed by - * {@code Load2} and all subsequent load instructions are loaded. {@code StoreLoad} barriers - * protect against a subsequent load incorrectly using {@code Store1}'s data value rather than - * that from a more recent store to the same location performed by a different processor. - * Because of this, on the processors discussed below, a {@code StoreLoad} is strictly necessary - * only for separating stores from subsequent loads of the same location(s) as were stored - * before the barrier. {@code StoreLoad} barriers are needed on nearly all recent - * multiprocessors, and are usually the most expensive kind. Part of the reason they are - * expensive is that they must disable mechanisms that ordinarily bypass cache to satisfy loads - * from write-buffers. This might be implemented by letting the buffer fully flush, among other - * possible stalls. - */ - public static final int STORE_LOAD = 0x0004; - - /** - * The sequence {@code Store1; StoreStore; Store2} ensures that {@code Store1}'s data are - * visible to other processors (i.e., flushed to memory) before the data associated with - * {@code Store2} and all subsequent store instructions. In general, {@code StoreStore} barriers - * are needed on processors that do not otherwise guarantee strict ordering of flushes from - * write buffers and/or caches to other processors or main memory. - */ - public static final int STORE_STORE = 0x0008; - - public static final int JMM_PRE_VOLATILE_WRITE = LOAD_STORE | STORE_STORE; - public static final int JMM_POST_VOLATILE_WRITE = STORE_LOAD | STORE_STORE; - public static final int JMM_PRE_VOLATILE_READ = 0; - public static final int JMM_POST_VOLATILE_READ = LOAD_LOAD | LOAD_STORE; - - public static String barriersString(int barriers) { - StringBuilder sb = new StringBuilder(); - sb.append((barriers & LOAD_LOAD) != 0 ? "LOAD_LOAD " : ""); - sb.append((barriers & LOAD_STORE) != 0 ? "LOAD_STORE " : ""); - sb.append((barriers & STORE_LOAD) != 0 ? "STORE_LOAD " : ""); - sb.append((barriers & STORE_STORE) != 0 ? "STORE_STORE " : ""); - return sb.toString().trim(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ReferenceMap.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ReferenceMap.java deleted file mode 100644 index 305c503105a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ReferenceMap.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Marker type for an object containing information about where the object references are in machine - * state (e.g., registers or stack locations). This is typically associated with an execution point - * in compiled code. - */ -public abstract class ReferenceMap { -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java deleted file mode 100644 index f271053db1e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/Register.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.ValueKind; - -/** - * Represents a target machine register. - */ -public final class Register implements Comparable { - - public static final RegisterCategory SPECIAL = new RegisterCategory("SPECIAL"); - - /** - * Invalid register. - */ - public static final Register None = new Register(-1, -1, "noreg", SPECIAL); - - /** - * The identifier for this register that is unique across all the registers in a - * {@link Architecture}. A valid register has {@code number >= 0}. - */ - public final int number; - - /** - * The mnemonic of this register. - */ - public final String name; - - /** - * The actual encoding in a target machine instruction for this register, which may or may not - * be the same as {@link #number}. - */ - public final int encoding; - - /** - * The assembler calls this method to get the register's encoding. - */ - public int encoding() { - return encoding; - } - - /** - * A platform specific register category that describes which values can be stored in a - * register. - */ - private final RegisterCategory registerCategory; - - /** - * A platform specific register type that describes which values can be stored in a register. - */ - public static class RegisterCategory { - - private final String name; - private final boolean mayContainReference; - - public RegisterCategory(String name) { - this(name, true); - } - - public RegisterCategory(String name, boolean mayContainReference) { - this.name = name; - this.mayContainReference = mayContainReference; - } - - @Override - public String toString() { - return name; - } - - @Override - public int hashCode() { - return 23 + name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof RegisterCategory) { - RegisterCategory that = (RegisterCategory) obj; - return this.name.equals(that.name); - } - return false; - } - } - - /** - * Creates a {@link Register} instance. - * - * @param number unique identifier for the register - * @param encoding the target machine encoding for the register - * @param name the mnemonic name for the register - * @param registerCategory the register category - */ - public Register(int number, int encoding, String name, RegisterCategory registerCategory) { - this.number = number; - this.name = name; - this.registerCategory = registerCategory; - this.encoding = encoding; - } - - public RegisterCategory getRegisterCategory() { - return registerCategory; - } - - /** - * Determine whether this register needs to be part of the reference map. - */ - public boolean mayContainReference() { - return registerCategory.mayContainReference; - } - - /** - * Gets this register as a {@linkplain RegisterValue value} with a specified kind. - * - * @param kind the specified kind - * @return the {@link RegisterValue} - */ - public RegisterValue asValue(ValueKind kind) { - return new RegisterValue(kind, this); - } - - /** - * Gets this register as a {@linkplain RegisterValue value} with no particular kind. - * - * @return a {@link RegisterValue} with {@link ValueKind#Illegal} kind. - */ - public RegisterValue asValue() { - return asValue(ValueKind.Illegal); - } - - /** - * Determines if this is a valid register. - * - * @return {@code true} iff this register is valid - */ - public boolean isValid() { - return number >= 0; - } - - @Override - public String toString() { - return name; - } - - @Override - public int compareTo(Register o) { - if (number < o.number) { - return -1; - } - if (number > o.number) { - return 1; - } - return 0; - } - - @Override - public int hashCode() { - return 17 + name.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Register) { - Register other = (Register) obj; - if (number == other.number) { - assert name.equals(other.name); - assert encoding == other.encoding; - assert registerCategory.equals(other.registerCategory); - return true; - } - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterAttributes.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterAttributes.java deleted file mode 100644 index 65268774484..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterAttributes.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * A collection of register attributes. The specific attribute values for a register may be local to - * a compilation context. For example, a {@link RegisterConfig} in use during a compilation will - * determine which registers are callee saved. - */ -public class RegisterAttributes { - - private final boolean callerSave; - private final boolean calleeSave; - private final boolean allocatable; - - public RegisterAttributes(boolean isCallerSave, boolean isCalleeSave, boolean isAllocatable) { - this.callerSave = isCallerSave; - this.calleeSave = isCalleeSave; - this.allocatable = isAllocatable; - } - - public static final RegisterAttributes NONE = new RegisterAttributes(false, false, false); - - /** - * Creates a map from register {@linkplain Register#number numbers} to register - * {@linkplain RegisterAttributes attributes} for a given register configuration and set of - * registers. - * - * @param registerConfig a register configuration - * @param registers a set of registers - * @return an array whose length is the max register number in {@code registers} plus 1. An - * element at index i holds the attributes of the register whose number is i. - */ - public static List createMap(RegisterConfig registerConfig, List registers) { - RegisterAttributes[] map = new RegisterAttributes[registers.size()]; - List callerSaveRegisters = registerConfig.getCallerSaveRegisters(); - List calleeSaveRegisters = registerConfig.getCalleeSaveRegisters() == null ? Collections.emptyList() : registerConfig.getCalleeSaveRegisters(); - List allocatableRegisters = registerConfig.getAllocatableRegisters(); - for (Register reg : registers) { - if (reg != null) { - RegisterAttributes attr = new RegisterAttributes(callerSaveRegisters.contains(reg), calleeSaveRegisters.contains(reg), allocatableRegisters.contains(reg)); - if (map.length <= reg.number) { - map = Arrays.copyOf(map, reg.number + 1); - } - map[reg.number] = attr; - } - } - for (int i = 0; i < map.length; i++) { - if (map[i] == null) { - map[i] = NONE; - } - } - return List.of(map); - } - - /** - * @return {@code true} if a register is available for use by a register allocator otherwise - * {@code false} - */ - public boolean isAllocatable() { - return allocatable; - } - - /** - * @return {@code true} if a register whose value preservation (if required) across a call is - * the responsibility of the callee otherwise {@code false} - */ - public boolean isCalleeSave() { - return calleeSave; - } - - /** - * @return {@code true} if a register whose value preservation (if required) across a call is - * the responsibility of the caller otherwise {@code false} - */ - public boolean isCallerSave() { - return callerSave; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterConfig.java deleted file mode 100644 index 0cc1980b28f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterConfig.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.List; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.ValueKind; - -/** - * A register configuration binds roles and {@linkplain RegisterAttributes attributes} to physical - * registers. - */ -public interface RegisterConfig { - - /** - * Gets the register to be used for returning a value of a given kind. - */ - Register getReturnRegister(JavaKind kind); - - /** - * Gets the maximum allowed size of the frame. - */ - default int getMaximumFrameSize() { - return Integer.MAX_VALUE; - } - - /** - * Gets the register used as the frame pointer. Spill slots and outgoing stack-based arguments - * are addressed relative to this register. - */ - Register getFrameRegister(); - - /** - * Gets the calling convention describing how arguments are passed. - * - * @param type the type of calling convention being requested - * @param returnType the return type (can be null for methods returning {@code void}) - * @param parameterTypes the types of the arguments of the call - * @param valueKindFactory the factory to create custom {@link ValueKind ValueKinds} - */ - CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory valueKindFactory); - - /** - * Gets the ordered set of registers that are can be used to pass parameters according to a - * given calling convention. - * - * @param type the type of calling convention - * @param kind specifies what kind of registers is being requested - * @return the ordered set of registers that may be used to pass parameters in a call conforming - * to {@code type} - */ - List getCallingConventionRegisters(Type type, JavaKind kind); - - /** - * Gets the set of all registers that might be used by the register allocator. - */ - List getAllocatableRegisters(); - - /** - * Filters a set of registers and returns only those that can be used by the register allocator - * for a value of a particular kind. - */ - List filterAllocatableRegisters(PlatformKind kind, List registers); - - /** - * Gets the registers whose values must be preserved by a method across any call it makes. - */ - List getCallerSaveRegisters(); - - /** - * Gets the registers whose values must be preserved by the callee. - */ - List getCalleeSaveRegisters(); - - /** - * Returns the storage kind for a callee-save register, which determines how the register is - * saved and restored. For example, according to the Windows x64 ABI, the upper portions of - * XMM0-XMM15 are considered destroyed, so saving the full width of these registers is not - * necessary. - */ - default PlatformKind getCalleeSaveRegisterStorageKind(Architecture arch, Register calleeSaveRegister) { - return arch.getLargestStorableKind(calleeSaveRegister.getRegisterCategory()); - } - - /** - * Gets a map from register {@linkplain Register#number numbers} to register - * {@linkplain RegisterAttributes attributes} for this register configuration. - * - * @return a list where an element at index i holds the attributes of the register whose - * number is i - */ - List getAttributesMap(); - - /** - * Determines if all {@link #getAllocatableRegisters() allocatable} registers are - * {@link #getCallerSaveRegisters() caller saved}. - */ - boolean areAllAllocatableRegistersCallerSaved(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterSaveLayout.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterSaveLayout.java deleted file mode 100644 index 49c9608a21e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterSaveLayout.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.TreeMap; - -/** - * A map from registers to frame slots. This can be used to describe where callee saved registers - * are saved in a callee's frame. - */ -public final class RegisterSaveLayout { - - /** - * Keys. - */ - private final Register[] registers; - - /** - * Slot indexes relative to stack pointer. - */ - private final int[] slots; - - /** - * Creates a map from registers to frame slots. - * - * @param registers the keys in the map - * @param slots frame slot index for each register in {@code registers} - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `registers` and `slots`") - public RegisterSaveLayout(Register[] registers, int[] slots) { - assert registers.length == slots.length; - this.registers = registers; - this.slots = slots; - assert registersToSlots(false).size() == registers.length : "non-unique registers"; - assert new HashSet<>(registersToSlots(false).values()).size() == slots.length : "non-unqiue slots"; - } - - /** - * Gets the number of entries in this map. - */ - public int size() { - return registers.length; - } - - /** - * Gets the frame slot index for a given register. - * - * @param register register to get the frame slot index for - * @return frame slot index - */ - public int registerToSlot(Register register) { - for (int i = 0; i < registers.length; i++) { - if (register.equals(registers[i])) { - return slots[i]; - } - } - throw new IllegalArgumentException(register + " not saved by this layout: " + this); - } - - /** - * Gets this layout information as a {@link Map} from registers to slots. - */ - public Map registersToSlots(boolean sorted) { - Map result; - if (sorted) { - result = new TreeMap<>(); - } else { - result = new HashMap<>(); - } - for (int i = 0; i < registers.length; i++) { - result.put(registers[i], slots[i]); - } - return result; - } - - /** - * Gets this layout information as a {@link Map} from slots to registers. - */ - public Map slotsToRegisters(boolean sorted) { - Map result; - if (sorted) { - result = new TreeMap<>(); - } else { - result = new HashMap<>(); - } - for (int i = 0; i < registers.length; i++) { - result.put(slots[i], registers[i]); - } - return result; - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof RegisterSaveLayout) { - RegisterSaveLayout that = (RegisterSaveLayout) obj; - if (Arrays.equals(registers, that.registers) && Arrays.equals(slots, that.slots)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return registersToSlots(true).toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterValue.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterValue.java deleted file mode 100644 index 7104fc0c26d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/RegisterValue.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.ValueKind; - -/** - * Denotes a register that stores a value of a fixed kind. - */ -public final class RegisterValue extends AllocatableValue { - - private final Register reg; - - protected RegisterValue(ValueKind kind, Register register) { - super(kind); - this.reg = register; - } - - @Override - public String toString() { - return getRegister().name + getKindSuffix(); - } - - /** - * @return the register that contains the value - */ - public Register getRegister() { - return reg; - } - - @Override - public int hashCode() { - return 29 * super.hashCode() + reg.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof RegisterValue) { - RegisterValue other = (RegisterValue) obj; - return super.equals(obj) && reg.equals(other.reg); - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackLockValue.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackLockValue.java deleted file mode 100644 index 43337e539ea..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackLockValue.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaValue; - -/** - * Represents lock information in the debug information. - */ -public final class StackLockValue implements JavaValue { - - private JavaValue owner; - private AllocatableValue slot; - private final boolean eliminated; - - public StackLockValue(JavaValue object, AllocatableValue slot, boolean eliminated) { - this.owner = object; - this.slot = slot; - this.eliminated = eliminated; - } - - public JavaValue getOwner() { - return owner; - } - - public void setOwner(JavaValue newOwner) { - this.owner = newOwner; - } - - public AllocatableValue getSlot() { - return slot; - } - - public boolean isEliminated() { - return eliminated; - } - - @Override - public String toString() { - return "monitor[" + owner + (slot != null ? ", " + slot : "") + (eliminated ? ", eliminated" : "") + "]"; - } - - @Override - public int hashCode() { - final int prime = 43; - int result = super.hashCode(); - result = prime * result + (eliminated ? 1231 : 1237); - result = prime * result + owner.hashCode(); - result = prime * result + slot.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof StackLockValue) { - StackLockValue other = (StackLockValue) obj; - return super.equals(obj) && eliminated == other.eliminated && owner.equals(other.owner) && slot.equals(other.slot); - } - return false; - } - - public void setSlot(AllocatableValue stackSlot) { - slot = stackSlot; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackSlot.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackSlot.java deleted file mode 100644 index ca4a8b531f0..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/StackSlot.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.ValueKind; - -/** - * Represents a compiler spill slot or an outgoing stack-based argument in a method's frame or an - * incoming stack-based argument in a method's {@linkplain #isInCallerFrame() caller's frame}. - */ -public final class StackSlot extends AllocatableValue { - - private final int offset; - private final boolean addFrameSize; - - /** - * Gets a {@link StackSlot} instance representing a stack slot at a given index holding a value - * of a given kind. - * - * @param kind The kind of the value stored in the stack slot. - * @param offset The offset of the stack slot (in bytes) - * @param addFrameSize Specifies if the offset is relative to the stack pointer, or the - * beginning of the frame (stack pointer + total frame size). - */ - public static StackSlot get(ValueKind kind, int offset, boolean addFrameSize) { - assert addFrameSize || offset >= 0; - return new StackSlot(kind, offset, addFrameSize); - } - - /** - * Private constructor to enforce use of {@link #get(ValueKind, int, boolean)} so that a cache - * can be used. - */ - private StackSlot(ValueKind kind, int offset, boolean addFrameSize) { - super(kind); - this.offset = offset; - this.addFrameSize = addFrameSize; - } - - /** - * Gets the offset of this stack slot, relative to the stack pointer. - * - * @return The offset of this slot (in bytes). - */ - public int getOffset(int totalFrameSize) { - assert totalFrameSize > 0 || !addFrameSize; - int result = offset + (addFrameSize ? totalFrameSize : 0); - assert result >= 0; - return result; - } - - public boolean isInCallerFrame() { - return addFrameSize && offset >= 0; - } - - public int getRawOffset() { - return offset; - } - - public boolean getRawAddFrameSize() { - return addFrameSize; - } - - @Override - public String toString() { - if (!addFrameSize) { - return "out:" + offset + getKindSuffix(); - } else if (offset >= 0) { - return "in:" + offset + getKindSuffix(); - } else { - return "stack:" + (-offset) + getKindSuffix(); - } - } - - /** - * Gets this stack slot used to pass an argument from the perspective of a caller. - */ - public StackSlot asOutArg() { - assert offset >= 0; - if (addFrameSize) { - return get(getValueKind(), offset, false); - } - return this; - } - - /** - * Gets this stack slot used to pass an argument from the perspective of a callee. - */ - public StackSlot asInArg() { - assert offset >= 0; - if (!addFrameSize) { - return get(getValueKind(), offset, true); - } - return this; - } - - @Override - public int hashCode() { - final int prime = 37; - int result = super.hashCode(); - result = prime * result + (addFrameSize ? 1231 : 1237); - result = prime * result + offset; - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof StackSlot) { - StackSlot other = (StackSlot) obj; - return super.equals(obj) && addFrameSize == other.addFrameSize && offset == other.offset; - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/SuppressFBWarnings.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/SuppressFBWarnings.java deleted file mode 100644 index 21a59625b13..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/SuppressFBWarnings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -/** - * Used to suppress FindBugs warnings. - */ -@interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java deleted file mode 100644 index e1e746c6fe3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/TargetDescription.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.services.Services; -import jdk.internal.util.OperatingSystem; - -/** - * Represents the target machine for a compiler, including the CPU architecture, the size of - * pointers and references, alignment of stacks, caches, etc. - */ -public class TargetDescription { - - public final boolean linuxOs = OperatingSystem.isLinux(); - public final boolean macOs = OperatingSystem.isMacOS(); - - public final Architecture arch; - - /** - * Specifies if this is a multi-processor system. - */ - public final boolean isMP; - - /** - * Specifies if this target supports encoding objects inline in the machine code. - */ - public final boolean inlineObjects; - - /** - * The machine word size on this target. - */ - public final int wordSize; - - /** - * The {@link JavaKind} to be used for representing raw pointers and CPU registers in Java code. - */ - public final JavaKind wordJavaKind; - - /** - * The stack alignment requirement of the platform. For example, from Appendix D of - * Intel 64 and IA-32 Architectures - * Optimization Reference Manual: - * - *
-     *     "It is important to ensure that the stack frame is aligned to a
-     *      16-byte boundary upon function entry to keep local __m128 data,
-     *      parameters, and XMM register spill locations aligned throughout
-     *      a function invocation."
-     * 
- */ - public final int stackAlignment; - - /** - * Maximum constant displacement at which a memory access can no longer be an implicit null - * check. - */ - public final int implicitNullCheckLimit; - - public TargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects) { - this.arch = arch; - this.isMP = isMP; - this.wordSize = arch.getWordSize(); - this.wordJavaKind = JavaKind.fromWordSize(wordSize); - this.stackAlignment = stackAlignment; - this.implicitNullCheckLimit = implicitNullCheckLimit; - this.inlineObjects = inlineObjects; - - assert arch.getPlatformKind(wordJavaKind).equals(arch.getWordKind()); - } - - @Override - public final int hashCode() { - throw new UnsupportedOperationException(); - } - - @Override - public final boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof TargetDescription) { - TargetDescription that = (TargetDescription) obj; - // @formatter:off - if (this.implicitNullCheckLimit == that.implicitNullCheckLimit && - this.inlineObjects == that.inlineObjects && - this.isMP == that.isMP && - this.stackAlignment == that.stackAlignment && - this.wordJavaKind.equals(that.wordJavaKind) && - this.wordSize == that.wordSize && - this.arch.equals(that.arch)) { - return true; - } - // @formatter:on - } - return false; - } - - @Override - public String toString() { - return identityHashCodeString(this); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueKindFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueKindFactory.java deleted file mode 100644 index 57519afab14..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueKindFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ValueKind; - -/** - * Can be implemented by compilers to create custom {@link ValueKind} subclasses. - */ -public interface ValueKindFactory> { - - K getValueKind(JavaKind javaKind); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueUtil.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueUtil.java deleted file mode 100644 index 8b019a9df0a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/ValueUtil.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; - -/** - * Utility class for working with the {@link Value} class and its subclasses. - */ -public final class ValueUtil { - - public static boolean isIllegal(Value value) { - assert value != null; - return Value.ILLEGAL.equals(value); - } - - public static boolean isIllegalJavaValue(JavaValue value) { - assert value != null; - return Value.ILLEGAL.equals(value); - } - - public static boolean isLegal(Value value) { - return !isIllegal(value); - } - - public static boolean isVirtualObject(JavaValue value) { - assert value != null; - return value instanceof VirtualObject; - } - - public static VirtualObject asVirtualObject(JavaValue value) { - assert value != null; - return (VirtualObject) value; - } - - public static boolean isConstantJavaValue(JavaValue value) { - assert value != null; - return value instanceof JavaConstant; - } - - public static JavaConstant asConstantJavaValue(JavaValue value) { - assert value != null; - return (JavaConstant) value; - } - - public static boolean isAllocatableValue(Value value) { - assert value != null; - return value instanceof AllocatableValue; - } - - public static AllocatableValue asAllocatableValue(Value value) { - assert value != null; - return (AllocatableValue) value; - } - - public static boolean isStackSlot(Value value) { - assert value != null; - return value instanceof StackSlot; - } - - public static StackSlot asStackSlot(Value value) { - assert value != null; - return (StackSlot) value; - } - - public static boolean isRegister(Value value) { - assert value != null; - return value instanceof RegisterValue; - } - - public static Register asRegister(Value value) { - return asRegisterValue(value).getRegister(); - } - - public static RegisterValue asRegisterValue(Value value) { - assert value != null; - return (RegisterValue) value; - } - - public static Register asRegister(Value value, PlatformKind kind) { - if (value.getPlatformKind() != kind) { - throw new InternalError("needed: " + kind + " got: " + value.getPlatformKind()); - } else { - return asRegister(value); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java deleted file mode 100644 index 6f91bfb6c1f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/VirtualObject.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code; - -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Set; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * An instance of this class represents an object whose allocation was removed by escape analysis. - * The information stored in the {@link VirtualObject} is used during deoptimization to recreate the - * object. - */ -public final class VirtualObject implements JavaValue { - - private final ResolvedJavaType type; - private JavaValue[] values; - private JavaKind[] slotKinds; - private final int id; - private boolean isAutoBox; - - /** - * Creates a new {@link VirtualObject} for the given type, with the given fields. If - * {@code type} is an instance class then {@code values} provides the values for the fields - * returned by {@link ResolvedJavaType#getInstanceFields(boolean) getInstanceFields(true)}. If - * {@code type} is an array then the length of the values array determines the reallocated array - * length. - * - * @param type the type of the object whose allocation was removed during compilation. This can - * be either an instance of an array type. - * @param id a unique id that identifies the object within the debug information for one - * position in the compiled code. - * @return a new {@link VirtualObject} instance. - */ - public static VirtualObject get(ResolvedJavaType type, int id) { - return new VirtualObject(type, id, false); - } - - /** - * Creates a new {@link VirtualObject} for the given type, with the given fields. If - * {@code type} is an instance class then {@code values} provides the values for the fields - * returned by {@link ResolvedJavaType#getInstanceFields(boolean) getInstanceFields(true)}. If - * {@code type} is an array then the length of the values array determines the reallocated array - * length. - * - * @param type the type of the object whose allocation was removed during compilation. This can - * be either an instance of an array type. - * @param id a unique id that identifies the object within the debug information for one - * position in the compiled code. - * @param isAutoBox a flag that tells the runtime that the object may be a boxed primitive and - * that it possibly needs to be obtained from the box cache instead of creating a new - * instance. - * @return a new {@link VirtualObject} instance. - */ - public static VirtualObject get(ResolvedJavaType type, int id, boolean isAutoBox) { - return new VirtualObject(type, id, isAutoBox); - } - - private VirtualObject(ResolvedJavaType type, int id, boolean isAutoBox) { - this.type = type; - this.id = id; - this.isAutoBox = isAutoBox; - } - - private static StringBuilder appendValue(StringBuilder buf, JavaValue value, Set visited) { - if (value instanceof VirtualObject) { - VirtualObject vo = (VirtualObject) value; - buf.append("vobject:").append(vo.type.toJavaName(false)).append(':').append(vo.id); - if (!visited.contains(vo)) { - visited.add(vo); - buf.append('{'); - if (vo.values == null) { - buf.append(""); - } else { - if (vo.type.isArray()) { - for (int i = 0; i < vo.values.length; i++) { - if (i != 0) { - buf.append(','); - } - buf.append(i).append('='); - appendValue(buf, vo.values[i], visited); - } - } else { - ResolvedJavaField[] fields = vo.type.getInstanceFields(true); - int fieldIndex = 0; - for (int i = 0; i < vo.values.length; i++, fieldIndex++) { - if (i != 0) { - buf.append(','); - } - if (fieldIndex >= fields.length) { - buf.append(""); - } else { - ResolvedJavaField field = fields[fieldIndex]; - buf.append(field.getName()); - if (vo.slotKinds[i].getSlotCount() == 2 && field.getType().getJavaKind().getSlotCount() == 1) { - if (fieldIndex + 1 >= fields.length) { - buf.append("/"); - } else { - ResolvedJavaField field2 = fields[++fieldIndex]; - buf.append('/').append(field2.getName()); - } - } - } - buf.append('='); - appendValue(buf, vo.values[i], visited); - } - // Extra fields - for (; fieldIndex < fields.length; fieldIndex++) { - buf.append(fields[fieldIndex].getName()).append("="); - } - } - } - buf.append('}'); - } - } else { - buf.append(value); - } - return buf; - } - - public interface LayoutVerifier { - int getOffset(ResolvedJavaField field); - - default JavaKind getStorageKind(ResolvedJavaField field) { - return field.getType().getJavaKind(); - } - } - - public void verifyLayout(LayoutVerifier verifier) { - if (!type.isArray()) { - ResolvedJavaField[] fields = type.getInstanceFields(true); - int fieldIndex = 0; - for (int i = 0; i < values.length; i++, fieldIndex++) { - JavaKind slotKind = slotKinds[i]; - if (fieldIndex >= fields.length) { - throw new JVMCIError("Not enough fields for the values provided for %s", toString()); - } else { - ResolvedJavaField field = fields[fieldIndex]; - JavaKind fieldKind = verifier.getStorageKind(field); - if (slotKind.getSlotCount() == 2 && fieldKind == JavaKind.Int) { - int offset = verifier.getOffset(field); - if (offset % 8 != 0) { - throw new JVMCIError("Double word value stored across two ints must be aligned %s", toString()); - } - - if (fieldIndex + 1 >= fields.length) { - throw new JVMCIError("Missing second field for double word value stored in two ints %s", toString()); - } - ResolvedJavaField field2 = fields[fieldIndex + 1]; - if (field2.getType().getJavaKind() != JavaKind.Int) { - throw new JVMCIError("Second field for double word value stored in two ints must be int but got %s in %s", field2.getType().getJavaKind(), toString()); - } - int offset2 = verifier.getOffset(field2); - if (offset + 4 != offset2) { - throw new JVMCIError("Double word value stored across two ints must be sequential %s", toString()); - } - fieldIndex++; - } else if (fieldKind.getStackKind() != slotKind.getStackKind()) { - throw new JVMCIError("Expected value of kind %s but got %s for field %s in %s", fieldKind, slotKind, field, toString()); - } - } - } - // Extra fields - if (fieldIndex < fields.length) { - throw new JVMCIError("Not enough values provided for fields in %s", this); - } - } else if (type.getComponentType().getJavaKind() == JavaKind.Byte) { - for (int i = 0; i < values.length;) { - JavaKind slotkind = slotKinds[i]; - if (slotkind != JavaKind.Byte) { - if (!slotkind.isPrimitive()) { - throw new JVMCIError("Storing a non-primitive in a byte array: %s %s", slotkind, toString()); - } - int byteCount = 1; - while (++i < values.length && slotKinds[i] == JavaKind.Illegal) { - byteCount++; - } - /* - * Checks: a) The byte count is a valid count (ie: power of two), b) if the kind - * was not erased to int (happens for regular byte array accesses), check that - * the count is correct, c) No writes spanning more than a long. - */ - if (!CodeUtil.isPowerOf2(byteCount) || (slotkind.getStackKind() != JavaKind.Int && byteCount != slotkind.getByteCount()) || byteCount > JavaKind.Long.getByteCount()) { - throw new JVMCIError("Invalid number of illegals to reconstruct a byte array: %s in %s", byteCount, toString()); - } - continue; - } - i++; - } - } - } - - @Override - public String toString() { - Set visited = Collections.newSetFromMap(new IdentityHashMap()); - return appendValue(new StringBuilder(), this, visited).toString(); - } - - /** - * Returns the type of the object whose allocation was removed during compilation. This can be - * either an instance of an array type. - */ - public ResolvedJavaType getType() { - return type; - } - - /** - * Returns the array containing all the values to be stored into the object when it is - * recreated. This field is intentional exposed as a mutable array that a compiler may modify - * (e.g. during register allocation). - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "`values` is intentional mutable")// - public JavaValue[] getValues() { - return values; - } - - /** - * Returns the kind of the value at {@code index}. - */ - public JavaKind getSlotKind(int index) { - return slotKinds[index]; - } - - /** - * Returns the unique id that identifies the object within the debug information for one - * position in the compiled code. - */ - public int getId() { - return id; - } - - /** - * Returns true if the object is a box. For boxes the deoptimization would check if the value of - * the box is in the cache range and try to return a cached object. - */ - public boolean isAutoBox() { - return isAutoBox; - } - - /** - * Overwrites the current set of values with a new one. - * - * @param values an array containing all the values to be stored into the object when it is - * recreated. - * @param slotKinds an array containing the Java kinds of the values. This must have the same - * length as {@code values}. This array is now owned by this object and must not be - * mutated by the caller. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `slotKinds`") - public void setValues(JavaValue[] values, JavaKind[] slotKinds) { - assert values.length == slotKinds.length; - this.values = values; - this.slotKinds = slotKinds; - } - - @Override - public int hashCode() { - return 42 + type.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof VirtualObject that) { - int thatValuesLength = (that.values == null) ? 0 : that.values.length; - int valuesLength = (values == null) ? 0 : values.length; - if (!that.type.equals(type) || thatValuesLength != valuesLength) { - return false; - } - for (int i = 0; i < valuesLength; i++) { - /* - * Virtual objects can form cycles. Calling equals() could therefore lead to - * infinite recursion. - */ - if (!same(values[i], that.values[i])) { - return false; - } - } - return true; - } - return false; - } - - private static boolean same(Object o1, Object o2) { - return o1 == o2; - } - - /** - * Returns a copy of the array containing the Java kinds of the values stored in this virtual object. - */ - public JavaKind[] getSlotKinds() { - return (slotKinds == null) ? null : slotKinds.clone(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/package-info.java deleted file mode 100644 index b6474e28dbe..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * Package that defines the interface between a Java application that wants to install code and the - * runtime. The runtime provides in implementation of the {@link jdk.vm.ci.code.CodeCacheProvider} - * interface. The method {@link jdk.vm.ci.code.CodeCacheProvider#addCode} can be used to install code. - */ -package jdk.vm.ci.code; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Call.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Call.java deleted file mode 100644 index c323b055a35..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Call.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import java.util.Objects; - -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.meta.InvokeTarget; - -/** - * Represents a call in the code. - */ -public final class Call extends Infopoint { - - /** - * The target of the call. - */ - public final InvokeTarget target; - - /** - * The size of the call instruction. - */ - public final int size; - - /** - * Specifies if this call is direct or indirect. A direct call has an immediate operand encoding - * the absolute or relative (to the call itself) address of the target. An indirect call has a - * register or memory operand specifying the target address of the call. - */ - public final boolean direct; - - public Call(InvokeTarget target, int pcOffset, int size, boolean direct, DebugInfo debugInfo) { - super(pcOffset, debugInfo, InfopointReason.CALL); - this.size = size; - this.target = target; - this.direct = direct; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Call && super.equals(obj)) { - Call that = (Call) obj; - if (this.size == that.size && this.direct == that.direct && Objects.equals(this.target, that.target)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(pcOffset); - sb.append('['); - sb.append(target); - sb.append(']'); - - if (debugInfo != null) { - appendDebugInfo(sb, debugInfo); - } - - return sb.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ConstantReference.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ConstantReference.java deleted file mode 100644 index 232bc477de6..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ConstantReference.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import java.util.Objects; - -import jdk.vm.ci.meta.VMConstant; - -/** - * Represents an embedded {@link VMConstant} in the code or data section that needs to be - * {@link DataPatch patched} by the VM (e.g. an embedded pointer to a Java object). - */ -public final class ConstantReference extends Reference { - - private final VMConstant constant; - - public ConstantReference(VMConstant constant) { - this.constant = constant; - } - - public VMConstant getConstant() { - return constant; - } - - @Override - public String toString() { - return constant.toString(); - } - - @Override - public int hashCode() { - return constant.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ConstantReference) { - ConstantReference that = (ConstantReference) obj; - return Objects.equals(this.constant, that.constant); - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataPatch.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataPatch.java deleted file mode 100644 index df67033d8e9..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataPatch.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import java.util.Objects; - -import jdk.vm.ci.meta.VMConstant; - -/** - * Represents a code site that references some data. The associated data can be either a - * {@link DataSectionReference reference} to the data section, or it may be an inlined - * {@link VMConstant} that needs to be patched. - */ -public final class DataPatch extends Site { - - public Reference reference; - public Object note; - - public DataPatch(int pcOffset, Reference reference) { - super(pcOffset); - this.reference = reference; - this.note = null; - } - - public DataPatch(int pcOffset, Reference reference, Object note) { - super(pcOffset); - this.reference = reference; - this.note = note; - } - - @Override - public String toString() { - if (note != null) { - return String.format("%d[, note: %s]", pcOffset, reference.toString(), note.toString()); - } else { - return String.format("%d[]", pcOffset, reference.toString()); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DataPatch) { - DataPatch that = (DataPatch) obj; - if (this.pcOffset == that.pcOffset && Objects.equals(this.reference, that.reference) && Objects.equals(this.note, that.note)) { - return true; - } - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataSectionReference.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataSectionReference.java deleted file mode 100644 index 364141e2c2a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/DataSectionReference.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -/** - * Represents a pointer to some location in the data section that should be {@link DataPatch - * patched} into the code. - */ -public final class DataSectionReference extends Reference { - - private boolean initialized; - private int offset; - - public DataSectionReference() { - // will be set after the data section layout is fixed - offset = 0xDEADDEAD; - } - - public int getOffset() { - assert initialized; - - return offset; - } - - public void setOffset(int offset) { - assert !initialized; - initialized = true; - - this.offset = offset; - } - - @Override - public int hashCode() { - return offset; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DataSectionReference) { - DataSectionReference that = (DataSectionReference) obj; - return this.offset == that.offset; - } - return false; - } - - @Override - public String toString() { - if (initialized) { - return String.format("DataSection[0x%x]", offset); - } else { - return "DataSection[?]"; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ExceptionHandler.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ExceptionHandler.java deleted file mode 100644 index 3f9f73f3867..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ExceptionHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -/** - * Represents exception handler information for a specific code position. It includes the catch code - * position as well as the caught exception type. - */ -public final class ExceptionHandler extends Site { - - public final int handlerPos; - - public ExceptionHandler(int pcOffset, int handlerPos) { - super(pcOffset); - this.handlerPos = handlerPos; - } - - @Override - public String toString() { - return String.format("%d[]", pcOffset, handlerPos); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExceptionHandler) { - ExceptionHandler that = (ExceptionHandler) obj; - if (this.pcOffset == that.pcOffset && this.handlerPos == that.handlerPos) { - return true; - } - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ImplicitExceptionDispatch.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ImplicitExceptionDispatch.java deleted file mode 100644 index 2d4bf6eec45..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/ImplicitExceptionDispatch.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import jdk.vm.ci.code.DebugInfo; - -/** - * Represents an implicit exception dispatch in the code. Implicit exception dispatch is a - * platform-specific optimization that makes use of an operating system's trap mechanism, to turn - * specific branches into sequential code with implicit traps. Information contained in this class - * will be used by the runtime to register implicit exception dispatch, i.e., a mapping from an - * exceptional PC offset to a continuation PC offset. - */ -public final class ImplicitExceptionDispatch extends Infopoint { - - public final int dispatchOffset; - - /** - * Construct an implicit exception dispatch. - * - * @param pcOffset the exceptional PC offset - * @param dispatchOffset the continuation PC offset - * @param debugInfo debugging information at the exceptional PC - */ - public ImplicitExceptionDispatch(int pcOffset, int dispatchOffset, DebugInfo debugInfo) { - super(pcOffset, debugInfo, InfopointReason.IMPLICIT_EXCEPTION); - this.dispatchOffset = dispatchOffset; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ImplicitExceptionDispatch && super.equals(obj)) { - ImplicitExceptionDispatch that = (ImplicitExceptionDispatch) obj; - if (this.dispatchOffset == that.dispatchOffset) { - return true; - } - } - return false; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(pcOffset); - sb.append("->"); - sb.append(dispatchOffset); - - if (debugInfo != null) { - appendDebugInfo(sb, debugInfo); - } - - return sb.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java deleted file mode 100644 index e590768cab7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Infopoint.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import java.util.Map; -import java.util.Objects; - -import jdk.vm.ci.code.BytecodePosition; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.ReferenceMap; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterSaveLayout; -import jdk.vm.ci.meta.MetaUtil; - -/** - * Represents an infopoint with associated debug info. Note that safepoints are also infopoints. - */ -public class Infopoint extends Site implements Comparable { - - public final DebugInfo debugInfo; - - public final InfopointReason reason; - - public Infopoint(int pcOffset, DebugInfo debugInfo, InfopointReason reason) { - super(pcOffset); - this.debugInfo = debugInfo; - this.reason = reason; - assert reason != InfopointReason.CALL || this instanceof Call : getClass(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append(pcOffset); - sb.append("[]"); - appendDebugInfo(sb, debugInfo); - return sb.toString(); - } - - @Override - public int compareTo(Infopoint o) { - if (pcOffset < o.pcOffset) { - return -1; - } else if (pcOffset > o.pcOffset) { - return 1; - } - return this.reason.compareTo(o.reason); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj != null && obj.getClass() == getClass()) { - Infopoint that = (Infopoint) obj; - if (this.pcOffset == that.pcOffset && Objects.equals(this.debugInfo, that.debugInfo) && Objects.equals(this.reason, that.reason)) { - return true; - } - } - return false; - } - - protected static void appendDebugInfo(StringBuilder sb, DebugInfo info) { - if (info != null) { - ReferenceMap refMap = info.getReferenceMap(); - if (refMap != null) { - sb.append(refMap.toString()); - sb.append(']'); - } - RegisterSaveLayout calleeSaveInfo = info.getCalleeSaveInfo(); - if (calleeSaveInfo != null) { - sb.append(" callee-save-info["); - String sep = ""; - for (Map.Entry e : calleeSaveInfo.registersToSlots(true).entrySet()) { - sb.append(sep).append(e.getKey()).append("->").append(e.getValue()); - sep = ", "; - } - sb.append(']'); - } - BytecodePosition codePos = info.getBytecodePosition(); - if (codePos != null) { - MetaUtil.appendLocation(sb.append(" "), codePos.getMethod(), codePos.getBCI()); - if (info.hasFrame()) { - sb.append(" #locals=").append(info.frame().numLocals).append(" #expr=").append(info.frame().numStack); - if (info.frame().numLocks > 0) { - sb.append(" #locks=").append(info.frame().numLocks); - } - } - } - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/InfopointReason.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/InfopointReason.java deleted file mode 100644 index ae890bde4ca..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/InfopointReason.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -/** - * A reason for infopoint insertion. - */ -public enum InfopointReason { - - SAFEPOINT, - CALL, - IMPLICIT_EXCEPTION, - METHOD_START, - METHOD_END, - BYTECODE_POSITION; -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Mark.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Mark.java deleted file mode 100644 index ed2dc336dbb..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Mark.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import java.util.Objects; - -/** - * Associates arbitrary information with a position in machine code. For example, HotSpot specific - * code in a compiler backend may use this to denote the position of a safepoint, exception handler - * entry point, verified entry point etc. - */ -public final class Mark extends Site { - - /** - * An object denoting extra semantic information about the machine code position of this mark. - */ - public final Object id; - - /** - * Creates a mark that associates {@code id} with the machine code position {@code pcOffset}. - * - * @param pcOffset - * @param id - */ - public Mark(int pcOffset, Object id) { - super(pcOffset); - this.id = id; - } - - @Override - public String toString() { - if (id == null) { - return String.format("%d[]", pcOffset); - } else if (id instanceof Integer) { - return String.format("%d[]", pcOffset, Integer.toHexString((Integer) id)); - } else { - return String.format("%d[]", pcOffset, id.toString()); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Mark) { - Mark that = (Mark) obj; - if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) { - return true; - } - } - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Reference.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Reference.java deleted file mode 100644 index 601d4158a63..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Reference.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -/** - * Represents some external data that is referenced by the code. - */ -public abstract class Reference { - - @Override - public abstract int hashCode(); - - @Override - public abstract boolean equals(Object obj); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Site.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Site.java deleted file mode 100644 index d12a78e5106..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Site.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.site; - -import static jdk.vm.ci.meta.MetaUtil.identityHashCodeString; - -/** - * Represents a code position with associated additional information. - */ -public abstract class Site { - - /** - * The position (or offset) of this site with respect to the start of the target method. - */ - public final int pcOffset; - - public Site(int pos) { - this.pcOffset = pos; - } - - @Override - public int hashCode() { - return 41 * pcOffset; - } - - @Override - public String toString() { - return identityHashCodeString(this); - } - - @Override - public abstract boolean equals(Object obj); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/package-info.java deleted file mode 100644 index b661834eb2e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * Package that defines the information associated with various {@link jdk.vm.ci.code.site.Site - * sites} in generated code. - */ -package jdk.vm.ci.code.site; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java deleted file mode 100644 index f307b24eead..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrame.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.stack; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Access to the object variables in a stack frame. - */ -public interface InspectedFrame { - - /** - * Returns the value of the object local at {@code index}. This value is a copy iff - * {@link #isVirtual(int)} is true. - */ - Object getLocal(int index); - - /** - * Returns whether the local at {@code index} is a virtual object, and therefore the object - * returned by {@link #getLocal(int)} is a copy. - */ - boolean isVirtual(int index); - - /** - * Returns true if the stack frame is a compiled stack frame and there are virtual objects - * anywhere in the current state of the compiled method. This can return true even if - * {@link #isVirtual(int)} return false for all locals. - */ - boolean hasVirtualObjects(); - - /** - * This method will materialize all virtual objects, deoptimize the stack frame and make sure - * that subsequent execution of the deoptimized frame uses the materialized values. - * - * @see StackIntrospection#canMaterializeVirtualObjects - * @throws IllegalArgumentException if stack introspection does not support - * materialization of virtual objects for this frame - */ - void materializeVirtualObjects(boolean invalidateCode); - - /** - * @return the current bytecode index - */ - int getBytecodeIndex(); - - /** - * @return the current method - */ - ResolvedJavaMethod getMethod(); - - /** - * Checks if the current method is equal to the given method. This is semantically equivalent to - * {@code method.equals(getMethod())}, but can be implemented more efficiently. - */ - boolean isMethod(ResolvedJavaMethod method); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrameVisitor.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrameVisitor.java deleted file mode 100644 index e3177903ee8..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/InspectedFrameVisitor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.stack; - -/** - * Callback interface for {@link StackIntrospection#iterateFrames}. Implementations of - * {@link #visitFrame} return null to indicate that frame iteration should continue and the next - * caller frame should be visited; and return any non-null value to indicate that frame iteration - * should stop. - */ -public interface InspectedFrameVisitor { - - T visitFrame(InspectedFrame frame); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java deleted file mode 100644 index bdc0a1c3f62..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/StackIntrospection.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.stack; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public interface StackIntrospection { - - /** - * Walks the current stack, providing {@link InspectedFrame}s to the visitor that can be used to - * inspect the stack frame's contents. Iteration continues as long as - * {@link InspectedFrameVisitor#visitFrame}, which is invoked for every {@link InspectedFrame}, - * returns {@code null}. A non-null return value from {@link InspectedFrameVisitor#visitFrame} - * indicates that frame iteration should stop. - * - * @param initialMethods if this is non-{@code null}, then the stack walk will start at the - * first frame whose method is one of these methods. - * @param matchingMethods if this is non-{@code null}, then only frames whose methods are in - * this array are visited - * @param initialSkip the number of matching methods to skip (including the initial method) - * @param visitor the visitor that is called for every matching method - * @return the last result returned by the visitor (which is non-null to indicate that iteration - * should stop), or null if the whole stack was iterated. - */ - T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor); - - /** - * Determines if {@link InspectedFrame#materializeVirtualObjects(boolean)} can be called for frames - * visited by {@link #iterateFrames}. - */ - default boolean canMaterializeVirtualObjects() { - return true; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/package-info.java deleted file mode 100644 index ed1dbac18a3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/stack/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -/** - * Package that defines the interface for runtime stack introspection. - */ -package jdk.vm.ci.code.stack; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/InitTimer.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/InitTimer.java deleted file mode 100644 index 94fb6f4e9b0..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/InitTimer.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -import java.util.concurrent.atomic.AtomicInteger; - -import jdk.vm.ci.services.Services; - -/** - * A facility for timing a step in the runtime initialization sequence. This is independent from all - * other JVMCI code so as to not perturb the initialization sequence. It is enabled by setting the - * {@code "jvmci.inittimer"} system property to {@code "true"}. - */ -public final class InitTimer implements AutoCloseable { - private final String name; - private final long start; - - private InitTimer(String name) { - int n = nesting.getAndIncrement(); - if (n == 0) { - initializingThread = Thread.currentThread(); - System.out.println("INITIALIZING THREAD: " + initializingThread); - } else { - assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread; - } - this.name = name; - this.start = System.currentTimeMillis(); - System.out.println("START: " + SPACES.substring(0, n * 2) + name); - } - - @Override - @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field") - public void close() { - final long end = System.currentTimeMillis(); - int n = nesting.decrementAndGet(); - System.out.println(" DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]"); - if (n == 0) { - initializingThread = null; - } - } - - public static InitTimer timer(String name) { - return isEnabled() ? new InitTimer(name) : null; - } - - public static InitTimer timer(String name, Object suffix) { - return isEnabled() ? new InitTimer(name + suffix) : null; - } - - /** - * Determines if initialization timing is enabled. Note: This property cannot use - * {@code HotSpotJVMCIRuntime.Option} since that class is not visible from this package. - */ - private static boolean isEnabled() { - if (enabledPropertyValue == null) { - enabledPropertyValue = Boolean.parseBoolean(Services.getSavedProperty("jvmci.InitTimer")); - nesting = new AtomicInteger(); - } - return enabledPropertyValue; - } - - /** - * Cache for value of {@code jvmci.InitTimer} system property. - */ - private static Boolean enabledPropertyValue; - - private static AtomicInteger nesting; - private static final String SPACES = " "; - - /** - * Used to assert the invariant that all related initialization happens on the same thread. - */ - static Thread initializingThread; -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/JVMCIError.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/JVMCIError.java deleted file mode 100644 index e5b4180b1d9..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/JVMCIError.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -import java.util.ArrayList; -import java.util.Locale; - -/** - * Indicates a condition in JVMCI related code that should never occur during normal operation. - */ -public class JVMCIError extends Error { - - private static final long serialVersionUID = 531632331813456233L; - - public static RuntimeException unimplemented() { - throw new JVMCIError("unimplemented"); - } - - public static RuntimeException unimplemented(String msg) { - throw new JVMCIError("unimplemented: %s", msg); - } - - public static RuntimeException shouldNotReachHere() { - throw new JVMCIError("should not reach here"); - } - - public static RuntimeException shouldNotReachHere(String msg) { - throw new JVMCIError("should not reach here: %s", msg); - } - - public static RuntimeException shouldNotReachHere(Throwable cause) { - throw new JVMCIError(cause); - } - - /** - * Checks a given condition and throws a {@link JVMCIError} if it is false. Guarantees are - * stronger than assertions in that they are always checked. Error messages for guarantee - * violations should clearly indicate the nature of the problem as well as a suggested solution - * if possible. - * - * @param condition the condition to check - * @param msg the message that will be associated with the error, in - * {@link String#format(String, Object...)} syntax - * @param args arguments to the format string - */ - public static void guarantee(boolean condition, String msg, Object... args) { - if (!condition) { - throw new JVMCIError("failed guarantee: " + msg, args); - } - } - - /** - * This constructor creates a {@link JVMCIError} with a given message. - * - * @param msg the message that will be associated with the error - */ - public JVMCIError(String msg) { - super(msg); - } - - /** - * This constructor creates a {@link JVMCIError} with a message assembled via - * {@link String#format(String, Object...)}. It always uses the ENGLISH locale in order to - * always generate the same output. - * - * @param msg the message that will be associated with the error, in String.format syntax - * @param args parameters to String.format - parameters that implement {@link Iterable} will be - * expanded into a [x, x, ...] representation. - */ - public JVMCIError(String msg, Object... args) { - super(format(msg, args)); - } - - /** - * This constructor creates a {@link JVMCIError} for a given causing Throwable instance. - * - * @param cause the original exception that contains additional information on this error - */ - public JVMCIError(Throwable cause) { - super(cause); - } - - private static String format(String msg, Object... args) { - if (args != null) { - // expand Iterable parameters into a list representation - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof Iterable) { - ArrayList list = new ArrayList<>(); - for (Object o : (Iterable) args[i]) { - list.add(o); - } - args[i] = list.toString(); - } - } - } - return String.format(Locale.ENGLISH, msg, args); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/SuppressFBWarnings.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/SuppressFBWarnings.java deleted file mode 100644 index 870693c8e9c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/SuppressFBWarnings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.common; - -/** - * Used to suppress FindBugs warnings. - */ -@interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/package-info.java deleted file mode 100644 index 6e62672ccac..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/common/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Common utility classes used by the JVMCI API. - */ -package jdk.vm.ci.common; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/AnnotationDataDecoder.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/AnnotationDataDecoder.java deleted file mode 100644 index 9cc33a395fc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/AnnotationDataDecoder.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Map; - -import jdk.internal.vm.VMSupport.AnnotationDecoder; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.EnumData; -import jdk.vm.ci.meta.ErrorData; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaUtil; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.UnresolvedJavaType; - -/** - * Implementation of {@link AnnotationDecoder} that resolves type names to {@link JavaType} values - * and employs {@link AnnotationData} and {@link EnumData} to represent decoded annotations and enum - * constants respectively. - */ -final class AnnotationDataDecoder implements AnnotationDecoder { - - static final AnnotationDataDecoder INSTANCE = new AnnotationDataDecoder(); - - @Override - public JavaType resolveType(String name) { - String internalName = MetaUtil.toInternalName(name); - return UnresolvedJavaType.create(internalName); - } - - @Override - public AnnotationData newAnnotation(JavaType type, Map.Entry[] elements) { - return new AnnotationData(type, elements); - } - - @Override - public EnumData newEnumValue(JavaType enumType, String name) { - return new EnumData(enumType, name); - } - - @Override - public ErrorData newErrorValue(String description) { - return new ErrorData(description); - } - - static ResolvedJavaType[] asArray(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - ResolvedJavaType[] filter = new ResolvedJavaType[2 + types.length]; - filter[0] = type1; - filter[1] = type2; - System.arraycopy(types, 0, filter, 2, types.length); - return filter; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/Cleaner.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/Cleaner.java deleted file mode 100644 index d9d82b413eb..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/Cleaner.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; - -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * A cleaner tracks a referent object and includes some {@linkplain #doCleanup() cleanup code} that - * is run some time after the referent object has become weakly-reachable. - * - * This is like {@link java.lang.ref.Cleaner} but with weak semantics instead of phantom. Objects - * referenced by this might be referenced by {@link ResolvedJavaType} which is kept alive by a - * {@link WeakReference} so we need equivalent reference strength. - */ -public abstract class Cleaner extends WeakReference { - - /** - * Head of linked list of cleaners. - */ - private static Cleaner first; - - /** - * Linked list pointers. - */ - private Cleaner next = null; - private Cleaner prev = null; - - Cleaner(Object referent) { - super(referent, queue); - add(this); - } - - private static synchronized Cleaner add(Cleaner cl) { - if (first != null) { - clean(); - } - if (first != null) { - cl.next = first; - first.prev = cl; - } - first = cl; - return cl; - } - - /** - * Removes {@code cl} from the linked list of cleaners. - */ - private static synchronized void remove(Cleaner cl) { - // If already removed, do nothing - if (cl.next == cl) { - return; - } - - // Update list - if (first == cl) { - if (cl.next != null) { - first = cl.next; - } else { - first = cl.prev; - } - } - if (cl.next != null) { - cl.next.prev = cl.prev; - } - if (cl.prev != null) { - cl.prev.next = cl.next; - } - - // Indicate removal by pointing the cleaner to itself - cl.next = cl; - cl.prev = cl; - } - - /** - * Performs the cleanup action now that this object's referent has become weakly reachable. - * - * @return true if the clean up action cleared the referent of an oop handle and requires a - * subsequent call to {@link CompilerToVM#releaseClearedOopHandles()} to reclaim the - * resources of the handle itself - */ - abstract boolean doCleanup(); - - /** - * Remove the cleaners whose referents have become weakly reachable. - */ - public static void clean() { - Cleaner c = (Cleaner) queue.poll(); - boolean oopHandleCleared = false; - while (c != null) { - remove(c); - if (c.doCleanup()) { - oopHandleCleared = true; - } - c = (Cleaner) queue.poll(); - } - if (oopHandleCleared) { - CompilerToVM.compilerToVM().releaseClearedOopHandles(); - } - } - - /** - * The {@link ReferenceQueue} to which {@link Cleaner}s are enqueued once their referents' - * become unreachable. - */ - private static final ReferenceQueue queue = new ReferenceQueue<>(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerThreadCanCallJavaScope.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerThreadCanCallJavaScope.java deleted file mode 100644 index ff346fa94bc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerThreadCanCallJavaScope.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Scope used to potentially change whether the current thread can make VM-to-Java calls. - * A scope is exited by the {@link #close()} method so it should be used in a - * try-with-resources statement. - * - * The scope does nothing if the current thread is not a HotSpot VM CompilerThread - * for a JVMCI compiler. - */ -public class CompilerThreadCanCallJavaScope implements AutoCloseable { - - /** - * Thread state used during the scope. - */ - private final boolean state; - - /** - * Non-null iff the thread state needs resetting in {@link #close()}. - */ - private final CompilerToVM vm; - - /** - * The thread on which the constructor was called. - */ - private final Thread thread; - - /** - * Opens a scope to allow/disallow the current thread to make VM-to-Java calls. - * The scope is a no-op if the current thread is not a HotSpot VM CompilerThread - * for a JVMCI compiler. - * - * @param newState true/false to allow/disallow VM-to-Java calls within the scope - */ - public CompilerThreadCanCallJavaScope(boolean newState) { - this.state = newState; - this.thread = Thread.currentThread(); - CompilerToVM vm = HotSpotJVMCIRuntime.runtime().getCompilerToVM(); - if (vm.updateCompilerThreadCanCallJava(newState)) { - this.vm = vm; - } else { - this.vm = null; - } - } - - /** - * Resets the state of the current thread with respect to whether it can make - * VM-to-Java calls to what it was before the constructor was called. - * - * @throws IllegalStateException if called on a different thread than the constructor - */ - @Override - public void close() { - if (this.thread != Thread.currentThread()) { - throw new IllegalStateException(); - } - - if (vm != null) { - vm.updateCompilerThreadCanCallJava(!state); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java deleted file mode 100644 index ee578cfd5f1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java +++ /dev/null @@ -1,1558 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Executable; -import java.lang.reflect.Field; - -import jdk.internal.misc.Unsafe; -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.code.stack.InspectedFrameVisitor; -import jdk.vm.ci.common.InitTimer; -import static jdk.vm.ci.common.InitTimer.timer; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native - * pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not - * denote a valid native object. - * - * Note also that some calls pass a raw VM value to avoid a JNI upcall. For example, - * {@link #getBytecode(HotSpotResolvedJavaMethodImpl, long)} needs the raw {@code Method*} value - * (stored in {@link HotSpotResolvedJavaMethodImpl#methodHandle}) in the C++ implementation. The - * {@link HotSpotResolvedJavaMethodImpl} wrapper is still passed as well as it may be the last - * reference keeping the raw value alive. - */ -final class CompilerToVM { - /** - * Initializes the native part of the JVMCI runtime. - */ - private static native void registerNatives(); - - /** - * These values mirror the equivalent values from {@code Unsafe} but are appropriate for the JVM - * being compiled against. - */ - final int ARRAY_BOOLEAN_BASE_OFFSET; - final int ARRAY_BYTE_BASE_OFFSET; - final int ARRAY_SHORT_BASE_OFFSET; - final int ARRAY_CHAR_BASE_OFFSET; - final int ARRAY_INT_BASE_OFFSET; - final int ARRAY_LONG_BASE_OFFSET; - final int ARRAY_FLOAT_BASE_OFFSET; - final int ARRAY_DOUBLE_BASE_OFFSET; - final int ARRAY_OBJECT_BASE_OFFSET; - final int ARRAY_BOOLEAN_INDEX_SCALE; - final int ARRAY_BYTE_INDEX_SCALE; - final int ARRAY_SHORT_INDEX_SCALE; - final int ARRAY_CHAR_INDEX_SCALE; - final int ARRAY_INT_INDEX_SCALE; - final int ARRAY_LONG_INDEX_SCALE; - final int ARRAY_FLOAT_INDEX_SCALE; - final int ARRAY_DOUBLE_INDEX_SCALE; - final int ARRAY_OBJECT_INDEX_SCALE; - - @SuppressWarnings("try") - CompilerToVM() { - try (InitTimer t = timer("CompilerToVM.registerNatives")) { - registerNatives(); - ARRAY_BOOLEAN_BASE_OFFSET = arrayBaseOffset(JavaKind.Boolean.getTypeChar()); - ARRAY_BYTE_BASE_OFFSET = arrayBaseOffset(JavaKind.Byte.getTypeChar()); - ARRAY_SHORT_BASE_OFFSET = arrayBaseOffset(JavaKind.Short.getTypeChar()); - ARRAY_CHAR_BASE_OFFSET = arrayBaseOffset(JavaKind.Char.getTypeChar()); - ARRAY_INT_BASE_OFFSET = arrayBaseOffset(JavaKind.Int.getTypeChar()); - ARRAY_LONG_BASE_OFFSET = arrayBaseOffset(JavaKind.Long.getTypeChar()); - ARRAY_FLOAT_BASE_OFFSET = arrayBaseOffset(JavaKind.Float.getTypeChar()); - ARRAY_DOUBLE_BASE_OFFSET = arrayBaseOffset(JavaKind.Double.getTypeChar()); - ARRAY_OBJECT_BASE_OFFSET = arrayBaseOffset(JavaKind.Object.getTypeChar()); - ARRAY_BOOLEAN_INDEX_SCALE = arrayIndexScale(JavaKind.Boolean.getTypeChar()); - ARRAY_BYTE_INDEX_SCALE = arrayIndexScale(JavaKind.Byte.getTypeChar()); - ARRAY_SHORT_INDEX_SCALE = arrayIndexScale(JavaKind.Short.getTypeChar()); - ARRAY_CHAR_INDEX_SCALE = arrayIndexScale(JavaKind.Char.getTypeChar()); - ARRAY_INT_INDEX_SCALE = arrayIndexScale(JavaKind.Int.getTypeChar()); - ARRAY_LONG_INDEX_SCALE = arrayIndexScale(JavaKind.Long.getTypeChar()); - ARRAY_FLOAT_INDEX_SCALE = arrayIndexScale(JavaKind.Float.getTypeChar()); - ARRAY_DOUBLE_INDEX_SCALE = arrayIndexScale(JavaKind.Double.getTypeChar()); - ARRAY_OBJECT_INDEX_SCALE = arrayIndexScale(JavaKind.Object.getTypeChar()); - } - } - - native int arrayBaseOffset(char typeChar); - - native int arrayIndexScale(char typeChar); - - /** - * Gets the {@link CompilerToVM} instance associated with the singleton - * {@link HotSpotJVMCIRuntime} instance. - */ - public static CompilerToVM compilerToVM() { - return runtime().getCompilerToVM(); - } - - /** - * Copies the original bytecode of {@code method} into a new byte array and returns it. - * - * @return a new byte array containing the original bytecode of {@code method} - */ - byte[] getBytecode(HotSpotResolvedJavaMethodImpl method) { - return getBytecode(method, method.getMethodPointer()); - } - - private native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets the number of entries in {@code method}'s exception handler table or 0 if it has no - * exception handler table. - */ - int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method) { - return getExceptionTableLength(method, method.getMethodPointer()); - } - - private native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets the address of the first entry in {@code method}'s exception handler table. - * - * Each entry is a native object described by these fields: - * - *
    - *
  • {@link HotSpotVMConfig#exceptionTableElementSize}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementStartPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementEndPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementHandlerPcOffset}
  • - *
  • {@link HotSpotVMConfig#exceptionTableElementCatchTypeIndexOffset} - *
- * - * @return 0 if {@code method} has no exception handlers (i.e. - * {@code getExceptionTableLength(method) == 0}) - */ - long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method) { - return getExceptionTableStart(method, method.getMethodPointer()); - } - - private native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Determines whether {@code method} is currently compilable by the JVMCI compiler being used by - * the VM. This can return false if JVMCI compilation failed earlier for {@code method}, a - * breakpoint is currently set in {@code method} or {@code method} contains other bytecode - * features that require special handling by the VM. - */ - boolean isCompilable(HotSpotResolvedJavaMethodImpl method) { - return isCompilable(method, method.getMethodPointer()); - } - - private native boolean isCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Determines if {@code method} is targeted by a VM directive (e.g., - * {@code -XX:CompileCommand=dontinline,}) or annotation (e.g., - * {@code jdk.internal.vm.annotation.DontInline}) that specifies it should not be inlined. - */ - boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method) { - return hasNeverInlineDirective(method, method.getMethodPointer()); - } - - private native boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Determines if {@code method} should be inlined at any cost. This could be because: - *
    - *
  • a CompileOracle directive may forces inlining of this methods
  • - *
  • an annotation forces inlining of this method
  • - *
- */ - boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method) { - return shouldInlineMethod(method, method.getMethodPointer()); - } - - private native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. - * - * @param actualHolderType the best known type of receiver - * @param method the method on which to base the search - * @return the method result or 0 is there is no unique concrete method for {@code method} - */ - HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method) { - return findUniqueConcreteMethod(actualHolderType, actualHolderType.getKlassPointer(), method, method.getMetaspacePointer()); - } - - private native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets the implementor for the interface class {@code type}. - * - * @return the implementor if there is a single implementor, {@code null} if there is no - * implementor, or {@code type} itself if there is more than one implementor - * @throws IllegalArgumentException if type is not an interface type - */ - HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type) { - return getImplementor(type, type.getKlassPointer()); - } - - private native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type, long klassPointer); - - /** - * Determines if {@code method} is ignored by security stack walks. - */ - boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method) { - return methodIsIgnoredBySecurityStackWalk(method, method.getMetaspacePointer()); - } - - private native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Converts a name to a type. - * - * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format - * @param accessingClass the class loader of this class is used for resolution. Must not be null. - * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will - * either return a {@link ResolvedJavaType} or throw an exception - * @return the type for {@code name} or {@code null} if resolution failed and {@code resolve == false} - * @throws NoClassDefFoundError if {@code resolve == true} and the resolution failed - */ - HotSpotResolvedJavaType lookupType(String name, HotSpotResolvedObjectTypeImpl accessingClass, boolean resolve) throws NoClassDefFoundError { - return lookupType(name, accessingClass, accessingClass.getKlassPointer(), -1, resolve); - } - - /** - * Converts a name to a type. - * - * @param classLoader the class loader to use for resolution. Must not be {@code null}, - * {@link ClassLoader#getPlatformClassLoader} or {@link ClassLoader#getSystemClassLoader} - * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format - * @return the type for {@code name} - * @throws NoClassDefFoundError if resolution failed - */ - HotSpotResolvedJavaType lookupType(ClassLoader classLoader, String name) throws NoClassDefFoundError { - int accessingClassLoader; - if (classLoader == null) { - accessingClassLoader = 0; - } else if (classLoader == ClassLoader.getPlatformClassLoader()) { - accessingClassLoader = 1; - } else if (classLoader == ClassLoader.getSystemClassLoader()) { - accessingClassLoader = 2; - } else { - throw new IllegalArgumentException("Unsupported class loader for lookup: " + classLoader); - } - return lookupType(name, null, 0L, accessingClassLoader, true); - } - - /** - * @param accessingClassLoader ignored if {@code accessingKlassPointer != 0L}. Otherwise, the supported values are: - * 0 - boot class loader - * 1 - {@linkplain ClassLoader#getPlatformClassLoader() platform class loader} - * 2 - {@linkplain ClassLoader#getSystemClassLoader() system class loader} - */ - private native HotSpotResolvedJavaType lookupType(String name, HotSpotResolvedObjectTypeImpl accessingClass, long accessingKlassPointer, int accessingClassLoader, boolean resolve) throws NoClassDefFoundError; - - /** - * Converts {@code javaClass} to a HotSpotResolvedJavaType. - * - * Must not be called if {@link Services#IS_IN_NATIVE_IMAGE} is {@code true}. - */ - native HotSpotResolvedJavaType lookupClass(Class javaClass); - - native HotSpotResolvedJavaType lookupJClass(long jclass); - - /** - * Gets the {@code jobject} value wrapped by {@code peerObject}. - * Must not be called if {@link Services#IS_IN_NATIVE_IMAGE} is {@code false}. - */ - native long getJObjectValue(HotSpotObjectConstantImpl peerObject); - - /** - * Resolves the entry at index {@code cpi} in {@code constantPool} to an interned String object. - * - * The behavior of this method is undefined if {@code cpi} does not denote an - * {@code JVM_CONSTANT_String}. - */ - JavaConstant getUncachedStringInPool(HotSpotConstantPool constantPool, int cpi) { - return getUncachedStringInPool(constantPool, constantPool.getConstantPoolPointer(), cpi); - } - - private native JavaConstant getUncachedStringInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi); - - /** - * Gets the entry at index {@code cpi} in {@code constantPool}, looking in the - * constant pool cache first. - * - * The behavior of this method is undefined if {@code cpi} does not denote one of the following - * entry types: {@code JVM_CONSTANT_Dynamic}, {@code JVM_CONSTANT_String}, - * {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError}, - * {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}. - * - * @param resolve specifies if a resolved entry is expected. If {@code false}, - * {@code null} is returned for an unresolved entry. - */ - JavaConstant lookupConstantInPool(HotSpotConstantPool constantPool, int cpi, boolean resolve) { - return lookupConstantInPool(constantPool, constantPool.getConstantPoolPointer(), cpi, resolve); - } - - private native JavaConstant lookupConstantInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi, boolean resolve); - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} index referenced by the {@code rawIndex}. - * The meaning of {@code rawIndex} is dependent on the given {@opcode}. - * - * The behavior of this method is undefined if the class holding the {@code constantPool} - * has not yet been rewritten, or {@code rawIndex} is not a valid index for - * this class for the given {@code opcode} - */ - int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int rawIndex, int opcode) { - return lookupNameAndTypeRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, opcode); - } - - private native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex, int opcode); - - /** - * Gets the name of the {@code JVM_CONSTANT_NameAndType} entry in {@code constantPool} - * referenced by the {@code which}. - * - * The behavior of this method is undefined if the class holding the {@code constantPool} - * has not yet been rewritten, or {@code which} is not a valid index for - * this class for the given {@code opcode} - * - * @param which for INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}, must be {@code cpci}. For all other bytecodes, - * must be {@code rawIndex} - */ - String lookupNameInPool(HotSpotConstantPool constantPool, int which, int opcode) { - return lookupNameInPool(constantPool, constantPool.getConstantPoolPointer(), which, opcode); - } - - private native String lookupNameInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which, int opcode); - - /** - * Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry in {@code constantPool} - * referenced by the {@code which}. - * - * The behavior of this method is undefined if the class holding the {@code constantPool} - * has not yet been rewritten, or {@code which} is not a valid index for - * this class for the given {@code opcode} - * - * @param which for INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}, must be {@code cpci}. For all other bytecodes, - * must be {@code rawIndex} - */ - String lookupSignatureInPool(HotSpotConstantPool constantPool, int which, int opcode) { - return lookupSignatureInPool(constantPool, constantPool.getConstantPoolPointer(), which, opcode); - } - - private native String lookupSignatureInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which, int opcode); - - /** - * Gets the {@code JVM_CONSTANT_Class} index from the entry in {@code constantPool} - * referenced by the {@code which}. The meaning of {@code which} is dependent - * on the given {@opcode}. - * - * The behavior of this method is undefined if the class holding the {@code constantPool} - * has not yet been rewritten, or {@code which} is not a valid index for - * this class for the given {@code opcode} - * - * @param which for INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}, must be {@code cpci}. For all other bytecodes, - * must be {@code rawIndex} - */ - int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int which, int opcode) { - return lookupKlassRefIndexInPool(constantPool, constantPool.getConstantPoolPointer(), which, opcode); - } - - private native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which, int opcode); - - /** - * Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in - * {@code constantPool}. This method does not perform any resolution. - * - * The behavior of this method is undefined if {@code cpi} does not denote a - * {@code JVM_CONSTANT_Class} entry. - * - * @return the resolved class entry or a String otherwise - */ - Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi) { - return lookupKlassInPool(constantPool, constantPool.getConstantPoolPointer(), cpi); - } - - private native Object lookupKlassInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi); - - /** - * Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This - * method does not perform any resolution. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a method. - * - * @param opcode the opcode of the instruction for which the lookup is being performed or - * {@code -1}. If non-negative, then resolution checks specific to the bytecode it - * denotes are performed if the method is already resolved. Should any of these - * checks fail, 0 is returned. - * @param caller if non-null, do access checks in the context of {@code caller} calling the - * looked up method - * @return the resolved method entry, 0 otherwise - */ - HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode, HotSpotResolvedJavaMethodImpl caller) { - long callerMethodPointer = caller == null ? 0L : caller.getMethodPointer(); - return lookupMethodInPool(constantPool, constantPool.getConstantPoolPointer(), cpi, opcode, caller, callerMethodPointer); - } - - private native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, - long constantPoolPointer, - int cpi, - byte opcode, - HotSpotResolvedJavaMethodImpl caller, - long callerMethodPointer); - - /** - * Converts the indy index operand of an invokedynamic instruction - * to an index directly into {@code constantPool}. - * - * @param resolve if {@true}, then resolve the entry (which may call a bootstrap method) - * @return {@code JVM_CONSTANT_InvokeDynamic} constant pool entry index for the invokedynamic - */ - int decodeIndyIndexToCPIndex(HotSpotConstantPool constantPool, int encoded_indy_index, boolean resolve) { - return decodeIndyIndexToCPIndex(constantPool, constantPool.getConstantPoolPointer(), encoded_indy_index, resolve); - } - - private native int decodeIndyIndexToCPIndex(HotSpotConstantPool constantPool, long constantPoolPointer, int encoded_indy_index, boolean resolve); - - /** - * Converts the {@code rawIndex} operand of a rewritten getfield/putfield/getstatic/putstatic instruction - * to an index directly into {@code constantPool}. - * - * @throws IllegalArgumentException if {@code rawIndex} is out of range. - * @return {@code JVM_CONSTANT_FieldRef} constant pool entry index for the instruction - */ - int decodeFieldIndexToCPIndex(HotSpotConstantPool constantPool, int rawIndex) { - return decodeFieldIndexToCPIndex(constantPool, constantPool.getConstantPoolPointer(), rawIndex); - } - - private native int decodeFieldIndexToCPIndex(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex); - - /** - * Converts the {@code rawIndex} operand of a rewritten invokestatic/invokespecial/invokeinterface/invokevirtual instruction - * to an index directly into {@code constantPool}. - * - * @throws IllegalArgumentException if {@code rawIndex} is out of range. - * @return {@code JVM_CONSTANT_MethodRef} or {@code JVM_CONSTANT_InterfaceMethodRef} constant pool entry index for the instruction - */ - int decodeMethodIndexToCPIndex(HotSpotConstantPool constantPool, int rawIndex) { - return decodeMethodIndexToCPIndex(constantPool, constantPool.getConstantPoolPointer(), rawIndex); - } - - private native int decodeMethodIndexToCPIndex(HotSpotConstantPool constantPool, long constantPoolPointer, int rawIndex); - - /** - * Returns the number of {@code ResolvedIndyEntry}s present within this constant - * pool. - */ - int getNumIndyEntries(HotSpotConstantPool constantPool) { - return getNumIndyEntries(constantPool, constantPool.getConstantPoolPointer()); - } - - private native int getNumIndyEntries(HotSpotConstantPool constantPool, long constantPoolPointer); - - /** - * Resolves the details for invoking the bootstrap method associated with the - * {@code CONSTANT_Dynamic_info} or @{code CONSTANT_InvokeDynamic_info} entry at {@code cpi} in - * {@code constant pool}. - * - * The return value encodes the details in an object array that is described by the pseudo Java - * object {@code info} below: - * - *
-     *     bsm_invocation = [
-     *         ResolvedJavaMethod[] method,
-     *         String name,
-     *         Object type,             // JavaConstant: reference to Class (condy) or MethodType (indy)
-     *         Object staticArguments,  // null: no static arguments
-     *                                  // JavaConstant: single static argument
-     *                                  // JavaConstant[]: multiple static arguments
-     *                                  // int[]: static arguments to be resolved via BootstrapCallInfo
-     *     ]
-     * 
- * - * @return bootstrap method invocation details as encoded above - */ - Object[] resolveBootstrapMethod(HotSpotConstantPool constantPool, int cpi) { - return resolveBootstrapMethod(constantPool, constantPool.getConstantPoolPointer(), cpi); - } - - private native Object[] resolveBootstrapMethod(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi); - - /** - * Gets the constant pool index of a static argument of a {@code CONSTANT_Dynamic_info} or - * @{code CONSTANT_InvokeDynamic_info} entry. Used when the list of static arguments in the - * {@link BootstrapMethodInvocation} is a {@code List} of the form - * {{@code arg_count}, {@code pool_index}}, meaning the arguments are not already resolved and that - * the JDK has to lookup the arguments when they are needed. The {@code cpi} corresponds to - * {@code pool_index} and the {@code index} has to be smaller than {@code arg_count}. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a {@code CONSTANT_Dynamic_info} or a @{code CONSTANT_InvokeDynamic_info}, or if the index - * is out of bounds. - * - * @param cpi the index of a {@code CONSTANT_Dynamic_info} or @{code CONSTANT_InvokeDynamic_info} entry - * @param index the index of the static argument in the list of static arguments - * @return the constant pool index associated with the static argument - */ - int bootstrapArgumentIndexAt(HotSpotConstantPool constantPool, int cpi, int index) { - return bootstrapArgumentIndexAt(constantPool, constantPool.getConstantPoolPointer(), cpi, index); - } - - private native int bootstrapArgumentIndexAt(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi, int index); - - /** - * If {@code cpi} denotes an entry representing a signature polymorphic method ({@jvms 2.9}), - * this method ensures that the type referenced by the entry is loaded and initialized. It - * {@code cpi} does not denote a signature polymorphic method, this method does nothing. - */ - void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi) { - resolveInvokeHandleInPool(constantPool, constantPool.getConstantPoolPointer(), cpi); - } - - private native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi); - - /** - * If {@code cpi} denotes an entry representing a resolved dynamic adapter (see - * {@link #decodeIndyIndexToCPIndex} and {@link #resolveInvokeHandleInPool}), return the - * opcode of the instruction for which the resolution was performed ({@code invokedynamic} or - * {@code invokevirtual}), or {@code -1} otherwise. - */ - int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi, int opcode) { - return isResolvedInvokeHandleInPool(constantPool, constantPool.getConstantPoolPointer(), cpi, opcode); - } - - private native int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi, int opcode); - - /** - * Gets the list of type names (in the format of {@link JavaType#getName()}) denoting the - * classes that define signature polymorphic methods. - */ - native String[] getSignaturePolymorphicHolders(); - - /** - * Gets the resolved type denoted by the entry at index {@code cpi} in {@code constantPool}. - * - * The behavior of this method is undefined if {@code cpi} does not denote an entry representing - * a class. - * - * @throws LinkageError if resolution failed - */ - HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError { - return resolveTypeInPool(constantPool, constantPool.getConstantPoolPointer(), cpi); - } - - private native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int cpi) throws LinkageError; - - /** - * Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry denoted by - * {@code rawIndex}. For some opcodes, checks are performed that require the - * {@code method} that contains {@code opcode} to be specified. The values returned in - * {@code info} are: - * - *
-     *     [ aflags,  // fieldDescriptor::access_flags()
-     *       offset,  // fieldDescriptor::offset()
-     *       index,   // fieldDescriptor::index()
-     *       fflags   // fieldDescriptor::field_flags()
-     *     ]
-     * 
- * - * The behavior of this method is undefined if {@code rawIndex} is invalid. - * - * @param info an array in which the details of the field are returned - * @return the type defining the field if resolution is successful, null if the type cannot be resolved - * @throws LinkageError if there were other problems resolving the field - */ - HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int rawIndex, HotSpotResolvedJavaMethodImpl method, byte opcode, int[] info) { - long methodPointer = method != null ? method.getMethodPointer() : 0L; - return resolveFieldInPool(constantPool, constantPool.getConstantPoolPointer(), rawIndex, method, methodPointer, opcode, info); - } - - private native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, long constantPoolPointer, - int rawIndex, HotSpotResolvedJavaMethodImpl method, long methodPointer, byte opcode, int[] info); - - /** - * Gets the appendix object (if any) associated with the entry identified by {@code which}. - * - * @param which if negative, is treated as an encoded indy index for INVOKEDYNAMIC; - * Otherwise, it's treated as a constant pool cache index - * for INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}. - */ - HotSpotObjectConstantImpl lookupAppendixInPool(HotSpotConstantPool constantPool, int which, int opcode) { - return lookupAppendixInPool(constantPool, constantPool.getConstantPoolPointer(), which, opcode); - } - - private native HotSpotObjectConstantImpl lookupAppendixInPool(HotSpotConstantPool constantPool, long constantPoolPointer, int which, int opcode); - - /** - * Installs the result of a compilation into the code cache. - * - * @param compiledCode the result of a compilation - * @param code the details of the installed CodeBlob are written to this object - * - * @return the outcome of the installation which will be one of - * {@link HotSpotVMConfig#codeInstallResultOk}, - * {@link HotSpotVMConfig#codeInstallResultCacheFull}, - * {@link HotSpotVMConfig#codeInstallResultCodeTooLarge} or - * {@link HotSpotVMConfig#codeInstallResultDependenciesFailed}. - * @throws JVMCIError if there is something wrong with the compiled code or the associated - * metadata. - */ - int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, long failedSpeculationsAddress, byte[] speculations) { - int codeInstallFlags = getInstallCodeFlags(); - boolean withComments = (codeInstallFlags & 0x0001) != 0; - boolean withMethods = (codeInstallFlags & 0x0002) != 0; - boolean withTypeInfo; - if ((codeInstallFlags & 0x0004) != 0 && HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.isDefault) { - withTypeInfo = true; - } else { - withTypeInfo = HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.getBoolean(); - } - try (HotSpotCompiledCodeStream stream = new HotSpotCompiledCodeStream(compiledCode, withTypeInfo, withComments, withMethods)) { - return installCode0(stream.headChunk, stream.timeNS, withTypeInfo, compiledCode, stream.objectPool, code, failedSpeculationsAddress, speculations); - } - } - - native int installCode0(long compiledCodeBuffer, - long serializationNS, - boolean withTypeInfo, - HotSpotCompiledCode compiledCode, - Object[] objectPool, - InstalledCode code, - long failedSpeculationsAddress, - byte[] speculations); - - native String getInvalidationReasonDescription(int invalidationReason); - - /** - * Gets flags specifying optional parts of code info. Only if a flag is set, will the - * corresponding code info being included in the {@linkplain HotSpotCompiledCodeStream - * serialized code stream}. - * - *
    - *
  • 0x0001: code comments ({@link HotSpotCompiledCode#comments})
  • - *
  • 0x0002: methods ({@link HotSpotCompiledCode#methods})
  • - *
  • 0x0004: enable {@link Option#CodeSerializationTypeInfo} if it not explicitly specified - * (i.e., {@link Option#isDefault} is {@code true})
  • - *
- */ - private native int getInstallCodeFlags(); - - /** - * Resets all compilation statistics. - */ - native void resetCompilationStatistics(); - - /** - * Reads the database of VM info. The return value encodes the info in a nested object array - * that is described by the pseudo Java object {@code info} below: - * - *
-     *     info = [
-     *         VMField[] vmFields,
-     *         [String name, Long size, ...] vmTypeSizes,
-     *         [String name, Long value, ...] vmConstants,
-     *         [String name, Long value, ...] vmAddresses,
-     *         VMFlag[] vmFlags
-     *         VMIntrinsicMethod[] vmIntrinsics
-     *     ]
-     * 
- * - * @return VM info as encoded above - */ - native Object[] readConfiguration(); - - /** - * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic - * type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of - * {@code exactReceiver}. - * - * @param exactReceiver the exact receiver type - * @param caller the caller or context type used to perform access checks - * @return the link-time resolved method (might be abstract) or {@code null} if it is either a - * signature polymorphic method or can not be linked. - */ - HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller) { - return resolveMethod(exactReceiver, exactReceiver.getKlassPointer(), method, method.getMethodPointer(), caller, caller.getKlassPointer()); - } - - private native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, long exactReceiverKlass, - HotSpotResolvedJavaMethodImpl method, long methodPointer, - HotSpotResolvedObjectTypeImpl caller, long callerKlass); - - /** - * Gets the static initializer of {@code type}. - * - * @return {@code null} if {@code type} has no static initializer - */ - HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type) { - return getClassInitializer(type, type.getKlassPointer()); - } - - private native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type, long klassPointer); - - /** - * Determines if {@code type} or any of its currently loaded subclasses overrides - * {@code Object.finalize()}. - */ - boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type) { - return hasFinalizableSubclass(type, type.getKlassPointer()); - } - - private native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type, long klassPointer); - - /** - * Gets the method corresponding to {@code executable}. - */ - native HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(Executable executable); - - /** - * Gets the maximum absolute offset of a PC relative call to {@code address} from any position - * in the code cache. - * - * @param address an address that may be called from any code in the code cache - * @return -1 if {@code address == 0} - */ - native long getMaxCallTargetOffset(long address); - - /** - * Gets a textual disassembly of {@code codeBlob}. - * - * @return a non-zero length string containing a disassembly of {@code codeBlob} or null if - * {@code codeBlob} could not be disassembled for some reason - */ - // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage - synchronized native String disassembleCodeBlob(InstalledCode installedCode); - - /** - * Gets a stack trace element for {@code method} at bytecode index {@code bci}. - */ - StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci) { - return getStackTraceElement(method, method.getMethodPointer(), bci); - } - - private native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, long methodPointer, int bci); - - /** - * Executes some {@code installedCode} with arguments {@code args}. - * - * @return the result of executing {@code nmethodMirror} - * @throws InvalidInstalledCodeException if {@code nmethodMirror} has been invalidated - */ - native Object executeHotSpotNmethod(Object[] args, HotSpotNmethod nmethodMirror) throws InvalidInstalledCodeException; - - /** - * Gets the line number table for {@code method}. The line number table is encoded as (bci, - * source line number) pairs. - * - * @return the line number table for {@code method} or null if it doesn't have one - */ - long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method) { - return getLineNumberTable(method, method.getMethodPointer()); - } - - private native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets the number of entries in the local variable table for {@code method}. - * - * @return the number of entries in the local variable table for {@code method} - */ - int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method) { - return getLocalVariableTableLength(method, method.getMethodPointer()); - } - - private native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets the address of the first entry in the local variable table for {@code method}. - * - * Each entry is a native object described by these fields: - * - *
    - *
  • {@link HotSpotVMConfig#localVariableTableElementSize}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementLengthOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}
  • - *
  • {@link HotSpotVMConfig#localVariableTableElementSlotOffset} - *
  • {@link HotSpotVMConfig#localVariableTableElementStartBciOffset} - *
- * - * @return 0 if {@code method} does not have a local variable table - */ - long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method) { - return getLocalVariableTableStart(method, method.getMetaspacePointer()); - } - - private native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Sets flags on {@code method} indicating that it should never be inlined or compiled by the - * VM. - */ - void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method) { - setNotInlinableOrCompilable(method, method.getMethodPointer()); - } - - private native void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Invalidates the profiling information for {@code method} and (re)initializes it such that - * profiling restarts upon its next invocation. - */ - void reprofile(HotSpotResolvedJavaMethodImpl method) { - reprofile(method, method.getMethodPointer()); - } - - private native void reprofile(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Updates {@code nmethodMirror} such that {@link InvalidInstalledCodeException} will be raised - * the next time {@code nmethodMirror} is {@linkplain #executeHotSpotNmethod executed}. The - * {@code nmethod} associated with {@code nmethodMirror} is also made non-entrant and if - * {@code deoptimize == true} any current activations of the {@code nmethod} are deoptimized. - */ - native void invalidateHotSpotNmethod(HotSpotNmethod nmethodMirror, boolean deoptimize, int invalidationReason); - - /** - * Collects the current values of all JVMCI benchmark counters, summed up over all threads. - */ - native long[] collectCounters(); - - /** - * Get the current number of counters allocated for use by JVMCI. Should be the same value as - * the flag {@code JVMCICounterSize}. - */ - native int getCountersSize(); - - /** - * Attempt to change the size of the counters allocated for JVMCI. This requires a safepoint to - * safely reallocate the storage but it's advisable to increase the size in reasonable chunks. - */ - native boolean setCountersSize(int newSize); - - /** - * Determines if {@code methodData} is mature. - * - * @param methodData a {@code MethodData*} value - */ - native boolean isMature(long methodData); - - /** - * Generate a unique id to identify the result of the compile. - */ - int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI) { - return allocateCompileId(method, method.getMethodPointer(), entryBCI); - } - - private native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, long methodPointer, int entryBCI); - - /** - * Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for - * compilation level {@code level}. - */ - boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level) { - return hasCompiledCodeForOSR(method, method.getMethodPointer(), entryBCI, level); - } - - private native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, long methodPoiner, int entryBCI, int level); - - /** - * Gets the value of {@code symbol} as a String. - * - * @param symbol a {@code Symbol*} value - */ - native String getSymbol(long symbol); - - /** - * Gets the name for a {@code klass} as it would appear in a signature. - * - * @param klass a {@code Klass*} value - */ - native String getSignatureName(long klass); - - /** - * @see jdk.vm.ci.code.stack.StackIntrospection#iterateFrames - */ - native T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor); - - /** - * Materializes all virtual objects within {@code stackFrame} and updates its locals. - * - * @param invalidate if {@code true}, the compiled method for the stack frame will be - * invalidated - */ - native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); - - /** - * Gets the v-table index for interface method {@code method} in the receiver {@code type} or - * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s - * v-table. - * - * @throws InternalError if {@code type} is an interface, {@code method} is not defined by an - * interface, {@code type} does not implement the interface defining {@code method} - * or class represented by {@code type} is not initialized - */ - int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method) { - return getVtableIndexForInterfaceMethod(type, type.getKlassPointer(), method, method.getMethodPointer()); - } - - private native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, long klassPointer, HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Determines if debug info should also be emitted at non-safepoint locations. - */ - native boolean shouldDebugNonSafepoints(); - - /** - * Writes {@code length} bytes from {@code buffer} to HotSpot's log stream. - * - * @param buffer if {@code length <= 8}, then the bytes are encoded in this value in native - * endianness order otherwise this is the address of a native memory buffer holding - * the bytes - * @param flush specifies if the log stream should be flushed after writing - */ - native void writeDebugOutput(long buffer, int length, boolean flush); - - /** - * Flush HotSpot's log stream. - */ - native void flushDebugOutput(); - - /** - * Read a HotSpot {@code Method*} value from the memory location described by {@code base} plus - * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This - * method does no checking that the memory location actually contains a valid pointer and may - * crash the VM if an invalid location is provided. If {@code base == null} is null then - * {@code displacement} is used by itself. If {@code base} is a - * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or - * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object - * and added to {@code displacement}. Any other non-null object type causes an - * {@link IllegalArgumentException} to be thrown. - * - * @param base an object to read from or null - * @param displacement - * @return null or the resolved method for this location - */ - native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(HotSpotObjectConstantImpl base, long displacement); - - /** - * Gets the {@code ConstantPool*} associated with {@code object} and returns a - * {@link HotSpotConstantPool} wrapping it. - * - * @param object a {@link HotSpotResolvedJavaMethodImpl} or - * {@link HotSpotResolvedObjectTypeImpl} object - * @return a {@link HotSpotConstantPool} wrapping the {@code ConstantPool*} associated with - * {@code object} - * @throws NullPointerException if {@code object == null} - * @throws IllegalArgumentException if {@code object} is neither a - * {@link HotSpotResolvedJavaMethodImpl} nor a {@link HotSpotResolvedObjectTypeImpl} - */ - HotSpotConstantPool getConstantPool(MetaspaceObject object) { - return getConstantPool(object, object.getMetaspacePointer(), object instanceof HotSpotResolvedJavaType); - } - - native HotSpotConstantPool getConstantPool(Object object, long klassOrMethod, boolean isKlass); - - /** - * Read a {@code Klass*} value from the memory location described by {@code base} plus - * {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This method - * only performs the read if the memory location is known to contain a valid Klass*. If - * {@code base} is a {@link HotSpotConstantPool}, {@link HotSpotMethodData}, {@link HotSpotObjectConstantImpl}, - * or {@link HotSpotResolvedObjectTypeImpl} then the field - * corresopnding to {@code displacement} is fetched using the appropriate HotSpot accessor. Any - * other object type or an unexpected displacement causes an {@link IllegalArgumentException} to - * be thrown. The set of fields which can be read in this fashion corresponds to the {@link VMField} - * with type {@code Klass*} that are described in the {@link HotSpotVMConfigStore#getFields()}. - * Additionally several injected fields in {@link Class} are also handled. - * - * @param base an object to read from - * @param displacement - * @param compressed true if the location contains a compressed Klass* - * @return null or the resolved method for this location - * @throws NullPointerException if {@code base == null} - */ - private native HotSpotResolvedObjectTypeImpl getResolvedJavaType0(Object base, long displacement, boolean compressed); - - HotSpotResolvedObjectTypeImpl getResolvedJavaType(HotSpotConstantPool base, long displacement) { - return getResolvedJavaType0(base, displacement, false); - } - - HotSpotResolvedObjectTypeImpl getResolvedJavaType(HotSpotMethodData base, long displacement) { - return getResolvedJavaType0(base, displacement, false); - } - - HotSpotResolvedObjectTypeImpl getResolvedJavaType(HotSpotResolvedObjectTypeImpl base, long displacement, boolean compressed) { - return getResolvedJavaType0(base, displacement, compressed); - } - - HotSpotResolvedObjectTypeImpl getResolvedJavaType(HotSpotObjectConstantImpl base, long displacement, boolean compressed) { - return getResolvedJavaType0(base, displacement, compressed); - } - - /** - * Reads a {@code Klass*} from {@code address} (i.e., {@code address} is a {@code Klass**} - * value) and wraps it in a {@link HotSpotResolvedObjectTypeImpl}. This VM call must be used for - * any {@code Klass*} value not known to be already wrapped in a - * {@link HotSpotResolvedObjectTypeImpl}. The VM call is necessary so that the {@code Klass*} is - * wrapped in a {@code JVMCIKlassHandle} to protect it from the concurrent scanning done by G1. - */ - HotSpotResolvedObjectTypeImpl getResolvedJavaType(long address) { - return getResolvedJavaType0(null, address, false); - } - - /** - * Return the size of the HotSpot ProfileData* pointed at by {@code position}. If - * {@code position} is outside the space of the MethodData then an - * {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that - * isn't pointing at a valid ProfileData will crash the VM. - * - * @param metaspaceMethodData - * @param position - * @return the size of the ProfileData item pointed at by {@code position} - * @throws IllegalArgumentException if an out of range position is given - */ - native int methodDataProfileDataSize(long metaspaceMethodData, int position); - - - native int methodDataExceptionSeen(long metaspaceMethodData, int bci); - - /** - * Return the amount of native stack required for the interpreter frames represented by - * {@code frame}. This is used when emitting the stack banging code to ensure that there is - * enough space for the frames during deoptimization. - * - * @param frame - * @return the number of bytes required for deoptimization of this frame state - */ - native int interpreterFrameSize(BytecodeFrame frame); - - /** - * Invokes non-public method {@code java.lang.invoke.LambdaForm.compileToBytecode()} on - * {@code lambdaForm} (which must be a {@code java.lang.invoke.LambdaForm} instance). - */ - native void compileToBytecode(HotSpotObjectConstantImpl lambdaForm); - - /** - * Gets the value of the VM flag named {@code name}. - * - * @param name name of a VM option - * @return {@code this} if the named VM option doesn't exist, a {@link String} or {@code null} - * if its type is {@code ccstr} or {@code ccstrlist}, a {@link Double} if its type is - * {@code double}, a {@link Boolean} if its type is {@code bool} otherwise a - * {@link Long} - */ - native Object getFlagValue(String name); - - /** - * @see ResolvedJavaType#getInterfaces() - */ - HotSpotResolvedObjectTypeImpl[] getInterfaces(HotSpotResolvedObjectTypeImpl klass) { - return getInterfaces(klass, klass.getKlassPointer()); - } - - native HotSpotResolvedObjectTypeImpl[] getInterfaces(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * @see ResolvedJavaType#getComponentType() - */ - HotSpotResolvedJavaType getComponentType(HotSpotResolvedObjectTypeImpl klass) { - return getComponentType(klass, klass.getKlassPointer()); - } - - native HotSpotResolvedJavaType getComponentType(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Get the array class for the primitive type represented by the {@link JavaKind#getTypeChar()} - * value in {@code typeChar} or the non-primitive type represented by {@code nonPrimitiveKlass}. - * This can't be done symbolically since hidden classes can't be looked up by name. - * - * Exactly one of {@code primitiveTypeChar} or {@code nonPrimitiveKlass} must be non-zero. - * - * @param primitiveTypeChar a {@link JavaKind#getTypeChar()} value for a primitive type - * @param nonPrimitiveKlass a non-primitive type - */ - HotSpotResolvedObjectTypeImpl getArrayType(char primitiveTypeChar, HotSpotResolvedObjectTypeImpl nonPrimitiveKlass) { - long nonPrimitiveKlassPointer = nonPrimitiveKlass != null ? nonPrimitiveKlass.getKlassPointer() : 0L; - return getArrayType(primitiveTypeChar, nonPrimitiveKlass, nonPrimitiveKlassPointer); - } - - native HotSpotResolvedObjectTypeImpl getArrayType(char typeChar, HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Forces initialization of {@code klass}. - */ - void ensureInitialized(HotSpotResolvedObjectTypeImpl klass) { - ensureInitialized(klass, klass.getKlassPointer()); - } - - native void ensureInitialized(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Forces linking of {@code klass}. - */ - void ensureLinked(HotSpotResolvedObjectTypeImpl klass) { - ensureLinked(klass, klass.getKlassPointer()); - } - - native void ensureLinked(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Checks if {@code object} is a String and is an interned string value. - */ - native boolean isInternedString(HotSpotObjectConstantImpl object); - - /** - * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object - * represented by this constant. - */ - native int getIdentityHashCode(HotSpotObjectConstantImpl object); - - /** - * Converts a constant object representing a boxed primitive into a boxed primitive. - */ - native Object unboxPrimitive(HotSpotObjectConstantImpl object); - - /** - * Converts a boxed primitive into a JavaConstant representing the same value. - */ - native HotSpotObjectConstantImpl boxPrimitive(Object source); - - /** - * Gets the {@link ResolvedJavaMethod}s for all the constructors of {@code klass}. - */ - ResolvedJavaMethod[] getDeclaredConstructors(HotSpotResolvedObjectTypeImpl klass) { - return getDeclaredConstructors(klass, klass.getKlassPointer()); - } - - native ResolvedJavaMethod[] getDeclaredConstructors(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Gets the {@link ResolvedJavaMethod}s for all non-overpass and non-initializer - * methods of {@code klass}. - */ - ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass) { - return getDeclaredMethods(klass, klass.getKlassPointer()); - } - - native ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Gets the {@link ResolvedJavaMethod}s for all methods of {@code klass}. - */ - ResolvedJavaMethod[] getAllMethods(HotSpotResolvedObjectTypeImpl klass) { - return getAllMethods(klass, klass.getKlassPointer()); - } - - native ResolvedJavaMethod[] getAllMethods(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - HotSpotResolvedObjectTypeImpl.FieldInfo[] getDeclaredFieldsInfo(HotSpotResolvedObjectTypeImpl klass) { - return getDeclaredFieldsInfo(klass, klass.getKlassPointer()); - } - - native HotSpotResolvedObjectTypeImpl.FieldInfo[] getDeclaredFieldsInfo(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Reads the current value of a static field of {@code declaringKlass}. Extra sanity checking is - * performed on the offset and kind of the read being performed. - * - * @param declaringKlass the type in which the static field is declared - * @param offset the offset of the field in the {@link Class} mirror of {@code declaringKlass} - * @throws IllegalArgumentException if any of the sanity checks fail - */ - JavaConstant readStaticFieldValue(HotSpotResolvedObjectTypeImpl declaringKlass, long offset, char typeChar) { - return readStaticFieldValue(declaringKlass, declaringKlass.getKlassPointer(), offset, typeChar); - } - - native JavaConstant readStaticFieldValue(HotSpotResolvedObjectTypeImpl declaringKlass, long declaringKlassPointer, long offset, char typeChar); - - /** - * Reads the current value of an instance field. If {@code expectedType} is non-null, then - * {@code object} is expected to be a subtype of {@code expectedType}. Extra sanity checking is - * performed on the offset and kind of the read being performed. - * - * @param object the object from which the field is to be read. If {@code object} is of type - * {@link Class} and {@code offset} is >= the offset of the static field storage in a - * {@link Class} instance, then this operation is a static field read. - * @param expectedType the expected type of {@code object} - * @throws IllegalArgumentException if any of the sanity checks fail - */ - JavaConstant readFieldValue(HotSpotObjectConstantImpl object, HotSpotResolvedObjectTypeImpl expectedType, long offset, char typeChar) { - long expectedTypePointer = expectedType != null ? expectedType.getKlassPointer() : 0L; - return readFieldValue(object, expectedType, expectedTypePointer, offset, typeChar); - } - - native JavaConstant readFieldValue(HotSpotObjectConstantImpl object, HotSpotResolvedObjectTypeImpl expectedType, long expectedTypePointer, long offset, char typeChar); - - /** - * @see ResolvedJavaType#isInstance(JavaConstant) - */ - boolean isInstance(HotSpotResolvedObjectTypeImpl klass, HotSpotObjectConstantImpl object) { - return isInstance(klass, klass.getKlassPointer(), object); - } - - native boolean isInstance(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotObjectConstantImpl object); - - /** - * @see ResolvedJavaType#isAssignableFrom(ResolvedJavaType) - */ - boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl klass, HotSpotResolvedObjectTypeImpl subklass) { - return isAssignableFrom(klass, klass.getKlassPointer(), subklass, subklass.getKlassPointer()); - } - - native boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl klass, long klassPointer, HotSpotResolvedObjectTypeImpl subklass, long subklassPointer); - - /** - * @see ConstantReflectionProvider#asJavaType(Constant) - */ - native HotSpotResolvedJavaType asJavaType(HotSpotObjectConstantImpl object); - - /** - * Converts a String constant into a String. - */ - native String asString(HotSpotObjectConstantImpl object); - - /** - * Compares the contents of {@code xHandle} and {@code yHandle} for pointer equality. - */ - native boolean equals(HotSpotObjectConstantImpl x, long xHandle, HotSpotObjectConstantImpl y, long yHandle); - - /** - * Gets a {@link JavaConstant} wrapping the {@link java.lang.Class} mirror for {@code klass}. - */ - HotSpotObjectConstantImpl getJavaMirror(HotSpotResolvedObjectTypeImpl klass) { - return getJavaMirror(klass, klass.getKlassPointer()); - } - - native HotSpotObjectConstantImpl getJavaMirror(HotSpotResolvedObjectTypeImpl type, long klassPointer); - - /** - * Returns the length of the array if {@code object} represents an array or -1 otherwise. - */ - native int getArrayLength(HotSpotObjectConstantImpl object); - - /** - * Reads the element at {@code index} if {@code object} is an array. Elements of an object array - * are returned as {@link JavaConstant}s and primitives are returned as boxed values. The value - * {@code null} is returned if the {@code index} is out of range or object is not an array. - */ - native Object readArrayElement(HotSpotObjectConstantImpl object, int index); - - /** - * @see HotSpotJVMCIRuntime#registerNativeMethods - */ - native long[] registerNativeMethods(Class clazz); - - /** - * @see HotSpotJVMCIRuntime#translate(Object) - */ - native long translate(Object obj, boolean callPostTranslation); - - /** - * @see HotSpotJVMCIRuntime#unhand(Class, long) - */ - native Object unhand(long handle); - - /** - * Updates {@code address} and {@code entryPoint} fields of {@code nmethodMirror} based on the - * current state of the {@code nmethod} identified by {@code address} and - * {@code nmethodMirror.compileId} in the code cache. - */ - native void updateHotSpotNmethod(HotSpotNmethod nmethodMirror); - - /** - * @see InstalledCode#getCode() - */ - native byte[] getCode(HotSpotInstalledCode code); - - /** - * Gets a {@link Executable} corresponding to {@code method}. - */ - Executable asReflectionExecutable(HotSpotResolvedJavaMethodImpl method) { - return asReflectionExecutable(method, method.getMethodPointer()); - } - - native Executable asReflectionExecutable(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Gets a {@link Field} denoted by {@code holder} and {@code index}. - * - * @param holder the class in which the requested field is declared - * @param fieldIndex the {@code fieldDescriptor::index()} denoting the field - */ - Field asReflectionField(HotSpotResolvedObjectTypeImpl holder, int fieldIndex) { - return asReflectionField(holder, holder.getKlassPointer(), fieldIndex); - } - - native Field asReflectionField(HotSpotResolvedObjectTypeImpl holder, long holderPointer, int fieldIndex); - - /** - * @see HotSpotJVMCIRuntime#getIntrinsificationTrustPredicate(Class...) - */ - boolean isTrustedForIntrinsics(HotSpotResolvedObjectTypeImpl klass) { - return isTrustedForIntrinsics(klass, klass.getKlassPointer()); - } - - native boolean isTrustedForIntrinsics(HotSpotResolvedObjectTypeImpl klass, long klassPointer); - - /** - * Clears the oop handle in {@code handle}. - */ - native void clearOopHandle(long handle); - - /** - * Releases all oop handles whose referent is null. - */ - native void releaseClearedOopHandles(); - - /** - * Gets the failed speculations pointed to by {@code *failedSpeculationsAddress}. - * - * @param currentFailures the known failures at {@code failedSpeculationsAddress} - * @return the list of failed speculations with each entry being a single speculation in the - * format emitted by {@link HotSpotSpeculationEncoding#toByteArray()} - */ - native byte[][] getFailedSpeculations(long failedSpeculationsAddress, byte[][] currentFailures); - - /** - * Gets the address of the {@code MethodData::_failed_speculations} field in the - * {@code MethodData} associated with {@code method}. This will create and install the - * {@code MethodData} if it didn't already exist. - */ - long getFailedSpeculationsAddress(HotSpotResolvedJavaMethodImpl method) { - return getFailedSpeculationsAddress(method, method.getMethodPointer()); - } - - native long getFailedSpeculationsAddress(HotSpotResolvedJavaMethodImpl method, long methodPointer); - - /** - * Frees the failed speculations pointed to by {@code *failedSpeculationsAddress}. - */ - native void releaseFailedSpeculations(long failedSpeculationsAddress); - - /** - * Adds a speculation to the failed speculations pointed to by - * {@code *failedSpeculationsAddress}. - * - * @return {@code false} if the speculation could not be appended to the list - */ - native boolean addFailedSpeculation(long failedSpeculationsAddress, byte[] speculation); - - /** - * @see HotSpotJVMCIRuntime#isCurrentThreadAttached() - */ - native boolean isCurrentThreadAttached(); - - /** - * @see HotSpotJVMCIRuntime#getCurrentJavaThread() - */ - native long getCurrentJavaThread(); - - /** - * @param name name of current thread if in a native image otherwise {@code null} - * @see HotSpotJVMCIRuntime#attachCurrentThread - */ - native boolean attachCurrentThread(byte[] name, boolean asDaemon, long[] javaVMInfo); - - /** - * @see HotSpotJVMCIRuntime#detachCurrentThread - */ - native boolean detachCurrentThread(boolean release); - - /** - * @see HotSpotJVMCIRuntime#exitHotSpot(int) - */ - native void callSystemExit(int status); - - /** - * @see JFR.Ticks#now - */ - native long ticksNow(); - - /** - * @see HotSpotJVMCIRuntime#setThreadLocalObject(int, Object) - */ - native void setThreadLocalObject(int id, Object value); - - /** - * @see HotSpotJVMCIRuntime#getThreadLocalObject(int) - */ - native Object getThreadLocalObject(int id); - - /** - * @see HotSpotJVMCIRuntime#setThreadLocalLong(int, long) - */ - native void setThreadLocalLong(int id, long value); - - /** - * @see HotSpotJVMCIRuntime#getThreadLocalLong(int) - */ - native long getThreadLocalLong(int id); - - /** - * Adds phases in HotSpot JFR. - * - * @see JFR.CompilerPhaseEvent#write - */ - native int registerCompilerPhase(String phaseName); - - /** - * @see JFR.CompilerPhaseEvent#write - */ - native void notifyCompilerPhaseEvent(long startTime, int phase, int compileId, int level); - - /** - * @see JFR.CompilerInliningEvent#write - */ - void notifyCompilerInliningEvent(int compileId, HotSpotResolvedJavaMethodImpl caller, HotSpotResolvedJavaMethodImpl callee, boolean succeeded, String message, int bci) { - notifyCompilerInliningEvent(compileId, caller, caller.getMethodPointer(), callee, callee.getMethodPointer(), succeeded, message, bci); - } - - native void notifyCompilerInliningEvent(int compileId, HotSpotResolvedJavaMethodImpl caller, long callerPointer, - HotSpotResolvedJavaMethodImpl callee, long calleePointer, boolean succeeded, String message, int bci); - - /** - * Gets the serialized annotation info for {@code type} by calling - * {@code VMSupport.encodeAnnotations} in the HotSpot heap. - */ - byte[] getEncodedClassAnnotationData(HotSpotResolvedObjectTypeImpl type, ResolvedJavaType[] filter) { - try (KlassPointers a = new KlassPointers(filter)) { - return getEncodedClassAnnotationData(type, type.getKlassPointer(), - a.types, a.types.length, a.buffer()); - } - } - - native byte[] getEncodedClassAnnotationData(HotSpotResolvedObjectTypeImpl type, long klassPointer, - Object filter, int filterLength, long filterKlassPointers); - - /** - * Gets the serialized annotation info for {@code method} by calling - * {@code VMSupport.encodeAnnotations} in the HotSpot heap. - */ - byte[] getEncodedExecutableAnnotationData(HotSpotResolvedJavaMethodImpl method, ResolvedJavaType[] filter) { - try (KlassPointers a = new KlassPointers(filter)) { - return getEncodedExecutableAnnotationData(method, method.getMethodPointer(), - a.types, a.types.length, a.buffer()); - } - } - - native byte[] getEncodedExecutableAnnotationData(HotSpotResolvedJavaMethodImpl method, long methodPointer, - Object filter, int filterLength, long filterKlassPointers); - - /** - * Gets the serialized annotation info for the field denoted by {@code holder} and - * {@code fieldIndex} by calling {@code VMSupport.encodeAnnotations} in the HotSpot heap. - */ - byte[] getEncodedFieldAnnotationData(HotSpotResolvedObjectTypeImpl holder, int fieldIndex, ResolvedJavaType[] filter) { - try (KlassPointers a = new KlassPointers(filter)) { - return getEncodedFieldAnnotationData(holder, holder.getKlassPointer(), fieldIndex, - a.types, a.types.length, a.buffer()); - } - } - - native byte[] getEncodedFieldAnnotationData(HotSpotResolvedObjectTypeImpl holder, long klassPointer, int fieldIndex, - Object filterTypes, int filterLength, long filterKlassPointers); - - /** - * Helper for passing {@Klass*} values to native code. - */ - static final class KlassPointers implements AutoCloseable { - final ResolvedJavaType[] types; - long pointersArray; - final Unsafe unsafe = UnsafeAccess.UNSAFE; - - KlassPointers(ResolvedJavaType[] types) { - this.types = types; - } - - /** - * Gets the buffer in which to pass the {@Klass*} values to JNI. - * - * @return a {@Klass*} value if {@code types.length == 1} otherwise the address of a native - * buffer holding an array of {@Klass*} values - */ - long buffer() { - int length = types.length; - if (length == 1) { - return ((HotSpotResolvedObjectTypeImpl) types[0]).getKlassPointer(); - } else { - pointersArray = unsafe.allocateMemory(length * Long.BYTES); - long pos = pointersArray; - for (int i = 0; i < types.length; i++) { - HotSpotResolvedObjectTypeImpl hsType = (HotSpotResolvedObjectTypeImpl) types[i]; - unsafe.putLong(pos, hsType.getKlassPointer()); - pos += Long.BYTES; - } - } - return pointersArray; - } - - @Override - public void close() { - if (types.length != 1 && pointersArray != 0) { - unsafe.freeMemory(pointersArray); - pointersArray = 0; - } - } - } - - /** - * @see HotSpotResolvedJavaMethod#getOopMapAt - */ - void getOopMapAt(HotSpotResolvedJavaMethodImpl method, int bci, long[] oopMap) { - getOopMapAt(method, method.getMethodPointer(), bci, oopMap); - } - - native void getOopMapAt(HotSpotResolvedJavaMethodImpl method, long methodPointer, int bci, long[] oopMap); - - /** - * If the current thread is a CompilerThread associated with a JVMCI compiler where - * newState != CompilerThread::_can_call_java, then _can_call_java is set to newState. - * - * @returns false if no change was made, otherwise true - */ - native boolean updateCompilerThreadCanCallJava(boolean newState); - - /** - * Returns the current {@code CompileBroker} compilation activity mode which is one of: - * {@code stop_compilation = 0}, {@code run_compilation = 1} or {@code shutdown_compilation = 2} - */ - native int getCompilationActivityMode(); - - /** - * Returns whether the current thread is a CompilerThread. - */ - native boolean isCompilerThread(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java deleted file mode 100644 index c241af0348a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaConstant; - -final class DirectHotSpotObjectConstantImpl extends HotSpotObjectConstantImpl { - - static JavaConstant forObject(Object object, boolean compressed) { - if (object == null) { - return compressed ? HotSpotCompressedNullConstant.COMPRESSED_NULL : JavaConstant.NULL_POINTER; - } else { - return new DirectHotSpotObjectConstantImpl(object, compressed); - } - } - - static HotSpotObjectConstantImpl forNonNullObject(Object object, boolean compressed) { - if (object == null) { - throw new NullPointerException(); - } - return new DirectHotSpotObjectConstantImpl(object, compressed); - } - - private DirectHotSpotObjectConstantImpl(Object object, boolean compressed) { - super(compressed); - assert object != null; - this.object = object; - } - - final Object object; - - @Override - public JavaConstant compress() { - if (compressed) { - throw new IllegalArgumentException("already compressed: " + this); - } - return new DirectHotSpotObjectConstantImpl(object, true); - } - - @Override - public JavaConstant uncompress() { - if (!compressed) { - throw new IllegalArgumentException("not compressed: " + this); - } - return new DirectHotSpotObjectConstantImpl(object, false); - } - - @Override - public int getIdentityHashCode() { - return System.identityHashCode(object); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EmptyEventProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EmptyEventProvider.java deleted file mode 100644 index db9b161dd32..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EmptyEventProvider.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * An empty implementation for {@link EventProvider}. This implementation is used when no logging is - * requested. - */ -final class EmptyEventProvider implements EventProvider { - - static InternalError shouldNotReachHere() { - throw new InternalError("should not reach here"); - } - - @Override - public CompilationEvent newCompilationEvent() { - return new EmptyCompilationEvent(); - } - - static class EmptyCompilationEvent implements CompilationEvent { - @Override - public void commit() { - throw shouldNotReachHere(); - } - - @Override - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - @Override - public void begin() { - } - - @Override - public void end() { - } - - @Override - public void setMethod(String method) { - throw shouldNotReachHere(); - } - - @Override - public void setCompileId(int compileId) { - throw shouldNotReachHere(); - } - - @Override - public void setCompileLevel(int compileLevel) { - throw shouldNotReachHere(); - } - - @Override - public void setSucceeded(boolean succeeded) { - throw shouldNotReachHere(); - } - - @Override - public void setIsOsr(boolean isOsr) { - throw shouldNotReachHere(); - } - - @Override - public void setCodeSize(int codeSize) { - throw shouldNotReachHere(); - } - - @Override - public void setInlinedBytes(int inlinedBytes) { - throw shouldNotReachHere(); - } - } - - @Override - public CompilerFailureEvent newCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - static class EmptyCompilerFailureEvent implements CompilerFailureEvent { - @Override - public void commit() { - throw shouldNotReachHere(); - } - - @Override - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - @Override - public void setCompileId(int compileId) { - throw shouldNotReachHere(); - } - - @Override - public void setMessage(String message) { - throw shouldNotReachHere(); - } - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EventProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EventProvider.java deleted file mode 100644 index 6b4d0af067d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/EventProvider.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilationEvent; -import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilerFailureEvent; - -/** - * Service-provider class for logging compiler related events. - */ -public interface EventProvider { - - /** - * Creates and returns an empty implementation for {@link EventProvider}. This implementation - * can be used when no logging is requested. - */ - static EventProvider createEmptyEventProvider() { - return new EmptyEventProvider(); - } - - /** - * Creates and returns an empty implementation for {@link CompilationEvent}. - */ - static CompilationEvent createEmptyCompilationEvent() { - return new EmptyCompilationEvent(); - } - - /** - * Creates and returns an empty implementation for {@link CompilationEvent}. - */ - static CompilerFailureEvent createEmptyCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - /** - * An instant event is an event that is not considered to have taken any time. - */ - public interface InstantEvent { - /** - * Commits the event. - */ - void commit(); - - /** - * Determines if this particular event instance would be committed to the data stream right - * now if application called {@link #commit()}. This in turn depends on whether the event is - * enabled and possible other factors. - * - * @return if this event would be committed on a call to {@link #commit()}. - */ - boolean shouldWrite(); - } - - /** - * Timed events describe an operation that somehow consumes time. - */ - public interface TimedEvent extends InstantEvent { - /** - * Starts the timing for this event. - */ - void begin(); - - /** - * Ends the timing period for this event. - */ - void end(); - } - - /** - * Creates a new {@link CompilationEvent}. - * - * @return a compilation event - */ - CompilationEvent newCompilationEvent(); - - /** - * A compilation event. - */ - public interface CompilationEvent extends TimedEvent { - void setMethod(String method); - - void setCompileId(int compileId); - - void setCompileLevel(int compileLevel); - - void setSucceeded(boolean succeeded); - - void setIsOsr(boolean isOsr); - - void setCodeSize(int codeSize); - - void setInlinedBytes(int inlinedBytes); - } - - /** - * Creates a new {@link CompilerFailureEvent}. - * - * @return a compiler failure event - */ - CompilerFailureEvent newCompilerFailureEvent(); - - /** - * A compiler failure event. - */ - public interface CompilerFailureEvent extends InstantEvent { - void setCompileId(int compileId); - - void setMessage(String message); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HandleCleaner.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HandleCleaner.java deleted file mode 100644 index 558e5fccf80..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HandleCleaner.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -/** - * This class manages a set of {@code jobject} and {@code jmetadata} handles whose lifetimes are - * dependent on associated {@link IndirectHotSpotObjectConstantImpl} and - * {@link MetaspaceHandleObject} wrapper objects respectively. - * - * The general theory of operation is that all wrappers are created by calling into the VM which - * calls back out to actually create the wrapper instance. During the call the VM keeps the object - * or metadata reference alive through the use of handles. Once the call completes the wrapper - * object is registered here and will be scanned during metadata scanning. The weakness of the - * reference to the wrapper object allows the handles to be reclaimed when they are no longer used. - */ -final class HandleCleaner extends Cleaner { - - /** - * A {@code jmetadata} or {@code jobject} handle. - */ - private final long handle; - - /** - * Specifies if {@link #handle} is a {@code jobject} or {@code jmetadata}. - */ - private final boolean isJObject; - - private HandleCleaner(Object wrapper, long handle, boolean isJObject) { - super(wrapper); - this.handle = handle; - this.isJObject = isJObject; - } - - /** - * Releases the resource associated with {@code this.handle}. - */ - @Override - boolean doCleanup() { - if (isJObject) { - IndirectHotSpotObjectConstantImpl.clearHandle(handle); - return true; - } else { - // Setting the target of a jmetadata handle to 0 enables - // the handle to be reused. See MetadataHandles in - // metadataHandles.hpp for more info. - long value = UNSAFE.getLong(null, handle); - UNSAFE.compareAndSetLong(null, handle, value, 0); - return false; - } - } - - /** - * Registers a cleaner for {@code handle}. The cleaner will release the handle some time after - * {@code wrapper} is detected as unreachable by the garbage collector. - */ - @SuppressWarnings("unused") - static void create(Object wrapper, long handle) { - assert wrapper instanceof IndirectHotSpotObjectConstantImpl || wrapper instanceof MetaspaceHandleObject; - new HandleCleaner(wrapper, handle, wrapper instanceof IndirectHotSpotObjectConstantImpl); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java deleted file mode 100644 index 3a6f28ce2a9..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCallingConventionType.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; - -public enum HotSpotCallingConventionType implements CallingConvention.Type { - /** - * A request for the outgoing argument locations at a call site to Java code. - */ - JavaCall(true), - - /** - * A request for the incoming argument locations. - */ - JavaCallee(false), - - /** - * A request for the outgoing argument locations at a call site to external native code that - * complies with the platform ABI. - */ - NativeCall(true); - - /** - * Determines if this is a request for the outgoing argument locations at a call site. - */ - public final boolean out; - - public static final Type[] VALUES = values(); - - HotSpotCallingConventionType(boolean out) { - this.out = out; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java deleted file mode 100644 index 271b27721d3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Map; -import java.util.Objects; - -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.site.Call; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.SpeculationLog; - -/** - * HotSpot implementation of {@link CodeCacheProvider}. - */ -public class HotSpotCodeCacheProvider implements CodeCacheProvider { - - protected final HotSpotJVMCIRuntime runtime; - private final HotSpotVMConfig config; - protected final TargetDescription target; - protected final RegisterConfig regConfig; - - public HotSpotCodeCacheProvider(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { - this.runtime = runtime; - this.config = runtime.getConfig(); - this.target = target; - this.regConfig = regConfig; - } - - @Override - public String getMarkName(Mark mark) { - int markId = (int) mark.id; - HotSpotVMConfigStore store = runtime.getConfigStore(); - for (Map.Entry e : store.getConstants().entrySet()) { - String name = e.getKey(); - if (name.startsWith("MARKID_") && e.getValue() == markId) { - return name; - } - } - return CodeCacheProvider.super.getMarkName(mark); - } - - /** - * Decodes a call target to a mnemonic if possible. - */ - @Override - public String getTargetName(Call call) { - if (call.target instanceof HotSpotForeignCallTarget) { - long address = ((HotSpotForeignCallTarget) call.target).address; - HotSpotVMConfigStore store = runtime.getConfigStore(); - for (Map.Entry e : store.getFields().entrySet()) { - VMField field = e.getValue(); - if (field.isStatic() && field.value != null && field.value instanceof Long && ((Long) field.value) == address) { - return e.getValue() + ":0x" + Long.toHexString(address); - } - } - } - return CodeCacheProvider.super.getTargetName(call); - } - - @Override - public RegisterConfig getRegisterConfig() { - return regConfig; - } - - @Override - public int getMinimumOutgoingSize() { - return config.runtimeCallStackSize; - } - - private InstalledCode logOrDump(InstalledCode installedCode, CompiledCode compiledCode) { - runtime.notifyInstall(this, installedCode, compiledCode); - return installedCode; - } - - @Override - public InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault, boolean profileDeopt) { - InstalledCode resultInstalledCode; - if (installedCode != null) { - throw new IllegalArgumentException("InstalledCode argument must be null"); - } - HotSpotCompiledCode hsCompiledCode = (HotSpotCompiledCode) compiledCode; - String name = hsCompiledCode.getName(); - HotSpotCompiledNmethod hsCompiledNmethod = null; - HotSpotSpeculationLog speculationLog = null; - if (log != null) { - if (log.hasSpeculations()) { - speculationLog = (HotSpotSpeculationLog) log; - } - } - byte[] speculations; - long failedSpeculationsAddress; - if (speculationLog != null) { - speculations = speculationLog.getFlattenedSpeculations(true); - failedSpeculationsAddress = speculationLog.getFailedSpeculationsAddress(); - } else { - speculations = new byte[0]; - failedSpeculationsAddress = 0L; - } - - if (method == null) { - // Must be a stub - resultInstalledCode = new HotSpotRuntimeStub(name); - } else { - hsCompiledNmethod = (HotSpotCompiledNmethod) hsCompiledCode; - HotSpotResolvedJavaMethodImpl hsMethod = (HotSpotResolvedJavaMethodImpl) method; - HotSpotNmethod nmethod = new HotSpotNmethod(hsMethod, name, isDefault, profileDeopt, hsCompiledNmethod.id); - nmethod.setSpeculationLog(speculationLog); - resultInstalledCode = nmethod; - } - - int result = runtime.getCompilerToVM().installCode(hsCompiledCode, resultInstalledCode, failedSpeculationsAddress, speculations); - if (result != config.codeInstallResultOk) { - String resultDesc = config.getCodeInstallResultDescription(result); - if (hsCompiledNmethod != null) { - String msg = hsCompiledNmethod.getInstallationFailureMessage(); - if (msg != null) { - msg = String.format("Code installation failed: %s%n%s", resultDesc, msg); - } else { - msg = String.format("Code installation failed: %s", resultDesc); - } - throw new BailoutException(result >= config.codeInstallResultFirstPermanentBailout, msg); - } else { - throw new BailoutException("Error installing %s: %s", ((HotSpotCompiledCode) compiledCode).getName(), resultDesc); - } - } - return logOrDump(resultInstalledCode, compiledCode); - } - - public void invalidateInstalledCode(InstalledCode installedCode, int invalidationReason) { - if (installedCode instanceof HotSpotNmethod) { - HotSpotNmethod nmethod = (HotSpotNmethod) installedCode; - nmethod.invalidate(true, invalidationReason); - } else { - throw new IllegalArgumentException("Cannot invalidate a " + Objects.requireNonNull(installedCode).getClass().getName()); - } - } - - @Override - public void invalidateInstalledCode(InstalledCode installedCode) { - invalidateInstalledCode(installedCode, jvmciInvalidationReason()); - } - - @Override - public TargetDescription getTarget() { - return target; - } - - public String disassemble(InstalledCode code) { - if (code.isValid()) { - return runtime.getCompilerToVM().disassembleCodeBlob(code); - } - return null; - } - - @Override - public SpeculationLog createSpeculationLog() { - return new HotSpotSpeculationLog(); - } - - @Override - public long getMaxCallTargetOffset(long address) { - return runtime.getCompilerToVM().getMaxCallTargetOffset(address); - } - - @Override - public boolean shouldDebugNonSafepoints() { - return runtime.getCompilerToVM().shouldDebugNonSafepoints(); - } - - public int interpreterFrameSize(BytecodeFrame pos) { - return runtime.getCompilerToVM().interpreterFrameSize(pos); - } - - /** - * Resets all compilation statistics. - */ - public void resetCompilationStatistics() { - runtime.getCompilerToVM().resetCompilationStatistics(); - } - - private static int jvmciInvalidationReason() { - return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java deleted file mode 100644 index cfc3d86056a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompilationRequest; - -/** - * A compilation request with extra HotSpot specific context such as a compilation identifier and - * the address of a {@code JVMCIEnv} object that provides native context for a compilation. - */ -public class HotSpotCompilationRequest extends CompilationRequest { - /** - * Address of the native {@code JVMCICompileState} associated with the request. - */ - private final long compileState; - - /** - * An identifier for the request. - */ - private final int id; - - /** - * Creates a request to compile a method starting at a given BCI and allocates an identifier to - * the request. - * - * @param method the method to be compiled - * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the - * method's entry point - * @param compileState address of a native {@code JVMCICompileState} object or 0L - */ - public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long compileState) { - this(method, entryBCI, compileState, method.allocateCompileId(entryBCI)); - } - - /** - * Creates a request to compile a method starting at a given BCI. - * - * @param method the method to be compiled - * @param entryBCI the bytecode index (BCI) at which to start compiling where -1 denotes the - * method's entry point - * @param compileState address of a native {@code JVMCICompileState} object or 0L - * @param id an identifier for the request - */ - public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long compileState, int id) { - super(method, entryBCI); - this.compileState = compileState; - this.id = id; - } - - @Override - public HotSpotResolvedJavaMethod getMethod() { - return (HotSpotResolvedJavaMethod) super.getMethod(); - } - - /** - * Gets the address of the native {@code JVMCICompileState} or 0L if no such object exists. This - * method should really be named {@code getCompileState} but must remain as is for API - * stability. - */ - public long getJvmciEnv() { - return compileState; - } - - /** - * Gets the VM allocated identifier for this compilation. - */ - public int getId() { - return id; - } - - @Override - public String toString() { - return id + ":" + super.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java deleted file mode 100644 index 644a4f7d6ce..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompilationRequestResult.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestResult; - -/** - * HotSpot specific information about the result of a {@link CompilationRequest}. - */ -public final class HotSpotCompilationRequestResult implements CompilationRequestResult { - - /** - * A user readable description of the failure. - * - * This field is read by the VM. - */ - private final String failureMessage; - - /** - * Whether this is a transient failure where retrying would help. - * - * This field is read by the VM. - */ - private final boolean retry; - - /** - * Number of bytecodes inlined into the compilation, exclusive of the bytecodes in the root - * method. - * - * This field is read by the VM. - */ - private final int inlinedBytecodes; - - private HotSpotCompilationRequestResult(String failureMessage, boolean retry, int inlinedBytecodes) { - this.failureMessage = failureMessage; - this.retry = retry; - this.inlinedBytecodes = inlinedBytecodes; - } - - @Override - public Object getFailure() { - return failureMessage; - } - - /** - * Creates a result representing a successful compilation. - * - * @param inlinedBytecodes number of bytecodes inlined into the compilation, exclusive of the - * bytecodes in the root method - */ - public static HotSpotCompilationRequestResult success(int inlinedBytecodes) { - return new HotSpotCompilationRequestResult(null, true, inlinedBytecodes); - } - - /** - * Creates a result representing a failed compilation. - * - * @param failureMessage a description of the failure - * @param retry whether this is a transient failure where retrying may succeed - */ - public static HotSpotCompilationRequestResult failure(String failureMessage, boolean retry) { - return new HotSpotCompilationRequestResult(failureMessage, retry, 0); - } - - public String getFailureMessage() { - return failureMessage; - } - - public boolean getRetry() { - return retry; - } - - public int getInlinedBytecodes() { - return inlinedBytecodes; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCode.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCode.java deleted file mode 100644 index dffd54e3117..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCode.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * A {@link CompiledCode} with additional HotSpot-specific information required for installing the - * code in HotSpot's code cache. - */ -public class HotSpotCompiledCode implements CompiledCode { - - /** - * The name of this compilation unit. - */ - protected final String name; - - /** - * The buffer containing the emitted machine code. - */ - protected final byte[] targetCode; - - /** - * The leading number of bytes in {@link #targetCode} containing the emitted machine code. - */ - protected final int targetCodeSize; - - /** - * A list of code annotations describing special sites in {@link #targetCode}. - */ - protected final Site[] sites; - - /** - * A list of {@link Assumption} this code relies on. - */ - protected final Assumption[] assumptions; - - /** - * The list of the methods whose bytecodes were used as input to the compilation. If - * {@code null}, then the compilation did not record method dependencies. Otherwise, the first - * element of this array is the root method of the compilation. - */ - protected final ResolvedJavaMethod[] methods; - - /** - * A list of comments that will be included in code dumps. - */ - protected final Comment[] comments; - - /** - * The data section containing serialized constants for the emitted machine code. - */ - protected final byte[] dataSection; - - /** - * The minimum alignment of the data section. - */ - protected final int dataSectionAlignment; - - /** - * A list of relocations in the {@link #dataSection}. - */ - protected final DataPatch[] dataSectionPatches; - - /** - * A flag determining whether this code is immutable and position independent. - */ - protected final boolean isImmutablePIC; - - /** - * The total size of the stack frame of this compiled method. - */ - protected final int totalFrameSize; - - /** - * The deopt rescue slot. Must be non-null if there is a safepoint in the method. - */ - protected final StackSlot deoptRescueSlot; - - public static class Comment { - - public final String text; - public final int pcOffset; - - public Comment(int pcOffset, String text) { - this.text = text; - this.pcOffset = pcOffset; - } - } - - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `sites`, `targetCode`, `comments`, `methods`, `dataSection`, `dataSectionPatches` and `assumptions`") - public HotSpotCompiledCode(String name, - byte[] targetCode, - int targetCodeSize, - Site[] sites, - Assumption[] assumptions, - ResolvedJavaMethod[] methods, - Comment[] comments, - byte[] dataSection, - int dataSectionAlignment, - DataPatch[] dataSectionPatches, - boolean isImmutablePIC, - int totalFrameSize, - StackSlot deoptRescueSlot) { - this.name = name; - this.targetCode = targetCode; - this.targetCodeSize = targetCodeSize; - this.sites = sites; - this.assumptions = assumptions; - this.methods = methods; - - this.comments = comments; - this.dataSection = dataSection; - this.dataSectionAlignment = dataSectionAlignment; - this.dataSectionPatches = dataSectionPatches; - this.isImmutablePIC = isImmutablePIC; - this.totalFrameSize = totalFrameSize; - this.deoptRescueSlot = deoptRescueSlot; - - assert validateFrames(); - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return name; - } - - /** - * Ensure that all the frames passed into the VM are properly formatted with an empty or illegal - * slot following double word slots. - */ - private boolean validateFrames() { - for (Site site : sites) { - if (site instanceof Infopoint) { - Infopoint info = (Infopoint) site; - if (info.debugInfo != null) { - BytecodeFrame frame = info.debugInfo.frame(); - assert frame == null || frame.validateFormat(); - if (info.debugInfo.getVirtualObjectMapping() != null) { - for (VirtualObject v : info.debugInfo.getVirtualObjectMapping()) { - verifyVirtualObject(v); - } - } - } - } - } - return true; - } - - public static void verifyVirtualObject(VirtualObject v) { - v.verifyLayout(new VirtualObject.LayoutVerifier() { - @Override - public int getOffset(ResolvedJavaField field) { - return field.getOffset(); - } - }); - } - - /** - * Returns a copy of the compiled machine code. - */ - public byte[] getTargetCode() { - return (targetCode == null) ? null : targetCode.clone(); - } - - /** - * Gets the size of the compiled machine code in bytes. - */ - public int getTargetCodeSize() { - return targetCodeSize; - } - - /** - * Returns a copy of the code annotations describing special sites in {@link #targetCode}. - */ - public Site[] getSites() { - return (sites == null) ? null : sites.clone(); - } - - /** - * Returns an array copy of the assumptions this code relies on. - */ - public Assumption[] getAssumptions() { - return (assumptions == null) ? null : assumptions.clone(); - } - - /** - * Returns an array copy of the methods whose bytecodes were used as input to the compilation. - */ - public ResolvedJavaMethod[] getMethods() { - return (methods == null) ? null : methods.clone(); - } - - /** - * Returns an array copy of the comments that are included in code dumps. - */ - public Comment[] getComments() { - return (comments == null) ? null : comments.clone(); - } - - /** - * Returns a copy of the data section containing serialized constants for the emitted machine code. - */ - public byte[] getDataSection() { - return (dataSection == null) ? null : dataSection.clone(); - } - - /** - * Gets the minimum alignment of the data section. - */ - public int getDataSectionAlignment() { - return dataSectionAlignment; - } - - /** - * Returns a copy of the {@link #dataSection} relocations. - */ - public DataPatch[] getDataSectionPatches() { - return (dataSectionPatches == null) ? null : dataSectionPatches.clone(); - } - - /** - * Checks if this compiled code is immutable and position independent. - */ - public boolean isImmutablePIC() { - return isImmutablePIC; - } - - /** - * Gets the total size of the stack frame of this compiled method. - */ - public int getTotalFrameSize() { - return totalFrameSize; - } - - /** - * Gets the deoptimization rescue slot associated with this compiled code. - */ - public StackSlot getDeoptRescueSlot() { - return deoptRescueSlot; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java deleted file mode 100644 index 565b38de96e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java +++ /dev/null @@ -1,1291 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.CALLSITE_TARGET_VALUE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.CONCRETE_METHOD; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.CONCRETE_SUBTYPE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.ILLEGAL; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.JOBJECT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.LEAF_TYPE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.NO_FINALIZABLE_SUBCLASS; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.NULL_CONSTANT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.OBJECT_ID; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.OBJECT_ID2; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_JOBJECT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_KLASS; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_METHOD; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_NARROW_JOBJECT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_NARROW_KLASS; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_NARROW_OBJECT_ID; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_NARROW_OBJECT_ID2; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_OBJECT_ID; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PATCH_OBJECT_ID2; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PRIMITIVE4; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PRIMITIVE8; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.PRIMITIVE_0; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.RAW_CONSTANT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_NARROW_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_PRIMITIVE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_VECTOR; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_CALL; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_DATA_PATCH; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_EXCEPTION_HANDLER; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_FOREIGN_CALL; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_FOREIGN_CALL_NO_DEBUG_INFO; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_IMPLICIT_EXCEPTION; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_IMPLICIT_EXCEPTION_DISPATCH; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_INFOPOINT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_MARK; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_SAFEPOINT; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_NARROW_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_PRIMITIVE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_VECTOR; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT4_NARROW_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT4_OOP; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT4_PRIMITIVE; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT4_VECTOR; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.VIRTUAL_OBJECT_ID; -import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.VIRTUAL_OBJECT_ID2; - -import java.io.PrintStream; -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; - -import jdk.internal.misc.Unsafe; -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.BytecodePosition; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.ReferenceMap; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterSaveLayout; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.code.StackLockValue; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.code.site.Call; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.site.ExceptionHandler; -import jdk.vm.ci.code.site.ImplicitExceptionDispatch; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.InfopointReason; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.code.site.Reference; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.Assumptions.CallSiteTargetValue; -import jdk.vm.ci.meta.Assumptions.ConcreteMethod; -import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; -import jdk.vm.ci.meta.Assumptions.LeafType; -import jdk.vm.ci.meta.Assumptions.NoFinalizableSubclass; -import jdk.vm.ci.meta.InvokeTarget; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.PrimitiveConstant; -import jdk.vm.ci.meta.RawConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.VMConstant; -import jdk.vm.ci.meta.Value; -import jdk.vm.ci.services.Services; - -/** - * Serializes {@link HotSpotCompiledCode} to a list linked native memory chunks. Each chunk has the - * following layout: - * - *
- *   | word |  4   |<------  size -------->|             |
- *   +------+------+-----------------------+-------------+
- *   | next | size |       used data       | unused data |
- *   +------+------+-----------------------+-------------+
- *
- *   |<----------- chunkSize --------------------------->|
- *   |<-- HEADER ->|
- * 
- * - * Each chunk is twice as large as its predecessor. See {@link #ensureCapacity(int)}. - * - * @see Option#DumpSerializedCode - * @see Option#CodeSerializationTypeInfo - */ -final class HotSpotCompiledCodeStream implements AutoCloseable { - - // 24K is sufficient for most compilations. - private static final int INITIAL_CHUNK_SIZE = 24 * 1024; - private static final int HEADER = Unsafe.ADDRESS_SIZE + 4; - - // @formatter:off - // HotSpotCompiledCode flags. - // Defined by HotSpotCompiledCodeFlags enum in jvmciCodeInstaller.hpp. - private static final int IS_NMETHOD = c("HCC_IS_NMETHOD"); - private static final int HAS_ASSUMPTIONS = c("HCC_HAS_ASSUMPTIONS"); - private static final int HAS_METHODS = c("HCC_HAS_METHODS"); - private static final int HAS_DEOPT_RESCUE_SLOT = c("HCC_HAS_DEOPT_RESCUE_SLOT"); - private static final int HAS_COMMENTS = c("HCC_HAS_COMMENTS"); - - // DebugInfo flags. - // Defined by DebugInfoFlags enum in jvmciCodeInstaller.hpp. - private static final int HAS_REFERENCE_MAP = c("DI_HAS_REFERENCE_MAP"); - private static final int HAS_CALLEE_SAVE_INFO = c("DI_HAS_CALLEE_SAVE_INFO"); - private static final int HAS_FRAMES = c("DI_HAS_FRAMES"); - - // BytecodeFrame flags - // Defined by DebugInfoFrameFlags enum in jvmciCodeInstaller.hpp. - private static final int HAS_LOCALS = c("DIF_HAS_LOCALS"); - private static final int HAS_STACK = c("DIF_HAS_STACK"); - private static final int HAS_LOCKS = c("DIF_HAS_LOCKS"); - private static final int DURING_CALL = c("DIF_DURING_CALL"); - private static final int RETHROW_EXCEPTION = c("DIF_RETHROW_EXCEPTION"); - // @formatter:on - - // Sentinel value in a DebugInfo stream denoting no register. - private static final int NO_REGISTER = c("NO_REGISTER"); - - enum Tag { - ILLEGAL, - REGISTER_PRIMITIVE, - REGISTER_OOP, - REGISTER_NARROW_OOP, - REGISTER_VECTOR, - STACK_SLOT_PRIMITIVE, - STACK_SLOT_OOP, - STACK_SLOT_NARROW_OOP, - STACK_SLOT_VECTOR, - STACK_SLOT4_PRIMITIVE, - STACK_SLOT4_OOP, - STACK_SLOT4_NARROW_OOP, - STACK_SLOT4_VECTOR, - VIRTUAL_OBJECT_ID, - VIRTUAL_OBJECT_ID2, - NULL_CONSTANT, - RAW_CONSTANT, - PRIMITIVE_0, - PRIMITIVE4, - PRIMITIVE8, - JOBJECT, - OBJECT_ID, - OBJECT_ID2, - - NO_FINALIZABLE_SUBCLASS, - CONCRETE_SUBTYPE, - LEAF_TYPE, - CONCRETE_METHOD, - CALLSITE_TARGET_VALUE, - - PATCH_OBJECT_ID, - PATCH_OBJECT_ID2, - PATCH_NARROW_OBJECT_ID, - PATCH_NARROW_OBJECT_ID2, - PATCH_JOBJECT, - PATCH_NARROW_JOBJECT, - PATCH_KLASS, - PATCH_NARROW_KLASS, - PATCH_METHOD, - PATCH_DATA_SECTION_REFERENCE, - - SITE_CALL, - SITE_FOREIGN_CALL, - SITE_FOREIGN_CALL_NO_DEBUG_INFO, - SITE_SAFEPOINT, - SITE_INFOPOINT, - SITE_IMPLICIT_EXCEPTION, - SITE_IMPLICIT_EXCEPTION_DISPATCH, - SITE_MARK, - SITE_DATA_PATCH, - SITE_EXCEPTION_HANDLER; - - Tag() { - int expect = ordinal(); - int actual = c(name()); - if (expect != actual) { - throw new JVMCIError("%s: expected %d, got %d", name(), expect, actual); - } - } - } - - private final Unsafe unsafe = UnsafeAccess.UNSAFE; - private final HotSpotJVMCIRuntime runtime; - - /** - * Specifies if the name and size of each data element is written to the buffer. - */ - private final boolean withTypeInfo; - - /** - * Lazily initialized string from {@link HotSpotCompiledCode#name} or - * {@link HotSpotCompiledNmethod#method}. - */ - private Object codeDesc; - - /** - * Constant pool for {@linkplain DirectHotSpotObjectConstantImpl direct} object references. - */ - - /** - * Alternative to using {@link IdentityHashMap} which would require dealing with the - * {@link IdentityHashMap#NULL_KEY} constant. - */ - static class IdentityBox { - Object obj; - - IdentityBox(Object obj) { - this.obj = obj; - } - - @Override - public boolean equals(Object other) { - IdentityBox that = (IdentityBox) other; - return that.obj == obj; - } - - @Override - public int hashCode() { - return System.identityHashCode(obj); - } - } - - private HashMap objects; - final Object[] objectPool; - - /** - * Head and current chunk. - */ - final long headChunk; - private long currentChunk; - - /** - * Size of current chunk. - */ - private int currentChunkSize; - - /** - * Index of current chunk. - */ - private int currentChunkIndex; - - /** - * Insertion position in current chunk. - */ - private int currentChunkOffset; - - /** - * Nanoseconds spent in {@link HotSpotCompiledCodeStream#HotSpotCompiledCodeStream}. - */ - long timeNS; - - private JVMCIError error(String format, Object... args) { - String prefix = String.format("%s[offset=%d]", codeDesc(), getTotalDataSize()); - throw new JVMCIError(prefix + ": " + format, args); - } - - /** - * Gets the size of payload data in the buffer. - */ - private int getTotalDataSize() { - int offset = currentChunkOffset - HEADER; - for (long chunk = headChunk; chunk != currentChunk; chunk = getChunkNext(chunk)) { - offset += getDataSize(chunk); - } - return offset; - } - - /** - * Reads the size of the payload in {@code chunk}. - */ - private int getDataSize(long chunk) { - int sizeOffset = Unsafe.ADDRESS_SIZE; - return unsafe.getInt(chunk + sizeOffset); - } - - /** - * Writes the size of the payload in {@code chunk}. - */ - private void setDataSize(long chunk, int size) { - int sizeOffset = Unsafe.ADDRESS_SIZE; - unsafe.putInt(chunk + sizeOffset, size); - } - - /** - * Reads the pointer in chunk pointing to the next chunk in the list. - */ - private long getChunkNext(long chunk) { - return unsafe.getAddress(chunk); - } - - /** - * Writes the pointer in chunk pointing to the next chunk in the list. - */ - private void setChunkNext(long chunk, long next) { - unsafe.putAddress(chunk, next); - } - - /** - * Ensures there is capacity for appending {@code toWrite} additional bytes. - */ - private void ensureCapacity(int toWrite) { - if (currentChunkOffset + toWrite > currentChunkSize) { - // Save current chunk data size - int dataSize = currentChunkOffset - HEADER; - setDataSize(currentChunk, dataSize); - - // Allocate new chunk and link it. Each chunk is - // at least as twice as large as its predecessor. - int nextChunkSize = currentChunkSize * 2; - if (nextChunkSize < toWrite + HEADER) { - nextChunkSize = toWrite + HEADER; - } - long nextChunk = unsafe.allocateMemory(nextChunkSize); - setChunkNext(currentChunk, nextChunk); - setChunkNext(nextChunk, 0); - - // Make new chunk current - currentChunk = nextChunk; - currentChunkSize = nextChunkSize; - currentChunkOffset = HEADER; - currentChunkIndex++; - } - } - - /** - * Emits type info for a write to the buffer and ensures there's sufficient capacity. - * - * @param name name of data element to be written - * @param sizeInBytes the size of the data element to be written - */ - private void beforeWrite(String name, int sizeInBytes) { - emitType(name, sizeInBytes); - ensureCapacity(sizeInBytes); - } - - /** - * Emits the name and size in bytes of a data element if type info is enabled. - * - * @param name - * @param sizeInBytes - */ - private void emitType(String name, int sizeInBytes) { - if (withTypeInfo) { - int len = name.length(); - if ((len & 0xFF) != len) { - // Length must be <= 0xFF - throw error("Data element label is too long (%d): %s", len, name); - } - if (sizeInBytes < 0 || sizeInBytes > 8) { - throw error("Data element size is not between 0 and 8 inclusive: %d", sizeInBytes); - } - int toWrite = 1 + 1 + len + 1; - ensureCapacity(toWrite); - - // sizeInBytes - unsafe.putByte(currentChunk + currentChunkOffset, (byte) sizeInBytes); - currentChunkOffset++; - - // length - unsafe.putByte(currentChunk + currentChunkOffset, (byte) len); - currentChunkOffset++; - - // body - for (int i = 0; i < len; i++) { - int c = name.charAt(i); - if (c >= 0x80 || c == 0) { - throw error("label contains non-ascii char at %d: %s", i, name); - } - unsafe.putByte(currentChunk + currentChunkOffset, (byte) c); - currentChunkOffset++; - } - } - } - - private static boolean isU1(int value) { - return (value & 0xFF) == value; - } - - private void writeU1(String name, int value) { - if (!isU1(value)) { - throw error("value not a u1: " + value); - } - byte b = (byte) value; - beforeWrite(name, 1); - unsafe.putByte(currentChunk + currentChunkOffset, b); - currentChunkOffset++; - } - - private void writeBoolean(String name, boolean value) { - writeU1(name, value ? 1 : 0); - } - - private void writeInt(String name, int value) { - beforeWrite(name, 4); - unsafe.putInt(currentChunk + currentChunkOffset, value); - currentChunkOffset += 4; - } - - private void rawWriteU2(String name, int value) { - beforeWrite(name, 2); - char ch = (char) value; - unsafe.putChar(currentChunk + currentChunkOffset, ch); - currentChunkOffset += 2; - } - - private void writeU2(String name, int value) { - if (value < Character.MIN_VALUE || value > Character.MAX_VALUE) { - throw error("value not a u2: " + value); - } - rawWriteU2(name, value); - } - - private static boolean isS2(int value) { - return value >= Short.MIN_VALUE && value <= Short.MAX_VALUE; - } - - private void writeS2(String name, int value) { - if (!isS2(value)) { - throw error("value not an s2: " + value); - } - rawWriteU2(name, value); - } - - private void writeLong(String name, long value) { - beforeWrite(name, 8); - unsafe.putLong(currentChunk + currentChunkOffset, value); - currentChunkOffset += 8; - } - - /** - * Writes the UTF8 bytes for {@code value} to the stream followed by a 0. - */ - private void writeUTF8(String name, String value) { - if (value == null) { - writeInt(name, -1); - return; - } - - byte[] utf = value.getBytes(StandardCharsets.UTF_8); - - emitType(name, 4); - - int toWrite = 4 + utf.length + 1; - ensureCapacity(toWrite); - - // length - unsafe.putInt(currentChunk + currentChunkOffset, utf.length); - currentChunkOffset += 4; - - // body - for (int i = 0; i < utf.length; i++) { - byte b = utf[i]; - unsafe.putByte(currentChunk + currentChunkOffset, b); - currentChunkOffset++; - } - - // trailing 0 - unsafe.putByte(currentChunk + currentChunkOffset, (byte) 0); - currentChunkOffset++; - } - - private String codeDesc() { - if (codeDesc instanceof ResolvedJavaMethod) { - codeDesc = ((ResolvedJavaMethod) codeDesc).format("%H.%n(%p)"); - } else if (codeDesc == null) { - codeDesc = ""; - } - return codeDesc.toString(); - } - - /** - * Serializes {@code}. - * - * @param code the object to serialize - * @param withTypeInfo see {@link Option#CodeSerializationTypeInfo} - * @param withComments include {@link HotSpotCompiledCode#comments} in the stream - * @param withMethods include {@link HotSpotCompiledCode#methods} in the stream - */ - HotSpotCompiledCodeStream(HotSpotCompiledCode code, boolean withTypeInfo, boolean withComments, boolean withMethods) { - long start = System.nanoTime(); - this.currentChunkSize = INITIAL_CHUNK_SIZE; - this.headChunk = unsafe.allocateMemory(currentChunkSize); - this.currentChunk = headChunk; - this.currentChunkOffset = HEADER; - setChunkNext(currentChunk, 0); - setDataSize(currentChunk, 0); - - this.runtime = HotSpotJVMCIRuntime.runtime(); - this.withTypeInfo = withTypeInfo; - - ResolvedJavaMethod[] methods = withMethods ? code.methods : null; - Assumption[] assumptions = code.assumptions; - StackSlot deoptRescueSlot = code.deoptRescueSlot; - Comment[] comments = withComments ? code.comments : null; - - String name = code.name; - codeDesc = name; - HotSpotCompiledNmethod nmethod; - if (code instanceof HotSpotCompiledNmethod) { - nmethod = (HotSpotCompiledNmethod) code; - if (codeDesc == null) { - codeDesc = nmethod.method; - } - } else { - nmethod = null; - } - - // @formatter:off - int flags = setIf(IS_NMETHOD, nmethod != null) | - setIf(HAS_METHODS, nmethod != null && methods != null && methods.length != 0 ) | - setIf(HAS_ASSUMPTIONS, assumptions) | - setIf(HAS_DEOPT_RESCUE_SLOT, deoptRescueSlot != null) | - setIf(HAS_COMMENTS, comments); - // @formatter:on - - writeU1("code:flags", flags); - writeUTF8("name", name); - if (nmethod != null) { - writeMethod("method", nmethod.method); - writeInt("entryBCI", nmethod.entryBCI); - writeLong("compileState", nmethod.compileState); - writeBoolean("hasUnsafeAccess", nmethod.hasUnsafeAccess); - writeBoolean("hasScopedAccess", nmethod.hasScopedAccess()); - writeInt("id", nmethod.id); - } - - if (isSet(flags, HAS_ASSUMPTIONS)) { - writeAssumptions(assumptions); - } - if (isSet(flags, HAS_METHODS)) { - writeU2("methods:length", methods.length); - for (ResolvedJavaMethod method : methods) { - writeMethod("method", method); - } - } - - writeInt("sites:length", code.sites.length); - writeInt("targetCodeSize", code.targetCodeSize); - writeInt("totalFrameSize", code.totalFrameSize); - if (isSet(flags, HAS_DEOPT_RESCUE_SLOT)) { - int offset = deoptRescueSlot.getRawOffset(); - writeInt("offset", offset); - writeBoolean("addRawFrameSize", deoptRescueSlot.getRawAddFrameSize()); - } - writeInt("dataSectionSize", code.dataSection.length); - writeU1("dataSectionAlignment", code.dataSectionAlignment); - - writeStubCounts(code); - writeDataSectionPatches(code.dataSectionPatches); - writeSites(code); - - if (isSet(flags, HAS_COMMENTS)) { - writeU2("comments:length", comments.length); - for (Comment c : comments) { - writeInt("comment:pcOffset", c.pcOffset); - writeUTF8("comment:text", c.text); - } - } - - // Finalize current (and last) chunk - int dataSize = currentChunkOffset - HEADER; - setDataSize(currentChunk, dataSize); - - objectPool = !Services.IS_IN_NATIVE_IMAGE ? finalizeObjectPool() : null; - - maybeDump(name, nmethod); - - this.timeNS = System.nanoTime() - start; - } - - /** - * Creates the pool for {@link DirectHotSpotObjectConstantImpl} values written to the stream. - */ - private Object[] finalizeObjectPool() throws JVMCIError { - if (objects != null) { - Object[] pool = new Object[objects.size()]; - for (Map.Entry e : objects.entrySet()) { - int id = e.getValue(); - Object object = e.getKey().obj; - if (object == null) { - throw error("unexpected null in object pool at %d - map is %s", id, objects); - } - pool[id] = object; - } - return pool; - } else { - return null; - } - } - - /** - * Determines if {@code name} or {@code method} are matched by - * {@link Option#DumpSerializedCode}. - * - * @return the matched value or null if no match was made - */ - private static String shouldDump(String name, HotSpotCompiledNmethod nmethod) { - String filter = Option.DumpSerializedCode.getString(); - if (filter == null) { - return null; - } - if (name != null && name.contains(filter)) { - return name; - } - if (nmethod != null) { - String fqn = nmethod.method.format("%H.%n(%p)"); - if (fqn.contains(filter)) { - return fqn; - } - } - return null; - } - - /** - * Dumps the buffer to TTY if {@code name} or {@code method} are matched by - * {@link Option#DumpSerializedCode}. - */ - private void maybeDump(String name, HotSpotCompiledNmethod nmethod) { - String dumpName = shouldDump(name, nmethod); - if (dumpName != null) { - dump(dumpName); - } - } - - private void dump(String dumpName) { - int dataSize; - PrintStream out = new PrintStream(runtime.getLogStream()); - out.printf("Dumping serialized HotSpotCompiledMethod data for %s (head: 0x%016x, chunks: %d, total data size:%d):%n", - dumpName, headChunk, currentChunkIndex + 1, getTotalDataSize()); - int chunkIndex = 0; - for (long c = headChunk; c != 0; c = getChunkNext(c)) { - long data0 = c + HEADER; - dataSize = getDataSize(c); - byte[] data = new byte[dataSize]; - unsafe.copyMemory(null, data0, data, Unsafe.ARRAY_BYTE_BASE_OFFSET, dataSize); - out.printf("[CHUNK %d: address=0x%016x, data=0x%016x:0x%016x, data size=%d]%n", - chunkIndex, c, data0, data0 + dataSize, dataSize); - hexdump(out, data0, data); - chunkIndex++; - } - } - - private static void hexdump(PrintStream out, long address, byte[] data) { - int col = 0; - for (int pos = 0; pos < data.length; pos++) { - if (col % 16 == 0) { - out.printf("0x%016x:", address + pos); - } - if (col % 2 == 0) { - out.print(' '); - } - if (pos < data.length) { - byte b = data[pos]; - char ch = (char) ((char) b & 0xff); - out.printf("%02X", (int) ch); - } else { - out.print(" "); - } - if ((col + 1) % 16 == 0) { - out.print(" "); - for (int j = pos - 15; j <= pos; ++j) { - byte b = data[j]; - char ch = (char) ((char) b & 0xff); - out.print(ch >= 32 && ch <= 126 ? ch : '.'); - } - out.println(); - } - col++; - } - out.println(); - } - - @Override - public void close() { - for (long c = headChunk; c != 0;) { - long next = getChunkNext(c); - unsafe.freeMemory(c); - c = next; - } - } - - private void writeSites(HotSpotCompiledCode code) { - Site[] sites = code.sites; - for (Site site : sites) { - writeInt("site:pcOffset", site.pcOffset); - if (site instanceof Call) { - Call call = (Call) site; - DebugInfo debugInfo = call.debugInfo; - InvokeTarget target = call.target; - if (target instanceof HotSpotForeignCallTarget) { - HotSpotForeignCallTarget foreignCall = (HotSpotForeignCallTarget) target; - writeTag(debugInfo == null ? SITE_FOREIGN_CALL_NO_DEBUG_INFO : SITE_FOREIGN_CALL); - writeLong("target", foreignCall.address); - if (debugInfo != null) { - writeDebugInfo(debugInfo, true); - } - } else { - if (debugInfo == null) { - throw error("debug info expected at call %s", call); - } - writeTag(SITE_CALL); - ResolvedJavaMethod method = (ResolvedJavaMethod) target; - writeMethod("target", method); - writeBoolean("direct", call.direct); - writeDebugInfo(debugInfo, true); - } - } else if (site instanceof Infopoint) { - Infopoint info = (Infopoint) site; - InfopointReason reason = info.reason; - DebugInfo debugInfo = info.debugInfo; - if (debugInfo == null) { - throw error("debug info expected at infopoint %s", info); - } - Tag tag; - switch (reason) { - case SAFEPOINT: - tag = SITE_SAFEPOINT; - break; - case IMPLICIT_EXCEPTION: - tag = info instanceof ImplicitExceptionDispatch ? SITE_IMPLICIT_EXCEPTION_DISPATCH : SITE_IMPLICIT_EXCEPTION; - break; - case CALL: - throw error("only %s objects expected to have CALL reason: %s", Call.class.getName(), info); - default: - tag = SITE_INFOPOINT; - break; - } - writeTag(tag); - boolean fullInfo = reason == InfopointReason.SAFEPOINT || reason == InfopointReason.IMPLICIT_EXCEPTION; - writeDebugInfo(debugInfo, fullInfo); - if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) { - int dispatchOffset = ((ImplicitExceptionDispatch) info).dispatchOffset; - writeInt("dispatchOffset", dispatchOffset); - } - - } else if (site instanceof DataPatch) { - writeTag(SITE_DATA_PATCH); - DataPatch patch = (DataPatch) site; - writeDataPatch(patch, code); - } else if (site instanceof Mark) { - Mark mark = (Mark) site; - writeTag(SITE_MARK); - writeU1("mark:id", (int) mark.id); - } else if (site instanceof ExceptionHandler) { - ExceptionHandler handler = (ExceptionHandler) site; - writeTag(SITE_EXCEPTION_HANDLER); - writeInt("site:handlerPos", handler.handlerPos); - } - } - } - - private void writeDataSectionPatches(DataPatch[] dataSectionPatches) { - writeU2("dataSectionPatches:length", dataSectionPatches.length); - for (DataPatch dp : dataSectionPatches) { - Reference ref = dp.reference; - if (!(ref instanceof ConstantReference)) { - throw error("invalid patch in data section: %s", dp); - } - writeInt("patch:pcOffset", dp.pcOffset); - ConstantReference cref = (ConstantReference) ref; - VMConstant con = cref.getConstant(); - if (con instanceof HotSpotMetaspaceConstantImpl) { - writeMetaspaceConstantPatch((HotSpotMetaspaceConstantImpl) con); - } else { - if (!(con instanceof HotSpotObjectConstantImpl)) { - throw error("invalid constant in data section: %s", con); - } - writeOopConstantPatch((HotSpotObjectConstantImpl) con); - } - } - } - - private void writeDataPatch(DataPatch patch, HotSpotCompiledCode code) { - Reference ref = patch.reference; - if (ref instanceof ConstantReference) { - ConstantReference cref = (ConstantReference) ref; - VMConstant con = cref.getConstant(); - if (con instanceof HotSpotObjectConstantImpl) { - writeOopConstantPatch((HotSpotObjectConstantImpl) con); - } else if (con instanceof HotSpotMetaspaceConstantImpl) { - writeMetaspaceConstantPatch((HotSpotMetaspaceConstantImpl) con); - } else { - throw error("unexpected constant patch: %s", con); - } - } else if (ref instanceof DataSectionReference) { - DataSectionReference dsref = (DataSectionReference) ref; - int dataOffset = dsref.getOffset(); - if (dataOffset < 0 || dataOffset >= code.dataSection.length) { - throw error("data offset 0x%X points outside data section (size 0x%X)", dataOffset, code.dataSection.length); - } - writeTag(Tag.PATCH_DATA_SECTION_REFERENCE); - writeInt("data:offset", dataOffset); - } else { - throw error("unexpected data reference patch: %s", ref); - } - } - - private void writeOopConstantPatch(HotSpotObjectConstantImpl con) { - if (con instanceof DirectHotSpotObjectConstantImpl) { - if (Services.IS_IN_NATIVE_IMAGE) { - throw error("Direct object constant reached the backend: %s", con); - } - DirectHotSpotObjectConstantImpl obj = (DirectHotSpotObjectConstantImpl) con; - if (!obj.isCompressed()) { - writeObjectID(obj, PATCH_OBJECT_ID, PATCH_OBJECT_ID2); - } else { - writeObjectID(obj, PATCH_NARROW_OBJECT_ID, PATCH_NARROW_OBJECT_ID2); - } - } else { - IndirectHotSpotObjectConstantImpl obj = (IndirectHotSpotObjectConstantImpl) con; - if (!obj.isCompressed()) { - writeTag(PATCH_JOBJECT); - } else { - writeTag(PATCH_NARROW_JOBJECT); - } - writeLong("jobject", obj.getHandle()); - } - } - - private void writeMetaspaceConstantPatch(HotSpotMetaspaceConstantImpl metaspaceCon) throws JVMCIError { - if (metaspaceCon.isCompressed()) { - writeTag(PATCH_NARROW_KLASS); - HotSpotResolvedObjectType type = metaspaceCon.asResolvedJavaType(); - if (type == null) { - throw error("unexpected compressed pointer: %s", metaspaceCon); - } - writeObjectType("patch:klass", type); - } else { - HotSpotResolvedObjectType type = metaspaceCon.asResolvedJavaType(); - HotSpotResolvedJavaMethod method = metaspaceCon.asResolvedJavaMethod(); - if (type != null) { - writeTag(PATCH_KLASS); - writeObjectType("patch:klass", type); - } else { - if (method == null) { - throw error("unexpected metadata reference: %s", metaspaceCon); - } - writeTag(PATCH_METHOD); - writeMethod("patch:method", method); - } - } - } - - private static final int MARK_INVOKEINTERFACE = c("INVOKEINTERFACE"); - private static final int MARK_INVOKEVIRTUAL = c("INVOKEVIRTUAL"); - private static final int MARK_INVOKESTATIC = c("INVOKESTATIC"); - private static final int MARK_INVOKESPECIAL = c("INVOKESPECIAL"); - - private static int c(String name) { - return HotSpotJVMCIRuntime.runtime().config.getConstant("CodeInstaller::" + name, Integer.class); - } - - private void writeStubCounts(HotSpotCompiledCode code) { - int numStaticCallStubs = 0; - int numTrampolineStubs = 0; - for (Site site : code.sites) { - if (site instanceof Mark) { - Mark mark = (Mark) site; - if (!(mark.id instanceof Integer)) { - error("Mark id must be Integer, not %s", mark.id.getClass().getName()); - } - int id = (Integer) mark.id; - if (id == MARK_INVOKEINTERFACE || id == MARK_INVOKEVIRTUAL) { - numTrampolineStubs++; - } else if (id == MARK_INVOKESTATIC || id == MARK_INVOKESPECIAL) { - numStaticCallStubs++; - numTrampolineStubs++; - } - } - } - writeU2("numStaticCallStubs", numStaticCallStubs); - writeU2("numTrampolineStubs", numTrampolineStubs); - } - - private void writeAssumptions(Assumption[] assumptions) { - writeU2("assumptions:length", assumptions.length); - for (Assumption a : assumptions) { - if (a instanceof NoFinalizableSubclass) { - writeTag(NO_FINALIZABLE_SUBCLASS); - writeObjectType("receiverType", ((NoFinalizableSubclass) a).receiverType); - } else if (a instanceof ConcreteSubtype) { - writeTag(CONCRETE_SUBTYPE); - ConcreteSubtype cs = (ConcreteSubtype) a; - writeObjectType("context", cs.context); - writeObjectType("subtype", cs.subtype); - } else if (a instanceof LeafType) { - writeTag(LEAF_TYPE); - writeObjectType("context", ((LeafType) a).context); - } else if (a instanceof ConcreteMethod) { - writeTag(CONCRETE_METHOD); - ConcreteMethod cm = (ConcreteMethod) a; - writeObjectType("context", cm.context); - writeMethod("impl", cm.impl); - } else if (a instanceof CallSiteTargetValue) { - writeTag(CALLSITE_TARGET_VALUE); - CallSiteTargetValue cs = (CallSiteTargetValue) a; - writeJavaValue(cs.callSite, JavaKind.Object); - writeJavaValue(cs.methodHandle, JavaKind.Object); - } else { - throw error("unexpected assumption %s", a); - } - } - } - - private void writeDebugInfo(DebugInfo debugInfo, boolean fullInfo) { - ReferenceMap referenceMap = debugInfo.getReferenceMap(); - RegisterSaveLayout calleeSaveInfo = debugInfo.getCalleeSaveInfo(); - BytecodePosition bytecodePosition = debugInfo.getBytecodePosition(); - - int flags = 0; - if (bytecodePosition != null) { - flags |= HAS_FRAMES; - } - if (fullInfo) { - if (referenceMap == null) { - throw error("reference map is null"); - } - flags |= HAS_REFERENCE_MAP; - if (calleeSaveInfo != null) { - flags |= HAS_CALLEE_SAVE_INFO; - } - } - writeU1("debugInfo:flags", flags); - - if (fullInfo) { - writeReferenceMap(referenceMap); - if (calleeSaveInfo != null) { - writeCalleeSaveInfo(calleeSaveInfo); - } - writeVirtualObjects(debugInfo.getVirtualObjectMapping()); - } - if (bytecodePosition != null) { - writeFrame(bytecodePosition, fullInfo, 0); - } - } - - private void writeVirtualObjects(VirtualObject[] virtualObjects) { - int length = virtualObjects != null ? virtualObjects.length : 0; - writeU2("virtualObjects:length", length); - for (int i = 0; i < length; i++) { - VirtualObject vo = virtualObjects[i]; - writeObjectType("type", vo.getType()); - writeBoolean("isAutoBox", vo.isAutoBox()); - } - for (int i = 0; i < length; i++) { - VirtualObject vo = virtualObjects[i]; - int id = vo.getId(); - if (id != i) { - throw error("duplicate virtual object id %d", id); - } - JavaValue[] values = vo.getValues(); - int valuesLength = values != null ? values.length : 0; - writeU2("values:length", valuesLength); - if (valuesLength != 0) { - for (int j = 0; j < values.length; j++) { - writeBasicType(vo.getSlotKind(j)); - JavaValue jv = values[j]; - writeJavaValue(jv, vo.getSlotKind(j)); - } - } - } - } - - private void writeCalleeSaveInfo(RegisterSaveLayout calleeSaveInfo) { - Map map = calleeSaveInfo.registersToSlots(false); - writeU2("calleeSaveInfo:length", map.size()); - for (Map.Entry e : map.entrySet()) { - writeRegister(e.getKey()); - writeU2("slot", e.getValue()); - } - } - - private void writeTag(Tag tag) { - writeU1("tag", (byte) tag.ordinal()); - } - - private void writeBasicType(JavaKind kind) { - writeU1("basicType", (byte) kind.getBasicType()); - } - - private void writeObjectType(String name, ResolvedJavaType type) { - HotSpotResolvedObjectTypeImpl objType = (HotSpotResolvedObjectTypeImpl) type; - writeLong(name, objType.getKlassPointer()); - } - - private void writeMethod(String name, ResolvedJavaMethod method) { - HotSpotResolvedJavaMethodImpl impl = (HotSpotResolvedJavaMethodImpl) method; - writeLong(name, impl.getMethodPointer()); - } - - private boolean isNarrowOop(Value oopValue) { - return oopValue.getPlatformKind() != runtime.getHostJVMCIBackend().getTarget().arch.getWordKind(); - } - - private boolean isVector(Value value) { - return value.getPlatformKind().getVectorLength() > 1; - } - - private void writeJavaValue(JavaValue value, JavaKind kind) { - if (value == Value.ILLEGAL) { - writeTag(ILLEGAL); - } else if (value == JavaConstant.NULL_POINTER || value instanceof HotSpotCompressedNullConstant) { - if (JavaKind.Object != kind) { - throw error("object constant (%s) kind expected to be Object, got %s", value, kind); - } - writeTag(NULL_CONSTANT); - } else if (value instanceof RegisterValue) { - RegisterValue reg = (RegisterValue) value; - Tag tag; - if (kind == JavaKind.Object) { - if (isVector(reg)) { - tag = REGISTER_VECTOR; - } else { - tag = isNarrowOop(reg) ? REGISTER_NARROW_OOP : REGISTER_OOP; - } - } else { - tag = REGISTER_PRIMITIVE; - } - writeTag(tag); - writeRegister(reg.getRegister()); - } else if (value instanceof StackSlot) { - StackSlot slot = (StackSlot) value; - Tag tag; - int offset = slot.getRawOffset(); - boolean s2 = isS2(offset); - if (kind == JavaKind.Object) { - if (isVector(slot)) { - tag = s2 ? STACK_SLOT_VECTOR : STACK_SLOT4_VECTOR; - } else if (isNarrowOop(slot)) { - tag = s2 ? STACK_SLOT_NARROW_OOP : STACK_SLOT4_NARROW_OOP; - } else { - tag = s2 ? STACK_SLOT_OOP : STACK_SLOT4_OOP; - } - } else { - tag = s2 ? STACK_SLOT_PRIMITIVE : STACK_SLOT4_PRIMITIVE; - } - writeTag(tag); - if (s2) { - writeS2("offset", slot.getRawOffset()); - } else { - writeInt("offset4", slot.getRawOffset()); - } - writeBoolean("addRawFrameSize", slot.getRawAddFrameSize()); - } else if (value instanceof VirtualObject) { - VirtualObject vo = (VirtualObject) value; - if (kind != JavaKind.Object) { - throw error("virtual object kind must be Object, not %s", kind); - } - int id = vo.getId(); - if (isU1(id)) { - writeTag(VIRTUAL_OBJECT_ID); - writeU1("id", id); - } else { - writeTag(VIRTUAL_OBJECT_ID2); - writeU2("id:2", id); - } - } else if (value instanceof RawConstant) { - RawConstant prim = (RawConstant) value; - writeTag(RAW_CONSTANT); - writeLong("primitive", prim.getRawValue()); - } else if (value instanceof PrimitiveConstant) { - PrimitiveConstant prim = (PrimitiveConstant) value; - if (prim.getJavaKind() != kind) { - throw error("primitive constant (%s) kind expected to be %s, got %s", prim, kind, prim.getJavaKind()); - } - long raw = prim.getRawValue(); - if (raw == 0) { - writeTag(PRIMITIVE_0); - } else if (raw >= Integer.MIN_VALUE && raw <= Integer.MAX_VALUE) { - writeTag(PRIMITIVE4); - int rawInt = (int) raw; - writeInt("primitive4", rawInt); - } else { - writeTag(PRIMITIVE8); - writeLong("primitive8", raw); - } - } else if (value instanceof IndirectHotSpotObjectConstantImpl) { - if (JavaKind.Object != kind) { - throw error("object constant (%s) kind expected to be Object, got %s", value, kind); - } - IndirectHotSpotObjectConstantImpl obj = (IndirectHotSpotObjectConstantImpl) value; - writeTag(JOBJECT); - writeLong("jobject", obj.getHandle()); - } else if (value instanceof DirectHotSpotObjectConstantImpl) { - if (JavaKind.Object != kind) { - throw error("object constant (%s) kind expected to be Object, got %s", value, kind); - } - writeObjectID((DirectHotSpotObjectConstantImpl) value, OBJECT_ID, OBJECT_ID2); - } else { - throw error("unsupported type: " + value.getClass()); - } - } - - private int writeObjectID(DirectHotSpotObjectConstantImpl value, Tag u1Tag, Tag u2Tag) { - if (Services.IS_IN_NATIVE_IMAGE) { - throw error("SVM object value cannot be installed in HotSpot code cache: %s", value); - } - Object obj = value.object; - if (obj == null) { - throw error("direct object should not be null"); - } - IdentityBox key = new IdentityBox(obj); - if (objects == null) { - objects = new HashMap<>(8); - } - Integer idBox = objects.get(key); - if (idBox == null) { - idBox = objects.size(); - objects.put(key, idBox); - } - int id = idBox; - if (isU1(id)) { - writeTag(u1Tag); - writeU1("id", id); - } else { - writeTag(u2Tag); - writeU2("id:2", id); - } - return id; - } - - /** - * Returns {@code flag} if {@code condition == true} else {@code 0}. - */ - private static int setIf(int flag, Object[] array) { - return array != null && array.length > 0 ? flag : 0; - } - - /** - * Returns {@code flag} if {@code condition == true} else {@code 0}. - */ - private static int setIf(int flag, boolean condition) { - return condition ? flag : 0; - } - - /** - * Returns {@code flag} if {@code condition != 0} else {@code 0}. - */ - private static int setIf(int flag, int condition) { - return condition != 0 ? flag : 0; - } - - private static boolean isSet(int flags, int bit) { - return (flags & bit) != 0; - } - - private void writeFrame(BytecodePosition pos, boolean fullInfo, int depth) { - if (pos == null) { - writeU2("depth", depth); - return; - } - writeFrame(pos.getCaller(), fullInfo, depth + 1); - writeMethod("method", pos.getMethod()); - writeInt("bci", pos.getBCI()); - if (fullInfo) { - BytecodeFrame f = (BytecodeFrame) pos; - f.verifyInvariants(); - int numLocals = f.numLocals; - int numStack = f.numStack; - int numLocks = f.numLocks; - - // @formatter:off - int flags = setIf(HAS_LOCALS, numLocals) | - setIf(HAS_STACK, numStack) | - setIf(HAS_LOCKS, numLocks) | - setIf(DURING_CALL, f.duringCall) | - setIf(RETHROW_EXCEPTION, f.rethrowException); - // @formatter:on - writeU1("flags", flags); - - if (numLocals != 0) { - writeU2("numLocals", numLocals); - for (int i = 0; i < numLocals; i++) { - JavaKind kind = f.getLocalValueKind(i); - writeBasicType(kind); - writeJavaValue(f.getLocalValue(i), kind); - } - } - if (numStack != 0) { - writeU2("numStack", numStack); - for (int i = 0; i < numStack; i++) { - JavaKind kind = f.getStackValueKind(i); - writeBasicType(kind); - writeJavaValue(f.getStackValue(i), kind); - } - } - if (numLocks != 0) { - writeU2("numLocks", numLocks); - for (int i = 0; i < numLocks; i++) { - StackLockValue lock = (StackLockValue) f.getLockValue(i); - writeBoolean("isEliminated", lock.isEliminated()); - writeJavaValue(lock.getOwner(), JavaKind.Object); - writeJavaValue(lock.getSlot(), JavaKind.Object); - } - } - } - } - - private void writeReferenceMap(ReferenceMap map) { - HotSpotReferenceMap hsMap = (HotSpotReferenceMap) map; - int length = hsMap.objects.length; - writeU2("maxRegisterSize", hsMap.maxRegisterSize); - int derivedBaseLength = hsMap.derivedBase.length; - int sizeInBytesLength = hsMap.sizeInBytes.length; - if (derivedBaseLength != length || sizeInBytesLength != length) { - throw error("arrays in reference map have different sizes: %d %d %d", length, derivedBaseLength, sizeInBytesLength); - } - writeU2("referenceMap:length", length); - for (int i = 0; i < length; i++) { - Location derived = hsMap.derivedBase[i]; - writeBoolean("hasDerived", derived != null); - int size = hsMap.sizeInBytes[i]; - if (size % 4 != 0) { - throw error("invalid oop size in ReferenceMap: %d", size); - } - writeU2("sizeInBytes", size); - writeLocation(hsMap.objects[i]); - if (derived != null) { - writeLocation(derived); - } - } - } - - private void writeLocation(Location loc) { - writeRegister(loc.reg); - writeU2("offset", loc.offset); - } - - private void writeRegister(Register reg) { - if (reg == null) { - writeU2("register", NO_REGISTER); - } else { - writeU2("register", reg.number); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java deleted file mode 100644 index f532617a09e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledNmethod.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * {@link HotSpotCompiledCode} destined for installation as an nmethod. - */ -public final class HotSpotCompiledNmethod extends HotSpotCompiledCode { - - protected final HotSpotResolvedJavaMethod method; - protected final int entryBCI; - - /** - * Compilation identifier. - */ - protected final int id; - - /** - * Address of a native {@code JVMCICompileState} object or 0L if no such object exists. - */ - protected final long compileState; - - protected final boolean hasUnsafeAccess; - - /** - * May be set by VM if code installation fails. It will describe in more detail why installation - * failed (e.g., exactly which dependency failed). - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "set by the VM") private String installationFailureMessage; - - public HotSpotCompiledNmethod(String name, - byte[] targetCode, - int targetCodeSize, - Site[] sites, - Assumption[] assumptions, - ResolvedJavaMethod[] methods, - Comment[] comments, - byte[] dataSection, - int dataSectionAlignment, - DataPatch[] dataSectionPatches, - boolean isImmutablePIC, - int totalFrameSize, - StackSlot deoptRescueSlot, - HotSpotResolvedJavaMethod method, - int entryBCI, - int id, - long compileState, - boolean hasUnsafeAccess) { - super(name, - targetCode, - targetCodeSize, - sites, - assumptions, - methods, - comments, - dataSection, - dataSectionAlignment, - dataSectionPatches, - isImmutablePIC, - totalFrameSize, - deoptRescueSlot); - this.method = method; - this.entryBCI = entryBCI; - this.id = id; - this.compileState = compileState; - this.hasUnsafeAccess = hasUnsafeAccess; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + id + ":" + method.format("%H.%n(%p)%r@") + entryBCI + "]"; - } - - public String getInstallationFailureMessage() { - return installationFailureMessage; - } - - /** - * Determines if {@code methods} contains at least one entry for which {@code HotSpotResolvedJavaMethod.isScoped()} returns true. - */ - public boolean hasScopedAccess() { - if (methods == null) { - return false; - } - for (ResolvedJavaMethod method : methods) { - if (method instanceof HotSpotResolvedJavaMethod hotSpotMethod) { - if (hotSpotMethod.isScoped()) { - return true; - } - } - } - return false; - } - - /** - * Returns the method to which this compiled nmethod belongs. - */ - public HotSpotResolvedJavaMethod getMethod() { - return method; - } - - /** - * Returns the bytecode index (BCI) in the {@link #getMethod() method} that is the beginning of this compiled - * nmethod. -1 denotes the beginning of the method. - * - * @return the entry BCI of this nmethod or -1 if the entry is the method's beginning - */ - public int getEntryBCI() { - return entryBCI; - } - - /** - * Returns the identifier of the compilation request. - */ - public int getId() { - return id; - } - - /** - * Returns the address of a native {@code JVMCICompileState} object associated with this compiled nmethod. - * If no such object exists, it returns 0L. - * - * @return the address of the native {@code JVMCICompileState} object or 0L if it does not exist - */ - public long getCompileState() { - return compileState; - } - - /** - * Checks if this compiled nmethod has a memory access via the {@code Unsafe} class. - */ - public boolean hasUnsafeAccess() { - return hasUnsafeAccess; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java deleted file mode 100644 index 370eaee7b3f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; - -/** - * The compressed representation of the {@link JavaConstant#NULL_POINTER null constant}. - */ -public final class HotSpotCompressedNullConstant implements JavaConstant, HotSpotConstant { - - public static final JavaConstant COMPRESSED_NULL = new HotSpotCompressedNullConstant(); - - private HotSpotCompressedNullConstant() { - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public boolean isNull() { - return true; - } - - @Override - public boolean isCompressed() { - return true; - } - - @Override - public boolean isCompressible() { - return false; - } - - @Override - public Constant compress() { - throw new IllegalArgumentException("not compressible"); - } - - @Override - public Constant uncompress() { - return NULL_POINTER; - } - - @Override - public boolean isDefaultForKind() { - return true; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public String toString() { - return JavaConstant.toString(this); - } - - @Override - public String toValueString() { - return "null"; - } - - @Override - public int hashCode() { - return System.identityHashCode(this); - } - - @Override - public boolean equals(Object o) { - return o instanceof HotSpotCompressedNullConstant; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java deleted file mode 100644 index 81b25e6c51d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; - -/** - * A value in a space managed by Hotspot (e.g. heap or metaspace). - * Some of these values can be referenced with a compressed pointer - * instead of a full word-sized pointer. - */ -public interface HotSpotConstant extends Constant { - - /** - * Determines if this constant is compressed. - */ - boolean isCompressed(); - - /** - * Determines if this constant is compressible. - */ - boolean isCompressible(); - - /** - * Gets a compressed version of this uncompressed constant. - * - * @throws IllegalArgumentException if this constant is not compressible - */ - Constant compress(); - - /** - * Gets an uncompressed version of this compressed constant. - * - * @throws IllegalArgumentException if this is an uncompressed constant - * or this constant is not compressible - */ - Constant uncompress(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPool.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPool.java deleted file mode 100644 index 20e3915527d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantPool.java +++ /dev/null @@ -1,991 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.AbstractList; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import jdk.vm.ci.common.JVMCIError; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaField; -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PrimitiveConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.meta.UnresolvedJavaField; -import jdk.vm.ci.meta.UnresolvedJavaMethod; -import jdk.vm.ci.meta.UnresolvedJavaType; - -/** - * Implementation of {@link ConstantPool} for HotSpot. - * - * The following convention is used in the jdk.vm.ci.hotspot package when accessing the ConstantPool with an index: - *
    - *
  • rawIndex - Index in the bytecode stream after the opcode (could be rewritten for some opcodes)
  • - *
  • cpi - The constant pool index (as specified in JVM Spec)
  • - *
  • cpci - The constant pool cache index, used only by the four bytecodes INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}. - * It's the same as {@code rawIndex}.
  • - *
  • which - May be either a {@code rawIndex} or a {@code cpci}.
  • - *
- * - * Note that {@code cpci} and {@code which} are used only in the HotSpot-specific implementation. They - * are not used by the public interface in jdk.vm.ci.meta.*. - * After JDK-8301993, all uses of {@code cpci} and {@code which} will be replaced with {@code rawIndex}. - */ -public final class HotSpotConstantPool implements ConstantPool, MetaspaceHandleObject { - - /** - * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. - */ - public static class Bytecodes { - public static final int LDC = 18; // 0x12 - public static final int LDC_W = 19; // 0x13 - public static final int LDC2_W = 20; // 0x14 - public static final int GETSTATIC = 178; // 0xB2 - public static final int PUTSTATIC = 179; // 0xB3 - public static final int GETFIELD = 180; // 0xB4 - public static final int PUTFIELD = 181; // 0xB5 - public static final int INVOKEVIRTUAL = 182; // 0xB6 - public static final int INVOKESPECIAL = 183; // 0xB7 - public static final int INVOKESTATIC = 184; // 0xB8 - public static final int INVOKEINTERFACE = 185; // 0xB9 - public static final int INVOKEDYNAMIC = 186; // 0xBA - public static final int NEW = 187; // 0xBB - public static final int NEWARRAY = 188; // 0xBC - public static final int ANEWARRAY = 189; // 0xBD - public static final int CHECKCAST = 192; // 0xC0 - public static final int INSTANCEOF = 193; // 0xC1 - public static final int MULTIANEWARRAY = 197; // 0xC5 - - static boolean isInvoke(int opcode) { - switch (opcode) { - case INVOKEVIRTUAL: - case INVOKESPECIAL: - case INVOKESTATIC: - case INVOKEINTERFACE: - case INVOKEDYNAMIC: - return true; - default: - return false; - } - } - - /** - * See: {@code Rewriter::maybe_rewrite_invokehandle}. - */ - static boolean isInvokeHandleAlias(int opcode) { - switch (opcode) { - case INVOKEVIRTUAL: - case INVOKESPECIAL: - return true; - default: - return false; - } - } - } - - static final class JvmConstant { - private final int tag; - private final String name; - - JvmConstant(int tag, String name) { - this.tag = tag; - this.name = name; - } - - @Override - public String toString() { - return name; - } - } - - /** - * {@code JVM_CONSTANT} constants used in the VM including both public and internal ones. - */ - static final class JvmConstants { - - private final HotSpotVMConfig c = config(); - private final int externalMax = c.jvmConstantExternalMax; - private final int internalMax = c.jvmConstantInternalMax; - private final int internalMin = c.jvmConstantInternalMin; - private final JvmConstant[] table = new JvmConstant[externalMax + 1 + (internalMax - internalMin) + 1]; - - final JvmConstant jvmUtf8 = add(new JvmConstant(c.jvmConstantUtf8, "Utf8")); - final JvmConstant jvmInteger = add(new JvmConstant(c.jvmConstantInteger, "Integer")); - final JvmConstant jvmLong = add(new JvmConstant(c.jvmConstantLong, "Long")); - final JvmConstant jvmFloat = add(new JvmConstant(c.jvmConstantFloat, "Float")); - final JvmConstant jvmDouble = add(new JvmConstant(c.jvmConstantDouble, "Double")); - final JvmConstant jvmClass = add(new JvmConstant(c.jvmConstantClass, "Class")); - final JvmConstant jvmUnresolvedClass = add(new JvmConstant(c.jvmConstantUnresolvedClass, "UnresolvedClass")); - final JvmConstant jvmUnresolvedClassInError = add(new JvmConstant(c.jvmConstantUnresolvedClassInError, "UnresolvedClassInError")); - final JvmConstant jvmString = add(new JvmConstant(c.jvmConstantString, "String")); - final JvmConstant jvmFieldref = add(new JvmConstant(c.jvmConstantFieldref, "Fieldref")); - final JvmConstant jvmMethodref = add(new JvmConstant(c.jvmConstantMethodref, "Methodref")); - final JvmConstant jvmInterfaceMethodref = add(new JvmConstant(c.jvmConstantInterfaceMethodref, "InterfaceMethodref")); - final JvmConstant jvmNameAndType = add(new JvmConstant(c.jvmConstantNameAndType, "NameAndType")); - final JvmConstant jvmMethodHandle = add(new JvmConstant(c.jvmConstantMethodHandle, "MethodHandle")); - final JvmConstant jvmMethodHandleInError = add(new JvmConstant(c.jvmConstantMethodHandleInError, "MethodHandleInError")); - final JvmConstant jvmMethodType = add(new JvmConstant(c.jvmConstantMethodType, "MethodType")); - final JvmConstant jvmMethodTypeInError = add(new JvmConstant(c.jvmConstantMethodTypeInError, "MethodTypeInError")); - final JvmConstant jvmInvokeDynamic = add(new JvmConstant(c.jvmConstantInvokeDynamic, "InvokeDynamic")); - final JvmConstant jvmDynamic = add(new JvmConstant(c.jvmConstantDynamic, "Dynamic")); - final JvmConstant jvmDynamicInError = add(new JvmConstant(c.jvmConstantDynamicInError, "DynamicInError")); - - private JvmConstant add(JvmConstant constant) { - table[indexOf(constant.tag)] = constant; - return constant; - } - - private int indexOf(int tag) { - if (tag >= internalMin) { - return tag - internalMin + externalMax + 1; - } else { - assert tag <= externalMax; - } - return tag; - } - - JvmConstant get(int tag) { - JvmConstant res = table[indexOf(tag)]; - if (res != null) { - return res; - } - throw new JVMCIError("Unknown JvmConstant tag %s", tag); - } - - private static volatile JvmConstants instance; - - static JvmConstants instance() { - JvmConstants result = instance; - if (result == null) { - synchronized (JvmConstants.class) { - result = instance; - if (result == null) { - instance = result = new JvmConstants(); - } - } - } - return result; - } - } - - private static class LookupTypeCacheElement { - int lastCpi = Integer.MIN_VALUE; - JavaType javaType; - - LookupTypeCacheElement(int lastCpi, JavaType javaType) { - super(); - this.lastCpi = lastCpi; - this.javaType = javaType; - } - } - - /** - * A {@code jmetadata} value that is a handle to {@code ConstantPool*} value. - */ - private final long constantPoolHandle; - - private volatile LookupTypeCacheElement lastLookupType; - private final JvmConstants constants; - - /** - * Cache for {@link #getHolder()}. - */ - private HotSpotResolvedObjectTypeImpl holder; - - /** - * Gets the JVMCI mirror from a HotSpot constant pool. The VM is responsible for ensuring that - * the ConstantPool is kept alive for the duration of this call and the - * {@link HotSpotJVMCIRuntime} keeps it alive after that. - * - * Called from the VM. - * - * @param constantPoolHandle a {@code jmetaspace} handle to a raw {@code ConstantPool*} value - * @return the {@link HotSpotConstantPool} corresponding to {@code constantPoolHandle} - */ - @SuppressWarnings("unused") - @VMEntryPoint - private static HotSpotConstantPool fromMetaspace(long constantPoolHandle) { - return new HotSpotConstantPool(constantPoolHandle); - } - - private HotSpotConstantPool(long constantPoolHandle) { - this.constantPoolHandle = constantPoolHandle; - this.constants = JvmConstants.instance(); - HandleCleaner.create(this, constantPoolHandle); - } - - /** - * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. - * - * @return holder for this constant pool - */ - private HotSpotResolvedObjectType getHolder() { - if (holder == null) { - holder = compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset); - } - return holder; - } - - /** - * Gets the raw {@code ConstantPool*} value for the this constant pool. - */ - long getConstantPoolPointer() { - return getMetaspacePointer(); - } - - @Override - public long getMetadataHandle() { - return constantPoolHandle; - } - - /** - * Gets the constant pool tag at index {@code index}. - * - * @param index constant pool index - * @return constant pool tag - */ - private JvmConstant getTagAt(int index) { - checkBounds(index); - HotSpotVMConfig config = config(); - final long metaspaceConstantPoolTags = UNSAFE.getAddress(getConstantPoolPointer() + config.constantPoolTagsOffset); - final int tag = UNSAFE.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); - if (tag == 0) { - return null; - } - return constants.get(tag); - } - - /** - * Gets the constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return constant pool entry - */ - long getEntryAt(int index) { - checkBounds(index); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getAddress(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the integer constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return integer constant pool entry at index - */ - private int getIntAt(int index) { - checkTag(index, constants.jvmInteger); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the long constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return long constant pool entry - */ - private long getLongAt(int index) { - checkTag(index, constants.jvmLong); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getLong(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the float constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return float constant pool entry - */ - private float getFloatAt(int index) { - checkTag(index, constants.jvmFloat); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getFloat(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the double constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return float constant pool entry - */ - private double getDoubleAt(int index) { - checkTag(index, constants.jvmDouble); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getDouble(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. - * - * @param index constant pool index - * @return {@code JVM_CONSTANT_NameAndType} constant pool entry - */ - private int getNameAndTypeAt(int index) { - checkTag(index, constants.jvmNameAndType); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset); - } - - /** - * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index - * {@code index}. - * - * @param rawIndex rewritten index in the bytecode stream - * @param opcode the opcode of the instruction for which the lookup is being performed - * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry - */ - private int getNameAndTypeRefIndexAt(int rawIndex, int opcode) { - return compilerToVM().lookupNameAndTypeRefIndexInPool(this, rawIndex, opcode); - } - - /** - * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at - * index {@code index}. - * - * @param index constant pool index - * @return name reference index - */ - private int getNameRefIndexAt(int index) { - final int refIndex = getNameAndTypeAt(index); - // name ref index is in the low 16-bits. - return refIndex & 0xFFFF; - } - - - /** - * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry - * at index {@code index}. - * - * @param index constant pool index - * @return signature reference index - */ - private int getSignatureRefIndexAt(int index) { - final int refIndex = getNameAndTypeAt(index); - // signature ref index is in the high 16-bits. - return refIndex >>> 16; - } - - /** - * Gets the klass reference index constant pool entry at index {@code index}. - * - * @param which for INVOKE{VIRTUAL,SPECIAL,STATIC,INTERFACE}, must be {@code cpci}. For all other bytecodes, - * must be {@code rawIndex} - * @param opcode the opcode of the instruction for which the lookup is being performed - * @return klass reference index - */ - private int getKlassRefIndexAt(int which, int opcode) { - return compilerToVM().lookupKlassRefIndexInPool(this, which, opcode); - } - - /** - * Gets the uncached klass reference index constant pool entry at index {@code index}. See: - * {@code ConstantPool::uncached_klass_ref_index_at}. - * - * @param index constant pool index - * @return klass reference index - */ - private int getUncachedKlassRefIndexAt(int index) { - checkTagIsFieldOrMethod(index); - int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize; - final int refIndex = UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolSize + offset); - // klass ref index is in the low 16-bits. - return refIndex & 0xFFFF; - } - - /** - * Checks that the constant pool index {@code index} is in the bounds of the constant pool. - * - * @param index constant pool index - * @throws IndexOutOfBoundsException if the check fails - */ - private void checkBounds(int index) { - if (index < 1 || index >= length()) { - throw new IndexOutOfBoundsException("index " + index + " not between 1 and " + length()); - } - } - - /** - * Checks that the constant pool tag at index {@code index} is equal to {@code tag}. - * - * @param index constant pool index - * @param tag expected tag - * @throws IllegalArgumentException if the check fails - */ - private void checkTag(int index, JvmConstant tag) { - final JvmConstant tagAt = getTagAt(index); - if (tagAt != tag) { - throw new IllegalArgumentException("constant pool tag at index " + index + " is " + tagAt + " but expected " + tag); - } - } - - /** - * Asserts that the constant pool tag at index {@code index} is a - * {@link JvmConstants#jvmFieldref}, or a {@link JvmConstants#jvmMethodref}, or a - * {@link JvmConstants#jvmInterfaceMethodref}. - * - * @param index constant pool index - * @throws IllegalArgumentException if the check fails - */ - private void checkTagIsFieldOrMethod(int index) { - final JvmConstant tagAt = getTagAt(index); - if (tagAt != constants.jvmFieldref && tagAt != constants.jvmMethodref && tagAt != constants.jvmInterfaceMethodref) { - throw new IllegalArgumentException("constant pool tag at index " + index + " is " + tagAt); - } - } - - @Override - public int length() { - return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolLengthOffset); - } - - public boolean hasDynamicConstant() { - return (flags() & config().constantPoolHasDynamicConstant) != 0; - } - - private int flags() { - return UNSAFE.getInt(getConstantPoolPointer() + config().constantPoolFlagsOffset); - } - - /** - * Represents a list of static arguments from a {@link BootstrapMethodInvocation} of the form - * {{@code arg_count}, {@code pool_index}}, meaning the arguments are not already resolved - * and that the JDK has to lookup the arguments when they are needed. The {@code bssIndex} - * corresponds to {@code pool_index} and the {@code size} corresponds to {@code arg_count}. - */ - static class CachedBSMArgs extends AbstractList { - private final JavaConstant[] cache; - private final HotSpotConstantPool cp; - private final int bssIndex; - - CachedBSMArgs(HotSpotConstantPool cp, int bssIndex, int size) { - this.cp = cp; - this.bssIndex = bssIndex; - this.cache = new JavaConstant[size]; - } - - /** - * Lazily resolves and caches the argument at the given index and returns it. The method - * {@link CompilerToVM#bootstrapArgumentIndexAt} is used to obtain the constant pool - * index of the entry and the method {@link ConstantPool#lookupConstant} is used to - * resolve it. If the resolution failed, the index is returned as a - * {@link PrimitiveConstant}. - * - * @param index index of the element to return - * @return A {@link JavaConstant} corresponding to the static argument requested. A return - * value of type {@link PrimitiveConstant} represents an unresolved constant pool entry - */ - @Override - public JavaConstant get(int index) { - JavaConstant res = cache[index]; - if (res == null) { - int argCpi = compilerToVM().bootstrapArgumentIndexAt(cp, bssIndex, index); - Object object = cp.lookupConstant(argCpi, false); - if (object instanceof PrimitiveConstant primitiveConstant) { - res = runtime().getReflection().boxPrimitive(primitiveConstant); - } else if (object instanceof JavaConstant javaConstant) { - res = javaConstant; - } else if (object instanceof JavaType type) { - res = runtime().getReflection().forObject(type); - } else { - res = JavaConstant.forInt(argCpi); - } - cache[index] = res; - } - return res; - } - - @Override - public int size() { - return cache.length; - } - } - - class BootstrapMethodInvocationImpl implements BootstrapMethodInvocation { - private final boolean indy; - private final ResolvedJavaMethod method; - private final String name; - private final JavaConstant type; - private final List staticArguments; - private final int cpiOrIndyIndex; - - BootstrapMethodInvocationImpl(boolean indy, ResolvedJavaMethod method, String name, JavaConstant type, List staticArguments, int cpiOrIndyIndex) { - this.indy = indy; - this.method = method; - this.name = name; - this.type = type; - this.staticArguments = staticArguments; - this.cpiOrIndyIndex = cpiOrIndyIndex; - } - - @Override - public ResolvedJavaMethod getMethod() { - return method; - } - - @Override - public String getName() { - return name; - } - - @Override - public boolean isInvokeDynamic() { - return indy; - } - - @Override - public JavaConstant getType() { - return type; - } - - @Override - public List getStaticArguments() { - return staticArguments; - } - - @Override - public void resolve() { - if (isInvokeDynamic()) { - loadReferencedType(cpiOrIndyIndex, Bytecodes.INVOKEDYNAMIC); - } else { - lookupConstant(cpiOrIndyIndex, true); - } - } - - @Override - public JavaConstant lookup() { - if (isInvokeDynamic()) { - return lookupAppendix(cpiOrIndyIndex, Bytecodes.INVOKEDYNAMIC); - } else { - return (JavaConstant) lookupConstant(cpiOrIndyIndex, false); - } - } - - @Override - public String toString() { - String static_args = staticArguments.stream().map(BootstrapMethodInvocationImpl::argumentAsString).collect(Collectors.joining(", ", "[", "]")); - return "BootstrapMethod[" + (indy ? "indy" : "condy") + - ", method:" + method.format("%H.%n(%p)") + - ", name: " + name + - ", type: " + type.toValueString() + - ", static arguments:" + static_args; - } - - private static String argumentAsString(JavaConstant arg) { - String type = arg.getJavaKind().getJavaName(); - String value = arg.toValueString(); - return type + ":" + value; - } - } - - @Override - public BootstrapMethodInvocation lookupBootstrapMethodInvocation(int index, int opcode) { - int cpi = opcode == -1 ? index : indyIndexConstantPoolIndex(index, opcode); - final JvmConstant tag = getTagAt(cpi); - switch (tag.name) { - case "InvokeDynamic": - case "Dynamic": - Object[] bsmi = compilerToVM().resolveBootstrapMethod(this, cpi); - ResolvedJavaMethod method = (ResolvedJavaMethod) bsmi[0]; - String name = (String) bsmi[1]; - JavaConstant type = (JavaConstant) bsmi[2]; - Object staticArguments = bsmi[3]; - List staticArgumentsList; - if (staticArguments == null) { - staticArgumentsList = List.of(); - } else if (staticArguments instanceof JavaConstant) { - staticArgumentsList = List.of((JavaConstant) staticArguments); - } else if (staticArguments instanceof JavaConstant[]) { - staticArgumentsList = List.of((JavaConstant[]) staticArguments); - } else { - int[] bsciArgs = (int[]) staticArguments; - int argCount = bsciArgs[0]; - int bss_index = bsciArgs[1]; - staticArgumentsList = new CachedBSMArgs(this, bss_index, argCount); - } - boolean isIndy = tag.name.equals("InvokeDynamic"); - return new BootstrapMethodInvocationImpl(isIndy, method, name, type, staticArgumentsList, isIndy ? index : cpi); - default: - return null; - } - } - - private boolean isDynamicEntry(int cpi) { - JvmConstant tagAt = getTagAt(cpi); - return tagAt != null && tagAt.name.equals("Dynamic"); - } - - @Override - public List lookupBootstrapMethodInvocations(boolean invokeDynamic){ - if (invokeDynamic) { - int numIndys = compilerToVM().getNumIndyEntries(this); - if (numIndys == 0) { - return List.of(); - } - return IntStream.range(0, numIndys) - .mapToObj(i -> lookupBootstrapMethodInvocation(i, Bytecodes.INVOKEDYNAMIC)) - .toList(); - } else { - return IntStream.range(1, length()) - .filter(this::isDynamicEntry) - .mapToObj(cpi -> lookupBootstrapMethodInvocation(cpi, -1)) - .toList(); - } - } - - /** - * Gets the {@link JavaConstant} for the {@code ConstantValue} attribute of a field. - */ - JavaConstant getStaticFieldConstantValue(int cpi) { - final JvmConstant tag = getTagAt(cpi); - switch (tag.name) { - case "Integer": - return JavaConstant.forInt(getIntAt(cpi)); - case "Long": - return JavaConstant.forLong(getLongAt(cpi)); - case "Float": - return JavaConstant.forFloat(getFloatAt(cpi)); - case "Double": - return JavaConstant.forDouble(getDoubleAt(cpi)); - case "String": - return compilerToVM().getUncachedStringInPool(this, cpi); - default: - throw new IllegalArgumentException("Illegal entry for a ConstantValue attribute:" + tag); - } - } - - @Override - public Object lookupConstant(int cpi) { - return lookupConstant(cpi, true); - } - - @Override - public Object lookupConstant(int cpi, boolean resolve) { - final JvmConstant tag = getTagAt(cpi); - switch (tag.name) { - case "Integer": - return JavaConstant.forInt(getIntAt(cpi)); - case "Long": - return JavaConstant.forLong(getLongAt(cpi)); - case "Float": - return JavaConstant.forFloat(getFloatAt(cpi)); - case "Double": - return JavaConstant.forDouble(getDoubleAt(cpi)); - case "Class": - case "UnresolvedClass": - case "UnresolvedClassInError": - final int opcode = -1; // opcode is not used - return lookupType(cpi, opcode); - case "String": - /* - * Normally, we would expect a String here, but unsafe anonymous classes can have - * "pseudo strings" (arbitrary live objects) patched into a String entry. Such - * entries do not have a symbol in the constant pool slot. - */ - return compilerToVM().lookupConstantInPool(this, cpi, true); - case "MethodHandle": - case "MethodHandleInError": - case "MethodType": - case "MethodTypeInError": - case "Dynamic": - case "DynamicInError": - return compilerToVM().lookupConstantInPool(this, cpi, resolve); - default: - throw new JVMCIError("Unknown constant pool tag %s", tag); - } - - } - - @Override - public String lookupUtf8(int cpi) { - checkTag(cpi, constants.jvmUtf8); - return compilerToVM().getSymbol(getEntryAt(cpi)); - } - - @Override - public Signature lookupSignature(int cpi) { - return new HotSpotSignature(runtime(), lookupUtf8(cpi)); - } - - @Override - public JavaConstant lookupAppendix(int rawIndex, int opcode) { - if (!Bytecodes.isInvoke(opcode)) { - throw new IllegalArgumentException("expected an invoke bytecode for " + rawIndex + ", got " + opcode); - } - return compilerToVM().lookupAppendixInPool(this, rawIndex, opcode); - } - - /** - * Gets a {@link JavaType} corresponding a given resolved or unresolved type. - * - * @param type either a ResolvedJavaType or a String naming a unresolved type. - */ - private static JavaType getJavaType(final Object type) { - if (type instanceof String) { - String name = (String) type; - return UnresolvedJavaType.create("L" + name + ";"); - } else { - return (JavaType) type; - } - } - - @Override - public JavaMethod lookupMethod(int rawIndex, int opcode, ResolvedJavaMethod caller) { - final HotSpotResolvedJavaMethod method = compilerToVM().lookupMethodInPool(this, rawIndex, (byte) opcode, (HotSpotResolvedJavaMethodImpl) caller); - if (method != null) { - return method; - } else { - // Get the method's name and signature. - String name = compilerToVM().lookupNameInPool(this, rawIndex, opcode); - HotSpotSignature signature = new HotSpotSignature(runtime(), compilerToVM().lookupSignatureInPool(this, rawIndex, opcode)); - if (opcode == Bytecodes.INVOKEDYNAMIC) { - return new UnresolvedJavaMethod(name, signature, runtime().getMethodHandleClass()); - } else { - final int klassIndex = getKlassRefIndexAt(rawIndex, opcode); - final Object type = compilerToVM().lookupKlassInPool(this, klassIndex); - return new UnresolvedJavaMethod(name, signature, getJavaType(type)); - } - } - } - - @Override - public JavaType lookupType(int cpi, int opcode) { - final LookupTypeCacheElement elem = this.lastLookupType; - if (elem != null && elem.lastCpi == cpi) { - return elem.javaType; - } else { - final Object type = compilerToVM().lookupKlassInPool(this, cpi); - JavaType result = getJavaType(type); - if (result instanceof ResolvedJavaType) { - this.lastLookupType = new LookupTypeCacheElement(cpi, result); - } - return result; - } - } - - @Override - public JavaType lookupReferencedType(int rawIndex, int opcode) { - int cpi; - switch (opcode) { - case Bytecodes.CHECKCAST: - case Bytecodes.INSTANCEOF: - case Bytecodes.NEW: - case Bytecodes.ANEWARRAY: - case Bytecodes.MULTIANEWARRAY: - case Bytecodes.LDC: - case Bytecodes.LDC_W: - case Bytecodes.LDC2_W: - cpi = rawIndex; - break; - case Bytecodes.GETSTATIC: - case Bytecodes.PUTSTATIC: - case Bytecodes.GETFIELD: - case Bytecodes.PUTFIELD: - cpi = getKlassRefIndexAt(rawIndex, opcode); - break; - case Bytecodes.INVOKEVIRTUAL: - case Bytecodes.INVOKESPECIAL: - case Bytecodes.INVOKESTATIC: - case Bytecodes.INVOKEINTERFACE: { - cpi = getKlassRefIndexAt(rawIndex, opcode); - break; - } - default: - throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); - } - final Object type = compilerToVM().lookupKlassInPool(this, cpi); - return getJavaType(type); - } - - @Override - public JavaField lookupField(int rawIndex, ResolvedJavaMethod method, int opcode) { - final int nameAndTypeIndex = getNameAndTypeRefIndexAt(rawIndex, opcode); - final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); - String typeName = lookupUtf8(typeIndex); - JavaType type = runtime().lookupType(typeName, getHolder(), false); - - final int holderIndex = getKlassRefIndexAt(rawIndex, opcode); - JavaType fieldHolder = lookupType(holderIndex, opcode); - - if (fieldHolder instanceof HotSpotResolvedObjectTypeImpl) { - int[] info = new int[4]; - HotSpotResolvedObjectTypeImpl resolvedHolder; - try { - resolvedHolder = compilerToVM().resolveFieldInPool(this, rawIndex, (HotSpotResolvedJavaMethodImpl) method, (byte) opcode, info); - } catch (Throwable cause) { - return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type, cause); - } - if (resolvedHolder == null) { - return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type); - } - final int flags = info[0]; - final int offset = info[1]; - final int fieldIndex = info[2]; - final int fieldFlags = info[3]; - HotSpotResolvedJavaField result = resolvedHolder.createField(type, offset, flags, fieldFlags, fieldIndex); - return result; - } else { - return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type); - } - } - - /** - * Converts a raw index for the INVOKEDYNAMIC bytecode to a constant pool index. - * - * @param rawIndex index from the bytecode - * - * @param opcode bytecode to convert the index for. Must be INVOKEDYNAMIC. - * - * @return constant pool index - */ - private int indyIndexConstantPoolIndex(int rawIndex, int opcode) { - if (opcode != Bytecodes.INVOKEDYNAMIC) { - throw new IllegalArgumentException("expected INVOKEDYNAMIC at " + rawIndex + ", got " + opcode); - } - return compilerToVM().decodeIndyIndexToCPIndex(this, rawIndex, false); - } - - @Override - public void loadReferencedType(int rawIndex, int opcode) { - loadReferencedType(rawIndex, opcode, true /* initialize */); - } - - @Override - @SuppressWarnings("fallthrough") - public void loadReferencedType(int rawIndex, int opcode, boolean initialize) { - int cpi; - switch (opcode) { - case Bytecodes.CHECKCAST: - case Bytecodes.INSTANCEOF: - case Bytecodes.NEW: - case Bytecodes.ANEWARRAY: - case Bytecodes.MULTIANEWARRAY: - case Bytecodes.LDC: - case Bytecodes.LDC_W: - case Bytecodes.LDC2_W: - cpi = rawIndex; - break; - case Bytecodes.INVOKEDYNAMIC: { - cpi = compilerToVM().decodeIndyIndexToCPIndex(this, rawIndex, true); - break; - } - case Bytecodes.GETSTATIC: - case Bytecodes.PUTSTATIC: - case Bytecodes.GETFIELD: - case Bytecodes.PUTFIELD: - cpi = compilerToVM().decodeFieldIndexToCPIndex(this, rawIndex); - break; - case Bytecodes.INVOKEVIRTUAL: - case Bytecodes.INVOKESPECIAL: - case Bytecodes.INVOKESTATIC: - case Bytecodes.INVOKEINTERFACE: { - cpi = compilerToVM().decodeMethodIndexToCPIndex(this, rawIndex); - break; - } - default: - throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); - } - - final JvmConstant tag = getTagAt(cpi); - if (tag == null) { - assert getTagAt(cpi - 1) == constants.jvmDouble || getTagAt(cpi - 1) == constants.jvmLong; - return; - } - switch (tag.name) { - case "Methodref": - case "Fieldref": - case "InterfaceMethodref": - cpi = getUncachedKlassRefIndexAt(cpi); - // Read the tag only once because it could change between multiple reads. - final JvmConstant klassTag = getTagAt(cpi); - assert klassTag == constants.jvmClass || klassTag == constants.jvmUnresolvedClass || klassTag == constants.jvmUnresolvedClassInError : klassTag; - // fall through - case "Class": - case "UnresolvedClass": - case "UnresolvedClassInError": - final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, cpi); - if (initialize && !type.isPrimitive() && !type.isArray()) { - type.ensureInitialized(); - } - if (tag == constants.jvmMethodref) { - if (Bytecodes.isInvokeHandleAlias(opcode) && isSignaturePolymorphicHolder(type)) { - checkTag(compilerToVM().decodeMethodIndexToCPIndex(this, rawIndex), constants.jvmMethodref); - compilerToVM().resolveInvokeHandleInPool(this, rawIndex); - } - } - - break; - case "InvokeDynamic": - // nothing - break; - default: - // nothing - break; - } - - } - - // Lazily initialized. - private static String[] signaturePolymorphicHolders; - - /** - * Determines if {@code type} contains signature polymorphic methods. - */ - @SuppressFBWarnings(value = "LI_LAZY_INIT_STATIC", justification = "signaturePolymorphicHolders is a cache, not a singleton that must be constructed exactly once" + - "and compiler re-ordering is not an issue due to the VM call") - static boolean isSignaturePolymorphicHolder(final ResolvedJavaType type) { - String name = type.getName(); - if (signaturePolymorphicHolders == null) { - signaturePolymorphicHolders = compilerToVM().getSignaturePolymorphicHolders(); - } - for (String holder : signaturePolymorphicHolders) { - if (name.equals(holder)) { - return true; - } - } - return false; - } - - public String getSourceFileName() { - final int sourceFileNameIndex = UNSAFE.getChar(getConstantPoolPointer() + config().constantPoolSourceFileNameIndexOffset); - if (sourceFileNameIndex == 0) { - return null; - } - return lookupUtf8(sourceFileNameIndex); - } - - @Override - public String toString() { - return "HotSpotConstantPool<" + getHolder().toJavaName() + ">"; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java deleted file mode 100644 index 9e1cd287527..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; - -import java.util.Objects; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * HotSpot implementation of {@link ConstantReflectionProvider}. - */ -public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider { - - protected final HotSpotJVMCIRuntime runtime; - protected final HotSpotMethodHandleAccessProvider methodHandleAccess; - private final HotSpotMemoryAccessProviderImpl memoryAccess; - - public HotSpotConstantReflectionProvider(HotSpotJVMCIRuntime runtime) { - this.runtime = runtime; - this.methodHandleAccess = new HotSpotMethodHandleAccessProvider(this); - this.memoryAccess = new HotSpotMemoryAccessProviderImpl(runtime); - } - - @Override - public MethodHandleAccessProvider getMethodHandleAccess() { - return methodHandleAccess; - } - - @Override - public MemoryAccessProvider getMemoryAccessProvider() { - return memoryAccess; - } - - @Override - public Boolean constantEquals(Constant x, Constant y) { - if (x == y) { - return true; - } else if (x instanceof HotSpotObjectConstantImpl) { - return y instanceof HotSpotObjectConstantImpl && x.equals(y); - } else { - return Objects.equals(x, y); - } - } - - @Override - public Integer readArrayLength(JavaConstant array) { - if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { - return null; - } - - HotSpotObjectConstantImpl arrayObject = ((HotSpotObjectConstantImpl) array); - return runtime.getReflection().getLength(arrayObject); - } - - @Override - public JavaConstant readArrayElement(JavaConstant array, int index) { - if (array == null || array.getJavaKind() != JavaKind.Object || array.isNull()) { - return null; - } - HotSpotObjectConstantImpl arrayObject = ((HotSpotObjectConstantImpl) array); - return runtime.getReflection().readArrayElement(arrayObject, index); - } - - /** - * Check if the constant is a boxed value that is guaranteed to be cached by the platform. - * Otherwise the generated code might be the only reference to the boxed value and since object - * references from nmethods are weak this can cause GC problems. - * - * @return true if the box is cached - */ - private static boolean isBoxCached(JavaConstant source) { - switch (source.getJavaKind()) { - case Boolean: - return true; - case Char: - return source.asInt() <= 127; - case Byte: - case Short: - case Int: - return source.asInt() >= -128 && source.asInt() <= 127; - case Long: - return source.asLong() >= -128 && source.asLong() <= 127; - case Float: - case Double: - return false; - default: - throw new IllegalArgumentException("unexpected kind " + source.getJavaKind()); - } - } - - @Override - public JavaConstant boxPrimitive(JavaConstant source) { - if (source == null || !source.getJavaKind().isPrimitive() || !isBoxCached(source)) { - return null; - } - return runtime.getReflection().boxPrimitive(source); - } - - @Override - public JavaConstant unboxPrimitive(JavaConstant source) { - if (source == null || !source.getJavaKind().isObject()) { - return null; - } - if (source.isNull()) { - return null; - } - return runtime.getReflection().unboxPrimitive((HotSpotObjectConstantImpl) source); - } - - @Override - public JavaConstant forString(String value) { - return runtime.getReflection().forObject(value); - } - - public JavaConstant forObject(Object value) { - return runtime.getReflection().forObject(value); - } - - @Override - public ResolvedJavaType asJavaType(Constant constant) { - if (constant instanceof HotSpotObjectConstantImpl) { - return ((HotSpotObjectConstantImpl) constant).asJavaType(); - } - if (constant instanceof HotSpotMetaspaceConstant) { - MetaspaceObject obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); - if (obj instanceof HotSpotResolvedObjectTypeImpl) { - return (ResolvedJavaType) obj; - } - } - return null; - } - - @Override - public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) { - HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; - if (hotspotField.isStatic()) { - HotSpotResolvedObjectTypeImpl declaringType = (HotSpotResolvedObjectTypeImpl) hotspotField.getDeclaringClass(); - if (declaringType.isInitialized()) { - return runtime().compilerToVm.readStaticFieldValue(declaringType, hotspotField.getOffset(), - hotspotField.getType().getJavaKind().getTypeChar()); - } - } else if (receiver instanceof HotSpotObjectConstantImpl) { - return ((HotSpotObjectConstantImpl) receiver).readFieldValue(hotspotField); - } else if (receiver == null) { - throw new NullPointerException("receiver is null"); - } - return null; - } - - @Override - public JavaConstant asJavaClass(ResolvedJavaType type) { - return ((HotSpotResolvedJavaType) type).getJavaMirror(); - } - - @Override - public Constant asObjectHub(ResolvedJavaType type) { - if (type instanceof HotSpotResolvedObjectType) { - return ((HotSpotResolvedObjectType) type).klass(); - } else { - throw JVMCIError.unimplemented(); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java deleted file mode 100644 index cdce4f473f7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotForeignCallTarget.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.InvokeTarget; - -public class HotSpotForeignCallTarget implements InvokeTarget { - - /** - * The entry point address of this call's target. - */ - @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "accessed by subclasses")// - protected long address; - - public HotSpotForeignCallTarget(long address) { - this.address = address; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotInstalledCode.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotInstalledCode.java deleted file mode 100644 index 0e1b864790c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotInstalledCode.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; - -import jdk.vm.ci.code.InstalledCode; - -/** - * Implementation of {@link InstalledCode} for HotSpot representing a {@code CodeBlob}. The address - * of the {@code CodeBlob} is stored in {@link InstalledCode#address}. - */ -public abstract class HotSpotInstalledCode extends InstalledCode { - - /** - * Total size of the code blob (i.e. {@code CodeBlob::size()}). - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int size; - - /** - * Start address of the code (i.e. {@code CodeBlob::code_begin()}). - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private long codeStart; - - /** - * Size of the code (i.e. {@code CodeBlob::code_size()}). - */ - @SuppressFBWarnings(value = "UWF_UNWRITTEN_FIELD", justification = "field is set by the native part") private int codeSize; - - public HotSpotInstalledCode(String name) { - super(name); - } - - /** - * Gets the value of {@code CodeBlob::size()}. - */ - public int getSize() { - return size; - } - - @Override - public abstract String toString(); - - /** - * Gets the value of {@code CodeBlob::code_begin()} if {@linkplain #isValid() valid}, 0 - * otherwise. - */ - @Override - public long getStart() { - return codeStart; - } - - /** - * Gets the value of {@code CodeBlob::code_size()} if {@linkplain #isValid() valid}, 0 - * otherwise. - */ - public long getCodeSize() { - return codeSize; - } - - @Override - public byte[] getCode() { - return compilerToVM().getCode(this); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java deleted file mode 100644 index 6ee925cd3a7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.HashMap; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link HotSpotJVMCIReflection} in terms of standard JDK reflection API. This is - * only available when running in the HotSpot heap. - */ -final class HotSpotJDKReflection extends HotSpotJVMCIReflection { - - @Override - Object resolveObject(HotSpotObjectConstantImpl object) { - if (object == null) { - return null; - } - return ((DirectHotSpotObjectConstantImpl) object).object; - } - - @Override - boolean isInstance(HotSpotResolvedObjectTypeImpl holder, HotSpotObjectConstantImpl obj) { - Class javaMirror = getMirror(holder); - Object value = resolveObject(obj); - return javaMirror.isInstance(value); - } - - @Override - boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedObjectTypeImpl otherType) { - Class javaMirror = getMirror(holder); - return javaMirror.isAssignableFrom(getMirror(otherType)); - - } - - @Override - Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.getAnnotations(); - } - - @Override - Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.getDeclaredAnnotations(); - } - - @Override - T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass) { - Class javaMirror = getMirror(holder); - return javaMirror.getAnnotation(annotationClass); - } - - @Override - boolean isLocalClass(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.isLocalClass(); - } - - @Override - boolean isMemberClass(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.isMemberClass(); - } - - @Override - HotSpotResolvedObjectType getEnclosingClass(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return (HotSpotResolvedObjectType) runtime().fromClass(javaMirror.getEnclosingClass()); - } - - @Override - boolean equals(HotSpotObjectConstantImpl a, HotSpotObjectConstantImpl b) { - return resolveObject(a) == resolveObject(b) && a.isCompressed() == b.isCompressed(); - } - - @Override - ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaMethod) { - java.lang.reflect.Parameter[] javaParameters = getMethod(javaMethod).getParameters(); - ResolvedJavaMethod.Parameter[] res = new ResolvedJavaMethod.Parameter[javaParameters.length]; - for (int i = 0; i < res.length; i++) { - java.lang.reflect.Parameter src = javaParameters[i]; - String paramName = src.isNamePresent() ? src.getName() : null; - res[i] = new ResolvedJavaMethod.Parameter(paramName, src.getModifiers(), javaMethod, i); - } - return res; - } - - @Override - Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getParameterAnnotations(); - } - - @Override - Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getGenericParameterTypes(); - } - - @Override - Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - return getField(javaField).getAnnotations(); - } - - @Override - Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getAnnotations(); - } - - @Override - Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getDeclaredAnnotations(); - } - - @Override - Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - return getField(javaField).getDeclaredAnnotations(); - } - - @Override - T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass) { - return getMethod(javaMethod).getAnnotation(annotationClass); - } - - @Override - T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass) { - return getField(javaField).getAnnotation(annotationClass); - } - - @Override - HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object) { - Object value = resolveObject(object); - Class theClass = value.getClass(); - return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(theClass); - } - - @Override - String asString(HotSpotObjectConstantImpl object) { - Object value = resolveObject(object); - if (value instanceof String) { - return (String) value; - } - return null; - } - - @Override - ResolvedJavaType asJavaType(HotSpotObjectConstantImpl object) { - Object value = resolveObject(object); - if (value instanceof Class) { - Class javaClass = (Class) value; - return runtime().fromClass(javaClass); - } - if (value instanceof ResolvedJavaType) { - return (ResolvedJavaType) value; - } - return null; - } - - @SuppressWarnings("unchecked") - @Override - T asObject(HotSpotObjectConstantImpl object, Class type) { - Object value = resolveObject(object); - if (type.isInstance(value)) { - return (T) value; - } - return null; - } - - @Override - Object asObject(HotSpotObjectConstantImpl object, HotSpotResolvedJavaType type) { - Object value = resolveObject(object); - if (getMirror(type).isInstance(value)) { - return value; - } - return null; - } - - @Override - String formatString(HotSpotObjectConstantImpl object) { - return JavaKind.Object.format(resolveObject(object)); - } - - @Override - Integer getLength(HotSpotObjectConstantImpl arrayObject) { - Object object = resolveObject(arrayObject); - if (object.getClass().isArray()) { - return Array.getLength(object); - } - return null; - } - - @Override - JavaConstant readArrayElement(HotSpotObjectConstantImpl arrayObject, int index) { - Object a = resolveObject(arrayObject); - if (!a.getClass().isArray() || index < 0 || index >= Array.getLength(a)) { - return null; - } - if (a instanceof Object[]) { - Object element = ((Object[]) a)[index]; - return forObject(element); - } else { - if (a instanceof int[]) { - return JavaConstant.forInt(((int[]) a)[index]); - } else if (a instanceof char[]) { - return JavaConstant.forChar(((char[]) a)[index]); - } else if (a instanceof byte[]) { - return JavaConstant.forByte(((byte[]) a)[index]); - } else if (a instanceof long[]) { - return JavaConstant.forLong(((long[]) a)[index]); - } else if (a instanceof short[]) { - return JavaConstant.forShort(((short[]) a)[index]); - } else if (a instanceof float[]) { - return JavaConstant.forFloat(((float[]) a)[index]); - } else if (a instanceof double[]) { - return JavaConstant.forDouble(((double[]) a)[index]); - } else if (a instanceof boolean[]) { - return JavaConstant.forBoolean(((boolean[]) a)[index]); - } else { - throw new JVMCIError("Should not reach here"); - } - } - } - - @Override - JavaConstant unboxPrimitive(HotSpotObjectConstantImpl source) { - return JavaConstant.forBoxedPrimitive(resolveObject(source)); - } - - @Override - JavaConstant forObject(Object value) { - if (value == null) { - return JavaConstant.NULL_POINTER; - } - return forNonNullObject(value); - } - - private static HotSpotObjectConstantImpl forNonNullObject(Object value) { - return DirectHotSpotObjectConstantImpl.forNonNullObject(value, false); - } - - @Override - JavaConstant boxPrimitive(JavaConstant source) { - return forNonNullObject(source.asBoxedPrimitive()); - } - - /** - * Gets a {@link Method} object corresponding to {@code method}. This method guarantees the same - * {@link Method} object is returned if called twice on the same {@code method} value. - */ - static Executable getMethod(HotSpotResolvedJavaMethodImpl method) { - assert !method.isClassInitializer() : method; - if (method.toJavaCache == null) { - synchronized (method) { - if (method.toJavaCache == null) { - method.toJavaCache = compilerToVM().asReflectionExecutable(method); - } - } - } - return method.toJavaCache; - } - - /** - * Gets a {@link Field} object corresponding to {@code field}. This method guarantees the same - * {@link Field} object is returned if called twice on the same {@code field} value. This is - * required to ensure the results of {@link HotSpotResolvedJavaFieldImpl#getAnnotations()} and - * {@link HotSpotResolvedJavaFieldImpl#getAnnotation(Class)} are stable (i.e., for a given field - * {@code f} and annotation class {@code a}, the same object is returned for each call to - * {@code f.getAnnotation(a)}). - */ - static Field getField(HotSpotResolvedJavaFieldImpl field) { - HotSpotResolvedObjectTypeImpl declaringClass = field.getDeclaringClass(); - synchronized (declaringClass) { - HashMap cache = declaringClass.reflectionFieldCache; - if (cache == null) { - cache = new HashMap<>(); - declaringClass.reflectionFieldCache = cache; - } - Field reflect = cache.get(field); - if (reflect == null) { - reflect = compilerToVM().asReflectionField(field.getDeclaringClass(), field.getIndex()); - cache.put(field, reflect); - } - return reflect; - } - } - - Class getMirror(HotSpotResolvedObjectTypeImpl holder) { - return (Class) resolveObject((HotSpotObjectConstantImpl) holder.getJavaMirror()); - } - - Class getMirror(HotSpotResolvedJavaType type) { - assert type != null; - if (type instanceof HotSpotResolvedPrimitiveType) { - return (Class) resolveObject(((HotSpotResolvedPrimitiveType) type).mirror); - } else { - return getMirror((HotSpotResolvedObjectTypeImpl) type); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java deleted file mode 100644 index e0fc314de5b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIBackendFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.LongFunction; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.runtime.JVMCIBackend; - -public interface HotSpotJVMCIBackendFactory { - - JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host); - - /** - * Gets the CPU architecture of this backend. - */ - String getArchitecture(); - - /** - * Converts a bit mask of CPU features to enum constants. - * - * @param CPU feature enum type - * @param enumType the class of {@code CPUFeatureType} - * @param constants VM constants. Each entry whose key starts with {@code "VM_Version::CPU_"} - * specifies a CPU feature and its value is a mask for a bit in {@code features} - * @param bitMaskSupplier supplier to get the bit mask for the corresponding VM constant - * @param featuresSupplier supplier to get the bits specifying CPU features - * @param renaming maps from VM feature names to enum constant names where the two differ - * @throws IllegalArgumentException if any VM CPU feature constant cannot be converted to an - * enum value - * @return the set of converted values - */ - static > EnumSet convertFeatures( - Class enumType, - Map constants, - LongFunction bitMaskSupplier, - LongFunction featuresSupplier, - Map renaming) { - EnumSet outFeatures = EnumSet.noneOf(enumType); - List missing = new ArrayList<>(); - for (Entry e : constants.entrySet()) { - long bitMask = bitMaskSupplier.apply(e.getValue()); - String key = e.getKey(); - if (key.startsWith("VM_Version::CPU_")) { - String name = key.substring("VM_Version::CPU_".length()); - try { - CPUFeatureType feature = Enum.valueOf(enumType, renaming.getOrDefault(name, name)); - if ((featuresSupplier.apply(e.getValue()) & bitMask) != 0) { - outFeatures.add(feature); - } - } catch (IllegalArgumentException iae) { - missing.add(name); - } - } - } - if (!missing.isEmpty()) { - throw new JVMCIError("Missing CPU feature constants: %s", missing); - } - return outFeatures; - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java deleted file mode 100644 index 8767531451b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE; - -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCICompilerFactory; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.services.JVMCIPermission; -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.services.Services; - -final class HotSpotJVMCICompilerConfig { - - /** - * This factory allows JVMCI initialization to succeed but raises an error if the VM asks JVMCI - * to perform a compilation. This allows the reflective parts of the JVMCI API to be used - * without requiring a compiler implementation to be available. - */ - private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { - - private final String reason; - private final HotSpotJVMCIRuntime runtime; - - DummyCompilerFactory(String reason, HotSpotJVMCIRuntime runtime) { - this.reason = reason; - this.runtime = runtime; - if (runtime.getConfig().getFlag("EagerJVMCI", Boolean.class)) { - if (runtime.getCompilerToVM().isCompilerThread()) { - throw noCompilerError(); - } else { - // This path will be taken when initializing JVMCI on a non-JIT thread. - // Such a usage of JVMCI might never request a compilation so delay the - // noCompilerError until such a request is made. - } - } - } - - /** - * Exits the VM due to unavailability of a JVMCI compiler. - */ - Error noCompilerError() { - throw runtime.exitHotSpotWithMessage(1, "Cannot use JVMCI compiler: %s%n", reason); - } - - @Override - public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) { - throw noCompilerError(); - } - - @Override - public String getCompilerName() { - return "null"; - } - - @Override - public JVMCICompiler createCompiler(JVMCIRuntime rt) { - return this; - } - - @Override - public boolean isGCSupported(int gcIdentifier) { - return false; - } - } - - /** - * Factory of the selected system compiler. - */ - private static JVMCICompilerFactory compilerFactory; - - /** - * Gets the selected system compiler factory. - * - * @return the selected system compiler factory - * @throws SecurityException if a security manager is present and it denies - * {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method - */ - static JVMCICompilerFactory getCompilerFactory(HotSpotJVMCIRuntime runtime) { - if (compilerFactory == null) { - JVMCICompilerFactory factory = null; - String compilerName = Option.Compiler.getString(); - if (compilerName != null) { - String compPropertyName = Option.Compiler.getPropertyName(); - if (compilerName.isEmpty()) { - factory = new DummyCompilerFactory("Value of " + compPropertyName + " is empty", runtime); - } else if (compilerName.equals("null")) { - factory = new DummyCompilerFactory("Value of " + compPropertyName + " is \"null\"", runtime); - } else { - for (JVMCICompilerFactory f : getJVMCICompilerFactories()) { - if (f.getCompilerName().equals(compilerName)) { - factory = f; - } - } - if (factory == null) { - String reason; - if (Services.IS_IN_NATIVE_IMAGE) { - reason = String.format("JVMCI compiler '%s' not found in JVMCI native library.%n" + - "Use -XX:-UseJVMCINativeLibrary when specifying a JVMCI compiler available on a class path with %s.%n", - compilerName, compPropertyName); - } else { - reason = String.format("JVMCI compiler '%s' specified by %s not found%n", compilerName, compPropertyName); - } - factory = new DummyCompilerFactory(reason, runtime); - } - } - } else { - // Auto select a single available compiler - String reason = "No JVMCI compiler found"; - for (JVMCICompilerFactory f : getJVMCICompilerFactories()) { - if (factory == null) { - openJVMCITo(f.getClass().getModule()); - factory = f; - } else { - // Multiple factories seen - cancel auto selection - reason = "Multiple JVMCI compilers found: \"" + factory.getCompilerName() + "\" and \"" + f.getCompilerName() + "\""; - factory = null; - break; - } - } - if (factory == null) { - factory = new DummyCompilerFactory(reason, runtime); - } - } - factory.onSelection(); - compilerFactory = factory; - } - return compilerFactory; - } - - /** - * Opens all JVMCI packages to {@code otherModule}. - */ - private static void openJVMCITo(Module otherModule) { - if (!IS_IN_NATIVE_IMAGE) { - Module jvmci = HotSpotJVMCICompilerConfig.class.getModule(); - if (jvmci != otherModule) { - Set packages = jvmci.getPackages(); - for (String pkg : packages) { - boolean opened = jvmci.isOpen(pkg, otherModule); - if (!opened) { - jvmci.addOpens(pkg, otherModule); - } - } - } - } - } - - private static List getJVMCICompilerFactories() { - return JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java deleted file mode 100644 index 3211e0ab409..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * API for reflecting on the internals of HotSpot JVMCI types and objects. - */ -abstract class HotSpotJVMCIReflection { - - abstract boolean isInstance(HotSpotResolvedObjectTypeImpl holder, HotSpotObjectConstantImpl obj); - - abstract boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedObjectTypeImpl otherType); - - abstract Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder); - - abstract Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder); - - abstract T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass); - - abstract boolean isLocalClass(HotSpotResolvedObjectTypeImpl holder); - - abstract boolean isMemberClass(HotSpotResolvedObjectTypeImpl holder); - - abstract HotSpotResolvedObjectType getEnclosingClass(HotSpotResolvedObjectTypeImpl holder); - - abstract boolean equals(HotSpotObjectConstantImpl hotSpotResolvedJavaType, HotSpotObjectConstantImpl that); - - abstract ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaMethod); - - abstract Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod); - - abstract Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod); - - abstract Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaMethod); - - abstract Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaField); - - abstract Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod); - - abstract Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaMethod); - - abstract T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass); - - abstract HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object); - - abstract String asString(HotSpotObjectConstantImpl object); - - /** - * Given a {@link java.lang.Class} instance, return the corresponding ResolvedJavaType. - */ - abstract ResolvedJavaType asJavaType(HotSpotObjectConstantImpl object); - - abstract T asObject(HotSpotObjectConstantImpl object, Class type); - - abstract Object asObject(HotSpotObjectConstantImpl object, HotSpotResolvedJavaType type); - - abstract String formatString(HotSpotObjectConstantImpl object); - - abstract Integer getLength(HotSpotObjectConstantImpl arrayObject); - - abstract JavaConstant readArrayElement(HotSpotObjectConstantImpl arrayObject, int index); - - abstract JavaConstant unboxPrimitive(HotSpotObjectConstantImpl source); - - abstract JavaConstant forObject(Object value); - - abstract JavaConstant boxPrimitive(JavaConstant source); - - abstract T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass); - - /** - * Resolves {@code objectHandle} to a raw object if possible. - * - * @throws HotSpotJVMCIUnsupportedOperationError if {@code objectHandle} refers to an object in - * another heap - */ - abstract Object resolveObject(HotSpotObjectConstantImpl objectHandle); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java deleted file mode 100644 index c35f216e624..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java +++ /dev/null @@ -1,1486 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.common.InitTimer.timer; -import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE; - -import java.io.IOException; -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.Serializable; -import java.lang.invoke.CallSite; -import java.lang.invoke.ConstantCallSite; -import java.lang.invoke.MethodHandle; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.WeakReference; -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Formatter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.ServiceLoader; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import jdk.internal.misc.Unsafe; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestResult; -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.UnresolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; -import jdk.vm.ci.runtime.JVMCIBackend; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCICompilerFactory; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.services.Services; - -/** - * HotSpot implementation of a JVMCI runtime. - */ -public final class HotSpotJVMCIRuntime implements JVMCIRuntime { - - /** - * Singleton instance lazily initialized via double-checked locking. - */ - private static volatile HotSpotJVMCIRuntime instance; - - private HotSpotResolvedObjectTypeImpl javaLangObject; - private HotSpotResolvedObjectTypeImpl javaLangInvokeMethodHandle; - private HotSpotResolvedObjectTypeImpl constantCallSiteType; - private HotSpotResolvedObjectTypeImpl callSiteType; - private HotSpotResolvedObjectTypeImpl javaLangString; - private HotSpotResolvedObjectTypeImpl javaLangClass; - private HotSpotResolvedObjectTypeImpl throwableType; - private HotSpotResolvedObjectTypeImpl serializableType; - private HotSpotResolvedObjectTypeImpl cloneableType; - private HotSpotResolvedObjectTypeImpl enumType; - - HotSpotResolvedObjectTypeImpl getJavaLangObject() { - if (javaLangObject == null) { - javaLangObject = (HotSpotResolvedObjectTypeImpl) fromClass(Object.class); - } - return javaLangObject; - } - - HotSpotResolvedObjectTypeImpl getJavaLangString() { - if (javaLangString == null) { - javaLangString = (HotSpotResolvedObjectTypeImpl) fromClass(String.class); - } - return javaLangString; - } - - HotSpotResolvedObjectTypeImpl getJavaLangClass() { - if (javaLangClass == null) { - javaLangClass = (HotSpotResolvedObjectTypeImpl) fromClass(Class.class); - } - return javaLangClass; - } - - HotSpotResolvedObjectTypeImpl getJavaLangCloneable() { - if (cloneableType == null) { - cloneableType = (HotSpotResolvedObjectTypeImpl) fromClass(Cloneable.class); - } - return cloneableType; - } - - HotSpotResolvedObjectTypeImpl getJavaLangSerializable() { - if (serializableType == null) { - serializableType = (HotSpotResolvedObjectTypeImpl) fromClass(Serializable.class); - } - return serializableType; - } - - HotSpotResolvedObjectTypeImpl getJavaLangThrowable() { - if (throwableType == null) { - throwableType = (HotSpotResolvedObjectTypeImpl) fromClass(Throwable.class); - } - return throwableType; - } - - HotSpotResolvedObjectTypeImpl getJavaLangEnum() { - if (enumType == null) { - enumType = (HotSpotResolvedObjectTypeImpl) fromClass(Enum.class); - } - return enumType; - } - - HotSpotResolvedObjectTypeImpl getConstantCallSite() { - if (constantCallSiteType == null) { - constantCallSiteType = (HotSpotResolvedObjectTypeImpl) fromClass(ConstantCallSite.class); - } - return constantCallSiteType; - } - - HotSpotResolvedObjectTypeImpl getCallSite() { - if (callSiteType == null) { - callSiteType = (HotSpotResolvedObjectTypeImpl) fromClass(CallSite.class); - } - return callSiteType; - } - - HotSpotResolvedObjectType getMethodHandleClass() { - if (javaLangInvokeMethodHandle == null) { - javaLangInvokeMethodHandle = (HotSpotResolvedObjectTypeImpl) fromClass(MethodHandle.class); - } - return javaLangInvokeMethodHandle; - } - - /** - * Gets the singleton {@link HotSpotJVMCIRuntime} object. - */ - @VMEntryPoint - @SuppressWarnings("try") - public static HotSpotJVMCIRuntime runtime() { - HotSpotJVMCIRuntime result = instance; - if (result == null) { - // Synchronize on JVMCI.class to avoid deadlock - // between the two JVMCI initialization paths: - // HotSpotJVMCIRuntime.runtime() and JVMCI.getRuntime(). - synchronized (JVMCI.class) { - result = instance; - if (result == null) { - try (InitTimer t = timer("HotSpotJVMCIRuntime.")) { - instance = result = new HotSpotJVMCIRuntime(); - - // Can only do eager initialization of the JVMCI compiler - // once the singleton instance is available. - if (result.config.getFlag("EagerJVMCI", Boolean.class)) { - // EagerJVMCI only applies to JVMCI when used by the CompileBroker. - if (result.getCompilerToVM().isCompilerThread()) { - result.getCompiler(); - } - } - } - // Ensures JVMCIRuntime::_HotSpotJVMCIRuntime_instance is - // initialized. - JVMCI.getRuntime(); - } - } - } - return result; - } - - @VMEntryPoint - static String[] exceptionToString(Throwable o, boolean toString, boolean stackTrace) { - String[] res = {null, null}; - if (toString) { - res[0] = o.toString(); - } - if (stackTrace) { - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - try (PrintStream ps = new PrintStream(buf)) { - o.printStackTrace(ps); - } - res[1] = buf.toString(StandardCharsets.UTF_8); - } - return res; - } - - /** - * Set of recognized {@code "jvmci.*"} system properties. - */ - static final Map options = new HashMap<>(); - - /** - * Sentinel help value to denote options that are not printed by -XX:+JVMCIPrintProperties. - * Javadoc is used instead to document these options. - */ - private static final String[] NO_HELP = null; - - /** - * A list of all supported JVMCI options. - */ - public enum Option { - // @formatter:off - Compiler(String.class, null, - "Selects the system compiler. This must match the getCompilerName() value", - "returned by a jdk.vm.ci.runtime.JVMCICompilerFactory provider. ", - "An empty string or the value \"null\" selects a compiler ", - "that raises an exception upon receiving a compilation request."), - - PrintConfig(Boolean.class, false, "Prints VM values (e.g. flags, constants, field offsets etc) exposed to JVMCI."), - - InitTimer(Boolean.class, false, NO_HELP), - - /** - * Prepends the size and label of each element to the stream when serializing {@link HotSpotCompiledCode} - * to verify both ends of the protocol agree on the format. Defaults to true in non-product builds. - */ - CodeSerializationTypeInfo(Boolean.class, false, NO_HELP), - - /** - * Dumps serialized code during code installation for code whose qualified form (e.g. - * {@code java.lang.String.hashCode()}) contains this option's value as a substring. - */ - DumpSerializedCode(String.class, null, NO_HELP), - - /** - * Forces {@link #translate} to throw an exception in the context of the peer runtime for - * translated objects that match this value. See {@link #postTranslation} for more details. - * This option exists solely to test correct handling of translation failures. - */ - ForceTranslateFailure(String.class, null, NO_HELP), - - /** - * Captures a stack trace along with scoped foreign object reference wrappers - * to debug an issue with a wrapper being used after its scope has closed. - */ - AuditHandles(Boolean.class, false, NO_HELP), - - /** - * Enables tracing of profiling info when read by JVMCI. - * Empty value: trace all methods - * Non-empty value: trace methods whose fully qualified name contains the value - */ - TraceMethodDataFilter(String.class, null, NO_HELP), - - UseProfilingInformation(Boolean.class, true, NO_HELP); - // @formatter:on - - /** - * The prefix for system properties that are JVMCI options. - */ - private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci."; - - /** - * Sentinel for value initialized to {@code null} since {@code null} means uninitialized. - */ - private static final String NULL_VALUE = "NULL"; - - private final Class type; - private Object value; - private final Object defaultValue; - boolean isDefault = true; - private final String[] helpLines; - - Option(Class type, Object defaultValue, String... helpLines) { - assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name(); - this.type = type; - this.defaultValue = defaultValue; - this.helpLines = helpLines; - Object existing = options.put(getPropertyName(), this); - assert existing == null : getPropertyName(); - } - - @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum") - private void init(String propertyValue) { - assert value == null : "cannot re-initialize " + name(); - if (propertyValue == null) { - this.value = defaultValue == null ? NULL_VALUE : defaultValue; - this.isDefault = true; - } else { - if (type == Boolean.class) { - this.value = Boolean.parseBoolean(propertyValue); - } else if (type == String.class) { - this.value = propertyValue; - } else { - throw new JVMCIError("Unexpected option type " + type); - } - this.isDefault = false; - } - } - - @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum") - private Object getValue() { - if (value == NULL_VALUE) { - return null; - } - if (value == null) { - return defaultValue; - } - return value; - } - - /** - * Gets the name of system property from which this option gets its value. - */ - public String getPropertyName() { - return JVMCI_OPTION_PROPERTY_PREFIX + name(); - } - - /** - * Returns the option's value as boolean. - * - * @return option's value - */ - public boolean getBoolean() { - return (boolean) getValue(); - } - - /** - * Returns the option's value as String. - * - * @return option's value - */ - public String getString() { - return (String) getValue(); - } - - private static final int PROPERTY_LINE_WIDTH = 80; - private static final int PROPERTY_HELP_INDENT = 10; - - /** - * Prints a description of the properties used to configure shared JVMCI code. - * - * @param out stream to print to - */ - public static void printProperties(PrintStream out) { - out.println("[JVMCI properties]"); - Option[] values = values(); - for (Option option : values) { - if (option.helpLines == null) { - continue; - } - Object value = option.getValue(); - if (value instanceof String) { - value = '"' + String.valueOf(value) + '"'; - } - - String name = option.getPropertyName(); - String assign = option.isDefault ? "=" : ":="; - String typeName = option.type.getSimpleName(); - String linePrefix = String.format("%s %s %s ", name, assign, value); - int typeStartPos = PROPERTY_LINE_WIDTH - typeName.length(); - int linePad = typeStartPos - linePrefix.length(); - if (linePad > 0) { - out.printf("%s%-" + linePad + "s[%s]%n", linePrefix, "", typeName); - } else { - out.printf("%s[%s]%n", linePrefix, typeName); - } - for (String line : option.helpLines) { - out.printf("%" + PROPERTY_HELP_INDENT + "s%s%n", "", line); - } - out.println(); - } - } - - /** - * Compute string similarity based on Dice's coefficient. - * - * Ported from str_similar() in globals.cpp. - */ - static float stringSimiliarity(String str1, String str2) { - int hit = 0; - for (int i = 0; i < str1.length() - 1; ++i) { - for (int j = 0; j < str2.length() - 1; ++j) { - if ((str1.charAt(i) == str2.charAt(j)) && (str1.charAt(i + 1) == str2.charAt(j + 1))) { - ++hit; - break; - } - } - } - return 2.0f * hit / (str1.length() + str2.length()); - } - - private static final float FUZZY_MATCH_THRESHOLD = 0.7F; - - /** - * Parses all system properties starting with {@value #JVMCI_OPTION_PROPERTY_PREFIX} and - * initializes the options based on their values. - * - * @param runtime - */ - static void parse(HotSpotJVMCIRuntime runtime) { - Map savedProps = jdk.vm.ci.services.Services.getSavedProperties(); - for (Map.Entry e : savedProps.entrySet()) { - String name = e.getKey(); - if (name.startsWith(Option.JVMCI_OPTION_PROPERTY_PREFIX)) { - Object value = options.get(name); - if (value == null) { - List matches = new ArrayList<>(); - for (String pn : options.keySet()) { - float score = stringSimiliarity(pn, name); - if (score >= FUZZY_MATCH_THRESHOLD) { - matches.add(pn); - } - } - Formatter msg = new Formatter(); - msg.format("Error parsing JVMCI options: Could not find option %s", name); - if (!matches.isEmpty()) { - msg.format("%nDid you mean one of the following?"); - for (String match : matches) { - msg.format("%n %s=", match); - } - } - msg.format("%nError: A fatal exception has occurred. Program will exit.%n"); - runtime.exitHotSpotWithMessage(1, msg.toString()); - } else if (value instanceof Option) { - Option option = (Option) value; - option.init(e.getValue()); - } - } - } - } - } - - /** - * The backend factory for the JVMCI shared library. - */ - private static final HotSpotJVMCIBackendFactory backendFactory; - static { - String arch = HotSpotVMConfig.getHostArchitectureName(); - HotSpotJVMCIBackendFactory selected = null; - for (HotSpotJVMCIBackendFactory factory : ServiceLoader.load(HotSpotJVMCIBackendFactory.class)) { - if (factory.getArchitecture().equalsIgnoreCase(arch)) { - if (selected != null) { - throw new JVMCIError("Multiple factories available for %s: %s and %s", - arch, selected, factory); - } - selected = factory; - } - } - if (selected == null) { - throw new JVMCIError("No JVMCI runtime available for the %s architecture", arch); - } - backendFactory = selected; - } - - /** - * Gets the kind of a word value on the {@linkplain #getHostJVMCIBackend() host} backend. - */ - public static JavaKind getHostWordKind() { - return runtime().getHostJVMCIBackend().getCodeCache().getTarget().wordJavaKind; - } - - protected final CompilerToVM compilerToVm; - - protected final HotSpotVMConfigStore configStore; - protected final HotSpotVMConfig config; - private final JVMCIBackend hostBackend; - - private final JVMCICompilerFactory compilerFactory; - private volatile JVMCICompiler compiler; - protected final HotSpotJVMCIReflection reflection; - - private volatile boolean creatingCompiler; - - /** - * Cache for speeding up {@link #fromClass(Class)}. - */ - private volatile ClassValue> resolvedJavaType; - - /** - * To avoid calling ClassValue.remove to refresh the weak reference, which under certain - * circumstances can lead to an infinite loop, we use a permanent holder with a mutable field - * that we refresh. - */ - private static class WeakReferenceHolder { - private volatile WeakReference ref; - - WeakReferenceHolder(T value) { - set(value); - } - - void set(T value) { - ref = new WeakReference<>(value); - } - - T get() { - return ref.get(); - } - } - - - /** - * A weak reference that also tracks the key used to insert the value into {@link #resolvedJavaTypes} so that - * it can be removed when the referent is cleared. - */ - static class KlassWeakReference extends WeakReference { - - private final Long klassPointer; - - public KlassWeakReference(Long klassPointer, HotSpotResolvedObjectTypeImpl referent, ReferenceQueue q) { - super(referent, q); - this.klassPointer = klassPointer; - } - } - - /** - * A mapping from the {@code Klass*} to the corresponding {@link HotSpotResolvedObjectTypeImpl}. The value is - * held weakly through a {@link KlassWeakReference} so that unused types can be unloaded when the compiler no longer needs them. - */ - private HashMap resolvedJavaTypes; - - /** - * A {@link ReferenceQueue} to track when {@link KlassWeakReference}s have been freed so that the corresponding - * entry in {@link #resolvedJavaTypes} can be cleared. - */ - private ReferenceQueue resolvedJavaTypesQueue; - - /** - * Stores the value set by {@link #excludeFromJVMCICompilation(Module...)} so that it can be - * read from the VM. - */ - @SuppressWarnings("unused")// - private Module[] excludeFromJVMCICompilation; - - private final Map, JVMCIBackend> backends = new HashMap<>(); - - private final List vmEventListeners; - - @SuppressWarnings("try") - private HotSpotJVMCIRuntime() { - compilerToVm = new CompilerToVM(); - - try (InitTimer t = timer("HotSpotVMConfig")) { - configStore = new HotSpotVMConfigStore(compilerToVm); - config = new HotSpotVMConfig(configStore); - } - - reflection = IS_IN_NATIVE_IMAGE ? new SharedLibraryJVMCIReflection() : new HotSpotJDKReflection(); - - PrintStream vmLogStream = null; - if (IS_IN_NATIVE_IMAGE) { - // Redirect System.out and System.err to HotSpot's TTY stream - vmLogStream = new PrintStream(getLogStream()); - System.setOut(vmLogStream); - System.setErr(vmLogStream); - } - - // Initialize the Option values. - Option.parse(this); - - try (InitTimer t = timer("create JVMCI backend:", backendFactory.getArchitecture())) { - hostBackend = registerBackend(backendFactory.createJVMCIBackend(this, null)); - } - - compilerFactory = HotSpotJVMCICompilerConfig.getCompilerFactory(this); - if (config.getFlag("JVMCIPrintProperties", Boolean.class)) { - if (vmLogStream == null) { - vmLogStream = new PrintStream(getLogStream()); - } - Option.printProperties(vmLogStream); - compilerFactory.printProperties(vmLogStream); - exitHotSpot(0); - } - - if (Option.PrintConfig.getBoolean()) { - configStore.printConfig(this); - } - - vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class); - } - - /** - * Sets the current thread's {@code JavaThread::_jvmci_reserved_oop} field to {@code value}. - * - * @throws IllegalArgumentException if the {@code JavaThread::_jvmci_reserved_oop} field - * does not exist - */ - public void setThreadLocalObject(int id, Object value) { - compilerToVm.setThreadLocalObject(id, value); - } - - /** - * Get the value of the current thread's {@code JavaThread::_jvmci_reserved_oop} field. - * - * @throws IllegalArgumentException if the {@code JavaThread::_jvmci_reserved_oop} field - * does not exist - */ - public Object getThreadLocalObject(int id) { - return compilerToVm.getThreadLocalObject(id); - } - - /** - * Sets the current thread's {@code JavaThread::_jvmci_reserved} field to {@code value}. - * - * @throws IllegalArgumentException if the {@code JavaThread::_jvmci_reserved} field does - * not exist - */ - public void setThreadLocalLong(int id, long value) { - compilerToVm.setThreadLocalLong(id, value); - } - - /** - * Get the value of the current thread's {@code JavaThread::_jvmci_reserved} field. - * - * @throws IllegalArgumentException if the {@code JavaThread::_jvmci_reserved} field does - * not exist - */ - public long getThreadLocalLong(int id) { - return compilerToVm.getThreadLocalLong(id); - } - - HotSpotResolvedJavaType createClass(Class javaClass) { - if (javaClass.isPrimitive()) { - return HotSpotResolvedPrimitiveType.forKind(JavaKind.fromJavaClass(javaClass)); - } - if (IS_IN_NATIVE_IMAGE) { - return compilerToVm.lookupType(javaClass.getClassLoader(), javaClass.getName().replace('.', '/')); - } - return compilerToVm.lookupClass(javaClass); - } - - private HotSpotResolvedJavaType fromClass0(Class javaClass) { - if (resolvedJavaType == null) { - synchronized (this) { - if (resolvedJavaType == null) { - resolvedJavaType = new ClassValue<>() { - @Override - protected WeakReferenceHolder computeValue(Class type) { - return new WeakReferenceHolder<>(createClass(type)); - } - }; - } - } - } - - WeakReferenceHolder ref = resolvedJavaType.get(javaClass); - HotSpotResolvedJavaType javaType = ref.get(); - if (javaType == null) { - /* - * If the referent has become null, create a new value and update cached weak reference. - */ - javaType = createClass(javaClass); - ref.set(javaType); - } - return javaType; - } - - /** - * Gets the JVMCI mirror for a {@link Class} object. - * - * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} - */ - HotSpotResolvedJavaType fromClass(Class javaClass) { - if (javaClass == null) { - return null; - } - return fromClass0(javaClass); - } - - synchronized HotSpotResolvedObjectTypeImpl fromMetaspace(Long klassPointer) { - if (resolvedJavaTypes == null) { - resolvedJavaTypes = new HashMap<>(); - resolvedJavaTypesQueue = new ReferenceQueue<>(); - } - assert klassPointer != 0; - KlassWeakReference klassReference = resolvedJavaTypes.get(klassPointer); - HotSpotResolvedObjectTypeImpl javaType = null; - if (klassReference != null) { - javaType = klassReference.get(); - } - if (javaType == null) { - String name = compilerToVm.getSignatureName(klassPointer); - javaType = new HotSpotResolvedObjectTypeImpl(klassPointer, name); - resolvedJavaTypes.put(klassPointer, new KlassWeakReference(klassPointer, javaType, resolvedJavaTypesQueue)); - } - expungeStaleKlassEntries(); - return javaType; - } - - - /** - * Clean up WeakReferences whose referents have been cleared. This should be called from a synchronized context. - */ - private void expungeStaleKlassEntries() { - KlassWeakReference current = (KlassWeakReference) resolvedJavaTypesQueue.poll(); - while (current != null) { - // Make sure the entry is still mapped to the weak reference - if (resolvedJavaTypes.get(current.klassPointer) == current) { - resolvedJavaTypes.remove(current.klassPointer); - } - current = (KlassWeakReference) resolvedJavaTypesQueue.poll(); - } - } - - private JVMCIBackend registerBackend(JVMCIBackend backend) { - Class arch = backend.getCodeCache().getTarget().arch.getClass(); - JVMCIBackend oldValue = backends.put(arch, backend); - assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName(); - return backend; - } - - public HotSpotVMConfigStore getConfigStore() { - return configStore; - } - - public HotSpotVMConfig getConfig() { - return config; - } - - public CompilerToVM getCompilerToVM() { - return compilerToVm; - } - - HotSpotJVMCIReflection getReflection() { - return reflection; - } - - /** - * Gets a predicate that determines if a given type can be considered trusted for the purpose of - * intrinsifying methods it declares. - * - * @param compilerLeafClasses classes in the leaves of the module graph comprising the JVMCI - * compiler. - */ - public Predicate getIntrinsificationTrustPredicate(Class... compilerLeafClasses) { - return new Predicate<>() { - @Override - public boolean test(ResolvedJavaType type) { - if (type instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl hsType = (HotSpotResolvedObjectTypeImpl) type; - return compilerToVm.isTrustedForIntrinsics(hsType); - } else { - return false; - } - } - }; - } - - /** - * Gets the {@link Class} corresponding to {@code type}. - * - * @param type the type for which a {@link Class} is requested - * @return the original Java class corresponding to {@code type} or {@code null} if this runtime - * does not support mapping {@link ResolvedJavaType} instances to {@link Class} - * instances - */ - public Class getMirror(ResolvedJavaType type) { - if (type instanceof HotSpotResolvedJavaType hType && reflection instanceof HotSpotJDKReflection) { - return ((HotSpotJDKReflection) reflection).getMirror(hType); - } - return null; - } - - /** - * Gets the {@link Executable} corresponding to {@code method}. - * - * @param method the method for which an {@link Executable} is requested - * @return the original Java method or constructor corresponding to {@code method} or - * {@code null} if this runtime does not support mapping {@link ResolvedJavaMethod} - * instances to {@link Executable} instances - */ - public Executable getMirror(ResolvedJavaMethod method) { - if (!method.isClassInitializer() && method instanceof HotSpotResolvedJavaMethodImpl hMethod && reflection instanceof HotSpotJDKReflection) { - return HotSpotJDKReflection.getMethod(hMethod); - } - return null; - } - - /** - * Gets the {@link Field} corresponding to {@code field}. - * - * @param field the field for which a {@link Field} is requested - * @return the original Java field corresponding to {@code field} or {@code null} if this - * runtime does not support mapping {@link ResolvedJavaField} instances to {@link Field} - * instances - */ - public Field getMirror(ResolvedJavaField field) { - if (!field.isInternal() && field instanceof HotSpotResolvedJavaFieldImpl hField && reflection instanceof HotSpotJDKReflection) { - return HotSpotJDKReflection.getField(hField); - } - return null; - } - - static class ErrorCreatingCompiler implements JVMCICompiler { - private final RuntimeException t; - - ErrorCreatingCompiler(RuntimeException t) { - this.t = t; - } - - @Override - public CompilationRequestResult compileMethod(CompilationRequest request) { - throw t; - } - - @Override - public boolean isGCSupported(int gcIdentifier) { - return false; - } - } - - @Override - public JVMCICompiler getCompiler() { - if (compiler == null) { - synchronized (this) { - if (compiler == null) { - assert !creatingCompiler : "recursive compiler creation"; - creatingCompiler = true; - try { - compiler = compilerFactory.createCompiler(this); - } catch (RuntimeException t) { - compiler = new ErrorCreatingCompiler(t); - } finally { - creatingCompiler = false; - } - } - } - } - if (compiler instanceof ErrorCreatingCompiler) { - throw ((ErrorCreatingCompiler) compiler).t; - } - return compiler; - } - - /** - * Converts a name to a Java type. This method attempts to resolve {@code name} to a - * {@link ResolvedJavaType}. - * - * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format - * @param accessingType the context of resolution which must be non-null - * @param resolve specifies whether resolution failure results in an unresolved type being - * return or a {@link LinkageError} being thrown - * @return a Java type for {@code name} which is guaranteed to be of type - * {@link ResolvedJavaType} if {@code resolve == true} - * @throws LinkageError if {@code resolve == true} and the resolution failed - * @throws NullPointerException if {@code accessingClass} is {@code null} - */ - public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { - Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class"); - return lookupTypeInternal(name, accessingType, resolve); - } - - /** - * Converts a HotSpot heap JNI {@code hotspot_jclass_value} to a {@link ResolvedJavaType}, - * provided that the {@code hotspot_jclass_value} is a valid JNI reference to a Java Class. If - * this requirement is not met, {@link IllegalArgumentException} is thrown. - * - * @param hotspot_jclass_value a JNI reference to a {@link Class} value in the HotSpot heap - * @return a {@link ResolvedJavaType} for the referenced type - * @throws IllegalArgumentException if {@code hotspot_jclass_value} is not a valid JNI reference - * to a {@link Class} object in the HotSpot heap. It is the responsibility of the - * caller to make sure the argument is valid. The checks performed by this method - * are best effort. Hence, the caller must not rely on the checks and corresponding - * exceptions! - */ - public HotSpotResolvedJavaType asResolvedJavaType(long hotspot_jclass_value) { - if (hotspot_jclass_value == 0L) { - return null; - } - return compilerToVm.lookupJClass(hotspot_jclass_value); - } - - JavaType lookupTypeInternal(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { - // If the name represents a primitive type we can short-circuit the lookup. - if (name.length() == 1) { - JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return HotSpotResolvedPrimitiveType.forKind(kind); - } - - // Resolve non-primitive types in the VM. - HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType; - final HotSpotResolvedJavaType klass = compilerToVm.lookupType(name, hsAccessingType, resolve); - - if (klass == null) { - assert resolve == false : name; - return UnresolvedJavaType.create(name); - } - return klass; - } - - /** - * Gets the {@code jobject} value wrapped by {@code peerObject}. The returned value is - * a JNI local reference whose lifetime is scoped by the nearest Java caller (from - * HotSpot's perspective). You can use {@code PushLocalFrame} and {@code PopLocalFrame} to - * shorten the lifetime of the reference. The current thread's state must be - * {@code _thread_in_native}. A call from the JVMCI shared library (e.g. libgraal) is in such - * a state. - * - * @param peerObject a reference to an object in the HotSpot heap - * @return the {@code jobject} value unpacked from {@code peerObject} - * @throws IllegalArgumentException if the current runtime is not the JVMCI shared library or - * {@code peerObject} is not a HotSpot heap object reference - * @throws IllegalStateException if not called from within the JVMCI shared library - * or if there is no Java caller frame on the stack - * (i.e., JavaThread::has_last_Java_frame returns false) - */ - public long getJObjectValue(HotSpotObjectConstant peerObject) { - return compilerToVm.getJObjectValue((HotSpotObjectConstantImpl)peerObject); - } - - @Override - public JVMCIBackend getHostJVMCIBackend() { - return hostBackend; - } - - @Override - public JVMCIBackend getJVMCIBackend(Class arch) { - assert arch != Architecture.class; - return backends.get(arch); - } - - public Map, JVMCIBackend> getJVMCIBackends() { - return Collections.unmodifiableMap(backends); - } - - @VMEntryPoint - private HotSpotCompilationRequestResult compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long compileState, int id) { - HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, compileState, id); - CompilationRequestResult result = getCompiler().compileMethod(request); - assert result != null : "compileMethod must always return something"; - HotSpotCompilationRequestResult hsResult; - if (result instanceof HotSpotCompilationRequestResult) { - hsResult = (HotSpotCompilationRequestResult) result; - } else { - Object failure = result.getFailure(); - if (failure != null) { - boolean retry = false; // Be conservative with unknown compiler - hsResult = HotSpotCompilationRequestResult.failure(failure.toString(), retry); - } else { - int inlinedBytecodes = -1; - hsResult = HotSpotCompilationRequestResult.success(inlinedBytecodes); - } - } - return hsResult; - } - - @VMEntryPoint - private boolean isGCSupported(int gcIdentifier) { - return getCompiler().isGCSupported(gcIdentifier); - } - - @VMEntryPoint - private boolean isIntrinsicSupported(int intrinsicIdentifier) { - return getCompiler().isIntrinsicSupported(intrinsicIdentifier); - } - - /** - * Guard to ensure shut down actions are performed by at most one thread. - */ - private final AtomicBoolean isShutdown = new AtomicBoolean(); - - /** - * Shuts down the runtime. - */ - @VMEntryPoint - private void shutdown() throws Exception { - if (isShutdown.compareAndSet(false, true)) { - // Cleaners are normally only processed when a new Cleaner is - // instantiated so process all remaining cleaners now. - Cleaner.clean(); - - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - vmEventListener.notifyShutdown(); - } - } - } - - /** - * Notify on completion of a bootstrap. - */ - @VMEntryPoint - private void bootstrapFinished() throws Exception { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - vmEventListener.notifyBootstrapFinished(); - } - } - - /** - * Notify on successful install into the CodeCache. - * - * @param hotSpotCodeCacheProvider - * @param installedCode - * @param compiledCode - */ - void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - for (HotSpotVMEventListener vmEventListener : vmEventListeners) { - vmEventListener.notifyInstall(hotSpotCodeCacheProvider, installedCode, compiledCode); - } - } - - /** - * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to HotSpot's - * log stream. - * - * @param flush specifies if the log stream should be flushed after writing - * @param canThrow specifies if an error in the {@code bytes}, {@code offset} or {@code length} - * arguments should result in an exception or a negative return value. If - * {@code false}, this call will not perform any heap allocation - * @return 0 on success, -1 if {@code bytes == null && !canThrow}, -2 if {@code !canThrow} and - * copying would cause access of data outside array bounds - * @throws NullPointerException if {@code bytes == null} - * @throws IndexOutOfBoundsException if copying would cause access of data outside array bounds - */ - public int writeDebugOutput(byte[] bytes, int offset, int length, boolean flush, boolean canThrow) { - return writeDebugOutput0(compilerToVm, bytes, offset, length, flush, canThrow); - } - - /** - * @see #writeDebugOutput - */ - static int writeDebugOutput0(CompilerToVM vm, byte[] bytes, int offset, int length, boolean flush, boolean canThrow) { - if (bytes == null) { - if (!canThrow) { - return -1; - } - throw new NullPointerException(); - } - if (offset < 0 || length < 0 || offset + length > bytes.length) { - if (!canThrow) { - return -2; - } - throw new ArrayIndexOutOfBoundsException(); - } - if (length <= 8) { - ByteBuffer buffer = ByteBuffer.wrap(bytes, offset, length); - if (length != 8) { - ByteBuffer buffer8 = ByteBuffer.allocate(8); - buffer8.put(buffer); - buffer8.position(8); - buffer = buffer8; - } - buffer.order(ByteOrder.nativeOrder()); - vm.writeDebugOutput(buffer.getLong(0), length, flush); - } else { - Unsafe unsafe = UnsafeAccess.UNSAFE; - long buffer = unsafe.allocateMemory(length); - try { - unsafe.copyMemory(bytes, Unsafe.ARRAY_BYTE_BASE_OFFSET, null, buffer, length); - vm.writeDebugOutput(buffer, length, flush); - } finally { - unsafe.freeMemory(buffer); - } - } - return 0; - } - - /** - * Gets an output stream that writes to HotSpot's {@code tty} stream. - */ - public OutputStream getLogStream() { - return new OutputStream() { - - @Override - public void write(byte[] b, int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || off > b.length || len < 0 || (off + len) > b.length || (off + len) < 0) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return; - } - writeDebugOutput(b, off, len, false, true); - } - - @Override - public void write(int b) throws IOException { - write(new byte[]{(byte) b}, 0, 1); - } - - @Override - public void flush() throws IOException { - compilerToVm.flushDebugOutput(); - } - }; - } - - /** - * Collects the current values of all JVMCI benchmark counters, summed up over all threads. - */ - public long[] collectCounters() { - return compilerToVm.collectCounters(); - } - - /** - * @return the current number of per thread counters. May be set through - * {@code -XX:JVMCICompilerSize=} command line option or the - * {@link #setCountersSize(int)} call. - */ - public int getCountersSize() { - return compilerToVm.getCountersSize(); - } - - /** - * Attempt to enlarge the number of per thread counters available. Requires a safepoint so - * resizing should be rare to avoid performance effects. - * - * @param newSize - * @return false if the resizing failed - */ - public boolean setCountersSize(int newSize) { - return compilerToVm.setCountersSize(newSize); - } - - /** - * The offset from the origin of an array to the first element. - * - * @return the offset in bytes - */ - public int getArrayBaseOffset(JavaKind kind) { - switch (kind) { - case Boolean: - return compilerToVm.ARRAY_BOOLEAN_BASE_OFFSET; - case Byte: - return compilerToVm.ARRAY_BYTE_BASE_OFFSET; - case Char: - return compilerToVm.ARRAY_CHAR_BASE_OFFSET; - case Short: - return compilerToVm.ARRAY_SHORT_BASE_OFFSET; - case Int: - return compilerToVm.ARRAY_INT_BASE_OFFSET; - case Long: - return compilerToVm.ARRAY_LONG_BASE_OFFSET; - case Float: - return compilerToVm.ARRAY_FLOAT_BASE_OFFSET; - case Double: - return compilerToVm.ARRAY_DOUBLE_BASE_OFFSET; - case Object: - return compilerToVm.ARRAY_OBJECT_BASE_OFFSET; - default: - throw new JVMCIError("%s", kind); - } - - } - - /** - * The scale used for the index when accessing elements of an array of this kind. - * - * @return the scale in order to convert the index into a byte offset - */ - public int getArrayIndexScale(JavaKind kind) { - switch (kind) { - case Boolean: - return compilerToVm.ARRAY_BOOLEAN_INDEX_SCALE; - case Byte: - return compilerToVm.ARRAY_BYTE_INDEX_SCALE; - case Char: - return compilerToVm.ARRAY_CHAR_INDEX_SCALE; - case Short: - return compilerToVm.ARRAY_SHORT_INDEX_SCALE; - case Int: - return compilerToVm.ARRAY_INT_INDEX_SCALE; - case Long: - return compilerToVm.ARRAY_LONG_INDEX_SCALE; - case Float: - return compilerToVm.ARRAY_FLOAT_INDEX_SCALE; - case Double: - return compilerToVm.ARRAY_DOUBLE_INDEX_SCALE; - case Object: - return compilerToVm.ARRAY_OBJECT_INDEX_SCALE; - default: - throw new JVMCIError("%s", kind); - - } - } - - /** - * Links each native method in {@code clazz} to an implementation in the JVMCI shared library. - *

- * A use case for this is a JVMCI compiler implementation that offers an API to Java code - * executing in HotSpot to exercise functionality (mostly) in the JVMCI shared library. For - * example: - * - *

-     * package com.jcompile;
-     *
-     * import java.lang.reflect.Method;
-     *
-     * public static class JCompile {
-     *     static {
-     *         HotSpotJVMCIRuntime.runtime().registerNativeMethods(JCompile.class);
-     *     }
-     *     public static boolean compile(Method method, String[] options) {
-     *         // Convert to simpler data types for passing/serializing across native interface
-     *         long metaspaceMethodHandle = getHandle(method);
-     *         char[] opts = convertToCharArray(options);
-     *         return compile(metaspaceMethodHandle, opts);
-     *     }
-     *     private static native boolean compile0(long metaspaceMethodHandle, char[] options);
-     *
-     *     private static long getHandle(Method method) { ... }
-     *     private static char[] convertToCharArray(String[] a) { ... }
-     * }
-     * 
- * - * The implementation of the native {@code JCompile.compile0} method would be in the JVMCI - * shared library that contains the JVMCI compiler. The {@code JCompile.compile0} implementation - * must be exported as the following JNI-compatible symbol: - * - *
-     * Java_com_jcompile_JCompile_compile0
-     * 
- * - * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#resolving_native_method_names" - * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#creating_the_vm" - * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#invocation_api_functions" - * - * - * @return info about the Java VM in the JVMCI shared library {@code JavaVM*}. The info is - * encoded in a long array as follows: - * - *
-     *     long[] info = {
-     *         javaVM, // the {@code JavaVM*} value
-     *         javaVM->functions->reserved0,
-     *         javaVM->functions->reserved1,
-     *         javaVM->functions->reserved2
-     *     }
-     *         
- * - * @throws NullPointerException if {@code clazz == null} - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws IllegalStateException if the current execution context is the JVMCI shared library - * @throws IllegalArgumentException if {@code clazz} is {@link Class#isPrimitive()} - * @throws UnsatisfiedLinkError if there's a problem linking a native method in {@code clazz} - * (no matching JNI symbol or the native method is already linked to a different - * address) - */ - public long[] registerNativeMethods(Class clazz) { - return compilerToVm.registerNativeMethods(clazz); - } - - /** - * Creates or retrieves an object in the peer runtime that mirrors {@code obj}. The types whose - * objects can be translated are: - *
    - *
  • {@link HotSpotResolvedJavaMethodImpl},
  • - *
  • {@link HotSpotResolvedObjectTypeImpl},
  • - *
  • {@link HotSpotResolvedPrimitiveType},
  • - *
  • {@link IndirectHotSpotObjectConstantImpl},
  • - *
  • {@link DirectHotSpotObjectConstantImpl} and
  • - *
  • {@link HotSpotNmethod}
  • - *
- * - * This mechanism can be used to pass and return values between the HotSpot and JVMCI shared - * library runtimes. In the receiving runtime, the value can be converted back to an object with - * {@link #unhand(Class, long)}. - * - * @param obj an object for which an equivalent instance in the peer runtime is requested - * @return a JNI global reference to the mirror of {@code obj} in the peer runtime - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws IllegalArgumentException if {@code obj} is not of a translatable type - * - * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references" - */ - public long translate(Object obj) { - return compilerToVm.translate(obj, Option.ForceTranslateFailure.getString() != null); - } - - private static final Pattern FORCE_TRANSLATE_FAILURE_FILTER_RE = Pattern.compile("(?:(method|type|nmethod)/)?([^:]+)(?::(hotspot|native))?"); - - /** - * Forces translation failure based on {@code translatedObject} and the value of - * {@link Option#ForceTranslateFailure}. The value is zero or more filters separated by a comma. - * The syntax for a filter is: - * - *
-     *   Filter = [ TypeSelector "/" ] Substring [ ":" JVMCIEnvSelector ] .
-     *   TypeSelector = "type" | "method" | "nmethod"
-     *   JVMCIEnvSelector = "native" | "hotspot"
-     * 
- * - * For example: - * - *
-     *   -Djvmci.ForceTranslateFailure=nmethod/StackOverflowError:native,method/computeHash,execute
-     * 
- * - * will cause failure of: - *
    - *
  • translating a {@link HotSpotNmethod} to the libjvmci heap whose fully qualified name - * contains "StackOverflowError"
  • - *
  • translating a {@link HotSpotResolvedJavaMethodImpl} to the libjvmci or HotSpot heap whose - * fully qualified name contains "computeHash"
  • - *
  • translating a {@link HotSpotNmethod}, {@link HotSpotResolvedJavaMethodImpl} or - * {@link HotSpotResolvedObjectTypeImpl} to the libjvmci or HotSpot heap whose fully qualified - * name contains "execute"
  • - *
- */ - @VMEntryPoint - static void postTranslation(Object translatedObject) { - String value = Option.ForceTranslateFailure.getString(); - String toMatch; - String type; - if (translatedObject instanceof HotSpotResolvedJavaMethodImpl) { - toMatch = ((HotSpotResolvedJavaMethodImpl) translatedObject).format("%H.%n"); - type = "method"; - } else if (translatedObject instanceof HotSpotResolvedObjectTypeImpl) { - toMatch = ((HotSpotResolvedObjectTypeImpl) translatedObject).toJavaName(); - type = "type"; - } else if (translatedObject instanceof HotSpotNmethod) { - HotSpotNmethod nmethod = (HotSpotNmethod) translatedObject; - if (nmethod.getMethod() != null) { - toMatch = nmethod.getMethod().format("%H.%n"); - } else { - toMatch = String.valueOf(nmethod.getName()); - } - type = "nmethod"; - } else { - return; - } - String[] filters = value.split(","); - for (String filter : filters) { - Matcher m = FORCE_TRANSLATE_FAILURE_FILTER_RE.matcher(filter); - if (!m.matches()) { - throw new IllegalArgumentException(Option.ForceTranslateFailure + " filter does not match " + FORCE_TRANSLATE_FAILURE_FILTER_RE + ": " + filter); - } - String typeSelector = m.group(1); - String substring = m.group(2); - String jvmciEnvSelector = m.group(3); - if (jvmciEnvSelector != null) { - if (jvmciEnvSelector.equals("native")) { - if (!Services.IS_IN_NATIVE_IMAGE) { - continue; - } - } else { - if (Services.IS_IN_NATIVE_IMAGE) { - continue; - } - } - } - if (typeSelector != null && !typeSelector.equals(type)) { - continue; - } - if (toMatch.contains(substring)) { - throw new RuntimeException("translation of " + translatedObject + " failed due to matching " + Option.ForceTranslateFailure + " filter \"" + filter + "\""); - } - } - } - - /** - * Dereferences and returns the object referred to by the JNI global reference {@code handle}. - * The global reference is deleted prior to returning. Any further use of {@code handle} is - * invalid. - * - * @param handle a JNI global reference to an object in the current runtime - * @return the object referred to by {@code handle} - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws ClassCastException if the returned object cannot be cast to {@code type} - * - * @see "https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/design.html#global_and_local_references" - * - */ - public T unhand(Class type, long handle) { - return type.cast(compilerToVm.unhand(handle)); - } - - /** - * Determines if the current thread is attached to the peer runtime. - * - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws IllegalStateException if the peer runtime has not been initialized - */ - public boolean isCurrentThreadAttached() { - return compilerToVm.isCurrentThreadAttached(); - } - - /** - * Gets the address of the HotSpot {@code JavaThread} C++ object for the current thread. This - * will return {@code 0} if called from an unattached JVMCI shared library thread. - */ - public long getCurrentJavaThread() { - return compilerToVm.getCurrentJavaThread(); - } - - /** - * Ensures the current thread is attached to the peer runtime. - * - * @param asDaemon if the thread is not yet attached, should it be attached as a daemon - * @param javaVMInfo if non-null, the JavaVM info as returned by {@link #registerNativeMethods} - * is returned in this array - * @return {@code true} if this call attached the current thread, {@code false} if the current - * thread was already attached - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws IllegalStateException if the peer runtime has not been initialized or there is an - * error while trying to attach the thread - * @throws ArrayIndexOutOfBoundsException if {@code javaVMInfo} is non-null and is shorter than - * the length of the array returned by {@link #registerNativeMethods} - */ - public boolean attachCurrentThread(boolean asDaemon, long[] javaVMInfo) { - byte[] name = IS_IN_NATIVE_IMAGE ? Thread.currentThread().getName().getBytes() : null; - return compilerToVm.attachCurrentThread(name, asDaemon, javaVMInfo); - } - - /** - * Detaches the current thread from the peer runtime. - * - * @param release if {@code true} and this is the last thread attached to the peer runtime, the - * {@code JavaVM} associated with the peer runtime is destroyed if possible - * @return {@code true} if the {@code JavaVM} associated with the peer runtime was destroyed as - * a result of this call - * @throws UnsupportedOperationException if the JVMCI shared library is not enabled (i.e. - * {@code -XX:-UseJVMCINativeLibrary}) - * @throws IllegalStateException if the peer runtime has not been initialized or if the current - * thread is not attached or if there is an error while trying to detach the thread - */ - public boolean detachCurrentThread(boolean release) { - return compilerToVm.detachCurrentThread(release); - } - - /** - * Informs HotSpot that no method whose module is in {@code modules} is to be compiled with - * {@link #compileMethod}. - * - * @param modules the set of modules containing JVMCI compiler classes - */ - public void excludeFromJVMCICompilation(Module... modules) { - this.excludeFromJVMCICompilation = modules.clone(); - } - - /** - * Calls {@link System#exit(int)} in HotSpot's runtime. - */ - public void exitHotSpot(int status) { - if (!IS_IN_NATIVE_IMAGE) { - System.exit(status); - } - compilerToVm.callSystemExit(status); - } - - /** - * Writes a message to HotSpot's log stream and then calls {@link System#exit(int)} in HotSpot's - * runtime. - */ - JVMCIError exitHotSpotWithMessage(int status, String format, Object... args) { - byte[] messageBytes = String.format(format, args).getBytes(); - writeDebugOutput(messageBytes, 0, messageBytes.length, true, true); - exitHotSpot(status); - throw JVMCIError.shouldNotReachHere(); - } - - /** - * Returns HotSpot's {@code CompileBroker} compilation activity mode which is one of: - * {@code stop_compilation = 0}, {@code run_compilation = 1} or {@code shutdown_compilation = 2} - */ - public int getCompilationActivityMode() { - return compilerToVm.getCompilationActivityMode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIUnsupportedOperationError.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIUnsupportedOperationError.java deleted file mode 100644 index 0715220cfcb..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIUnsupportedOperationError.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.services.Services; - -/** - * Indicates a path in HotSpot JVMCI related code that is unsupported in the current execution - * environment. For example, certain operations are not supported by JVMCI code running in an ahead - * of time compiled {@linkplain Services#IS_IN_NATIVE_IMAGE native image}. This usually reflects - * functionality only needed in non-native image execution that would require a more complex - * implementation to support in a native image. - * - * An example of such functionality is {@link ResolvedJavaType#isLocal()}. This can be conveniently - * implemented when JVMCI is running on the HotSpot heap as we can obtain the {@link Class} mirror - * for the {@link ResolvedJavaType} and call {@link Class#isLocalClass()}. In a native image, there - * is no {@link Class} mirror available in the native image heap so implementing this would involve - * a call into VM native code that in turn would make an upcall into Java code executing on the - * HotSpot heap. We have opted to defer implementing functionality such as this until there's a - * demonstrated need for it. - */ -public class HotSpotJVMCIUnsupportedOperationError extends Error { - - public HotSpotJVMCIUnsupportedOperationError(String reason) { - super(reason); - } - - public HotSpotJVMCIUnsupportedOperationError(String reason, Throwable cause) { - super(reason, cause); - } - - private static final long serialVersionUID = 7782431672678016392L; - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJavaType.java deleted file mode 100644 index d8fcb61079c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJavaType.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaType; - -/** - * Common base class for all HotSpot {@link JavaType} implementations. - */ -public abstract class HotSpotJavaType implements JavaType { - - private final String name; - - public HotSpotJavaType(String name) { - this.name = name; - } - - @Override - public String getName() { - return name; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java deleted file mode 100644 index 15250e2c7d1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MemoryAccessProvider; - -/** - * HotSpot specific extension of {@link MemoryAccessProvider}. - */ -public interface HotSpotMemoryAccessProvider extends MemoryAccessProvider { - - /** - * @throws IllegalArgumentException if the address computed from {@code base} and - * {@code displacement} does not denote a location holding a narrow oop - */ - JavaConstant readNarrowOopConstant(Constant base, long displacement); - - Constant readKlassPointerConstant(Constant base, long displacement); - - Constant readNarrowKlassPointerConstant(Constant base, long displacement); - - Constant readMethodPointerConstant(Constant base, long displacement); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java deleted file mode 100644 index f22749edccc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.meta.PrimitiveConstant; - -/** - * HotSpot implementation of {@link MemoryAccessProvider}. - */ -class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider { - - protected final HotSpotJVMCIRuntime runtime; - - HotSpotMemoryAccessProviderImpl(HotSpotJVMCIRuntime runtime) { - this.runtime = runtime; - } - - private static long asRawPointer(Constant base) { - if (base instanceof HotSpotMetaspaceConstantImpl) { - MetaspaceObject meta = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - return meta.getMetaspacePointer(); - } else if (base instanceof PrimitiveConstant) { - PrimitiveConstant prim = (PrimitiveConstant) base; - if (prim.getJavaKind().isNumericInteger()) { - return prim.asLong(); - } - } - throw new IllegalArgumentException(String.valueOf(base)); - } - - @Override - public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) { - if (baseConstant instanceof HotSpotObjectConstantImpl) { - JavaKind readKind = kind; - if (kind.getBitCount() != bits) { - switch (bits) { - case Byte.SIZE: - readKind = JavaKind.Byte; - break; - case Short.SIZE: - readKind = JavaKind.Short; - break; - case Integer.SIZE: - readKind = JavaKind.Int; - break; - case Long.SIZE: - readKind = JavaKind.Long; - break; - default: - throw new IllegalArgumentException(String.valueOf(bits)); - } - } - HotSpotObjectConstantImpl baseObject = (HotSpotObjectConstantImpl) baseConstant; - JavaConstant result = runtime().compilerToVm.readFieldValue(baseObject, null, initialDisplacement, readKind.getTypeChar()); - if (result != null && kind != readKind) { - return JavaConstant.forPrimitive(kind, result.asLong()); - } - return result; - } else { - long pointer = asRawPointer(baseConstant); - long value; - switch (bits) { - case Byte.SIZE: - value = UNSAFE.getByte(pointer + initialDisplacement); - break; - case Short.SIZE: - value = UNSAFE.getShort(pointer + initialDisplacement); - break; - case Integer.SIZE: - value = UNSAFE.getInt(pointer + initialDisplacement); - break; - case Long.SIZE: - value = UNSAFE.getLong(pointer + initialDisplacement); - break; - default: - throw new IllegalArgumentException(String.valueOf(bits)); - } - return JavaConstant.forPrimitive(kind, value); - } - } - - @Override - public JavaConstant readObjectConstant(Constant base, long displacement) { - if (base instanceof HotSpotObjectConstantImpl) { - HotSpotObjectConstantImpl hsBase = (HotSpotObjectConstantImpl) base; - return runtime.getCompilerToVM().readFieldValue(hsBase, null, displacement, JavaKind.Object.getTypeChar()); - } - if (base instanceof HotSpotMetaspaceConstant) { - MetaspaceObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); - if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl type = (HotSpotResolvedObjectTypeImpl) metaspaceObject; - if (displacement == runtime.getConfig().javaMirrorOffset) { - // Klass::_java_mirror is valid for all Klass* values - return type.getJavaMirror(); - } - return null; - } else { - throw new IllegalArgumentException(String.valueOf(metaspaceObject)); - } - } - return null; - } - - @Override - public JavaConstant readNarrowOopConstant(Constant base, long displacement) { - if (base instanceof HotSpotObjectConstantImpl) { - assert runtime.getConfig().useCompressedOops; - HotSpotObjectConstantImpl hsBase = (HotSpotObjectConstantImpl) base; - JavaConstant res = runtime.getCompilerToVM().readFieldValue(hsBase, null, displacement, JavaKind.Object.getTypeChar()); - if (res != null) { - return JavaConstant.NULL_POINTER.equals(res) ? HotSpotCompressedNullConstant.COMPRESSED_NULL : ((HotSpotObjectConstant) res).compress(); - } - } - return null; - } - - private HotSpotResolvedObjectTypeImpl readKlass(Constant base, long displacement, boolean compressed) { - assert (base instanceof HotSpotMetaspaceConstantImpl) || (base instanceof HotSpotObjectConstantImpl) : base.getClass(); - if (base instanceof HotSpotMetaspaceConstantImpl) { - return runtime.getCompilerToVM().getResolvedJavaType((HotSpotResolvedObjectTypeImpl) ((HotSpotMetaspaceConstantImpl) base).asResolvedJavaType(), displacement, compressed); - } else { - return runtime.getCompilerToVM().getResolvedJavaType(((HotSpotObjectConstantImpl) base), displacement, compressed); - } - } - - @Override - public Constant readKlassPointerConstant(Constant base, long displacement) { - HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, false); - if (klass == null) { - return JavaConstant.NULL_POINTER; - } - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, false); - } - - @Override - public Constant readNarrowKlassPointerConstant(Constant base, long displacement) { - HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, true); - if (klass == null) { - return HotSpotCompressedNullConstant.COMPRESSED_NULL; - } - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, true); - } - - @Override - public Constant readMethodPointerConstant(Constant base, long displacement) { - assert (base instanceof HotSpotObjectConstantImpl); - HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod((HotSpotObjectConstantImpl) base, displacement); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java deleted file mode 100644 index 0bc6fce0ce2..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Objects; - -import jdk.vm.ci.code.CodeUtil; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.DeoptimizationAction; -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.SpeculationLog.NoSpeculationReason; -import jdk.vm.ci.meta.SpeculationLog.Speculation; - -// JaCoCo Exclude - -/** - * HotSpot implementation of {@link MetaAccessProvider}. - */ -public class HotSpotMetaAccessProvider implements MetaAccessProvider { - - protected final HotSpotJVMCIRuntime runtime; - - public HotSpotMetaAccessProvider(HotSpotJVMCIRuntime runtime) { - this.runtime = runtime; - } - - @Override - public ResolvedJavaType lookupJavaType(Class clazz) { - if (clazz == null) { - throw new IllegalArgumentException("Class parameter was null"); - } - return runtime.fromClass(clazz); - } - - @Override - public HotSpotResolvedObjectType lookupJavaType(JavaConstant constant) { - if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) { - return null; - } - return ((HotSpotObjectConstant) constant).getType(); - } - - @Override - public Signature parseMethodDescriptor(String signature) { - return new HotSpotSignature(runtime, signature); - } - - @Override - public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { - return runtime.getCompilerToVM().asResolvedJavaMethod(Objects.requireNonNull(reflectionMethod)); - } - - @Override - public ResolvedJavaField lookupJavaField(Field reflectionField) { - Class fieldHolder = reflectionField.getDeclaringClass(); - - HotSpotResolvedJavaType holder = runtime.fromClass(fieldHolder); - assert holder != null : fieldHolder; - ResolvedJavaField[] fields; - if (Modifier.isStatic(reflectionField.getModifiers())) { - fields = holder.getStaticFields(); - } else { - fields = holder.getInstanceFields(false); - } - ResolvedJavaType fieldType = lookupJavaType(reflectionField.getType()); - for (ResolvedJavaField field : fields) { - if (reflectionField.getName().equals(field.getName()) && field.getType().equals(fieldType)) { - assert Modifier.isStatic(reflectionField.getModifiers()) == field.isStatic(); - return field; - } - } - - throw new JVMCIError("unresolved field %s", reflectionField); - } - - private static int intMaskRight(int n) { - assert n <= 32; - return n == 32 ? -1 : (1 << n) - 1; - } - - @Override - public JavaConstant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId) { - HotSpotVMConfig config = runtime.getConfig(); - int actionValue = convertDeoptAction(action); - int reasonValue = convertDeoptReason(reason); - int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits); - JavaConstant c = JavaConstant.forInt( - ~((debugValue << config.deoptimizationDebugIdShift) | (reasonValue << config.deoptimizationReasonShift) | (actionValue << config.deoptimizationActionShift))); - assert c.asInt() < 0; - return c; - } - - @Override - public DeoptimizationReason decodeDeoptReason(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - int reasonValue = ((~constant.asInt()) >> config.deoptimizationReasonShift) & intMaskRight(config.deoptimizationReasonBits); - DeoptimizationReason reason = convertDeoptReason(reasonValue); - return reason; - } - - @Override - public DeoptimizationAction decodeDeoptAction(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - int actionValue = ((~constant.asInt()) >> config.deoptimizationActionShift) & intMaskRight(config.deoptimizationActionBits); - DeoptimizationAction action = convertDeoptAction(actionValue); - return action; - } - - @Override - public int decodeDebugId(JavaConstant constant) { - HotSpotVMConfig config = runtime.getConfig(); - return ((~constant.asInt()) >> config.deoptimizationDebugIdShift) & intMaskRight(config.deoptimizationDebugIdBits); - } - - @Override - public JavaConstant encodeSpeculation(Speculation speculation) { - if (speculation.getReason() instanceof NoSpeculationReason) { - return JavaConstant.LONG_0; - } - return ((HotSpotSpeculationLog.HotSpotSpeculation) speculation).getEncoding(); - } - - @Override - public Speculation decodeSpeculation(JavaConstant constant, SpeculationLog speculationLog) { - if (constant.equals(JavaConstant.LONG_0)) { - return SpeculationLog.NO_SPECULATION; - } - if (speculationLog == null) { - throw new IllegalArgumentException("A speculation log is required to decode the speculation denoted by " + constant); - } - return speculationLog.lookupSpeculation(constant); - } - - public int convertDeoptAction(DeoptimizationAction action) { - HotSpotVMConfig config = runtime.getConfig(); - switch (action) { - case None: - return config.deoptActionNone; - case RecompileIfTooManyDeopts: - return config.deoptActionMaybeRecompile; - case InvalidateReprofile: - return config.deoptActionReinterpret; - case InvalidateRecompile: - return config.deoptActionMakeNotEntrant; - case InvalidateStopCompiling: - return config.deoptActionMakeNotCompilable; - default: - throw new JVMCIError("%s", action); - } - } - - public DeoptimizationAction convertDeoptAction(int action) { - HotSpotVMConfig config = runtime.getConfig(); - if (action == config.deoptActionNone) { - return DeoptimizationAction.None; - } - if (action == config.deoptActionMaybeRecompile) { - return DeoptimizationAction.RecompileIfTooManyDeopts; - } - if (action == config.deoptActionReinterpret) { - return DeoptimizationAction.InvalidateReprofile; - } - if (action == config.deoptActionMakeNotEntrant) { - return DeoptimizationAction.InvalidateRecompile; - } - if (action == config.deoptActionMakeNotCompilable) { - return DeoptimizationAction.InvalidateStopCompiling; - } - throw new JVMCIError("%d", action); - } - - public int convertDeoptReason(DeoptimizationReason reason) { - HotSpotVMConfig config = runtime.getConfig(); - switch (reason) { - case None: - return config.deoptReasonNone; - case NullCheckException: - return config.deoptReasonNullCheck; - case BoundsCheckException: - return config.deoptReasonRangeCheck; - case ClassCastException: - return config.deoptReasonClassCheck; - case ArrayStoreException: - return config.deoptReasonArrayCheck; - case UnreachedCode: - return config.deoptReasonUnreached0; - case TypeCheckedInliningViolated: - return config.deoptReasonTypeCheckInlining; - case OptimizedTypeCheckViolated: - return config.deoptReasonOptimizedTypeCheck; - case NotCompiledExceptionHandler: - return config.deoptReasonNotCompiledExceptionHandler; - case Unresolved: - return config.deoptReasonUnresolved; - case JavaSubroutineMismatch: - return config.deoptReasonJsrMismatch; - case ArithmeticException: - return config.deoptReasonDiv0Check; - case RuntimeConstraint: - return config.deoptReasonConstraint; - case LoopLimitCheck: - return config.deoptReasonLoopLimitCheck; - case Aliasing: - return config.deoptReasonAliasing; - case TransferToInterpreter: - return config.deoptReasonTransferToInterpreter; - default: - throw new JVMCIError("%s", reason); - } - } - - public DeoptimizationReason convertDeoptReason(int reason) { - HotSpotVMConfig config = runtime.getConfig(); - if (reason == config.deoptReasonNone) { - return DeoptimizationReason.None; - } - if (reason == config.deoptReasonNullCheck) { - return DeoptimizationReason.NullCheckException; - } - if (reason == config.deoptReasonRangeCheck) { - return DeoptimizationReason.BoundsCheckException; - } - if (reason == config.deoptReasonClassCheck) { - return DeoptimizationReason.ClassCastException; - } - if (reason == config.deoptReasonArrayCheck) { - return DeoptimizationReason.ArrayStoreException; - } - if (reason == config.deoptReasonUnreached0) { - return DeoptimizationReason.UnreachedCode; - } - if (reason == config.deoptReasonTypeCheckInlining) { - return DeoptimizationReason.TypeCheckedInliningViolated; - } - if (reason == config.deoptReasonOptimizedTypeCheck) { - return DeoptimizationReason.OptimizedTypeCheckViolated; - } - if (reason == config.deoptReasonNotCompiledExceptionHandler) { - return DeoptimizationReason.NotCompiledExceptionHandler; - } - if (reason == config.deoptReasonUnresolved) { - return DeoptimizationReason.Unresolved; - } - if (reason == config.deoptReasonJsrMismatch) { - return DeoptimizationReason.JavaSubroutineMismatch; - } - if (reason == config.deoptReasonDiv0Check) { - return DeoptimizationReason.ArithmeticException; - } - if (reason == config.deoptReasonConstraint) { - return DeoptimizationReason.RuntimeConstraint; - } - if (reason == config.deoptReasonLoopLimitCheck) { - return DeoptimizationReason.LoopLimitCheck; - } - if (reason == config.deoptReasonAliasing) { - return DeoptimizationReason.Aliasing; - } - if (reason == config.deoptReasonTransferToInterpreter) { - return DeoptimizationReason.TransferToInterpreter; - } - throw new JVMCIError("%x", reason); - } - - @Override - public long getMemorySize(JavaConstant constant) { - if (constant.getJavaKind() == JavaKind.Object) { - HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant); - - if (lookupJavaType == null) { - return 0; - } else { - if (lookupJavaType.isArray()) { - int length = runtime.getHostJVMCIBackend().getConstantReflection().readArrayLength(constant); - ResolvedJavaType elementType = lookupJavaType.getComponentType(); - JavaKind elementKind = elementType.getJavaKind(); - final int headerSize = runtime.getArrayBaseOffset(elementKind); - int sizeOfElement = runtime.getArrayIndexScale(elementKind); - int log2ElementSize = CodeUtil.log2(sizeOfElement); - return computeArrayAllocationSize(length, headerSize, log2ElementSize); - } - return lookupJavaType.instanceSize(); - } - } else { - return constant.getJavaKind().getByteCount(); - } - } - - /** - * Computes the size of the memory chunk allocated for an array. This size accounts for the - * array header size, body size and any padding after the last element to satisfy object - * alignment requirements. - * - * @param length the number of elements in the array - * @param headerSize the size of the array header - * @param log2ElementSize log2 of the size of an element in the array - * @return the size of the memory chunk - */ - public int computeArrayAllocationSize(int length, int headerSize, int log2ElementSize) { - HotSpotVMConfig config = runtime.getConfig(); - int alignment = config.objectAlignment; - int size = (length << log2ElementSize) + headerSize + (alignment - 1); - int mask = ~(alignment - 1); - return size & mask; - } - - @Override - public int getArrayBaseOffset(JavaKind kind) { - return runtime.getArrayBaseOffset(kind); - } - - @Override - public int getArrayIndexScale(JavaKind kind) { - return runtime.getArrayIndexScale(kind); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java deleted file mode 100644 index f42d84539dd..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.VMConstant; - -public interface HotSpotMetaspaceConstant extends HotSpotConstant, VMConstant { - - HotSpotResolvedObjectType asResolvedJavaType(); - - HotSpotResolvedJavaMethod asResolvedJavaMethod(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java deleted file mode 100644 index 641dd4676ae..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Objects; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.VMConstant; - -final class HotSpotMetaspaceConstantImpl implements HotSpotMetaspaceConstant, VMConstant { - - static HotSpotMetaspaceConstantImpl forMetaspaceObject(MetaspaceObject metaspaceObject, boolean compressed) { - return new HotSpotMetaspaceConstantImpl(metaspaceObject, compressed); - } - - static MetaspaceObject getMetaspaceObject(Constant constant) { - return ((HotSpotMetaspaceConstantImpl) constant).metaspaceObject; - } - - private final MetaspaceObject metaspaceObject; - private final boolean compressed; - - private HotSpotMetaspaceConstantImpl(MetaspaceObject metaspaceObject, boolean compressed) { - this.metaspaceObject = metaspaceObject; - this.compressed = compressed; - } - - @Override - public int hashCode() { - return System.identityHashCode(metaspaceObject) ^ (compressed ? 1 : 2); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof HotSpotMetaspaceConstantImpl)) { - return false; - } - - HotSpotMetaspaceConstantImpl other = (HotSpotMetaspaceConstantImpl) o; - return Objects.equals(this.metaspaceObject, other.metaspaceObject) && this.compressed == other.compressed; - } - - @Override - public String toValueString() { - return String.format("meta{%s%s}", metaspaceObject, compressed ? ";compressed" : ""); - } - - @Override - public String toString() { - return toValueString(); - } - - @Override - public boolean isDefaultForKind() { - return false; - } - - @Override - public boolean isCompressed() { - return compressed; - } - - @Override - public boolean isCompressible() { - return !compressed; - } - - @Override - public Constant compress() { - if (compressed) { - throw new IllegalArgumentException("already compressed: " + this); - } - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, true); - assert res.isCompressed(); - return res; - } - - @Override - public Constant uncompress() { - if (!compressed) { - throw new IllegalArgumentException("not compressed: " + this); - } - HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, false); - assert !res.isCompressed(); - return res; - } - - @Override - public HotSpotResolvedObjectType asResolvedJavaType() { - if (metaspaceObject instanceof HotSpotResolvedObjectType) { - return (HotSpotResolvedObjectType) metaspaceObject; - } - return null; - } - - @Override - public HotSpotResolvedJavaMethod asResolvedJavaMethod() { - if (metaspaceObject instanceof HotSpotResolvedJavaMethod) { - return (HotSpotResolvedJavaMethod) metaspaceObject; - } - return null; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethod.java deleted file mode 100644 index c2145b298b6..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethod.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.FormattableFlags.ALTERNATE; -import static java.util.FormattableFlags.LEFT_JUSTIFY; -import static java.util.FormattableFlags.UPPERCASE; - -import java.util.Formattable; -import java.util.Formatter; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -abstract class HotSpotMethod implements JavaMethod, Formattable { - - public static String applyFormattingFlagsAndWidth(String s, int flags, int width) { - if (flags == 0 && width < 0) { - return s; - } - StringBuilder sb = new StringBuilder(s); - - // apply width and justification - int len = sb.length(); - if (len < width) { - for (int i = 0; i < width - len; i++) { - if ((flags & LEFT_JUSTIFY) == LEFT_JUSTIFY) { - sb.append(' '); - } else { - sb.insert(0, ' '); - } - } - } - - String res = sb.toString(); - if ((flags & UPPERCASE) == UPPERCASE) { - res = res.toUpperCase(); - } - return res; - } - - /** - * Controls whether {@link #toString()} includes the qualified or simple name of the class in - * which the method is declared. - */ - public static final boolean FULLY_QUALIFIED_METHOD_NAME = false; - - @Override - public final String toString() { - char h = FULLY_QUALIFIED_METHOD_NAME ? 'H' : 'h'; - String suffix = this instanceof ResolvedJavaMethod ? "" : ", unresolved"; - String fmt = String.format("HotSpotMethod<%%%c.%%n(%%p)%s>", h, suffix); - return format(fmt); - } - - @Override - public void formatTo(Formatter formatter, int flags, int width, int precision) { - String base = (flags & ALTERNATE) == ALTERNATE ? getName() : toString(); - formatter.format(applyFormattingFlagsAndWidth(base, flags & ~ALTERNATE, width)); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java deleted file mode 100644 index 2478b97a5b2..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodData.java +++ /dev/null @@ -1,837 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.lang.String.format; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.util.Arrays; - -import jdk.internal.misc.Unsafe; -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaMethodProfile.ProfiledMethod; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.TriState; - -/** - * Access to a HotSpot {@code MethodData} structure (defined in methodData.hpp). - */ -final class HotSpotMethodData implements MetaspaceObject { - - /** - * VM state that can be reset when building an AOT image. - */ - static final class VMState { - final HotSpotVMConfig config = config(); - final HotSpotMethodDataAccessor noDataNoExceptionAccessor = new NoMethodData(this, config.dataLayoutNoTag, TriState.FALSE); - final HotSpotMethodDataAccessor noDataExceptionPossiblyNotRecordedAccessor = new NoMethodData(this, config.dataLayoutNoTag, TriState.UNKNOWN); - final int noDataSize = cellIndexToOffset(0); - final int bitDataSize = cellIndexToOffset(0); - final int bitDataNullSeenFlag = 1 << config.bitDataNullSeenFlag; - final int counterDataSize = cellIndexToOffset(1); - final int counterDataCountOffset = cellIndexToOffset(config.methodDataCountOffset); - final int jumpDataSize = cellIndexToOffset(2); - final int takenCountOffset = cellIndexToOffset(config.jumpDataTakenOffset); - final int takenDisplacementOffset = cellIndexToOffset(config.jumpDataDisplacementOffset); - final int typeDataRowSize = cellsToBytes(config.receiverTypeDataReceiverTypeRowCellCount); - - final int typeDataFirstTypeOffset = cellIndexToOffset(config.receiverTypeDataReceiver0Offset); - final int typeDataFirstTypeCountOffset = cellIndexToOffset(config.receiverTypeDataCount0Offset); - - final int typeCheckDataSize = cellIndexToOffset(1) + typeDataRowSize * config.typeProfileWidth; - final int virtualCallDataSize = cellIndexToOffset(1) + typeDataRowSize * (config.typeProfileWidth + config.methodProfileWidth); - final int virtualCallDataFirstMethodOffset = typeDataFirstTypeOffset + typeDataRowSize * config.typeProfileWidth; - final int virtualCallDataFirstMethodCountOffset = typeDataFirstTypeCountOffset + typeDataRowSize * config.typeProfileWidth; - - final int retDataRowSize = cellsToBytes(3); - final int retDataSize = cellIndexToOffset(1) + retDataRowSize * config.bciProfileWidth; - - final int branchDataSize = cellIndexToOffset(3); - final int notTakenCountOffset = cellIndexToOffset(config.branchDataNotTakenOffset); - - final int arrayDataLengthOffset = cellIndexToOffset(config.arrayDataArrayLenOffset); - final int arrayDataStartOffset = cellIndexToOffset(config.arrayDataArrayStartOffset); - - final int multiBranchDataSize = cellIndexToOffset(1); - final int multiBranchDataRowSizeInCells = config.multiBranchDataPerCaseCellCount; - final int multiBranchDataRowSize = cellsToBytes(multiBranchDataRowSizeInCells); - final int multiBranchDataFirstCountOffset = arrayDataStartOffset + cellsToBytes(0); - final int multiBranchDataFirstDisplacementOffset = arrayDataStartOffset + cellsToBytes(1); - - final int argInfoDataSize = cellIndexToOffset(1); - - // sorted by tag - // @formatter:off - final HotSpotMethodDataAccessor[] profileDataAccessors = { - null, - new BitData(this, config.dataLayoutBitDataTag), - new CounterData(this, config.dataLayoutCounterDataTag), - new JumpData(this, config.dataLayoutJumpDataTag), - new ReceiverTypeData(this, config.dataLayoutReceiverTypeDataTag), - new VirtualCallData(this, config.dataLayoutVirtualCallDataTag), - new RetData(this, config.dataLayoutRetDataTag), - new BranchData(this, config.dataLayoutBranchDataTag), - new MultiBranchData(this, config.dataLayoutMultiBranchDataTag), - new ArgInfoData(this, config.dataLayoutArgInfoDataTag), - new UnknownProfileData(this, config.dataLayoutCallTypeDataTag), - new VirtualCallTypeData(this, config.dataLayoutVirtualCallTypeDataTag), - new UnknownProfileData(this, config.dataLayoutParametersTypeDataTag), - new UnknownProfileData(this, config.dataLayoutSpeculativeTrapDataTag), - }; - // @formatter:on - - private boolean checkAccessorTags() { - int expectedTag = 0; - for (HotSpotMethodDataAccessor accessor : profileDataAccessors) { - if (expectedTag == 0) { - assert accessor == null; - } else { - assert accessor.tag == expectedTag : expectedTag + " != " + accessor.tag + " " + accessor; - } - expectedTag++; - } - return true; - } - - private VMState() { - assert checkAccessorTags(); - } - - private static int truncateLongToInt(long value) { - return value > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) value; - } - - private int computeFullOffset(int position, int offsetInBytes) { - return config.methodDataOopDataOffset + position + offsetInBytes; - } - - private int cellIndexToOffset(int cells) { - return config.dataLayoutHeaderSize + cellsToBytes(cells); - } - - private int cellsToBytes(int cells) { - return cells * config.dataLayoutCellSize; - } - - /** - * Singleton instance lazily initialized via double-checked locking. - */ - private static volatile VMState instance; - - static VMState instance() { - VMState result = instance; - if (result == null) { - synchronized (VMState.class) { - result = instance; - if (result == null) { - instance = result = new VMState(); - } - } - } - return result; - } - } - - /** - * A {@code MethodData*} value. - */ - final long methodDataPointer; - private final HotSpotResolvedJavaMethodImpl method; - private final VMState state; - - HotSpotMethodData(long methodDataPointer, HotSpotResolvedJavaMethodImpl method) { - this.methodDataPointer = methodDataPointer; - this.method = method; - this.state = VMState.instance(); - } - - @Override - public long getMetaspacePointer() { - return methodDataPointer; - } - - /** - * @return value of the MethodData::_data_size field - */ - private int normalDataSize() { - return UNSAFE.getInt(methodDataPointer + state.config.methodDataDataSize); - } - - /** - * Returns the size of the extra data records. This method does the same calculation as - * MethodData::extra_data_size(). - * - * @return size of extra data records - */ - private int extraDataSize() { - final int extraDataBase = state.config.methodDataOopDataOffset + normalDataSize(); - final int extraDataLimit = UNSAFE.getInt(methodDataPointer + state.config.methodDataSize); - return extraDataLimit - extraDataBase; - } - - public boolean hasNormalData() { - return normalDataSize() > 0; - } - - /** - * Return true if there is an extra data section and the first tag is non-zero. - */ - public boolean hasExtraData() { - return extraDataSize() > 0 && HotSpotMethodDataAccessor.readTag(state.config, this, getExtraDataBeginOffset()) != 0; - } - - private int getExtraDataBeginOffset() { - return normalDataSize(); - } - - public boolean isWithin(int position) { - return position >= 0 && position < normalDataSize(); - } - - public int getDeoptimizationCount(DeoptimizationReason reason) { - HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); - int reasonIndex = metaAccess.convertDeoptReason(reason); - return UNSAFE.getByte(methodDataPointer + state.config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; - } - - public int getOSRDeoptimizationCount(DeoptimizationReason reason) { - HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) runtime().getHostJVMCIBackend().getMetaAccess(); - int reasonIndex = metaAccess.convertDeoptReason(reason); - return UNSAFE.getByte(methodDataPointer + state.config.methodDataOopTrapHistoryOffset + state.config.deoptReasonOSROffset + reasonIndex) & 0xFF; - } - - public int getDecompileCount() { - return UNSAFE.getInt(methodDataPointer + state.config.methodDataDecompiles); - } - - public int getOverflowRecompileCount() { - return UNSAFE.getInt(methodDataPointer + state.config.methodDataOverflowRecompiles); - } - - public int getOverflowTrapCount() { - return UNSAFE.getInt(methodDataPointer + state.config.methodDataOverflowTraps); - } - - public HotSpotMethodDataAccessor getNormalData(int position) { - if (position >= normalDataSize()) { - return null; - } - - return getData(position); - } - - public static HotSpotMethodDataAccessor getNoDataAccessor(boolean exceptionPossiblyNotRecorded) { - if (exceptionPossiblyNotRecorded) { - return VMState.instance().noDataExceptionPossiblyNotRecordedAccessor; - } else { - return VMState.instance().noDataNoExceptionAccessor; - } - } - - private HotSpotMethodDataAccessor getData(int position) { - assert position >= 0 : "out of bounds"; - final int tag = HotSpotMethodDataAccessor.readTag(state.config, this, position); - HotSpotMethodDataAccessor accessor = state.profileDataAccessors[tag]; - assert accessor == null || accessor.getTag() == tag : "wrong data accessor " + accessor + " for tag " + tag; - return accessor; - } - - int readUnsignedByte(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return UNSAFE.getByte(methodDataPointer + fullOffsetInBytes) & 0xFF; - } - - int readUnsignedShort(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return UNSAFE.getShort(methodDataPointer + fullOffsetInBytes) & 0xFFFF; - } - - /** - * Since the values are stored in cells (platform words) this method uses - * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. - */ - private long readUnsignedInt(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return UNSAFE.getAddress(methodDataPointer + fullOffsetInBytes) & 0xFFFFFFFFL; - } - - private int readUnsignedIntAsSignedInt(int position, int offsetInBytes) { - long value = readUnsignedInt(position, offsetInBytes); - return VMState.truncateLongToInt(value); - } - - /** - * Since the values are stored in cells (platform words) this method uses - * {@link Unsafe#getAddress} to read the right value on both little and big endian machines. - */ - private int readInt(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return (int) UNSAFE.getAddress(methodDataPointer + fullOffsetInBytes); - } - - private HotSpotResolvedJavaMethod readMethod(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return compilerToVM().getResolvedJavaMethod(null, methodDataPointer + fullOffsetInBytes); - } - - private HotSpotResolvedObjectTypeImpl readKlass(int position, int offsetInBytes) { - long fullOffsetInBytes = state.computeFullOffset(position, offsetInBytes); - return compilerToVM().getResolvedJavaType(this, fullOffsetInBytes); - } - - /** - * Returns whether profiling ran long enough that the profile information is mature. Other - * informational data will still be valid even if the profile isn't mature. - */ - public boolean isProfileMature() { - return runtime().getCompilerToVM().isMature(methodDataPointer); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - String nl = System.lineSeparator(); - String nlIndent = String.format("%n%38s", ""); - sb.append("Raw method data for "); - sb.append(method.format("%H.%n(%p)")); - sb.append(":"); - sb.append(nl); - sb.append(String.format("nof_decompiles(%d) nof_overflow_recompiles(%d) nof_overflow_traps(%d)%n", - getDecompileCount(), getOverflowRecompileCount(), getOverflowTrapCount())); - if (hasNormalData()) { - int pos = 0; - HotSpotMethodDataAccessor data; - while ((data = getNormalData(pos)) != null) { - if (pos != 0) { - sb.append(nl); - } - int bci = data.getBCI(this, pos); - sb.append(String.format("%-6d bci: %-6d%-20s", pos, bci, data.getClass().getSimpleName())); - sb.append(data.appendTo(new StringBuilder(), this, pos).toString().replace(nl, nlIndent)); - pos = pos + data.getSize(this, pos); - } - } - - return sb.toString(); - } - - static class NoMethodData extends HotSpotMethodDataAccessor { - - private final TriState exceptionSeen; - - protected NoMethodData(VMState state, int tag, TriState exceptionSeen) { - super(state, tag, state.noDataSize); - this.exceptionSeen = exceptionSeen; - } - - @Override - public int getBCI(HotSpotMethodData data, int position) { - return -1; - } - - @Override - public TriState getExceptionSeen(HotSpotMethodData data, int position) { - return exceptionSeen; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb; - } - } - - static class BitData extends HotSpotMethodDataAccessor { - - private BitData(VMState state, int tag) { - super(state, tag, state.bitDataSize); - } - - protected BitData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public TriState getNullSeen(HotSpotMethodData data, int position) { - return TriState.get((getFlags(data, position) & state.bitDataNullSeenFlag) != 0); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("exception_seen(%s)", getExceptionSeen(data, pos))); - } - } - - static class CounterData extends BitData { - - CounterData(VMState state, int tag) { - super(state, tag, state.counterDataSize); - } - - protected CounterData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return getCounterValue(data, position); - } - - protected int getCounterValue(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, state.counterDataCountOffset); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("count(%d) null_seen(%s) exception_seen(%s)", getCounterValue(data, pos), getNullSeen(data, pos), getExceptionSeen(data, pos))); - } - } - - static class JumpData extends HotSpotMethodDataAccessor { - - JumpData(VMState state, int tag) { - super(state, tag, state.jumpDataSize); - } - - protected JumpData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public double getBranchTakenProbability(HotSpotMethodData data, int position) { - return getExecutionCount(data, position) != 0 ? 1 : 0; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, state.takenCountOffset); - } - - public int getTakenDisplacement(HotSpotMethodData data, int position) { - return data.readInt(position, state.takenDisplacementOffset); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("taken(%d) displacement(%d)", getExecutionCount(data, pos), getTakenDisplacement(data, pos))); - } - } - - record RawItemProfile(int entries, T[] items, long[] counts, long totalCount) {} - - abstract static class AbstractTypeData extends CounterData { - - protected AbstractTypeData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { - return createTypeProfile(getNullSeen(data, position), getRawTypeProfile(data, position)); - } - - private RawItemProfile getRawTypeProfile(HotSpotMethodData data, int position) { - int typeProfileWidth = config.typeProfileWidth; - - ResolvedJavaType[] types = new ResolvedJavaType[typeProfileWidth]; - long[] counts = new long[typeProfileWidth]; - long totalCount = 0; - int entries = 0; - - outer: for (int i = 0; i < typeProfileWidth; i++) { - HotSpotResolvedObjectTypeImpl receiverKlass = data.readKlass(position, getTypeOffset(i)); - if (receiverKlass != null) { - HotSpotResolvedObjectTypeImpl klass = receiverKlass; - long count = data.readUnsignedInt(position, getTypeCountOffset(i)); - /* - * Because of races in the profile collection machinery it's possible for a - * class to appear multiple times so merge them to make the profile look - * rational. - */ - for (int j = 0; j < entries; j++) { - if (types[j].equals(klass)) { - totalCount += count; - counts[j] += count; - continue outer; - } - } - types[entries] = klass; - totalCount += count; - counts[entries] = count; - entries++; - } - } - - totalCount += getCounterValue(data, position); - return new RawItemProfile<>(entries, types, counts, totalCount); - } - - private JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile profile) { - if (profile.entries <= 0 || profile.totalCount <= 0) { - return null; - } - - ProfiledType[] ptypes = new ProfiledType[profile.entries]; - double totalProbability = 0.0; - for (int i = 0; i < profile.entries; i++) { - double p = profile.counts[i]; - p = p / profile.totalCount; - totalProbability += p; - ptypes[i] = new ProfiledType(profile.items[i], p); - } - - Arrays.sort(ptypes); - - double notRecordedTypeProbability = profile.entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); - assert notRecordedTypeProbability == 0 || profile.entries == config.typeProfileWidth; - return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes); - } - - private int getTypeOffset(int row) { - return state.typeDataFirstTypeOffset + row * state.typeDataRowSize; - } - - protected int getTypeCountOffset(int row) { - return state.typeDataFirstTypeCountOffset + row * state.typeDataRowSize; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - RawItemProfile profile = getRawTypeProfile(data, pos); - TriState nullSeen = getNullSeen(data, pos); - TriState exceptionSeen = getExceptionSeen(data, pos); - sb.append(format("count(%d) null_seen(%s) exception_seen(%s) entries(%d)", getCounterValue(data, pos), nullSeen, exceptionSeen, - profile.entries)); - for (int i = 0; i < profile.entries; i++) { - long count = profile.counts[i]; - sb.append(format("%n %s (%d, %4.2f)", profile.items[i].toJavaName(), count, (double) count / profile.totalCount)); - } - return sb; - } - } - - static class ReceiverTypeData extends AbstractTypeData { - - ReceiverTypeData(VMState state, int tag) { - super(state, tag, state.typeCheckDataSize); - } - - protected ReceiverTypeData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - return -1; - } - } - - static class VirtualCallData extends ReceiverTypeData { - - VirtualCallData(VMState state, int tag) { - super(state, tag, state.virtualCallDataSize); - } - - protected VirtualCallData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - final int typeProfileWidth = config.typeProfileWidth; - - long total = 0; - for (int i = 0; i < typeProfileWidth; i++) { - total += data.readUnsignedInt(position, getTypeCountOffset(i)); - } - - total += getCounterValue(data, position); - return VMState.truncateLongToInt(total); - } - - @Override - public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { - return createMethodProfile(getRawMethodProfile(data, position)); - } - - private RawItemProfile getRawMethodProfile(HotSpotMethodData data, int position) { - int profileWidth = config.methodProfileWidth; - - ResolvedJavaMethod[] methods = new ResolvedJavaMethod[profileWidth]; - long[] counts = new long[profileWidth]; - long totalCount = 0; - int entries = 0; - - for (int i = 0; i < profileWidth; i++) { - HotSpotResolvedJavaMethod method = data.readMethod(position, getMethodOffset(i)); - if (method != null) { - methods[entries] = method; - long count = data.readUnsignedInt(position, getMethodCountOffset(i)); - totalCount += count; - counts[entries] = count; - - entries++; - } - } - - // Fixup the case of C1's inability to optimize profiling of a statically bindable call - // site. If it's a monomorphic call site, attribute all the counts to the first type (if - // any is recorded). - if (entries == 1) { - counts[0] = totalCount; - } - - return new RawItemProfile<>(entries, methods, counts, totalCount); - } - - private JavaMethodProfile createMethodProfile(RawItemProfile profile) { - if (profile.entries <= 0 || profile.totalCount <= 0) { - return null; - } - - ProfiledMethod[] pmethods = new ProfiledMethod[profile.entries]; - double totalProbability = 0.0; - for (int i = 0; i < profile.entries; i++) { - double p = profile.counts[i]; - p = p / profile.totalCount; - totalProbability += p; - pmethods[i] = new ProfiledMethod(profile.items[i], p); - } - - Arrays.sort(pmethods); - - double notRecordedMethodProbability = profile.entries < config.methodProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability)); - assert notRecordedMethodProbability == 0 || profile.entries == config.methodProfileWidth; - return new JavaMethodProfile(notRecordedMethodProbability, pmethods); - } - - private int getMethodOffset(int row) { - return state.virtualCallDataFirstMethodOffset + row * state.typeDataRowSize; - } - - private int getMethodCountOffset(int row) { - return state.virtualCallDataFirstMethodCountOffset + row * state.typeDataRowSize; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - RawItemProfile profile = getRawMethodProfile(data, pos); - super.appendTo(sb.append(format("exception_seen(%s) ", getExceptionSeen(data, pos))), data, pos).append(format("%nmethod_entries(%d)", profile.entries)); - for (int i = 0; i < profile.entries; i++) { - long count = profile.counts[i]; - sb.append(format("%n %s (%d, %4.2f)", profile.items[i].format("%H.%n(%p)"), count, (double) count / profile.totalCount)); - } - return sb; - } - } - - static class VirtualCallTypeData extends VirtualCallData { - - VirtualCallTypeData(VMState state, int tag) { - super(state, tag, 0); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - assert staticSize == 0; - return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position); - } - } - - static class RetData extends CounterData { - - RetData(VMState state, int tag) { - super(state, tag, state.retDataSize); - } - } - - static class BranchData extends JumpData { - - BranchData(VMState state, int tag) { - super(state, tag, state.branchDataSize); - } - - @Override - public double getBranchTakenProbability(HotSpotMethodData data, int position) { - long takenCount = data.readUnsignedInt(position, state.takenCountOffset); - long notTakenCount = data.readUnsignedInt(position, state.notTakenCountOffset); - long total = takenCount + notTakenCount; - - return total <= 0 ? -1 : takenCount / (double) total; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - long count = data.readUnsignedInt(position, state.takenCountOffset) + data.readUnsignedInt(position, state.notTakenCountOffset); - return VMState.truncateLongToInt(count); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - long taken = data.readUnsignedInt(pos, state.takenCountOffset); - long notTaken = data.readUnsignedInt(pos, state.notTakenCountOffset); - double takenProbability = getBranchTakenProbability(data, pos); - return sb.append(format("taken(%d, %4.2f) not_taken(%d, %4.2f) displacement(%d)", taken, takenProbability, notTaken, 1.0D - takenProbability, getTakenDisplacement(data, pos))); - } - } - - static class ArrayData extends HotSpotMethodDataAccessor { - - ArrayData(VMState state, int tag, int staticSize) { - super(state, tag, staticSize); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - return state.cellsToBytes(getLength(data, position)); - } - - protected int getLength(HotSpotMethodData data, int position) { - return data.readInt(position, state.arrayDataLengthOffset); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return sb.append(format("length(%d)", getLength(data, pos))); - } - } - - static class MultiBranchData extends ArrayData { - - MultiBranchData(VMState state, int tag) { - super(state, tag, state.multiBranchDataSize); - } - - @Override - public double[] getSwitchProbabilities(HotSpotMethodData data, int position) { - int arrayLength = getLength(data, position); - assert arrayLength > 0 : "switch must have at least the default case"; - assert arrayLength % state.multiBranchDataRowSizeInCells == 0 : "array must have full rows"; - - int length = arrayLength / state.multiBranchDataRowSizeInCells; - long totalCount = 0; - double[] result = new double[length]; - - // default case is first in HotSpot but last for the compiler - long count = readCount(data, position, 0); - totalCount += count; - result[length - 1] = count; - - for (int i = 1; i < length; i++) { - count = readCount(data, position, i); - totalCount += count; - result[i - 1] = count; - } - - if (totalCount <= 0) { - return null; - } else { - for (int i = 0; i < length; i++) { - result[i] = result[i] / totalCount; - } - return result; - } - } - - private long readCount(HotSpotMethodData data, int position, int i) { - int offset; - long count; - offset = getCountOffset(i); - count = data.readUnsignedInt(position, offset); - return count; - } - - @Override - public int getExecutionCount(HotSpotMethodData data, int position) { - int arrayLength = getLength(data, position); - assert arrayLength > 0 : "switch must have at least the default case"; - assert arrayLength % state.multiBranchDataRowSizeInCells == 0 : "array must have full rows"; - - int length = arrayLength / state.multiBranchDataRowSizeInCells; - long totalCount = 0; - for (int i = 0; i < length; i++) { - int offset = getCountOffset(i); - totalCount += data.readUnsignedInt(position, offset); - } - - return VMState.truncateLongToInt(totalCount); - } - - private int getCountOffset(int index) { - return state.multiBranchDataFirstCountOffset + index * state.multiBranchDataRowSize; - } - - private int getDisplacementOffset(int index) { - return state.multiBranchDataFirstDisplacementOffset + index * state.multiBranchDataRowSize; - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - int entries = getLength(data, pos) / state.multiBranchDataRowSizeInCells; - sb.append(format("entries(%d)", entries)); - for (int i = 0; i < entries; i++) { - sb.append(format("%n %d: count(%d) displacement(%d)", i, data.readUnsignedInt(pos, getCountOffset(i)), data.readUnsignedInt(pos, getDisplacementOffset(i)))); - } - return sb; - } - } - - static class ArgInfoData extends ArrayData { - - ArgInfoData(VMState state, int tag) { - super(state, tag, state.argInfoDataSize); - } - } - - static class UnknownProfileData extends HotSpotMethodDataAccessor { - UnknownProfileData(VMState state, int tag) { - super(state, tag, 0); - } - - @Override - protected int getDynamicSize(HotSpotMethodData data, int position) { - assert staticSize == 0; - return HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position); - } - - @Override - public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - sb.append("unknown profile data with tag: " + tag); - return sb; - } - } - - public void setCompiledIRSize(int size) { - UNSAFE.putInt(methodDataPointer + state.config.methodDataIRSizeOffset, size); - } - - public int getCompiledIRSize() { - return UNSAFE.getInt(methodDataPointer + state.config.methodDataIRSizeOffset); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java deleted file mode 100644 index bde0ea3c5d5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.TriState; - -/** - * Base class for accessing the different kinds of data in a HotSpot {@code MethodData}. This is - * similar to {@link ProfilingInfo}, but most methods require a {@link HotSpotMethodData} and the - * exact position within the method data. - */ -abstract class HotSpotMethodDataAccessor { - - final int tag; - final int staticSize; - final HotSpotMethodData.VMState state; - final HotSpotVMConfig config; - - protected HotSpotMethodDataAccessor(HotSpotMethodData.VMState state, int tag, int staticSize) { - this.state = state; - this.config = state.config; - this.tag = tag; - this.staticSize = staticSize; - } - - /** - * Returns the tag stored in the LayoutData header. - * - * @return tag stored in the LayoutData header - */ - int getTag() { - return tag; - } - - static int readTag(HotSpotVMConfig config, HotSpotMethodData data, int position) { - final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset); - assert tag >= config.dataLayoutNoTag && tag <= config.dataLayoutSpeculativeTrapDataTag : "profile data tag out of bounds: " + tag; - return tag; - } - - /** - * Returns the BCI stored in the LayoutData header. - * - * @return an integer between 0 and {@link Short#MAX_VALUE} inclusive, or -1 if not supported - */ - int getBCI(HotSpotMethodData data, int position) { - return data.readUnsignedShort(position, config.dataLayoutBCIOffset); - } - - /** - * Computes the size for the specific data at the given position. - * - * @return a value greater than 0 - */ - final int getSize(HotSpotMethodData data, int position) { - int size = staticSize + getDynamicSize(data, position); - // Sanity check against VM - int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.methodDataPointer, position); - assert size == vmSize : size + " != " + vmSize; - return size; - } - - TriState getExceptionSeen(HotSpotMethodData data, int position) { - final int exceptionsMask = 1 << config.bitDataExceptionSeenFlag; - return TriState.get((getFlags(data, position) & exceptionsMask) != 0); - } - - /** - * @param data - * @param position - */ - JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { - return null; - } - - /** - * @param data - * @param position - */ - JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { - return null; - } - - /** - * @param data - * @param position - */ - double getBranchTakenProbability(HotSpotMethodData data, int position) { - return -1; - } - - /** - * @param data - * @param position - */ - double[] getSwitchProbabilities(HotSpotMethodData data, int position) { - return null; - } - - /** - * @param data - * @param position - */ - int getExecutionCount(HotSpotMethodData data, int position) { - return -1; - } - - /** - * @param data - * @param position - */ - TriState getNullSeen(HotSpotMethodData data, int position) { - return TriState.UNKNOWN; - } - - protected int getFlags(HotSpotMethodData data, int position) { - return data.readUnsignedByte(position, config.dataLayoutFlagsOffset); - } - - /** - * @param data - * @param position - */ - protected int getDynamicSize(HotSpotMethodData data, int position) { - return 0; - } - - abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java deleted file mode 100644 index 6211bd5063a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; - -import java.lang.invoke.MethodHandle; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotMethodData.VMState; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProvider { - - private final ConstantReflectionProvider constantReflection; - - public HotSpotMethodHandleAccessProvider(ConstantReflectionProvider constantReflection) { - this.constantReflection = constantReflection; - } - - /** - * Lazy initialized reflection on {@link MethodHandle} internals. Field and method lookup is - * only possible after the {@link HotSpotJVMCIRuntime} is fully initialized. - */ - static final class Internals { - final ResolvedJavaType lambdaFormType; - final ResolvedJavaField methodHandleFormField; - final ResolvedJavaField lambdaFormVmentryField; - final HotSpotResolvedJavaField callSiteTargetField; - final HotSpotResolvedJavaField constantCallSiteFrozenField; - final ResolvedJavaField methodField; - final HotSpotResolvedJavaField vmtargetField; - - /** - * Search for an instance field with the given name in a class. - * - * @param declaringType the type declaring the field - * @param fieldName name of the field to be searched - * @param fieldType resolved Java type of the field - * @return resolved Java field - * @throws NoSuchFieldError - */ - private static ResolvedJavaField findFieldInClass(ResolvedJavaType declaringType, String fieldName, ResolvedJavaType fieldType) { - ResolvedJavaField[] fields = declaringType.getInstanceFields(false); - for (ResolvedJavaField field : fields) { - if (field.getName().equals(fieldName) && field.getType().equals(fieldType)) { - return field; - } - } - throw new NoSuchFieldError(declaringType + "." + fieldName); - } - - private static ResolvedJavaType resolveType(String className, HotSpotResolvedObjectType accessingType) { - return (ResolvedJavaType) runtime().lookupTypeInternal(className, accessingType, true); - } - - private Internals() { - try { - HotSpotResolvedObjectType accessingType = runtime().getJavaLangObject(); - ResolvedJavaType methodHandleType = resolveType("Ljava/lang/invoke/MethodHandle;", accessingType); - ResolvedJavaType memberNameType = resolveType("Ljava/lang/invoke/MemberName;", accessingType); - lambdaFormType = resolveType("Ljava/lang/invoke/LambdaForm;", accessingType); - methodHandleFormField = findFieldInClass(methodHandleType, "form", lambdaFormType); - lambdaFormVmentryField = findFieldInClass(lambdaFormType, "vmentry", memberNameType); - - ResolvedJavaType methodType = resolveType("Ljava/lang/invoke/ResolvedMethodName;", accessingType); - methodField = findFieldInClass(memberNameType, "method", methodType); - vmtargetField = (HotSpotResolvedJavaField) findFieldInClass(methodType, "vmtarget", resolveType(Character.toString(HotSpotJVMCIRuntime.getHostWordKind().getTypeChar()), accessingType)); - - ResolvedJavaType callSiteType = resolveType("Ljava/lang/invoke/CallSite;", accessingType); - callSiteTargetField = (HotSpotResolvedJavaField) findFieldInClass(callSiteType, "target", methodHandleType); - ResolvedJavaType constantCallSiteType = resolveType("Ljava/lang/invoke/ConstantCallSite;", accessingType); - ResolvedJavaType booleanType = resolveType("Z", accessingType); - constantCallSiteFrozenField = (HotSpotResolvedJavaField) findFieldInClass(constantCallSiteType, "isFrozen", booleanType); - } catch (Throwable ex) { - throw new JVMCIError(ex); - } - } - - /** - * Singleton instance lazily initialized via double-checked locking. - */ - private static volatile Internals instance; - - static Internals instance() { - Internals result = instance; - if (result == null) { - synchronized (VMState.class) { - result = instance; - if (result == null) { - instance = result = new Internals(); - } - } - } - return result; - } - - } - - - @Override - public IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method) { - int intrinsicId = ((HotSpotResolvedJavaMethodImpl) method).intrinsicId(); - if (intrinsicId != 0) { - return getMethodHandleIntrinsic(intrinsicId); - } - return null; - } - - public static IntrinsicMethod getMethodHandleIntrinsic(int intrinsicId) { - HotSpotVMConfig config = runtime().getConfig(); - if (intrinsicId == config.vmIntrinsicInvokeBasic) { - return IntrinsicMethod.INVOKE_BASIC; - } else if (intrinsicId == config.vmIntrinsicLinkToInterface) { - return IntrinsicMethod.LINK_TO_INTERFACE; - } else if (intrinsicId == config.vmIntrinsicLinkToSpecial) { - return IntrinsicMethod.LINK_TO_SPECIAL; - } else if (intrinsicId == config.vmIntrinsicLinkToStatic) { - return IntrinsicMethod.LINK_TO_STATIC; - } else if (intrinsicId == config.vmIntrinsicLinkToVirtual) { - return IntrinsicMethod.LINK_TO_VIRTUAL; - } else if (intrinsicId == config.vmIntrinsicLinkToNative) { - return IntrinsicMethod.LINK_TO_NATIVE; - } - return null; - } - - @Override - public ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration) { - if (methodHandle.isNull()) { - return null; - } - - /* Load non-public field: LambdaForm MethodHandle.form */ - Internals internals = Internals.instance(); - JavaConstant lambdaForm = constantReflection.readFieldValue(internals.methodHandleFormField, methodHandle); - if (lambdaForm == null || lambdaForm.isNull()) { - return null; - } - - JavaConstant memberName = constantReflection.readFieldValue(internals.lambdaFormVmentryField, lambdaForm); - if (memberName.isNull() && forceBytecodeGeneration) { - compilerToVM().compileToBytecode((HotSpotObjectConstantImpl) lambdaForm); - memberName = constantReflection.readFieldValue(internals.lambdaFormVmentryField, lambdaForm); - assert memberName.isNonNull(); - } - JavaConstant method = constantReflection.readFieldValue(internals.methodField, memberName); - return getTargetMethod(method); - } - - @Override - public ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName) { - if (memberName.isNull()) { - return null; - } - JavaConstant method = constantReflection.readFieldValue(Internals.instance().methodField, memberName); - return getTargetMethod(method); - } - - /** - * Returns the {@link ResolvedJavaMethod} for the method of a java.lang.invoke.MemberName. - */ - private static ResolvedJavaMethod getTargetMethod(JavaConstant method) { - if (method == null) { - // If readFieldValue returns NULL the type was wrong - throw new IllegalArgumentException("unexpected type for memberName"); - } - - /* Read the ResolvedJavaMethod from the injected field MemberName.method.vmtarget */ - return compilerToVM().getResolvedJavaMethod((HotSpotObjectConstantImpl) method, Internals.instance().vmtargetField.getOffset()); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotModifiers.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotModifiers.java deleted file mode 100644 index ba1ea96eb1c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotModifiers.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.lang.reflect.Modifier.ABSTRACT; -import static java.lang.reflect.Modifier.FINAL; -import static java.lang.reflect.Modifier.INTERFACE; -import static java.lang.reflect.Modifier.NATIVE; -import static java.lang.reflect.Modifier.PRIVATE; -import static java.lang.reflect.Modifier.PROTECTED; -import static java.lang.reflect.Modifier.PUBLIC; -import static java.lang.reflect.Modifier.STATIC; -import static java.lang.reflect.Modifier.STRICT; -import static java.lang.reflect.Modifier.SYNCHRONIZED; -import static java.lang.reflect.Modifier.TRANSIENT; -import static java.lang.reflect.Modifier.VOLATILE; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; - -import java.lang.reflect.Modifier; - -/** - * The non-public modifiers in {@link Modifier} that need to be retrieved from - * {@link HotSpotVMConfig}. - */ -public class HotSpotModifiers { - - // @formatter:off - public static final int ANNOTATION = config().jvmAccAnnotation; - public static final int ENUM = config().jvmAccEnum; - public static final int VARARGS = config().jvmAccVarargs; - public static final int BRIDGE = config().jvmAccBridge; - public static final int SYNTHETIC = config().jvmAccSynthetic; - // @formatter:on - - public static int jvmClassModifiers() { - return PUBLIC | FINAL | INTERFACE | ABSTRACT | ANNOTATION | ENUM | SYNTHETIC; - } - - public static int jvmMethodModifiers() { - return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | SYNCHRONIZED | BRIDGE | VARARGS | NATIVE | ABSTRACT | STRICT | SYNTHETIC; - } - - public static int jvmFieldModifiers() { - return PUBLIC | PRIVATE | PROTECTED | STATIC | FINAL | VOLATILE | TRANSIENT | ENUM | SYNTHETIC; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotNmethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotNmethod.java deleted file mode 100644 index f5cd5013f65..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotNmethod.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Implementation of {@link InstalledCode} for code installed as an {@code nmethod}. The address of - * the {@code nmethod} is stored in {@link InstalledCode#address} and the value of - * {@code nmethod::verified_entry_point()} is in {@link InstalledCode#entryPoint}. - */ -public class HotSpotNmethod extends HotSpotInstalledCode { - - /** - * This (indirect) {@code Method*} reference is safe since class redefinition preserves all - * methods associated with nmethods in the code cache. - */ - private final HotSpotResolvedJavaMethodImpl method; - - /** - * Specifies whether the {@code nmethod} associated with this object is the code executed by - * default HotSpot linkage when a normal Java call to {@link #method} is made. That is, does - * {@code this.method.metadataHandle->_code} == {@code this.address}. If not, then the - * {@code nmethod} can only be invoked via a reference to this object. An example of this is the - * trampoline mechanism used by Truffle: https://goo.gl/LX88rZ. - */ - private final boolean isDefault; - - /** - * Specifies whether HotSpot should profile deoptimizations for the {@code nmethod} associated - * with this object. This is particularly useful for whitebox testing scenarios that involve - * deoptimization. - */ - private final boolean profileDeopt; - - /** - * Determines whether this object is in the oops table of the nmethod. - *

- * If this object is in the oops table, the VM uses the oops table entry to update this object's - * {@link #address} and {@link #entryPoint} fields when the state of the nmethod changes. The - * nmethod will be unloadable when this object dies. - *

- * Otherwise, the nmethod's unloadability is not changed when this object dies. - */ - boolean inOopsTable() { - return compileIdSnapshot != 0; - } - - /** - * If this field is 0, this object is in the oops table of the nmethod. Otherwise, the value of - * the field records the nmethod's compile identifier. This value is used to confirm if an entry - * in the code cache retrieved by {@link #address} is indeed the nmethod represented by this - * object. - * - * @see #inOopsTable - */ - private final long compileIdSnapshot; - - /** - * Identify the reason that caused this nmethod to be invalidated. - * A value of -1 means that the nmethod was not invalidated. - */ - private int invalidationReason; - - HotSpotNmethod(HotSpotResolvedJavaMethodImpl method, String name, boolean isDefault, boolean profileDeopt, long compileId) { - super(name); - this.method = method; - this.isDefault = isDefault; - this.profileDeopt = profileDeopt; - boolean inOopsTable = !IS_IN_NATIVE_IMAGE && !isDefault; - this.compileIdSnapshot = inOopsTable ? 0L : compileId; - this.invalidationReason = -1; - assert inOopsTable || compileId != 0L : this; - } - - /** - * Attaches {@code log} to this object. If {@code log.managesFailedSpeculations() == true}, this - * ensures the failed speculation list lives at least as long as this object. - */ - public void setSpeculationLog(HotSpotSpeculationLog log) { - this.speculationLog = log; - } - - /** - * The speculation log containing speculations embedded in the nmethod. - *

- * If {@code speculationLog.managesFailedSpeculations() == true}, this field ensures the failed - * speculation list lives at least as long as this object. This prevents deoptimization from - * appending to an already freed list. - */ - @SuppressWarnings("unused") - private HotSpotSpeculationLog speculationLog; - - /** - * Determines if the nmethod associated with this object is the compiled entry point for - * {@link #getMethod()}. - */ - public boolean isDefault() { - return isDefault; - } - - /** - * Determines if HotSpot should profile deoptimization for the {@code nmethod} associated - * with this object. - */ - public boolean profileDeopt() { - return profileDeopt; - } - - @Override - public boolean isValid() { - if (compileIdSnapshot != 0L) { - compilerToVM().updateHotSpotNmethod(this); - } - return super.isValid(); - } - - public ResolvedJavaMethod getMethod() { - return method; - } - - /** - * Invalidate this nmethod using the reason specified in {@code invalidationReason} and - * optionally deoptimize the method if {@code deoptimize} is set. - * - * @param deoptimize whether or not to deoptimize the method. - * @param invalidationReason invalidation reason code. - */ - public void invalidate(boolean deoptimize, int invalidationReason) { - compilerToVM().invalidateHotSpotNmethod(this, deoptimize, invalidationReason); - } - - @Override - public void invalidate(boolean deoptimize) { - invalidate(deoptimize, jvmciInvalidationReason()); - } - - @Override - public long getAddress() { - if (compileIdSnapshot != 0L) { - compilerToVM().updateHotSpotNmethod(this); - } - return super.getAddress(); - } - - @Override - public long getEntryPoint() { - if (compileIdSnapshot != 0L) { - return 0; - } - return super.getEntryPoint(); - } - - @Override - public String toString() { - return String.format("HotSpotNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s, inOopsTable=%s]", - method, getAddress(), isDefault, name, inOopsTable()); - } - - private boolean checkArgs(Object... args) { - JavaType[] sig = method.toParameterTypes(); - assert args.length == sig.length : method.format("%H.%n(%p): expected ") + sig.length + " args, got " + args.length; - for (int i = 0; i < sig.length; i++) { - Object arg = args[i]; - if (arg == null) { - assert sig[i].getJavaKind() == JavaKind.Object : method.format("%H.%n(%p): expected arg ") + i + " to be Object, not " + sig[i]; - } else if (sig[i].getJavaKind() != JavaKind.Object) { - assert sig[i].getJavaKind().toBoxedJavaClass() == arg.getClass() : method.format("%H.%n(%p): expected arg ") + i + " to be " + sig[i] + ", not " + arg.getClass(); - } - } - return true; - } - - /** - * {@inheritDoc} - *

- * It's possible for the HotSpot runtime to sweep nmethods at any point in time. As a result, - * there is no guarantee that calling this method will execute the wrapped nmethod. Instead, it - * may end up executing the bytecode of the associated {@link #getMethod() Java method}. Only if - * {@link #isValid()} is {@code true} after returning can the caller be sure that the nmethod - * was executed. If {@link #isValid()} is {@code false}, then the only way to determine if the - * nmethod was executed is to test for some side-effect specific to the nmethod (e.g., update to - * a field) that is not performed by the bytecode of the associated {@link #getMethod() Java - * method}. - */ - @Override - public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - if (IS_IN_NATIVE_IMAGE) { - throw new HotSpotJVMCIUnsupportedOperationError("Cannot execute nmethod via mirror in native image"); - } - assert checkArgs(args); - return compilerToVM().executeHotSpotNmethod(args, this); - } - - @Override - public long getStart() { - return isValid() ? super.getStart() : 0; - } - - /** - * @return an integer representing the reason why this nmethod was invalidated. - */ - public int getInvalidationReason() { - return invalidationReason; - } - - /** - * @return a String describing the reason why this nmethod was invalidated. - */ - public String getInvalidationReasonDescription() { - return compilerToVM().getInvalidationReasonDescription(this.getInvalidationReason()); - } - - private static int jvmciInvalidationReason() { - return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstant.java deleted file mode 100644 index ca54e8325f3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstant.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Assumptions; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.VMConstant; - -import java.lang.invoke.CallSite; -import java.lang.invoke.ConstantCallSite; -import java.util.Objects; - -/** - * Represents a constant non-{@code null} object reference, within the compiler and across the - * compiler/runtime interface. - */ -public interface HotSpotObjectConstant extends JavaConstant, HotSpotConstant, VMConstant { - - @Override - JavaConstant compress(); - - @Override - JavaConstant uncompress(); - - /** - * Gets the resolved Java type of the object represented by this constant. - */ - HotSpotResolvedObjectType getType(); - - /** - * Gets the {@linkplain System#identityHashCode(Object) identity} has code for the object - * represented by this constant. - */ - int getIdentityHashCode(); - - /** - * Gets the result of {@link CallSite#getTarget()} for the {@link CallSite} object represented - * by this constant. - * - * @param assumptions used to register an assumption that the {@link CallSite}'s target does not - * change - * @return {@code null} if this constant does not represent a {@link CallSite} object - */ - default JavaConstant getCallSiteTarget(Assumptions assumptions) { - Assumptions.AssumptionResult result = getCallSiteTarget(); - if (!result.canRecordTo(assumptions)) { - return null; - } - result.recordTo(assumptions); - return result.getResult(); - } - - /** - * Gets the result of {@link CallSite#getTarget()} for the {@link CallSite} object represented - * by this constant. The target is bound to an assumption if this is not a fully initialized - * {@link ConstantCallSite}. - * - * @return a call-site target (possibly bound to an assumption) or {@code null} if this constant - * does not represent a {@link CallSite} object - */ - default Assumptions.AssumptionResult getCallSiteTarget() { - throw new UnsupportedOperationException("getCallSiteTarget"); - } - - /** - * Determines if this constant represents an {@linkplain String#intern() interned} string. - */ - boolean isInternedString(); - - /** - * Gets the object represented by this constant represents if it is of a given type. - * - * @param type the expected type of the object represented by this constant. If the object is - * required to be of this type, then wrap the call to this method in - * {@link Objects#requireNonNull(Object)}. - * @return the object value represented by this constant if it is an - * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise - * {@code null} - */ - T asObject(Class type); - - /** - * Gets the object represented by this constant represents if it is of a given type. - * - * @param type the expected type of the object represented by this constant. If the object is - * required to be of this type, then wrap the call to this method in - * {@link Objects#requireNonNull(Object)}. - * @return the object value represented by this constant if it is an - * {@link ResolvedJavaType#isInstance(JavaConstant) instance of} {@code type} otherwise - * {@code null} - */ - Object asObject(ResolvedJavaType type); - - @Override - String toValueString(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java deleted file mode 100644 index 9a067375245..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.services.Services.IS_IN_NATIVE_IMAGE; - -import jdk.vm.ci.meta.Assumptions; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Represents a constant non-{@code null} object reference, within the compiler and across the - * compiler/runtime interface. - */ -abstract class HotSpotObjectConstantImpl implements HotSpotObjectConstant { - - protected final boolean compressed; - - HotSpotObjectConstantImpl(boolean compressed) { - this.compressed = compressed; - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public boolean isCompressed() { - return compressed; - } - - @Override - public boolean isCompressible() { - return !compressed; - } - - @Override - public abstract JavaConstant compress(); - - @Override - public abstract JavaConstant uncompress(); - - @Override - public HotSpotResolvedObjectType getType() { - return runtime().reflection.getType(this); - } - - @Override - public abstract int getIdentityHashCode(); - - private boolean isFullyInitializedConstantCallSite() { - if (!runtime().getConstantCallSite().isInstance(this)) { - return false; - } - // read ConstantCallSite.isFrozen as a volatile field - HotSpotResolvedJavaField field = HotSpotMethodHandleAccessProvider.Internals.instance().constantCallSiteFrozenField; - boolean isFrozen = readFieldValue(field).asBoolean(); - // isFrozen true implies fully-initialized - return isFrozen; - } - - private HotSpotObjectConstantImpl readTarget() { - // read CallSite.target as a volatile field - HotSpotResolvedJavaField field = HotSpotMethodHandleAccessProvider.Internals.instance().callSiteTargetField; - return (HotSpotObjectConstantImpl) readFieldValue(field); - } - - @Override - public Assumptions.AssumptionResult getCallSiteTarget() { - if (runtime().getCallSite().isInstance(this)) { - // For ConstantCallSites, we need to read "isFrozen" before reading "target" - // isFullyInitializedConstantCallSite() reads "isFrozen" - if (isFullyInitializedConstantCallSite()) { - return new Assumptions.AssumptionResult<>(readTarget()); - } - HotSpotObjectConstantImpl result = readTarget(); - return new Assumptions.AssumptionResult<>(result, new Assumptions.CallSiteTargetValue(this, result)); - } - return null; - } - - @Override - public boolean isInternedString() { - return runtime().compilerToVm.isInternedString(this); - } - - @Override - public T asObject(Class type) { - return runtime().reflection.asObject(this, type); - } - - @Override - public Object asObject(ResolvedJavaType type) { - return runtime().reflection.asObject(this, (HotSpotResolvedJavaType) type); - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isDefaultForKind() { - return false; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } else if (o instanceof HotSpotObjectConstantImpl) { - HotSpotObjectConstantImpl other = (HotSpotObjectConstantImpl) o; - return runtime().reflection.equals(this, other); - } - return false; - } - - @Override - public int hashCode() { - return getIdentityHashCode(); - } - - @Override - public String toValueString() { - if (runtime().getJavaLangString().isInstance(this)) { - return "\"" + runtime().reflection.asString(this) + "\""; - } else { - return runtime().reflection.formatString(this); - } - } - - @Override - public String toString() { - return (compressed ? "NarrowOop" : getJavaKind().getJavaName()) + "[" + runtime().reflection.formatString(this) + "]"; - } - - public JavaConstant readFieldValue(HotSpotResolvedJavaField field) { - if (IS_IN_NATIVE_IMAGE && this instanceof DirectHotSpotObjectConstantImpl) { - // cannot read fields from objects due to lack of - // general reflection support in native image - return null; - } - if (field.isStatic()) { - return null; - } - HotSpotResolvedObjectTypeImpl declaringClass = (HotSpotResolvedObjectTypeImpl) field.getDeclaringClass(); - char typeChar = field.getType().getJavaKind().getTypeChar(); - return runtime().compilerToVm.readFieldValue(this, declaringClass, field.getOffset(), typeChar); - } - - public ResolvedJavaType asJavaType() { - return runtime().reflection.asJavaType(this); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantScope.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantScope.java deleted file mode 100644 index 867593d9def..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantScope.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import jdk.vm.ci.services.Services; - -/** - * A mechanism for limiting the lifetime of a foreign object reference encapsulated in a - * {@link HotSpotObjectConstant}. - * - * A {@link HotSpotObjectConstant} allocated in a {@linkplain #openLocalScope local} scope will have - * its reference to any foreign object cleared when the scope {@linkplain #close() closes}. This - * allows the foreign memory manager to reclaim the foreign object (once there are no other strong - * references to it). - * - * {@link HotSpotObjectConstantScope}s have no impact on {@link HotSpotObjectConstant}s that do not - * encapsulate a foreign object reference. - * - * The object returned by {@link #enterGlobalScope()} or {@link #openLocalScope(Object)} should - * always be used in a try-with-resources statement. Failure to close a scope will almost certainly - * result in foreign objects being leaked. - */ -public final class HotSpotObjectConstantScope implements AutoCloseable { - static final ThreadLocal CURRENT = new ThreadLocal<>(); - - private final HotSpotObjectConstantScope parent; - private List foreignObjects; - - /** - * An object whose {@link Object#toString()} value describes a non-global scope. This is - * {@code null} iff this is a global scope. - */ - final Object localScopeDescription; - - /** - * Opens a local scope that upon closing, will release foreign object references encapsulated by - * {@link HotSpotObjectConstant}s created in the scope. - * - * @param description an non-null object whose {@link Object#toString()} value describes the - * scope being opened - * @return {@code null} if the current runtime does not support remote object references - */ - public static HotSpotObjectConstantScope openLocalScope(Object description) { - return Services.IS_IN_NATIVE_IMAGE ? new HotSpotObjectConstantScope(Objects.requireNonNull(description)) : null; - } - - /** - * Enters the global scope. This is useful to escape a local scope for execution that will - * create foreign object references that need to outlive the local scope. - * - * Foreign object references encapsulated by {@link HotSpotObjectConstant}s created in the - * global scope are only subject to reclamation once the {@link HotSpotObjectConstant} wrapper - * dies. - * - * @return {@code null} if the current runtime does not support remote object references or if - * this thread is currently in the global scope - */ - public static HotSpotObjectConstantScope enterGlobalScope() { - return Services.IS_IN_NATIVE_IMAGE && CURRENT.get() != null ? new HotSpotObjectConstantScope(null) : null; - } - - private HotSpotObjectConstantScope(Object localScopeDescription) { - this.parent = CURRENT.get(); - CURRENT.set(this); - this.localScopeDescription = localScopeDescription; - } - - /** - * Determines if this scope is global. - */ - boolean isGlobal() { - return localScopeDescription == null; - } - - void add(IndirectHotSpotObjectConstantImpl obj) { - assert !isGlobal(); - if (foreignObjects == null) { - foreignObjects = new ArrayList<>(); - } - foreignObjects.add(obj); - } - - @VMEntryPoint - @Override - public void close() { - if (CURRENT.get() != this) { - throw new IllegalStateException("Cannot close non-active scope"); - } - if (foreignObjects != null) { - for (IndirectHotSpotObjectConstantImpl obj : foreignObjects) { - obj.clear(localScopeDescription); - } - foreignObjects = null; - CompilerToVM.compilerToVM().releaseClearedOopHandles(); - } - CURRENT.set(parent); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java deleted file mode 100644 index b89849fb454..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.ProfilingInfo; - -/** - * Extends {@link ProfilingInfo} with HotSpot specific profiling info. - */ -public interface HotSpotProfilingInfo extends ProfilingInfo { - - /** - * Returns {@code MethodData::_compiler_counters._nof_decompiles}. - */ - int getDecompileCount(); - - /** - * Returns {@code MethodData::_compiler_counters._nof_overflow_recompiles}. - */ - int getOverflowRecompileCount(); - - /** - * Returns {@code MethodData::_compiler_counters._nof_overflow_traps}. - */ - int getOverflowTrapCount(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfoImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfoImpl.java deleted file mode 100644 index 3dcdedef282..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotProfilingInfoImpl.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; - -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaMethodProfile; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.TriState; - -final class HotSpotProfilingInfoImpl implements HotSpotProfilingInfo { - - private final HotSpotMethodData methodData; - private final HotSpotResolvedJavaMethod method; - - private boolean isMature; - private int position; - private int hintPosition; - private int hintBCI; - private HotSpotMethodDataAccessor dataAccessor; - - private boolean includeNormal; - private boolean includeOSR; - - HotSpotProfilingInfoImpl(HotSpotMethodData methodData, HotSpotResolvedJavaMethod method, boolean includeNormal, boolean includeOSR) { - this.methodData = methodData; - this.method = method; - if (!method.getDeclaringClass().isLinked()) { - throw new IllegalArgumentException(method.format("%H.%n(%p) must be linked")); - } - this.includeNormal = includeNormal; - this.includeOSR = includeOSR; - this.isMature = methodData.isProfileMature(); - hintPosition = 0; - hintBCI = -1; - } - - @Override - public int getCodeSize() { - return method.getCodeSize(); - } - - @Override - public int getDecompileCount() { - return methodData.getDecompileCount(); - } - - @Override - public int getOverflowRecompileCount() { - return methodData.getOverflowRecompileCount(); - } - - @Override - public int getOverflowTrapCount() { - return methodData.getOverflowTrapCount(); - } - - @Override - public JavaTypeProfile getTypeProfile(int bci) { - if (!isMature) { - return null; - } - findBCI(bci); - return dataAccessor.getTypeProfile(methodData, position); - } - - @Override - public JavaMethodProfile getMethodProfile(int bci) { - if (!isMature) { - return null; - } - findBCI(bci); - return dataAccessor.getMethodProfile(methodData, position); - } - - @Override - public double getBranchTakenProbability(int bci) { - if (!isMature) { - return -1; - } - findBCI(bci); - return dataAccessor.getBranchTakenProbability(methodData, position); - } - - @Override - public double[] getSwitchProbabilities(int bci) { - if (!isMature) { - return null; - } - findBCI(bci); - return dataAccessor.getSwitchProbabilities(methodData, position); - } - - @Override - public TriState getExceptionSeen(int bci) { - if (!findBCI(bci)) { - // There might data in the extra data section but all accesses to that memory must be - // under a lock so go into VM to get the data. - int exceptionSeen = compilerToVM().methodDataExceptionSeen(methodData.methodDataPointer, bci); - if (exceptionSeen == -1) { - return TriState.UNKNOWN; - } - return TriState.get(exceptionSeen != 0); - } - return dataAccessor.getExceptionSeen(methodData, position); - } - - @Override - public TriState getNullSeen(int bci) { - findBCI(bci); - return dataAccessor.getNullSeen(methodData, position); - } - - @Override - public int getExecutionCount(int bci) { - if (!isMature) { - return -1; - } - findBCI(bci); - return dataAccessor.getExecutionCount(methodData, position); - } - - @Override - public int getDeoptimizationCount(DeoptimizationReason reason) { - int count = 0; - if (includeNormal) { - count += methodData.getDeoptimizationCount(reason); - } - if (includeOSR) { - count += methodData.getOSRDeoptimizationCount(reason); - } - return count; - } - - private boolean findBCI(int targetBCI) { - assert targetBCI >= 0 : "invalid BCI"; - - if (methodData.hasNormalData()) { - int currentPosition = targetBCI < hintBCI ? 0 : hintPosition; - HotSpotMethodDataAccessor currentAccessor; - while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) { - int currentBCI = currentAccessor.getBCI(methodData, currentPosition); - if (currentBCI == targetBCI) { - normalDataFound(currentAccessor, currentPosition, currentBCI); - return true; - } else if (currentBCI > targetBCI) { - break; - } - currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); - } - } - noDataFound(false); - return false; - } - - private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { - setCurrentData(data, pos); - this.hintPosition = position; - this.hintBCI = bci; - } - - private void noDataFound(boolean exceptionPossiblyNotRecorded) { - HotSpotMethodDataAccessor accessor = HotSpotMethodData.getNoDataAccessor(exceptionPossiblyNotRecorded); - setCurrentData(accessor, -1); - } - - private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { - this.dataAccessor = dataAccessor; - this.position = position; - } - - @Override - public boolean isMature() { - return isMature; - } - - public void ignoreMature() { - isMature = true; - } - - @Override - public String toString() { - return "HotSpotProfilingInfo<" + this.toString(null, "; ") + ">"; - } - - @Override - public void setMature() { - isMature = true; - } - - /** - * {@code MethodData::_jvmci_ir_size} (currently) supports at most one JVMCI compiler IR type - * which will be determined by the first JVMCI compiler that calls - * {@link #setCompilerIRSize(Class, int)}. - */ - private static volatile Class supportedCompilerIRType; - - @Override - public boolean setCompilerIRSize(Class irType, int size) { - if (supportedCompilerIRType == null) { - synchronized (HotSpotProfilingInfoImpl.class) { - if (supportedCompilerIRType == null) { - supportedCompilerIRType = irType; - } - } - } - if (supportedCompilerIRType != irType) { - return false; - } - methodData.setCompiledIRSize(size); - return true; - } - - @Override - public int getCompilerIRSize(Class irType) { - if (irType == supportedCompilerIRType) { - return methodData.getCompiledIRSize(); - } - return -1; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotReferenceMap.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotReferenceMap.java deleted file mode 100644 index 37fe0c14a31..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotReferenceMap.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Arrays; - -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.ReferenceMap; - -/** - * Describes where the object references are in machine state, compliant with what HotSpot expects. - */ -public final class HotSpotReferenceMap extends ReferenceMap { - - final Location[] objects; - final Location[] derivedBase; - final int[] sizeInBytes; - final int maxRegisterSize; - - /** - * - * @param objects This array is now owned by this object and must not be mutated by the caller. - * @param derivedBase This array is now owned by this object and must not be mutated by the - * caller. - * @param sizeInBytes This array is now owned by this object and must not be mutated by the - * caller. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `objects`, `derivedBase` and `sizeInBytes`") - public HotSpotReferenceMap(Location[] objects, Location[] derivedBase, int[] sizeInBytes, int maxRegisterSize) { - this.objects = objects; - this.derivedBase = derivedBase; - this.sizeInBytes = sizeInBytes; - this.maxRegisterSize = maxRegisterSize; - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotReferenceMap) { - HotSpotReferenceMap that = (HotSpotReferenceMap) obj; - if (sizeInBytes == that.sizeInBytes && maxRegisterSize == that.maxRegisterSize && Arrays.equals(objects, that.objects) && Arrays.equals(derivedBase, that.derivedBase)) { - return true; - } - } - return false; - } - - @Override - public String toString() { - return Arrays.toString(objects); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java deleted file mode 100644 index 4816c3a4be4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaField.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaField; - -/** - * Represents a field in a HotSpot type. - */ -public interface HotSpotResolvedJavaField extends ResolvedJavaField { - - /** - * Determines if a given object contains this field. - * - * @return true iff this is a non-static field and its declaring class is assignable from - * {@code object}'s class - */ - boolean isInObject(JavaConstant object); - - /** - * Determines if this field should be treated as a constant. - */ - boolean isStable(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java deleted file mode 100644 index ba29cad7849..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.internal.misc.Unsafe.ADDRESS_SIZE; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.checkAreAnnotations; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.checkIsAnnotation; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.getFirstAnnotationOrNull; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.annotation.Annotation; -import java.util.Collections; -import java.util.List; - -import jdk.internal.vm.VMSupport; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.UnresolvedJavaType; - -/** - * Represents a field in a HotSpot type. - */ -class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField { - - private final HotSpotResolvedObjectTypeImpl holder; - private JavaType type; - - /** - * Offset (in bytes) of field from start of its storage container (i.e. {@code instanceOop} or - * {@code Klass*}). - */ - private final int offset; - - /** - * Value of {@code fieldDescriptor::index()}. - */ - private final int index; - - /** - * This value contains all flags from the class file - */ - private final int classfileFlags; - - /** - * This value contains VM internal flags - */ - private final int internalFlags; - - HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, JavaType type, int offset, int classfileFlags, int internalFlags, int index) { - this.holder = holder; - this.type = type; - this.offset = offset; - this.classfileFlags = classfileFlags; - this.internalFlags = internalFlags; - this.index = index; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotResolvedJavaFieldImpl) { - HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj; - if (that.offset != this.offset || that.isStatic() != this.isStatic()) { - return false; - } else if (this.holder.equals(that.holder)) { - return true; - } - } - return false; - } - - @Override - public int hashCode() { - return holder.hashCode() ^ offset; - } - - @Override - public int getModifiers() { - return classfileFlags & HotSpotModifiers.jvmFieldModifiers(); - } - - @Override - public boolean isInternal() { - return (internalFlags & (1 << config().jvmFieldFlagInternalShift)) != 0; - } - - /** - * Determines if a given object contains this field. - * - * @return true iff this is a non-static field and its declaring class is assignable from - * {@code object}'s class - */ - @Override - public boolean isInObject(JavaConstant object) { - if (isStatic()) { - return false; - } - HotSpotObjectConstant constant = (HotSpotObjectConstant) object; - return getDeclaringClass().isAssignableFrom(constant.getType()); - } - - @Override - public HotSpotResolvedObjectTypeImpl getDeclaringClass() { - return holder; - } - - @Override - public String getName() { - return holder.getFieldInfo(index).getName(holder); - } - - @Override - public JavaType getType() { - // Pull field into local variable to prevent a race causing - // a ClassCastException below - JavaType currentType = type; - if (currentType instanceof UnresolvedJavaType) { - // Don't allow unresolved types to hang around forever - UnresolvedJavaType unresolvedType = (UnresolvedJavaType) currentType; - JavaType resolved = HotSpotJVMCIRuntime.runtime().lookupType(unresolvedType.getName(), holder, false); - if (resolved instanceof ResolvedJavaType) { - type = resolved; - } - } - return type; - - } - - /** - * Gets the offset (in bytes) of field from start of its storage container (i.e. - * {@code instanceOop} or {@code Klass*}). - */ - @Override - public int getOffset() { - return offset; - } - - /** - * Gets the value of this field's index (i.e. {@code fieldDescriptor::index()} in the encoded - * fields of the declaring class. - */ - int getIndex() { - return index; - } - - @Override - public String toString() { - return format("HotSpotResolvedJavaFieldImpl<%H.%n %t:") + offset + ">"; - } - - @Override - public boolean isSynthetic() { - return (config().jvmAccSynthetic & classfileFlags) != 0; - } - - /** - * Checks if this field has the {@code Stable} annotation. - * - * @return true if field has {@code Stable} annotation, false otherwise - */ - @Override - public boolean isStable() { - return (1 << (config().jvmFieldFlagStableShift ) & internalFlags) != 0; - } - - private boolean hasAnnotations() { - if (!isInternal()) { - HotSpotVMConfig config = config(); - final long metaspaceAnnotations = UNSAFE.getAddress(holder.getKlassPointer() + config.instanceKlassAnnotationsOffset); - if (metaspaceAnnotations != 0) { - long fieldsAnnotations = UNSAFE.getAddress(metaspaceAnnotations + config.annotationsFieldAnnotationsOffset); - if (fieldsAnnotations != 0) { - long fieldAnnotations = UNSAFE.getAddress(fieldsAnnotations + config.fieldsAnnotationsBaseOffset + (ADDRESS_SIZE * index)); - return fieldAnnotations != 0; - } - } - } - return false; - } - - @Override - public Annotation[] getAnnotations() { - if (!hasAnnotations()) { - return new Annotation[0]; - } - return runtime().reflection.getFieldAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!hasAnnotations()) { - return new Annotation[0]; - } - return runtime().reflection.getFieldDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!hasAnnotations()) { - return null; - } - return runtime().reflection.getFieldAnnotation(this, annotationClass); - } - - @Override - public JavaConstant getConstantValue() { - return holder.getFieldInfo(index).getConstantValue(holder); - } - - @Override - public AnnotationData getAnnotationData(ResolvedJavaType annotationType) { - if (!hasAnnotations()) { - checkIsAnnotation(annotationType); - return null; - } - return getFirstAnnotationOrNull(getAnnotationData0(annotationType)); - } - - @Override - public List getAnnotationData(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - checkIsAnnotation(type1); - checkIsAnnotation(type2); - checkAreAnnotations(types); - if (!hasAnnotations()) { - return List.of(); - } - return getAnnotationData0(AnnotationDataDecoder.asArray(type1, type2, types)); - } - - private List getAnnotationData0(ResolvedJavaType... filter) { - byte[] encoded = compilerToVM().getEncodedFieldAnnotationData(holder, index, filter); - return VMSupport.decodeAnnotations(encoded, AnnotationDataDecoder.INSTANCE); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java deleted file mode 100644 index 0f5c5002e0a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethod.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.lang.reflect.Modifier; -import java.util.BitSet; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaMethod} for resolved HotSpot methods. - */ -public interface HotSpotResolvedJavaMethod extends ResolvedJavaMethod { - - /** - * Returns true if this method has a {@code CallerSensitive} annotation. - * - * @return true if CallerSensitive annotation present, false otherwise - */ - boolean isCallerSensitive(); - - @Override - HotSpotResolvedObjectType getDeclaringClass(); - - /** - * Returns true if this method has a {@code ForceInline} annotation. - * - * @return true if ForceInline annotation present, false otherwise - */ - boolean isForceInline(); - - /** - * Returns true if this method has a {@code ReservedStackAccess} annotation. - * - * @return true if ReservedStackAccess annotation present, false otherwise - */ - boolean hasReservedStackAccess(); - - /** - * Sets flags on {@code method} indicating that it should never be inlined or compiled by the - * VM. - */ - void setNotInlinableOrCompilable(); - - /** - * Returns true if this method is one of the special methods that is ignored by security stack - * walks. - * - * @return true if special method ignored by security stack walks, false otherwise - */ - boolean ignoredBySecurityStackWalk(); - - ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver); - - /** - * Returns whether this method has compiled code. - * - * @return true if this method has compiled code, false otherwise - */ - boolean hasCompiledCode(); - - /** - * @param level - * @return true if the currently installed code was generated at {@code level}. - */ - boolean hasCompiledCodeAtLevel(int level); - - @Override - default boolean isDefault() { - if (isConstructor()) { - return false; - } - // Copied from java.lang.Method.isDefault() - int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; - return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); - } - - /** - * Returns the offset of this method into the v-table. The method must have a v-table entry as - * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is - * thrown. - * - * @return the offset of this method into the v-table - */ - int vtableEntryOffset(ResolvedJavaType resolved); - - int intrinsicId(); - - /** - * Determines if this method denotes itself as a candidate for intrinsification. As of JDK 9, - * this is denoted by the {@code IntrinsicCandidate} annotation. In earlier JDK versions, this - * method returns true. - * - * @see JDK-8076112 - */ - boolean isIntrinsicCandidate(); - - /** - * Allocates a compile id for this method by asking the VM for one. - * - * @param entryBCI entry bci - * @return compile id - */ - int allocateCompileId(int entryBCI); - - boolean hasCodeAtLevel(int entryBCI, int level); - - int methodIdnum(); - - - /** - * Computes which local variables and operand stack slots in {@code method} contain - * live object values at the instruction denoted by {@code bci}. This is the "oop map" - * used by the garbage collector for interpreter frames. - * - * @param bci the index of an instruction in this method's bytecodes - * @return the computed oop map. The first {@link #getMaxLocals} bits are for - * the local variables, the remaining bits are for the stack slots. - * @throws IllegalArgumentException if this method has no bytecode or - * {@code bci} is not the index of a bytecode instruction - */ - BitSet getOopMapAt(int bci); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java deleted file mode 100644 index 3c3aaf830fa..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java +++ /dev/null @@ -1,813 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotModifiers.BRIDGE; -import static jdk.vm.ci.hotspot.HotSpotModifiers.SYNTHETIC; -import static jdk.vm.ci.hotspot.HotSpotModifiers.VARARGS; -import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmMethodModifiers; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.checkAreAnnotations; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.checkIsAnnotation; -import static jdk.vm.ci.hotspot.HotSpotResolvedJavaType.getFirstAnnotationOrNull; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Executable; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.BitSet; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -import jdk.internal.vm.VMSupport; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.DefaultProfilingInfo; -import jdk.vm.ci.meta.ExceptionHandler; -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.LineNumberTable; -import jdk.vm.ci.meta.Local; -import jdk.vm.ci.meta.LocalVariableTable; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.TriState; - -/** - * Implementation of {@link JavaMethod} for resolved HotSpot methods. - */ -final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSpotResolvedJavaMethod, MetaspaceHandleObject { - - /** - * A {@code jmetadata} value that is a handle to {@code Method*} value. - */ - private final long methodHandle; - - private final HotSpotResolvedObjectTypeImpl holder; - private final HotSpotConstantPool constantPool; - final HotSpotSignature signature; - private HotSpotMethodData methodData; - private byte[] code; - - /** - * Cache for {@link HotSpotJDKReflection#getMethod}. - */ - volatile Executable toJavaCache; - - /** - * Only 30% of {@link HotSpotResolvedJavaMethodImpl}s have their name accessed so compute it - * lazily and cache it. - */ - private String nameCache; - - /** - * Gets the JVMCI mirror from a HotSpot method. The VM is responsible for ensuring that the - * Method* is kept alive for the duration of this call and the {@link HotSpotJVMCIRuntime} keeps - * it alive after that. - *

- * Called from the VM. - * - * @param metaspaceHandle a handle to metaspace Method object - * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod} - */ - @SuppressWarnings("unused") - @VMEntryPoint - private static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceHandle, HotSpotResolvedObjectTypeImpl holder) { - return holder.createMethod(metaspaceHandle); - } - - HotSpotResolvedJavaMethodImpl(HotSpotResolvedObjectTypeImpl holder, long metaspaceHandle) { - this.methodHandle = metaspaceHandle; - this.holder = holder; - - HotSpotVMConfig config = config(); - final long constMethod = getConstMethod(); - - /* - * Get the constant pool from the metaspace method. Some methods (e.g. intrinsics for - * signature-polymorphic method handle methods) have their own constant pool instead of the - * one from their holder. - */ - final long metaspaceConstantPool = UNSAFE.getAddress(constMethod + config.constMethodConstantsOffset); - if (metaspaceConstantPool == holder.getConstantPool().getConstantPoolPointer()) { - this.constantPool = holder.getConstantPool(); - } else { - this.constantPool = compilerToVM().getConstantPool(this); - } - - final int signatureIndex = UNSAFE.getChar(constMethod + config.constMethodSignatureIndexOffset); - this.signature = (HotSpotSignature) constantPool.lookupSignature(signatureIndex); - HandleCleaner.create(this, metaspaceHandle); - } - - /** - * Returns a pointer to this method's constant method data structure ( - * {@code Method::_constMethod}). This pointer isn't wrapped since it should be safe to use it - * within the context of this HotSpotResolvedJavaMethodImpl since the Method* and ConstMethod* - * are kept alive as a pair. - * - * @return pointer to this method's ConstMethod - */ - private long getConstMethod() { - return UNSAFE.getAddress(getMethodPointer() + config().methodConstMethodOffset); - } - - @Override - public String getName() { - if (nameCache == null) { - final int nameIndex = UNSAFE.getChar(getConstMethod() + config().constMethodNameIndexOffset); - nameCache = constantPool.lookupUtf8(nameIndex); - } - return nameCache; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof HotSpotResolvedJavaMethodImpl) { - HotSpotResolvedJavaMethodImpl that = (HotSpotResolvedJavaMethodImpl) obj; - return that.getMethodPointer() == getMethodPointer(); - } - return false; - } - - @Override - public int hashCode() { - return Long.hashCode(getMethodPointer()); - } - - /** - * Returns this method's flags ({@code Method::_flags}). - * - * @return flags of this method - */ - private int getFlags() { - return UNSAFE.getInt(getMethodPointer() + config().methodFlagsOffset); - } - - /** - * Returns this method's constant method flags ({@code ConstMethod::_flags}). - * - * @return flags of this method's ConstMethod - */ - private int getConstMethodFlags() { - return UNSAFE.getInt(getConstMethod() + config().constMethodFlagsOffset); - } - - @Override - public HotSpotResolvedObjectTypeImpl getDeclaringClass() { - return holder; - } - - /** - * Gets the address of the C++ Method object for this method. - */ - private Constant getMetaspaceMethodConstant() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); - } - - long getMethodPointer() { - long metaspacePointer = getMetaspacePointer(); - if (metaspacePointer == 0) { - throw new NullPointerException("Method* is null"); - } - return metaspacePointer; - } - - @Override - public long getMetadataHandle() { - return methodHandle; - } - - @Override - public Constant getEncoding() { - return getMetaspaceMethodConstant(); - } - - /** - * Gets the complete set of modifiers for this method which includes the JVM specification - * modifiers as well as the HotSpot internal modifiers. - */ - public int getAllModifiers() { - return UNSAFE.getInt(getMethodPointer() + config().methodAccessFlagsOffset); - } - - @Override - public int getModifiers() { - return getAllModifiers() & jvmMethodModifiers(); - } - - @Override - public boolean canBeStaticallyBound() { - return (isFinal() || isPrivate() || isStatic() || holder.isLeaf() || isConstructor()) && isConcrete(); - } - - @Override - public byte[] getCode() { - if (getCodeSize() == 0) { - return null; - } - if (code == null && holder.isLinked()) { - code = compilerToVM().getBytecode(this); - assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; - } - return code; - } - - @Override - public int getCodeSize() { - int codeSize = UNSAFE.getChar(getConstMethod() + config().constMethodCodeSizeOffset); - if (codeSize > 0 && !getDeclaringClass().isLinked()) { - return -1; - } - return codeSize; - } - - @Override - public ExceptionHandler[] getExceptionHandlers() { - final boolean hasExceptionTable = (getConstMethodFlags() & config().constMethodHasExceptionTable) != 0; - if (!hasExceptionTable) { - return new ExceptionHandler[0]; - } - - HotSpotVMConfig config = config(); - final int exceptionTableLength = compilerToVM().getExceptionTableLength(this); - ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength]; - long exceptionTableElement = compilerToVM().getExceptionTableStart(this); - - for (int i = 0; i < exceptionTableLength; i++) { - final int startPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementStartPcOffset); - final int endPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementEndPcOffset); - final int handlerPc = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementHandlerPcOffset); - int catchTypeIndex = UNSAFE.getChar(exceptionTableElement + config.exceptionTableElementCatchTypeIndexOffset); - - JavaType catchType; - if (catchTypeIndex == 0) { - catchType = null; - } else { - final int opcode = -1; // opcode is not used - catchType = constantPool.lookupType(catchTypeIndex, opcode); - - // Check for Throwable which catches everything. - if (catchType instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl resolvedType = (HotSpotResolvedObjectTypeImpl) catchType; - if (resolvedType.equals(runtime().getJavaLangThrowable())) { - catchTypeIndex = 0; - catchType = null; - } - } - } - handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType); - - // Go to the next ExceptionTableElement - exceptionTableElement += config.exceptionTableElementSize; - } - - return handlers; - } - - /** - * Returns true if this method has a {@code CallerSensitive} annotation. - * - * @return true if CallerSensitive annotation present, false otherwise - */ - @Override - public boolean isCallerSensitive() { - return (getConstMethodFlags() & config().constMethodFlagsCallerSensitive) != 0; - } - - /** - * Returns true if this method has a {@code ForceInline} annotation. - * - * @return true if ForceInline annotation present, false otherwise - */ - @Override - public boolean isForceInline() { - return (getFlags() & config().methodFlagsForceInline) != 0; - } - - /** - * Returns true if this method has a {@code ReservedStackAccess} annotation. - * - * @return true if ReservedStackAccess annotation present, false otherwise - */ - @Override - public boolean hasReservedStackAccess() { - return (getConstMethodFlags() & config().constMethodFlagsReservedStackAccess) != 0; - } - - /** - * Returns true if this method has a - * {@code jdk.internal.misc.ScopedMemoryAccess.Scoped} annotation. - * - * @return true if Scoped annotation present, false otherwise - */ - @Override - public boolean isScoped() { - return (getConstMethodFlags() & config().constMethodFlagsIsScoped) != 0; - } - - /** - * Sets flags on {@code method} indicating that it should never be inlined or compiled by the - * VM. - */ - @Override - public void setNotInlinableOrCompilable() { - compilerToVM().setNotInlinableOrCompilable(this); - } - - /** - * Returns true if this method is one of the special methods that is ignored by security stack - * walks. - * - * @return true if special method ignored by security stack walks, false otherwise - */ - @Override - public boolean ignoredBySecurityStackWalk() { - return compilerToVM().methodIsIgnoredBySecurityStackWalk(this); - } - - @Override - public boolean isClassInitializer() { - if (isStatic()) { - final int nameIndex = UNSAFE.getChar(getConstMethod() + config().constMethodNameIndexOffset); - long nameSymbol = constantPool.getEntryAt(nameIndex); - long clinitSymbol = config().symbolClinit; - return nameSymbol == clinitSymbol; - } - return false; - } - - @Override - public boolean isConstructor() { - if (!isStatic()) { - final int nameIndex = UNSAFE.getChar(getConstMethod() + config().constMethodNameIndexOffset); - long nameSymbol = constantPool.getEntryAt(nameIndex); - long initSymbol = config().symbolInit; - return nameSymbol == initSymbol; - } - return false; - } - - @Override - public int getMaxLocals() { - if (isAbstract() || isNative()) { - return 0; - } - HotSpotVMConfig config = config(); - return UNSAFE.getChar(getConstMethod() + config.methodMaxLocalsOffset); - } - - @Override - public int getMaxStackSize() { - if (isAbstract() || isNative()) { - return 0; - } - HotSpotVMConfig config = config(); - return config.extraStackEntries + UNSAFE.getChar(getConstMethod() + config.constMethodMaxStackOffset); - } - - @Override - public StackTraceElement asStackTraceElement(int bci) { - if (bci < 0 || bci >= getCodeSize()) { - // HotSpot code can only construct stack trace elements for valid bcis - StackTraceElement ste = compilerToVM().getStackTraceElement(this, 0); - return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); - } - return compilerToVM().getStackTraceElement(this, bci); - } - - @Override - public ResolvedJavaMethod uniqueConcreteMethod(HotSpotResolvedObjectType receiver) { - assert !canBeStaticallyBound() : this; - - if (receiver.isInterface()) { - // Cannot trust interfaces. Because of: - // interface I { void foo(); } - // class A { public void foo() {} } - // class B extends A implements I { } - // class C extends B { public void foo() { } } - // class D extends B { } - // Would lead to identify C.foo() as the unique concrete method for I.foo() without - // seeing A.foo(). - return null; - } - assert !receiver.isLinked() || isInVirtualMethodTable(receiver); - if (this.isDefault()) { - // CHA for default methods doesn't work and may crash the VM - return null; - } - HotSpotResolvedObjectTypeImpl hsReceiver = (HotSpotResolvedObjectTypeImpl) receiver; - return compilerToVM().findUniqueConcreteMethod(hsReceiver, this); - } - - @Override - public HotSpotSignature getSignature() { - return signature; - } - - /** - * Gets the value of {@code Method::_code}. - * - * @return the value of {@code Method::_code} - */ - private long getCompiledCode() { - HotSpotVMConfig config = config(); - return UNSAFE.getAddress(getMethodPointer() + config.methodCodeOffset); - } - - /** - * Returns whether this method has compiled code. - * - * @return true if this method has compiled code, false otherwise - */ - @Override - public boolean hasCompiledCode() { - return getCompiledCode() != 0L; - } - - /** - * @param level - * @return true if the currently installed code was generated at {@code level}. - */ - @Override - public boolean hasCompiledCodeAtLevel(int level) { - long compiledCode = getCompiledCode(); - if (compiledCode != 0) { - return UNSAFE.getByte(compiledCode + config().nmethodCompLevelOffset) == level; - } - return false; - } - - @Override - public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { - ProfilingInfo info; - - if (Option.UseProfilingInformation.getBoolean() && methodData == null) { - long methodDataPointer = UNSAFE.getAddress(getMethodPointer() + config().methodDataOffset); - if (methodDataPointer != 0) { - methodData = new HotSpotMethodData(methodDataPointer, this); - String methodDataFilter = Option.TraceMethodDataFilter.getString(); - if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { - String line = methodData.toString() + System.lineSeparator(); - byte[] lineBytes = line.getBytes(); - HotSpotJVMCIRuntime.runtime().writeDebugOutput(lineBytes, 0, lineBytes.length, true, true); - } - } - } - - if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) { - // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in - // case of a deoptimization. - info = DefaultProfilingInfo.get(TriState.FALSE); - } else { - info = new HotSpotProfilingInfoImpl(methodData, this, includeNormal, includeOSR); - } - return info; - } - - @Override - public void reprofile() { - compilerToVM().reprofile(this); - } - - @Override - public ConstantPool getConstantPool() { - return constantPool; - } - - @Override - public Parameter[] getParameters() { - if (signature.getParameterCount(false) == 0) { - return new ResolvedJavaMethod.Parameter[0]; - } - return runtime().reflection.getParameters(this); - } - - @Override - public Annotation[][] getParameterAnnotations() { - if ((getConstMethodFlags() & config().constMethodHasParameterAnnotations) == 0 || isClassInitializer()) { - return new Annotation[signature.getParameterCount(false)][0]; - } - return runtime().reflection.getParameterAnnotations(this); - } - - @Override - public Annotation[] getAnnotations() { - if (!hasAnnotations()) { - return new Annotation[0]; - } - return runtime().reflection.getMethodAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!hasAnnotations()) { - return new Annotation[0]; - } - return runtime().reflection.getMethodDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!hasAnnotations()) { - return null; - } - return runtime().reflection.getMethodAnnotation(this, annotationClass); - } - - /** - * Returns whether this method has annotations. - */ - private boolean hasAnnotations() { - return (getConstMethodFlags() & config().constMethodHasMethodAnnotations) != 0 && !isClassInitializer(); - } - - @Override - public boolean isBridge() { - return (BRIDGE & getModifiers()) != 0; - } - - @Override - public boolean isSynthetic() { - return (SYNTHETIC & getModifiers()) != 0; - } - - @Override - public boolean isVarArgs() { - return (VARARGS & getModifiers()) != 0; - } - - @Override - public boolean isDefault() { - // Copied from java.lang.Method.isDefault() - int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC; - return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface(); - } - - /* - * Currently in hotspot a method can either be a "normal" or an "overpass" - * method. Overpass methods are instance methods which are created when - * otherwise a valid candidate for method resolution would not be found. - */ - @Override - public boolean isDeclared() { - if (isConstructor() || isClassInitializer()) { - return false; - } - return (getConstMethodFlags() & config().constMethodFlagsIsOverpass) == 0; - } - - @Override - public Type[] getGenericParameterTypes() { - if (isClassInitializer()) { - return new Type[0]; - } - return runtime().reflection.getGenericParameterTypes(this); - } - - @Override - public boolean canBeInlined() { - if (isForceInline()) { - return true; - } - if (hasNeverInlineDirective()) { - return false; - } - return compilerToVM().isCompilable(this); - } - - @Override - public boolean hasNeverInlineDirective() { - return compilerToVM().hasNeverInlineDirective(this); - } - - @Override - public boolean shouldBeInlined() { - if (isForceInline()) { - return true; - } - return compilerToVM().shouldInlineMethod(this); - } - - @Override - public LineNumberTable getLineNumberTable() { - final boolean hasLineNumberTable = (getConstMethodFlags() & config().constMethodHasLineNumberTable) != 0; - if (!hasLineNumberTable) { - return null; - } - - long[] values = compilerToVM().getLineNumberTable(this); - if (values == null || values.length == 0) { - // Empty table so treat is as non-existent - return null; - } - assert values.length % 2 == 0; - int[] bci = new int[values.length / 2]; - int[] line = new int[values.length / 2]; - - for (int i = 0; i < values.length / 2; i++) { - bci[i] = (int) values[i * 2]; - line[i] = (int) values[i * 2 + 1]; - } - - return new LineNumberTable(line, bci); - } - - @Override - public LocalVariableTable getLocalVariableTable() { - final boolean hasLocalVariableTable = (getConstMethodFlags() & config().constMethodHasLocalVariableTable) != 0; - if (!hasLocalVariableTable) { - return null; - } - - HotSpotVMConfig config = config(); - long localVariableTableElement = compilerToVM().getLocalVariableTableStart(this); - final int localVariableTableLength = compilerToVM().getLocalVariableTableLength(this); - Local[] locals = new Local[localVariableTableLength]; - - for (int i = 0; i < localVariableTableLength; i++) { - final int startBci = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementStartBciOffset); - final int endBci = startBci + UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset) - 1; - final int nameCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementNameCpIndexOffset); - final int typeCpIndex = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementDescriptorCpIndexOffset); - final int slot = UNSAFE.getChar(localVariableTableElement + config.localVariableTableElementSlotOffset); - - String localName = getConstantPool().lookupUtf8(nameCpIndex); - String localType = getConstantPool().lookupUtf8(typeCpIndex); - - locals[i] = new Local(localName, runtime().lookupType(localType, holder, false), startBci, endBci, slot); - - // Go to the next LocalVariableTableElement - localVariableTableElement += config.localVariableTableElementSize; - } - - return new LocalVariableTable(locals); - } - - /** - * Returns the offset of this method into the v-table. The method must have a v-table entry as - * indicated by {@link #isInVirtualMethodTable(ResolvedJavaType)}, otherwise an exception is - * thrown. - * - * @return the offset of this method into the v-table - */ - @Override - public int vtableEntryOffset(ResolvedJavaType resolved) { - if (!isInVirtualMethodTable(resolved)) { - throw new JVMCIError("%s does not have a vtable entry in type %s", this, resolved); - } - HotSpotVMConfig config = config(); - final int vtableIndex = getVtableIndex((HotSpotResolvedObjectTypeImpl) resolved); - return config.klassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset; - } - - @Override - public boolean isInVirtualMethodTable(ResolvedJavaType resolved) { - if (resolved instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl hotspotResolved = (HotSpotResolvedObjectTypeImpl) resolved; - int vtableIndex = getVtableIndex(hotspotResolved); - return vtableIndex >= 0 && vtableIndex < hotspotResolved.getVtableLength(); - } - return false; - } - - private int getVtableIndex(HotSpotResolvedObjectTypeImpl resolved) { - if (!holder.isLinked()) { - return config().invalidVtableIndex; - } - if (holder.isInterface()) { - if (resolved.isInterface() || !resolved.isLinked() || !getDeclaringClass().isAssignableFrom(resolved)) { - return config().invalidVtableIndex; - } - return getVtableIndexForInterfaceMethod(resolved); - } - return getVtableIndex(); - } - - /** - * Returns this method's virtual table index. - * - * @return virtual table index - */ - private int getVtableIndex() { - assert !holder.isInterface(); - HotSpotVMConfig config = config(); - int result = UNSAFE.getInt(getMethodPointer() + config.methodVtableIndexOffset); - assert result >= config.nonvirtualVtableIndex : "must be linked"; - return result; - } - - private int getVtableIndexForInterfaceMethod(ResolvedJavaType resolved) { - HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; - return compilerToVM().getVtableIndexForInterfaceMethod(hotspotType, this); - } - - @Override - public SpeculationLog getSpeculationLog() { - long address = compilerToVM().getFailedSpeculationsAddress(this); - return new HotSpotSpeculationLog(address); - } - - @Override - public int intrinsicId() { - HotSpotVMConfig config = config(); - return UNSAFE.getChar(getMethodPointer() + config.methodIntrinsicIdOffset); - } - - @Override - public boolean isIntrinsicCandidate() { - return (getConstMethodFlags() & config().constMethodFlagsIntrinsicCandidate) != 0; - } - - /** - * Allocates a compile id for this method by asking the VM for one. - * - * @param entryBCI entry bci - * @return compile id - */ - @Override - public int allocateCompileId(int entryBCI) { - return compilerToVM().allocateCompileId(this, entryBCI); - } - - @Override - public boolean hasCodeAtLevel(int entryBCI, int level) { - if (entryBCI == config().invocationEntryBci) { - return hasCompiledCodeAtLevel(level); - } - return compilerToVM().hasCompiledCodeForOSR(this, entryBCI, level); - } - - @Override - public int methodIdnum() { - return UNSAFE.getChar(getConstMethod() + config().constMethodMethodIdnumOffset); - } - - @Override - public AnnotationData getAnnotationData(ResolvedJavaType type) { - if (!hasAnnotations()) { - checkIsAnnotation(type); - return null; - } - return getFirstAnnotationOrNull(getAnnotationData0(type)); - } - - @Override - public List getAnnotationData(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - checkIsAnnotation(type1); - checkIsAnnotation(type2); - checkAreAnnotations(types); - if (!hasAnnotations()) { - return List.of(); - } - return getAnnotationData0(AnnotationDataDecoder.asArray(type1, type2, types)); - } - - private List getAnnotationData0(ResolvedJavaType... filter) { - byte[] encoded = compilerToVM().getEncodedExecutableAnnotationData(this, filter); - return VMSupport.decodeAnnotations(encoded, AnnotationDataDecoder.INSTANCE); - } - - @Override - public BitSet getOopMapAt(int bci) { - if (getCodeSize() == 0) { - throw new IllegalArgumentException("has no bytecode"); - } - int nwords = ((getMaxLocals() + getMaxStackSize() - 1) / 64) + 1; - long[] oopMap = new long[nwords]; - compilerToVM().getOopMapAt(this, bci, oopMap); - return BitSet.valueOf(oopMap); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java deleted file mode 100644 index e8c7107cd89..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaType.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.List; - -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaType; - -public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { - - HotSpotResolvedObjectType arrayOfType; - - protected HotSpotResolvedJavaType(String name) { - super(name); - } - - @Override - public abstract boolean equals(Object obj); - - @Override - public int hashCode() { - return getName().hashCode(); - } - - /** - * Gets the runtime representation of the {@link Class} object of this type. - */ - public abstract JavaConstant getJavaMirror(); - - /** - * Gets the array type of this type without caching the result. - */ - protected abstract HotSpotResolvedObjectType getArrayType(); - - @Override - public HotSpotResolvedObjectType getArrayClass() { - if (arrayOfType == null) { - arrayOfType = getArrayType(); - } - return arrayOfType; - } - - /** - * Checks whether this type is currently being initialized. If a type is being initialized it - * implies that it was {@link #isLinked() linked} and that the static initializer is currently - * being run. - * - * @return {@code true} if this type is being initialized - */ - protected abstract boolean isBeingInitialized(); - - static void checkIsAnnotation(ResolvedJavaType type) { - if (!type.isAnnotation()) { - throw new IllegalArgumentException(type.toJavaName() + " is not an annotation interface"); - } - } - - static void checkAreAnnotations(ResolvedJavaType... types) { - for (ResolvedJavaType type : types) { - checkIsAnnotation(type); - } - } - - static AnnotationData getFirstAnnotationOrNull(List list) { - return list.isEmpty() ? null : list.get(0); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java deleted file mode 100644 index 5cad3d05bf5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectType.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. - */ -public interface HotSpotResolvedObjectType extends ResolvedJavaType { - - @Override - HotSpotResolvedObjectType getArrayClass(); - - @Override - ResolvedJavaType getComponentType(); - - @Override - AssumptionResult findLeafConcreteSubtype(); - - @Override - HotSpotResolvedObjectType getSuperclass(); - - @Override - HotSpotResolvedObjectType[] getInterfaces(); - - HotSpotResolvedObjectType getSupertype(); - - @Override - HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType); - - @Override - default boolean isPrimitive() { - return false; - } - - @Override - default JavaKind getJavaKind() { - return JavaKind.Object; - } - - ConstantPool getConstantPool(); - - /** - * Gets the instance size of this type. If an instance of this type cannot be fast path - * allocated, then the returned value is negative (its absolute value gives the size). Must not - * be called if this is an array or interface type. - */ - int instanceSize(); - - int getVtableLength(); - - @Override - AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method); - - /** - * Gets the runtime representation of the {@link Class} object of this type. - */ - default JavaConstant getJavaMirror() { - throw new UnsupportedOperationException("getJavaMirror"); - } - - /** - * Performs a fast-path check that this type is resolved in the context of a given accessing - * class. A negative result does not mean this type is not resolved with respect to - * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) - * re-resolving} the type. - */ - boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass); - - /** - * Gets the metaspace Klass boxed in a {@link JavaConstant}. - */ - Constant klass(); - - boolean isPrimaryType(); - - int superCheckOffset(); - - long prototypeMarkWord(); - - int layoutHelper(); - - @Override - HotSpotResolvedObjectType getEnclosingType(); - - @Override - ResolvedJavaMethod getClassInitializer(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java deleted file mode 100644 index 6074b2b32dc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ /dev/null @@ -1,1148 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.Objects.requireNonNull; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotConstantPool.isSignaturePolymorphicHolder; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmClassModifiers; -import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.ByteOrder; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; - -import jdk.internal.vm.VMSupport; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.Assumptions.ConcreteMethod; -import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; -import jdk.vm.ci.meta.Assumptions.LeafType; -import jdk.vm.ci.meta.Assumptions.NoFinalizableSubclass; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.UnresolvedJavaField; -import jdk.vm.ci.meta.UnresolvedJavaType; - -/** - * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. This class is not - * an {@link MetaspaceHandleObject} because it doesn't have to be scanned for GC. It's liveness is - * maintained by a reference to the {@link Class} instance. - */ -final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, MetaspaceObject { - - private static final HotSpotResolvedJavaField[] NO_FIELDS = new HotSpotResolvedJavaField[0]; - private static final int METHOD_CACHE_ARRAY_CAPACITY = 8; - - /** - * The {@code Klass*} of this type. - */ - private final long klassPointer; - - private HotSpotResolvedJavaMethodImpl[] methodCacheArray; - private HashMap methodCacheHashMap; - private volatile HotSpotResolvedJavaField[] instanceFields; - private volatile HotSpotResolvedObjectTypeImpl[] interfaces; - private HotSpotConstantPool constantPool; - private final JavaConstant mirror; - private HotSpotResolvedObjectTypeImpl superClass; - - /** - * Lazily initialized cache for {@link #getComponentType()}. Set to {@code this}, if this has no - * component type (i.e., this is an non-array type). - */ - private HotSpotResolvedJavaType componentType; - - /** - * Lazily initialized cache for FieldInfo. - */ - private FieldInfo[] fieldInfo; - - /** - * Managed exclusively by {@link HotSpotJDKReflection#getField}. - */ - HashMap reflectionFieldCache; - - static HotSpotResolvedObjectTypeImpl getJavaLangObject() { - return runtime().getJavaLangObject(); - } - - /** - * Gets the JVMCI mirror from a HotSpot type. - * - * Called from the VM. - * - * @param klassPointer a native pointer to the Klass* - * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} - */ - @SuppressWarnings("unused") - @VMEntryPoint - private static HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer) { - return runtime().fromMetaspace(klassPointer); - } - - /** - * Creates the JVMCI mirror for a {@link Class} object. - * - * NOTE: Creating an instance of this class does not install the mirror for the - * {@link Class} type. - *

- * - * @param klass the {@code Klass*} for the type - */ - @SuppressWarnings("try") - HotSpotResolvedObjectTypeImpl(long klass, String name) { - super(name); - assert klass != 0; - this.klassPointer = klass; - - // The mirror object must be in the global scope since - // this object will be cached in HotSpotJVMCIRuntime.resolvedJavaTypes - // and live across more than one compilation. - try (HotSpotObjectConstantScope global = HotSpotObjectConstantScope.enterGlobalScope()) { - this.mirror = runtime().compilerToVm.getJavaMirror(this); - assert getName().charAt(0) != '[' || isArray() : getName(); - } - } - - /** - * Gets the {@code Klass*} for this type. - */ - long getKlassPointer() { - long metaspacePointer = getMetaspacePointer(); - if (metaspacePointer == 0) { - throw new NullPointerException("Klass* is null"); - } - return metaspacePointer; - } - - @Override - public long getMetaspacePointer() { - return klassPointer; - } - - @Override - public int getModifiers() { - if (isArray()) { - return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT; - } else { - return getAccessFlags() & jvmClassModifiers(); - } - } - - public int getAccessFlags() { - if (isArray()) { - return 0; // Array Metadata doesn't set access_flags - } else { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getKlassPointer() + config.instanceKlassAccessFlagsOffset); - } - } - - public int getMiscFlags() { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getKlassPointer() + config.klassMiscFlagsOffset); - } - - @Override - public ResolvedJavaType getComponentType() { - if (componentType == null) { - if (isArray()) { - componentType = runtime().compilerToVm.getComponentType(this); - } else { - componentType = this; - } - } - return this.equals(componentType) ? null : componentType; - } - - @Override - public AssumptionResult findLeafConcreteSubtype() { - if (isLeaf()) { - // No assumptions are required. - return new AssumptionResult<>(this); - } - HotSpotVMConfig config = config(); - if (isArray()) { - ResolvedJavaType elementalType = getElementalType(); - AssumptionResult elementType = elementalType.findLeafConcreteSubtype(); - if (elementType != null && elementType.getResult().equals(elementalType)) { - /* - * If the elementType is leaf then the array is leaf under the same assumptions but - * only if the element type is exactly the leaf type. The element type can be - * abstract even if there is only one implementor of the abstract type. - */ - AssumptionResult result = new AssumptionResult<>(this); - result.add(elementType); - return result; - } - return null; - } else if (isInterface()) { - HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); - /* - * If the implementor field contains itself that indicates that the interface has more - * than one implementors (see: InstanceKlass::add_implementor). - */ - if (implementor == null || implementor.equals(this)) { - return null; - } - - assert !implementor.isInterface(); - if (implementor.isAbstract() || !implementor.isLeafClass()) { - AssumptionResult leafConcreteSubtype = implementor.findLeafConcreteSubtype(); - if (leafConcreteSubtype != null) { - assert !leafConcreteSubtype.getResult().equals(implementor); - AssumptionResult newResult = new AssumptionResult<>(leafConcreteSubtype.getResult(), new ConcreteSubtype(this, implementor)); - // Accumulate leaf assumptions and return the combined result. - newResult.add(leafConcreteSubtype); - return newResult; - } - return null; - } - return concreteSubtype(implementor); - } else { - HotSpotResolvedObjectTypeImpl type = this; - while (type.isAbstract()) { - HotSpotResolvedObjectTypeImpl subklass = type.getSubklass(); - if (subklass == null) { - return null; - } - if (compilerToVM().getResolvedJavaType(subklass, config.nextSiblingOffset, false) != null) { - return null; - } - type = subklass; - } - if (type.isAbstract() || type.isInterface() || !type.isLeafClass()) { - return null; - } - if (this.isAbstract()) { - return concreteSubtype(type); - } else { - assert this.equals(type); - return new AssumptionResult<>(type, new LeafType(type)); - } - } - } - - private AssumptionResult concreteSubtype(HotSpotResolvedObjectTypeImpl type) { - if (type.isLeaf()) { - return new AssumptionResult<>(type, new ConcreteSubtype(this, type)); - } else { - return new AssumptionResult<>(type, new LeafType(type), new ConcreteSubtype(this, type)); - } - } - - /** - * Returns if type {@code type} is a leaf class. This is the case if the - * {@code Klass::_subklass} field of the underlying class is zero. - * - * @return true if the type is a leaf class - */ - private boolean isLeafClass() { - // In general, compilerToVM().getResolvedJavaType should always be used to read a Klass* - // from HotSpot data structures but that has the side effect of creating a strong reference - // to the Class which we do not want since it can cause class unloading problems. Since - // this code is only checking for null vs non-null so it should be safe to perform this - // check directly. - return UNSAFE.getLong(this.getKlassPointer() + config().subklassOffset) == 0; - } - - /** - * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given - * type {@code type}. - * - * @return value of the subklass field as metaspace klass pointer - */ - private HotSpotResolvedObjectTypeImpl getSubklass() { - return compilerToVM().getResolvedJavaType(this, config().subklassOffset, false); - } - - @Override - public HotSpotResolvedObjectTypeImpl getSuperclass() { - if (isInterface()) { - return null; - } - HotSpotResolvedObjectTypeImpl javaLangObject = runtime().getJavaLangObject(); - if (this.equals(javaLangObject)) { - return null; - } - if (isArray()) { - return javaLangObject; - } - - // Cache result of native call - if (superClass == null) { - superClass = compilerToVM().getResolvedJavaType(this, config().superOffset, false); - } - return superClass; - } - - @Override - public HotSpotResolvedObjectTypeImpl[] getInterfaces() { - if (interfaces == null) { - if (isArray()) { - HotSpotResolvedObjectTypeImpl[] types = new HotSpotResolvedObjectTypeImpl[2]; - types[0] = runtime().getJavaLangCloneable(); - types[1] = runtime().getJavaLangSerializable(); - this.interfaces = types; - } else { - interfaces = runtime().compilerToVm.getInterfaces(this); - } - } - return interfaces; - } - - @Override - public HotSpotResolvedObjectTypeImpl getSingleImplementor() { - if (!isInterface()) { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); - } - return compilerToVM().getImplementor(this); - } - - @Override - public HotSpotResolvedObjectTypeImpl getSupertype() { - ResolvedJavaType component = getComponentType(); - if (component != null) { - if (component.equals(getJavaLangObject()) || component.isPrimitive()) { - return getJavaLangObject(); - } - HotSpotResolvedObjectTypeImpl supertype = ((HotSpotResolvedObjectTypeImpl) component).getSupertype(); - return (HotSpotResolvedObjectTypeImpl) supertype.getArrayClass(); - } - if (isInterface()) { - return getJavaLangObject(); - } - return getSuperclass(); - } - - @Override - public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType) { - if (otherType.isPrimitive()) { - return null; - } else { - HotSpotResolvedObjectTypeImpl t1 = this; - HotSpotResolvedObjectTypeImpl t2 = (HotSpotResolvedObjectTypeImpl) otherType; - while (true) { - if (t1.isAssignableFrom(t2)) { - return t1; - } - if (t2.isAssignableFrom(t1)) { - return t2; - } - t1 = t1.getSupertype(); - t2 = t2.getSupertype(); - } - } - } - - @Override - public AssumptionResult hasFinalizableSubclass() { - assert !isArray(); - if (!compilerToVM().hasFinalizableSubclass(this)) { - return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); - } - return new AssumptionResult<>(true); - } - - @Override - public boolean hasFinalizer() { - return (getMiscFlags() & config().jvmAccHasFinalizer) != 0; - } - - @Override - public boolean isArray() { - return layoutHelper() < config().klassLayoutHelperNeutralValue; - } - - @Override - public boolean isEnum() { - HotSpotResolvedObjectTypeImpl superclass = getSuperclass(); - return superclass != null && superclass.equals(runtime().getJavaLangEnum()); - } - - @Override - public boolean isInitialized() { - return isArray() ? true : getInitState() == config().instanceKlassStateFullyInitialized; - } - - @Override - public boolean isBeingInitialized() { - return isArray() ? false : getInitState() == config().instanceKlassStateBeingInitialized; - } - - @Override - public boolean isLinked() { - return isArray() ? true : getInitState() >= config().instanceKlassStateLinked; - } - - @Override - public void link() { - if (!isLinked()) { - runtime().compilerToVm.ensureLinked(this); - } - } - - @Override - public boolean hasDefaultMethods() { - HotSpotVMConfig config = config(); - int miscFlags = UNSAFE.getChar(getKlassPointer() + config.instanceKlassMiscFlagsOffset); - return (miscFlags & config.jvmMiscFlagsHasDefaultMethods) != 0; - } - - @Override - public boolean declaresDefaultMethods() { - HotSpotVMConfig config = config(); - int miscFlags = UNSAFE.getChar(getKlassPointer() + config.instanceKlassMiscFlagsOffset); - return (miscFlags & config.jvmMiscFlagsDeclaresDefaultMethods) != 0; - } - - /** - * Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace - * klass. - * - * @return state field value of this type - */ - private int getInitState() { - assert !isArray() : "_init_state only exists in InstanceKlass"; - return UNSAFE.getByte(getKlassPointer() + config().instanceKlassInitStateOffset) & 0xFF; - } - - @Override - public void initialize() { - if (!isInitialized()) { - runtime().compilerToVm.ensureInitialized(this); - assert isInitialized() || isBeingInitialized(); - } - } - - @Override - public boolean isInstance(JavaConstant obj) { - if (obj.getJavaKind() == JavaKind.Object && !obj.isNull()) { - return runtime().reflection.isInstance(this, (HotSpotObjectConstantImpl) obj); - } - return false; - } - - @Override - public boolean isInstanceClass() { - return !isArray() && !isInterface(); - } - - @Override - public boolean isInterface() { - return (getAccessFlags() & config().jvmAccInterface) != 0; - } - - @Override - public boolean isAssignableFrom(ResolvedJavaType other) { - assert other != null; - if (other instanceof HotSpotResolvedObjectTypeImpl) { - HotSpotResolvedObjectTypeImpl otherType = (HotSpotResolvedObjectTypeImpl) other; - return runtime().reflection.isAssignableFrom(this, otherType); - } - return false; - } - - @Override - public boolean isJavaLangObject() { - return getName().equals("Ljava/lang/Object;"); - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - assert !callerType.isArray(); - if (isInterface()) { - // Methods can only be resolved against concrete types - return null; - } - if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic() && !isSignaturePolymorphicHolder(method.getDeclaringClass())) { - return method; - } - if (!method.getDeclaringClass().isAssignableFrom(this)) { - return null; - } - if (method.isConstructor()) { - // Constructor calls should have been checked in the verifier and method's - // declaring class is assignable from this (see above) so treat it as resolved. - return method; - } - HotSpotResolvedJavaMethodImpl hotSpotMethod = (HotSpotResolvedJavaMethodImpl) method; - HotSpotResolvedObjectTypeImpl hotSpotCallerType = (HotSpotResolvedObjectTypeImpl) callerType; - return compilerToVM().resolveMethod(this, hotSpotMethod, hotSpotCallerType); - } - - @Override - public HotSpotConstantPool getConstantPool() { - if (constantPool == null || !isArray() && UNSAFE.getAddress(getKlassPointer() + config().instanceKlassConstantsOffset) != constantPool.getConstantPoolPointer()) { - /* - * If the pointer to the ConstantPool has changed since this was last read refresh the - * HotSpotConstantPool wrapper object. This ensures that uses of the constant pool are - * operating on the latest one and that HotSpotResolvedJavaMethodImpls will be able to - * use the shared copy instead of creating their own instance. - */ - constantPool = compilerToVM().getConstantPool(this); - } - return constantPool; - } - - /** - * Gets the instance size of this type. If an instance of this type cannot be fast path - * allocated, then the returned value is negative (its absolute value gives the size). Must not - * be called if this is an array or interface type. - */ - @Override - public int instanceSize() { - assert !isArray(); - assert !isInterface(); - - HotSpotVMConfig config = config(); - final int layoutHelper = layoutHelper(); - assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; - - // See: Klass::layout_helper_size_in_bytes - int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; - - // See: Klass::layout_helper_needs_slow_path - boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; - - return needsSlowPath ? -size : size; - } - - @Override - public int layoutHelper() { - HotSpotVMConfig config = config(); - assert getKlassPointer() != 0 : getName(); - return UNSAFE.getInt(getKlassPointer() + config.klassLayoutHelperOffset); - } - - synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceHandle) { - long metaspaceMethod = UNSAFE.getLong(metaspaceHandle); - // Maintain cache as array. - if (methodCacheArray == null) { - methodCacheArray = new HotSpotResolvedJavaMethodImpl[METHOD_CACHE_ARRAY_CAPACITY]; - } - - int i = 0; - for (; i < methodCacheArray.length; ++i) { - HotSpotResolvedJavaMethodImpl curMethod = methodCacheArray[i]; - if (curMethod == null) { - HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceHandle); - methodCacheArray[i] = newMethod; - return newMethod; - } else if (curMethod.getMethodPointer() == metaspaceMethod) { - return curMethod; - } - } - - // Fall-back to hash table. - if (methodCacheHashMap == null) { - methodCacheHashMap = new HashMap<>(); - } - - HotSpotResolvedJavaMethodImpl lookupResult = methodCacheHashMap.get(metaspaceMethod); - if (lookupResult == null) { - HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceHandle); - methodCacheHashMap.put(metaspaceMethod, newMethod); - return newMethod; - } else { - return lookupResult; - } - } - - @Override - public int getVtableLength() { - HotSpotVMConfig config = config(); - if (isInterface() || isArray()) { - /* Everything has the core vtable of java.lang.Object */ - return config.baseVtableLength(); - } - int result = UNSAFE.getInt(getKlassPointer() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); - assert result >= config.baseVtableLength() : UNSAFE.getInt(getKlassPointer() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize; - return result; - } - - HotSpotResolvedJavaField createField(JavaType type, int offset, int classfileFlags, int internalFlags, int index) { - return new HotSpotResolvedJavaFieldImpl(this, type, offset, classfileFlags, internalFlags, index); - } - - @Override - public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { - HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; - HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); - /* - * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared - * holder, usually because of phis, so make sure that the type is related to the declared - * type before using it for lookup. Unlinked types should also be ignored because we can't - * resolve the proper method to invoke. Generally unlinked types in invokes should result in - * a deopt instead since they can't really be used if they aren't linked yet. - */ - if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) { - if (hmethod.canBeStaticallyBound()) { - // No assumptions are required. - return new AssumptionResult<>(hmethod); - } - ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder); - if (result != null) { - return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result)); - } - return null; - } - /* - * The holder may be a subtype of the declaredHolder so make sure to resolve the method to - * the correct method for the subtype. - */ - HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) resolveMethod(hmethod, this); - if (resolvedMethod == null) { - // The type isn't known to implement the method. - return null; - } - if (resolvedMethod.canBeStaticallyBound()) { - // No assumptions are required. - return new AssumptionResult<>(resolvedMethod); - } - - ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this); - if (result != null) { - return new AssumptionResult<>(result, new ConcreteMethod(method, this, result)); - } - return null; - } - - private FieldInfo[] getFieldInfo() { - if (fieldInfo == null) { - fieldInfo = runtime().compilerToVm.getDeclaredFieldsInfo(this); - } - return fieldInfo; - } - - FieldInfo getFieldInfo(int index) { - return getFieldInfo()[index]; - } - - public void ensureInitialized() { - runtime().compilerToVm.ensureInitialized(this); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof HotSpotResolvedObjectTypeImpl)) { - return false; - } - HotSpotResolvedObjectTypeImpl that = (HotSpotResolvedObjectTypeImpl) obj; - return getKlassPointer() == that.getKlassPointer(); - } - - @Override - public JavaConstant getJavaMirror() { - return mirror; - } - - @Override - protected HotSpotResolvedObjectTypeImpl getArrayType() { - return runtime().compilerToVm.getArrayType((char) 0, this); - } - - /** - * This class represents the field information for one field contained in the fields array of an - * {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. - */ - static class FieldInfo { - - private final int nameIndex; - private final int signatureIndex; - private final int offset; - private final int classfileFlags; - private final int internalFlags; - private final int initializerIndex; - - /** - * Creates a field info with the provided indices. - * - * @param nameIndex index of field's name in the constant pool - * @param signatureIndex index of field's signature in the constant pool - * @param offset field's offset - * @param classfileFlags field's access flags (from the class file) - * @param internalFlags field's internal flags (from the VM) - * @param initializerIndex field's initial value index in the constant pool - */ - FieldInfo(int nameIndex, int signatureIndex, int offset, int classfileFlags, int internalFlags, int initializerIndex) { - this.nameIndex = nameIndex; - this.signatureIndex = signatureIndex; - this.offset = offset; - this.classfileFlags = classfileFlags; - this.internalFlags = internalFlags; - this.initializerIndex = initializerIndex; - } - - private int getClassfileFlags() { - return classfileFlags; - } - - private int getInternalFlags() { - return internalFlags; - } - - private int getNameIndex() { - return nameIndex; - } - - private int getSignatureIndex() { - return signatureIndex; - } - - private int getConstantValueIndex() { - return initializerIndex; - } - - public int getOffset() { - return offset; - } - - /** - * Returns the name of this field as a {@link String}. If the field is an internal field the - * name index is pointing into the vmSymbols table. - * @param klass field's holder class - */ - public String getName(HotSpotResolvedObjectTypeImpl klass) { - return isInternal() ? config().symbolAt(nameIndex) : klass.getConstantPool().lookupUtf8(nameIndex); - } - - /** - * Returns the signature of this field as {@link String}. If the field is an internal field - * the signature index is pointing into the vmSymbols table. - * @param klass field's holder class - */ - public String getSignature(HotSpotResolvedObjectTypeImpl klass) { - return isInternal() ? config().symbolAt(signatureIndex) : klass.getConstantPool().lookupUtf8(signatureIndex); - } - - /** - * Gets the {@link JavaConstant} for the {@code ConstantValue} attribute of this field. - * - * @return {@code null} if this field has no {@code ConstantValue} attribute - */ - public JavaConstant getConstantValue(HotSpotResolvedObjectTypeImpl klass) { - if (initializerIndex == 0) { - return null; - } - return klass.constantPool.getStaticFieldConstantValue(initializerIndex); - } - - public JavaType getType(HotSpotResolvedObjectTypeImpl klass) { - String signature = getSignature(klass); - return runtime().lookupType(signature, klass, false); - } - - private boolean isInternal() { - return (getInternalFlags() & (1 << config().jvmFieldFlagInternalShift)) != 0; - } - - public boolean isStatic() { - return Modifier.isStatic(getClassfileFlags()); - } - } - - @Override - public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { - if (instanceFields == null) { - if (isArray() || isInterface()) { - instanceFields = NO_FIELDS; - } else { - HotSpotResolvedJavaField[] prepend = NO_FIELDS; - if (getSuperclass() != null) { - prepend = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); - } - instanceFields = getFields(false, prepend); - } - } - if (!includeSuperclasses && getSuperclass() != null) { - int superClassFieldCount = getSuperclass().getInstanceFields(true).length; - if (superClassFieldCount == instanceFields.length) { - // This class does not have any instance fields of its own. - return NO_FIELDS; - } else if (superClassFieldCount != 0) { - // Fields of the current class can be interleaved with fields of its super-classes - // but the array of fields to be returned must be sorted by increasing offset - // This code populates the array, then applies the sorting function - HotSpotResolvedJavaField[] result = new HotSpotResolvedJavaField[instanceFields.length - superClassFieldCount]; - int i = 0; - for (HotSpotResolvedJavaField f : instanceFields) { - if (f.getDeclaringClass() == this) { - result[i++] = f; - } - } - return result; - } else { - // The super classes of this class do not have any instance fields. - } - } - return instanceFields; - } - - @Override - public ResolvedJavaField[] getStaticFields() { - if (isArray()) { - return new HotSpotResolvedJavaField[0]; - } else { - return getFields(true, NO_FIELDS); - } - } - - /** - * Gets the instance or static fields of this class. - * - * @param retrieveStaticFields specifies whether to return instance or static fields - * @param prepend an array to be prepended to the returned result - */ - private HotSpotResolvedJavaField[] getFields(boolean retrieveStaticFields, HotSpotResolvedJavaField[] prepend) { - HotSpotVMConfig config = config(); - int resultCount = 0; - int index = 0; - - for (index = 0; index < getFieldInfo().length; index++) { - if (getFieldInfo(index).isStatic() == retrieveStaticFields) { - resultCount++; - } - } - - if (resultCount == 0) { - return prepend; - } - - int prependLength = prepend.length; - resultCount += prependLength; - - HotSpotResolvedJavaField[] result = new HotSpotResolvedJavaField[resultCount]; - if (prependLength != 0) { - System.arraycopy(prepend, 0, result, 0, prependLength); - } - - // Fields of the current class can be interleaved with fields of its super-classes - // but the array of fields to be returned must be sorted by increasing offset - // This code populates the array, then applies the sorting function - int resultIndex = prependLength; - for (int i = 0; i < getFieldInfo().length; ++i) { - FieldInfo field = getFieldInfo(i); - if (field.isStatic() == retrieveStaticFields) { - int offset = field.getOffset(); - HotSpotResolvedJavaField resolvedJavaField = createField(field.getType(this), offset, field.getClassfileFlags(), field.getInternalFlags(), i); - result[resultIndex++] = resolvedJavaField; - } - } - return result; - } - - @Override - public String getSourceFileName() { - if (isArray()) { - return null; - } - return getConstantPool().getSourceFileName(); - } - - /** - * Determines if this type may have annotations. A positive result does not mean this type has - * annotations but a negative result guarantees this type has no annotations. - * - * @param includingInherited if true, expand this query to include superclasses of this type - */ - private boolean mayHaveAnnotations(boolean includingInherited) { - if (isArray()) { - return false; - } - HotSpotVMConfig config = config(); - final long metaspaceAnnotations = UNSAFE.getAddress(getKlassPointer() + config.instanceKlassAnnotationsOffset); - if (metaspaceAnnotations != 0) { - long classAnnotations = UNSAFE.getAddress(metaspaceAnnotations + config.annotationsClassAnnotationsOffset); - if (classAnnotations != 0) { - return true; - } - } - if (includingInherited) { - HotSpotResolvedObjectTypeImpl superClass = getSuperclass(); - if (superClass != null) { - return superClass.mayHaveAnnotations(true); - } - } - return false; - } - - private static final Annotation[] NO_ANNOTATIONS = {}; - - @Override - public Annotation[] getAnnotations() { - if (!mayHaveAnnotations(true)) { - return NO_ANNOTATIONS; - } - return runtime().reflection.getAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!mayHaveAnnotations(false)) { - return NO_ANNOTATIONS; - } - return runtime().reflection.getDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!mayHaveAnnotations(true)) { - return null; - } - return runtime().reflection.getAnnotation(this, annotationClass); - } - - /** - * Performs a fast-path check that this type is resolved in the context of a given accessing - * class. A negative result does not mean this type is not resolved with respect to - * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) - * re-resolving} the type. - */ - @Override - public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { - assert accessingClass != null; - ResolvedJavaType elementType = getElementalType(); - if (elementType.isPrimitive()) { - // Primitive type resolution is context free. - return true; - } - if (elementType.getName().startsWith("Ljava/") && hasSameClassLoader(runtime().getJavaLangObject())) { - // Classes in a java.* package defined by the boot class loader are always resolved. - return true; - } - HotSpotResolvedObjectTypeImpl otherMirror = ((HotSpotResolvedObjectTypeImpl) accessingClass); - return hasSameClassLoader(otherMirror); - } - - private boolean hasSameClassLoader(HotSpotResolvedObjectTypeImpl otherMirror) { - return UnsafeAccess.UNSAFE.getAddress(getKlassPointer() + config().classLoaderDataOffset) == UnsafeAccess.UNSAFE.getAddress( - otherMirror.getKlassPointer() + config().classLoaderDataOffset); - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) { - return this; - } - HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass; - return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true); - } - - /** - * Gets the metaspace Klass boxed in a {@link JavaConstant}. - */ - @Override - public Constant klass() { - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); - } - - @Override - public boolean isPrimaryType() { - return config().secondarySuperCacheOffset != superCheckOffset(); - } - - @Override - public int superCheckOffset() { - HotSpotVMConfig config = config(); - return UNSAFE.getInt(getKlassPointer() + config.superCheckOffsetOffset); - } - - @Override - public long prototypeMarkWord() { - HotSpotVMConfig config = config(); - return config.prototypeMarkWord(); - } - - @Override - public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) { - ResolvedJavaField[] declaredFields = getInstanceFields(true); - return findFieldWithOffset(offset, expectedEntryKind, declaredFields); - } - - public ResolvedJavaField findStaticFieldWithOffset(long offset, JavaKind expectedEntryKind) { - ResolvedJavaField[] declaredFields = getStaticFields(); - return findFieldWithOffset(offset, expectedEntryKind, declaredFields); - } - - private static ResolvedJavaField findFieldWithOffset(long offset, JavaKind expectedEntryKind, ResolvedJavaField[] declaredFields) { - for (ResolvedJavaField field : declaredFields) { - long resolvedFieldOffset = field.getOffset(); - // @formatter:off - if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && - expectedEntryKind.isPrimitive() && - !expectedEntryKind.equals(JavaKind.Void) && - field.getJavaKind().isPrimitive()) { - resolvedFieldOffset += - field.getJavaKind().getByteCount() - - Math.min(field.getJavaKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); - } - if (resolvedFieldOffset == offset) { - return field; - } - // @formatter:on - } - return null; - } - - @Override - public boolean isLocal() { - return runtime().reflection.isLocalClass(this); - } - - @Override - public boolean isMember() { - return runtime().reflection.isMemberClass(this); - } - - @Override - public HotSpotResolvedObjectType getEnclosingType() { - return runtime().reflection.getEnclosingClass(this); - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors() { - link(); - return runtime().compilerToVm.getDeclaredConstructors(this); - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors(boolean forceLink) { - if (forceLink) { - link(); - } - return runtime().compilerToVm.getDeclaredConstructors(this); - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods() { - return getDeclaredMethods(true); - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods(boolean forceLink) { - if (forceLink) { - link(); - } - return runtime().compilerToVm.getDeclaredMethods(this); - } - - @Override - public List getAllMethods(boolean forceLink) { - if (forceLink) { - link(); - } - return List.of(runtime().compilerToVm.getAllMethods(this)); - } - - @Override - public ResolvedJavaMethod getClassInitializer() { - if (!isArray()) { - return compilerToVM().getClassInitializer(this); - } - return null; - } - - @Override - public String toString() { - return "HotSpotType<" + getName() + ", resolved>"; - } - - @Override - public ResolvedJavaType lookupType(UnresolvedJavaType unresolvedJavaType, boolean resolve) { - JavaType javaType = HotSpotJVMCIRuntime.runtime().lookupType(unresolvedJavaType.getName(), this, resolve); - if (javaType instanceof ResolvedJavaType) { - return (ResolvedJavaType) javaType; - } - return null; - } - - @Override - public ResolvedJavaField resolveField(UnresolvedJavaField unresolvedJavaField, ResolvedJavaType accessingClass) { - for (ResolvedJavaField field : getInstanceFields(false)) { - if (field.getName().equals(unresolvedJavaField.getName())) { - return field; - } - } - for (ResolvedJavaField field : getStaticFields()) { - if (field.getName().equals(unresolvedJavaField.getName())) { - return field; - } - } - throw new InternalError(unresolvedJavaField.toString()); - } - - @Override - public boolean isCloneableWithAllocation() { - return (getMiscFlags() & config().jvmAccIsCloneableFast) != 0; - } - - @Override - public AnnotationData getAnnotationData(ResolvedJavaType annotationType) { - if (!mayHaveAnnotations(true)) { - checkIsAnnotation(annotationType); - return null; - } - return getFirstAnnotationOrNull(getAnnotationData0(annotationType)); - } - - @Override - public List getAnnotationData(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - if (!mayHaveAnnotations(true)) { - checkIsAnnotation(type1); - checkIsAnnotation(type2); - checkAreAnnotations(types); - return List.of(); - } - return getAnnotationData0(AnnotationDataDecoder.asArray(type1, type2, types)); - } - - private List getAnnotationData0(ResolvedJavaType... filter) { - byte[] encoded = compilerToVM().getEncodedClassAnnotationData(this, filter); - return VMSupport.decodeAnnotations(encoded, AnnotationDataDecoder.INSTANCE); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java deleted file mode 100644 index 9da92713be4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static java.util.Objects.requireNonNull; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Modifier; -import java.util.Collections; -import java.util.List; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link JavaType} for primitive HotSpot types. - */ -public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType { - - static HotSpotResolvedPrimitiveType[] primitives; - - private JavaKind kind; - HotSpotObjectConstantImpl mirror; - - /** - * Creates the JVMCI mirror for a primitive {@link JavaKind}. - * - * @param kind the Kind to create the mirror for - */ - private HotSpotResolvedPrimitiveType(JavaKind kind, HotSpotObjectConstantImpl mirror) { - super(String.valueOf(kind.getTypeChar())); - this.mirror = mirror; - this.kind = kind; - } - - /** - * Returns a primitive type instance corresponding to the given {@link JavaKind}. - * - * @param kind the Java kind of the primitive type - * @return the primitive type instance for the given Java kind - */ - public static HotSpotResolvedPrimitiveType forKind(JavaKind kind) { - HotSpotResolvedPrimitiveType primitive = primitives[kind.getBasicType()]; - assert primitive != null : kind; - return primitive; - } - - @VMEntryPoint - static HotSpotResolvedPrimitiveType fromMetaspace(HotSpotObjectConstantImpl mirror, char typeChar) { - JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(typeChar); - if (primitives == null) { - primitives = new HotSpotResolvedPrimitiveType[JavaKind.Void.getBasicType() + 1]; - } - HotSpotResolvedPrimitiveType result = new HotSpotResolvedPrimitiveType(kind, mirror); - primitives[kind.getBasicType()] = result; - return result; - } - - @Override - public int getModifiers() { - return Modifier.ABSTRACT | Modifier.FINAL | Modifier.PUBLIC; - } - - @Override - protected HotSpotResolvedObjectType getArrayType() { - if (kind == JavaKind.Void) { - return null; - } - return runtime().compilerToVm.getArrayType(getJavaKind().getTypeChar(), null); - } - - @Override - public ResolvedJavaType getElementalType() { - return this; - } - - @Override - public ResolvedJavaType getComponentType() { - return null; - } - - @Override - public ResolvedJavaType getSuperclass() { - return null; - } - - @Override - public ResolvedJavaType[] getInterfaces() { - return new ResolvedJavaType[0]; - } - - @Override - public ResolvedJavaType getSingleImplementor() { - throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); - } - - @Override - public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { - return null; - } - - @Override - public AssumptionResult hasFinalizableSubclass() { - return new AssumptionResult<>(false); - } - - @Override - public boolean hasFinalizer() { - return false; - } - - @Override - public boolean isArray() { - return false; - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public boolean isPrimitive() { - return true; - } - - @Override - public boolean isInitialized() { - return true; - } - - @Override - public boolean isBeingInitialized() { - return false; - } - - @Override - public boolean isLinked() { - return true; - } - - @Override - public boolean isInstance(JavaConstant obj) { - return false; - } - - @Override - public boolean isInstanceClass() { - return false; - } - - @Override - public boolean isInterface() { - return false; - } - - @Override - public boolean isAssignableFrom(ResolvedJavaType other) { - assert other != null; - return other.equals(this); - } - - @Override - public JavaKind getJavaKind() { - return kind; - } - - @Override - public boolean isJavaLangObject() { - return false; - } - - @Override - public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - return null; - } - - @Override - public String toString() { - return "HotSpotResolvedPrimitiveType<" + kind + ">"; - } - - @Override - public AssumptionResult findLeafConcreteSubtype() { - return new AssumptionResult<>(this); - } - - @Override - public AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method) { - return null; - } - - @Override - public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { - return new ResolvedJavaField[0]; - } - - @Override - public ResolvedJavaField[] getStaticFields() { - return new ResolvedJavaField[0]; - } - - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public Annotation[] getDeclaredAnnotations() { - return new Annotation[0]; - } - - @Override - public T getAnnotation(Class annotationClass) { - return null; - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - requireNonNull(accessingClass); - return this; - } - - @Override - public void initialize() { - } - - @Override - public void link() { - } - - @Override - public boolean hasDefaultMethods() { - return false; - } - - @Override - public boolean declaresDefaultMethods() { - return false; - } - - @Override - public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedType) { - return null; - } - - @Override - public String getSourceFileName() { - throw JVMCIError.unimplemented(); - } - - @Override - public boolean isLocal() { - return false; - } - - @Override - public boolean isMember() { - return false; - } - - @Override - public ResolvedJavaType getEnclosingType() { - return null; - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors() { - return new ResolvedJavaMethod[0]; - } - - @Override - public ResolvedJavaMethod[] getDeclaredConstructors(boolean forceLink) { - return new ResolvedJavaMethod[0]; - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods(boolean forceLink) { - return new ResolvedJavaMethod[0]; - } - - @Override - public ResolvedJavaMethod[] getDeclaredMethods() { - return new ResolvedJavaMethod[0]; - } - - @Override - public List getAllMethods(boolean forceLink) { - return List.of(); - } - - @Override - public ResolvedJavaMethod getClassInitializer() { - return null; - } - - @Override - public boolean isCloneableWithAllocation() { - return false; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof HotSpotResolvedPrimitiveType)) { - return false; - } - HotSpotResolvedPrimitiveType that = (HotSpotResolvedPrimitiveType) obj; - return that.kind == kind; - } - - @Override - public JavaConstant getJavaMirror() { - return mirror; - } - - @Override - public AnnotationData getAnnotationData(ResolvedJavaType type) { - checkIsAnnotation(type); - return null; - } - - @Override - public List getAnnotationData(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - checkIsAnnotation(type1); - checkIsAnnotation(type2); - checkAreAnnotations(types); - return List.of(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java deleted file mode 100644 index 0b79a006a40..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotRuntimeStub.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Implementation of {@link InstalledCode} for code installed as a {@code RuntimeStub}. The address - * of the {@code RuntimeStub} is stored in {@link InstalledCode#address} and the value of - * {@code RuntimeStub::entry_point()} is in {@link InstalledCode#entryPoint}. - */ -public class HotSpotRuntimeStub extends HotSpotInstalledCode { - - public HotSpotRuntimeStub(String name) { - super(name); - } - - public ResolvedJavaMethod getMethod() { - return null; - } - - @Override - public boolean isValid() { - return true; - } - - @Override - public void invalidate() { - } - - @Override - public String toString() { - return String.format("InstalledRuntimeStub[stub=%s, codeBlob=0x%x]", name, getAddress()); - } - - @Override - public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { - throw new InternalError("Cannot call stub " + name); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSignature.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSignature.java deleted file mode 100644 index 45565295bc9..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSignature.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.ArrayList; -import java.util.List; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.meta.UnresolvedJavaType; - -/** - * Represents a method signature. - */ -public class HotSpotSignature implements Signature { - - private final List parameters = new ArrayList<>(); - private final String returnType; - private final String originalString; - private ResolvedJavaType[] parameterTypes; - private ResolvedJavaType returnTypeCache; - private final HotSpotJVMCIRuntime runtime; - - public HotSpotSignature(HotSpotJVMCIRuntime runtime, String signature) { - this.runtime = runtime; - if (signature.length() == 0) { - throw new IllegalArgumentException("Signature cannot be empty"); - } - this.originalString = signature; - - if (signature.charAt(0) == '(') { - int cur = 1; - while (cur < signature.length() && signature.charAt(cur) != ')') { - int nextCur = parseSignature(signature, cur); - parameters.add(signature.substring(cur, nextCur)); - cur = nextCur; - } - - cur++; - int nextCur = parseSignature(signature, cur); - returnType = signature.substring(cur, nextCur); - if (nextCur != signature.length()) { - throw new IllegalArgumentException("Extra characters at end of signature: " + signature); - } - } else { - throw new IllegalArgumentException("Signature must start with a '(': " + signature); - } - } - - public HotSpotSignature(HotSpotJVMCIRuntime runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { - this.runtime = runtime; - this.parameterTypes = parameterTypes.clone(); - this.returnTypeCache = returnType; - this.returnType = returnType.getName(); - StringBuilder sb = new StringBuilder("("); - for (JavaType type : parameterTypes) { - parameters.add(type.getName()); - sb.append(type.getName()); - } - sb.append(")").append(returnType.getName()); - this.originalString = sb.toString(); - assert new HotSpotSignature(runtime, originalString).equals(this); - } - - private static int parseSignature(String signature, int start) { - try { - int cur = start; - char first; - do { - first = signature.charAt(cur); - cur++; - } while (first == '['); - - switch (first) { - case 'L': - while (signature.charAt(cur) != ';') { - if (signature.charAt(cur) == '.') { - throw new IllegalArgumentException("Class name in signature contains '.' at index " + cur + ": " + signature); - } - cur++; - } - cur++; - break; - case 'V': - case 'I': - case 'B': - case 'C': - case 'D': - case 'F': - case 'J': - case 'S': - case 'Z': - break; - default: - throw new IllegalArgumentException("Invalid character '" + signature.charAt(cur - 1) + "' at index " + (cur - 1) + " in signature: " + signature); - } - return cur; - } catch (StringIndexOutOfBoundsException e) { - throw new IllegalArgumentException("Truncated signature: " + signature); - } - } - - @Override - public int getParameterCount(boolean withReceiver) { - return parameters.size() + (withReceiver ? 1 : 0); - } - - @Override - public JavaKind getParameterKind(int index) { - return JavaKind.fromTypeString(parameters.get(index)); - } - - private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) { - assert accessingClass != null; - if (type == null) { - return false; - } else if (type instanceof HotSpotResolvedObjectTypeImpl) { - return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass); - } - return true; - } - - private static JavaType getUnresolvedOrPrimitiveType(HotSpotJVMCIRuntime runtime, String name) { - if (name.length() == 1) { - JavaKind kind = JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(kind.toJavaClass()); - } - return UnresolvedJavaType.create(name); - } - - @Override - public JavaType getParameterType(int index, ResolvedJavaType accessingClass) { - if (accessingClass == null) { - // Caller doesn't care about resolution context so return an unresolved - // or primitive type (primitive type resolution is context free) - return getUnresolvedOrPrimitiveType(runtime, parameters.get(index)); - } - if (parameterTypes == null) { - parameterTypes = new ResolvedJavaType[parameters.size()]; - } - - ResolvedJavaType type = parameterTypes[index]; - if (!checkValidCache(type, accessingClass)) { - JavaType result = runtime.lookupType(parameters.get(index), (HotSpotResolvedObjectType) accessingClass, false); - if (result instanceof ResolvedJavaType) { - type = (ResolvedJavaType) result; - parameterTypes[index] = type; - } else { - assert result != null; - return result; - } - } - assert type != null; - return type; - } - - @Override - public String toMethodDescriptor() { - assert originalString.equals(Signature.super.toMethodDescriptor()) : originalString + " != " + Signature.super.toMethodDescriptor(); - return originalString; - } - - @Override - public JavaKind getReturnKind() { - return JavaKind.fromTypeString(returnType); - } - - @Override - public JavaType getReturnType(ResolvedJavaType accessingClass) { - if (accessingClass == null) { - // Caller doesn't care about resolution context so return an unresolved - // or primitive type (primitive type resolution is context free) - return getUnresolvedOrPrimitiveType(runtime, returnType); - } - if (!checkValidCache(returnTypeCache, accessingClass)) { - JavaType result = runtime.lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); - if (result instanceof ResolvedJavaType) { - returnTypeCache = (ResolvedJavaType) result; - } else { - return result; - } - } - return returnTypeCache; - } - - @Override - public String toString() { - return "HotSpotSignature<" + originalString + ">"; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof HotSpotSignature) { - HotSpotSignature other = (HotSpotSignature) obj; - if (other.originalString.equals(originalString)) { - assert other.parameters.equals(parameters); - assert other.returnType.equals(returnType); - return true; - } - } - return false; - } - - @Override - public int hashCode() { - return originalString.hashCode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java deleted file mode 100644 index b730e9bfee1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationEncoding.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.SpeculationLog.SpeculationReasonEncoding; - -/** - * Implements a {@link SpeculationReasonEncoding} that {@linkplain #getByteArray() produces} a byte - * array. Data is added via a {@link DataOutputStream}. When producing the final byte array, if the - * total length of data exceeds {@value HotSpotSpeculationEncoding#MAX_LENGTH}, then a SHA-1 digest - * of the data is produced instead. - */ -final class HotSpotSpeculationEncoding extends ByteArrayOutputStream implements SpeculationReasonEncoding { - - /** - * Number of bits used for the length of an encoded speculation. The bit size of 5 is chosen to - * accommodate specifying // the length of a SHA-1 digest (i.e., 20 bytes). - */ - // Also defined in C++ JVMCINMethodData class - keep in sync. - static final int LENGTH_BITS = 5; - - /** - * The maximum length of an encoded speculation. - */ - static final int MAX_LENGTH = (1 << LENGTH_BITS) - 1; - - static final int LENGTH_MASK = MAX_LENGTH; - - private DataOutputStream dos = new DataOutputStream(this); - private byte[] result; - - HotSpotSpeculationEncoding() { - super(SHA1_LENGTH); - } - - private void checkOpen() { - if (result != null) { - throw new IllegalArgumentException("Cannot update closed speculation encoding"); - } - } - - private static final int NULL_METHOD = -1; - private static final int NULL_TYPE = -2; - private static final int NULL_STRING = -3; - - @Override - public void addByte(int value) { - checkOpen(); - try { - dos.writeByte(value); - } catch (IOException e) { - throw new InternalError(e); - } - } - - @Override - public void addShort(int value) { - checkOpen(); - try { - dos.writeShort(value); - } catch (IOException e) { - throw new InternalError(e); - } - } - - @Override - public void addMethod(ResolvedJavaMethod method) { - if (!addNull(method, NULL_METHOD)) { - checkOpen(); - if (method instanceof HotSpotResolvedJavaMethodImpl) { - try { - dos.writeLong(((HotSpotResolvedJavaMethodImpl) method).getMethodPointer()); - } catch (IOException e) { - throw new InternalError(e); - } - } else { - throw new IllegalArgumentException("Cannot encode unsupported type " + method.getClass().getName() + ": " + method.format("%H.%n(%p)")); - } - } - } - - @Override - public void addType(ResolvedJavaType type) { - if (!addNull(type, NULL_TYPE)) { - checkOpen(); - if (type instanceof HotSpotResolvedObjectTypeImpl) { - try { - dos.writeLong(((HotSpotResolvedObjectTypeImpl) type).getKlassPointer()); - } catch (IOException e) { - throw new InternalError(e); - } - } else { - throw new IllegalArgumentException("Cannot encode unsupported type " + type.getClass().getName() + ": " + type.toClassName()); - } - } - } - - @Override - public void addString(String value) { - if (!addNull(value, NULL_STRING)) { - checkOpen(); - try { - dos.writeChars(value); - } catch (IOException e) { - throw new InternalError(e); - } - } - } - - @Override - public void addInt(int value) { - checkOpen(); - try { - dos.writeInt(value); - } catch (IOException e) { - throw new InternalError(e); - } - } - - @Override - public void addLong(long value) { - checkOpen(); - try { - dos.writeLong(value); - } catch (IOException e) { - throw new InternalError(e); - } - } - - private boolean addNull(Object o, int nullValue) { - if (o == null) { - addInt(nullValue); - return true; - } - return false; - } - - /** - * Prototype SHA1 digest. - */ - private static final MessageDigest SHA1; - - /** - * Cloning the prototype is quicker than calling {@link MessageDigest#getInstance(String)} every - * time. - */ - private static final boolean SHA1_IS_CLONEABLE; - private static final int SHA1_LENGTH = 20; - - static { - MessageDigest sha1 = null; - boolean sha1IsCloneable = false; - try { - sha1 = MessageDigest.getInstance("SHA-1"); - sha1.clone(); - sha1IsCloneable = true; - } catch (NoSuchAlgorithmException e) { - // Should never happen given that SHA-1 is mandated in a - // compliant Java platform implementation. - throw new JVMCIError(e); - } catch (CloneNotSupportedException e) { - } - SHA1 = sha1; - SHA1_IS_CLONEABLE = sha1IsCloneable; - assert SHA1.getDigestLength() == SHA1_LENGTH; - assert SHA1_LENGTH < MAX_LENGTH; - } - - /** - * Gets the final encoded byte array and closes this encoding such that any further attempts to - * update it result in an {@link IllegalArgumentException}. - */ - byte[] getByteArray() { - if (result == null) { - if (count > MAX_LENGTH) { - try { - MessageDigest md = SHA1_IS_CLONEABLE ? (MessageDigest) SHA1.clone() : MessageDigest.getInstance("SHA-1"); - md.update(buf, 0, count); - result = md.digest(); - } catch (CloneNotSupportedException | NoSuchAlgorithmException e) { - throw new InternalError(e); - } - } else { - if (buf.length == count) { - // No need to copy the byte array - return buf; - } - result = Arrays.copyOf(buf, count); - } - dos = null; - } - return result; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java deleted file mode 100644 index bf9b1875663..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Formatter; -import java.util.List; -import java.util.Objects; - -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.SpeculationLog; - -/** - * Implements a {@link SpeculationLog} that can be used to: - *
    - *
  • Query failed speculations recorded in a native linked list of {@code FailedSpeculation}s (see - * methodData.hpp).
  • - *
  • Make speculations during compilation and record them in compiled code. This must only be done - * on compilation-local {@link HotSpotSpeculationLog} objects.
  • - *
- * - * The choice of constructor determines whether the native failed speculations list is - * {@linkplain #managesFailedSpeculations() managed} by a {@link HotSpotSpeculationLog} object. - */ -public class HotSpotSpeculationLog implements SpeculationLog { - - private static final byte[] NO_FLATTENED_SPECULATIONS = {}; - - /** - * Creates a speculation log that manages a failed speculation list. That is, when this object - * dies, the native resources of the list are freed. - * - * @see #managesFailedSpeculations() - * @see #getFailedSpeculationsAddress() - */ - public HotSpotSpeculationLog() { - managesFailedSpeculations = true; - } - - /** - * Creates a speculation log that reads from an externally managed failed speculation list. That - * is, the lifetime of the list is independent of this object. - * - * @param failedSpeculationsAddress an address in native memory at which the pointer to the - * externally managed sailed speculation list resides - */ - public HotSpotSpeculationLog(long failedSpeculationsAddress) { - if (failedSpeculationsAddress == 0) { - throw new IllegalArgumentException("failedSpeculationsAddress cannot be 0"); - } - this.failedSpeculationsAddress = failedSpeculationsAddress; - managesFailedSpeculations = false; - } - - /** - * Gets the address of the pointer to the native failed speculations list. This always returns a non-zero address. - * - * @see #managesFailedSpeculations() - */ - public long getFailedSpeculationsAddress() { - if (managesFailedSpeculations) { - synchronized (this) { - if (failedSpeculationsAddress == 0L) { - long address = UnsafeAccess.UNSAFE.allocateMemory(HotSpotJVMCIRuntime.getHostWordKind().getByteCount()); - UnsafeAccess.UNSAFE.putAddress(address, 0L); - failedSpeculationsAddress = address; - LogCleaner c = new LogCleaner(this, failedSpeculationsAddress); - assert c.address == failedSpeculationsAddress; - } - } - } - return failedSpeculationsAddress; - } - - /** - * Adds {@code speculation} to the native list of failed speculations. To update this object's - * view of the failed speculations, {@link #collectFailedSpeculations()} must be called after - * this method returns. - * - * This method exists primarily for testing purposes. Speculations are normally only added to - * the list by HotSpot during deoptimization. - * - * @return {@code false} if the speculation could not be appended to the list - */ - public boolean addFailedSpeculation(Speculation speculation) { - return compilerToVM().addFailedSpeculation(getFailedSpeculationsAddress(), ((HotSpotSpeculation) speculation).encoding); - } - - /** - * Returns {@code true} if the value returned by {@link #getFailedSpeculationsAddress()} is only - * valid only as long as this object is alive, {@code false} otherwise. - */ - public boolean managesFailedSpeculations() { - return managesFailedSpeculations; - } - - public static final class HotSpotSpeculation extends Speculation { - - /** - * A speculation id is a long encoding a length (low 5 bits) and an index into a - * {@code byte[]}. Combined, the index and length denote where the {@linkplain #encoding - * encoded speculation} is in a {@linkplain HotSpotSpeculationLog#getFlattenedSpeculations - * flattened} speculations array. - */ - private final JavaConstant id; - - private final byte[] encoding; - - public HotSpotSpeculation(SpeculationReason reason, JavaConstant id, byte[] encoding) { - super(reason); - this.id = id; - this.encoding = encoding; - } - - public JavaConstant getEncoding() { - return id; - } - - /** - * Returns a copy of the speculation reason encoding. - */ - public byte[] getReasonEncoding() { - return (encoding == null) ? null : encoding.clone(); - } - - @Override - public String toString() { - long indexAndLength = id.asLong(); - int index = decodeIndex(indexAndLength); - int length = decodeLength(indexAndLength); - return String.format("{0x%016x[index: %d, len: %d, hash: 0x%x]: %s}", indexAndLength, index, length, Arrays.hashCode(encoding), getReason()); - } - - @Override - public boolean equals(Object object) { - if (object instanceof HotSpotSpeculation that) { - return getReason().equals(that.getReason()) && id.equals(that.id) && Arrays.equals(encoding, that.encoding); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hash(getReason(), id, Arrays.hashCode(encoding)); - } - } - - /** - * Address of a pointer to a set of failed speculations. The address is recorded in the nmethod - * compiled with this speculation log such that when it fails a speculation, the speculation is - * added to the list. - */ - private long failedSpeculationsAddress; - - private final boolean managesFailedSpeculations; - - /** - * The list of failed speculations read from native memory via - * {@link CompilerToVM#getFailedSpeculations}. - */ - private byte[][] failedSpeculations; - - /** - * Speculations made during the compilation associated with this log. - */ - private List speculations; - private List speculationReasons; - - @Override - public void collectFailedSpeculations() { - if (failedSpeculationsAddress == 0) { - // If no memory has been allocated then don't force its creation - return; - } - - // Go through getFailedSpeculationsAddress() to ensure that any concurrent - // initialization of failedSpeculationsAddress is seen by this thread. - long address = getFailedSpeculationsAddress(); - if (UnsafeAccess.UNSAFE.getLong(address) != 0) { - failedSpeculations = compilerToVM().getFailedSpeculations(address, failedSpeculations); - assert failedSpeculations.getClass() == byte[][].class; - } - } - - byte[] getFlattenedSpeculations(boolean validate) { - if (speculations == null) { - return NO_FLATTENED_SPECULATIONS; - } - if (validate) { - int newFailuresStart = failedSpeculations == null ? 0 : failedSpeculations.length; - collectFailedSpeculations(); - if (failedSpeculations != null && failedSpeculations.length != newFailuresStart) { - for (SpeculationReason reason : speculationReasons) { - byte[] encoding = encode(reason); - // Only check against new failures - if (contains(failedSpeculations, newFailuresStart, encoding)) { - throw new BailoutException(false, "Speculation failed: " + reason); - } - } - } - } - int size = 0; - for (byte[] s : speculations) { - size += s.length; - } - byte[] result = new byte[size]; - size = 0; - for (byte[] s : speculations) { - System.arraycopy(s, 0, result, size, s.length); - size += s.length; - } - return result; - } - - /** - * @return {@code true} if the given speculation can be performed, i.e., it never failed so far, otherwise - * return {@code false}. Note, that this method returns consistent results for any given speculation for the - * entire lifetime of the enclosing SpeculationLog object. This means that speculations failed during a - * compilation will not be updated. - */ - @Override - public boolean maySpeculate(SpeculationReason reason) { - if (failedSpeculations != null && failedSpeculations.length != 0) { - byte[] encoding = encode(reason); - return !contains(failedSpeculations, 0, encoding); - } - return true; - } - - /** - * @return {@code true} if {@code needle} is in {@code haystack[fromIndex..haystack.length-1]} - */ - private static boolean contains(byte[][] haystack, int fromIndex, byte[] needle) { - for (int i = fromIndex; i < haystack.length; i++) { - byte[] fs = haystack[i]; - - if (Arrays.equals(fs, needle)) { - return true; - } - } - return false; - } - - private static long encodeIndexAndLength(int index, int length) { - if (length > HotSpotSpeculationEncoding.MAX_LENGTH || length < 0) { - throw new InternalError(String.format("Invalid encoded speculation length: %d (0x%x)", length, length)); - } - if (index < 0) { - throw new JVMCIError("Encoded speculation index is negative: %d (0x%x)", index, index); - } - return (index << HotSpotSpeculationEncoding.LENGTH_BITS) | length; - } - - private static int decodeIndex(long indexAndLength) { - return (int) (indexAndLength >>> HotSpotSpeculationEncoding.LENGTH_BITS); - } - - private static int decodeLength(long indexAndLength) { - return (int) (indexAndLength & HotSpotSpeculationEncoding.LENGTH_MASK); - } - - @Override - public Speculation speculate(SpeculationReason reason) { - byte[] encoding = encode(reason); - JavaConstant id; - if (speculations == null) { - speculations = new ArrayList<>(); - speculationReasons = new ArrayList<>(); - id = JavaConstant.forLong(encodeIndexAndLength(0, encoding.length)); - speculations.add(encoding); - speculationReasons.add(reason); - } else { - id = null; - int flattenedIndex = 0; - for (byte[] fs : speculations) { - if (Arrays.equals(fs, encoding)) { - id = JavaConstant.forLong(encodeIndexAndLength(flattenedIndex, fs.length)); - break; - } - flattenedIndex += fs.length; - } - if (id == null) { - id = JavaConstant.forLong(encodeIndexAndLength(flattenedIndex, encoding.length)); - speculations.add(encoding); - speculationReasons.add(reason); - } - } - - return new HotSpotSpeculation(reason, id, encoding); - } - - private static byte[] encode(SpeculationReason reason) { - HotSpotSpeculationEncoding encoding = (HotSpotSpeculationEncoding) reason.encode(HotSpotSpeculationEncoding::new); - byte[] result = encoding == null ? null : encoding.getByteArray(); - if (result == null) { - throw new IllegalArgumentException(HotSpotSpeculationLog.class.getName() + " expects " + reason.getClass().getName() + ".encode() to return a non-empty encoding"); - } - return result; - } - - @Override - public boolean hasSpeculations() { - return speculations != null; - } - - @Override - public Speculation lookupSpeculation(JavaConstant constant) { - if (constant.isDefaultForKind()) { - return NO_SPECULATION; - } - int flattenedIndex = decodeIndex(constant.asLong()); - int index = 0; - for (byte[] s : speculations) { - if (flattenedIndex == 0) { - SpeculationReason reason = speculationReasons.get(index); - return new HotSpotSpeculation(reason, constant, s); - } - index++; - flattenedIndex -= s.length; - } - throw new IllegalArgumentException("Unknown encoded speculation: " + constant); - } - - @Override - public String toString() { - Formatter buf = new Formatter(); - buf.format("{managed:%s, failedSpeculationsAddress:0x%x, failedSpeculations:[", managesFailedSpeculations, failedSpeculationsAddress); - - String sep = ""; - if (failedSpeculations != null) { - for (int i = 0; i < failedSpeculations.length; i++) { - buf.format("%s{len:%d, hash:0x%x}", sep, failedSpeculations[i].length, Arrays.hashCode(failedSpeculations[i])); - sep = ", "; - } - } - - buf.format("], speculations:["); - - int size = 0; - if (speculations != null) { - sep = ""; - for (int i = 0; i < speculations.size(); i++) { - byte[] s = speculations.get(i); - size += s.length; - buf.format("%s{len:%d, hash:0x%x, reason:{%s}}", sep, s.length, Arrays.hashCode(s), speculationReasons.get(i)); - sep = ", "; - } - } - buf.format("], len:%d, hash:0x%x}", size, Arrays.hashCode(getFlattenedSpeculations(false))); - return buf.toString(); - } - - /** - * Frees the native memory resources associated with {@link HotSpotSpeculationLog}s once they - * become reclaimable. - */ - private static final class LogCleaner extends Cleaner { - - LogCleaner(HotSpotSpeculationLog referent, long address) { - super(referent); - this.address = address; - } - - @Override - boolean doCleanup() { - long pointer = UnsafeAccess.UNSAFE.getAddress(address); - if (pointer != 0) { - compilerToVM().releaseFailedSpeculations(address); - } - UnsafeAccess.UNSAFE.freeMemory(address); - return false; - } - - final long address; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java deleted file mode 100644 index db91175fc8d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackFrameReference.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Arrays; - -import jdk.vm.ci.code.stack.InspectedFrame; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public class HotSpotStackFrameReference implements InspectedFrame { - - private CompilerToVM compilerToVM; - // set in the VM when materializeVirtualObjects is called - @SuppressWarnings("unused") private boolean objectsMaterialized; - - // information used to find the stack frame - private long stackPointer; - private int frameNumber; - - // information about the stack frame's contents - private int bci; - private HotSpotResolvedJavaMethod method; - private Object[] locals; - private boolean[] localIsVirtual; - - public long getStackPointer() { - return stackPointer; - } - - public int getFrameNumber() { - return frameNumber; - } - - @Override - public Object getLocal(int index) { - return locals[index]; - } - - @Override - public boolean isVirtual(int index) { - return localIsVirtual == null ? false : localIsVirtual[index]; - } - - @Override - public void materializeVirtualObjects(boolean invalidateCode) { - if (Thread.currentThread().isVirtual()) { - throw new IllegalArgumentException("cannot materialize frames of a virtual thread"); - } - compilerToVM.materializeVirtualObjects(this, invalidateCode); - } - - @Override - public int getBytecodeIndex() { - return bci; - } - - @Override - public ResolvedJavaMethod getMethod() { - return method; - } - - @Override - public boolean isMethod(ResolvedJavaMethod otherMethod) { - return method.equals(otherMethod); - } - - @Override - public boolean hasVirtualObjects() { - return localIsVirtual != null; - } - - @Override - public String toString() { - return "HotSpotStackFrameReference [stackPointer=" + stackPointer + ", frameNumber=" + frameNumber + ", bci=" + bci + ", method=" + getMethod() + ", locals=" + Arrays.toString(locals) + - ", localIsVirtual=" + Arrays.toString(localIsVirtual) + "]"; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java deleted file mode 100644 index 0b18bcbea5f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotStackIntrospection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.stack.InspectedFrameVisitor; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -public class HotSpotStackIntrospection implements StackIntrospection { - - protected final HotSpotJVMCIRuntime runtime; - - public HotSpotStackIntrospection(HotSpotJVMCIRuntime runtime) { - this.runtime = runtime; - } - - @Override - public T iterateFrames(ResolvedJavaMethod[] initialMethods, ResolvedJavaMethod[] matchingMethods, int initialSkip, InspectedFrameVisitor visitor) { - CompilerToVM compilerToVM = runtime.getCompilerToVM(); - return compilerToVM.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor); - } - - @Override - public boolean canMaterializeVirtualObjects() { - // Virtual threads do not support materializing locals (JDK-8307125) - return !Thread.currentThread().isVirtual(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java deleted file mode 100644 index c058f785715..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.services.Services; -import jdk.internal.misc.Unsafe; -import jdk.internal.util.Architecture; - -/** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. - */ -class HotSpotVMConfig extends HotSpotVMConfigAccess { - - /** - * Gets the configuration associated with the singleton {@link HotSpotJVMCIRuntime}. - */ - static HotSpotVMConfig config() { - return runtime().getConfig(); - } - - HotSpotVMConfig(HotSpotVMConfigStore store) { - super(store); - - int speculationLengthBits = getConstant("JVMCINMethodData::SPECULATION_LENGTH_BITS", Integer.class); - JVMCIError.guarantee(HotSpotSpeculationEncoding.LENGTH_BITS == speculationLengthBits, "%d != %d", HotSpotSpeculationEncoding.LENGTH_BITS, speculationLengthBits); - } - - /** - * Gets the host architecture name for the purpose of finding the corresponding - * {@linkplain HotSpotJVMCIBackendFactory backend}. - */ - static String getHostArchitectureName() { - Architecture arch = Architecture.current(); - switch (arch) { - case X64: return "amd64"; - default: return arch.name().toLowerCase(); - } - } - - final boolean useDeferredInitBarriers = getFlag("ReduceInitialCardMarks", Boolean.class); - - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - - final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class); - - final int klassOffsetInBytes = getFieldValue("CompilerToVM::Data::oopDesc_klass_offset_in_bytes", Integer.class, "int"); - - final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*"); - final int superOffset = getFieldOffset("Klass::_super", Integer.class, "Klass*"); - final int nextSiblingOffset = getFieldOffset("Klass::_next_sibling", Integer.class, "Klass*"); - final int superCheckOffsetOffset = getFieldOffset("Klass::_super_check_offset", Integer.class, "juint"); - final int secondarySuperCacheOffset = getFieldOffset("Klass::_secondary_super_cache", Integer.class, "Klass*"); - - final int classLoaderDataOffset = getFieldOffset("Klass::_class_loader_data", Integer.class, "ClassLoaderData*"); - - /** - * The offset of the _java_mirror field (of type {@link Class}) in a Klass. - */ - final int javaMirrorOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle"); - - final int klassLayoutHelperOffset = getFieldOffset("Klass::_layout_helper", Integer.class, "jint"); - - final int klassLayoutHelperNeutralValue = getConstant("Klass::_lh_neutral_value", Integer.class); - final int klassLayoutHelperInstanceSlowPathBit = getConstant("Klass::_lh_instance_slow_path_bit", Integer.class); - - final int vtableEntrySize = getFieldValue("CompilerToVM::Data::sizeof_vtableEntry", Integer.class, "int"); - final int vtableEntryMethodOffset = getFieldOffset("vtableEntry::_method", Integer.class, "Method*"); - - final int instanceKlassAccessFlagsOffset = getFieldOffset("InstanceKlass::_access_flags", Integer.class, "AccessFlags"); - final int instanceKlassInitStateOffset = getFieldOffset("InstanceKlass::_init_state", Integer.class, "InstanceKlass::ClassState"); - final int instanceKlassConstantsOffset = getFieldOffset("InstanceKlass::_constants", Integer.class, "ConstantPool*"); - final int instanceKlassFieldInfoStreamOffset = getFieldOffset("InstanceKlass::_fieldinfo_stream", Integer.class, "Array*"); - final int instanceKlassAnnotationsOffset = getFieldOffset("InstanceKlass::_annotations", Integer.class, "Annotations*"); - final int instanceKlassMiscFlagsOffset = getFieldOffset("InstanceKlass::_misc_flags._flags", Integer.class, "u2"); - final int klassMiscFlagsOffset = getFieldOffset("Klass::_misc_flags._flags", Integer.class, "u1"); - final int klassVtableStartOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_start_offset", Integer.class, "int"); - final int klassVtableLengthOffset = getFieldValue("CompilerToVM::Data::Klass_vtable_length_offset", Integer.class, "int"); - - final int instanceKlassStateLinked = getConstant("InstanceKlass::linked", Integer.class); - final int instanceKlassStateFullyInitialized = getConstant("InstanceKlass::fully_initialized", Integer.class); - final int instanceKlassStateBeingInitialized = getConstant("InstanceKlass::being_initialized", Integer.class); - - final int annotationsFieldAnnotationsOffset = getFieldOffset("Annotations::_fields_annotations", Integer.class, "Array*"); - final int annotationsClassAnnotationsOffset = getFieldOffset("Annotations::_class_annotations", Integer.class, "AnnotationArray*"); - final int fieldsAnnotationsBaseOffset = getFieldValue("CompilerToVM::Data::_fields_annotations_base_offset", Integer.class, "int"); - - final int arrayU1LengthOffset = getFieldOffset("Array::_length", Integer.class, "int"); - final int arrayU1DataOffset = getFieldOffset("Array::_data", Integer.class); - final int arrayU2DataOffset = getFieldOffset("Array::_data", Integer.class); - - final int jvmAccHasFinalizer = getConstant("KlassFlags::_misc_has_finalizer", Integer.class); - final int jvmFieldFlagInternalShift = getConstant("FieldInfo::FieldFlags::_ff_injected", Integer.class); - final int jvmFieldFlagStableShift = getConstant("FieldInfo::FieldFlags::_ff_stable", Integer.class); - final int jvmAccIsCloneableFast = getConstant("KlassFlags::_misc_is_cloneable_fast", Integer.class); - - // These modifiers are not public in Modifier so we get them via vmStructs. - final int jvmAccSynthetic = getConstant("JVM_ACC_SYNTHETIC", Integer.class); - final int jvmAccAnnotation = getConstant("JVM_ACC_ANNOTATION", Integer.class); - final int jvmAccBridge = getConstant("JVM_ACC_BRIDGE", Integer.class); - final int jvmAccVarargs = getConstant("JVM_ACC_VARARGS", Integer.class); - final int jvmAccEnum = getConstant("JVM_ACC_ENUM", Integer.class); - final int jvmAccInterface = getConstant("JVM_ACC_INTERFACE", Integer.class); - - final int jvmMiscFlagsHasDefaultMethods = getConstant("InstanceKlassFlags::_misc_has_nonstatic_concrete_methods", Integer.class); - final int jvmMiscFlagsDeclaresDefaultMethods = getConstant("InstanceKlassFlags::_misc_declares_nonstatic_concrete_methods", Integer.class); - - // This is only valid on AMD64. - final int runtimeCallStackSize = getConstant("frame::arg_reg_save_area_bytes", Integer.class, Architecture.isX64() ? null : 0); - - private final int markWordNoHashInPlace = getConstant("markWord::no_hash_in_place", Integer.class); - private final int markWordNoLockInPlace = getConstant("markWord::no_lock_in_place", Integer.class); - - /** - * See {@code markWord::prototype()}. - */ - long prototypeMarkWord() { - return markWordNoHashInPlace | markWordNoLockInPlace; - } - - final int methodAccessFlagsOffset = getFieldOffset("Method::_access_flags", Integer.class, "AccessFlags"); - final int methodConstMethodOffset = getFieldOffset("Method::_constMethod", Integer.class, "ConstMethod*"); - final int methodIntrinsicIdOffset = getFieldOffset("Method::_intrinsic_id", Integer.class, "u2"); - final int methodFlagsOffset = getFieldOffset("Method::_flags._status", Integer.class, "u4"); - final int methodVtableIndexOffset = getFieldOffset("Method::_vtable_index", Integer.class, "int"); - - final int methodDataOffset = getFieldOffset("Method::_method_data", Integer.class, "MethodData*"); - final int methodCodeOffset = getFieldOffset("Method::_code", Integer.class, "nmethod*"); - - final int methodFlagsForceInline = getConstant("MethodFlags::_misc_force_inline", Integer.class); - final int methodFlagsDontInline = getConstant("MethodFlags::_misc_dont_inline", Integer.class); - final int nonvirtualVtableIndex = getConstant("Method::nonvirtual_vtable_index", Integer.class); - final int invalidVtableIndex = getConstant("Method::invalid_vtable_index", Integer.class); - - final int methodDataSize = getFieldOffset("MethodData::_size", Integer.class, "int"); - final int methodDataDataSize = getFieldOffset("MethodData::_data_size", Integer.class, "int"); - final int methodDataOopDataOffset = getFieldOffset("MethodData::_data[0]", Integer.class, "intptr_t"); - final int methodDataOopTrapHistoryOffset = getFieldOffset("MethodData::_compiler_counters._trap_hist._array[0]", Integer.class, "u1"); - final int methodDataIRSizeOffset = getFieldOffset("MethodData::_jvmci_ir_size", Integer.class, "int"); - - final int methodDataDecompiles = getFieldOffset("MethodData::_compiler_counters._nof_decompiles", Integer.class, "uint"); - final int methodDataOverflowRecompiles = getFieldOffset("MethodData::_compiler_counters._nof_overflow_recompiles", Integer.class, "uint"); - final int methodDataOverflowTraps = getFieldOffset("MethodData::_compiler_counters._nof_overflow_traps", Integer.class, "uint"); - - final int nmethodCompLevelOffset = getFieldOffset("nmethod::_comp_level", Integer.class, "CompLevel"); - - final int compilationLevelNone = getConstant("CompLevel_none", Integer.class); - final int compilationLevelSimple = getConstant("CompLevel_simple", Integer.class); - final int compilationLevelLimitedProfile = getConstant("CompLevel_limited_profile", Integer.class); - final int compilationLevelFullProfile = getConstant("CompLevel_full_profile", Integer.class); - final int compilationLevelFullOptimization = getConstant("CompLevel_full_optimization", Integer.class); - - final int compLevelAdjustmentNone = getConstant("JVMCIRuntime::none", Integer.class); - final int compLevelAdjustmentByHolder = getConstant("JVMCIRuntime::by_holder", Integer.class); - final int compLevelAdjustmentByFullSignature = getConstant("JVMCIRuntime::by_full_signature", Integer.class); - - final int invocationEntryBci = getConstant("InvocationEntryBci", Integer.class); - - final int extraStackEntries = getFieldValue("CompilerToVM::Data::Method_extra_stack_entries", Integer.class, "int"); - - final int constMethodConstantsOffset = getFieldOffset("ConstMethod::_constants", Integer.class, "ConstantPool*"); - final int constMethodFlagsOffset = getFieldOffset("ConstMethod::_flags._flags", Integer.class, "u4"); - final int constMethodCodeSizeOffset = getFieldOffset("ConstMethod::_code_size", Integer.class, "u2"); - final int constMethodNameIndexOffset = getFieldOffset("ConstMethod::_name_index", Integer.class, "u2"); - final int constMethodSignatureIndexOffset = getFieldOffset("ConstMethod::_signature_index", Integer.class, "u2"); - final int constMethodMethodIdnumOffset = getFieldOffset("ConstMethod::_method_idnum", Integer.class, "u2"); - final int constMethodMaxStackOffset = getFieldOffset("ConstMethod::_max_stack", Integer.class, "u2"); - final int methodMaxLocalsOffset = getFieldOffset("ConstMethod::_max_locals", Integer.class, "u2"); - - final int constMethodFlagsReservedStackAccess = getConstant("ConstMethodFlags::_misc_reserved_stack_access", Integer.class); - final int constMethodFlagsCallerSensitive = getConstant("ConstMethodFlags::_misc_caller_sensitive", Integer.class); - final int constMethodFlagsIntrinsicCandidate = getConstant("ConstMethodFlags::_misc_intrinsic_candidate", Integer.class); - final int constMethodFlagsIsScoped = getConstant("ConstMethodFlags::_misc_is_scoped", Integer.class); - final int constMethodFlagsIsOverpass = getConstant("ConstMethodFlags::_misc_is_overpass", Integer.class); - final int constMethodHasLineNumberTable = getConstant("ConstMethodFlags::_misc_has_linenumber_table", Integer.class); - final int constMethodHasLocalVariableTable = getConstant("ConstMethodFlags::_misc_has_localvariable_table", Integer.class); - final int constMethodHasMethodAnnotations = getConstant("ConstMethodFlags::_misc_has_method_annotations", Integer.class); - final int constMethodHasParameterAnnotations = getConstant("ConstMethodFlags::_misc_has_parameter_annotations", Integer.class); - final int constMethodHasExceptionTable = getConstant("ConstMethodFlags::_misc_has_exception_table", Integer.class); - - final int exceptionTableElementSize = getFieldValue("CompilerToVM::Data::sizeof_ExceptionTableElement", Integer.class, "int"); - final int exceptionTableElementStartPcOffset = getFieldOffset("ExceptionTableElement::start_pc", Integer.class, "u2"); - final int exceptionTableElementEndPcOffset = getFieldOffset("ExceptionTableElement::end_pc", Integer.class, "u2"); - final int exceptionTableElementHandlerPcOffset = getFieldOffset("ExceptionTableElement::handler_pc", Integer.class, "u2"); - final int exceptionTableElementCatchTypeIndexOffset = getFieldOffset("ExceptionTableElement::catch_type_index", Integer.class, "u2"); - - final int localVariableTableElementSize = getFieldValue("CompilerToVM::Data::sizeof_LocalVariableTableElement", Integer.class, "int"); - final int localVariableTableElementStartBciOffset = getFieldOffset("LocalVariableTableElement::start_bci", Integer.class, "u2"); - final int localVariableTableElementLengthOffset = getFieldOffset("LocalVariableTableElement::length", Integer.class, "u2"); - final int localVariableTableElementNameCpIndexOffset = getFieldOffset("LocalVariableTableElement::name_cp_index", Integer.class, "u2"); - final int localVariableTableElementDescriptorCpIndexOffset = getFieldOffset("LocalVariableTableElement::descriptor_cp_index", Integer.class, "u2"); - final int localVariableTableElementSlotOffset = getFieldOffset("LocalVariableTableElement::slot", Integer.class, "u2"); - - final int constantPoolSize = getFieldValue("CompilerToVM::Data::sizeof_ConstantPool", Integer.class, "int"); - final int constantPoolTagsOffset = getFieldOffset("ConstantPool::_tags", Integer.class, "Array*"); - final int constantPoolHolderOffset = getFieldOffset("ConstantPool::_pool_holder", Integer.class, "InstanceKlass*"); - final int constantPoolLengthOffset = getFieldOffset("ConstantPool::_length", Integer.class, "int"); - final int constantPoolFlagsOffset = getFieldOffset("ConstantPool::_flags", Integer.class, "u2"); - - final int constantPoolHasDynamicConstant = getConstant("ConstantPool::_has_dynamic_constant", Integer.class); - final int constantPoolSourceFileNameIndexOffset = getFieldOffset("ConstantPool::_source_file_name_index", Integer.class, "u2"); - - final int jvmConstantUtf8 = getConstant("JVM_CONSTANT_Utf8", Integer.class); - final int jvmConstantInteger = getConstant("JVM_CONSTANT_Integer", Integer.class); - final int jvmConstantLong = getConstant("JVM_CONSTANT_Long", Integer.class); - final int jvmConstantFloat = getConstant("JVM_CONSTANT_Float", Integer.class); - final int jvmConstantDouble = getConstant("JVM_CONSTANT_Double", Integer.class); - final int jvmConstantClass = getConstant("JVM_CONSTANT_Class", Integer.class); - final int jvmConstantUnresolvedClass = getConstant("JVM_CONSTANT_UnresolvedClass", Integer.class); - final int jvmConstantUnresolvedClassInError = getConstant("JVM_CONSTANT_UnresolvedClassInError", Integer.class); - final int jvmConstantString = getConstant("JVM_CONSTANT_String", Integer.class); - final int jvmConstantFieldref = getConstant("JVM_CONSTANT_Fieldref", Integer.class); - final int jvmConstantMethodref = getConstant("JVM_CONSTANT_Methodref", Integer.class); - final int jvmConstantInterfaceMethodref = getConstant("JVM_CONSTANT_InterfaceMethodref", Integer.class); - final int jvmConstantNameAndType = getConstant("JVM_CONSTANT_NameAndType", Integer.class); - final int jvmConstantMethodHandle = getConstant("JVM_CONSTANT_MethodHandle", Integer.class); - final int jvmConstantMethodHandleInError = getConstant("JVM_CONSTANT_MethodHandleInError", Integer.class); - final int jvmConstantMethodType = getConstant("JVM_CONSTANT_MethodType", Integer.class); - final int jvmConstantMethodTypeInError = getConstant("JVM_CONSTANT_MethodTypeInError", Integer.class); - final int jvmConstantDynamic = getConstant("JVM_CONSTANT_Dynamic", Integer.class); - final int jvmConstantDynamicInError = getConstant("JVM_CONSTANT_DynamicInError", Integer.class); - final int jvmConstantInvokeDynamic = getConstant("JVM_CONSTANT_InvokeDynamic", Integer.class); - - final int jvmConstantExternalMax = getConstant("JVM_CONSTANT_ExternalMax", Integer.class); - final int jvmConstantInternalMin = getConstant("JVM_CONSTANT_InternalMin", Integer.class); - final int jvmConstantInternalMax = getConstant("JVM_CONSTANT_InternalMax", Integer.class); - - final int heapWordSize = getConstant("HeapWordSize", Integer.class); - - final long symbolVmSymbols = getFieldAddress("Symbol::_vm_symbols[0]", "Symbol*"); - final int vmSymbolsFirstSID = getConstant("vmSymbols::FIRST_SID", Integer.class); - final int vmSymbolsSIDLimit = getConstant("vmSymbols::SID_LIMIT", Integer.class); - - final long symbolInit = getFieldValue("CompilerToVM::Data::symbol_init", Long.class); - final long symbolClinit = getFieldValue("CompilerToVM::Data::symbol_clinit", Long.class); - - /** - * Returns the symbol in the {@code vmSymbols} table at position {@code index} as a - * {@link String}. - * - * @param index position in the symbol table - * @return the symbol at position id - */ - String symbolAt(int index) { - HotSpotJVMCIRuntime runtime = runtime(); - assert vmSymbolsFirstSID <= index && index < vmSymbolsSIDLimit : "index " + index + " is out of bounds"; - int offset = index * Unsafe.ADDRESS_SIZE; - return runtime.getCompilerToVM().getSymbol(UNSAFE.getAddress(symbolVmSymbols + offset)); - } - - final int universeBaseVtableSize = getFieldValue("CompilerToVM::Data::Universe_base_vtable_size", Integer.class, "int"); - - final int baseVtableLength() { - return universeBaseVtableSize / (vtableEntrySize / heapWordSize); - } - - final int klassOffset = getFieldValue("java_lang_Class::_klass_offset", Integer.class, "int"); - - /** - * The DataLayout header size is the same as the cell size. - */ - final int dataLayoutHeaderSize = getConstant("DataLayout::cell_size", Integer.class); - final int dataLayoutTagOffset = getFieldOffset("DataLayout::_header._struct._tag", Integer.class, "u1"); - final int dataLayoutFlagsOffset = getFieldOffset("DataLayout::_header._struct._flags", Integer.class, "u1"); - final int dataLayoutBCIOffset = getFieldOffset("DataLayout::_header._struct._bci", Integer.class, "u2"); - final int dataLayoutCellSize = getConstant("DataLayout::cell_size", Integer.class); - - final int dataLayoutNoTag = getConstant("DataLayout::no_tag", Integer.class); - final int dataLayoutBitDataTag = getConstant("DataLayout::bit_data_tag", Integer.class); - final int dataLayoutCounterDataTag = getConstant("DataLayout::counter_data_tag", Integer.class); - final int dataLayoutJumpDataTag = getConstant("DataLayout::jump_data_tag", Integer.class); - final int dataLayoutReceiverTypeDataTag = getConstant("DataLayout::receiver_type_data_tag", Integer.class); - final int dataLayoutVirtualCallDataTag = getConstant("DataLayout::virtual_call_data_tag", Integer.class); - final int dataLayoutRetDataTag = getConstant("DataLayout::ret_data_tag", Integer.class); - final int dataLayoutBranchDataTag = getConstant("DataLayout::branch_data_tag", Integer.class); - final int dataLayoutMultiBranchDataTag = getConstant("DataLayout::multi_branch_data_tag", Integer.class); - final int dataLayoutArgInfoDataTag = getConstant("DataLayout::arg_info_data_tag", Integer.class); - final int dataLayoutCallTypeDataTag = getConstant("DataLayout::call_type_data_tag", Integer.class); - final int dataLayoutVirtualCallTypeDataTag = getConstant("DataLayout::virtual_call_type_data_tag", Integer.class); - final int dataLayoutParametersTypeDataTag = getConstant("DataLayout::parameters_type_data_tag", Integer.class); - final int dataLayoutSpeculativeTrapDataTag = getConstant("DataLayout::speculative_trap_data_tag", Integer.class); - - final int bciProfileWidth = getFlag("BciProfileWidth", Integer.class); - final int typeProfileWidth = getFlag("TypeProfileWidth", Integer.class); - final int methodProfileWidth = getFlag("MethodProfileWidth", Integer.class, 0); - - final int deoptReasonNone = getConstant("Deoptimization::Reason_none", Integer.class); - final int deoptReasonNullCheck = getConstant("Deoptimization::Reason_null_check", Integer.class); - final int deoptReasonRangeCheck = getConstant("Deoptimization::Reason_range_check", Integer.class); - final int deoptReasonClassCheck = getConstant("Deoptimization::Reason_class_check", Integer.class); - final int deoptReasonArrayCheck = getConstant("Deoptimization::Reason_array_check", Integer.class); - final int deoptReasonUnreached0 = getConstant("Deoptimization::Reason_unreached0", Integer.class); - final int deoptReasonTypeCheckInlining = getConstant("Deoptimization::Reason_type_checked_inlining", Integer.class); - final int deoptReasonOptimizedTypeCheck = getConstant("Deoptimization::Reason_optimized_type_check", Integer.class); - final int deoptReasonNotCompiledExceptionHandler = getConstant("Deoptimization::Reason_not_compiled_exception_handler", Integer.class); - final int deoptReasonUnresolved = getConstant("Deoptimization::Reason_unresolved", Integer.class); - final int deoptReasonJsrMismatch = getConstant("Deoptimization::Reason_jsr_mismatch", Integer.class); - final int deoptReasonDiv0Check = getConstant("Deoptimization::Reason_div0_check", Integer.class); - final int deoptReasonConstraint = getConstant("Deoptimization::Reason_constraint", Integer.class); - final int deoptReasonLoopLimitCheck = getConstant("Deoptimization::Reason_loop_limit_check", Integer.class); - final int deoptReasonAliasing = getConstant("Deoptimization::Reason_aliasing", Integer.class); - final int deoptReasonTransferToInterpreter = getConstant("Deoptimization::Reason_transfer_to_interpreter", Integer.class); - final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_TRAP_HISTORY_LENGTH", Integer.class); - - final int deoptActionNone = getConstant("Deoptimization::Action_none", Integer.class); - final int deoptActionMaybeRecompile = getConstant("Deoptimization::Action_maybe_recompile", Integer.class); - final int deoptActionReinterpret = getConstant("Deoptimization::Action_reinterpret", Integer.class); - final int deoptActionMakeNotEntrant = getConstant("Deoptimization::Action_make_not_entrant", Integer.class); - final int deoptActionMakeNotCompilable = getConstant("Deoptimization::Action_make_not_compilable", Integer.class); - - final int deoptimizationActionBits = getConstant("Deoptimization::_action_bits", Integer.class); - final int deoptimizationReasonBits = getConstant("Deoptimization::_reason_bits", Integer.class); - final int deoptimizationDebugIdBits = getConstant("Deoptimization::_debug_id_bits", Integer.class); - final int deoptimizationActionShift = getConstant("Deoptimization::_action_shift", Integer.class); - final int deoptimizationReasonShift = getConstant("Deoptimization::_reason_shift", Integer.class); - final int deoptimizationDebugIdShift = getConstant("Deoptimization::_debug_id_shift", Integer.class); - - final int vmIntrinsicInvokeBasic = getConstant("vmIntrinsics::_invokeBasic", Integer.class); - final int vmIntrinsicLinkToVirtual = getConstant("vmIntrinsics::_linkToVirtual", Integer.class); - final int vmIntrinsicLinkToStatic = getConstant("vmIntrinsics::_linkToStatic", Integer.class); - final int vmIntrinsicLinkToSpecial = getConstant("vmIntrinsics::_linkToSpecial", Integer.class); - final int vmIntrinsicLinkToInterface = getConstant("vmIntrinsics::_linkToInterface", Integer.class); - final int vmIntrinsicLinkToNative = getConstant("vmIntrinsics::_linkToNative", Integer.class); - - final int codeInstallResultOk = getConstant("JVMCI::ok", Integer.class); - final int codeInstallResultDependenciesFailed = getConstant("JVMCI::dependencies_failed", Integer.class); - final int codeInstallResultCacheFull = getConstant("JVMCI::cache_full", Integer.class); - final int codeInstallResultCodeTooLarge = getConstant("JVMCI::code_too_large", Integer.class); - final int codeInstallResultNMethodReclaimed = getConstant("JVMCI::nmethod_reclaimed", Integer.class); - final int codeInstallResultFirstPermanentBailout = getConstant("JVMCI::first_permanent_bailout", Integer.class); - - String getCodeInstallResultDescription(int codeInstallResult) { - if (codeInstallResult == codeInstallResultOk) { - return "ok"; - } - if (codeInstallResult == codeInstallResultDependenciesFailed) { - return "dependencies failed"; - } - if (codeInstallResult == codeInstallResultCacheFull) { - return "code cache is full"; - } - if (codeInstallResult == codeInstallResultCodeTooLarge) { - return "code is too large"; - } - if (codeInstallResult == codeInstallResultNMethodReclaimed) { - return "nmethod reclaimed"; - } - assert false : codeInstallResult; - return "unknown"; - } - - final int bitDataExceptionSeenFlag = getConstant("BitData::exception_seen_flag", Integer.class); - final int bitDataNullSeenFlag = getConstant("BitData::null_seen_flag", Integer.class); - final int methodDataCountOffset = getConstant("CounterData::count_off", Integer.class); - final int jumpDataTakenOffset = getConstant("JumpData::taken_off_set", Integer.class); - final int jumpDataDisplacementOffset = getConstant("JumpData::displacement_off_set", Integer.class); - final int receiverTypeDataReceiverTypeRowCellCount = getConstant("ReceiverTypeData::receiver_type_row_cell_count", Integer.class); - final int receiverTypeDataReceiver0Offset = getConstant("ReceiverTypeData::receiver0_offset", Integer.class); - final int receiverTypeDataCount0Offset = getConstant("ReceiverTypeData::count0_offset", Integer.class); - final int branchDataNotTakenOffset = getConstant("BranchData::not_taken_off_set", Integer.class); - final int arrayDataArrayLenOffset = getConstant("ArrayData::array_len_off_set", Integer.class); - final int arrayDataArrayStartOffset = getConstant("ArrayData::array_start_off_set", Integer.class); - final int multiBranchDataPerCaseCellCount = getConstant("MultiBranchData::per_case_cell_count", Integer.class); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java deleted file mode 100644 index 5f921c767dd..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigAccess.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import java.util.Set; -import java.util.stream.Collectors; - -import jdk.vm.ci.common.JVMCIError; - -/** - * Access to VM configuration data. - */ -public class HotSpotVMConfigAccess { - - /** - * Gets the available configuration data. - */ - public HotSpotVMConfigStore getStore() { - return store; - } - - /** - * Gets the address of a C++ symbol. - * - * @param name name of C++ symbol - * @param notPresent if non-null and the symbol is not present then this value is returned - * @return the address of the symbol - * @throws JVMCIError if the symbol is not present and {@code notPresent == null} - */ - public long getAddress(String name, Long notPresent) { - Long entry = store.vmAddresses.get(name); - if (entry == null) { - if (notPresent != null) { - return notPresent; - } - throw missingEntry("address", name, store.vmFlags.keySet()); - - } - return entry; - } - - /** - * Gets the address of a C++ symbol. - * - * @param name name of C++ symbol - * @return the address of the symbol - * @throws JVMCIError if the symbol is not present - */ - public long getAddress(String name) { - return getAddress(name, null); - } - - /** - * Gets the value of a C++ constant. - * - * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"}) - * @param type the boxed type to which the constant value will be converted - * @param notPresent if non-null and the constant is not present then this value is returned - * @return the constant value converted to {@code type} - * @throws JVMCIError if the constant is not present and {@code notPresent == null} - */ - public T getConstant(String name, Class type, T notPresent) { - Long c = store.vmConstants.get(name); - if (c == null) { - if (notPresent != null) { - return notPresent; - } - throw missingEntry("constant", name, store.vmConstants.keySet()); - } - return type.cast(convertValue(name, type, c, null)); - } - - /** - * Gets the value of a C++ constant. - * - * @param name name of the constant (e.g., {@code "frame::arg_reg_save_area_bytes"}) - * @param type the boxed type to which the constant value will be converted - * @return the constant value converted to {@code type} - * @throws JVMCIError if the constant is not present - */ - public T getConstant(String name, Class type) { - return getConstant(name, type, null); - } - - /** - * Gets the offset of a non-static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the offset value will be converted (must be - * {@link Integer} or {@link Long}) - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @param notPresent if non-null and the field is not present then this value is returned - * @return the offset in bytes of the requested field - * @throws JVMCIError if the field is static or not present and {@code notPresent} is null - */ - public T getFieldOffset(String name, Class type, String cppType, T notPresent) { - return getFieldOffset0(name, type, notPresent, cppType, null); - } - - /** - * Gets the offset of a non-static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the offset value will be converted (must be - * {@link Integer} or {@link Long}) - * @param notPresent if non-null and the field is not present then this value is returned - * @param outCppType if non-null, the C++ type of the field (e.g., {@code "HeapWord*"}) is - * returned in element 0 of this array - * @return the offset in bytes of the requested field - * @throws JVMCIError if the field is static or not present and {@code notPresent} is null - */ - public T getFieldOffset(String name, Class type, T notPresent, String[] outCppType) { - return getFieldOffset0(name, type, notPresent, null, outCppType); - } - - /** - * Gets the offset of a non-static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the offset value will be converted (must be - * {@link Integer} or {@link Long}) - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @return the offset in bytes of the requested field - * @throws JVMCIError if the field is static or not present - */ - public T getFieldOffset(String name, Class type, String cppType) { - return getFieldOffset0(name, type, null, cppType, null); - } - - /** - * Gets the offset of a non-static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the offset value will be converted (must be - * {@link Integer} or {@link Long}) - * @return the offset in bytes of the requested field - * @throws JVMCIError if the field is static or not present - */ - public T getFieldOffset(String name, Class type) { - return getFieldOffset0(name, type, null, null, null); - } - - private T getFieldOffset0(String name, Class type, T notPresent, String inCppType, String[] outCppType) { - assert type == Integer.class || type == Long.class; - VMField entry = getField(name, inCppType, notPresent == null); - if (entry == null) { - return notPresent; - } - if (entry.address != 0) { - throw new JVMCIError("cannot get offset of static field " + name); - } - if (outCppType != null) { - outCppType[0] = entry.type; - } - return type.cast(convertValue(name, type, entry.offset, inCppType)); - } - - /** - * Gets the address of a static C++ field. - * - * @param name fully qualified name of the field - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @param notPresent if non-null and the field is not present then this value is returned - * @return the address of the requested field - * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null - */ - public long getFieldAddress(String name, String cppType, Long notPresent) { - return getFieldAddress0(name, notPresent, cppType, null); - } - - /** - * Gets the address of a static C++ field. - * - * @param name fully qualified name of the field - * @param notPresent if non-null and the field is not present then this value is returned - * @param outCppType if non-null, the C++ type of the field (e.g., {@code "HeapWord*"}) is - * returned in element 0 of this array - * @return the address of the requested field - * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null - */ - public long getFieldAddress(String name, Long notPresent, String[] outCppType) { - return getFieldAddress0(name, notPresent, null, outCppType); - } - - /** - * Gets the address of a static C++ field. - * - * @param name fully qualified name of the field - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @return the address of the requested field - * @throws JVMCIError if the field is not static or not present - */ - public long getFieldAddress(String name, String cppType) { - return getFieldAddress0(name, null, cppType, null); - } - - private long getFieldAddress0(String name, Long notPresent, String inCppType, String[] outCppType) { - VMField entry = getField(name, inCppType, notPresent == null); - if (entry == null) { - return notPresent; - } - if (entry.address == 0) { - throw new JVMCIError(name + " is not a static field"); - } - if (outCppType != null) { - outCppType[0] = entry.type; - } - return entry.address; - } - - /** - * Gets the value of a static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the constant value will be converted - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @param notPresent if non-null and the field is not present then this value is returned - * @return the value of the requested field - * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null - */ - public T getFieldValue(String name, Class type, String cppType, T notPresent) { - return getFieldValue0(name, type, notPresent, cppType, null); - } - - /** - * Gets the value of a static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the constant value will be converted - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @return the value of the requested field - * @throws JVMCIError if the field is not static or not present - */ - public T getFieldValue(String name, Class type, String cppType) { - return getFieldValue0(name, type, null, cppType, null); - } - - /** - * Gets the value of a static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the constant value will be converted - * @param notPresent if non-null and the field is not present then this value is returned - * @param outCppType if non-null, the C++ type of the field (e.g., {@code "HeapWord*"}) is - * returned in element 0 of this array - * @return the value of the requested field - * @throws JVMCIError if the field is not static or not present and {@code notPresent} is null - */ - public T getFieldValue(String name, Class type, T notPresent, String[] outCppType) { - return getFieldValue0(name, type, notPresent, null, outCppType); - } - - /** - * Gets the value of a static C++ field. - * - * @param name fully qualified name of the field - * @param type the boxed type to which the constant value will be converted - * @return the value of the requested field - * @throws JVMCIError if the field is not static or not present - */ - public T getFieldValue(String name, Class type) { - return getFieldValue0(name, type, null, null, null); - } - - private T getFieldValue0(String name, Class type, T notPresent, String inCppType, String[] outCppType) { - VMField entry = getField(name, inCppType, notPresent == null); - if (entry == null) { - return notPresent; - } - if (entry.value == null) { - throw new JVMCIError(name + " is not a static field "); - } - if (outCppType != null) { - outCppType[0] = entry.type; - } - return type.cast(convertValue(name, type, entry.value, inCppType)); - } - - /** - * Gets a C++ field. - * - * @param name fully qualified name of the field - * @param cppType if non-null, the expected C++ type of the field (e.g., {@code "HeapWord*"}) - * @param required specifies if the field must be present - * @return the field - * @throws JVMCIError if the field is not present and {@code required == true} - */ - public VMField getField(String name, String cppType, boolean required) { - VMField entry = store.vmFields.get(name); - if (entry == null) { - if (!required) { - return null; - } - throw missingEntry("field", name, store.vmFields.keySet()); - } - - // Make sure the native type is still the type we expect. - if (cppType != null && !cppType.equals(entry.type)) { - throw new JVMCIError("expected type " + cppType + " but VM field " + name + " is of type " + entry.type); - } - return entry; - } - - /** - * Gets a VM flag value. - * - * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"}) - * @param type the boxed type to which the flag's value will be converted - * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not - * present - * @throws JVMCIError if the flag is not present - */ - public T getFlag(String name, Class type) { - return getFlag(name, type, null); - } - - /** - * Gets a VM flag value. - * - * @param name name of the flag (e.g., {@code "CompileTheWorldStartAt"}) - * @param type the boxed type to which the flag's value will be converted - * @param notPresent if non-null and the flag is not present then this value is returned - * @return the flag's value converted to {@code type} or {@code notPresent} if the flag is not - * present - * @throws JVMCIError if the flag is not present and {@code notPresent == null} - */ - public T getFlag(String name, Class type, T notPresent) { - VMFlag entry = store.vmFlags.get(name); - Object value; - String cppType; - if (entry == null) { - // Fall back to VM call - value = store.compilerToVm.getFlagValue(name); - if (value == store.compilerToVm) { - if (notPresent != null) { - return notPresent; - } - throw missingEntry("flag", name, store.vmFlags.keySet()); - } else { - cppType = null; - } - } else { - value = entry.value; - cppType = entry.type; - } - return type.cast(convertValue(name, type, value, cppType)); - } - - private JVMCIError missingEntry(String category, String name, Set keys) { - throw new JVMCIError("expected VM %s not found in %s: %s%nAvailable values:%n %s", category, store, name, - keys.stream().sorted().collect(Collectors.joining(System.lineSeparator() + " "))); - } - - private static Object convertValue(String name, Class toType, Object value, String cppType) throws JVMCIError { - if (toType == Boolean.class) { - if (value instanceof String) { - return Boolean.valueOf((String) value); - } else if (value instanceof Boolean) { - return value; - } else if (value instanceof Long) { - return ((long) value) != 0; - } - } else if (toType == Byte.class) { - if (value instanceof Long) { - return (byte) (long) value; - } - } else if (toType == Integer.class) { - if (value instanceof Integer) { - return value; - } else if (value instanceof Long) { - return (int) (long) value; - } - } else if (toType == String.class) { - if (value == null || value instanceof String) { - return value; - } - } else if (toType == Long.class) { - return value; - } - - throw new JVMCIError("cannot convert " + name + " of type " + value.getClass().getSimpleName() + (cppType == null ? "" : " [" + cppType + "]") + " to " + toType.getSimpleName()); - } - - private final HotSpotVMConfigStore store; - - public HotSpotVMConfigAccess(HotSpotVMConfigStore store) { - this.store = store; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java deleted file mode 100644 index c6735cef5f6..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMConfigStore.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.common.InitTimer.timer; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.common.JVMCIError; - -/** - * Access to VM configuration data. - */ -public final class HotSpotVMConfigStore { - - /** - * Gets the C++ symbols whose addresses are exposed by this object. - * - * @return an unmodifiable map from the symbol names to their addresses - */ - public Map getAddresses() { - return Collections.unmodifiableMap(vmAddresses); - } - - /** - * Gets the C++ constants exposed by this object. - * - * @return an unmodifiable map from the names of C++ constants to their values - */ - public Map getConstants() { - return Collections.unmodifiableMap(vmConstants); - } - - /** - * Gets the VM flags exposed by this object. - * - * @return an unmodifiable map from VM flag names to {@link VMFlag} objects - */ - public Map getFlags() { - return Collections.unmodifiableMap(vmFlags); - } - - /** - * Gets the C++ fields exposed by this object. - * - * @return an unmodifiable map from VM field names to {@link VMField} objects - */ - public Map getFields() { - return Collections.unmodifiableMap(vmFields); - } - - /** - * Gets the VM intrinsic descriptions exposed by this object. - */ - public List getIntrinsics() { - return Collections.unmodifiableList(vmIntrinsics); - } - - /** - * Gets the VM intrinsic description by its ID. - */ - public VMIntrinsicMethod getIntrinsic(int intrinsicID) { - if (intrinsicID >= 1 && intrinsicID <= vmIntrinsics.size()) { - // valid intrinsicID starts from 1 - VMIntrinsicMethod intrinsic = vmIntrinsics.get(intrinsicID - 1); - // We speculate that vmIntrinsics are sorted by ID - if (intrinsic.id == intrinsicID) { - return intrinsic; - } - } - // Assumption failed, fall back to iteration - for (VMIntrinsicMethod intrinsic : vmIntrinsics) { - if (intrinsic.id == intrinsicID) { - return intrinsic; - } - } - return null; - } - - final HashMap vmFields; - final HashMap vmConstants; - final HashMap vmAddresses; - final HashMap vmFlags; - final List vmIntrinsics; - final CompilerToVM compilerToVm; - - /** - * Reads the database of VM info. The return value encodes the info in a nested object array - * that is described by the pseudo Java object {@code info} below: - * - *
-     *     info = [
-     *         VMField[] vmFields,
-     *         [String name, Long value, ...] vmConstants,
-     *         [String name, Long value, ...] vmAddresses,
-     *         VMFlag[] vmFlags
-     *         VMIntrinsicMethod[] vmIntrinsics
-     *     ]
-     * 
- */ - @SuppressWarnings("try") - HotSpotVMConfigStore(CompilerToVM compilerToVm) { - this.compilerToVm = compilerToVm; - Object[] data; - try (InitTimer t = timer("CompilerToVm readConfiguration")) { - data = compilerToVm.readConfiguration(); - } - if (data.length != 5) { - throw new JVMCIError("Expected data.length to be 5, not %d", data.length); - } - - // @formatter:off - VMField[] vmFieldsInfo = (VMField[]) data[0]; - Object[] vmConstantsInfo = (Object[]) data[1]; - Object[] vmAddressesInfo = (Object[]) data[2]; - VMFlag[] vmFlagsInfo = (VMFlag[]) data[3]; - - vmFields = new HashMap<>(vmFieldsInfo.length); - vmConstants = new HashMap<>(vmConstantsInfo.length); - vmAddresses = new HashMap<>(vmAddressesInfo.length); - vmFlags = new HashMap<>(vmFlagsInfo.length); - vmIntrinsics = Arrays.asList((VMIntrinsicMethod[]) data[4]); - // @formatter:on - - try (InitTimer t = timer("HotSpotVMConfigStore fill maps")) { - for (VMField vmField : vmFieldsInfo) { - vmFields.put(vmField.name, vmField); - } - - for (int i = 0; i < vmConstantsInfo.length / 2; i++) { - String name = (String) vmConstantsInfo[i * 2]; - Long value = (Long) vmConstantsInfo[i * 2 + 1]; - vmConstants.put(name, value); - } - - for (int i = 0; i < vmAddressesInfo.length / 2; i++) { - String name = (String) vmAddressesInfo[i * 2]; - Long value = (Long) vmAddressesInfo[i * 2 + 1]; - vmAddresses.put(name, value); - } - - for (VMFlag vmFlag : vmFlagsInfo) { - vmFlags.put(vmFlag.name, vmFlag); - } - } - } - - @Override - public String toString() { - return String.format("%s[%d fields, %d constants, %d addresses, %d flags, %d intrinsics]", - getClass().getSimpleName(), - vmFields.size(), - vmConstants.size(), - vmAddresses.size(), - vmFlags.size(), - vmIntrinsics.size()); - } - - void printConfig(HotSpotJVMCIRuntime runtime) { - TreeMap fields = new TreeMap<>(getFields()); - for (VMField field : fields.values()) { - if (!field.isStatic()) { - printConfigLine(runtime, "[vmconfig:instance field] %s %s {offset=%d[0x%x]}%n", field.type, field.name, field.offset, field.offset); - } else { - String value = field.value == null ? "null" : field.value instanceof Boolean ? field.value.toString() : String.format("%d[0x%x]", field.value, field.value); - printConfigLine(runtime, "[vmconfig:static field] %s %s = %s {address=0x%x}%n", field.type, field.name, value, field.address); - } - } - TreeMap flags = new TreeMap<>(getFlags()); - for (VMFlag flag : flags.values()) { - printConfigLine(runtime, "[vmconfig:flag] %s %s = %s%n", flag.type, flag.name, flag.value); - } - TreeMap addresses = new TreeMap<>(getAddresses()); - for (Map.Entry e : addresses.entrySet()) { - printConfigLine(runtime, "[vmconfig:address] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue()); - } - TreeMap constants = new TreeMap<>(getConstants()); - for (Map.Entry e : constants.entrySet()) { - printConfigLine(runtime, "[vmconfig:constant] %s = %d[0x%x]%n", e.getKey(), e.getValue(), e.getValue()); - } - for (VMIntrinsicMethod e : getIntrinsics()) { - printConfigLine(runtime, "[vmconfig:intrinsic] %d = (available:%b c1Supported:%b c2Supported:%b) %s.%s %s%n", - e.id, e.isAvailable, e.c1Supported, e.c2Supported, e.declaringClass, e.name, e.descriptor); - } - } - - @SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "no localization here please!") - private static void printConfigLine(HotSpotJVMCIRuntime runtime, String format, Object... args) { - String line = String.format(format, args); - byte[] lineBytes = line.getBytes(); - runtime.writeDebugOutput(lineBytes, 0, lineBytes.length, true, true); - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMEventListener.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMEventListener.java deleted file mode 100644 index e6c8b39eeac..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotVMEventListener.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; - -/** - * Listener for responding to VM events. - */ -public interface HotSpotVMEventListener { - - /** - * Notifies this client that the VM is shutting down. - */ - default void notifyShutdown() { - } - - /** - * Notify on successful install into the code cache. - * - * @param hotSpotCodeCacheProvider the code cache into which the code was installed - * @param installedCode the code that was installed - * @param compiledCode the compiled code from which {@code installedCode} was produced - */ - default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - } - - /** - * Notify on completion of a bootstrap. - */ - default void notifyBootstrapFinished() { - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java deleted file mode 100644 index 2b8f717840e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; -import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; -import jdk.vm.ci.meta.JavaConstant; - -/** - * Encapsulates a JNI reference to an object in the HotSpot heap. - * - * {@link IndirectHotSpotObjectConstantImpl} objects are only allocated in the shared library heap. - * - * @see HotSpotObjectConstantScope - */ -final class IndirectHotSpotObjectConstantImpl extends HotSpotObjectConstantImpl { - /** - * An object handle in {@code JVMCIRuntime::_oop_handles}. - */ - private long objectHandle; - - /** - * Lazily computed hash code. - */ - private int hashCode; - - final IndirectHotSpotObjectConstantImpl base; - - private static class Audit { - final Object scope; - final long handle; - final Throwable origin; - - Audit(Object scope, long handle, Throwable origin) { - this.scope = scope; - this.handle = handle; - this.origin = origin; - } - } - - /** - * Details useful to audit a scoped handle used after its creating scope closes. Set to an - * {@link Audit} object if {@link HotSpotJVMCIRuntime.Option#AuditHandles} is true otherwise to - * {@link HotSpotObjectConstantScope#localScopeDescription}. - */ - private Object rawAudit; - - @VMEntryPoint - private IndirectHotSpotObjectConstantImpl(long objectHandle, boolean compressed, boolean skipRegister) { - super(compressed); - assert objectHandle != 0 && UnsafeAccess.UNSAFE.getLong(objectHandle) != 0; - this.objectHandle = objectHandle; - this.base = null; - if (!skipRegister) { - HotSpotObjectConstantScope scope = HotSpotObjectConstantScope.CURRENT.get(); - if (scope != null && !scope.isGlobal()) { - scope.add(this); - if (HotSpotJVMCIRuntime.Option.AuditHandles.getBoolean()) { - rawAudit = new Audit(scope.localScopeDescription, objectHandle, new Throwable() { - @Override - public String toString() { - return "Created " + objectHandle; - } - }); - } - } else { - HandleCleaner.create(this, objectHandle); - } - } - } - - private IndirectHotSpotObjectConstantImpl(IndirectHotSpotObjectConstantImpl base, boolean compressed) { - super(compressed); - // This is a variant of an original object that only varies in compress vs uncompressed. - // Instead of creating a new handle, reference that object and objectHandle. - this.objectHandle = base.getHandle(); - // There should only be one level of indirection to the base object. - assert base.base == null || base.base.base == null; - this.base = base.base != null ? base.base : base; - } - - long getHandle() { - checkHandle(); - return objectHandle; - } - - private void checkHandle() { - if (objectHandle == 0L) { - String message; - if (rawAudit instanceof Audit) { - Audit audit = (Audit) rawAudit; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - ps.println("Foreign object reference " + audit.handle + " created in scope '" + audit.scope + "' is no longer valid. Origin: {"); - audit.origin.printStackTrace(ps); - ps.print('}'); - ps.flush(); - message = baos.toString(); - } else { - message = "Foreign object reference created in scope '" + rawAudit + "' is no longer valid. " + - "Set property " + Option.AuditHandles.getPropertyName() + "=true to show origin of invalid foreign references."; - } - throw new NullPointerException(message); - } - } - - boolean isValid() { - return objectHandle != 0L; - } - - @Override - public HotSpotResolvedObjectType getType() { - checkHandle(); - return super.getType(); - } - - /** - * Clears the foreign object reference. - */ - void clear(Object scopeDescription) { - checkHandle(); - if (rawAudit == null) { - rawAudit = scopeDescription; - } - - clearHandle(objectHandle); - objectHandle = 0L; - } - - /** - * Sets the referent of {@code handle} to 0 so that it will be reclaimed when calling - * {@link CompilerToVM#releaseClearedOopHandles}. This must be done with a VM call so - * that the JNI handle is cleared at a safepoint. - */ - static void clearHandle(long handle) { - runtime().compilerToVm.clearOopHandle(handle); - } - - @Override - public JavaConstant compress() { - if (compressed) { - throw new IllegalArgumentException("already compressed: " + this); - } - return new IndirectHotSpotObjectConstantImpl(this, true); - } - - @Override - public JavaConstant uncompress() { - if (!compressed) { - throw new IllegalArgumentException("not compressed: " + this); - } - return new IndirectHotSpotObjectConstantImpl(this, false); - } - - @Override - public int getIdentityHashCode() { - checkHandle(); - int hash = hashCode; - if (hash == 0) { - hash = runtime().compilerToVm.getIdentityHashCode(this); - if (hash == 0) { - hash = 31; - } - hashCode = hash; - } - return hash; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/JFR.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/JFR.java deleted file mode 100644 index 1339424236b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/JFR.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; - -import java.util.concurrent.ConcurrentHashMap; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -/** - * Helper methods for interacting with the Java Flight Recorder (JFR) to register events and notify - * it when events occur. The JFR events are defined in {@code - * src/share/jfr/metadata/metadata.xml}. - */ -public final class JFR { - - /** - * Provides access to current JFR time stamp. - */ - public static final class Ticks { - - /** - * @return current JFR time stamp - */ - public static long now() { - return compilerToVM().ticksNow(); - } - } - - /** - * Helper methods for managing JFR CompilerPhase events. The events are defined in {@code - * src/share/jfr/metadata/metadata.xml}. - */ - public static final class CompilerPhaseEvent { - - private static final ConcurrentHashMap phaseToId = new ConcurrentHashMap<>(); - - private static int getPhaseToId(String phaseName) { - return phaseToId.computeIfAbsent(phaseName, k -> compilerToVM().registerCompilerPhase(phaseName)); - } - - /** - * Commits a CompilerPhase event. - * - * @param startTime time captured at the start of compiler phase - * @param phaseName compiler phase name - * @param compileId current compilation unit id - * @param phaseLevel compiler phase nesting level - */ - public static void write(long startTime, String phaseName, int compileId, int phaseLevel) { - compilerToVM().notifyCompilerPhaseEvent(startTime, getPhaseToId(phaseName), compileId, phaseLevel); - } - } - - /** - * Helper methods for managing JFR CompilerInlining events. The events are defined in {@code - * src/share/jfr/metadata/metadata.xml}. - */ - public static final class CompilerInliningEvent { - - /** - * Commits a CompilerInlining event. - * - * @param compileId current compilation unit id - * @param caller caller method - * @param callee callee method - * @param succeeded inlining succeeded or not - * @param message extra information on inlining - * @param bci invocation byte code index - */ - public static void write(int compileId, ResolvedJavaMethod caller, ResolvedJavaMethod callee, boolean succeeded, String message, int bci) { - compilerToVM().notifyCompilerInliningEvent(compileId, (HotSpotResolvedJavaMethodImpl) caller, (HotSpotResolvedJavaMethodImpl) callee, succeeded, message, bci); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceHandleObject.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceHandleObject.java deleted file mode 100644 index 712f6e4266f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceHandleObject.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * A tag interface indicating that this type is a handledized wrapper around a HotSpot metaspace - * object that requires GC interaction to keep alive. - * - * It would preferable if this were the base class containing the pointer but that would require - * mixins since most of the wrapper types have complex supertype hierarchies. - */ -interface MetaspaceHandleObject extends MetaspaceObject { - - long getMetadataHandle(); - - @Override - default long getMetaspacePointer() { - return UnsafeAccess.UNSAFE.getLong(getMetadataHandle()); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceObject.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceObject.java deleted file mode 100644 index 6467b5f1b0c..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/MetaspaceObject.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * The marker interface for an object which wraps a HotSpot Metaspace object. - */ -interface MetaspaceObject { - - /** - * Gets the raw pointer to the {@code Metaspace} object. - * - * @return a {@code Klass*}, {@code Method*} or {@code ConstantPool*} value - */ - long getMetaspacePointer(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedHotSpotSpeculationLog.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedHotSpotSpeculationLog.java deleted file mode 100644 index befd0255e5e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedHotSpotSpeculationLog.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * A wrapper that holds a strong reference to a "master" speculation log that - * {@linkplain HotSpotSpeculationLog#managesFailedSpeculations() manages} the failed speculations - * list. - */ -public class SharedHotSpotSpeculationLog extends HotSpotSpeculationLog { - private final HotSpotSpeculationLog masterLog; - - public SharedHotSpotSpeculationLog(HotSpotSpeculationLog masterLog) { - super(masterLog.getFailedSpeculationsAddress()); - this.masterLog = masterLog; - } - - @Override - public String toString() { - return masterLog.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java deleted file mode 100644 index d7e8fd37ab2..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Array; -import java.lang.reflect.Type; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; - -/** - * Implementation of {@link HotSpotJVMCIReflection} when running in a JVMCI shared library. - */ -class SharedLibraryJVMCIReflection extends HotSpotJVMCIReflection { - - @Override - Object resolveObject(HotSpotObjectConstantImpl objectHandle) { - throw new HotSpotJVMCIUnsupportedOperationError("cannot resolve handle in a JVMCI shared library to a raw object: " + objectHandle); - } - - @Override - boolean isInstance(HotSpotResolvedObjectTypeImpl holder, HotSpotObjectConstantImpl obj) { - if (obj instanceof DirectHotSpotObjectConstantImpl) { - ResolvedJavaType type = getType(obj); - return holder.isAssignableFrom(type); - } - return runtime().compilerToVm.isInstance(holder, obj); - } - - @Override - boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedObjectTypeImpl otherType) { - return runtime().compilerToVm.isAssignableFrom(holder, otherType); - } - - @Override - boolean isLocalClass(HotSpotResolvedObjectTypeImpl holder) { - throw new HotSpotJVMCIUnsupportedOperationError("requires a call Class.isLocalClass()"); - } - - @Override - boolean isMemberClass(HotSpotResolvedObjectTypeImpl holder) { - throw new HotSpotJVMCIUnsupportedOperationError("requires a call Class.isMemberClass()"); - } - - @Override - HotSpotResolvedObjectType getEnclosingClass(HotSpotResolvedObjectTypeImpl holder) { - throw new HotSpotJVMCIUnsupportedOperationError("requires a call Class.getEnclosingClass()"); - } - - @Override - boolean equals(HotSpotObjectConstantImpl x, HotSpotObjectConstantImpl y) { - if (x == y) { - return true; - } - if (x.compressed != y.compressed) { - return false; - } - if (x instanceof DirectHotSpotObjectConstantImpl && y instanceof DirectHotSpotObjectConstantImpl) { - DirectHotSpotObjectConstantImpl xd = (DirectHotSpotObjectConstantImpl) x; - DirectHotSpotObjectConstantImpl yd = (DirectHotSpotObjectConstantImpl) y; - return (xd.object == yd.object); - } - if (x instanceof DirectHotSpotObjectConstantImpl || y instanceof DirectHotSpotObjectConstantImpl) { - // Mixing of constant types is always inequal - return false; - } - IndirectHotSpotObjectConstantImpl indirectX = (IndirectHotSpotObjectConstantImpl) x; - IndirectHotSpotObjectConstantImpl indirectY = (IndirectHotSpotObjectConstantImpl) y; - return runtime().compilerToVm.equals(x, indirectX.getHandle(), y, indirectY.getHandle()); - } - - @Override - ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaMethod) { - // ResolvedJavaMethod.getParameters allows a return value of null - return null; - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - static Annotation[] getClassAnnotations(String className) { - throw new InternalError("missing substitution: " + className); - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - static Annotation[][] getParameterAnnotations(String className, String methodName) { - throw new InternalError("missing substitution: " + className + " " + methodName); - } - - @Override - Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Annotation[] annotations = getClassAnnotations(holder.getName()); - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - Annotation[][] annotations = getParameterAnnotations(javaMethod.getDeclaringClass().getName(), javaMethod.getName()); - if (annotations == null) { - return new Annotation[javaMethod.signature.getParameterCount(false)][0]; - } - return annotations; - } - - @Override - Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - Annotation[] annotations = getMethodAnnotationsInternal(javaMethod); - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass) { - Annotation[] methodAnnotations = getMethodAnnotations(javaMethod); - if (methodAnnotations != null) { - for (Annotation ann : methodAnnotations) { - if (annotationClass.isInstance(ann)) { - return annotationClass.cast(ann); - } - } - } - return null; - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - @SuppressWarnings("unused") - private static Annotation[] getMethodAnnotationsInternal(ResolvedJavaMethod javaMethod) { - throw new InternalError("missing substitution"); - } - - @Override - Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaMethod) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object) { - if (object instanceof DirectHotSpotObjectConstantImpl) { - Class theClass = ((DirectHotSpotObjectConstantImpl) object).object.getClass(); - String name = theClass.getName().replace('.', '/'); - return (HotSpotResolvedObjectTypeImpl) runtime().compilerToVm.lookupType(theClass.getClassLoader(), name); - } - // HotSpot tests if the offset is oopDesc::klass_offset_in_bytes() and returns - // the object type accordingly. When UseCompactClassPointers is enabled, - // oopDesc::klass_offset_in_bytes() will return an offset halfway into the - // object's markWord as a placeholder referring to the klass pointer. - return runtime().compilerToVm.getResolvedJavaType(object, runtime().getConfig().klassOffsetInBytes, false); - } - - @Override - String asString(HotSpotObjectConstantImpl object) { - if (object instanceof IndirectHotSpotObjectConstantImpl) { - return runtime().compilerToVm.asString(object); - } - Object value = ((DirectHotSpotObjectConstantImpl) object).object; - if (value instanceof String) { - return (String) value; - } - return null; - } - - @Override - ResolvedJavaType asJavaType(HotSpotObjectConstantImpl object) { - if (object instanceof DirectHotSpotObjectConstantImpl) { - DirectHotSpotObjectConstantImpl direct = (DirectHotSpotObjectConstantImpl) object; - if (direct.object instanceof Class) { - Class javaClass = (Class) direct.object; - return runtime().fromClass(javaClass); - } - if (direct.object instanceof ResolvedJavaType) { - return (ResolvedJavaType) convertUnknownValue(direct.object); - } - return null; - } - return runtime().compilerToVm.asJavaType(object); - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - static Object convertUnknownValue(Object object) { - return object; - } - - @SuppressWarnings("unchecked") - @Override - T asObject(HotSpotObjectConstantImpl object, Class type) { - if (object instanceof DirectHotSpotObjectConstantImpl) { - Object theObject = ((DirectHotSpotObjectConstantImpl) object).object; - if (type.isInstance(theObject)) { - return (T) convertUnknownValue(type.cast(theObject)); - } - } - return null; - } - - @Override - Object asObject(HotSpotObjectConstantImpl object, HotSpotResolvedJavaType type) { - throw new HotSpotJVMCIUnsupportedOperationError("cannot resolve a shared library JVMCI object handle to a " + - "raw object as it may be in another runtime"); - } - - @Override - String formatString(HotSpotObjectConstantImpl object) { - if (object instanceof DirectHotSpotObjectConstantImpl) { - DirectHotSpotObjectConstantImpl direct = (DirectHotSpotObjectConstantImpl) object; - return "CompilerObject<" + direct.object.getClass().getName() + ">"; - } - IndirectHotSpotObjectConstantImpl indirect = (IndirectHotSpotObjectConstantImpl) object; - if (!indirect.isValid()) { - return "Instance"; - } - return "Instance<" + object.getType().toJavaName() + ">"; - } - - @Override - Integer getLength(HotSpotObjectConstantImpl object) { - if (object instanceof DirectHotSpotObjectConstantImpl) { - DirectHotSpotObjectConstantImpl direct = (DirectHotSpotObjectConstantImpl) object; - if (direct.object.getClass().isArray()) { - return Array.getLength(direct.object); - } - return null; - } - int length = runtime().compilerToVm.getArrayLength(object); - if (length >= 0) { - return length; - } - return null; - } - - @Override - JavaConstant readArrayElement(HotSpotObjectConstantImpl arrayObject, int index) { - Object result = runtime().compilerToVm.readArrayElement(arrayObject, index); - if (result == null) { - return null; - } - if (result instanceof JavaConstant) { - return (JavaConstant) result; - } - JavaConstant constant = JavaConstant.forBoxedPrimitive(result); - if (constant == null) { - throw new InternalError("Unexpected value " + result); - } - return constant; - } - - @Override - JavaConstant forObject(Object value) { - return DirectHotSpotObjectConstantImpl.forObject(value, false); - } - - @Override - JavaConstant unboxPrimitive(HotSpotObjectConstantImpl source) { - Object box = runtime().compilerToVm.unboxPrimitive(source); - return JavaConstant.forBoxedPrimitive(box); - } - - @Override - JavaConstant boxPrimitive(JavaConstant source) { - return runtime().compilerToVm.boxPrimitive(source.asBoxedPrimitive()); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SuppressFBWarnings.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SuppressFBWarnings.java deleted file mode 100644 index 8d5f73681cf..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SuppressFBWarnings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Used to suppress FindBugs warnings. - */ -@interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/UnsafeAccess.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/UnsafeAccess.java deleted file mode 100644 index afdff7a8890..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/UnsafeAccess.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.internal.misc.Unsafe; - -/** - * Package private access to the {@link Unsafe} capability. - */ -class UnsafeAccess { - - static final Unsafe UNSAFE = Unsafe.getUnsafe(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMEntryPoint.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMEntryPoint.java deleted file mode 100644 index e35e35a6b15..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMEntryPoint.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Marker interface for methods which are called from the JVM. - */ -@interface VMEntryPoint { - /** - * An optional comment describing the caller. - */ - String value() default ""; -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMField.java deleted file mode 100644 index da9db1ddc32..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMField.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Describes a C++ field exposed via {@link HotSpotVMConfigAccess}. - */ -public final class VMField { - - /** - * Fully qualified name of the represented field (e.g., "Klass::_name"). - */ - public final String name; - - /** - * The represented field's type (e.g., "Symbol*"). This may be {@code null}. - */ - public final String type; - - /** - * If the represented field is non-static, this is its offset within the containing structure. - */ - public final long offset; - - /** - * If the represented field is static, this is its address. Otherwise, this is 0. - */ - public final long address; - - /** - * Value of the field represented as a boxed boolean if its C++ type is bool otherwise as a - * boxed long; only valid for non-oop static fields. This value is only captured once, during - * JVMCI initialization. If {@link #type} cannot be meaningfully (e.g., a struct) or safely - * (e.g., an oop) expressed as a boxed object, this is {@code null}. - */ - public final Object value; - - /** - * Determines if the represented field is static. - */ - public boolean isStatic() { - return address != 0; - } - - /** - * Creates a description of a non-static field. - */ - @VMEntryPoint - public VMField(String name, String type, long offset, long address, Object value) { - this.name = name; - this.type = type; - this.offset = offset; - this.address = address; - this.value = value; - } - - @Override - public String toString() { - String val = value == null ? "null" : (type.contains("*") ? String.format("0x%x", value) : String.format("%s", value)); - return String.format("Field[name=%s, type=%s, offset=%d, address=0x%x, value=%s]", name, type, offset, address, val); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMFlag.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMFlag.java deleted file mode 100644 index 66030bbcfb0..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMFlag.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -/** - * Describes a VM flag exposed via {@link HotSpotVMConfigAccess}. - */ -public final class VMFlag { - - /** - * The name of the flag. - */ - public final String name; - - /** - * The C++ type of the flag. - */ - public final String type; - - /** - * The flag's value. - */ - public final Object value; - - @VMEntryPoint - VMFlag(String name, String type, Object value) { - this.name = name; - this.type = type; - this.value = value; - } - - @Override - public String toString() { - return String.format("Flag[type=%s, name=%s, value=%s]", type, name, value); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMIntrinsicMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMIntrinsicMethod.java deleted file mode 100644 index d43c9dcca72..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/VMIntrinsicMethod.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.Signature; - -/** - * Describes a method for which the VM has an intrinsic implementation. - */ -public final class VMIntrinsicMethod { - - /** - * The name of the class declaring the intrinsified method. The name is in class file format - * (see JVMS {@jvms 4.2.1}). For example, {@code "java/lang/Thread"} instead of - * {@code "java.lang.Thread"}. - */ - public final String declaringClass; - - /** - * The name of the intrinsified method. This is not guaranteed to be a legal method name (e.g., - * there is a HotSpot intrinsic with the name {@code ""}). - */ - public final String name; - - /** - * The {@link Signature#toMethodDescriptor() descriptor} of the intrinsified method. This is not - * guaranteed to be a legal method descriptor (e.g., intrinsics for signature polymorphic - * methods have a descriptor of {@code "*"}). - */ - public final String descriptor; - - /** - * The unique VM identifier for the intrinsic. - */ - public final int id; - - /** - * This value reflects the `ControlIntrinsic`, `DisableIntrinsic` and `UseXXXIntrinsic` VM flags - * as well as other factors such as the current CPU. - */ - public final boolean isAvailable; - - /** - * True if this intrinsic is supported by C1. - */ - public final boolean c1Supported; - - /** - * True if this intrinsic is supported by C2. - */ - public final boolean c2Supported; - - @VMEntryPoint - VMIntrinsicMethod(String declaringClass, String name, String descriptor, int id, - boolean isAvailable, boolean c1Supported, boolean c2Supported) { - this.declaringClass = declaringClass; - this.name = name; - this.descriptor = descriptor; - this.id = id; - this.isAvailable = isAvailable; - this.c1Supported = c1Supported; - this.c2Supported = c2Supported; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof VMIntrinsicMethod) { - VMIntrinsicMethod that = (VMIntrinsicMethod) obj; - if (that.id == this.id) { - assert that.name.equals(this.name) && - that.declaringClass.equals(this.declaringClass) && - that.descriptor.equals(this.descriptor) && - that.isAvailable == this.isAvailable && - that.c1Supported == this.c1Supported && - that.c2Supported == this.c2Supported; - return true; - } - } - return false; - } - - @Override - public int hashCode() { - return id; - } - - @Override - public String toString() { - return String.format("IntrinsicMethod[declaringClass=%s, name=%s, descriptor=%s, id=%d, isAvailable=%b, c1Supported=%b, c2Supported=%b]", - declaringClass, name, descriptor, id, isAvailable, c1Supported, c2Supported); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java deleted file mode 100644 index 1ee016b73a8..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotJVMCIBackendFactory.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.aarch64; - -import static java.util.Collections.emptyMap; -import static jdk.vm.ci.common.InitTimer.timer; - -import java.util.EnumSet; -import java.util.Map; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.aarch64.AArch64.CPUFeature; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class AArch64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - private static EnumSet computeFeatures(AArch64HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - Map constants = config.getStore().getConstants(); - return HotSpotJVMCIBackendFactory.convertFeatures(CPUFeature.class, constants, idx -> 1L << idx, _ -> config.vmVersionFeatures, emptyMap()); - } - - private static TargetDescription createTarget(AArch64HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new AArch64(computeFeatures(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntime runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - private static RegisterConfig createRegisterConfig(AArch64HotSpotVMConfig config, TargetDescription target) { - // ARMv8 defines r18 as being available to the platform ABI. Windows - // and Darwin use it for such. Linux doesn't assign it and thus r18 can - // be used as an additional register. - boolean canUsePlatformRegister = target.linuxOs; - return new AArch64HotSpotRegisterConfig(target, config.useCompressedOops, canUsePlatformRegister); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntime runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - - @Override - public String getArchitecture() { - return "aarch64"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @Override - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host) { - assert host == null; - AArch64HotSpotVMConfig config = new AArch64HotSpotVMConfig(runtime.getConfigStore()); - TargetDescription target = createTarget(config); - - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - ConstantReflectionProvider constantReflection; - HotSpotMetaAccessProvider metaAccess; - StackIntrospection stackIntrospection; - try (InitTimer _ = timer("create providers")) { - try (InitTimer _ = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer _ = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(config, target); - } - try (InitTimer _ = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer _ = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } - try (InitTimer _ = timer("create StackIntrospection provider")) { - stackIntrospection = new HotSpotStackIntrospection(runtime); - } - } - try (InitTimer _ = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, - StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java deleted file mode 100644 index 3ca3ea68edf..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotRegisterConfig.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.aarch64; - -import static jdk.vm.ci.aarch64.AArch64.lr; -import static jdk.vm.ci.aarch64.AArch64.r0; -import static jdk.vm.ci.aarch64.AArch64.r1; -import static jdk.vm.ci.aarch64.AArch64.r2; -import static jdk.vm.ci.aarch64.AArch64.r3; -import static jdk.vm.ci.aarch64.AArch64.r4; -import static jdk.vm.ci.aarch64.AArch64.r5; -import static jdk.vm.ci.aarch64.AArch64.r6; -import static jdk.vm.ci.aarch64.AArch64.r7; -import static jdk.vm.ci.aarch64.AArch64.rscratch1; -import static jdk.vm.ci.aarch64.AArch64.rscratch2; -import static jdk.vm.ci.aarch64.AArch64.r12; -import static jdk.vm.ci.aarch64.AArch64.r18; -import static jdk.vm.ci.aarch64.AArch64.r27; -import static jdk.vm.ci.aarch64.AArch64.r28; -import static jdk.vm.ci.aarch64.AArch64.r29; -import static jdk.vm.ci.aarch64.AArch64.r31; -import static jdk.vm.ci.aarch64.AArch64.sp; -import static jdk.vm.ci.aarch64.AArch64.v0; -import static jdk.vm.ci.aarch64.AArch64.v1; -import static jdk.vm.ci.aarch64.AArch64.v2; -import static jdk.vm.ci.aarch64.AArch64.v3; -import static jdk.vm.ci.aarch64.AArch64.v4; -import static jdk.vm.ci.aarch64.AArch64.v5; -import static jdk.vm.ci.aarch64.AArch64.v6; -import static jdk.vm.ci.aarch64.AArch64.v7; -import static jdk.vm.ci.aarch64.AArch64.zr; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.ValueKindFactory; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; -import jdk.vm.ci.meta.ValueKind; - -public class AArch64HotSpotRegisterConfig implements RegisterConfig { - - private final TargetDescription target; - - private final List allocatable; - - /** - * The caller saved registers always include all parameter registers. - */ - private final List callerSaved; - - private final boolean allAllocatableAreCallerSaved; - - private final List attributesMap; - - @Override - public List getAllocatableRegisters() { - return allocatable; - } - - @Override - public List filterAllocatableRegisters(PlatformKind kind, List registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - - return List.copyOf(list); - } - - @Override - public List getAttributesMap() { - return attributesMap; - } - - private final List javaGeneralParameterRegisters = List.of(r1, r2, r3, r4, r5, r6, r7, r0); - private final List nativeGeneralParameterRegisters = List.of(r0, r1, r2, r3, r4, r5, r6, r7); - private final List simdParameterRegisters = List.of(v0, v1, v2, v3, v4, v5, v6, v7); - - public static final Register inlineCacheRegister = rscratch2; - - /** - * Vtable stubs expect the metaspace Method in r12. - */ - public static final Register metaspaceMethodRegister = r12; - - /** - * The platform ABI can use r18 to carry inter-procedural state (e.g. thread - * context). If not defined as such by the platform ABI, it can be used as - * additional temporary register. - */ - public static final Register platformRegister = r18; - public static final Register heapBaseRegister = r27; - public static final Register threadRegister = r28; - public static final Register fp = r29; - - private static final List reservedRegisters = List.of(rscratch1, rscratch2, threadRegister, fp, lr, r31, zr, sp); - - private static List initAllocatable(Architecture arch, boolean reserveForHeapBase, boolean canUsePlatformRegister) { - List allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.size() - reservedRegisters.size() - (reserveForHeapBase ? 1 : 0) - (!canUsePlatformRegister ? 1 : 0)]; - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegisters.contains(reg)) { - // skip reserved registers - continue; - } - if (!canUsePlatformRegister && reg.equals(platformRegister)) { - continue; - } - assert !(reg.equals(threadRegister) || reg.equals(fp) || reg.equals(lr) || reg.equals(r31) || reg.equals(zr) || reg.equals(sp)); - if (reserveForHeapBase && reg.equals(heapBaseRegister)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return List.of(registers); - } - - public AArch64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops, boolean canUsePlatformRegister) { - this(target, initAllocatable(target.arch, useCompressedOops, canUsePlatformRegister)); - assert callerSaved.size() >= allocatable.size(); - } - - public AArch64HotSpotRegisterConfig(TargetDescription target, List allocatable) { - this.target = target; - - this.allocatable = allocatable; - Set callerSaveSet = new HashSet<>(); - callerSaveSet.addAll(allocatable); - callerSaveSet.addAll(simdParameterRegisters); - callerSaveSet.addAll(javaGeneralParameterRegisters); - callerSaveSet.addAll(nativeGeneralParameterRegisters); - callerSaved = List.copyOf(callerSaveSet); - - allAllocatableAreCallerSaved = true; - attributesMap = RegisterAttributes.createMap(this, AArch64.allRegisters); - } - - @Override - public List getCallerSaveRegisters() { - return callerSaved; - } - - @Override - public List getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return allAllocatableAreCallerSaved; - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory valueKindFactory) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - // On x64, parameter locations are the same whether viewed - // from the caller or callee perspective - return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - - @Override - public List getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; - case Float: - case Double: - return simdParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - private int parseStackArg(ValueKind valueKind, AllocatableValue[] locations, int index, int currentStackOffset, HotSpotCallingConventionType type) { - int kindSize = valueKind.getPlatformKind().getSizeInBytes(); - locations[index] = StackSlot.get(valueKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(kindSize, target.wordSize); - return currentStackOffset; - } - - private int parseDarwinNativeStackArg(ValueKind valueKind, AllocatableValue[] locations, int index, int currentStackOffset, HotSpotCallingConventionType type) { - int kindSize = valueKind.getPlatformKind().getSizeInBytes(); - if (currentStackOffset % kindSize != 0) { - // In MacOS natural alignment is used - // See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - currentStackOffset += kindSize - currentStackOffset % kindSize; - } - locations[index] = StackSlot.get(valueKind, currentStackOffset, !type.out); - // In MacOS "Function arguments may consume slots on the stack that are not multiples of 8 bytes" - // See https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - currentStackOffset += kindSize; - return currentStackOffset; - } - - private CallingConvention callingConvention(List generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, - ValueKindFactory valueKindFactory) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentSIMD = 0; - int currentStackOffset = 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.size()) { - Register register = generalParameterRegisters.get(currentGeneral++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - case Float: - case Double: - if (currentSIMD < simdParameterRegisters.size()) { - Register register = simdParameterRegisters.get(currentSIMD++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - if (target.macOs && type == HotSpotCallingConventionType.NativeCall) { - currentStackOffset = parseDarwinNativeStackArg(valueKindFactory.getValueKind(kind), locations, i, currentStackOffset, type); - } else { - currentStackOffset = parseStackArg(valueKindFactory.getValueKind(kind), locations, i, currentStackOffset, type); - } - } - } - - JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(valueKindFactory.getValueKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - @Override - public Register getReturnRegister(JavaKind kind) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return r0; - case Float: - case Double: - return v0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return sp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + getAllocatableRegisters() + "%n" + "CallerSave: " + getCallerSaveRegisters() + "%n"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java deleted file mode 100644 index 206909895fa..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/AArch64HotSpotVMConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.aarch64; - -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; - -/** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. - */ -class AArch64HotSpotVMConfig extends HotSpotVMConfigAccess { - - AArch64HotSpotVMConfig(HotSpotVMConfigStore config) { - super(config); - } - - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - final long vmVersionFeatures = getFieldValue("Abstract_VM_Version::_features", Long.class, "uint64_t"); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/package-info.java deleted file mode 100644 index fe75a538ad5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/aarch64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The AArch64 HotSpot specific portions of the JVMCI API. - */ -package jdk.vm.ci.hotspot.aarch64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java deleted file mode 100644 index 7c46c239092..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotJVMCIBackendFactory.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.amd64; - -import static jdk.vm.ci.common.InitTimer.timer; - -import java.util.EnumSet; -import java.util.Map; - -import jdk.internal.misc.Unsafe; -import jdk.internal.util.OperatingSystem; -import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.amd64.AMD64.CPUFeature; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - private static EnumSet computeFeatures(AMD64HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - Map constants = config.getStore().getConstants(); - Map renaming = Map.of("3DNOW_PREFETCH", "AMD_3DNOW_PREFETCH"); - long featuresBitMapAddress = config.vmVersionFeatures + config.vmFeaturesFeaturesOffset; - EnumSet features = HotSpotJVMCIBackendFactory.convertFeatures(CPUFeature.class, constants, idx -> { - final long featuresElementShiftCount = 6; // log (# of bits per long) - final long featuresElementMask = (1L << featuresElementShiftCount) - 1; - return 1L << (idx & featuresElementMask); - }, idx -> { - final long featuresElementShiftCount = 6; // log (# of bits per long) - long featureIndex = idx >>> featuresElementShiftCount; - return Unsafe.getUnsafe().getLong(featuresBitMapAddress + featureIndex * Long.BYTES); - }, renaming); - // SSE and SSE2 are no longer reported as of JDK-8383881, but JVMCI compiler may - // still model instructions using these feature flags, so add them explicitly here. - features.add(AMD64.CPUFeature.SSE); - features.add(AMD64.CPUFeature.SSE2); - return features; - } - - private static TargetDescription createTarget(AMD64HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new AMD64(computeFeatures(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntime runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - private static RegisterConfig createRegisterConfig(AMD64HotSpotVMConfig config, TargetDescription target) { - return new AMD64HotSpotRegisterConfig(target, config.useCompressedOops, OperatingSystem.isWindows()); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntime runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - - @Override - public String getArchitecture() { - return "AMD64"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @Override - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host) { - assert host == null; - AMD64HotSpotVMConfig config = new AMD64HotSpotVMConfig(runtime.getConfigStore()); - TargetDescription target = createTarget(config); - - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - ConstantReflectionProvider constantReflection; - HotSpotMetaAccessProvider metaAccess; - StackIntrospection stackIntrospection; - try (InitTimer _ = timer("create providers")) { - try (InitTimer _ = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer _ = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(config, target); - } - try (InitTimer _ = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer _ = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } - try (InitTimer _ = timer("create StackIntrospection provider")) { - stackIntrospection = new HotSpotStackIntrospection(runtime); - } - } - try (InitTimer _ = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, - StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java deleted file mode 100644 index 3849ac779c4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotRegisterConfig.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.amd64; - -import static jdk.vm.ci.amd64.AMD64.r12; -import static jdk.vm.ci.amd64.AMD64.r15; -import static jdk.vm.ci.amd64.AMD64.r8; -import static jdk.vm.ci.amd64.AMD64.r9; -import static jdk.vm.ci.amd64.AMD64.rax; -import static jdk.vm.ci.amd64.AMD64.rcx; -import static jdk.vm.ci.amd64.AMD64.rdi; -import static jdk.vm.ci.amd64.AMD64.rdx; -import static jdk.vm.ci.amd64.AMD64.rsi; -import static jdk.vm.ci.amd64.AMD64.rsp; -import static jdk.vm.ci.amd64.AMD64.xmm0; -import static jdk.vm.ci.amd64.AMD64.xmm1; -import static jdk.vm.ci.amd64.AMD64.xmm2; -import static jdk.vm.ci.amd64.AMD64.xmm3; -import static jdk.vm.ci.amd64.AMD64.xmm4; -import static jdk.vm.ci.amd64.AMD64.xmm5; -import static jdk.vm.ci.amd64.AMD64.xmm6; -import static jdk.vm.ci.amd64.AMD64.xmm7; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.ValueKindFactory; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; -import jdk.vm.ci.meta.ValueKind; - -public class AMD64HotSpotRegisterConfig implements RegisterConfig { - - private final TargetDescription target; - - private final List allocatable; - - /** - * The caller saved registers always include all parameter registers. - */ - private final List callerSaved; - - private final boolean allAllocatableAreCallerSaved; - - private final List attributesMap; - - @Override - public List getAllocatableRegisters() { - return allocatable; - } - - @Override - public List filterAllocatableRegisters(PlatformKind kind, List registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - - List ret = List.copyOf(list); - return ret; - } - - @Override - public List getAttributesMap() { - return attributesMap; - } - - private final List javaGeneralParameterRegisters; - private final List nativeGeneralParameterRegisters; - private final List javaXMMParameterRegisters; - private final List nativeXMMParameterRegisters; - private final boolean windowsOS; - - /* - * Some ABIs (e.g. Windows) require a so-called "home space", that is a save area on the stack - * to store the argument registers - */ - private final boolean needsNativeStackHomeSpace; - - private static final List reservedRegisters = List.of(rsp, r15); - - private static List initAllocatable(Architecture arch, boolean reserveForHeapBase) { - List allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.size() - reservedRegisters.size() - (reserveForHeapBase ? 1 : 0)]; - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegisters.contains(reg)) { - // skip reserved registers - continue; - } - if (reserveForHeapBase && reg.equals(r12)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return List.of(registers); - } - - public AMD64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops, boolean windowsOs) { - this(target, initAllocatable(target.arch, useCompressedOops), windowsOs); - assert callerSaved.size() >= allocatable.size(); - } - - public AMD64HotSpotRegisterConfig(TargetDescription target, List allocatable, boolean windowsOS) { - this.target = target; - this.windowsOS = windowsOS; - - if (windowsOS) { - javaGeneralParameterRegisters = List.of(rdx, r8, r9, rdi, rsi, rcx); - nativeGeneralParameterRegisters = List.of(rcx, rdx, r8, r9); - nativeXMMParameterRegisters = List.of(xmm0, xmm1, xmm2, xmm3); - this.needsNativeStackHomeSpace = true; - } else { - javaGeneralParameterRegisters = List.of(rsi, rdx, rcx, r8, r9, rdi); - nativeGeneralParameterRegisters = List.of(rdi, rsi, rdx, rcx, r8, r9); - nativeXMMParameterRegisters = List.of(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7); - this.needsNativeStackHomeSpace = false; - } - javaXMMParameterRegisters = List.of(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7); - - this.allocatable = allocatable; - Set callerSaveSet = new HashSet<>(); - callerSaveSet.addAll(allocatable); - callerSaveSet.addAll(javaXMMParameterRegisters); - callerSaveSet.addAll(javaGeneralParameterRegisters); - callerSaveSet.addAll(nativeGeneralParameterRegisters); - callerSaved = List.copyOf(callerSaveSet); - - allAllocatableAreCallerSaved = true; - attributesMap = RegisterAttributes.createMap(this, target.arch.getRegisters()); - } - - @Override - public List getCallerSaveRegisters() { - return callerSaved; - } - - @Override - public List getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return allAllocatableAreCallerSaved; - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory valueKindFactory) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(nativeGeneralParameterRegisters, nativeXMMParameterRegisters, windowsOS, returnType, parameterTypes, hotspotType, valueKindFactory); - } - // On x64, parameter locations are the same whether viewed - // from the caller or callee perspective - return callingConvention(javaGeneralParameterRegisters, javaXMMParameterRegisters, false, returnType, parameterTypes, hotspotType, valueKindFactory); - } - - @Override - public List getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; - case Float: - case Double: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeXMMParameterRegisters : javaXMMParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - /** - * Hand out registers matching the calling convention from the {@code generalParameterRegisters} - * and {@code xmmParameterRegisters} sets. Normally registers are handed out from each set - * individually based on the type of the argument. If the {@code unified} flag is true then hand - * out registers in a single sequence, selecting between the sets based on the type. This is to - * support the Windows calling convention which only ever passes 4 arguments in registers, no - * matter their types. - * - * @param generalParameterRegisters - * @param xmmParameterRegisters - * @param unified - * @param returnType - * @param parameterTypes - * @param type - * @param valueKindFactory - * @return the resulting calling convention - */ - private CallingConvention callingConvention(List generalParameterRegisters, List xmmParameterRegisters, boolean unified, JavaType returnType, JavaType[] parameterTypes, - HotSpotCallingConventionType type, - ValueKindFactory valueKindFactory) { - assert !unified || generalParameterRegisters.size() == xmmParameterRegisters.size() : "must be same size in unified mode"; - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentXMM = 0; - int currentStackOffset = type == HotSpotCallingConventionType.NativeCall && needsNativeStackHomeSpace ? generalParameterRegisters.size() * target.wordSize : 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.size()) { - Register register = generalParameterRegisters.get(currentGeneral++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - case Float: - case Double: - if ((unified ? currentGeneral : currentXMM) < xmmParameterRegisters.size()) { - Register register = xmmParameterRegisters.get(unified ? currentGeneral++ : currentXMM++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - ValueKind valueKind = valueKindFactory.getValueKind(kind); - locations[i] = StackSlot.get(valueKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(valueKind.getPlatformKind().getSizeInBytes(), target.wordSize); - } - } - assert !unified || currentXMM == 0 : "shouldn't be used in unified mode"; - - JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(valueKindFactory.getValueKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - @Override - public Register getReturnRegister(JavaKind kind) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return rax; - case Float: - case Double: - return xmm0; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return rsp; - } - - @Override - public String toString() { - return String.format("Allocatable: " + getAllocatableRegisters() + "%n" + "CallerSave: " + getCallerSaveRegisters() + "%n"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java deleted file mode 100644 index 1b3a46fc8d7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/AMD64HotSpotVMConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.amd64; - -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; - -/** - * Used to access AMD64 specific native configuration details. - */ -class AMD64HotSpotVMConfig extends HotSpotVMConfigAccess { - - AMD64HotSpotVMConfig(HotSpotVMConfigStore config) { - super(config); - } - - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - final long vmVersionFeatures = getFieldAddress("VM_Version::_features", "VM_Version::VM_Features"); - final long vmFeaturesFeaturesOffset = getFieldOffset("VM_Version::VM_Features::_features_bitmap[0]", Long.class, "uint64_t"); - final long vmFeaturesFeaturesSize = getFieldValue("VM_Version::VM_Features::_features_bitmap_size", Long.class, "int"); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/package-info.java deleted file mode 100644 index 7aa650817f4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/amd64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The AMD64 HotSpot specific portions of the JVMCI API. - */ -package jdk.vm.ci.hotspot.amd64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/package-info.java deleted file mode 100644 index 03a74a0dad2..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * HotSpot specific portions of the JVMCI API. - */ -package jdk.vm.ci.hotspot; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotJVMCIBackendFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotJVMCIBackendFactory.java deleted file mode 100644 index f50fcf1dbbc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotJVMCIBackendFactory.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.riscv64; - -import static java.util.Collections.emptyMap; -import static jdk.vm.ci.common.InitTimer.timer; - -import java.util.EnumSet; -import java.util.Map; - -import jdk.vm.ci.riscv64.RISCV64; -import jdk.vm.ci.riscv64.RISCV64.CPUFeature; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.common.InitTimer; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider; -import jdk.vm.ci.hotspot.HotSpotStackIntrospection; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class RISCV64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { - - private static EnumSet computeFeatures(RISCV64HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - Map constants = config.getStore().getConstants(); - return HotSpotJVMCIBackendFactory.convertFeatures(CPUFeature.class, constants, mask -> mask, _ -> config.vmVersionFeatures, emptyMap()); - } - - private static TargetDescription createTarget(RISCV64HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - Architecture arch = new RISCV64(computeFeatures(config)); - return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntime runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - private static RegisterConfig createRegisterConfig(RISCV64HotSpotVMConfig config, TargetDescription target) { - return new RISCV64HotSpotRegisterConfig(target, config.useCompressedOops, target.linuxOs); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntime runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntime runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - - @Override - public String getArchitecture() { - return "riscv64"; - } - - @Override - public String toString() { - return "JVMCIBackend:" + getArchitecture(); - } - - @Override - public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntime runtime, JVMCIBackend host) { - assert host == null; - RISCV64HotSpotVMConfig config = new RISCV64HotSpotVMConfig(runtime.getConfigStore()); - TargetDescription target = createTarget(config); - - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - ConstantReflectionProvider constantReflection; - HotSpotMetaAccessProvider metaAccess; - StackIntrospection stackIntrospection; - try (InitTimer _ = timer("create providers")) { - try (InitTimer _ = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer _ = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(config, target); - } - try (InitTimer _ = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer _ = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } - try (InitTimer _ = timer("create StackIntrospection provider")) { - stackIntrospection = new HotSpotStackIntrospection(runtime); - } - } - try (InitTimer _ = timer("instantiate backend")) { - return createBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } - } - - protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, - StackIntrospection stackIntrospection) { - return new JVMCIBackend(metaAccess, codeCache, constantReflection, stackIntrospection); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotRegisterConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotRegisterConfig.java deleted file mode 100644 index 80091d71fe9..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotRegisterConfig.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.riscv64; - -import static jdk.vm.ci.riscv64.RISCV64.x0; -import static jdk.vm.ci.riscv64.RISCV64.x1; -import static jdk.vm.ci.riscv64.RISCV64.x2; -import static jdk.vm.ci.riscv64.RISCV64.x3; -import static jdk.vm.ci.riscv64.RISCV64.x4; -import static jdk.vm.ci.riscv64.RISCV64.x5; -import static jdk.vm.ci.riscv64.RISCV64.x6; -import static jdk.vm.ci.riscv64.RISCV64.x7; -import static jdk.vm.ci.riscv64.RISCV64.x8; -import static jdk.vm.ci.riscv64.RISCV64.x10; -import static jdk.vm.ci.riscv64.RISCV64.x11; -import static jdk.vm.ci.riscv64.RISCV64.x12; -import static jdk.vm.ci.riscv64.RISCV64.x13; -import static jdk.vm.ci.riscv64.RISCV64.x14; -import static jdk.vm.ci.riscv64.RISCV64.x15; -import static jdk.vm.ci.riscv64.RISCV64.x16; -import static jdk.vm.ci.riscv64.RISCV64.x17; -import static jdk.vm.ci.riscv64.RISCV64.x23; -import static jdk.vm.ci.riscv64.RISCV64.x27; -import static jdk.vm.ci.riscv64.RISCV64.f10; -import static jdk.vm.ci.riscv64.RISCV64.f11; -import static jdk.vm.ci.riscv64.RISCV64.f12; -import static jdk.vm.ci.riscv64.RISCV64.f13; -import static jdk.vm.ci.riscv64.RISCV64.f14; -import static jdk.vm.ci.riscv64.RISCV64.f15; -import static jdk.vm.ci.riscv64.RISCV64.f16; -import static jdk.vm.ci.riscv64.RISCV64.f17; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import jdk.vm.ci.riscv64.RISCV64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CallingConvention.Type; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterAttributes; -import jdk.vm.ci.code.RegisterConfig; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.ValueKindFactory; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.Value; -import jdk.vm.ci.meta.ValueKind; - -public class RISCV64HotSpotRegisterConfig implements RegisterConfig { - - private final TargetDescription target; - - private final List allocatable; - - /** - * The caller saved registers always include all parameter registers. - */ - private final List callerSaved; - - private final boolean allAllocatableAreCallerSaved; - - private final List attributesMap; - - @Override - public List getAllocatableRegisters() { - return allocatable; - } - - @Override - public List filterAllocatableRegisters(PlatformKind kind, List registers) { - ArrayList list = new ArrayList<>(); - for (Register reg : registers) { - if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { - list.add(reg); - } - } - - return List.copyOf(list); - } - - @Override - public List getAttributesMap() { - return attributesMap; - } - - private final List javaGeneralParameterRegisters = List.of(x11, x12, x13, x14, x15, x16, x17, x10); - private final List nativeGeneralParameterRegisters = List.of(x10, x11, x12, x13, x14, x15, x16, x17); - private final List fpParameterRegisters = List.of(f10, f11, f12, f13, f14, f15, f16, f17); - - public static final Register zero = x0; - public static final Register ra = x1; - public static final Register sp = x2; - public static final Register gp = x3; - public static final Register tp = x4; - public static final Register t0 = x5; - public static final Register t1 = x6; - public static final Register t2 = x7; - public static final Register fp = x8; - public static final Register threadRegister = x23; - public static final Register heapBaseRegister = x27; - - private static final List reservedRegisters =List.of(zero, ra, sp, gp, tp, t0, t1, t2, fp); - - private static List initAllocatable(Architecture arch, boolean reserveForHeapBase) { - List allRegisters = arch.getAvailableValueRegisters(); - Register[] registers = new Register[allRegisters.size() - reservedRegisters.size() - (reserveForHeapBase ? 1 : 0)]; - - int idx = 0; - for (Register reg : allRegisters) { - if (reservedRegisters.contains(reg)) { - // skip reserved registers - continue; - } - assert !(reg.equals(zero) || reg.equals(ra) || reg.equals(sp) || reg.equals(gp) || reg.equals(tp) || - reg.equals(t0) || reg.equals(t1) || reg.equals(t2) || reg.equals(fp)); - if (reserveForHeapBase && reg.equals(heapBaseRegister)) { - // skip heap base register - continue; - } - - registers[idx++] = reg; - } - - assert idx == registers.length; - return List.of(registers); - } - - public RISCV64HotSpotRegisterConfig(TargetDescription target, boolean useCompressedOops, boolean linuxOs) { - this(target, initAllocatable(target.arch, useCompressedOops)); - assert callerSaved.size() >= allocatable.size(); - } - - public RISCV64HotSpotRegisterConfig(TargetDescription target, List allocatable) { - this.target = target; - this.allocatable = allocatable; - - Set callerSaveSet = new HashSet<>(); - callerSaveSet.addAll(allocatable); - callerSaveSet.addAll(fpParameterRegisters); - callerSaveSet.addAll(javaGeneralParameterRegisters); - callerSaveSet.addAll(nativeGeneralParameterRegisters); - callerSaved = List.copyOf(callerSaveSet); - - allAllocatableAreCallerSaved = true; - attributesMap = RegisterAttributes.createMap(this, RISCV64.allRegisters); - } - - @Override - public List getCallerSaveRegisters() { - return callerSaved; - } - - @Override - public List getCalleeSaveRegisters() { - return null; - } - - @Override - public boolean areAllAllocatableRegistersCallerSaved() { - return allAllocatableAreCallerSaved; - } - - @Override - public CallingConvention getCallingConvention(Type type, JavaType returnType, JavaType[] parameterTypes, ValueKindFactory valueKindFactory) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - if (type == HotSpotCallingConventionType.NativeCall) { - return callingConvention(nativeGeneralParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - return callingConvention(javaGeneralParameterRegisters, returnType, parameterTypes, hotspotType, valueKindFactory); - } - - @Override - public List getCallingConventionRegisters(Type type, JavaKind kind) { - HotSpotCallingConventionType hotspotType = (HotSpotCallingConventionType) type; - switch (kind) { - case Boolean: - case Byte: - case Short: - case Char: - case Int: - case Long: - case Object: - return hotspotType == HotSpotCallingConventionType.NativeCall ? nativeGeneralParameterRegisters : javaGeneralParameterRegisters; - case Float: - case Double: - return fpParameterRegisters; - default: - throw JVMCIError.shouldNotReachHere(); - } - } - - private CallingConvention callingConvention(List generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, HotSpotCallingConventionType type, - ValueKindFactory valueKindFactory) { - AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; - - int currentGeneral = 0; - int currentFP = 0; - int currentStackOffset = 0; - - for (int i = 0; i < parameterTypes.length; i++) { - final JavaKind kind = parameterTypes[i].getJavaKind().getStackKind(); - - switch (kind) { - case Byte: - case Boolean: - case Short: - case Char: - case Int: - case Long: - case Object: - if (currentGeneral < generalParameterRegisters.size()) { - Register register = generalParameterRegisters.get(currentGeneral++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - case Float: - case Double: - if (currentFP < fpParameterRegisters.size()) { - Register register = fpParameterRegisters.get(currentFP++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } else if (currentGeneral < generalParameterRegisters.size()) { - Register register = generalParameterRegisters.get(currentGeneral++); - locations[i] = register.asValue(valueKindFactory.getValueKind(kind)); - } - break; - default: - throw JVMCIError.shouldNotReachHere(); - } - - if (locations[i] == null) { - ValueKind valueKind = valueKindFactory.getValueKind(kind); - locations[i] = StackSlot.get(valueKind, currentStackOffset, !type.out); - currentStackOffset += Math.max(valueKind.getPlatformKind().getSizeInBytes(), target.wordSize); - } - } - - JavaKind returnKind = returnType == null ? JavaKind.Void : returnType.getJavaKind(); - AllocatableValue returnLocation = returnKind == JavaKind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(valueKindFactory.getValueKind(returnKind.getStackKind())); - return new CallingConvention(currentStackOffset, returnLocation, locations); - } - - @Override - public Register getReturnRegister(JavaKind kind) { - switch (kind) { - case Boolean: - case Byte: - case Char: - case Short: - case Int: - case Long: - case Object: - return x10; - case Float: - case Double: - return f10; - case Void: - case Illegal: - return null; - default: - throw new UnsupportedOperationException("no return register for type " + kind); - } - } - - @Override - public Register getFrameRegister() { - return x2; - } - - @Override - public String toString() { - return String.format("Allocatable: " + getAllocatableRegisters() + "%n" + "CallerSave: " + getCallerSaveRegisters() + "%n"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotVMConfig.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotVMConfig.java deleted file mode 100644 index 6b09f9f0603..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/RISCV64HotSpotVMConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.riscv64; - -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; - -/** - * Used to access native configuration details. - * - * All non-static, public fields in this class are so that they can be compiled as constants. - */ -class RISCV64HotSpotVMConfig extends HotSpotVMConfigAccess { - - RISCV64HotSpotVMConfig(HotSpotVMConfigStore config) { - super(config); - } - - final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - final long vmVersionFeatures = getFieldValue("Abstract_VM_Version::_features", Long.class, "uint64_t"); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/package-info.java deleted file mode 100644 index 41e886b31a3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/riscv64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The RISCV64 HotSpot specific portions of the JVMCI API. - */ -package jdk.vm.ci.hotspot.riscv64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractJavaProfile.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractJavaProfile.java deleted file mode 100644 index 4e703beddf6..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractJavaProfile.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * This object holds probability information for a set of items that were profiled at a specific - * BCI. The precision of the supplied values may vary, but a runtime that provides this information - * should be aware that it will be used to guide performance-critical decisions like speculative - * inlining, etc. - * - * @param a subclass of AbstractProfiledItem - * @param the class of the items that are profiled at the specific BCI and for which - * probabilities are stored. E.g., a ResolvedJavaType or a ResolvedJavaMethod. - */ -public abstract class AbstractJavaProfile, U> { - - private final double notRecordedProbability; - private final T[] pitems; - - /** - * - * @param notRecordedProbability - * @param pitems - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of the `pitems` array parameter") - public AbstractJavaProfile(double notRecordedProbability, T[] pitems) { - this.pitems = pitems; - assert !Double.isNaN(notRecordedProbability); - this.notRecordedProbability = notRecordedProbability; - assert isSorted(); - assert totalProbablility() >= 0 && totalProbablility() <= 1.0001 : totalProbablility() + " " + this; - } - - private double totalProbablility() { - double total = notRecordedProbability; - for (T item : pitems) { - total += item.probability; - } - return total; - } - - /** - * Determines if an array of profiled items are sorted in descending order of their - * probabilities. - */ - private boolean isSorted() { - for (int i = 1; i < pitems.length; i++) { - if (pitems[i - 1].getProbability() < pitems[i].getProbability()) { - return false; - } - } - return true; - } - - /** - * Returns the estimated probability of all types that could not be recorded due to profiling - * limitations. - * - * @return double value ≥ 0.0 and ≤ 1.0 - */ - public double getNotRecordedProbability() { - return notRecordedProbability; - } - - protected T[] getItems() { - return pitems; - } - - /** - * Searches for an entry of a given resolved Java type. - * - * @param type the type for which an entry should be searched - * @return the entry or null if no entry for this type can be found - */ - public T findEntry(ResolvedJavaType type) { - if (pitems != null) { - for (T pt : pitems) { - if (pt.getItem().equals(type)) { - return pt; - } - } - } - return null; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append(this.getClass().getName()); - builder.append("["); - if (pitems != null) { - for (T pt : pitems) { - builder.append(pt.toString()); - builder.append(", "); - } - } - builder.append(this.notRecordedProbability); - builder.append("]"); - return builder.toString(); - } - - public boolean isIncluded(U item) { - if (this.getNotRecordedProbability() > 0.0) { - return true; - } else { - for (int i = 0; i < getItems().length; i++) { - T pitem = getItems()[i]; - U curType = pitem.getItem(); - if (curType == item) { - return true; - } - } - } - return false; - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof AbstractJavaProfile)) { - return false; - } - AbstractJavaProfile that = (AbstractJavaProfile) obj; - if (that.notRecordedProbability != notRecordedProbability) { - return false; - } - if (that.pitems.length != pitems.length) { - return false; - } - for (int i = 0; i < pitems.length; ++i) { - if (!pitems[i].equals(that.pitems[i])) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - return (int) Double.doubleToLongBits(notRecordedProbability) + pitems.length * 13; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java deleted file mode 100644 index 87b8c99f1f6..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AbstractProfiledItem.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * A profiled type that has a probability. Profiled types are naturally sorted in descending order - * of their probabilities. - */ -public abstract class AbstractProfiledItem implements Comparable> { - - protected final T item; - protected final double probability; - - public AbstractProfiledItem(T item, double probability) { - assert item != null; - assert probability >= 0.0D && probability <= 1.0D; - this.item = item; - this.probability = probability; - } - - protected T getItem() { - return item; - } - - /** - * Returns the estimated probability of {@link #getItem()}. - * - * @return double value ≥ 0.0 and ≤ 1.0 - */ - public double getProbability() { - return probability; - } - - /** - * Returns -1 if the {@linkplain #getProbability() probability} of this item is greater than - * {@code o}'s probability, 0 if there are equal otherwise 1. - */ - @Override - public int compareTo(AbstractProfiledItem o) { - // Need to swap the order of operands so that higher probabilities are sorted first - return Double.compare(o.getProbability(), getProbability()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - temp = Double.doubleToLongBits(probability); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + item.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AbstractProfiledItem other = (AbstractProfiledItem) obj; - if (Double.doubleToLongBits(probability) != Double.doubleToLongBits(other.probability)) { - return false; - } - return item.equals(other.item); - } - - @Override - public abstract String toString(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AllocatableValue.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AllocatableValue.java deleted file mode 100644 index 23d696523a3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AllocatableValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Common base class for values that are stored in some location that's managed by the register - * allocator (e.g. register, stack slot). - */ -public abstract class AllocatableValue extends Value implements JavaValue { - - public static final AllocatableValue[] NONE = {}; - - public AllocatableValue(ValueKind kind) { - super(kind); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Annotated.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Annotated.java deleted file mode 100644 index 666e1181cb1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Annotated.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.annotation.Inherited; -import java.util.List; - -/** - * Represents a program element such as a method, constructor, field or class for which annotations - * may be present. - */ -public interface Annotated { - - /** - * Constructs the annotations present on this element whose types are in the set composed of {@code type1}, - * {@code type2} and {@code types}. All enum types referenced by the returned annotation are - * initialized. Class initialization is not triggered for enum types referenced by other - * annotations of this element. - * - * If this element is a class, then {@link Inherited} annotations are included in the set of - * annotations considered. - * - * See {@link java.lang.reflect.AnnotatedElement} for the definition of present. - * - * @param type1 an annotation type - * @param type2 an annotation type - * @param types more annotation types - * @return an immutable list of the annotations present on this element that match one of the - * given types - * @throws IllegalArgumentException if any type in the set composed of {@code type1}, - * {@code type2} and {@code types} is not an annotation interface type - * @throws UnsupportedOperationException if this operation is not supported - */ - default List getAnnotationData(ResolvedJavaType type1, ResolvedJavaType type2, ResolvedJavaType... types) { - throw new UnsupportedOperationException(); - } - - /** - * Constructs the annotation present on this element of type {@code type}. - * - * See {@link java.lang.reflect.AnnotatedElement} for the definition of present. - * - * @param type the type object corresponding to the annotation interface type - * @return this element's annotation for the specified annotation type if present on this - * element, else null - * @throws IllegalArgumentException if {@code type} is not an annotation interface type - * @throws UnsupportedOperationException if this operation is not supported - */ - default AnnotationData getAnnotationData(ResolvedJavaType type) { - throw new UnsupportedOperationException(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AnnotationData.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AnnotationData.java deleted file mode 100644 index 76edb8c83a7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/AnnotationData.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.annotation.Annotation; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -/** - * Represents an annotation where element values are represented with the types described - * {@linkplain #get here}. - * - * In contrast to the standard annotation API based on {@link Annotation}, use of - * {@link AnnotationData} allows annotations to be queried without the JVMCI runtime having to - * support dynamic loading of arbitrary {@link Annotation} classes. Such support is impossible in a - * closed world, ahead-of-time compiled environment such as libgraal. - */ -public final class AnnotationData { - - private final JavaType type; - private final Map elements; - - private static final Set> ELEMENT_TYPES = Set.of( - Boolean.class, - Byte.class, - Character.class, - Short.class, - Integer.class, - Float.class, - Long.class, - Double.class, - String.class, - EnumData.class, - AnnotationData.class); - - /** - * Creates an annotation. - * - * @param type the annotation interface of this annotation, represented as a {@link JavaType} - * @param elements the names and values of this annotation's element values. Each value's type - * must be one of the {@code AnnotationData} types described {@linkplain #get here} - * or it must be a {@link ErrorData} object whose {@code toString()} value describes - * the error raised while parsing the element. There is no distinction between a - * value explicitly present in the annotation and an element's default value. - * @throws IllegalArgumentException if the value of an entry in {@code elements} is not of an - * accepted type - * @throws NullPointerException if any of the above parameters is null or any entry in - * {@code elements} is null - */ - public AnnotationData(JavaType type, Map.Entry[] elements) { - this.type = Objects.requireNonNull(type); - for (Map.Entry e : elements) { - Object value = e.getValue(); - if (!(value instanceof ErrorData) && - !(value instanceof JavaType) && - !(value instanceof List) && - !ELEMENT_TYPES.contains(value.getClass())) { - throw new IllegalArgumentException("illegal type for element " + e.getKey() + ": " + value.getClass().getName()); - } - } - this.elements = Map.ofEntries(elements); - } - - /** - * @return the annotation interface of this annotation, represented as a {@link JavaType} - */ - public JavaType getAnnotationType() { - return type; - } - - // @formatter:off - /** - * Gets the annotation element denoted by {@code name}. The following table shows the - * correspondence between the type of an element as declared by a method in the annotation - * interface and the type of value returned by this method: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Annotation AnnotationData
boolean Boolean
byte Byte
char Character
short Short
int Integer
float Float
long Long
double Double
String String
Class JavaType
Enum EnumData
Annotation AnnotationData
[]immutable List<T> where T is one of the above types
- * - * @param the type of the element as per the {@code AnnotationData} column in the above - * table or {@link Object} - * @param elementType the class for the type of the element - * @return the annotation element denoted by {@code name} - * @throws ClassCastException if the element is not of type {@code V} - * @throws IllegalArgumentException if this annotation has no element named {@code name} or if - * there was an error parsing or creating the element value - */ - // @formatter:on - public V get(String name, Class elementType) { - Object val = elements.get(name); - if (val == null) { - throw new IllegalArgumentException("no element named " + name); - } - Class valClass = val.getClass(); - if (valClass == ErrorData.class) { - throw new IllegalArgumentException(val.toString()); - } - return elementType.cast(val); - } - - @Override - public String toString() { - return "@" + type.getName() + "(" + elements + ")"; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof AnnotationData) { - AnnotationData that = (AnnotationData) obj; - return this.type.equals(that.type) && this.elements.equals(that.elements); - - } - return false; - } - - @Override - public int hashCode() { - return type.hashCode() ^ elements.hashCode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java deleted file mode 100644 index ddbd7ba9805..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Assumptions.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -/** - * Class for recording assumptions made during compilation. - */ -public final class Assumptions implements Iterable { - - /** - * Abstract base class for assumptions. An assumption assumes a property of the runtime that may - * be invalidated by subsequent execution (e.g., that a class has no subclasses implementing - * {@link NoFinalizableSubclass Object.finalize()}). - */ - public abstract static class Assumption { - } - - /** - * A class for providing information that is only valid in association with a set of - * {@link Assumption}s. It is permissible for AssumptionResults to have no assumptions at all. - * For instance, if {@link ResolvedJavaType#isLeaf()} returns true for a type - * {@link ResolvedJavaType#findLeafConcreteSubtype()} can return an AssumptionResult with no - * assumptions since the leaf information is statically true. - * - * @param - */ - public static class AssumptionResult { - Assumption[] assumptions; - final T result; - - private static final Assumption[] EMPTY = new Assumption[0]; - - public AssumptionResult(T result, Assumption... assumptions) { - this.result = result; - this.assumptions = assumptions; - } - - public AssumptionResult(T result) { - this(result, EMPTY); - } - - public T getResult() { - return result; - } - - public boolean isAssumptionFree() { - return assumptions.length == 0; - } - - public void add(AssumptionResult other) { - Assumption[] newAssumptions = Arrays.copyOf(this.assumptions, this.assumptions.length + other.assumptions.length); - System.arraycopy(other.assumptions, 0, newAssumptions, this.assumptions.length, other.assumptions.length); - this.assumptions = newAssumptions; - } - - public boolean canRecordTo(Assumptions target) { - /* - * We can use the result if it is either assumption free, or if we have a valid - * Assumptions object where we can record assumptions. - */ - return assumptions.length == 0 || target != null; - } - - public void recordTo(Assumptions target) { - assert canRecordTo(target); - - for (Assumption assumption : assumptions) { - target.record(assumption); - } - } - - @Override - public String toString() { - return String.format("AssumptionResult<%s, assumptions=%s>", result, Arrays.toString(assumptions)); - } - } - - /** - * An assumption that a given class has no subclasses implementing {@code Object#finalize()}). - */ - public static final class NoFinalizableSubclass extends Assumption { - - public final ResolvedJavaType receiverType; - - public NoFinalizableSubclass(ResolvedJavaType receiverType) { - this.receiverType = receiverType; - } - - @Override - public int hashCode() { - return 31 + receiverType.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof NoFinalizableSubclass) { - NoFinalizableSubclass other = (NoFinalizableSubclass) obj; - return other.receiverType.equals(receiverType); - } - return false; - } - - @Override - public String toString() { - return "NoFinalizableSubclass[receiverType=" + receiverType.toJavaName() + "]"; - } - - } - - /** - * An assumption that a given abstract or interface type has one direct concrete subtype. There - * is no requirement that the subtype is a leaf type. - */ - public static final class ConcreteSubtype extends Assumption { - - /** - * Type the assumption is made about. - */ - public final ResolvedJavaType context; - - /** - * Assumed concrete sub-type of the context type. - */ - public final ResolvedJavaType subtype; - - public ConcreteSubtype(ResolvedJavaType context, ResolvedJavaType subtype) { - this.context = context; - this.subtype = subtype; - assert context.isAbstract(); - assert subtype.isConcrete() || context.isInterface() : subtype.toString() + " : " + context.toString(); - assert !subtype.isArray() || subtype.getElementalType().isFinalFlagSet() : subtype.toString() + " : " + context.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + context.hashCode(); - result = prime * result + subtype.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ConcreteSubtype) { - ConcreteSubtype other = (ConcreteSubtype) obj; - return other.context.equals(context) && other.subtype.equals(subtype); - } - return false; - } - - @Override - public String toString() { - return "ConcreteSubtype[context=" + context.toJavaName() + ", subtype=" + subtype.toJavaName() + "]"; - } - } - - /** - * An assumption that a given type has no subtypes. - */ - public static final class LeafType extends Assumption { - - /** - * Type the assumption is made about. - */ - public final ResolvedJavaType context; - - public LeafType(ResolvedJavaType context) { - assert !context.isLeaf() : "assumption isn't required for leaf types"; - this.context = context; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + context.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof LeafType) { - LeafType other = (LeafType) obj; - return other.context.equals(context); - } - return false; - } - - @Override - public String toString() { - return "LeafSubtype[context=" + context.toJavaName() + "]"; - } - } - - /** - * An assumption that a given virtual method has a given unique implementation. - */ - public static final class ConcreteMethod extends Assumption { - - /** - * A virtual (or interface) method whose unique implementation for the receiver type in - * {@link #context} is {@link #impl}. - */ - public final ResolvedJavaMethod method; - - /** - * A receiver type. - */ - public final ResolvedJavaType context; - - /** - * The unique implementation of {@link #method} for {@link #context}. - */ - public final ResolvedJavaMethod impl; - - public ConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) { - this.method = method; - this.context = context; - this.impl = impl; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + method.hashCode(); - result = prime * result + context.hashCode(); - result = prime * result + impl.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ConcreteMethod) { - ConcreteMethod other = (ConcreteMethod) obj; - return other.method.equals(method) && other.context.equals(context) && other.impl.equals(impl); - } - return false; - } - - @Override - public String toString() { - return "ConcreteMethod[method=" + method.format("%H.%n(%p)%r") + ", context=" + context.toJavaName() + ", impl=" + impl.format("%H.%n(%p)%r") + "]"; - } - } - - /** - * An assumption that a given call site's method handle did not change. - */ - public static final class CallSiteTargetValue extends Assumption { - - public final JavaConstant callSite; - public final JavaConstant methodHandle; - - public CallSiteTargetValue(JavaConstant callSite, JavaConstant methodHandle) { - this.callSite = callSite; - this.methodHandle = methodHandle; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + callSite.hashCode(); - result = prime * result + methodHandle.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof CallSiteTargetValue) { - CallSiteTargetValue other = (CallSiteTargetValue) obj; - return callSite.equals(other.callSite) && methodHandle.equals(other.methodHandle); - } - return false; - } - - @Override - public String toString() { - return "CallSiteTargetValue[callSite=" + callSite + ", methodHandle=" + methodHandle + "]"; - } - } - - private final Set assumptions = new HashSet<>(); - - /** - * Returns whether any assumptions have been registered. - * - * @return {@code true} if at least one assumption has been registered, {@code false} otherwise. - */ - public boolean isEmpty() { - return assumptions.isEmpty(); - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException("hashCode"); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof Assumptions) { - Assumptions that = (Assumptions) obj; - if (!this.assumptions.equals(that.assumptions)) { - return false; - } - return true; - } - return false; - } - - @Override - public Iterator iterator() { - return assumptions.iterator(); - } - - /** - * Records an assumption that the specified type has no finalizable subclasses. - * - * @param receiverType the type that is assumed to have no finalizable subclasses - */ - public void recordNoFinalizableSubclassAssumption(ResolvedJavaType receiverType) { - record(new NoFinalizableSubclass(receiverType)); - } - - /** - * Records that {@code subtype} is the only concrete subtype in the class hierarchy below - * {@code context}. - * - * @param context the root of the subtree of the class hierarchy that this assumptions is about - * @param subtype the one concrete subtype - */ - public void recordConcreteSubtype(ResolvedJavaType context, ResolvedJavaType subtype) { - record(new ConcreteSubtype(context, subtype)); - } - - /** - * Records that {@code impl} is the only possible concrete target for a virtual call to - * {@code method} with a receiver of type {@code context}. - * - * @param method a method that is the target of a virtual call - * @param context the receiver type of a call to {@code method} - * @param impl the concrete method that is the only possible target for the virtual call - */ - public void recordConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) { - record(new ConcreteMethod(method, context, impl)); - } - - public void record(Assumption assumption) { - assumptions.add(assumption); - } - - /** - * Gets a copy of the assumptions recorded in this object as an array. - */ - public Assumption[] toArray() { - return assumptions.toArray(new Assumption[assumptions.size()]); - } - - /** - * Copies assumptions recorded by another {@link Assumptions} object into this object. - */ - public void record(Assumptions other) { - assert other != this; - assumptions.addAll(other.assumptions); - } - - @Override - public String toString() { - return "Assumptions[" + assumptions + "]"; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Constant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Constant.java deleted file mode 100644 index 63002463fb5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Constant.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a compile-time constant (boxed) value within the compiler. - */ -public interface Constant { - - boolean isDefaultForKind(); - - String toValueString(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantPool.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantPool.java deleted file mode 100644 index ebd0df403a3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantPool.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.invoke.MethodType; -import java.util.List; - -/** - * Represents the runtime representation of the constant pool that is used by the compiler when - * parsing bytecode. Provides methods to look up a constant pool entry without performing - * resolution. They are used during compilation. - * - * The following convention is used when accessing the ConstantPool with an index: - *
    - *
  • rawIndex - index in the bytecode stream after the opcode (could be rewritten for some opcodes)
  • - *
  • cpi - the constant pool index (as specified in JVM Spec)
  • - *
- * - * Some of the methods are currently not using the convention correctly. That will be addressed in JDK-8314172. - */ -public interface ConstantPool { - - /** - * Returns the number of entries the constant pool. - * - * @return number of entries in the constant pool - */ - int length(); - - /** - * Ensures that the type referenced by the specified constant pool entry is loaded and - * initialized. This can be used to compile time resolve a type. It works for field, method, or - * type constant pool entries. - * - * @param rawIndex index in the bytecode stream after the {@code opcode} (could be rewritten for some opcodes) - * @param opcode the opcode of the instruction that references the type - */ - void loadReferencedType(int rawIndex, int opcode); - - /** - * Ensures that the type referenced by the specified constant pool entry is loaded. This can be - * used to compile time resolve a type. It works for field, method, or type constant pool - * entries. - * - * @param rawIndex index in the bytecode stream after the {@code opcode} (could be rewritten for some opcodes) - * @param opcode the opcode of the instruction that references the type - * @param initialize if {@code true}, the referenced type is either guaranteed to be initialized - * upon return or an initialization exception is thrown - */ - default void loadReferencedType(int rawIndex, int opcode, boolean initialize) { - if (initialize) { - loadReferencedType(rawIndex, opcode); - } else { - throw new UnsupportedOperationException(); - } - } - - /** - * Looks up the type referenced by the {@code rawIndex}. - * - * @param rawIndex index in the bytecode stream after the {@code opcode} (could be rewritten for some opcodes) - * @param opcode the opcode of the instruction with {@code rawIndex} as an operand - * @return a reference to the compiler interface type - */ - JavaType lookupReferencedType(int rawIndex, int opcode); - - /** - * Looks up a reference to a field. Resolution checks - * specific to the bytecode it denotes are performed if the field is already resolved. Checks - * for some bytecodes require the method that contains the bytecode to be specified. Should any - * of these checks fail, an unresolved field reference is returned. - * - * @param rawIndex rewritten index in the bytecode stream after the {@code opcode} - * @param opcode the opcode of the instruction for which the lookup is being performed - * @param method the method for which the lookup is being performed - * @return a reference to the field at {@code rawIndex} in this pool - */ - JavaField lookupField(int rawIndex, ResolvedJavaMethod method, int opcode); - - /** - * Looks up a reference to a method. If {@code opcode} is non-negative, then resolution checks - * specific to the bytecode it denotes are performed if the method is already resolved. Should - * any of these checks fail, an unresolved method reference is returned. - * - * @param cpi the constant pool index - * @param opcode the opcode of the instruction for which the lookup is being performed or - * {@code -1} - * @return a reference to the method at {@code cpi} in this pool - * @throws ClassFormatError if the entry at {@code cpi} is not a method - */ - default JavaMethod lookupMethod(int cpi, int opcode) { - return lookupMethod(cpi, opcode, null); - } - - /** - * Looks up a reference to a method. If {@code opcode} is non-negative, then resolution checks - * specific to the bytecode it denotes are performed if the method is already resolved. Should - * any of these checks fail, an unresolved method reference is returned. - * - * @param cpi the constant pool index - * @param opcode the opcode of the instruction for which the lookup is being performed or - * {@code -1} - * @param caller if non-null, do access checks in the context of {@code caller} calling the - * looked up method - * @return a reference to the method at {@code cpi} in this pool - * @throws ClassFormatError if the entry at {@code cpi} is not a method - * @throws IllegalAccessError if {@code caller} is non-null and it cannot link against the - * looked up method - */ - JavaMethod lookupMethod(int cpi, int opcode, ResolvedJavaMethod caller); - - /** - * The details for invoking a bootstrap method associated with a {@code CONSTANT_Dynamic_info} - * or {@code CONSTANT_InvokeDynamic_info} pool entry. - * - * @jvms 4.4.10 The {@code CONSTANT_Dynamic_info} and {@code CONSTANT_InvokeDynamic_info} - * Structures - * @jvms 4.7.23 The {@code BootstrapMethods} Attribute - */ - interface BootstrapMethodInvocation { - /** - * Gets the bootstrap method that will be invoked. - */ - ResolvedJavaMethod getMethod(); - - /** - * Returns {@code true} if this bootstrap method invocation is for a - * {@code CONSTANT_InvokeDynamic_info} pool entry, {@code false} if it is for a - * {@code CONSTANT_Dynamic_info} entry. - */ - boolean isInvokeDynamic(); - - /** - * Gets the name of the pool entry. - */ - String getName(); - - /** - * Returns a reference to the {@link MethodType} ({@code this.isInvokeDynamic() == true}) or - * {@link Class} ({@code this.isInvokeDynamic() == false}) resolved for the descriptor of - * the pool entry. - */ - JavaConstant getType(); - - /** - * Gets the static arguments with which the bootstrap method will be invoked. - * - * The {@linkplain JavaConstant#getJavaKind kind} of each argument will be - * {@link JavaKind#Object} or {@link JavaKind#Int}. The latter represents an - * unresolved {@code CONSTANT_Dynamic_info} entry. To resolve this entry, the - * corresponding bootstrap method has to be called first: - * - *
-         * List args = bmi.getStaticArguments();
-         * List resolvedArgs = new ArrayList<>(args.size());
-         * for (JavaConstant c : args) {
-         *     JavaConstant r = c;
-         *     if (c.getJavaKind() == JavaKind.Int) {
-         *         // If needed, access corresponding BootstrapMethodInvocation using
-         *         // cp.lookupBootstrapMethodInvocation(pc.asInt(), -1)
-         *         r = cp.lookupConstant(c.asInt(), true);
-         *     } else {
-         *         assert c.getJavaKind() == JavaKind.Object;
-         *     }
-         *     resolvedArgs.append(r);
-         * }
-         * 
- * - * The other types of entries are already resolved and can be used directly. - * - * @jvms 5.4.3.6 - */ - List getStaticArguments(); - - /** - * Resolves the element corresponding to this bootstrap. If - * {@code isInvokeDynamic()}, then the corresponding invoke dynamic is resolved. - * If {@code !isInvokeDynamic()}, then the dynamic constant pool entry will be - * resolved. - * - * @jvms 5.4.3.6 - */ - void resolve(); - - /** - * If {@code isInvokeDynamic()}, then this method looks up the corresponding - * invoke dynamic's appendix. If {@code !isInvokeDynamic()}, then this will - * return the constant pool entry's value. - */ - JavaConstant lookup(); - } - - /** - * Gets the details for invoking a bootstrap method associated with the - * {@code CONSTANT_Dynamic_info} or {@code CONSTANT_InvokeDynamic_info} pool entry - * in the constant pool. - * - * @param index if {@code opcode} is -1, {@code index} is a constant pool index. Otherwise {@code opcode} - * must be {@code Bytecodes.INVOKEDYNAMIC}, and {@code index} must be the operand of that - * opcode in the bytecode stream (i.e., a {@code rawIndex}). - * @param opcode must be {@code Bytecodes.INVOKEDYNAMIC}, or -1 if - * {@code index} was not decoded from a bytecode stream - * @return the bootstrap method invocation details or {@code null} if the entry specified by {@code index} - * is not a {@code CONSTANT_Dynamic_info} or {@code CONSTANT_InvokeDynamic_info} - * @jvms 4.7.23 The {@code BootstrapMethods} Attribute - */ - default BootstrapMethodInvocation lookupBootstrapMethodInvocation(int index, int opcode) { - throw new UnsupportedOperationException(); - } - - /** - * Returns either the BootstrapMethodInvocation instances for all invokedynamic - * bytecodes which reference this constant pool, or all - * {@code CONSTANT_Dynamic_info} BootstrapMethodInvocations within this constant - * pool. The returned List is unmodifiable; calls to any mutator method will - * always cause {@code UnsupportedOperationException} to be thrown. - * - * @param invokeDynamic when true, return all invokedynamic - * BootstrapMethodInvocations; otherwise, return all - * {@code CONSTANT_Dynamic_info} - * BootstrapMethodInvocations. - */ - List lookupBootstrapMethodInvocations(boolean invokeDynamic); - - /** - * Looks up a reference to a type. If {@code opcode} is non-negative, then resolution checks - * specific to the bytecode it denotes are performed if the type is already resolved. Should any - * of these checks fail, an unresolved type reference is returned. - * - * @param cpi the constant pool index - * @param opcode the opcode of the instruction for which the lookup is being performed or - * {@code -1} - * @return a reference to the compiler interface type - */ - JavaType lookupType(int cpi, int opcode); - - /** - * Looks up an Utf8 string. - * - * @param cpi the constant pool index - * @return the Utf8 string at index {@code cpi} in this constant pool - */ - String lookupUtf8(int cpi); - - /** - * Looks up a method signature. - * - * @param cpi the constant pool index - * @return the method signature at index {@code cpi} in this constant pool - */ - Signature lookupSignature(int cpi); - - /** - * Looks up a constant at the specified index. - * - * @param cpi the constant pool index - * @return the {@code Constant} or {@code JavaType} instance representing the constant pool - * entry - */ - Object lookupConstant(int cpi); - - /** - * Looks up a constant at the specified index. - * - * If {@code resolve == false} and the denoted constant is of type - * {@code JVM_CONSTANT_Dynamic}, {@code JVM_CONSTANT_MethodHandle} or - * {@code JVM_CONSTANT_MethodType} and it's not yet resolved then - * {@code null} is returned. - * - * @param cpi the constant pool index - * @return the {@code Constant} or {@code JavaType} instance representing the constant pool - * entry - */ - Object lookupConstant(int cpi, boolean resolve); - - /** - * Looks up the appendix at the specified index. - * - * @param rawIndex index in the bytecode stream after the {@code opcode} (could be rewritten for some opcodes) - * @param opcode the opcode of the instruction for which the lookup is being performed - * @return the appendix if it exists and is resolved or {@code null} - */ - JavaConstant lookupAppendix(int rawIndex, int opcode); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantReflectionProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantReflectionProvider.java deleted file mode 100644 index 75c2e5f9088..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ConstantReflectionProvider.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.invoke.MethodHandle; - -/** - * Reflection operations on values represented as {@linkplain JavaConstant constants}. All methods - * in this interface require the VM to access the actual object encapsulated in - * {@link JavaKind#Object object} constants. This access is not always possible, depending on kind - * of VM and the state that the VM is in. Therefore, all methods can return {@code null} at any - * time, to indicate that the result is not available at this point. The caller is responsible to - * check for {@code null} results and handle them properly, e.g., not perform an optimization. - */ -public interface ConstantReflectionProvider { - - /** - * Compares two constants for equality. The equality relationship is symmetric. Returns - * {@link Boolean#TRUE true} if the two constants represent the same run time value, - * {@link Boolean#FALSE false} if they are different. Returns {@code null} if the constants - * cannot be compared at this point. - */ - Boolean constantEquals(Constant x, Constant y); - - /** - * Returns the length of the array constant. Returns {@code null} if the constant is not an - * array, or if the array length is not available at this point. - */ - Integer readArrayLength(JavaConstant array); - - /** - * Reads a value from the given array at the given index. Returns {@code null} if the constant - * is not an array, if the index is out of bounds, or if the value is not available at this - * point. - */ - JavaConstant readArrayElement(JavaConstant array, int index); - - /** - * Gets the current value of this field for a given object, if available. - * - * There is no guarantee that the same value will be returned by this method for a field unless - * the field is considered to be constant by the runtime. - * - * @param receiver object from which this field's value is to be read. This value is ignored if - * this field is static. - * @return the value of this field or {@code null} if the value is not available (e.g., because - * the field holder is not yet initialized). - */ - JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver); - - /** - * Converts the given {@link JavaKind#isPrimitive() primitive} constant to a boxed - * {@link JavaKind#Object object} constant, according to the Java boxing rules. Returns - * {@code null} if the source is is not a primitive constant, or the boxed value is not - * available at this point. - */ - JavaConstant boxPrimitive(JavaConstant source); - - /** - * Converts the given {@link JavaKind#Object object} constant to a {@link JavaKind#isPrimitive() - * primitive} constant, according to the Java unboxing rules. Returns {@code null} if the source - * is is not an object constant that can be unboxed, or the unboxed value is not available at - * this point. - */ - JavaConstant unboxPrimitive(JavaConstant source); - - /** - * Gets a string as a {@link JavaConstant}. - */ - JavaConstant forString(String value); - - /** - * Returns the {@link ResolvedJavaType} for a {@link Class} object (or any other object regarded - * as a class by the VM) encapsulated in the given constant. Returns {@code null} if the - * constant does not encapsulate a class, or if the type is not available at this point. - */ - ResolvedJavaType asJavaType(Constant constant); - - /** - * Gets access to the internals of {@link MethodHandle}. - */ - MethodHandleAccessProvider getMethodHandleAccess(); - - /** - * Gets raw memory access. - */ - MemoryAccessProvider getMemoryAccessProvider(); - - /** - * Gets the runtime representation of the {@link Class} object of this type. - */ - JavaConstant asJavaClass(ResolvedJavaType type); - - /** - * Gets the runtime representation of the "hub" of this type--that is, the closest part of the - * type representation which is typically stored in the object header. - */ - Constant asObjectHub(ResolvedJavaType type); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DefaultProfilingInfo.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DefaultProfilingInfo.java deleted file mode 100644 index 4fa945a8969..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DefaultProfilingInfo.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * An implementation of {@link ProfilingInfo} that can used in the absence of real profile - * information. - */ -public final class DefaultProfilingInfo implements ProfilingInfo { - - private static final ProfilingInfo[] NO_PROFILING_INFO = { - new DefaultProfilingInfo(TriState.TRUE), - new DefaultProfilingInfo(TriState.FALSE), - new DefaultProfilingInfo(TriState.UNKNOWN) - }; - - private final TriState exceptionSeen; - - DefaultProfilingInfo(TriState exceptionSeen) { - this.exceptionSeen = exceptionSeen; - } - - @Override - public int getCodeSize() { - return 0; - } - - @Override - public JavaTypeProfile getTypeProfile(int bci) { - return null; - } - - @Override - public JavaMethodProfile getMethodProfile(int bci) { - return null; - } - - @Override - public double getBranchTakenProbability(int bci) { - return -1; - } - - @Override - public double[] getSwitchProbabilities(int bci) { - return null; - } - - @Override - public TriState getExceptionSeen(int bci) { - return exceptionSeen; - } - - @Override - public TriState getNullSeen(int bci) { - return TriState.UNKNOWN; - } - - @Override - public int getExecutionCount(int bci) { - return -1; - } - - public static ProfilingInfo get(TriState exceptionSeen) { - return NO_PROFILING_INFO[exceptionSeen.ordinal()]; - } - - @Override - public int getDeoptimizationCount(DeoptimizationReason reason) { - return 0; - } - - @Override - public boolean isMature() { - return false; - } - - @Override - public String toString() { - return "DefaultProfilingInfo<" + this.toString(null, "; ") + ">"; - } - - @Override - public void setMature() { - // Do nothing - } - - @Override - public boolean setCompilerIRSize(Class irType, int nodeCount) { - return false; - } - - @Override - public int getCompilerIRSize(Class irType) { - return -1; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationAction.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationAction.java deleted file mode 100644 index 0438b95e9be..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationAction.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Specifies the action that should be taken by the runtime in case a certain deoptimization is - * triggered. - */ -public enum DeoptimizationAction { - /** - * Do not invalidate the machine code. This is typically used when deoptimizing at a point where - * it's highly likely nothing will change the likelihood of the deoptimization happening again. - * For example, a compiled array allocation where the size is negative. - */ - None(false), - - /** - * Do not invalidate the machine code, but schedule a recompilation if this deoptimization is - * triggered too often. - */ - RecompileIfTooManyDeopts(true), - - /** - * Invalidate the machine code and reset the profiling information. - */ - InvalidateReprofile(true), - - /** - * Invalidate the machine code and immediately schedule a recompilation. This is typically used - * when deoptimizing to resolve an unresolved symbol in which case extra profiling is not - * required to determine that the deoptimization will not re-occur. - */ - InvalidateRecompile(true), - - /** - * Invalidate the machine code and stop compiling the outermost method of this compilation. - */ - InvalidateStopCompiling(true); - - private final boolean invalidatesCompilation; - - DeoptimizationAction(boolean invalidatesCompilation) { - this.invalidatesCompilation = invalidatesCompilation; - } - - public boolean doesInvalidateCompilation() { - return invalidatesCompilation; - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationReason.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationReason.java deleted file mode 100644 index 36c422beda5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/DeoptimizationReason.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Enumeration of reasons for why a deoptimization is happening. - */ -public enum DeoptimizationReason { - None, - NullCheckException, - BoundsCheckException, - ClassCastException, - ArrayStoreException, - UnreachedCode, - TypeCheckedInliningViolated, - OptimizedTypeCheckViolated, - NotCompiledExceptionHandler, - Unresolved, - JavaSubroutineMismatch, - ArithmeticException, - RuntimeConstraint, - LoopLimitCheck, - Aliasing, - TransferToInterpreter, -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EncodedSpeculationReason.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EncodedSpeculationReason.java deleted file mode 100644 index 02f91082fd5..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EncodedSpeculationReason.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -package jdk.vm.ci.meta; - -import java.util.Arrays; -import java.util.function.Supplier; - -import jdk.vm.ci.meta.SpeculationLog.SpeculationReason; - -/** - * An implementation of {@link SpeculationReason} based on encoded values. - */ -public class EncodedSpeculationReason implements SpeculationReason { - final int groupId; - final String groupName; - final Object[] context; - private SpeculationLog.SpeculationReasonEncoding encoding; - - public EncodedSpeculationReason(int groupId, String groupName, Object[] context) { - this.groupId = groupId; - this.groupName = groupName; - this.context = context; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof EncodedSpeculationReason) { - if (obj instanceof EncodedSpeculationReason) { - EncodedSpeculationReason that = (EncodedSpeculationReason) obj; - return this.groupId == that.groupId && Arrays.equals(this.context, that.context); - } - return false; - } - return false; - } - - @Override - public SpeculationLog.SpeculationReasonEncoding encode(Supplier encodingSupplier) { - if (encoding == null) { - encoding = encodingSupplier.get(); - encoding.addInt(groupId); - encoding.addInt(groupName.hashCode()); - for (Object o : context) { - if (o == null) { - encoding.addInt(0); - } else { - addNonNullObject(encoding, o); - } - } - } - return encoding; - } - - static void addNonNullObject(SpeculationLog.SpeculationReasonEncoding encoding, Object o) { - Class c = o.getClass(); - if (c == String.class) { - encoding.addString((String) o); - } else if (c == Byte.class) { - encoding.addByte((Byte) o); - } else if (c == Short.class) { - encoding.addShort((Short) o); - } else if (c == Character.class) { - encoding.addShort((Character) o); - } else if (c == Integer.class) { - encoding.addInt((Integer) o); - } else if (c == Long.class) { - encoding.addLong((Long) o); - } else if (c == Float.class) { - encoding.addInt(Float.floatToRawIntBits((Float) o)); - } else if (c == Double.class) { - encoding.addLong(Double.doubleToRawLongBits((Double) o)); - } else if (o instanceof Enum) { - encoding.addInt(((Enum) o).ordinal()); - } else if (o instanceof ResolvedJavaMethod) { - encoding.addMethod((ResolvedJavaMethod) o); - } else if (o instanceof ResolvedJavaType) { - encoding.addType((ResolvedJavaType) o); - } else if (o instanceof ResolvedJavaField) { - encoding.addField((ResolvedJavaField) o); - } else { - throw new IllegalArgumentException("Unsupported type for encoding: " + c.getName()); - } - } - - @Override - public int hashCode() { - return groupId + Arrays.hashCode(this.context); - } - - @Override - public String toString() { - return String.format("%s@%d%s", groupName, groupId, Arrays.toString(context)); - } - - /** - * Returns the group ID of this speculation reason. - */ - public int getGroupId() { - return groupId; - } - - /** - * Returns the group name of this speculation reason. - */ - public String getGroupName() { - return groupName; - } - - /** - * Returns a copy of the array of context objects. - */ - public Object[] getContext() { - return (context == null) ? null : context.clone(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EnumData.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EnumData.java deleted file mode 100644 index 4e8fc3a8ab7..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/EnumData.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents an enum constant within {@link AnnotationData}. - */ -public final class EnumData { - private final JavaType type; - private final String name; - - /** - * Creates an enum constant. - * - * @param type the {@linkplain Enum enum type} - * @param name the {@linkplain Enum#name() name} of the enum - */ - public EnumData(JavaType type, String name) { - this.type = type; - this.name = name; - } - - /** - * Gets the {@linkplain Enum enum type}. - */ - public JavaType getEnumType() { - return type; - } - - /** - * Gets the {@linkplain Enum#name() name} of the enum. - */ - public String getName() { - return name; - } - - @Override - public String toString() { - return name; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof EnumData) { - EnumData that = (EnumData) obj; - return this.type.equals(that.type) && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - return this.type.hashCode() ^ this.name.hashCode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ErrorData.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ErrorData.java deleted file mode 100644 index 72177ddcbbc..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ErrorData.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents an error constant within {@link AnnotationData}. - * - * Similar to {@code sun.reflect.annotation.ExceptionProxy}. - */ -public final class ErrorData { - private final String description; - - /** - * Creates an error constant. - * - * @param description description of the error - */ - public ErrorData(String description) { - this.description = description; - } - - @Override - public String toString() { - return description; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ErrorData) { - ErrorData that = (ErrorData) obj; - return this.description.equals(that.description); - } - return false; - } - - @Override - public int hashCode() { - return description.hashCode(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ExceptionHandler.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ExceptionHandler.java deleted file mode 100644 index 4beae9daa05..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ExceptionHandler.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.Objects; - -/** - * Represents an exception handler within the bytecodes. - */ -public final class ExceptionHandler { - - private final int startBCI; - private final int endBCI; - private final int handlerBCI; - private final int catchTypeCPI; - private final JavaType catchType; - - /** - * Creates a new exception handler with the specified ranges. - * - * @param startBCI the start index of the protected range - * @param endBCI the end index of the protected range - * @param catchBCI the index of the handler - * @param catchTypeCPI the index of the throwable class in the constant pool - * @param catchType the type caught by this exception handler - */ - public ExceptionHandler(int startBCI, int endBCI, int catchBCI, int catchTypeCPI, JavaType catchType) { - this.startBCI = startBCI; - this.endBCI = endBCI; - this.handlerBCI = catchBCI; - this.catchTypeCPI = catchTypeCPI; - this.catchType = catchType; - } - - /** - * Returns the start bytecode index of the protected range of this handler. - */ - public int getStartBCI() { - return startBCI; - } - - /** - * Returns the end bytecode index of the protected range of this handler. - */ - public int getEndBCI() { - return endBCI; - } - - /** - * Returns the bytecode index of the handler block of this handler. - */ - public int getHandlerBCI() { - return handlerBCI; - } - - /** - * Returns the index into the constant pool representing the type of exception caught by this - * handler. - */ - public int catchTypeCPI() { - return catchTypeCPI; - } - - /** - * Checks whether this handler catches all exceptions. - * - * @return {@code true} if this handler catches all exceptions - */ - public boolean isCatchAll() { - return catchTypeCPI == 0; - } - - /** - * Returns the type of exception caught by this exception handler. - */ - public JavaType getCatchType() { - return catchType; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof ExceptionHandler)) { - return false; - } - ExceptionHandler that = (ExceptionHandler) obj; - if (this.startBCI != that.startBCI || this.endBCI != that.endBCI || this.handlerBCI != that.handlerBCI || this.catchTypeCPI != that.catchTypeCPI) { - return false; - } - return Objects.equals(this.catchType, that.catchType); - } - - @Override - public String toString() { - return "ExceptionHandler"; - } - - @Override - public int hashCode() { - return catchTypeCPI ^ endBCI ^ handlerBCI; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/InvokeTarget.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/InvokeTarget.java deleted file mode 100644 index d22d7a9d622..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/InvokeTarget.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents the resolved target of an invocation. - */ -public interface InvokeTarget { -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaConstant.java deleted file mode 100644 index 905296c8c13..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaConstant.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a constant (boxed) value, such as an integer, floating point number, or object - * reference, within the compiler and across the compiler/runtime interface. Exports a set of - * {@code JavaConstant} instances that represent frequently used constant values, such as - * {@link #NULL_POINTER}. - */ -public interface JavaConstant extends Constant, JavaValue { - /* - * Using a larger cache for integers leads to only a slight increase in cache hit ratio which is - * not enough to justify the impact on startup time. - */ - JavaConstant NULL_POINTER = new NullConstant(); - PrimitiveConstant INT_MINUS_1 = new PrimitiveConstant(JavaKind.Int, -1); - PrimitiveConstant INT_0 = new PrimitiveConstant(JavaKind.Int, 0); - PrimitiveConstant INT_1 = new PrimitiveConstant(JavaKind.Int, 1); - PrimitiveConstant INT_2 = new PrimitiveConstant(JavaKind.Int, 2); - PrimitiveConstant LONG_0 = new PrimitiveConstant(JavaKind.Long, 0L); - PrimitiveConstant LONG_1 = new PrimitiveConstant(JavaKind.Long, 1L); - PrimitiveConstant FLOAT_0 = new PrimitiveConstant(JavaKind.Float, Float.floatToRawIntBits(0.0F)); - PrimitiveConstant FLOAT_1 = new PrimitiveConstant(JavaKind.Float, Float.floatToRawIntBits(1.0F)); - PrimitiveConstant DOUBLE_0 = new PrimitiveConstant(JavaKind.Double, Double.doubleToRawLongBits(0.0D)); - PrimitiveConstant DOUBLE_1 = new PrimitiveConstant(JavaKind.Double, Double.doubleToRawLongBits(1.0D)); - PrimitiveConstant TRUE = new PrimitiveConstant(JavaKind.Boolean, 1L); - PrimitiveConstant FALSE = new PrimitiveConstant(JavaKind.Boolean, 0L); - PrimitiveConstant ILLEGAL = new PrimitiveConstant(JavaKind.Illegal, 0); - - /** - * Returns the Java kind of this constant. - */ - JavaKind getJavaKind(); - - /** - * Checks whether this constant is null. - * - * @return {@code true} if this constant is the null constant - */ - boolean isNull(); - - static boolean isNull(Constant c) { - if (c instanceof JavaConstant) { - return ((JavaConstant) c).isNull(); - } else { - return false; - } - } - - /** - * Checks whether this constant is non-null. - * - * @return {@code true} if this constant is a primitive, or an object constant that is not null - */ - default boolean isNonNull() { - return !isNull(); - } - - /** - * Checks whether this constant is the default value for its kind (null, 0, 0.0, false). - * - * @return {@code true} if this constant is the default value for its kind - */ - @Override - boolean isDefaultForKind(); - - /** - * Returns the value of this constant as a boxed Java value. - * - * @return the value of this constant - */ - Object asBoxedPrimitive(); - - /** - * Returns the primitive int value this constant represents. The constant must have a - * {@link JavaKind#getStackKind()} of {@link JavaKind#Int}. - * - * @return the constant value - */ - int asInt(); - - /** - * Returns the primitive boolean value this constant represents. The constant must have kind - * {@link JavaKind#Boolean}. - * - * @return the constant value - */ - boolean asBoolean(); - - /** - * Returns the primitive long value this constant represents. The constant must have kind - * {@link JavaKind#Long}, a {@link JavaKind#getStackKind()} of {@link JavaKind#Int}. - * - * @return the constant value - */ - long asLong(); - - /** - * Returns the primitive float value this constant represents. The constant must have kind - * {@link JavaKind#Float}. - * - * @return the constant value - */ - float asFloat(); - - /** - * Returns the primitive double value this constant represents. The constant must have kind - * {@link JavaKind#Double}. - * - * @return the constant value - */ - double asDouble(); - - @Override - default String toValueString() { - if (getJavaKind() == JavaKind.Illegal) { - return "illegal"; - } else { - return getJavaKind().format(asBoxedPrimitive()); - } - } - - static String toString(JavaConstant constant) { - if (constant.getJavaKind() == JavaKind.Illegal) { - return "illegal"; - } else { - return constant.getJavaKind().getJavaName() + "[" + constant.toValueString() + "]"; - } - } - - /** - * Creates a boxed double constant. - * - * @param d the double value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forDouble(double d) { - if (Double.compare(0.0D, d) == 0) { - return DOUBLE_0; - } - if (Double.compare(d, 1.0D) == 0) { - return DOUBLE_1; - } - return new PrimitiveConstant(JavaKind.Double, Double.doubleToRawLongBits(d)); - } - - /** - * Creates a boxed float constant. - * - * @param f the float value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forFloat(float f) { - if (Float.compare(f, 0.0F) == 0) { - return FLOAT_0; - } - if (Float.compare(f, 1.0F) == 0) { - return FLOAT_1; - } - return new PrimitiveConstant(JavaKind.Float, Float.floatToRawIntBits(f)); - } - - /** - * Creates a boxed long constant. - * - * @param i the long value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forLong(long i) { - if (i == 0) { - return LONG_0; - } else if (i == 1) { - return LONG_1; - } else { - return new PrimitiveConstant(JavaKind.Long, i); - } - } - - /** - * Creates a boxed integer constant. - * - * @param i the integer value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forInt(int i) { - switch (i) { - case -1: - return INT_MINUS_1; - case 0: - return INT_0; - case 1: - return INT_1; - case 2: - return INT_2; - default: - return new PrimitiveConstant(JavaKind.Int, i); - } - } - - /** - * Creates a boxed byte constant. - * - * @param i the byte value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forByte(byte i) { - return new PrimitiveConstant(JavaKind.Byte, i); - } - - /** - * Creates a boxed boolean constant. - * - * @param i the boolean value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forBoolean(boolean i) { - return i ? TRUE : FALSE; - } - - /** - * Creates a boxed char constant. - * - * @param i the char value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forChar(char i) { - return new PrimitiveConstant(JavaKind.Char, i); - } - - /** - * Creates a boxed short constant. - * - * @param i the short value to box - * @return a boxed copy of {@code value} - */ - static PrimitiveConstant forShort(short i) { - return new PrimitiveConstant(JavaKind.Short, i); - } - - /** - * Creates a {@link JavaConstant} from a primitive integer of a certain kind. - */ - static PrimitiveConstant forIntegerKind(JavaKind kind, long i) { - switch (kind) { - case Boolean: - return forBoolean(i != 0); - case Byte: - return forByte((byte) i); - case Short: - return forShort((short) i); - case Char: - return forChar((char) i); - case Int: - return forInt((int) i); - case Long: - return forLong(i); - default: - throw new IllegalArgumentException("not an integer kind: " + kind); - } - } - - /** - * Creates a {@link JavaConstant} from a primitive integer of a certain width. - */ - static PrimitiveConstant forPrimitiveInt(int bits, long i) { - assert bits <= 64; - switch (bits) { - case 1: - return forBoolean(i != 0); - case 8: - return forByte((byte) i); - case 16: - return forShort((short) i); - case 32: - return forInt((int) i); - case 64: - return forLong(i); - default: - throw new IllegalArgumentException("unsupported integer width: " + bits); - } - } - - static PrimitiveConstant forPrimitive(char typeChar, long rawValue) { - return forPrimitive(JavaKind.fromPrimitiveOrVoidTypeChar(typeChar), rawValue); - } - - static PrimitiveConstant forPrimitive(JavaKind kind, long rawValue) { - switch (kind) { - case Boolean: - return JavaConstant.forBoolean(rawValue != 0); - case Byte: - return JavaConstant.forByte((byte) rawValue); - case Char: - return JavaConstant.forChar((char) rawValue); - case Short: - return JavaConstant.forShort((short) rawValue); - case Int: - return JavaConstant.forInt((int) rawValue); - case Long: - return JavaConstant.forLong(rawValue); - case Float: - return JavaConstant.forFloat(Float.intBitsToFloat((int) rawValue)); - case Double: - return JavaConstant.forDouble(Double.longBitsToDouble(rawValue)); - default: - throw new IllegalArgumentException("Unsupported kind: " + kind); - } - } - - /** - * Creates a boxed constant for the given boxed primitive value. - * - * @param value the Java boxed value - * @return the primitive constant holding the {@code value} - */ - static PrimitiveConstant forBoxedPrimitive(Object value) { - if (value instanceof Boolean) { - return forBoolean((Boolean) value); - } else if (value instanceof Byte) { - return forByte((Byte) value); - } else if (value instanceof Character) { - return forChar((Character) value); - } else if (value instanceof Short) { - return forShort((Short) value); - } else if (value instanceof Integer) { - return forInt((Integer) value); - } else if (value instanceof Long) { - return forLong((Long) value); - } else if (value instanceof Float) { - return forFloat((Float) value); - } else if (value instanceof Double) { - return forDouble((Double) value); - } else { - return null; - } - } - - static PrimitiveConstant forIllegal() { - return JavaConstant.ILLEGAL; - } - - /** - * Returns a constant with the default value for the given kind. - */ - static JavaConstant defaultForKind(JavaKind kind) { - switch (kind) { - case Boolean: - return FALSE; - case Byte: - return forByte((byte) 0); - case Char: - return forChar((char) 0); - case Short: - return forShort((short) 0); - case Int: - return INT_0; - case Double: - return DOUBLE_0; - case Float: - return FLOAT_0; - case Long: - return LONG_0; - case Object: - return NULL_POINTER; - default: - throw new IllegalArgumentException(kind.toString()); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaField.java deleted file mode 100644 index f4b386a0ee4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaField.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.IllegalFormatException; -import java.util.UnknownFormatConversionException; - -/** - * Represents a reference to a Java field, either resolved or unresolved fields. Fields, like - * methods and types, are resolved through {@link ConstantPool constant pools}. - */ -public interface JavaField { - - /** - * Returns the name of this field. - */ - String getName(); - - /** - * Returns a {@link JavaType} object that identifies the declared type for this field. - */ - JavaType getType(); - - /** - * Returns the kind of this field. This is the same as calling {@link #getType}. - * {@link JavaType#getJavaKind getJavaKind}. - */ - default JavaKind getJavaKind() { - return getType().getJavaKind(); - } - - /** - * Returns the {@link JavaType} object representing the class or interface that declares this - * field. - */ - JavaType getDeclaringClass(); - - /** - * Gets a string for this field formatted according to a given format specification. A format - * specification is composed of characters that are to be copied verbatim to the result and - * specifiers that denote an attribute of this field that is to be copied to the result. A - * specifier is a single character preceded by a '%' character. The accepted specifiers and the - * field attributes they denote are described below: - * - *
-     *     Specifier | Description                                          | Example(s)
-     *     ----------+------------------------------------------------------------------------------------------
-     *     'T'       | Qualified type                                       | "int" "java.lang.String"
-     *     't'       | Unqualified type                                     | "int" "String"
-     *     'H'       | Qualified holder                                     | "java.util.Map.Entry"
-     *     'h'       | Unqualified holder                                   | "Entry"
-     *     'n'       | Field name                                           | "age"
-     *     'f'       | Indicator if field is unresolved, static or instance | "unresolved" "static" "instance"
-     *     '%'       | A '%' character                                      | "%"
-     * 
- * - * @param format a format specification - * @return the result of formatting this field according to {@code format} - * @throws IllegalFormatException if an illegal specifier is encountered in {@code format} - */ - default String format(String format) throws IllegalFormatException { - StringBuilder sb = new StringBuilder(); - int index = 0; - JavaType type = getType(); - while (index < format.length()) { - char ch = format.charAt(index++); - if (ch == '%') { - if (index >= format.length()) { - throw new UnknownFormatConversionException("An unquoted '%' character cannot terminate a field format specification"); - } - char specifier = format.charAt(index++); - switch (specifier) { - case 'T': - case 't': { - sb.append(type.toJavaName(specifier == 'T')); - break; - } - case 'H': - case 'h': { - sb.append(getDeclaringClass().toJavaName(specifier == 'H')); - break; - } - case 'n': { - sb.append(getName()); - break; - } - case 'f': { - sb.append(!(this instanceof ResolvedJavaField) ? "unresolved" : ((ResolvedJavaField) this).isStatic() ? "static" : "instance"); - break; - } - case '%': { - sb.append('%'); - break; - } - default: { - throw new UnknownFormatConversionException(String.valueOf(specifier)); - } - } - } else { - sb.append(ch); - } - } - return sb.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaKind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaKind.java deleted file mode 100644 index baa7e295d32..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaKind.java +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.Array; - -//JaCoCo Exclude - -/** - * Denotes the basic kinds of types in CRI, including the all the Java primitive types, for example, - * {@link JavaKind#Int} for {@code int} and {@link JavaKind#Object} for all object types. A kind has - * a single character short name, a Java name, and a set of flags further describing its behavior. - */ -public enum JavaKind { - /** The primitive boolean kind, represented as an int on the stack. */ - Boolean('Z', 4, "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), - - /** The primitive byte kind, represented as an int on the stack. */ - Byte('B', 8, "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), - - /** The primitive short kind, represented as an int on the stack. */ - Short('S', 9, "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), - - /** The primitive char kind, represented as an int on the stack. */ - Char('C', 5, "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), - - /** The primitive int kind, represented as an int on the stack. */ - Int('I', 10, "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), - - /** The primitive float kind. */ - Float('F', 6, "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), - - /** The primitive long kind. */ - Long('J', 11, "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), - - /** The primitive double kind. */ - Double('D', 7, "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), - - /** The Object kind, also used for arrays. */ - Object('A', 12, "Object", 1, false, null, null), - - /** The void kind. */ - Void('V', 14, "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), - - /** The non-type. */ - Illegal('-', 99, "illegal", 0, false, null, null); - - private final char typeChar; - private final String javaName; - private final boolean isStackInt; - private final Class primitiveJavaClass; - private final Class boxedJavaClass; - private final int slotCount; - private final int basicType; - - JavaKind(char typeChar, int basicType, String javaName, int slotCount, boolean isStackInt, Class primitiveJavaClass, Class boxedJavaClass) { - this.typeChar = typeChar; - this.javaName = javaName; - this.slotCount = slotCount; - this.isStackInt = isStackInt; - this.primitiveJavaClass = primitiveJavaClass; - this.boxedJavaClass = boxedJavaClass; - this.basicType = basicType; - assert primitiveJavaClass == null || javaName.equals(primitiveJavaClass.getName()); - } - - /** - * Returns the number of stack slots occupied by this kind according to the Java bytecodes - * specification. - */ - public int getSlotCount() { - return this.slotCount; - } - - /** - * Returns whether this kind occupied two stack slots. - */ - public boolean needsTwoSlots() { - return this.slotCount == 2; - } - - /** - * Returns the name of the kind as a single upper case character. For the void and primitive - * kinds, this is the FieldType term in table 4.3-A of JVMS {@jvms 4.3.2}. For - * {@link #Object}, the character {@code 'A'} is returned and for {@link #Illegal}, {@code '-'} - * is returned. - */ - public char getTypeChar() { - return typeChar; - } - - /** - * Returns the JVM BasicType value for this type. - */ - public int getBasicType() { - return basicType; - } - - /** - * Returns the name of this kind which will also be it Java programming language name if it is - * {@linkplain #isPrimitive() primitive} or {@code void}. - */ - public String getJavaName() { - return javaName; - } - - /** - * Checks whether this type is a Java primitive type. - * - * @return {@code true} if this is {@link #Boolean}, {@link #Byte}, {@link #Char}, - * {@link #Short}, {@link #Int}, {@link #Long}, {@link #Float}, {@link #Double}, or - * {@link #Void}. - */ - public boolean isPrimitive() { - return primitiveJavaClass != null; - } - - /** - * Returns the kind that represents this kind when on the Java operand stack. - * - * @return the kind used on the operand stack - */ - public JavaKind getStackKind() { - if (isStackInt) { - return Int; - } - return this; - } - - /** - * Checks whether this type is a Java primitive type representing an integer number. - * - * @return {@code true} if the stack kind is {@link #Int} or {@link #Long}. - */ - public boolean isNumericInteger() { - return isStackInt || this == JavaKind.Long; - } - - /** - * Checks whether this type is a Java primitive type representing an unsigned number. - * - * @return {@code true} if the kind is {@link #Boolean} or {@link #Char}. - */ - public boolean isUnsigned() { - return this == JavaKind.Boolean || this == JavaKind.Char; - } - - /** - * Checks whether this type is a Java primitive type representing a floating point number. - * - * @return {@code true} if this is {@link #Float} or {@link #Double}. - */ - public boolean isNumericFloat() { - return this == JavaKind.Float || this == JavaKind.Double; - } - - /** - * Checks whether this represent an Object of some sort. - * - * @return {@code true} if this is {@link #Object}. - */ - public boolean isObject() { - return this == JavaKind.Object; - } - - /** - * Returns the kind corresponding to the Java type string. - * - * @param typeString the Java type string - * @return the kind - */ - public static JavaKind fromTypeString(String typeString) { - assert typeString.length() > 0; - final char first = typeString.charAt(0); - if (first == '[' || first == 'L') { - return JavaKind.Object; - } - return JavaKind.fromPrimitiveOrVoidTypeChar(first); - } - - /** - * Returns the kind of a word given the size of a word in bytes. - * - * @param wordSizeInBytes the size of a word in bytes - * @return the kind representing a word value - */ - public static JavaKind fromWordSize(int wordSizeInBytes) { - if (wordSizeInBytes == 8) { - return JavaKind.Long; - } else { - assert wordSizeInBytes == 4 : "Unsupported word size!"; - return JavaKind.Int; - } - } - - /** - * Returns the kind from the character describing a primitive or void. - * - * @param ch the character for a void or primitive kind as returned by {@link #getTypeChar()} - * @return the kind - */ - public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) { - switch (ch) { - case 'Z': - return Boolean; - case 'C': - return Char; - case 'F': - return Float; - case 'D': - return Double; - case 'B': - return Byte; - case 'S': - return Short; - case 'I': - return Int; - case 'J': - return Long; - case 'V': - return Void; - } - throw new IllegalArgumentException("unknown primitive or void type character: " + ch); - } - - /** - * Returns the Kind representing the given Java class. - * - * @param klass the class - * @return the kind - */ - public static JavaKind fromJavaClass(Class klass) { - if (klass == Boolean.primitiveJavaClass) { - return Boolean; - } else if (klass == Byte.primitiveJavaClass) { - return Byte; - } else if (klass == Short.primitiveJavaClass) { - return Short; - } else if (klass == Char.primitiveJavaClass) { - return Char; - } else if (klass == Int.primitiveJavaClass) { - return Int; - } else if (klass == Long.primitiveJavaClass) { - return Long; - } else if (klass == Float.primitiveJavaClass) { - return Float; - } else if (klass == Double.primitiveJavaClass) { - return Double; - } else if (klass == Void.primitiveJavaClass) { - return Void; - } else { - return Object; - } - } - - /** - * Returns the Java class representing this kind. - * - * @return the Java class - */ - public Class toJavaClass() { - return primitiveJavaClass; - } - - /** - * Returns the Java class for instances of boxed values of this kind. - * - * @return the Java class - */ - public Class toBoxedJavaClass() { - return boxedJavaClass; - } - - /** - * Converts this value type to a string. - */ - @Override - public String toString() { - return javaName; - } - - /** - * Marker interface for types that should be {@linkplain JavaKind#format(Object) formatted} with - * their {@link Object#toString()} value. Calling {@link Object#toString()} on other objects - * poses a security risk because it can potentially call user code. - */ - public interface FormatWithToString { - } - - /** - * Classes for which invoking {@link Object#toString()} does not run user code. - */ - private static boolean isToStringSafe(Class c) { - return c == Boolean.class || c == Byte.class || c == Character.class || c == Short.class || c == Integer.class || c == Float.class || c == Long.class || c == Double.class; - } - - /** - * Gets a formatted string for a given value of this kind. - * - * @param value a value of this kind - * @return a formatted string for {@code value} based on this kind - */ - public String format(Object value) { - if (isPrimitive()) { - assert isToStringSafe(value.getClass()); - return value.toString(); - } else { - if (value == null) { - return "null"; - } else { - if (value instanceof String) { - String s = (String) value; - if (s.length() > 50) { - return "String:\"" + s.substring(0, 30) + "...\""; - } else { - return "String:\"" + s + '"'; - } - } else if (value instanceof JavaType) { - return "JavaType:" + ((JavaType) value).toJavaName(); - } else if (value instanceof Enum) { - return MetaUtil.getSimpleName(value.getClass(), true) + ":" + ((Enum) value).name(); - } else if (value instanceof FormatWithToString) { - return MetaUtil.getSimpleName(value.getClass(), true) + ":" + String.valueOf(value); - } else if (value instanceof Class) { - return "Class:" + ((Class) value).getName(); - } else if (isToStringSafe(value.getClass())) { - return value.toString(); - } else if (value.getClass().isArray()) { - return formatArray(value); - } else { - return MetaUtil.getSimpleName(value.getClass(), true) + "@" + System.identityHashCode(value); - } - } - } - } - - private static final int MAX_FORMAT_ARRAY_LENGTH = 5; - - private static String formatArray(Object array) { - Class componentType = array.getClass().getComponentType(); - assert componentType != null; - int arrayLength = Array.getLength(array); - StringBuilder buf = new StringBuilder(MetaUtil.getSimpleName(componentType, true)).append('[').append(arrayLength).append("]{"); - int length = Math.min(MAX_FORMAT_ARRAY_LENGTH, arrayLength); - boolean primitive = componentType.isPrimitive(); - for (int i = 0; i < length; i++) { - if (primitive) { - buf.append(Array.get(array, i)); - } else { - Object o = ((Object[]) array)[i]; - buf.append(JavaKind.Object.format(o)); - } - if (i != length - 1) { - buf.append(", "); - } - } - if (arrayLength != length) { - buf.append(", ..."); - } - return buf.append('}').toString(); - } - - /** - * Gets the minimum value that can be represented as a value of this kind. - * - * @return the minimum value represented as a {@code long} - */ - public long getMinValue() { - switch (this) { - case Boolean: - return 0; - case Byte: - return java.lang.Byte.MIN_VALUE; - case Char: - return java.lang.Character.MIN_VALUE; - case Short: - return java.lang.Short.MIN_VALUE; - case Int: - return java.lang.Integer.MIN_VALUE; - case Long: - return java.lang.Long.MIN_VALUE; - case Float: - return java.lang.Float.floatToRawIntBits(java.lang.Float.MIN_VALUE); - case Double: - return java.lang.Double.doubleToRawLongBits(java.lang.Double.MIN_VALUE); - default: - throw new IllegalArgumentException("illegal call to minValue on " + this); - } - } - - /** - * Gets the maximum value that can be represented as a value of this kind. - * - * @return the maximum value represented as a {@code long} - */ - public long getMaxValue() { - switch (this) { - case Boolean: - return 1; - case Byte: - return java.lang.Byte.MAX_VALUE; - case Char: - return java.lang.Character.MAX_VALUE; - case Short: - return java.lang.Short.MAX_VALUE; - case Int: - return java.lang.Integer.MAX_VALUE; - case Long: - return java.lang.Long.MAX_VALUE; - case Float: - return java.lang.Float.floatToRawIntBits(java.lang.Float.MAX_VALUE); - case Double: - return java.lang.Double.doubleToRawLongBits(java.lang.Double.MAX_VALUE); - default: - throw new IllegalArgumentException("illegal call to maxValue on " + this); - } - } - - /** - * Number of bytes that are necessary to represent a value of this kind. - * - * @return the number of bytes - */ - public int getByteCount() { - if (this == Boolean) { - return 1; - } else { - return getBitCount() >> 3; - } - } - - /** - * Number of bits that are necessary to represent a value of this kind. - * - * @return the number of bits - */ - public int getBitCount() { - switch (this) { - case Boolean: - return 1; - case Byte: - return 8; - case Char: - case Short: - return 16; - case Float: - return 32; - case Int: - return 32; - case Double: - return 64; - case Long: - return 64; - default: - throw new IllegalArgumentException("illegal call to getBitCount() on " + this); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethod.java deleted file mode 100644 index 122c888d52d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethod.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.IllegalFormatException; -import java.util.UnknownFormatConversionException; - -/** - * Represents a reference to a Java method, either resolved or unresolved. Methods, like fields and - * types, are resolved through {@link ConstantPool constant pools}. - */ -public interface JavaMethod { - - /** - * Returns the name of this method. - */ - String getName(); - - /** - * Returns the {@link JavaType} object representing the class or interface that declares this - * method. - */ - JavaType getDeclaringClass(); - - /** - * Returns the signature of this method. - */ - Signature getSignature(); - - /** - * Gets a string for this method formatted according to a given format specification. A format - * specification is composed of characters that are to be copied verbatim to the result and - * specifiers that denote an attribute of this method that is to be copied to the result. A - * specifier is a single character preceded by a '%' character. The accepted specifiers and the - * method attributes they denote are described below: - * - *
-     *     Specifier | Description                                          | Example(s)
-     *     ----------+------------------------------------------------------------------------------------------
-     *     'R'       | Qualified return type                                | "int" "java.lang.String"
-     *     'r'       | Unqualified return type                              | "int" "String"
-     *     'H'       | Qualified holder                                     | "java.util.Map.Entry"
-     *     'h'       | Unqualified holder                                   | "Entry"
-     *     'n'       | Method name                                          | "add"
-     *     'P'       | Qualified parameter types, separated by ', '         | "int, java.lang.String"
-     *     'p'       | Unqualified parameter types, separated by ', '       | "int, String"
-     *     'f'       | Indicator if method is unresolved, static or virtual | "unresolved" "static" "virtual"
-     *     '%'       | A '%' character                                      | "%"
-     * 
- * - * @param format a format specification - * @return the result of formatting this method according to {@code format} - * @throws IllegalFormatException if an illegal specifier is encountered in {@code format} - */ - default String format(String format) throws IllegalFormatException { - StringBuilder sb = new StringBuilder(); - int index = 0; - Signature sig = null; - while (index < format.length()) { - char ch = format.charAt(index++); - if (ch == '%') { - if (index >= format.length()) { - throw new UnknownFormatConversionException("An unquoted '%' character cannot terminate a method format specification"); - } - char specifier = format.charAt(index++); - switch (specifier) { - case 'R': - case 'r': { - if (sig == null) { - sig = getSignature(); - } - sb.append(sig.getReturnType(null).toJavaName(specifier == 'R')); - break; - } - case 'H': - case 'h': { - sb.append(getDeclaringClass().toJavaName(specifier == 'H')); - break; - } - case 'n': { - sb.append(getName()); - break; - } - case 'P': - case 'p': { - if (sig == null) { - sig = getSignature(); - } - for (int i = 0; i < sig.getParameterCount(false); i++) { - if (i != 0) { - sb.append(", "); - } - sb.append(sig.getParameterType(i, null).toJavaName(specifier == 'P')); - } - break; - } - case 'f': { - sb.append(!(this instanceof ResolvedJavaMethod) ? "unresolved" : ((ResolvedJavaMethod) this).isStatic() ? "static" : "virtual"); - break; - } - case '%': { - sb.append('%'); - break; - } - default: { - throw new UnknownFormatConversionException(String.valueOf(specifier)); - } - } - } else { - sb.append(ch); - } - } - return sb.toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethodProfile.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethodProfile.java deleted file mode 100644 index f63c6f5a6d3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaMethodProfile.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import jdk.vm.ci.meta.JavaMethodProfile.ProfiledMethod; - -/** - * This profile object represents the method profile at a specific BCI. The precision of the - * supplied values may vary, but a runtime that provides this information should be aware that it - * will be used to guide performance-critical decisions like speculative inlining, etc. - */ -public final class JavaMethodProfile extends AbstractJavaProfile { - - public JavaMethodProfile(double notRecordedProbability, ProfiledMethod[] pitems) { - super(notRecordedProbability, pitems); - } - - public ProfiledMethod[] getMethods() { - return super.getItems(); - } - - public static class ProfiledMethod extends AbstractProfiledItem { - - public ProfiledMethod(ResolvedJavaMethod method, double probability) { - super(method, probability); - } - - /** - * Returns the type for this profile entry. - */ - public ResolvedJavaMethod getMethod() { - return getItem(); - } - - @Override - public String toString() { - return "{" + item.getName() + ", " + probability + "}"; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaType.java deleted file mode 100644 index 6d76cf93680..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaType.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import static jdk.vm.ci.meta.MetaUtil.internalNameToJava; - -/** - * Represents a resolved or unresolved type. Types include primitives, objects, {@code void}, and - * arrays thereof. - */ -public interface JavaType { - - /** - * Returns the name of this type in internal form. The following are examples of strings - * returned by this method: - * - *
-     *     "Ljava/lang/Object;"
-     *     "I"
-     *     "[[B"
-     * 
- */ - String getName(); - - /** - * Returns an unqualified name of this type. - * - *
-     *     "Object"
-     *     "Integer"
-     * 
- */ - default String getUnqualifiedName() { - String name = getName(); - if (name.indexOf('/') != -1) { - name = name.substring(name.lastIndexOf('/') + 1); - } - if (name.endsWith(";")) { - name = name.substring(0, name.length() - 1); - } - return name; - } - - /** - * Checks whether this type is an array class. - * - * @return {@code true} if this type is an array class - */ - default boolean isArray() { - return getComponentType() != null; - } - - /** - * For array types, gets the type of the components, or {@code null} if this is not an array - * type. This method is analogous to {@link Class#getComponentType()}. - */ - JavaType getComponentType(); - - /** - * Gets the elemental type for this given type. The elemental type is the corresponding zero - * dimensional type of an array type. For example, the elemental type of {@code int[][][]} is - * {@code int}. A non-array type is its own elemental type. - */ - default JavaType getElementalType() { - JavaType t = this; - while (t.getComponentType() != null) { - t = t.getComponentType(); - } - return t; - } - - /** - * Gets the array class type representing an array with elements of this type. - */ - JavaType getArrayClass(); - - /** - * Gets the {@link JavaKind} of this type. - */ - JavaKind getJavaKind(); - - /** - * Resolves this type to a {@link ResolvedJavaType}. - * - * @param accessingClass the context of resolution (must not be null) - * @return the resolved Java type - * @throws LinkageError if the resolution failed - * @throws NullPointerException if {@code accessingClass} is {@code null} - */ - ResolvedJavaType resolve(ResolvedJavaType accessingClass); - - /** - * Gets the Java programming language name for this type. The following are examples of strings - * returned by this method: - * - *
-     *      java.lang.Object
-     *      int
-     *      boolean[][]
-     * 
- * - * @return the Java name corresponding to this type - */ - default String toJavaName() { - return internalNameToJava(getName(), true, false); - } - - /** - * Gets the Java programming language name for this type. The following are examples of strings - * returned by this method: - * - *
-     *     qualified == true:
-     *         java.lang.Object
-     *         int
-     *         boolean[][]
-     *     qualified == false:
-     *         Object
-     *         int
-     *         boolean[][]
-     * 
- * - * @param qualified specifies if the package prefix of this type should be included in the - * returned name - * @return the Java name corresponding to this type - */ - default String toJavaName(boolean qualified) { - JavaKind kind = getJavaKind(); - if (kind == JavaKind.Object) { - return internalNameToJava(getName(), qualified, false); - } - return getJavaKind().getJavaName(); - } - - /** - * Returns this type's name in the same format as {@link Class#getName()}. - */ - default String toClassName() { - return internalNameToJava(getName(), true, true); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaTypeProfile.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaTypeProfile.java deleted file mode 100644 index 5ee9db58cfe..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaTypeProfile.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; - -import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; - -/** - * This profile object represents the type profile at a specific BCI. The precision of the supplied - * values may vary, but a runtime that provides this information should be aware that it will be - * used to guide performance-critical decisions like speculative inlining, etc. - */ -public final class JavaTypeProfile extends AbstractJavaProfile { - - private static final ProfiledType[] EMPTY_ARRAY = new ProfiledType[0]; - - private final TriState nullSeen; - - public JavaTypeProfile(TriState nullSeen, double notRecordedProbability, ProfiledType[] pitems) { - super(notRecordedProbability, pitems); - this.nullSeen = nullSeen; - } - - /** - * Returns whether a null value was at the type check. - */ - public TriState getNullSeen() { - return nullSeen; - } - - /** - * A list of types for which the runtime has recorded probability information. Note that this - * includes both positive and negative types where a positive type is a subtype of the checked - * type and a negative type is not. - */ - public ProfiledType[] getTypes() { - return getItems(); - } - - public JavaTypeProfile restrict(JavaTypeProfile otherProfile) { - if (otherProfile.getNotRecordedProbability() > 0.0) { - // Not useful for restricting since there is an unknown set of types occurring. - return this; - } - - if (this.getNotRecordedProbability() > 0.0) { - // We are unrestricted, so the other profile is always a better estimate. - return otherProfile; - } - - ArrayList result = new ArrayList<>(); - for (int i = 0; i < getItems().length; i++) { - ProfiledType ptype = getItems()[i]; - ResolvedJavaType type = ptype.getItem(); - if (otherProfile.isIncluded(type)) { - result.add(ptype); - } - } - - TriState newNullSeen = (otherProfile.getNullSeen() == TriState.FALSE) ? TriState.FALSE : getNullSeen(); - double newNotRecorded = getNotRecordedProbability(); - return createAdjustedProfile(result, newNullSeen, newNotRecorded); - } - - public JavaTypeProfile restrict(ResolvedJavaType declaredType, boolean nonNull) { - ArrayList result = new ArrayList<>(); - for (int i = 0; i < getItems().length; i++) { - ProfiledType ptype = getItems()[i]; - ResolvedJavaType type = ptype.getItem(); - if (declaredType.isAssignableFrom(type)) { - result.add(ptype); - } - } - - TriState newNullSeen = (nonNull) ? TriState.FALSE : getNullSeen(); - double newNotRecorded = this.getNotRecordedProbability(); - // Assume for the types not recorded, the incompatibility rate is the same. - if (getItems().length != 0) { - newNotRecorded *= ((double) result.size() / (double) getItems().length); - } - return createAdjustedProfile(result, newNullSeen, newNotRecorded); - } - - private JavaTypeProfile createAdjustedProfile(ArrayList result, TriState newNullSeen, double newNotRecorded) { - if (result.size() != this.getItems().length || newNotRecorded != getNotRecordedProbability() || newNullSeen != getNullSeen()) { - if (result.size() == 0) { - return new JavaTypeProfile(newNullSeen, 1.0, EMPTY_ARRAY); - } - double factor; - if (result.size() == this.getItems().length) { - /* List of types did not change, no need to recompute probabilities. */ - factor = 1.0; - } else { - double probabilitySum = 0.0; - for (int i = 0; i < result.size(); i++) { - probabilitySum += result.get(i).getProbability(); - } - probabilitySum += newNotRecorded; - - factor = 1.0 / probabilitySum; // Normalize to 1.0 - assert factor >= 1.0; - } - ProfiledType[] newResult = new ProfiledType[result.size()]; - for (int i = 0; i < newResult.length; ++i) { - ProfiledType curType = result.get(i); - newResult[i] = new ProfiledType(curType.getItem(), Math.min(1.0, curType.getProbability() * factor)); - } - double newNotRecordedTypeProbability = Math.min(1.0, newNotRecorded * factor); - return new JavaTypeProfile(newNullSeen, newNotRecordedTypeProbability, newResult); - } - return this; - } - - @Override - public boolean equals(Object other) { - return super.equals(other) && nullSeen.equals(((JavaTypeProfile) other).nullSeen); - } - - @Override - public int hashCode() { - return nullSeen.hashCode() + super.hashCode(); - } - - public static class ProfiledType extends AbstractProfiledItem { - - public ProfiledType(ResolvedJavaType type, double probability) { - super(type, probability); - assert type.isArray() || type.isConcrete() : type + " %04x".formatted(type.getModifiers()); - } - - /** - * Returns the type for this profile entry. - */ - public ResolvedJavaType getType() { - return getItem(); - } - - @Override - public String toString() { - return String.format("%.6f#%s", probability, item); - } - } - - @Override - public String toString() { - StringBuilder buf = new StringBuilder("JavaTypeProfile", getNotRecordedProbability())).toString(); - } - - /** - * Returns {@code true} if all types seen at this location have been recorded in the profile. - */ - public boolean allTypesRecorded() { - return this.getNotRecordedProbability() == 0.0; - } - - /** - * Returns the single monormorphic type representing this profile or {@code null} if no such - * type exists. - */ - public ResolvedJavaType asSingleType() { - if (allTypesRecorded() && this.getTypes().length == 1) { - return getTypes()[0].getType(); - } - return null; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaValue.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaValue.java deleted file mode 100644 index 95864edb136..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/JavaValue.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Marker interface for things that represent a Java value. - */ -public interface JavaValue { -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LineNumberTable.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LineNumberTable.java deleted file mode 100644 index 6a5fce95699..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LineNumberTable.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Maps bytecode indexes to source line numbers. - * - * @jvms 4.7.12 - */ -public class LineNumberTable { - - private final int[] lineNumbers; - private final int[] bcis; - - /** - * - * @param lineNumbers an array of source line numbers. This array is now owned by this object - * and should not be mutated by the caller. - * @param bcis an array of bytecode indexes the same length at {@code lineNumbers} whose entries - * are sorted in ascending order. This array is now owned by this object and must not - * be mutated by the caller. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `lineNumbers` and `bcis`") - public LineNumberTable(int[] lineNumbers, int[] bcis) { - assert bcis.length == lineNumbers.length; - this.lineNumbers = lineNumbers; - this.bcis = bcis; - } - - /** - * Gets a source line number for bytecode index {@code atBci}. - */ - public int getLineNumber(int atBci) { - for (int i = 0; i < this.bcis.length - 1; i++) { - if (this.bcis[i] <= atBci && atBci < this.bcis[i + 1]) { - return lineNumbers[i]; - } - } - return lineNumbers[lineNumbers.length - 1]; - } - - /** - * Gets a copy of the array of line numbers that was passed to this object's constructor. - */ - public int[] getLineNumbers() { - return lineNumbers.clone(); - } - - /** - * Gets a copy of the array of bytecode indexes that was passed to this object's constructor. - */ - public int[] getBcis() { - return bcis.clone(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java deleted file mode 100644 index c68ce13d811..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Local.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Describes the type and bytecode index range in which a local variable is live. - */ -public class Local { - - private final String name; - private final int startBci; - private final int endBci; - private final int slot; - private final JavaType type; - - public Local(String name, JavaType type, int startBci, int endBci, int slot) { - this.name = name; - this.startBci = startBci; - this.endBci = endBci; - this.slot = slot; - this.type = type; - } - - /** - * Returns the first BCI at which this local has a value (inclusive). - */ - public int getStartBCI() { - return startBci; - } - - - /** - * Returns the last BCI at which this local has a value (inclusive). - * If the value returned is less than {@link #getStartBCI}, this object denotes a local - * variable that is never live. - */ - public int getEndBCI() { - return endBci; - } - - public String getName() { - return name; - } - - public JavaType getType() { - return type; - } - - public int getSlot() { - return slot; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Local)) { - return false; - } - Local that = (Local) obj; - return this.name.equals(that.name) && this.startBci == that.startBci && this.endBci == that.endBci && this.slot == that.slot && this.type.equals(that.type); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public String toString() { - return "LocalImpl"; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LocalVariableTable.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LocalVariableTable.java deleted file mode 100644 index 4ac00c930b4..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/LocalVariableTable.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.ArrayList; -import java.util.List; - -/** - * Describes the {@link Local}s for a Java method. - * - * @jvms 4.7.13 - */ -public class LocalVariableTable { - - private final Local[] locals; - - /** - * Creates an object describing the {@link Local}s for a Java method. - * - * @param locals array of objects describing local variables. This array is now owned by this - * object and must not be mutated by the caller. - */ - @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `locals`") - public LocalVariableTable(Local[] locals) { - this.locals = locals; - } - - /** - * Gets a description of a local variable that occupies the bytecode frame slot indexed by - * {@code slot} and is live at the bytecode index {@code bci}. - * - * @return a description of the requested local variable or null if no such variable matches - * {@code slot} and {@code bci} - */ - public Local getLocal(int slot, int bci) { - Local result = null; - for (Local local : locals) { - if (local.getSlot() == slot && local.getStartBCI() <= bci && local.getEndBCI() >= bci) { - if (result == null) { - result = local; - } else { - throw new IllegalStateException("Locals overlap!"); - } - } - } - return result; - } - - /** - * Gets a copy of the array of {@link Local}s that was passed to this object's constructor. - */ - public Local[] getLocals() { - return locals.clone(); - } - - /** - * Gets a description of all the local variables live at the bytecode index {@code bci}. - */ - public Local[] getLocalsAt(int bci) { - List result = new ArrayList<>(); - for (Local l : locals) { - if (l.getStartBCI() <= bci && bci <= l.getEndBCI()) { - result.add(l); - } - } - return result.toArray(new Local[result.size()]); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MemoryAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MemoryAccessProvider.java deleted file mode 100644 index 30c4273a97e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MemoryAccessProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Provides memory access operations for the target VM. - */ -public interface MemoryAccessProvider { - - /** - * Reads a primitive value using a base address and a displacement. - * - * @param kind the {@link JavaKind} of the returned {@link JavaConstant} object - * @param base the base address from which the value is read - * @param displacement the displacement within the object in bytes - * @param bits the number of bits to read from memory - * @return the read value encapsulated in a {@link JavaConstant} object of {@link JavaKind} kind - * @throws IllegalArgumentException if the read is out of bounds of the object or {@code kind} - * is {@link JavaKind#Void} or not {@linkplain JavaKind#isPrimitive() primitive} - * kind or {@code bits} is not 8, 16, 32 or 64, or the read is unaligned - */ - JavaConstant readPrimitiveConstant(JavaKind kind, Constant base, long displacement, int bits) throws IllegalArgumentException; - - /** - * Reads a Java {@link Object} value using a base address and a displacement. - * - * @param base the base address from which the value is read - * @param displacement the displacement within the object in bytes - * @return the read value encapsulated in a {@link Constant} object - * @throws IllegalArgumentException if the address computed from {@code base} and - * {@code displacement} does not denote a location holding an {@code Object} value - */ - JavaConstant readObjectConstant(Constant base, long displacement); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaAccessProvider.java deleted file mode 100644 index 2686ab1737f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaAccessProvider.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import jdk.vm.ci.meta.SpeculationLog.Speculation; - -/** - * Provides access to the metadata of a class typically provided in a class file. - */ -public interface MetaAccessProvider { - - /** - * Returns the resolved Java type representing a given Java class. - * - * @param clazz the Java class object - * @return the resolved Java type object - */ - ResolvedJavaType lookupJavaType(Class clazz); - - /** - * Returns the resolved Java types representing some given Java classes. - * - * @param classes the Java class objects - * @return the resolved Java type objects - */ - default ResolvedJavaType[] lookupJavaTypes(Class[] classes) { - ResolvedJavaType[] result = new ResolvedJavaType[classes.length]; - for (int i = 0; i < result.length; i++) { - result[i] = lookupJavaType(classes[i]); - } - return result; - } - - /** - * Provides the {@link ResolvedJavaMethod} for a {@link Method} or {@link Constructor} obtained - * via reflection. - */ - ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod); - - /** - * Provides the {@link ResolvedJavaField} for a {@link Field} obtained via reflection. - */ - ResolvedJavaField lookupJavaField(Field reflectionField); - - /** - * Returns the resolved Java type of the given {@link JavaConstant} object. - * - * @return {@code null} if {@code constant.isNull() || !constant.kind.isObject()} - */ - ResolvedJavaType lookupJavaType(JavaConstant constant); - - /** - * Returns the number of bytes occupied by this constant value or constant object. - * - * @param constant the constant whose bytes should be measured - * @return the number of bytes occupied by this constant - */ - long getMemorySize(JavaConstant constant); - - /** - * Parses a method descriptor ({@jvms 4.3.3}) into a {@link Signature}. - * - * @throws IllegalArgumentException if the method descriptor is not well formed - */ - Signature parseMethodDescriptor(String methodDescriptor); - - /** - * Encodes a deoptimization action and a deoptimization reason in an integer value. - * - * @param debugId an integer that can be used to track the origin of a deoptimization at - * runtime. There is no guarantee that the runtime will use this value. The runtime - * may even keep fewer than 32 bits. - * - * @return the encoded value as an integer - */ - JavaConstant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId); - - /** - * Gets a constant that denotes {@code speculation}. The constant can passed to the - * deoptimization handler (e.g., through a thread local) to indicate a failed speculation. - */ - JavaConstant encodeSpeculation(Speculation speculation); - - /** - * Decodes {@code constant} back to a {@link Speculation} object. - * - * @throws IllegalArgumentException if {@code constant} can only be decoded through a - * {@link SpeculationLog} and {@code speculationLog} does not contain the - * speculation denoted by {@code constant} - */ - Speculation decodeSpeculation(JavaConstant constant, SpeculationLog speculationLog); - - DeoptimizationReason decodeDeoptReason(JavaConstant constant); - - DeoptimizationAction decodeDeoptAction(JavaConstant constant); - - int decodeDebugId(JavaConstant constant); - - int getArrayBaseOffset(JavaKind elementKind); - - int getArrayIndexScale(JavaKind elementKind); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaUtil.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaUtil.java deleted file mode 100644 index 8ee2818b613..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MetaUtil.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Miscellaneous collection of utility methods used by {@code jdk.vm.ci.meta} and its clients. - */ -public class MetaUtil { - - public static final char PACKAGE_SEPARATOR_INTERNAL = '/'; - public static final char HIDDEN_SEPARATOR_INTERNAL = '.'; - public static final char PACKAGE_SEPARATOR_JAVA = HIDDEN_SEPARATOR_INTERNAL; - public static final char HIDDEN_SEPARATOR_JAVA = PACKAGE_SEPARATOR_INTERNAL; - - /** - * Extends the functionality of {@link Class#getSimpleName()} to include a non-empty string for - * anonymous and local classes. - * - * @param clazz the class for which the simple name is being requested - * @param withEnclosingClass specifies if the returned name should be qualified with the name(s) - * of the enclosing class/classes of {@code clazz} (if any). This option is ignored - * if {@code clazz} denotes an anonymous or local class. - * @return the simple name - */ - public static String getSimpleName(Class clazz, boolean withEnclosingClass) { - final String simpleName = safeSimpleName(clazz); - if (simpleName.length() != 0) { - if (withEnclosingClass) { - String prefix = ""; - Class enclosingClass = clazz; - while ((enclosingClass = enclosingClass.getEnclosingClass()) != null) { - prefix = safeSimpleName(enclosingClass) + "." + prefix; - } - return prefix + simpleName; - } - return simpleName; - } - // Must be an anonymous or local class - final String name = clazz.getName(); - int index = name.indexOf('$'); - if (index == -1) { - return name; - } - index = name.lastIndexOf('.', index); - if (index == -1) { - return name; - } - return name.substring(index + 1); - } - - private static String safeSimpleName(Class clazz) { - try { - return clazz.getSimpleName(); - } catch (InternalError e) { - // Scala inner class names do not always start with '$', - // causing Class.getSimpleName to throw an InternalError - Class enclosingClass = clazz.getEnclosingClass(); - String fqn = clazz.getName(); - if (enclosingClass == null) { - // Should never happen given logic in - // Class.getSimpleName but best be safe - return fqn; - } - String enclosingFQN = enclosingClass.getName(); - int length = fqn.length(); - if (enclosingFQN.length() >= length) { - // Should also never happen - return fqn; - } - return fqn.substring(enclosingFQN.length()); - } - } - - /** - * Hidden classes have {@code /} characters in their internal names and {@code .} characters in their names returned - * by {@link Class#getName()} that are not package separators. - * These are distinguished by being followed by a character that is not a - * {@link Character#isJavaIdentifierStart(char)} (e.g., - * "jdk.vm.ci.runtime.test.TypeUniverse$$Lambda/869601985"). - * - * @param name the name to perform the replacements on - * @param packageSeparator the {@link Character} used as the package separator, e.g. {@code /} in internal form - * @param hiddenSeparator the {@link Character} used as the hidden class separator, e.g. {@code .} in internal form - */ - private static String replacePackageAndHiddenSeparators(String name, Character packageSeparator, Character hiddenSeparator) { - int index = name.indexOf(hiddenSeparator); // check if it's a hidden class - int length = name.length(); - StringBuilder buf = new StringBuilder(length); - if (index < 0) { - buf.append(name.replace(packageSeparator, hiddenSeparator)); - } else { - buf.append(name.substring(0, index).replace(packageSeparator, hiddenSeparator)); - buf.append(packageSeparator); - buf.append(name.substring(index + 1)); - } - return buf.toString(); - } - - /** - * Converts a type name in internal form to an external form. - * - * @param name the internal name to convert - * @param qualified whether the returned name should be qualified with the package name - * @param classForNameCompatible specifies if the returned name for array types should be in - * {@link Class#forName(String)} format (e.g., {@code "[Ljava.lang.Object;"}, - * {@code "[[I"}) or in Java source code format (e.g., {@code "java.lang.Object[]"}, - * {@code "int[][]"} ). - */ - public static String internalNameToJava(String name, boolean qualified, boolean classForNameCompatible) { - switch (name.charAt(0)) { - case 'L': { - String type = name.substring(1, name.length() - 1); - String result = replacePackageAndHiddenSeparators(type, PACKAGE_SEPARATOR_INTERNAL, HIDDEN_SEPARATOR_INTERNAL); - if (!qualified) { - final int lastDot = result.lastIndexOf(HIDDEN_SEPARATOR_INTERNAL); - if (lastDot != -1) { - result = result.substring(lastDot + 1); - } - } - return result; - } - case '[': - if (classForNameCompatible) { - return replacePackageAndHiddenSeparators(name, PACKAGE_SEPARATOR_INTERNAL, HIDDEN_SEPARATOR_INTERNAL); - } else { - return internalNameToJava(name.substring(1), qualified, false) + "[]"; - } - default: - if (name.length() != 1) { - throw new IllegalArgumentException("Illegal internal name: " + name); - } - return JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)).getJavaName(); - } - } - - /** - * Convenient shortcut for calling - * {@link #appendLocation(StringBuilder, ResolvedJavaMethod, int)} without having to supply a - * {@link StringBuilder} instance and convert the result to a string. - */ - public static String toLocation(ResolvedJavaMethod method, int bci) { - return appendLocation(new StringBuilder(), method, bci).toString(); - } - - /** - * Appends a string representation of a location specified by a given method and bci to a given - * {@link StringBuilder}. If a stack trace element with a non-null file name and non-negative - * line number is {@linkplain ResolvedJavaMethod#asStackTraceElement(int) available} for the - * given method, then the string returned is the {@link StackTraceElement#toString()} value of - * the stack trace element, suffixed by the bci location. For example: - * - *
-     *     java.lang.String.valueOf(String.java:2930) [bci: 12]
-     * 
- * - * Otherwise, the string returned is the value of applying {@link JavaMethod#format(String)} - * with the format string {@code "%H.%n(%p)"}, suffixed by the bci location. For example: - * - *
-     *     java.lang.String.valueOf(int) [bci: 12]
-     * 
- * - * @param sb - * @param method - * @param bci - */ - public static StringBuilder appendLocation(StringBuilder sb, ResolvedJavaMethod method, int bci) { - if (method != null) { - StackTraceElement ste = method.asStackTraceElement(bci); - if (ste.getFileName() != null && ste.getLineNumber() > 0) { - sb.append(ste); - } else { - sb.append(method.format("%H.%n(%p)")); - } - } else { - sb.append("Null method"); - } - return sb.append(" [bci: ").append(bci).append(']'); - } - - static void appendProfile(StringBuilder buf, AbstractJavaProfile profile, int bci, String type, String sep) { - if (profile != null) { - AbstractProfiledItem[] pitems = profile.getItems(); - if (pitems != null) { - buf.append(String.format("%s@%d:", type, bci)); - for (int j = 0; j < pitems.length; j++) { - AbstractProfiledItem pitem = pitems[j]; - buf.append(String.format(" %.6f (%s)%s", pitem.getProbability(), pitem.getItem(), sep)); - } - if (profile.getNotRecordedProbability() != 0) { - buf.append(String.format(" %.6f %s", profile.getNotRecordedProbability(), type, sep)); - } else { - buf.append(String.format(" %s", type, sep)); - } - } - } - } - - /** - * Converts a Java source-language class name into the internal form. - * - * @param className the class name - * @return the internal name form of the class name - */ - public static String toInternalName(String className) { - if (className.startsWith("[")) { - /* Already in the correct array style. */ - return replacePackageAndHiddenSeparators(className, PACKAGE_SEPARATOR_JAVA, HIDDEN_SEPARATOR_JAVA); - } - - StringBuilder result = new StringBuilder(); - String base = className; - while (base.endsWith("[]")) { - result.append("["); - base = base.substring(0, base.length() - 2); - } - - switch (base) { - case "boolean": - result.append("Z"); - break; - case "byte": - result.append("B"); - break; - case "short": - result.append("S"); - break; - case "char": - result.append("C"); - break; - case "int": - result.append("I"); - break; - case "float": - result.append("F"); - break; - case "long": - result.append("J"); - break; - case "double": - result.append("D"); - break; - case "void": - result.append("V"); - break; - default: - result.append("L") - .append(replacePackageAndHiddenSeparators(base, PACKAGE_SEPARATOR_JAVA, HIDDEN_SEPARATOR_JAVA)) - .append(";"); - break; - } - return result.toString(); - } - - /** - * Gets a string representation of an object based soley on its class and its - * {@linkplain System#identityHashCode(Object) identity hash code}. This avoids and calls to - * virtual methods on the object such as {@link Object#hashCode()}. - */ - public static String identityHashCodeString(Object obj) { - if (obj == null) { - return "null"; - } - return obj.getClass().getName() + "@" + System.identityHashCode(obj); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MethodHandleAccessProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MethodHandleAccessProvider.java deleted file mode 100644 index f4aa7b28bed..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/MethodHandleAccessProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.invoke.MethodHandle; - -/** - * Interface to access the internals of the {@link MethodHandle} implementation of the VM. An - * implementation of this interface is usually required to access non-public classes, methods, and - * fields of {@link MethodHandle}, i.e., data that is not standardized by the Java specification. - */ -public interface MethodHandleAccessProvider { - - /** - * Identification for methods defined on the class {@link MethodHandle} that are processed by - * the {@link MethodHandleAccessProvider}. - */ - enum IntrinsicMethod { - /** The method {@code MethodHandle.invokeBasic}. */ - INVOKE_BASIC, - /** The method {@code MethodHandle.linkToStatic}. */ - LINK_TO_STATIC, - /** The method {@code MethodHandle.linkToSpecial}. */ - LINK_TO_SPECIAL, - /** The method {@code MethodHandle.linkToVirtual}. */ - LINK_TO_VIRTUAL, - /** The method {@code MethodHandle.linkToInterface}. */ - LINK_TO_INTERFACE, - /** The method {@code MethodHandle.linkToNative}. */ - LINK_TO_NATIVE - } - - /** - * Returns the method handle method intrinsic identifier for the provided method, or - * {@code null} if the method is not an intrinsic processed by this interface. - * - * @throws NullPointerException if {@code method} is null - */ - IntrinsicMethod lookupMethodHandleIntrinsic(ResolvedJavaMethod method); - - /** - * Resolves the invocation target for an invocation of {@link IntrinsicMethod#INVOKE_BASIC - * MethodHandle.invokeBasic} with the given constant receiver {@link MethodHandle}. Returns - * {@code null} if the invocation target is not available at this time. - * - * The first invocations of a method handle can use an interpreter to lookup the actual invoked - * method; frequently executed method handles can use Java bytecode generation to avoid the - * interpreter overhead. If the parameter forceBytecodeGeneration is set to true, the VM should - * try to generate bytecodes before this method returns. - * - * @return {@code null} if {@code methodHandle} is not a {@link MethodHandle} or the invocation - * target is not available at this time - * @throws NullPointerException if {@code methodHandle} is null - */ - ResolvedJavaMethod resolveInvokeBasicTarget(JavaConstant methodHandle, boolean forceBytecodeGeneration); - - /** - * Resolves the invocation target for an invocation of a {@code MethodHandle.linkTo*} method - * with the given constant member name. The member name is the last parameter of the - * {@code linkTo*} method. - * - * @return {@code null} if the invocation target is not available at this time - * @throws NullPointerException if {@code memberName} is null - * @throws IllegalArgumentException if {@code memberName} is not a - * {@code java.lang.invoke.MemberName} - */ - ResolvedJavaMethod resolveLinkToTarget(JavaConstant memberName); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java deleted file mode 100644 index 2a193cc79b3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.Modifier; - -import static java.lang.reflect.Modifier.PRIVATE; -import static java.lang.reflect.Modifier.PROTECTED; -import static java.lang.reflect.Modifier.PUBLIC; - -/** - * A Java element (i.e., a class, interface, field or method) that is described by a set of Java - * language {@linkplain #getModifiers() modifiers}. - */ -public interface ModifiersProvider { - - /** - * Returns the modifiers for this element. - */ - int getModifiers(); - - /** - * @see Modifier#isInterface(int) - */ - default boolean isInterface() { - return Modifier.isInterface(getModifiers()); - } - - /** - * @see Modifier#isSynchronized(int) - */ - default boolean isSynchronized() { - return Modifier.isSynchronized(getModifiers()); - } - - /** - * @see Modifier#isStatic(int) - */ - default boolean isStatic() { - return Modifier.isStatic(getModifiers()); - } - - /** - * The setting of the final modifier bit for types is somewhat confusing, so don't export - * isFinal by default. Subclasses like {@link ResolvedJavaField} and {@link ResolvedJavaMethod} - * can export it as isFinal, but {@link ResolvedJavaType} can provide a more sensible equivalent - * like {@link ResolvedJavaType#isLeaf}. - * - * @see Modifier#isFinal(int) - */ - default boolean isFinalFlagSet() { - return Modifier.isFinal(getModifiers()); - } - - /** - * @see Modifier#isPublic(int) - */ - default boolean isPublic() { - return Modifier.isPublic(getModifiers()); - } - - /** - * Determines if this element is neither {@linkplain #isPublic() public}, - * {@linkplain #isProtected() protected} nor {@linkplain #isPrivate() private}. - */ - default boolean isPackagePrivate() { - return ((PUBLIC | PROTECTED | PRIVATE) & getModifiers()) == 0; - } - - /** - * @see Modifier#isPrivate(int) - */ - default boolean isPrivate() { - return Modifier.isPrivate(getModifiers()); - } - - /** - * @see Modifier#isProtected(int) - */ - default boolean isProtected() { - return Modifier.isProtected(getModifiers()); - } - - /** - * @see Modifier#isTransient(int) - */ - default boolean isTransient() { - return Modifier.isTransient(getModifiers()); - } - - /** - * @see Modifier#isStrict(int) - */ - default boolean isStrict() { - return Modifier.isStrict(getModifiers()); - } - - /** - * @see Modifier#isVolatile(int) - */ - default boolean isVolatile() { - return Modifier.isVolatile(getModifiers()); - } - - /** - * @see Modifier#isNative(int) - */ - default boolean isNative() { - return Modifier.isNative(getModifiers()); - } - - /** - * @see Modifier#isAbstract(int) - */ - default boolean isAbstract() { - return Modifier.isAbstract(getModifiers()); - } - - /** - * Returns true if this element is a method with a concrete implementation, or a type that can - * be instantiated. For example, array types return true for both {@link #isAbstract()} and this - * method. - * - * @see ResolvedJavaType#isConcrete() - */ - default boolean isConcrete() { - return !isAbstract(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/NullConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/NullConstant.java deleted file mode 100644 index 3f95674a648..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/NullConstant.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * The implementation type of the {@link JavaConstant#NULL_POINTER null constant}. - */ -final class NullConstant implements JavaConstant { - - protected NullConstant() { - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public boolean isNull() { - return true; - } - - @Override - public boolean isDefaultForKind() { - return true; - } - - @Override - public Object asBoxedPrimitive() { - throw new IllegalArgumentException(); - } - - @Override - public int asInt() { - throw new IllegalArgumentException(); - } - - @Override - public boolean asBoolean() { - throw new IllegalArgumentException(); - } - - @Override - public long asLong() { - throw new IllegalArgumentException(); - } - - @Override - public float asFloat() { - throw new IllegalArgumentException(); - } - - @Override - public double asDouble() { - throw new IllegalArgumentException(); - } - - @Override - public String toString() { - return JavaConstant.toString(this); - } - - @Override - public String toValueString() { - return "null"; - } - - @Override - public int hashCode() { - return 13; - } - - @Override - public boolean equals(Object o) { - return o instanceof NullConstant; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PlatformKind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PlatformKind.java deleted file mode 100644 index 0d01d209a98..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PlatformKind.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a platform-specific low-level type for values. - */ -public interface PlatformKind { - - String name(); - - public interface Key { - - } - - class EnumKey> implements Key { - private final Enum e; - - public EnumKey(Enum e) { - this.e = e; - } - - @Override - public int hashCode() { - return e.ordinal(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof EnumKey) { - EnumKey that = (EnumKey) obj; - return this.e == that.e; - } - return false; - } - } - - /** - * Gets a value associated with this object that can be used as a stable key in a map. The - * {@link Object#hashCode()} implementation of the returned value should be stable between VM - * executions. - */ - Key getKey(); - - /** - * Get the size in bytes of this {@link PlatformKind}. - */ - int getSizeInBytes(); - - /** - * Returns how many primitive values fit in this {@link PlatformKind}. For scalar types this is - * one, for SIMD types it may be higher. - */ - int getVectorLength(); - - /** - * Gets a single type char that identifies this type for use in debug output. - */ - char getTypeChar(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PrimitiveConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PrimitiveConstant.java deleted file mode 100644 index 6a3d576bb27..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/PrimitiveConstant.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.nio.ByteBuffer; - -/** - * Represents a primitive constant value, such as an integer or floating point number, within the - * compiler and across the compiler/runtime interface. - */ -public class PrimitiveConstant implements JavaConstant, SerializableConstant { - - private final JavaKind kind; - - /** - * The boxed primitive value as a {@code long}. For {@code float} and {@code double} values, - * this value is the result of {@link Float#floatToRawIntBits(float)} and - * {@link Double#doubleToRawLongBits(double)} respectively. - */ - private final long primitive; - - protected PrimitiveConstant(JavaKind kind, long primitive) { - this.primitive = primitive; - this.kind = kind; - - assert kind.isPrimitive() || kind == JavaKind.Illegal; - } - - static PrimitiveConstant forTypeChar(char kind, long i) { - return JavaConstant.forIntegerKind(JavaKind.fromPrimitiveOrVoidTypeChar(kind), i); - } - - public long getRawValue() { - return primitive; - } - - @Override - public JavaKind getJavaKind() { - return kind; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isDefaultForKind() { - return primitive == 0; - } - - @Override - public boolean asBoolean() { - assert getJavaKind() == JavaKind.Boolean; - return primitive != 0L; - } - - @Override - public int asInt() { - assert getJavaKind().getStackKind() == JavaKind.Int : getJavaKind().getStackKind(); - return (int) primitive; - } - - @Override - public long asLong() { - assert getJavaKind().isNumericInteger(); - return primitive; - } - - @Override - public float asFloat() { - assert getJavaKind() == JavaKind.Float; - return Float.intBitsToFloat((int) primitive); - } - - @Override - public double asDouble() { - assert getJavaKind() == JavaKind.Double; - return Double.longBitsToDouble(primitive); - } - - @Override - public Object asBoxedPrimitive() { - switch (getJavaKind()) { - case Byte: - return Byte.valueOf((byte) primitive); - case Boolean: - return Boolean.valueOf(asBoolean()); - case Short: - return Short.valueOf((short) primitive); - case Char: - return Character.valueOf((char) primitive); - case Int: - return Integer.valueOf(asInt()); - case Long: - return Long.valueOf(asLong()); - case Float: - return Float.valueOf(asFloat()); - case Double: - return Double.valueOf(asDouble()); - default: - throw new IllegalArgumentException("unexpected kind " + getJavaKind()); - } - } - - @Override - public int getSerializedSize() { - return getJavaKind().getByteCount(); - } - - @Override - public void serialize(ByteBuffer buffer) { - switch (getJavaKind()) { - case Byte: - case Boolean: - buffer.put((byte) primitive); - break; - case Short: - buffer.putShort((short) primitive); - break; - case Char: - buffer.putChar((char) primitive); - break; - case Int: - buffer.putInt(asInt()); - break; - case Long: - buffer.putLong(asLong()); - break; - case Float: - buffer.putFloat(asFloat()); - break; - case Double: - buffer.putDouble(asDouble()); - break; - default: - throw new IllegalArgumentException("unexpected kind " + getJavaKind()); - } - } - - @Override - public int hashCode() { - return (int) (primitive ^ (primitive >>> 32)) * (getJavaKind().ordinal() + 31); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (!(o instanceof PrimitiveConstant)) { - return false; - } - PrimitiveConstant other = (PrimitiveConstant) o; - return this.kind.equals(other.kind) && this.primitive == other.primitive; - } - - @Override - public String toString() { - if (getJavaKind() == JavaKind.Illegal) { - return "illegal"; - } else { - return getJavaKind().getJavaName() + "[" + asBoxedPrimitive() + "|0x" + Long.toHexString(primitive) + "]"; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ProfilingInfo.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ProfilingInfo.java deleted file mode 100644 index 7eaa8e96670..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ProfilingInfo.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Provides access to the profiling information of one specific method. Every accessor method - * returns the information that is available at the time of invocation. If a method is invoked - * multiple times, it may return significantly different results for every invocation as the - * profiling information may be changed by other Java threads at any time. - */ -public interface ProfilingInfo { - - /** - * Returns the length of the bytecodes associated with this profile. - */ - int getCodeSize(); - - /** - * Returns an estimate of how often the branch at the given byte code was taken. - * - * @return The estimated probability, with 0.0 meaning never and 1.0 meaning always, or -1 if - * this information is not available. - */ - double getBranchTakenProbability(int bci); - - /** - * Returns an estimate of how often the switch cases are taken at the given BCI. The default - * case is stored as the last entry. - * - * @return A double value that contains the estimated probabilities, with 0.0 meaning never and - * 1.0 meaning always, or -1 if this information is not available. - */ - double[] getSwitchProbabilities(int bci); - - /** - * Returns the TypeProfile for the given BCI. - * - * @return Returns a JavaTypeProfile object, or null if not available. - */ - JavaTypeProfile getTypeProfile(int bci); - - /** - * Returns the MethodProfile for the given BCI. - * - * @return Returns a JavaMethodProfile object, or null if not available. - */ - JavaMethodProfile getMethodProfile(int bci); - - /** - * Returns information if the given BCI did ever throw an exception. - * - * @return {@link TriState#TRUE} if the instruction has thrown an exception at least once, - * {@link TriState#FALSE} if it never threw an exception, and {@link TriState#UNKNOWN} - * if this information was not recorded. - */ - TriState getExceptionSeen(int bci); - - /** - * Returns information if null was ever seen for the given BCI. This information is collected - * for the aastore, checkcast and instanceof bytecodes. - * - * @return {@link TriState#TRUE} if null was seen for the instruction, {@link TriState#FALSE} if - * null was NOT seen, and {@link TriState#UNKNOWN} if this information was not recorded. - */ - TriState getNullSeen(int bci); - - /** - * Returns an estimate how often the current BCI was executed. Avoid comparing execution counts - * to each other, as the returned value highly depends on the time of invocation. - * - * @return the estimated execution count or -1 if not available. - */ - int getExecutionCount(int bci); - - /** - * Returns how frequently a method was deoptimized for the given deoptimization reason. This - * only indicates how often the method did fall back to the interpreter for the execution and - * does not indicate how often it was recompiled. - * - * @param reason the reason for which the number of deoptimizations should be queried - * @return the number of times the compiled method deoptimized for the given reason. - */ - int getDeoptimizationCount(DeoptimizationReason reason); - - /** - * Records the size of the compiler intermediate representation (IR) associated with this - * method. - * - * @param irType the IR type for which the size is being recorded - * @param irSize the IR size to be recorded. The unit depends on the IR. - * @return whether recording this information for {@code irType} is supported - */ - boolean setCompilerIRSize(Class irType, int irSize); - - /** - * Gets the size of the compiler intermediate representation (IR) associated with this method - * last recorded by {@link #setCompilerIRSize(Class, int)}. - * - * @param irType the IR type for which the size is being requested - * @return the requested IR size or -1 if it is unavailable for {@code irType} - */ - int getCompilerIRSize(Class irType); - - /** - * Returns true if the profiling information can be assumed as sufficiently accurate. - * - * @return true if the profiling information was recorded often enough mature enough, false - * otherwise. - */ - boolean isMature(); - - /** - * Force data to be treated as mature if possible. - */ - void setMature(); - - /** - * Formats this profiling information to a string. - * - * @param method an optional method that augments the profile string returned - * @param sep the separator to use for each separate profile record - */ - default String toString(ResolvedJavaMethod method, String sep) { - StringBuilder buf = new StringBuilder(100); - if (method != null) { - buf.append(String.format("canBeStaticallyBound: %b%s", method.canBeStaticallyBound(), sep)); - } - for (int i = 0; i < getCodeSize(); i++) { - if (getExecutionCount(i) != -1) { - buf.append(String.format("executionCount@%d: %d%s", i, getExecutionCount(i), sep)); - } - - if (getBranchTakenProbability(i) != -1) { - buf.append(String.format("branchProbability@%d: %.6f%s", i, getBranchTakenProbability(i), sep)); - } - - double[] switchProbabilities = getSwitchProbabilities(i); - if (switchProbabilities != null) { - buf.append(String.format("switchProbabilities@%d:", i)); - for (int j = 0; j < switchProbabilities.length; j++) { - buf.append(String.format(" %.6f", switchProbabilities[j])); - } - buf.append(sep); - } - - if (getExceptionSeen(i) != TriState.UNKNOWN) { - buf.append(String.format("exceptionSeen@%d: %s%s", i, getExceptionSeen(i).name(), sep)); - } - - if (getNullSeen(i) != TriState.UNKNOWN) { - buf.append(String.format("nullSeen@%d: %s%s", i, getNullSeen(i).name(), sep)); - } - - JavaTypeProfile typeProfile = getTypeProfile(i); - MetaUtil.appendProfile(buf, typeProfile, i, "types", sep); - - JavaMethodProfile methodProfile = getMethodProfile(i); - MetaUtil.appendProfile(buf, methodProfile, i, "methods", sep); - } - - boolean firstDeoptReason = true; - for (DeoptimizationReason reason : DeoptimizationReason.values()) { - int count = getDeoptimizationCount(reason); - if (count > 0) { - if (firstDeoptReason) { - buf.append("deoptimization history").append(sep); - firstDeoptReason = false; - } - buf.append(String.format(" %s: %d%s", reason.name(), count, sep)); - } - } - if (buf.length() == 0) { - return ""; - } - String s = buf.toString(); - return s.substring(0, s.length() - sep.length()); - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/RawConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/RawConstant.java deleted file mode 100644 index b622a1c958e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/RawConstant.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -public class RawConstant extends PrimitiveConstant { - - public RawConstant(long rawValue) { - super(JavaKind.Int, rawValue); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java deleted file mode 100644 index e6e0a9da167..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.AccessFlag.Location; - -/** - * Represents a reference to a resolved Java field. Fields, like methods and types, are resolved - * through {@link ConstantPool constant pools}. - */ -public interface ResolvedJavaField extends JavaField, ModifiersProvider, AnnotatedElement, Annotated { - - /** - * {@inheritDoc} - *

- * Only the {@linkplain Location#FIELD field flags} specified in the JVM - * specification will be included in the returned mask. - */ - @Override - int getModifiers(); - - /** - * Returns the offset of the field relative to the base of its storage container (e.g., - * {@code instanceOop} for an instance field or {@code Klass*} for a static field on HotSpot). - */ - int getOffset(); - - default boolean isFinal() { - return ModifiersProvider.super.isFinalFlagSet(); - } - - /** - * Determines if this field was injected by the VM. Such a field, for example, is not derived - * from a class file. - */ - boolean isInternal(); - - /** - * Determines if this field is a synthetic field as defined by the Java Language Specification. - */ - boolean isSynthetic(); - - /** - * Returns the {@link ResolvedJavaType} object representing the class or interface that declares - * this field. - */ - @Override - ResolvedJavaType getDeclaringClass(); - - /** - * Gets the value of the {@code ConstantValue} attribute ({@jvms 4.7.2}) associated with this - * field. - * - * @return {@code null} if this field has no {@code ConstantValue} attribute - * @throws UnsupportedOperationException if this operation is not supported - */ - default JavaConstant getConstantValue() { - throw new UnsupportedOperationException(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java deleted file mode 100644 index 75ca31ce8b3..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java +++ /dev/null @@ -1,489 +0,0 @@ -/* - * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.util.BitSet; - -/** - * Represents a resolved Java method. Methods, like fields and types, are resolved through - * {@link ConstantPool constant pools}. - */ -public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, AnnotatedElement, Annotated { - - /** - * Returns the method's bytecode. The returned bytecode does not contain breakpoints or non-Java - * bytecodes. This will return {@code null} if {@link #getCodeSize()} returns {@code <= 0} or if - * {@link #hasBytecodes()} returns {@code false}. - * - * The contained constant pool indexes may not be the ones found in the original class file but - * they can be used with the JVMCI API (e.g. methods in {@link ConstantPool}). - * - * @return {@code null} if {@code getLinkedCodeSize() <= 0} otherwise the bytecode of the method - * whose length is guaranteed to be {@code > 0} - */ - byte[] getCode(); - - /** - * Returns the size of the method's bytecode. If this method returns a value {@code > 0} then - * {@link #getCode()} will not return {@code null}. - * - * @return 0 if the method has no bytecode, {@code -1} if the method does have bytecode but its - * {@linkplain #getDeclaringClass() declaring class} is not - * {@linkplain ResolvedJavaType#isLinked() linked} otherwise the size of the bytecode in - * bytes (guaranteed to be {@code > 0}) - */ - int getCodeSize(); - - /** - * Returns the {@link ResolvedJavaType} object representing the class or interface that declares - * this method. - */ - @Override - ResolvedJavaType getDeclaringClass(); - - /** - * Returns the maximum number of locals used in this method's bytecodes. - */ - int getMaxLocals(); - - /** - * Returns the maximum number of stack slots used in this method's bytecodes. - */ - int getMaxStackSize(); - - default boolean isFinal() { - return ModifiersProvider.super.isFinalFlagSet(); - } - - /** - * Determines if this method is a synthetic method as defined by the Java Language - * Specification. - */ - boolean isSynthetic(); - - /** - * Checks if the method is a varargs method. - * - * @return whether the method is a varargs method - * @jvms 4.6 - */ - boolean isVarArgs(); - - /** - * Checks if the method is a bridge method. - * - * @return whether the method is a bridge method - * @jvms 4.6 - */ - boolean isBridge(); - - /** - * Returns {@code true} if this method is a default method; returns {@code false} otherwise. - * - * A default method is a public non-abstract instance method, that is, a non-static method with - * a body, declared in an interface type. - * - * @return true if and only if this method is a default method as defined by the Java Language - * Specification. - */ - boolean isDefault(); - - /** - * Returns {@code true} if this method is contained in the array returned by - * {@code getDeclaringClass().getDeclaredMethods()} - */ - boolean isDeclared(); - - /** - * Checks whether this method is a class initializer. - * - * @return {@code true} if the method is a class initializer - */ - boolean isClassInitializer(); - - /** - * Checks whether this method is a constructor. - * - * @return {@code true} if the method is a constructor - */ - boolean isConstructor(); - - /** - * Checks whether this method can be statically bound (usually, that means it is final or - * private or static, but not abstract, or the declaring class is final). - * - * @return {@code true} if this method can be statically bound - */ - boolean canBeStaticallyBound(); - - /** - * Returns the list of exception handlers for this method. - */ - ExceptionHandler[] getExceptionHandlers(); - - /** - * Returns a stack trace element for this method and a given bytecode index. - */ - StackTraceElement asStackTraceElement(int bci); - - /** - * Returns an object that provides access to the profiling information recorded for this method. - */ - default ProfilingInfo getProfilingInfo() { - return getProfilingInfo(true, true); - } - - /** - * Returns an object that provides access to the profiling information recorded for this method. - * - * @param includeNormal if true, - * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason) - * deoptimization counts} will include deoptimization that happened during execution - * of standard non-osr methods. - * @param includeOSR if true, - * {@linkplain ProfilingInfo#getDeoptimizationCount(DeoptimizationReason) - * deoptimization counts} will include deoptimization that happened during execution - * of on-stack-replacement methods. - */ - ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR); - - /** - * Invalidates the profiling information and restarts profiling upon the next invocation. - */ - void reprofile(); - - /** - * Returns the constant pool of this method. - */ - ConstantPool getConstantPool(); - - /** - * A {@code Parameter} provides information about method parameters. - */ - class Parameter implements AnnotatedElement { - private final String name; - private final ResolvedJavaMethod method; - private final int modifiers; - private final int index; - - /** - * Constructor for {@code Parameter}. - * - * @param name the name of the parameter or {@code null} if there is no - * {@literal MethodParameters} class file attribute providing a non-empty name - * for the parameter - * @param modifiers the modifier flags for the parameter - * @param method the method which defines this parameter - * @param index the index of the parameter - */ - public Parameter(String name, - int modifiers, - ResolvedJavaMethod method, - int index) { - assert name == null || !name.isEmpty(); - this.name = name; - this.modifiers = modifiers; - this.method = method; - this.index = index; - } - - /** - * Gets the name of the parameter. If the parameter's name is {@linkplain #isNamePresent() - * present}, then this method returns the name provided by the class file. Otherwise, this - * method synthesizes a name of the form argN, where N is the index of the parameter in the - * descriptor of the method which declares the parameter. - * - * @return the name of the parameter, either provided by the class file or synthesized if - * the class file does not provide a name - */ - public String getName() { - if (name == null) { - return "arg" + index; - } else { - return name; - } - } - - /** - * Gets the method declaring the parameter. - */ - public ResolvedJavaMethod getDeclaringMethod() { - return method; - } - - /** - * Get the modifier flags for the parameter. - */ - public int getModifiers() { - return modifiers; - } - - /** - * Gets the kind of the parameter. - */ - public JavaKind getKind() { - return method.getSignature().getParameterKind(index); - } - - /** - * Gets the formal type of the parameter. - */ - public Type getParameterizedType() { - return method.getGenericParameterTypes()[index]; - } - - /** - * Gets the type of the parameter. - */ - public JavaType getType() { - return method.getSignature().getParameterType(index, method.getDeclaringClass()); - } - - /** - * Determines if the parameter has a name according to a {@literal MethodParameters} class - * file attribute. - * - * @return true if and only if the parameter has a name according to the class file. - */ - public boolean isNamePresent() { - return name != null; - } - - /** - * Determines if the parameter represents a variable argument list. - */ - public boolean isVarArgs() { - return method.isVarArgs() && index == method.getSignature().getParameterCount(false) - 1; - } - - @Override - public T getAnnotation(Class annotationClass) { - return method.getParameterAnnotations(annotationClass)[index]; - } - - @Override - public Annotation[] getAnnotations() { - return method.getParameterAnnotations()[index]; - } - - @Override - public Annotation[] getDeclaredAnnotations() { - return getAnnotations(); - } - - @Override - public String toString() { - Type type = getParameterizedType(); - String typename = type.getTypeName(); - if (isVarArgs()) { - typename = typename.replaceFirst("\\[\\]$", "..."); - } - - final StringBuilder sb = new StringBuilder(); - if (Modifier.isFinal(getModifiers())) { - sb.append("final "); - } - return sb.append(typename).append(' ').append(getName()).toString(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Parameter) { - Parameter other = (Parameter) obj; - return (other.method.equals(method) && other.index == index); - } - return false; - } - - @Override - public int hashCode() { - return method.hashCode() ^ index; - } - } - - /** - * Returns an array of {@code Parameter} objects that represent all the parameters to this - * method. Returns an array of length 0 if this method has no parameters. Returns {@code null} - * if the parameter information is unavailable. - */ - default Parameter[] getParameters() { - return null; - } - - /** - * Returns an array of arrays that represent the annotations on the formal parameters, in - * declaration order, of this method. - * - * @see Method#getParameterAnnotations() - */ - Annotation[][] getParameterAnnotations(); - - /** - * Returns an array of {@link Type} objects that represent the formal parameter types, in - * declaration order, of this method. - * - * @see Method#getGenericParameterTypes() - */ - Type[] getGenericParameterTypes(); - - /** - * Returns {@code true} if this method is not excluded from inlining and has associated Java - * bytecodes (@see {@link ResolvedJavaMethod#hasBytecodes()}). - */ - boolean canBeInlined(); - - /** - * Determines if this method is targeted by a VM directive (e.g., - * {@code -XX:CompileCommand=dontinline,}) or VM recognized annotation (e.g., - * {@code jdk.internal.vm.annotation.DontInline}) that specifies it should not be inlined. - */ - boolean hasNeverInlineDirective(); - - /** - * Returns {@code true} if the inlining of this method should be forced. - */ - boolean shouldBeInlined(); - - /** - * Returns the LineNumberTable of this method or null if this method does not have a line - * numbers table. - */ - LineNumberTable getLineNumberTable(); - - /** - * Returns the local variable table of this method or null if this method does not have a local - * variable table. - */ - LocalVariableTable getLocalVariableTable(); - - /** - * Gets the encoding of (that is, a constant representing the value of) this method. - * - * @return a constant representing a reference to this method - */ - Constant getEncoding(); - - /** - * Checks if this method is present in the virtual table for subtypes of the specified - * {@linkplain ResolvedJavaType type}. - * - * @return true is this method is present in the virtual table for subtypes of this type. - */ - boolean isInVirtualMethodTable(ResolvedJavaType resolved); - - /** - * Gets the annotation of a particular type for a formal parameter of this method. - * - * @param annotationClass the Class object corresponding to the annotation type - * @param parameterIndex the index of a formal parameter of {@code method} - * @return the annotation of type {@code annotationClass} for the formal parameter present, else - * null - * @throws IndexOutOfBoundsException if {@code parameterIndex} does not denote a formal - * parameter - */ - default T getParameterAnnotation(Class annotationClass, int parameterIndex) { - if (parameterIndex >= 0) { - Annotation[][] parameterAnnotations = getParameterAnnotations(); - for (Annotation a : parameterAnnotations[parameterIndex]) { - if (a.annotationType() == annotationClass) { - return annotationClass.cast(a); - } - } - } - return null; - } - - default JavaType[] toParameterTypes() { - JavaType receiver = isStatic() || isConstructor() ? null : getDeclaringClass(); - return getSignature().toParameterTypes(receiver); - } - - /** - * Gets the annotations of a particular type for the formal parameters of this method. - * - * @param annotationClass the Class object corresponding to the annotation type - * @return the annotation of type {@code annotationClass} (if any) for each formal parameter - * present - */ - @SuppressWarnings("unchecked") - default T[] getParameterAnnotations(Class annotationClass) { - Annotation[][] parameterAnnotations = getParameterAnnotations(); - T[] result = (T[]) Array.newInstance(annotationClass, parameterAnnotations.length); - for (int i = 0; i < parameterAnnotations.length; i++) { - for (Annotation a : parameterAnnotations[i]) { - if (a.annotationType() == annotationClass) { - result[i] = annotationClass.cast(a); - } - } - } - return result; - } - - /** - * @see #getCodeSize() - * @return {@code getCodeSize() > 0} - */ - default boolean hasBytecodes() { - return getCodeSize() > 0; - } - - /** - * Checks whether the method has a receiver parameter - i.e., whether it is not static. - * - * @return whether the method has a receiver parameter - */ - default boolean hasReceiver() { - return !isStatic(); - } - - /** - * Determines if this method is {@link java.lang.Object#Object()}. - */ - default boolean isJavaLangObjectInit() { - return getDeclaringClass().isJavaLangObject() && getName().equals(""); - } - - /** - * Returns true if this method has a - * {@code jdk.internal.misc.ScopedMemoryAccess.Scoped} annotation. - * - * @return true if Scoped annotation present, false otherwise. - */ - default boolean isScoped() { - throw new UnsupportedOperationException(); - } - - /** - * Gets a speculation log that can be used when compiling this method to make new speculations - * and query previously failed speculations. The implementation may return a new - * {@link SpeculationLog} object each time this method is called so its the caller's - * responsibility to ensure the same speculation log is used throughout a compilation. - */ - SpeculationLog getSpeculationLog(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java deleted file mode 100644 index 4e11cce4f68..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.lang.reflect.AnnotatedElement; -import java.util.List; - -import jdk.vm.ci.meta.Assumptions.AssumptionResult; - -/** - * Represents a resolved Java type. Types include primitives, objects, {@code void}, and arrays - * thereof. Types, like fields and methods, are resolved through {@link ConstantPool constant pools} - * . - */ -public interface ResolvedJavaType extends JavaType, ModifiersProvider, AnnotatedElement, Annotated { - /** - * Checks whether this type has a finalizer method. - * - * @return {@code true} if this class has a finalizer - */ - boolean hasFinalizer(); - - /** - * Checks whether this type might have finalizable subclasses. Any decisions based on a - * negative answer require the registration of a dependency, since this information may change. - * For example, dynamic class loading can later load a finalizable subclass. - * - * @return an {@link AssumptionResult} specifying if this class may have any subclasses with - * finalizers along with any assumptions under which this answer holds - */ - AssumptionResult hasFinalizableSubclass(); - - /** - * Returns true if this type represents an annotation interface. - * - * @return {@code true} if this type represents an annotation interface - */ - default boolean isAnnotation() { - return (getModifiers() & java.lang.reflect.AccessFlag.ANNOTATION.mask()) != 0; - } - - /** - * Checks whether this type is an interface. - * - * @return {@code true} if this type is an interface - */ - @Override - boolean isInterface(); - - /** - * Checks whether this type is an instance class. - * - * @return {@code true} if this type is an instance class - */ - boolean isInstanceClass(); - - /** - * Checks whether this type is primitive. - * - * @return {@code true} if this type is primitive - */ - boolean isPrimitive(); - - /* - * The setting of the final bit for types is a bit confusing since arrays are marked as final. - * This method provides a semantically equivalent test that appropriate for types. - */ - default boolean isLeaf() { - return getElementalType().isFinalFlagSet(); - } - - /** - * Checks whether this type is an enum. - * - * @return {@code true} if this type is an enum - */ - boolean isEnum(); - - /** - * Checks whether this type is initialized. If a type is initialized it implies that it was - * {@link #isLinked() linked} and that the static initializer has run. - * - * @return {@code true} if this type is initialized - */ - boolean isInitialized(); - - /** - * Initializes this type. - */ - void initialize(); - - /** - * Checks whether this type is linked and verified. When a type is linked the static initializer - * has not necessarily run. An {@link #isInitialized() initialized} type is always linked. - * - * @return {@code true} if this type is linked - */ - boolean isLinked(); - - /** - * Links this type. If this method returns normally, then future calls of {@link #isLinked} will - * return true and future calls of {@link #link} are no-ops. If the method throws an exception, - * then future calls of {@link #isLinked} will return false and future calls of {@link #link} - * will reattempt the linking step which might succeed or throw an exception. - */ - default void link() { - throw new UnsupportedOperationException("link is unsupported"); - } - - /** - * Checks whether this type or any of its supertypes or superinterfaces has default methods. - */ - default boolean hasDefaultMethods() { - throw new UnsupportedOperationException("hasDefaultMethods is unsupported"); - } - - /** - * Checks whether this type declares defaults methods. - */ - default boolean declaresDefaultMethods() { - throw new UnsupportedOperationException("declaresDefaultMethods is unsupported"); - } - - /** - * Determines if this type is either the same as, or is a superclass or superinterface of, the - * type represented by the specified parameter. This method is identical to - * {@link Class#isAssignableFrom(Class)} in terms of the value return for this type. - */ - boolean isAssignableFrom(ResolvedJavaType other); - - /** - * Returns {@code null} since support for VM anonymous class was removed by JDK-8243287. This - * method is preserved for JVMCI backwards compatibility. - */ - @Deprecated - default ResolvedJavaType getHostClass() { - return null; - } - - /** - * Returns true if this type is exactly the type {@link java.lang.Object}. - */ - default boolean isJavaLangObject() { - // Removed assertion due to https://bugs.eclipse.org/bugs/show_bug.cgi?id=434442 - return getSuperclass() == null && !isInterface() && getJavaKind() == JavaKind.Object; - } - - /** - * Checks whether the specified object is an instance of this type. - * - * @param obj the object to test - * @return {@code true} if the object is an instance of this type - */ - boolean isInstance(JavaConstant obj); - - /** - * Gets the super class of this type. If this type represents either the {@code Object} class, - * an interface, a primitive type, or void, then null is returned. If this object represents an - * array class then the type object representing the {@code Object} class is returned. - */ - ResolvedJavaType getSuperclass(); - - /** - * Gets the interfaces implemented or extended by this type. This method is analogous to - * {@link Class#getInterfaces()} and as such, only returns the interfaces directly implemented - * or extended by this type. - */ - ResolvedJavaType[] getInterfaces(); - - /** - * Gets the single implementor of this type. Calling this method on a non-interface type causes - * an exception. - *

- * If the compiler uses the result of this method for its compilation, the usage must be guarded - * because the verifier can not guarantee that the assigned type really implements this - * interface. Additionally, class loading can invalidate the result of this method. - * - * @return {@code null} if there is no implementor, the implementor if there is only one, or - * {@code this} if there are more than one. - */ - ResolvedJavaType getSingleImplementor(); - - /** - * Walks the class hierarchy upwards and returns the least common class that is a superclass of - * both the current and the given type. - * - * @return the least common type that is a super type of both the current and the given type, or - * {@code null} if primitive types are involved. - */ - ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType); - - /** - * Attempts to get a leaf concrete subclass of this type. - *

- * For an {@linkplain #isArray() array} type A, the leaf concrete subclass is A if the - * {@linkplain #getElementalType() elemental} type of A is final (which includes primitive - * types). Otherwise {@code null} is returned for A. - *

- * For a non-array type T, the result is the leaf concrete type in the current hierarchy of T. - *

- * A runtime may decide not to manage or walk a large hierarchy and so the result is - * conservative. That is, a non-null result is guaranteed to be the leaf concrete class in T's - * hierarchy at the current point in time but a null result does not necessarily imply - * that there is no leaf concrete class in T's hierarchy. - *

- * If the compiler uses the result of this method for its compilation, it must register the - * {@link AssumptionResult} in its {@link Assumptions} because dynamic class loading can - * invalidate the result of this method. - * - * @return an {@link AssumptionResult} containing the leaf concrete subclass for this type as - * described above - */ - AssumptionResult findLeafConcreteSubtype(); - - @Override - ResolvedJavaType getComponentType(); - - @Override - default ResolvedJavaType getElementalType() { - ResolvedJavaType t = this; - while (t.isArray()) { - t = t.getComponentType(); - } - return t; - } - - @Override - ResolvedJavaType getArrayClass(); - - /** - * Resolves the method implementation for virtual dispatches on objects of this dynamic type. - * This resolution process only searches "up" the class hierarchy of this type. A broader search - * that also walks "down" the hierarchy is implemented by - * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. For interface types it returns null - * since no concrete object can be an interface. - * - * @param method the method to select the implementation of - * @param callerType the caller or context type used to perform access checks - * @return the link-time resolved method (might be abstract) or {@code null} if it is either a - * signature polymorphic method or can not be linked. - */ - ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); - - /** - * A convenience wrapper for {@link #resolveMethod(ResolvedJavaMethod, ResolvedJavaType)} that - * only returns non-abstract methods. - * - * @param method the method to select the implementation of - * @param callerType the caller or context type used to perform access checks - * @return the concrete method that would be selected at runtime, or {@code null} if there is no - * concrete implementation of {@code method} in this type or any of its superclasses - */ - default ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType); - if (resolvedMethod == null || resolvedMethod.isAbstract()) { - return null; - } - return resolvedMethod; - } - - /** - * Given a {@link ResolvedJavaMethod} A, returns a concrete {@link ResolvedJavaMethod} B that is - * the only possible unique target for a virtual call on A(). Returns {@code null} if either no - * such concrete method or more than one such method exists. Returns the method A if A is a - * concrete method that is not overridden. - *

- * If the compiler uses the result of this method for its compilation, it must register an - * assumption because dynamic class loading can invalidate the result of this method. - * - * @param method the method A for which a unique concrete target is searched - * @return the unique concrete target or {@code null} if no such target exists or assumptions - * are not supported by this runtime - */ - AssumptionResult findUniqueConcreteMethod(ResolvedJavaMethod method); - - /** - * Returns the non-static fields of this class, including - * {@linkplain ResolvedJavaField#isInternal() internal} fields. A zero-length array is returned - * for array and primitive types. The order of fields declared by a single class returned by - * this method is the same as {@link Class#getDeclaredFields}. - * - * @param includeSuperclasses if true, then non-static fields for the complete hierarchy of this - * type are included in the result with superclass fields coming before subclass fields - * @return an array of non-static fields - */ - ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses); - - /** - * Returns the static fields of this class, including {@linkplain ResolvedJavaField#isInternal() - * internal} fields. A zero-length array is returned for array and primitive types. The order of - * fields returned by this method is the same as {@link Class#getDeclaredFields}. - */ - ResolvedJavaField[] getStaticFields(); - - /** - * Returns the instance field of this class (or one of its super classes) at the given offset, - * or {@code null} if there is no such field. - * - * @param offset the offset of the field to look for - * @return the field with the given offset, or {@code null} if there is no such field. - */ - ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedKind); - - /** - * Returns name of source file of this type. - */ - String getSourceFileName(); - - /** - * Returns {@code true} if the type is a local type. - */ - boolean isLocal(); - - /** - * Returns {@code true} if the type is a member type. - */ - boolean isMember(); - - /** - * Returns the enclosing type of this type, if it exists, or {@code null}. - */ - ResolvedJavaType getEnclosingType(); - - /** - * Returns an array reflecting all the constructors declared by this type. This method is - * similar to {@link Class#getDeclaredConstructors()} in terms of returned constructors. Calling - * this method forces this type to be {@link #link linked}. - */ - ResolvedJavaMethod[] getDeclaredConstructors(); - - /** - * Returns an array reflecting all the constructors declared by this type. This method is - * similar to {@link Class#getDeclaredConstructors()} in terms of returned constructors. - * - * @param forceLink if {@code true}, forces this type to be {@link #link linked} - */ - default ResolvedJavaMethod[] getDeclaredConstructors(boolean forceLink) { - throw new UnsupportedOperationException(); - } - - /** - * Returns an array reflecting all the methods declared by this type. This method is similar to - * {@link Class#getDeclaredMethods()} in terms of returned methods. Calling this method forces - * this type to be {@link #link linked}. - */ - ResolvedJavaMethod[] getDeclaredMethods(); - - /** - * Returns an array reflecting all the methods declared by this type. This method is similar to - * {@link Class#getDeclaredMethods()} in terms of returned methods. - * - * @param forceLink if {@code true}, forces this type to be {@link #link linked} - */ - default ResolvedJavaMethod[] getDeclaredMethods(boolean forceLink) { - throw new UnsupportedOperationException(); - } - - /** - * Returns a list containing all methods present within this type. This list can - * include methods implicitly created and used by the VM that are not present in - * {@link #getDeclaredMethods}. The returned List is unmodifiable; calls to any - * mutator method will always cause {@code UnsupportedOperationException} to be - * thrown. - * - * @param forceLink if {@code true}, forces this type to be {@link #link linked} - */ - List getAllMethods(boolean forceLink); - - /** - * Returns the {@code } method for this class if there is one. - */ - ResolvedJavaMethod getClassInitializer(); - - default ResolvedJavaMethod findMethod(String name, Signature signature) { - for (ResolvedJavaMethod method : getDeclaredMethods()) { - if (method.getName().equals(name) && method.getSignature().equals(signature)) { - return method; - } - } - return null; - } - - /** - * Returns true if this type is {@link Cloneable} and can be safely cloned by creating a normal - * Java allocation and populating it from the fields returned by - * {@link #getInstanceFields(boolean)}. Some types may require special handling by the platform - * so they would to go through the normal {@link Object#clone} path. - */ - boolean isCloneableWithAllocation(); - - /** - * Lookup an unresolved type relative to an existing resolved type. - */ - @SuppressWarnings("unused") - default ResolvedJavaType lookupType(UnresolvedJavaType unresolvedJavaType, boolean resolve) { - return null; - } - - @SuppressWarnings("unused") - default ResolvedJavaField resolveField(UnresolvedJavaField unresolvedJavaField, ResolvedJavaType accessingClass) { - return null; - } - - @Override - default boolean isConcrete() { - return isArray() || !isAbstract(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SerializableConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SerializableConstant.java deleted file mode 100644 index 05231627c5a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SerializableConstant.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.nio.ByteBuffer; - -/** - * Represents a compile-time constant that can be converted to a byte array. - */ -public interface SerializableConstant extends Constant { - - /** - * Return the size in bytes of the serialized representation of this constant. - */ - int getSerializedSize(); - - /** - * Serialize the constant into the ByteBuffer. There must be at least - * {@link #getSerializedSize()} bytes available capacity in the buffer. - */ - void serialize(ByteBuffer buffer); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Signature.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Signature.java deleted file mode 100644 index 88d46996f5e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Signature.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a method signature provided by the runtime. - * - * @jvms 4.3.3 - */ -public interface Signature { - - /** - * Returns the number of parameters in this signature, adding 1 for a receiver if requested. - * - * @param receiver true if 1 is to be added to the result for a receiver - * @return the number of parameters; + 1 iff {@code receiver == true} - */ - int getParameterCount(boolean receiver); - - /** - * Gets the parameter type at the specified position. - * - * @param index the index into the parameters, with {@code 0} indicating the first parameter - * @param accessingClass the context of the type lookup. If non-null, its class loader is used - * for resolving the type. If {@code null}, then the type returned is either - * unresolved or a resolved type whose resolution is context free (e.g., a primitive - * type or a type in a java.* package). - * @return the {@code index}'th parameter type - * @throws LinkageError if {@code accessingClass != null} and resolution fails - * - */ - JavaType getParameterType(int index, ResolvedJavaType accessingClass); - - /** - * Gets the parameter kind at the specified position. This is the same as calling - * {@link #getParameterType}. {@link JavaType#getJavaKind getJavaKind}. - * - * @param index the index into the parameters, with {@code 0} indicating the first parameter - * @return the kind of the parameter at the specified position - */ - default JavaKind getParameterKind(int index) { - return getParameterType(index, null).getJavaKind(); - } - - /** - * Gets the return type of this signature. - * - * @param accessingClass the context of the type lookup. If non-null, its class loader is used - * for resolving the type. If {@code null}, then the type returned is either - * unresolved or a resolved type whose resolution is context free (e.g., a primitive - * type or a type in a java.* package). - * @return the return type - * @throws LinkageError if {@code accessingClass != null} and resolution fails - */ - JavaType getReturnType(ResolvedJavaType accessingClass); - - /** - * Gets the return kind of this signature. This is the same as calling {@link #getReturnType}. - * {@link JavaType#getJavaKind getJavaKind}. - */ - default JavaKind getReturnKind() { - return getReturnType(null).getJavaKind(); - } - - /** - * Gets the method descriptor ({@jvms 4.3.3}) corresponding to this signature. For example: - * - *

-     * (ILjava/lang/String;D)V
-     * 
- * - * @return the signature as a string - */ - default String toMethodDescriptor() { - StringBuilder sb = new StringBuilder("("); - for (int i = 0; i < getParameterCount(false); ++i) { - sb.append(getParameterType(i, null).getName()); - } - sb.append(')').append(getReturnType(null).getName()); - return sb.toString(); - } - - default JavaType[] toParameterTypes(JavaType receiverType) { - int args = getParameterCount(false); - JavaType[] result; - int i = 0; - if (receiverType != null) { - result = new JavaType[args + 1]; - result[0] = receiverType; - i = 1; - } else { - result = new JavaType[args]; - } - for (int j = 0; j < args; j++) { - result[i + j] = getParameterType(j, null); - } - return result; - } - - default JavaKind[] toParameterKinds(boolean receiver) { - int args = getParameterCount(false); - JavaKind[] result; - int i = 0; - if (receiver) { - result = new JavaKind[args + 1]; - result[0] = JavaKind.Object; - i = 1; - } else { - result = new JavaKind[args]; - } - for (int j = 0; j < args; j++) { - result[i + j] = getParameterKind(j); - } - return result; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SpeculationLog.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SpeculationLog.java deleted file mode 100644 index f860150b252..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SpeculationLog.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -import java.util.Map; -import java.util.function.Supplier; - -/** - * Manages unique {@link SpeculationReason} objects that denote why a deoptimization occurred. - * Reasons are embedded in compiled code for a method. If the compiled code deoptimizes at a - * position associated with a {@link SpeculationReason}, the reason is added to a set of failed - * speculations associated with the method. A subsequent compilation of the method can query the - * failed speculations via a {@link SpeculationLog} to avoid making a speculation based on - * invalidated reasons. This avoids repeated deoptimizations. - */ -public interface SpeculationLog { - /** - * The specific attributes of a speculation that a compiler uses to denote a speculation in a - * compiled method. Typical attributes of a speculation are a bytecode position, type - * information about a variable being speculated on and an enum denoting the type of operation - * to which the speculation applies. A {@link SpeculationReason} is used as a key in a - * {@link Map} and so it must implement {@link Object#equals(Object)} and - * {@link Object#hashCode()} in terms of its attributes. - * - * A JVMCI implementation may serialize speculations for storage off heap (e.g. in native memory - * associated with an nmethod). For this reason, the attributes of a {@link SpeculationReason} - * are restricted to those supported by the {@code add...} methods of - * {@link SpeculationReasonEncoding}. - */ - public interface SpeculationReason { - - /** - * Encodes the attributes of this reason using a {@link SpeculationReasonEncoding}. For - * efficiency, a {@link SpeculationReason} implementation should cache the returned value - * and return it for all subsequent calls to this method. This also underlines the - * requirement that the encoding for a specific reason instance should be stable. - * - * @param encodingSupplier source of a {@link SpeculationReasonEncoding} - * @return a {@link SpeculationReasonEncoding} that encodes all the attributes that uniquely - * identify this reason - */ - default SpeculationReasonEncoding encode(Supplier encodingSupplier) { - return null; - } - } - - /** - * Provides a facility for encoding the attributes of a {@link SpeculationReason}. The encoding - * format is determined by the implementation of this interface. - */ - public interface SpeculationReasonEncoding { - void addByte(int value); - - void addShort(int value); - - void addInt(int value); - - void addLong(long value); - - void addMethod(ResolvedJavaMethod method); - - void addType(ResolvedJavaType type); - - void addString(String value); - - default void addField(ResolvedJavaField field) { - addType(field.getDeclaringClass()); - addInt(field.getModifiers()); - addInt(field.getOffset()); - } - } - - /** - * Marker class that indicates that a speculation has no reason. - */ - final class NoSpeculationReason implements SpeculationReason { - } - - class Speculation { - private final SpeculationReason reason; - - public Speculation(SpeculationReason reason) { - this.reason = reason; - } - - public SpeculationReason getReason() { - return reason; - } - - @Override - public String toString() { - return reason.toString(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Speculation) { - Speculation other = (Speculation) obj; - return reason.equals(other.reason); - } - return false; - } - - @Override - public int hashCode() { - return getReason().hashCode(); - } - } - - Speculation NO_SPECULATION = new Speculation(new NoSpeculationReason()); - - /** - * Updates the set of failed speculations recorded in this log. This must be called before - * compilation. - */ - void collectFailedSpeculations(); - - /** - * If this method returns true, the compiler is allowed to {@link #speculate} with the given - * reason. - */ - boolean maySpeculate(SpeculationReason reason); - - /** - * Registers a speculation performed by the compiler. The compiler must guard every call to this - * method for a specific reason with a call to {@link #maySpeculate(SpeculationReason)}. - * - * This API is subject to a benign race where a during the course of a compilation another - * thread might fail a speculation such that {@link #maySpeculate(SpeculationReason)} will - * return false but an earlier call returned true. This method will still return a working - * {@link Speculation} in that case but the compile will eventually be invalidated and the - * compile attempted again without the now invalid speculation. - * - * @param reason an object representing the reason for the speculation - * @return a compiler constant encapsulating the provided reason. It is usually passed as an - * argument to the deoptimization function. - */ - Speculation speculate(SpeculationReason reason); - - /** - * Returns if this log has speculations. - * - * @return true if there are speculations, false otherwise - */ - boolean hasSpeculations(); - - /** - * Given a {@link JavaConstant} previously returned from - * {@link MetaAccessProvider#encodeSpeculation(Speculation)} return the original - * {@link Speculation} object. - */ - Speculation lookupSpeculation(JavaConstant constant); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SuppressFBWarnings.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SuppressFBWarnings.java deleted file mode 100644 index 5d28bd8f3db..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/SuppressFBWarnings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Used to suppress FindBugs warnings. - */ -@interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/TriState.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/TriState.java deleted file mode 100644 index cf85e651067..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/TriState.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a logic value that can be either {@link #TRUE}, {@link #FALSE}, or {@link #UNKNOWN}. - */ -public enum TriState { - TRUE, - FALSE, - UNKNOWN; - - public static TriState get(boolean value) { - return value ? TRUE : FALSE; - } - - /** - * This is optimistic about {@link #UNKNOWN} (it prefers known values over {@link #UNKNOWN}) and - * pesimistic about known (it perfers {@link #TRUE} over {@link #FALSE}). - */ - public static TriState merge(TriState a, TriState b) { - if (a == TRUE || b == TRUE) { - return TRUE; - } - if (a == FALSE || b == FALSE) { - return FALSE; - } - assert a == UNKNOWN && b == UNKNOWN; - return UNKNOWN; - } - - public boolean isTrue() { - return this == TRUE; - } - - public boolean isFalse() { - return this == FALSE; - } - - public boolean isUnknown() { - return this == UNKNOWN; - } - - public boolean isKnown() { - return this != UNKNOWN; - } - - public boolean toBoolean() { - if (isTrue()) { - return true; - } else if (isFalse()) { - return false; - } else { - throw new IllegalStateException("Cannot convert to boolean, TriState is in an unknown state"); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaField.java deleted file mode 100644 index d3c874ca26b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaField.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * A implementation of {@link JavaField} for an unresolved field. - */ -public final class UnresolvedJavaField implements JavaField { - - private final String name; - private final JavaType holder; - private final JavaType type; - - /** - * The reason field resolution failed. Can be null. - */ - private final Throwable cause; - - public UnresolvedJavaField(JavaType holder, String name, JavaType type, Throwable cause) { - this.name = name; - this.type = type; - this.holder = holder; - this.cause = cause; - } - - public UnresolvedJavaField(JavaType holder, String name, JavaType type) { - this(holder, name, type, null); - } - - /** - * Gets the exception, if any, representing the reason field resolution resulted in this object. - */ - public Throwable getCause() { - return cause; - } - - @Override - public String getName() { - return name; - } - - @Override - public JavaType getType() { - return type; - } - - @Override - public JavaType getDeclaringClass() { - return holder; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof UnresolvedJavaField)) { - return false; - } - UnresolvedJavaField that = (UnresolvedJavaField) obj; - return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type); - } - - /** - * Converts this compiler interface field to a string. - */ - @Override - public String toString() { - return format("UnresolvedJavaField<%H.%n %t>"); - } - - public ResolvedJavaField resolve(ResolvedJavaType accessingClass) { - ResolvedJavaType resolvedHolder = holder.resolve(accessingClass); - return resolvedHolder.resolveField(this, accessingClass); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaMethod.java deleted file mode 100644 index 1ec73cc8030..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaMethod.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Implementation of {@link JavaMethod} for unresolved HotSpot methods. - */ -public final class UnresolvedJavaMethod implements JavaMethod { - - private final String name; - private final Signature signature; - protected JavaType holder; - - /** - * The reason method resolution failed. Can be null. - */ - private final Throwable cause; - - public UnresolvedJavaMethod(String name, Signature signature, JavaType holder, Throwable cause) { - this.name = name; - this.holder = holder; - this.signature = signature; - this.cause = cause; - } - - public UnresolvedJavaMethod(String name, Signature signature, JavaType holder) { - this(name, signature, holder, null); - } - - /** - * Gets the exception, if any, representing the reason method resolution resulted in this object. - */ - public Throwable getCause() { - return cause; - } - - @Override - public String getName() { - return name; - } - - @Override - public Signature getSignature() { - return signature; - } - - @Override - public JavaType getDeclaringClass() { - return holder; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof UnresolvedJavaMethod)) { - return false; - } - UnresolvedJavaMethod that = (UnresolvedJavaMethod) obj; - return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaType.java deleted file mode 100644 index 1740744b4b1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/UnresolvedJavaType.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Implementation of {@link JavaType} for unresolved HotSpot classes. - */ -public final class UnresolvedJavaType implements JavaType { - private final String name; - - /** - * The reason type resolution failed. Can be null. - */ - private final Throwable cause; - - @Override - public String getName() { - return name; - } - - private UnresolvedJavaType(String name, Throwable cause) { - this.name = name; - this.cause = cause; - assert name.length() == 1 && JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)) != null || name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name; - } - - /** - * Creates an unresolved type for a valid {@link JavaType#getName() type name}. - */ - public static UnresolvedJavaType create(String name) { - return new UnresolvedJavaType(name, null); - } - - /** - * Creates an unresolved type for a valid {@link JavaType#getName() type name}. - */ - public static UnresolvedJavaType create(String name, Throwable cause) { - return new UnresolvedJavaType(name, cause); - } - - /** - * Gets the exception, if any, representing the reason type resolution resulted in this object. - */ - public Throwable getCause() { - return cause; - } - - @Override - public JavaType getComponentType() { - if (getName().charAt(0) == '[') { - return new UnresolvedJavaType(getName().substring(1), null); - } - return null; - } - - @Override - public JavaType getArrayClass() { - return new UnresolvedJavaType('[' + getName(), null); - } - - @Override - public JavaKind getJavaKind() { - return JavaKind.Object; - } - - @Override - public int hashCode() { - return getName().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof UnresolvedJavaType)) { - return false; - } - UnresolvedJavaType that = (UnresolvedJavaType) obj; - return this.getName().equals(that.getName()); - } - - @Override - public String toString() { - return "UnresolvedJavaType<" + getName() + ">"; - } - - @Override - public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - return accessingClass.lookupType(this, true); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/VMConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/VMConstant.java deleted file mode 100644 index ecd15057e97..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/VMConstant.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents a constant that needs to be patched at runtime by the VM. - */ -public interface VMConstant extends Constant { -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java deleted file mode 100644 index 81090c2b92e..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/Value.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Abstract base class for values. - */ -public abstract class Value { - - public static final Value[] NO_VALUES = new Value[0]; - - public static final AllocatableValue ILLEGAL = new IllegalValue(); - - private static final class IllegalValue extends AllocatableValue { - private IllegalValue() { - super(ValueKind.Illegal); - } - - @Override - public String toString() { - return "-"; - } - - @Override - public boolean equals(Object other) { - // Due to de-serialization this object may exist multiple times. So we compare classes - // instead of the individual objects. - return other instanceof IllegalValue; - } - } - - private final ValueKind valueKind; - - /** - * Initializes a new value of the specified kind. - * - * @param valueKind the kind - */ - protected Value(ValueKind valueKind) { - this.valueKind = valueKind; - } - - /** - * Returns a String representation of the kind, which should be the end of all - * {@link #toString()} implementation of subclasses. - */ - protected final String getKindSuffix() { - return "|" + valueKind.getKindSuffix(); - } - - public final ValueKind getValueKind() { - return valueKind; - } - - public final > K getValueKind(Class cls) { - return cls.cast(valueKind); - } - - /** - * Returns the platform specific kind used to store this value. - */ - public final PlatformKind getPlatformKind() { - return valueKind.getPlatformKind(); - } - - @Override - public int hashCode() { - return 41 + valueKind.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Value) { - Value that = (Value) obj; - return valueKind.equals(that.valueKind); - } - return false; - } - - /** - * Checks if this value is identical to {@code other}. - * - * Warning: Use with caution! Usually equivalence {@link #equals(Object)} is sufficient and - * should be used. - */ - public final boolean identityEquals(Value other) { - return this == other; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ValueKind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ValueKind.java deleted file mode 100644 index b3a0b56a360..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ValueKind.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.meta; - -/** - * Represents the type of {@link Value values}. This class can be extended by compilers to track - * additional information about values. - */ -public abstract class ValueKind> { - - private enum IllegalKind implements PlatformKind { - ILLEGAL; - - private final EnumKey key = new EnumKey<>(this); - - @Override - public Key getKey() { - return key; - } - - @Override - public int getSizeInBytes() { - return 0; - } - - @Override - public int getVectorLength() { - return 0; - } - - @Override - public char getTypeChar() { - return '-'; - } - } - - private static class IllegalValueKind extends ValueKind { - - IllegalValueKind() { - super(IllegalKind.ILLEGAL); - } - - @Override - public IllegalValueKind changeType(PlatformKind newPlatformKind) { - return this; - } - - @Override - public String toString() { - return "ILLEGAL"; - } - } - - /** - * The non-type. - */ - public static final ValueKind Illegal = new IllegalValueKind(); - - private final PlatformKind platformKind; - - public ValueKind(PlatformKind platformKind) { - this.platformKind = platformKind; - } - - public final PlatformKind getPlatformKind() { - return platformKind; - } - - /** - * Create a new {@link ValueKind} with a different {@link PlatformKind}. Subclasses must - * override this to preserve the additional information added by the compiler. - */ - public abstract K changeType(PlatformKind newPlatformKind); - - /** - * Returns a String representation of the kind, which will be included at the end of - * {@link Value#toString()} implementation. Defaults to {@link #toString()} but can be - * overridden to provide something more specific. - */ - public String getKindSuffix() { - return toString(); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/package-info.java deleted file mode 100644 index 421bfefe537..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * Package that defines the interface between a runtime and a Java application that wants to access - * meta information. The runtime provides an implementation of the - * {@link jdk.vm.ci.meta.MetaAccessProvider} interface. - */ -package jdk.vm.ci.meta; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64.java deleted file mode 100644 index 79491e507fd..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.riscv64; - -import java.nio.ByteOrder; -import java.util.EnumSet; -import java.util.List; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CPUFeatureName; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; - -/** - * Represents the RISCV64 architecture. - * - * The value returned by {@code Architecture#getName} for an instance of this class is {@code "riscv64"}. - */ -public class RISCV64 extends Architecture { - - public static final RegisterCategory CPU = new RegisterCategory("CPU"); - - // General purpose CPU registers - public static final Register x0 = new Register(0, 0, "x0", CPU); - public static final Register x1 = new Register(1, 1, "x1", CPU); - public static final Register x2 = new Register(2, 2, "x2", CPU); - public static final Register x3 = new Register(3, 3, "x3", CPU); - public static final Register x4 = new Register(4, 4, "x4", CPU); - public static final Register x5 = new Register(5, 5, "x5", CPU); - public static final Register x6 = new Register(6, 6, "x6", CPU); - public static final Register x7 = new Register(7, 7, "x7", CPU); - public static final Register x8 = new Register(8, 8, "x8", CPU); - public static final Register x9 = new Register(9, 9, "x9", CPU); - public static final Register x10 = new Register(10, 10, "x10", CPU); - public static final Register x11 = new Register(11, 11, "x11", CPU); - public static final Register x12 = new Register(12, 12, "x12", CPU); - public static final Register x13 = new Register(13, 13, "x13", CPU); - public static final Register x14 = new Register(14, 14, "x14", CPU); - public static final Register x15 = new Register(15, 15, "x15", CPU); - public static final Register x16 = new Register(16, 16, "x16", CPU); - public static final Register x17 = new Register(17, 17, "x17", CPU); - public static final Register x18 = new Register(18, 18, "x18", CPU); - public static final Register x19 = new Register(19, 19, "x19", CPU); - public static final Register x20 = new Register(20, 20, "x20", CPU); - public static final Register x21 = new Register(21, 21, "x21", CPU); - public static final Register x22 = new Register(22, 22, "x22", CPU); - public static final Register x23 = new Register(23, 23, "x23", CPU); - public static final Register x24 = new Register(24, 24, "x24", CPU); - public static final Register x25 = new Register(25, 25, "x25", CPU); - public static final Register x26 = new Register(26, 26, "x26", CPU); - public static final Register x27 = new Register(27, 27, "x27", CPU); - public static final Register x28 = new Register(28, 28, "x28", CPU); - public static final Register x29 = new Register(29, 29, "x29", CPU); - public static final Register x30 = new Register(30, 30, "x30", CPU); - public static final Register x31 = new Register(31, 31, "x31", CPU); - - // @formatter:off - public static final List cpuRegisters = List.of( - x0, x1, x2, x3, x4, x5, x6, x7, - x8, x9, x10, x11, x12, x13, x14, x15, - x16, x17, x18, x19, x20, x21, x22, x23, - x24, x25, x26, x27, x28, x29, x30, x31 - ); - // @formatter:on - - public static final RegisterCategory FP = new RegisterCategory("FP"); - - // Simd registers - public static final Register f0 = new Register(32, 0, "f0", FP); - public static final Register f1 = new Register(33, 1, "f1", FP); - public static final Register f2 = new Register(34, 2, "f2", FP); - public static final Register f3 = new Register(35, 3, "f3", FP); - public static final Register f4 = new Register(36, 4, "f4", FP); - public static final Register f5 = new Register(37, 5, "f5", FP); - public static final Register f6 = new Register(38, 6, "f6", FP); - public static final Register f7 = new Register(39, 7, "f7", FP); - public static final Register f8 = new Register(40, 8, "f8", FP); - public static final Register f9 = new Register(41, 9, "f9", FP); - public static final Register f10 = new Register(42, 10, "f10", FP); - public static final Register f11 = new Register(43, 11, "f11", FP); - public static final Register f12 = new Register(44, 12, "f12", FP); - public static final Register f13 = new Register(45, 13, "f13", FP); - public static final Register f14 = new Register(46, 14, "f14", FP); - public static final Register f15 = new Register(47, 15, "f15", FP); - public static final Register f16 = new Register(48, 16, "f16", FP); - public static final Register f17 = new Register(49, 17, "f17", FP); - public static final Register f18 = new Register(50, 18, "f18", FP); - public static final Register f19 = new Register(51, 19, "f19", FP); - public static final Register f20 = new Register(52, 20, "f20", FP); - public static final Register f21 = new Register(53, 21, "f21", FP); - public static final Register f22 = new Register(54, 22, "f22", FP); - public static final Register f23 = new Register(55, 23, "f23", FP); - public static final Register f24 = new Register(56, 24, "f24", FP); - public static final Register f25 = new Register(57, 25, "f25", FP); - public static final Register f26 = new Register(58, 26, "f26", FP); - public static final Register f27 = new Register(59, 27, "f27", FP); - public static final Register f28 = new Register(60, 28, "f28", FP); - public static final Register f29 = new Register(61, 29, "f29", FP); - public static final Register f30 = new Register(62, 30, "f30", FP); - public static final Register f31 = new Register(63, 31, "f31", FP); - - // @formatter:off - public static final List fpRegisters = List.of( - f0, f1, f2, f3, f4, f5, f6, f7, - f8, f9, f10, f11, f12, f13, f14, f15, - f16, f17, f18, f19, f20, f21, f22, f23, - f24, f25, f26, f27, f28, f29, f30, f31 - ); - // @formatter:on - - // @formatter:off - public static final List allRegisters = List.of( - x0, x1, x2, x3, x4, x5, x6, x7, - x8, x9, x10, x11, x12, x13, x14, x15, - x16, x17, x18, x19, x20, x21, x22, x23, - x24, x25, x26, x27, x28, x29, x30, x31, - - f0, f1, f2, f3, f4, f5, f6, f7, - f8, f9, f10, f11, f12, f13, f14, f15, - f16, f17, f18, f19, f20, f21, f22, f23, - f24, f25, f26, f27, f28, f29, f30, f31 - ); - // @formatter:on - - /** - * Basic set of CPU features mirroring what is returned from the mcpuid register. See: - * {@code VM_Version::cpuFeatureFlags}. - */ - public enum CPUFeature implements CPUFeatureName { - I, - M, - A, - F, - D, - C, - V - } - - private final EnumSet features; - - public RISCV64(EnumSet features) { - super("riscv64", RISCV64Kind.QWORD, ByteOrder.LITTLE_ENDIAN, true, allRegisters, 0, 0, 8); - this.features = features; - } - - @Override - public EnumSet getFeatures() { - return features; - } - - @Override - public PlatformKind getPlatformKind(JavaKind javaKind) { - switch (javaKind) { - case Boolean: - case Byte: - return RISCV64Kind.BYTE; - case Short: - case Char: - return RISCV64Kind.WORD; - case Int: - return RISCV64Kind.DWORD; - case Long: - case Object: - return RISCV64Kind.QWORD; - case Float: - return RISCV64Kind.SINGLE; - case Double: - return RISCV64Kind.DOUBLE; - default: - return null; - } - } - - @Override - public boolean canStoreValue(RegisterCategory category, PlatformKind platformKind) { - RISCV64Kind kind = (RISCV64Kind) platformKind; - if (kind.isInteger()) { - return category.equals(CPU); - } else if (kind.isFP()) { - return category.equals(FP); - } - return false; - } - - @Override - public RISCV64Kind getLargestStorableKind(RegisterCategory category) { - if (category.equals(CPU)) { - return RISCV64Kind.QWORD; - } else if (category.equals(FP)) { - return RISCV64Kind.DOUBLE; - } else { - return null; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64Kind.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64Kind.java deleted file mode 100644 index 6ff4ed5b41a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/RISCV64Kind.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.riscv64; - -import jdk.vm.ci.meta.PlatformKind; - -public enum RISCV64Kind implements PlatformKind { - - // scalar - BYTE(1), - WORD(2), - DWORD(4), - QWORD(8), - SINGLE(4), - DOUBLE(8); - - private final int size; - private final int vectorLength; - - private final RISCV64Kind scalar; - private final EnumKey key = new EnumKey<>(this); - - RISCV64Kind(int size) { - this.size = size; - this.scalar = this; - this.vectorLength = 1; - } - - RISCV64Kind(int size, RISCV64Kind scalar) { - this.size = size; - this.scalar = scalar; - - assert size % scalar.size == 0; - this.vectorLength = size / scalar.size; - } - - public RISCV64Kind getScalar() { - return scalar; - } - - @Override - public int getSizeInBytes() { - return size; - } - - @Override - public int getVectorLength() { - return vectorLength; - } - - @Override - public Key getKey() { - return key; - } - - public boolean isInteger() { - switch (this) { - case BYTE: - case WORD: - case DWORD: - case QWORD: - return true; - default: - return false; - } - } - - public boolean isFP() { - switch (this) { - case SINGLE: - case DOUBLE: - return true; - default: - return false; - } - } - - @Override - public char getTypeChar() { - switch (this) { - case BYTE: - return 'b'; - case WORD: - return 'w'; - case DWORD: - return 'd'; - case QWORD: - return 'q'; - case SINGLE: - return 'S'; - case DOUBLE: - return 'D'; - default: - return '-'; - } - } - -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/package-info.java deleted file mode 100644 index cd6bebb971a..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/riscv64/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The RISCV64 platform independent portions of the JVMCI API. - */ -package jdk.vm.ci.riscv64; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCI.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCI.java deleted file mode 100644 index d07df2ba75d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCI.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime; - -import java.util.Formatter; - -import jdk.vm.ci.services.Services; - -public class JVMCI { - - /** - * Singleton instance lazily initialized via double-checked locking. - */ - private static volatile JVMCIRuntime runtime; - - private static boolean initializing; - - public static void initialize() { - // force static initializer - } - - private static native JVMCIRuntime initializeRuntime(); - - /** - * Gets the singleton {@link JVMCIRuntime} instance available to the application. - * - * @throws UnsupportedOperationException if JVMCI is not supported - */ - public static JVMCIRuntime getRuntime() { - JVMCIRuntime result = runtime; - if (result == null) { - synchronized (JVMCI.class) { - result = runtime; - if (result == null) { - if (initializing) { - // In recursive call from HotSpotJVMCIRuntime.runtime - // so no need to re-enter initializeRuntime below. This - // path is only entered if JVMCI initialization starts - // with JVMCI.getRuntime(). - return null; - } - initializing = true; - try { - runtime = result = initializeRuntime(); - } catch (UnsatisfiedLinkError e) { - String javaHome = Services.getSavedProperty("java.home"); - String vmName = Services.getSavedProperty("java.vm.name"); - Formatter errorMessage = new Formatter(); - errorMessage.format("The VM does not support the JVMCI API.%n"); - errorMessage.format("Currently used Java home directory is %s.%n", javaHome); - errorMessage.format("Currently used VM configuration is: %s", vmName); - throw new UnsupportedOperationException(errorMessage.toString()); - } finally { - initializing = false; - } - } - } - } - return result; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIBackend.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIBackend.java deleted file mode 100644 index 28b296e095b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIBackend.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime; - -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.StackIntrospection; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.MetaAccessProvider; - -/** - * A JVMCI backend encapsulates the capabilities needed by a Java based compiler for compiling and - * installing code for a single compute unit within a JVM. In a JVM with support for heterogeneous - * computing, more than one backend may be exposed. - */ -public class JVMCIBackend { - - private final MetaAccessProvider metaAccess; - private final CodeCacheProvider codeCache; - private final ConstantReflectionProvider constantReflection; - private final StackIntrospection stackIntrospection; - - public JVMCIBackend(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, StackIntrospection stackIntrospection) { - this.metaAccess = metaAccess; - this.codeCache = codeCache; - this.constantReflection = constantReflection; - this.stackIntrospection = stackIntrospection; - } - - public MetaAccessProvider getMetaAccess() { - return metaAccess; - } - - public CodeCacheProvider getCodeCache() { - return codeCache; - } - - public ConstantReflectionProvider getConstantReflection() { - return constantReflection; - } - - public TargetDescription getTarget() { - return codeCache.getTarget(); - } - - public StackIntrospection getStackIntrospection() { - return stackIntrospection; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompiler.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompiler.java deleted file mode 100644 index accd9e01490..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompiler.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime; - -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestResult; - -public interface JVMCICompiler { - int INVOCATION_ENTRY_BCI = -1; - - /** - * Services a compilation request. This object should compile the method to machine code and - * install it in the code cache if the compilation is successful. - */ - CompilationRequestResult compileMethod(CompilationRequest request); - - /** - * Determines if this compiler supports the {@code gcIdentifier} garbage collector. The default - * implementation of this method returns true as that is the effective answer given by a - * {@link JVMCICompiler} before this method was added. - * - * @param gcIdentifier a VM dependent GC identifier - */ - default boolean isGCSupported(int gcIdentifier) { - return true; - } - - /** - * Determines if this compiler supports the {@code intrinsicIdentifier} intrinsic. The default - * implementation of this method returns false as that is the effective answer given by a - * {@link JVMCICompiler} before this method was added. - * - * @param intrinsicIdentifier intrinsic identifier defined in vmIntrinsics.hpp. - */ - default boolean isIntrinsicSupported(int intrinsicIdentifier) { - return false; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompilerFactory.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompilerFactory.java deleted file mode 100644 index bae1713175d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCICompilerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime; - -import java.io.PrintStream; - -/** - * Factory for creating JVMCI compilers. - */ -public interface JVMCICompilerFactory { - - /** - * Get the name of this compiler. The name is used by JVMCI to determine which factory to use. - */ - String getCompilerName(); - - /** - * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime) - * create} a compiler and it should now perform any heavy weight initialization that it deferred - * during construction. - */ - default void onSelection() { - } - - /** - * Create a new instance of a {@link JVMCICompiler}. - */ - JVMCICompiler createCompiler(JVMCIRuntime runtime); - - /** - * Prints a description of the properties used to configure this compiler. - * - * @param out where to print the message - */ - default void printProperties(PrintStream out) { - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIRuntime.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIRuntime.java deleted file mode 100644 index b705417e941..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/JVMCIRuntime.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime; - -import jdk.vm.ci.code.Architecture; - -/** - * Interface for accessing the {@link JVMCI} APIs supported by the runtime. - */ -public interface JVMCIRuntime { - - /** - * Gets the default system compiler. - */ - JVMCICompiler getCompiler(); - - /** - * Gets the host JVMCI backend. - */ - JVMCIBackend getHostJVMCIBackend(); - - /** - * Gets the backend for a given architecture. - * - * @param arch a specific architecture class - */ - JVMCIBackend getJVMCIBackend(Class arch); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/package-info.java deleted file mode 100644 index 62b56030537..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/runtime/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The core runtime interface of the JVMCI API. - */ -package jdk.vm.ci.runtime; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIPermission.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIPermission.java deleted file mode 100644 index 2548dd78093..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIPermission.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -import java.security.BasicPermission; - -/** - * This class represents the permission to access JVMCI services. - */ -public class JVMCIPermission extends BasicPermission { - - private static final long serialVersionUID = 6346818963934448226L; - - public JVMCIPermission() { - super("jvmci"); - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java deleted file mode 100644 index 98856337cec..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/JVMCIServiceLocator.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -import java.util.ArrayList; -import java.util.List; -import java.util.ServiceLoader; - -/** - * Service-provider class for the runtime to locate providers of JVMCI services where the latter are - * not in packages exported by the JVMCI module. As part of instantiating a - * {@link JVMCIServiceLocator}, all JVMCI packages will be opened to the module defining the class - * of the instantiated object. - * - * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use - * {@link #getProviders(Class)}. - */ -public abstract class JVMCIServiceLocator { - - private static Void checkPermission() { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new JVMCIPermission()); - } - return null; - } - - @SuppressWarnings("unused") - private JVMCIServiceLocator(Void ignore) { - } - - /** - * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI opens all its - * packages to the module defining the type of this object. - * - * @throws SecurityException if a security manager has been installed and it denies - * {@link JVMCIPermission} - */ - protected JVMCIServiceLocator() { - this(checkPermission()); - Services.openJVMCITo(getClass().getModule()); - } - - /** - * Gets the provider of the service defined by {@code service} or {@code null} if this object - * does not have a provider for {@code service}. - */ - protected abstract S getProvider(Class service); - - /** - * The available set of locators. - */ - private static final List locators = new ArrayList<>(); - static { - ServiceLoader.load(JVMCIServiceLocator.class).forEach(locators::add); - } - - /** - * Gets the providers of the service defined by {@code service} by querying the available - * {@link JVMCIServiceLocator} providers. - * - * @throws SecurityException if a security manager is present and it denies - * {@link JVMCIPermission} - */ - public static List getProviders(Class service) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new JVMCIPermission()); - } - List providers = new ArrayList<>(); - for (JVMCIServiceLocator access : locators) { - S provider = access.getProvider(service); - if (provider != null) { - providers.add(provider); - } - } - return providers; - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java deleted file mode 100644 index c2bccb1bac1..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/Services.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.function.Consumer; -import java.util.function.Supplier; - -import jdk.internal.misc.TerminatingThreadLocal; -import jdk.internal.misc.VM; -import jdk.internal.misc.Unsafe; -import jdk.internal.util.Architecture; -import jdk.internal.util.OperatingSystem; - -/** - * Provides utilities needed by JVMCI clients. - */ -public final class Services { - - /** - * Guards code that should only be run in a JVMCI shared library. Such code must be directly - * guarded by an {@code if} statement on this field - the guard cannot be behind a method call. - * - * The value of this field in a JVMCI shared library runtime must be {@code true}. - */ - public static final boolean IS_IN_NATIVE_IMAGE; - static { - /* - * Prevents javac from constant folding use of this field. It is set to true by the process - * that builds the shared library. - */ - IS_IN_NATIVE_IMAGE = false; - } - - private Services() { - } - - /** - * Lazily initialized in {@link #getSavedProperties}. - */ - private static volatile Map savedProperties; - - /** - * Gets an unmodifiable copy of the system properties as of VM startup. - * - * If running on Hotspot, this will be the system properties parsed by {@code arguments.cpp} - * plus {@code java.specification.version}, {@code os.name} and {@code os.arch}. The latter two - * are forced to be the real OS and architecture. That is, values for these two properties set - * on the command line are ignored. - */ - public static Map getSavedProperties() { - if (savedProperties == null) { - synchronized (Services.class) { - if (savedProperties == null) { - savedProperties = initProperties(); - } - } - } - return savedProperties; - } - - /** - * Helper method equivalent to {@link #getSavedProperties()}{@code .getOrDefault(name, def)}. - */ - public static String getSavedProperty(String name, String def) { - return Services.getSavedProperties().getOrDefault(name, def); - } - - /** - * Helper method equivalent to {@link #getSavedProperties()}{@code .get(name)}. - */ - public static String getSavedProperty(String name) { - return Services.getSavedProperties().get(name); - } - - /** - * Causes the JVMCI subsystem to be initialized if it isn't already initialized. - */ - public static void initializeJVMCI() { - try { - Class.forName("jdk.vm.ci.runtime.JVMCI"); - } catch (ClassNotFoundException e) { - throw new InternalError(e); - } - } - - /** - * Opens all JVMCI packages to {@code otherModule}. - */ - static void openJVMCITo(Module otherModule) { - Module jvmci = Services.class.getModule(); - if (jvmci != otherModule) { - Set packages = jvmci.getPackages(); - for (String pkg : packages) { - boolean opened = jvmci.isOpen(pkg, otherModule); - if (!opened) { - jvmci.addOpens(pkg, otherModule); - } - } - } - } - - /** - * Creates a thread-local variable that notifies {@code onThreadTermination} when a thread - * terminates and it has been initialized in the terminating thread (even if it was initialized - * with a null value). A typical use is to release resources associated with a thread. - * - * @param initialValue a supplier to be used to determine the initial value - * @param onThreadTermination a consumer invoked by a thread when terminating and the - * thread-local has an associated value for the terminating thread. The current - * thread's value of the thread-local variable is passed as a parameter to the - * consumer. - */ - public static ThreadLocal createTerminatingThreadLocal(Supplier initialValue, Consumer onThreadTermination) { - Objects.requireNonNull(initialValue, "initialValue must be non null."); - Objects.requireNonNull(onThreadTermination, "onThreadTermination must be non null."); - return new TerminatingThreadLocal<>() { - - @Override - protected T initialValue() { - return initialValue.get(); - } - - @Override - protected void threadTerminated(T value) { - onThreadTermination.accept(value); - } - }; - } - - static String toJavaString(Unsafe unsafe, long cstring) { - if (cstring == 0) { - return null; - } - int len = 0; - for (long p = cstring; unsafe.getByte(p) != 0; p++) { - len++; - } - byte[] buf = new byte[len]; - for (int i = 0; i < len; i++) { - buf[i] = unsafe.getByte(cstring + i); - } - return new String(buf, java.nio.charset.StandardCharsets.UTF_8); - } - - /** - * Gets the value of {@code Arguments::systemProperties()} and puts the offsets - * of {@code SystemProperty} fields into {@code offsets}. The values returned in - * {@code offsets} are: - * - *
-     *     [ next,  // SystemProperty::next_offset_in_bytes()
-     *       key,   // SystemProperty::key_offset_in_bytes()
-     *       value  // PathString::value_offset_in_bytes()
-     *     ]
-     * 
- * - * Ideally this would be done with vmstructs but that code is in {@code jdk.vm.ci.hotspot}. - */ - private static native long readSystemPropertiesInfo(int[] offsets); - - /** - * Parses the native {@code Arguments::systemProperties()} data structure using Unsafe to - * create a properties map. This parsing is safe as argument parsing in completed in - * early VM start before this code can be executed, making {@code Arguments::systemProperties()} - * effectively read-only by now. - */ - private static Map initProperties() { - int[] offsets = new int[3]; - long systemProperties = readSystemPropertiesInfo(offsets); - int nextOffset = offsets[0]; - int keyOffset = offsets[1]; - int valueOffset = offsets[2]; - - int count = 0; - Unsafe unsafe = Unsafe.getUnsafe(); - for (long prop = systemProperties; prop != 0; prop = unsafe.getLong(prop + nextOffset)) { - if (unsafe.getLong(prop + valueOffset) != 0) { - count++; - } else { - // Some internal properties (e.g. jdk.boot.class.path.append) can have a null - // value and should just be ignored. Note that null is different than the empty string. - } - } - Map props = new HashMap<>(count + 1); - int i = 0; - for (long prop = systemProperties; prop != 0; prop = unsafe.getLong(prop + nextOffset)) { - String key = toJavaString(unsafe, unsafe.getLong(prop + keyOffset)); - long valueAddress = unsafe.getLong(prop + valueOffset); - if (valueAddress != 0) { - props.put(key, new SystemProperties.Value(unsafe, valueAddress)); - i++; - } - } - if (i != count) { - throw new InternalError(i + " != " + count); - } - if (!props.containsKey("java.specification.version")) { - SystemProperties.Value v = Objects.requireNonNull(props.get("java.vm.specification.version")); - props.put("java.specification.version", v); - } - - SystemProperties res = new SystemProperties(unsafe, sanitizeOSArch(props)); - if ("true".equals(res.get("debug.jvmci.PrintSavedProperties"))) { - System.out.println("[Saved system properties]"); - for (Map.Entry e : res.entrySet()) { - System.out.printf("%s=%s%n", e.getKey(), e.getValue()); - } - } - return res; - } - - // Force os.name and os.arch to reflect the actual OS and architecture. - // JVMCI configures itself based on these values and needs to be isolated - // from apps that set them on the command line. - private static Map sanitizeOSArch(Map props) { - props.put("os.arch", new SystemProperties.Value(realArch())); - props.put("os.name", new SystemProperties.Value(realOS())); - return props; - } - - private static String realOS() { - OperatingSystem os = OperatingSystem.current(); - switch (os) { - case LINUX: return "Linux"; - case MACOS: return "Mac OS X"; - case AIX: return "AIX"; - case WINDOWS: { - String osName = System.getProperty("os.name"); - if (osName.startsWith("Windows")) { - // Use original value which is often more "complete" - // E.g. "Windows Server 2012" - return osName; - } - return "Windows"; - } - default: throw new InternalError("missing case for " + os); - } - } - - private static String realArch() { - Architecture arch = Architecture.current(); - switch (arch) { - case X64: return "x86_64"; - case X86: return "x86"; - case AARCH64: return "aarch64"; - case RISCV64: return "riscv64"; - case ARM: return "arm"; - case S390: return "s390"; - case PPC64: return "ppc64"; - case OTHER: return "other"; - default: throw new InternalError("missing case for " + arch); - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SuppressFBWarnings.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SuppressFBWarnings.java deleted file mode 100644 index 88b6c7bc653..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SuppressFBWarnings.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -/** - * Used to suppress FindBugs warnings. - */ -@interface SuppressFBWarnings { - /** - * The set of FindBugs - * warnings that are to be - * suppressed in annotated element. The value can be a bug category, kind or pattern. - */ - String[] value(); - - /** - * Reason why the warning is suppressed. - */ - String justification(); -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SystemProperties.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SystemProperties.java deleted file mode 100644 index 2b4f3141e6b..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/SystemProperties.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import jdk.internal.misc.Unsafe; - -/** - * Unmodifiable map for storing system properties read from native memory whose values have their - * string representation constructed on first access. - */ -final class SystemProperties implements Map { - - private final Unsafe unsafe; - private final Map entries; - private Set> entrySet; - private Collection values; - - SystemProperties(Unsafe unsafe, Map entries) { - this.unsafe = unsafe; - this.entries = entries; - } - - @Override - public int size() { - return entries.size(); - } - - @Override - public boolean isEmpty() { - return entries.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return entries.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - for (Value v : entries.values()) { - if (v.getString(unsafe).equals(value)) { - return true; - } - } - return false; - } - - @Override - public String get(Object key) { - Value v = entries.get(key); - if (v != null) { - return v.getString(unsafe); - } - return null; - } - - @Override - public String put(String key, String value) { - throw new UnsupportedOperationException(); - } - - @Override - public String remove(Object key) { - throw new UnsupportedOperationException(); - } - - @Override - public void putAll(Map m) { - throw new UnsupportedOperationException(); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(); - } - - @Override - public Set keySet() { - return entries.keySet(); - } - - @Override - public Collection values() { - if (values == null) { - values = entries.values().stream().map(v -> v.getString(unsafe)).collect(Collectors.toUnmodifiableList()); - } - return values; - } - - static class Property implements Map.Entry { - private final Unsafe unsafe; - private final String key; - private final Value value; - - Property(Unsafe unsafe, Map.Entry e) { - this.unsafe = unsafe; - this.key = e.getKey(); - this.value = e.getValue(); - } - - @Override - public String getKey() { - return key; - } - - @Override - public String getValue() { - return value.getString(unsafe); - } - - @Override - public String setValue(String value) { - throw new UnsupportedOperationException(); - } - }; - - @Override - public Set> entrySet() { - if (entrySet == null) { - entrySet = entries.entrySet().stream().map(e -> new Property(unsafe, e)).collect(Collectors.toUnmodifiableSet()); - } - return entrySet; - } - - /** - * Represents a value in {@link SystemProperties}. - */ - static class Value { - private final long cstring; - private volatile String string; - - /** - * Creates a value whose string representation will be lazily constructed from {@code cstring}. - */ - Value(Unsafe unsafe, long cstring) { - this.cstring = cstring; - } - - /** - * Creates a value whose string representation is known at construction time. - */ - Value(String string) { - this.cstring = 0; - this.string = string; - } - - String getString(Unsafe unsafe) { - if (string == null) { - // Racy but it doesn't matter. - string = Services.toJavaString(unsafe, cstring); - } - return string; - } - } -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/VMEntryPoint.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/VMEntryPoint.java deleted file mode 100644 index a499ae91584..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/VMEntryPoint.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.services; - -/** - * Marker interface for methods which are called from the JVM. - */ -@interface VMEntryPoint { - /** - * An optional comment describing the caller. - */ - String value() default ""; -} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/package-info.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/package-info.java deleted file mode 100644 index 69729a2519f..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/services/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * The service related portions of the JVMCI API. - */ -package jdk.vm.ci.services; diff --git a/src/jdk.internal.vm.ci/share/classes/module-info.java b/src/jdk.internal.vm.ci/share/classes/module-info.java deleted file mode 100644 index 14f97412b3d..00000000000 --- a/src/jdk.internal.vm.ci/share/classes/module-info.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -module jdk.internal.vm.ci { - exports jdk.vm.ci.services to - jdk.graal.compiler, - jdk.graal.compiler.management; - exports jdk.vm.ci.runtime to - jdk.graal.compiler, - jdk.graal.compiler.management; - exports jdk.vm.ci.meta to jdk.graal.compiler; - exports jdk.vm.ci.code to jdk.graal.compiler; - exports jdk.vm.ci.hotspot to jdk.graal.compiler; - - uses jdk.vm.ci.services.JVMCIServiceLocator; - uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; - - provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with - jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory, - jdk.vm.ci.hotspot.amd64.AMD64HotSpotJVMCIBackendFactory, - jdk.vm.ci.hotspot.riscv64.RISCV64HotSpotJVMCIBackendFactory; -} diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java index de7584d3e3f..aabd9a094bc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/TypeLibrary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,6 @@ import jdk.internal.module.Modules; public final class TypeLibrary { private static boolean implicitFieldTypes; private static final Map types = LinkedHashMap.newLinkedHashMap(350); - private static volatile boolean initialized; static final ValueDescriptor DURATION_FIELD = createDurationField(); static final ValueDescriptor THREAD_FIELD = createThreadField(); static final ValueDescriptor STACK_TRACE_FIELD = createStackTraceField(); @@ -101,11 +100,6 @@ public final class TypeLibrary { } public static synchronized void initialize() { - // The usual case is that TypeLibrary is initialized only once by the MetadataRepository singleton. - // However, this check is needed to ensure some tools (ie. GraalVM Native Image) do not perform the initialization routine twice. - if (initialized) { - return; - } List jvmTypes; try { jvmTypes = MetadataLoader.createTypes(); @@ -114,7 +108,6 @@ public final class TypeLibrary { throw new Error("JFR: Could not read metadata"); } visitReachable(jvmTypes, t -> !types.containsKey(t.getId()), t -> types.put(t.getId(), t)); - initialized = true; if (Logger.shouldLog(LogTag.JFR_SYSTEM_METADATA, LogLevel.INFO)) { Stream s = types.values().stream().sorted((x, y) -> Long.compare(x.getId(), y.getId())); s.forEach(t -> t.log("Added", LogTag.JFR_SYSTEM_METADATA, LogLevel.INFO)); diff --git a/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java b/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java index 9a806a85552..31e50cefdfe 100644 --- a/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java +++ b/src/utils/LogCompilation/src/main/java/com/sun/hotspot/tools/compiler/LogParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1176,7 +1176,7 @@ public class LogParser extends DefaultHandler implements ErrorHandler { lateInlineScope.push(site); } else if (expectStringConcatTrap == true) { // Record the location of the replace_string_concat for the - // uncommon_trap 'intrinsic_or_type_checked_inlining' that should follow it + // uncommon_trap 'intrinsic' that should follow it current_bci = Integer.parseInt(search(atts, "bci")); Method m = method(search(atts, "method")); site = new CallSite(current_bci, m); diff --git a/src/utils/LogCompilation/src/test/resources/8314319.xml b/src/utils/LogCompilation/src/test/resources/8314319.xml index 789025c790e..15a7d7e80fe 100644 --- a/src/utils/LogCompilation/src/test/resources/8314319.xml +++ b/src/utils/LogCompilation/src/test/resources/8314319.xml @@ -7,15 +7,15 @@ OpenJDK 64-Bit Server VM - - - + + + - + @@ -66,7 +66,7 @@ OpenJDK 64-Bit Server VM - + @@ -118,7 +118,7 @@ OpenJDK 64-Bit Server VM - + @@ -136,7 +136,7 @@ OpenJDK 64-Bit Server VM - + @@ -173,7 +173,7 @@ OpenJDK 64-Bit Server VM - + @@ -285,7 +285,7 @@ OpenJDK 64-Bit Server VM - + @@ -321,7 +321,7 @@ OpenJDK 64-Bit Server VM - + @@ -358,7 +358,7 @@ OpenJDK 64-Bit Server VM - + @@ -372,7 +372,7 @@ OpenJDK 64-Bit Server VM - + @@ -405,7 +405,7 @@ OpenJDK 64-Bit Server VM - + diff --git a/test/hotspot/jtreg/ProblemList-jvmti-stress-agent.txt b/test/hotspot/jtreg/ProblemList-jvmti-stress-agent.txt index a30d6dfecff..656c223ed2b 100644 --- a/test/hotspot/jtreg/ProblemList-jvmti-stress-agent.txt +++ b/test/hotspot/jtreg/ProblemList-jvmti-stress-agent.txt @@ -63,10 +63,6 @@ compiler/loopopts/superword/TestDependencyOffsets.java#vec-v032-U 0000 compiler/loopopts/superword/TestDependencyOffsets.java#vec-v064-A 0000000 generic-all compiler/loopopts/superword/TestDependencyOffsets.java#vec-v064-U 0000000 generic-all -# Requires solo jvmti capabilities - -compiler/jvmci/events/JvmciShutdownEventTest.java 0000000 generic-all - # jdwp runtime/6294277/SourceDebugExtension.java 0000000 generic-all diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 351ef2a540c..2985b11bf25 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -30,14 +30,6 @@ vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 8343233 generic-all -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java 8343233 generic-aarch64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java 8343233 generic-aarch64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java 8343233 generic-aarch64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java 8343233 generic-aarch64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java 8343233 generic-aarch64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java 8343233 generic-aarch64 - ############################################################################# # Preview project specific failures go here at the end of the file. diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 7b24cf98e27..422e6ddd060 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -62,15 +62,6 @@ compiler/vectorization/TestVectorAlgorithms.java#noSuperWord 8376803 aix-ppc64,l compiler/vectorization/TestVectorAlgorithms.java#vanilla 8376803 aix-ppc64,linux-s390x compiler/vectorization/TestVectorAlgorithms.java#noOptimizeFill 8376803 aix-ppc64,linux-s390x -compiler/jvmci/TestUncaughtErrorInCompileMethod.java 8309073 generic-all -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java 8331704 linux-riscv64 -compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInvalidationReasonTest.java 8360168 linux-riscv64 - compiler/floatingpoint/TestSubnormalFloat.java 8317810 generic-i586 compiler/floatingpoint/TestSubnormalDouble.java 8317810 generic-i586 diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 892529b966f..9717da05522 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -67,8 +67,6 @@ requires.properties= \ vm.gc.Shenandoah \ vm.gc.Epsilon \ vm.gc.Z \ - vm.jvmci \ - vm.jvmci.enabled \ vm.cpu.features \ vm.pageSize \ vm.debug \ @@ -88,9 +86,6 @@ requires.properties= \ vm.cds.write.streamed.java.heap \ vm.continuations \ vm.jvmti \ - vm.graal.enabled \ - jdk.hasLibgraal \ - vm.libgraal.jit \ vm.compiler1.enabled \ vm.compiler2.enabled \ vm.musl \ diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index a1aff165445..e09235f6a39 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -181,7 +181,6 @@ tier1_compiler_2 = \ compiler/inlining/ \ compiler/integerArithmetic/ \ compiler/interpreter/ \ - compiler/jvmci/ \ -compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java \ -compiler/codecache/stress \ -compiler/codegen/aes \ diff --git a/test/hotspot/jtreg/applications/ctw/modules/generate.bash b/test/hotspot/jtreg/applications/ctw/modules/generate.bash index a3d60f7ecfa..8771fc2d41b 100644 --- a/test/hotspot/jtreg/applications/ctw/modules/generate.bash +++ b/test/hotspot/jtreg/applications/ctw/modules/generate.bash @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -100,8 +100,6 @@ do # Those have no classes (needs to be checked on re-generations)! "jdk.jdwp.agent") ;; - "jdk.graal.compiler") ;; - "jdk.graal.compiler.management") ;; "jdk.crypto.ec") ;; "java.se") ;; diff --git a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java b/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java deleted file mode 100644 index 9d49c50e19e..00000000000 --- a/test/hotspot/jtreg/applications/ctw/modules/jdk_internal_vm_ci.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary run CTW for all classes from jdk.internal.vm.ci module - * - * @library /test/lib / /testlibrary/ctw/src - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.jimage - * java.base/jdk.internal.misc - * java.base/jdk.internal.reflect - * @modules jdk.internal.vm.ci - * - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run driver/timeout=7200 sun.hotspot.tools.ctw.CtwRunner modules:jdk.internal.vm.ci - */ diff --git a/test/hotspot/jtreg/compiler/arguments/BMICommandLineOptionTestBase.java b/test/hotspot/jtreg/compiler/arguments/BMICommandLineOptionTestBase.java index 089679d8da2..ebe2a561b29 100644 --- a/test/hotspot/jtreg/compiler/arguments/BMICommandLineOptionTestBase.java +++ b/test/hotspot/jtreg/compiler/arguments/BMICommandLineOptionTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ import jdk.test.lib.cli.CommandLineOptionTest; * specific options and that values of these options processed correctly. * In order to do that test launch a new VM with tested options, the same * flavor-specific flag as one that was used for parent VM (-client, -server, - * -minimal, -graal) and '-version'. + * -minimal) and '-version'. */ public abstract class BMICommandLineOptionTestBase extends CPUSpecificCommandLineOptionTest { diff --git a/test/hotspot/jtreg/compiler/arguments/BMISupportedCPUTest.java b/test/hotspot/jtreg/compiler/arguments/BMISupportedCPUTest.java index 4979de0ae5c..831385f9623 100644 --- a/test/hotspot/jtreg/compiler/arguments/BMISupportedCPUTest.java +++ b/test/hotspot/jtreg/compiler/arguments/BMISupportedCPUTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ import jdk.test.lib.cli.CommandLineOptionTest; * specific options and that values of these options processed correctly. * In order to do that test launch a new VM with tested options, the same * flavor-specific flag as one that was used for parent VM (-client, -server, - * -minimal, -graal) and '-version'. + * -minimal) and '-version'. */ public class BMISupportedCPUTest extends BMICommandLineOptionTestBase { diff --git a/test/hotspot/jtreg/compiler/arguments/BMIUnsupportedCPUTest.java b/test/hotspot/jtreg/compiler/arguments/BMIUnsupportedCPUTest.java index 957bc7607a2..ee0ba74d757 100644 --- a/test/hotspot/jtreg/compiler/arguments/BMIUnsupportedCPUTest.java +++ b/test/hotspot/jtreg/compiler/arguments/BMIUnsupportedCPUTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,7 @@ import jdk.test.lib.cli.CommandLineOptionTest; * specific options and that values of these options processed correctly. * In order to do that test launch a new VM with tested options, the same * flavor-specific flag as one that was used for parent VM (-client, -server, - * -minimal, -graal) and '-version'. + * -minimal) and '-version'. */ public class BMIUnsupportedCPUTest extends BMICommandLineOptionTestBase { diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java index 9e920a08b0f..deb9bf84487 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyNoInitDeopt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 8072016 * @summary Infinite deoptimization/recompilation cycles in case of arraycopy with tightly coupled allocation - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java index 22bf1f88ae7..e8804d5735c 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @bug 8248791 8375442 * @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) where loads are wrongly replaced by zero. - * @requires vm.compiler2.enabled | vm.graal.enabled + * @requires vm.compiler2.enabled * * @run main/othervm -XX:-ReduceBulkZeroing * -XX:CompileCommand=dontinline,${test.main.class}::* diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java index 5c910a4d293..0ee33043dc1 100644 --- a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java +++ b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @bug 8235332 8248226 * @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) fields with StressGCM * @library / - * @requires vm.compiler2.enabled | vm.graal.enabled + * @requires vm.compiler2.enabled * * @run main/othervm -Xbatch * -XX:CompileCommand=dontinline,compiler.arraycopy.TestCloneAccessStressGCM::test diff --git a/test/hotspot/jtreg/compiler/c2/Test8004741.java b/test/hotspot/jtreg/compiler/c2/Test8004741.java index 08f4da62280..4b0b241cb53 100644 --- a/test/hotspot/jtreg/compiler/c2/Test8004741.java +++ b/test/hotspot/jtreg/compiler/c2/Test8004741.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 8004741 * @summary Missing compiled exception handle table entry for multidimensional array allocation * - * @requires !vm.graal.enabled * @library /test/lib * * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesG1.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesG1.java index 04c5f5392db..dcd28f80b5d 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesG1.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesG1.java @@ -30,8 +30,7 @@ * * @requires vm.flagless * @requires os.arch=="aarch64" & vm.debug == true & - * vm.flavor == "server" & !vm.graal.enabled & - * vm.gc.G1 + * vm.flavor == "server" & vm.gc.G1 * * @build compiler.c2.aarch64.TestVolatiles * compiler.c2.aarch64.TestVolatileLoad diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesParallel.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesParallel.java index 8c2ae00cc08..c42345dd1f5 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesParallel.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesParallel.java @@ -30,8 +30,7 @@ * * @requires vm.flagless * @requires os.arch=="aarch64" & vm.debug == true & - * vm.flavor == "server" & !vm.graal.enabled & - * vm.gc.Parallel + * vm.flavor == "server" & vm.gc.Parallel * * @build compiler.c2.aarch64.TestVolatiles * compiler.c2.aarch64.TestVolatileLoad diff --git a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesSerial.java b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesSerial.java index 499ce86abca..02adbb5ceb4 100644 --- a/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesSerial.java +++ b/test/hotspot/jtreg/compiler/c2/aarch64/TestVolatilesSerial.java @@ -30,8 +30,7 @@ * * @requires vm.flagless * @requires os.arch=="aarch64" & vm.debug == true & - * vm.flavor == "server" & !vm.graal.enabled & - * vm.gc.Serial + * vm.flavor == "server" & vm.gc.Serial * * @build compiler.c2.aarch64.TestVolatiles * compiler.c2.aarch64.TestVolatileLoad diff --git a/test/hotspot/jtreg/compiler/cha/AbstractRootMethod.java b/test/hotspot/jtreg/compiler/cha/AbstractRootMethod.java index 4aa5eeffff9..e0a0fbda92f 100644 --- a/test/hotspot/jtreg/compiler/cha/AbstractRootMethod.java +++ b/test/hotspot/jtreg/compiler/cha/AbstractRootMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /* * @test - * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * java.base/jdk.internal.vm.annotation * @library /testlibrary/asm diff --git a/test/hotspot/jtreg/compiler/cha/DefaultRootMethod.java b/test/hotspot/jtreg/compiler/cha/DefaultRootMethod.java index 37ac89f6975..1a040eba333 100644 --- a/test/hotspot/jtreg/compiler/cha/DefaultRootMethod.java +++ b/test/hotspot/jtreg/compiler/cha/DefaultRootMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /* * @test - * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * java.base/jdk.internal.vm.annotation * @library /testlibrary/asm diff --git a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java index 5e2dc2e3d56..5c0b8a073d9 100644 --- a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java +++ b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /* * @test - * @requires !vm.graal.enabled * @requires vm.opt.StressMethodHandleLinkerInlining == null | !vm.opt.StressMethodHandleLinkerInlining * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java index db5f31d8c77..417a6bbc00f 100644 --- a/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java +++ b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test TestOverloadCompileQueues * @bug 8163511 8230402 * @summary Test overloading the C1 and C2 compile queues with tasks. - * @requires !vm.graal.enabled * @run main/othervm/timeout=1200 -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1 * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues * @run main/othervm/timeout=1200 -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2 diff --git a/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java b/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java index ff33e4739b7..968775aa931 100644 --- a/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java +++ b/test/hotspot/jtreg/compiler/codegen/TestCharVect2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * @test * @bug 8001183 * @summary incorrect results of char vectors right shift operation - * @requires vm.compiler2.enabled | vm.graal.enabled + * @requires vm.compiler2.enabled * * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.codegen.TestCharVect2 * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.codegen.TestCharVect2 diff --git a/test/hotspot/jtreg/compiler/compilercontrol/jcmd/PrintDirectivesTest.java b/test/hotspot/jtreg/compiler/compilercontrol/jcmd/PrintDirectivesTest.java index de1ac0b4bde..01cb783f6d8 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/jcmd/PrintDirectivesTest.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/jcmd/PrintDirectivesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ * @summary Tests jcmd to be able to add a directive to compile only specified methods * @modules java.base/jdk.internal.misc * @library /test/lib / - * @requires vm.flavor != "minimal" & !vm.graal.enabled + * @requires vm.flavor != "minimal" * * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/compilercontrol/logcompilation/LogTest.java b/test/hotspot/jtreg/compiler/compilercontrol/logcompilation/LogTest.java index 12b6a1987a7..cff1ad745f7 100644 --- a/test/hotspot/jtreg/compiler/compilercontrol/logcompilation/LogTest.java +++ b/test/hotspot/jtreg/compiler/compilercontrol/logcompilation/LogTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Tests LogCompilation executed standalone without log commands or directives * - * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * @library /test/lib / * diff --git a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java index b3aa0283fa5..1a86e40e53a 100644 --- a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java +++ b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnSupportedConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java index 7fc6d7f86c1..c5e64dc7e2e 100644 --- a/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java +++ b/test/hotspot/jtreg/compiler/cpuflags/TestAESIntrinsicsOnUnsupportedConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ * * @build jdk.test.whitebox.WhiteBox * @requires !(vm.cpu.features ~= ".*aes.*" | vm.cpu.features ~= ".*zvkn.*") - * @requires vm.compiler1.enabled | !vm.graal.enabled * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+WhiteBoxAPI -Xbatch diff --git a/test/hotspot/jtreg/compiler/escapeAnalysis/TestEliminateLocksOffCrash.java b/test/hotspot/jtreg/compiler/escapeAnalysis/TestEliminateLocksOffCrash.java index 33044701460..050c434886a 100644 --- a/test/hotspot/jtreg/compiler/escapeAnalysis/TestEliminateLocksOffCrash.java +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestEliminateLocksOffCrash.java @@ -25,7 +25,7 @@ * @test * @bug 8227384 * @summary C2 compilation fails with "graph should be schedulable" when running with -XX:-EliminateLocks - * @requires vm.compiler2.enabled & !vm.graal.enabled + * @requires vm.compiler2.enabled * * @run main/othervm -XX:-EliminateLocks TestEliminateLocksOffCrash */ diff --git a/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java index 77d166f6857..beb60c07c63 100644 --- a/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java +++ b/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java @@ -34,7 +34,6 @@ * @bug 8139258 8165673 * @summary Regression test for passing float args to a jni function. * - * @requires !vm.graal.enabled * @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs */ diff --git a/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecode.java b/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecode.java index 1600559a712..6097a427ef4 100644 --- a/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecode.java +++ b/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ public class TestVerifyStackWithUnreachableBytecode { public static void main(String[] args) { TestCase t = testCaseFromString(args[0]); - // The following is designed to cause a deopt with the reason `null_assert_or_unreached0` + // The following is designed to cause a deopt with the reason `null_assert` // when accessing A.val using getstatic due to the class B not being loaded and the consequent // assumption of A.val == null. TestVerifyStackWithUnreachableBytecodeA.val = null; diff --git a/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecodeImpl.jasm b/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecodeImpl.jasm index 584f697f103..1588b3464f9 100644 --- a/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecodeImpl.jasm +++ b/test/hotspot/jtreg/compiler/interpreter/TestVerifyStackWithUnreachableBytecodeImpl.jasm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ super class TestVerifyStackWithUnreachableBytecodeImpl version 49:0 { // If A not loaded -> trap for TestVerifyStackWithUnreachableBytecodeA unloaded // If a loaded, but TestVerifyStackWithUnreachableBytecodeB not -> assume TestVerifyStackWithUnreachableBytecodeA.val null, else trap. - // -> "null_assert_or_unreached0" + // -> "null_assert" getstatic Field compiler/interpreter/TestVerifyStackWithUnreachableBytecodeA.val:"Lcompiler/interpreter/TestVerifyStackWithUnreachableBytecodeB;"; areturn; diff --git a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java index 310fce78f9b..fa15a686a43 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,10 +146,7 @@ public class IntrinsicAvailableTest extends CompilerWhiteBoxTest { if (TIERED_COMPILATION) { checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE); } - // Dont bother check JVMCI compiler - returns false on all intrinsics. - if (!Boolean.valueOf(getVMOption("UseJVMCICompiler"))) { - checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION); - } + checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION); } else { checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE); } diff --git a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java index 7eb1c855f4b..43095027134 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/IntrinsicDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8138651 * - * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * @library /test/lib / * diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java index d2fc3f29a75..29511fc6b38 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java index 374da537619..252ff6ee773 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/AndnTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java index 645fde13534..c2b90f0ec45 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java index 8531f8580c1..b1b65e7088b 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsiTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java index 2509ed281c3..a996d637cff 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java index 33223c595a6..19d622682a7 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java index 2c249db8fd0..e46b8049cda 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java index 4082cd4aa5b..6abf08de8cf 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BlsrTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled & vm.cpu.features ~= ".*avx.*" + * @requires vm.flavor == "server" & vm.cpu.features ~= ".*avx.*" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java index 872fefd883c..8185dda4db1 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @requires vm.simpleArch == "x64" & vm.flavor == "server" & !vm.graal.enabled + * @requires vm.simpleArch == "x64" & vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java index 34f1eb4f3a3..1061d2f09d2 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java index 30cadaf200e..cd16eb9a010 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/LZcntTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java index bc6c1276450..9d8b707bfd5 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java index b5db7b861c3..76ae60683ba 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java +++ b/test/hotspot/jtreg/compiler/intrinsics/bmi/verifycode/TZcntTestL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8031321 - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management diff --git a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java index ff8358c3cd8..82c3ffef9ac 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java +++ b/test/hotspot/jtreg/compiler/intrinsics/klass/CastNullCheckDroppingsTest.java @@ -25,7 +25,7 @@ * @test NullCheckDroppingsTest * @bug 8054492 * @summary Casting can result in redundant null checks in generated code - * @requires vm.hasJFR & vm.flavor == "server" & !vm.graal.enabled & vm.flagless + * @requires vm.hasJFR & vm.flavor == "server" & vm.flagless * * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java b/test/hotspot/jtreg/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java deleted file mode 100644 index 25c0b2a1e72..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.runtime - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true - * -XX:+EnableJVMCI - * compiler.jvmci.JVM_GetJVMCIRuntimeTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false - * -XX:-EnableJVMCI -XX:-UseJVMCICompiler - * compiler.jvmci.JVM_GetJVMCIRuntimeTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true - * -XX:+EnableJVMCI - * compiler.jvmci.JVM_GetJVMCIRuntimeTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=false - * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded=true - * -XX:-EnableJVMCI -XX:-UseJVMCICompiler - * compiler.jvmci.JVM_GetJVMCIRuntimeTest - - */ - -package compiler.jvmci; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.runtime.JVMCI; - -public class JVM_GetJVMCIRuntimeTest implements Runnable { - private static final boolean IS_POSITIVE = Boolean.getBoolean( - "compiler.jvmci.JVM_GetJVMCIRuntimeTest.positive"); - private static final boolean IN_THREAD = Boolean.getBoolean( - "compiler.jvmci.JVM_GetJVMCIRuntimeTest.threaded"); - - public static void main(String[] args) throws Throwable { - JVM_GetJVMCIRuntimeTest instance = new JVM_GetJVMCIRuntimeTest(); - if (IN_THREAD) { - Thread t = new Thread(instance); - t.start(); - t.join(); - } else { - instance.run(); - } - } - - public void run() { - Object result; - try { - result = JVMCI.getRuntime(); - } catch (InternalError e) { - if (IS_POSITIVE) { - throw new AssertionError("unexpected exception", e); - } - return; - } - if (!IS_POSITIVE) { - throw new AssertionError("didn't get expected exception"); - } - Asserts.assertNotNull(result, - "initializeRuntime returned null"); - Asserts.assertEQ(result, JVMCI.getRuntime(), - "initializeRuntime returns different results"); - - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java b/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java deleted file mode 100644 index ed3e0920bf4..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestEnableJVMCIProduct.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8235539 8245717 - * @summary Tests effect of -XX:+EnableJVMCIProduct on EnableJVMCI and UseJVMCICompiler - * @requires vm.flagless - * @requires vm.jvmci - * @library /test/lib - * @run driver TestEnableJVMCIProduct - */ - -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.stream.Collectors; - -public class TestEnableJVMCIProduct { - - static class Expectation { - final String name; - final String value; - final String origin; - final String pattern; - Expectation(final String name, String value, String origin) { - this.name = name; - this.value = value; - this.origin = origin; - this.pattern = "bool +" + name + " += " + value + " +\\{JVMCI product\\} \\{" + origin + "\\}"; - } - } - - public static void main(String[] args) throws Exception { - if (args.length != 0) { - // Called as subprocess. Print system properties named by - // `args[1..]` to the file `args[0]` and then exit. - Files.writeString(Path.of(args[0]), - List.of(args).subList(1, args.length).stream() - .map(a -> "%s=%s".formatted(a, System.getProperty(a))) - .collect(Collectors.joining(","))); - return; - } - // Test EnableJVMCIProduct without any other explicit JVMCI option - test("-XX:-PrintWarnings", - new Expectation("EnableJVMCI", "true", "default"), - new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:+UseJVMCICompiler", - new Expectation("EnableJVMCI", "true", "default"), - new Expectation("UseJVMCICompiler", "true", "command line")); - test("-XX:-UseJVMCICompiler", - new Expectation("EnableJVMCI", "true", "default"), - new Expectation("UseJVMCICompiler", "false", "command line")); - test("-XX:+EnableJVMCI", - new Expectation("EnableJVMCI", "true", "command line"), - new Expectation("UseJVMCICompiler", "true", "default")); - test("-XX:-EnableJVMCI", - new Expectation("EnableJVMCI", "false", "command line"), - new Expectation("UseJVMCICompiler", "false", "default")); - test("-XX:+EnableJVMCIProduct", - new Expectation("EnableJVMCIProduct", "true", "(?:command line|jimage)"), - new Expectation("EnableJVMCI", "true", "default"), - new Expectation("UseJVMCICompiler", "true", "default")); - } - - static int id; - - static void test(String explicitFlag, Expectation... expectations) throws Exception { - String[] flags = {"-XX:+EnableJVMCIProduct", "-XX:+UseGraalJIT"}; - String cwd = System.getProperty("user.dir"); - for (String flag : flags) { - Path propsPath = Path.of("props." + id++); - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", flag, "-XX:-UnlockExperimentalVMOptions", - explicitFlag, - "-XX:+PrintFlagsFinal", - "--class-path=" + System.getProperty("java.class.path"), - "TestEnableJVMCIProduct", propsPath.toString(), "jvmci.Compiler"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - for (Expectation expectation : expectations) { - output.stdoutShouldMatch(expectation.pattern); - } - if (output.getExitValue() != 0) { - // This should only happen when JVMCI compilation is requested and the VM has no - // JVMCI compiler (e.g. Graal is not included in the build) - if (flag.equals("-XX:+UseGraalJIT")) { - output.shouldContain("JVMCI compiler 'graal' specified by jvmci.Compiler not found"); - } else { - output.stdoutShouldMatch("No JVMCI compiler found"); - } - } else if (flag.equals("-XX:+UseGraalJIT")) { - String props = Files.readString(propsPath); - String expect = "jvmci.Compiler=graal"; - if (!props.contains(expect)) { - throw new RuntimeException("\"%s\" does not contain \"%s\"".formatted(props, expect)); - } - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java b/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java deleted file mode 100644 index 0758fd24df0..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestInvalidJVMCIOption.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test TestInvalidJVMCIOption - * @bug 8257220 - * @summary Ensures invalid JVMCI options do not crash the VM with a hs-err log. - * @requires vm.flagless - * @requires vm.jvmci - * @library /test/lib - * @run driver TestInvalidJVMCIOption - */ - -import jdk.test.lib.Asserts; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -public class TestInvalidJVMCIOption { - - public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EagerJVMCI", - "-XX:+UseJVMCICompiler", - "-Djvmci.XXXXXXXXX=true"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - String expectStdout = String.format( - "Error parsing JVMCI options: Could not find option jvmci.XXXXXXXXX%n" + - "Error: A fatal exception has occurred. Program will exit.%n"); - - // Test for containment instead of equality as -XX:+EagerJVMCI means - // the main thread and one or more libjvmci compiler threads - // may initialize libjvmci at the same time and thus the error - // message can appear multiple times. - output.stdoutShouldContain(expectStdout); - - output.stderrShouldBeEmpty(); - output.shouldHaveExitValue(1); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java deleted file mode 100644 index 49066d741ed..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCIPrintProperties.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test TestBasicLogOutput - * @bug 8203370 - * @summary Ensure -XX:+JVMCIPrintProperties successfully prints expected output to stdout. - * @requires vm.flagless - * @requires vm.jvmci - * @library /test/lib - * @run driver TestJVMCIPrintProperties - */ - -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -public class TestJVMCIPrintProperties { - - public static void main(String[] args) throws Exception { - test("-XX:+EnableJVMCI"); - test("-XX:+UseJVMCICompiler"); - } - - static void test(String enableFlag) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - enableFlag, "-Djvmci.Compiler=null", - "-XX:-EagerJVMCI", - "-XX:+JVMCIPrintProperties"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[JVMCI properties]"); // expected message - output.shouldContain("jvmci.Compiler := \"null\""); // expected message - output.shouldContain("jvmci.PrintConfig = false"); // expected message - output.shouldHaveExitValue(0); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java b/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java deleted file mode 100644 index 6d0f87fa0f5..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestJVMCISavedProperties.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test TestJVMCISavedProperties - * @bug 8309390 - * @summary Ensures Services.getSavedProperties() includes properties set on - * the command line as well some specified properties but not - * properties set programmatically. - * @requires vm.flagless - * @requires vm.jvmci - * @library /test/lib - * @run driver TestJVMCISavedProperties - */ - -import jdk.test.lib.Asserts; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; - -public class TestJVMCISavedProperties { - - public static void main(String[] args) throws Exception { - if (args.length != 0) { - System.setProperty("app3.NotPresentInSavedProperties", "42"); - System.out.println("DONE IN MAIN"); - return; - } - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EagerJVMCI", - "-XX:+EnableJVMCI", - "-Ddebug.jvmci.PrintSavedProperties=true", - "-Dapp1.propX=true", - "-Dapp2.propY=SomeStringValue", - "TestJVMCISavedProperties", "true"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.stdoutShouldContain("debug.jvmci.PrintSavedProperties=true"); - output.stdoutShouldContain("app1.propX=true"); - output.stdoutShouldContain("app2.propY=SomeStringValue"); - output.stdoutShouldContain("java.specification.version=" + Runtime.version().feature()); - output.stdoutShouldContain("os.name="); - output.stdoutShouldContain("os.arch="); - output.stdoutShouldNotContain("NotPresentInSavedProperties"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config deleted file mode 100644 index f54fcb0b8dc..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config +++ /dev/null @@ -1 +0,0 @@ -compiler.jvmci.TestUncaughtErrorInCompileMethod$Locator diff --git a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java deleted file mode 100644 index 1c2d07d3255..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @summary Tests handling of an exception thrown by HotSpotJVMCIRuntime.compileMethod. - * Requires a debug VM as it uses test.jvmci.compileMethodExceptionIsFatal - * which is only read in a debug VM. - * @requires vm.jvmci - * @requires vm.debug - * @requires vm.flagless - * @library /test/lib / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.services - * @run driver jdk.test.lib.FileInstaller ./TestUncaughtErrorInCompileMethod.config - * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator - * @run driver compiler.jvmci.TestUncaughtErrorInCompileMethod - */ - -package compiler.jvmci; - -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCICompilerFactory; -import jdk.vm.ci.runtime.JVMCIRuntime; - -import java.io.File; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -public class TestUncaughtErrorInCompileMethod { - - static volatile boolean compilerCreationErrorOccurred; - - /** - * @param args if args.length != 0, then executing in subprocess - */ - public static void main(String[] args) throws Exception { - if (args.length == 0) { - testSubprocess(false); - testSubprocess(true); - } else { - int total = 0; - while (!compilerCreationErrorOccurred) { - // Do some random work to trigger compilation - total += getTime(); - total += String.valueOf(total).hashCode(); - } - System.out.println(total); - } - } - - private static long getTime() { - return System.currentTimeMillis(); - } - - static void testSubprocess(boolean fatalError) throws Exception { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - "-XX:+UseJVMCICompiler", "-Djvmci.Compiler=ErrorCompiler", - "-XX:-UseJVMCINativeLibrary", - "-XX:-TieredCompilation", - "-XX:+PrintCompilation", - "--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED", - "-Dtest.jvmci.compileMethodExceptionIsFatal=" + (fatalError ? "true" : "false"), - "-XX:+PrintWarnings", - "-Xbootclasspath/a:.", - TestUncaughtErrorInCompileMethod.class.getName(), "true"); - Process p = pb.start(); - OutputAnalyzer output = new OutputAnalyzer(p); - - if (!waitForProcess(p)) { - // The subprocess might not enter JVMCI compilation. - // Print the subprocess output and pass the test in this case. - System.out.println(output.getOutput()); - return; - } - - if (fatalError) { - output.shouldContain("testing JVMCI fatal exception handling"); - output.shouldNotHaveExitValue(0); - File hs_err_file = openHsErrFileFromOutput(output); - Path hsErrPath = hs_err_file.toPath(); - if (!Files.exists(hsErrPath)) { - throw new RuntimeException("hs_err_pid file missing at " + hsErrPath); - } - String hsErr = Files.readString(hsErrPath); - - /* - * JVMCI Events (11 events): - * ... - * Event: 0.274 Thread 0x0000000146819210 compiler.jvmci.TestUncaughtErrorInCompileMethod$CompilerCreationError - * Event: 0.274 Thread 0x0000000146819210 at compiler.jvmci.TestUncaughtErrorInCompileMethod$1.createCompiler(TestUncaughtErrorInCompileMethod.java:147) - * Event: 0.274 Thread 0x0000000146819210 at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.getCompiler(HotSpotJVMCIRuntime.java:829) - * Event: 0.274 Thread 0x0000000146819210 at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java:943) - */ - - // Check that hs-err contains the stack trace of the fatal exception (sample shown above) - String[] stackTraceSubstrings = { - "at compiler.jvmci.TestUncaughtErrorInCompileMethod$Locator$1.createCompiler(TestUncaughtErrorInCompileMethod.java", - "at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java" - }; - for (String expect : stackTraceSubstrings) { - if (!hsErr.contains(expect)) { - throw new RuntimeException("Could not find \"" + expect + "\" in " + hsErrPath); - } - } - } else { - output.shouldContain("COMPILE SKIPPED: uncaught exception in call_HotSpotJVMCIRuntime_compileMethod [compiler.jvmci.TestUncaughtErrorInCompileMethod$CompilerCreationError"); - output.shouldHaveExitValue(0); - } - } - - /** - * @return true if {@code p} exited on its own, false if it had to be destroyed - */ - private static boolean waitForProcess(Process p) { - while (true) { - try { - boolean exited = p.waitFor(10, TimeUnit.SECONDS); - if (!exited) { - System.out.println("destroying process: " + p); - p.destroy(); - Thread.sleep(1000); - while (p.isAlive()) { - System.out.println("forcibly destroying process: " + p); - Thread.sleep(1000); - p.destroyForcibly(); - } - return false; - } - return true; - } catch (InterruptedException e) { - e.printStackTrace(System.out); - } - } - } - - public TestUncaughtErrorInCompileMethod() { - } - - static class CompilerCreationError extends InternalError { - CompilerCreationError(int attempt) { - super("attempt " + attempt); - } - } - - public static class Locator extends JVMCIServiceLocator { - - @Override - public S getProvider(Class service) { - if (service == JVMCICompilerFactory.class) { - return service.cast(new JVMCICompilerFactory() { - final AtomicInteger counter = new AtomicInteger(); - @Override - public String getCompilerName() { - return "ErrorCompiler"; - } - - @Override - public JVMCICompiler createCompiler(JVMCIRuntime runtime) { - int attempt = counter.incrementAndGet(); - CompilerCreationError e = new CompilerCreationError(attempt); - e.printStackTrace(); - if (attempt >= 10) { - // Delay notifying the loop in main so that compilation failures - // have time to be reported by -XX:+PrintCompilation. - compilerCreationErrorOccurred = true; - } - throw e; - } - }); - } - return null; - } - } - - /** - * Given the output of a java VM that crashed, extract the name of the hs-err file from the output - */ - public static String extractHsErrFileNameFromOutput(OutputAnalyzer output) { - output.shouldMatch("# A fatal error has been detected.*"); - - // extract hs-err file - String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); - if (hs_err_file == null) { - throw new RuntimeException("Did not find hs-err file in output.\n"); - } - - return hs_err_file; - } - - /** - * Given the output of a java VM that crashed, extract the name of the hs-err file from the output, - * open that file and return its File. - */ - public static File openHsErrFileFromOutput(OutputAnalyzer output) { - String name = extractHsErrFileNameFromOutput(output); - File f = new File(name); - if (!f.exists()) { - throw new RuntimeException("Cannot find hs-err file at " + f.getAbsolutePath()); - } - return f; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java b/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java deleted file mode 100644 index 1e3dc23673b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/TestValidateModules.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8186145 - * @requires vm.jvmci - * @library /test/lib - * @build TestValidateModules jdk.test.lib.process.* - * @run main TestValidateModules - * @summary Ensure java --validate-modules works with --XX:+EnableJVMCI - */ - -import jdk.test.lib.process.ProcessTools; - -public class TestValidateModules { - public static void main(String... args) throws Exception { - ProcessTools.executeTestJava("-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", - "--validate-modules", - "--list-modules") - .outputTo(System.out) - .errorTo(System.out) - .stdoutShouldContain("java.base") - .stdoutShouldContain("jdk.internal.vm.ci") - .shouldHaveExitValue(0); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/CTVMUtilities.java b/test/hotspot/jtreg/compiler/jvmci/common/CTVMUtilities.java deleted file mode 100644 index c98d9944c80..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/CTVMUtilities.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.io.IOException; -import java.lang.classfile.Attributes; -import java.lang.classfile.ClassFile; -import java.lang.classfile.ClassModel; -import java.lang.classfile.MethodModel; -import java.lang.constant.ClassDesc; -import java.lang.constant.ConstantDescs; -import java.lang.constant.MethodTypeDesc; -import java.lang.invoke.MethodType; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -public class CTVMUtilities { - /* - * A method to return HotSpotResolvedJavaMethod object using class object - * and method as input - */ - public static HotSpotResolvedJavaMethod getResolvedMethod(Class cls, - Executable method) { - if (!(method instanceof Method || method instanceof Constructor)) { - throw new Error("wrong executable type " + method.getClass()); - } - return CompilerToVMHelper.asResolvedJavaMethod(method); - } - - public static HotSpotResolvedJavaMethod getResolvedMethod( - Executable method) { - return getResolvedMethod(method.getDeclaringClass(), method); - } - - public static InstalledCode getInstalledCode(ResolvedJavaMethod method, String name, long address, long entryPoint) { - return CompilerToVMHelper.getInstalledCode(method, name, address, entryPoint); - } - - public static Map getBciToLineNumber(Executable method) { - ClassModel classModel = findClassBytes(method.getDeclaringClass()); - MethodModel methodModel = findMethod(classModel, method); - if (methodModel == null) - return Map.of(); - - var foundLineNumberTable = methodModel.code().flatMap(code -> - code.findAttribute(Attributes.lineNumberTable())); - if (foundLineNumberTable.isEmpty()) { - boolean isEmptyMethod = Modifier.isAbstract(method.getModifiers()) - || Modifier.isNative(method.getModifiers()); - if (!isEmptyMethod) { - throw new Error(method + " doesn't contains the line numbers table " - + "(the method marked neither abstract nor native)"); - } - return Map.of(); - } - - Map lineNumbers = new TreeMap<>(); - foundLineNumberTable.get().lineNumbers().forEach(ln -> - lineNumbers.put(ln.startPc(), ln.lineNumber())); - return lineNumbers; - } - - // Finds the ClassFile API model of a given class, or fail with an Error. - public static ClassModel findClassBytes(Class clazz) { - String binaryName = clazz.getName(); - byte[] fileBytes; - try (var inputStream = clazz.getModule().getResourceAsStream( - binaryName.replace('.', '/') + ".class")) { - fileBytes = inputStream.readAllBytes(); - } catch (IOException e) { - throw new Error("TEST BUG: cannot read " + binaryName, e); - } - return ClassFile.of().parse(fileBytes); - } - - // Finds a matching method in a class model, or null if none match. - public static MethodModel findMethod(ClassModel classModel, Executable method) { - MethodTypeDesc methodType = MethodType.methodType( - method instanceof Method m ? m.getReturnType() : void.class, - method.getParameterTypes()).describeConstable().orElseThrow(); - String methodName = method instanceof Method m ? m.getName() : ConstantDescs.INIT_NAME; - - for (var methodModel : classModel.methods()) { - if (methodModel.methodName().equalsString(methodName) - && methodModel.methodType().isMethodType(methodType)) { - return methodModel; - } - } - return null; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/CodeInstallerTest.java b/test/hotspot/jtreg/compiler/jvmci/common/CodeInstallerTest.java deleted file mode 100644 index 1fc49c93ac8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/CodeInstallerTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common; - -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.hotspot.HotSpotCompiledCode; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotCompiledNmethod; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.runtime.JVMCI; -import jdk.vm.ci.runtime.JVMCIBackend; -import org.junit.Assert; - -import java.lang.reflect.Method; - -public class CodeInstallerTest { - - protected final Architecture arch; - protected final CodeCacheProvider codeCache; - protected final MetaAccessProvider metaAccess; - protected final HotSpotConstantReflectionProvider constantReflection; - - protected final HotSpotResolvedJavaMethod dummyMethod; - - public static void dummyMethod() { - } - - protected CodeInstallerTest() { - JVMCIBackend backend = JVMCI.getRuntime().getHostJVMCIBackend(); - metaAccess = backend.getMetaAccess(); - codeCache = backend.getCodeCache(); - constantReflection = (HotSpotConstantReflectionProvider) backend.getConstantReflection(); - arch = codeCache.getTarget().arch; - - Method method = null; - try { - method = CodeInstallerTest.class.getMethod("dummyMethod"); - } catch (NoSuchMethodException e) { - Assert.fail(); - } - - dummyMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); - } - - protected InstalledCode installEmptyCode(Site[] sites, - Assumption[] assumptions, - Comment[] comments, - int dataSectionAlignment, - DataPatch[] dataSectionPatches, - StackSlot deoptRescueSlot) { - ResolvedJavaMethod[] methods = {dummyMethod}; - byte[] targetCode = {0}; - int targetCodeSize = targetCode.length; - boolean isImmutablePIC = false; - int totalFrameSize = 0; - int entryBCI = 0; - int id = 1; - long compileState = 0L; - boolean hasUnsafeAccess = false; - - HotSpotCompiledCode code = - new HotSpotCompiledNmethod("dummyMethod", - targetCode, - targetCodeSize, - sites, - assumptions, - methods, - comments, - new byte[8], - dataSectionAlignment, - dataSectionPatches, - isImmutablePIC, - totalFrameSize, - deoptRescueSlot, - dummyMethod, - entryBCI, - id, - compileState, - hasUnsafeAccess); - SpeculationLog log = null; - InstalledCode installedCode = null; - return codeCache.addCode(dummyMethod, code, log, installedCode, true); - } - - protected Register getRegister(PlatformKind kind, int index) { - int idx = index; - for (Register reg : arch.getAvailableValueRegisters()) { - if (arch.canStoreValue(reg.getRegisterCategory(), kind)) { - if (idx-- == 0) { - return reg; - } - } - } - return null; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/JVMCIHelpers.java b/test/hotspot/jtreg/compiler/jvmci/common/JVMCIHelpers.java deleted file mode 100644 index 00c8b164c6a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/JVMCIHelpers.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common; - -import jdk.vm.ci.code.CompilationRequest; -import jdk.vm.ci.code.CompilationRequestResult; -import jdk.vm.ci.hotspot.HotSpotVMEventListener; -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.runtime.JVMCICompilerFactory; - -/* - * A stub classes to be able to use jvmci - */ -public class JVMCIHelpers extends JVMCIServiceLocator { - - @Override - public S getProvider(Class service) { - if (service == JVMCICompilerFactory.class) { - return service.cast(new EmptyCompilerFactory()); - } - if (service == HotSpotVMEventListener.class) { - return service.cast(new EmptyVMEventListener()); - } - return null; - } - - public static class EmptyVMEventListener implements HotSpotVMEventListener { - // just empty, using default interface methods - } - - public static class EmptyCompilationRequestResult implements CompilationRequestResult { - @Override - public Object getFailure() { - return "no compiler configured"; - } - } - public static class EmptyHotspotCompiler implements JVMCICompiler { - - @Override - public CompilationRequestResult compileMethod(CompilationRequest request) { - // do nothing - return new EmptyCompilationRequestResult(); - } - } - - public static class EmptyCompilerFactory implements JVMCICompilerFactory { - - @Override - public String getCompilerName() { - return "EmptyCompiler"; - } - - @Override - public JVMCICompiler createCompiler(JVMCIRuntime runtime) { - return new EmptyHotspotCompiler(); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java deleted file mode 100644 index d4c04ffb742..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/CompilerToVMHelper.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.stack.InspectedFrameVisitor; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.runtime.JVMCI; -import java.lang.reflect.Executable; - -/** - * A simple "proxy" class to get test access to CompilerToVM package-private methods - */ -public class CompilerToVMHelper { - public static final CompilerToVM CTVM = new CompilerToVM(); - private static final MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - public static byte[] getBytecode(HotSpotResolvedJavaMethod method) { - return CTVM.getBytecode((HotSpotResolvedJavaMethodImpl)method); - } - - public static int getExceptionTableLength(HotSpotResolvedJavaMethod method) { - return CTVM.getExceptionTableLength((HotSpotResolvedJavaMethodImpl)method); - } - - public static long getExceptionTableStart(HotSpotResolvedJavaMethod method) { - return CTVM.getExceptionTableStart((HotSpotResolvedJavaMethodImpl)method); - } - - public static Object getFlagValue(String name) { - return CTVM.getFlagValue(name); - } - - public static boolean isCompilable(HotSpotResolvedJavaMethod method) { - return CTVM.isCompilable((HotSpotResolvedJavaMethodImpl)method); - } - - public static boolean hasNeverInlineDirective(HotSpotResolvedJavaMethod method) { - return CTVM.hasNeverInlineDirective((HotSpotResolvedJavaMethodImpl)method); - } - - public static boolean shouldInlineMethod(HotSpotResolvedJavaMethod method) { - return CTVM.shouldInlineMethod((HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedJavaMethod findUniqueConcreteMethod( - HotSpotResolvedObjectType actualHolderType, - HotSpotResolvedJavaMethod method) { - return CTVM.findUniqueConcreteMethod((HotSpotResolvedObjectTypeImpl) actualHolderType, (HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedObjectType getImplementor(HotSpotResolvedObjectType type) { - return CTVM.getImplementor((HotSpotResolvedObjectTypeImpl) type); - } - - public static boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethod method) { - return CTVM.methodIsIgnoredBySecurityStackWalk((HotSpotResolvedJavaMethodImpl)method); - } - - public static HotSpotResolvedObjectType lookupType(String name, - Class accessClass, boolean resolve) throws NoClassDefFoundError { - if (accessClass == null) { - throw new NullPointerException(); - } - HotSpotResolvedObjectTypeImpl accessingClass = (HotSpotResolvedObjectTypeImpl) metaAccess.lookupJavaType(accessClass); - return (HotSpotResolvedObjectType) CTVM.lookupType(name, accessingClass, resolve); - } - - public static HotSpotResolvedObjectType lookupTypeHelper(String name, - Class accessingClass, boolean resolve) { - return lookupType(name, accessingClass, resolve); - } - - public static Object lookupConstantInPool(ConstantPool constantPool, int cpi, boolean resolve) { - DirectHotSpotObjectConstantImpl obj = (DirectHotSpotObjectConstantImpl) CTVM.lookupConstantInPool((HotSpotConstantPool) constantPool, cpi, resolve); - return obj.object; - } - - public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int rawIndex, int opcode) { - return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, rawIndex, opcode); - } - - public static String lookupNameInPool(ConstantPool constantPool, int rawIndex, int opcode) { - return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, rawIndex, opcode); - } - - public static String lookupSignatureInPool(ConstantPool constantPool, int rawIndex, int opcode) { - return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, rawIndex, opcode); - } - - public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int rawIndex, int opcode) { - return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, rawIndex, opcode); - } - - public static Object lookupKlassInPool(ConstantPool constantPool, int cpi) { - return CTVM.lookupKlassInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedJavaMethod lookupMethodInPool( - ConstantPool constantPool, int cpi, byte opcode) { - HotSpotResolvedJavaMethodImpl caller = null; - return CTVM.lookupMethodInPool((HotSpotConstantPool) constantPool, cpi, opcode, null); - } - - public static void resolveInvokeHandleInPool( - ConstantPool constantPool, int cpi) { - CTVM.resolveInvokeHandleInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedObjectType resolveTypeInPool( - ConstantPool constantPool, int cpi) { - return CTVM.resolveTypeInPool((HotSpotConstantPool) constantPool, cpi); - } - - public static HotSpotResolvedObjectType resolveFieldInPool( - ConstantPool constantPool, int cpi, ResolvedJavaMethod method, byte opcode, int[] info) { - return CTVM.resolveFieldInPool((HotSpotConstantPool) constantPool, cpi, (HotSpotResolvedJavaMethodImpl) method, opcode, info); - } - - public static Object lookupAppendixInPool( - ConstantPool constantPool, int cpi, int opcode) { - return CTVM.lookupAppendixInPool((HotSpotConstantPool) constantPool, cpi, opcode); - } - - public static int installCode(TargetDescription target, - HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog) { - byte[] speculations; - long failedSpeculationsAddress; - if (speculationLog != null) { - speculations = speculationLog.getFlattenedSpeculations(true); - failedSpeculationsAddress = speculationLog.getFailedSpeculationsAddress(); - } else { - speculations = new byte[0]; - failedSpeculationsAddress = 0L; - } - return CTVM.installCode(compiledCode, code, failedSpeculationsAddress, speculations); - } - - public static void resetCompilationStatistics() { - CTVM.resetCompilationStatistics(); - } - - public static Object[] readConfiguration() { - return CTVM.readConfiguration(); - } - - public static HotSpotResolvedJavaMethod resolveMethod( - HotSpotResolvedObjectType exactReceiver, - HotSpotResolvedJavaMethod method, - HotSpotResolvedObjectType caller) { - return CTVM.resolveMethod((HotSpotResolvedObjectTypeImpl) exactReceiver, (HotSpotResolvedJavaMethodImpl) method, (HotSpotResolvedObjectTypeImpl) caller); - } - - public static HotSpotResolvedJavaMethod getClassInitializer( - HotSpotResolvedObjectType type) { - return CTVM.getClassInitializer((HotSpotResolvedObjectTypeImpl) type); - } - - public static boolean hasFinalizableSubclass(HotSpotResolvedObjectType type) { - return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type); - } - - public static HotSpotResolvedJavaMethodImpl asResolvedJavaMethod( - Executable executable) { - return CTVM.asResolvedJavaMethod(executable); - } - - public static long getMaxCallTargetOffset(long address) { - return CTVM.getMaxCallTargetOffset(address); - } - - public static String disassembleCodeBlob(InstalledCode codeBlob) { - return CTVM.disassembleCodeBlob(codeBlob); - } - - public static StackTraceElement getStackTraceElement( - HotSpotResolvedJavaMethod method, int bci) { - return CTVM.getStackTraceElement((HotSpotResolvedJavaMethodImpl)method, bci); - } - - public static Object executeHotSpotNmethod(Object[] args, - HotSpotNmethod nmethodMirror) throws InvalidInstalledCodeException { - return CTVM.executeHotSpotNmethod(args, nmethodMirror); - } - - public static long[] getLineNumberTable(HotSpotResolvedJavaMethod method) { - return CTVM.getLineNumberTable((HotSpotResolvedJavaMethodImpl)method); - } - - public static int getLocalVariableTableLength(HotSpotResolvedJavaMethod method) { - return CTVM.getLocalVariableTableLength((HotSpotResolvedJavaMethodImpl)method); - } - - public static long getLocalVariableTableStart(HotSpotResolvedJavaMethod method) { - return CTVM.getLocalVariableTableStart((HotSpotResolvedJavaMethodImpl)method); - } - - public static void setNotInlinableOrCompilable(HotSpotResolvedJavaMethod method) { - CTVM.setNotInlinableOrCompilable((HotSpotResolvedJavaMethodImpl)method); - } - - public static void reprofile(HotSpotResolvedJavaMethod method) { - CTVM.reprofile((HotSpotResolvedJavaMethodImpl)method); - } - - public static void invalidateHotSpotNmethod(HotSpotNmethod nmethodMirror, boolean deoptimize, int invalidationReason) { - CTVM.invalidateHotSpotNmethod(nmethodMirror, deoptimize, invalidationReason); - } - - public static long[] collectCounters() { - return CTVM.collectCounters(); - } - - public static boolean isMature(long metaspaceMethodData) { - return CTVM.isMature(metaspaceMethodData); - } - - public static int allocateCompileId(HotSpotResolvedJavaMethod method, - int entryBCI) { - return CTVM.allocateCompileId((HotSpotResolvedJavaMethodImpl) method, entryBCI); - } - - public static boolean hasCompiledCodeForOSR( - HotSpotResolvedJavaMethod method, int entryBCI, int level) { - return CTVM.hasCompiledCodeForOSR((HotSpotResolvedJavaMethodImpl) method, entryBCI, level); - } - - public static String getSymbol(long metaspaceSymbol) { - return CTVM.getSymbol(metaspaceSymbol); - } - - public static T iterateFrames( - ResolvedJavaMethod[] initialMethods, - ResolvedJavaMethod[] matchingMethods, - int initialSkip, - InspectedFrameVisitor visitor) { - return CTVM.iterateFrames(initialMethods, matchingMethods, initialSkip, visitor); - } - - public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectType type, - HotSpotResolvedJavaMethod method) { - return CTVM.getVtableIndexForInterfaceMethod((HotSpotResolvedObjectTypeImpl) type, (HotSpotResolvedJavaMethodImpl) method); - } - - public static boolean shouldDebugNonSafepoints() { - return CTVM.shouldDebugNonSafepoints(); - } - - public static void flushDebugOutput() { - CTVM.flushDebugOutput(); - } - - public static HotSpotResolvedJavaMethod getResolvedJavaMethod(HotSpotObjectConstantImpl base, - long displacement) { - return CTVM.getResolvedJavaMethod(base, displacement); - } - - public static HotSpotConstantPool getConstantPool(MetaspaceObject object) { - return CTVM.getConstantPool(object); - } - - public static long getMetaspacePointer(Object o) { - return ((MetaspaceObject) o).getMetaspacePointer(); - } - - public static Class CompilerToVMClass() { - return CompilerToVM.class; - } - - public static JavaConstant getJavaMirror(HotSpotResolvedObjectType type) { - return ((HotSpotResolvedJavaType) type).getJavaMirror(); - } - - public static HotSpotResolvedObjectType fromObjectClass(Class theClass) { - return (HotSpotResolvedObjectType) metaAccess.lookupJavaType(theClass); - } - - public static InstalledCode getInstalledCode(ResolvedJavaMethod method, String name, long address, long entryPoint) { - return new InstalledCodeStub((HotSpotResolvedJavaMethodImpl) method, name, address, entryPoint); - } - private static class InstalledCodeStub extends HotSpotNmethod { - private InstalledCodeStub(HotSpotResolvedJavaMethodImpl method, String name, long address, long entryPoint) { - super(method, name, false, true, 0); - this.address = address; - this.entryPoint = entryPoint; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldHelper.java b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldHelper.java deleted file mode 100644 index d83d6e972bd..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldHelper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; - -public class HotSpotResolvedJavaFieldHelper { - public static ResolvedJavaField createField(HotSpotResolvedObjectTypeImpl holder, JavaType type, int offset, int modifiers, int internalModifiers, int index) { - return new HotSpotResolvedJavaFieldImpl(holder, type, offset, modifiers, internalModifiers, index); - } - - public static int getIndex(ResolvedJavaField field) { - return ((HotSpotResolvedJavaFieldImpl) field).getIndex(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/MetaAccessWrapper.java b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/MetaAccessWrapper.java deleted file mode 100644 index d1aec4ed9f8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/MetaAccessWrapper.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -import jdk.vm.ci.meta.JVMCIMetaAccessContext; -import jdk.vm.ci.meta.ResolvedJavaType; - -/* - * A JVMCIMetaAccessContext wrapper class to mark context - * being provided/returned - */ -public class MetaAccessWrapper implements JVMCIMetaAccessContext { - private static final HotSpotJVMCIMetaAccessContext CONTEXT - = new HotSpotJVMCIMetaAccessContext(); - @Override - public ResolvedJavaType fromClass(Class clazz) { - return CONTEXT.fromClass(clazz); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java b/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java deleted file mode 100644 index 5d84630ea1b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/patches/jdk.internal.vm.ci/jdk/vm/ci/hotspot/PublicMetaspaceWrapperObject.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot; - -/** - * A public available version of MetaspaceWrapperObject interface. - */ -public interface PublicMetaspaceWrapperObject extends MetaspaceHandleObject { } diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClass.java deleted file mode 100644 index ebe39ce33c7..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClass.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public abstract class AbstractClass { - public static final long initTime = System.currentTimeMillis(); - public abstract void abstractMethod(); -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClassExtender.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClassExtender.java deleted file mode 100644 index 595ff289119..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AbstractClassExtender.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class AbstractClassExtender extends AbstractClass { - @Override - public void abstractMethod() { - // empty - } - - @SuppressWarnings("removal") - @Override - protected void finalize() throws Throwable { - super.finalize(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementer.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementer.java deleted file mode 100644 index ca42a7c327f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class AnotherSingleImplementer implements AnotherSingleImplementerInterface { - - @Override - public void interfaceMethod() { - // empty - } - - public void nonInterfaceMethod() { - // empty - } - - @SuppressWarnings("removal") - @Override - public void finalize() throws Throwable { - super.finalize(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementerInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementerInterface.java deleted file mode 100644 index 52e66b1a341..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/AnotherSingleImplementerInterface.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface AnotherSingleImplementerInterface { - public static final long initTime = System.currentTimeMillis(); - - default void defaultMethod() { - // empty - } - - void interfaceMethod(); - - void finalize() throws Throwable; -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotExtendClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotExtendClass.java deleted file mode 100644 index 97e27bf5003..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotExtendClass.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class DoNotExtendClass { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotImplementInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotImplementInterface.java deleted file mode 100644 index fb721a35df4..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DoNotImplementInterface.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface DoNotImplementInterface { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DuplicateSimpleSingleImplementerInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/DuplicateSimpleSingleImplementerInterface.java deleted file mode 100644 index 03f18e92a70..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/DuplicateSimpleSingleImplementerInterface.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface DuplicateSimpleSingleImplementerInterface { - void interfaceMethod(); -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClass.java deleted file mode 100644 index 080b1ec61b2..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClass.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class MultiSubclassedClass { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass1.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass1.java deleted file mode 100644 index d1b25ddca07..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass1.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class MultiSubclassedClassSubclass1 extends MultiSubclassedClass { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass2.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass2.java deleted file mode 100644 index f39564e4543..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultiSubclassedClassSubclass2.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class MultiSubclassedClassSubclass2 extends MultiSubclassedClass { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleAbstractImplementer.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleAbstractImplementer.java deleted file mode 100644 index e3b211e8f6a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleAbstractImplementer.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -import java.util.HashMap; -import java.util.Map; - -public abstract class MultipleAbstractImplementer - implements MultipleImplementersInterface { - - // Different access levels on the fields of this class are used on purpose. - // It is needed to verify jdk.vm.ci.CompilerToVM constant pool related - // methods, e.g. resolveFieldInPool. - - private static int intStaticField = INT_CONSTANT; - final static long longStaticField = LONG_CONSTANT; - volatile static float floatStaticField = FLOAT_CONSTANT; - static double doubleStaticField = DOUBLE_CONSTANT; - public static String stringStaticField = STRING_CONSTANT; - protected static Object objectStaticField = OBJECT_CONSTANT; - - public int intField = INT_CONSTANT; - private long longField = LONG_CONSTANT; - protected float floatField = FLOAT_CONSTANT; - transient double doubleField = DOUBLE_CONSTANT; - volatile String stringField = STRING_CONSTANT; - String stringFieldEmpty = ""; - final Object objectField; - - public MultipleAbstractImplementer() { - intField = Integer.MAX_VALUE; - longField = Long.MAX_VALUE; - floatField = Float.MAX_VALUE; - doubleField = Double.MAX_VALUE; - stringField = "Message"; - objectField = new Object(); - } - - public abstract void abstractMethod(); - - @SuppressWarnings("removal") - @Override - public void finalize() throws Throwable { - super.finalize(); - } - - public void lambdaUsingMethod2() { - Thread t = new Thread(this::testMethod); - t.start(); - } - - /** - * This method is needed to have "getstatic" and "getfield" instructions - * in the class. These instructions are needed to test - * resolveFieldInPool method, because it needs a bytecode as one of its arguments. - */ - public void printFileds() { - System.out.println(intStaticField); - System.out.println(longStaticField); - System.out.println(floatStaticField); - System.out.println(doubleStaticField); - System.out.println(stringStaticField); - System.out.println(objectStaticField); - System.out.println(intField); - System.out.println(longField); - System.out.println(floatField); - System.out.println(doubleField); - System.out.println(stringField); - System.out.println(stringFieldEmpty); - System.out.println(objectField); - } - - public static void staticMethod() { - System.getProperties(); // calling some static method - Map map = new HashMap(); // calling some constructor - map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method - map.remove(OBJECT_CONSTANT); // calling some default interface method - } - - @Override - public void instanceMethod() { - toString(); // calling some virtual method - super.toString(); // calling some special method - } - - @Override - public void anonClassMethod() { - new Runnable() { - @Override - public void run() { - System.out.println("Running"); - } - }.run(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer1.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer1.java deleted file mode 100644 index 00004386c33..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer1.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class MultipleImplementer1 implements MultipleImplementersInterface { - - @Override - public void defaultMethod() { - // empty - } - - @Override - public void testMethod() { - // empty - } - - @SuppressWarnings("removal") - @Override - public void finalize() throws Throwable { - super.finalize(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer2.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer2.java deleted file mode 100644 index f091a75aa38..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementer2.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -import java.util.HashMap; -import java.util.Map; - -public class MultipleImplementer2 implements MultipleImplementersInterface { - - // Different access levels on the fields of this class are used on purpose. - // It is needed to verify jdk.vm.ci.CompilerToVM constant pool related - // methods, e.g. resolveFieldInPool. - - private static int intStaticField = INT_CONSTANT; - final static long longStaticField = LONG_CONSTANT; - volatile static float floatStaticField = FLOAT_CONSTANT; - static double doubleStaticField = DOUBLE_CONSTANT; - public static String stringStaticField = STRING_CONSTANT; - protected static Object objectStaticField = OBJECT_CONSTANT; - - public int intField = INT_CONSTANT; - private long longField = LONG_CONSTANT; - protected float floatField = FLOAT_CONSTANT; - transient double doubleField = DOUBLE_CONSTANT; - volatile String stringField = STRING_CONSTANT; - String stringFieldEmpty = ""; - final Object objectField; - - public MultipleImplementer2() { - intField = Integer.MAX_VALUE; - longField = Long.MAX_VALUE; - floatField = Float.MAX_VALUE; - doubleField = Double.MAX_VALUE; - stringField = "Message"; - objectField = new Object(); - } - - @Override - public void testMethod() { - // empty - } - - @SuppressWarnings("removal") - @Override - public void finalize() throws Throwable { - super.finalize(); - } - - public void lambdaUsingMethod2() { - Thread t = new Thread(this::testMethod); - t.start(); - } - - /** - * This method is needed to have "getstatic" and "getfield" instructions - * in the class. These instructions are needed to test - * resolveFieldInPool method, because it needs a bytecode as one of its arguments. - */ - public void printFileds() { - System.out.println(intStaticField); - System.out.println(longStaticField); - System.out.println(floatStaticField); - System.out.println(doubleStaticField); - System.out.println(stringStaticField); - System.out.println(objectStaticField); - System.out.println(intField); - System.out.println(longField); - System.out.println(floatField); - System.out.println(doubleField); - System.out.println(stringField); - System.out.println(stringFieldEmpty); - System.out.println(objectField); - } - - public static void staticMethod() { - System.getProperties(); // calling some static method - Map map = new HashMap(); // calling some constructor - map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method - map.remove(OBJECT_CONSTANT); // calling some default interface method - } - - @Override - public void instanceMethod() { - toString(); // calling some virtual method - super.toString(); // calling some special method - } - - @Override - public void anonClassMethod() { - new Runnable() { - @Override - public void run() { - System.out.println("Running"); - } - }.run(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterface.java deleted file mode 100644 index 2c721809b59..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterface.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -import java.util.HashMap; -import java.util.Map; - -public interface MultipleImplementersInterface { - - int INT_CONSTANT = Integer.MAX_VALUE; - long LONG_CONSTANT = Long.MAX_VALUE; - float FLOAT_CONSTANT = Float.MAX_VALUE; - double DOUBLE_CONSTANT = Double.MAX_VALUE; - String STRING_CONSTANT = "Hello"; - Object OBJECT_CONSTANT = new Object(); - - default void defaultMethod() { - // empty - } - - void testMethod(); - - @SuppressWarnings("removal") - default void finalize() throws Throwable { - // empty - } - - default void lambdaUsingMethod() { - Thread t = new Thread(this::defaultMethod); - t.start(); - } - - default void printFields() { - System.out.println(OBJECT_CONSTANT); - String s = ""; - System.out.println(s); - } - - static void staticMethod() { - System.getProperties(); // calling some static method - Map map = new HashMap(); // calling some constructor - map.put(OBJECT_CONSTANT, OBJECT_CONSTANT); // calling some interface method - map.remove(OBJECT_CONSTANT); // calling some default interface method - } - - default void instanceMethod() { - toString(); // calling some virtual method - } - - default void anonClassMethod() { - new Runnable() { - @Override - public void run() { - System.out.println("Running"); - } - }.run(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterfaceExtender.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterfaceExtender.java deleted file mode 100644 index 5091a4bc382..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleImplementersInterfaceExtender.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface MultipleImplementersInterfaceExtender - extends MultipleImplementersInterface { - // provide default implementation for parent interface - @Override - default void testMethod() { - // empty - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleSuperImplementers.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleSuperImplementers.java deleted file mode 100644 index d4aeee57f27..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/MultipleSuperImplementers.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public abstract class MultipleSuperImplementers implements DuplicateSimpleSingleImplementerInterface, SimpleSingleImplementerInterface { - @SuppressWarnings("removal") - public void finalize() { - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/PackagePrivateClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/PackagePrivateClass.java deleted file mode 100644 index 25099b28e80..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/PackagePrivateClass.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -class PackagePrivateClass { - // empty -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleClass.java deleted file mode 100644 index e2b4172e25c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -// just a most common simple class with method "testMethod" to use anywhere -public class SimpleClass { - - public void testMethod() { - // empty - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleSingleImplementerInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleSingleImplementerInterface.java deleted file mode 100644 index 4f03bbb761c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SimpleSingleImplementerInterface.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface SimpleSingleImplementerInterface { - void interfaceMethod(); -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementer.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementer.java deleted file mode 100644 index 84e71ff7943..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class SingleImplementer implements SingleImplementerInterface { - public static final long initTime = System.currentTimeMillis(); - - @Override - public void interfaceMethod() { - // empty - } - - public void nonInterfaceMethod() { - // empty - } - @SuppressWarnings("removal") - @Override - public void finalize() throws Throwable { - super.finalize(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementerInterface.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementerInterface.java deleted file mode 100644 index 6e547dd9ca8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleImplementerInterface.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public interface SingleImplementerInterface { - public static final long initTime = System.currentTimeMillis(); - - default void defaultMethod() { - // empty - } - - void interfaceMethod(); - - void finalize() throws Throwable; -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclass.java deleted file mode 100644 index 86eca3fb4a2..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclass.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class SingleSubclass extends SingleSubclassedClass { - public void usualMethod() { - // empty - } - - @Override - public void overridenMethod() { - // empty - } - - private void privateMethod() { - // empty - } - - public static void staticMethod() { - // empty - } - - protected void protectedMethod() { - // empty - } - - void defaultAccessMethod() { - // empty - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclassedClass.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclassedClass.java deleted file mode 100644 index 215c3ed36cd..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/SingleSubclassedClass.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -public class SingleSubclassedClass { - public void inheritedMethod() { - // empty - } - - public void overridenMethod() { - //empty - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/common/testcases/TestCase.java b/test/hotspot/jtreg/compiler/jvmci/common/testcases/TestCase.java deleted file mode 100644 index 6b69b1b773b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/common/testcases/TestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.common.testcases; - -import java.lang.reflect.Executable; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * A test case for tests in compiler.jvmci.compilerToVM package. - */ -public class TestCase { - private static final Class[] CLASSES = { - AbstractClass.class, - AbstractClassExtender.class, - AnotherSingleImplementer.class, - AnotherSingleImplementerInterface.class, - DoNotExtendClass.class, - DoNotImplementInterface.class, - MultipleAbstractImplementer.class, - MultipleImplementer1.class, - MultipleImplementer2.class, - MultipleImplementersInterface.class, - MultipleImplementersInterfaceExtender.class, - MultiSubclassedClass.class, - MultiSubclassedClassSubclass1.class, - MultiSubclassedClassSubclass2.class, - PackagePrivateClass.class, - SimpleClass.class, - SingleImplementer.class, - SingleImplementerInterface.class, - SingleSubclass.class, - SingleSubclassedClass.class - }; - - public static Collection> getAllClasses() { - return Arrays.asList(CLASSES); - } - - public static Collection getAllExecutables() { - Set result = new HashSet<>(); - for (Class aClass : CLASSES) { - result.addAll(Arrays.asList(aClass.getMethods())); - result.addAll(Arrays.asList(aClass.getConstructors())); - } - return result; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java deleted file mode 100644 index a963d5e196d..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @key randomness - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.test.whitebox.WhiteBox jdk.test.whitebox.parser.DiagnosticCommand - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * jdk.test.whitebox.parser.DiagnosticCommand - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-BackgroundCompilation - * compiler.jvmci.compilerToVM.AllocateCompileIdTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.test.lib.util.Pair; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.code.NMethod; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class AllocateCompileIdTest { - - private static final int SOME_REPEAT_VALUE = 5; - private final HashSet ids = new HashSet<>(); - - public static void main(String[] args) { - AllocateCompileIdTest test = new AllocateCompileIdTest(); - createTestCasesCorrectBci().forEach(test::runSanityCorrectTest); - createTestCasesIncorrectBci().forEach(test::runSanityIncorrectTest); - } - - private static List createTestCasesCorrectBci() { - List result = new ArrayList<>(); - try { - Class aClass = DummyClass.class; - Method method = aClass.getMethod("withLoop"); - Object receiver = new DummyClass(); - result.add(new CompileCodeTestCase(receiver, method, 17)); - result.add(new CompileCodeTestCase(receiver, method, -1)); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG : " + e, e); - } - return result; - } - - private static List>> - createTestCasesIncorrectBci() { - List>> result - = new ArrayList<>(); - try { - Class aClass = DummyClass.class; - Object receiver = new DummyClass(); - Method method = aClass.getMethod("dummyInstanceFunction"); - // greater than bytecode.length - byte[] bytecode = CompilerToVMHelper.getBytecode(CTVMUtilities - .getResolvedMethod(method)); - Stream.of( - // greater than bytecode.length - bytecode.length + 4, - bytecode.length + 50, - bytecode.length + 200, - // negative cases - -4, -50, -200) - .map(bci -> new Pair>( - new CompileCodeTestCase(receiver, method, bci), - IllegalArgumentException.class)) - .collect(Collectors.toList()); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG : " + e.getMessage(), e); - } - return result; - } - - private void runSanityCorrectTest(CompileCodeTestCase testCase) { - System.out.println(testCase); - Executable aMethod = testCase.executable; - // to generate ciTypeFlow - testCase.invoke(Utils.getNullValues(aMethod.getParameterTypes())); - int bci = testCase.bci; - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - for (int i = 0; i < SOME_REPEAT_VALUE; ++i) { - int wbCompileID = getWBCompileID(testCase); - int id = CompilerToVMHelper.allocateCompileId(method, bci); - Asserts.assertNE(id, 0, testCase + " : zero compile id"); - Asserts.assertGT(id, wbCompileID, testCase - + " : allocated 'compile id' not greater than existed"); - Asserts.assertTrue(ids.add(wbCompileID), testCase - + " : vm compilation allocated existing id " + id); - Asserts.assertTrue(ids.add(id), testCase - + " : allocateCompileId returned existing id " + id); - } - } - - private void runSanityIncorrectTest( - Pair> testCase) { - System.out.println(testCase); - Class exception = testCase.second; - Executable aMethod = testCase.first.executable; - int bci = testCase.first.bci; - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - Utils.runAndCheckException( - () -> CompilerToVMHelper.allocateCompileId(method, bci), - exception); - } - - private int getWBCompileID(CompileCodeTestCase testCase) { - NMethod nm = testCase.deoptimizeAndCompile(); - if (nm == null || nm.compile_id <= 0) { - throw new Error("TEST BUG : cannot compile method " + testCase); - } - return nm.compile_id; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java deleted file mode 100644 index d79432fa5c6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/AsResolvedJavaMethodTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.AsResolvedJavaMethodTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.util.Arrays; -import java.util.ArrayList; -import java.util.List; - -public class AsResolvedJavaMethodTest { - - private static class A { - { - System.out.println("Dummy"); - } - public void f1() {} - public int f2() { return 0; } - public String f3() { return ""; } - } - - - private static class S { - static { - System.out.println("Dummy static"); - } - public S() {} - public void f1() {} - public int f2() { return 0; } - public String f3() { return ""; } - } - - private class B extends A { - public void f4() {} - } - - private interface I { - void f1(); - int f2(); - String f3(); - } - - public static void main(String[] args) { - List> testCases = getTestCases(); - testCases.forEach(AsResolvedJavaMethodTest::test); - } - - private static List> getTestCases() { - List> testCases = new ArrayList<>(); - testCases.add(A.class); - testCases.add(S.class); - testCases.add(I.class); - testCases.add(B.class); - return testCases; - } - - private static void test(Class aClass) { - testCorrectMethods(aClass); - } - - private static void testCorrectMethods(Class holder) { - List executables = new ArrayList<>(); - executables.addAll(Arrays.asList(holder.getDeclaredMethods())); - executables.addAll(Arrays.asList(holder.getDeclaredConstructors())); - for (Executable executable : executables) { - HotSpotResolvedJavaMethod method = CompilerToVMHelper - .asResolvedJavaMethod(executable); - Asserts.assertNotNull(method, "could not convert " + method); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CollectCountersTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CollectCountersTest.java deleted file mode 100644 index dc54ff1974c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CollectCountersTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib/ - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -XX:+EnableJVMCI - * -XX:JVMCICounterSize=0 - * -Dcompiler.jvmci.compilerToVM.CollectCountersTest.expected=0 - * compiler.jvmci.compilerToVM.CollectCountersTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -XX:+EnableJVMCI - * -XX:JVMCICounterSize=11 - * -Dcompiler.jvmci.compilerToVM.CollectCountersTest.expected=11 - * compiler.jvmci.compilerToVM.CollectCountersTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; - -public class CollectCountersTest { - private static final int EXPECTED = Integer.getInteger( - "compiler.jvmci.compilerToVM.CollectCountersTest.expected"); - public static void main(String args[]) { - new CollectCountersTest().runTest(); - } - - private void runTest() { - long[] counters = CompilerToVMHelper.collectCounters(); - Asserts.assertNotNull(counters, "Expected not-null counters array"); - int ctvmData = counters.length; - Asserts.assertEQ(EXPECTED, ctvmData, "Unexpected counters amount"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CompileCodeTestCase.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CompileCodeTestCase.java deleted file mode 100644 index a880218b53b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/CompileCodeTestCase.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.testlibrary.CompilerUtils; -import jdk.test.lib.util.Pair; -import jdk.test.lib.Utils; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.runtime.JVMCI; -import jdk.test.whitebox.WhiteBox; -import jdk.test.whitebox.code.NMethod; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * A test case for tests which require compiled code. - */ -public class CompileCodeTestCase { - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final int COMP_LEVEL; - static { - int[] levels = CompilerUtils.getAvailableCompilationLevels(); - if (levels.length == 0) { - throw new Error("TESTBUG: no compilers available"); - } - COMP_LEVEL = levels[levels.length - 1]; - } - private static final Class[] CLASSES = { - Interface.class, - Dummy.class, - DummyEx.class}; - private static final Map, Object> RECEIVERS; - - public final Object receiver; - public final Executable executable; - public final int bci; - private final boolean isOsr; - - public CompileCodeTestCase(Object receiver, Executable executable, - int bci) { - this.receiver = receiver; - this.executable = executable; - this.bci = bci; - isOsr = (bci >= 0); - } - - public NMethod compile() { - return compile(COMP_LEVEL); - } - - public Pair invoke(Object[] args) { - boolean old = executable.isAccessible(); - executable.setAccessible(true); - try { - try { - if (executable instanceof Method) { - Method m = (Method) executable; - return new Pair<>(m.invoke(receiver, args), null); - } - - if (executable instanceof Constructor) { - Constructor c = (Constructor) executable; - return new Pair<>(c.newInstance(args), null); - } - } catch (InvocationTargetException e) { - return new Pair<>(null, e.getCause()); - } catch (Throwable e) { - return new Pair<>(null, e); - } - } finally { - executable.setAccessible(old); - } - throw new Error(executable + " has unsupported type " - + executable.getClass()); - } - - public NMethod compile(int level) { - String directive = "[{ match: \"" + executable.getDeclaringClass().getName().replace('.', '/') - + "." + (executable instanceof Constructor ? "" : executable.getName()) - + "\", " + "BackgroundCompilation: false }]"; - if (WB.addCompilerDirective(directive) != 1) { - throw new Error("Failed to add compiler directive: " + directive); - } - boolean enqueued = WB.enqueueMethodForCompilation(executable, - level, bci); - if (!enqueued) { - throw new Error(String.format( - "%s can't be enqueued for %scompilation on level %d", - executable, bci >= 0 ? "osr-" : "", level)); - } - Utils.waitForCondition(() -> WB.isMethodCompiled(executable, isOsr)); - return NMethod.get(executable, isOsr); - } - - public static List generate(int bci) { - ArrayList result = new ArrayList<>(); - for (Class aClass : CLASSES) { - Object receiver = RECEIVERS.get(aClass); - if (receiver == null) { - throw new Error("TESTBUG : no receiver for class " + aClass); - } - for (Executable m : aClass.getDeclaredConstructors()) { - result.add(new CompileCodeTestCase(receiver, m, bci)); - } - Arrays.stream(aClass.getDeclaredMethods()) - .filter(m -> !Modifier.isAbstract(m.getModifiers())) - .filter(m -> !Modifier.isNative(m.getModifiers())) - .map(m -> new CompileCodeTestCase(receiver, m, bci)) - .forEach(result::add); - } - return result; - } - - public NMethod toNMethod() { - return NMethod.get(executable, isOsr); - } - - public InstalledCode toInstalledCode() { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaMethod resolvedJavaMethod = metaAccess.lookupJavaMethod(executable); - NMethod nmethod = toNMethod(); - long address = nmethod == null ? 0L : nmethod.address; - long entryPoint = nmethod == null ? 0L : nmethod.entry_point; - return CTVMUtilities.getInstalledCode(resolvedJavaMethod, executable.getName(), address, entryPoint); - } - - @Override - public String toString() { - return "CompileCodeTestCase{" + - "executable=" + executable + - ", bci=" + bci + - '}'; - } - - public void deoptimize() { - WB.deoptimizeMethod(executable, isOsr); - } - - public NMethod deoptimizeAndCompile() { - deoptimize(); - return compile(); - } - - // classes which are used as "input" data in test cases - private static interface Interface { - Interface interfaceMethod(); - default Long defaultOverriddenMethod(Interface[] array) { - return array == null ? 0L : array.length; - } - default int defaultMethod(Object o) { - return o != null ? o.hashCode() : 0; - } - } - - private static abstract class Dummy implements Interface { - protected Dummy() { - } - - private static void staticMethod() { - } - - Dummy instanceMethod(int i) { - return null; - } - - abstract Object abstractMethod(double d); - - @Override - public Long defaultOverriddenMethod(Interface[] array) { - return 0L; - } - } - - public static class DummyEx extends Dummy { - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public DummyEx() { - } - - protected Dummy instanceMethod(int i) { - if (i == 0) { - return this; - } - return null; - } - - @Override - Object abstractMethod(double d) { - return this; - } - - @Override - public Interface interfaceMethod() { - return null; - } - } - - static { - Map, Object> map = new HashMap<>(); - map.put(CompileCodeTestCase.DummyEx.class, - new CompileCodeTestCase.DummyEx()); - map.put(CompileCodeTestCase.Dummy.class, - new CompileCodeTestCase.Dummy() { - @Override - public CompileCodeTestCase.Interface interfaceMethod() { - throw new AbstractMethodError(); - } - - @Override - Object abstractMethod(double d) { - throw new AbstractMethodError(); - } - }); - map.put(CompileCodeTestCase.Interface.class, - new CompileCodeTestCase.Interface() { - @Override - public CompileCodeTestCase.Interface interfaceMethod() { - throw new AbstractMethodError(); - } - }); - RECEIVERS = Collections.unmodifiableMap(map); - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java deleted file mode 100644 index 81fe7ad1b9d..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.internal.reflect.ConstantPool; -import jdk.internal.reflect.ConstantPool.Tag; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_CLASS; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_DOUBLE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FLOAT; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTEGER; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVALID; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_LONG; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODHANDLE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODTYPE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_NAMEANDTYPE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_STRING; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_UTF8; - -/** - * Common class for jdk.vm.ci.hotspot.CompilerToVM constant pool tests - */ -public class ConstantPoolTestCase { - - private static final Map TAG_TO_TYPE_MAP; - static { - TAG_TO_TYPE_MAP = new HashMap<>(); - TAG_TO_TYPE_MAP.put(Tag.CLASS, CONSTANT_CLASS); - TAG_TO_TYPE_MAP.put(Tag.FIELDREF, CONSTANT_FIELDREF); - TAG_TO_TYPE_MAP.put(Tag.METHODREF, CONSTANT_METHODREF); - TAG_TO_TYPE_MAP.put(Tag.INTERFACEMETHODREF, CONSTANT_INTERFACEMETHODREF); - TAG_TO_TYPE_MAP.put(Tag.STRING, CONSTANT_STRING); - TAG_TO_TYPE_MAP.put(Tag.INTEGER, CONSTANT_INTEGER); - TAG_TO_TYPE_MAP.put(Tag.FLOAT, CONSTANT_FLOAT); - TAG_TO_TYPE_MAP.put(Tag.LONG, CONSTANT_LONG); - TAG_TO_TYPE_MAP.put(Tag.DOUBLE, CONSTANT_DOUBLE); - TAG_TO_TYPE_MAP.put(Tag.NAMEANDTYPE, CONSTANT_NAMEANDTYPE); - TAG_TO_TYPE_MAP.put(Tag.UTF8, CONSTANT_UTF8); - TAG_TO_TYPE_MAP.put(Tag.METHODHANDLE, CONSTANT_METHODHANDLE); - TAG_TO_TYPE_MAP.put(Tag.METHODTYPE, CONSTANT_METHODTYPE); - TAG_TO_TYPE_MAP.put(Tag.INVOKEDYNAMIC, CONSTANT_INVOKEDYNAMIC); - TAG_TO_TYPE_MAP.put(Tag.INVALID, CONSTANT_INVALID); - } - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private final Map typeTests; - - public static enum ConstantTypes { - CONSTANT_CLASS { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - ConstantPool constantPoolSS = dummyClass.constantPoolSS; - checkIndex(constantPoolSS, index); - Class klass = constantPoolSS.getClassAt(index); - String klassName = klass.getName(); - TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); - for (TestedCPEntry entry : testedEntries) { - if (entry.klass.replaceAll("/", "\\.").equals(klassName)) { - return entry; - } - } - return null; - } - }, - CONSTANT_FIELDREF { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - return this.getTestedCPEntryForMethodAndField(dummyClass, index); - } - }, - CONSTANT_METHODREF { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - return this.getTestedCPEntryForMethodAndField(dummyClass, index); - } - }, - CONSTANT_INTERFACEMETHODREF { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - return this.getTestedCPEntryForMethodAndField(dummyClass, index); - } - }, - CONSTANT_STRING { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - ConstantPool constantPoolSS = dummyClass.constantPoolSS; - checkIndex(constantPoolSS, index); - String value = constantPoolSS.getStringAt(index); - TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); - for (TestedCPEntry entry : testedEntries) { - if (entry.name.equals(value)) { - return entry; - } - } - return null; - } - }, - CONSTANT_INTEGER, - CONSTANT_FLOAT, - CONSTANT_LONG, - CONSTANT_DOUBLE, - CONSTANT_NAMEANDTYPE, - CONSTANT_UTF8, - CONSTANT_METHODHANDLE, - CONSTANT_METHODTYPE, - CONSTANT_INVOKEDYNAMIC { - @Override - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - ConstantPool constantPoolSS = dummyClass.constantPoolSS; - checkIndex(constantPoolSS, index); - int nameAndTypeIndex = constantPoolSS.getNameAndTypeRefIndexAt(index); - String[] info = constantPoolSS.getNameAndTypeRefInfoAt(nameAndTypeIndex); - TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); - for (TestedCPEntry entry : testedEntries) { - if (info[0].equals(entry.name) && info[1].equals(entry.type)) { - return entry; - } - } - return null; - } - }, - CONSTANT_INVALID; - - public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { - return null; // returning null by default - } - - public TestedCPEntry[] getAllCPEntriesForType(DummyClasses dummyClass) { - TestedCPEntry[] toReturn = dummyClass.testedCP.get(this); - if (toReturn == null) { - return new TestedCPEntry[0]; - } - return dummyClass.testedCP.get(this); - } - - protected TestedCPEntry getTestedCPEntryForMethodAndField(DummyClasses dummyClass, int index) { - ConstantPool constantPoolSS = dummyClass.constantPoolSS; - checkIndex(constantPoolSS, index); - String[] info = constantPoolSS.getMemberRefInfoAt(index); - TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); - for (TestedCPEntry entry : testedEntries) { - if (info[0].equals(entry.klass) && info[1].equals(entry.name) && info[2].equals(entry.type)) { - return entry; - } - } - return null; - } - - protected void checkIndex(ConstantPool constantPoolSS, int index) { - ConstantPool.Tag tag = constantPoolSS.getTagAt(index); - ConstantTypes type = mapTagToCPType(tag); - if (!this.equals(type)) { - String msg = String.format("TESTBUG: CP tag should be a %s, but is %s", - this.name(), - type.name()); - throw new Error(msg); - } - } - } - - public static interface Validator { - void validate(jdk.vm.ci.meta.ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int index); - } - - public static class TestedCPEntry { - public final String klass; - public final String name; - public final String type; - public final ResolvedJavaMethod[] methods; - public final byte[] opcodes; - public final int accFlags; - - public TestedCPEntry(String klass, String name, String type, byte[] opcodes, int accFlags) { - this(klass, name, type, null, opcodes, accFlags); - } - - public TestedCPEntry(String klass, String name, String type, ResolvedJavaMethod[] methods, byte[] opcodes, int accFlags) { - this.klass = klass; - this.name = name; - this.type = type; - if (methods != null) { - this.methods = new ResolvedJavaMethod[methods.length]; - System.arraycopy(methods, 0, this.methods, 0, methods.length); - } else { - this.methods = null; - } - if (opcodes != null) { - this.opcodes = new byte[opcodes.length]; - System.arraycopy(opcodes, 0, this.opcodes, 0, opcodes.length); - } else { - this.opcodes = null; - } - this.accFlags = accFlags; - } - - public TestedCPEntry(String klass, String name, String type, byte[] opcodes) { - this(klass, name, type, opcodes, 0); - } - - public TestedCPEntry(String klass, String name, String type) { - this(klass, name, type, null, 0); - } - } - - public static ConstantTypes mapTagToCPType(Tag tag) { - return TAG_TO_TYPE_MAP.get(tag); - } - - public ConstantPoolTestCase(Map typeTests) { - this.typeTests = new HashMap<>(); - this.typeTests.putAll(typeTests); - } - - public void test() { - for (DummyClasses dummyClass : DummyClasses.values()) { - System.out.printf("Testing dummy %s with constant pool", - dummyClass.klass); - HotSpotResolvedObjectType holder = CompilerToVMHelper.fromObjectClass(dummyClass.klass); - jdk.vm.ci.meta.ConstantPool constantPoolCTVM = holder.getConstantPool(); - ConstantPool constantPoolSS = dummyClass.constantPoolSS; - for (int i = 0; i < constantPoolSS.getSize(); i++) { - Tag tag = constantPoolSS.getTagAt(i); - ConstantTypes cpType = mapTagToCPType(tag); - if (!typeTests.keySet().contains(cpType)) { - continue; - } - typeTests.get(cpType).validate(constantPoolCTVM, cpType, dummyClass, i); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java deleted file mode 100644 index da6642bdc18..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.MultipleAbstractImplementer; -import compiler.jvmci.common.testcases.MultipleImplementer2; -import compiler.jvmci.common.testcases.MultipleImplementersInterface; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import jdk.internal.access.SharedSecrets; -import org.objectweb.asm.Opcodes; -import jdk.internal.reflect.ConstantPool; -import jdk.internal.reflect.ConstantPool.Tag; -import jdk.vm.ci.hotspot.HotSpotConstantPool.Bytecodes; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; -import jdk.test.whitebox.WhiteBox; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_CLASS; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODHANDLE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODTYPE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_STRING; - -/** - * Class contains hard-coded constant pool tables for dummy classes used for - * jdk.vm.ci.hotspot.CompilerToVM constant pool methods - */ -public class ConstantPoolTestsHelper { - - public static final int NO_CP_CACHE_PRESENT = Integer.MAX_VALUE; - private static final MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - public enum DummyClasses { - DUMMY_CLASS(MultipleImplementer2.class, CP_MAP_FOR_CLASS), - DUMMY_ABS_CLASS(MultipleAbstractImplementer.class, CP_MAP_FOR_ABS_CLASS), - DUMMY_INTERFACE(MultipleImplementersInterface.class, CP_MAP_FOR_INTERFACE); - - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - public final Class klass; - public final ConstantPool constantPoolSS; - public final Map testedCP; - - DummyClasses(Class klass, Map testedCP) { - this.klass = klass; - this.constantPoolSS = SharedSecrets.getJavaLangAccess().getConstantPool(klass); - this.testedCP = testedCP; - } - - public int getCPCacheIndex(int cpi) { - if (constantPoolSS.getTagAt(cpi).equals(Tag.INVOKEDYNAMIC)) { - for (int indy_index = 0; indy_index < WB.getIndyInfoLength(this.klass); indy_index++) { - if (WB.getIndyCPIndex(this.klass, indy_index) == cpi) { - return indy_index; - } - } - } - if (constantPoolSS.getTagAt(cpi).equals(Tag.FIELDREF)) { - for (int field_index = 0; field_index < WB.getFieldEntriesLength(this.klass); field_index++) { - if (WB.getFieldCPIndex(this.klass, field_index) == cpi) { - return field_index; - } - } - } - if (constantPoolSS.getTagAt(cpi).equals(Tag.METHODREF) || constantPoolSS.getTagAt(cpi).equals(Tag.INTERFACEMETHODREF)) { - for (int method_index = 0; method_index < WB.getMethodEntriesLength(this.klass); method_index++) { - if (WB.getMethodCPIndex(this.klass, method_index) == cpi) { - return method_index; - } - } - } - return NO_CP_CACHE_PRESENT; - } - } - - /** - * - * @param cpType Constant type from the Constant pool - * @return a bytecode that's suitable for passing to the following functions for the given cpType: - * - CompilerToVMHelper.lookupNameAndTypeRefIndexInPool() - * - CompilerToVMHelper.lookupNameInPool() - * - CompilerToVMHelper.lookupSignatureInPool() - * - CompilerToVMHelper.lookupKlassRefIndexInPool() - */ - public static int getDummyOpcode(ConstantTypes cpType) { - switch (cpType) { - case CONSTANT_FIELDREF: - return Bytecodes.GETFIELD; - case CONSTANT_METHODREF: - return Bytecodes.INVOKEVIRTUAL; - case CONSTANT_INTERFACEMETHODREF: - return Bytecodes.INVOKEINTERFACE; - case CONSTANT_INVOKEDYNAMIC: - return Bytecodes.INVOKEDYNAMIC; - default: - throw new IllegalArgumentException("Unexpected constant pool entry type"); - } - } - /** - * Obtain a resolved Java method declared by a given type. - * - * @param type the declaring type - * @param the method's name - * - * Currently, the lookup is based only on the method's name - * but not on the method's signature (i.e., the first method - * with a matching name declared on {@code type} is returned). - */ - private static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { - if (methodName.equals("")) { - return type.getClassInitializer(); - } - - if (methodName.equals("")) { - ResolvedJavaMethod[] initializers = type.getDeclaredConstructors(); - if (initializers.length >= 0) { - return initializers[0]; - } else { - throw new IllegalArgumentException(); - } - } - - for (ResolvedJavaMethod method : type.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - return method; - } - } - - throw new IllegalArgumentException(); - } - - private static ResolvedJavaType getType(Class clazz) { - ResolvedJavaType type = metaAccess.lookupJavaType(clazz); - type.initialize(); - return type; - } - - private static final Map CP_MAP_FOR_CLASS = new HashMap<>(); - static { - CP_MAP_FOR_CLASS.put(CONSTANT_CLASS, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", null, null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2$1", null, null), - new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_FIELDREF, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "intStaticField", - "I", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "longStaticField", - "J", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_FINAL | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "floatStaticField", - "F", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_VOLATILE | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "doubleStaticField", - "D", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "stringStaticField", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "objectStaticField", - "Ljava/lang/Object;", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "intField", - "I", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PUBLIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "longField", - "J", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PRIVATE), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "floatField", - "F", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PROTECTED), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "doubleField", - "D", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_TRANSIENT), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "objectField", - "Ljava/lang/Object;", - new ResolvedJavaMethod[] { getMethod(getType(MultipleImplementer2.class), ""), null }, - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_FINAL), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "stringField", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_VOLATILE), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "stringFieldEmpty", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - 0), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_METHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/System", - "getProperties", - "()Ljava/util/Properties;", - new byte[] {(byte) Opcodes.INVOKESTATIC}), - new TestedCPEntry("java/util/HashMap", - "", - "()V", - new byte[] {(byte) Opcodes.INVOKESPECIAL}), - new TestedCPEntry("java/lang/Object", - "toString", - "()Ljava/lang/String;", - new byte[] {(byte) Opcodes.INVOKESPECIAL, - (byte) Opcodes.INVOKEVIRTUAL}), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2$1", - "", - "(Lcompiler/jvmci/common/testcases/MultipleImplementer2;)V", - new byte[0]), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", - "run", - "()V", - new byte[0]), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_INTERFACEMETHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/util/Map", - "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - new TestedCPEntry("java/util/Map", - "remove", - "(Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_STRING, - new TestedCPEntry[] { - new TestedCPEntry(null, "Message", null), - new TestedCPEntry(null, "", null), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_METHODHANDLE, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/invoke/LambdaMetafactory", - "metafactory", - "(Ljava/lang/invoke/MethodHandles$Lookup;" - + "Ljava/lang/String;" - + "Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodHandle;" - + "Ljava/lang/invoke/MethodType;)" - + "Ljava/lang/invoke/CallSite;", - null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", - "testMethod", - "()V"), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_METHODTYPE, - new TestedCPEntry[] { - new TestedCPEntry(null, null, "()V"), - } - ); - CP_MAP_FOR_CLASS.put(CONSTANT_INVOKEDYNAMIC, - new TestedCPEntry[] { - new TestedCPEntry(null, - "run", - "(Lcompiler/jvmci/common/testcases/MultipleImplementer2;)" - + "Ljava/lang/Runnable;"), - } - ); - } - - private static final Map CP_MAP_FOR_ABS_CLASS - = new HashMap<>(); - static { - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_CLASS, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", null, null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", null, null), - new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_FIELDREF, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "intStaticField", - "I", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "longStaticField", - "J", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_FINAL | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "floatStaticField", - "F", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_VOLATILE | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "doubleStaticField", - "D", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "stringStaticField", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "objectStaticField", - "Ljava/lang/Object;", - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "intField", - "I", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PUBLIC), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "longField", - "J", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PRIVATE), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "floatField", - "F", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_PROTECTED), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "doubleField", - "D", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_TRANSIENT), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "objectField", - "Ljava/lang/Object;", - new ResolvedJavaMethod[] { getMethod(getType(MultipleAbstractImplementer.class), ""), null }, - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_FINAL), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "stringField", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - Opcodes.ACC_VOLATILE), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "stringFieldEmpty", - "Ljava/lang/String;", - new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD}, - 0), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/System", - "getProperties", - "()Ljava/util/Properties;", - new byte[] {(byte) Opcodes.INVOKESTATIC}), - new TestedCPEntry("java/util/HashMap", - "", - "()V", - new byte[] {(byte) Opcodes.INVOKESPECIAL}), - new TestedCPEntry("java/lang/Object", - "toString", - "()Ljava/lang/String;", - new byte[] {(byte) Opcodes.INVOKESPECIAL, - (byte) Opcodes.INVOKEVIRTUAL}), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", - "", - "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)V", - new byte[0]), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", - "run", - "()V", - new byte[0]), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_INTERFACEMETHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/util/Map", - "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - new TestedCPEntry("java/util/Map", - "remove", - "(Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_STRING, - new TestedCPEntry[] { - new TestedCPEntry(null, "Message", null), - new TestedCPEntry(null, "", null), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODHANDLE, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/invoke/LambdaMetafactory", - "metafactory", - "(Ljava/lang/invoke/MethodHandles$Lookup;" - + "Ljava/lang/String;" - + "Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodHandle;" - + "Ljava/lang/invoke/MethodType;)" - + "Ljava/lang/invoke/CallSite;", - null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", - "testMethod", - "()V"), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODTYPE, - new TestedCPEntry[] { - new TestedCPEntry(null, null, "()V"), - } - ); - CP_MAP_FOR_ABS_CLASS.put(CONSTANT_INVOKEDYNAMIC, - new TestedCPEntry[] { - new TestedCPEntry(null, - "run", - "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)" - + "Ljava/lang/Runnable;"), - } - ); - } - - private static final Map CP_MAP_FOR_INTERFACE - = new HashMap<>(); - static { - CP_MAP_FOR_INTERFACE.put(CONSTANT_CLASS, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface$1", null, null), - new TestedCPEntry("java/lang/Object", null, null), - new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_FIELDREF, - new TestedCPEntry[] { - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", - "OBJECT_CONSTANT", - "Ljava/lang/Object;", - new ResolvedJavaMethod[] { getMethod(getType(MultipleImplementersInterface.class), ""), null }, - new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC}, - Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_PUBLIC), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/System", - "getProperties", - "()Ljava/util/Properties;", - new byte[] {(byte) Opcodes.INVOKESTATIC}), - new TestedCPEntry("java/util/HashMap", - "", - "()V", - new byte[] {(byte) Opcodes.INVOKESPECIAL}), - new TestedCPEntry("java/lang/Object", - "toString", - "()Ljava/lang/String;", - new byte[] {(byte) Opcodes.INVOKEVIRTUAL}), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", - "", - "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)V", - new byte[0]), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", - "run", - "()V", - new byte[0]), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_INTERFACEMETHODREF, - new TestedCPEntry[] { - new TestedCPEntry("java/util/Map", - "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - new TestedCPEntry("java/util/Map", - "remove", - "(Ljava/lang/Object;)Ljava/lang/Object;", - new byte[] {(byte) Opcodes.INVOKEINTERFACE}), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_STRING, - new TestedCPEntry[] { - new TestedCPEntry(null, "Hello", null), - new TestedCPEntry(null, "", null), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODHANDLE, - new TestedCPEntry[] { - new TestedCPEntry("java/lang/invoke/LambdaMetafactory", - "metafactory", - "(Ljava/lang/invoke/MethodHandles$Lookup;" - + "Ljava/lang/String;Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodType;" - + "Ljava/lang/invoke/MethodHandle;" - + "Ljava/lang/invoke/MethodType;)" - + "Ljava/lang/invoke/CallSite;"), - new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", - "defaultMethod", - "()V"), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODTYPE, - new TestedCPEntry[] { - new TestedCPEntry(null, null, "()V"), - } - ); - CP_MAP_FOR_INTERFACE.put(CONSTANT_INVOKEDYNAMIC, - new TestedCPEntry[] { - new TestedCPEntry(null, - "run", - "(Lcompiler/jvmci/common/testcases/MultipleImplementersInterface;)" - + "Ljava/lang/Runnable;"), - } - ); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java deleted file mode 100644 index 0b0faca313d..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build jdk.test.whitebox.WhiteBox - * compiler.jvmci.compilerToVM.DisassembleCodeBlobTest - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-BackgroundCompilation - * compiler.jvmci.compilerToVM.DisassembleCodeBlobTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.test.whitebox.code.NMethod; - -import java.util.List; - -public class DisassembleCodeBlobTest { - - public static void main(String[] args) { - DisassembleCodeBlobTest test - = new DisassembleCodeBlobTest(); - List testCases - = CompileCodeTestCase.generate(/* bci = */ -1); - testCases.forEach(test::check); - testCases.stream().findAny().ifPresent(test::checkZero); - test.checkNull(); - } - - private void checkNull() { - Utils.runAndCheckException( - () -> { CompilerToVMHelper.disassembleCodeBlob(null); }, - NullPointerException.class); - } - - private void checkZero(CompileCodeTestCase testCase) { - System.out.println("checkZero for " + testCase); - testCase.deoptimize(); - InstalledCode installedCode = testCase.toInstalledCode(); - String str = CompilerToVMHelper.disassembleCodeBlob(installedCode); - Asserts.assertNull(str, testCase - + " : non-null return value for invalid installCode"); - } - - private void checkLineStart(CompileCodeTestCase testCase, String line, String match) { - Asserts.assertTrue(line.startsWith(match), - testCase + " : line \"" + line + "\" does not start with: \"" + match +"\""); - } - - private void check(CompileCodeTestCase testCase) { - System.out.println(testCase); - // to have a clean state - NMethod nMethod = testCase.deoptimizeAndCompile(); - if (nMethod == null) { - throw new Error(testCase + " : method is not compiled"); - } - InstalledCode installedCode = testCase.toInstalledCode(); - String str1 = CompilerToVMHelper.disassembleCodeBlob(installedCode); - if (str1 != null) { - Asserts.assertGT(str1.length(), 0, - testCase + " : returned string has to be non-zero length"); - } - // The very first call to the disassembler contains a string specifying the - // architecture: [Disassembling for mach='i386:x86-64'] - // so discard it and try again. - String str2 = CompilerToVMHelper.disassembleCodeBlob(installedCode); - String[] strLines = str2.split("\\R"); - // Check some basic layout - int MIN_LINES = 5; - Asserts.assertTrue(strLines.length > 2, - testCase + " : read " + strLines.length + " lines, " + MIN_LINES + " expected"); - int l = 1; - checkLineStart(testCase, strLines[l++], "Compiled method "); // 2 - checkLineStart(testCase, strLines[l++], " total in heap "); // 3 - int foundDisassemblyLine = -1; - int foundEntryPointLine = -1; - for (; l < strLines.length; ++l) { - String line = strLines[l]; - if (line.equals("[Disassembly]") || line.equals("[MachCode]")) { - Asserts.assertTrue(foundDisassemblyLine == -1, - testCase + " : Duplicate disassembly section markers found at lines " + foundDisassemblyLine + " and " + l); - foundDisassemblyLine = l; - } - if (line.equals("[Entry Point]") || line.equals("[Verified Entry Point]")) { - Asserts.assertTrue(foundDisassemblyLine != -1, - testCase + " : entry point found but [Disassembly] section missing "); - foundEntryPointLine = l; - break; - } - } - Asserts.assertTrue(foundDisassemblyLine != -1, testCase + " : no disassembly section found"); - Asserts.assertTrue(foundEntryPointLine != -1, testCase + " : no entry point found"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java deleted file mode 100644 index 8e98eb23c2f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.DoNotInlineOrCompileTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Executable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class DoNotInlineOrCompileTest { - - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(DoNotInlineOrCompileTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - boolean hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method); - Asserts.assertFalse(hasNeverInlineDirective, "Unexpected initial " + - "value of property 'hasNeverInlineDirective'"); - CompilerToVMHelper.setNotInlinableOrCompilable(method); - hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method); - Asserts.assertTrue(hasNeverInlineDirective, aMethod - + " : hasNeverInlineDirective is false even after setNotInlinableOrCompilable'"); - } - - private static List createTestCases() { - List testCases = new ArrayList<>(); - - Class aClass = DummyClass.class; - testCases.addAll(Arrays.asList(aClass.getDeclaredMethods())); - testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors())); - return testCases; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyAbstractClass.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyAbstractClass.java deleted file mode 100644 index bda67911dfc..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyAbstractClass.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -abstract class DummyAbstractClass implements DummyInterface { - public abstract int dummyAbstractFunction(); -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyClass.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyClass.java deleted file mode 100644 index 5bced3ab09f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyClass.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Utils; -import jdk.test.whitebox.WhiteBox; - -import java.util.Random; - -class DummyClass extends DummyAbstractClass { - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - int p1 = 5; - int p2 = 6; - - public int dummyInstanceFunction() { - String str1 = "123123123"; - double x = 3.14; - int y = Integer.parseInt(str1); - - return y / (int) x; - } - - public int dummyEmptyInstanceFunction() { - return 42; - } - - public static int dummyEmptyStaticFunction() { - return -42; - } - - @Override - public int dummyAbstractFunction() { - int z = p1 * p2; - return (int) (Math.cos(p2 - p1 + z) * 100); - } - - @Override - public void dummyFunction() { - dummyEmptyInstanceFunction(); - } - - public void withLoop() { - long tier4 = (Long) WB.getVMFlag("Tier4BackEdgeThreshold"); - for (long i = 0; i < tier4; ++i) { - randomProfile(); - } - } - - private double randomProfile() { - String str1 = "123123123"; - double x = 3.14; - int y = Integer.parseInt(str1); - - Random rnd = Utils.getRandomInstance(); - if (rnd.nextDouble() > 0.2) { - return y / (int) x; - } else { - return x / y; - } - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyInterface.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyInterface.java deleted file mode 100644 index 1a733e30c33..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/DummyInterface.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.compilerToVM; - -interface DummyInterface { - void dummyFunction(); - - default int dummyDefaultFunction(int x, int y) { - int z = x * y; - return (int) (Math.cos(x - y + z) * 100); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java deleted file mode 100644 index bf34372ef0f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @ignore 8249621 - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-BackgroundCompilation - * compiler.jvmci.compilerToVM.ExecuteInstalledCodeTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.test.lib.util.Pair; -import jdk.test.lib.Utils; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.InvalidInstalledCodeException; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.test.whitebox.code.NMethod; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; - -public class ExecuteInstalledCodeTest { - - public static void main(String[] args) { - ExecuteInstalledCodeTest test = new ExecuteInstalledCodeTest(); - List testCases = new ArrayList<>(); - testCases.addAll(CompileCodeTestCase.generate(/* bci = */ -1)); - testCases .stream() - // ignore of abstract class -- 8138793 - .filter(e -> !(e.executable instanceof Constructor - && Modifier.isAbstract( - e.executable.getDeclaringClass() - .getModifiers()))) - .forEach(test::checkSanity); - } - - private void checkSanity(CompileCodeTestCase testCase) { - System.out.println(testCase); - // to have a clean state - testCase.deoptimize(); - Pair reflectionResult; - Object[] args = Utils.getNullValues( - testCase.executable.getParameterTypes()); - reflectionResult = testCase.invoke(args); - NMethod nMethod = testCase.compile(); - if (nMethod == null) { - throw new Error(testCase + " : nmethod is null"); - } - InstalledCode installedCode = testCase.toInstalledCode(); - Object result = null; - Throwable expectedException = reflectionResult.second; - boolean gotException = true; - try { - args = addReceiver(testCase, args); - result = CompilerToVMHelper.executeInstalledCode( - args, installedCode); - if (testCase.executable instanceof Constructor) { - // doesn't have return value, it changes receiver - result = args[0]; - } - gotException = false; - } catch (InvalidInstalledCodeException e) { - throw new AssertionError( - testCase + " : unexpected InvalidInstalledCodeException", e); - } catch (Throwable t) { - if (expectedException == null) { - throw new AssertionError(testCase - + " : got unexpected execption : " + t.getMessage(), t); - } - - if (expectedException.getClass() != t.getClass()) { - System.err.println("exception from CompilerToVM:"); - t.printStackTrace(); - System.err.println("exception from reflection:"); - expectedException.printStackTrace(); - throw new AssertionError(String.format( - "%s : got unexpected different exceptions : %s != %s", - testCase, expectedException.getClass(), t.getClass())); - } - } - - Asserts.assertEQ(reflectionResult.first, result, testCase - + " : different return value"); - if (!gotException) { - Asserts.assertNull(expectedException, testCase - + " : expected exception hasn't been thrown"); - } - } - - private Object[] addReceiver(CompileCodeTestCase testCase, Object[] args) { - if (!Modifier.isStatic(testCase.executable.getModifiers())) { - // add instance as 0th arg - Object[] newArgs = new Object[args.length + 1]; - newArgs[0] = testCase.receiver; - System.arraycopy(args, 0, newArgs, 1, args.length); - args = newArgs; - } - return args; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java deleted file mode 100644 index a9d730694b0..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.DuplicateSimpleSingleImplementerInterface; -import compiler.jvmci.common.testcases.SimpleSingleImplementerInterface; -import compiler.jvmci.common.testcases.MultipleImplementer1; -import compiler.jvmci.common.testcases.MultipleSuperImplementers; -import compiler.jvmci.common.testcases.SingleImplementer; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import compiler.jvmci.common.testcases.SingleSubclass; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -public class FindUniqueConcreteMethodTest { - public static void main(String args[]) { - FindUniqueConcreteMethodTest test = new FindUniqueConcreteMethodTest(); - try { - for (TestCase tcase : createTestCases()) { - test.runTest(tcase); - } - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG: can't find method", e); - } - } - - private static Set createTestCases() { - Set result = new HashSet<>(); - // a public method - result.add(new TestCase(true, SingleSubclass.class, "usualMethod")); - // overriden method - result.add(new TestCase(true, SingleSubclass.class, "overridenMethod")); - // private method - result.add(new TestCase(InternalError.class, SingleSubclass.class, "privateMethod")); - // protected method - result.add(new TestCase(true, SingleSubclass.class, "protectedMethod")); - // default(package-private) method - result.add(new TestCase(true, SingleSubclass.class, "defaultAccessMethod")); - // default interface method redefined in implementer - result.add(new TestCase(true, MultipleImplementer1.class, "defaultMethod")); - // interface method - result.add(new TestCase(true, MultipleImplementer1.class, "testMethod")); - // default interface method not redefined in implementer - // result.add(new TestCase(true, SingleImplementer.class, - // SingleImplementerInterface.class, "defaultMethod")); - // static method - result.add(new TestCase(InternalError.class, SingleSubclass.class, "staticMethod")); - // interface method - result.add(new TestCase(false, MultipleSuperImplementers.class, - DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod")); - result.add(new TestCase(false, MultipleSuperImplementers.class, - SimpleSingleImplementerInterface.class, "interfaceMethod")); - return result; - } - - private void runTest(TestCase tcase) throws NoSuchMethodException { - System.out.println(tcase); - Method method = tcase.holder.getDeclaredMethod(tcase.methodName); - HotSpotResolvedJavaMethod testMethod = CTVMUtilities.getResolvedMethod(method); - - HotSpotResolvedObjectType resolvedType = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver), getClass(), - /* resolve = */ true); - if (tcase.exception != null) { - try { - HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper - .findUniqueConcreteMethod(resolvedType, testMethod); - - Asserts.fail("Exception " + tcase.exception.getName() + " not thrown for " + tcase.methodName); - } catch (Throwable t) { - Asserts.assertEQ(t.getClass(), tcase.exception, "Wrong exception thrown for " + tcase.methodName); - } - } else { - HotSpotResolvedJavaMethod concreteMethod = CompilerToVMHelper - .findUniqueConcreteMethod(resolvedType, testMethod); - Asserts.assertEQ(concreteMethod, tcase.isPositive ? testMethod : null, - "Unexpected concrete method for " + tcase.methodName); - } - } - - private static class TestCase { - public final Class receiver; - public final Class holder; - public final String methodName; - public final boolean isPositive; - public final Class exception; - - public TestCase(boolean isPositive, Class clazz, Class holder, - String methodName, Class exception) { - this.receiver = clazz; - this.methodName = methodName; - this.isPositive = isPositive; - this.holder = holder; - this.exception = exception; - } - - public TestCase(boolean isPositive, Class clazz, Class holder, - String methodName) { - this(isPositive, clazz, holder, methodName, null); - } - - public TestCase(boolean isPositive, Class clazz, String methodName) { - this(isPositive, clazz, clazz, methodName, null); - } - - public TestCase(Class exception, Class clazz, String methodName) { - this(false, clazz, clazz, methodName, exception); - } - - @Override - public String toString() { - return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, exception=%s", - receiver.getName(), holder.getName(), methodName, isPositive, - exception == null ? "" : exception.getName()); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetBytecodeTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetBytecodeTest.java deleted file mode 100644 index 0404cd03a04..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetBytecodeTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetBytecodeTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.TestCase; -import org.objectweb.asm.Opcodes; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.lang.reflect.Modifier; - -public class GetBytecodeTest { - - public static void main(String[] args) { - TestCase.getAllExecutables() - .forEach(GetBytecodeTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - byte[] bytecode = CompilerToVMHelper.getBytecode(method); - - int mods = aMethod.getModifiers(); - boolean shouldHasZeroLength = Modifier.isAbstract(mods) - || Modifier.isNative(mods); - boolean correctLength = (bytecode.length == 0 && shouldHasZeroLength) - || (bytecode.length > 0 && !shouldHasZeroLength); - - Asserts.assertTrue(correctLength, "Bytecode of '" + aMethod + "' has " - + bytecode.length + " length"); - - if (!shouldHasZeroLength) { - Asserts.assertTrue(containsReturn(bytecode), "Bytecode of '" - + aMethod + "' doesn't have any return statement"); - } - } - - private static boolean containsReturn(byte[] bytecode) { - for (byte b : bytecode) { - // cast unsigned byte to int - int value = (int) b & 0x000000FF; - switch (value) { - case Opcodes.RET: - case Opcodes.ARETURN: - case Opcodes.IRETURN: - case Opcodes.LRETURN: - case Opcodes.FRETURN: - case Opcodes.DRETURN: - case Opcodes.RETURN: - return true; - } - } - return false; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetClassInitializerTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetClassInitializerTest.java deleted file mode 100644 index 312dc00d6b4..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetClassInitializerTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetClassInitializerTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.AbstractClass; -import compiler.jvmci.common.testcases.AbstractClassExtender; -import compiler.jvmci.common.testcases.DoNotExtendClass; -import compiler.jvmci.common.testcases.MultipleImplementersInterfaceExtender; -import compiler.jvmci.common.testcases.SingleImplementer; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.util.HashSet; -import java.util.Set; - -public class GetClassInitializerTest { - - public static void main(String args[]) { - GetClassInitializerTest test = new GetClassInitializerTest(); - for (TestCase tcase : createTestCases()) { - test.runTest(tcase); - } - } - - private static Set createTestCases() { - Set result = new HashSet<>(); - // a simple class with initializer - result.add(new TestCase(SingleImplementer.class, true)); - // an interface with initializer - result.add(new TestCase(SingleImplementerInterface.class, true)); - // an abstract class with initializer - result.add(new TestCase(AbstractClass.class, true)); - // a class without initializer, extending class with initializer - result.add(new TestCase(AbstractClassExtender.class, false)); - // an interface without initializer - result.add(new TestCase(MultipleImplementersInterfaceExtender.class, false)); - // a class without initializer - result.add(new TestCase(DoNotExtendClass.class, false)); - return result; - } - - private void runTest(TestCase tcase) { - System.out.println(tcase); - String className = tcase.holder.getName(); - HotSpotResolvedObjectType resolvedClazz = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.holder), - getClass(), /* resolve = */ true); - HotSpotResolvedJavaMethod initializer = CompilerToVMHelper - .getClassInitializer(resolvedClazz); - if (tcase.isPositive) { - Asserts.assertNotNull(initializer, "Couldn't get initializer for " - + className); - Asserts.assertEQ(initializer.getName(), "", - "Unexpected initializer name for " + className); - } else { - Asserts.assertNull(initializer, "Unexpected: found initializer for " - + className); - } - } - - private static class TestCase { - public final Class holder; - public final boolean isPositive; - - public TestCase(Class clazz, boolean isPositive) { - this.holder = clazz; - this.isPositive = isPositive; - } - - @Override - public String toString() { - return "CASE: clazz=" + holder.getName() - + ", isPositive=" + isPositive; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetConstantPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetConstantPoolTest.java deleted file mode 100644 index f02b2871d94..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetConstantPoolTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @ignore 8249621 - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetConstantPoolTest - */ -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Utils; -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.TestCase; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.ConstantPool; - -import java.lang.reflect.Field; -import java.lang.reflect.Executable; - -/** - * Tests for jdk.vm.ci.hotspot.CompilerToVM::getConstantPool method - */ -public class GetConstantPoolTest { - - public static void testMethod(Executable executable) { - test(CTVMUtilities.getResolvedMethod(executable)); - } - - public static void testClass(Class cls) { - HotSpotResolvedObjectType type = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(cls), - GetConstantPoolTest.class, /* resolve = */ true); - test(type); - } - - private static void test(Object object) { - ConstantPool cp = CompilerToVMHelper.getConstantPool(object); - System.out.println(object + " -> " + cp); - } - - public static void main(String[] args) { - TestCase.getAllClasses().forEach(GetConstantPoolTest::testClass); - TestCase.getAllExecutables().forEach(GetConstantPoolTest::testMethod); - testNull(); - testObject(); - } - - private static void testNull() { - try { - Object cp = CompilerToVMHelper.getConstantPool(null); - throw new AssertionError("Test OBJECT." - + " Expected IllegalArgumentException has not been caught"); - } catch (NullPointerException npe) { - // expected - } - } - private static void testObject() { - try { - Object cp = CompilerToVMHelper.getConstantPool(new Object()); - throw new AssertionError("Test OBJECT." - + " Expected IllegalArgumentException has not been caught"); - } catch (IllegalArgumentException iae) { - // expected - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetExceptionTableTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetExceptionTableTest.java deleted file mode 100644 index 0e0a5ee6e2c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetExceptionTableTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetExceptionTableTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.io.IOException; -import java.lang.reflect.Executable; -import java.net.Socket; -import java.util.HashMap; -import java.util.Map; - -public class GetExceptionTableTest { - - public static final int TRY_CATCH_COUNT = 3; - public static final int TRY_CATCH_FINALLY_COUNT = 8; - public static final int TRY_WITH_RESOURCES_COUNT = 5; - public static final int EMPTY_COUNT = 0; - - public static void main(String[] args) { - Map testCases = createTestCases(); - testCases.forEach(GetExceptionTableTest::runSanityTest); - } - - private static Map createTestCases() { - HashMap methods = new HashMap<>(); - try { - Class aClass = GetExceptionTableTest.DummyClass.class; - methods.put(aClass.getMethod("tryCatchDummy"), TRY_CATCH_COUNT); - methods.put(aClass.getMethod("tryCatchFinallyDummy"), - TRY_CATCH_FINALLY_COUNT); - methods.put(aClass.getMethod("tryWithResourcesDummy"), - TRY_WITH_RESOURCES_COUNT); - methods.put(aClass.getMethod("emptyFunction"), EMPTY_COUNT); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG", e); - } - return methods; - } - - private static void runSanityTest(Executable aMethod, - Integer expectedTableLength) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - int tableLength = CompilerToVMHelper.getExceptionTableLength(method); - Asserts.assertEQ(tableLength, expectedTableLength, aMethod - + " incorrect exception table length."); - - long tableStart = CompilerToVMHelper.getExceptionTableStart(method); - if (tableLength > 0) { - Asserts.assertNE(tableStart, 0L, aMethod + " exception table starts " - + "at 0."); - } - } - - private static class DummyClass { - public static void emptyFunction() {} - public static void tryCatchDummy() throws Throwable { - try { - throw new Exception("Dummy exception"); - } catch (ArithmeticException ex) { - throw new IOException(ex.getMessage()); - } catch (IOException ex) { - throw new Exception(ex); - } catch (Exception ex) { - throw new Exception(ex); - } - } - - public int tryCatchFinallyDummy() { - // 4 times catch/finally = 8 catch-blocks and finally-blocks - try { - throw new Exception("Dummy exception"); - } catch (IndexOutOfBoundsException ex) { - return 1; - } catch (ArithmeticException ex) { - return 2; - } catch (IOException ex) { - return 3; - } catch (Exception ex) { - return 4; - } finally { - return 0; - } - } - - public static int tryWithResourcesDummy() throws Throwable { - try (Socket socket = new Socket()) { - throw new Exception("Dummy exception"); - } catch (ArithmeticException ex) { - return 1; - } catch (IOException ex) { - return 2; - } catch (Exception ex) { - return 3; - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java deleted file mode 100644 index f29c10a34f8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8173912 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. - * compiler.jvmci.compilerToVM.GetFlagValueTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import jdk.test.whitebox.WhiteBox; - -public class GetFlagValueTest { - public static void main(String[] args) throws Exception { - try { - CompilerToVMHelper.getFlagValue(null); - Asserts.fail("Expected NullPointerException when calling getFlagValue(null)"); - } catch (NullPointerException e) { - // expected - } - - Object missing = CompilerToVMHelper.getFlagValue("this is surely not a flag"); - Asserts.assertEquals(CompilerToVMHelper.CTVM, missing); - - ProcessBuilder pb; - OutputAnalyzer out; - - pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", - "-XX:+PrintFlagsFinal", - "-version"); - out = new OutputAnalyzer(pb.start()); - - out.shouldHaveExitValue(0); - String[] lines = out.getStdout().split("\\r?\\n"); - Asserts.assertTrue(lines.length > 1, "Expected output from -XX:+PrintFlagsFinal"); - - final WhiteBox wb = WhiteBox.getWhiteBox(); - - // Line example: ccstr PrintIdealGraphAddress = 127.0.0.1 {C2 develop} {default} - Pattern flagLine = Pattern.compile("(\\w+)\\s+(\\w+)\\s+:?= (?:(.+))\\{[^}]+\\}\\s+\\{[^}]+\\}"); - for (String line : lines) { - if (line.indexOf('=') != -1) { - line = line.trim(); - Matcher m = flagLine.matcher(line); - Asserts.assertTrue(m.matches(), "Unexpected line in -XX:+PrintFlagsFinal output: " + line); - String type = m.group(1); - String name = m.group(2); - String expect = m.group(3).trim(); - Object value = CompilerToVMHelper.getFlagValue(name); - Object wbValue = wb.getVMFlag(name); - Asserts.assertEquals(value, wbValue, "Value of flag " + name); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetImplementorTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetImplementorTest.java deleted file mode 100644 index e576adc148e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetImplementorTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib/ - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetImplementorTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.AbstractClass; -import compiler.jvmci.common.testcases.AbstractClassExtender; -import compiler.jvmci.common.testcases.DoNotExtendClass; -import compiler.jvmci.common.testcases.DoNotImplementInterface; -import compiler.jvmci.common.testcases.MultipleImplementer1; -import compiler.jvmci.common.testcases.MultipleImplementer2; -import compiler.jvmci.common.testcases.MultipleImplementersInterface; -import compiler.jvmci.common.testcases.SingleImplementer; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import compiler.jvmci.common.testcases.SingleSubclass; -import compiler.jvmci.common.testcases.SingleSubclassedClass; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Stream; - -public class GetImplementorTest { - public static void main(String args[]) { - GetImplementorTest test = new GetImplementorTest(); - for (TestCase tcase : createTestCases()) { - test.runTest(tcase); - } - } - - private static Set createTestCases() { - Set result = new HashSet<>(); - Stream.of( - SingleSubclass.class, - AbstractClassExtender.class, - MultipleImplementer2.class, - MultipleImplementer1.class, - MultipleImplementersInterface.class, - DoNotImplementInterface.class, - DoNotExtendClass.class, - AbstractClass.class, - SingleSubclassedClass.class) - .forEach(Utils::ensureClassIsLoaded); - // an interface with single class implementing it - result.add(new TestCase(SingleImplementerInterface.class, - SingleImplementer.class)); - /* an interface with multiple implementers. According to getImplementor - javadoc, an itself should be returned in case of more than one - implementor - */ - result.add(new TestCase(MultipleImplementersInterface.class, - MultipleImplementersInterface.class)); - // an interface with no implementors - result.add(new TestCase(DoNotImplementInterface.class, null)); - // an abstract class with extender class - result.add(new TestCase(AbstractClass.class, null)); - // a simple class, which is not extended - result.add(new TestCase(DoNotExtendClass.class, null)); - // a usual class, which is extended - result.add(new TestCase(SingleSubclassedClass.class, null)); - return result; - } - - private void runTest(TestCase tcase) { - System.out.println(tcase); - HotSpotResolvedObjectType resolvedIface = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.anInterface), - getClass(), /* resolve = */ true); - if (!resolvedIface.isInterface()) { - try { - CompilerToVMHelper.getImplementor(resolvedIface); - Asserts.fail("Expected " + IllegalArgumentException.class.getName()); - } catch (IllegalArgumentException e) { - } - return; - } - HotSpotResolvedObjectType resolvedImplementer = CompilerToVMHelper - .getImplementor(resolvedIface); - HotSpotResolvedObjectType resolvedExpected = null; - if (tcase.expectedImplementer != null) { - resolvedExpected = CompilerToVMHelper.lookupTypeHelper(Utils - .toJVMTypeSignature(tcase.expectedImplementer), - getClass(), /* resolve = */ true); - } - Asserts.assertEQ(resolvedImplementer, resolvedExpected, - "Unexpected implementer for " + tcase.anInterface.getName()); - } - - private static class TestCase { - public final Class anInterface; - public final Class expectedImplementer; - - public TestCase(Class iface, Class expectedImplementer) { - this.anInterface = iface; - this.expectedImplementer = expectedImplementer; - } - - @Override - public String toString() { - return String.format("CASE: interface=%s, expected=%s", - anInterface.getName(), - expectedImplementer == null - ? null - : expectedImplementer.getName()); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java deleted file mode 100644 index e1fcd1aadac..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetLineNumberTableTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.TestCase; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.util.Arrays; -import java.util.Map; - -public class GetLineNumberTableTest { - public static void main(String[] args) { - TestCase.getAllExecutables() - .forEach(GetLineNumberTableTest::runSanityTest); - } - - public static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - long[] lineNumbers = CompilerToVMHelper.getLineNumberTable(method); - long[] expectedLineNumbers = getExpectedLineNumbers(aMethod); - - Asserts.assertTrue(Arrays.equals(lineNumbers, expectedLineNumbers), - String.format("%s : unequal table values : %n%s%n%s%n", - aMethod, - Arrays.toString(lineNumbers), - Arrays.toString(expectedLineNumbers))); - } - - public static long[] getExpectedLineNumbers(Executable aMethod) { - Map bciToLine = CTVMUtilities - .getBciToLineNumber(aMethod); - long[] result = null; - if (!bciToLine.isEmpty()) { - result = new long[2 * bciToLine.size()]; - int i = 0; - for (Integer key : bciToLine.keySet()) { - result[i++] = key.longValue(); - result[i++] = bciToLine.get(key).longValue(); - } - } - // compilerToVM::getLineNumberTable returns null in case empty table - return result; - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java deleted file mode 100644 index 83b6618d555..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @clean compiler.jvmci.compilerToVM.* - * @compile -g DummyInterface.java - * @compile -g DummyAbstractClass.java - * @compile -g DummyClass.java - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetLocalVariableTableTest - * @clean compiler.jvmci.compilerToVM.* - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.util.HashMap; -import java.util.Map; - -public class GetLocalVariableTableTest { - - public static final int MAIN_LOCALS_COUNT = 0; - public static final int INSTANCE_LOCALS_COUNT = 4; - public static final int EMPTY_INSTANCE_COUNT = 1; - public static final int EMPTY_STATIC_COUNT = 0; - public static final int ABSTRACT_INHERIT_LOCALS_COUNT = 2; - public static final int DEFAULTFUNC_LOCALS_COUNT = 4; - - public static void main(String[] args) { - Map testCases = createTestCases(); - testCases.forEach(GetLocalVariableTableTest::runSanityTest); - } - - private static Map createTestCases() { - HashMap methods = new HashMap<>(); - try { - Class aClass; - - aClass = GetLocalVariableTableTest.class; - methods.put(aClass.getDeclaredMethod("main", String[].class), - MAIN_LOCALS_COUNT); - - aClass = DummyClass.class; - methods.put(aClass.getMethod("dummyInstanceFunction"), - INSTANCE_LOCALS_COUNT); - methods.put(aClass.getMethod("dummyEmptyInstanceFunction"), - EMPTY_INSTANCE_COUNT); - methods.put(aClass.getMethod("dummyEmptyStaticFunction"), - EMPTY_STATIC_COUNT); - methods.put(aClass.getMethod("dummyFunction"), - EMPTY_INSTANCE_COUNT); - methods.put(aClass.getMethod("dummyAbstractFunction"), - ABSTRACT_INHERIT_LOCALS_COUNT); - - aClass = DummyInterface.class; - methods.put(aClass.getMethod("dummyFunction"), EMPTY_STATIC_COUNT); - methods.put(aClass.getMethod("dummyDefaultFunction", int.class, - int.class), DEFAULTFUNC_LOCALS_COUNT); - - aClass = DummyAbstractClass.class; - methods.put(aClass.getMethod("dummyAbstractFunction"), 0); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG", e); - } - return methods; - } - - private static void runSanityTest(Executable aMethod, - Integer expectedTableLength) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - - int tblLength = CompilerToVMHelper.getLocalVariableTableLength(method); - Asserts.assertEQ(tblLength, expectedTableLength, aMethod + " : incorrect " - + "local variable table length."); - - long tblStart = CompilerToVMHelper.getLocalVariableTableStart(method); - if (tblLength > 0) { - Asserts.assertNE(tblStart, 0L, aMethod + " : local variable table starts" - + " at 0 with length " + tblLength); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java deleted file mode 100644 index bf43ca431b6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib/ - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * compiler.jvmci.compilerToVM.GetMaxCallTargetOffsetTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; - -public class GetMaxCallTargetOffsetTest { - public static void main(String args[]) { - new GetMaxCallTargetOffsetTest().runTest(); - } - - private void runTest() { - long offset1 = CompilerToVMHelper.getMaxCallTargetOffset(0L); - Asserts.assertNE(offset1, 0L, - "Unexpected maxCallTargetOffset for 0L"); - long offset2 = CompilerToVMHelper.getMaxCallTargetOffset(100L); - Asserts.assertNE(offset2, 0L, - "Unexpected maxCallTargetOffset for 100L"); - long offset3 = CompilerToVMHelper.getMaxCallTargetOffset(1000000L); - Asserts.assertNE(offset3, 0L, - "Unexpected maxCallTargetOffset for 1000000L"); - // there can be 2 same offsets, but not 3 - Asserts.assertFalse(offset1 == offset2 && offset2 == offset3, - "All 3 offsets are unexpectedly equal: " + offset1); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java deleted file mode 100644 index d12759af21e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - /* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @ignore 8249621 - * @modules java.base/jdk.internal.misc:+open - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.internal.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject - * jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetResolvedJavaMethodTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.internal.misc.Unsafe; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class GetResolvedJavaMethodTest { - private static enum TestCase { - NULL_BASE { - @Override - HotSpotResolvedJavaMethod getResolvedJavaMethod() { - return CompilerToVMHelper.getResolvedJavaMethod( - null, getPtrToMethod()); - } - }, - JAVA_METHOD_BASE { - @Override - HotSpotResolvedJavaMethod getResolvedJavaMethod() { - HotSpotResolvedJavaMethod methodInstance = TEST_METHOD; - try { - METASPACE_METHOD_FIELD.set(methodInstance, - getPtrToMethod()); - } catch (ReflectiveOperationException e) { - throw new Error("TEST BUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaMethod( - methodInstance, 0L); - } - }, - JAVA_METHOD_BASE_IN_TWO { - @Override - HotSpotResolvedJavaMethod getResolvedJavaMethod() { - long ptr = getPtrToMethod(); - HotSpotResolvedJavaMethod methodInstance = TEST_METHOD; - try { - METASPACE_METHOD_FIELD.set(methodInstance, ptr / 2L); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaMethod(methodInstance, - ptr - ptr / 2L); - } - }, - JAVA_METHOD_BASE_ZERO { - @Override - HotSpotResolvedJavaMethod getResolvedJavaMethod() { - long ptr = getPtrToMethod(); - HotSpotResolvedJavaMethod methodInstance = TEST_METHOD; - try { - METASPACE_METHOD_FIELD.set(methodInstance, 0L); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaMethod(methodInstance, - ptr); - } - } - ; - abstract HotSpotResolvedJavaMethod getResolvedJavaMethod(); - } - - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final Field METASPACE_METHOD_FIELD; - private static final Class TEST_CLASS = GetResolvedJavaMethodTest.class; - private static final HotSpotResolvedJavaMethod TEST_METHOD; - private static final long PTR; - static { - try { - Method method = TEST_CLASS.getDeclaredMethod("test", TestCase.class); - TEST_METHOD = CompilerToVMHelper.asResolvedJavaMethod(method); - } catch (NoSuchMethodException e) { - throw new Error("TESTBUG : " + e, e); - } - try { - // jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.metaspaceMethod - METASPACE_METHOD_FIELD = TEST_METHOD.getClass() - .getDeclaredField("metaspaceMethod"); - METASPACE_METHOD_FIELD.setAccessible(true); - PTR = (long) METASPACE_METHOD_FIELD.get(TEST_METHOD); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - - } - - private static long getPtrToMethod() { - Field field; - try { - field = TEST_CLASS.getDeclaredField("PTR"); - } catch (NoSuchFieldException e) { - throw new Error("TEST BUG : " + e, e); - } - Object base = UNSAFE.staticFieldBase(field); - return WB.getObjectAddress(base) + UNSAFE.staticFieldOffset(field); - } - - public void test(TestCase testCase) { - System.out.println(testCase.name()); - HotSpotResolvedJavaMethod result = testCase.getResolvedJavaMethod(); - Asserts.assertNotNull(result, testCase + " : got null"); - Asserts.assertEQ(TEST_CLASS, - CompilerToVMHelper.getMirror(result.getDeclaringClass()), - testCase + " : unexpected declaring class"); - } - - public static void main(String[] args) { - GetResolvedJavaMethodTest test = new GetResolvedJavaMethodTest(); - for (TestCase testCase : TestCase.values()) { - test.test(testCase); - } - testObjectBase(); - testMetaspaceWrapperBase(); - } - - private static void testMetaspaceWrapperBase() { - try { - HotSpotResolvedJavaMethod method - = CompilerToVMHelper.getResolvedJavaMethod( - new PublicMetaspaceWrapperObject() { - @Override - public long getMetaspacePointer() { - return getPtrToMethod(); - } - }, 0L); - throw new AssertionError("Test METASPACE_WRAPPER_BASE." - + " Expected IllegalArgumentException has not been caught"); - } catch (IllegalArgumentException e) { - // expected - } - } - - private static void testObjectBase() { - try { - HotSpotResolvedJavaMethod method - = CompilerToVMHelper.getResolvedJavaMethod(new Object(), 0L); - throw new AssertionError("Test OBJECT_BASE." - + " Expected IllegalArgumentException has not been caught"); - } catch (IllegalArgumentException e) { - // expected - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java deleted file mode 100644 index 1e2e2d50232..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @ignore 8249621 - * @ignore 8158860 - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.internal.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject - * jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UseCompressedOops - * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseCompressedOops -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetResolvedJavaTypeTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.internal.misc.Unsafe; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; -import jdk.vm.ci.meta.ConstantPool; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Field; - -public class GetResolvedJavaTypeTest { - private static enum TestCase { - NULL_BASE { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - return CompilerToVMHelper.getResolvedJavaType( - null, getPtrToKlass(), COMPRESSED); - } - }, - JAVA_METHOD_BASE { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - HotSpotResolvedJavaMethod methodInstance - = CompilerToVMHelper.getResolvedJavaMethodAtSlot( - TEST_CLASS, 0); - Field field; - try { - // jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl.metaspaceMethod - field = methodInstance.getClass() - .getDeclaredField("metaspaceMethod"); - field.setAccessible(true); - field.set(methodInstance, getPtrToKlass()); - } catch (ReflectiveOperationException e) { - throw new Error("TEST BUG : " + e, e); - } - - return CompilerToVMHelper.getResolvedJavaType(methodInstance, - 0L, COMPRESSED); - } - }, - CONSTANT_POOL_BASE { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - ConstantPool cpInst; - try { - cpInst = CompilerToVMHelper.getConstantPool(null, - getPtrToKlass()); - // jdk.vm.ci.hotspot.HotSpotConstantPool.metaspaceConstantPool - Field field = cpInst.getClass() - .getDeclaredField("metaspaceConstantPool"); - field.setAccessible(true); - field.set(cpInst, getPtrToKlass()); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaType(cpInst, - 0L, COMPRESSED); - } - }, - CONSTANT_POOL_BASE_IN_TWO { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - long ptr = getPtrToKlass(); - ConstantPool cpInst = CompilerToVMHelper - .fromObjectClass(TEST_CLASS) - .getConstantPool(); - try { - Field field = cpInst.getClass() - .getDeclaredField("metaspaceConstantPool"); - field.setAccessible(true); - field.set(cpInst, ptr / 2L); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaType(cpInst, - ptr - ptr / 2L, COMPRESSED); - } - }, - CONSTANT_POOL_BASE_ZERO { - @Override - HotSpotResolvedObjectType getResolvedJavaType() { - long ptr = getPtrToKlass(); - ConstantPool cpInst = CompilerTovMHelper - .fromObjectClass(TEST_CLASS) - .getConstantPool(); - try { - Field field = cpInst.getClass() - .getDeclaredField("metaspaceConstantPool"); - field.setAccessible(true); - field.set(cpInst, 0L); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG : " + e, e); - } - return CompilerToVMHelper.getResolvedJavaType(cpInst, - ptr, COMPRESSED); - } - }, - ; - abstract HotSpotResolvedObjectType getResolvedJavaType(); - } - - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final Class TEST_CLASS = GetResolvedJavaTypeTest.class; - /* a compressed parameter for tested method is set to false because - unsafe.getKlassPointer always returns uncompressed pointer */ - private static final boolean COMPRESSED = false; - - private static long getPtrToKlass() { - Field field; - try { - field = TEST_CLASS.getDeclaredField("PTR"); - } catch (NoSuchFieldException e) { - throw new Error("TEST BUG : " + e, e); - } - Object base = UNSAFE.staticFieldBase(field); - return WB.getObjectAddress(base) + UNSAFE.staticFieldOffset(field); - } - - public void test(TestCase testCase) { - System.out.println(testCase.name()); - HotSpotResolvedObjectType type = testCase.getResolvedJavaType(); - Asserts.assertEQ(TEST_CLASS, - CompilerToVMHelper.getMirror(type), - testCase + " : unexpected class returned"); - } - - public static void main(String[] args) { - GetResolvedJavaTypeTest test = new GetResolvedJavaTypeTest(); - for (TestCase testCase : TestCase.values()) { - test.test(testCase); - } - testObjectBase(); - testMetaspaceWrapperBase(); - } - - private static void testMetaspaceWrapperBase() { - try { - HotSpotResolvedObjectType type - = CompilerToVMHelper.getResolvedJavaType( - new PublicMetaspaceWrapperObject() { - @Override - public long getMetaspacePointer() { - return getPtrToKlass(); - } - }, 0L, COMPRESSED); - throw new AssertionError("Test METASPACE_WRAPPER_BASE." - + " Expected IllegalArgumentException has not been caught"); - } catch (IllegalArgumentException iae) { - // expected - } - } - - private static void testObjectBase() { - try { - HotSpotResolvedObjectType type - = CompilerToVMHelper.getResolvedJavaType(new Object(), 0L, - COMPRESSED); - throw new AssertionError("Test OBJECT_BASE." - + " Expected IllegalArgumentException has not been caught"); - } catch (IllegalArgumentException iae) { - // expected - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java deleted file mode 100644 index 7b78753b01b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetStackTraceElementTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.TestCase; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Map; - -public class GetStackTraceElementTest { - - public static void main(String[] args) { - Map testCases = createTestCases(); - testCases.forEach(GetStackTraceElementTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod, int[] bcis) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - String className = aMethod.getDeclaringClass().getName(); - String methodName = aMethod.getName().equals(className) - ? "" - : aMethod.getName(); - String fileName = getFileName(className); - Map bciWithLineNumber = CTVMUtilities - .getBciToLineNumber(aMethod); - boolean isNative = Modifier.isNative(aMethod.getModifiers()); - int lineNumber = -1; - for (int bci : bcis) { - StackTraceElement ste = CompilerToVMHelper - .getStackTraceElement(method, bci); - Asserts.assertNotNull(ste, aMethod + " : got null StackTraceElement" - + " at bci " + bci); - Asserts.assertEQ(className, ste.getClassName(), aMethod - + " : unexpected class name"); - Asserts.assertEQ(fileName, ste.getFileName(), aMethod - + " : unexpected filename"); - Asserts.assertEQ(methodName, ste.getMethodName(), aMethod - + " : unexpected method name"); - Asserts.assertEQ(isNative, ste.isNativeMethod(), aMethod - + " : unexpected 'isNative' value"); - if (bciWithLineNumber.size() > 0) { - if (bciWithLineNumber.containsKey(bci)) { - lineNumber = bciWithLineNumber.get(bci); - } - Asserts.assertEQ(lineNumber, ste.getLineNumber(), aMethod - + " : unexpected line number"); - } else { - // native and abstract function - Asserts.assertGT(0, ste.getLineNumber(), - aMethod + " : unexpected line number for abstract " - + "or native method"); - } - } - - } - - private static String getFileName(String className) { - int lastDot = className.lastIndexOf('.'); - int firstDol = className.contains("$") - ? className.indexOf('$') - : className.length(); - return className.substring(lastDot + 1, firstDol) + ".java"; - } - - private static Map createTestCases() { - Map testCases = new HashMap<>(); - - try { - Class aClass = DummyClass.class; - Method aMethod = aClass.getDeclaredMethod("dummyInstanceFunction"); - int[] bci = new int[] {0, 2, 3, 6, 7, 8, 11, 13, 15, 16, 17, 18}; - testCases.put(aMethod, bci); - - aMethod = aClass.getDeclaredMethod("dummyEmptyFunction"); - bci = new int[] {0}; - testCases.put(aMethod, bci); - - aMethod = aClass.getDeclaredMethod("nativeFunction"); - bci = new int[] {0}; - testCases.put(aMethod, bci); - - TestCase.getAllExecutables() - .forEach(c -> testCases.put(c, new int[] {0})); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG : test method not found", e); - } - return testCases; - } - - private class DummyClass { - public int dummyInstanceFunction() { - String str1 = "123123123"; - double x = 3.14; - int y = Integer.parseInt(str1); - - return y / (int)x; - } - - public void dummyEmptyFunction() {} - - public native void nativeFunction(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetSymbolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetSymbolTest.java deleted file mode 100644 index 7fc3235b88c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetSymbolTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc:+open - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetSymbolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.SingleImplementer; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.ConstantPool; - -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class GetSymbolTest { - private static final int CONSTANT_POOL_UTF8_TAG = 1; // see jvms, section 4.4 - - private static final Function> NAMES = members -> - Stream.of(members) - .map(Member::getName) - .collect(Collectors.toList()); - - public static void main(String[] args) { - new GetSymbolTest().test(SingleImplementer.class); - } - - private void test(Class aClass) { - Utils.ensureClassIsLoaded(aClass); - Method method; - try { - method = aClass.getDeclaredMethod("nonInterfaceMethod"); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG: can't find test method", e); - } - HotSpotResolvedJavaMethod resolvedMethod - = CTVMUtilities.getResolvedMethod(aClass, method); - List symbols; - try { - symbols = getSymbols(resolvedMethod); - } catch (ReflectiveOperationException e) { - throw new Error("TEST BUG: can't access private members", e); - } - List classSymbols = new ArrayList<>(); - classSymbols.addAll(NAMES.apply(aClass.getDeclaredFields())); - classSymbols.addAll(NAMES.apply(aClass.getDeclaredMethods())); - // Check that all members of test class have symbols from constant pool - for (String s : classSymbols) { - if (!symbols.contains(s)) { - // failed. print all symbols found by getSymbol - System.out.println("getSymbol data:"); - for (String ctvmValue : symbols) { - System.out.println(ctvmValue); - } - throw new AssertionError("Unable to find symbol " + s - + " using CompilerToVM.getSymbol"); - } - } - } - - private List getSymbols(HotSpotResolvedJavaMethod - metaspaceMethod) throws ReflectiveOperationException { - List symbols = new ArrayList<>(); - ConstantPool pool = metaspaceMethod.getConstantPool(); - long length = pool.length(); - // jvms-4.1: The constant_pool table is indexed from 1 ... - for (int i = 1; i < length; i++) { - if (getTag(pool, i) == CONSTANT_POOL_UTF8_TAG) { - long entryPointer; - Method getEntryAt = pool.getClass() - .getDeclaredMethod("getEntryAt", int.class); - getEntryAt.setAccessible(true); - entryPointer = (Long) getEntryAt.invoke(pool, i); - String symbol = CompilerToVMHelper.getSymbol(entryPointer); - symbols.add(symbol); - } - } - return symbols; - } - - private int getTag(ConstantPool pool, int index) - throws ReflectiveOperationException { - Object jvmConstant; - Method getTag = pool.getClass().getDeclaredMethod("getTagAt", - int.class); - getTag.setAccessible(true); - jvmConstant = getTag.invoke(pool, index); - Field tagCode = jvmConstant.getClass().getDeclaredField("tag"); - tagCode.setAccessible(true); - return tagCode.getInt(jvmConstant); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java deleted file mode 100644 index 1fb4ea723ee..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.GetVtableIndexForInterfaceTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.AbstractClass; -import compiler.jvmci.common.testcases.AnotherSingleImplementer; -import compiler.jvmci.common.testcases.AnotherSingleImplementerInterface; -import compiler.jvmci.common.testcases.DoNotExtendClass; -import compiler.jvmci.common.testcases.MultipleAbstractImplementer; -import compiler.jvmci.common.testcases.MultipleImplementersInterface; -import compiler.jvmci.common.testcases.MultipleImplementersInterfaceExtender; -import compiler.jvmci.common.testcases.SingleImplementer; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import compiler.jvmci.common.testcases.SingleSubclass; -import compiler.jvmci.common.testcases.SingleSubclassedClass; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Stream; - -public class GetVtableIndexForInterfaceTest { - private static final int INVALID_VTABLE_INDEX = -4; // see method.hpp: VtableIndexFlag - - public static void main(String args[]) { - GetVtableIndexForInterfaceTest test - = new GetVtableIndexForInterfaceTest(); - try { - for (TestCase tcase : createTestCases()) { - test.runTest(tcase); - } - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG: can't find requested method", e); - } - } - - private static Set createTestCases() { - Set result = new HashSet<>(); - Stream.of( - AbstractClass.class, - SingleImplementer.class, - SingleImplementerInterface.class, - MultipleImplementersInterface.class, - MultipleImplementersInterfaceExtender.class, - SingleSubclass.class, - SingleSubclassedClass.class, - DoNotExtendClass.class, - MultipleAbstractImplementer.class - ) - .forEach(Utils::ensureClassIsLoaded); - // non iface method - result.add(new TestCase(SingleImplementer.class, - SingleImplementer.class, "nonInterfaceMethod", - false, InternalError.class)); - // iface method w/o default implementation - result.add(new TestCase(SingleImplementer.class, - SingleImplementerInterface.class, "interfaceMethod", false)); - /* another iface which provides default implementation for the - original iface*/ - result.add(new TestCase(MultipleImplementersInterfaceExtender.class, - MultipleImplementersInterface.class, "testMethod", false, - InternalError.class)); - // iface method w/ default implementation - result.add(new TestCase(SingleImplementer.class, - SingleImplementerInterface.class, "defaultMethod", true)); - // non iface class - result.add(new TestCase(SingleSubclass.class, - SingleSubclassedClass.class, "inheritedMethod", false, - InternalError.class)); - // class not implementing iface - result.add(new TestCase(DoNotExtendClass.class, - SingleImplementerInterface.class, "defaultMethod", false, - InternalError.class)); - // abstract class which doesn't implement iface - result.add(new TestCase(AbstractClass.class, - SingleImplementerInterface.class, "defaultMethod", false, - InternalError.class)); - // abstract class which implements iface - result.add(new TestCase(MultipleAbstractImplementer.class, - MultipleImplementersInterface.class, "defaultMethod", true)); - // class not initialized - result.add(new TestCase(AnotherSingleImplementer.class, - AnotherSingleImplementerInterface.class, "defaultMethod", false, - InternalError.class)); - return result; - } - - private void runTest(TestCase tcase) throws NoSuchMethodException { - System.out.println(tcase); - Method method = tcase.holder.getDeclaredMethod(tcase.methodName); - HotSpotResolvedObjectType metaspaceKlass = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver), - getClass(), /* resolve = */ true); - HotSpotResolvedJavaMethod metaspaceMethod = CTVMUtilities - .getResolvedMethod(tcase.holder, method); - int index = 0; - try { - index = CompilerToVMHelper - .getVtableIndexForInterfaceMethod(metaspaceKlass, - metaspaceMethod); - } catch (Throwable t) { - if (tcase.isPositive || tcase.expectedException == null) { - throw new Error("Caught unexpected exception " + t); - } - if (!tcase.expectedException.equals(t.getClass())) { - throw new Error(String.format("Caught %s while expected %s", - t.getClass().getName(), - tcase.expectedException.getName())); - } - return; - } - if (tcase.expectedException != null) { - throw new AssertionError("Expected exception wasn't caught: " - + tcase.expectedException.getName()); - } - if (tcase.isPositive) { - Asserts.assertNE(index, INVALID_VTABLE_INDEX, - "Unexpected: got invalid index"); - } else { - Asserts.assertEQ(index, INVALID_VTABLE_INDEX, - "Unexpected: got valid index "); - } - } - - private static class TestCase { - public final Class receiver; - public final Class holder; - public final String methodName; - public final boolean isPositive; - public final Class expectedException; - - public TestCase(Class receiver, Class holder, String methodName, - boolean isPositive, - Class expectedException) { - this.receiver = receiver; - this.holder = holder; - this.methodName = methodName; - this.isPositive = isPositive; - this.expectedException = expectedException; - } - - public TestCase(Class receiver, Class holder, String methodName, - boolean isPositive) { - this(receiver, holder, methodName, isPositive, null); - } - - @Override - public String toString() { - return String.format("CASE: receiver=%s, holder=%s, method=%s," - + " isPositive=%s%n", receiver.getName(), holder.getName(), - methodName, isPositive); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java deleted file mode 100644 index af25f731ed1..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @key randomness - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-BackgroundCompilation - * compiler.jvmci.compilerToVM.HasCompiledCodeForOSRTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.testlibrary.CompilerUtils; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.code.NMethod; - -import java.lang.reflect.Executable; -import java.util.ArrayList; -import java.util.List; - -public class HasCompiledCodeForOSRTest { - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(HasCompiledCodeForOSRTest::runSanityTest); - } - - public static List createTestCases() { - List testCases = new ArrayList<>(); - - try { - Class aClass = DummyClass.class; - Object receiver = new DummyClass(); - testCases.add(new CompileCodeTestCase(receiver, - aClass.getMethod("withLoop"), 17)); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG : " + e.getMessage(), e); - } - return testCases; - } - - private static void runSanityTest(CompileCodeTestCase testCase) { - System.out.println(testCase); - Executable aMethod = testCase.executable; - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - testCase.invoke(Utils.getNullValues(aMethod.getParameterTypes())); - testCase.deoptimize(); - int[] levels = CompilerUtils.getAvailableCompilationLevels(); - // not compiled - for (int level : levels) { - boolean isCompiled = CompilerToVMHelper.hasCompiledCodeForOSR( - method, testCase.bci, level); - Asserts.assertFalse(isCompiled, String.format( - "%s : unexpected return value for non-compiled method at " - + "level %d", testCase, level)); - } - NMethod nm = testCase.compile(); - if (nm == null) { - throw new Error(String.format( - "TEST BUG : %s : cannot compile method", testCase)); - } - - boolean isCompiled; - int level = nm.comp_level; - int[] someLevels = new int[] {-4, 0, 1, 2, 3, 4, 5, 45}; - // check levels - for (int i : someLevels) { - isCompiled = CompilerToVMHelper.hasCompiledCodeForOSR( - method, testCase.bci, i); - Asserts.assertEQ(isCompiled, level == i, String.format( - "%s : unexpected return value for compiled method at " - + "level %d", testCase, i)); - } - - // check bci - byte[] bytecode = CompilerToVMHelper.getBytecode(CTVMUtilities - .getResolvedMethod(testCase.executable)); - int[] incorrectBci = new int[] { - testCase.bci + 1, - testCase.bci - 1, - -200, - -10, - bytecode.length, - bytecode.length + 1, - bytecode.length + 4, - bytecode.length + 200 - }; - for (int bci : incorrectBci) { - isCompiled = CompilerToVMHelper.hasCompiledCodeForOSR( - method, bci, level); - Asserts.assertFalse(isCompiled, String.format( - "%s : unexpected return value for compiled method at " - + "level %d with bci = %d ", - testCase, level, bci)); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java deleted file mode 100644 index 233b91eb55b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.HasFinalizableSubclassTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.AbstractClass; -import compiler.jvmci.common.testcases.AbstractClassExtender; -import compiler.jvmci.common.testcases.DoNotImplementInterface; -import compiler.jvmci.common.testcases.MultipleImplementer1; -import compiler.jvmci.common.testcases.MultipleImplementersInterface; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Stream; - -public class HasFinalizableSubclassTest { - public static void main(String args[]) { - HasFinalizableSubclassTest test = new HasFinalizableSubclassTest(); - for (TestCase tcase : createTestCases()) { - test.runTest(tcase); - } - } - - private static Set createTestCases() { - Stream.of( - AbstractClassExtender.class, - SingleImplementerInterface.class, - MultipleImplementersInterface.class, - MultipleImplementer1.class, - DoNotImplementInterface.class) - .forEach(Utils::ensureClassIsLoaded); - Set result = new HashSet<>(); - // iface with finalize method - result.add(new TestCase(SingleImplementerInterface.class, false)); - // iface with default finalize method - result.add(new TestCase(MultipleImplementersInterface.class, false)); - // class which implements iface w/ default finalize method - result.add(new TestCase(MultipleImplementer1.class, true)); - // abstract class with finalizeable subclass - result.add(new TestCase(AbstractClass.class, true)); - // non-implemented iface - result.add(new TestCase(DoNotImplementInterface.class, false)); - return result; - } - - private void runTest(TestCase tcase) { - System.out.println(tcase); - HotSpotResolvedObjectType metaspaceKlass = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.aClass), - getClass(), /* resolve = */ true); - Asserts.assertEQ(tcase.expected, - CompilerToVMHelper.hasFinalizableSubclass(metaspaceKlass), - "Unexpected finalizableSubclass state for " - + tcase.aClass.getName()); - } - - private static class TestCase { - public final Class aClass; - public final boolean expected; - - public TestCase(Class clazz, boolean expected) { - this.aClass = clazz; - this.expected = expected; - } - @Override - public String toString() { - return "CASE: class= " + aClass.getName() + ", expected=" + expected; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasNeverInlineDirectiveTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasNeverInlineDirectiveTest.java deleted file mode 100644 index c8836b674d8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasNeverInlineDirectiveTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.HasNeverInlineDirectiveTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Executable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class HasNeverInlineDirectiveTest { - - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(HasNeverInlineDirectiveTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - boolean hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method); - boolean expected = WB.testSetDontInlineMethod(aMethod, true); - Asserts.assertEQ(hasNeverInlineDirective, expected, "Unexpected initial " + - "value of property 'hasNeverInlineDirective'"); - - hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method); - Asserts.assertTrue(hasNeverInlineDirective, aMethod + "Unexpected value of " + - "property 'hasNeverInlineDirective' after setting 'do not inline' to true"); - WB.testSetDontInlineMethod(aMethod, false); - hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method); - Asserts.assertFalse(hasNeverInlineDirective, "Unexpected value of " + - "property 'hasNeverInlineDirective' after setting 'do not inline' to false"); - } - - private static List createTestCases() { - List testCases = new ArrayList<>(); - - Class aClass = DummyClass.class; - testCases.addAll(Arrays.asList(aClass.getDeclaredMethods())); - testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors())); - return testCases; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java deleted file mode 100644 index 93b987f0d9e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.graal.enabled & vm.compMode == "Xmixed" - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler - * compiler.jvmci.compilerToVM.IsCompilableTest - */ - -/** - * @test - * @requires vm.jvmci & vm.compMode == "Xmixed" - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.IsCompilableTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Executable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class IsCompilableTest { - - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(IsCompilableTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - boolean isCompilable = CompilerToVMHelper.isCompilable(method); - boolean expected = WB.isMethodCompilable(aMethod); - Asserts.assertEQ(isCompilable, expected, "Unexpected initial " + - "value of property 'compilable'"); - - WB.makeMethodNotCompilable(aMethod); - isCompilable = CompilerToVMHelper.isCompilable(method); - Asserts.assertFalse(isCompilable, aMethod + "Unexpected value of " + - "property 'isCompilable' after setting 'compilable' to false"); - } - - private static List createTestCases() { - List testCases = new ArrayList<>(); - - Class aClass = DummyClass.class; - testCases.addAll(Arrays.asList(aClass.getDeclaredMethods())); - testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors())); - return testCases; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.java deleted file mode 100644 index 6b635394727..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * ../common/patches - * @modules java.base/jdk.internal.misc - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * compiler.jvmci.compilerToVM.IsMatureTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.SimpleClass; -import compiler.whitebox.CompilerWhiteBoxTest; -import jdk.test.lib.Asserts; -import jdk.test.lib.Platform; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Executable; - -public class IsMatureTest { - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final boolean TIERED - = WB.getBooleanVMFlag("TieredCompilation"); - - public static void main(String[] args) throws Exception { - new IsMatureTest().test(); - } - - public void test() throws Exception { - SimpleClass sclass = new SimpleClass(); - Executable method = SimpleClass.class.getDeclaredMethod("testMethod"); - long methodData = WB.getMethodData(method); - boolean isMature = CompilerToVMHelper.isMature(methodData); - Asserts.assertEQ(methodData, 0L, - "Never invoked method can't have method data"); - Asserts.assertFalse(isMature, "Never invoked method can't be mature"); - for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { - sclass.testMethod(); - } - methodData = WB.getMethodData(method); - isMature = CompilerToVMHelper.isMature(methodData); - int compLevel = WB.getMethodCompilationLevel(method); - // methodData doesn't necessarily exist for interpreter and compilation level 1 - if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_NONE - && compLevel != CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE) { - Asserts.assertNE(methodData, 0L, - "Multiple times invoked method should have method data"); - // The method may or may not be mature if it's compiled with limited profile. - if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE) { - Asserts.assertEQ(isMature, !Platform.isComp(), - "Unexpected isMature state for multiple times invoked method"); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java deleted file mode 100644 index 7d84380b859..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) - * @library / /test/lib - * ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbatch -XX:CompileThresholdScaling=1.0 - * -XX:CompileCommand=dontinline,compiler.jvmci.common.testcases.SimpleClass::testMethod - * compiler.jvmci.compilerToVM.IsMatureVsReprofileTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.SimpleClass; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.test.lib.Asserts; -import jdk.test.whitebox.WhiteBox; -import compiler.whitebox.CompilerWhiteBoxTest; -import java.lang.reflect.Executable; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.lib.Platform; - -public class IsMatureVsReprofileTest { - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - private static final boolean TIERED = WB.getBooleanVMFlag("TieredCompilation"); - private static final boolean IS_XCOMP = Platform.isComp(); - - public static void main(String[] args) throws Exception { - new IsMatureVsReprofileTest().test(); - } - - public void test() throws Exception { - SimpleClass sclass = new SimpleClass(); - Executable method = SimpleClass.class.getDeclaredMethod("testMethod"); - long metaspaceMethodData = WB.getMethodData(method); - Asserts.assertEQ(metaspaceMethodData, 0L, "MDO should be null for a " - + "never invoked method"); - boolean isMature = CompilerToVMHelper.isMature(metaspaceMethodData); - Asserts.assertFalse(isMature, "null MDO can't be mature"); - for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { - sclass.testMethod(); - } - Asserts.assertTrue(WB.isMethodCompiled(method), - "Method should be compiled"); - metaspaceMethodData = WB.getMethodData(method); - Asserts.assertNE(metaspaceMethodData, 0L, - "Multiple times invoked method should have MDO"); - isMature = CompilerToVMHelper.isMature(metaspaceMethodData); - /* a method is not mature for -Xcomp and -Tiered, - see NonTieredCompPolicy::is_mature */ - Asserts.assertEQ(!IS_XCOMP, isMature, - "Unexpected isMature state for compiled method"); - HotSpotResolvedJavaMethod resolvedMethod - = CTVMUtilities.getResolvedMethod(method); - CompilerToVMHelper.reprofile(resolvedMethod); - Asserts.assertFalse(WB.isMethodCompiled(method), - "Unexpected method compilation state after reprofile"); - metaspaceMethodData = WB.getMethodData(method); - isMature = CompilerToVMHelper.isMature(metaspaceMethodData); - Asserts.assertNE(metaspaceMethodData, 0L, - "Got null MDO after reprofile"); - Asserts.assertFalse(isMature, - "Got unexpected isMature state after reprofiling"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java deleted file mode 100644 index 7f2a3900dc6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IterateFramesNative.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8269592 - * - * @requires vm.jvmci - * - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.stack - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbatch -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * compiler.jvmci.compilerToVM.IterateFramesNative - * @run main/othervm -Xcomp -Xbootclasspath/a:. - * -XX:CompileOnly=compiler.jvmci.compilerToVM.IterateFramesNative::callerNative - * -XX:CompileOnly=jdk.vm.ci.hotspot.CompilerToVM::iterateFrames - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -Dcompiler.jvmci.compilerToVM.IterateFramesNative.checkCompiled=true - * compiler.jvmci.compilerToVM.IterateFramesNative - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.whitebox.CompilerWhiteBoxTest; -import jdk.test.lib.Asserts; -import jdk.vm.ci.code.stack.InspectedFrameVisitor; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotStackFrameReference; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicInteger; - -public class IterateFramesNative { - private static final WhiteBox WB; - private static final Method NATIVE_METHOD; - private static final Method ITERATE_FRAMES_METHOD; - private static final ResolvedJavaMethod NATIVE_METHOD_RESOLVED; - private static final ResolvedJavaMethod NATIVE_CALLBACK_METHOD_RESOLVED; - private static final boolean CHECK_COMPILED; - - static { - Method nativeCallbackMethod; - WB = WhiteBox.getWhiteBox(); - try { - NATIVE_METHOD = IterateFramesNative.class.getDeclaredMethod("callerNative", - Runnable.class); - nativeCallbackMethod = IterateFramesNative.class.getDeclaredMethod("testNativeFrameCallback", - Helper.class, int.class); - ITERATE_FRAMES_METHOD = CompilerToVMHelper.CompilerToVMClass().getDeclaredMethod( - "iterateFrames", - ResolvedJavaMethod[].class, - ResolvedJavaMethod[].class, - int.class, - InspectedFrameVisitor.class); - } catch (NoSuchMethodException e) { - throw new Error("Can't get executable for test method", e); - } - NATIVE_METHOD_RESOLVED = CTVMUtilities.getResolvedMethod(NATIVE_METHOD); - NATIVE_CALLBACK_METHOD_RESOLVED = CTVMUtilities.getResolvedMethod(nativeCallbackMethod); - CHECK_COMPILED = Boolean.getBoolean( - "compiler.jvmci.compilerToVM.IterateFramesNative.checkCompiled"); - - loadNativeLibrary(); - } - - public static void main(String[] args) { - new IterateFramesNative().test(); - } - - private void test() { - // Run enough iterations to reach compilation. - for (int i = 0; i < (CHECK_COMPILED ? 1 : 10_000); i++) { - testNativeFrame("someString", i); - } - - if (CHECK_COMPILED) { - // Verify that we reached compilation at some point. - Asserts.assertTrue(WB.isMethodCompiled(ITERATE_FRAMES_METHOD), - "Expected native method to be compiled: " + ITERATE_FRAMES_METHOD); - Asserts.assertTrue(WB.isMethodCompiled(NATIVE_METHOD), - "Expected native method to be compiled: " + NATIVE_METHOD); - } - } - - /** - * Loads native library(libIterateFramesNative.so) - */ - protected static void loadNativeLibrary() { - System.loadLibrary("IterateFramesNative"); - } - - public static native void callerNative(Runnable runnable); - - private void testNativeFrame(String str, int iteration) { - Helper innerHelper = new Helper(str); - - callerNative(() -> testNativeFrameCallback(innerHelper, iteration)); - - Asserts.assertEQ(innerHelper.string, NATIVE_METHOD_RESOLVED.getName(), - "Native frame not found?: " + NATIVE_METHOD_RESOLVED.getName()); - } - - private void testNativeFrameCallback(Helper helper, int iteration) { - HotSpotStackFrameReference initialFrame = CompilerToVMHelper.iterateFrames( - null, - null, - 0, - f -> { - HotSpotStackFrameReference frame = (HotSpotStackFrameReference) f; - Asserts.assertNotNull(frame, "got null frame for native method"); - return frame; - }); - Asserts.assertNotNull(initialFrame, "frame must not be null"); - Asserts.assertEQ(initialFrame.getMethod().getName(), "iterateFrames", - "Expected initial frame method to be CompilerToVM.iterateFrames"); - - AtomicInteger frameCounter = new AtomicInteger(); - ResolvedJavaMethod[] methods = new ResolvedJavaMethod[] {NATIVE_METHOD_RESOLVED, NATIVE_CALLBACK_METHOD_RESOLVED}; - CompilerToVMHelper.iterateFrames( - methods, - methods, - 0, - f -> { - HotSpotStackFrameReference frame = (HotSpotStackFrameReference) f; - Asserts.assertNotNull(frame, "got null frame for native method"); - int index = frameCounter.getAndIncrement(); - if (index == 0) { - Asserts.assertTrue(frame.isMethod(NATIVE_CALLBACK_METHOD_RESOLVED), - "unexpected method: " + frame.getMethod().getName()); - } else if (index == 1) { - Asserts.assertTrue(frame.isMethod(NATIVE_METHOD_RESOLVED), - "unexpected method: " + frame.getMethod().getName()); - helper.string = frame.getMethod().getName(); - Asserts.assertFalse(frame.hasVirtualObjects(), - "native frames do not have virtual objects"); - return frame; // stop - } - return null; - }); - } - - private class Helper { - public String string; - - public Helper(String s) { - this.string = s; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java deleted file mode 100644 index be511f4e011..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @ignore 8249621 - * @modules java.base/jdk.internal.misc:open - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:open - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives.positive=true - * -XX:+EnableJVMCI - * compiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Dcompiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives.positive=false - * -XX:-EnableJVMCI -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.runtime.JVMCI; - -import java.lang.reflect.Method; - -public class JVM_RegisterJVMCINatives { - private static final boolean IS_POSITIVE = Boolean.getBoolean( - "compiler.jvmci.compilerToVM.JVM_RegisterJVMCINatives.positive"); - - private final Method registerNatives; - - public static void main(String[] args) { - new JVM_RegisterJVMCINatives().runTest(); - } - - private void runTest() { - Object result; - try { - result = invoke(); - } catch (InternalError e) { - if (IS_POSITIVE) { - throw new AssertionError("unexpected exception", e); - } - return; - } - if (!IS_POSITIVE) { - throw new AssertionError("didn't get expected exception"); - } - Asserts.assertNull(result, - "registerNatives()V returned non-null"); - Asserts.assertEQ(result, invoke(), - "registerNatives returns different results"); - - } - private Object invoke() { - Object result; - try { - result = registerNatives.invoke(JVMCI.class); - } catch (ReflectiveOperationException e) { - throw new Error("can't invoke registerNatives", e); - } - return result; - } - - private JVM_RegisterJVMCINatives() { - Method method; - try { - method = Class.forName("jdk.vm.ci.hotspot.CompilerToVM", - /* initialize = */ false, - this.getClass().getClassLoader()) - .getDeclaredMethod("registerNatives"); - method.setAccessible(true); - } catch (ReflectiveOperationException e) { - throw new Error("can't find CompilerToVM::registerNatives", e); - } - registerNatives = method; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupConstantInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupConstantInPoolTest.java deleted file mode 100644 index d7590710dba..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupConstantInPoolTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupConstantInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.meta.ConstantPool; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODHANDLE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODTYPE; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_STRING; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupConstantInPool} method - */ -public class LookupConstantInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_STRING, LookupConstantInPoolTest::validateString); - typeTests.put(CONSTANT_METHODHANDLE, LookupConstantInPoolTest::validateMethodHandle); - typeTests.put(CONSTANT_METHODTYPE, LookupConstantInPoolTest::validateMethodType); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validateString(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int index = cpi; - String cached = ""; - int cpci = dummyClass.getCPCacheIndex(cpi); - if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { - index = cpci; - cached = "cached "; - } - Object constantInPool = CompilerToVMHelper.lookupConstantInPool(constantPoolCTVM, index, true); - String stringToVerify = (String) constantInPool; - String stringToRefer = entry.name; - if (stringToRefer.equals("") && cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { - stringToRefer = null; // tested method returns null for cached empty strings - } - String msg = String.format("Wrong string accessed by %sconstant pool index %d", cached, index); - Asserts.assertEQ(stringToRefer, stringToVerify, msg); - } - - private static final String NOT_NULL_MSG - = "Object returned by lookupConstantInPool method should not be null"; - - - private static void validateMethodHandle(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int index) { - Object constantInPool = CompilerToVMHelper.lookupConstantInPool(constantPoolCTVM, index, true); - String msg = String.format("%s for index %d", NOT_NULL_MSG, index); - Asserts.assertNotNull(constantInPool, msg); - if (!(constantInPool instanceof MethodHandle)) { - msg = String.format("Wrong constant pool entry accessed by index" - + " %d: %s, but should be subclass of %s", - index, - constantInPool.getClass(), - MethodHandle.class.getName()); - throw new AssertionError(msg); - } - } - - private static void validateMethodType(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int index) { - Object constantInPool = CompilerToVMHelper.lookupConstantInPool(constantPoolCTVM, index, true); - String msg = String.format("%s for index %d", NOT_NULL_MSG, index); - Asserts.assertNotNull(constantInPool, msg); - Class mtToVerify = constantInPool.getClass(); - Class mtToRefer = MethodType.class; - msg = String.format("Wrong method type class accessed by" - + " constant pool index %d", - index); - Asserts.assertEQ(mtToRefer, mtToVerify, msg); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java deleted file mode 100644 index 8549c274b9b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassInPoolTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @summary Testing compiler.jvmci.CompilerToVM.lookupKlassInPool method - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupKlassInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_CLASS; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupKlassInPool} method - */ -public class LookupKlassInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_CLASS, LookupKlassInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - public static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int i) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, i); - if (entry == null) { - return; - } - Object classToVerify = CompilerToVMHelper.lookupKlassInPool(constantPoolCTVM, i); - if (!(classToVerify instanceof HotSpotResolvedObjectType) && !(classToVerify instanceof String)) { - String msg = String.format("Output of method CTVM.lookupKlassInPool is neither" - + " a HotSpotResolvedObjectType, nor a String"); - throw new AssertionError(msg); - } - String classNameToRefer = entry.klass; - String outputToVerify = classToVerify.toString(); - if (!outputToVerify.contains(classNameToRefer)) { - String msg = String.format("Wrong class accessed by constant pool index %d: %s, but should be %s", - i, - outputToVerify, - classNameToRefer); - throw new AssertionError(msg); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java deleted file mode 100644 index f1c590700a1..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupKlassRefIndexInPoolTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupKlassRefIndexInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupKlassRefIndexInPool} method - */ -public class LookupKlassRefIndexInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_METHODREF, LookupKlassRefIndexInPoolTest::validate); - typeTests.put(CONSTANT_INTERFACEMETHODREF, LookupKlassRefIndexInPoolTest::validate); - typeTests.put(CONSTANT_FIELDREF, LookupKlassRefIndexInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType); - int index = dummyClass.getCPCacheIndex(cpi); - Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten"); - int indexToVerify = CompilerToVMHelper.lookupKlassRefIndexInPool(constantPoolCTVM, index, opcode); - int indexToRefer = dummyClass.constantPoolSS.getClassRefIndexAt(cpi); - String msg = String.format("Wrong class index returned by lookupKlassRefIndexInPool method " - + "applied to cached constant pool index %d", index); - Asserts.assertEQ(indexToRefer, indexToVerify, msg); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java deleted file mode 100644 index 9054aa91c22..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupMethodInPoolTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupMethodInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupMethodInPool} method - */ -public class LookupMethodInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_METHODREF, LookupMethodInPoolTest::validate); - typeTests.put(CONSTANT_INTERFACEMETHODREF, LookupMethodInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int index = cpi; - String cached = ""; - int cpci = dummyClass.getCPCacheIndex(cpi); - if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { - index = cpci; - cached = "cached "; - } - for (int j = 0; j < entry.opcodes.length; j++) { - HotSpotResolvedJavaMethod methodToVerify = CompilerToVMHelper - .lookupMethodInPool(constantPoolCTVM, index, entry.opcodes[j]); - String msg = String.format("Object returned by lookupMethodInPool method" - + " for %sindex %d should not be null", - cached, - index); - Asserts.assertNotNull(methodToVerify, msg); - String[] classNameSplit = entry.klass.split("/"); - String classNameToRefer = classNameSplit[classNameSplit.length - 1]; - String methodNameToRefer = entry.name; - String methodToVerifyToString = methodToVerify.toString(); - if (!methodToVerifyToString.contains(classNameToRefer) - || !methodToVerifyToString.contains(methodNameToRefer)) { - msg = String.format("String representation \"%s\" of the object" - + " returned by lookupMethodInPool method" - + " for index %d does not contain a method's class name" - + " or method's name, should contain %s.%s", - methodToVerifyToString, - index, - classNameToRefer, - methodNameToRefer); - throw new AssertionError(msg); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java deleted file mode 100644 index 0605a4659b8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameAndTypeRefIndexInPoolTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupNameAndTypeRefIndexInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupNameAndTypeRefIndexInPool} method - */ -public class LookupNameAndTypeRefIndexInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_METHODREF, LookupNameAndTypeRefIndexInPoolTest::validate); - typeTests.put(CONSTANT_INTERFACEMETHODREF, LookupNameAndTypeRefIndexInPoolTest::validate); - typeTests.put(CONSTANT_FIELDREF, LookupNameAndTypeRefIndexInPoolTest::validate); - typeTests.put(CONSTANT_INVOKEDYNAMIC, LookupNameAndTypeRefIndexInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType); - int index = dummyClass.getCPCacheIndex(cpi); - Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten"); - int indexToVerify = CompilerToVMHelper.lookupNameAndTypeRefIndexInPool(constantPoolCTVM, index, opcode); - int indexToRefer = dummyClass.constantPoolSS.getNameAndTypeRefIndexAt(cpi); - String msg = String.format("Wrong nameAndType index returned by lookupNameAndTypeRefIndexInPool" - + " method applied to cached constant pool index %d", index); - Asserts.assertEQ(indexToRefer, indexToVerify, msg); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java deleted file mode 100644 index b054444acea..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupNameInPoolTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupNameInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupNameInPool} method - */ -public class LookupNameInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_METHODREF, LookupNameInPoolTest::validate); - typeTests.put(CONSTANT_INTERFACEMETHODREF, LookupNameInPoolTest::validate); - typeTests.put(CONSTANT_FIELDREF, LookupNameInPoolTest::validate); - typeTests.put(CONSTANT_INVOKEDYNAMIC, LookupNameInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType); - int index = dummyClass.getCPCacheIndex(cpi); - Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten"); - String nameToVerify = CompilerToVMHelper.lookupNameInPool(constantPoolCTVM, index, opcode); - String nameToRefer = entry.name; - String msg = String.format("Wrong name accessed by cached constant pool index %d", index); - Asserts.assertEQ(nameToVerify, nameToRefer, msg); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java deleted file mode 100644 index 5dc33ee3d08..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupSignatureInPoolTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupSignatureInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.lookupSignatureInPool} method - */ -public class LookupSignatureInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_METHODREF, LookupSignatureInPoolTest::validate); - typeTests.put(CONSTANT_INTERFACEMETHODREF, LookupSignatureInPoolTest::validate); - typeTests.put(CONSTANT_FIELDREF, LookupSignatureInPoolTest::validate); - typeTests.put(CONSTANT_INVOKEDYNAMIC, LookupSignatureInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int opcode = ConstantPoolTestsHelper.getDummyOpcode(cpType); - int index = dummyClass.getCPCacheIndex(cpi); - Asserts.assertTrue(index != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT, "the class must have been rewritten"); - String sigToVerify = CompilerToVMHelper.lookupSignatureInPool(constantPoolCTVM, index, opcode); - String sigToRefer = entry.type; - String msg = String.format("Wrong signature accessed by cached constant pool index %d", index); - Asserts.assertEQ(sigToVerify, sigToRefer, msg); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupTypeTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupTypeTest.java deleted file mode 100644 index 3f149c9c53e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/LookupTypeTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @modules java.base/jdk.internal.access - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.LookupTypeTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.testcases.DoNotExtendClass; -import compiler.jvmci.common.testcases.MultiSubclassedClass; -import compiler.jvmci.common.testcases.SingleSubclass; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaType; - -import java.io.ByteArrayOutputStream; -import java.io.CharArrayWriter; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -public class LookupTypeTest { - - /** - * Abstracts which lookup method is being tested. - */ - public interface Lookup { - ResolvedJavaType lookupType(String name, Class accessingClass, boolean resolve); - } - - public static void main(String args[]) { - LookupTypeTest test = new LookupTypeTest(); - - // Test CompilerToVM.lookupType - for (TestCase tcase : createTestCases(false, true)) { - test.runTest(tcase, CompilerToVMHelper::lookupType); - } - - // Test HotSpotJVMCIRuntime.lookupType - HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); - MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess(); - for (TestCase tcase : createTestCases(true, false)) { - test.runTest(tcase, (name, accessingClass, resolve) -> (ResolvedJavaType) runtime.lookupType(name, - (HotSpotResolvedObjectType) metaAccess.lookupJavaType(accessingClass), resolve)); - } - } - - private static List createTestCases(boolean allowPrimitive, boolean allowNullAccessingClass) { - List result = new ArrayList<>(); - // a primitive class - if (allowPrimitive) { - result.add(new TestCase(Utils.toJVMTypeSignature(int.class), - LookupTypeTest.class, true, true)); - } else { - result.add(new TestCase(Utils.toJVMTypeSignature(int.class), - LookupTypeTest.class, true, false, InternalError.class)); - } - // lookup not existing class - result.add(new TestCase("Lsome_not_existing;", LookupTypeTest.class, - true, false, NoClassDefFoundError.class)); - // lookup invalid classname - result.add(new TestCase("L!@#$%^&**()[]{}?;", LookupTypeTest.class, - true, false, NoClassDefFoundError.class)); - // lookup package private class - result.add(new TestCase( - "Lcompiler/jvmci/compilerToVM/testcases/PackagePrivateClass;", - LookupTypeTest.class, true, false, - NoClassDefFoundError.class)); - // lookup usual class with resolve=true - result.add(new TestCase(Utils.toJVMTypeSignature(SingleSubclass.class), - LookupTypeTest.class, true, true)); - // lookup usual class with resolve=false - result.add(new TestCase( - Utils.toJVMTypeSignature(DoNotExtendClass.class), - LookupTypeTest.class, false, true)); - // lookup usual class with null accessor - if (allowNullAccessingClass) { - result.add(new TestCase( - Utils.toJVMTypeSignature(MultiSubclassedClass.class), null, - false, false, NullPointerException.class)); - } - return result; - } - - private void runTest(TestCase tcase, Lookup lookup) { - System.out.println(tcase); - ResolvedJavaType metaspaceKlass; - try { - metaspaceKlass = lookup.lookupType(tcase.className, - tcase.accessing, tcase.resolve); - } catch (Throwable t) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - t.printStackTrace(new PrintStream(bos)); - String tString = bos.toString(); - Asserts.assertNotNull(tcase.expectedException, - "Assumed no exception, but got " + tString); - Asserts.assertFalse(tcase.isPositive, - "Got unexpected exception " + tString); - Asserts.assertEQ(t.getClass(), tcase.expectedException, - "Unexpected exception: " + tString); - // passed - return; - } - if (tcase.expectedException != null) { - throw new AssertionError("Expected exception was not thrown: " - + tcase.expectedException.getName()); - } - if (tcase.isPositive) { - Asserts.assertNotNull(metaspaceKlass, - "Unexpected null metaspace klass"); - Asserts.assertEQ(metaspaceKlass.getName(), tcase.className, - "Got unexpected resolved class name"); - } else { - Asserts.assertNull(metaspaceKlass, "Unexpected metaspace klass"); - } - } - - private static class TestCase { - public final String className; - public final Class accessing; - public final boolean resolve; - public final boolean isPositive; - public final Class expectedException; - - public TestCase(String className, Class accessing, boolean resolve, - boolean isPositive, - Class expectedException) { - this.className = className; - this.accessing = accessing; - this.resolve = resolve; - this.isPositive = isPositive; - this.expectedException = expectedException; - } - - public TestCase(String className, Class accessing, boolean resolve, - boolean isPositive) { - this.className = className; - this.accessing = accessing; - this.resolve = resolve; - this.isPositive = isPositive; - this.expectedException = null; - } - - @Override - public String toString() { - return String.format("CASE: class=%s, accessing=%s," - + " resolve=%s, positive=%s, expectedException=%s", className, - accessing, resolve, isPositive, expectedException); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java deleted file mode 100644 index b6b818f5739..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * - * @requires vm.jvmci & vm.compMode == "Xmixed" - * @requires vm.opt.final.EliminateAllocations == true - * @requires vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps - * - * @comment no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved - * @requires vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true - * - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.stack - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbatch -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2 - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3 - * -XX:+DoEscapeAnalysis - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false - * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xbatch -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2 - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3 - * -XX:+DoEscapeAnalysis - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false - * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xbatch -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2 - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3 - * -XX:+DoEscapeAnalysis - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true - * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - * @run main/othervm -Xbatch -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame - * -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2 - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse - * -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3 - * -XX:+DoEscapeAnalysis - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false - * -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true - * compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.testlibrary.CompilerUtils; -import compiler.whitebox.CompilerWhiteBoxTest; -import jdk.test.lib.Asserts; -import jdk.vm.ci.code.stack.InspectedFrame; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotStackFrameReference; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jtreg.SkippedException; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Method; - -public class MaterializeVirtualObjectTest { - private static final WhiteBox WB; - private static final boolean INVALIDATE; - private static final int COMPILE_THRESHOLD; - private static final Method MATERIALIZED_METHOD; - private static final Method NOT_MATERIALIZED_METHOD; - private static final Method FRAME3_METHOD; - private static final ResolvedJavaMethod MATERIALIZED_RESOLVED; - private static final ResolvedJavaMethod NOT_MATERIALIZED_RESOLVED; - private static final ResolvedJavaMethod FRAME2_RESOLVED; - private static final ResolvedJavaMethod FRAME3_RESOLVED; - private static final boolean MATERIALIZE_FIRST; - - static { - Method method1; - Method method2; - WB = WhiteBox.getWhiteBox(); - try { - method1 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame", - String.class, int.class); - method2 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame2", - String.class, int.class); - FRAME3_METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame3", - Helper.class, int.class); - } catch (NoSuchMethodException e) { - throw new Error("Can't get executable for test method", e); - } - ResolvedJavaMethod resolved1; - resolved1 = CTVMUtilities.getResolvedMethod(method1); - FRAME2_RESOLVED = CTVMUtilities.getResolvedMethod(method2); - FRAME3_RESOLVED = CTVMUtilities.getResolvedMethod(FRAME3_METHOD); - INVALIDATE = Boolean.getBoolean( - "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate"); - COMPILE_THRESHOLD = CompilerWhiteBoxTest.THRESHOLD; - MATERIALIZE_FIRST = Boolean.getBoolean( - "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst"); - MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved1 : FRAME2_RESOLVED; - NOT_MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? FRAME2_RESOLVED : resolved1; - MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method1 : method2; - NOT_MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method2 : method1; - } - - public static void main(String[] args) { - int levels[] = CompilerUtils.getAvailableCompilationLevels(); - // we need compilation level 4 to use EscapeAnalysis - if (levels.length < 1 || levels[levels.length - 1] != 4) { - throw new SkippedException("Test needs compilation level 4"); - } - - try { - new MaterializeVirtualObjectTest().test(); - } catch (MaterializationNotSupported e) { - Asserts.assertTrue(Thread.currentThread().isVirtual()); - } - } - - private static String getName() { - return "CASE: invalidate=" + INVALIDATE + ", materializedMethod=" - + (MATERIALIZE_FIRST ? "testFrame" : "testFrame2") - + ", notMaterializedMethod=" - + (MATERIALIZE_FIRST ? "testFrame2" : "testFrame"); - } - - private void test() { - Asserts.assertFalse(WB.isMethodCompiled(MATERIALIZED_METHOD), - getName() + " : materialized method is compiled"); - Asserts.assertFalse(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), - getName() + " : not materialized method is compiled"); - for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { - testFrame("someString", i); - } - Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName() - + " : materialized method not compiled"); - Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), - getName() + " : not materialized method not compiled"); - testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD); - - // run second test types - for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { - testFrame("someString", i); - } - Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName() - + " : materialized method not compiled"); - Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), - getName() + " : not materialized method not compiled"); - testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD + 1); - } - - private void testFrame(String str, int iteration) { - Helper helper = new Helper(str); - testFrame2(str, iteration); - Asserts.assertTrue((helper.string != null) && (this != null) - && (helper != null), String.format("%s : some locals are null", getName())); - } - - private void testFrame2(String str, int iteration) { - Helper helper = new Helper(str); - Helper helper2 = new Helper("bar"); - testFrame3(helper, iteration); - Asserts.assertTrue((helper.string != null) && (this != null) && helper.string == str - && (helper != null), String.format("%s : some locals are null", getName())); - Asserts.assertTrue((helper2.string != null) && (this != null) - && (helper2 != null), String.format("%s : some locals are null", getName())); - } - - private void testFrame3(Helper outerHelper, int iteration) { - Helper innerHelper = new Helper("foo"); - recurse(2, iteration); - Asserts.assertTrue((innerHelper.string != null) && (this != null) - && (innerHelper != null), String.format("%s : some locals are null", getName())); - Asserts.assertTrue((outerHelper.string != null) && (this != null) - && (outerHelper != null), String.format("%s : some locals are null", getName())); - } - - private void recurse(int depth, int iteration) { - if (depth == 0) { - check(iteration); - } else { - Integer s = new Integer(depth); - recurse(depth - 1, iteration); - Asserts.assertEQ(s.intValue(), depth, - String.format("different values: %s != %s", s.intValue(), depth)); - } - } - - private static void materializeVirtualObjects(InspectedFrame f, boolean invalidateCode) { - try { - f.materializeVirtualObjects(invalidateCode); - } catch (IllegalArgumentException e) { - throw new MaterializationNotSupported(e); - } - } - - private void checkStructure(boolean materialize) { - boolean[] framesSeen = new boolean[2]; - Object[] helpers = new Object[1]; - CompilerToVMHelper.iterateFrames( - new ResolvedJavaMethod[] {FRAME3_RESOLVED}, - null, /* any */ - 0, - f -> { - if (!framesSeen[1]) { - Asserts.assertTrue(f.isMethod(FRAME3_RESOLVED), - "Expected testFrame3 first"); - framesSeen[1] = true; - Asserts.assertTrue(f.getLocal(0) != null, "this should not be null"); - Asserts.assertTrue(f.getLocal(1) != null, "outerHelper should not be null"); - Asserts.assertTrue(f.getLocal(3) != null, "innerHelper should not be null"); - Asserts.assertEQ(((Helper) f.getLocal(3)).string, "foo", "innerHelper.string should be foo"); - helpers[0] = f.getLocal(1); - if (materialize) { - materializeVirtualObjects(f, false); - } - return null; //continue - } else { - Asserts.assertFalse(framesSeen[0], "frame3 can not have been seen"); - Asserts.assertTrue(f.isMethod(FRAME2_RESOLVED), - "Expected testFrame2 second"); - framesSeen[0] = true; - Asserts.assertTrue(f.getLocal(0) != null, "this should not be null"); - Asserts.assertTrue(f.getLocal(1) != null, "str should not be null"); - Asserts.assertTrue(f.getLocal(3) != null, "helper should not be null"); - Asserts.assertTrue(f.getLocal(4) != null, "helper2 should not be null"); - Asserts.assertEQ(((Helper) f.getLocal(3)).string, f.getLocal(1), "helper.string should be the same as str"); - Asserts.assertEQ(((Helper) f.getLocal(4)).string, "bar", "helper2.string should be foo"); - if (!materialize) { - Asserts.assertEQ(f.getLocal(3), helpers[0], "helper should be the same as frame3's outerHelper"); - } - return f; // stop - } - }); - Asserts.assertTrue(framesSeen[1], "frame3 should have been seen"); - Asserts.assertTrue(framesSeen[0], "frame2 should have been seen"); - } - - private void check(int iteration) { - // Materialize virtual objects on last invocation - if (iteration == COMPILE_THRESHOLD) { - // get frames and check not-null - HotSpotStackFrameReference materialized = CompilerToVMHelper.iterateFrames( - new ResolvedJavaMethod[] {MATERIALIZED_RESOLVED}, - null /* any */, - 0, - f -> (HotSpotStackFrameReference) f); - Asserts.assertNotNull(materialized, getName() - + " : got null frame for materialized method"); - Asserts.assertTrue(materialized.isMethod(MATERIALIZED_RESOLVED), - "Expected materialized method but got " + materialized); - InspectedFrame notMaterialized = CompilerToVMHelper.iterateFrames( - new ResolvedJavaMethod[] {NOT_MATERIALIZED_RESOLVED}, - null /* any */, - 0, - f -> f); - Asserts.assertNE(materialized, notMaterialized, - "Got same frame pointer for both tested frames"); - Asserts.assertTrue(notMaterialized.isMethod(NOT_MATERIALIZED_RESOLVED), - "Expected notMaterialized method but got " + notMaterialized); - Asserts.assertNotNull(notMaterialized, getName() - + " : got null frame for not materialized method"); - Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName() - + " : materialized method not compiled"); - Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), - getName() + " : not materialized method not compiled"); - // check that frames has virtual objects before materialization stage - Asserts.assertTrue(materialized.hasVirtualObjects(), getName() - + ": materialized frame has no virtual object before materialization"); - Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName() - + ": notMaterialized frame has no virtual object before materialization"); - // materialize - materializeVirtualObjects(materialized, INVALIDATE); - // check that only not materialized frame has virtual objects - Asserts.assertFalse(materialized.hasVirtualObjects(), getName() - + " : materialized has virtual object after materialization"); - Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName() - + " : notMaterialized has no virtual object after materialization"); - // check that materialized frame was deoptimized in case invalidate=true - Asserts.assertEQ(WB.isMethodCompiled(MATERIALIZED_METHOD), !INVALIDATE, getName() - + " : materialized method has unexpected compiled status"); - // check that not materialized frame wasn't deoptimized - Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), getName() - + " : not materialized method has unexpected compiled status"); - } else if (iteration == COMPILE_THRESHOLD + 1) { - checkStructure(false); - checkStructure(true); - } - } - - private class Helper { - public String string; - - public Helper(String s) { - this.string = s; - } - } - - static class MaterializationNotSupported extends RuntimeException { - public MaterializationNotSupported(Throwable cause) { - super(cause); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java deleted file mode 100644 index 17000b7fa01..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.MethodIsIgnoredBySecurityStackWalkTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -import java.lang.reflect.Executable; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -public class MethodIsIgnoredBySecurityStackWalkTest { - - public static void main(String[] args) { - Map testCases = createTestCases(); - testCases.forEach( - MethodIsIgnoredBySecurityStackWalkTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod, Boolean expected) { - HotSpotResolvedJavaMethod method - = CTVMUtilities.getResolvedMethod(aMethod); - boolean isIgnored = CompilerToVMHelper - .methodIsIgnoredBySecurityStackWalk(method); - String msg = String.format("%s is%s ignored but must%s", aMethod, - isIgnored ? "" : " not", - expected ? "" : " not"); - Asserts.assertEQ(isIgnored, expected, msg); - } - - private static Map createTestCases() { - Map testCases = new HashMap<>(); - - try { - Class aClass = Method.class; - testCases.put(aClass.getMethod("invoke", Object.class, - Object[].class), true); - - aClass = Class.forName("jdk.internal.reflect.DirectMethodHandleAccessor$NativeAccessor"); - testCases.put(aClass.getMethod("invoke", Object.class, - Object[].class), true); - testCases.put(aClass.getDeclaredMethod("invoke0", Method.class, - Object.class, Object[].class), true); - - aClass = MethodIsIgnoredBySecurityStackWalkTest.class; - for (Executable method : aClass.getMethods()) { - testCases.put(method, false); - } - for (Executable method : aClass.getDeclaredMethods()) { - testCases.put(method, false); - } - for (Executable method : aClass.getConstructors()) { - testCases.put(method, false); - } - } catch (NoSuchMethodException | ClassNotFoundException e) { - throw new Error("TEST BUG " + e.getMessage(), e); - } - return testCases; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReadConfigurationTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReadConfigurationTest.java deleted file mode 100644 index af130b8747a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReadConfigurationTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build compiler.jvmci.compilerToVM.ReadConfigurationTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.ReadConfigurationTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.VMField; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; -import jdk.vm.ci.hotspot.VMIntrinsicMethod; - -public class ReadConfigurationTest { - public static void main(String args[]) { - new ReadConfigurationTest().runTest(); - } - - private void runTest() { - HotSpotVMConfigStore store = HotSpotJVMCIRuntime.runtime().getConfigStore(); - TestHotSpotVMConfig config = new TestHotSpotVMConfig(store); - Asserts.assertNE(config.codeCacheHighBound, 0L, "Got null address"); - Asserts.assertNE(config.stubRoutineJintArrayCopy, 0L, "Got null address"); - - for (VMField field : store.getFields().values()) { - Object value = field.value; - if (value != null) { - Asserts.assertTrue(value instanceof Long || value instanceof Boolean, - "Got unexpected value type for VM field " + field.name + ": " + value.getClass()); - } - } - - for (VMIntrinsicMethod m : config.getStore().getIntrinsics()) { - Asserts.assertNotNull(m); - Asserts.assertNotNull(m.declaringClass); - Asserts.assertFalse(m.declaringClass.contains("."), - "declaringClass should be in class file format: " + m.declaringClass); - Asserts.assertNotNull(m.name); - Asserts.assertNotNull(m.descriptor); - Asserts.assertTrue(m.id > 0); - } - } - - private static class TestHotSpotVMConfig extends HotSpotVMConfigAccess { - - private TestHotSpotVMConfig(HotSpotVMConfigStore store) { - super(store); - } - - final long codeCacheHighBound = getFieldValue("CodeCache::_high_bound", Long.class); - final long stubRoutineJintArrayCopy = getFieldValue("StubRoutines::_jint_arraycopy", Long.class); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReprofileTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReprofileTest.java deleted file mode 100644 index 9e8beec3395..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReprofileTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -Xmixed -Xbatch - * -XX:TypeProfileLevel=0 - * compiler.jvmci.compilerToVM.ReprofileTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.whitebox.CompilerWhiteBoxTest; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.ProfilingInfo; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -public class ReprofileTest { - - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(ReprofileTest::runSanityTest); - } - - private static List createTestCases() { - List testCases = new ArrayList<>(); - try { - - Class aClass = DummyClass.class; - testCases.add(aClass.getMethod("dummyInstanceFunction")); - - aClass = DummyClass.class; - testCases.add(aClass.getMethod("dummyFunction")); - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG " + e.getMessage(), e); - } - return testCases; - } - - private static void runSanityTest(Method aMethod) { - System.out.println(aMethod); - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - ProfilingInfo startProfile = method.getProfilingInfo(); - Asserts.assertFalse(startProfile.isMature(), aMethod - + " : profiling info is mature in the beginning"); - - // make interpreter to profile this method - try { - Object obj = aMethod.getDeclaringClass().newInstance(); - for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { - aMethod.invoke(obj); - } - } catch (ReflectiveOperationException e) { - throw new Error("TEST BUG : " + e.getMessage(), e); - } - ProfilingInfo compProfile = method.getProfilingInfo(); - - Asserts.assertNE(startProfile.toString(), compProfile.toString(), - String.format("%s : profiling info wasn't changed after " - + "%d invocations", - aMethod, CompilerWhiteBoxTest.THRESHOLD)); - Asserts.assertTrue(compProfile.isMature(), - String.format("%s is not mature after %d invocations", - aMethod, CompilerWhiteBoxTest.THRESHOLD)); - - CompilerToVMHelper.reprofile(method); - ProfilingInfo reprofiledProfile = method.getProfilingInfo(); - - Asserts.assertNE(startProfile.toString(), reprofiledProfile.toString(), - aMethod + " : profiling info wasn't changed after reprofiling"); - Asserts.assertNE(compProfile.toString(), reprofiledProfile.toString(), - aMethod + " : profiling info didn't change after reprofile"); - Asserts.assertFalse(reprofiledProfile.isMature(), aMethod - + " : profiling info is mature after reprofiling"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java deleted file mode 100644 index ab693c0e2d0..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8138708 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.misc - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.ResolveFieldInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.internal.misc.Unsafe; -import org.objectweb.asm.Opcodes; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.ConstantPool; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method - */ -public class ResolveFieldInPoolTest { - - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_FIELDREF, ResolveFieldInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - private static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int cpi) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); - if (entry == null) { - return; - } - int index = cpi; - String cached = ""; - int cpci = dummyClass.getCPCacheIndex(cpi); - if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { - index = cpci; - cached = "cached "; - } - for (int j = 0; j < entry.opcodes.length; j++) { - int[] info = new int[4]; - HotSpotResolvedObjectType fieldToVerify - = CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM, - index, - entry.methods == null ? null : entry.methods[j], - entry.opcodes[j], - info); - String msg = String.format("Object returned by resolveFieldInPool method" - + " for %sindex %d should not be null", - cached, - index); - Asserts.assertNotNull(fieldToVerify, msg); - String classNameToRefer = entry.klass; - String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString(); - if (!fieldToVerifyKlassToString.contains(classNameToRefer)) { - msg = String.format("String representation \"%s\" of the object" - + " returned by resolveFieldInPool method" - + " for index %d does not contain a field's class name," - + " should contain %s", - fieldToVerifyKlassToString, - index, - classNameToRefer); - throw new AssertionError(msg); - } - msg = String.format("Access flags returned by resolveFieldInPool" - + " method are wrong for the field %s.%s" - + " at %sindex %d", - entry.klass, - entry.name, - cached, - index); - Asserts.assertEQ(info[0], entry.accFlags, msg); - if (cpci == -1) { - return; - } - Class classOfTheField = null; - Field fieldToRefer = null; - try { - classOfTheField = Class.forName(classNameToRefer.replaceAll("/", "\\.")); - fieldToRefer = classOfTheField.getDeclaredField(entry.name); - fieldToRefer.setAccessible(true); - } catch (Exception ex) { - throw new Error("Unexpected exception", ex); - } - int offsetToRefer; - if ((entry.accFlags & Opcodes.ACC_STATIC) != 0) { - offsetToRefer = (int) UNSAFE.staticFieldOffset(fieldToRefer); - } else { - offsetToRefer = (int) UNSAFE.objectFieldOffset(fieldToRefer); - } - msg = String.format("Field offset returned by resolveFieldInPool" - + " method is wrong for the field %s.%s" - + " at %sindex %d", - entry.klass, - entry.name, - cached, - index); - Asserts.assertEQ(info[1], offsetToRefer, msg); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveMethodTest.java deleted file mode 100644 index 33bb73af331..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.ResolveMethodTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import compiler.jvmci.common.testcases.AbstractClass; -import compiler.jvmci.common.testcases.AbstractClassExtender; -import compiler.jvmci.common.testcases.MultipleImplementer1; -import compiler.jvmci.common.testcases.MultipleImplementer2; -import compiler.jvmci.common.testcases.MultipleImplementersInterface; -import compiler.jvmci.common.testcases.SingleImplementer; -import compiler.jvmci.common.testcases.SingleImplementerInterface; -import compiler.jvmci.common.testcases.SingleSubclass; -import compiler.jvmci.common.testcases.SingleSubclassedClass; -import jdk.internal.misc.Unsafe; -import jdk.test.lib.Asserts; -import jdk.test.lib.Utils; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; - -import java.util.HashSet; -import java.util.Set; - -public class ResolveMethodTest { - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - - public static void main(String args[]) { - ResolveMethodTest test = new ResolveMethodTest(); - // positive cases - try { - for (TestCase tcase: createTestCases()) { - test.runTest(tcase); - } - } catch (NoSuchMethodException e) { - throw new Error("TEST BUG: can't find requested method", e); - } - } - - private static Set createTestCases() { - Set result = new HashSet<>(); - // a usual class public method - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "usualMethod", ResolveMethodTest.class, true)); - // an array method - result.add(new TestCase(int[].class, Object.class, "toString", - ResolveMethodTest.class, true)); - // a method from base class, which was overriden in tested one - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "overridenMethod", ResolveMethodTest.class, true)); - // a method from base class, which was not overriden in tested one - result.add(new TestCase(SingleSubclass.class, - SingleSubclassedClass.class, "inheritedMethod", - ResolveMethodTest.class, true)); - /* a method from base class, which was overriden in tested one with - base class as holder */ - result.add(new TestCase(SingleSubclass.class, - SingleSubclassedClass.class, "overridenMethod", - ResolveMethodTest.class, true)); - // an interface method - result.add(new TestCase(SingleImplementer.class, - SingleImplementerInterface.class, "interfaceMethod", - ResolveMethodTest.class, true)); - // an interface default method overriden in implementer - result.add(new TestCase(MultipleImplementer1.class, - MultipleImplementersInterface.class, "defaultMethod", - ResolveMethodTest.class, true)); - // an interface default method not overriden in implementer - result.add(new TestCase(MultipleImplementer2.class, - MultipleImplementersInterface.class, "defaultMethod", - ResolveMethodTest.class, true)); - // an abstract method - result.add(new TestCase(AbstractClassExtender.class, AbstractClass.class, - "abstractMethod", ResolveMethodTest.class, true)); - // private method with right accessor - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "privateMethod", SingleSubclass.class, true)); - // package-private method with right accessor - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "defaultAccessMethod", SingleSubclass.class, true)); - - // negative cases - - // private method of another class - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "privateMethod", ResolveMethodTest.class, false)); - // package-private method from another package - result.add(new TestCase(SingleSubclass.class, SingleSubclass.class, - "defaultAccessMethod", ResolveMethodTest.class, false)); - return result; - } - - private void runTest(TestCase tcase) throws NoSuchMethodException { - System.out.println(tcase); - HotSpotResolvedJavaMethod metaspaceMethod = CTVMUtilities - .getResolvedMethod(tcase.holder, - tcase.holder.getDeclaredMethod(tcase.methodName)); - HotSpotResolvedObjectType holderMetaspace = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.holder), - getClass(), /* resolve = */ true); - HotSpotResolvedObjectType callerMetaspace = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.caller), - getClass(), /* resolve = */ true); - HotSpotResolvedObjectType receiverMetaspace = CompilerToVMHelper - .lookupTypeHelper(Utils.toJVMTypeSignature(tcase.receiver), - getClass(), /* resolve = */ true); - - // Can only resolve methods on a linked class so force initialization - receiverMetaspace.initialize(); - HotSpotResolvedJavaMethod resolvedMetaspaceMethod - = CompilerToVMHelper.resolveMethod(receiverMetaspace, - metaspaceMethod, callerMetaspace); - if (tcase.isPositive) { - Asserts.assertNotNull(resolvedMetaspaceMethod, - "Unexpected null resolved method value for " - + tcase.methodName); - Asserts.assertEQ(metaspaceMethod.getName(), tcase.methodName, - "Reflection and c2vm method names doesn't match"); - } else { - Asserts.assertNull(resolvedMetaspaceMethod, - "Method unexpectedly resolved"); - } - } - - private static class TestCase { - public final Class receiver; - public final Class holder; - public final Class caller; - public final String methodName; - public final boolean isPositive; - - public TestCase(Class recv, Class holder, String methodName, - Class caller, boolean isPositive) { - this.receiver = recv; - this.holder = holder; - this.caller = caller; - this.methodName = methodName; - this.isPositive = isPositive; - } - - @Override - public String toString() { - return String.format("CASE: receiver=%s, holder=%s, method=%s," - + "caller=%s, isPositive=%s%n", receiver.getName(), - holder.getName(), methodName, caller.getName(), isPositive); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java deleted file mode 100644 index 6acd555ea84..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ResolveTypeInPoolTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @summary Testing compiler.jvmci.CompilerToVM.resolveTypeInPool method - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.access - * java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.ResolveTypeInPoolTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; -import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; -import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.meta.ConstantPool; - -import java.util.HashMap; -import java.util.Map; - -import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_CLASS; - -/** - * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveTypeInPool} method - */ -public class ResolveTypeInPoolTest { - - public static void main(String[] args) throws Exception { - Map typeTests = new HashMap<>(); - typeTests.put(CONSTANT_CLASS, ResolveTypeInPoolTest::validate); - ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); - testCase.test(); - // The next "Class.forName" and repeating "testCase.test()" - // are here for the following reason. - // The first test run is without dummy class initialization, - // which means no constant pool cache exists. - // The second run is with initialized class (with constant pool cache available). - // Some CompilerToVM methods require different input - // depending on whether CP cache exists or not. - for (DummyClasses dummy : DummyClasses.values()) { - Class.forName(dummy.klass.getName()); - } - testCase.test(); - } - - public static void validate(ConstantPool constantPoolCTVM, - ConstantTypes cpType, - DummyClasses dummyClass, - int i) { - TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, i); - if (entry == null) { - return; - } - HotSpotResolvedObjectType typeToVerify = CompilerToVMHelper.resolveTypeInPool(constantPoolCTVM, i); - String classNameToRefer = entry.klass; - String outputToVerify = typeToVerify.toString(); - if (!outputToVerify.contains(classNameToRefer)) { - String msg = String.format("Wrong class accessed by constant" - + " pool index %d: %s, but should be %s", - i, - outputToVerify, - classNameToRefer); - throw new AssertionError(msg); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java deleted file mode 100644 index 0cefb66e711..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library / /test/lib/ - * @library ../common/patches - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UnlockDiagnosticVMOptions - * -XX:+DebugNonSafepoints - * -Dcompiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest.expected=true - * compiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:+UnlockDiagnosticVMOptions - * -XX:-DebugNonSafepoints - * -Dcompiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest.expected=false - * compiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest - */ - -package compiler.jvmci.compilerToVM; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; - -public class ShouldDebugNonSafepointsTest { - private static final boolean EXPECTED = Boolean.getBoolean("compiler" - + ".jvmci.compilerToVM.ShouldDebugNonSafepointsTest.expected"); - - public static void main(String args[]) { - new ShouldDebugNonSafepointsTest().runTest(); - } - - private void runTest() { - Asserts.assertEQ(CompilerToVMHelper.shouldDebugNonSafepoints(), - EXPECTED, "Unexpected shouldDebugnonSafepoints value"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java deleted file mode 100644 index 77f0d534220..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler - * compiler.jvmci.compilerToVM.ShouldInlineMethodTest - */ - -package compiler.jvmci.compilerToVM; - -import compiler.jvmci.common.CTVMUtilities; -import jdk.test.lib.Asserts; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.test.whitebox.WhiteBox; - -import java.lang.reflect.Executable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class ShouldInlineMethodTest { - - private static final WhiteBox WB = WhiteBox.getWhiteBox(); - - public static void main(String[] args) { - List testCases = createTestCases(); - testCases.forEach(ShouldInlineMethodTest::runSanityTest); - } - - private static void runSanityTest(Executable aMethod) { - HotSpotResolvedJavaMethod method = CTVMUtilities - .getResolvedMethod(aMethod); - boolean shouldInline = CompilerToVMHelper.shouldInlineMethod(method); - boolean expectedShouldInline = WB.testSetForceInlineMethod(aMethod, - true); - Asserts.assertEQ(shouldInline, expectedShouldInline, - "Unexpected value of property 'should inline'"); - - shouldInline = CompilerToVMHelper.shouldInlineMethod(method); - Asserts.assertTrue(shouldInline, "Unexpected value of property " - + "'should inline' after setting 'force inline' to true"); - WB.testSetForceInlineMethod(aMethod, false); - shouldInline = CompilerToVMHelper.shouldInlineMethod(method); - Asserts.assertFalse(shouldInline, "Unexpected value of property " - + "'should inline' after setting 'force inline' to false"); - } - - private static List createTestCases() { - List testCases = new ArrayList<>(); - - Class aClass = DummyClass.class; - testCases.addAll(Arrays.asList(aClass.getDeclaredMethods())); - testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors())); - return testCases; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/libIterateFramesNative.c b/test/hotspot/jtreg/compiler/jvmci/compilerToVM/libIterateFramesNative.c deleted file mode 100644 index 747c0c365e2..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/compilerToVM/libIterateFramesNative.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define CHECK_EXCEPTIONS if ((*env)->ExceptionCheck(env)) return - -JNIEXPORT void JNICALL Java_compiler_jvmci_compilerToVM_IterateFramesNative_callerNative(JNIEnv *env, jobject obj, jobject runnable) { - jclass cls = (*env)->GetObjectClass(env, runnable); - jmethodID runMethodID = (*env)->GetMethodID(env, cls, "run", "()V"); - CHECK_EXCEPTIONS; - (*env)->CallVoidMethod(env, runnable, runMethodID); - CHECK_EXCEPTIONS; -} - -#ifdef __cplusplus -} -#endif diff --git a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidCompilationResult.java b/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidCompilationResult.java deleted file mode 100644 index afd08eb69ca..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidCompilationResult.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @library / - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler compiler.jvmci.errors.TestInvalidCompilationResult - */ - -package compiler.jvmci.errors; - -import compiler.jvmci.common.CodeInstallerTest; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.InfopointReason; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.code.site.Reference; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.VMConstant; -import org.junit.Test; - -/** - * Tests for errors in the code installer. - */ -public class TestInvalidCompilationResult extends CodeInstallerTest { - - private static class InvalidAssumption extends Assumption { - } - - private static class InvalidVMConstant implements VMConstant { - - public boolean isDefaultForKind() { - return false; - } - - public String toValueString() { - return null; - } - } - - private static class InvalidReference extends Reference { - - @Override - public int hashCode() { - return 0; - } - - @Override - public boolean equals(Object obj) { - return false; - } - } - - // DataSectionAlignment value matches the alignment sizeof(jdouble) of the CodeBuffer::SECT_CONSTS code section - static final int validDataSectionAlignment = 8; - - @Test(expected = JVMCIError.class) - public void testInvalidAssumption() { - installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidAlignment() { - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0], null); - } - - @Test(expected = NullPointerException.class) - public void testNullDataPatchInDataSection() { - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{null}, null); - } - - @Test(expected = NullPointerException.class) - public void testNullReferenceInDataSection() { - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, null)}, null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidDataSectionReference() { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(0); - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidNarrowMethodInDataSection() { - HotSpotConstant c = (HotSpotConstant) dummyMethod.getEncoding(); - ConstantReference ref = new ConstantReference((VMConstant) c.compress()); - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null); - } - - @Test(expected = JVMCIError.class) - public void testNullConstantInDataSection() { - ConstantReference ref = new ConstantReference(null); - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidConstantInDataSection() { - ConstantReference ref = new ConstantReference(new InvalidVMConstant()); - installEmptyCode(new Site[0], new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[]{new DataPatch(0, ref)}, null); - } - - @Test(expected = JVMCIError.class) - public void testNullReferenceInCode() { - installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testNullConstantInCode() { - ConstantReference ref = new ConstantReference(null); - installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidConstantInCode() { - ConstantReference ref = new ConstantReference(new InvalidVMConstant()); - installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidReference() { - InvalidReference ref = new InvalidReference(); - installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testOutOfBoundsDataSectionReference() { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(0x1000); - installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidMark() { - installEmptyCode(new Site[]{new Mark(0, new Object())}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInvalidMarkInt() { - installEmptyCode(new Site[]{new Mark(0, -1)}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = NullPointerException.class) - public void testNullSite() { - installEmptyCode(new Site[]{null}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testInfopointMissingDebugInfo() { - Infopoint info = new Infopoint(0, null, InfopointReason.METHOD_START); - installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], null); - } - - @Test(expected = JVMCIError.class) - public void testSafepointMissingDebugInfo() { - Infopoint info = new Infopoint(0, null, InfopointReason.SAFEPOINT); - StackSlot deoptRescueSlot = StackSlot.get(null, 0, true); - installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], deoptRescueSlot); - } - - @Test(expected = JVMCIError.class) - public void testInvalidDeoptRescueSlot() { - StackSlot deoptRescueSlot = StackSlot.get(null, -1, false); - installEmptyCode(new Site[]{}, new Assumption[0], new Comment[0], validDataSectionAlignment, new DataPatch[0], deoptRescueSlot); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidDebugInfo.java b/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidDebugInfo.java deleted file mode 100644 index 6443b4f4b44..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidDebugInfo.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @library / - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler compiler.jvmci.errors.TestInvalidDebugInfo - */ - -package compiler.jvmci.errors; - -import compiler.jvmci.common.CodeInstallerTest; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.InfopointReason; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotReferenceMap; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Value; -import jdk.vm.ci.meta.ValueKind; -import org.junit.Test; - -/** - * Tests for errors in debug info. - */ -public class TestInvalidDebugInfo extends CodeInstallerTest { - - private static class UnknownJavaValue implements JavaValue { - } - - private static class TestValueKind extends ValueKind { - - TestValueKind(Architecture arch, JavaKind kind) { - this(arch.getPlatformKind(kind)); - } - - TestValueKind(PlatformKind kind) { - super(kind); - } - - @Override - public TestValueKind changeType(PlatformKind kind) { - return new TestValueKind(kind); - } - } - - private void test(JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks) { - test(null, values, slotKinds, locals, stack, locks); - } - - private void test(VirtualObject[] vobj, JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks) { - test(vobj, values, slotKinds, locals, stack, locks, StackSlot.get(null, 0, true)); - } - - private void test(VirtualObject[] vobj, JavaValue[] values, JavaKind[] slotKinds, int locals, int stack, int locks, StackSlot deoptRescueSlot) { - BytecodeFrame frame = new BytecodeFrame(null, dummyMethod, 0, false, false, values, slotKinds, locals, stack, locks); - DebugInfo info = new DebugInfo(frame, vobj); - info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8)); - installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 8, new DataPatch[0], deoptRescueSlot); - } - - @Test(expected = NullPointerException.class) - public void testNullValues() { - test(null, new JavaKind[0], 0, 0, 0); - } - - @Test(expected = NullPointerException.class) - public void testNullSlotKinds() { - test(new JavaValue[0], null, 0, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testMissingDeoptRescueSlot() { - test(null, new JavaValue[0], new JavaKind[0], 0, 0, 0, null); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedScopeValuesLength() { - test(new JavaValue[]{JavaConstant.FALSE}, new JavaKind[0], 0, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedScopeSlotKindsLength() { - test(new JavaValue[0], new JavaKind[]{JavaKind.Boolean}, 0, 0, 0); - } - - @Test(expected = NullPointerException.class) - public void testNullValue() { - test(new JavaValue[]{null}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = NullPointerException.class) - public void testNullSlotKind() { - test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{null}, 1, 0, 0); - } - - @Test(expected = NullPointerException.class) - public void testNullMonitor() { - test(new JavaValue[]{null}, new JavaKind[0], 0, 0, 1); - } - - @Test(expected = JVMCIError.class) - public void testWrongMonitorType() { - test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[0], 0, 0, 1); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedIllegalValue() { - test(new JavaValue[]{Value.ILLEGAL}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedTypeInCPURegister() { - Register reg = getRegister(arch.getPlatformKind(JavaKind.Int), 0); - test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Void}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedTypeInFloatRegister() { - Register reg = getRegister(arch.getPlatformKind(JavaKind.Float), 0); - test(new JavaValue[]{reg.asValue()}, new JavaKind[]{JavaKind.Void}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedTypeOnStack() { - ValueKind kind = new TestValueKind(codeCache.getTarget().arch, JavaKind.Int); - StackSlot value = StackSlot.get(kind, 8, false); - test(new JavaValue[]{value}, new JavaKind[]{JavaKind.Void}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testWrongConstantType() { - test(new JavaValue[]{JavaConstant.INT_0}, new JavaKind[]{JavaKind.Object}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnsupportedConstantType() { - test(new JavaValue[]{JavaConstant.forShort((short) 0)}, new JavaKind[]{JavaKind.Short}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedNull() { - test(new JavaValue[]{JavaConstant.NULL_POINTER}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedObject() { - JavaValue wrapped = constantReflection.forObject(this); - test(new JavaValue[]{wrapped}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnknownJavaValue() { - test(new JavaValue[]{new UnknownJavaValue()}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testMissingIllegalAfterDouble() { - test(new JavaValue[]{JavaConstant.DOUBLE_0, JavaConstant.INT_0}, new JavaKind[]{JavaKind.Double, JavaKind.Int}, 2, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testInvalidVirtualObjectId() { - ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class); - VirtualObject o = VirtualObject.get(obj, 5); - o.setValues(new JavaValue[0], new JavaKind[0]); - - test(new VirtualObject[]{o}, new JavaValue[0], new JavaKind[0], 0, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testDuplicateVirtualObject() { - ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class); - VirtualObject o1 = VirtualObject.get(obj, 0); - o1.setValues(new JavaValue[0], new JavaKind[0]); - - VirtualObject o2 = VirtualObject.get(obj, 0); - o2.setValues(new JavaValue[0], new JavaKind[0]); - - test(new VirtualObject[]{o1, o2}, new JavaValue[0], new JavaKind[0], 0, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUnexpectedVirtualObject() { - ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class); - VirtualObject o = VirtualObject.get(obj, 0); - o.setValues(new JavaValue[0], new JavaKind[0]); - - test(new VirtualObject[]{o}, new JavaValue[]{o}, new JavaKind[]{JavaKind.Int}, 1, 0, 0); - } - - @Test(expected = JVMCIError.class) - public void testUndefinedVirtualObject() { - ResolvedJavaType obj = metaAccess.lookupJavaType(Object.class); - VirtualObject o0 = VirtualObject.get(obj, 0); - o0.setValues(new JavaValue[0], new JavaKind[0]); - - VirtualObject o1 = VirtualObject.get(obj, 1); - o1.setValues(new JavaValue[0], new JavaKind[0]); - - test(new VirtualObject[]{o0}, new JavaValue[]{o1}, new JavaKind[]{JavaKind.Object}, 1, 0, 0); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidOopMap.java b/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidOopMap.java deleted file mode 100644 index a17970ef0b6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidOopMap.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @library / - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler compiler.jvmci.errors.TestInvalidOopMap - */ - -package compiler.jvmci.errors; - -import compiler.jvmci.common.CodeInstallerTest; -import jdk.vm.ci.code.BytecodePosition; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.ReferenceMap; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.InfopointReason; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotReferenceMap; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; -import org.junit.Test; - -/** - * Tests for errors in oop maps. - */ -public class TestInvalidOopMap extends CodeInstallerTest { - - private static class InvalidReferenceMap extends ReferenceMap { - } - - private void test(ReferenceMap refMap) { - BytecodePosition pos = new BytecodePosition(null, dummyMethod, 0); - DebugInfo info = new DebugInfo(pos); - info.setReferenceMap(refMap); - installEmptyCode(new Site[]{new Infopoint(0, info, InfopointReason.SAFEPOINT)}, new Assumption[0], new Comment[0], 8, new DataPatch[0], StackSlot.get(null, 0, true)); - } - - @Test(expected = JVMCIError.class) - public void testMissingReferenceMap() { - test(null); - } - - @Test(expected = ClassCastException.class) - public void testInvalidReferenceMap() { - test(new InvalidReferenceMap()); - } - - @Test(expected = NullPointerException.class) - public void testNullOops() { - test(new HotSpotReferenceMap(null, new Location[0], new int[0], 8)); - } - - @Test(expected = NullPointerException.class) - public void testNullBase() { - test(new HotSpotReferenceMap(new Location[0], null, new int[0], 8)); - } - - @Test(expected = NullPointerException.class) - public void testNullSize() { - test(new HotSpotReferenceMap(new Location[0], new Location[0], null, 8)); - } - - @Test(expected = JVMCIError.class) - public void testInvalidLength() { - test(new HotSpotReferenceMap(new Location[1], new Location[2], new int[3], 8)); - } - - @Test(expected = JVMCIError.class) - public void testInvalidShortOop() { - PlatformKind kind = arch.getPlatformKind(JavaKind.Short); - Register reg = getRegister(kind, 0); - - Location[] oops = new Location[]{Location.register(reg)}; - Location[] base = new Location[]{null}; - int[] size = new int[]{kind.getSizeInBytes()}; - - test(new HotSpotReferenceMap(oops, base, size, 8)); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidTieredStopAtLevel.java b/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidTieredStopAtLevel.java deleted file mode 100644 index 0a00987f3d8..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidTieredStopAtLevel.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2020, Tencent. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8241232 - * @requires vm.flagless - * @requires vm.jvmci - * @library /test/lib - * @run driver TestInvalidTieredStopAtLevel - */ - -import jdk.test.lib.process.ProcessTools; - -public class TestInvalidTieredStopAtLevel { - public static void main(String... args) throws Exception { - ProcessTools.executeTestJava("-XX:+UnlockExperimentalVMOptions", - "-XX:+UseJVMCICompiler", - "-XX:+BootstrapJVMCI", - "-XX:TieredStopAtLevel=1", - "-Xcomp") - .outputTo(System.out) - .errorTo(System.out) - .stdoutShouldNotContain("hs_err"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.config b/test/hotspot/jtreg/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.config deleted file mode 100644 index 494110c8bd2..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.config +++ /dev/null @@ -1 +0,0 @@ -compiler.jvmci.events.JvmciCreateMetaAccessContextTest diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config deleted file mode 100644 index 709b87f94ef..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config +++ /dev/null @@ -1,2 +0,0 @@ -compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest$Locator -compiler.jvmci.common.JVMCIHelpers diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java deleted file mode 100644 index 8d3b5fcce5b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8156034 - * @requires vm.jvmci & !vm.graal.enabled & vm.compMode == "Xmixed" & vm.opt.TieredStopAtLevel == null - * @library / /test/lib - * @library ../common/patches - * @library /testlibrary/asm - * @modules java.base/jdk.internal.misc - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.services - * - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @build compiler.jvmci.common.JVMCIHelpers - * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config - * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator - * @run driver jdk.test.lib.helpers.ClassFileInstaller - * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler - * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory - * compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult - * compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. - * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI -XX:-UseJVMCINativeLibrary - * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=false - * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. - * -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI -XX:-UseJVMCINativeLibrary - * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=true - * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest - */ - -package compiler.jvmci.events; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.hotspot.HotSpotVMEventListener; - -public class JvmciNotifyBootstrapFinishedEventTest { - private static final boolean BOOTSTRAP = Boolean - .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); - private static volatile int gotBootstrapNotification = 0; - - public static void main(String args[]) { - if (BOOTSTRAP) { - Asserts.assertEQ(gotBootstrapNotification, 1, "Did not receive expected number of bootstrap events"); - } else { - Asserts.assertEQ(gotBootstrapNotification, 0, "Got unexpected bootstrap event"); - } - } - - public static class Locator extends JVMCIServiceLocator implements HotSpotVMEventListener { - public Locator() { - Thread.dumpStack(); - } - @Override - public S getProvider(Class service) { - if (service == HotSpotVMEventListener.class) { - return service.cast(this); - } - return null; - } - - @Override - public void notifyBootstrapFinished() { - gotBootstrapNotification++; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventListener.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventListener.java deleted file mode 100644 index 4b9007909da..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventListener.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package compiler.jvmci.events; - -import jdk.vm.ci.services.JVMCIServiceLocator; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotVMEventListener; - -public class JvmciShutdownEventListener extends JVMCIServiceLocator implements HotSpotVMEventListener { - public static final String MESSAGE = "Shutdown notified"; - public static final String GOT_INTERNAL_ERROR = "Got internal error"; - - public static class Main { - public static void main(String args[]) { - try { - HotSpotJVMCIRuntime.runtime(); // let's trigger that lazy jvmci init - } catch (Error e) { - System.out.println(GOT_INTERNAL_ERROR); - } - } - } - - @Override - public S getProvider(Class service) { - if (service == HotSpotVMEventListener.class) { - return service.cast(this); - } - return null; - } - - @Override - public void notifyShutdown() { - System.out.println(MESSAGE); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.config b/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.config deleted file mode 100644 index 5931551e083..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.config +++ /dev/null @@ -1,2 +0,0 @@ -compiler.jvmci.events.JvmciShutdownEventListener -compiler.jvmci.common.JVMCIHelpers diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java deleted file mode 100644 index aab802c888c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciShutdownEventTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8136421 - * @requires vm.jvmci - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.services - * - * @build compiler.jvmci.common.JVMCIHelpers - * compiler.jvmci.events.JvmciShutdownEventListener - * @run main/othervm jdk.test.lib.FileInstaller ./JvmciShutdownEventTest.config - * ./META-INF/services/jdk.vm.ci.services.JVMCIServiceLocator - * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller - * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler - * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory - * compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult - * compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener - * compiler.jvmci.events.JvmciShutdownEventListener - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * compiler.jvmci.events.JvmciShutdownEventTest - */ - -package compiler.jvmci.events; - -import jdk.test.lib.process.ExitCode; -import jdk.test.lib.cli.CommandLineOptionTest; - -public class JvmciShutdownEventTest { - private final static String[] MESSAGE = { - JvmciShutdownEventListener.MESSAGE - }; - - private final static String[] ERROR_MESSAGE = { - JvmciShutdownEventListener.GOT_INTERNAL_ERROR - }; - - public static void main(String args[]) throws Throwable { - boolean addTestVMOptions = true; - CommandLineOptionTest.verifyJVMStartup(MESSAGE, ERROR_MESSAGE, - "Unexpected exit code with +EnableJVMCI", - "Unexpected output with +EnableJVMCI", ExitCode.OK, - addTestVMOptions, "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", "-XX:-UseJVMCICompiler", "-Xbootclasspath/a:.", - JvmciShutdownEventListener.Main.class.getName() - ); - - CommandLineOptionTest.verifyJVMStartup(ERROR_MESSAGE, MESSAGE, - "Unexpected exit code with -EnableJVMCI", - "Unexpected output with -EnableJVMCI", ExitCode.OK, - addTestVMOptions, "-XX:+UnlockExperimentalVMOptions", - "-XX:-EnableJVMCI", "-XX:-UseJVMCICompiler", "-Xbootclasspath/a:.", - JvmciShutdownEventListener.Main.class.getName() - ); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c deleted file mode 100644 index 88dbc92a04e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/libNativeCallTest.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include -#include - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -jfloat JNICALL SS(jfloat f1, jfloat f2) { - return f1 + f2; -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getFF(JNIEnv *env, jclass clazz) { - return (jlong)(intptr_t)SS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1FF(JNIEnv *env, jclass clazz, jfloat a, jfloat b) { - return SS(a, b); -} - -jfloat JNICALL SDILDS(jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return (jfloat)(a + b + c + d + e + f); -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getSDILDS(JNIEnv *env, jclass clazz) { - return (jlong)(intptr_t)SDILDS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1SDILDS(JNIEnv *env, jclass clazz, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return SDILDS(a, b, c, d, e, f); -} - -jfloat JNICALL F32SDILDS(jfloat f00, jfloat f01, jfloat f02, jfloat f03, jfloat f04, jfloat f05, jfloat f06, jfloat f07, - jfloat f08, jfloat f09, jfloat f0a, jfloat f0b, jfloat f0c, jfloat f0d, jfloat f0e, jfloat f0f, - jfloat f10, jfloat f11, jfloat f12, jfloat f13, jfloat f14, jfloat f15, jfloat f16, jfloat f17, - jfloat f18, jfloat f19, jfloat f1a, jfloat f1b, jfloat f1c, jfloat f1d, jfloat f1e, jfloat f1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return (jfloat)(f00 + f01 + f02 + f03 + f04 + f05 + f06 + f07 + - f08 + f09 + f0a + f0b + f0c + f0d + f0e + f0f + - f10 + f11 + f12 + f13 + f14 + f15 + f16 + f17 + - f18 + f19 + f1a + f1b + f1c + f1d + f1e + f1f + - a + b + c + d + e + f); -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getF32SDILDS(JNIEnv *env, jclass clazz) { - return (jlong)(intptr_t)F32SDILDS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1F32SDILDS(JNIEnv *env, jclass clazz, - jfloat f00, jfloat f01, jfloat f02, jfloat f03, - jfloat f04, jfloat f05, jfloat f06, jfloat f07, - jfloat f08, jfloat f09, jfloat f0a, jfloat f0b, - jfloat f0c, jfloat f0d, jfloat f0e, jfloat f0f, - jfloat f10, jfloat f11, jfloat f12, jfloat f13, - jfloat f14, jfloat f15, jfloat f16, jfloat f17, - jfloat f18, jfloat f19, jfloat f1a, jfloat f1b, - jfloat f1c, jfloat f1d, jfloat f1e, jfloat f1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return F32SDILDS(f00, f01, f02, f03, f04, f05, f06, f07, - f08, f09, f0a, f0b, f0c, f0d, f0e, f0f, - f10, f11, f12, f13, f14, f15, f16, f17, - f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, - a, b, c, d, e, f); -} - - -jfloat JNICALL D32SDILDS(jdouble d00, jdouble d01, jdouble d02, jdouble d03, jdouble d04, jdouble d05, jdouble d06, jdouble d07, - jdouble d08, jdouble d09, jdouble d0a, jdouble d0b, jdouble d0c, jdouble d0d, jdouble d0e, jdouble d0f, - jdouble d10, jdouble d11, jdouble d12, jdouble d13, jdouble d14, jdouble d15, jdouble d16, jdouble d17, - jdouble d18, jdouble d19, jdouble d1a, jdouble d1b, jdouble d1c, jdouble d1d, jdouble d1e, jdouble d1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return (jfloat)(d00 + d01 + d02 + d03 + d04 + d05 + d06 + d07 + - d08 + d09 + d0a + d0b + d0c + d0d + d0e + d0f + - d10 + d11 + d12 + d13 + d14 + d15 + d16 + d17 + - d18 + d19 + d1a + d1b + d1c + d1d + d1e + d1f + - a + b + c + d + e + f); -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getD32SDILDS(JNIEnv *env, jclass clazz) { - return (jlong)(intptr_t)D32SDILDS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1D32SDILDS(JNIEnv *env, jclass clazz, - jdouble d00, jdouble d01, jdouble d02, jdouble d03, - jdouble d04, jdouble d05, jdouble d06, jdouble d07, - jdouble d08, jdouble d09, jdouble d0a, jdouble d0b, - jdouble d0c, jdouble d0d, jdouble d0e, jdouble d0f, - jdouble d10, jdouble d11, jdouble d12, jdouble d13, - jdouble d14, jdouble d15, jdouble d16, jdouble d17, - jdouble d18, jdouble d19, jdouble d1a, jdouble d1b, - jdouble d1c, jdouble d1d, jdouble d1e, jdouble d1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return D32SDILDS(d00, d01, d02, d03, d04, d05, d06, d07, - d08, d09, d0a, d0b, d0c, d0d, d0e, d0f, - d10, d11, d12, d13, d14, d15, d16, d17, - d18, d19, d1a, d1b, d1c, d1d, d1e, d1f, - a, b, c, d, e, f); -} - - -jfloat JNICALL I32SDILDS(jint i00, jint i01, jint i02, jint i03, jint i04, jint i05, jint i06, jint i07, - jint i08, jint i09, jint i0a, jint i0b, jint i0c, jint i0d, jint i0e, jint i0f, - jint i10, jint i11, jint i12, jint i13, jint i14, jint i15, jint i16, jint i17, - jint i18, jint i19, jint i1a, jint i1b, jint i1c, jint i1d, jint i1e, jint i1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return (jfloat)(i00 + i01 + i02 + i03 + i04 + i05 + i06 + i07 + - i08 + i09 + i0a + i0b + i0c + i0d + i0e + i0f + - i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + - i18 + i19 + i1a + i1b + i1c + i1d + i1e + i1f + - a + b + c + d + e + f); -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getI32SDILDS(JNIEnv *env, jclass clazz) { - return (jlong) (intptr_t) I32SDILDS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1I32SDILDS(JNIEnv *env, jclass clazz, - jint i00, jint i01, jint i02, jint i03, - jint i04, jint i05, jint i06, jint i07, - jint i08, jint i09, jint i0a, jint i0b, - jint i0c, jint i0d, jint i0e, jint i0f, - jint i10, jint i11, jint i12, jint i13, - jint i14, jint i15, jint i16, jint i17, - jint i18, jint i19, jint i1a, jint i1b, - jint i1c, jint i1d, jint i1e, jint i1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return I32SDILDS(i00, i01, i02, i03, i04, i05, i06, i07, - i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, - i10, i11, i12, i13, i14, i15, i16, i17, - i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, - a, b, c, d, e, f); -} - -jfloat JNICALL L32SDILDS(jlong l00, jlong l01, jlong l02, jlong l03, jlong l04, jlong l05, jlong l06, jlong l07, - jlong l08, jlong l09, jlong l0a, jlong l0b, jlong l0c, jlong l0d, jlong l0e, jlong l0f, - jlong l10, jlong l11, jlong l12, jlong l13, jlong l14, jlong l15, jlong l16, jlong l17, - jlong l18, jlong l19, jlong l1a, jlong l1b, jlong l1c, jlong l1d, jlong l1e, jlong l1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return (jfloat)(l00 + l01 + l02 + l03 + l04 + l05 + l06 + l07 + - l08 + l09 + l0a + l0b + l0c + l0d + l0e + l0f + - l10 + l11 + l12 + l13 + l14 + l15 + l16 + l17 + - l18 + l19 + l1a + l1b + l1c + l1d + l1e + l1f + - a + b + c + d + e + f); -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getL32SDILDS(JNIEnv *env, jclass clazz) { - return (jlong)(intptr_t)L32SDILDS; -} - -JNIEXPORT jfloat JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1L32SDILDS(JNIEnv *env, jclass clazz, - jlong l00, jlong l01, jlong l02, jlong l03, - jlong l04, jlong l05, jlong l06, jlong l07, - jlong l08, jlong l09, jlong l0a, jlong l0b, - jlong l0c, jlong l0d, jlong l0e, jlong l0f, - jlong l10, jlong l11, jlong l12, jlong l13, - jlong l14, jlong l15, jlong l16, jlong l17, - jlong l18, jlong l19, jlong l1a, jlong l1b, - jlong l1c, jlong l1d, jlong l1e, jlong l1f, - jfloat a, jdouble b, jint c, jlong d, jdouble e, jfloat f) { - return L32SDILDS(l00, l01, l02, l03, l04, l05, l06, l07, - l08, l09, l0a, l0b, l0c, l0d, l0e, l0f, - l10, l11, l12, l13, l14, l15, l16, l17, - l18, l19, l1a, l1b, l1c, l1d, l1e, l1f, - a, b, c, d, e, f); -} - -jint JNICALL I32I(jint i00, jint i01, jint i02, jint i03, jint i04, jint i05, jint i06, jint i07, - jint i08, jint i09, jint i0a, jint i0b, jint i0c, jint i0d, jint i0e, jint i0f, - jint i10, jint i11, jint i12, jint i13, jint i14, jint i15, jint i16, jint i17, - jint i18, jint i19, jint i1a, jint i1b, jint i1c, jint i1d, jint i1e, jint i1f, - jint a) { - return i00 + i01 + i02 + i03 + i04 + i05 + i06 + i07 + - i08 + i09 + i0a + i0b + i0c + i0d + i0e + i0f + - i10 + i11 + i12 + i13 + i14 + i15 + i16 + i17 + - i18 + i19 + i1a + i1b + i1c + i1d + i1e + i1f + - a; -} - -JNIEXPORT jlong JNICALL Java_jdk_vm_ci_code_test_NativeCallTest_getI32I(JNIEnv *env, jclass clazz) { - return (jlong) (intptr_t) I32I; -} - -JNIEXPORT jint JNICALL Java_jdk_vm_ci_code_test_NativeCallTest__1I32I(JNIEnv *env, jclass clazz, - jint i00, jint i01, jint i02, jint i03, - jint i04, jint i05, jint i06, jint i07, - jint i08, jint i09, jint i0a, jint i0b, - jint i0c, jint i0d, jint i0e, jint i0f, - jint i10, jint i11, jint i12, jint i13, - jint i14, jint i15, jint i16, jint i17, - jint i18, jint i19, jint i1a, jint i1b, - jint i1c, jint i1d, jint i1e, jint i1f, - jint a) { - return I32I(i00, i01, i02, i03, i04, i05, i06, i07, - i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, - i10, i11, i12, i13, i14, i15, i16, i17, - i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, - a); -} - -#ifdef __cplusplus -} -#endif - diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java deleted file mode 100644 index a38424e5572..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.test; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.riscv64.RISCV64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.code.TargetDescription; -import jdk.vm.ci.code.test.aarch64.AArch64TestAssembler; -import jdk.vm.ci.code.test.amd64.AMD64TestAssembler; -import jdk.vm.ci.code.test.riscv64.RISCV64TestAssembler; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotCompiledCode; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotNmethod; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.runtime.JVMCI; -import jdk.vm.ci.runtime.JVMCIBackend; -import org.junit.Assert; - -import java.lang.reflect.Method; - -/** - * Base class for code installation tests. - */ -public class CodeInstallationTest { - - private static final boolean DEBUG = false; - - protected final MetaAccessProvider metaAccess; - protected final CodeCacheProvider codeCache; - protected final TargetDescription target; - protected final ConstantReflectionProvider constantReflection; - protected final TestHotSpotVMConfig config; - protected final Architecture arch; - - public CodeInstallationTest() { - JVMCIBackend backend = JVMCI.getRuntime().getHostJVMCIBackend(); - metaAccess = backend.getMetaAccess(); - codeCache = backend.getCodeCache(); - target = backend.getTarget(); - constantReflection = backend.getConstantReflection(); - arch = codeCache.getTarget().arch; - config = new TestHotSpotVMConfig(HotSpotJVMCIRuntime.runtime().getConfigStore(), arch); - } - - protected interface TestCompiler { - - void compile(TestAssembler asm); - } - - private TestAssembler createAssembler() { - if (arch instanceof AMD64) { - return new AMD64TestAssembler(codeCache, config); - } else if (arch instanceof AArch64) { - return new AArch64TestAssembler(codeCache, config); - } else if (arch instanceof RISCV64) { - return new RISCV64TestAssembler(codeCache, config); - } else { - Assert.fail("unsupported architecture"); - return null; - } - } - - protected Method getMethod(String name, Class... args) { - try { - return getClass().getMethod(name, args); - } catch (NoSuchMethodException e) { - Assert.fail("method not found"); - return null; - } - } - - protected HotSpotNmethod test(TestCompiler compiler, Method method, Object... args) { - try { - HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); - TestAssembler asm = createAssembler(); - - asm.emitPrologue(); - compiler.compile(asm); - asm.emitEpilogue(); - - HotSpotCompiledCode code = asm.finish(resolvedMethod); - InstalledCode installed = codeCache.addCode(resolvedMethod, code, null, null, true); - - if (DEBUG) { - String str = ((HotSpotCodeCacheProvider) codeCache).disassemble(installed); - System.out.println(str); - } - - Object expected = method.invoke(null, args); - Object actual = installed.executeVarargs(args); - Assert.assertEquals(expected, actual); - return (HotSpotNmethod) installed; - } catch (Exception e) { - throw new AssertionError(e); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInvalidationReasonTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInvalidationReasonTest.java deleted file mode 100644 index 624a2290509..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInvalidationReasonTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library /test/lib / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.CodeInvalidationReasonTest - */ - -package jdk.vm.ci.code.test; - -import jdk.test.lib.Asserts; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.hotspot.HotSpotNmethod; - -import org.junit.Test; - -import java.lang.reflect.Method; - -/** - * Test if setting HotSpotNmethod invalidation reason around works. - */ -public class CodeInvalidationReasonTest extends CodeInstallationTest { - - public static int add(int a, int b) { - return a + b; - } - - private static void compileAdd(TestAssembler asm) { - Register arg0 = asm.emitIntArg0(); - Register arg1 = asm.emitIntArg1(); - Register ret = asm.emitIntAdd(arg0, arg1); - asm.emitIntRet(ret); - } - - @Test - public void test() { - Method method = getMethod("add", int.class, int.class); - - HotSpotNmethod nmethod = test(CodeInvalidationReasonTest::compileAdd, method, 5, 7); - Asserts.assertEquals(-1 /* since it was not invalidated yet. */, nmethod.getInvalidationReason()); - - nmethod.invalidate(true, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE); - Asserts.assertEquals(config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE, nmethod.getInvalidationReason()); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java deleted file mode 100644 index b0c7d11edfe..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.DataPatchTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Assume; -import org.junit.Test; - -/** - * Test code installation with data patches. - */ -public class DataPatchTest extends CodeInstallationTest { - - public static Class getConstClass() { - return DataPatchTest.class; - } - - private void test(TestCompiler compiler) { - test(compiler, getMethod("getConstClass")); - } - - @Test - public void testInlineObject() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); - Register ret = asm.emitLoadPointer(c); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testInlineNarrowObject() { - Assume.assumeTrue(config.useCompressedOops); - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); - Register compressed = asm.emitLoadPointer((HotSpotConstant) c.compress()); - Register ret = asm.emitUncompressPointer(compressed, config.narrowOopBase, config.narrowOopShift); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testDataSectionReference() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); - DataSectionReference ref = asm.emitDataItem(c); - Register ret = asm.emitLoadPointer(ref); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testNarrowDataSectionReference() { - Assume.assumeTrue(config.useCompressedOops); - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant c = (HotSpotConstant) constantReflection.asJavaClass(type); - HotSpotConstant cCompressed = (HotSpotConstant) c.compress(); - DataSectionReference ref = asm.emitDataItem(cCompressed); - Register compressed = asm.emitLoadNarrowPointer(ref); - Register ret = asm.emitUncompressPointer(compressed, config.narrowOopBase, config.narrowOopShift); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testInlineMetadata() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - Register klass = asm.emitLoadPointer((HotSpotConstant) constantReflection.asObjectHub(type)); - Register ret = asm.emitLoadPointer(asm.emitLoadPointer(klass, config.classMirrorHandleOffset), 0); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testInlineNarrowMetadata() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); - Register narrowKlass = asm.emitLoadPointer((HotSpotConstant) hub.compress()); - Register klass = asm.emitUncompressPointer(narrowKlass, config.narrowKlassBase, config.narrowKlassShift); - Register ret = asm.emitLoadPointer(asm.emitLoadPointer(klass, config.classMirrorHandleOffset), 0); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testMetadataInDataSection() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); - DataSectionReference ref = asm.emitDataItem(hub); - Register klass = asm.emitLoadPointer(ref); - Register ret = asm.emitLoadPointer(asm.emitLoadPointer(klass, config.classMirrorHandleOffset), 0); - asm.emitPointerRet(ret); - }); - } - - @Test - public void testNarrowMetadataInDataSection() { - test(asm -> { - ResolvedJavaType type = metaAccess.lookupJavaType(getConstClass()); - HotSpotConstant hub = (HotSpotConstant) constantReflection.asObjectHub(type); - HotSpotConstant narrowHub = (HotSpotConstant) hub.compress(); - DataSectionReference ref = asm.emitDataItem(narrowHub); - Register narrowKlass = asm.emitLoadNarrowPointer(ref); - Register klass = asm.emitUncompressPointer(narrowKlass, config.narrowKlassBase, config.narrowKlassShift); - Register ret = asm.emitLoadPointer(asm.emitLoadPointer(klass, config.classMirrorHandleOffset), 0); - asm.emitPointerRet(ret); - }); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java deleted file mode 100644 index 205d2e8b362..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.hotspot.HotSpotReferenceMap; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Test code installation with debug information. - */ -public class DebugInfoTest extends CodeInstallationTest { - - protected interface DebugInfoCompiler { - - VirtualObject[] compile(TestAssembler asm, JavaValue[] frameValues); - } - - protected void test(DebugInfoCompiler compiler, Method method, int bci, JavaKind... slotKinds) { - test(compiler, method, bci, new Location[0], new Location[0], new int[0], slotKinds); - } - - protected void test(DebugInfoCompiler compiler, Method method, int bci, Location[] objects, Location[] derivedBase, int[] sizeInBytes, JavaKind... slotKinds) { - ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(method); - - int numLocals = resolvedMethod.getMaxLocals(); - int numStack = slotKinds.length - numLocals; - JavaValue[] values = new JavaValue[slotKinds.length]; - test(asm -> { - /* - * Ensure that any objects mentioned in the VirtualObjects are also in the OopMap. - */ - List newLocations = new ArrayList<>(Arrays.asList(objects)); - List newDerived = new ArrayList<>(Arrays.asList(derivedBase)); - int[] newSizeInBytes = sizeInBytes; - VirtualObject[] vobjs = compiler.compile(asm, values); - if (vobjs != null) { - for (VirtualObject obj : vobjs) { - JavaValue[] objValues = obj.getValues(); - for (int i = 0; i < objValues.length; i++) { - if (obj.getSlotKind(i) == JavaKind.Object) { - Location oopLocation = null; - int bytes = -1; - if (objValues[i] instanceof RegisterValue) { - RegisterValue reg = (RegisterValue) objValues[i]; - oopLocation = Location.register(reg.getRegister()); - bytes = reg.getValueKind().getPlatformKind().getSizeInBytes(); - } else if (objValues[i] instanceof StackSlot) { - StackSlot slot = (StackSlot) objValues[i]; - oopLocation = Location.stack(asm.getOffset(slot)); - bytes = slot.getValueKind().getPlatformKind().getSizeInBytes(); - } - if (oopLocation != null && !newLocations.contains(oopLocation)) { - newLocations.add(oopLocation); - newDerived.add(null); - newSizeInBytes = Arrays.copyOf(newSizeInBytes, newSizeInBytes.length + 1); - newSizeInBytes[newSizeInBytes.length - 1] = bytes; - } - } - } - } - } - - BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, bci, false, false, values, slotKinds, numLocals, numStack, 0); - DebugInfo info = new DebugInfo(frame, vobjs); - info.setReferenceMap(new HotSpotReferenceMap(newLocations.toArray(new Location[0]), newDerived.toArray(new Location[0]), newSizeInBytes, 8)); - - asm.emitTrap(info); - }, method); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java deleted file mode 100644 index f7e68043da7..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InstalledCodeTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test 8355034 - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.code - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InstalledCodeTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.InstalledCode; -import org.junit.Assert; -import org.junit.Test; - -public class InstalledCodeTest { - - @Test - public void testNullName() { - new InstalledCode(null); - } - - @Test - public void testTooLongName() { - String longName = new String(new char[InstalledCode.MAX_NAME_LENGTH]).replace('\0', 'A'); - new InstalledCode(longName); - try { - String tooLongName = longName + "X"; - new InstalledCode(tooLongName); - } catch (IllegalArgumentException iae) { - // Threw IllegalArgumentException as expected. - return; - } - Assert.fail("expected IllegalArgumentException"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java deleted file mode 100644 index 879e6f86058..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.InterpreterFrameSizeTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import org.junit.Assert; -import org.junit.Test; - -public class InterpreterFrameSizeTest extends CodeInstallationTest { - - HotSpotCodeCacheProvider hotspotCodeCache() { - return (HotSpotCodeCacheProvider) codeCache; - } - - @Test - public void testNull() { - try { - hotspotCodeCache().interpreterFrameSize(null); - } catch (NullPointerException npe) { - // Threw NPE as expected. - return; - } - Assert.fail("expected NullPointerException"); - } - - @Test - public void test() { - ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(getMethod("testNull")); - - int bci = 0; - int numLocals = resolvedMethod.getMaxLocals(); - int numStack = 0; - JavaValue[] values = new JavaValue[numLocals]; - JavaKind[] slotKinds = new JavaKind[numLocals]; - BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, bci, false, false, values, slotKinds, numLocals, numStack, 0); - int size = hotspotCodeCache().interpreterFrameSize(frame); - if (size <= 0) { - Assert.fail("expected non-zero result"); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java deleted file mode 100644 index 3d49a4f3575..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/MaxOopMapStackOffsetTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.common - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.MaxOopMapStackOffsetTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.Location; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import org.junit.Test; - -public class MaxOopMapStackOffsetTest extends DebugInfoTest { - - public static int pass() { - return 42; - } - - public static int fail() { - return 42; - } - - private void test(String name, int offset) { - Location location = Location.stack(offset); - DebugInfoCompiler compiler = (asm, values) -> { - asm.growFrame(offset); - Register v = asm.emitLoadInt(0); - asm.emitIntToStack(v); - values[0] = JavaConstant.forInt(42); - return null; - }; - test(compiler, getMethod(name), 2, new Location[]{location}, new Location[1], new int[]{4}, JavaKind.Int); - } - - private int maxOffset() { - return config.maxOopMapStackOffset; - } - - private int wordSize() { - return config.heapWordSize; - } - - @Test(expected = JVMCIError.class) - public void failTooLargeOffset() { - // This should throw a JVMCIError during installation because the offset is too large. - test("fail", maxOffset() + wordSize()); - } - - @Test - public void passWithLargeOffset() { - test("pass", maxOffset()); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java deleted file mode 100644 index ebd57b6faaf..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library /test/lib / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java TestHotSpotVMConfig.java NativeCallTest.java TestAssembler.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm/native -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbootclasspath/a:. jdk.vm.ci.code.test.NativeCallTest - */ -package jdk.vm.ci.code.test; - -import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall; - -import org.junit.BeforeClass; -import org.junit.Test; - -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.meta.JavaType; - -public class NativeCallTest extends CodeInstallationTest { - - @BeforeClass - public static void beforeClass() { - System.loadLibrary("NativeCallTest"); - } - - @Test - public void testFF() { - float a = 1.2345678f; - float b = 8.7654321f; - test("FF", getFF(), float.class, new Class[]{float.class, float.class}, new Object[]{a, b}); - } - - @Test - public void testSDILDS() { - float a = 1.2345678f; - double b = 3.212434; - int c = 43921652; - long d = 412435326; - double e = .31212333; - float f = 8.7654321f; - Class[] argClazz = new Class[]{float.class, double.class, int.class, long.class, double.class, - float.class}; - test("SDILDS", getSDILDS(), float.class, argClazz, new Object[]{a, b, c, d, e, f}); - } - - @Test - public void testF32SDILDS() { - int sCount = 32; - // Pairs of , - Object[] remainingArgs = new Object[]{ - 1.2345678F, float.class, - 3.212434D, double.class, - 43921652, int.class, - 0xCAFEBABEDEADBEEFL, long.class, - .31212333D, double.class, - 8.7654321F, float.class - }; - Class[] argClazz = new Class[sCount + remainingArgs.length / 2]; - Object[] argValues = new Object[sCount + remainingArgs.length / 2]; - for (int i = 0; i < sCount; i++) { - argValues[i] = (float) i; - argClazz[i] = float.class; - } - for (int i = 0; i < remainingArgs.length; i += 2) { - argValues[sCount + i / 2] = remainingArgs[i + 0]; - argClazz[sCount + i / 2] = (Class) remainingArgs[i + 1]; - } - test("F32SDILDS", getF32SDILDS(), float.class, argClazz, argValues); - } - - @Test - public void testI32SDILDS() { - int sCount = 32; - // Pairs of , - Object[] remainingArgs = new Object[]{ - 1.2345678F, float.class, - 3.212434D, double.class, - 43921652, int.class, - 0xCAFEBABEDEADBEEFL, long.class, - .31212333D, double.class, - 8.7654321F, float.class - }; - Class[] argClazz = new Class[sCount + remainingArgs.length / 2]; - Object[] argValues = new Object[sCount + remainingArgs.length / 2]; - for (int i = 0; i < sCount; i++) { - argValues[i] = i; - argClazz[i] = int.class; - } - for (int i = 0; i < remainingArgs.length; i += 2) { - argValues[sCount + i / 2] = remainingArgs[i + 0]; - argClazz[sCount + i / 2] = (Class) remainingArgs[i + 1]; - } - test("I32SDILDS", getI32SDILDS(), float.class, argClazz, argValues); - } - - @Test - public void testI32I() { - int sCount = 32; - // Pairs of , - Object[] remainingArgs = new Object[]{ - 12, int.class - }; - Class[] argClazz = new Class[sCount + remainingArgs.length / 2]; - Object[] argValues = new Object[sCount + remainingArgs.length / 2]; - for (int i = 0; i < sCount; i++) { - argValues[i] = i; - argClazz[i] = int.class; - } - for (int i = 0; i < remainingArgs.length; i += 2) { - argValues[sCount + i / 2] = remainingArgs[i + 0]; - argClazz[sCount + i / 2] = (Class) remainingArgs[i + 1]; - } - test("I32I", getI32I(), int.class, argClazz, argValues); - } - - public void test(String name, long addr, Class returnClazz, Class[] types, Object[] values) { - try { - test(asm -> { - JavaType[] argTypes = new JavaType[types.length]; - int i = 0; - for (Class clazz : types) { - argTypes[i++] = metaAccess.lookupJavaType(clazz); - } - JavaType returnType = metaAccess.lookupJavaType(returnClazz); - CallingConvention cc = codeCache.getRegisterConfig().getCallingConvention(NativeCall, returnType, argTypes, asm.valueKindFactory); - asm.emitCallPrologue(cc, values); - asm.emitCall(addr); - asm.emitCallEpilogue(cc); - if (returnClazz == float.class) { - asm.emitFloatRet(((RegisterValue) cc.getReturn()).getRegister()); - } else if (returnClazz == int.class) { - asm.emitIntRet(((RegisterValue) cc.getReturn()).getRegister()); - } else { - assert false : "Unimplemented return type: " + returnClazz; - } - }, getMethod(name, types), values); - } catch (Throwable e) { - e.printStackTrace(); - throw e; - } - } - - // Checkstyle: stop - - public static native long getFF(); - - public static native float _FF(float a, float b); - - public static float FF(float a, float b) { - return _FF(a, b); - } - - public static native long getSDILDS(); - - public static native float _SDILDS(float a, double b, int c, long d, double e, float f); - - public static float SDILDS(float a, double b, int c, long d, double e, float f) { - return _SDILDS(a, b, c, d, e, f); - } - - public static native long getF32SDILDS(); - - public static native float _F32SDILDS(float f00, float f01, float f02, float f03, float f04, float f05, float f06, float f07, - float f08, float f09, float f0a, float f0b, float f0c, float f0d, float f0e, float f0f, - float f10, float f11, float f12, float f13, float f14, float f15, float f16, float f17, - float f18, float f19, float f1a, float f1b, float f1c, float f1d, float f1e, float f1f, - float a, double b, int c, long d, double e, float f); - - public static float F32SDILDS(float f00, float f01, float f02, float f03, float f04, float f05, float f06, float f07, - float f08, float f09, float f0a, float f0b, float f0c, float f0d, float f0e, float f0f, - float f10, float f11, float f12, float f13, float f14, float f15, float f16, float f17, - float f18, float f19, float f1a, float f1b, float f1c, float f1d, float f1e, float f1f, - float a, double b, int c, long d, double e, float f) { - return _F32SDILDS(f00, f01, f02, f03, f04, f05, f06, f07, - f08, f09, f0a, f0b, f0c, f0d, f0e, f0f, - f10, f11, f12, f13, f14, f15, f16, f17, - f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, - a, b, c, d, e, f); - } - - public static native long getD32SDILDS(); - - public static native float _D32SDILDS(double d00, double d01, double d02, double d03, double d04, double d05, double d06, double d07, - double d08, double d09, double d0a, double d0b, double d0c, double d0d, double d0e, double d0f, - double d10, double d11, double d12, double d13, double d14, double d15, double d16, double d17, - double d18, double d19, double d1a, double d1b, double d1c, double d1d, double d1e, double d1f, - float a, double b, int c, long d, double e, float f); - - @SuppressWarnings("unused") - public static float D32SDILDS(double d00, double d01, double d02, double d03, double d04, double d05, double d06, double d07, - double d08, double d09, double d0a, double d0b, double d0c, double d0d, double d0e, double d0f, - double d10, double d11, double d12, double d13, double d14, double d15, double d16, double d17, - double d18, double d19, double d1a, double d1b, double d1c, double d1d, double d1e, double d1f, - float a, double b, int c, long d, double e, float f) { - return _D32SDILDS(d00, d01, d02, d03, d04, d05, d06, d07, - d08, d09, d0a, d0b, d0c, d0d, d0e, d0d, - d10, d11, d12, d13, d14, d15, d16, d17, - d18, d19, d1a, d1b, d1c, d1d, d1e, d1f, - a, b, c, d, e, f); - } - - public static native long getI32SDILDS(); - - public static native float _I32SDILDS(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, - int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, - int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, - int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, - float a, double b, int c, long d, double e, float f); - - public static float I32SDILDS(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, - int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, - int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, - int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, - float a, double b, int c, long d, double e, float f) { - return _I32SDILDS(i00, i01, i02, i03, i04, i05, i06, i07, - i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, - i10, i11, i12, i13, i14, i15, i16, i17, - i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, - a, b, c, d, e, f); - } - - public static native long getL32SDILDS(); - - public static native float _L32SDILDS(long l00, long l01, long l02, long l03, long l04, long l05, long l06, long l07, - long l08, long l09, long l0a, long l0b, long l0c, long l0d, long l0e, long l0f, - long l10, long l11, long l12, long l13, long l14, long l15, long l16, long l17, - long l18, long l19, long l1a, long l1b, long l1c, long l1d, long l1e, long l1f, - float a, double b, int c, long d, double e, float f); - - public static float L32SDILDS(long l00, long l01, long l02, long l03, long l04, long l05, long l06, long l07, - long l08, long l09, long l0a, long l0b, long l0c, long l0d, long l0e, long l0f, - long l10, long l11, long l12, long l13, long l14, long l15, long l16, long l17, - long l18, long l19, long l1a, long l1b, long l1c, long l1d, long l1e, long l1f, - float a, double b, int c, long d, double e, float f) { - return _L32SDILDS(l00, l01, l02, l03, l04, l05, l06, l07, - l08, l09, l0a, l0b, l0c, l0d, l0e, l0f, - l10, l11, l12, l13, l14, l15, l16, l17, - l18, l19, l1a, l1b, l1c, l1d, l1e, l1f, - a, b, c, d, e, f); - } - - public static native long getI32I(); - - public static native int _I32I(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, - int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, - int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, - int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, - int a); - - public static int I32I(int i00, int i01, int i02, int i03, int i04, int i05, int i06, int i07, - int i08, int i09, int i0a, int i0b, int i0c, int i0d, int i0e, int i0f, - int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, - int i18, int i19, int i1a, int i1b, int i1c, int i1d, int i1e, int i1f, - int a) { - return _I32I(i00, i01, i02, i03, i04, i05, i06, i07, - i08, i09, i0a, i0b, i0c, i0d, i0e, i0f, - i10, i11, i12, i13, i14, i15, i16, i17, - i18, i19, i1a, i1b, i1c, i1d, i1e, i1f, - a); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/RuntimeStubAllocFailTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/RuntimeStubAllocFailTest.java deleted file mode 100644 index 3ca2c555d2e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/RuntimeStubAllocFailTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci & !vm.graal.enabled & vm.compMode == "Xmixed" - * @library / /test/lib - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @run main/othervm -XX:+UnlockExperimentalVMOptions - * -Xbootclasspath/a:. - * -XX:+EnableJVMCI -XX:JVMCITraceLevel=1 - * -Dtest.jvmci.forceRuntimeStubAllocFail=test_stub_that_fails_to_be_allocated - * jdk.vm.ci.code.test.RuntimeStubAllocFailTest - */ - -package jdk.vm.ci.code.test; - -import jdk.test.lib.Asserts; -import jdk.test.lib.Platform; -import jdk.vm.ci.code.BailoutException; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.hotspot.HotSpotCompiledCode; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.runtime.JVMCI; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.runtime.JVMCIBackend; - -public class RuntimeStubAllocFailTest { - - public static void main(String args[]) { - JVMCIBackend backend = JVMCI.getRuntime().getHostJVMCIBackend(); - HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) backend.getCodeCache(); - int dataSectionAlignment = 8; // CodeBuffer::SECT_CONSTS code section alignment - String stubToFail = System.getProperty("test.jvmci.forceRuntimeStubAllocFail"); - if (Platform.isDebugBuild() && stubToFail != null) { - HotSpotCompiledCode stub = new HotSpotCompiledCode(stubToFail, - /* targetCode */ new byte[0], - /* targetCodeSize */ 0, - /* sites */ new Site[0], - /* assumptions */ new Assumption[0], - /* methods */ new ResolvedJavaMethod[0], - /* comments */ new Comment[0], - /* dataSection */ new byte[0], - dataSectionAlignment, - /* dataSectionPatches */ new DataPatch[0], - /* isImmutablePIC */ false, - /* totalFrameSize */ 0, - /* deoptRescueSlot */ null); - try { - codeCache.installCode(null, stub, null, null, true, true); - throw new AssertionError("Didn't get expected " + BailoutException.class.getName()); - } catch (BailoutException e) { - Asserts.assertEQ(e.getMessage(), "Error installing " + stubToFail + ": code cache is full"); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java deleted file mode 100644 index 4c76aea7a40..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library /test/lib / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.SimpleCodeInstallationTest - */ - -package jdk.vm.ci.code.test; -import jdk.test.lib.Asserts; - -import jdk.vm.ci.code.Register; -import jdk.vm.ci.hotspot.HotSpotNmethod; -import org.junit.Test; - -/** - * Test simple code installation. - */ -public class SimpleCodeInstallationTest extends CodeInstallationTest { - - public static int add(int a, int b) { - return a + b; - } - - private static void compileAdd(TestAssembler asm) { - Register arg0 = asm.emitIntArg0(); - Register arg1 = asm.emitIntArg1(); - Register ret = asm.emitIntAdd(arg0, arg1); - asm.emitIntRet(ret); - } - - @Test - public void test() { - HotSpotNmethod nmethod = test(SimpleCodeInstallationTest::compileAdd, getMethod("add", int.class, int.class), 5, 7); - - // Test code invalidation - Asserts.assertTrue(nmethod.isValid(), "code is not valid, i = " + nmethod); - Asserts.assertTrue(nmethod.isAlive(), "code is not alive, i = " + nmethod); - Asserts.assertNotEquals(nmethod.getStart(), 0L); - - // Make nmethod non-entrant but still alive - nmethod.invalidate(false, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE); - Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod); - Asserts.assertTrue(nmethod.isAlive(), "code is not alive, i = " + nmethod); - Asserts.assertEquals(nmethod.getStart(), 0L); - - // Deoptimize the nmethod and cut the link to it from the HotSpotNmethod - nmethod.invalidate(true, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE); - Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod); - Asserts.assertFalse(nmethod.isAlive(), "code is alive, i = " + nmethod); - Asserts.assertEquals(nmethod.getStart(), 0L); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java deleted file mode 100644 index b27a5038ff5..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.SimpleDebugInfoTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.Register; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Value; -import org.junit.Assume; -import org.junit.Test; - -public class SimpleDebugInfoTest extends DebugInfoTest { - - public static int intOnStack() { - return 42; - } - - private void testIntOnStack(DebugInfoCompiler compiler) { - test(compiler, getMethod("intOnStack"), 2, JavaKind.Int); - } - - public static int intInLocal() { - int local = 42; - return local; - } - - public void testIntInLocal(DebugInfoCompiler compiler) { - test(compiler, getMethod("intInLocal"), 3, JavaKind.Int); - } - - @Test - public void testConstInt() { - DebugInfoCompiler compiler = (asm, values) -> { - values[0] = JavaConstant.forInt(42); - return null; - }; - testIntOnStack(compiler); - testIntInLocal(compiler); - } - - @Test - public void testRegInt() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadInt(42); - values[0] = reg.asValue(asm.getValueKind(JavaKind.Int)); - return null; - }; - testIntOnStack(compiler); - testIntInLocal(compiler); - } - - @Test - public void testStackInt() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadInt(42); - values[0] = asm.emitIntToStack(reg); - return null; - }; - testIntOnStack(compiler); - testIntInLocal(compiler); - } - - public static float floatOnStack() { - return 42.0f; - } - - private void testFloatOnStack(DebugInfoCompiler compiler) { - test(compiler, getMethod("floatOnStack"), 2, JavaKind.Float); - } - - public static float floatInLocal() { - float local = 42.0f; - return local; - } - - private void testFloatInLocal(DebugInfoCompiler compiler) { - test(compiler, getMethod("floatInLocal"), 3, JavaKind.Float); - } - - @Test - public void testConstFloat() { - DebugInfoCompiler compiler = (asm, values) -> { - values[0] = JavaConstant.forFloat(42.0f); - return null; - }; - testFloatOnStack(compiler); - testFloatInLocal(compiler); - } - - @Test - public void testRegFloat() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadFloat(42.0f); - values[0] = reg.asValue(asm.getValueKind(JavaKind.Float)); - return null; - }; - testFloatOnStack(compiler); - testFloatInLocal(compiler); - } - - @Test - public void testStackFloat() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadFloat(42.0f); - values[0] = asm.emitFloatToStack(reg); - return null; - }; - testFloatOnStack(compiler); - testFloatInLocal(compiler); - } - - public static long longOnStack() { - return 42; - } - - private void testLongOnStack(DebugInfoCompiler compiler) { - test(compiler, getMethod("longOnStack"), 3, JavaKind.Long, JavaKind.Illegal); - } - - public static long longInLocal() { - long local = 42; - return local; - } - - private void testLongInLocal(DebugInfoCompiler compiler) { - test(compiler, getMethod("longInLocal"), 4, JavaKind.Long, JavaKind.Illegal); - } - - @Test - public void testConstLong() { - DebugInfoCompiler compiler = (asm, values) -> { - values[0] = JavaConstant.forLong(42); - values[1] = Value.ILLEGAL; - return null; - }; - testLongOnStack(compiler); - testLongInLocal(compiler); - } - - @Test - public void testRegLong() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadLong(42); - values[0] = reg.asValue(asm.getValueKind(JavaKind.Long)); - values[1] = Value.ILLEGAL; - return null; - }; - testLongOnStack(compiler); - testLongInLocal(compiler); - } - - @Test - public void testStackLong() { - DebugInfoCompiler compiler = (asm, values) -> { - Register reg = asm.emitLoadLong(42); - values[0] = asm.emitLongToStack(reg); - values[1] = Value.ILLEGAL; - return null; - }; - testLongOnStack(compiler); - testLongInLocal(compiler); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java deleted file mode 100644 index 4d953cac898..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java +++ /dev/null @@ -1,485 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.ValueKindFactory; -import jdk.vm.ci.code.site.Call; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataPatch; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.site.Infopoint; -import jdk.vm.ci.code.site.InfopointReason; -import jdk.vm.ci.code.site.Mark; -import jdk.vm.ci.code.site.Reference; -import jdk.vm.ci.code.site.Site; -import jdk.vm.ci.hotspot.HotSpotCompiledCode; -import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; -import jdk.vm.ci.hotspot.HotSpotCompiledNmethod; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.Assumptions.Assumption; -import jdk.vm.ci.meta.InvokeTarget; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.PlatformKind; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.VMConstant; -import jdk.vm.ci.meta.ValueKind; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.Arrays; - -/** - * Simple assembler used by the code installation tests. - */ -public abstract class TestAssembler { - - /** - * Emit the method prologue code (e.g. building the new stack frame). - */ - public abstract void emitPrologue(); - - /** - * Emit the method epilogue code (e.g. the deopt handler). - */ - public abstract void emitEpilogue(); - - /** - * Emit code to grow the stack frame. - * - * @param size the size in bytes that the stack should grow - */ - public abstract void emitGrowStack(int size); - - /** - * Get the register containing the first 32-bit integer argument. - */ - public abstract Register emitIntArg0(); - - /** - * Get the register containing the second 32-bit integer argument. - */ - public abstract Register emitIntArg1(); - - /** - * Emit code to add two 32-bit integer registers. May reuse one of the argument registers. - */ - public abstract Register emitIntAdd(Register a, Register b); - - /** - * Emit code to load a constant 32-bit integer to a register. - */ - public abstract Register emitLoadInt(int value); - - /** - * Emit code to load a constant 64-bit integer to a register. - */ - public abstract Register emitLoadLong(long value); - - /** - * Emit code to load a constant single-precision float to a register. - */ - public abstract Register emitLoadFloat(float value); - - /** - * Emit code to load a constant oop or metaspace pointer to a register. The pointer may be wide - * or narrow, depending on {@link HotSpotConstant#isCompressed() c.isCompressed()}. - */ - public abstract Register emitLoadPointer(HotSpotConstant c); - - /** - * Emit code to load a wide pointer from the {@link HotSpotCompiledCode#dataSection} to a - * register. - */ - public abstract Register emitLoadPointer(DataSectionReference ref); - - /** - * Emit code to load a narrow pointer from the {@link HotSpotCompiledCode#dataSection} to a - * register. - */ - public abstract Register emitLoadNarrowPointer(DataSectionReference ref); - - /** - * Emit code to load a (wide) pointer from a memory location to a register. - */ - public abstract Register emitLoadPointer(Register base, int offset); - - /** - * Emit code to store a 32-bit integer from a register to a new stack slot. - */ - public abstract StackSlot emitIntToStack(Register a); - - /** - * Emit code to store a 64-bit integer from a register to a new stack slot. - */ - public abstract StackSlot emitLongToStack(Register a); - - /** - * Emit code to store a single-precision float from a register to a new stack slot. - */ - public abstract StackSlot emitFloatToStack(Register a); - - /** - * Emit code to store a double-precision float from a register to a new stack slot. - */ - public abstract StackSlot emitDoubleToStack(Register a); - - /** - * Emit code to store a wide pointer from a register to a new stack slot. - */ - public abstract StackSlot emitPointerToStack(Register a); - - /** - * Emit code to store a narrow pointer from a register to a new stack slot. - */ - public abstract StackSlot emitNarrowPointerToStack(Register a); - - /** - * Emit code to uncompress a narrow pointer. The input pointer is guaranteed to be non-null. - */ - public abstract Register emitUncompressPointer(Register compressed, long base, int shift); - - /** - * Emit code to return from a function, returning a 32-bit integer. - */ - public abstract void emitIntRet(Register a); - - /** - * Emit code to return from a function, returning a single precision float. - */ - public abstract void emitFloatRet(Register a); - - /** - * Emit code to return from a function, returning a wide oop pointer. - */ - public abstract void emitPointerRet(Register a); - - /** - * Emit code that traps, forcing a deoptimization. - */ - public abstract void emitTrap(DebugInfo info); - - public final ValueKind narrowOopKind; - - protected final Buffer code; - protected final Buffer data; - private final ArrayList sites; - private final ArrayList dataPatches; - - protected final CodeCacheProvider codeCache; - protected final TestHotSpotVMConfig config; - - private final Register[] registers; - private int nextRegister; - - protected int frameSize; - private int stackAlignment; - private int curStackSlot; - - private StackSlot deoptRescue; - - public ValueKindFactory valueKindFactory = new ValueKindFactory<>() { - public TestValueKind getValueKind(JavaKind javaKind) { - return (TestValueKind) TestAssembler.this.getValueKind(javaKind); - } - }; - - static class TestValueKind extends ValueKind { - - TestValueKind(PlatformKind kind) { - super(kind); - } - - @Override - public TestValueKind changeType(PlatformKind kind) { - return new TestValueKind(kind); - } - } - - protected TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) { - this.narrowOopKind = new TestValueKind(narrowOopKind); - - this.code = new Buffer(); - this.data = new Buffer(); - this.sites = new ArrayList<>(); - this.dataPatches = new ArrayList<>(); - - this.codeCache = codeCache; - this.config = config; - - this.registers = registers; - this.nextRegister = 0; - - this.frameSize = initialFrameSize; - this.stackAlignment = stackAlignment; - this.curStackSlot = initialFrameSize; - } - - public class Bookmark implements AutoCloseable { - private final int registerMark = nextRegister; - private final int codePos = code.position(); - private final int dataPos = data.position(); - - @Override - public void close() { - nextRegister = registerMark; - code.data.position(codePos); - data.data.position(dataPos); - } - } - - /** - * Enters a scope in which the current register, code and data emitting state - * is restored upon leaving the scope. - */ - public Bookmark bookmark() { - return new Bookmark(); - } - - public ValueKind getValueKind(JavaKind kind) { - return new TestValueKind(codeCache.getTarget().arch.getPlatformKind(kind)); - } - - protected Register newRegister() { - return registers[nextRegister++]; - } - - protected StackSlot newStackSlot(PlatformKind kind) { - growFrame(kind.getSizeInBytes()); - return StackSlot.get(new TestValueKind(kind), -curStackSlot, true); - } - - public int getOffset(StackSlot slot) { - return slot.getOffset(frameSize); - } - - protected void growFrame(int sizeInBytes) { - curStackSlot += sizeInBytes; - if (curStackSlot > frameSize) { - int newFrameSize = curStackSlot; - if (newFrameSize % stackAlignment != 0) { - newFrameSize += stackAlignment - (newFrameSize % stackAlignment); - } - emitGrowStack(newFrameSize - frameSize); - frameSize = newFrameSize; - } - } - - protected void setDeoptRescueSlot(StackSlot deoptRescue) { - this.deoptRescue = deoptRescue; - } - - protected void recordCall(InvokeTarget target, int size, boolean direct, DebugInfo debugInfo) { - sites.add(new Call(target, code.position(), size, direct, debugInfo)); - } - - protected void recordMark(Object id) { - sites.add(new Mark(code.position(), id)); - } - - protected void recordImplicitException(DebugInfo info) { - sites.add(new Infopoint(code.position(), info, InfopointReason.IMPLICIT_EXCEPTION)); - } - - protected void recordDataPatchInCode(Reference ref) { - sites.add(new DataPatch(code.position(), ref)); - } - - protected void recordDataPatchInData(Reference ref) { - dataPatches.add(new DataPatch(data.position(), ref)); - } - - /** - * Emits the 32 bit constant `c` into the data section. - */ - public DataSectionReference emitDataItem(int c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - - recordDataPatchInCode(ref); - data.emitInt(c); - return ref; - } - - public DataSectionReference emitDataItem(HotSpotConstant c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - - recordDataPatchInData(new ConstantReference((VMConstant) c)); - if (c.isCompressed()) { - data.emitInt(0xDEADDEAD); - } else { - data.emitLong(0xDEADDEADDEADDEADL); - } - - return ref; - } - - public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) { - int id = method.allocateCompileId(0); - byte[] finishedCode = code.finish(); - Site[] finishedSites = sites.toArray(new Site[0]); - byte[] finishedData = data.finish(); - DataPatch[] finishedDataPatches = dataPatches.toArray(new DataPatch[0]); - int dataSectionAlignment = 8; // CodeBuffer::SECT_CONSTS code section alignment - return new HotSpotCompiledNmethod(method.getName(), finishedCode, finishedCode.length, finishedSites, new Assumption[0], new ResolvedJavaMethod[]{method}, new Comment[0], finishedData, dataSectionAlignment, - finishedDataPatches, false, frameSize, deoptRescue, method, -1, id, 0L, false); - } - - /** - * @param n Number of bits that should be set to 1. Must be between 0 and 32 (inclusive). - * @return A number with n bits set to 1. - */ - public static int getNbitNumberInt(int n) { - assert n >= 0 && n <= 32 : "0 <= n <= 32; instead: " + n; - if (n < 32) { - return (1 << n) - 1; - } else { - return 0xFFFFFFFF; - } - } - - public static boolean isSignedNbit(int n, int value) { - assert n > 0 && n < 32 : n; - int min = -(1 << (n - 1)); - int max = (1 << (n - 1)) - 1; - return value >= min && value <= max; - } - - public static boolean isUnsignedNbit(int n, int value) { - assert n > 0 && n < 32 : n; - return 32 - Integer.numberOfLeadingZeros(value) <= n; - } - - /** - * Determines if `x` is in the range of signed byte values. - */ - public static boolean isByte(int x) { - return (byte) x == x; - } - - /** - * Determines if `l` is in the range of signed int values. - */ - public static boolean isInt(long l) { - return (int) l == l; - } - - public static void check(boolean condition, String errorMessage, Object... args) { - if (!condition) { - throw new AssertionError(errorMessage.formatted(args)); - } - } - protected static class Buffer { - - private ByteBuffer data = ByteBuffer.allocate(32).order(ByteOrder.nativeOrder()); - - private void ensureSize(int length) { - if (length >= data.limit()) { - byte[] newBuf = Arrays.copyOf(data.array(), length * 4); - ByteBuffer newData = ByteBuffer.wrap(newBuf); - newData.order(data.order()); - newData.position(data.position()); - data = newData; - } - } - - public int position() { - return data.position(); - } - - public void emitByte(int b) { - ensureSize(data.position() + 1); - data.put((byte) (b & 0xFF)); - } - - public void emitShort(int b) { - ensureSize(data.position() + 2); - data.putShort((short) b); - } - - public void emitInt(int b) { - ensureSize(data.position() + 4); - data.putInt(b); - } - - public void emitLong(long b) { - ensureSize(data.position() + 8); - data.putLong(b); - } - - public void emitFloat(float f) { - ensureSize(data.position() + 4); - data.putFloat(f); - } - - public void emitDouble(double f) { - ensureSize(data.position() + 8); - data.putDouble(f); - } - - public void align(int alignment) { - int pos = data.position(); - int misaligned = pos % alignment; - if (misaligned != 0) { - pos += alignment - misaligned; - data.position(pos); - } - } - - private byte[] finish() { - return Arrays.copyOf(data.array(), data.position()); - } - } - - /** - * Loads a primitive into the Allocatable av. Implementors may only implement - * primitive types. - */ - public abstract void emitLoad(AllocatableValue av, Object prim); - - /** - * Emit a call to a fixed address addr. - */ - public abstract void emitCall(long addr); - - /** - * Emit code which is necessary to call a method with {@link CallingConvention} cc - * and arguments prim. - */ - public abstract void emitCallPrologue(CallingConvention cc, Object... prim); - - /** - * Emit code which is necessary after calling a method with CallingConvention cc. - */ - public abstract void emitCallEpilogue(CallingConvention cc); - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java deleted file mode 100644 index 4b0065d0e70..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestHotSpotVMConfig.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.test; - -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.code.Architecture; -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.hotspot.HotSpotVMConfigStore; - -public class TestHotSpotVMConfig extends HotSpotVMConfigAccess { - - public TestHotSpotVMConfig(HotSpotVMConfigStore config, Architecture arch) { - super(config); - ropProtection = (arch instanceof AArch64) ? getFieldValue("VM_Version::_rop_protection", Boolean.class) : false; - nmethodEntryBarrierConcurrentPatch = initNmethodEntryBarrierConcurrentPatch(arch); - } - - public final boolean useCompressedOops = getFlag("UseCompressedOops", Boolean.class); - - public final long narrowOopBase = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_base", Long.class, "address"); - public final int narrowOopShift = getFieldValue("CompilerToVM::Data::Universe_narrow_oop_shift", Integer.class, "int"); - - public final long narrowKlassBase = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_base", Long.class, "address"); - public final int narrowKlassShift = getFieldValue("CompilerToVM::Data::Universe_narrow_klass_shift", Integer.class, "int"); - - public final int classMirrorHandleOffset = getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle"); - - // Checkstyle: stop - public final int MARKID_DEOPT_HANDLER_ENTRY = getConstant("CodeInstaller::DEOPT_HANDLER_ENTRY", Integer.class); - public final int MARKID_FRAME_COMPLETE = getConstant("CodeInstaller::FRAME_COMPLETE", Integer.class); - public final int MARKID_ENTRY_BARRIER_PATCH = getConstant("CodeInstaller::ENTRY_BARRIER_PATCH", Integer.class); - public final long handleDeoptStub = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", Long.class, "address"); - - public final int maxOopMapStackOffset = getFieldValue("CompilerToVM::Data::_max_oop_map_stack_offset", Integer.class, "int"); - public final int heapWordSize = getConstant("HeapWordSize", Integer.class); - - public final int NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE = getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class); - - public final boolean ropProtection; - - private Boolean initNmethodEntryBarrierConcurrentPatch(Architecture arch) { - Boolean patchConcurrent = null; - if (arch instanceof AArch64 && nmethodEntryBarrier != 0) { - Integer patchingType = getFieldValue("CompilerToVM::Data::BarrierSetAssembler_nmethod_patching_type", Integer.class, "int"); - if (patchingType != null) { - // There currently only 2 variants in use that differ only by the presence of a - // dmb instruction - int stw = getConstant("NMethodPatchingType::stw_instruction_and_data_patch", Integer.class); - int conc = getConstant("NMethodPatchingType::conc_instruction_and_data_patch", Integer.class); - if (patchingType == stw) { - patchConcurrent = false; - } else if (patchingType == conc) { - patchConcurrent = true; - } else { - throw new IllegalArgumentException("unsupported barrier sequence " + patchingType); - } - } - } - return patchConcurrent; - } - - public final int threadDisarmedOffset = getFieldValue("CompilerToVM::Data::thread_disarmed_guard_value_offset", Integer.class, "int"); - public final long nmethodEntryBarrier = getFieldValue("CompilerToVM::Data::nmethod_entry_barrier", Long.class, "address"); - public final Boolean nmethodEntryBarrierConcurrentPatch; -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java deleted file mode 100644 index 543128e932c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" - * @library / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.code.site - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.aarch64 - * jdk.internal.vm.ci/jdk.vm.ci.amd64 - * jdk.internal.vm.ci/jdk.vm.ci.riscv64 - * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java TestHotSpotVMConfig.java amd64/AMD64TestAssembler.java aarch64/AArch64TestAssembler.java riscv64/RISCV64TestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.code.test.VirtualObjectDebugInfoTest - */ - -package jdk.vm.ci.code.test; - -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Objects; - -public class VirtualObjectDebugInfoTest extends DebugInfoTest { - - private static class TestClass { - - private long longField; - private int intField; - private float floatField; - private Object[] arrayField; - - TestClass() { - this.longField = 8472; - this.intField = 42; - this.floatField = 3.14f; - this.arrayField = new Object[]{Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!"}; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof TestClass)) { - return false; - } - - TestClass other = (TestClass) o; - if (this.longField != other.longField || this.intField != other.intField || this.floatField != other.floatField || this.arrayField.length != other.arrayField.length) { - return false; - } - - for (int i = 0; i < this.arrayField.length; i++) { - // break cycle - if (this.arrayField[i] == this && other.arrayField[i] == other) { - continue; - } - - if (!Objects.equals(this.arrayField[i], other.arrayField[i])) { - return false; - } - } - - return true; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - } - - public static TestClass buildObject() { - return new TestClass(); - } - - public static TestClass buildObjectStack() { - return new TestClass(); - } - - boolean storeToStack; - - private VirtualObject[] compileBuildObject(TestAssembler asm, JavaValue[] values) { - TestClass template = new TestClass(); - ArrayList vobjs = new ArrayList<>(); - - ResolvedJavaType retType = metaAccess.lookupJavaType(TestClass.class); - VirtualObject ret = VirtualObject.get(retType, vobjs.size()); - vobjs.add(ret); - values[0] = ret; - - ResolvedJavaType arrayType = metaAccess.lookupJavaType(Object[].class); - VirtualObject array = VirtualObject.get(arrayType, vobjs.size()); - vobjs.add(array); - - // build array for ret.arrayField - ResolvedJavaType integerType = metaAccess.lookupJavaType(Integer.class); - JavaValue[] arrayContent = new JavaValue[template.arrayField.length]; - JavaKind[] arrayKind = new JavaKind[template.arrayField.length]; - for (int i = 0; i < arrayContent.length; i++) { - arrayKind[i] = JavaKind.Object; - if (template.arrayField[i] == null) { - arrayContent[i] = JavaConstant.NULL_POINTER; - } else if (template.arrayField[i] == template) { - arrayContent[i] = ret; - } else if (template.arrayField[i] instanceof Integer) { - int value = (Integer) template.arrayField[i]; - VirtualObject boxed = VirtualObject.get(integerType, vobjs.size()); - vobjs.add(boxed); - arrayContent[i] = boxed; - boxed.setValues(new JavaValue[]{JavaConstant.forInt(value)}, new JavaKind[]{JavaKind.Int}); - } else if (template.arrayField[i] instanceof String) { - String value = (String) template.arrayField[i]; - Register reg = asm.emitLoadPointer((HotSpotConstant) constantReflection.forString(value)); - if (storeToStack) { - arrayContent[i] = asm.emitPointerToStack(reg); - } else { - arrayContent[i] = reg.asValue(asm.getValueKind(JavaKind.Object)); - } - } else { - Assert.fail("unexpected value"); - } - } - array.setValues(arrayContent, arrayKind); - - // build return object - ResolvedJavaField[] fields = retType.getInstanceFields(true); - JavaValue[] retContent = new JavaValue[fields.length]; - JavaKind[] retKind = new JavaKind[fields.length]; - for (int i = 0; i < fields.length; i++) { - retKind[i] = fields[i].getJavaKind(); - switch (retKind[i]) { - case Long: // template.longField - retContent[i] = JavaConstant.forLong(template.longField); - break; - case Int: // template.intField - Register intReg = asm.emitLoadInt(template.intField); - retContent[i] = asm.emitIntToStack(intReg); - break; - case Float: // template.floatField - Register fReg = asm.emitLoadFloat(template.floatField); - retContent[i] = fReg.asValue(asm.getValueKind(JavaKind.Float)); - break; - case Object: // template.arrayField - retContent[i] = array; - break; - default: - Assert.fail("unexpected field"); - } - } - ret.setValues(retContent, retKind); - - return vobjs.toArray(new VirtualObject[0]); - } - - @Test - public void testBuildObject() { - storeToStack = false; - test(this::compileBuildObject, getMethod("buildObject"), 7, JavaKind.Object); - } - - @Test - public void testBuildObjectStack() { - storeToStack = true; - test(this::compileBuildObject, getMethod("buildObjectStack"), 7, JavaKind.Object); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectFormattingTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectFormattingTest.java deleted file mode 100644 index 4b8df9785f3..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectFormattingTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.test; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaType; - -public class VirtualObjectFormattingTest extends VirtualObjectTestBase { - - @Test - public void testFormat() { - testBase(); - } - - @Override - protected void test(ResolvedJavaType klass, JavaValue[] kinds, JavaKind[] values, boolean malformed) { - // Verify that VirtualObject.toString will produce output without throwing exceptions or - // asserting. - VirtualObject virtual = VirtualObject.get(klass, 0); - virtual.setValues(kinds, values); - Assert.assertTrue(!virtual.toString().equals("")); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectTestBase.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectTestBase.java deleted file mode 100644 index 453974fdd76..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectTestBase.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.code.test; - -import java.util.Arrays; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; - -public abstract class VirtualObjectTestBase { - - private static final int DEFAULT_BYTE_ARRAY_LENGTH = 50; - - public static class SimpleObject { - int i1; - int i2; - int i3; - int i4; - int i5; - int i6; - } - - public static JavaConstant getValue(JavaKind kind) { - long dummyValue = kind.ordinal(); - dummyValue = dummyValue | dummyValue << 8; - dummyValue = dummyValue | dummyValue << 16; - dummyValue = dummyValue | dummyValue << 32; - if (kind.isNumericInteger()) { - return JavaConstant.forIntegerKind(kind, dummyValue); - } else if (kind == JavaKind.Double) { - return JavaConstant.forDouble(Double.longBitsToDouble(dummyValue)); - } else if (kind == JavaKind.Float) { - return JavaConstant.forFloat(Float.intBitsToFloat((int) dummyValue)); - } else { - return JavaConstant.NULL_POINTER; - } - } - - public static JavaValue[] getJavaValues(JavaKind[] kinds) { - JavaValue[] values = new JavaValue[kinds.length]; - for (int i = 0; i < kinds.length; i++) { - values[i] = getValue(kinds[i]); - } - return values; - } - - /** - * Subclasses are expected to override this method to provide their own verification logic using - * the normal JUnit {@link org.junit.Assert} methods. - * - * @param klass class for the {@link jdk.vm.ci.code.VirtualObject} - * @param kinds {@link JavaKind Javakinds} for values - * @param values {@link JavaValue values} for materializing the - * {@link jdk.vm.ci.code.VirtualObject} - * @param malformed indicates whether the resulting virtual object is considered to be properly - * formed relative to the fields of {@code klass} - * @throws AssertionError if a problem is detected - */ - protected abstract void test(ResolvedJavaType klass, JavaValue[] kinds, JavaKind[] values, boolean malformed); - - public void testBase() { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - ResolvedJavaType simple = metaAccess.lookupJavaType(SimpleObject.class); - ResolvedJavaField[] fields = simple.getInstanceFields(true); - - JavaKind[] fieldKinds = new JavaKind[fields.length]; - for (int i = 0; i < fields.length; i++) { - fieldKinds[i] = fields[i].getType().getJavaKind(); - } - - // Generate a straightforward VirtualObject with values that match to declared field types. - JavaKind[] kinds = fieldKinds.clone(); - JavaValue[] values = getJavaValues(kinds); - test(simple, values, kinds, false); - - // Spread a long value across two int fields starting at an aligned field - kinds = Arrays.copyOf(fieldKinds, fieldKinds.length - 1); - kinds[fields[0].getOffset() % 8 == 0 ? 0 : 1] = JavaKind.Long; - test(simple, getJavaValues(kinds), kinds, false); - - // Produce a long value for the final int field so there is no matching int field for the - // second half of the long - kinds = fieldKinds.clone(); - kinds[kinds.length - 1] = JavaKind.Long; - test(simple, getJavaValues(kinds), kinds, true); - - // Not enough values for the fields. - kinds = Arrays.copyOf(fieldKinds, fieldKinds.length - 1); - test(simple, getJavaValues(kinds), kinds, true); - - // Too many values for the fields. - kinds = Arrays.copyOf(fieldKinds, fieldKinds.length + 1); - kinds[kinds.length - 1] = JavaKind.Int; - test(simple, getJavaValues(kinds), kinds, true); - } - - public void testByteArray() { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - ResolvedJavaType byteArrayType = metaAccess.lookupJavaType(byte[].class); - - JavaKind[] arrayKinds = new JavaKind[DEFAULT_BYTE_ARRAY_LENGTH]; - for (int i = 0; i < DEFAULT_BYTE_ARRAY_LENGTH; i++) { - arrayKinds[i] = JavaKind.Byte; - } - - JavaKind[] kinds; - JavaValue[] values; - - // Generate a straighforward byte array. - kinds = arrayKinds.clone(); - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, false); - - // Write all primitive kinds into a byte array. Only primitives with enough Illegals should - // succeed. - for (JavaKind kind : JavaKind.values()) { - if (kind.isPrimitive() && kind != JavaKind.Void) { - kinds = arrayKinds.clone(); - kinds[0] = kind; - for (int i = 1; i < kind.getByteCount() /* && i < DEFAULT_BYTE_ARRAY_LENGTH */; i++) { - kinds[i] = JavaKind.Illegal; - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, false); - } - } - - // Write all kinds into a byte array, but forget to set Illegals. - for (JavaKind kind : JavaKind.values()) { - if (kind.isPrimitive() && kind != JavaKind.Void) { - kinds = arrayKinds.clone(); - kinds[0] = kind; - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, kind.getStackKind() != JavaKind.Int); - } - } - - // Write all kinds into a byte array, but set a wrong number of Illegals. - for (JavaKind kind : JavaKind.values()) { - if (kind.isPrimitive() && kind != JavaKind.Void) { - kinds = arrayKinds.clone(); - kinds[0] = kind; - for (int i = 1; i < 5 /* && i < DEFAULT_BYTE_ARRAY_LENGTH */; i++) { - kinds[i] = JavaKind.Illegal; - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, true); - } - } - - // Write a reference in a byte array. - kinds = arrayKinds.clone(); - kinds[0] = JavaKind.Object; - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, true); - - // Put too many Illegals. - kinds = arrayKinds.clone(); - for (int i = 1; i < DEFAULT_BYTE_ARRAY_LENGTH; i++) { - kinds[i] = JavaKind.Illegal; - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, true); - - // Fill a byte array with Illegals. - kinds = arrayKinds.clone(); - for (int i = 0; i < DEFAULT_BYTE_ARRAY_LENGTH; i++) { - kinds[i] = JavaKind.Illegal; - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, true); - - // Write all kinds in a byte array successively. - kinds = arrayKinds.clone(); - int i = 0; - for (JavaKind kind : JavaKind.values()) { - if (kind.isPrimitive() && kind != JavaKind.Void) { - kinds[i] = kind; - for (int j = 1; j < kind.getByteCount(); j++) { - kinds[i + j] = JavaKind.Illegal; - } - i = i + kind.getByteCount(); - } - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, false); - - // Write all kinds in a byte array successively, with an interleaving byte. - kinds = arrayKinds.clone(); - i = 0; - for (JavaKind kind : JavaKind.values()) { - if (kind.isPrimitive() && kind != JavaKind.Void) { - kinds[i] = kind; - for (int j = 1; j < kind.getByteCount(); j++) { - kinds[i + j] = JavaKind.Illegal; - } - i = i + kind.getByteCount() + 1; - } - } - values = getJavaValues(kinds); - test(byteArrayType, values, kinds, false); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java deleted file mode 100644 index d64ca7544e6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java +++ /dev/null @@ -1,666 +0,0 @@ -/* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2023, Arm Limited. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.code.test.aarch64; - -import java.util.List; -import jdk.vm.ci.aarch64.AArch64; -import jdk.vm.ci.aarch64.AArch64Kind; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.test.TestAssembler; -import jdk.vm.ci.code.test.TestHotSpotVMConfig; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.VMConstant; - -public class AArch64TestAssembler extends TestAssembler { - - private static final Register scratchRegister = AArch64.rscratch1; - private static final Register scratchRegister2 = AArch64.rscratch2; - private static final Register doubleScratch = AArch64.v9; - - /** - * Condition Flags for branches. See C1.2.4 - */ - public enum ConditionFlag { - // Integer | Floating-point meanings - /** Equal | Equal. */ - EQ(0x0), - - /** Not Equal | Not equal or unordered. */ - NE(0x1), - - /** Unsigned Higher or Same | Greater than, equal or unordered. */ - HS(0x2), - - /** Unsigned lower | less than. */ - LO(0x3), - - /** Minus (negative) | less than. */ - MI(0x4), - - /** Plus (positive or zero) | greater than, equal or unordered. */ - PL(0x5), - - /** Overflow set | unordered. */ - VS(0x6), - - /** Overflow clear | ordered. */ - VC(0x7), - - /** Unsigned higher | greater than or unordered. */ - HI(0x8), - - /** Unsigned lower or same | less than or equal. */ - LS(0x9), - - /** Signed greater than or equal | greater than or equal. */ - GE(0xA), - - /** Signed less than | less than or unordered. */ - LT(0xB), - - /** Signed greater than | greater than. */ - GT(0xC), - - /** Signed less than or equal | less than, equal or unordered. */ - LE(0xD), - - /** Always | always. */ - AL(0xE), - - /** Always | always (identical to AL, just to have valid 0b1111 encoding). */ - NV(0xF); - - public final int encoding; - - ConditionFlag(int encoding) { - this.encoding = encoding; - } - } - - public AArch64TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) { - super(codeCache, config, - 16 /* initialFrameSize */, 16 /* stackAlignment */, - AArch64Kind.DWORD /* narrowOopKind */, - /* registers */ - AArch64.r0, AArch64.r1, AArch64.r2, AArch64.r3, - AArch64.r4, AArch64.r5, AArch64.r6, AArch64.r7); - } - - private static int f(int val, int msb, int lsb) { - int nbits = msb - lsb + 1; - assert val >= 0; - assert val < (1 << nbits); - assert msb >= lsb; - return val << lsb; - } - - private static int f(Register r, int msb, int lsb) { - assert msb - lsb == 4; - return f(r.encoding, msb, lsb); - } - - private void emitNop() { - code.emitInt(0xd503201f); - } - - private void emitAdd(Register Rd, Register Rn, Register Rm) { - // ADD (shifted register) - code.emitInt(f(0b10001011000, 31, 21) - | f(Rm, 20, 16) - | f(0, 15, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitAdd(Register Rd, Register Rn, int imm12) { - // ADD (immediate) - code.emitInt(f(0b1001000100, 31, 22) - | f(imm12, 21, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitSub(Register Rd, Register Rn, int imm12) { - // SUB (immediate) - code.emitInt(f(0b1101000100, 31, 22) - | f(imm12, 21, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitSub(Register Rd, Register Rn, Register Rm) { - // SUB (extended register) - code.emitInt(f(0b11001011001, 31, 21) - | f(Rm, 20, 16) - | f(0b011000, 15, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitMov(Register Rd, Register Rm) { - // MOV (register) - code.emitInt(f(0b10101010000, 31, 21) - | f(Rm, 20, 16) - | f(0, 15, 10) - | f(AArch64.zr, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitMovz(Register Rd, int imm16, int shift) { - // MOVZ - int hw = 0; - switch (shift) { - case 0: hw = 0; break; - case 16: hw = 1; break; - case 32: hw = 2; break; - case 48: hw = 3; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(0b110100101, 31, 23) - | f(hw, 22, 21) - | f(imm16, 20, 5) - | f(Rd, 4, 0)); - } - - private void emitMovk(Register Rd, int imm16, int shift) { - // MOVK - int hw = 0; - switch (shift) { - case 0: hw = 0; break; - case 16: hw = 1; break; - case 32: hw = 2; break; - case 48: hw = 3; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(0b111100101, 31, 23) - | f(hw, 22, 21) - | f(imm16, 20, 5) - | f(Rd, 4, 0)); - } - - private void emitShiftLeft(Register Rd, Register Rn, int shift) { - // LSL (immediate) - code.emitInt(f(0b1101001101, 31, 22) - | f(-shift & 0b111111, 21, 16) - | f(63 - shift, 15, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - private void emitLoadRegister(Register Rt, AArch64Kind kind, int offset) { - // LDR (literal) - int opc = 0; - switch (kind) { - case DWORD: opc = 0; break; - case QWORD: opc = 1; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(opc, 31, 30) - | f(0b011000, 29, 24) - | f(offset, 23, 5) - | f(Rt, 4, 0)); - } - - private void emitLoadRegister(Register Rt, AArch64Kind kind, Register Rn, int offset) { - // LDR (immediate) - assert offset >= 0; - int size = 0; - switch (kind) { - case DWORD: size = 0b10; break; - case QWORD: size = 0b11; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(size, 31, 30) - | f(0b11100101, 29, 22) - | f(offset >> size, 21, 10) - | f(Rn, 9, 5) - | f(Rt, 4, 0)); - } - - private void emitStoreRegister(Register Rt, AArch64Kind kind, Register Rn, int offset) { - // STR (immediate) - assert offset >= 0; - int size = 0, fp = 0; - switch (kind) { - case DWORD: size = 0b10; fp = 0; break; - case QWORD: size = 0b11; fp = 0; break; - case SINGLE: size = 0b10; fp = 1; break; - case DOUBLE: size = 0b11; fp = 1; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(size, 31, 30) - | f(0b111, 29, 27) - | f(fp, 26, 26) - | f(0b0100, 25, 22) - | f(offset >> size, 21, 10) - | f(Rn, 9, 5) - | f(Rt, 4, 0)); - } - - private void emitBlr(Register Rn) { - // BLR - code.emitInt(f(0b1101011000111111000000, 31, 10) - | f(Rn, 9, 5) - | f(0, 4, 0)); - } - - /** - * C6.2.25 Branch conditionally. - * - * @param condition may not be null. - * @param imm21 Signed 21-bit offset, has to be 4-byte aligned. - */ - protected void emitBranch(ConditionFlag condition, int imm21) { - // B.cond - check(isSignedNbit(21, imm21) && (imm21 & 0b11) == 0, - "0x%x must be a 21-bit signed number and 4-byte aligned", imm21); - int imm19 = (imm21 & getNbitNumberInt(21)) >> 2; - code.emitInt(f(0b001010100, 31, 24) - | f(imm19, 23, 4) - | f(condition.encoding, 3, 0)); - } - - private void emitFmov(Register Rd, AArch64Kind kind, Register Rn) { - // FMOV (general) - int ftype = 0, sf = 0; - switch (kind) { - case SINGLE: sf = 0; ftype = 0b00; break; - case DOUBLE: sf = 1; ftype = 0b01; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(sf, 31, 31) - | f(0b0011110, 30, 24) - | f(ftype, 23, 22) - | f(0b100111, 21, 16) - | f(0, 15, 10) - | f(Rn, 9, 5) - | f(Rd, 4, 0)); - } - - @Override - public void emitGrowStack(int size) { - assert size % 16 == 0; - if (size > -4096 && size < 0) { - emitAdd(AArch64.sp, AArch64.sp, -size); - } else if (size == 0) { - // No-op - } else if (size < 4096) { - emitSub(AArch64.sp, AArch64.sp, size); - } else if (size < 65535) { - emitMovz(scratchRegister, size & 0xffff, 0); - emitMovk(scratchRegister, (size >> 16) & 0xffff, 16); - emitSub(AArch64.sp, AArch64.sp, scratchRegister); - } else { - throw new IllegalArgumentException(); - } - } - - @Override - public void emitPrologue() { - // Must be patchable by NativeJump::patch_verified_entry - emitNop(); - if (config.ropProtection) { - code.emitInt(0xf94003df); // ldr xzr, [x30] - code.emitInt(0xd503231f); // paciaz - } - code.emitInt(0xa9bf7bfd); // stp x29, x30, [sp, #-16]! - code.emitInt(0x910003fd); // mov x29, sp - - emitNMethodEntryBarrier(); - - setDeoptRescueSlot(newStackSlot(AArch64Kind.QWORD)); - } - - private void emitNMethodEntryBarrier() { - recordMark(config.MARKID_ENTRY_BARRIER_PATCH); - DataSectionReference ref = emitDataItem(0); - emitLoadPointer(scratchRegister, AArch64Kind.DWORD, ref); - if (config.nmethodEntryBarrierConcurrentPatch) { - code.emitInt(0xd50339bf); // dmb ishld - } - Register thread = AArch64.r28; - emitLoadPointer(scratchRegister2, AArch64Kind.DWORD, thread, config.threadDisarmedOffset); - code.emitInt(0x6b09011f); // cmp w8, w9 - emitBranch(ConditionFlag.EQ, 8); // jump over slow path, runtime call - emitCall(config.nmethodEntryBarrier); - } - - @Override - public void emitEpilogue() { - recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); - recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 4*4, true, null); - emitCall(0xdeaddeaddeadL); - } - - @Override - public void emitCallPrologue(CallingConvention cc, Object... prim) { - growFrame(cc.getStackSize()); - List args = cc.getArguments(); - for (int i = 0; i < args.size(); i++) { - emitLoad(args.get(i), prim[i]); - } - } - - @Override - public void emitCallEpilogue(CallingConvention cc) { - growFrame(-cc.getStackSize()); - } - - @Override - public void emitCall(long addr) { - emitLoadPointer48(scratchRegister, addr); - emitBlr(scratchRegister); - } - - @Override - public void emitLoad(AllocatableValue av, Object prim) { - if (av instanceof RegisterValue) { - Register reg = ((RegisterValue) av).getRegister(); - if (prim instanceof Float) { - emitLoadFloat(reg, (Float) prim); - } else if (prim instanceof Double) { - emitLoadDouble(reg, (Double) prim); - } else if (prim instanceof Integer) { - emitLoadInt(reg, (Integer) prim); - } else if (prim instanceof Long) { - emitLoadLong(reg, (Long) prim); - } - } else if (av instanceof StackSlot) { - StackSlot slot = (StackSlot) av; - if (prim instanceof Float) { - emitFloatToStack(slot, emitLoadFloat(doubleScratch, (Float) prim)); - } else if (prim instanceof Double) { - emitDoubleToStack(slot, emitLoadDouble(doubleScratch, (Double) prim)); - } else if (prim instanceof Integer) { - emitIntToStack(slot, emitLoadInt(scratchRegister, (Integer) prim)); - } else if (prim instanceof Long) { - emitLongToStack(slot, emitLoadLong(scratchRegister, (Long) prim)); - } else { - assert false : "Unimplemented"; - } - } else { - throw new IllegalArgumentException("Unknown value " + av); - } - } - - private void emitLoadPointer32(Register ret, long addr) { - long a = addr; - long al = a; - a >>= 16; - long ah = a; - a >>= 16; - assert a == 0 : "invalid pointer" + Long.toHexString(addr); - // Set upper 16 bits first. See MacroAssembler::patch_oop(). - emitMovz(ret, ((int)ah & 0xffff), 16); - emitMovk(ret, ((int)al & 0xffff), 0); - } - - private void emitLoadPointer48(Register ret, long addr) { - // 48-bit VA - long a = addr; - emitMovz(ret, ((int)a & 0xffff), 0); - a >>= 16; - emitMovk(ret, ((int)a & 0xffff), 16); - a >>= 16; - emitMovk(ret, ((int)a & 0xffff), 32); - a >>= 16; - assert a == 0 : "invalid pointer" + Long.toHexString(addr); - } - - @Override - public Register emitLoadPointer(HotSpotConstant c) { - recordDataPatchInCode(new ConstantReference((VMConstant) c)); - - Register ret = newRegister(); - if (c.isCompressed()) { - emitLoadPointer32(ret, 0xdeaddeadL); - } else { - emitLoadPointer48(ret, 0xdeaddeaddeadL); - } - return ret; - } - - @Override - public Register emitLoadPointer(Register b, int offset) { - return emitLoadPointer(newRegister(), AArch64Kind.QWORD, b, offset); - } - - public Register emitLoadPointer(Register ret, AArch64Kind kind, Register b, int offset) { - emitLoadRegister(ret, kind, b, offset); - return ret; - } - - @Override - public Register emitLoadNarrowPointer(DataSectionReference ref) { - recordDataPatchInCode(ref); - - Register ret = newRegister(); - emitLoadRegister(ret, AArch64Kind.DWORD, 0xdead); - return ret; - } - - @Override - public Register emitLoadPointer(DataSectionReference ref) { - return emitLoadPointer(newRegister(), AArch64Kind.QWORD, ref); - } - - public Register emitLoadPointer(Register ret, AArch64Kind kind, DataSectionReference ref) { - recordDataPatchInCode(ref); - - emitLoadRegister(ret, kind, 0xdead); - return ret; - } - - private Register emitLoadDouble(Register reg, double c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitDouble(c); - - recordDataPatchInCode(ref); - emitLoadRegister(scratchRegister, AArch64Kind.QWORD, 0xdead); - emitFmov(reg, AArch64Kind.DOUBLE, scratchRegister); - return reg; - } - - private Register emitLoadFloat(Register reg, float c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitFloat(c); - - recordDataPatchInCode(ref); - emitLoadRegister(scratchRegister, AArch64Kind.DWORD, 0xdead); - emitFmov(reg, AArch64Kind.SINGLE, scratchRegister); - return reg; - } - - @Override - public Register emitLoadFloat(float c) { - Register ret = AArch64.v0; - return emitLoadFloat(ret, c); - } - - private Register emitLoadLong(Register reg, long c) { - emitMovz(reg, (int)(c & 0xffff), 0); - emitMovk(reg, (int)((c >> 16) & 0xffff), 16); - emitMovk(reg, (int)((c >> 32) & 0xffff), 32); - emitMovk(reg, (int)((c >> 48) & 0xffff), 48); - return reg; - } - - @Override - public Register emitLoadLong(long c) { - Register ret = newRegister(); - return emitLoadLong(ret, c); - } - - private Register emitLoadInt(Register reg, int c) { - emitMovz(reg, (int)(c & 0xffff), 0); - emitMovk(reg, (int)((c >> 16) & 0xffff), 16); - return reg; - } - - @Override - public Register emitLoadInt(int c) { - Register ret = newRegister(); - return emitLoadInt(ret, c); - } - - @Override - public Register emitIntArg0() { - return codeCache.getRegisterConfig() - .getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int) - .get(0); - } - - @Override - public Register emitIntArg1() { - return codeCache.getRegisterConfig() - .getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int) - .get(1); - } - - @Override - public Register emitIntAdd(Register a, Register b) { - emitAdd(a, a, b); - return a; - } - - @Override - public void emitTrap(DebugInfo info) { - // Dereference null pointer - emitMovz(scratchRegister, 0, 0); - recordImplicitException(info); - emitLoadRegister(AArch64.zr, AArch64Kind.QWORD, scratchRegister, 0); - } - - @Override - public void emitIntRet(Register a) { - emitMov(AArch64.r0, a); - code.emitInt(0x910003bf); // mov sp, x29 - code.emitInt(0xa8c17bfd); // ldp x29, x30, [sp], #16 - if (config.ropProtection) { - code.emitInt(0xd503239f); // autiaz - code.emitInt(0xf94003df); // ldr xzr, [x30] - } - code.emitInt(0xd65f03c0); // ret - } - - @Override - public void emitFloatRet(Register a) { - assert a == AArch64.v0 : "Unimplemented move " + a; - code.emitInt(0x910003bf); // mov sp, x29 - code.emitInt(0xa8c17bfd); // ldp x29, x30, [sp], #16 - if (config.ropProtection) { - code.emitInt(0xd503239f); // autiaz - code.emitInt(0xf94003df); // ldr xzr, [x30] - } - code.emitInt(0xd65f03c0); // ret - } - - @Override - public void emitPointerRet(Register a) { - emitIntRet(a); - } - - @Override - public StackSlot emitPointerToStack(Register a) { - return emitLongToStack(a); - } - - @Override - public StackSlot emitNarrowPointerToStack(Register a) { - return emitIntToStack(a); - } - - @Override - public Register emitUncompressPointer(Register compressed, long base, int shift) { - if (shift > 0) { - emitShiftLeft(compressed, compressed, shift); - } - - if (base != 0) { - emitLoadLong(scratchRegister, base); - emitAdd(compressed, compressed, scratchRegister); - } - - return compressed; - } - - private StackSlot emitDoubleToStack(StackSlot slot, Register a) { - emitStoreRegister(a, AArch64Kind.DOUBLE, AArch64.sp, slot.getOffset(frameSize)); - return slot; - } - - @Override - public StackSlot emitDoubleToStack(Register a) { - StackSlot ret = newStackSlot(AArch64Kind.DOUBLE); - return emitDoubleToStack(ret, a); - } - - private StackSlot emitFloatToStack(StackSlot slot, Register a) { - emitStoreRegister(a, AArch64Kind.SINGLE, AArch64.sp, slot.getOffset(frameSize)); - return slot; - } - - @Override - public StackSlot emitFloatToStack(Register a) { - StackSlot ret = newStackSlot(AArch64Kind.SINGLE); - return emitFloatToStack(ret, a); - } - - private StackSlot emitIntToStack(StackSlot slot, Register a) { - emitStoreRegister(a, AArch64Kind.DWORD, AArch64.sp, slot.getOffset(frameSize)); - return slot; - } - - @Override - public StackSlot emitIntToStack(Register a) { - StackSlot ret = newStackSlot(AArch64Kind.DWORD); - return emitIntToStack(ret, a); - } - - private StackSlot emitLongToStack(StackSlot slot, Register a) { - emitStoreRegister(a, AArch64Kind.QWORD, AArch64.sp, slot.getOffset(frameSize)); - return slot; - } - - @Override - public StackSlot emitLongToStack(Register a) { - StackSlot ret = newStackSlot(AArch64Kind.QWORD); - return emitLongToStack(ret, a); - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java deleted file mode 100644 index 1ca0e9ac879..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.code.test.amd64; - -import static jdk.vm.ci.amd64.AMD64.xmm0; - -import java.util.List; -import jdk.vm.ci.amd64.AMD64; -import jdk.vm.ci.amd64.AMD64Kind; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.test.TestAssembler; -import jdk.vm.ci.code.test.TestHotSpotVMConfig; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.VMConstant; - -public class AMD64TestAssembler extends TestAssembler { - - private static final Register scratchRegister = AMD64.r12; - private static final Register doubleScratch = AMD64.xmm15; - - /** - * The x86 condition codes used for conditional jumps/moves. - */ - public enum ConditionFlag { - Zero(0x4, "|zero|"), - NotZero(0x5, "|nzero|"), - Equal(0x4, "="), - NotEqual(0x5, "!="), - Less(0xc, "<"), - LessEqual(0xe, "<="), - Greater(0xf, ">"), - GreaterEqual(0xd, ">="), - Below(0x2, "|<|"), - BelowEqual(0x6, "|<=|"), - Above(0x7, "|>|"), - AboveEqual(0x3, "|>=|"), - Overflow(0x0, "|of|"), - NoOverflow(0x1, "|nof|"), - CarrySet(0x2, "|carry|"), - CarryClear(0x3, "|ncarry|"), - Negative(0x8, "|neg|"), - Positive(0x9, "|pos|"), - Parity(0xa, "|par|"), - NoParity(0xb, "|npar|"); - - public final int value; - public final String operator; - - ConditionFlag(int value, String operator) { - this.value = value; - this.operator = operator; - } - } - - public AMD64TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) { - super(codeCache, config, 16, 16, AMD64Kind.DWORD, AMD64.rax, AMD64.rcx, AMD64.rdi, AMD64.r8, AMD64.r9, AMD64.r10); - } - - private void emitFatNop() { - // 5 byte NOP: - // NOP DWORD ptr [EAX + EAX*1 + 00H] - code.emitByte(0x0F); - code.emitByte(0x1F); - code.emitByte(0x44); - code.emitByte(0x00); - code.emitByte(0x00); - } - - /** - * Emit the expected patchable code sequence for the nmethod entry barrier. The int sized - * payload must be naturally aligned so it can be patched atomically. - */ - private void emitNMethodEntryCompare(int displacement) { - // cmp dword ptr [r15 + ], 0x00000000 - // 41 81 7f 00 00 00 00 - code.emitByte(0x41); - code.emitByte(0x81); - code.emitByte(0x7f); - check(isByte(displacement), "expected byte sized displacement: 0x%x", displacement); - code.emitByte(displacement & 0xff); - check(code.position() % 4 == 0, "must be aligned"); - code.emitInt(0); - } - - /** - * Emits a long (i.e. 6 byte) format conditional branch. - * - * @param offset the offset of the branch target wrt the start of the branch instruction - */ - private void emitBranch(ConditionFlag condition, int offset) { - final int longSize = 6; - int disp32 = offset - longSize; - - // 0000 1111 1000 tttn #32-bit disp - check(isInt(disp32), "must be 32bit disp: %d", disp32); - code.emitByte(0x0F); - code.emitByte(0x80 | condition.value); - code.emitInt(disp32); - } - - public void emitAlign(int modulus) { - while (code.position() % modulus != 0) { - code.emitByte(0x90); - } - } - - private void emitNMethodEntryBarrier() { - // The following code sequence must be emitted in exactly this fashion as HotSpot - // will check that the barrier is the expected code sequence. - emitAlign(4); - recordMark(config.MARKID_FRAME_COMPLETE); - recordMark(config.MARKID_ENTRY_BARRIER_PATCH); - emitNMethodEntryCompare(config.threadDisarmedOffset); - int branchOffset; - try (Bookmark bm = bookmark()) { - int pos = code.position(); - emitBranch(ConditionFlag.Equal, 0); - emitCall(config.nmethodEntryBarrier); - branchOffset = code.position() - pos; - } - emitBranch(ConditionFlag.Equal, branchOffset); - emitCall(config.nmethodEntryBarrier); - } - - @Override - public void emitPrologue() { - // WARNING: Initial instruction MUST be 5 bytes or longer so that - // NativeJump::patch_verified_entry will be able to patch out the entry - // code safely. - emitFatNop(); - code.emitByte(0x50 | AMD64.rbp.encoding); // PUSH rbp - emitMove(true, AMD64.rbp, AMD64.rsp); // MOV rbp, rsp - emitNMethodEntryBarrier(); - setDeoptRescueSlot(newStackSlot(AMD64Kind.QWORD)); - } - - @Override - public void emitEpilogue() { - recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); - recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 5, true, null); - code.emitByte(0xE8); // CALL rel32 - code.emitInt(0xDEADDEAD); - } - - @Override - public void emitGrowStack(int size) { - // SUB rsp, size - code.emitByte(0x48); - code.emitByte(0x81); - code.emitByte(0xEC); - code.emitInt(size); - } - - @Override - public Register emitIntArg0() { - return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int).get(0); - } - - @Override - public Register emitIntArg1() { - return codeCache.getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int).get(1); - } - - private void emitREX(boolean w, int r, int x, int b) { - int wrxb = (w ? 0x08 : 0) | ((r >> 3) << 2) | ((x >> 3) << 1) | (b >> 3); - if (wrxb != 0) { - code.emitByte(0x40 | wrxb); - } - } - - private void emitModRMReg(boolean w, int opcode, int r, int m) { - emitREX(w, r, 0, m); - code.emitByte((byte) opcode); - code.emitByte((byte) 0xC0 | ((r & 0x7) << 3) | (m & 0x7)); - } - - private void emitModRMMemory(boolean w, int opcode, int r, int b, int offset) { - emitREX(w, r, 0, b); - code.emitByte((byte) opcode); - code.emitByte((byte) 0x80 | ((r & 0x7) << 3) | (b & 0x7)); - code.emitInt(offset); - } - - @Override - public Register emitLoadInt(int c) { - Register ret = newRegister(); - return emitLoadInt(ret, c); - } - - public Register emitLoadInt(Register ret, int c) { - emitREX(false, 0, 0, ret.encoding); - code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32 - code.emitInt(c); - return ret; - } - - @Override - public Register emitLoadLong(long c) { - Register ret = newRegister(); - return emitLoadLong(ret, c); - } - - public Register emitLoadLong(Register ret, long c) { - emitREX(true, 0, 0, ret.encoding); - code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r64, imm64 - code.emitLong(c); - return ret; - } - - @Override - public Register emitLoadFloat(float c) { - Register ret = AMD64.xmm0; - return emitLoadFloat(ret, c); - } - - public Register emitLoadFloat(Register ret, float c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitFloat(c); - - recordDataPatchInCode(ref); - emitREX(false, ret.encoding, 0, 0); - code.emitByte(0xF3); - code.emitByte(0x0F); - code.emitByte(0x10); // MOVSS xmm1, xmm2/m32 - code.emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // xmm, [rip+offset] - code.emitInt(0xDEADDEAD); - return ret; - } - - public Register emitLoadDouble(double c) { - Register ret = AMD64.xmm0; - return emitLoadDouble(ret, c); - } - - public Register emitLoadDouble(Register ret, double c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitDouble(c); - - recordDataPatchInCode(ref); - emitREX(false, ret.encoding, 0, 0); - code.emitByte(0xF2); - code.emitByte(0x0F); - code.emitByte(0x10); // MOVSD xmm1, xmm2/m32 - code.emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // xmm, [rip+offset] - code.emitInt(0xDEADDEAD); - return ret; - } - - @Override - public Register emitLoadPointer(HotSpotConstant c) { - recordDataPatchInCode(new ConstantReference((VMConstant) c)); - if (c.isCompressed()) { - Register ret = newRegister(); - emitREX(false, 0, 0, ret.encoding); - code.emitByte(0xB8 | (ret.encoding & 0x7)); // MOV r32, imm32 - code.emitInt(0xDEADDEAD); - return ret; - } else { - return emitLoadLong(0xDEADDEADDEADDEADL); - } - } - - private Register emitLoadPointer(DataSectionReference ref, boolean narrow) { - recordDataPatchInCode(ref); - Register ret = newRegister(); - emitREX(!narrow, ret.encoding, 0, 0); - code.emitByte(0x8B); // MOV r64,r/m64 - code.emitByte(0x05 | ((ret.encoding & 0x7) << 3)); // r64, [rip+offset] - code.emitInt(0xDEADDEAD); - return ret; - } - - @Override - public Register emitLoadPointer(DataSectionReference ref) { - return emitLoadPointer(ref, false); - } - - @Override - public Register emitLoadNarrowPointer(DataSectionReference ref) { - return emitLoadPointer(ref, true); - } - - @Override - public Register emitLoadPointer(Register b, int offset) { - Register ret = newRegister(); - emitModRMMemory(true, 0x8B, ret.encoding, b.encoding, offset); // MOV r64,r/m64 - return ret; - } - - private int getAdjustedOffset(StackSlot ret) { - if (ret.getRawOffset() < 0) { - return ret.getRawOffset() + 16; - } else { - return -(frameSize - ret.getRawOffset()) + 16; - } - } - - @Override - public StackSlot emitIntToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.DWORD); - return emitIntToStack(ret, a); - } - - public StackSlot emitIntToStack(StackSlot ret, Register a) { - // MOV r/m32,r32 - emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, getAdjustedOffset(ret)); - return ret; - } - - @Override - public StackSlot emitLongToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.QWORD); - return emitLongToStack(ret, a); - } - - public StackSlot emitLongToStack(StackSlot ret, Register a) { - // MOV r/m64,r64 - emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, getAdjustedOffset(ret)); - return ret; - } - - @Override - public StackSlot emitFloatToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.SINGLE); - return emitFloatToStack(ret, a); - } - - public StackSlot emitFloatToStack(StackSlot ret, Register a) { - emitREX(false, a.encoding, 0, 0); - code.emitByte(0xF3); - code.emitByte(0x0F); - code.emitByte(0x11); // MOVSS xmm2/m32, xmm1 - code.emitByte(0x85 | ((a.encoding & 0x7) << 3)); // [rbp+offset] - code.emitInt(getAdjustedOffset(ret)); - return ret; - } - - @Override - public StackSlot emitDoubleToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.DOUBLE); - return emitDoubleToStack(ret, a); - } - - public StackSlot emitDoubleToStack(StackSlot ret, Register a) { - emitREX(false, a.encoding, 0, 0); - code.emitByte(0xF2); - code.emitByte(0x0F); - code.emitByte(0x11); // MOVSD xmm2/m32, xmm1 - code.emitByte(0x85 | ((a.encoding & 0x7) << 3)); // [rbp+offset] - code.emitInt(getAdjustedOffset(ret)); - return ret; - } - - @Override - public StackSlot emitPointerToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.QWORD); - // MOV r/m64,r64 - emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); - return ret; - } - - @Override - public StackSlot emitNarrowPointerToStack(Register a) { - StackSlot ret = newStackSlot(AMD64Kind.DWORD); - // MOV r/m32,r32 - emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); - return ret; - } - - @Override - public Register emitUncompressPointer(Register compressed, long base, int shift) { - if (shift > 0) { - emitModRMReg(true, 0xC1, 4, compressed.encoding); - code.emitByte(shift); - } - if (base == 0) { - return compressed; - } else { - Register tmp = emitLoadLong(base); - emitModRMReg(true, 0x03, tmp.encoding, compressed.encoding); - return tmp; - } - } - - @Override - public Register emitIntAdd(Register a, Register b) { - emitModRMReg(false, 0x03, a.encoding, b.encoding); - return a; - } - - private void emitMove(boolean w, Register to, Register from) { - if (to != from) { - emitModRMReg(w, 0x8B, to.encoding, from.encoding); - } - } - - @Override - public void emitIntRet(Register a) { - emitMove(false, AMD64.rax, a); // MOV eax, ... - emitMove(true, AMD64.rsp, AMD64.rbp); // MOV rsp, rbp - code.emitByte(0x58 | AMD64.rbp.encoding); // POP rbp - code.emitByte(0xC3); // RET - } - - @Override - public void emitFloatRet(Register a) { - assert a == xmm0 : "Unimplemented move " + a; - emitMove(true, AMD64.rsp, AMD64.rbp); // MOV rsp, rbp - code.emitByte(0x58 | AMD64.rbp.encoding); // POP rbp - code.emitByte(0xC3); // RET - } - - @Override - public void emitPointerRet(Register a) { - emitMove(true, AMD64.rax, a); // MOV rax, ... - emitMove(true, AMD64.rsp, AMD64.rbp); // MOV rsp, rbp - code.emitByte(0x58 | AMD64.rbp.encoding); // POP rbp - code.emitByte(0xC3); // RET - } - - @Override - public void emitTrap(DebugInfo info) { - recordImplicitException(info); - // MOV rax, [0] - code.emitByte(0x8B); - code.emitByte(0x04); - code.emitByte(0x25); - code.emitInt(0); - } - - @Override - public void emitLoad(AllocatableValue av, Object prim) { - if (av instanceof RegisterValue) { - Register reg = ((RegisterValue) av).getRegister(); - if (prim instanceof Float) { - emitLoadFloat(reg, (Float) prim); - } else if (prim instanceof Double) { - emitLoadDouble(reg, (Double) prim); - } else if (prim instanceof Integer) { - emitLoadInt(reg, (Integer) prim); - } else if (prim instanceof Long) { - emitLoadLong(reg, (Long) prim); - } - } else if (av instanceof StackSlot) { - StackSlot slot = (StackSlot) av; - if (prim instanceof Float) { - emitFloatToStack(slot, emitLoadFloat(doubleScratch, (Float) prim)); - } else if (prim instanceof Double) { - emitDoubleToStack(slot, emitLoadDouble(doubleScratch, (Double) prim)); - } else if (prim instanceof Integer) { - emitIntToStack(slot, emitLoadInt(scratchRegister, (Integer) prim)); - } else if (prim instanceof Long) { - emitLongToStack(slot, emitLoadLong(scratchRegister, (Long) prim)); - } else { - assert false : "Unimplemented"; - } - } else { - throw new IllegalArgumentException("Unknown value " + av); - } - } - - @Override - public void emitCallPrologue(CallingConvention cc, Object... prim) { - growFrame(cc.getStackSize()); - List args = cc.getArguments(); - // Do the emission in reverse, this avoids register collisons of xmm0 - which is used a - // scratch register when putting arguments on the stack. - for (int i = args.size() - 1; i >= 0; i--) { - emitLoad(args.get(i), prim[i]); - } - } - - @Override - public void emitCall(long addr) { - Register target = emitLoadLong(AMD64.rax, addr); - code.emitByte(0xFF); // CALL r/m64 - int enc = target.encoding; - if (enc >= 8) { - code.emitByte(0x41); - enc -= 8; - } - code.emitByte(0xD0 | enc); - } - - @Override - public void emitCallEpilogue(CallingConvention cc) { - growFrame(-cc.getStackSize()); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/riscv64/RISCV64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/riscv64/RISCV64TestAssembler.java deleted file mode 100644 index 6da2f088b60..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/riscv64/RISCV64TestAssembler.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.code.test.riscv64; - -import java.util.List; -import jdk.vm.ci.code.CallingConvention; -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.code.DebugInfo; -import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterValue; -import jdk.vm.ci.code.StackSlot; -import jdk.vm.ci.code.site.ConstantReference; -import jdk.vm.ci.code.site.DataSectionReference; -import jdk.vm.ci.code.test.TestAssembler; -import jdk.vm.ci.code.test.TestHotSpotVMConfig; -import jdk.vm.ci.hotspot.HotSpotCallingConventionType; -import jdk.vm.ci.hotspot.HotSpotConstant; -import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; -import jdk.vm.ci.meta.AllocatableValue; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.VMConstant; -import jdk.vm.ci.riscv64.RISCV64; -import jdk.vm.ci.riscv64.RISCV64Kind; - -public class RISCV64TestAssembler extends TestAssembler { - - private static final Register scratchRegister = RISCV64.x5; - private static final Register doubleScratch = RISCV64.f5; - - public RISCV64TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config) { - super(codeCache, config, - 16 /* initialFrameSize */, 16 /* stackAlignment */, - RISCV64Kind.DWORD /* narrowOopKind */, - /* registers */ - RISCV64.x10, RISCV64.x11, RISCV64.x12, RISCV64.x13, - RISCV64.x14, RISCV64.x15, RISCV64.x16, RISCV64.x17); - } - - private static int f(int val, int msb, int lsb) { - int nbits = msb - lsb + 1; - assert val >= 0; - assert val < (1 << nbits); - assert msb >= lsb; - return val << lsb; - } - - private static int f(Register r, int msb, int lsb) { - assert msb - lsb == 4; - return f(r.encoding, msb, lsb); - } - - private static int instructionImmediate(int imm, int rs1, int funct, int rd, int opcode) { - return f(imm, 31, 20) | f(rs1, 19, 15) | f(funct, 14, 12) | f(rd, 11, 7) | f(opcode, 6, 0); - } - - private static int instructionRegister(int funct7, int rs2, int rs1, int funct3, int rd, int opcode) { - return f(funct7, 31, 25) | f(rs2, 24, 20) | f(rs1, 19, 15) | f(funct3, 14, 12) | f(rd, 11, 7) | f(opcode, 6, 0); - } - - private void emitNop() { - code.emitInt(instructionImmediate(0, 0, 0b000, 0, 0b0010011)); - } - - private void emitAdd(Register Rd, Register Rm, Register Rn) { - // ADD - code.emitInt(instructionRegister(0b0000000, Rn.encoding, Rm.encoding, 0b000, Rd.encoding, 0b0110011)); - } - - private void emitAdd(Register Rd, Register Rn, int imm12) { - // ADDI - code.emitInt(instructionImmediate(imm12 & 0xfff, Rn.encoding, 0b000, Rd.encoding, 0b0010011)); - } - - private void emitAddW(Register Rd, Register Rn, int imm12) { - // ADDIW - code.emitInt(instructionImmediate(imm12 & 0xfff, Rn.encoding, 0b000, Rd.encoding, 0b0011011)); - } - - private void emitSub(Register Rd, Register Rn, int imm12) { - // SUBI - emitAdd(Rd, Rn, -imm12);; - } - - private void emitSub(Register Rd, Register Rm, Register Rn) { - // SUB - code.emitInt(instructionRegister(0b0100000, Rn.encoding, Rm.encoding, 0b000, Rd.encoding, 0b0110011)); - } - - private void emitMv(Register Rd, Register Rn) { - // MV - code.emitInt(instructionRegister(0b0000000, 0, Rn.encoding, 0b000, Rd.encoding, 0b0110011)); - } - - private void emitShiftLeft(Register Rd, Register Rn, int shift) { - // SLLI - code.emitInt(instructionImmediate(shift & 0x3f, Rn.encoding, 0b001, Rd.encoding, 0b0010011)); - } - - private void emitShiftRight(Register Rd, Register Rn, int shift) { - // SRLI - code.emitInt(instructionImmediate(shift & 0x3f, Rn.encoding, 0b101, Rd.encoding, 0b0010011)); - } - - private void emitLui(Register Rd, int imm20) { - // LUI - code.emitInt(f(imm20, 31, 12) | f(Rd, 11, 7) | f(0b0110111, 6, 0)); - } - - private void emitAuipc(Register Rd, int imm20) { - // AUIPC - code.emitInt(f(imm20, 31, 12) | f(Rd, 11, 7) | f(0b0010111, 6, 0)); - } - - private void emitLoadImmediate(Register Rd, int imm32) { - long upper = imm32, lower = imm32; - lower = (lower << 52) >> 52; - upper -= lower; - upper = (int) upper; - emitLui(Rd, ((int) (upper >> 12)) & 0xfffff); - emitAddW(Rd, Rd, (int) lower); - } - - private void emitLoadRegister(Register Rd, RISCV64Kind kind, Register Rn, int offset) { - // LB/LH/LW/LD (immediate) - assert offset >= 0; - int size = 0; - int opc = 0; - switch (kind) { - case BYTE: size = 0b000; opc = 0b0000011; break; - case WORD: size = 0b001; opc = 0b0000011; break; - case DWORD: size = 0b010; opc = 0b0000011; break; - case QWORD: size = 0b011; opc = 0b0000011; break; - case SINGLE: size = 0b010; opc = 0b0000111; break; - case DOUBLE: size = 0b011; opc = 0b0000111; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f(offset, 31, 20) | f(Rn, 19, 15) | f(size, 14, 12) | f(Rd, 11, 7) | f(opc, 6, 0)); - } - - private void emitStoreRegister(Register Rd, RISCV64Kind kind, Register Rn, int offset) { - // SB/SH/SW/SD (immediate) - assert offset >= 0; - int size = 0; - int opc = 0; - switch (kind) { - case BYTE: size = 0b000; opc = 0b0100011; break; - case WORD: size = 0b001; opc = 0b0100011; break; - case DWORD: size = 0b010; opc = 0b0100011; break; - case QWORD: size = 0b011; opc = 0b0100011; break; - case SINGLE: size = 0b010; opc = 0b0100111; break; - case DOUBLE: size = 0b011; opc = 0b0100111; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(f((offset >> 5), 31, 25) | f(Rd, 24, 20) | f(Rn, 19, 15) | f(size, 14, 12) | f((offset & 0x1f), 11, 7) | f(opc, 6, 0)); - } - - private void emitJalr(Register Rd, Register Rn, int imm) { - code.emitInt(instructionImmediate(imm & 0xfff, Rn.encoding, 0b000, Rd.encoding, 0b1100111)); - } - - private void emitFmv(Register Rd, RISCV64Kind kind, Register Rn) { - int funct = 0; - switch (kind) { - case SINGLE: funct = 0b1111000; break; - case DOUBLE: funct = 0b1111001; break; - default: throw new IllegalArgumentException(); - } - code.emitInt(instructionRegister(funct, 0b00000, Rn.encoding, 0b000, Rd.encoding, 0b1010011)); - } - - @Override - public void emitGrowStack(int size) { - assert size % 16 == 0; - if (size > -2048 && size < 0) { - emitAdd(RISCV64.x2, RISCV64.x2, -size); - } else if (size == 0) { - // No-op - } else if (size < 2048) { - emitSub(RISCV64.x2, RISCV64.x2, size); - } else if (size < 65535) { - emitLoadImmediate(scratchRegister, size); - emitSub(RISCV64.x2, RISCV64.x2, scratchRegister); - } else { - throw new IllegalArgumentException(); - } - } - - @Override - public void emitPrologue() { - // Must be patchable by NativeJump::patch_verified_entry - emitNop(); - emitAdd(RISCV64.x2, RISCV64.x2, -32); // addi sp sp -32 - emitStoreRegister(RISCV64.x8, RISCV64Kind.QWORD, RISCV64.x2, 0); // sd x8 sp(0) - emitStoreRegister(RISCV64.x1, RISCV64Kind.QWORD, RISCV64.x2, 8); // sd x1 sp(8) - emitMv(RISCV64.x8, RISCV64.x2); // mv x8, x2 - - setDeoptRescueSlot(newStackSlot(RISCV64Kind.QWORD)); - } - - @Override - public void emitEpilogue() { - recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); - recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 6*4, true, null); - emitCall(0xdeaddeaddeadL); - } - - @Override - public void emitCallPrologue(CallingConvention cc, Object... prim) { - growFrame(cc.getStackSize()); - List args = cc.getArguments(); - for (int i = 0; i < args.size(); i++) { - emitLoad(args.get(i), prim[i]); - } - } - - @Override - public void emitCallEpilogue(CallingConvention cc) { - growFrame(-cc.getStackSize()); - } - - @Override - public void emitCall(long addr) { - emitMovPtrHelper(scratchRegister, addr); - emitJalr(RISCV64.x1, scratchRegister, (int) (addr & 0x3f)); - } - - @Override - public void emitLoad(AllocatableValue av, Object prim) { - if (av instanceof RegisterValue) { - Register reg = ((RegisterValue) av).getRegister(); - if (prim instanceof Float) { - emitLoadFloat(reg, (Float) prim); - } else if (prim instanceof Double) { - emitLoadDouble(reg, (Double) prim); - } else if (prim instanceof Integer) { - emitLoadInt(reg, (Integer) prim); - } else if (prim instanceof Long) { - emitLoadLong(reg, (Long) prim); - } - } else if (av instanceof StackSlot) { - StackSlot slot = (StackSlot) av; - if (prim instanceof Float) { - emitFloatToStack(slot, emitLoadFloat(doubleScratch, (Float) prim)); - } else if (prim instanceof Double) { - emitDoubleToStack(slot, emitLoadDouble(doubleScratch, (Double) prim)); - } else if (prim instanceof Integer) { - emitIntToStack(slot, emitLoadInt(scratchRegister, (Integer) prim)); - } else if (prim instanceof Long) { - emitLongToStack(slot, emitLoadLong(scratchRegister, (Long) prim)); - } else { - assert false : "Unimplemented"; - } - } else { - throw new IllegalArgumentException("Unknown value " + av); - } - } - - private void emitLoad32(Register ret, int addr) { - long upper = addr, lower = addr; - lower = (lower << 52) >> 52; - upper -= lower; - upper = (int) upper; - emitLui(ret, ((int) (upper >> 12)) & 0xfffff); - emitAdd(ret, ret, (int) lower); - } - - private void emitMovPtrHelper(Register ret, long addr) { - // 48-bit VA - assert (addr >> 48) == 0 : "invalid pointer" + Long.toHexString(addr); - emitLoad32(ret, (int) (addr >> 17)); - emitShiftLeft(ret, ret, 11); - emitAdd(ret, ret, (int) ((addr >> 6) & 0x7ff)); - emitShiftLeft(ret, ret, 6); - } - - private void emitLoadPointer32(Register ret, int addr) { - emitLoadImmediate(ret, addr); - // Lui sign-extends the value, which we do not want - emitShiftLeft(ret, ret, 32); - emitShiftRight(ret, ret, 32); - } - - private void emitLoadPointer48(Register ret, long addr) { - emitMovPtrHelper(ret, addr); - emitAdd(ret, ret, (int) (addr & 0x3f)); - } - - @Override - public Register emitLoadPointer(HotSpotConstant c) { - recordDataPatchInCode(new ConstantReference((VMConstant) c)); - - Register ret = newRegister(); - if (c.isCompressed()) { - emitLoadPointer32(ret, 0xdeaddead); - } else { - emitLoadPointer48(ret, 0xdeaddeaddeadL); - } - return ret; - } - - @Override - public Register emitLoadPointer(Register b, int offset) { - Register ret = newRegister(); - emitLoadRegister(ret, RISCV64Kind.QWORD, b, offset & 0xfff); - return ret; - } - - @Override - public Register emitLoadNarrowPointer(DataSectionReference ref) { - recordDataPatchInCode(ref); - - Register ret = newRegister(); - emitAuipc(ret, 0xdead >> 11); - emitLoadRegister(ret, RISCV64Kind.DWORD, ret, 0xdead & 0x7ff); - // The value is sign-extendsed, which we do not want - emitShiftLeft(ret, ret, 32); - emitShiftRight(ret, ret, 32); - return ret; - } - - @Override - public Register emitLoadPointer(DataSectionReference ref) { - recordDataPatchInCode(ref); - - Register ret = newRegister(); - emitAuipc(ret, 0xdead >> 11); - emitLoadRegister(ret, RISCV64Kind.QWORD, ret, 0xdead & 0x7ff); - return ret; - } - - private Register emitLoadDouble(Register reg, double c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitDouble(c); - - recordDataPatchInCode(ref); - emitAuipc(scratchRegister, 0xdead >> 11); - emitLoadRegister(scratchRegister, RISCV64Kind.QWORD, scratchRegister, 0xdead & 0x7ff); - if (reg.getRegisterCategory().equals(RISCV64.FP)) { - emitFmv(reg, RISCV64Kind.DOUBLE, scratchRegister); - } else { - emitMv(reg, scratchRegister); - } - return reg; - } - - private Register emitLoadFloat(Register reg, float c) { - DataSectionReference ref = new DataSectionReference(); - ref.setOffset(data.position()); - data.emitFloat(c); - - recordDataPatchInCode(ref); - emitAuipc(scratchRegister, 0xdead >> 11); - emitLoadRegister(scratchRegister, RISCV64Kind.DWORD, scratchRegister, 0xdead & 0x7ff); - if (reg.getRegisterCategory().equals(RISCV64.FP)) { - emitFmv(reg, RISCV64Kind.SINGLE, scratchRegister); - } else { - emitMv(reg, scratchRegister); - } - return reg; - } - - @Override - public Register emitLoadFloat(float c) { - Register ret = RISCV64.f10; - return emitLoadFloat(ret, c); - } - - private Register emitLoadLong(Register reg, long c) { - long lower = c & 0xffffffff; - lower = lower - ((lower << 44) >> 44); - emitLoad32(reg, (int) ((c >> 32) & 0xffffffff)); - emitShiftLeft(reg, reg, 12); - emitAdd(reg, reg, (int) ((lower >> 20) & 0xfff)); - emitShiftLeft(reg, reg, 12); - emitAdd(reg, reg, (int) ((c << 44) >> 52)); - emitShiftLeft(reg, reg, 8); - emitAdd(reg, reg, (int) (c & 0xff)); - return reg; - } - - @Override - public Register emitLoadLong(long c) { - Register ret = newRegister(); - return emitLoadLong(ret, c); - } - - private Register emitLoadInt(Register reg, int c) { - emitLoadImmediate(reg, c); - return reg; - } - - @Override - public Register emitLoadInt(int c) { - Register ret = newRegister(); - return emitLoadInt(ret, c); - } - - @Override - public Register emitIntArg0() { - return codeCache.getRegisterConfig() - .getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int) - .get(0); - } - - @Override - public Register emitIntArg1() { - return codeCache.getRegisterConfig() - .getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, JavaKind.Int) - .get(1); - } - - @Override - public Register emitIntAdd(Register a, Register b) { - emitAdd(a, a, b); - return a; - } - - @Override - public void emitTrap(DebugInfo info) { - // Dereference null pointer - emitAdd(scratchRegister, RISCV64.x0, 0); - recordImplicitException(info); - emitLoadRegister(RISCV64.x0, RISCV64Kind.QWORD, scratchRegister, 0); - } - - @Override - public void emitIntRet(Register a) { - emitMv(RISCV64.x10, a); - emitMv(RISCV64.x2, RISCV64.x8); // mv sp, x8 - emitLoadRegister(RISCV64.x8, RISCV64Kind.QWORD, RISCV64.x2, 0); // ld x8 0(sp) - emitLoadRegister(RISCV64.x1, RISCV64Kind.QWORD, RISCV64.x2, 8); // ld x1 8(sp) - emitAdd(RISCV64.x2, RISCV64.x2, 32); // addi sp sp 32 - emitJalr(RISCV64.x0, RISCV64.x1, 0); // ret - } - - @Override - public void emitFloatRet(Register a) { - assert a == RISCV64.f10 : "Unimplemented move " + a; - emitMv(RISCV64.x2, RISCV64.x8); // mv sp, x8 - emitLoadRegister(RISCV64.x8, RISCV64Kind.QWORD, RISCV64.x2, 0); // ld x8 0(sp) - emitLoadRegister(RISCV64.x1, RISCV64Kind.QWORD, RISCV64.x2, 8); // ld x1 8(sp) - emitAdd(RISCV64.x2, RISCV64.x2, 32); // addi sp sp 32 - emitJalr(RISCV64.x0, RISCV64.x1, 0); // ret - } - - @Override - public void emitPointerRet(Register a) { - emitIntRet(a); - } - - @Override - public StackSlot emitPointerToStack(Register a) { - return emitLongToStack(a); - } - - @Override - public StackSlot emitNarrowPointerToStack(Register a) { - return emitIntToStack(a); - } - - @Override - public Register emitUncompressPointer(Register compressed, long base, int shift) { - if (shift > 0) { - emitShiftLeft(compressed, compressed, shift); - } - - if (base != 0) { - emitLoadLong(scratchRegister, base); - emitAdd(compressed, compressed, scratchRegister); - } - - return compressed; - } - - private StackSlot emitDoubleToStack(StackSlot slot, Register a) { - emitStoreRegister(a, RISCV64Kind.DOUBLE, RISCV64.x2, slot.getOffset(frameSize) & 0xfff); - return slot; - } - - @Override - public StackSlot emitDoubleToStack(Register a) { - StackSlot ret = newStackSlot(RISCV64Kind.DOUBLE); - return emitDoubleToStack(ret, a); - } - - private StackSlot emitFloatToStack(StackSlot slot, Register a) { - emitStoreRegister(a, RISCV64Kind.SINGLE, RISCV64.x2, slot.getOffset(frameSize) & 0xfff); - return slot; - } - - @Override - public StackSlot emitFloatToStack(Register a) { - StackSlot ret = newStackSlot(RISCV64Kind.SINGLE); - return emitFloatToStack(ret, a); - } - - private StackSlot emitIntToStack(StackSlot slot, Register a) { - emitStoreRegister(a, RISCV64Kind.DWORD, RISCV64.x2, slot.getOffset(frameSize) & 0xfff); - return slot; - } - - @Override - public StackSlot emitIntToStack(Register a) { - StackSlot ret = newStackSlot(RISCV64Kind.DWORD); - return emitIntToStack(ret, a); - } - - private StackSlot emitLongToStack(StackSlot slot, Register a) { - emitStoreRegister(a, RISCV64Kind.QWORD, RISCV64.x2, slot.getOffset(frameSize) & 0xfff); - return slot; - } - - @Override - public StackSlot emitLongToStack(Register a) { - StackSlot ret = newStackSlot(RISCV64Kind.QWORD); - return emitLongToStack(ret, a); - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/AsJavaTypeDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/AsJavaTypeDataProvider.java deleted file mode 100644 index 88dd983c63e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/AsJavaTypeDataProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class AsJavaTypeDataProvider { - - @DataProvider(name = "asJavaTypeDataProvider") - public static Object[][] asJavaTypeDataProvider() { - return new Object[][]{ - {CONSTANT_REFLECTION_PROVIDER.forObject(DummyClass.class), - "jdk.vm.ci.hotspot.test.DummyClass"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(boolean.class), "boolean"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(byte.class), "byte"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(short.class), "short"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(char.class), "char"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(int.class), "int"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(long.class), "long"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(float.class), "float"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(double.class), "double"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(Object.class), "java.lang.Object"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(boolean[].class), "boolean[]"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(boolean[][].class), "boolean[][]"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(Object[].class), "java.lang.Object[]"}, - {CONSTANT_REFLECTION_PROVIDER.forObject(Object[][].class), "java.lang.Object[][]"}, - {JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.booleanField), null}, - {CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectField), null}, - {CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE), null}, - {CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayWithValues), null}, - {CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayArrayWithValues), null}, - {JavaConstant.NULL_POINTER, null}, {null, null}}; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/BoxPrimitiveDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/BoxPrimitiveDataProvider.java deleted file mode 100644 index af0ce73c33c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/BoxPrimitiveDataProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.LinkedList; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class BoxPrimitiveDataProvider { - - @DataProvider(name = "boxPrimitiveDataProvider") - public static Object[][] boxPrimitiveDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - // Boolean testing - cfgSet.add( - new Object[]{JavaConstant.forBoolean(true), CONSTANT_REFLECTION_PROVIDER.forObject(true)}); - cfgSet.add(new Object[]{JavaConstant.forBoolean(false), - CONSTANT_REFLECTION_PROVIDER.forObject(false)}); - // Boxed boolean testing (returns null) - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(true), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(false), null}); - for (byte number : new byte[]{-128, 0, 1, 127}) { - // Integer primitives testing - cfgSet.add(new Object[]{JavaConstant.forByte(number), - CONSTANT_REFLECTION_PROVIDER.forObject(Byte.valueOf(number))}); - cfgSet.add(new Object[]{JavaConstant.forShort(number), - CONSTANT_REFLECTION_PROVIDER.forObject(Short.valueOf(number))}); - cfgSet.add(new Object[]{JavaConstant.forInt(number), - CONSTANT_REFLECTION_PROVIDER.forObject(Integer.valueOf(number))}); - cfgSet.add(new Object[]{JavaConstant.forLong(number), - CONSTANT_REFLECTION_PROVIDER.forObject(Long.valueOf(number))}); - if (number >= 0) { - cfgSet.add(new Object[]{JavaConstant.forChar((char) number), - CONSTANT_REFLECTION_PROVIDER.forObject(Character.valueOf((char) number))}); - } - // Float and Double variables are not cached, - // so the tested method returns "null" on them - cfgSet.add(new Object[]{JavaConstant.forFloat(number), null}); - cfgSet.add(new Object[]{JavaConstant.forDouble(number), null}); - // Boxed primitives testing (return null) - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Byte.valueOf(number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Short.valueOf(number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Integer.valueOf(number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Long.valueOf(number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Character.valueOf((char) number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Float.valueOf(number)), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Double.valueOf(number)), null}); - } - // Integer primitives testing with big non-cached values (returns null) - cfgSet.add(new Object[]{JavaConstant.forShort(Short.MAX_VALUE), null}); - cfgSet.add(new Object[]{JavaConstant.forInt(Integer.MAX_VALUE), null}); - cfgSet.add(new Object[]{JavaConstant.forLong(Long.MAX_VALUE), null}); - cfgSet.add(new Object[]{JavaConstant.forChar(Character.MAX_VALUE), null}); - // Non-primitives testing - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectField), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayWithValues), - null}); - // Null testing - cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, null}); - cfgSet.add(new Object[]{null, null}); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ConstantEqualsDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ConstantEqualsDataProvider.java deleted file mode 100644 index 494f86f562a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ConstantEqualsDataProvider.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Objects; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class ConstantEqualsDataProvider { - @DataProvider(name = "constantEqualsDataProvider") - public static Object[][] constantEqualsDataProvider() { - HashMap constMap = new HashMap<>(); - constMap.put(DUMMY_CLASS_INSTANCE.booleanField, JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.booleanField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultBooleanField, - JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.stableDefaultBooleanField)); - constMap.put(DUMMY_CLASS_INSTANCE.byteField, JavaConstant.forByte(DUMMY_CLASS_INSTANCE.byteField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalByteField, JavaConstant.forByte(DUMMY_CLASS_INSTANCE.finalByteField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultByteField, - JavaConstant.forByte(DUMMY_CLASS_INSTANCE.stableDefaultByteField)); - constMap.put(DUMMY_CLASS_INSTANCE.shortField, JavaConstant.forShort(DUMMY_CLASS_INSTANCE.shortField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalShortField, JavaConstant.forShort(DUMMY_CLASS_INSTANCE.finalShortField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultShortField, - JavaConstant.forShort(DUMMY_CLASS_INSTANCE.stableDefaultShortField)); - constMap.put(DUMMY_CLASS_INSTANCE.intField, JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalIntField, JavaConstant.forInt(DUMMY_CLASS_INSTANCE.finalIntField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultIntField, - JavaConstant.forInt(DUMMY_CLASS_INSTANCE.stableDefaultIntField)); - constMap.put(DUMMY_CLASS_INSTANCE.longField, JavaConstant.forLong(DUMMY_CLASS_INSTANCE.longField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalLongField, JavaConstant.forLong(DUMMY_CLASS_INSTANCE.finalLongField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultLongField, - JavaConstant.forLong(DUMMY_CLASS_INSTANCE.stableDefaultLongField)); - constMap.put(DUMMY_CLASS_INSTANCE.doubleField, JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.doubleField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalDoubleField, - JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.finalDoubleField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultDoubleField, - JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.stableDefaultDoubleField)); - constMap.put(DUMMY_CLASS_INSTANCE.floatField, JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.floatField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalFloatField, JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.finalFloatField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultFloatField, - JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.stableDefaultFloatField)); - constMap.put(DUMMY_CLASS_INSTANCE.charField, JavaConstant.forChar(DUMMY_CLASS_INSTANCE.charField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalCharField, JavaConstant.forChar(DUMMY_CLASS_INSTANCE.finalCharField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultCharField, - JavaConstant.forChar(DUMMY_CLASS_INSTANCE.stableDefaultCharField)); - constMap.put(DUMMY_CLASS_INSTANCE.stringField, - CONSTANT_REFLECTION_PROVIDER.forString(DUMMY_CLASS_INSTANCE.stringField)); - constMap.put(DUMMY_CLASS_INSTANCE.stringField2, - CONSTANT_REFLECTION_PROVIDER.forString(DUMMY_CLASS_INSTANCE.stringField2)); - constMap.put(DUMMY_CLASS_INSTANCE.objectField, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectField)); - constMap.put(DUMMY_CLASS_INSTANCE.finalObjectField, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.finalObjectField)); - constMap.put(DUMMY_CLASS_INSTANCE.stableDefaultObjectField, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.stableDefaultObjectField)); - constMap.put(null, null); - constMap.put(JavaConstant.NULL_POINTER, JavaConstant.NULL_POINTER); - LinkedList cfgSet = new LinkedList<>(); - constMap.entrySet().stream().forEach((obj1) -> { - constMap.entrySet().stream().forEach((obj2) -> { - cfgSet.add(new Object[]{obj1.getValue(), obj2.getValue(), - Objects.equals(obj1.getKey(), obj2.getKey())}); - }); - }); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/DummyClass.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/DummyClass.java deleted file mode 100644 index 29b3a5c7bcf..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/DummyClass.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.internal.vm.annotation.Stable; - -public class DummyClass { - - public boolean booleanField = true; - public byte byteField = 2; - public short shortField = 3; - public char charField = 'a'; - public int intField = 4; - public long longField = 5L; - public float floatField = 4.5f; - public double doubleField = 53.2; - public Object objectField = new Object(); - - public final boolean finalBooleanField = true; - public final byte finalByteField = -2; - public final short finalShortField = -3; - public final char finalCharField = 'b'; - public final int finalIntField = 8; - public final long finalLongField = 888L; - public final float finalFloatField = 77.8f; - public final double finalDoubleField = -234.2; - public final Object finalObjectField = new Object(); - - @Stable public boolean stableBooleanField = true; - @Stable public byte stableByteField = -2; - @Stable public short stableShortField = -3; - @Stable public char stableCharField = 'c'; - @Stable public int stableIntField = 8; - @Stable public long stableLongField = 888L; - @Stable public float stableFloatField = 77.8f; - @Stable public double stableDoubleField = -234.2; - @Stable public Object stableObjectField = new Object(); - - @Stable public boolean stableDefaultBooleanField; - @Stable public byte stableDefaultByteField; - @Stable public short stableDefaultShortField; - @Stable public char stableDefaultCharField; - @Stable public int stableDefaultIntField; - @Stable public long stableDefaultLongField; - @Stable public float stableDefaultFloatField; - @Stable public double stableDefaultDoubleField; - @Stable public Object stableDefaultObjectField; - - public final boolean finalDefaultBooleanField = false; - public final byte finalDefaultByteField = 0; - public final short finalDefaultShortField = 0; - public final char finalDefaultCharField = 0; - public final int finalDefaultIntField = 0; - public final long finalDefaultLongField = 0L; - public final float finalDefaultFloatField = 0.0f; - public final double finalDefaultDoubleField = 0.0; - public final Object finalDefaultObjectField = null; - - public static boolean staticBooleanField = true; - public static byte staticByteField = -1; - public static short staticShortField = 11; - public static char staticCharField = 'e'; - public static int staticIntField = 344; - public static long staticLongField = 34231212L; - public static float staticFloatField = -4.5f; - public static double staticDoubleField = 453.2; - public static Object staticObjectField = new Object(); - - public static final boolean staticFinalBooleanField = true; - public static final byte staticFinalByteField = -51; - public static final short staticFinalShortField = 911; - public static final char staticFinalCharField = 'g'; - public static final int staticFinalIntField = 9344; - public static final long staticFinalLongField = 54231212L; - public static final float staticFinalFloatField = -42.5f; - public static final double staticFinalDoubleField = 5453.2; - public static final Object staticFinalObjectField = new Object(); - - @Stable public static boolean staticStableBooleanField = true; - @Stable public static byte staticStableByteField = -61; - @Stable public static short staticStableShortField = 661; - @Stable public static char staticStableCharField = 'y'; - @Stable public static int staticStableIntField = 6574; - @Stable public static long staticStableLongField = -2342L; - @Stable public static float staticStableFloatField = -466.5f; - @Stable public static double staticStableDoubleField = 4563.2; - @Stable public static Object staticStableObjectField = new Object(); - - @Stable public static boolean staticStableDefaultBooleanField; - @Stable public static byte staticStableDefaultByteField; - @Stable public static short staticStableDefaultShortField; - @Stable public static char staticStableDefaultCharField; - @Stable public static int staticStableDefaultIntField; - @Stable public static long staticStableDefaultLongField; - @Stable public static float staticStableDefaultFloatField; - @Stable public static double staticStableDefaultDoubleField; - @Stable public static Object staticStableDefaultObjectField; - - public boolean[] booleanArrayWithValues = new boolean[]{true, false}; - public byte[] byteArrayWithValues = new byte[]{43, 0}; - public short[] shortArrayWithValues = new short[]{9, 0}; - public char[] charArrayWithValues = new char[]{'a', 0}; - public int[] intArrayWithValues = new int[]{99, 0}; - public long[] longArrayWithValues = new long[]{868L, 0L}; - public float[] floatArrayWithValues = new float[]{75.8f, 0f}; - public double[] doubleArrayWithValues = new double[]{-294.66, 0.0}; - public Object[] objectArrayWithValues = new Object[]{new Object(), null}; - - @Stable public boolean[] stableBooleanArrayWithValues = new boolean[]{true, false}; - @Stable public byte[] stableByteArrayWithValues = new byte[]{-2, 0}; - @Stable public short[] stableShortArrayWithValues = new short[]{-3, 0}; - @Stable public char[] stableCharArrayWithValues = new char[]{'c', 0}; - @Stable public int[] stableIntArrayWithValues = new int[]{8, 0}; - @Stable public long[] stableLongArrayWithValues = new long[]{888L, 0L}; - @Stable public float[] stableFloatArrayWithValues = new float[]{77.8f, 0f}; - @Stable public double[] stableDoubleArrayWithValues = new double[]{-234.2, 0.0}; - @Stable public Object[] stableObjectArrayWithValues = new Object[]{new Object(), null}; - - public boolean[][] booleanArrayArrayWithValues = new boolean[][]{{true}, null}; - public byte[][] byteArrayArrayWithValues = new byte[][]{{43, 0}, null}; - public short[][] shortArrayArrayWithValues = new short[][]{{9, 0}, null}; - public char[][] charArrayArrayWithValues = new char[][]{{'a', 0}, null}; - public int[][] intArrayArrayWithValues = new int[][]{{99, 0}, null}; - public long[][] longArrayArrayWithValues = new long[][]{{868L, 0L}, null}; - public float[][] floatArrayArrayWithValues = new float[][]{{75.8f, 0f}, null}; - public double[][] doubleArrayArrayWithValues = new double[][]{{-294.66, 0.0}, null}; - public Object[][] objectArrayArrayWithValues = new Object[][]{{new Object(), null}, null}; - - @Stable public boolean[][] stableBooleanArrayArrayWithValues = new boolean[][]{{true, false}, null}; - @Stable public byte[][] stableByteArrayArrayWithValues = new byte[][]{{-2, 0}, null}; - @Stable public short[][] stableShortArrayArrayWithValues = new short[][]{{-3, 0}, null}; - @Stable public char[][] stableCharArrayArrayWithValues = new char[][]{{'c', 0}, null}; - @Stable public int[][] stableIntArrayArrayWithValues = new int[][]{{8, 0}, null}; - @Stable public long[][] stableLongArrayArrayWithValues = new long[][]{{888L, 0L}, null}; - @Stable public float[][] stableFloatArrayArrayWithValues = new float[][]{{77.8f, 0f}, null}; - @Stable public double[][] stableDoubleArrayArrayWithValues = new double[][]{{-234.2, 0.0}, null}; - @Stable public Object[][] stableObjectArrayArrayWithValues = new Object[][]{{new Object(), null}, null}; - - // Strings for testing "forString" method - public final String stringField = "abc"; - public final String stringField2 = "xyz"; - public final String stringEmptyField = ""; -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForObjectDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForObjectDataProvider.java deleted file mode 100644 index 85d22f2efda..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForObjectDataProvider.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import org.testng.annotations.DataProvider; - -public class ForObjectDataProvider { - @DataProvider(name = "forObjectDataProvider") - public static Object[][] forObjectDataProvider() { - return new Object[][]{ - {TestHelper.DUMMY_CLASS_INSTANCE.objectField, - "Object[Object@" + TestHelper.DUMMY_CLASS_INSTANCE.objectField.hashCode() + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.stringField, - "Object[String:\"" + TestHelper.DUMMY_CLASS_INSTANCE.stringField + "\"]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.booleanField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.booleanField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.byteField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.byteField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.charField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.charField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.shortField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.shortField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.intField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.intField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.longField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.longField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.floatField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.floatField + "]"}, - {TestHelper.DUMMY_CLASS_INSTANCE.doubleField, - "Object[" + TestHelper.DUMMY_CLASS_INSTANCE.doubleField + "]"}, - {new Object[0], "Object[Object[" + 0 + "]{}]"}, {new Object[1], "Object[Object[" + 1 + "]{null}]"}, - {null, "Object[null]"}}; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForStringDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForStringDataProvider.java deleted file mode 100644 index 9aa6651b5a9..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ForStringDataProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import org.testng.annotations.DataProvider; - -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class ForStringDataProvider { - @DataProvider(name = "forStringDataProvider") - public static Object[][] forStringDataProvider() { - return new Object[][]{ - {DUMMY_CLASS_INSTANCE.stringField, "Object[String:\"" + DUMMY_CLASS_INSTANCE.stringField + "\"]"}, - {DUMMY_CLASS_INSTANCE.stringEmptyField, "Object[String:\"\"]"}, - {null, "Object[null]"}}; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java deleted file mode 100644 index 59a4933d793..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotConstantReflectionProviderTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test jdk.vm.ci.hotspot.test.HotSpotConstantReflectionProviderTest - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * java.base/jdk.internal.vm.annotation - * java.base/jdk.internal.misc - * @library /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * @build jdk.vm.ci.hotspot.test.DummyClass - * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller jdk.vm.ci.hotspot.test.DummyClass - * @run testng/othervm/timeout=300 -Xbootclasspath/a:. - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.HotSpotConstantReflectionProviderTest - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import org.testng.Assert; -import org.testng.annotations.Test; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; - -public class HotSpotConstantReflectionProviderTest { - - @Test(dataProvider = "forObjectDataProvider", dataProviderClass = ForObjectDataProvider.class) - public void testForObject(Object obj, String expected) { - JavaConstant jConst = TestHelper.CONSTANT_REFLECTION_PROVIDER.forObject(obj); - Assert.assertNotNull(jConst, - "An instance of JavaConstant returned by" + " \"forObject\" method should not be null"); - Assert.assertEquals(jConst.toString(), expected, "Unexpected result:"); - } - - @Test(dataProvider = "forStringDataProvider", dataProviderClass = ForStringDataProvider.class) - public void testForString(String string, String expected) { - JavaConstant jConst = CONSTANT_REFLECTION_PROVIDER.forString(string); - Assert.assertNotNull(jConst, - "An instance of JavaConstant returned by" + " \"forString\" method should not be null"); - Assert.assertEquals(jConst.toString(), expected, "Unexpected result:"); - } - - @Test(dataProvider = "constantEqualsDataProvider", dataProviderClass = ConstantEqualsDataProvider.class) - public void testConstantEquals(Constant const1, Constant const2, Boolean expected) { - Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.constantEquals(const1, const2), expected, - "Unexpected result:"); - } - - @Test(dataProvider = "readArrayLengthDataProvider", dataProviderClass = ReadArrayLengthDataProvider.class) - public void testReadArrayLength(JavaConstant array, Integer expected) { - Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readArrayLength(array), expected, - "Unexpected result:"); - } - - @Test(dataProvider = "readArrayElementDataProvider", dataProviderClass = ReadArrayElementDataProvider.class) - public void testReadArrayElement(JavaConstant array, int index, Object expected) { - Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readArrayElement(array, index), expected, - "Unexpected result:"); - } - - @Test(dataProvider = "readFieldValueDataProvider", dataProviderClass = ReadFieldValueDataProvider.class) - public void testReadFieldValue(ResolvedJavaField field, JavaConstant receiver, JavaConstant expected) { - JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.readFieldValue(field, receiver); - Assert.assertEquals(actual == null ? "null" : actual.toString(), - expected == null ? "null" : expected.toString(), "Unexpected result:"); - } - - @Test(dataProvider = "readFieldValueNegativeDataProvider", dataProviderClass = ReadFieldValueDataProvider.class, expectedExceptions = {NullPointerException.class}) - public void testNegativeReadFieldValue(ResolvedJavaField field, JavaConstant receiver) { - CONSTANT_REFLECTION_PROVIDER.readFieldValue(field, receiver); - } - - @Test(dataProvider = "asJavaTypeDataProvider", dataProviderClass = AsJavaTypeDataProvider.class) - public void testAsJavaType(JavaConstant constant, String expected) { - ResolvedJavaType actual = CONSTANT_REFLECTION_PROVIDER.asJavaType(constant); - Assert.assertEquals(actual == null ? "null" : actual.toJavaName(), - expected == null ? "null" : expected, - "Unexpected result, wrong type returned:"); - } - - @Test(dataProvider = "boxPrimitiveDataProvider", dataProviderClass = BoxPrimitiveDataProvider.class) - public void testBoxPrimitive(JavaConstant constant, JavaConstant expected) { - JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.boxPrimitive(constant); - Assert.assertEquals(actual, expected, "Unexpected result:"); - } - - @Test(dataProvider = "unboxPrimitiveDataProvider", dataProviderClass = UnboxPrimitiveDataProvider.class) - public void testUnboxPrimitive(JavaConstant constant, JavaConstant expected) { - JavaConstant actual = CONSTANT_REFLECTION_PROVIDER.unboxPrimitive(constant); - Assert.assertEquals(actual, expected, "Unexpected result:"); - } - - @Test - public void testGetMemoryAccessProvider() { - MemoryAccessProvider actual = CONSTANT_REFLECTION_PROVIDER.getMemoryAccessProvider(); - Assert.assertNotNull(actual, "Returned MemoryAccessProvider instance should not be null"); - } - - @Test - public void testGetMethodHandleAccess() { - MethodHandleAccessProvider actual = CONSTANT_REFLECTION_PROVIDER.getMethodHandleAccess(); - Assert.assertNotNull(actual, - "Returned MethodHandleAccessProvider instance should not be null"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java deleted file mode 100644 index e4de1dd0bee..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.hotspot.test; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotModifiers; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; - -/** - * - * @test - * @requires vm.jvmci - * @summary Tests HotSpotResolvedJavaField functionality - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * @run junit/othervm --add-opens=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.HotSpotResolvedJavaFieldTest - */ -public class HotSpotResolvedJavaFieldTest { - - private static final Class[] classesWithInternalFields = {Class.class, ClassLoader.class}; - - private static final Method createFieldMethod; - private static final Field indexField; - private static final Field internalFlagsField; - - static { - Method m = null; - Field f1 = null; - Field f2 = null; - try { - Class typeImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl"); - m = typeImpl.getDeclaredMethod("createField", JavaType.class, int.class, int.class, int.class, int.class); - m.setAccessible(true); - Class fieldImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldImpl"); - f1 = fieldImpl.getDeclaredField("index"); - f1.setAccessible(true); - f2 = fieldImpl.getDeclaredField("internalFlags"); - f2.setAccessible(true); - } catch (Exception e) { - throw new AssertionError(e); - } - - createFieldMethod = m; - indexField = f1; - internalFlagsField = f2; - } - - HotSpotJVMCIRuntime runtime() { - return (HotSpotJVMCIRuntime) JVMCI.getRuntime(); - } - - MetaAccessProvider getMetaAccess() { - return runtime().getHostJVMCIBackend().getMetaAccess(); - } - - /** - * Tests that {@link HotSpotResolvedJavaField#getModifiers()} only includes the modifiers - * returned by {@link Field#getModifiers()}. Namely, it must not include - * {@code HotSpotResolvedJavaField#FIELD_INTERNAL_FLAG}. - */ - @Test - public void testModifiersForInternal() { - for (Class c : classesWithInternalFields) { - ResolvedJavaType type = getMetaAccess().lookupJavaType(c); - for (ResolvedJavaField field : type.getInstanceFields(false)) { - if (field.isInternal()) { - Assert.assertEquals(0, ~HotSpotModifiers.jvmFieldModifiers() & field.getModifiers()); - } - } - } - } - - /** - * Tests that {@code HotSpotResolvedObjectTypeImpl#createField(String, JavaType, int, int)} - * always returns an {@linkplain ResolvedJavaField#equals(Object) equivalent} object for an - * internal field. - * - * @throws InvocationTargetException - * @throws IllegalArgumentException - * @throws IllegalAccessException - */ - @Test - public void testEquivalenceForInternalFields() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - for (Class c : classesWithInternalFields) { - ResolvedJavaType type = getMetaAccess().lookupJavaType(c); - for (ResolvedJavaField field : type.getInstanceFields(false)) { - if (field.isInternal()) { - HotSpotResolvedJavaField expected = (HotSpotResolvedJavaField) field; - int index = indexField.getInt(expected); - int internalFlags = internalFlagsField.getInt(expected); - ResolvedJavaField actual = (ResolvedJavaField) createFieldMethod.invoke(type, expected.getType(), expected.getOffset(), expected.getModifiers(), internalFlags, index); - Assert.assertEquals(expected, actual); - } - } - } - } - - @Test - public void testIsInObject() { - for (Field f : String.class.getDeclaredFields()) { - HotSpotResolvedJavaField rf = (HotSpotResolvedJavaField) getMetaAccess().lookupJavaField(f); - Assert.assertEquals(rf.toString(), rf.isInObject(runtime().getHostJVMCIBackend().getConstantReflection().forString("a string")), !rf.isStatic()); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/IsEmbeddableDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/IsEmbeddableDataProvider.java deleted file mode 100644 index 004f32c7588..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/IsEmbeddableDataProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class IsEmbeddableDataProvider { - @DataProvider(name = "isEmbeddableDataProvider") - public static Object[][] isEmbeddableDataProvider() { - return new Object[][]{{JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.booleanField), true}, - {JavaConstant.forByte(DUMMY_CLASS_INSTANCE.byteField), true}, - {JavaConstant.forShort(DUMMY_CLASS_INSTANCE.shortField), true}, - {JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField), true}, - {JavaConstant.forLong(DUMMY_CLASS_INSTANCE.longField), true}, - {JavaConstant.forChar(DUMMY_CLASS_INSTANCE.charField), true}, - {JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.floatField), true}, - {JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.doubleField), true}, - {CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectField), true}, - {JavaConstant.NULL_POINTER, true}, {null, true}}; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java deleted file mode 100644 index dd52d0384fe..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderData.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import java.lang.reflect.Field; - -import org.testng.annotations.DataProvider; - -import jdk.test.whitebox.WhiteBox; -import jdk.internal.misc.Unsafe; -import jdk.vm.ci.hotspot.CompilerToVMHelper; -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; -import jdk.vm.ci.hotspot.HotSpotVMConfigAccess; -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.runtime.JVMCI; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; - -public class MemoryAccessProviderData { - private static final Unsafe UNSAFE = Unsafe.getUnsafe(); - private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); - private static final TestClass TEST_OBJECT = new TestClass(); - private static final JavaConstant TEST_CONSTANT = CONSTANT_REFLECTION.forObject(TEST_OBJECT); - private static final JavaConstant TEST_CLASS_CONSTANT = CONSTANT_REFLECTION.forObject(TestClass.class); - - private static final KindData[] PRIMITIVE_KIND_DATA = { - new KindData(JavaKind.Boolean, TEST_OBJECT), - new KindData(JavaKind.Byte, TEST_OBJECT), - new KindData(JavaKind.Char, TEST_OBJECT), - new KindData(JavaKind.Short, TEST_OBJECT), - new KindData(JavaKind.Int, TEST_OBJECT), - new KindData(JavaKind.Float, TEST_OBJECT), - new KindData(JavaKind.Long, TEST_OBJECT), - new KindData(JavaKind.Double, TEST_OBJECT) - }; - private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); - - - @DataProvider(name = "positiveObject") - public static Object[][] getPositiveObjectJavaKind() { - HotSpotJVMCIRuntime runtime = (HotSpotJVMCIRuntime) JVMCI.getRuntime(); - int offset = new HotSpotVMConfigAccess(runtime.getConfigStore()).getFieldOffset("Klass::_java_mirror", Integer.class, "OopHandle"); - Constant wrappedKlassPointer = CompilerToVMHelper.fromObjectClass(TestClass.class).klass(); - return new Object[][]{new Object[]{JavaKind.Object, wrappedKlassPointer, (long) offset, TEST_CLASS_CONSTANT, 0}}; - } - - @DataProvider(name = "positivePrimitive") - public static Object[][] getPositivePrimitiveJavaKinds() { - List result = new ArrayList<>(); - for (KindData k : PRIMITIVE_KIND_DATA) { - result.add(new Object[] {k.kind, TEST_CONSTANT, k.instanceFieldOffset, k.instanceFieldValue, Math.max(8, k.kind.getBitCount())}); - result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, k.staticFieldOffset, k.staticFieldValue, Math.max(8, k.kind.getBitCount())}); - } - return result.toArray(new Object[result.size()][]); - } - @DataProvider(name = "unalignedPrimitive") - public static Object[][] getUnalignedPrimitiveJavaKinds() { - List result = new ArrayList<>(); - for (KindData k : PRIMITIVE_KIND_DATA) { - if (k.unalignedInstanceFieldValue != null) { - result.add(new Object[] {k.kind, TEST_CONSTANT, k.instanceFieldOffset - 1, k.unalignedInstanceFieldValue, Math.max(8, k.kind.getBitCount())}); - } - } - return result.toArray(new Object[result.size()][]); - } - - @DataProvider(name = "outOfBoundsInstanceFields") - public static Object[][] getOutOfBoundsStaticFieldReads() { - long instanceSize = WHITE_BOX.getObjectSize(TEST_OBJECT); - List result = new ArrayList<>(); - for (KindData k : PRIMITIVE_KIND_DATA) { - long lastValidOffset = instanceSize - (k.kind.getByteCount()); - result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset, false}); - result.add(new Object[] {k.kind, TEST_CONSTANT, (long) -1, true}); - result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset + 1, true}); - result.add(new Object[] {k.kind, TEST_CONSTANT, lastValidOffset + 100, true}); - } - return result.toArray(new Object[result.size()][]); - } - - @DataProvider(name = "outOfBoundsStaticFields") - public static Object[][] getOutOfBoundsInstanceFieldReads() { - long staticsSize = WHITE_BOX.getObjectSize(TEST_OBJECT.getClass()); - List result = new ArrayList<>(); - for (KindData k : PRIMITIVE_KIND_DATA) { - long lastValidOffset = staticsSize - (k.kind.getByteCount()); - result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset, false}); - result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, (long) -1, true}); - result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset + 1, true}); - result.add(new Object[] {k.kind, TEST_CLASS_CONSTANT, lastValidOffset + 100, true}); - } - return result.toArray(new Object[result.size()][]); - } - - @DataProvider(name = "outOfBoundsObjectArray") - public static Object[][] getOutOfBoundsObjectArrayReads() { - List result = new ArrayList<>(); - - for (int i = 0; i < 8; i++) { - Object[] objects = new Object[i]; - for (int e = 0; e < i; e++) { - objects[e] = e; - } - long firstValidOffset = UNSAFE.ARRAY_OBJECT_BASE_OFFSET; - long endOfObjectOffset = UNSAFE.ARRAY_OBJECT_BASE_OFFSET + i * UNSAFE.ARRAY_OBJECT_INDEX_SCALE; - JavaConstant constant = CONSTANT_REFLECTION.forObject(objects); - result.add(new Object[] {JavaKind.Object, constant, firstValidOffset, i == 0}); - result.add(new Object[] {JavaKind.Object, constant, (long) 0, true}); - result.add(new Object[] {JavaKind.Object, constant, (long) -1, true}); - result.add(new Object[] {JavaKind.Object, constant, endOfObjectOffset - UNSAFE.ARRAY_OBJECT_INDEX_SCALE, i == 0}); - result.add(new Object[] {JavaKind.Object, constant, endOfObjectOffset, true}); - result.add(new Object[] {JavaKind.Object, constant, endOfObjectOffset + 100, true}); - } - return result.toArray(new Object[result.size()][]); - } - - @DataProvider(name = "negative") - public static Object[][] getNegativeJavaKinds() { - return new Object[][]{ - new Object[]{JavaKind.Void, JavaConstant.NULL_POINTER}, - new Object[]{JavaKind.Illegal, JavaConstant.INT_1}}; - } - - - private static class TestClass { - public final boolean booleanField = true; - public final byte byteField = 2; - public final short shortField = 3; - public final int intField = 4; - public final long longField = 5L; - public final double doubleField = 6.0d; - public final float floatField = 7.0f; - public final char charField = 'a'; - public final String objectField = "abc"; - - public static final boolean booleanStaticField = true; - public static final byte byteStaticField = 2; - public static final short shortStaticField = 3; - public static final int intStaticField = 4; - public static final long longStaticField = 5L; - public static final double doubleStaticField = 6.0d; - public static final float floatStaticField = 7.0f; - public static final char charStaticField = 'a'; - public static final String objectStaticField = "abc"; - } - - - static class KindData { - final JavaKind kind; - final Field instanceField; - final Field staticField; - final long instanceFieldOffset; - final long staticFieldOffset; - final JavaConstant instanceFieldValue; - final JavaConstant staticFieldValue; - final JavaConstant unalignedInstanceFieldValue; - KindData(JavaKind kind, Object testObject) { - this.kind = kind; - try { - Class c = testObject.getClass(); - instanceField = c.getDeclaredField(kind.getJavaName() + "Field"); - staticField = c.getDeclaredField(kind.getJavaName() + "StaticField"); - instanceField.setAccessible(true); - staticField.setAccessible(true); - instanceFieldOffset = UNSAFE.objectFieldOffset(instanceField); - staticFieldOffset = UNSAFE.staticFieldOffset(staticField); - instanceFieldValue = JavaConstant.forBoxedPrimitive(instanceField.get(testObject)); - staticFieldValue = JavaConstant.forBoxedPrimitive(staticField.get(null)); - if (kind == JavaKind.Long) { - unalignedInstanceFieldValue = JavaConstant.forLong(UNSAFE.getLongUnaligned(testObject, instanceFieldOffset - 1)); - } else if (kind == JavaKind.Int) { - unalignedInstanceFieldValue = JavaConstant.forInt(UNSAFE.getIntUnaligned(testObject, instanceFieldOffset - 1)); - } else if (kind == JavaKind.Char) { - unalignedInstanceFieldValue = JavaConstant.forChar(UNSAFE.getCharUnaligned(testObject, instanceFieldOffset - 1)); - } else if (kind == JavaKind.Short) { - unalignedInstanceFieldValue = JavaConstant.forShort(UNSAFE.getShortUnaligned(testObject, instanceFieldOffset - 1)); - } else { - unalignedInstanceFieldValue = null; - } - } catch (Exception e) { - throw new Error("TESTBUG for kind " + kind, e); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java deleted file mode 100644 index c4db9cdf16b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MemoryAccessProviderTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8152341 - * @requires vm.jvmci - * @library /compiler/jvmci/common/patches /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.common - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * java.base/jdk.internal.misc - * @build jdk.test.whitebox.WhiteBox - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run testng/othervm -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.MemoryAccessProviderTest - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.test.whitebox.WhiteBox; - -import jdk.vm.ci.meta.Constant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MemoryAccessProvider; -import jdk.vm.ci.runtime.JVMCI; -import org.testng.Assert; -import org.testng.annotations.Test; - -public class MemoryAccessProviderTest { - private static final MemoryAccessProvider PROVIDER = JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection().getMemoryAccessProvider(); - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class) - public void testPositiveReadPrimitiveConstant(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertEquals(PROVIDER.readPrimitiveConstant(kind, base, offset, bitsCount), expected, "Failed to read constant"); - } - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testReadPrimitiveConstantNullBase(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertNull(PROVIDER.readPrimitiveConstant(kind, null, offset, bitsCount), "Unexpected value for null base"); - } - - @Test(dataProvider = "unalignedPrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testReadUnalignedConstantConstant(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - PROVIDER.readPrimitiveConstant(kind, null, offset, bitsCount); - } - - @Test(dataProvider = "negative", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testNegativeReadPrimitiveConstant(JavaKind kind, Constant base) { - PROVIDER.readPrimitiveConstant(kind, base, 0L, kind == null ? 0 : kind.getByteCount() / 8); - } - - @Test(dataProvider = "outOfBoundsInstanceFields", dataProviderClass = MemoryAccessProviderData.class) - public void testReadPrimitiveInstanceFieldOutOfBounds(JavaKind kind, Constant base, Long offset, boolean isOutOfBounds) { - try { - PROVIDER.readPrimitiveConstant(kind, base, offset, kind.getByteCount() * 8); - Assert.assertFalse(isOutOfBounds); - } catch (IllegalArgumentException iae) { - Assert.assertTrue(isOutOfBounds, iae.getMessage()); - } - } - - @Test(dataProvider = "outOfBoundsStaticFields", dataProviderClass = MemoryAccessProviderData.class) - public void testReadPrimitiveStaticFieldOutOFBounds(JavaKind kind, Constant base, Long offset, boolean isOutOfBounds) { - try { - PROVIDER.readPrimitiveConstant(kind, base, offset, kind.getByteCount() * 8); - Assert.assertFalse(isOutOfBounds); - } catch (IllegalArgumentException iae) { - Assert.assertTrue(isOutOfBounds, iae.getMessage()); - } - } - - @Test(dataProvider = "outOfBoundsObjectArray", dataProviderClass = MemoryAccessProviderData.class) - public void testReadObjectOutOfBoundsObjectArray(JavaKind kind, Constant base, Long offset, boolean isOutOfBounds) { - try { - PROVIDER.readObjectConstant(base, offset); - Assert.assertFalse(isOutOfBounds); - } catch (IllegalArgumentException iae) { - Assert.assertTrue(isOutOfBounds, iae.getMessage()); - } - } - - @Test(dataProvider = "positiveObject", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testObjectReadPrimitiveConstant(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - PROVIDER.readPrimitiveConstant(kind, base, 0L, bitsCount); - } - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testReadPrimitiveConstantLessBits(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - PROVIDER.readPrimitiveConstant(kind, base, offset, bitsCount - 1); - } - - @Test(dataProvider = "positiveObject", dataProviderClass = MemoryAccessProviderData.class) - public void testPositiveReadObjectConstant(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertEquals(PROVIDER.readObjectConstant(base, offset), expected, "Unexpected result"); - } - - @Test(dataProvider = "positiveObject", dataProviderClass = MemoryAccessProviderData.class) - public void testNegativeReadObjectConstantNullBase(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertNull(PROVIDER.readObjectConstant(null, offset), "Unexpected return"); - } - - @Test(dataProvider = "positiveObject", dataProviderClass = MemoryAccessProviderData.class) - public void testNegativeReadObjectConstantWrongOffset(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertNull(PROVIDER.readObjectConstant(base, offset + 1), "Expected null"); - } - - @Test(dataProvider = "positivePrimitive", dataProviderClass = MemoryAccessProviderData.class, expectedExceptions = {IllegalArgumentException.class}) - public void testNegativeReadObjectConstantPrimitiveBase(JavaKind kind, Constant base, Long offset, Object expected, int bitsCount) { - Assert.assertNull(PROVIDER.readObjectConstant(base, offset), "Expected null"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderData.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderData.java deleted file mode 100644 index 236a2350a9d..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderData.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.runtime.JVMCI; -import org.testng.annotations.DataProvider; - -import java.io.File; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Paths; - -public class MethodHandleAccessProviderData implements TestInterface { - private static final MetaAccessProvider META_ACCESS = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); - // see DirectMethodHandle.java to check invoke* method names assignment - private static final String IVIRTUAL_RESOLVED_NAME = "invokeVirtual"; - private static final String ISTATIC_RESOLVED_NAME = "invokeStatic"; - private static final String ISPECIAL_RESOLVED_NAME = "invokeSpecial"; - private static final String ISTATICINIT_RESOLVED_NAME = "invokeStaticInit"; - private static final String IINTERFACE_RESOLVED_NAME = "invokeInterface"; - private static final String INEWSPECIAL_RESOLVED_NAME = "newInvokeSpecial"; - - @DataProvider(name = "intrinsicsPositive") - public static Object[][] getIntrinsicsDataPositive() { - Object[][] result; - try { - result = new Object[][]{ - new Object[]{ - META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("invokeBasic", Object[].class)), - MethodHandleAccessProvider.IntrinsicMethod.INVOKE_BASIC}, - new Object[]{ - META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("linkToInterface", Object[].class)), - MethodHandleAccessProvider.IntrinsicMethod.LINK_TO_INTERFACE}, - new Object[]{ - META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("linkToStatic", Object[].class)), - MethodHandleAccessProvider.IntrinsicMethod.LINK_TO_STATIC}, - new Object[]{ - META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("linkToVirtual", Object[].class)), - MethodHandleAccessProvider.IntrinsicMethod.LINK_TO_VIRTUAL}, - new Object[]{ - META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("linkToSpecial", Object[].class)), - MethodHandleAccessProvider.IntrinsicMethod.LINK_TO_SPECIAL}}; - } catch (NoSuchMethodException e) { - throw new Error("TESTBUG: can't find method: " + e, e); - } - return result; - } - - @DataProvider(name = "intrinsicsNegative") - public static Object[][] getIntrinsicsDataNegative() { - Object[][] result; - try { - result = new Object[][]{new Object[]{META_ACCESS.lookupJavaMethod(MethodHandle.class.getDeclaredMethod("invokeWithArguments", Object[].class))}}; - } catch (NoSuchMethodException e) { - throw new Error("TESTBUG: can't find method: " + e, e); - } - return result; - } - - @DataProvider(name = "invokeBasicNegative1") - public static Object[][] getInvokeBasicDataNegative1() { - Object[][] result; - JavaConstant wrongObject = CONSTANT_REFLECTION.forObject("42"); - // 2nd parameter is force bytecode generation = true/false - result = new Object[][]{ - new Object[]{wrongObject, true}, - new Object[]{wrongObject, false}, - new Object[]{JavaConstant.NULL_POINTER, true}, - new Object[]{JavaConstant.NULL_POINTER, false}}; - return result; - } - - @DataProvider(name = "invokeBasicNegative2") - public static Object[][] getInvokeBasicDataNegative2() { - Object[][] result; - // 2nd parameter is force bytecode generation = true/false - result = new Object[][]{ - new Object[]{null, true}, - new Object[]{null, false}}; - return result; - } - - @DataProvider(name = "invokeBasicPositive") - public static Object[][] getInvokeBasicDataPositive() { - Object[][] result; - MethodHandle mhIVirtual; - MethodHandle mhIStatic; - MethodHandle mhISpecial; - MethodHandle mhIStaticInit; - MethodHandle mhINewSpecial; - MethodHandle mhIInterface; - MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType voidRet = MethodType.methodType(void.class); - Class self = MethodHandleAccessProviderData.class; - // let's get a separate, thus, not initialized class - ClassLoader current = self.getClassLoader(); - String[] cpaths = System.getProperty("java.class.path").split(File.pathSeparator); - URL[] urls = new URL[cpaths.length]; - try { - for (int i = 0; i < cpaths.length; i++) { - urls[i] = Paths.get(cpaths[i]).toUri().toURL(); - } - } catch (MalformedURLException e) { - throw new Error("Can't parse classpath url: " + e, e); - } - Class clone; - try { - clone = new ParentLastURLClassLoader(urls, current).loadClass(self.getName()); - } catch (ClassNotFoundException e) { - throw new Error("TESTBUG: can't find class: " + e, e); - } - try { - mhIVirtual = lookup.findVirtual(self, "publicMethod", voidRet); - mhIStatic = lookup.findStatic(self, "staticMethod", voidRet); - mhISpecial = lookup.findSpecial(self, "privateMethod", voidRet, self); - mhIStaticInit = lookup.findStatic(clone, "staticMethod", voidRet); - mhINewSpecial = lookup.findConstructor(self, voidRet); - mhIInterface = lookup.findVirtual(TestInterface.class, "interfaceMethod", voidRet); - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new Error("TESTBUG: lookup failed: " + e, e); - } - JavaConstant jcIVirtual = CONSTANT_REFLECTION.forObject(mhIVirtual); - JavaConstant jcIStatic = CONSTANT_REFLECTION.forObject(mhIStatic); - JavaConstant jcISpecial = CONSTANT_REFLECTION.forObject(mhISpecial); - JavaConstant jcIStaticInit = CONSTANT_REFLECTION.forObject(mhIStaticInit); - JavaConstant jcINewSpecial = CONSTANT_REFLECTION.forObject(mhINewSpecial); - JavaConstant jcIInterface = CONSTANT_REFLECTION.forObject(mhIInterface); - // 2nd parameter is force bytecode generation = true/false - result = new Object[][]{ - new Object[]{jcIVirtual, true, IVIRTUAL_RESOLVED_NAME}, - new Object[]{jcIVirtual, false, IVIRTUAL_RESOLVED_NAME}, - new Object[]{jcIStatic, true, ISTATIC_RESOLVED_NAME}, - new Object[]{jcIStatic, false, ISTATIC_RESOLVED_NAME}, - new Object[]{jcISpecial, true, ISPECIAL_RESOLVED_NAME}, - new Object[]{jcISpecial, false, ISPECIAL_RESOLVED_NAME}, - new Object[]{jcIStaticInit, true, ISTATICINIT_RESOLVED_NAME}, - new Object[]{jcIStaticInit, false, ISTATICINIT_RESOLVED_NAME}, - new Object[]{jcINewSpecial, false, INEWSPECIAL_RESOLVED_NAME}, - new Object[]{jcINewSpecial, true, INEWSPECIAL_RESOLVED_NAME}, - new Object[]{jcIInterface, false, IINTERFACE_RESOLVED_NAME}, - new Object[]{jcIInterface, true, IINTERFACE_RESOLVED_NAME}}; - return result; - } - - // can't use nested classes for storing these test methods. see JDK-8010319 - @SuppressWarnings("unused") - private void privateMethod() { - // empty - } - - public static void staticMethod() { - // empty - } - - public void publicMethod() { - // empty - } - - @Override - public void interfaceMethod() { - // empty - } -} - -interface TestInterface { - void interfaceMethod(); -} - -class ParentLastURLClassLoader extends URLClassLoader { - - ParentLastURLClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); - } - - @Override - public Class loadClass(String name) throws ClassNotFoundException { - try { - Class c = findClass(name); - if (c != null) { - return c; - } - } catch (ClassNotFoundException e) { - // ignore - } - return super.loadClass(name); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java deleted file mode 100644 index 4c3fcb9d0fb..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/MethodHandleAccessProviderTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 8152343 - * @bug 8161068 - * @requires vm.jvmci - * @library /test/lib /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * @modules java.base/java.lang.invoke:+open - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open - * @run testng/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.MethodHandleAccessProviderTest - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider; -import jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.runtime.JVMCI; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Method; - -public class MethodHandleAccessProviderTest { - private static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); - private static final MethodHandleAccessProvider PROVIDER = CONSTANT_REFLECTION.getMethodHandleAccess(); - private static final MetaAccessProvider META_ACCESS = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - @Test(dataProvider = "intrinsicsPositive", dataProviderClass = MethodHandleAccessProviderData.class) - public void testLookupMethodHandleIntrinsic(ResolvedJavaMethod mtd, IntrinsicMethod expected) { - Assert.assertEquals(expected, PROVIDER.lookupMethodHandleIntrinsic(mtd), "Unexpected intrinsic returned for " + mtd); - } - - @Test(dataProvider = "intrinsicsNegative", dataProviderClass = MethodHandleAccessProviderData.class) - public void testLookupMethodHandleIntrinsicNegative(ResolvedJavaMethod mtd) { - Assert.assertNull(PROVIDER.lookupMethodHandleIntrinsic(mtd), "Expected null return for " + mtd); - } - - @Test(expectedExceptions = {NullPointerException.class}) - public void testLookupMethodHandleIntrinsicNull() { - PROVIDER.lookupMethodHandleIntrinsic(null); - } - - @Test(dataProvider = "invokeBasicPositive", dataProviderClass = MethodHandleAccessProviderData.class) - public void testResolveInvokeBasicTarget(JavaConstant javaConstantMethodHandle, boolean force, String expected) { - ResolvedJavaMethod mtd = PROVIDER.resolveInvokeBasicTarget(javaConstantMethodHandle, force); - Assert.assertTrue(mtd.getName().startsWith(expected), "Unexpected method resolved: " + mtd); - } - - @Test(dataProvider = "invokeBasicNegative1", dataProviderClass = MethodHandleAccessProviderData.class) - public void testResolveInvokeBasicTargetNegative1(JavaConstant javaConstantMethodHandle, boolean force) { - Assert.assertNull(PROVIDER.resolveInvokeBasicTarget(javaConstantMethodHandle, force), - "Expected null return for " + javaConstantMethodHandle + " with force=" + force); - } - - @Test(dataProvider = "invokeBasicNegative2", dataProviderClass = MethodHandleAccessProviderData.class, expectedExceptions = {NullPointerException.class}) - public void testResolveInvokeBasicTargetNegative2(JavaConstant javaConstantMethodHandle, boolean force) { - PROVIDER.resolveInvokeBasicTarget(javaConstantMethodHandle, force); - } - - @Test - public void testResolveLinkToTarget() { - Method self; - try { - self = getClass().getDeclaredMethod("testResolveLinkToTarget"); - } catch (NoSuchMethodException e) { - throw new Error("TESTBUG: can't find method: " + e, e); - } - MethodHandle mh; - try { - mh = MethodHandles.lookup().unreflect(self); - } catch (IllegalAccessException e) { - throw new Error("TESTBUG: can't get MHandle: " + e, e); - } - Method internalMemberNameMethod; - try { - internalMemberNameMethod = mh.getClass().getDeclaredMethod("internalMemberName"); - } catch (NoSuchMethodException e) { - throw new Error("TESTBUG: can't find method: " + e, e); - } - internalMemberNameMethod.setAccessible(true); - Object memberName; - try { - memberName = internalMemberNameMethod.invoke(mh); - } catch (ReflectiveOperationException e) { - throw new Error("TESTBUG: can't invoke internalMemberName method", e); - } - JavaConstant jcMemberName = CONSTANT_REFLECTION.forObject(memberName); - ResolvedJavaMethod mtd = PROVIDER.resolveLinkToTarget(jcMemberName); - Assert.assertEquals(mtd, META_ACCESS.lookupJavaMethod(self), "Got unexpected method: " + mtd); - } - - @Test(expectedExceptions = {NullPointerException.class}) - public void testResolveLinkToTargetNegativeNull() { - PROVIDER.resolveLinkToTarget(null); - } - - @Test - public void testResolveLinkToTargetNegativeNullConstant() { - Assert.assertNull(PROVIDER.resolveLinkToTarget(JavaConstant.NULL_POINTER), "Expected null return"); - } - - @Test(expectedExceptions = {IllegalArgumentException.class}) - public void testResolveLinkToTargetNegativeWrongConstant() { - PROVIDER.resolveLinkToTarget(CONSTANT_REFLECTION.forObject("42")); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayElementDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayElementDataProvider.java deleted file mode 100644 index e10f7113269..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayElementDataProvider.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.LinkedList; -import java.util.stream.Stream; - -import static jdk.vm.ci.hotspot.test.TestHelper.ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.ARRAY_ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; -import static jdk.vm.ci.hotspot.test.TestHelper.INSTANCE_FIELDS_MAP; - -public class ReadArrayElementDataProvider { - - @DataProvider(name = "readArrayElementDataProvider") - public static Object[][] readArrayElementDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - for (int i : new int[]{0, 1}) { - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayWithValues), - i, JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.booleanArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.byteArrayWithValues), - i, JavaConstant.forByte(DUMMY_CLASS_INSTANCE.byteArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.shortArrayWithValues), - i, JavaConstant.forShort(DUMMY_CLASS_INSTANCE.shortArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.charArrayWithValues), - i, JavaConstant.forChar(DUMMY_CLASS_INSTANCE.charArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intArrayWithValues), - i, JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.longArrayWithValues), - i, JavaConstant.forLong(DUMMY_CLASS_INSTANCE.longArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.floatArrayWithValues), - i, JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.floatArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.doubleArrayWithValues), - i, JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.doubleArrayWithValues[i])}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectArrayWithValues), - i, CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.booleanArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.byteArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.byteArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.shortArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.shortArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.charArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.charArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.longArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.longArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.floatArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.floatArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.doubleArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.doubleArrayArrayWithValues[i])}); - cfgSet.add(new Object[]{ - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectArrayArrayWithValues), i, - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectArrayArrayWithValues[i])}); - } - Stream.concat(ARRAYS_MAP.values().stream(), ARRAY_ARRAYS_MAP.values().stream()).forEach((array) -> { - for (int i : new int[]{-1, 2}) { - cfgSet.add(new Object[]{array, i, null}); - } - }); - cfgSet.add(new Object[]{null, 0, null}); - cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, 0, null}); - INSTANCE_FIELDS_MAP.values().forEach((constant) -> { - cfgSet.add(new Object[]{constant, 0, null}); - }); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayLengthDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayLengthDataProvider.java deleted file mode 100644 index 110c2a2ba5a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadArrayLengthDataProvider.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.LinkedList; -import java.util.List; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class ReadArrayLengthDataProvider { - - public static List createListOfDummyArrays(int length) { - List arrays = new LinkedList<>(); - arrays.add(new boolean[length]); - arrays.add(new byte[length]); - arrays.add(new short[length]); - arrays.add(new char[length]); - arrays.add(new int[length]); - arrays.add(new long[length]); - arrays.add(new float[length]); - arrays.add(new double[length]); - arrays.add(new Object[length]); - arrays.add(new boolean[length][2]); - arrays.add(new byte[length][2]); - arrays.add(new short[length][2]); - arrays.add(new char[length][2]); - arrays.add(new int[length][2]); - arrays.add(new long[length][2]); - arrays.add(new float[length][2]); - arrays.add(new double[length][2]); - arrays.add(new Object[length][2]); - return arrays; - } - - @DataProvider(name = "readArrayLengthDataProvider") - public static Object[][] readArrayLengthDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - for (int i : new int[]{0, 1, 42}) { - createListOfDummyArrays(i).stream().forEach((array) -> { - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(array), i}); - }); - } - cfgSet.add(new Object[]{null, null}); - cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.intField), null}); - cfgSet.add(new Object[]{JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField), null}); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadFieldValueDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadFieldValueDataProvider.java deleted file mode 100644 index f3758b28717..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/ReadFieldValueDataProvider.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.LinkedList; - -import static jdk.vm.ci.hotspot.test.TestHelper.ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.ARRAY_ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_CONSTANT; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; -import static jdk.vm.ci.hotspot.test.TestHelper.INSTANCE_FIELDS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.INSTANCE_STABLE_FIELDS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.STABLE_ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.STABLE_ARRAY_ARRAYS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.STATIC_FIELDS_MAP; -import static jdk.vm.ci.hotspot.test.TestHelper.STATIC_STABLE_FIELDS_MAP; - -public class ReadFieldValueDataProvider { - - @DataProvider(name = "readFieldValueDataProvider") - public static Object[][] readFieldValueDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - // Testing instance non-stable fields - INSTANCE_FIELDS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing static non-stable fields with null as receiver - STATIC_FIELDS_MAP.entrySet().stream().forEach((staticField) -> { - cfgSet.add(new Object[]{staticField.getKey(), null, staticField.getValue()}); - }); - // Testing static non-stable fields with JavaConstant.NULL_POINTER as receiver - STATIC_FIELDS_MAP.entrySet().stream().forEach((staticField) -> { - cfgSet.add(new Object[]{staticField.getKey(), - JavaConstant.NULL_POINTER, - staticField.getValue()}); - }); - // Testing instance stable fields - INSTANCE_STABLE_FIELDS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing static stable fields with null as receiver - STATIC_STABLE_FIELDS_MAP.entrySet().stream().forEach((staticField) -> { - cfgSet.add(new Object[]{staticField.getKey(), null, staticField.getValue()}); - }); - // Testing static stable fields with JavaConstant.NULL_POINTER as receiver - STATIC_STABLE_FIELDS_MAP.entrySet().stream().forEach((staticField) -> { - cfgSet.add(new Object[]{staticField.getKey(), - JavaConstant.NULL_POINTER, - staticField.getValue()}); - }); - // Testing instance non-stable array fields - ARRAYS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing instance stable array fields - STABLE_ARRAYS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing instance non-stable array-of-array fields - ARRAY_ARRAYS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing instance stable array-of-array fields - STABLE_ARRAY_ARRAYS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - DUMMY_CLASS_CONSTANT, - instanceField.getValue()}); - }); - // Testing instance fields with JavaConstant.NULL_POINTER as receiver - INSTANCE_FIELDS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), JavaConstant.NULL_POINTER, null}); - }); - // Testing instance fields with an object that does not have the field - INSTANCE_FIELDS_MAP.entrySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField.getKey(), - CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE.objectField), - null}); - }); - return cfgSet.toArray(new Object[0][0]); - } - - @DataProvider(name = "readFieldValueNegativeDataProvider") - public static Object[][] readFieldValueNegativeDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - // Testing instance fields with null as receiver - INSTANCE_FIELDS_MAP.keySet().stream().forEach((instanceField) -> { - cfgSet.add(new Object[]{instanceField, null}); - }); - // Testing null as a field argument - cfgSet.add(new Object[]{null, null}); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestDynamicConstant.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestDynamicConstant.java deleted file mode 100644 index b6e4f9cf2ef..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestDynamicConstant.java +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @summary Test CONSTANT_Dynamic resolution by HotSpotConstantPool. - * @library /testlibrary/asm - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.hotspot.test.TestDynamicConstant - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -XX:+UnlockDiagnosticVMOptions -XX:UseBootstrapCallInfo=3 - * jdk.vm.ci.hotspot.test.TestDynamicConstant - */ - -package jdk.vm.ci.hotspot.test; - -import java.io.File; -import java.io.IOException; -import java.lang.invoke.CallSite; -import java.lang.invoke.ConstantBootstraps; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.invoke.StringConcatFactory; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.util.List; -import java.util.Map; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.ConstantDynamic; -import org.objectweb.asm.Handle; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import jdk.vm.ci.hotspot.HotSpotObjectConstant; -import jdk.vm.ci.hotspot.HotSpotConstantPool; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.ConstantPool.BootstrapMethodInvocation; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.PrimitiveConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.runtime.JVMCI; - -/** - * Tests support for Dynamic constants and {@link jdk.vm.ci.meta.ConstantPool#lookupBootstrapMethodInvocation}. - * - * @see "https://openjdk.org/jeps/309" - * @see "https://bugs.openjdk.org/browse/JDK-8177279" - */ -public class TestDynamicConstant implements Opcodes { - - private static final int PUBLIC_STATIC = ACC_PUBLIC | ACC_STATIC; - - static final String testClassInternalName = Type.getInternalName(TestDynamicConstant.class); - static final String constantBootstrapsClassInternalName = Type.getInternalName(ConstantBootstraps.class); - - enum CondyType { - /** - * Condy whose bootstrap method is one of the {@code TestDynamicConstant.getBSM()} - * methods. - */ - CALL_DIRECT_BSM, - - /** - * Condy whose bootstrap method is one of the {@code TestDynamicConstant.getBSM( constant, int i)} - * methods with one condy arg and one int arg. - */ - CALL_DIRECT_WITH_ARGS_BSM, - - /** - * Condy whose bootstrap method is {@link ConstantBootstraps#invoke} that invokes one of the - * {@code TestDynamicConstant.get()} methods. - */ - CALL_INDIRECT_BSM, - - /** - * Condy whose bootstrap method is {@link ConstantBootstraps#invoke} that invokes one of the - * {@code TestDynamicConstant.get( p1, p2)} methods with args that are - * condys themselves. - */ - CALL_INDIRECT_WITH_ARGS_BSM - } - - /** - * Generates a class with a static {@code run} method that returns a value loaded from - * CONSTANT_Dynamic constant pool entry. - */ - static class TestGenerator { - - /** - * Type of value returned by the generated {@code run} method. - */ - final Type type; - - /** - * Type of condy used to produce the returned value. - */ - final CondyType condyType; - - /** - * Base name of the static {@code TestDynamicConstant.get} method(s) invoked from - * condys in the generated class. - */ - final String getter; - - /** - * Name of the generated class. - */ - final String className; - - TestGenerator(Class type, CondyType condyType) { - String typeName = type.getSimpleName(); - this.type = Type.getType(type); - this.condyType = condyType; - this.getter = "get" + typeName.substring(0, 1).toUpperCase() + typeName.substring(1); - this.className = TestDynamicConstant.class.getName() + "$" + typeName + '_' + condyType; - } - - Class generateClass() throws ClassNotFoundException { - TestCL cl = new TestCL(getClass().getClassLoader()); - return cl.findClass(className); - } - - byte[] generateClassfile() { - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - cw.visit(V16, ACC_SUPER | ACC_PUBLIC, className.replace('.', '/'), null, "java/lang/Object", null); - - // @formatter:off - // Object ConstantBootstraps.invoke(MethodHandles.Lookup lookup, String name, Class type, MethodHandle handle, Object... args) - // @formatter:on - String invokeSig = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;"; - Handle invokeHandle = new Handle(H_INVOKESTATIC, constantBootstrapsClassInternalName, "invoke", invokeSig, false); - - String desc = type.getDescriptor(); - ConstantDynamic condy; - if (condyType == CondyType.CALL_DIRECT_BSM) { - // Example: int TestDynamicConstant.getIntBSM(MethodHandles.Lookup l, String name, - // Class type) - String sig = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)" + desc; - Handle handle = new Handle(H_INVOKESTATIC, testClassInternalName, getter + "BSM", sig, false); - - condy = new ConstantDynamic("const", desc, handle); - MethodVisitor run = cw.visitMethod(PUBLIC_STATIC, "run", "()" + desc, null, null); - run.visitLdcInsn(condy); - run.visitInsn(type.getOpcode(IRETURN)); - run.visitMaxs(0, 0); - run.visitEnd(); - } else if (condyType == CondyType.CALL_DIRECT_WITH_ARGS_BSM) { - // Example: int TestDynamicConstant.getIntBSM(MethodHandles.Lookup l, String name, - // Class type, int constant, int i) - String sig1 = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)" + desc; - String sig2 = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;" + desc + "I)" + desc; - - Handle handle1 = new Handle(H_INVOKESTATIC, testClassInternalName, getter + "BSM", sig1, false); - Handle handle2 = new Handle(H_INVOKESTATIC, testClassInternalName, getter + "BSM", sig2, false); - - ConstantDynamic condy1 = new ConstantDynamic("const1", desc, handle1); - ConstantDynamic condy2 = new ConstantDynamic("const2", desc, handle2, condy1, Integer.MAX_VALUE); - - condy = condy2; - MethodVisitor run = cw.visitMethod(PUBLIC_STATIC, "run", "()" + desc, null, null); - run.visitLdcInsn(condy); - run.visitInsn(type.getOpcode(IRETURN)); - run.visitMaxs(0, 0); - run.visitEnd(); - } else if (condyType == CondyType.CALL_INDIRECT_BSM) { - // Example: int TestDynamicConstant.getInt() - Handle handle = new Handle(H_INVOKESTATIC, testClassInternalName, getter, "()" + desc, false); - - condy = new ConstantDynamic("const", desc, invokeHandle, handle); - MethodVisitor run = cw.visitMethod(PUBLIC_STATIC, "run", "()" + desc, null, null); - run.visitLdcInsn(condy); - run.visitInsn(type.getOpcode(IRETURN)); - run.visitMaxs(0, 0); - run.visitEnd(); - } else { - assert condyType == CondyType.CALL_INDIRECT_WITH_ARGS_BSM; - // Example: int TestDynamicConstant.getInt() - Handle handle1 = new Handle(H_INVOKESTATIC, testClassInternalName, getter, "()" + desc, false); - - // Example: int TestDynamicConstant.getInt(int v1, int v2) - Handle handle2 = new Handle(H_INVOKESTATIC, testClassInternalName, getter, "(" + desc + desc + ")" + desc, false); - - ConstantDynamic condy1 = new ConstantDynamic("const1", desc, invokeHandle, handle1); - ConstantDynamic condy2 = new ConstantDynamic("const2", desc, invokeHandle, handle2, condy1, condy1); - condy = condy2; - - MethodVisitor run = cw.visitMethod(PUBLIC_STATIC, "run", "()" + desc, null, null); - run.visitLdcInsn(condy2); - run.visitInsn(type.getOpcode(IRETURN)); - run.visitMaxs(0, 0); - run.visitEnd(); - } - - MethodVisitor concat = cw.visitMethod(PUBLIC_STATIC, "concat", "()Ljava/lang/String;", null, null); - String sig = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;"; - Handle handle = new Handle(H_INVOKESTATIC, Type.getInternalName(StringConcatFactory.class), "makeConcatWithConstants", sig, false); - String recipe = "var arg=\u0001, const arg=\u0002"; - Object[] bsmArgs = {recipe, condy}; - concat.visitLdcInsn(condy); - concat.visitInvokeDynamicInsn("do_concat", "(" + desc + ")Ljava/lang/String;", handle, bsmArgs); - concat.visitInsn(ARETURN); - concat.visitMaxs(0, 0); - concat.visitEnd(); - - MethodVisitor shouldNotBeCalled = cw.visitMethod(PUBLIC_STATIC, "shouldNotBeCalled", "()V", null, null); - sig = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; - handle = new Handle(H_INVOKESTATIC, testClassInternalName, "shouldNotBeCalledBSM", sig, false); - shouldNotBeCalled.visitInvokeDynamicInsn("do_shouldNotBeCalled", "()V", handle); - shouldNotBeCalled.visitInsn(RETURN); - shouldNotBeCalled.visitMaxs(0, 0); - shouldNotBeCalled.visitEnd(); - - cw.visitEnd(); - return cw.toByteArray(); - } - - private final class TestCL extends ClassLoader { - String saveClassfilesDir = System.getProperty("save.classfiles.dir"); - - private TestCL(ClassLoader parent) { - super(parent); - } - - @Override - protected Class findClass(String name) throws ClassNotFoundException { - if (name.equals(className)) { - byte[] classfileBytes = generateClassfile(); - if (saveClassfilesDir != null) { - try { - File classfile = new File(saveClassfilesDir, name.replace('.', File.separatorChar) + ".class"); - File classfileDir = classfile.getParentFile(); - classfileDir.mkdirs(); - Files.write(classfile.toPath(), classfileBytes); - System.out.println("Wrote: " + classfile.getAbsolutePath()); - } catch (IOException cause) { - Assert.fail("Error saving class file for " + name, cause); - } - } - return defineClass(name, classfileBytes, 0, classfileBytes.length); - } else { - return super.findClass(name); - } - } - } - } - - /** - * Asserts that {@link ConstantPool#lookupConstant(int, boolean)} with {@code resolve == false} - * returns null for all resolvable constant entries. - */ - private static void assertNoEagerConstantResolution(Class testClass, ConstantPool cp, Method getTagAt) throws Exception { - for (int cpi = 1; cpi < cp.length(); cpi++) { - String tag = String.valueOf(getTagAt.invoke(cp, cpi)); - switch (tag) { - case "MethodHandle": - case "MethodType": - case "Dynamic": { - Object con = cp.lookupConstant(cpi, false); - Assert.assertNull(con, "Unexpected eager resolution in " + testClass + " at cpi " + cpi + " (tag: " + tag + ")"); - break; - } - } - } - } - - /** - * Ensures {@link ConstantPool#lookupBootstrapMethodInvocation} does not invoke the associated bootstrap method. - */ - private static void assertLookupBMIDoesNotInvokeBM(MetaAccessProvider metaAccess, Class testClass) throws Exception { - ResolvedJavaMethod shouldNotBeCalled = metaAccess.lookupJavaMethod(testClass.getDeclaredMethod("shouldNotBeCalled")); - ConstantPool cp = shouldNotBeCalled.getConstantPool(); - int rawIndex = getFirstInvokedynamicOperand(shouldNotBeCalled); - BootstrapMethodInvocation bmi = cp.lookupBootstrapMethodInvocation(rawIndex, INVOKEDYNAMIC); - Assert.assertEquals(bmi.getName(), "do_shouldNotBeCalled"); - Assert.assertEquals(bmi.getMethod().getName(), "shouldNotBeCalledBSM"); - } - - @SuppressWarnings("try") - @Test - public void test() throws Throwable { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - Class[] types = { - boolean.class, - byte.class, - short.class, - char.class, - int.class, - float.class, - long.class, - double.class, - String.class, - Object.class, - List.class - }; - - Method getTagAt = HotSpotConstantPool.class.getDeclaredMethod("getTagAt", int.class); - getTagAt.setAccessible(true); - - for (Class type : types) { - for (CondyType condyType : CondyType.values()) { - TestGenerator e = new TestGenerator(type, condyType); - Class testClass = e.generateClass(); - Method m = testClass.getDeclaredMethod("run"); - ResolvedJavaMethod run = metaAccess.lookupJavaMethod(m); - ConstantPool cp = run.getConstantPool(); - - assertNoEagerConstantResolution(testClass, cp, getTagAt); - assertLookupBMIDoesNotInvokeBM(metaAccess, testClass); - - if (type != Object.class) { - testLookupBootstrapMethodInvocation(condyType, metaAccess, testClass, getTagAt); - } else { - // StringConcatFactoryStringConcatFactory cannot accept null constants - } - - Object lastConstant = null; - for (int cpi = 1; cpi < cp.length(); cpi++) { - String tag = String.valueOf(getTagAt.invoke(cp, cpi)); - if (tag.equals("Dynamic")) { - lastConstant = cp.lookupConstant(cpi); - } - } - Assert.assertTrue(lastConstant != null, "No Dynamic entries in constant pool of " + testClass.getName()); - - // Execute code to resolve condy by execution and compare - // with condy resolved via ConstantPool - Object expect = m.invoke(null); - Object actual; - if (lastConstant == PrimitiveConstant.NULL_POINTER) { - actual = null; - } else if (lastConstant instanceof PrimitiveConstant) { - actual = ((PrimitiveConstant) lastConstant).asBoxedPrimitive(); - } else { - actual = ((HotSpotObjectConstant) lastConstant).asObject(type); - } - Assert.assertEquals(actual, expect, m + ":"); - } - } - } - - /** - * Tests {@link jdk.vm.ci.meta.ConstantPool#lookupBootstrapMethodInvocation}. - */ - private void testLookupBootstrapMethodInvocation(CondyType condyType, MetaAccessProvider metaAccess, Class testClass, Method getTagAt) throws Throwable { - Method m = testClass.getDeclaredMethod("concat"); - ResolvedJavaMethod concat = metaAccess.lookupJavaMethod(m); - ConstantPool cp = concat.getConstantPool(); - - // Contains a map of (bootstrap method names, resolvable) values. - Map expectedIndyBSMs = Map.of( - "jdk.vm.ci.hotspot.test.TestDynamicConstant.shouldNotBeCalledBSM", false, - "java.lang.invoke.StringConcatFactory.makeConcatWithConstants", true - ); - - for (int cpi = 1; cpi < cp.length(); cpi++) { - String tag = String.valueOf(getTagAt.invoke(cp, cpi)); - BootstrapMethodInvocation bsmi = cp.lookupBootstrapMethodInvocation(cpi, -1); - if (tag.equals("InvokeDynamic") || tag.equals("Dynamic")) { - Assert.assertNotNull(bsmi); - String bsm = bsmi.getMethod().format("%H.%n"); - if (tag.equals("InvokeDynamic")) { - Assert.assertTrue(bsmi.isInvokeDynamic()); - Assert.assertTrue(expectedIndyBSMs.containsKey(bsm), expectedIndyBSMs.toString()); - } else { - Assert.assertFalse(bsmi.isInvokeDynamic()); - Assert.assertNull(bsmi.lookup()); - checkBsmName(condyType, bsm); - List staticArguments = bsmi.getStaticArguments(); - for (int i = 0; i < staticArguments.size(); ++i) { - JavaConstant constant = staticArguments.get(i); - if (constant instanceof PrimitiveConstant) { - String innerTag = String.valueOf(getTagAt.invoke(cp, constant.asInt())); - if (condyType == CondyType.CALL_DIRECT_WITH_ARGS_BSM) { - Assert.assertEquals(i, 0); - Assert.assertEquals(innerTag, "Dynamic"); - } - if (innerTag.equals("Dynamic")) { - BootstrapMethodInvocation innerBsmi = cp.lookupBootstrapMethodInvocation(constant.asInt(), -1); - String innerBsm = innerBsmi.getMethod().format("%H.%n"); - checkBsmName(condyType, innerBsm); - } else { - Assert.assertEquals(innerTag, "MethodHandle"); - } - } else { - if (condyType == CondyType.CALL_DIRECT_WITH_ARGS_BSM) { - Assert.assertEquals(i, 1); - } - Assert.assertTrue(staticArguments.get(i) instanceof HotSpotObjectConstant); - } - } - } - } else { - Assert.assertNull(bsmi, String.valueOf(bsmi)); - } - } - - testLoadReferencedType(concat, cp); - - testLookupBootstrapMethodInvocations(condyType, cp, expectedIndyBSMs); - } - - private static void testLookupBootstrapMethodInvocations(CondyType condyType, ConstantPool cp, Map expectedIndyBSMs) { - List indyBSMs = cp.lookupBootstrapMethodInvocations(true); - Assert.assertEquals(indyBSMs.size(), 2); - for (var bsmi : indyBSMs) { - String bsm = bsmi.getMethod().format("%H.%n"); - Assert.assertTrue(expectedIndyBSMs.containsKey(bsm), expectedIndyBSMs.toString()); - Assert.assertTrue(bsmi.isInvokeDynamic()); - if (expectedIndyBSMs.get(bsm)) { - bsmi.resolve(); - Assert.assertNotNull(bsmi.lookup()); - } else { - try { - bsmi.resolve(); - } catch (BootstrapMethodError bme) { - // expected error - } - Assert.assertNull(bsmi.lookup()); - } - } - - List condyBSMs = cp.lookupBootstrapMethodInvocations(false); - int expectedNumCondys = switch(condyType) { - case CALL_DIRECT_BSM, CALL_INDIRECT_BSM -> 1; - case CALL_DIRECT_WITH_ARGS_BSM, CALL_INDIRECT_WITH_ARGS_BSM -> 2; - }; - Assert.assertEquals(condyBSMs.size(), expectedNumCondys); - for (var bsmi : condyBSMs) { - Assert.assertTrue(!bsmi.isInvokeDynamic()); - bsmi.resolve(); - Assert.assertNotNull(bsmi.lookup()); - } - } - - private static void checkBsmName(CondyType condyType, String bsm) { - if (condyType == CondyType.CALL_DIRECT_BSM || condyType == CondyType.CALL_DIRECT_WITH_ARGS_BSM) { - Assert.assertTrue(bsm.startsWith("jdk.vm.ci.hotspot.test.TestDynamicConstant.get") && bsm.endsWith("BSM"), bsm); - } else { - Assert.assertEquals(bsm, "java.lang.invoke.ConstantBootstraps.invoke"); - } - } - - private static int beS4(byte[] data, int bci) { - return (data[bci] << 24) | ((data[bci + 1] & 0xff) << 16) | ((data[bci + 2] & 0xff) << 8) | (data[bci + 3] & 0xff); - } - - private static int beU1(byte[] data, int bci) { - return data[bci] & 0xff; - } - private static final int LDC2_W = 20; - - /** - * Gets the operand of the first invokedynamic in {@code method}. This - * assumes that the bytecode of {@code method} is an INVOKEDYNAMIC instruction, - * possibly preceded by an LDC instruction. - */ - private static int getFirstInvokedynamicOperand(ResolvedJavaMethod method) { - byte[] code = method.getCode(); - int opcode = beU1(code, 0); - if (opcode == INVOKEDYNAMIC) { - return beS4(code, 1); - } - Assert.assertTrue(opcode == LDC || opcode == LDC2_W, String.valueOf(opcode)); - int bci = opcode == LDC ? 2 : 3; - Assert.assertEquals(beU1(code, bci), INVOKEDYNAMIC); - return beS4(code, bci + 1); - } - - /** - * Ensures that loadReferencedType for an invokedynamic call site does not throw an exception. - */ - private static void testLoadReferencedType(ResolvedJavaMethod method, ConstantPool cp) { - int rawIndex = getFirstInvokedynamicOperand(method); - cp.loadReferencedType(rawIndex, INVOKEDYNAMIC, false); - } - - // @formatter:off - @SuppressWarnings("unused") public static boolean getBooleanBSM(MethodHandles.Lookup l, String name, Class type) { return true; } - @SuppressWarnings("unused") public static char getCharBSM (MethodHandles.Lookup l, String name, Class type) { return '*'; } - @SuppressWarnings("unused") public static short getShortBSM (MethodHandles.Lookup l, String name, Class type) { return Short.MAX_VALUE; } - @SuppressWarnings("unused") public static byte getByteBSM (MethodHandles.Lookup l, String name, Class type) { return Byte.MAX_VALUE; } - @SuppressWarnings("unused") public static int getIntBSM (MethodHandles.Lookup l, String name, Class type) { return Integer.MAX_VALUE; } - @SuppressWarnings("unused") public static float getFloatBSM (MethodHandles.Lookup l, String name, Class type) { return Float.MAX_VALUE; } - @SuppressWarnings("unused") public static long getLongBSM (MethodHandles.Lookup l, String name, Class type) { return Long.MAX_VALUE; } - @SuppressWarnings("unused") public static double getDoubleBSM (MethodHandles.Lookup l, String name, Class type) { return Double.MAX_VALUE; } - @SuppressWarnings("unused") public static String getStringBSM (MethodHandles.Lookup l, String name, Class type) { return "a string"; } - @SuppressWarnings("unused") public static Object getObjectBSM (MethodHandles.Lookup l, String name, Class type) { return null; } - @SuppressWarnings("unused") public static List getListBSM (MethodHandles.Lookup l, String name, Class type) { return List.of("element"); } - - @SuppressWarnings("unused") public static boolean getBooleanBSM(MethodHandles.Lookup l, String name, Class type, boolean constant, int i) { return true; } - @SuppressWarnings("unused") public static char getCharBSM (MethodHandles.Lookup l, String name, Class type, char constant, int i) { return '*'; } - @SuppressWarnings("unused") public static short getShortBSM (MethodHandles.Lookup l, String name, Class type, short constant, int i) { return Short.MAX_VALUE; } - @SuppressWarnings("unused") public static byte getByteBSM (MethodHandles.Lookup l, String name, Class type, byte constant, int i) { return Byte.MAX_VALUE; } - @SuppressWarnings("unused") public static int getIntBSM (MethodHandles.Lookup l, String name, Class type, int constant, int i) { return Integer.MAX_VALUE; } - @SuppressWarnings("unused") public static float getFloatBSM (MethodHandles.Lookup l, String name, Class type, float constant, int i) { return Float.MAX_VALUE; } - @SuppressWarnings("unused") public static long getLongBSM (MethodHandles.Lookup l, String name, Class type, long constant, int i) { return Long.MAX_VALUE; } - @SuppressWarnings("unused") public static double getDoubleBSM (MethodHandles.Lookup l, String name, Class type, double constant, int i) { return Double.MAX_VALUE; } - @SuppressWarnings("unused") public static String getStringBSM (MethodHandles.Lookup l, String name, Class type, String constant, int i) { return "a string"; } - @SuppressWarnings("unused") public static Object getObjectBSM (MethodHandles.Lookup l, String name, Class type, Object constant, int i) { return null; } - @SuppressWarnings("unused") public static List getListBSM (MethodHandles.Lookup l, String name, Class type, List constant, int i) { return List.of("element"); } - - - public static boolean getBoolean() { return true; } - public static char getChar () { return '*'; } - public static short getShort () { return Short.MAX_VALUE; } - public static byte getByte () { return Byte.MAX_VALUE; } - public static int getInt () { return Integer.MAX_VALUE; } - public static float getFloat () { return Float.MAX_VALUE; } - public static long getLong () { return Long.MAX_VALUE; } - public static double getDouble () { return Double.MAX_VALUE; } - public static String getString () { return "a string"; } - public static Object getObject () { return null; } - public static List getList () { return List.of("element"); } - - public static boolean getBoolean(boolean v1, boolean v2) { return v1 || v2; } - public static char getChar (char v1, char v2) { return (char)(v1 ^ v2); } - public static short getShort (short v1, short v2) { return (short)(v1 ^ v2); } - public static byte getByte (byte v1, byte v2) { return (byte)(v1 ^ v2); } - public static int getInt (int v1, int v2) { return v1 ^ v2; } - public static float getFloat (float v1, float v2) { return v1 * v2; } - public static long getLong (long v1, long v2) { return v1 ^ v2; } - public static double getDouble (double v1, double v2) { return v1 * v2; } - public static String getString (String v1, String v2) { return v1 + v2; } - public static Object getObject (Object v1, Object v2) { return null; } - public static List getList (List v1, List v2) { return List.of(v1, v2); } - // @formatter:on - - // A bootstrap method that should never be called - public static CallSite shouldNotBeCalledBSM(MethodHandles.Lookup caller, String name, MethodType type) throws Exception { - throw new RuntimeException("should not be called"); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHelper.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHelper.java deleted file mode 100644 index 53ed106e46e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHelper.java +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.runtime.JVMCI; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -public class TestHelper { - - public static final DummyClass DUMMY_CLASS_INSTANCE = new DummyClass(); - public static final HotSpotConstantReflectionProvider CONSTANT_REFLECTION_PROVIDER = (HotSpotConstantReflectionProvider) JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); - public static final JavaConstant DUMMY_CLASS_CONSTANT = CONSTANT_REFLECTION_PROVIDER.forObject(DUMMY_CLASS_INSTANCE); - - public static final Map INSTANCE_FIELDS_MAP = new HashMap<>(); - - static { - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "booleanField"), - JavaConstant.forBoolean(DUMMY_CLASS_INSTANCE.booleanField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "byteField"), - JavaConstant.forByte(DUMMY_CLASS_INSTANCE.byteField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "shortField"), - JavaConstant.forShort(DUMMY_CLASS_INSTANCE.shortField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "charField"), - JavaConstant.forChar(DUMMY_CLASS_INSTANCE.charField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "intField"), - JavaConstant.forInt(DUMMY_CLASS_INSTANCE.intField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "longField"), - JavaConstant.forLong(DUMMY_CLASS_INSTANCE.longField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "floatField"), - JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.floatField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "doubleField"), - JavaConstant.forDouble(DUMMY_CLASS_INSTANCE.doubleField)); - INSTANCE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "objectField"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.objectField)); - } - - public static final Map INSTANCE_FINAL_FIELDS_MAP = new HashMap<>(); - - static { - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalBooleanField"), - JavaConstant.forBoolean( - DUMMY_CLASS_INSTANCE.finalBooleanField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalByteField"), - JavaConstant.forByte(DUMMY_CLASS_INSTANCE.finalByteField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalShortField"), - JavaConstant.forShort(DUMMY_CLASS_INSTANCE.finalShortField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalCharField"), - JavaConstant.forChar(DUMMY_CLASS_INSTANCE.finalCharField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalIntField"), - JavaConstant.forInt(DUMMY_CLASS_INSTANCE.finalIntField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalLongField"), - JavaConstant.forLong(DUMMY_CLASS_INSTANCE.finalLongField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalFloatField"), - JavaConstant.forFloat(DUMMY_CLASS_INSTANCE.finalFloatField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalDoubleField"), - JavaConstant.forDouble( - DUMMY_CLASS_INSTANCE.finalDoubleField)); - INSTANCE_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "finalObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.finalObjectField)); - } - - public static final Map INSTANCE_FINAL_DEFAULT_FIELDS_MAP = new HashMap<>(); - - static { - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultBooleanField"), - JavaConstant.forBoolean( - DUMMY_CLASS_INSTANCE.finalDefaultBooleanField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultByteField"), - JavaConstant.forByte( - DUMMY_CLASS_INSTANCE.finalDefaultByteField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultShortField"), - JavaConstant.forShort( - DUMMY_CLASS_INSTANCE.finalDefaultShortField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultCharField"), - JavaConstant.forChar( - DUMMY_CLASS_INSTANCE.finalDefaultCharField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultIntField"), - JavaConstant.forInt( - DUMMY_CLASS_INSTANCE.finalDefaultIntField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultLongField"), - JavaConstant.forLong( - DUMMY_CLASS_INSTANCE.finalDefaultLongField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultFloatField"), - JavaConstant.forFloat( - DUMMY_CLASS_INSTANCE.finalDefaultFloatField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultDoubleField"), - JavaConstant.forDouble( - DUMMY_CLASS_INSTANCE.finalDefaultDoubleField)); - INSTANCE_FINAL_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "finalDefaultObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.finalDefaultObjectField)); - } - - public static final Map INSTANCE_STABLE_FIELDS_MAP = new HashMap<>(); - - static { - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableBooleanField"), - JavaConstant.forBoolean( - DUMMY_CLASS_INSTANCE.stableBooleanField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableByteField"), - JavaConstant.forByte(DUMMY_CLASS_INSTANCE.stableByteField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableShortField"), - JavaConstant.forShort( - DUMMY_CLASS_INSTANCE.stableShortField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableCharField"), - JavaConstant.forChar(DUMMY_CLASS_INSTANCE.stableCharField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableIntField"), - JavaConstant.forInt(DUMMY_CLASS_INSTANCE.stableIntField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableLongField"), - JavaConstant.forLong(DUMMY_CLASS_INSTANCE.stableLongField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableFloatField"), - JavaConstant.forFloat( - DUMMY_CLASS_INSTANCE.stableFloatField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableDoubleField"), - JavaConstant.forDouble( - DUMMY_CLASS_INSTANCE.stableDoubleField)); - INSTANCE_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "stableObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableObjectField)); - } - - public static final Map STATIC_FIELDS_MAP = new HashMap<>(); - - static { - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticBooleanField"), - JavaConstant.forBoolean(DummyClass.staticBooleanField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticByteField"), - JavaConstant.forByte(DummyClass.staticByteField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticShortField"), - JavaConstant.forShort(DummyClass.staticShortField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticCharField"), - JavaConstant.forChar(DummyClass.staticCharField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticIntField"), - JavaConstant.forInt(DummyClass.staticIntField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticLongField"), - JavaConstant.forLong(DummyClass.staticLongField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFloatField"), - JavaConstant.forFloat(DummyClass.staticFloatField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticDoubleField"), - JavaConstant.forDouble(DummyClass.staticDoubleField)); - STATIC_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject(DummyClass.staticObjectField)); - } - - public static final Map STATIC_FINAL_FIELDS_MAP = new HashMap<>(); - - static { - STATIC_FINAL_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticFinalBooleanField"), - JavaConstant.forBoolean(DummyClass.staticFinalBooleanField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalByteField"), - JavaConstant.forByte(DummyClass.staticFinalByteField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalShortField"), - JavaConstant.forShort(DummyClass.staticFinalShortField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalCharField"), - JavaConstant.forChar(DummyClass.staticFinalCharField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalIntField"), - JavaConstant.forInt(DummyClass.staticFinalIntField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalLongField"), - JavaConstant.forLong(DummyClass.staticFinalLongField)); - STATIC_FINAL_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticFinalFloatField"), - JavaConstant.forFloat(DummyClass.staticFinalFloatField)); - STATIC_FINAL_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticFinalDoubleField"), - JavaConstant.forDouble(DummyClass.staticFinalDoubleField)); - STATIC_FINAL_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticFinalObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject(DummyClass.staticFinalObjectField)); - } - - public static final Map STATIC_STABLE_FIELDS_MAP = new HashMap<>(); - - static { - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableBooleanField"), - JavaConstant.forBoolean(DummyClass.staticStableBooleanField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableByteField"), - JavaConstant.forByte(DummyClass.staticStableByteField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableShortField"), - JavaConstant.forShort(DummyClass.staticStableShortField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableCharField"), - JavaConstant.forChar(DummyClass.staticStableCharField)); - STATIC_STABLE_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, "staticStableIntField"), - JavaConstant.forInt(DummyClass.staticStableIntField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableLongField"), - JavaConstant.forLong(DummyClass.staticStableLongField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableFloatField"), - JavaConstant.forFloat(DummyClass.staticStableFloatField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableDoubleField"), - JavaConstant.forDouble(DummyClass.staticStableDoubleField)); - STATIC_STABLE_FIELDS_MAP.put( - getResolvedJavaField(DummyClass.class, "staticStableObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject(DummyClass.staticStableObjectField)); - } - - public static final Map STATIC_STABLE_DEFAULT_FIELDS_MAP = new HashMap<>(); - - static { - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultBooleanField"), - JavaConstant.forBoolean( - DummyClass.staticStableDefaultBooleanField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultByteField"), - JavaConstant.forByte( - DummyClass.staticStableDefaultByteField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultShortField"), - JavaConstant.forShort( - DummyClass.staticStableDefaultShortField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultCharField"), - JavaConstant.forChar( - DummyClass.staticStableDefaultCharField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultIntField"), - JavaConstant.forInt( - DummyClass.staticStableDefaultIntField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultLongField"), - JavaConstant.forLong( - DummyClass.staticStableDefaultLongField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultFloatField"), - JavaConstant.forFloat( - DummyClass.staticStableDefaultFloatField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultDoubleField"), - JavaConstant.forDouble( - DummyClass.staticStableDefaultDoubleField)); - STATIC_STABLE_DEFAULT_FIELDS_MAP.put(getResolvedJavaField(DummyClass.class, - "staticStableDefaultObjectField"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DummyClass.staticStableDefaultObjectField)); - } - - public static final int ARRAY_DIMENSION = 1; - public static final int ARRAY_OF_ARRAYS_DIMENSION = 2; - - public static final Map ARRAYS_MAP = new HashMap<>(); - - static { - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "booleanArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.booleanArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "byteArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.byteArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "shortArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.shortArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "charArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.charArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "intArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.intArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "longArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.longArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "floatArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.floatArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "doubleArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.doubleArrayWithValues)); - ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "objectArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.objectArrayWithValues)); - } - - public static final Map STABLE_ARRAYS_MAP = new HashMap<>(); - - static { - STABLE_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableBooleanArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableBooleanArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableByteArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableByteArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableShortArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableShortArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableCharArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableCharArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableIntArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableIntArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableLongArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableLongArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableFloatArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableFloatArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableDoubleArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableDoubleArrayWithValues)); - STABLE_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "stableObjectArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableObjectArrayWithValues)); - } - - public static final Map ARRAY_ARRAYS_MAP = new HashMap<>(); - - static { - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "booleanArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.booleanArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "byteArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.byteArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "shortArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.shortArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "charArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.charArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "intArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.intArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "longArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.longArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "floatArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.floatArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "doubleArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.doubleArrayArrayWithValues)); - ARRAY_ARRAYS_MAP.put(getResolvedJavaField(DummyClass.class, "objectArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.objectArrayArrayWithValues)); - } - - public static final Map STABLE_ARRAY_ARRAYS_MAP = new HashMap<>(); - - static { - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableBooleanArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableBooleanArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableByteArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableByteArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableShortArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableShortArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableCharArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableCharArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableIntArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableIntArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableLongArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableLongArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableFloatArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableFloatArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableDoubleArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableDoubleArrayArrayWithValues)); - STABLE_ARRAY_ARRAYS_MAP.put( - getResolvedJavaField(DummyClass.class, "stableObjectArrayArrayWithValues"), - CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.stableObjectArrayArrayWithValues)); - } - - public static ResolvedJavaField getResolvedJavaField(Class clazz, String fieldName) { - Field reflectionField = null; - try { - reflectionField = clazz.getDeclaredField(fieldName); - reflectionField.setAccessible(true); - } catch (NoSuchFieldException ex) { - throw new Error("Test bug: Invalid field name: " + ex, ex); - } catch (SecurityException ex) { - throw new Error("Unexpected error: " + ex, ex); - } - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - return metaAccess.lookupJavaField(reflectionField); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java deleted file mode 100644 index e62de99f366..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotJVMCIRuntime.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @library /test/lib / - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.common - * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * /compiler/jvmci/jdk.vm.ci.code.test/src - * @library /test/lib - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.hotspot.test.TestHotSpotJVMCIRuntime - */ - -package jdk.vm.ci.hotspot.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.function.Predicate; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaType; - -import jdk.test.lib.Platform; - -public class TestHotSpotJVMCIRuntime { - - @Test - public void writeDebugOutputTest() { - HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); - - expectWriteDebugOutputFailure(runtime, null, 0, 0, true, true, NullPointerException.class); - expectWriteDebugOutputFailure(runtime, null, 0, 0, true, false, -1); - - byte[] emptyOutput = {}; - byte[] nonEmptyOutput = String.format("non-empty output%n").getBytes(); - - for (boolean canThrow : new boolean[]{true, false}) { - for (byte[] output : new byte[][]{emptyOutput, nonEmptyOutput}) { - for (int offset = 0; offset < output.length; offset++) { - int length = output.length - offset; - runtime.writeDebugOutput(output, offset, length, true, canThrow); - } - - Object expect = canThrow ? IndexOutOfBoundsException.class : -2; - expectWriteDebugOutputFailure(runtime, output, output.length + 1, 0, true, canThrow, expect); - expectWriteDebugOutputFailure(runtime, output, 0, output.length + 1, true, canThrow, expect); - expectWriteDebugOutputFailure(runtime, output, -1, 0, true, canThrow, expect); - expectWriteDebugOutputFailure(runtime, output, 0, -1, true, canThrow, expect); - } - } - } - - private static void expectWriteDebugOutputFailure(HotSpotJVMCIRuntime runtime, byte[] bytes, int offset, int length, boolean flush, boolean canThrow, Object expect) { - try { - int result = runtime.writeDebugOutput(bytes, offset, length, flush, canThrow); - if (expect instanceof Integer) { - Assert.assertEquals((int) expect, result); - } else { - Assert.fail("expected " + expect + ", got " + result + " for bytes == " + Arrays.toString(bytes)); - } - } catch (Exception e) { - if (expect instanceof Integer) { - Assert.fail("expected " + expect + ", got " + e + " for bytes == " + Arrays.toString(bytes)); - } else { - Assert.assertTrue(((Class) expect).isInstance(e), e.toString()); - } - } - } - - @Test - public void getIntrinsificationTrustPredicateTest() throws Exception { - HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); - MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess(); - Predicate predicate = runtime.getIntrinsificationTrustPredicate(HotSpotJVMCIRuntime.class); - List> classes = new ArrayList<>(Arrays.asList( - Object.class, - String.class, - Class.class, - HotSpotJVMCIRuntime.class, - VirtualObjectLayoutTest.class, - TestHotSpotJVMCIRuntime.class)); - try { - classes.add(Class.forName("com.sun.crypto.provider.AES_Crypt")); - classes.add(Class.forName("com.sun.crypto.provider.CipherBlockChaining")); - } catch (ClassNotFoundException e) { - // Extension classes not available - } - ClassLoader jvmciLoader = HotSpotJVMCIRuntime.class.getClassLoader(); - ClassLoader platformLoader = ClassLoader.getPlatformClassLoader(); - for (Class c : classes) { - ClassLoader cl = c.getClassLoader(); - boolean expected = cl == null || cl == jvmciLoader || cl == platformLoader; - boolean actual = predicate.test(metaAccess.lookupJavaType(c)); - Assert.assertEquals(expected, actual, c + ": cl=" + cl); - } - } - - /** - * Test program that calls into the VM and expects an {@code OutOfMemoryError} to be - * raised when {@code test.jvmci.forceEnomemOnLibjvmciInit == true}. - * - * For example: - *
-     * Exception in thread "main" java.lang.OutOfMemoryError: JNI_ENOMEM creating or attaching to libjvmci
-     *    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVM.attachCurrentThread(Native Method)
-     *    at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.attachCurrentThread(HotSpotJVMCIRuntime.java:1385)
-     *    at jdk.vm.ci.hotspot.test.TestHotSpotJVMCIRuntime$JNIEnomemVMCall.main(TestHotSpotJVMCIRuntime.java:133)
-     * 
- */ - public static class JNIEnomemVMCall { - public static void main(String[] args) { - String name = args[0]; - HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); - MetaAccessProvider metaAccess = runtime.getHostJVMCIBackend().getMetaAccess(); - if (name.equals("translate")) { - runtime.translate("object"); - } else if (name.equals("attachCurrentThread")) { - runtime.attachCurrentThread(false, null); - } else if (name.equals("registerNativeMethods")) { - runtime.registerNativeMethods(JNIEnomemVMCall.class); - } else { - throw new InternalError("Unknown method: " + name); - } - } - } - - @Test - public void jniEnomemTest() throws Exception { - if (!Platform.isDebugBuild()) { - // The test.jvmci.forceEnomemOnLibjvmciInit property is only - // read in a debug VM. - return; - } - String[] names = {"translate", "attachCurrentThread", "registerNativeMethods"}; - for (String name : names) { - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EnableJVMCI", - "-XX:-UseJVMCICompiler", - "-XX:+UseJVMCINativeLibrary", - "-Dtest.jvmci.forceEnomemOnLibjvmciInit=true", - "--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED", - "--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED", - "--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED", - "-Xbootclasspath/a:.", - JNIEnomemVMCall.class.getName(), name); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("java.lang.OutOfMemoryError: JNI_ENOMEM creating or attaching to libjvmci"); - output.shouldNotHaveExitValue(0); - } - } - - @Test - public void lookupTypeTest() throws Exception { - // This is tested by compiler/jvmci/compilerToVM/LookupTypeTest.java - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotResolvedJavaField.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotResolvedJavaField.java deleted file mode 100644 index 489f9dcf97d..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotResolvedJavaField.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * @library /compiler/jvmci/common/patches - * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldHelper - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.hotspot.test.TestHotSpotResolvedJavaField - */ - -package jdk.vm.ci.hotspot.test; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldHelper; -import jdk.vm.ci.meta.ResolvedJavaField; - -public class TestHotSpotResolvedJavaField { - - @Test - public void testIndex() { - int max = Character.MAX_VALUE; - int[] valid = {0, 1, max - 1, max}; - for (int index : valid) { - ResolvedJavaField field = HotSpotResolvedJavaFieldHelper.createField(null, null, 0, 0, 0, index); - Assert.assertEquals(HotSpotResolvedJavaFieldHelper.getIndex(field), index); - } - } - - @Test - public void testOffset() { - int min = Integer.MIN_VALUE; - int max = Integer.MAX_VALUE; - int[] valid = {min, min + 1, -2, 0, 1, max - 1, max}; - for (int offset : valid) { - ResolvedJavaField field = HotSpotResolvedJavaFieldHelper.createField(null, null, offset, 0, 0, 0); - Assert.assertEquals(field.getOffset(), offset); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java deleted file mode 100644 index dfd0ad5b15b..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/TestHotSpotSpeculationLog.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.hotspot.test.TestHotSpotSpeculationLog - */ - -package jdk.vm.ci.hotspot.test; - -import java.util.function.Supplier; - -import org.testng.Assert; -import org.testng.SkipException; -import org.testng.annotations.Test; - -import jdk.vm.ci.hotspot.HotSpotSpeculationLog; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.SpeculationLog.SpeculationReasonEncoding; -import jdk.vm.ci.runtime.JVMCI; - -public class TestHotSpotSpeculationLog { - - static final class DummyReason implements SpeculationLog.SpeculationReason { - - final String name; - private SpeculationReasonEncoding cachedEncoding; - - DummyReason(String name) { - this.name = name; - } - - @Override - public SpeculationReasonEncoding encode(Supplier encodingSupplier) { - SpeculationReasonEncoding encoding = cachedEncoding; - if (encoding == null) { - encoding = encodingSupplier.get(); - encoding.addString(name); - } - cachedEncoding = encoding; - return encoding; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof DummyReason) { - DummyReason that = (DummyReason) obj; - return this.name.equals(that.name); - } - return super.equals(obj); - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - return name; - } - } - - @Test - public synchronized void testFailedSpeculations() { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - HotSpotSpeculationLog log = new HotSpotSpeculationLog(); - DummyReason reason1 = new DummyReason("dummy1"); - String longName = new String(new char[2000]).replace('\0', 'X'); - DummyReason reason2 = new DummyReason(longName); - Assert.assertTrue(log.maySpeculate(reason1)); - Assert.assertTrue(log.maySpeculate(reason2)); - - SpeculationLog.Speculation s1 = log.speculate(reason1); - SpeculationLog.Speculation s2 = log.speculate(reason2); - - JavaConstant encodedS1 = metaAccess.encodeSpeculation(s1); - JavaConstant encodedS2 = metaAccess.encodeSpeculation(s2); - Assert.assertEquals(JavaKind.Long, encodedS1.getJavaKind()); - Assert.assertEquals(JavaKind.Long, encodedS2.getJavaKind()); - - boolean added = log.addFailedSpeculation(s1); - if (!added) { - throw new SkipException("log.addFailedSpeculation(s1) is false"); - } - - log.collectFailedSpeculations(); - Assert.assertFalse(log.maySpeculate(reason1)); - Assert.assertTrue(log.maySpeculate(reason2)); - - added = log.addFailedSpeculation(s2); - if (!added) { - throw new SkipException("log.addFailedSpeculation(s2) is false"); - } - log.collectFailedSpeculations(); - Assert.assertFalse(log.maySpeculate(reason1)); - Assert.assertFalse(log.maySpeculate(reason2), log.toString()); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/UnboxPrimitiveDataProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/UnboxPrimitiveDataProvider.java deleted file mode 100644 index de40dbfa003..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/UnboxPrimitiveDataProvider.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.vm.ci.hotspot.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.testng.annotations.DataProvider; - -import java.util.LinkedList; - -import static jdk.vm.ci.hotspot.test.TestHelper.CONSTANT_REFLECTION_PROVIDER; -import static jdk.vm.ci.hotspot.test.TestHelper.DUMMY_CLASS_INSTANCE; - -public class UnboxPrimitiveDataProvider { - - @DataProvider(name = "unboxPrimitiveDataProvider") - public static Object[][] unboxPrimitiveDataProvider() { - LinkedList cfgSet = new LinkedList<>(); - // Testing boolean - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - true), JavaConstant.forBoolean(true)}); - cfgSet.add(new Object[]{JavaConstant.forBoolean(true), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(false), - JavaConstant.forBoolean(false)}); - cfgSet.add(new Object[]{JavaConstant.forBoolean(false), null}); - for (byte number : new byte[]{-128, 0, 1, 127}) { - // Testing boxed primitives - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Byte.valueOf(number)), - JavaConstant.forByte(number)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Short.valueOf(number)), - JavaConstant.forShort(number)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Integer.valueOf(number)), - JavaConstant.forInt(number)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Long.valueOf(number)), - JavaConstant.forLong(number)}); - if (number >= 0) { - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - Character.valueOf((char) number)), - JavaConstant.forChar((char) number)}); - } - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - Float.valueOf(number * 1.1f)), - JavaConstant.forFloat(number * 1.1f)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - Double.valueOf(number * 1.1)), - JavaConstant.forDouble(number * 1.1)}); - // Testing non-boxed primitives (should result in returning of "null") - cfgSet.add(new Object[]{JavaConstant.forByte(number), null}); - cfgSet.add(new Object[]{JavaConstant.forShort(number), null}); - cfgSet.add(new Object[]{JavaConstant.forInt(number), null}); - cfgSet.add(new Object[]{JavaConstant.forLong(number), null}); - cfgSet.add(new Object[]{JavaConstant.forChar((char) number), null}); - cfgSet.add(new Object[]{JavaConstant.forFloat(number), null}); - cfgSet.add(new Object[]{JavaConstant.forDouble(number), null}); - } - // Testing boxed primitives with max values - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Short.MAX_VALUE), - JavaConstant.forShort(Short.MAX_VALUE)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Integer.MAX_VALUE), - JavaConstant.forInt(Integer.MAX_VALUE)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Long.MAX_VALUE), - JavaConstant.forLong(Long.MAX_VALUE)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Character.MAX_VALUE), - JavaConstant.forChar(Character.MAX_VALUE)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Float.MAX_VALUE), - JavaConstant.forFloat(Float.MAX_VALUE)}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject(Double.MAX_VALUE), - JavaConstant.forDouble(Double.MAX_VALUE)}); - // Non-primitives testing - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.objectField), null}); - cfgSet.add(new Object[]{CONSTANT_REFLECTION_PROVIDER.forObject( - DUMMY_CLASS_INSTANCE.booleanArrayWithValues), - null}); - // Null testing - cfgSet.add(new Object[]{JavaConstant.NULL_POINTER, null}); - cfgSet.add(new Object[]{null, null}); - return cfgSet.toArray(new Object[0][0]); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java deleted file mode 100644 index 69efb536e8a..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/VirtualObjectLayoutTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.common - * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * /compiler/jvmci/jdk.vm.ci.code.test/src - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.hotspot.test.VirtualObjectLayoutTest - */ - -package jdk.vm.ci.hotspot.test; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import jdk.vm.ci.code.VirtualObject; -import jdk.vm.ci.code.test.VirtualObjectTestBase; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.HotSpotCompiledCode; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.ResolvedJavaType; - -public class VirtualObjectLayoutTest extends VirtualObjectTestBase { - - @Override - protected void test(ResolvedJavaType klass, JavaValue[] values, JavaKind[] kinds, boolean error) { - // Verify that the layout checking will correctly report errors - VirtualObject virtual = VirtualObject.get(klass, 0); - virtual.setValues(values, kinds); - try { - HotSpotCompiledCode.verifyVirtualObject(virtual); - } catch (JVMCIError e) { - Assert.assertTrue(error, "Unexpected error verifying " + virtual); - return; - } - Assert.assertFalse(error, "Expected error but passed verifying " + virtual); - } - - @Test - public void testFormat() { - testBase(); - } - - @Test - public void testByteArrayFormat() { - testByteArray(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantPoolTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantPoolTest.java deleted file mode 100644 index b811d8753cb..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantPoolTest.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:open - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.common - * @library /compiler/jvmci/jdk.vm.ci.hotspot.test/src - * /compiler/jvmci/jdk.vm.ci.code.test/src - * @run testng/othervm - * -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler - * jdk.vm.ci.runtime.test.ConstantPoolTest - */ -package jdk.vm.ci.runtime.test; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.invoke.MethodType; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaField; -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.runtime.JVMCI; - -public class ConstantPoolTest { - - static Object cloneByteArray(byte[] arr) { - return arr.clone(); - } - - static Object cloneCharArray(char[] arr) { - return arr.clone(); - } - - static Object cloneShortArray(short[] arr) { - return arr.clone(); - } - - static Object cloneIntArray(int[] arr) { - return arr.clone(); - } - - static Object cloneFloatArray(float[] arr) { - return arr.clone(); - } - - static Object cloneLongArray(long[] arr) { - return arr.clone(); - } - - static Object cloneDoubleArray(double[] arr) { - return arr.clone(); - } - - static Object cloneObjectArray(Object[] arr) { - return arr.clone(); - } - - public static final int ICONST_0 = 3; - public static final int ALOAD_0 = 42; - public static final int ALOAD_1 = 43; - public static final int GETSTATIC = 178; - public static final int INVOKEVIRTUAL = 182; - public static final int INVOKEDYNAMIC = 186; - - public static int beU2(byte[] data, int bci) { - return ((data[bci] & 0xff) << 8) | (data[bci + 1] & 0xff); - } - - public static int beU1(byte[] data, int bci) { - return data[bci] & 0xff; - } - - public static int beS4(byte[] data, int bci) { - return (data[bci] << 24) | ((data[bci + 1] & 0xff) << 16) | ((data[bci + 2] & 0xff) << 8) | (data[bci + 3] & 0xff); - } - - @Test - public void lookupArrayCloneMethodTest() throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - for (ResolvedJavaMethod m : type.getDeclaredMethods()) { - if (m.getName().startsWith("clone")) { - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode, m.toString()); - Assert.assertEquals(5, bytecode.length, m.toString()); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0), m.toString()); - Assert.assertEquals(INVOKEVIRTUAL, beU1(bytecode, 1), m.toString()); - int cpi = beU2(bytecode, 2); - JavaMethod callee = m.getConstantPool().lookupMethod(cpi, INVOKEVIRTUAL); - Assert.assertTrue(callee instanceof ResolvedJavaMethod, callee.toString()); - } - } - } - - static int someStaticField = 1; - static int getStaticField() { - return someStaticField; - } - - @Test - public void lookupFieldTest() throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - - String methodName = "getStaticField"; - Signature methodSig = metaAccess.parseMethodDescriptor("()I"); - ResolvedJavaMethod m = type.findMethod(methodName, methodSig); - Assert.assertNotNull(m); - - // Expected: - // 0: getstatic "someStaticField":"I"; - // 3: ireturn; - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(4, bytecode.length); - Assert.assertEquals(GETSTATIC, beU1(bytecode, 0)); - int rawIndex = beU2(bytecode, 1); - JavaField field = m.getConstantPool().lookupField(rawIndex, m, GETSTATIC); - Assert.assertEquals("someStaticField", field.getName(), "Wrong field name; rawIndex = " + rawIndex + ";"); - } - - static String concatString1(String a, String b) { - return a + b; - } - - static String concatString2(String a, String b) { - return a + b; - } - - // We never call this method, so its indy is never resolved. - static String concatString3_never_call(String a, String b) { - return a + b; - } - - static void invokeHandle(MethodHandle mh) throws Throwable { - mh.invokeExact(0); - } - - static void intFunc(int t) {} - - @Test - public void lookupAppendixTest() throws Throwable { - // We want at least two indy bytecodes -- with a single indy, the rawIndex is -1, - // or 0xffffffff. Even if we load it with the wrong endianness, it will still come - // "correctly" out as -1. - concatString1("aaa", "bbb"); // force the indy to be resolved - concatString2("aaa", "bbb"); // force the indy to be resolved - - MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType mt = MethodType.methodType(void.class, int.class); - MethodHandle mh = lookup.findStatic(ConstantPoolTest.class, "intFunc", mt); - invokeHandle(mh); - - lookupAppendixTest_dynamic("concatString1"); - lookupAppendixTest_dynamic("concatString2"); - lookupAppendixTest_virtual(); - } - - private void lookupAppendixTest_dynamic(String methodName) throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - Signature methodSig = metaAccess.parseMethodDescriptor("(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); - ResolvedJavaMethod m = type.findMethod(methodName, methodSig); - Assert.assertNotNull(m); - - // Expected: - // aload_0; - // aload_1; - // invokedynamic ...StringConcatFactory.makeConcatWithConstants... - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(8, bytecode.length); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0)); - Assert.assertEquals(ALOAD_1, beU1(bytecode, 1)); - Assert.assertEquals(INVOKEDYNAMIC, beU1(bytecode, 2)); - - // Note: internally HotSpot stores the indy index as a native int32, but m.getCode() byte-swaps all such - // indices so they appear to be big-endian. - int rawIndex = beS4(bytecode, 3); - JavaConstant constant = m.getConstantPool().lookupAppendix(rawIndex, INVOKEDYNAMIC); - Assert.assertTrue(constant.toString().startsWith("Object["), "wrong appendix: " + constant); - } - - private void lookupAppendixTest_virtual() throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - Signature methodSig = metaAccess.parseMethodDescriptor("(Ljava/lang/invoke/MethodHandle;)V"); - ResolvedJavaMethod m = type.findMethod("invokeHandle", methodSig); - Assert.assertNotNull(m); - - // Expected - // aload_0 - // iconst_0 - // invokevirtual #rawIndex // Method java/lang/invoke/MethodHandle.invokeExact:(I)V - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(6, bytecode.length); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0)); - Assert.assertEquals(ICONST_0, beU1(bytecode, 1)); - Assert.assertEquals(INVOKEVIRTUAL, beU1(bytecode, 2)); - - int rawIndex = beU2(bytecode, 3); - //System.out.println("rawIndex = " + rawIndex); - JavaConstant constant = m.getConstantPool().lookupAppendix(rawIndex, INVOKEVIRTUAL); - //System.out.println("constant = " + constant); - Assert.assertTrue(constant.toString().startsWith("Object["), "wrong appendix: " + constant); - } - - static void invokeVirtual(Object o) { - o.hashCode(); - } - - @Test - public void lookupMethodTest_dynamic() throws Exception { - concatString1("aaa", "bbb"); // force the indy to be resolved - - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - Signature methodSig = metaAccess.parseMethodDescriptor("(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); - ResolvedJavaMethod m = type.findMethod("concatString1", methodSig); - Assert.assertNotNull(m); - - // Expected: - // aload_0; - // aload_1; - // invokedynamic ...StringConcatFactory.makeConcatWithConstants... - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(8, bytecode.length); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0)); - Assert.assertEquals(ALOAD_1, beU1(bytecode, 1)); - Assert.assertEquals(INVOKEDYNAMIC, beU1(bytecode, 2)); - - // Note: internally HotSpot stores the indy index as a native int32, but m.getCode() byte-swaps all such - // indices so they appear to be big-endian. - int rawIndex = beS4(bytecode, 3); - System.out.println("rawIndex = " + rawIndex); - JavaMethod callee = m.getConstantPool().lookupMethod(rawIndex, INVOKEDYNAMIC, /*caller=*/m); - System.out.println("callee = " + callee); - Assert.assertTrue(callee.toString().equals("HotSpotMethod"), - "wrong method: " + callee); - } - - @Test - public void lookupMethodTest_dynamic_unresolved() throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - Signature methodSig = metaAccess.parseMethodDescriptor("(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); - ResolvedJavaMethod m = type.findMethod("concatString3_never_call", methodSig); - Assert.assertNotNull(m); - - // Expected: - // aload_0; - // aload_1; - // invokedynamic ...StringConcatFactory.makeConcatWithConstants... - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(8, bytecode.length); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0)); - Assert.assertEquals(ALOAD_1, beU1(bytecode, 1)); - Assert.assertEquals(INVOKEDYNAMIC, beU1(bytecode, 2)); - - // Note: internally HotSpot stores the indy index as a native int32, but m.getCode() byte-swaps all such - // indices so they appear to be big-endian. - int rawIndex = beS4(bytecode, 3); - System.out.println("rawIndex = " + rawIndex); - JavaMethod callee = m.getConstantPool().lookupMethod(rawIndex, INVOKEDYNAMIC, /*caller=*/m); - System.out.println("callee = " + callee); - Assert.assertTrue(callee.toString().startsWith("jdk.vm.ci.meta.UnresolvedJavaMethod"), - "wrong method: " + callee); - } - - @Test - public void lookupMethodTest_virtual() throws Exception { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType type = metaAccess.lookupJavaType(ConstantPoolTest.class); - Signature methodSig = metaAccess.parseMethodDescriptor("(Ljava/lang/Object;)V"); - ResolvedJavaMethod m = type.findMethod("invokeVirtual", methodSig); - Assert.assertNotNull(m); - - // Expected - // 0: aload_0 - // 1: invokevirtual #rawIndex // Method Method java/lang/Object.hashCode:()I - byte[] bytecode = m.getCode(); - Assert.assertNotNull(bytecode); - Assert.assertEquals(ALOAD_0, beU1(bytecode, 0)); - Assert.assertEquals(INVOKEVIRTUAL, beU1(bytecode, 1)); - int rawIndex = beU2(bytecode, 2); - System.out.println("rawIndex = " + rawIndex); - JavaMethod callee = m.getConstantPool().lookupMethod(rawIndex, INVOKEVIRTUAL, /*caller=*/m); - System.out.println("callee = " + callee); - Assert.assertTrue(callee.toString().equals("HotSpotMethod"), - "wrong method: " + callee); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java deleted file mode 100644 index e284591c0fc..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.ConstantTest - */ -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.JavaConstant; -import org.junit.Assert; -import org.junit.Test; - -public class ConstantTest extends FieldUniverse { - - @Test - public void testNegativeZero() { - Assert.assertTrue("Constant for 0.0f must be different from -0.0f", JavaConstant.FLOAT_0 != JavaConstant.forFloat(-0.0F)); - Assert.assertTrue("Constant for 0.0d must be different from -0.0d", JavaConstant.DOUBLE_0 != JavaConstant.forDouble(-0.0d)); - } - - @Test - public void testNullIsNull() { - Assert.assertTrue(JavaConstant.NULL_POINTER.isNull()); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/FieldUniverse.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/FieldUniverse.java deleted file mode 100644 index dcc380d158f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/FieldUniverse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.ResolvedJavaField; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -/** - * Context for field related tests. - */ -public class FieldUniverse extends TypeUniverse { - - public static final Map fields = new HashMap<>(); - - { - for (Class c : classes) { - for (Field f : c.getDeclaredFields()) { - ResolvedJavaField field = metaAccess.lookupJavaField(f); - fields.put(f, field); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/MethodUniverse.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/MethodUniverse.java deleted file mode 100644 index 92366580a91..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/MethodUniverse.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.ResolvedJavaMethod; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -/** - * Context for method related tests. - */ -public class MethodUniverse extends TypeUniverse { - - public static final Map methods = new HashMap<>(); - public static final Map, ResolvedJavaMethod> constructors = new HashMap<>(); - - { - for (Class c : classes) { - for (Method m : c.getDeclaredMethods()) { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m); - methods.put(m, method); - } - for (Constructor m : c.getDeclaredConstructors()) { - constructors.put(m, metaAccess.lookupJavaMethod(m)); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/NameAndSignature.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/NameAndSignature.java deleted file mode 100644 index 3bd14c7e206..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/NameAndSignature.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; -import jdk.vm.ci.runtime.JVMCI; - -import java.lang.reflect.Method; -import java.util.Arrays; - -class NameAndSignature { - - public static final MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - - final String name; - final Class returnType; - final Class[] parameterTypes; - - NameAndSignature(Method m) { - this.name = m.getName(); - this.returnType = m.getReturnType(); - this.parameterTypes = m.getParameterTypes(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof NameAndSignature) { - NameAndSignature s = (NameAndSignature) obj; - return s.returnType == returnType && name.equals(s.name) && Arrays.equals(s.parameterTypes, parameterTypes); - } - return false; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(name + "("); - String sep = ""; - for (Class p : parameterTypes) { - sb.append(sep); - sep = ", "; - sb.append(p.getName()); - } - return sb.append(')').append(returnType.getName()).toString(); - } - - public boolean signatureEquals(ResolvedJavaMethod m) { - Signature s = m.getSignature(); - ResolvedJavaType declaringClass = m.getDeclaringClass(); - if (!s.getReturnType(declaringClass).resolve(declaringClass).equals(metaAccess.lookupJavaType(returnType))) { - return false; - } - if (s.getParameterCount(false) != parameterTypes.length) { - return false; - } - for (int i = 0; i < parameterTypes.length; i++) { - if (!s.getParameterType(i, declaringClass).resolve(declaringClass).equals(metaAccess.lookupJavaType(parameterTypes[i]))) { - return false; - } - } - return true; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java deleted file mode 100644 index a6f58fd1375..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @requires vm.jvmti - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.attach - * java.base/jdk.internal.misc - * @run junit/othervm/timeout=480 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -Djdk.attach.allowAttachSelf jdk.vm.ci.runtime.test.RedefineClassTest - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.ResolvedJavaMethod; -import org.junit.Assert; -import org.junit.Test; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.instrument.ClassFileTransformer; -import java.lang.instrument.IllegalClassFormatException; -import java.lang.instrument.Instrumentation; -import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.ProtectionDomain; -import java.util.Arrays; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; - -import static org.junit.Assume.assumeTrue; - -/** - * Tests that {@link ResolvedJavaMethod}s are safe in the context of class redefinition being used - * to redefine the method to which they refer. - */ -public class RedefineClassTest extends TypeUniverse { - - static class Foo { - public static Object getName() { - return "foo"; - } - } - - @Test - public void test() throws Throwable { - - Method fooMethod = Foo.class.getDeclaredMethod("getName"); - - ResolvedJavaMethod foo1 = metaAccess.lookupJavaMethod(fooMethod); - ResolvedJavaMethod foo2 = metaAccess.lookupJavaMethod(fooMethod); - - String foo1Code = Arrays.toString(foo1.getCode()); - String foo2Code = Arrays.toString(foo2.getCode()); - - Assert.assertEquals("foo", Foo.getName()); - - redefineFoo(); - System.gc(); - - // Make sure the transformation happened - Assert.assertEquals("bar", Foo.getName()); - - Assert.assertEquals(foo1Code, Arrays.toString(foo1.getCode())); - Assert.assertEquals(foo2Code, Arrays.toString(foo1.getCode())); - } - - /** - * Adds the class file bytes for a given class to a JAR stream. - */ - static void add(JarOutputStream jar, Class c) throws IOException { - String name = c.getName(); - String classAsPath = name.replace('.', '/') + ".class"; - jar.putNextEntry(new JarEntry(classAsPath)); - - InputStream stream = c.getClassLoader().getResourceAsStream(classAsPath); - - int nRead; - byte[] buf = new byte[1024]; - while ((nRead = stream.read(buf, 0, buf.length)) != -1) { - jar.write(buf, 0, nRead); - } - - jar.closeEntry(); - } - - protected void redefineFoo() throws Exception { - Manifest manifest = new Manifest(); - manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); - Attributes mainAttrs = manifest.getMainAttributes(); - mainAttrs.putValue("Agent-Class", FooAgent.class.getName()); - mainAttrs.putValue("Can-Redefine-Classes", "true"); - mainAttrs.putValue("Can-Retransform-Classes", "true"); - - Path jar = Files.createTempFile("myagent", ".jar"); - try { - JarOutputStream jarStream = new JarOutputStream(new FileOutputStream(jar.toFile()), manifest); - add(jarStream, FooAgent.class); - add(jarStream, FooTransformer.class); - jarStream.close(); - - loadAgent(jar); - } finally { - Files.deleteIfExists(jar); - } - } - - public static void loadAgent(Path agent) throws Exception { - String pid = Long.toString(ProcessHandle.current().pid()); - ClassLoader cl = ClassLoader.getSystemClassLoader(); - Class c = Class.forName("com.sun.tools.attach.VirtualMachine", true, cl); - Method attach = c.getDeclaredMethod("attach", String.class); - Method loadAgent = c.getDeclaredMethod("loadAgent", String.class, String.class); - Method detach = c.getDeclaredMethod("detach"); - Object vm = attach.invoke(null, pid); - loadAgent.invoke(vm, agent.toString(), ""); - detach.invoke(vm); - } - - public static class FooAgent { - - public static void agentmain(@SuppressWarnings("unused") String args, Instrumentation inst) throws Exception { - if (inst.isRedefineClassesSupported() && inst.isRetransformClassesSupported()) { - inst.addTransformer(new FooTransformer(), true); - Class[] allClasses = inst.getAllLoadedClasses(); - for (int i = 0; i < allClasses.length; i++) { - Class c = allClasses[i]; - if (c == Foo.class) { - inst.retransformClasses(new Class[]{c}); - } - } - } - } - } - - /** - * This transformer replaces the first instance of the constant "foo" in the class file for - * {@link Foo} with "bar". - */ - static class FooTransformer implements ClassFileTransformer { - - @Override - public byte[] transform(ClassLoader cl, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { - if (Foo.class.equals(classBeingRedefined)) { - String cf = new String(classfileBuffer); - int i = cf.indexOf("foo"); - Assert.assertTrue("cannot find \"foo\" constant in " + Foo.class.getSimpleName() + "'s class file", i > 0); - classfileBuffer[i] = 'b'; - classfileBuffer[i + 1] = 'a'; - classfileBuffer[i + 2] = 'r'; - } - return classfileBuffer; - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java deleted file mode 100644 index 52d5ae2cc0e..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.ResolvedJavaTypeResolveConcreteMethodTest - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertNotNull; - -public class ResolvedJavaTypeResolveConcreteMethodTest { - public final MetaAccessProvider metaAccess; - - public ResolvedJavaTypeResolveConcreteMethodTest() { - metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - } - - protected abstract static class A { - @SuppressWarnings("unused") - private void priv() { - } - - public void v1() { - } - - public void v2() { - } - - public abstract void abs(); - } - - protected static class B extends A implements I { - @Override - public void i() { - } - - @Override - public void v2() { - } - - @Override - public void abs() { - - } - } - - protected static class C extends B { - @Override - public void d() { - } - } - - protected abstract static class D extends A { - - } - - protected static class E extends D { - @Override - public void abs() { - } - } - - protected interface I { - void i(); - - default void d() { - } - } - - @Test - public void testDefaultMethod() { - ResolvedJavaType i = getType(I.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod di = getMethod(i, "d"); - ResolvedJavaMethod dc = getMethod(c, "d"); - - assertEquals(null, i.resolveConcreteMethod(di, c)); - assertEquals(di, b.resolveConcreteMethod(di, c)); - assertEquals(dc, c.resolveConcreteMethod(di, c)); - } - - @Test - public void testPrivateMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod priv = getMethod(a, "priv"); - - // nestmates have access to private methods - assertNotNull(a.resolveConcreteMethod(priv, c)); - assertNotNull(b.resolveConcreteMethod(priv, c)); - } - - @Test - public void testAbstractMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaType d = getType(D.class); - ResolvedJavaType e = getType(E.class); - ResolvedJavaMethod absa = getMethod(a, "abs"); - ResolvedJavaMethod absb = getMethod(b, "abs"); - ResolvedJavaMethod abse = getMethod(e, "abs"); - - assertNull(a.resolveConcreteMethod(absa, c)); - assertNull(d.resolveConcreteMethod(absa, c)); - - assertEquals(absb, b.resolveConcreteMethod(absa, c)); - assertEquals(absb, b.resolveConcreteMethod(absb, c)); - assertEquals(absb, c.resolveConcreteMethod(absa, c)); - assertEquals(absb, c.resolveConcreteMethod(absb, c)); - assertEquals(abse, e.resolveConcreteMethod(absa, c)); - assertNull(e.resolveConcreteMethod(absb, c)); - assertEquals(abse, e.resolveConcreteMethod(abse, c)); - } - - @Test - public void testVirtualMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod v1a = getMethod(a, "v1"); - ResolvedJavaMethod v2a = getMethod(a, "v2"); - ResolvedJavaMethod v2b = getMethod(b, "v2"); - - assertEquals(v1a, a.resolveConcreteMethod(v1a, c)); - assertEquals(v1a, b.resolveConcreteMethod(v1a, c)); - assertEquals(v1a, c.resolveConcreteMethod(v1a, c)); - assertEquals(v2a, a.resolveConcreteMethod(v2a, c)); - assertEquals(v2b, b.resolveConcreteMethod(v2a, c)); - assertEquals(v2b, b.resolveConcreteMethod(v2b, c)); - assertEquals(v2b, c.resolveConcreteMethod(v2a, c)); - assertEquals(v2b, c.resolveConcreteMethod(v2b, c)); - - } - - static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { - for (ResolvedJavaMethod method : type.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - return method; - } - } - throw new IllegalArgumentException(); - } - - protected ResolvedJavaType getType(Class clazz) { - ResolvedJavaType type = metaAccess.lookupJavaType(clazz); - type.initialize(); - return type; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java deleted file mode 100644 index 3ff60054d56..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.ResolvedJavaTypeResolveMethodTest - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertNotNull; - -public class ResolvedJavaTypeResolveMethodTest { - public final MetaAccessProvider metaAccess; - - public ResolvedJavaTypeResolveMethodTest() { - metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - } - - protected abstract static class A { - @SuppressWarnings("unused") - private void priv() { - } - - public void v1() { - } - - public void v2() { - } - - public abstract void abs(); - } - - protected static class B extends A implements I { - @Override - public void i() { - } - - @Override - public void v2() { - } - - @Override - public void abs() { - - } - } - - protected static class C extends B { - @Override - public void d() { - } - } - - protected abstract static class D extends A { - - } - - protected static class E extends D { - @Override - public void abs() { - } - } - - protected interface I { - void i(); - - default void d() { - } - } - - @Test - public void testDefaultMethod() { - ResolvedJavaType i = getType(I.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod di = getMethod(i, "d"); - ResolvedJavaMethod dc = getMethod(c, "d"); - - assertEquals(null, i.resolveMethod(di, c)); - assertEquals(di, b.resolveMethod(di, c)); - assertEquals(dc, c.resolveMethod(di, c)); - } - - @Test - public void testPrivateMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod priv = getMethod(a, "priv"); - - // nestmates have access to private methods - assertNotNull(a.resolveMethod(priv, c)); - assertNotNull(b.resolveMethod(priv, c)); - } - - @Test - public void testAbstractMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaType d = getType(D.class); - ResolvedJavaType e = getType(E.class); - ResolvedJavaMethod absa = getMethod(a, "abs"); - ResolvedJavaMethod absb = getMethod(b, "abs"); - ResolvedJavaMethod abse = getMethod(e, "abs"); - - assertEquals(absa, a.resolveMethod(absa, c)); - assertEquals(absa, d.resolveMethod(absa, c)); - - assertEquals(absb, b.resolveMethod(absa, c)); - assertEquals(absb, b.resolveMethod(absb, c)); - assertEquals(absb, c.resolveMethod(absa, c)); - assertEquals(absb, c.resolveMethod(absb, c)); - assertEquals(abse, e.resolveMethod(absa, c)); - assertNull(e.resolveMethod(absb, c)); - assertEquals(abse, e.resolveMethod(abse, c)); - } - - @Test - public void testVirtualMethod() { - ResolvedJavaType a = getType(A.class); - ResolvedJavaType b = getType(B.class); - ResolvedJavaType c = getType(C.class); - ResolvedJavaMethod v1a = getMethod(a, "v1"); - ResolvedJavaMethod v2a = getMethod(a, "v2"); - ResolvedJavaMethod v2b = getMethod(b, "v2"); - - assertEquals(v1a, a.resolveMethod(v1a, c)); - assertEquals(v1a, b.resolveMethod(v1a, c)); - assertEquals(v1a, c.resolveMethod(v1a, c)); - assertEquals(v2a, a.resolveMethod(v2a, c)); - assertEquals(v2b, b.resolveMethod(v2a, c)); - assertEquals(v2b, b.resolveMethod(v2b, c)); - assertEquals(v2b, c.resolveMethod(v2a, c)); - assertEquals(v2b, c.resolveMethod(v2b, c)); - - } - - static class ClassType { - } - - interface InterfaceType { - } - - @Test - public void testCloneAccessibility() { - /* - * The resolution machinery for clone on arrays has some hacks in that show up in odd places - * so make sure that resolveMethod works as expected. - */ - ResolvedJavaType interfaceType = getType(InterfaceType.class); - ResolvedJavaType classType = getType(ClassType.class); - ResolvedJavaType arrayType = getType(double[].class); - ResolvedJavaMethod cloneMethod = getMethod(getType(Object.class), "clone"); - assertEquals("Can't resolve clone for class", cloneMethod, arrayType.resolveMethod(cloneMethod, classType)); - assertEquals("Can't resolve clone for interface", cloneMethod, arrayType.resolveMethod(cloneMethod, interfaceType)); - } - - static ResolvedJavaMethod getMethod(ResolvedJavaType type, String methodName) { - for (ResolvedJavaMethod method : type.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - return method; - } - } - throw new IllegalArgumentException(); - } - - protected ResolvedJavaType getType(Class clazz) { - ResolvedJavaType type = metaAccess.lookupJavaType(clazz); - type.initialize(); - return type; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestBytecodeFrame.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestBytecodeFrame.java deleted file mode 100644 index 2e86a386624..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestBytecodeFrame.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestBytecodeFrame - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaValue; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import org.junit.Test; - -import java.util.Map; -import java.util.Iterator; - -import org.junit.Assert; - -public class TestBytecodeFrame extends MethodUniverse { - - private static void assertEquals(BytecodeFrame f1, BytecodeFrame f2) { - Assert.assertEquals(f1, f2); - Assert.assertEquals(f1.hashCode(), f2.hashCode()); - } - - private static void assertNotEquals(BytecodeFrame f1, BytecodeFrame f2) { - Assert.assertNotEquals(f1, f2); - Assert.assertNotEquals(f1.hashCode(), f2.hashCode()); - } - - /** - * Tests the {@link BytecodeFrame#equals} and {@link BytecodeFrame#hashCode}. - */ - @Test - public void equalsAndHashcodeTest() { - Iterator iter = methods.values().iterator(); - ResolvedJavaMethod m1 = iter.next(); - ResolvedJavaMethod m2 = iter.next(); - ResolvedJavaMethod m3 = iter.next(); - - JavaValue[] values = { - JavaConstant.INT_0, - JavaConstant.INT_1, - JavaConstant.INT_2, - JavaConstant.NULL_POINTER, - }; - JavaKind[] slotKinds = { - JavaKind.Int, - JavaKind.Int, - JavaKind.Int, - JavaKind.Object, - }; - JavaValue[] values2 = { - JavaConstant.INT_1, - JavaConstant.INT_2, - JavaConstant.NULL_POINTER, - JavaConstant.INT_0, - }; - JavaKind[] slotKinds2 = { - JavaKind.Int, - JavaKind.Int, - JavaKind.Object, - JavaKind.Int, - }; - - // The BytecodeFrame objects below will not all pass BytecodeFrame.verifyInvariants - // but that's fine for simply testing equals and hashCode. - BytecodeFrame caller = new BytecodeFrame(null, m3, 0, false, true, values, slotKinds, 1, 1, 0); - BytecodeFrame f1 = new BytecodeFrame(caller, m1, 0, false, true, values, slotKinds, 1, 1, 0); - // Differing field - assertNotEquals(f1, new BytecodeFrame(caller, m2, 0, false, true, values, slotKinds, 1, 1, 0)); // method - assertNotEquals(f1, new BytecodeFrame(caller, m1, 1, false, true, values, slotKinds, 1, 1, 0)); // bci - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, true, true, values, slotKinds, 1, 1, 0)); // rethrowException - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, false, values, slotKinds, 1, 1, 0)); // duringCall - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, true, values2, slotKinds, 1, 1, 0)); // values - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, true, values, slotKinds2, 1, 1, 0)); // slotKinds - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, false, values, slotKinds, 2, 1, 0)); // numLocals - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, false, values, slotKinds, 1, 2, 0)); // numStack - assertNotEquals(f1, new BytecodeFrame(caller, m1, 0, false, false, values, slotKinds, 1, 1, 1)); // numLocks - assertEquals(f1, f1); - - BytecodeFrame f2 = new BytecodeFrame(caller, m1, 0, false, true, values, slotKinds, 1, 1, 0); - assertEquals(f1, f2); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java deleted file mode 100644 index 128430b1902..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestConstantReflectionProvider - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import org.junit.Test; - -import java.lang.reflect.Array; -import java.util.List; - -import static org.junit.Assert.*; - -/** - * Tests for {@link ConstantReflectionProvider}. It assumes an implementation of the interface that - * actually returns non-null results for access operations that are possible, i.e., the tests will - * fail for an implementation that spuriously returns null (which is allowed by the specification). - */ -public class TestConstantReflectionProvider extends TypeUniverse { - - @Test - public void constantEqualsTest() { - for (ConstantValue c1 : constants()) { - for (ConstantValue c2 : constants()) { - // test symmetry - assertEquals(constantReflection.constantEquals(c1.value, c2.value), constantReflection.constantEquals(c2.value, c1.value)); - if (c1.value.getJavaKind() != JavaKind.Object && c2.value.getJavaKind() != JavaKind.Object) { - assertEquals(c1.value.equals(c2.value), constantReflection.constantEquals(c2.value, c1.value)); - } - } - } - } - - @Test - public void readArrayLengthTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - Integer actual = constantReflection.readArrayLength(c); - if (c.getJavaKind() != JavaKind.Object || c.isNull() || !cv.boxed.getClass().isArray()) { - assertNull(actual); - } else { - assertNotNull(actual); - int actualInt = actual; - assertEquals(Array.getLength(cv.boxed), actualInt); - } - } - } - - static class PrimitiveConstants { - static final long LONG_CONST = 42; - static final int INT_CONST = 66; - static final byte BYTE_CONST = 123; - static final boolean BOOL_CONST = true; - } - - static class BoxedConstants { - static final Long LONG_CONST = 42L; - static final Integer INT_CONST = 66; - static final Byte BYTE_CONST = 123; - static final Boolean BOOL_CONST = true; - } - - @Test - public void boxTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - JavaConstant boxed = constantReflection.boxPrimitive(c); - if (boxed != null && c.getJavaKind().isPrimitive()) { - assertTrue(boxed.getJavaKind().isObject()); - assertFalse(boxed.isNull()); - } - } - - List primitiveConstants = readConstants(PrimitiveConstants.class); - List boxedConstants = readConstants(BoxedConstants.class); - for (int i = 0; i < primitiveConstants.size(); i++) { - ConstantValue prim = primitiveConstants.get(i); - ConstantValue box = boxedConstants.get(i); - assertEquals(box.value, constantReflection.boxPrimitive(prim.value)); - } - - assertNull(constantReflection.boxPrimitive(JavaConstant.NULL_POINTER)); - } - - @Test - public void unboxTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - JavaConstant unboxed = c.isNull() ? null : constantReflection.unboxPrimitive(c); - if (unboxed != null) { - assertFalse(unboxed.getJavaKind().isObject()); - } - } - List primitiveConstants = readConstants(PrimitiveConstants.class); - List boxedConstants = readConstants(BoxedConstants.class); - for (int i = 0; i < primitiveConstants.size(); i++) { - ConstantValue prim = primitiveConstants.get(i); - ConstantValue box = boxedConstants.get(i); - assert prim.getSimpleName().equals(box.getSimpleName()); - assertEquals(prim.value, constantReflection.unboxPrimitive(box.value)); - } - - assertNull(constantReflection.unboxPrimitive(JavaConstant.NULL_POINTER)); - } - - static class ArrayConstants { - static final byte[] BYTE_ARRAY_CONST = new byte[]{0}; - static final Object[] OBJECT_ARRAY_CONST = new Object[]{null}; - } - - @Test - public void readOnePastLastArrayElementTest() { - for (ConstantValue cv : readConstants(ArrayConstants.class)) { - if (cv.boxed != null && cv.boxed.getClass().isArray()) { - JavaKind kind = metaAccess.lookupJavaType(cv.value).getComponentType().getJavaKind(); - long offset = metaAccess.getArrayBaseOffset(kind) + (long) metaAccess.getArrayIndexScale(kind) * Array.getLength(cv.boxed); - // read array[array.length] - assertThrows(IllegalArgumentException.class, () -> { - if (kind == JavaKind.Object) { - constantReflection.getMemoryAccessProvider().readObjectConstant(cv.value, offset); - } else { - constantReflection.getMemoryAccessProvider().readPrimitiveConstant(kind, cv.value, offset, kind.getBitCount()); - } - }); - } - } - } - - static class IntArrayConstants { - static final int[] INT_ARRAY_CONST = new int[]{0}; - } - - @Test - public void readPartiallyOutOfBoundsTest() { - for (ConstantValue cv : readConstants(IntArrayConstants.class)) { - JavaKind kind = metaAccess.lookupJavaType(cv.value).getComponentType().getJavaKind(); - long offset = metaAccess.getArrayBaseOffset(kind) + (long) metaAccess.getArrayIndexScale(kind) * (Array.getLength(cv.boxed) - 1); - // read a long from array[array.length - 1], which is partially out of bounds - JavaKind accessKind = JavaKind.Long; - assertThrows(IllegalArgumentException.class, () -> constantReflection.getMemoryAccessProvider().readPrimitiveConstant(accessKind, cv.value, offset, accessKind.getBitCount())); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java deleted file mode 100644 index ea62ab0dd0f..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestJavaField - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.JavaField; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Test; - -import java.lang.reflect.Field; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests for {@link JavaField}. - */ -public class TestJavaField extends FieldUniverse { - - @Test - public void getNameTest() { - for (Map.Entry e : fields.entrySet()) { - String expected = e.getKey().getName(); - String actual = e.getValue().getName(); - assertEquals(expected, actual); - } - } - - @Test - public void getTypeTest() { - for (Map.Entry e : fields.entrySet()) { - // Must resolve types first as a resolved types != unresolved types - ResolvedJavaField rf = e.getValue(); - JavaType expected = metaAccess.lookupJavaType(e.getKey().getType()).resolve(rf.getDeclaringClass()); - JavaType actual = rf.getType().resolve(rf.getDeclaringClass()); - assertEquals(expected, actual); - } - } - - @Test - public void getJavaKindTest() { - for (Map.Entry e : fields.entrySet()) { - JavaKind expected = metaAccess.lookupJavaType(e.getKey().getType()).getJavaKind(); - JavaKind actual = e.getValue().getJavaKind(); - assertEquals(expected, actual); - } - } - - @Test - public void getDeclaringClassTest() { - for (Map.Entry e : fields.entrySet()) { - Class expected = e.getKey().getDeclaringClass(); - ResolvedJavaType actual = e.getValue().getDeclaringClass(); - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java deleted file mode 100644 index 010c739c7d1..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestJavaMethod - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.JavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Test; - -import java.lang.reflect.Method; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Tests for {@link JavaMethod}. - */ -public class TestJavaMethod extends MethodUniverse { - - @Test - public void getNameTest() { - for (Map.Entry e : methods.entrySet()) { - String expected = e.getKey().getName(); - String actual = e.getValue().getName(); - assertEquals(expected, actual); - } - } - - @Test - public void getDeclaringClassTest() { - for (Map.Entry e : methods.entrySet()) { - Class expected = e.getKey().getDeclaringClass(); - ResolvedJavaType actual = e.getValue().getDeclaringClass(); - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } - - @Test - public void getSignatureTest() { - for (Map.Entry e : methods.entrySet()) { - assertTrue(new NameAndSignature(e.getKey()).signatureEquals(e.getValue())); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java deleted file mode 100644 index 27c68c43781..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestJavaType - */ - -package jdk.vm.ci.runtime.test; - -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests for {@link JavaType}. - */ -public class TestJavaType extends TypeUniverse { - - public TestJavaType() { - } - - @Test - public void getJavaKindTest() { - for (Class c : classes) { - JavaType type = metaAccess.lookupJavaType(c); - JavaKind expected = JavaKind.fromJavaClass(c); - JavaKind actual = type.getJavaKind(); - assertEquals(expected, actual); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java deleted file mode 100644 index b40bd2a5114..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestMetaAccessProvider - */ - -package jdk.vm.ci.runtime.test; - -import static jdk.vm.ci.meta.MetaUtil.toInternalName; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.junit.Test; - -import jdk.vm.ci.meta.DeoptimizationAction; -import jdk.vm.ci.meta.DeoptimizationReason; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.Signature; - -/** - * Tests for {@link MetaAccessProvider}. - */ -public class TestMetaAccessProvider extends TypeUniverse { - private static final DeoptimizationAction DEOPT_ACTION = DeoptimizationAction.InvalidateRecompile; - private static final DeoptimizationReason DEOPT_REASON = DeoptimizationReason.Aliasing; - private static final int INT_23BITS_SET = 0x7FFFFF; - private static final int[] DEBUG_IDS = new int[]{0, 1, 42, INT_23BITS_SET}; - private static final int[] VALID_ENCODED_VALUES = new int[]{ - metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[0]).asInt(), - metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[1]).asInt(), - metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[2]).asInt(), - metaAccess.encodeDeoptActionAndReason(DEOPT_ACTION, DEOPT_REASON, DEBUG_IDS[3]).asInt() - }; - - private static boolean isHiddenClass(Class cls) { - if (cls.isHidden()) { - return true; - } - - // Check array of hidden type. - while (cls.getComponentType() != null) { - cls = cls.getComponentType(); - } - if (cls.isHidden()) { - return true; - } - return false; - } - - @Test - public void lookupJavaTypeTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertNotNull(c.toString(), type); - if (!isHiddenClass(c)) { - assertEquals(c.toString(), type.getName(), toInternalName(c.getName())); - assertEquals(c.toString(), type.getName(), toInternalName(type.toJavaName())); - assertEquals(c.toString(), c.getName(), type.toClassName()); - if (!type.isArray()) { - assertEquals(c.toString(), c.getName(), type.toJavaName()); - } - } - } - } - - @Test(expected = IllegalArgumentException.class) - public void lookupJavaTypeNegativeTest() { - metaAccess.lookupJavaType((Class) null); - } - - @Test - public void lookupJavaTypesTest() { - ResolvedJavaType[] result = metaAccess.lookupJavaTypes(classes.toArray(new Class[classes.size()])); - int counter = 0; - for (Class aClass : classes) { - if (!isHiddenClass(aClass)) { - assertEquals("Unexpected javaType: " + result[counter] + " while expecting of class: " + aClass, result[counter].toClassName(), aClass.getName()); - } - counter++; - } - } - - @Test(expected = NullPointerException.class) - public void lookupJavaTypesNegative1Test() { - assertNull("Expected null", metaAccess.lookupJavaTypes(null)); - } - - @Test(expected = IllegalArgumentException.class) - public void lookupJavaTypesNegative2Test() { - ResolvedJavaType[] result = metaAccess.lookupJavaTypes(new Class[]{null, null, null}); - for (ResolvedJavaType aType : result) { - assertNull("Expected null javaType", aType); - } - result = metaAccess.lookupJavaTypes(new Class[]{String.class, String.class}); - assertEquals("Results not equals", result[0].getClass(), result[1].getClass()); - assertEquals("Result is not String.class", result[0].getClass(), String.class); - } - - @Test - public void lookupJavaMethodTest() { - for (Class c : classes) { - for (Method reflect : c.getDeclaredMethods()) { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(reflect); - assertNotNull(method); - assertTrue(method.getDeclaringClass().equals(metaAccess.lookupJavaType(reflect.getDeclaringClass()))); - } - } - } - - @Test(expected = NullPointerException.class) - public void lookupJavaMethodNegativeTest() { - metaAccess.lookupJavaMethod(null); - } - - @Test - public void lookupJavaFieldTest() { - for (Class c : classes) { - for (Field reflect : c.getDeclaredFields()) { - ResolvedJavaField field = metaAccess.lookupJavaField(reflect); - assertNotNull(field); - assertTrue(field.getDeclaringClass().equals(metaAccess.lookupJavaType(reflect.getDeclaringClass()))); - } - } - } - - @Test - public void lookupJavaTypeConstantTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - if (c.getJavaKind() == JavaKind.Object && !c.isNull()) { - Object o = cv.boxed; - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertNotNull(type); - assertTrue(type.equals(metaAccess.lookupJavaType(o.getClass()))); - } else { - assertEquals(metaAccess.lookupJavaType(c), null); - } - } - } - - @Test(expected = NullPointerException.class) - public void lookupJavaTypeConstantNegativeTest() { - metaAccess.lookupJavaType((JavaConstant) null); - } - - @Test - public void getMemorySizeTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - if (c.getJavaKind() == JavaKind.Illegal) { - continue; - } - long memSize = metaAccess.getMemorySize(c); - if (c.isNull()) { - assertEquals("Expected size = 0 for null", memSize, 0L); - } else { - assertTrue("Expected size != 0 for " + cv, memSize != 0L); - } - } - } - - @Test(expected = NullPointerException.class) - public void getMemorySizeNegativeTest() { - metaAccess.getMemorySize(null); - } - - @Test - public void parseMethodDescriptorTest() { - for (String retType : new String[]{"V", "Z", "Ljava/lang/String;"}) { - for (String paramTypes : new String[]{"", "B", - "Ljava/lang/String;", "JLjava/lang/String;", - "Ljava/lang/String;F", - "[Ljava/lang/String;ZBCDFIJLS[ILjava/lang/Object;"}) { - String signature = "(" + paramTypes + ")" + retType; - Signature result = metaAccess.parseMethodDescriptor(signature); - assertEquals("Expected signatures to be equal", result.toMethodDescriptor(), signature); - } - } - } - - @Test(expected = NullPointerException.class) - public void parseMethodDescriptorNegativeNullTest() { - metaAccess.parseMethodDescriptor(null); - } - - @Test(expected = NullPointerException.class) - public void encodeDeoptActionAndReasonNegative1Test() { - metaAccess.encodeDeoptActionAndReason(null, DeoptimizationReason.Aliasing, 0); - - } - - @Test(expected = NullPointerException.class) - public void encodeDeoptActionAndReasonNegative2Test() { - metaAccess.encodeDeoptActionAndReason(DeoptimizationAction.InvalidateRecompile, null, 0); - } - - @Test - public void decodeDeoptReasonTest() { - for (int encoded : VALID_ENCODED_VALUES) { - JavaConstant value = JavaConstant.forInt(encoded); - DeoptimizationReason reason = metaAccess.decodeDeoptReason(value); - assertEquals("Expected equal reasons", reason, DEOPT_REASON); - } - } - - @Test - public void decodeDeoptReasonNegative1Test() { - int encoded = 42; - JavaConstant value = JavaConstant.forInt(encoded); - metaAccess.decodeDeoptReason(value); - } - - @Test(expected = NullPointerException.class) - public void decodeDeoptReasonNegative2Test() { - metaAccess.decodeDeoptReason(null); - } - - @Test - public void decodeDeoptActionTest() { - for (int encoded : VALID_ENCODED_VALUES) { - JavaConstant value = JavaConstant.forInt(encoded); - DeoptimizationAction action = metaAccess.decodeDeoptAction(value); - assertEquals("Expected equal actions", action, DEOPT_ACTION); - } - } - - @Test - public void decodeDeoptActionNegative1Test() { - int encoded = 123456789; - JavaConstant value = JavaConstant.forInt(encoded); - metaAccess.decodeDeoptAction(value); - } - - @Test(expected = NullPointerException.class) - public void decodeDeoptActionNegative2Test() { - metaAccess.decodeDeoptAction(null); - } - - @Test - public void decodeDebugIdTest() { - for (int i = 0; i < VALID_ENCODED_VALUES.length; i++) { - JavaConstant value = JavaConstant.forInt(VALID_ENCODED_VALUES[i]); - assertEquals("Unexpected debugId", metaAccess.decodeDebugId(value), DEBUG_IDS[i]); - } - } - - @Test - public void parseSignatureTest() { - for (String badSig : new String[]{"", "()", "(", "()Vextra", "()E", "(E)", "(Ljava.lang.Object;)V"}) { - try { - metaAccess.parseMethodDescriptor(badSig); - throw new AssertionError("Expected signature to be invalid: " + badSig); - } catch (IllegalArgumentException e) { - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java deleted file mode 100644 index 706aec05a29..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java - * TestResolvedJavaType.java - * @clean jdk.internal.vm.test.AnnotationTestInput$Missing - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * java.base/jdk.internal.reflect - * java.base/jdk.internal.misc - * java.base/jdk.internal.vm - * java.base/sun.reflect.annotation - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestResolvedJavaField - */ - -package jdk.vm.ci.runtime.test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.internal.vm.test.AnnotationTestInput; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.test.TestResolvedJavaField.TestClassLoader; - -/** - * Tests for {@link ResolvedJavaField}. - */ -public class TestResolvedJavaField extends FieldUniverse { - - public TestResolvedJavaField() { - } - - @Test - public void equalsTest() { - for (ResolvedJavaField f : fields.values()) { - for (ResolvedJavaField that : fields.values()) { - boolean expect = f == that; - boolean actual = f.equals(that); - assertEquals(expect, actual); - } - } - } - - @Test - public void getModifiersTest() { - for (Map.Entry e : fields.entrySet()) { - int expected = e.getKey().getModifiers(); - int actual = e.getValue().getModifiers(); - assertEquals(expected, actual); - } - } - - @Test - public void isSyntheticTest() { - for (Map.Entry e : fields.entrySet()) { - boolean expected = e.getKey().isSynthetic(); - boolean actual = e.getValue().isSynthetic(); - assertEquals(expected, actual); - } - } - - @Test - public void getAnnotationsTest() { - for (Map.Entry e : fields.entrySet()) { - Annotation[] expected = e.getKey().getAnnotations(); - Annotation[] actual = e.getValue().getAnnotations(); - assertArrayEquals(expected, actual); - } - } - - @Test - public void getAnnotationTest() { - for (Map.Entry e : fields.entrySet()) { - for (Annotation expected : e.getKey().getAnnotations()) { - if (expected != null) { - Annotation actual = e.getValue().getAnnotation(expected.annotationType()); - assertEquals(expected, actual); - } - } - } - } - - @Test - public void getDeclaringClassTest() { - for (Map.Entry e : fields.entrySet()) { - ResolvedJavaField field = e.getValue(); - ResolvedJavaType actual = field.getDeclaringClass(); - ResolvedJavaType expect = metaAccess.lookupJavaType(e.getKey().getDeclaringClass()); - assertEquals(field.toString(), expect, actual); - } - } - - @Test - public void getOffsetTest() { - for (Map.Entry e : fields.entrySet()) { - Field javaField = e.getKey(); - ResolvedJavaField field = e.getValue(); - int actual = field.getOffset(); - long expect = field.isStatic() ? unsafe.staticFieldOffset(javaField) : unsafe.objectFieldOffset(javaField); - assertEquals(field.toString(), expect, actual); - } - } - - @Test - public void isFinalTest() { - for (Map.Entry e : fields.entrySet()) { - ResolvedJavaField field = e.getValue(); - boolean actual = field.isFinal(); - boolean expect = Modifier.isFinal(e.getKey().getModifiers()); - assertEquals(field.toString(), expect, actual); - } - } - - @Test - public void isInternalTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - for (ResolvedJavaField field : type.getInstanceFields(false)) { - if (field.isInternal()) { - try { - c.getDeclaredField(field.getName()); - throw new AssertionError("got reflection object for internal field: " + field); - } catch (NoSuchFieldException e) { - // expected - } - } - } - } - } - - private Method findTestMethod(Method apiMethod) { - String testName = apiMethod.getName() + "Test"; - for (Method m : getClass().getDeclaredMethods()) { - if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) { - return m; - } - } - return null; - } - - @Test - public void getAnnotationDataTest() throws Exception { - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredField("annotatedField")); - for (Field f : fields.keySet()) { - TestResolvedJavaType.getAnnotationDataTest(f); - } - } - - // @formatter:off - private static final String[] untestedApiMethods = { - }; - // @formatter:on - - /** - * Ensures that any new methods added to {@link ResolvedJavaMethod} either have a test written - * for them or are added to {@link #untestedApiMethods}. - */ - @Test - public void testCoverage() { - Set known = new HashSet<>(Arrays.asList(untestedApiMethods)); - for (Method m : ResolvedJavaField.class.getDeclaredMethods()) { - if (m.isSynthetic()) { - continue; - } - if (findTestMethod(m) == null) { - assertTrue("test missing for " + m, known.contains(m.getName())); - } else { - assertFalse("test should be removed from untestedApiMethods" + m, known.contains(m.getName())); - } - } - } - - private static final String NON_EXISTENT_CLASS_NAME = "XXXXXXXXXXX"; - - static class TestClassLoader extends ClassLoader { - - @Override - protected Class findClass(final String name) throws ClassNotFoundException { - if (!name.equals(TypeWithUnresolvedFieldType.class.getName())) { - return super.findClass(name); - } - // copy classfile to byte array - byte[] classData = null; - try { - String simpleName = TypeWithUnresolvedFieldType.class.getSimpleName(); - InputStream is = TypeWithUnresolvedFieldType.class.getResourceAsStream(simpleName + ".class"); - assert is != null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] buf = new byte[1024]; - int size; - while ((size = is.read(buf, 0, buf.length)) != -1) { - baos.write(buf, 0, size); - } - baos.flush(); - classData = baos.toByteArray(); - } catch (IOException e) { - Assert.fail("can't access class: " + name); - } - - // replace all occurrences of "PrintStream" in classfile - int index = -1; - - while ((index = indexOf(classData, index + 1, "PrintStream")) != -1) { - replace(classData, index, NON_EXISTENT_CLASS_NAME); - } - - Class c = defineClass(null, classData, 0, classData.length); - return c; - } - - private static int indexOf(byte[] b, int index, String find) { - for (int i = index; i < b.length; i++) { - boolean match = true; - for (int j = i; j < i + find.length(); j++) { - if (b[j] != (byte) find.charAt(j - i)) { - match = false; - break; - } - } - if (match) { - return i; - } - } - return -1; - } - - private static void replace(byte[] b, int index, String replace) { - for (int i = index; i < index + replace.length(); i++) { - b[i] = (byte) replace.charAt(i - index); - } - } - } - - /** - * Tests that calling {@link ResolvedJavaField#getType()} does not cause a linkage error if the - * type of the field is not resolvable. - */ - @Test - public void testGetType() throws ClassNotFoundException { - Class c = new TestClassLoader().findClass(TypeWithUnresolvedFieldType.class.getName()); - ResolvedJavaType type = metaAccess.lookupJavaType(c); - for (ResolvedJavaField field : type.getInstanceFields(false)) { - assertTrue(field.getName().equals("fieldWithUnresolvableType")); - field.getType(); - field.toString(); - field.getAnnotations(); - } - } - - @Test - public void getConstantValueTest() { - ConstantReflectionProvider cr = constantReflection; - Map expects = Map.of( - "INT", JavaConstant.forInt(42), - "SHORT", JavaConstant.forInt(43), - "CHAR", JavaConstant.forInt(44), - "BYTE", JavaConstant.forInt(45), - "FLOAT", JavaConstant.forFloat(46.46F), - "LONG", JavaConstant.forLong(47L), - "DOUBLE", JavaConstant.forDouble(48.48D)); - ResolvedJavaType type = metaAccess.lookupJavaType(FieldsWithConstantValueAttributes.class); - for (ResolvedJavaField field : type.getStaticFields()) { - JavaConstant actual = field.getConstantValue(); - String name = field.getName(); - if (name.endsWith("2")) { - assertNull(field.toString(), actual); - } else if (name.equals("STRING")) { - JavaConstant expect = cr.forString("STRING_VALUE"); - assertEquals(field.toString(), expect, actual); - - // String ConstantValues are interned so should not - // be identical to a newly allocated String - expect = cr.forString(new String("STRING_VALUE")); - assertNotEquals(field.toString(), expect, actual); - } else { - JavaConstant expect = expects.get(name); - assertEquals(field.toString(), expect, actual); - } - } - } -} - -class FieldsWithConstantValueAttributes { - public static final String STRING = "STRING_VALUE"; - public static final int INT = 42; - public static final short SHORT = 43; - public static final char CHAR = 44; - public static final byte BYTE = 45; - public static final float FLOAT = 46.46F; - public static final long LONG = 47L; - public static final double DOUBLE = 48.48D; - - public static final String STRING2; - public static final int INT2; - public static final short SHORT2; - public static final char CHAR2; - public static final byte BYTE2; - public static final float FLOAT2; - public static final long LONG2; - public static final double DOUBLE2; - - static { - JVMCIError.shouldNotReachHere("should not be initialized"); - STRING2 = STRING; - INT2 = INT; - SHORT2 = SHORT; - BYTE2 = BYTE; - CHAR2 = CHAR; - FLOAT2 = FLOAT; - LONG2 = LONG; - DOUBLE2 = DOUBLE; - } -} - -class TypeWithUnresolvedFieldType { - /** - * {@link TestClassLoader} will rewrite the type of this field to "Ljava/io/XXXXXXXXXXX;". - */ - PrintStream fieldWithUnresolvableType; -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java deleted file mode 100644 index 58612aa0da1..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java +++ /dev/null @@ -1,855 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java - * TestResolvedJavaType.java - * @clean jdk.internal.vm.test.AnnotationTestInput$Missing - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * java.base/jdk.internal.reflect - * java.base/jdk.internal.misc - * java.base/jdk.internal.vm - * java.base/sun.reflect.annotation - * @run junit/othervm/timeout=960 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestResolvedJavaMethod - */ - -package jdk.vm.ci.runtime.test; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.DataInputStream; -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.net.URI; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.BitSet; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.internal.vm.test.AnnotationTestInput; -import java.lang.classfile.Attributes; -import java.lang.classfile.ClassFile; -import java.lang.classfile.ClassModel; -import java.lang.classfile.CodeElement; -import java.lang.classfile.MethodModel; -import java.lang.classfile.Instruction; -import java.lang.classfile.attribute.CodeAttribute; - -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.meta.ExceptionHandler; -import jdk.vm.ci.meta.Local; -import jdk.vm.ci.meta.LocalVariableTable; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaMethod.Parameter; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.test.TestResolvedJavaMethod.AnnotationDataTest.Annotation1; -import jdk.vm.ci.runtime.test.TestResolvedJavaMethod.AnnotationDataTest.Annotation2; -import jdk.vm.ci.runtime.test.TestResolvedJavaMethod.AnnotationDataTest.Annotation3; -import jdk.vm.ci.runtime.test.TestResolvedJavaMethod.AnnotationDataTest.NumbersDE; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; - -/** - * Tests for {@link ResolvedJavaMethod}. - */ -public class TestResolvedJavaMethod extends MethodUniverse { - - public TestResolvedJavaMethod() { - } - - /** - * @see ResolvedJavaMethod#getCode() - */ - @Test - public void getCodeTest() { - for (ResolvedJavaMethod m : joinValues(methods, constructors)) { - String ms = m.toString(); - byte[] code = m.getCode(); - if (code == null) { - assertEquals(ms, m.getCodeSize(), 0); - } else { - assertTrue(ms, code.length > 0); - } - } - } - - /** - * @see ResolvedJavaMethod#getCodeSize() - */ - @Test - public void getCodeSizeTest() { - ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class); - assertTrue(!unlinkedType.isLinked()); - for (ResolvedJavaMethod m : addExecutables(joinValues(methods, constructors), unlinkedType, false)) { - int codeSize = m.getCodeSize(); - String ms = m.toString(); - if (m.isAbstract() || m.isNative()) { - assertEquals(ms, codeSize, 0); - } else if (!m.getDeclaringClass().isLinked()) { - assertEquals(ms, -1, codeSize); - } else { - assertTrue(ms, codeSize > 0); - } - } - assertTrue(!unlinkedType.isLinked()); - } - - @Test - public void equalsTest() { - List executables = joinValues(methods, constructors); - for (ResolvedJavaMethod m : executables) { - for (ResolvedJavaMethod that : executables) { - boolean expect = m == that; - boolean actual = m.equals(that); - assertEquals(expect, actual); - } - } - } - - @Test - public void getModifiersTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - ResolvedJavaMethod m = e.getValue(); - int expected = e.getKey().getModifiers(); - int actual = m.getModifiers(); - assertEquals(String.format("%s: 0x%x != 0x%x", m, expected, actual), expected, actual); - } - } - - /** - * @see ResolvedJavaMethod#isClassInitializer() - */ - @Test - public void isClassInitializerTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - // Class initializers are hidden from reflection - ResolvedJavaMethod m = e.getValue(); - assertFalse(m.isClassInitializer()); - } - } - - @Test - public void isConstructorTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertFalse(m.isConstructor()); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertTrue(m.isConstructor()); - } - } - - @Test - public void isSyntheticTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(e.getKey().isSynthetic(), m.isSynthetic()); - } - } - - @Test - public void isBridgeTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(e.getKey().isBridge(), m.isBridge()); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(false, m.isBridge()); - } - } - - @Test - public void isVarArgsTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(e.getKey().isVarArgs(), m.isVarArgs()); - } - } - - @Test - public void isSynchronizedTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(Modifier.isSynchronized(e.getKey().getModifiers()), m.isSynchronized()); - } - } - - @Test - public void canBeStaticallyBoundTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey())); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - boolean expect = m.canBeStaticallyBound(); - boolean actual = canBeStaticallyBound(e.getKey()); - assertEquals(m.toString(), expect, actual); - } - } - - private static boolean canBeStaticallyBound(Member method) { - int modifiers = method.getModifiers(); - return (Modifier.isFinal(modifiers) || - Modifier.isPrivate(modifiers) || - Modifier.isStatic(modifiers) || - method instanceof Constructor || - Modifier.isFinal(method.getDeclaringClass().getModifiers())) && - !Modifier.isAbstract(modifiers); - } - - private static String methodWithExceptionHandlers(String p1, Object o2) { - try { - return p1.substring(100) + o2.toString(); - } catch (IndexOutOfBoundsException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - e.printStackTrace(); - } catch (RuntimeException e) { - e.printStackTrace(); - } - return null; - } - - @Test - public void getExceptionHandlersTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithExceptionHandlers", String.class, Object.class)); - ExceptionHandler[] handlers = method.getExceptionHandlers(); - assertNotNull(handlers); - assertEquals(handlers.length, 3); - handlers[0].getCatchType().equals(metaAccess.lookupJavaType(IndexOutOfBoundsException.class)); - handlers[1].getCatchType().equals(metaAccess.lookupJavaType(NullPointerException.class)); - handlers[2].getCatchType().equals(metaAccess.lookupJavaType(RuntimeException.class)); - } - - private static String nullPointerExceptionOnFirstLine(Object o, String ignored) { - return o.toString() + ignored; - } - - @Test - public void asStackTraceElementTest() throws NoSuchMethodException { - try { - nullPointerExceptionOnFirstLine(null, "ignored"); - Assert.fail("should not reach here"); - } catch (NullPointerException e) { - StackTraceElement expected = e.getStackTrace()[0]; - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); - StackTraceElement actual = method.asStackTraceElement(0); - // JVMCI StackTraceElements omit the class loader and module info - assertEquals(expected.toString(), actual.toString()); - } - } - - @Test - public void getConstantPoolTest() { - for (Map.Entry e : join(methods, constructors).entrySet()) { - ResolvedJavaMethod m = e.getValue(); - ConstantPool cp = m.getConstantPool(); - assertTrue(cp.length() > 0); - } - } - - @Test - public void getParametersTest() { - for (Map.Entry e : methods.entrySet()) { - java.lang.reflect.Parameter[] expected = e.getKey().getParameters(); - Parameter[] actual = e.getValue().getParameters(); - assertEquals(actual.length, expected.length); - for (int i = 0; i < actual.length; i++) { - java.lang.reflect.Parameter exp = expected[i]; - Parameter act = actual[i]; - assertEquals(exp.getName(), act.getName()); - assertEquals(exp.isNamePresent(), act.isNamePresent()); - assertEquals(exp.getModifiers(), act.getModifiers()); - assertArrayEquals(exp.getAnnotations(), act.getAnnotations()); - assertEquals(exp.getType().getName(), act.getType().toClassName()); - assertEquals(exp.getParameterizedType(), act.getParameterizedType()); - assertEquals(metaAccess.lookupJavaMethod(exp.getDeclaringExecutable()), act.getDeclaringMethod()); - } - } - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @interface TestAnnotation { - long value(); - } - - @Test - @TestAnnotation(value = 1000L) - public void getAnnotationTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationTest")); - TestAnnotation annotation = method.getAnnotation(TestAnnotation.class); - assertNotNull(annotation); - assertEquals(1000L, annotation.value()); - } - - @Test - @TestAnnotation(value = 1000L) - public void getAnnotationsTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationsTest")); - Annotation[] annotations = method.getAnnotations(); - assertNotNull(annotations); - assertEquals(2, annotations.length); - TestAnnotation annotation = null; - for (Annotation a : annotations) { - if (a instanceof TestAnnotation) { - annotation = (TestAnnotation) a; - break; - } - } - assertNotNull(annotation); - assertEquals(1000L, annotation.value()); - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.PARAMETER) - @interface NonNull { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.PARAMETER) - @interface Special { - } - - private static native void methodWithAnnotatedParameters(@NonNull HashMap p1, @Special @NonNull Class p2); - - @Test - public void getParameterAnnotationsTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); - Annotation[][] annotations = method.getParameterAnnotations(); - assertEquals(2, annotations.length); - assertEquals(1, annotations[0].length); - assertEquals(NonNull.class, annotations[0][0].annotationType()); - assertEquals(2, annotations[1].length); - assertEquals(Special.class, annotations[1][0].annotationType()); - assertEquals(NonNull.class, annotations[1][1].annotationType()); - } - - @Test - public void getGenericParameterTypesTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); - Type[] genericParameterTypes = method.getGenericParameterTypes(); - assertEquals(2, genericParameterTypes.length); - assertEquals("java.util.HashMap", genericParameterTypes[0].toString()); - assertEquals("java.lang.Class", genericParameterTypes[1].toString()); - } - - @Test - public void getMaxLocalsTest() throws NoSuchMethodException { - ResolvedJavaMethod method1 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); - ResolvedJavaMethod method2 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); - assertEquals(0, method1.getMaxLocals()); - assertEquals(2, method2.getMaxLocals()); - - } - - @Test - public void getMaxStackSizeTest() throws NoSuchMethodException { - ResolvedJavaMethod method1 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); - ResolvedJavaMethod method2 = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class)); - assertEquals(0, method1.getMaxStackSize()); - // some versions of javac produce bytecode with a stacksize of 2 for this method - // JSR 292 also sometimes need one more stack slot - int method2StackSize = method2.getMaxStackSize(); - assertTrue(2 <= method2StackSize && method2StackSize <= 4); - } - - @Test - public void isDefaultTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertEquals(e.getKey().isDefault(), m.isDefault()); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertFalse(m.isDefault()); - } - } - - @Test - public void isDeclaredTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - boolean expectedDeclared = Arrays.stream(m.getDeclaringClass().getDeclaredMethods()).anyMatch(i -> i.equals(m)); - assertEquals(expectedDeclared, m.isDeclared()); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertFalse(m.isDeclared()); - } - } - - @Test - public void hasReceiverTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertTrue(m.hasReceiver() != Modifier.isStatic(e.getKey().getModifiers())); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertTrue(m.hasReceiver()); - } - } - - public static List addExecutables(List to, ResolvedJavaType declaringType, boolean forceLink) { - to.addAll(List.of(declaringType.getDeclaredMethods(forceLink))); - to.addAll(List.of(declaringType.getDeclaredConstructors(forceLink))); - return to; - } - - @Test - public void hasBytecodesTest() { - ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class); - assertTrue(!unlinkedType.isLinked()); - for (ResolvedJavaMethod m : addExecutables(joinValues(methods, constructors), unlinkedType, false)) { - boolean expect = m.getDeclaringClass().isLinked() && m.isConcrete() && !m.isNative(); - boolean actual = m.hasBytecodes(); - assertEquals(m.toString(), expect, actual); - } - assertTrue(!unlinkedType.isLinked()); - } - - @Test - public void isJavaLangObjectInitTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Object.class.getConstructor()); - assertTrue(method.isJavaLangObjectInit()); - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - assertFalse(m.isJavaLangObjectInit()); - } - for (Map.Entry, ResolvedJavaMethod> e : constructors.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - Constructor key = e.getKey(); - if (key.getDeclaringClass() == Object.class && key.getParameters().length == 0) { - assertTrue(m.isJavaLangObjectInit()); - } else { - assertFalse(m.isJavaLangObjectInit()); - } - } - } - - @Test - public void isScopedTest() throws NoSuchMethodException, ClassNotFoundException { - // Must use reflection as ScopedMemoryAccess$Scoped is package-private - Class scopedAnnotationClass = Class.forName("jdk.internal.misc.ScopedMemoryAccess$Scoped").asSubclass(Annotation.class); - boolean scopedMethodFound = false; - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - Method key = e.getKey(); - boolean expect = key.isAnnotationPresent(scopedAnnotationClass); - boolean actual = m.isScoped(); - assertEquals(m.toString(), expect, actual); - if (expect) { - scopedMethodFound = true; - } - } - assertTrue("At least one scoped method must be present", scopedMethodFound); - } - - abstract static class UnlinkedType { - abstract void abstractMethod(); - - void concreteMethod() { - } - - native void nativeMethod(); - } - - /** - * All public non-final methods should be available in the vtable. - */ - @Test - public void testVirtualMethodTableAccess() { - ResolvedJavaType unlinkedType = metaAccess.lookupJavaType(UnlinkedType.class); - assertTrue(!unlinkedType.isLinked()); - for (Class c : classes) { - if (c.isInterface()) { - for (Method m : c.getDeclaredMethods()) { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m); - method.isInVirtualMethodTable(unlinkedType); - } - } - } - for (Class c : classes) { - if (c.isPrimitive() || c.isInterface()) { - continue; - } - ResolvedJavaType receiverType = metaAccess.lookupJavaType(c); - for (Method m : c.getMethods()) { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m); - if (!method.isStatic() && !method.isFinal() && !method.getDeclaringClass().isLeaf() && !method.getDeclaringClass().isInterface()) { - assertTrue(method + " not available in " + receiverType, method.isInVirtualMethodTable(receiverType)); - } - } - } - } - - /** - * Encapsulates input for {@link TestResolvedJavaMethod#getAnnotationDataTest}. - */ - static class AnnotationDataTest { - - public enum NumbersEN { - One, - Two; - } - - public enum NumbersDE { - Eins, - Zwei; - } - - public enum NumbersUA { - Odyn, - Dva; - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface Annotation1 { - NumbersEN value() default NumbersEN.One; - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface Annotation2 { - NumbersDE value() default NumbersDE.Eins; - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface Annotation3 { - NumbersUA value() default NumbersUA.Odyn; - } - - @Annotation1 - @Annotation2 - @Annotation3(NumbersUA.Dva) - static void methodWithThreeAnnotations() { - - } - } - - @Test - public void getAnnotationDataTest() throws Exception { - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("annotatedMethod")); - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("missingAnnotation")); - try { - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("missingNestedAnnotation")); - throw new AssertionError("expected " + NoClassDefFoundError.class.getName()); - } catch (NoClassDefFoundError e) { - Assert.assertEquals("jdk/internal/vm/test/AnnotationTestInput$Missing", e.getMessage()); - } - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("missingTypeOfClassMember")); - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("missingMember")); - TestResolvedJavaType.getAnnotationDataTest(AnnotationTestInput.class.getDeclaredMethod("changeTypeOfMember")); - - for (Method m : methods.keySet()) { - TestResolvedJavaType.getAnnotationDataTest(m); - } - - ResolvedJavaMethod m = metaAccess.lookupJavaMethod(AnnotationDataTest.class.getDeclaredMethod("methodWithThreeAnnotations")); - ResolvedJavaType a1 = metaAccess.lookupJavaType(Annotation1.class); - ResolvedJavaType a2 = metaAccess.lookupJavaType(Annotation2.class); - ResolvedJavaType a3 = metaAccess.lookupJavaType(Annotation3.class); - ResolvedJavaType a4 = metaAccess.lookupJavaType(AnnotationDataTest.class); - ResolvedJavaType numbersDEType = metaAccess.lookupJavaType(NumbersDE.class); - - // Ensure NumbersDE is not initialized before Annotation2 is requested - Assert.assertFalse(numbersDEType.isInitialized()); - Assert.assertEquals(2, m.getAnnotationData(a1, a3).size()); - - // Ensure NumbersDE is initialized after Annotation2 is requested - Assert.assertNotNull(m.getAnnotationData(a2)); - Assert.assertTrue(numbersDEType.isInitialized()); - } - - private static ClassModel readClassfile(Class c) throws Exception { - String name = c.getName(); - final int lastDot = name.lastIndexOf('.'); - if (lastDot != -1) { - name = name.substring(lastDot + 1); - } - URI uri = c.getResource(name + ".class").toURI(); - if (uri.getScheme().equals("jar")) { - final String[] parts = uri.toString().split("!"); - if (parts.length == 2) { - try (FileSystem fs = FileSystems.newFileSystem(URI.create(parts[0]), new HashMap<>())) { - return ClassFile.of().parse(fs.getPath(parts[1])); - } - } - } - return ClassFile.of().parse(Paths.get(uri)); - } - - public static void methodWithManyArgs( - Object o0, int i1, int i2, int i3, int i4, int i5, int i6, int i7, - int i8, int i9, int i10, int i11, int i12, int i13, int i14, int i15, - int i16, int i17, int i18, int i19, int i20, int i21, int i22, int i23, - int i24, int i25, int i26, int i27, int i28, int i29, int i30, int i31, - int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, - int i40, int i41, int i42, int i43, int i44, int i45, int i46, int i47, - int i48, int i49, int i50, int i51, int i52, int i53, int i54, int i55, - int i56, int i57, int i58, int i59, int i60, int i61, int i62, int i63, - Object o64, int i65, int i66, int i67, int i68, int i69, int i70, int i71, - int i72, int i73, int i74, int i75, int i76, int i77, int i78, int i79, - int i80, int i81, int i82, int i83, int i84, int i85, int i86, int i87, - int i88, int i89, int i90, int i91, int i92, int i93, int i94, int i95, - int i96, int i97, int i98, int i99, int i100, int i101, int i102, int i103, - int i104, int i105, int i106, int i107, int i108, int i109, int i110, int i111, - int i112, int i113, int i114, int i115, int i116, int i117, int i118, int i119, - int i120, int i121, int i122, int i123, int i124, int i125, int i126, int i127, - Object o128) - { - o0.hashCode(); - o64.hashCode(); - if (o128 != null) { - Object t1 = "tmp val"; - t1.hashCode(); - } else { - int t1 = 42 + i1; - String.valueOf(t1); - } - o128.hashCode(); - } - - private static Map buildMethodMap(ResolvedJavaType type) { - Map methodMap = new HashMap<>(); - for (ResolvedJavaMethod m : type.getDeclaredMethods()) { - if (m.hasBytecodes()) { - String key = m.getName() + ":" + m.getSignature().toMethodDescriptor(); - methodMap.put(key, m); - } - } - for (ResolvedJavaMethod m : type.getDeclaredConstructors()) { - if (m.hasBytecodes()) { - String key = ":" + m.getSignature().toMethodDescriptor(); - methodMap.put(key, m); - } - } - ResolvedJavaMethod clinit = type.getClassInitializer(); - if (clinit != null) { - String key = ":()V"; - methodMap.put(key, clinit); - } - return methodMap; - } - - @Test - public void getOopMapAtTest() throws Exception { - Collection> allClasses = new ArrayList<>(classes); - - // Add this class so that methodWithManyArgs is processed - allClasses.add(getClass()); - - boolean[] processedMethodWithManyArgs = {false}; - - for (Class c : allClasses) { - if (c.isArray() || c.isPrimitive() || c.isHidden()) { - continue; - } - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Map methodMap = buildMethodMap(type); - ClassModel cf = readClassfile(c); - for (MethodModel cm : cf.methods()) { - cm.findAttribute(Attributes.code()).ifPresent(codeAttr -> { - String key = cm.methodName().stringValue() + ":" + cm.methodType().stringValue(); - HotSpotResolvedJavaMethod m = (HotSpotResolvedJavaMethod) Objects.requireNonNull(methodMap.get(key)); - boolean isMethodWithManyArgs = c == getClass() && m.getName().equals("methodWithManyArgs"); - if (isMethodWithManyArgs) { - processedMethodWithManyArgs[0] = true; - } - int maxSlots = m.getMaxLocals() + m.getMaxStackSize(); - - int bci = 0; - Map expectOopMaps = !isMethodWithManyArgs ? null : Map.of( - "{0, 64, 128}", new int[] {0}, - "{0, 64, 128, 130}", new int[] {0}, - "{0, 64, 128, 129}", new int[] {0}); - for (CodeElement i : codeAttr.elementList()) { - if (i instanceof Instruction ins) { - BitSet oopMap = m.getOopMapAt(bci); - if (isMethodWithManyArgs) { - System.out.printf("methodWithManyArgs@%d [%d]: %s%n", bci, maxSlots, oopMap); - System.out.printf("methodWithManyArgs@%d [%d]: %s%n", bci, maxSlots, ins); - - // Assumes stability of javac output - String where = "methodWithManyArgs@" + bci; - String oopMapString = String.valueOf(oopMap); - int[] count = expectOopMaps.get(oopMapString); - if (count == null) { - throw new AssertionError(where + ": unexpected oop map: " + oopMapString); - } - count[0]++; - } - - // Requesting an oop map at an invalid BCI must throw an exception - if (ins.sizeInBytes() > 1) { - try { - oopMap = m.getOopMapAt(bci + 1); - throw new AssertionError("expected exception for illegal bci %d in %s: %s".formatted(bci + 1, m.format("%H.%n(%p)"), oopMap)); - } catch(IllegalArgumentException e) { - // expected - } - } - bci += ins.sizeInBytes(); - } - } - if (isMethodWithManyArgs) { - for (var e : expectOopMaps.entrySet()) { - if (e.getValue()[0] == 0) { - throw new AssertionError(m.format("%H.%n(%p)") + "did not find expected oop map: " + e.getKey()); - } - System.out.printf("methodWithManyArgs: %s = %d%n", e.getKey(), e.getValue()[0]); - } - } - }); - } - } - - Assert.assertTrue(processedMethodWithManyArgs[0]); - } - - @Test - public void getLocalVariableTableTest() { - for (ResolvedJavaMethod m : methods.values()) { - LocalVariableTable table = m.getLocalVariableTable(); - if (table == null) { - continue; - } - for (Local l : table.getLocals()) { - if (l.getStartBCI() < 0) { - throw new AssertionError(m.format("%H.%n(%p)") + " local " + l.getName() + " starts at " + l.getStartBCI()); - } - if (l.getEndBCI() >= m.getCodeSize()) { - throw new AssertionError(m.format("%H.%n(%p)") + " (" + m.getCodeSize() + "bytes) local " + l.getName() + " ends at " + l.getEndBCI()); - } - } - } - } - - private Method findTestMethod(Method apiMethod) { - String testName = apiMethod.getName() + "Test"; - for (Method m : getClass().getDeclaredMethods()) { - if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) { - return m; - } - } - return null; - } - - // @formatter:off - private static final String[] untestedApiMethods = { - "newInstance", - "getDeclaringClass", - "getEncoding", - "getProfilingInfo", - "reprofile", - "getCompilerStorage", - "hasNeverInlineDirective", - "canBeInlined", - "shouldBeInlined", - "getLineNumberTable", - "isInVirtualMethodTable", - "toParameterTypes", - "getParameterAnnotation", - "getSpeculationLog", - "isFinal", - "invoke", - "$jacocoInit" - }; - // @formatter:on - - /** - * Ensures that any new methods added to {@link ResolvedJavaMethod} either have a test written - * for them or are added to {@link #untestedApiMethods}. - */ - @Test - public void testCoverage() { - Set known = new HashSet<>(Arrays.asList(untestedApiMethods)); - for (Method m : ResolvedJavaMethod.class.getDeclaredMethods()) { - if (Modifier.isStatic(m.getModifiers())) { - continue; - } - if (findTestMethod(m) == null) { - assertTrue("test missing for " + m, known.contains(m.getName())); - } else { - assertFalse("test should be removed from untestedApiMethods" + m, known.contains(m.getName())); - } - } - } - - @SafeVarargs - public static Map join(Map... maps) { - Map res = new HashMap<>(); - for (Map e : maps) { - res.putAll(e); - } - return res; - } - - @SafeVarargs - public static List joinValues(Map... maps) { - List res = new ArrayList<>(); - for (Map e : maps) { - res.addAll(e.values()); - } - return res; - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java deleted file mode 100644 index 2ea54f2b4ef..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ /dev/null @@ -1,1478 +0,0 @@ -/* - * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @library /testlibrary/asm - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java - * @clean jdk.internal.vm.test.AnnotationTestInput$Missing - * @compile ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java - * ../../../../../../../../../../../jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java - * @modules java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * java.base/jdk.internal.misc - * java.base/jdk.internal.vm - * java.base/sun.reflect.annotation - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestResolvedJavaType - */ - -package jdk.vm.ci.runtime.test; - -import static java.lang.reflect.Modifier.isAbstract; -import static java.lang.reflect.Modifier.isFinal; -import static java.lang.reflect.Modifier.isPrivate; -import static java.lang.reflect.Modifier.isProtected; -import static java.lang.reflect.Modifier.isPublic; -import static java.lang.reflect.Modifier.isStatic; -import static jdk.vm.ci.meta.MetaUtil.internalNameToJava; -import static jdk.vm.ci.meta.MetaUtil.toInternalName; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.DataInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.invoke.MethodHandles.Lookup; -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.function.BiConsumer; -import java.util.function.Supplier; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.internal.reflect.ConstantPool; -import jdk.internal.vm.test.AnnotationTestInput; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.Annotated; -import jdk.vm.ci.meta.AnnotationData; -import jdk.vm.ci.meta.EnumData; -import jdk.vm.ci.meta.Assumptions.AssumptionResult; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.JavaType; -import jdk.vm.ci.meta.MetaUtil; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.UnresolvedJavaType; -import sun.reflect.annotation.AnnotationSupport; -import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; - -/** - * Tests for {@link ResolvedJavaType}. - */ -public class TestResolvedJavaType extends TypeUniverse { - private static final Class SIGNATURE_POLYMORPHIC_CLASS = findPolymorphicSignatureClass(); - private static final HotSpotJVMCIRuntime runtime = HotSpotJVMCIRuntime.runtime(); - - public TestResolvedJavaType() { - } - - @Test - public void getMirrorTest() { - for (ResolvedJavaType type : javaTypes) { - assertEquals(type.toClassName(), runtime.getMirror(type).getName()); - } - } - - @Test - public void equalsTest() { - for (ResolvedJavaType t : javaTypes) { - for (ResolvedJavaType that : javaTypes) { - boolean expect = t == that; - boolean actual = t.equals(that); - assertEquals(expect, actual); - } - } - } - - @SuppressWarnings("unchecked") - private static Class findPolymorphicSignatureClass() { - Class signaturePolyAnnotation = null; - try { - for (Class clazz : TestResolvedJavaType.class.getClassLoader().loadClass("java.lang.invoke.MethodHandle").getDeclaredClasses()) { - if (clazz.getName().endsWith("PolymorphicSignature") && Annotation.class.isAssignableFrom(clazz)) { - signaturePolyAnnotation = (Class) clazz; - break; - } - } - } catch (Throwable e) { - throw new AssertionError("Could not find annotation PolymorphicSignature in java.lang.invoke.MethodHandle", e); - } - assertNotNull(signaturePolyAnnotation); - return signaturePolyAnnotation; - } - - @Test - public void findInstanceFieldWithOffsetTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Set reflectionFields = Set.copyOf(getInstanceFields(c, true)); - for (Field f : reflectionFields) { - ResolvedJavaField rf = lookupField(type.getInstanceFields(true), f); - assertNotNull(rf); - long offset = isStatic(f.getModifiers()) ? unsafe.staticFieldOffset(f) : unsafe.objectFieldOffset(f); - ResolvedJavaField result = type.findInstanceFieldWithOffset(offset, rf.getJavaKind()); - assertNotNull(result); - assertTrue(fieldsEqual(f, result)); - } - } - } - - @Test - public void isAnnotationTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = c.isAnnotation(); - boolean actual = type.isAnnotation(); - assertEquals(expected, actual); - } - } - - @Test - public void isInterfaceTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = c.isInterface(); - boolean actual = type.isInterface(); - assertEquals(expected, actual); - } - } - - @Test - public void isEnumTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = c.isEnum(); - boolean actual = type.isEnum(); - assertEquals(expected, actual); - } - } - - @Test - public void isInstanceClassTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = !c.isArray() && !c.isPrimitive() && !c.isInterface(); - boolean actual = type.isInstanceClass(); - assertEquals(expected, actual); - } - } - - @Test - public void isArrayTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = c.isArray(); - boolean actual = type.isArray(); - assertEquals(expected, actual); - } - } - - @Test - public void isConcreteTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - boolean expected = c.isArray() || !isAbstract(c.getModifiers()); - boolean actual = type.isConcrete(); - assertEquals(expected, actual); - } - } - - @Test - public void lambdaInternalNameTest() { - // Verify that the last dot in lambda types is properly handled when transitioning from - // internal name to java - // name and vice versa. - Supplier lambda = () -> () -> System.out.println("run"); - ResolvedJavaType lambdaType = metaAccess.lookupJavaType(lambda.getClass()); - String typeName = lambdaType.getName(); - String javaName = lambda.getClass().getName(); - assertEquals(typeName, toInternalName(javaName)); - assertEquals(javaName, internalNameToJava(typeName, true, true)); - } - - @Test - public void getModifiersTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - int mask = Modifier.classModifiers() & ~Modifier.STATIC; - int expected = c.getModifiers() & mask; - int actual = type.getModifiers() & mask; - Class elementalType = c; - while (elementalType.isArray()) { - elementalType = elementalType.getComponentType(); - } - if (elementalType.isMemberClass()) { - // member class get their modifiers from the inner-class attribute in the JVM and - // from the classfile header in jvmci - expected &= ~(Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED); - actual &= ~(Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED); - } - assertEquals(String.format("%s: 0x%x != 0x%x", type, expected, actual), expected, actual); - } - } - - @Test - public void isAssignableFromTest() { - Class[] all = classes.toArray(new Class[classes.size()]); - for (int i = 0; i < all.length; i++) { - Class c1 = all[i]; - for (int j = i; j < all.length; j++) { - Class c2 = all[j]; - ResolvedJavaType t1 = metaAccess.lookupJavaType(c1); - ResolvedJavaType t2 = metaAccess.lookupJavaType(c2); - boolean expected = c1.isAssignableFrom(c2); - boolean actual = t1.isAssignableFrom(t2); - assertEquals(expected, actual); - if (expected && t1 != t2) { - assertFalse(t2.isAssignableFrom(t1)); - } - } - } - } - - @Test - public void isInstanceTest() { - for (ConstantValue cv : constants()) { - JavaConstant c = cv.value; - if (c.getJavaKind() == JavaKind.Object && !c.isNull()) { - ResolvedJavaType cType = metaAccess.lookupJavaType(c); - for (ResolvedJavaType t : javaTypes) { - if (t.isAssignableFrom(cType)) { - assertTrue(t.isInstance(c)); - } else { - assertFalse(t.isInstance(c)); - } - } - } - } - } - - @Test - public void getSuperclassTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Class expected = c.getSuperclass(); - ResolvedJavaType actual = type.getSuperclass(); - if (expected == null) { - assertTrue(actual == null); - } else { - assertNotNull(actual); - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } - } - - @Test - public void getInterfacesTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Class[] expected = c.getInterfaces(); - ResolvedJavaType[] actual = type.getInterfaces(); - assertEquals(expected.length, actual.length); - for (int i = 0; i < expected.length; i++) { - assertTrue(actual[i].equals(metaAccess.lookupJavaType(expected[i]))); - } - } - } - - public Class getSupertype(Class c) { - assert !c.isPrimitive(); - if (c.isArray()) { - Class componentType = c.getComponentType(); - if (componentType.isPrimitive() || componentType == Object.class) { - return Object.class; - } - return getArrayClass(getSupertype(componentType)); - } - if (c.isInterface()) { - return Object.class; - } - return c.getSuperclass(); - } - - public Class findLeastCommonAncestor(Class c1Initial, Class c2Initial) { - if (c1Initial.isPrimitive() || c2Initial.isPrimitive()) { - return null; - } else { - Class c1 = c1Initial; - Class c2 = c2Initial; - while (true) { - if (c1.isAssignableFrom(c2)) { - return c1; - } - if (c2.isAssignableFrom(c1)) { - return c2; - } - c1 = getSupertype(c1); - c2 = getSupertype(c2); - } - } - } - - @Test - public void findLeastCommonAncestorTest() { - Class[] all = classes.toArray(new Class[classes.size()]); - for (int i = 0; i < all.length; i++) { - Class c1 = all[i]; - for (int j = i; j < all.length; j++) { - Class c2 = all[j]; - ResolvedJavaType t1 = metaAccess.lookupJavaType(c1); - ResolvedJavaType t2 = metaAccess.lookupJavaType(c2); - Class expected = findLeastCommonAncestor(c1, c2); - ResolvedJavaType actual = t1.findLeastCommonAncestor(t2); - if (expected == null) { - assertTrue(actual == null); - } else { - assertNotNull(actual); - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } - } - } - - @Test - public void linkTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - type.link(); - } - } - - private class HidingClassLoader extends ClassLoader { - @Override - protected Class findClass(final String name) throws ClassNotFoundException { - if (name.endsWith("MissingInterface")) { - throw new ClassNotFoundException("missing"); - } - byte[] classData = null; - try { - InputStream is = HidingClassLoader.class.getResourceAsStream("/" + name.replace('.', '/') + ".class"); - classData = new byte[is.available()]; - new DataInputStream(is).readFully(classData); - } catch (IOException e) { - Assert.fail("can't access class: " + name); - } - - return defineClass(null, classData, 0, classData.length); - } - - ResolvedJavaType lookupJavaType(String name) throws ClassNotFoundException { - return metaAccess.lookupJavaType(loadClass(name)); - } - - HidingClassLoader() { - super(null); - } - - } - - interface MissingInterface { - } - - static class MissingInterfaceImpl implements MissingInterface { - } - - interface SomeInterface { - default MissingInterface someMethod() { - return new MissingInterfaceImpl(); - } - } - - static class Wrapper implements SomeInterface { - } - - @Test - public void linkExceptionTest() throws ClassNotFoundException { - HidingClassLoader cl = new HidingClassLoader(); - ResolvedJavaType inner = cl.lookupJavaType(Wrapper.class.getName()); - assertTrue("expected default methods", inner.hasDefaultMethods()); - try { - inner.link(); - assertFalse("link should throw an exception", true); - } catch (NoClassDefFoundError e) { - } - } - - @Test - public void hasDefaultMethodsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertEquals(hasDefaultMethods(type), type.hasDefaultMethods()); - } - } - - @Test - public void declaresDefaultMethodsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertEquals(declaresDefaultMethods(type), type.declaresDefaultMethods()); - } - } - - private static boolean hasDefaultMethods(ResolvedJavaType type) { - if (!type.isInterface() && type.getSuperclass() != null && hasDefaultMethods(type.getSuperclass())) { - return true; - } - for (ResolvedJavaType iface : type.getInterfaces()) { - if (hasDefaultMethods(iface)) { - return true; - } - } - return declaresDefaultMethods(type); - } - - static boolean declaresDefaultMethods(ResolvedJavaType type) { - if (!type.isInterface()) { - /* Only interfaces can declare default methods. */ - return false; - } - for (ResolvedJavaMethod method : type.getDeclaredMethods()) { - if (method.isDefault()) { - assert !Modifier.isStatic(method.getModifiers()) : "Default method that is static?"; - return true; - } - } - return false; - } - - private static class Base { - } - - abstract static class Abstract1 extends Base { - } - - interface Interface1 { - } - - static class Concrete1 extends Abstract1 { - } - - static class Concrete2 extends Abstract1 implements Interface1 { - } - - static class Concrete3 extends Concrete2 { - } - - static final class Final1 extends Abstract1 { - } - - abstract static class Abstract4 extends Concrete3 { - } - - void checkConcreteSubtype(ResolvedJavaType type, ResolvedJavaType expected) { - AssumptionResult leafConcreteSubtype = type.findLeafConcreteSubtype(); - if (leafConcreteSubtype == null) { - // findLeafConcreteSubtype() is conservative - } else { - if (expected == null) { - assertNull(leafConcreteSubtype); - } else { - assertTrue(leafConcreteSubtype.getResult().equals(expected)); - } - assertTrue(!type.isLeaf() || leafConcreteSubtype.isAssumptionFree()); - } - - if (!type.isArray()) { - ResolvedJavaType arrayType = type.getArrayClass(); - AssumptionResult arraySubtype = arrayType.findLeafConcreteSubtype(); - if (arraySubtype != null) { - assertEquals(arraySubtype.getResult(), arrayType); - } else { - // findLeafConcreteSubtype() method is conservative - } - } - } - - @Test - public void findLeafConcreteSubtypeTest() { - ResolvedJavaType base = metaAccess.lookupJavaType(Base.class); - checkConcreteSubtype(base, base); - - ResolvedJavaType a1 = metaAccess.lookupJavaType(Abstract1.class); - ResolvedJavaType c1 = metaAccess.lookupJavaType(Concrete1.class); - - checkConcreteSubtype(base, null); - checkConcreteSubtype(a1, c1); - checkConcreteSubtype(c1, c1); - - ResolvedJavaType i1 = metaAccess.lookupJavaType(Interface1.class); - ResolvedJavaType c2 = metaAccess.lookupJavaType(Concrete2.class); - - checkConcreteSubtype(base, null); - checkConcreteSubtype(a1, null); - checkConcreteSubtype(c1, c1); - checkConcreteSubtype(i1, c2); - checkConcreteSubtype(c2, c2); - - ResolvedJavaType c3 = metaAccess.lookupJavaType(Concrete3.class); - checkConcreteSubtype(c2, null); - checkConcreteSubtype(c3, c3); - - ResolvedJavaType a4 = metaAccess.lookupJavaType(Abstract4.class); - checkConcreteSubtype(c3, null); - checkConcreteSubtype(a4, null); - - ResolvedJavaType a1a = metaAccess.lookupJavaType(Abstract1[].class); - checkConcreteSubtype(a1a, null); - ResolvedJavaType i1a = metaAccess.lookupJavaType(Interface1[].class); - checkConcreteSubtype(i1a, null); - ResolvedJavaType c1a = metaAccess.lookupJavaType(Concrete1[].class); - checkConcreteSubtype(c1a, c1a); - ResolvedJavaType f1a = metaAccess.lookupJavaType(Final1[].class); - checkConcreteSubtype(f1a, f1a); - - ResolvedJavaType obja = metaAccess.lookupJavaType(Object[].class); - checkConcreteSubtype(obja, null); - - ResolvedJavaType inta = metaAccess.lookupJavaType(int[].class); - checkConcreteSubtype(inta, inta); - } - - interface NoImplementor { - } - - interface SingleImplementorInterface { - } - - static class SingleConcreteImplementor implements SingleImplementorInterface { - } - - interface SingleAbstractImplementorInterface { - } - - abstract static class SingleAbstractImplementor implements SingleAbstractImplementorInterface { - } - - interface MultiImplementorInterface { - } - - static class ConcreteImplementor1 implements MultiImplementorInterface { - } - - static class ConcreteImplementor2 implements MultiImplementorInterface { - } - - interface MultipleAbstractImplementorInterface { - } - - abstract static class MultiAbstractImplementor1 implements MultipleAbstractImplementorInterface { - } - - abstract static class MultiAbstractImplementor2 implements MultipleAbstractImplementorInterface { - } - - interface SingleAbstractImplementorInterface2 { - } - - interface ExtendedSingleImplementorInterface { - } - - abstract static class SingleAbstractImplementor2 implements SingleAbstractImplementorInterface2 { - } - - static class ConcreteTransitiveImplementor1 extends SingleAbstractImplementor2 implements ExtendedSingleImplementorInterface { - } - - static class ConcreteTransitiveImplementor2 extends SingleAbstractImplementor2 implements ExtendedSingleImplementorInterface { - } - - @Test - public void getSingleImplementorTest() { - ResolvedJavaType iNi = metaAccess.lookupJavaType(NoImplementor.class); - assertNull(iNi.getSingleImplementor()); - - ResolvedJavaType iSi = metaAccess.lookupJavaType(SingleImplementorInterface.class); - ResolvedJavaType cSi = metaAccess.lookupJavaType(SingleConcreteImplementor.class); - assertEquals(cSi, iSi.getSingleImplementor()); - - ResolvedJavaType iSai = metaAccess.lookupJavaType(SingleAbstractImplementorInterface.class); - ResolvedJavaType aSai = metaAccess.lookupJavaType(SingleAbstractImplementor.class); - assertEquals(aSai, iSai.getSingleImplementor()); - - ResolvedJavaType iMi = metaAccess.lookupJavaType(MultiImplementorInterface.class); - metaAccess.lookupJavaType(ConcreteImplementor1.class); - metaAccess.lookupJavaType(ConcreteImplementor2.class); - assertEquals(iMi, iMi.getSingleImplementor()); - - ResolvedJavaType iMai = metaAccess.lookupJavaType(MultipleAbstractImplementorInterface.class); - metaAccess.lookupJavaType(MultiAbstractImplementor1.class); - metaAccess.lookupJavaType(MultiAbstractImplementor2.class); - assertEquals(iMai, iMai.getSingleImplementor()); - - ResolvedJavaType iSai2 = metaAccess.lookupJavaType(SingleAbstractImplementorInterface2.class); - ResolvedJavaType aSai2 = metaAccess.lookupJavaType(SingleAbstractImplementor2.class); - metaAccess.lookupJavaType(ConcreteTransitiveImplementor1.class); - metaAccess.lookupJavaType(ConcreteTransitiveImplementor2.class); - assertEquals(aSai2, iSai2.getSingleImplementor()); - - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - try { - type.getSingleImplementor(); - if (!c.isInterface()) { - throw new AssertionError("Expected exception for calling getSingleImplmentor on " + c.getName()); - } - } catch (JVMCIError e) { - if (c.isInterface()) { - throw new AssertionError("Unexpected exception", e); - } - } - } - } - - @Test(expected = JVMCIError.class) - public void getSingleImplementorTestClassReceiver() { - ResolvedJavaType base = metaAccess.lookupJavaType(Base.class); - base.getSingleImplementor(); - } - - @Test(expected = JVMCIError.class) - public void getSingleImplementorTestPrimitiveReceiver() { - ResolvedJavaType primitive = metaAccess.lookupJavaType(int.class); - primitive.getSingleImplementor(); - } - - @Test - public void getComponentTypeTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Class expected = c.getComponentType(); - ResolvedJavaType actual = type.getComponentType(); - if (expected == null) { - assertNull(actual); - } else { - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } - } - - @Test - public void getArrayClassTest() { - for (Class c : classes) { - if (c != void.class) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Class expected = getArrayClass(c); - ResolvedJavaType actual = type.getArrayClass(); - assertTrue(actual.equals(metaAccess.lookupJavaType(expected))); - } - } - } - - static class Declarations { - - final Method implementation; - final Set declarations; - - Declarations(Method impl) { - this.implementation = impl; - declarations = new HashSet<>(); - } - } - - /** - * See Method - * overriding. - */ - static boolean isOverriderOf(Method impl, Method m) { - if (!isPrivate(m.getModifiers()) && !isFinal(m.getModifiers())) { - if (m.getName().equals(impl.getName())) { - if (m.getReturnType() == impl.getReturnType()) { - if (Arrays.equals(m.getParameterTypes(), impl.getParameterTypes())) { - if (isPublic(m.getModifiers()) || isProtected(m.getModifiers())) { - // m is public or protected - return isPublic(impl.getModifiers()) || isProtected(impl.getModifiers()); - } else { - // m is package-private - return impl.getDeclaringClass().getPackage() == m.getDeclaringClass().getPackage(); - } - } - } - } - } - return false; - } - - static final Map, VTable> vtables = new HashMap<>(); - - static class VTable { - - final Map methods = new HashMap<>(); - } - - static synchronized VTable getVTable(Class c) { - VTable vtable = vtables.get(c); - if (vtable == null) { - vtable = new VTable(); - if (c != Object.class) { - VTable superVtable = getVTable(c.getSuperclass()); - vtable.methods.putAll(superVtable.methods); - } - for (Method m : c.getDeclaredMethods()) { - if (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers())) { - if (isAbstract(m.getModifiers())) { - // A subclass makes a concrete method in a superclass abstract - vtable.methods.remove(new NameAndSignature(m)); - } else { - vtable.methods.put(new NameAndSignature(m), m); - } - } - } - vtables.put(c, vtable); - } - return vtable; - } - - static Set findDeclarations(Method impl, Class c) { - Set declarations = new HashSet<>(); - NameAndSignature implSig = new NameAndSignature(impl); - if (c != null) { - for (Method m : c.getDeclaredMethods()) { - if (new NameAndSignature(m).equals(implSig)) { - declarations.add(m); - break; - } - } - if (!c.isInterface()) { - declarations.addAll(findDeclarations(impl, c.getSuperclass())); - } - for (Class i : c.getInterfaces()) { - declarations.addAll(findDeclarations(impl, i)); - } - } - return declarations; - } - - @Test - public void resolveMethodTest() { - ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - if (c.isInterface()) { - for (Method m : c.getDeclaredMethods()) { - ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveMethod(resolved, context); - assertEquals(m.toString(), null, impl); - } - } else if (c.isPrimitive()) { - assertEquals("No methods expected", c.getDeclaredMethods().length, 0); - } else { - VTable vtable = getVTable(c); - for (Method impl : vtable.methods.values()) { - Set decls = findDeclarations(impl, c); - for (Method decl : decls) { - ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); - if (m.isPublic()) { - ResolvedJavaMethod resolvedMethod = type.resolveMethod(m, context); - if (isSignaturePolymorphic(m)) { - // Signature polymorphic methods must not be resolved - assertNull(resolvedMethod); - } else { - ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - assertEquals(m.toString(), i, resolvedMethod); - } - } - } - } - // For backwards compatibility treat constructors as resolvable even though they - // aren't virtually dispatched. - ResolvedJavaType declaringClass = metaAccess.lookupJavaType(c); - for (Constructor m : c.getDeclaredConstructors()) { - ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass); - assertEquals(m.toString(), decl, impl); - } - for (Method m : c.getDeclaredMethods()) { - if (isStatic(m.getModifiers())) { - // resolveMethod really shouldn't be called with static methods and the - // result is is somewhat inconsistent so just ignore them - continue; - } - ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass); - ResolvedJavaMethod expected = isSignaturePolymorphic(decl) ? null : decl; - assertEquals(m.toString(), expected, impl); - } - } - } - } - - @Test - public void resolveConcreteMethodTest() { - ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - if (c.isInterface()) { - for (Method m : c.getDeclaredMethods()) { - ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); - assertEquals(m.toString(), null, impl); - } - } else if (c.isPrimitive()) { - assertEquals("No methods expected", c.getDeclaredMethods().length, 0); - } else { - VTable vtable = getVTable(c); - for (Method impl : vtable.methods.values()) { - Set decls = findDeclarations(impl, c); - for (Method decl : decls) { - ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); - if (m.isPublic()) { - ResolvedJavaMethod resolvedMethod = type.resolveConcreteMethod(m, context); - if (isSignaturePolymorphic(m)) { - // Signature polymorphic methods must not be resolved - assertNull(String.format("Got: %s", resolvedMethod), resolvedMethod); - } else { - ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - assertEquals(i, resolvedMethod); - } - } - } - } - for (Method m : c.getDeclaredMethods()) { - ResolvedJavaMethod impl = type.resolveConcreteMethod(metaAccess.lookupJavaMethod(m), context); - ResolvedJavaMethod expected = isAbstract(m.getModifiers()) ? null : impl; - assertEquals(type + " " + m.toString(), expected, impl); - } - } - } - } - - @Test - public void findUniqueConcreteMethodTest() throws NoSuchMethodException { - ResolvedJavaMethod thisMethod = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("findUniqueConcreteMethodTest")); - ResolvedJavaMethod ucm = metaAccess.lookupJavaType(getClass()).findUniqueConcreteMethod(thisMethod).getResult(); - assertEquals(thisMethod, ucm); - } - - public static List getInstanceFields(Class c, boolean includeSuperclasses) { - if (c.isArray() || c.isPrimitive() || c.isInterface()) { - return List.of(); - } - List result = new ArrayList<>(); - for (Field f : c.getDeclaredFields()) { - if (!Modifier.isStatic(f.getModifiers())) { - result.add(f); - } - } - if (includeSuperclasses && c != Object.class) { - List allFields = getInstanceFields(c.getSuperclass(), true); - allFields.addAll(result); - result = allFields; - } - return result; - } - - public static Set getStaticFields(Class c) { - Set result = new HashSet<>(); - for (Field f : c.getDeclaredFields()) { - if (Modifier.isStatic(f.getModifiers())) { - result.add(f); - } - } - return result; - } - - public boolean fieldsEqual(Field f, ResolvedJavaField rjf) { - return rjf.getDeclaringClass().equals(metaAccess.lookupJavaType(f.getDeclaringClass())) && rjf.getName().equals(f.getName()) && - rjf.getType().resolve(rjf.getDeclaringClass()).equals(metaAccess.lookupJavaType(f.getType())); - } - - public ResolvedJavaField lookupField(ResolvedJavaField[] fields, Field key) { - for (ResolvedJavaField rf : fields) { - if (fieldsEqual(key, rf)) { - return rf; - } - } - return null; - } - - public Field lookupField(Collection fields, ResolvedJavaField key) { - for (Field f : fields) { - if (fieldsEqual(f, key)) { - return f; - } - } - return null; - } - - /** - * Replicates the semantics of jdk.internal.reflect.Reflection#fieldFilterMap. - */ - private static boolean isHiddenFromReflection(ResolvedJavaField f) { - if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(Class.class))) { - String name = f.getName(); - return name.equals("classLoader") || - name.equals("classData") || - name.equals("modifiers") || - name.equals("protectionDomain") || - name.equals("primitive"); - } - if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(Lookup.class))) { - return f.getName().equals("allowedModes") || f.getName().equals("lookupClass"); - } - if (f.getDeclaringClass().equals(metaAccess.lookupJavaType(ClassLoader.class)) || - f.getDeclaringClass().equals(metaAccess.lookupJavaType(AccessibleObject.class)) || - f.getDeclaringClass().equals(metaAccess.lookupJavaType(Constructor.class)) || - f.getDeclaringClass().equals(metaAccess.lookupJavaType(Field.class)) || - f.getDeclaringClass().equals(metaAccess.lookupJavaType(Method.class)) || - f.getDeclaringClass().equals(metaAccess.lookupJavaType(Module.class))) { - return true; - } - return false; - } - - @Test - public void getInstanceFieldsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - for (boolean includeSuperclasses : new boolean[]{true, false}) { - List reflectFields = getInstanceFields(c, includeSuperclasses); - ResolvedJavaField[] fields = type.getInstanceFields(includeSuperclasses); - int reflectFieldIndex = 0; - for (int i = 0; i < fields.length; i++) { - ResolvedJavaField field = fields[i]; - var mirror = runtime.getMirror(field); - if (field.isInternal()) { - assertNull(field.toString(), mirror); - continue; - } - assertNotNull(field.toString(), mirror); - if (isHiddenFromReflection(field)) { - continue; - } - Field reflectField = reflectFields.get(reflectFieldIndex++); - ResolvedJavaField field2 = lookupField(fields, reflectField); - - assertEquals("ResolvedJavaType.getInstanceFields order differs from Class.getDeclaredFields", field, field2); - } - for (ResolvedJavaField rf : fields) { - if (!isHiddenFromReflection(rf)) { - assertEquals(rf.toString(), lookupField(reflectFields, rf) != null, !rf.isInternal()); - } - } - - // Test stability of getInstanceFields - ResolvedJavaField[] fields2 = type.getInstanceFields(includeSuperclasses); - assertArrayEquals(fields, fields2); - } - } - } - - @Test - public void getStaticFieldsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Set expected = getStaticFields(c); - ResolvedJavaField[] actual = type.getStaticFields(); - for (Field f : expected) { - assertNotNull(lookupField(actual, f)); - } - for (ResolvedJavaField rf : actual) { - var mirror = runtime.getMirror(rf); - assertNotNull(rf.toString(), mirror); - if (!isHiddenFromReflection(rf)) { - assertEquals(lookupField(expected, rf) != null, !rf.isInternal()); - } - } - - // Test stability of getStaticFields - ResolvedJavaField[] actual2 = type.getStaticFields(); - assertArrayEquals(actual, actual2); - } - } - - @Test - public void getDeclaredMethodsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Method[] raw = c.getDeclaredMethods(); - Set expected = new HashSet<>(); - for (Method m : raw) { - ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(m); - assertNotNull(resolvedMethod); - expected.add(resolvedMethod); - } - Set actual = new HashSet<>(Arrays.asList(type.getDeclaredMethods())); - for (ResolvedJavaMethod method : actual) { - assertNotNull(method.toString(), runtime.getMirror(method)); - } - assertEquals(expected, actual); - } - } - - @Test - public void getDeclaredConstructorsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Constructor[] raw = c.getDeclaredConstructors(); - Set expected = new HashSet<>(); - for (Constructor m : raw) { - ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(m); - assertNotNull(resolvedMethod); - expected.add(resolvedMethod); - } - Set actual = new HashSet<>(Arrays.asList(type.getDeclaredConstructors())); - for (ResolvedJavaMethod method : actual) { - assertNotNull(runtime.getMirror(method)); - } - assertEquals(expected, actual); - } - } - - @Test - public void getAllMethodsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - Set allMethods = new HashSet<>(type.getAllMethods(true)); - Stream allKnownMethods = Stream.concat(Arrays.stream(type.getDeclaredMethods()), Arrays.stream(type.getDeclaredConstructors())); - allKnownMethods = Stream.concat(allKnownMethods, Stream.ofNullable(type.getClassInitializer())); - List missingMethods = allKnownMethods.filter(m -> !allMethods.contains(m)).toList(); - assertTrue(missingMethods.toString(), missingMethods.isEmpty()); - } - } - - static class A { - static String name = "foo"; - } - - static class B extends A { - } - - static class C { - } - - static class D { - void foo() { - // use of assertions causes the class to have a - assert getClass() != null; - } - } - - static class SubD extends D { - - } - - private static ResolvedJavaMethod getClassInitializer(Class c) { - ResolvedJavaMethod clinit = metaAccess.lookupJavaType(c).getClassInitializer(); - if (clinit != null) { - assertEquals(0, clinit.getAnnotations().length); - assertEquals(0, clinit.getDeclaredAnnotations().length); - assertNull(runtime.getMirror(clinit)); - } - return clinit; - } - - @Test - public void getClassInitializerTest() { - assertNotNull(getClassInitializer(A.class)); - assertNotNull(getClassInitializer(D.class)); - assertNull(getClassInitializer(B.class)); - assertNull(getClassInitializer(C.class)); - assertNull(getClassInitializer(int.class)); - assertNull(getClassInitializer(void.class)); - for (Class c : classes) { - getClassInitializer(c); - } - } - - @Test - public void getAnnotationsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertArrayEquals(c.getAnnotations(), type.getAnnotations()); - } - } - - @Test - public void getAnnotationTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - for (Annotation a : c.getAnnotations()) { - assertEquals(a, type.getAnnotation(a.annotationType())); - } - } - } - - @Test - public void getSourceFileNameTest() { - Class c = Object.class; - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertEquals(type.getSourceFileName(), "Object.java"); - } - - @Test - public void memberClassesTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertEquals(c.isLocalClass(), type.isLocal()); - assertEquals(c.isMemberClass(), type.isMember()); - Class enclc = c.getEnclosingClass(); - ResolvedJavaType enclt = type.getEnclosingType(); - assertFalse(enclc == null ^ enclt == null); - if (enclc != null) { - assertEquals(enclt, metaAccess.lookupJavaType(enclc)); - } - } - } - - @Test - public void isLeafTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - ResolvedJavaType arrayType = c != void.class ? metaAccess.lookupJavaType(getArrayClass(c)) : null; - if (c.isPrimitive()) { - assertTrue(type.isLeaf()); - assertTrue(arrayType == null || arrayType.isLeaf()); - } else { - assertTrue(c.toString(), type.isLeaf() == arrayType.isLeaf()); - if (!c.isArray()) { - assertTrue(c.toString(), type.isLeaf() == Modifier.isFinal(c.getModifiers())); - } - } - } - } - - static class TrivialCloneable implements Cloneable { - @Override - protected Object clone() { - return new TrivialCloneable(); - } - } - - @Test - public void isCloneableWithAllocationTest() { - ResolvedJavaType cloneable = metaAccess.lookupJavaType(Cloneable.class); - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - if (type.isCloneableWithAllocation()) { - // Only Cloneable types should be allocation cloneable - assertTrue(c.toString(), cloneable.isAssignableFrom(type)); - } - } - /* - * We can't know for sure which types should be allocation cloneable on a particular - * platform but assume that at least totally trivial objects should be. - */ - ResolvedJavaType trivialCloneable = metaAccess.lookupJavaType(TrivialCloneable.class); - assertTrue(trivialCloneable.toString(), trivialCloneable.isCloneableWithAllocation()); - } - - @Test - public void findMethodTest() { - try { - ResolvedJavaMethod findFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("()V")); - ResolvedJavaMethod expectedFoo = metaAccess.lookupJavaMethod(D.class.getDeclaredMethod("foo")); - assertEquals(expectedFoo, findFoo); - - ResolvedJavaMethod wrongReturnTypeFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("()I")); - assertNull(wrongReturnTypeFoo); - - ResolvedJavaMethod wrongArgumentsFoo = metaAccess.lookupJavaType(D.class).findMethod("foo", metaAccess.parseMethodDescriptor("(I)V")); - assertNull(wrongArgumentsFoo); - - ResolvedJavaMethod wrongNameFoo = metaAccess.lookupJavaType(D.class).findMethod("bar", metaAccess.parseMethodDescriptor("()V")); - assertNull(wrongNameFoo); - - ResolvedJavaMethod wrongClassFoo = metaAccess.lookupJavaType(SubD.class).findMethod("foo", metaAccess.parseMethodDescriptor("()V")); - assertNull(wrongClassFoo); - } catch (NoSuchMethodException | SecurityException e) { - throw new RuntimeException(e); - } - } - - private Method findTestMethod(Method apiMethod) { - String testName = apiMethod.getName() + "Test"; - for (Method m : getClass().getDeclaredMethods()) { - if (m.getName().equals(testName) && m.getAnnotation(Test.class) != null) { - return m; - } - } - return null; - } - - @Test - public void getAnnotationDataTest() throws Exception { - getAnnotationDataTest(AnnotationTestInput.AnnotatedClass.class); - getAnnotationDataTest(int.class); - getAnnotationDataTest(void.class); - for (Class c : classes) { - getAnnotationDataTest(c); - } - - // Primitive classes have no annotations but we cannot directly - // test absence of annotations. Instead, just ensure empty answers - // are returned when looking up an arbitrary annotation type. - Class[] prims = {void.class, byte.class, int.class, double.class, float.class, short.class, char.class, long.class}; - ResolvedJavaType overrideType = metaAccess.lookupJavaType(Override.class); - for (Class c : prims) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - AnnotationData ad = type.getAnnotationData(overrideType); - Assert.assertNull(String.valueOf(ad), ad); - List adArray = type.getAnnotationData(overrideType, overrideType); - Assert.assertEquals(0, adArray.size()); - } - - // Test that inherited annotations are handled properly. - ResolvedJavaType namedType = metaAccess.lookupJavaType(AnnotationTestInput.Named.class); - AnnotationData ad = metaAccess.lookupJavaType(AnnotationTestInput.OwnName.class).getAnnotationData(namedType); - Assert.assertEquals("NonInheritedValue", ad.get("value", String.class)); - ad = metaAccess.lookupJavaType(AnnotationTestInput.InheritedName1.class).getAnnotationData(namedType); - Assert.assertEquals("Super1", ad.get("value", String.class)); - ad = metaAccess.lookupJavaType(AnnotationTestInput.InheritedName2.class).getAnnotationData(namedType); - Assert.assertEquals("Super2", ad.get("value", String.class)); - ad = metaAccess.lookupJavaType(AnnotationTestInput.InheritedName3.class).getAnnotationData(namedType); - Assert.assertEquals("Super1", ad.get("value", String.class)); - } - - // @formatter:off - private static final String[] untestedApiMethods = { - "initialize", - "isPrimitive", - "newArray", - "isInitialized", - "isLinked", - "getJavaClass", - "getObjectHub", - "getHostClass", - "hasFinalizableSubclass", - "hasFinalizer", - "isLocal", - "isJavaLangObject", - "isMember", - "getElementalType", - "getEnclosingType", - "lookupType", - "resolveField", - "$jacocoInit" - }; - // @formatter:on - - /** - * Ensures that any new methods added to {@link ResolvedJavaMethod} either have a test written - * for them or are added to {@link #untestedApiMethods}. - */ - @Test - public void testCoverage() { - Set known = new HashSet<>(Arrays.asList(untestedApiMethods)); - for (Method m : ResolvedJavaType.class.getDeclaredMethods()) { - if (findTestMethod(m) == null) { - assertTrue("test missing for " + m, known.contains(m.getName())); - } else { - assertFalse("test should be removed from untestedApiMethods" + m, known.contains(m.getName())); - } - } - } - - private static boolean isSignaturePolymorphic(ResolvedJavaMethod method) { - return method.getAnnotation(SIGNATURE_POLYMORPHIC_CLASS) != null; - } - - private static void getAnnotationDataExpectedToFail(Annotated annotated, ResolvedJavaType... annotationTypes) { - try { - if (annotationTypes.length == 1) { - annotated.getAnnotationData(annotationTypes[0]); - } else { - var tail = Arrays.copyOfRange(annotationTypes, 2, annotationTypes.length); - annotated.getAnnotationData(annotationTypes[0], annotationTypes[1], tail); - } - String s = Stream.of(annotationTypes).map(ResolvedJavaType::toJavaName).collect(Collectors.joining(", ")); - throw new AssertionError("Expected IllegalArgumentException for retrieving (" + s + " from " + annotated); - } catch (IllegalArgumentException iae) { - assertTrue(iae.getMessage(), iae.getMessage().contains("not an annotation interface")); - } - } - - /** - * Tests that {@link AnnotationData} obtained from a {@link Class}, {@link Method} or - * {@link Field} matches {@link AnnotatedElement#getAnnotations()} for the corresponding JVMCI - * object. - * - * @param annotatedElement a {@link Class}, {@link Method} or {@link Field} object - */ - public static void getAnnotationDataTest(AnnotatedElement annotatedElement) throws Exception { - Annotated annotated = toAnnotated(annotatedElement); - ResolvedJavaType objectType = metaAccess.lookupJavaType(Object.class); - ResolvedJavaType suppressWarningsType = metaAccess.lookupJavaType(SuppressWarnings.class); - getAnnotationDataExpectedToFail(annotated, objectType); - getAnnotationDataExpectedToFail(annotated, suppressWarningsType, objectType); - getAnnotationDataExpectedToFail(annotated, suppressWarningsType, suppressWarningsType, objectType); - - // Check that querying a missing annotation returns null or an empty list - assertNull(annotated.getAnnotationData(suppressWarningsType)); - List data = annotated.getAnnotationData(suppressWarningsType, suppressWarningsType); - assertTrue(data.toString(), data.isEmpty()); - data = annotated.getAnnotationData(suppressWarningsType, suppressWarningsType, suppressWarningsType, suppressWarningsType); - assertTrue(data.toString(), data.isEmpty()); - - testGetAnnotationData(annotatedElement, annotated, List.of(annotatedElement.getAnnotations())); - } - - private static void testGetAnnotationData(AnnotatedElement annotatedElement, Annotated annotated, List annotations) throws AssertionError { - ResolvedJavaType suppressWarningsType = metaAccess.lookupJavaType(SuppressWarnings.class); - for (Annotation a : annotations) { - var annotationType = metaAccess.lookupJavaType(a.annotationType()); - AnnotationData ad = annotated.getAnnotationData(annotationType); - assertAnnotationsEquals(a, ad); - - // Check that encoding/decoding produces a stable result - AnnotationData ad2 = annotated.getAnnotationData(annotationType); - assertEquals(ad, ad2); - - List annotationData = annotated.getAnnotationData(annotationType, suppressWarningsType, suppressWarningsType); - assertEquals(1, annotationData.size()); - } - if (annotations.size() < 2) { - return; - } - ResolvedJavaType type1 = metaAccess.lookupJavaType(annotations.get(0).annotationType()); - ResolvedJavaType type2 = metaAccess.lookupJavaType(annotations.get(1).annotationType()); - for (int i = 2; i < annotations.size(); i++) { - - ResolvedJavaType[] types = annotations.// - subList(2, i + 1).// - stream().map(a -> metaAccess.lookupJavaType(a.annotationType())).// - toArray(ResolvedJavaType[]::new); - List annotationData = annotated.getAnnotationData(type1, type2, types); - assertEquals(2 + types.length, annotationData.size()); - - for (int j = 0; j < annotationData.size(); j++) { - Annotation a = annotations.get(j); - AnnotationData ad = annotationData.get(j); - assertAnnotationsEquals(a, ad); - } - } - } - - private static Annotated toAnnotated(AnnotatedElement element) { - if (element instanceof Class t) { - return metaAccess.lookupJavaType(t); - } else if (element instanceof Method m) { - return metaAccess.lookupJavaMethod(m); - } else { - Field f = (Field) element; - return metaAccess.lookupJavaField(f); - } - } - - private static UnresolvedJavaType asType(Class valueType) { - return UnresolvedJavaType.create(MetaUtil.toInternalName(valueType.getName())); - } - - private static void assertAnnotationsEquals(Annotation a, AnnotationData ad) { - Map values = AnnotationSupport.memberValues(a); - for (Map.Entry e : values.entrySet()) { - String name = e.getKey(); - Object aValue = e.getValue(); - Object adValue; - try { - adValue = ad.get(name, Object.class); - } catch (IllegalArgumentException ex) { - assertEquals(aValue.toString(), ex.getMessage()); - continue; - } - try { - assertAnnotationElementsEqual(aValue, adValue); - } catch (ClassCastException ex) { - throw new AssertionError(a.getClass().getName() + "." + name + " has wrong type: " + adValue.getClass().getName(), ex); - } - } - } - - private static void assertAnnotationElementsEqual(Object aValue, Object adValue) { - Class valueType = aValue.getClass(); - if (valueType.isEnum()) { - assertEnumObjectsEquals(aValue, adValue); - } else if (aValue instanceof Class) { - assertClassObjectsEquals(aValue, adValue); - } else if (aValue instanceof Annotation) { - assertAnnotationObjectsEquals(aValue, adValue); - } else if (valueType.isArray()) { - List adList = (List) adValue; - int length = Array.getLength(aValue); - assertEquals(length, adList.size()); - for (int i = 0; i < length; i++) { - assertAnnotationElementsEqual(Array.get(aValue, i), adList.get(i)); - } - } else { - assertEquals(aValue.getClass(), adValue.getClass()); - assertEquals(aValue, adValue); - } - } - - private static void assertClassObjectsEquals(Object aValue, Object adValue) { - String aName = ((Class) aValue).getName(); - String adName = ((JavaType) adValue).toClassName(); - assertEquals(aName, adName); - } - - private static void assertEnumObjectsEquals(Object aValue, Object adValue) { - EnumData adEnum = (EnumData) adValue; - String adEnumName = adEnum.getName(); - String aEnumName = ((Enum) aValue).name(); - assertEquals(adEnumName, aEnumName); - } - - private static void assertAnnotationObjectsEquals(Object aValue, Object adValue) { - Annotation aAnnotation = (Annotation) aValue; - AnnotationData adAnnotation = (AnnotationData) adValue; - assertAnnotationsEquals(aAnnotation, adAnnotation); - } - - private static void assertArraysEqual(Object aValue, Object adValue, int length, BiConsumer assertEqualty) { - Object[] aArray = (Object[]) aValue; - Object[] adArray = (Object[]) adValue; - for (int i = 0; i < length; i++) { - assertEqualty.accept(aArray[i], adArray[i]); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSingleImplementor.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSingleImplementor.java deleted file mode 100644 index d403db3848c..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSingleImplementor.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8238190 - * @summary Verify single interface implementor recording supports diamond-shaped class hierarchies - * @requires vm.jvmci - * @library ../../../../../ - * @modules java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestSingleImplementor - */ - -package jdk.vm.ci.runtime.test; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.vm.ci.meta.ResolvedJavaType; - - -public class TestSingleImplementor extends TypeUniverse { - - static int SideEffect; - - interface I { - void foo(); - } - - interface I1 extends I { - } - - interface I2 extends I { - } - - static class Impl implements I1, I2 { - @Override - public void foo() { - SideEffect = 42; - } - } - - public static void snippetDiamond(I i) { - i.foo(); - } - - @Test - public void testDiamondShape() throws Throwable { - snippetDiamond(new Impl()); - ResolvedJavaType interfaceType = metaAccess.lookupJavaType(I.class); - ResolvedJavaType implementationType = metaAccess.lookupJavaType(Impl.class); - Assert.assertEquals(implementationType, interfaceType.getSingleImplementor()); - } - - interface IF1 { - void foo(); - } - - static class Impl1 implements IF1 { - @Override - public void foo() { - SideEffect = 43; - } - } - - public static void snippetRegular(IF1 i) { - i.foo(); - } - - @Test - public void testRegularShape() throws Throwable { - snippetRegular(new Impl1()); - ResolvedJavaType interfaceType = metaAccess.lookupJavaType(IF1.class); - ResolvedJavaType implementationType = metaAccess.lookupJavaType(Impl1.class); - Assert.assertEquals(implementationType, interfaceType.getSingleImplementor()); - } - -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSpeculationLog.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSpeculationLog.java deleted file mode 100644 index e4d1344a8f6..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestSpeculationLog.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @requires vm.jvmci - * @library ../../../../../ - * @modules java.base/jdk.internal.reflect - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.code - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * jdk.internal.vm.ci/jdk.vm.ci.common - * java.base/jdk.internal.misc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.runtime.test.TestSpeculationLog - */ -package jdk.vm.ci.runtime.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.function.Supplier; - -import org.junit.Assert; -import org.junit.Test; - -import jdk.vm.ci.code.CodeCacheProvider; -import jdk.vm.ci.meta.EncodedSpeculationReason; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.SpeculationLog; -import jdk.vm.ci.meta.SpeculationLog.SpeculationReasonEncoding; -import jdk.vm.ci.runtime.JVMCI; - -public class TestSpeculationLog extends MethodUniverse { - - static final class Dummy implements SpeculationLog.SpeculationReason { - - final int[] ints = {Integer.MIN_VALUE, -42, -1, 0, 1, 42, Integer.MAX_VALUE}; - final long[] longs = {Long.MIN_VALUE, -42, -1, 0, 1, 42, Long.MAX_VALUE}; - final String[] strings = {null, "non-empty string", ""}; - final Collection methods = new ArrayList<>(MethodUniverse.methods.values()).subList(0, 10); - final Collection constructors = new ArrayList<>(MethodUniverse.constructors.values()).subList(0, 10); - final Collection types = new ArrayList<>(TypeUniverse.javaTypes).subList(0, 10); - - private final boolean useCache; - private SpeculationReasonEncoding cachedEncoding; - - Dummy(boolean useCache) { - this.useCache = useCache; - } - - @Override - public SpeculationReasonEncoding encode(Supplier encodingSupplier) { - SpeculationReasonEncoding encoding = cachedEncoding; - if (encoding == null) { - encoding = encodingSupplier.get(); - for (int i : ints) { - encoding.addInt(i); - } - for (long l : longs) { - encoding.addLong(l); - } - for (String s : strings) { - encoding.addString(s); - } - for (ResolvedJavaMethod m : methods) { - encoding.addMethod(m); - } - for (ResolvedJavaMethod c : constructors) { - encoding.addMethod(c); - } - for (ResolvedJavaType t : types) { - encoding.addType(t); - } - encoding.addMethod(null); - encoding.addType(null); - } - if (useCache) { - cachedEncoding = encoding; - } - return encoding; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Dummy) { - Dummy that = (Dummy) obj; - return Arrays.equals(this.ints, that.ints) && - Arrays.equals(this.longs, that.longs) && - Arrays.equals(this.strings, that.strings) && - this.methods.equals(that.methods) && - this.constructors.equals(that.constructors) && - this.types.equals(that.types); - } - return super.equals(obj); - } - - @Override - public int hashCode() { - return 31 * Arrays.hashCode(ints) ^ - Arrays.hashCode(longs) ^ - Arrays.hashCode(strings) ^ - methods.hashCode() ^ - constructors.hashCode() ^ - types.hashCode(); - } - } - - @Test - public synchronized void testSpeculationIdentity() { - CodeCacheProvider codeCache = JVMCI.getRuntime().getHostJVMCIBackend().getCodeCache(); - SpeculationLog log = codeCache.createSpeculationLog(); - Dummy spec1 = new Dummy(true); - Dummy spec2 = new Dummy(false); - Assert.assertTrue(log.maySpeculate(spec1)); - Assert.assertTrue(log.maySpeculate(spec2)); - SpeculationLog.Speculation s1 = log.speculate(spec1); - SpeculationLog.Speculation s2 = log.speculate(spec2); - Assert.assertTrue("Speculation should maintain identity", s1.equals(s2)); - JavaConstant e1 = metaAccess.encodeSpeculation(s1); - JavaConstant e2 = metaAccess.encodeSpeculation(s2); - Assert.assertTrue("speculation encoding should maintain identity", e1.equals(e2)); - } - - @Test - public void testEncodedSpeculationReasonIncludesGroupName() { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - CodeCacheProvider codeCache = JVMCI.getRuntime().getHostJVMCIBackend().getCodeCache(); - SpeculationLog log = codeCache.createSpeculationLog(); - Object[] context = {"context"}; - SpeculationLog.SpeculationReason sr1 = new EncodedSpeculationReason(0, "group0", context); - SpeculationLog.SpeculationReason sr2 = new EncodedSpeculationReason(0, "group1", context); - SpeculationLog.Speculation s1 = log.speculate(sr1); - SpeculationLog.Speculation s2 = log.speculate(sr2); - JavaConstant es1 = metaAccess.encodeSpeculation(s1); - JavaConstant es2 = metaAccess.encodeSpeculation(s2); - if (es1.equals(es2)) { - Assert.fail( - String.format("EncodedSpeculationReasons with different groupName should produce unique encoded speculations:%n" + - " Reason 1: %s%n" + - " Reason 2: %s%n" + - " Speculation 1: %s%n" + - " Speculation 2: %s%n" + - " Encoded speculation 1: %s%n" + - " Encoded speculation 2: %s%n", sr1, sr2, s1, s2, es1, es2)); - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java deleted file mode 100644 index 28ba77fa6b0..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.vm.ci.runtime.test; - -import static java.lang.reflect.Modifier.isFinal; -import static java.lang.reflect.Modifier.isStatic; - -import java.io.Serializable; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.AbstractCollection; -import java.util.AbstractList; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import java.util.TreeMap; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import org.junit.Test; - -import jdk.internal.misc.Unsafe; -import jdk.internal.misc.ScopedMemoryAccess; -import jdk.vm.ci.meta.ConstantReflectionProvider; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaField; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.runtime.JVMCI; - -/** - * Context for type related tests. - */ -public class TypeUniverse { - - public static final Unsafe unsafe; - public static final double JAVA_VERSION = Double.valueOf(System.getProperty("java.specification.version")); - - public static final MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - public static final ConstantReflectionProvider constantReflection = JVMCI.getRuntime().getHostJVMCIBackend().getConstantReflection(); - public static final Collection> classes = new HashSet<>(); - public static final Set javaTypes; - public static final ResolvedJavaType predicateType; - public static final Map, Class> arrayClasses = new HashMap<>(); - - private static List constants; - - public class InnerClass { - - } - - public static class InnerStaticClass { - - } - - public static final class InnerStaticFinalClass { - - } - - private class PrivateInnerClass { - - } - - protected class ProtectedInnerClass { - - } - - static { - Unsafe theUnsafe = null; - try { - theUnsafe = Unsafe.getUnsafe(); - } catch (Exception e) { - try { - Field theUnsafeField = Unsafe.class.getDeclaredField("theUnsafe"); - theUnsafeField.setAccessible(true); - theUnsafe = (Unsafe) theUnsafeField.get(null); - } catch (Exception e1) { - throw (InternalError) new InternalError("unable to initialize unsafe").initCause(e1); - } - } - unsafe = theUnsafe; - - Class[] initialClasses = {void.class, boolean.class, byte.class, short.class, char.class, int.class, float.class, long.class, double.class, Object.class, Class.class, boolean[].class, - byte[].class, short[].class, char[].class, int[].class, float[].class, long[].class, double[].class, Object[].class, Class[].class, List[].class, boolean[][].class, - byte[][].class, short[][].class, char[][].class, int[][].class, float[][].class, long[][].class, double[][].class, Object[][].class, Class[][].class, List[][].class, - ClassLoader.class, String.class, Serializable.class, Cloneable.class, Test.class, TestMetaAccessProvider.class, List.class, Collection.class, Map.class, Queue.class, - HashMap.class, LinkedHashMap.class, IdentityHashMap.class, AbstractCollection.class, AbstractList.class, ArrayList.class, InnerClass.class, InnerStaticClass.class, - InnerStaticFinalClass.class, PrivateInnerClass.class, ProtectedInnerClass.class, ScopedMemoryAccess.class}; - for (Class c : initialClasses) { - addClass(c); - } - Predicate predicate = s -> s.length() == 1; - addClass(predicate.getClass()); - predicateType = metaAccess.lookupJavaType(predicate.getClass()); - - javaTypes = Collections.unmodifiableSet(classes.stream().map(c -> metaAccess.lookupJavaType(c)).collect(Collectors.toSet())); - } - - static class ConstantsUniverse { - static final Object[] ARRAYS = classes.stream().map(c -> c != void.class && !c.isArray() ? Array.newInstance(c, 42) : null).filter(o -> o != null).collect(Collectors.toList()).toArray(); - static final Object CONST1 = new ArrayList<>(); - static final Object CONST2 = new ArrayList<>(); - static final Object CONST3 = new IdentityHashMap<>(); - static final Object CONST4 = new LinkedHashMap<>(); - static final Object CONST5 = new TreeMap<>(); - static final Object CONST6 = new ArrayDeque<>(); - static final Object CONST7 = new LinkedList<>(); - static final Object CONST8 = "a string"; - static final Object CONST9 = 42; - static final Object CONST10 = String.class; - static final Object CONST11 = String[].class; - } - - public static List constants() { - if (constants == null) { - List res = readConstants(JavaConstant.class); - res.addAll(readConstants(ConstantsUniverse.class)); - constants = res; - } - return constants; - } - - public static class ConstantValue { - public final String name; - public final JavaConstant value; - public final Object boxed; - - public ConstantValue(String name, JavaConstant value, Object boxed) { - this.name = name; - this.value = value; - this.boxed = boxed; - } - - @Override - public String toString() { - return name + "=" + value; - } - - public String getSimpleName() { - return name.substring(name.lastIndexOf('.') + 1); - } - } - - /** - * Reads the value of all {@code static final} fields from a given class into an array of - * {@link ConstantValue}s. - */ - public static List readConstants(Class fromClass) { - try { - List res = new ArrayList<>(); - for (Field field : fromClass.getDeclaredFields()) { - if (isStatic(field.getModifiers()) && isFinal(field.getModifiers())) { - ResolvedJavaField javaField = metaAccess.lookupJavaField(field); - Object boxed = field.get(null); - if (boxed instanceof JavaConstant) { - res.add(new ConstantValue(javaField.format("%H.%n"), (JavaConstant) boxed, boxed)); - } else { - JavaConstant value = constantReflection.readFieldValue(javaField, null); - if (value != null) { - res.add(new ConstantValue(javaField.format("%H.%n"), value, boxed)); - if (boxed instanceof Object[]) { - Object[] arr = (Object[]) boxed; - for (int i = 0; i < arr.length; i++) { - JavaConstant element = constantReflection.readArrayElement(value, i); - if (element != null) { - res.add(new ConstantValue(javaField.format("%H.%n[" + i + "]"), element, arr[i])); - } - } - } - } - } - } - } - return res; - } catch (Exception e) { - throw new AssertionError(e); - } - } - - public synchronized Class getArrayClass(Class componentType) { - Class arrayClass = arrayClasses.get(componentType); - if (arrayClass == null) { - arrayClass = Array.newInstance(componentType, 0).getClass(); - arrayClasses.put(componentType, arrayClass); - } - return arrayClass; - } - - public static int dimensions(Class c) { - if (c.getComponentType() != null) { - return 1 + dimensions(c.getComponentType()); - } - return 0; - } - - private static void addClass(Class c) { - if (classes.add(c)) { - if (c.getSuperclass() != null) { - addClass(c.getSuperclass()); - } - for (Class sc : c.getInterfaces()) { - addClass(sc); - } - for (Class dc : c.getDeclaredClasses()) { - addClass(dc); - } - for (Method m : c.getDeclaredMethods()) { - addClass(m.getReturnType()); - for (Class p : m.getParameterTypes()) { - addClass(p); - } - } - - if (c != void.class && dimensions(c) < 2) { - Class arrayClass = Array.newInstance(c, 0).getClass(); - arrayClasses.put(c, arrayClass); - addClass(arrayClass); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/meta/ProfilingInfoTest.java b/test/hotspot/jtreg/compiler/jvmci/meta/ProfilingInfoTest.java deleted file mode 100644 index 278d52322d9..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/meta/ProfilingInfoTest.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * These tests are explicitly testing the profiling behavior of the - * interpreter. C1-based profiling differs slightly and when -Xcomp - * is present, profiles will be created by C1 compiled code, not the - * interpreter. - * - * @test - * @requires vm.jvmci - * @requires vm.compMode != "Xcomp" - * @requires vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel > 1 - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -Xbootclasspath/a:. compiler.jvmci.meta.ProfilingInfoTest - */ -package compiler.jvmci.meta; - -import java.io.Serializable; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -import jdk.vm.ci.hotspot.HotSpotProfilingInfo; -import jdk.vm.ci.meta.JavaTypeProfile; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ProfilingInfo; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; -import jdk.vm.ci.meta.TriState; -import jdk.vm.ci.runtime.JVMCI; - -/** - * Tests profiling information provided by the runtime. - *

- * NOTE: These tests are actually not very robust. The problem is that only partial profiling - * information may be gathered for any given method. For example, HotSpot's advanced compilation - * policy can decide to only gather partial profiles in a first level compilation (see - * AdvancedThresholdPolicy::common(...) in advancedThresholdPolicy.cpp). Because of this, - * occasionally tests for {@link ProfilingInfo#getNullSeen(int)} can fail since HotSpot only sets - * the null_seen bit when doing full profiling. - */ -public class ProfilingInfoTest { - - private static final int N = 10; - private static final double DELTA = 1d / Integer.MAX_VALUE; - - @Test - public void testBranchTakenProbability() { - ProfilingInfo info = profile("branchProbabilitySnippet", 0); - Assert.assertEquals(0.0, info.getBranchTakenProbability(1), DELTA); - Assert.assertEquals(N, info.getExecutionCount(1)); - Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA); - Assert.assertEquals(0, info.getExecutionCount(8)); - - info = profile("branchProbabilitySnippet", 1); - Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA); - Assert.assertEquals(N, info.getExecutionCount(1)); - Assert.assertEquals(0.0, info.getBranchTakenProbability(8), DELTA); - Assert.assertEquals(N, info.getExecutionCount(8)); - - info = profile("branchProbabilitySnippet", 2); - Assert.assertEquals(1.0, info.getBranchTakenProbability(1), DELTA); - Assert.assertEquals(N, info.getExecutionCount(1)); - Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA); - Assert.assertEquals(N, info.getExecutionCount(8)); - - continueProfiling(3 * N, "branchProbabilitySnippet", 0); - Assert.assertEquals(0.25, info.getBranchTakenProbability(1), DELTA); - Assert.assertEquals(4 * N, info.getExecutionCount(1)); - Assert.assertEquals(1.0, info.getBranchTakenProbability(8), DELTA); - Assert.assertEquals(N, info.getExecutionCount(8)); - - resetProfile("branchProbabilitySnippet"); - Assert.assertEquals(-1.0, info.getBranchTakenProbability(1), DELTA); - Assert.assertEquals(0, info.getExecutionCount(1)); - Assert.assertEquals(-1.0, info.getBranchTakenProbability(8), DELTA); - Assert.assertEquals(0, info.getExecutionCount(8)); - } - - public static int branchProbabilitySnippet(int value) { - if (value == 0) { - return -1; - } else if (value == 1) { - return -2; - } else { - return -3; - } - } - - @Test - public void testSwitchProbabilities() { - ProfilingInfo info = profile("switchProbabilitySnippet", 0); - Assert.assertArrayEquals(new double[]{1.0, 0.0, 0.0}, info.getSwitchProbabilities(1), DELTA); - - info = profile("switchProbabilitySnippet", 1); - Assert.assertArrayEquals(new double[]{0.0, 1.0, 0.0}, info.getSwitchProbabilities(1), DELTA); - - info = profile("switchProbabilitySnippet", 2); - Assert.assertArrayEquals(new double[]{0.0, 0.0, 1.0}, info.getSwitchProbabilities(1), DELTA); - - resetProfile("switchProbabilitySnippet"); - Assert.assertNull(info.getSwitchProbabilities(1)); - } - - public static int switchProbabilitySnippet(int value) { - switch (value) { - case 0: - return -1; - case 1: - return -2; - default: - return -3; - } - } - - @Test - public void testProfileInvokeVirtual() { - testTypeProfile("invokeVirtualSnippet", 1); - } - - public static int invokeVirtualSnippet(Object obj) { - return obj.hashCode(); - } - - @Test - public void testTypeProfileInvokeInterface() { - testTypeProfile("invokeInterfaceSnippet", 1); - } - - public static int invokeInterfaceSnippet(CharSequence a) { - return a.length(); - } - - @Test - public void testTypeProfileCheckCast() { - testTypeProfile("checkCastSnippet", 1); - } - - public static Serializable checkCastSnippet(Object obj) { - try { - return (Serializable) obj; - } catch (ClassCastException e) { - return null; - } - } - - @Test - public void testTypeProfileInstanceOf() { - testTypeProfile("instanceOfSnippet", 1); - } - - public static boolean instanceOfSnippet(Object obj) { - return obj instanceof Serializable; - } - - private void testTypeProfile(String testSnippet, int bci) { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaType stringType = metaAccess.lookupJavaType(String.class); - ResolvedJavaType stringBuilderType = metaAccess.lookupJavaType(StringBuilder.class); - - ProfilingInfo info = profile(testSnippet, "ABC"); - JavaTypeProfile typeProfile = info.getTypeProfile(bci); - Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA); - Assert.assertEquals(1, typeProfile.getTypes().length); - Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType()); - Assert.assertEquals(1.0, typeProfile.getTypes()[0].getProbability(), DELTA); - - continueProfiling(testSnippet, new StringBuilder()); - typeProfile = info.getTypeProfile(bci); - Assert.assertEquals(0.0, typeProfile.getNotRecordedProbability(), DELTA); - Assert.assertEquals(2, typeProfile.getTypes().length); - Assert.assertEquals(stringType, typeProfile.getTypes()[0].getType()); - Assert.assertEquals(stringBuilderType, typeProfile.getTypes()[1].getType()); - Assert.assertEquals(0.5, typeProfile.getTypes()[0].getProbability(), DELTA); - Assert.assertEquals(0.5, typeProfile.getTypes()[1].getProbability(), DELTA); - - resetProfile(testSnippet); - typeProfile = info.getTypeProfile(bci); - Assert.assertNull(typeProfile); - - // Basic test that the counters are non-negative - HotSpotProfilingInfo hsInfo = (HotSpotProfilingInfo) info; - int count = hsInfo.getDecompileCount(); - Assert.assertTrue("count = " + count, count >= 0); - count = hsInfo.getOverflowRecompileCount(); - Assert.assertTrue("count = " + count, count >= 0); - count = hsInfo.getOverflowTrapCount(); - Assert.assertTrue("count = " + count, count >= 0); - } - - public ProfilingInfoTest() { - } - - @Test - public void testExceptionSeen() { - // NullPointerException - ProfilingInfo info = profile("nullPointerExceptionSnippet", 5); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - - info = profile("nullPointerExceptionSnippet", (Object) null); - Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); - - resetProfile("nullPointerExceptionSnippet"); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - - // ArrayOutOfBoundsException - info = profile("arrayIndexOutOfBoundsExceptionSnippet", new int[1]); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(2)); - - info = profile("arrayIndexOutOfBoundsExceptionSnippet", new int[0]); - Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(2)); - - resetProfile("arrayIndexOutOfBoundsExceptionSnippet"); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(2)); - - // CheckCastException - info = profile("checkCastExceptionSnippet", "ABC"); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - - info = profile("checkCastExceptionSnippet", 5); - Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); - - resetProfile("checkCastExceptionSnippet"); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - - // Invoke with exception - info = profile("invokeWithExceptionSnippet", false); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - - info = profile("invokeWithExceptionSnippet", true); - Assert.assertEquals(TriState.TRUE, info.getExceptionSeen(1)); - - resetProfile("invokeWithExceptionSnippet"); - Assert.assertEquals(TriState.FALSE, info.getExceptionSeen(1)); - } - - public static int nullPointerExceptionSnippet(Object obj) { - try { - return obj.hashCode(); - } catch (NullPointerException e) { - return 1; - } - } - - public static int arrayIndexOutOfBoundsExceptionSnippet(int[] array) { - try { - return array[0]; - } catch (ArrayIndexOutOfBoundsException e) { - return 1; - } - } - - public static int checkCastExceptionSnippet(Object obj) { - try { - return ((String) obj).length(); - } catch (ClassCastException e) { - return 1; - } - } - - public static int invokeWithExceptionSnippet(boolean doThrow) { - try { - return throwException(doThrow); - } catch (IllegalArgumentException e) { - return 1; - } - } - - private static int throwException(boolean doThrow) { - if (doThrow) { - throw new IllegalArgumentException(); - } else { - return 1; - } - } - - @Test - public void testNullSeen() { - testNullSeen("instanceOfSnippet"); - testNullSeen("checkCastSnippet"); - } - - private void testNullSeen(String snippet) { - ProfilingInfo info = profile(snippet, 1); - Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); - - continueProfiling(snippet, "ABC"); - Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); - - continueProfiling(snippet, new Object()); - Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); - - if (TriState.TRUE == info.getNullSeen(1)) { - // See the javadoc comment for ProfilingInfoTest. - continueProfiling(snippet, (Object) null); - Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); - - continueProfiling(snippet, 0.0); - Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); - - continueProfiling(snippet, new Object()); - Assert.assertEquals(TriState.TRUE, info.getNullSeen(1)); - } - - resetProfile(snippet); - Assert.assertEquals(TriState.FALSE, info.getNullSeen(1)); - } - - private ProfilingInfo profile(String methodName, Object... args) { - return profile(true, N, methodName, args); - } - - private void continueProfiling(String methodName, Object... args) { - profile(false, N, methodName, args); - } - - private void continueProfiling(int executions, String methodName, Object... args) { - profile(false, executions, methodName, args); - } - - private ProfilingInfo profile(boolean resetProfile, int executions, String methodName, Object... args) { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - Method method = getMethod(methodName); - ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); - Assert.assertTrue(javaMethod.isStatic()); - if (resetProfile) { - javaMethod.reprofile(); - } - - for (int i = 0; i < executions; ++i) { - try { - method.invoke(null, args); - } catch (Throwable e) { - Assert.fail("method should not throw an exception: " + e.toString()); - } - } - - ProfilingInfo info = javaMethod.getProfilingInfo(); - // The execution counts are low so force maturity - info.setMature(); - return info; - } - - static Method getMethod(String methodName) { - for (Method method : ProfilingInfoTest.class.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - return method; - } - } - throw new IllegalArgumentException(); - } - - private void resetProfile(String methodName) { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(getMethod(methodName)); - javaMethod.reprofile(); - } -} diff --git a/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java b/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java deleted file mode 100644 index 51989a2cd06..00000000000 --- a/test/hotspot/jtreg/compiler/jvmci/meta/StableFieldTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/** - * @test - * @bug 8151664 - * @requires vm.jvmci - * @library /test/lib / - * @modules java.base/jdk.internal.misc - * @modules java.base/jdk.internal.vm.annotation - * jdk.internal.vm.ci/jdk.vm.ci.hotspot - * jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @compile StableFieldTest.java - * @run main/othervm jdk.test.lib.helpers.ClassFileInstaller compiler.jvmci.meta.StableFieldTest - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler -Xbootclasspath/a:. compiler.jvmci.meta.StableFieldTest - */ - -package compiler.jvmci.meta; - -import jdk.internal.vm.annotation.Stable; -import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.runtime.JVMCI; - -public class StableFieldTest { - - @Stable static int myStaticField = 5; - @Stable int myInstanceField = 10; - - public static void main(String[] args) throws Throwable { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - for (String name : new String[] {"myStaticField", "myInstanceField"}) { - java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name); - HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField); - if (!field.isStable()) { - throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField); - } - } - } -} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index cd4f62825e8..07d4ce4f74a 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -926,12 +926,6 @@ public class IRNode { beforeMatchingNameRegex(IF, "If\\b"); } - // Does not work for VM builds without JVMCI like x86_32 (a rule containing this regex will be skipped without having JVMCI built). - public static final String INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP = PREFIX + "INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP" + POSTFIX; - static { - trapNodes(INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, "intrinsic_or_type_checked_inlining"); - } - public static final String INTRINSIC_TRAP = PREFIX + "INTRINSIC_TRAP" + POSTFIX; static { trapNodes(INTRINSIC_TRAP, "intrinsic"); @@ -3607,12 +3601,6 @@ public class IRNode { */ public static void checkIRNodeSupported(String node) throws CheckedTestFrameworkException { switch (node) { - case INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP -> { - if (!WhiteBox.getWhiteBox().isJVMCISupportedByGC()) { - throw new CheckedTestFrameworkException("INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP is unsupported " + - "in builds without JVMCI."); - } - } case CHECKCAST_ARRAYCOPY -> { if (Platform.isS390x()) { throw new CheckedTestFrameworkException("CHECKCAST_ARRAYCOPY is unsupported on s390."); diff --git a/test/hotspot/jtreg/compiler/loopopts/LoopRotateBadNodeBudget.java b/test/hotspot/jtreg/compiler/loopopts/LoopRotateBadNodeBudget.java index ea926ddca28..25ce28e5e6e 100644 --- a/test/hotspot/jtreg/compiler/loopopts/LoopRotateBadNodeBudget.java +++ b/test/hotspot/jtreg/compiler/loopopts/LoopRotateBadNodeBudget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @summary Node estimate for loop rotate is not correct/sufficient: * assert(delta <= 2 * required) failed: Bad node estimate ... * - * @requires vm.compiler2.enabled & !vm.graal.enabled + * @requires vm.compiler2.enabled * * @run main/othervm -XX:PartialPeelNewPhiDelta=5 LoopRotateBadNodeBudget * @run main/othervm -Xbatch -XX:PartialPeelNewPhiDelta=5 LoopRotateBadNodeBudget diff --git a/test/hotspot/jtreg/compiler/loopopts/LoopUnrollBadNodeBudget.java b/test/hotspot/jtreg/compiler/loopopts/LoopUnrollBadNodeBudget.java index 77a8cc0237f..9ad2a2a77da 100644 --- a/test/hotspot/jtreg/compiler/loopopts/LoopUnrollBadNodeBudget.java +++ b/test/hotspot/jtreg/compiler/loopopts/LoopUnrollBadNodeBudget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,6 @@ * @summary Node estimate for loop unrolling is not correct/sufficient: * assert(delta <= 2 * required) failed: Bad node estimate ... * - * @requires !vm.graal.enabled - * * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation * LoopUnrollBadNodeBudget * diff --git a/test/hotspot/jtreg/compiler/loopopts/LoopUnswitchingBadNodeBudget.java b/test/hotspot/jtreg/compiler/loopopts/LoopUnswitchingBadNodeBudget.java index f8f7a0c984f..7ddb495c586 100644 --- a/test/hotspot/jtreg/compiler/loopopts/LoopUnswitchingBadNodeBudget.java +++ b/test/hotspot/jtreg/compiler/loopopts/LoopUnswitchingBadNodeBudget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,6 @@ * @summary Node estimate for loop unswitching is not correct: * assert(delta <= 2 * required) failed: Bad node estimate * - * @requires !vm.graal.enabled - * * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation * -XX:-UseOnStackReplacement -XX:CompileOnly=LoopUnswitchingBadNodeBudget::test * -XX:CompileCommand=dontinline,LoopUnswitchingBadNodeBudget::helper diff --git a/test/hotspot/jtreg/compiler/loopopts/TestDivZeroCheckControl.java b/test/hotspot/jtreg/compiler/loopopts/TestDivZeroCheckControl.java index f38fb403a41..af55ce33f61 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestDivZeroCheckControl.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestDivZeroCheckControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,15 +32,6 @@ * compiler.loopopts.TestDivZeroCheckControl */ -/* - * @test - * @summary Verify that zero check is executed before division/modulo operation. - * @requires vm.graal.enabled - * @run main/othervm -Xbatch - * -XX:CompileCommand=dontinline,compiler.loopopts.TestDivZeroCheckControl::test* - * compiler.loopopts.TestDivZeroCheckControl - */ - package compiler.loopopts; public class TestDivZeroCheckControl { diff --git a/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java b/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java index 378c8e6da75..8edae2bdcee 100644 --- a/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java +++ b/test/hotspot/jtreg/compiler/loopopts/UseCountedLoopSafepointsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop * @library /test/lib / * @requires vm.compMode != "Xint" & vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) & vm.debug == true - * @requires !vm.graal.enabled * @modules java.base/jdk.internal.misc * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java index c7fedf8982e..69b9b132989 100644 --- a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java +++ b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java @@ -26,7 +26,7 @@ * @bug 8241486 * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @requires vm.gc.G1 * @library /test/lib * @run driver TestNoWarningLoopStripMiningIterSet G1 @@ -37,7 +37,7 @@ * @bug 8241486 * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @requires vm.gc.Shenandoah * @library /test/lib * @run driver TestNoWarningLoopStripMiningIterSet Shenandoah @@ -48,7 +48,7 @@ * @bug 8241486 * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @requires vm.gc.Z * @library /test/lib * @run driver TestNoWarningLoopStripMiningIterSet Z @@ -59,7 +59,7 @@ * @bug 8241486 * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.graal.enabled + * @requires vm.flavor == "server" * @requires vm.gc.Epsilon * @library /test/lib * @run driver TestNoWarningLoopStripMiningIterSet Epsilon diff --git a/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java b/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java index 9d64a08b691..79388fe58b8 100644 --- a/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java +++ b/test/hotspot/jtreg/compiler/profiling/TestTypeProfiling.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * @summary Parameters type profiling is not performed from aarch64 interpreter * * @requires os.arch != "arm" - * @requires vm.flavor == "server" & vm.compMode == "Xmixed" & !vm.graal.enabled + * @requires vm.flavor == "server" & vm.compMode == "Xmixed" * * @comment the test can't be run w/ TieredStopAtLevel < 4 * @requires vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4 diff --git a/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckSmearing.java b/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckSmearing.java index 6f9d05899dd..24de4268d1a 100644 --- a/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckSmearing.java +++ b/test/hotspot/jtreg/compiler/rangechecks/TestRangeCheckSmearing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement - * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EagerJVMCI + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions * compiler.rangechecks.TestRangeCheckSmearing * */ diff --git a/test/hotspot/jtreg/compiler/runtime/Test6859338.java b/test/hotspot/jtreg/compiler/runtime/Test6859338.java index ac2eefccfa5..9180906390a 100644 --- a/test/hotspot/jtreg/compiler/runtime/Test6859338.java +++ b/test/hotspot/jtreg/compiler/runtime/Test6859338.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 6859338 * @summary Assertion failure in sharedRuntime.cpp * - * @requires vm.compiler1.enabled | !vm.graal.enabled * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter * compiler.runtime.Test6859338 diff --git a/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java b/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java index 2bf8afae609..5dd938442cc 100644 --- a/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java +++ b/test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java @@ -36,7 +36,6 @@ * @requires vm.opt.TieredStopAtLevel == null & vm.opt.TieredCompilation == null * @requires vm.simpleArch == "x86" | vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64" * @requires vm.debug - * @requires !vm.graal.enabled * @run driver compiler.sharedstubs.SharedStubToInterpTest -XX:-TieredCompilation * */ diff --git a/test/hotspot/jtreg/compiler/tiered/TieredModesTest.java b/test/hotspot/jtreg/compiler/tiered/TieredModesTest.java index aa4dbc4b448..ae1cf26448b 100644 --- a/test/hotspot/jtreg/compiler/tiered/TieredModesTest.java +++ b/test/hotspot/jtreg/compiler/tiered/TieredModesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,9 +33,6 @@ * @run main/othervm -XX:+TieredCompilation -XX:CompilationMode=high-only -XX:TieredStopAtLevel=3 * -XX:CompileCommand=compileonly,compiler.tiered.TieredModesTest::test * compiler.tiered.TieredModesTest - * @run main/othervm -XX:+TieredCompilation -XX:CompilationMode=high-only-quick-internal -XX:TieredStopAtLevel=3 - * -XX:CompileCommand=compileonly,compiler.tiered.TieredModesTest::test - * compiler.tiered.TieredModesTest */ package compiler.tiered; diff --git a/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java b/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java index 678b2883b16..10e8185e05c 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/Decompile.java @@ -56,11 +56,7 @@ public class Decompile { private static final int PerBytecodeTrapLimit = WB.getIntxVMFlag("PerBytecodeTrapLimit").intValue(); // The number of interpreter invocations after which a decompiled method will be re-compiled. private static final int Tier0InvokeNotifyFreq = (int)Math.pow(2, WB.getIntxVMFlag("Tier0InvokeNotifyFreqLog")); - // VM builds without JVMCI like x86_32 call the bimorphic inlining trap just 'bimorphic' - // while all the other builds with JVMCI call it 'bimorphic_or_optimized_type_check'. - // Only builds with JVMCI have the "EnableJVMCI" flag. - private static final boolean isJVMCISupported = (WB.getBooleanVMFlag("EnableJVMCI") != null); - private static final String bimorphicTrapName = isJVMCISupported ? "bimorphic_or_optimized_type_check" : "bimorphic"; + private static final String bimorphicTrapName = "bimorphic"; static class Base { void foo() {} diff --git a/test/hotspot/jtreg/compiler/uncommontrap/Test8009761.java b/test/hotspot/jtreg/compiler/uncommontrap/Test8009761.java index 33278a26eb4..417a676b3fb 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/Test8009761.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/Test8009761.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,7 @@ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss512K - * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EagerJVMCI + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions * -XX:CompileCommand=exclude,compiler.uncommontrap.Test8009761::m2 * compiler.uncommontrap.Test8009761 */ diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java index 1f5fc3d36bd..7a4f15d6461 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 6898462 8198826 * @summary failed reallocations of scalar replaced objects during deoptimization causes crash * - * @requires !vm.graal.enabled * @run main/othervm/timeout=480 -XX:-BackgroundCompilation -Xmx128M -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::main * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::m9_1 @@ -37,7 +36,7 @@ * @test id=Z * @bug 8273456 * @summary Test that ttyLock is ranked above StackWatermark_lock - * @requires !vm.graal.enabled & vm.gc.Z + * @requires vm.gc.Z * @run main/othervm/timeout=480 -XX:-BackgroundCompilation -Xmx128M -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::main * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::m9_1 diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java index d539b56d850..1875230721d 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestUnstableIfTrap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 8030976 8059226 - * @requires !vm.graal.enabled & (vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps) + * @requires (vm.opt.StressUnstableIfTraps == null | !vm.opt.StressUnstableIfTraps) * @library /test/lib / * @library /testlibrary/asm * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java index a124c58055a..38d54f65a32 100644 --- a/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/test/hotspot/jtreg/compiler/unsafe/UnsafeGetStableArrayElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -228,12 +228,7 @@ public class UnsafeGetStableArrayElement { } static void testMismatched(Callable c, Runnable setDefaultAction, boolean objectArray, boolean aligned) throws Exception { - if (Compiler.isGraalEnabled() && !objectArray && aligned) { - // Graal will constant fold mismatched reads from primitive stable arrays, except unaligned ones - run(c, setDefaultAction, null); - } else { - run(c, null, setDefaultAction); - } + run(c, null, setDefaultAction); Setter.reset(); } diff --git a/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java b/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java index 045270e4568..bc293610a10 100644 --- a/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java +++ b/test/hotspot/jtreg/compiler/whitebox/BlockingCompilation.java @@ -28,7 +28,6 @@ * @modules java.base/jdk.internal.misc * @library /test/lib / * - * @requires vm.compiler1.enabled | !vm.graal.enabled * @requires vm.opt.DeoptimizeALot != true * * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/compiler/whitebox/ForceNMethodSweepTest.java b/test/hotspot/jtreg/compiler/whitebox/ForceNMethodSweepTest.java index e55bc33b6ee..cfe58d927c0 100644 --- a/test/hotspot/jtreg/compiler/whitebox/ForceNMethodSweepTest.java +++ b/test/hotspot/jtreg/compiler/whitebox/ForceNMethodSweepTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ * -XX:-TieredCompilation -XX:+WhiteBoxAPI * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* * -XX:-BackgroundCompilation - * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+EagerJVMCI + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions * compiler.whitebox.ForceNMethodSweepTest */ diff --git a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java index a80b16b96a4..34a221b1025 100644 --- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ package gc.arguments; * @test TestTargetSurvivorRatioFlag * @summary Verify that option TargetSurvivorRatio affects survivor space occupancy after minor GC. * @requires vm.opt.ExplicitGCInvokesConcurrent != true - * @requires vm.opt.UseJVMCICompiler != true * @requires vm.gc != "Z" & vm.gc != "Shenandoah" * @library /test/lib * @library / diff --git a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java index 10c85c30c33..24991d06f52 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,10 +55,6 @@ public class TestUseCompressedOopsFlagsWithUlimit { args.add("-XX:MaxRAMPercentage=" + maxrampercent); args.add("-XX:+PrintFlagsFinal"); - // Avoid issues with libjvmci failing to reserve - // a large virtual address space for its heap - args.add("-Xint"); - args.add("-version"); // Convert bytes to kbytes for ulimit -v diff --git a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java index d28c0888579..36e38e6e2fb 100644 --- a/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java +++ b/test/hotspot/jtreg/gc/g1/TestGCLogMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,13 +80,13 @@ public class TestGCLogMessages { } }; - private class LogMessageWithLevelC2OrJVMCIOnly extends LogMessageWithLevel { - public LogMessageWithLevelC2OrJVMCIOnly(String message, Level level) { + private class LogMessageWithLevelC2 extends LogMessageWithLevel { + public LogMessageWithLevelC2(String message, Level level) { super(message, level); } public boolean isAvailable() { - return Compiler.isC2OrJVMCIIncluded(); + return Compiler.isC2Enabled(); } } @@ -182,7 +182,7 @@ public class TestGCLogMessages { // Post Evacuate Cleanup 2 new LogMessageWithLevel("Post Evacuate Cleanup 2:", Level.DEBUG), - new LogMessageWithLevelC2OrJVMCIOnly("Update Derived Pointers", Level.DEBUG), + new LogMessageWithLevelC2("Update Derived Pointers", Level.DEBUG), new LogMessageWithLevel("Resize TLABs \\(ms\\):", Level.DEBUG), new LogMessageWithLevel("Free Collection Set \\(ms\\):", Level.DEBUG), new LogMessageWithLevel("Serial Free Collection Set:", Level.TRACE), diff --git a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java index 26dfe932f59..539b965e895 100644 --- a/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java +++ b/test/hotspot/jtreg/gc/g1/ihop/TestIHOPStatic.java @@ -28,7 +28,6 @@ * @requires vm.gc.G1 * @requires !vm.flightRecorder * @requires vm.opt.ExplicitGCInvokesConcurrent != true - * @requires !vm.graal.enabled * @requires vm.compMode != "Xcomp" * @requires os.maxMemory > 1G * @library /test/lib / diff --git a/test/hotspot/jtreg/gc/z/TestNoUncommit.java b/test/hotspot/jtreg/gc/z/TestNoUncommit.java index cb4ab7923c7..ae3c1aedd93 100644 --- a/test/hotspot/jtreg/gc/z/TestNoUncommit.java +++ b/test/hotspot/jtreg/gc/z/TestNoUncommit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package gc.z; /* * @test TestNoUncommit - * @requires vm.gc.Z & !vm.graal.enabled + * @requires vm.gc.Z * @summary Test ZGC uncommit unused memory disabled * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms512M -Xmx512M -XX:ZUncommitDelay=1 gc.z.TestNoUncommit * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=1 -XX:-ZUncommit gc.z.TestNoUncommit diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 81ab75a9514..6fc59f3b71e 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -223,12 +223,6 @@ public class TestOptionsWithRanges { */ excludeTestMaxRange("CICompilerCount"); - /* - * Exclude JVMCI threads counts from testing similar to other threads counts. - */ - excludeTestMaxRange("JVMCIThreads"); - excludeTestMaxRange("JVMCIHostThreads"); - /* * Exclude below options as their maximum value would consume too much memory * and would affect other tests that run in parallel. diff --git a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java index 617bf910108..1135c4b0abb 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java +++ b/test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -188,10 +188,6 @@ public class JVMOptionsUtils { option.addPrepend("-XX:+UseNUMA"); } - if (name.contains("JVMCI")) { - option.addPrepend("-XX:+EnableJVMCI"); - } - switch (name) { case "MinHeapFreeRatio": option.addPrepend("-XX:MaxHeapFreeRatio=100"); @@ -227,12 +223,6 @@ public class JVMOptionsUtils { case "TLABWasteIncrement": option.addPrepend("-XX:+UseParallelGC"); break; - case "BootstrapJVMCI": - case "PrintBootstrap": - case "JVMCIThreads": - case "JVMCIHostThreads": - option.addPrepend("-XX:+UseJVMCICompiler"); - break; default: /* Do nothing */ break; diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedCPUSpecificClassSpaceReservation.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedCPUSpecificClassSpaceReservation.java index 35e4b9ef233..fdcc35685d2 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedCPUSpecificClassSpaceReservation.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedCPUSpecificClassSpaceReservation.java @@ -1,6 +1,6 @@ /* * Copyright (c) 2023, 2025, Red Hat. All rights reserved. - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /* * @test * @summary Test the various CPU-specific reservation schemes - * @requires vm.bits == 64 & !vm.graal.enabled & vm.debug == true + * @requires vm.bits == 64 & vm.debug == true * @requires vm.flagless * @requires vm.cds * @requires vm.cds.default.archive.available diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java index fe1f8cb92fc..3db403e51c6 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointers.java @@ -25,7 +25,7 @@ * @test * @bug 8024927 * @summary Testing address of compressed class pointer space as best as possible. - * @requires vm.bits == 64 & !vm.graal.enabled + * @requires vm.bits == 64 * @requires vm.flagless * @comment Testing compressed class pointers without compressed oops is not possible * on MacOS because the heap is given an arbitrary address that occasionally diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java index 0e72341e565..d14dbc93245 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ * @test * @summary Testing that, faced with a given (possibly odd) mapping address of class space, the encoding * scheme fits the address - * @requires vm.bits == 64 & !vm.graal.enabled & vm.debug == true + * @requires vm.bits == 64 & vm.debug == true * @requires vm.flagless * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java index 309a77ae7ef..8dab946dbcb 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestDwarf.java @@ -28,7 +28,7 @@ * @summary Test DWARF parser with various crashes if debug symbols are available. If the libjvm debug symbols are not * in the same directory as the libjvm.so file, in a subdirectory called .debug, or in the path specified * by the environment variable _JVM_DWARF_PATH, then no verification of the hs_err_file is done for libjvm.so. - * @requires vm.debug == true & vm.flagless & vm.compMode != "Xint" & os.family == "linux" & !vm.graal.enabled & vm.gc.G1 + * @requires vm.debug == true & vm.flagless & vm.compMode != "Xint" & os.family == "linux" & vm.gc.G1 * @requires !vm.ubsan * @modules java.base/jdk.internal.misc * @run main/native/othervm -Xbootclasspath/a:. -XX:-CreateCoredumpOnCrash TestDwarf diff --git a/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java b/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java index 34075e898d1..a6cb1f64992 100644 --- a/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java +++ b/test/hotspot/jtreg/runtime/NMT/MallocSiteTypeChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -52,7 +52,7 @@ public class MallocSiteTypeChange { output.shouldContain("Baseline taken"); wb.NMTFree(addr); - addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 9 /* mtInternal */ ); + addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 8 /* mtInternal */ ); output = NMTTestUtils.startJcmdVMNativeMemory("detail.diff"); output.shouldContain("(malloc=0KB type=Test -4KB)"); output.shouldContain("(malloc=2KB type=Internal +2KB #1 +1)"); diff --git a/test/hotspot/jtreg/runtime/cds/BootAppendTests.java b/test/hotspot/jtreg/runtime/cds/BootAppendTests.java index 642aa2209f4..07375f8f488 100644 --- a/test/hotspot/jtreg/runtime/cds/BootAppendTests.java +++ b/test/hotspot/jtreg/runtime/cds/BootAppendTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /** * @test - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @summary Testing -Xbootclasspath/a support for CDS * @requires vm.cds * @library /test/lib diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java index 4781b78331f..a43888c81cd 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/MainModuleOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -160,25 +160,20 @@ public class MainModuleOnly extends DynamicArchiveTestBase { .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); }); - boolean skippedTest = false; - if (!Compiler.isGraalEnabled()) { - // run with the archive with the --limit-modules option. - // CDS will be disabled with this options and the main class will be - // loaded from the modular jar. - run(topArchiveName, - "-Xlog:cds+dynamic=debug,cds=debug,class+load=trace", - "-cp", destJar.toString(), - "--limit-modules", "java.base," + TEST_MODULE1, - "--module-path", moduleDir.toString(), - "-m", TEST_MODULE1) - .assertSilentlyDisabledCDS(out -> { - out.shouldHaveExitValue(0) - .shouldMatch("CDS is disabled when the.*option is specified") - .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); - }); - } else { - skippedTest = true; - } + // run with the archive with the --limit-modules option. + // CDS will be disabled with this options and the main class will be + // loaded from the modular jar. + run(topArchiveName, + "-Xlog:cds+dynamic=debug,cds=debug,class+load=trace", + "-cp", destJar.toString(), + "--limit-modules", "java.base," + TEST_MODULE1, + "--module-path", moduleDir.toString(), + "-m", TEST_MODULE1) + .assertSilentlyDisabledCDS(out -> { + out.shouldHaveExitValue(0) + .shouldMatch("CDS is disabled when the.*option is specified") + .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); + }); // run with the archive with the --patch-module option. // CDS will be disabled with this options and the main class will be // loaded from the modular jar. @@ -265,9 +260,5 @@ public class MainModuleOnly extends DynamicArchiveTestBase { .ifAbnormalExit(output -> { output.shouldMatch("os::stat error.*CDS dump aborted"); }); - - if (skippedTest) { - throw new SkippedException("Skipped --limit-modules test; it can't be run with Graal enabled"); - } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java index 6e5ae13a137..6858a9fc183 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,17 +25,10 @@ /* * @test * @summary A few edge cases where there's no class to be included in the dynamic archive. - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @comment The test assumes that when "java -version" is executed, only a very limited number * of classes are loaded, and all of those are loaded from the default shared archive. * - * However, when graal is used as the JIT, many extra classes are loaded during VM start-up. - * Some of those are loaded dynamically from jrt:/. Some classes are also defined by - * LambdaMetafactory. This causes complexity that cannot be easily handled by this test. - * - * The VM code covered by this test can be sufficiently tested with C1/C2. So there's no need - * to bend over backwards to run this test with graal. - * * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes * @build StrConcatApp * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/JigsawOptionsCombo.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/JigsawOptionsCombo.java index 8aadf37e30c..e06ddcc6568 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/JigsawOptionsCombo.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/JigsawOptionsCombo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @test * @summary Test combinations of jigsaw options that affect the use of AppCDS * - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @library /test/lib .. * @compile ../test-classes/Hello.java ../test-classes/HelloMore.java * @run driver JigsawOptionsCombo diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java index cf9ffb2403a..959b507d03b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java @@ -135,35 +135,6 @@ public class AddmodsOption { .shouldContain("WARNING: Using incubator modules: jdk.incubator.vector") .shouldHaveExitValue(0); - if (Compiler.isJVMCIEnabled()) { - // dump an archive with JVMCI option which indirectly adds the - // jdk.internal.vm.ci module using the --add-modules option - archiveName = TestCommon.getNewArchiveName("jvmci-module"); - TestCommon.setCurrentArchiveName(archiveName); - oa = TestCommon.dumpBaseArchive( - archiveName, - loggingOption, - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", - "-version"); - oa.shouldHaveExitValue(0); - - // run with the JVMCI option - oa = TestCommon.execCommon( - loggingOption, - "-XX:+UnlockExperimentalVMOptions", - "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", - "-version"); - try { - oa.shouldHaveExitValue(0) - .shouldMatch("aot,module.*Restored from archive: entry.0x.*name jdk.internal.vm.ci"); - } catch (RuntimeException re) { - // JVMCI compile may not be available - oa.shouldHaveExitValue(1) - .shouldContain("Cannot use JVMCI compiler: No JVMCI compiler found"); - } - } - // dump an archive with multiple modules in -add-modules archiveName = TestCommon.getNewArchiveName("muti-modules"); TestCommon.setCurrentArchiveName(archiveName); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java index 1d2d87809f5..a77c38c21b9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/BootAppendTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /** * @test * @summary AppCDS tests for testing -Xbootclasspath/a - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile src/jdk/test/Main.java * @compile src/com/sun/tools/javac/MyMain.jasm diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/ClassPathTests.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/ClassPathTests.java index 1a80b92ef4e..b91b8b9ae8a 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/ClassPathTests.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/ClassPathTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @library ../.. * @library /test/lib * @compile src/jdk/test/Main.java diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java index c967176b22d..fa275704f00 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/classpathtests/EmptyClassInBootClassPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ * 2) app loader will load the class from the jimage by default; * app loader will load the class from the bootclasspath if the * "--limit-modules java.base" option is specified - * @requires vm.cds & !vm.graal.enabled + * @requires vm.cds * @requires test.thread.factory == null * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @modules java.base/jdk.internal.access diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java index 2fd5ddbd2bb..c6b97335f4d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,24 +143,19 @@ public class MainModuleOnly { .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); }); - boolean skippedTest = false; - if (!Compiler.isGraalEnabled()) { - // run with the archive with the --limit-modules option. - // CDS will be disabled with this options and the main class will be - // loaded from the modular jar. - TestCommon.run("-Xlog:class+load=trace", - "-cp", destJar.toString(), - "--limit-modules", "java.base," + TEST_MODULE1, - "--module-path", moduleDir.toString(), - "-m", TEST_MODULE1) - .assertSilentlyDisabledCDS(out -> { - out.shouldHaveExitValue(0) - .shouldMatch("CDS is disabled when the.*option is specified") - .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); - }); - } else { - skippedTest = true; - } + // run with the archive with the --limit-modules option. + // CDS will be disabled with this options and the main class will be + // loaded from the modular jar. + TestCommon.run("-Xlog:class+load=trace", + "-cp", destJar.toString(), + "--limit-modules", "java.base," + TEST_MODULE1, + "--module-path", moduleDir.toString(), + "-m", TEST_MODULE1) + .assertSilentlyDisabledCDS(out -> { + out.shouldHaveExitValue(0) + .shouldMatch("CDS is disabled when the.*option is specified") + .shouldMatch(".class.load. com.simple.Main source:.*com.simple.jar"); + }); // run with the archive with the --patch-module option. // CDS will be disabled with this options and the main class will be // loaded from the modular jar. @@ -243,9 +238,5 @@ public class MainModuleOnly { if (output.getExitValue() != 0) { output.shouldMatch("os::stat error.*CDS dump aborted"); } - - if (skippedTest) { - throw new SkippedException("Skipped --limit-modules test; it can't be run with Graal enabled"); - } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java index e5ead078696..1d9ad077f6f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ModulePathAndFMG.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ /** * @test * @bug 8328313 - * @requires vm.cds & !vm.graal.enabled & vm.cds.write.archived.java.heap + * @requires vm.cds & vm.cds.write.archived.java.heap * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @run driver ModulePathAndFMG * @summary test module path changes for full module graph handling. diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java index add9987b382..1a29c9672eb 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/OptimizeModuleHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test - * @requires vm.cds & !vm.graal.enabled & vm.cds.write.archived.java.heap + * @requires vm.cds & vm.cds.write.archived.java.heap * @requires test.thread.factory == null * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @run driver OptimizeModuleHandlingTest diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/parallelLoad/ParallelLoadAndTransformTest.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/parallelLoad/ParallelLoadAndTransformTest.java index 21f809da88e..bb98e262ea9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/parallelLoad/ParallelLoadAndTransformTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/parallelLoad/ParallelLoadAndTransformTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,6 @@ * /test/hotspot/jtreg/runtime/cds/appcds/test-classes /test/hotspot/jtreg/runtime/cds/appcds/jvmti * /test/hotspot/jtreg/testlibrary/jvmti * @requires vm.cds - * @requires !vm.graal.enabled * @requires vm.jvmti * @build TransformUtil TransformerAgent ParallelLoad * @run driver ParallelLoadAndTransformTest diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformInterfaceImplementorAppCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformInterfaceImplementorAppCDS.java index f2f2f9bfdf2..91d796170b4 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformInterfaceImplementorAppCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformInterfaceImplementorAppCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ * /test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes * @requires vm.cds * @requires vm.jvmti - * @requires !vm.graal.enabled * @build TransformUtil TransformerAgent Interface Implementor * @run main/othervm TransformRelatedClassesAppCDS Interface Implementor */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformSuperSubAppCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformSuperSubAppCDS.java index 63d2244f03d..7cebb7ecbb9 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformSuperSubAppCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jvmti/transformRelatedClasses/TransformSuperSubAppCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ * /test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes * @requires vm.cds * @requires vm.jvmti - * @requires !vm.graal.enabled * @build TransformUtil TransformerAgent SubClass SuperClazz * @run main/othervm TransformRelatedClassesAppCDS SuperClazz SubClass */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh index c86adf00881..1afc1e0d749 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh +++ b/test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ do fname="$i$name_suffix" cat << EOF > $fname /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,7 +77,6 @@ EOF cat << EOF >> $fname * @requires vm.cds.supports.aot.class.linking * @comment work around JDK-8345635 - * @requires !vm.jvmci.enabled EOF fi diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java index 76bf66a49b0..10eeef05b7c 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ * @summary Tests how CDS works when critical library classes are replaced with JVMTI ClassFileLoadHook * @library /test/lib * @requires vm.cds.write.archived.java.heap - * @requires !vm.jvmci.enabled * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox * @run main/othervm/native ReplaceCriticalClassesForSubgraphs diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java index 9375903ee21..24257f24190 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformInterfaceAndImplementor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ * @library /test/lib /runtime/cds /testlibrary/jvmti * @requires vm.cds * @requires vm.jvmti - * @requires !vm.graal.enabled * @build TransformUtil TransformerAgent Interface Implementor * @run main/othervm TransformRelatedClasses Interface Implementor */ diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java index 588c994bae7..ccc6e987e5e 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperAndSubClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ * @library /test/lib /runtime/cds /testlibrary/jvmti * @requires vm.cds * @requires vm.jvmti - * @requires !vm.graal.enabled * @build TransformUtil TransformerAgent SubClass SuperClazz * @run main/othervm TransformRelatedClasses SuperClazz SubClass */ diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java index 6bc9dbc511b..688d9e40d36 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/transformRelatedClasses/TransformSuperSubTwoPckgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ * @library /test/lib /runtime/cds /testlibrary/jvmti * @requires vm.cds * @requires vm.jvmti - * @requires !vm.graal.enabled * @build TransformUtil TransformerAgent SubClass SuperClazz * @compile myPkg2/SubClass.java myPkg1/SuperClazz.java * @run main/othervm TransformRelatedClasses myPkg1.SuperClazz myPkg2.SubClass diff --git a/test/hotspot/jtreg/runtime/clinit/ClassInitBarrier.java b/test/hotspot/jtreg/runtime/clinit/ClassInitBarrier.java index 402b38e0666..7dd4f85e25f 100644 --- a/test/hotspot/jtreg/runtime/clinit/ClassInitBarrier.java +++ b/test/hotspot/jtreg/runtime/clinit/ClassInitBarrier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ * @test * @library /test/lib * - * @requires !vm.graal.enabled - * * @run main/othervm/native -Xbatch -XX:CompileCommand=dontinline,*::test* -Xint -DTHROW=false -Xcheck:jni ClassInitBarrier * @run main/othervm/native -Xbatch -XX:CompileCommand=dontinline,*::test* -Xint -DTHROW=true -Xcheck:jni ClassInitBarrier * diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java b/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java index 508dcf197e3..1d64670c211 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/AbstractMethodError/AbstractMethodErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -25,7 +25,7 @@ /** * @test * @summary Check that the verbose message of the AME is printed correctly. - * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & !vm.graal.enabled & vm.opt.UseJVMCICompiler != true & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) + * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) * @requires vm.opt.DeoptimizeALot != true * @library /test/lib / * @build jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java b/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java index cf316a8bfd6..615a4bdba5b 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/ArrayIndexOutOfBoundsExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2019 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,14 +26,10 @@ * @test * @summary Test extended ArrayIndexOutOfBoundsException message. The * message lists information about the array and the indexes involved. - * @comment This will run in 'normal' mode when Graal is not enabled, else - * Graal mode. * @run testng ArrayIndexOutOfBoundsExceptionTest */ /** * @test - * @requires !vm.graal.enabled - * @comment These test C1 and C2 so make no sense when Graal is enabled. * @run testng/othervm/timeout=480 -Xcomp -XX:-TieredCompilation ArrayIndexOutOfBoundsExceptionTest * @run testng/othervm/timeout=480 -Xcomp -XX:TieredStopAtLevel=1 ArrayIndexOutOfBoundsExceptionTest */ diff --git a/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java b/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java index 5891ff60c42..b5e84636379 100644 --- a/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java +++ b/test/hotspot/jtreg/runtime/exceptionMsgs/IncompatibleClassChangeError/IncompatibleClassChangeErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -26,7 +26,7 @@ * @test * @summary Check that the verbose message of ICCE is printed correctly. * The test forces errors in vtable stubs and interpreter. - * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & (!vm.graal.enabled | vm.opt.TieredCompilation == true) & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) + * @requires !(os.arch=="arm") & vm.flavor == "server" & vm.compMode=="Xmixed" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel==4) * @library /test/lib / * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java b/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java index 3a620115b81..ba994ce25b7 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/GetModulesInfo/JvmtiGetAllModulesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,10 +70,6 @@ public class JvmtiGetAllModulesTest { // to be equal to what Java reports modules.removeIf(mod -> !mod.isNamed()); - // jdk.proxy1 and jdk.proxy2 modules are dynamically initialized by Graal code in case Graal VM is used. - // We need to filter them out because they are not part of boot modules. See more details in JDK-8195156. - modules.removeIf(mod -> mod.getName().startsWith("jdk.proxy")); - return modules; } diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java index 33216d64be2..0ed7211940e 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -24,13 +24,9 @@ package MyPackage; -import java.lang.management.ManagementFactory; import java.util.ArrayList; import java.util.List; -import com.sun.management.HotSpotDiagnosticMXBean; -import com.sun.management.VMOption; - /** API for handling the underlying heap sampling monitoring system. */ public class HeapMonitor { private static int[][] arrays; @@ -61,7 +57,7 @@ public class HeapMonitor { int sum = 0; List frames = new ArrayList(); allocate(frames); - frames.add(new Frame("allocate", "()Ljava/util/List;", "HeapMonitor.java", 63)); + frames.add(new Frame("allocate", "()Ljava/util/List;", "HeapMonitor.java", 59)); return frames; } @@ -70,8 +66,8 @@ public class HeapMonitor { for (int j = 0; j < allocationIterations; j++) { sum += actuallyAllocate(); } - frames.add(new Frame("actuallyAllocate", "()I", "HeapMonitor.java", 98)); - frames.add(new Frame("allocate", "(Ljava/util/List;)V", "HeapMonitor.java", 71)); + frames.add(new Frame("actuallyAllocate", "()I", "HeapMonitor.java", 94)); + frames.add(new Frame("allocate", "(Ljava/util/List;)V", "HeapMonitor.java", 67)); } public static List repeatAllocate(int max) { @@ -79,7 +75,7 @@ public class HeapMonitor { for (int i = 0; i < max; i++) { frames = allocate(); } - frames.add(new Frame("repeatAllocate", "(I)Ljava/util/List;", "HeapMonitor.java", 80)); + frames.add(new Frame("repeatAllocate", "(I)Ljava/util/List;", "HeapMonitor.java", 76)); return frames; } @@ -104,10 +100,7 @@ public class HeapMonitor { } private static long oneElementSize; - private static native long getSize(Frame[] frames, boolean checkLines); - private static long getSize(Frame[] frames) { - return getSize(frames, getCheckLines()); - } + private static native long getSize(Frame[] frames); // Calculate the size of a 1-element array in order to assess sampling interval // via the HeapMonitorStatIntervalTest. @@ -119,7 +112,7 @@ public class HeapMonitor { List frameList = allocate(); disableSamplingEvents(); - frameList.add(new Frame("calculateOneElementSize", "()V", "HeapMonitor.java", 119)); + frameList.add(new Frame("calculateOneElementSize", "()V", "HeapMonitor.java", 112)); Frame[] frames = frameList.toArray(new Frame[0]); // Get the actual size. @@ -210,7 +203,7 @@ public class HeapMonitor { System.gc(); List frameList = allocate(); frameList.add(new Frame("allocateAndCheckFrames", "(ZZ)[LMyPackage/Frame;", "HeapMonitor.java", - 211)); + 204)); Frame[] frames = frameList.toArray(new Frame[0]); boolean foundLive = obtainedEvents(frames); @@ -235,41 +228,14 @@ public class HeapMonitor { } public native static int sampledEvents(); - public native static boolean obtainedEvents(Frame[] frames, boolean checkLines); - public native static boolean garbageContains(Frame[] frames, boolean checkLines); + public native static boolean obtainedEvents(Frame[] frames); + public native static boolean garbageContains(Frame[] frames); public native static boolean eventStorageIsEmpty(); public native static void resetEventStorage(); public native static int getEventStorageElementCount(); public native static void forceGarbageCollection(); public native static boolean enableVMEvents(); - private static boolean getCheckLines() { - boolean checkLines = true; - - // Do not check lines for Graal since it is not always "precise" with BCIs at uncommon traps. - try { - HotSpotDiagnosticMXBean bean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); - - VMOption enableJVMCI = bean.getVMOption("EnableJVMCI"); - VMOption useJVMCICompiler = bean.getVMOption("UseJVMCICompiler"); - - checkLines = !(enableJVMCI.getValue().equals("true") - && useJVMCICompiler.getValue().equals("true")); - } catch (Exception e) { - // NOP. - } - - return checkLines; - } - - public static boolean obtainedEvents(Frame[] frames) { - return obtainedEvents(frames, getCheckLines()); - } - - public static boolean garbageContains(Frame[] frames) { - return garbageContains(frames, getCheckLines()); - } - public static boolean statsHaveExpectedNumberSamples(int expected, int acceptedErrorPercentage) { double actual = sampledEvents(); double diffPercentage = 100 * Math.abs(actual - expected) / expected; diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorVMEventsTest.java b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorVMEventsTest.java index 65625aea2e7..4a14c625037 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorVMEventsTest.java +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorVMEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -28,12 +28,10 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadFactory; -// Graal is not tested here due to Graal not supporting DisableIntrinsic. /** * @test * @summary Verifies that when the VM event is sent, sampled events are also collected. * @requires vm.jvmti - * @requires !vm.graal.enabled * @build Frame HeapMonitor * @compile HeapMonitorVMEventsTest.java * @run main/othervm/native -XX:+UnlockDiagnosticVMOptions @@ -45,7 +43,6 @@ import java.util.concurrent.ThreadFactory; * @test * @summary Verifies that when the VM event is sent, sampled events are also collected. * @requires vm.jvmti - * @requires !vm.graal.enabled * @build Frame HeapMonitor * @compile HeapMonitorVMEventsTest.java * @run main/othervm/native -XX:+UnlockDiagnosticVMOptions diff --git a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp index b70f4834f23..33b20454654 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp +++ b/test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitorTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, Google and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -190,7 +190,6 @@ static jboolean check_sample_content(JNIEnv* env, ObjectTrace* trace, ExpectedContentFrame *expected, size_t expected_count, - jboolean check_lines, int print_out_comparisons) { jvmtiFrameInfo* frames; size_t i; @@ -243,10 +242,10 @@ static jboolean check_sample_content(JNIEnv* env, differ = (strcmp(name, expected[i].name) || strcmp(signature, expected[i].signature) || strcmp(file_name, expected[i].file_name) || - (check_lines && line_number != expected[i].line_number)); + line_number != expected[i].line_number); if (print_out_comparisons) { - fprintf(stderr, "\tComparing: (check_lines: %d)\n", check_lines); + fprintf(stderr, "\tComparing:\n"); fprintf(stderr, "\t\tNames: %s and %s\n", name, expected[i].name); fprintf(stderr, "\t\tSignatures: %s and %s\n", signature, expected[i].signature); fprintf(stderr, "\t\tFile name: %s and %s\n", file_name, expected[i].file_name); @@ -446,15 +445,14 @@ static double event_storage_get_average_size(EventStorage* storage) { static jboolean event_storage_contains(JNIEnv* env, EventStorage* storage, ExpectedContentFrame* frames, - size_t size, - jboolean check_lines) { + size_t size) { int i; event_storage_lock(storage); fprintf(stderr, "Checking storage count %d\n", storage->live_object_count); for (i = 0; i < storage->live_object_count; i++) { ObjectTrace* trace = storage->live_objects[i]; - if (check_sample_content(env, trace, frames, size, check_lines, PRINT_OUT)) { + if (check_sample_content(env, trace, frames, size, PRINT_OUT)) { event_storage_unlock(storage); return TRUE; } @@ -466,15 +464,14 @@ static jboolean event_storage_contains(JNIEnv* env, static jlong event_storage_get_size(JNIEnv* env, EventStorage* storage, ExpectedContentFrame* frames, - size_t size, - jboolean check_lines) { + size_t size) { int i; event_storage_lock(storage); fprintf(stderr, "Getting element from storage count, size %d\n", storage->live_object_count); for (i = 0; i < storage->live_object_count; i++) { ObjectTrace* trace = storage->live_objects[i]; - if (check_sample_content(env, trace, frames, size, check_lines, PRINT_OUT)) { + if (check_sample_content(env, trace, frames, size, PRINT_OUT)) { jlong result = trace->size; event_storage_unlock(storage); return result; @@ -487,8 +484,7 @@ static jlong event_storage_get_size(JNIEnv* env, static jboolean event_storage_garbage_contains(JNIEnv* env, EventStorage* storage, ExpectedContentFrame* frames, - size_t size, - jboolean check_lines) { + size_t size) { int i; event_storage_lock(storage); fprintf(stderr, "Checking garbage storage count %d\n", @@ -500,7 +496,7 @@ static jboolean event_storage_garbage_contains(JNIEnv* env, continue; } - if (check_sample_content(env, trace, frames, size, check_lines, PRINT_OUT)) { + if (check_sample_content(env, trace, frames, size, PRINT_OUT)) { event_storage_unlock(storage); return TRUE; } @@ -927,14 +923,13 @@ static ExpectedContentFrame *get_native_frames(JNIEnv* env, jclass cls, JNIEXPORT jboolean JNICALL Java_MyPackage_HeapMonitor_obtainedEvents(JNIEnv* env, jclass cls, - jobjectArray frames, - jboolean check_lines) { + jobjectArray frames) { jboolean result; jsize size = env->GetArrayLength(frames); ExpectedContentFrame *native_frames = get_native_frames(env, cls, frames); result = event_storage_contains(env, &global_event_storage, native_frames, - size, check_lines); + size); free(native_frames), native_frames = nullptr; return result; @@ -942,14 +937,13 @@ Java_MyPackage_HeapMonitor_obtainedEvents(JNIEnv* env, jclass cls, JNIEXPORT jboolean JNICALL Java_MyPackage_HeapMonitor_garbageContains(JNIEnv* env, jclass cls, - jobjectArray frames, - jboolean check_lines) { + jobjectArray frames) { jboolean result; jsize size = env->GetArrayLength(frames); ExpectedContentFrame *native_frames = get_native_frames(env, cls, frames); result = event_storage_garbage_contains(env, &global_event_storage, - native_frames, size, check_lines); + native_frames, size); free(native_frames), native_frames = nullptr; return result; @@ -957,14 +951,13 @@ Java_MyPackage_HeapMonitor_garbageContains(JNIEnv* env, jclass cls, JNIEXPORT jlong JNICALL Java_MyPackage_HeapMonitor_getSize(JNIEnv* env, jclass cls, - jobjectArray frames, - jboolean check_lines) { + jobjectArray frames) { jlong result = 0; jsize size = env->GetArrayLength(frames); ExpectedContentFrame *native_frames = get_native_frames(env, cls, frames); result = event_storage_get_size(env, &global_event_storage, - native_frames, size, check_lines); + native_frames, size); free(native_frames), native_frames = nullptr; return result; diff --git a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineObject.java b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineObject.java index 23fdafe401b..a135d42607b 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineObject.java +++ b/test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/TestRedefineObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import jdk.test.lib.process.OutputAnalyzer; * @test * @bug 8005056 8009728 8218399 * @requires vm.jvmti - * @requires !vm.graal.enabled * @library /test/lib * @modules java.base/jdk.internal.misc * java.instrument diff --git a/test/hotspot/jtreg/serviceability/sa/TestUniverse.java b/test/hotspot/jtreg/serviceability/sa/TestUniverse.java index c519127c4f3..c912421c51b 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestUniverse.java +++ b/test/hotspot/jtreg/serviceability/sa/TestUniverse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,14 +111,6 @@ public class TestUniverse { return false; } - if (Compiler.isGraalEnabled()) { - if (gc == GC.Epsilon || gc == GC.Z || gc == GC.Shenandoah) { - // Not supported - System.out.println ("Skipped testing of " + gc + "GC, not supported by Graal"); - return false; - } - } - // Selected and supported return true; } diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java index e4111238b59..cb5f43b3fb9 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestIRMatching.java @@ -210,13 +210,10 @@ public class TestIRMatching { BadFailOnConstraint.create(Traps.class, "rangeCheck", 2, "CallStaticJava", "uncommon_trap", "range_check"), BadFailOnConstraint.create(Traps.class, "rangeCheck", 3, "CallStaticJava", "uncommon_trap", "null_check"), GoodRuleConstraint.create(Traps.class, "rangeCheck", 4), - BadFailOnConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 1, "CallStaticJava", "uncommon_trap"), - WhiteBox.getWhiteBox().isJVMCISupportedByGC() ? - BadFailOnConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 2, "CallStaticJava", "uncommon_trap", "intrinsic_or_type_checked_inlining") - : GoodRuleConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 2), - BadFailOnConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 3, "CallStaticJava", "uncommon_trap", "intrinsic"), - BadFailOnConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 4, "CallStaticJava", "uncommon_trap", "null_check"), - GoodRuleConstraint.create(Traps.class, "instrinsicOrTypeCheckedInlining", 5) + BadFailOnConstraint.create(Traps.class, "intrinsic", 1, "CallStaticJava", "uncommon_trap"), + BadFailOnConstraint.create(Traps.class, "intrinsic", 2, "CallStaticJava", "uncommon_trap", "intrinsic"), + BadFailOnConstraint.create(Traps.class, "intrinsic", 3, "CallStaticJava", "uncommon_trap", "null_check"), + GoodRuleConstraint.create(Traps.class, "intrinsic", 4) ); @@ -1118,7 +1115,6 @@ class Traps { IRNode.RANGE_CHECK_TRAP, IRNode.CLASS_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void noTraps() { for (int i = 0; i < 100; i++) { @@ -1139,7 +1135,6 @@ class Traps { IRNode.RANGE_CHECK_TRAP, IRNode.CLASS_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void predicateTrap() { for (int i = 0; i < 100; i++) { @@ -1159,7 +1154,6 @@ class Traps { IRNode.RANGE_CHECK_TRAP, IRNode.UNSTABLE_IF_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void nullCheck() { if (myClass instanceof MyClassSub) { @@ -1176,7 +1170,6 @@ class Traps { IRNode.RANGE_CHECK_TRAP, IRNode.CLASS_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public Object nullAssert() { return notLoaded.notLoadedFld; @@ -1192,7 +1185,6 @@ class Traps { IRNode.RANGE_CHECK_TRAP, IRNode.CLASS_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void unstableIf(boolean flag) { if (flag) { @@ -1211,7 +1203,6 @@ class Traps { IRNode.NULL_ASSERT_TRAP, IRNode.RANGE_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void classCheck() { try { @@ -1230,7 +1221,6 @@ class Traps { IRNode.NULL_ASSERT_TRAP, IRNode.CLASS_CHECK_TRAP, IRNode.INTRINSIC_TRAP, - IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP, IRNode.UNHANDLED_TRAP}) public void rangeCheck() { iArr[1] = 3; @@ -1239,7 +1229,6 @@ class Traps { @Test @IR(failOn = IRNode.TRAP) // fails - @IR(failOn = IRNode.INTRINSIC_OR_TYPE_CHECKED_INLINING_TRAP) // fails @IR(failOn = IRNode.INTRINSIC_TRAP) // fails @IR(failOn = IRNode.NULL_CHECK_TRAP) // fails @IR(failOn = {IRNode.PREDICATE_TRAP, @@ -1248,7 +1237,7 @@ class Traps { IRNode.CLASS_CHECK_TRAP, IRNode.RANGE_CHECK_TRAP, IRNode.UNHANDLED_TRAP}) - public void instrinsicOrTypeCheckedInlining() { + public void intrinsic() { System.arraycopy(oArr, 0, mArr, 0, 8); } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java index 8cc023acaae..6bd2c4f4851 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects001/referringObjects001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,6 @@ * referrers with supported type(Strong, PhantomReference, SoftReference, WeakReference) * * @requires vm.gc != "Z" - * @requires !vm.graal.enabled * @library /vmTestbase * /test/lib * @build nsk.jdi.ObjectReference.referringObjects.referringObjects001.referringObjects001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java index a04b323d0d1..a1a191d0071 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/referringObjects/referringObjects003/referringObjects003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,6 @@ * being collected. * - check that there are no references to test threads in target VM * - * @requires !vm.graal.enabled * @library /vmTestbase * /test/lib * @build nsk.jdi.ObjectReference.referringObjects.referringObjects003.referringObjects003 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java index eb979db15e0..ce1b92d0af5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/instances/instances001/instances001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,6 @@ * - check the number of instances is correct * done * - * @requires !vm.graal.enabled * @library /vmTestbase * /test/lib * @build nsk.jdi.ReferenceType.instances.instances001.instances001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java index 079c81cbdc2..577f814601a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ * in debuggee VM through 'ArrayType.newInstance()' till VMOutOfMemoryException. Any other exception * thrown by 'ArrayType.newInstance()' is treated as product bug. * - * @requires !vm.graal.enabled * @library /vmTestbase * /test/lib * @build nsk.jdi.VMOutOfMemoryException.VMOutOfMemoryException001.VMOutOfMemoryException001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java index 98496bb957c..6fc0740f150 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allThreads/allthreads001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -194,8 +194,8 @@ public class allthreads001 { String threadName = "testedThread"; - // Suspend VM to ensure no new background thread (e.g. JVMCI - // compiler thread) is started between two allThreads() calls. + // Suspend VM to ensure no new background thread + // is started between two allThreads() calls. vm.suspend(); List allThreads1 = vm.allThreads(); log2("allThreads1.size() = " + allThreads1.size()); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java index e1a885b4d18..3a853853e9b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/instanceCounts/instancecounts001/instancecounts001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ * - the debugger process checks that instanceCounts returns 0 and no * com.sun.jdi.ObjectCollectedException is thrown * - * @requires !vm.graal.enabled * @library /vmTestbase * /test/lib * @build nsk.jdi.VirtualMachine.instanceCounts.instancecounts001.instancecounts001 diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/ReferringObjects/referringObjects001/referringObjects001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/ReferringObjects/referringObjects001/referringObjects001.java index f578d3be7d4..bcb6dabac75 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/ReferringObjects/referringObjects001/referringObjects001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ObjectReference/ReferringObjects/referringObjects001/referringObjects001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,6 @@ * Finally, debugger sends debuggee signal to quit, waits for it exits * and exits too with the proper exit code. * - * @requires !vm.graal.enabled * @library /vmTestbase /test/hotspot/jtreg/vmTestbase * /test/lib * @run main/othervm/native diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ReferenceType/Instances/instances001/instances001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ReferenceType/Instances/instances001/instances001.java index 5a83ed4435b..9fc64097b16 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ReferenceType/Instances/instances001/instances001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ReferenceType/Instances/instances001/instances001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,6 @@ * and exits too with the proper exit code. * * @requires vm.gc != "Z" - * @requires !vm.graal.enabled * @library /vmTestbase /test/hotspot/jtreg/vmTestbase * /test/lib * @run main/othervm/native diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/InstanceCounts/instanceCounts001/instanceCounts001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/InstanceCounts/instanceCounts001/instanceCounts001.java index dc21d1bc9d3..a8fdde609a5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/InstanceCounts/instanceCounts001/instanceCounts001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/InstanceCounts/instanceCounts001/instanceCounts001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,6 @@ * and exits too with the proper exit code. * * @requires vm.gc != "Z" - * @requires !vm.graal.enabled * @library /vmTestbase /test/hotspot/jtreg/vmTestbase * /test/lib * @build nsk.jdwp.VirtualMachine.InstanceCounts.instanceCounts001.instanceCounts001a diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java index e9f4ee7c4f1..0720b87cb87 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/Allocate/alloc001/alloc001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,8 +87,6 @@ public class alloc001 { "-Djava.library.path=" + Utils.TEST_NATIVE_PATH, "-agentpath:" + Utils.TEST_NATIVE_PATH + File.separator + System.mapLibraryName("alloc001"), "-XX:CompressedClassSpaceSize=64m", - "-Xint", // Avoids issues with libjvmci failing to reserve - // a large virtual address space for its heap Test.class.getName() )); cmd = escapeCmd(cmd); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted002/TestDescription.java index d9f9f5c664b..fff38ac42d4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted002/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ResourceExhausted/resexhausted002/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ * * @library /vmTestbase * /test/lib - * @requires !vm.graal.enabled * @run main/othervm/native * -agentlib:resexhausted=-waittime=5 * -Xms128m diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/TestDriver.java index bf7256652f2..413c92f36ef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF08/gf08t001/TestDriver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,11 +74,6 @@ public class TestDriver { boolean isShenandoahGCon = GC.Shenandoah.isSelected(); boolean isUseEpsilonGCon = GC.Epsilon.isSelected(); - if (Compiler.isGraalEnabled() && - (isUseZGCon || isUseEpsilonGCon || isShenandoahGCon)) { - return; // Graal does not support these GCs - } - String keyPhrase; if ((isExplicitGCInvokesConcurrentOn && isUseG1GCon) || isUseZGCon || isShenandoahGCon) { keyPhrase = "GC"; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp index 542e286c63c..6a02abcd6c3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -601,7 +601,7 @@ int suspendThreadAtMethod(jvmtiEnv *jvmti, jclass cls, jobject thread, jmethodID // We need to ensure that the thread is suspended at the right place when the top // frame belongs to the test rather than to incidental Java code (classloading, - // JVMCI, etc). Below we do resume/suspend in the loop until the target method + // etc). Below we do resume/suspend in the loop until the target method // is executed in the top frame or the loop counter exceeds the limit. for (int i = 0; i < 10; i++) { err = jvmti->GetFrameLocation(thread, 0, &method, &loc); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.hpp b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.hpp index 4a3d3e7bf4f..82888bea21d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.hpp +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -371,7 +371,7 @@ void nsk_jvmti_agentFailed(); /** * This method makes the thread to be suspended at the right place when the top frame -* belongs to the test rather than to incidental Java code (classloading, JVMCI, etc). +* belongs to the test rather than to incidental Java code (classloading, etc). */ int suspendThreadAtMethod(jvmtiEnv *jvmti, jclass cls, jobject thread, jmethodID method); diff --git a/test/jdk/ProblemList-Virtual.txt b/test/jdk/ProblemList-Virtual.txt index 8dd65f257f8..60fa9884522 100644 --- a/test/jdk/ProblemList-Virtual.txt +++ b/test/jdk/ProblemList-Virtual.txt @@ -21,7 +21,7 @@ # questions. # -com/sun/jdi/EATests.java#id0 8264699 generic-all +com/sun/jdi/EATests.java 8264699 generic-all ########## ## Tests failing when main() is executed in additional vthread or in vthread instead of thread diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index 0e339d29cea..08a476427bb 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -95,7 +95,6 @@ requires.properties= \ vm.gc.Shenandoah \ vm.gc.Epsilon \ vm.gc.Z \ - vm.graal.enabled \ vm.compiler1.enabled \ vm.compiler2.enabled \ vm.cds \ @@ -109,8 +108,6 @@ requires.properties= \ vm.debug \ vm.hasSA \ vm.hasJFR \ - vm.jvmci \ - vm.jvmci.enabled \ vm.jvmti \ vm.cpu.features \ container.support \ diff --git a/test/jdk/com/sun/jdi/EATests.java b/test/jdk/com/sun/jdi/EATests.java index f5289e6b011..29f56f977a8 100644 --- a/test/jdk/com/sun/jdi/EATests.java +++ b/test/jdk/com/sun/jdi/EATests.java @@ -105,36 +105,6 @@ * -XX:GuaranteedAsyncDeflationInterval=1 */ -/** - * @test - * @bug 8227745 - * - * @summary This is another configuration of EATests.java to test Graal. Some testcases are expected - * to fail because Graal does not provide all information about non-escaping objects in - * scope. These are skipped. - * - * @author Richard Reingruber richard DOT reingruber AT sap DOT com - * - * @requires ((vm.compMode == "Xmixed") & vm.graal.enabled) - * - * @library /test/lib /test/hotspot/jtreg - * - * @run build TestScaffold VMConnection TargetListener TargetAdapter jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run compile -g EATests.java - * - * @comment Test with Graal. Some testcases are expected to fail because Graal does not provide all information about non-escaping - * objects in scope. These are skipped. - * @run driver EATests - * -XX:+UnlockDiagnosticVMOptions - * -Xms256m -Xmx256m - * -Xbootclasspath/a:. - * -XX:CompileCommand=dontinline,*::dontinline_* - * -XX:+WhiteBoxAPI - * -Xbatch - * -XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler - */ - import com.sun.jdi.*; import com.sun.jdi.event.*; import compiler.testlibrary.CompilerUtils; @@ -297,7 +267,6 @@ public class EATests extends TestScaffold { public static class TargetVMOptions { - public final boolean UseJVMCICompiler; public final boolean EliminateAllocations; public final boolean DeoptimizeObjectsALot; public final boolean DoEscapeAnalysis; @@ -314,8 +283,6 @@ public class EATests extends TestScaffold { EliminateAllocations = DoEscapeAnalysis && ((PrimitiveValue) val).booleanValue(); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("DeoptimizeObjectsALot")); DeoptimizeObjectsALot = ((PrimitiveValue) val).booleanValue(); - val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("UseJVMCICompiler")); - UseJVMCICompiler = ((PrimitiveValue) val).booleanValue(); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ZGCIsSelected")); ZGCIsSelected = ((PrimitiveValue) val).booleanValue(); val = testCaseBaseTargetClass.getValue(testCaseBaseTargetClass.fieldByName("ShenandoahGCIsSelected")); @@ -468,7 +435,7 @@ abstract class EATestCaseBaseDebugger extends EATestCaseBaseShared { /** * Set a breakpoint in the given method and resume all threads. The * breakpoint is configured to suspend just the thread that reaches it - * instead of all threads. This is important when running with graal. + * instead of all threads. */ public BreakpointEvent resumeTo(String clsName, String methodName, String signature) { boolean suspendThreadOnly = true; @@ -806,9 +773,8 @@ abstract class EATestCaseBaseTarget extends EATestCaseBaseShared implements Runn } // Some of the fields are only read by the debugger - public static final boolean UseJVMCICompiler = unbox(WB.getBooleanVMFlag("UseJVMCICompiler"), false); - public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), UseJVMCICompiler); - public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), UseJVMCICompiler); + public static final boolean DoEscapeAnalysis = unbox(WB.getBooleanVMFlag("DoEscapeAnalysis"), false); + public static final boolean EliminateAllocations = unbox(WB.getBooleanVMFlag("EliminateAllocations"), false); public static final boolean DeoptimizeObjectsALot = WB.getBooleanVMFlag("DeoptimizeObjectsALot"); public static final boolean ZGCIsSelected = GC.Z.isSelected(); public static final boolean ShenandoahGCIsSelected = GC.Shenandoah.isSelected(); @@ -994,23 +960,8 @@ abstract class EATestCaseBaseTarget extends EATestCaseBaseShared implements Runn } int highestLevel = CompilerUtils.getMaxCompilationLevel(); int compLevel = WB.getMethodCompilationLevel(m); - if (!UseJVMCICompiler) { - Asserts.assertEQ(highestLevel, compLevel, - m + " not on expected compilation level"); - } else { - // Background compilation (-Xbatch) will block a thread with timeout - // (see CompileBroker::wait_for_jvmci_completion()). Therefore it is - // possible to reach here before the main test method is compiled. - // In that case we wait for it to be compiled. - while (compLevel != highestLevel) { - msg(TESTMETHOD_DEFAULT_NAME + " is compiled on level " + compLevel + - ". Wait until highes level (" + highestLevel + ") is reached."); - try { - Thread.sleep(200); - } catch (InterruptedException e) { /* ignored */ } - compLevel = WB.getMethodCompilationLevel(m); - } - } + Asserts.assertEQ(highestLevel, compLevel, + m + " not on expected compilation level"); } // to be overridden as appropriate @@ -2199,12 +2150,6 @@ class EARelockingArgEscapeLWLockedInCalleeFrameTarget extends EATestCaseBaseTarg l1.dontinline_sync_method(this); // l1 escapes } } - - @Override - public boolean testFrameShouldBeDeoptimized() { - // Graal does not provide debug info about arg escape objects, therefore the frame is not deoptimized - return !UseJVMCICompiler && super.testFrameShouldBeDeoptimized(); - } } ///////////////////////////////////////////////////////////////////////////// @@ -2503,12 +2448,6 @@ class EADeoptFrameAfterReadLocalObject_02Target extends EATestCaseBaseTarget { super.setUp(); testMethodDepth = 2; } - - @Override - public boolean testFrameShouldBeDeoptimized() { - // Graal does not provide debug info about arg escape objects, therefore the frame is not deoptimized - return !UseJVMCICompiler && super.testFrameShouldBeDeoptimized(); - } } ///////////////////////////////////////////////////////////////////////////// @@ -2765,12 +2704,6 @@ class EAPopFrameNotInlined extends EATestCaseBaseDebugger { bpe.thread().popFrames(bpe.thread().frame(0)); msg("PopFrame DONE"); } - - @Override - public boolean shouldSkip() { - // And Graal currently doesn't support PopFrame - return super.shouldSkip() || env.targetVMOptions.UseJVMCICompiler; - } } class EAPopFrameNotInlinedTarget extends EATestCaseBaseTarget { @@ -2792,12 +2725,6 @@ class EAPopFrameNotInlinedTarget extends EATestCaseBaseTarget { public int getExpectedIResult() { return 4 + 2; } - - @Override - public boolean shouldSkip() { - // And Graal currently doesn't support PopFrame - return super.shouldSkip() || UseJVMCICompiler; - } } ///////////////////////////////////////////////////////////////////////////// @@ -2840,14 +2767,12 @@ class EAPopFrameNotInlinedReallocFailure extends EATestCaseBaseDebugger { @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || env.targetVMOptions.ShenandoahGCIsSelected || - env.targetVMOptions.DeoptimizeObjectsALot || - env.targetVMOptions.UseJVMCICompiler; + env.targetVMOptions.DeoptimizeObjectsALot; } } @@ -2886,14 +2811,12 @@ class EAPopFrameNotInlinedReallocFailureTarget extends EATestCaseBaseTarget { @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || ShenandoahGCIsSelected || - DeoptimizeObjectsALot || - UseJVMCICompiler; + DeoptimizeObjectsALot; } } @@ -2940,14 +2863,12 @@ class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailure extends EATestCa @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || env.targetVMOptions.ShenandoahGCIsSelected || - env.targetVMOptions.DeoptimizeObjectsALot || - env.targetVMOptions.UseJVMCICompiler; + env.targetVMOptions.DeoptimizeObjectsALot; } } @@ -3002,14 +2923,12 @@ class EAPopInlinedMethodWithScalarReplacedObjectsReallocFailureTarget extends EA @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't provide all information about non-escaping objects in debug info return super.shouldSkip() || !EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || ShenandoahGCIsSelected || - DeoptimizeObjectsALot || - UseJVMCICompiler; + DeoptimizeObjectsALot; } } @@ -3045,12 +2964,6 @@ class EAForceEarlyReturnNotInlined extends EATestCaseBaseDebugger { printStack(thread); msg("ForceEarlyReturn DONE"); } - - @Override - public boolean shouldSkip() { - // Graal currently doesn't support Force Early Return - return super.shouldSkip() || env.targetVMOptions.UseJVMCICompiler; - } } class EAForceEarlyReturnNotInlinedTarget extends EATestCaseBaseTarget { @@ -3075,12 +2988,6 @@ class EAForceEarlyReturnNotInlinedTarget extends EATestCaseBaseTarget { public boolean testFrameShouldBeDeoptimized() { return true; // because of stepping } - - @Override - public boolean shouldSkip() { - // Graal currently doesn't support Force Early Return - return super.shouldSkip() || UseJVMCICompiler; - } } ///////////////////////////////////////////////////////////////////////////// @@ -3109,12 +3016,6 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjects extends EATestC printStack(thread); msg("ForceEarlyReturn DONE"); } - - @Override - public boolean shouldSkip() { - // Graal currently doesn't support Force Early Return - return super.shouldSkip() || env.targetVMOptions.UseJVMCICompiler; - } } class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsTarget extends EATestCaseBaseTarget { @@ -3159,12 +3060,6 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsTarget extends E public boolean testFrameShouldBeDeoptimized() { return true; // because of stepping } - - @Override - public boolean shouldSkip() { - // Graal currently doesn't support Force Early Return - return super.shouldSkip() || UseJVMCICompiler; - } } ///////////////////////////////////////////////////////////////////////////// @@ -3209,14 +3104,12 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailure e @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't support Force Early Return return super.shouldSkip() || !env.targetVMOptions.EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected env.targetVMOptions.ZGCIsSelected || env.targetVMOptions.ShenandoahGCIsSelected || - env.targetVMOptions.DeoptimizeObjectsALot || - env.targetVMOptions.UseJVMCICompiler; + env.targetVMOptions.DeoptimizeObjectsALot; } } @@ -3272,14 +3165,12 @@ class EAForceEarlyReturnOfInlinedMethodWithScalarReplacedObjectsReallocFailureTa @Override public boolean shouldSkip() { // OOMEs because of realloc failures with DeoptimizeObjectsALot are too random. - // And Graal currently doesn't support Force Early Return return super.shouldSkip() || !EliminateAllocations || // With ZGC or Shenandoah the OOME is not always thrown as expected ZGCIsSelected || ShenandoahGCIsSelected || - DeoptimizeObjectsALot || - UseJVMCICompiler; + DeoptimizeObjectsALot; } } diff --git a/test/jdk/com/sun/jdi/ExceptionEvents.java b/test/jdk/com/sun/jdi/ExceptionEvents.java index ee9e91b4dd9..e4c694d29a0 100644 --- a/test/jdk/com/sun/jdi/ExceptionEvents.java +++ b/test/jdk/com/sun/jdi/ExceptionEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -429,7 +429,6 @@ public class ExceptionEvents extends TestScaffold { request.addClassExclusionFilter("com.oracle.*"); request.addClassExclusionFilter("oracle.*"); request.addClassExclusionFilter("jdk.internal.*"); - request.addClassExclusionFilter("jdk.vm.ci.hotspot.*"); request.setSuspendPolicy(suspendPolicy); request.enable(); diff --git a/test/jdk/com/sun/tools/attach/modules/Driver.java b/test/jdk/com/sun/tools/attach/modules/Driver.java index 94d37531c55..12be9003a9b 100644 --- a/test/jdk/com/sun/tools/attach/modules/Driver.java +++ b/test/jdk/com/sun/tools/attach/modules/Driver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /** * @test - * @requires !vm.graal.enabled * @modules jdk.attach * @build m/* Agent * @run main/othervm -Djdk.attach.allowAttachSelf m/p.Main jmx javaagent diff --git a/test/jdk/java/lang/Class/GetPackageBootLoaderChildLayer.java b/test/jdk/java/lang/Class/GetPackageBootLoaderChildLayer.java index 9be52f15bb6..42d48b75f39 100644 --- a/test/jdk/java/lang/Class/GetPackageBootLoaderChildLayer.java +++ b/test/jdk/java/lang/Class/GetPackageBootLoaderChildLayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /** * @test - * @requires !vm.graal.enabled * @modules jdk.attach * @run main/othervm --limit-modules jdk.attach -Djdk.attach.allowAttachSelf * GetPackageBootLoaderChildLayer diff --git a/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java b/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java index 4f700df33dc..26769df6309 100644 --- a/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java +++ b/test/jdk/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,11 +36,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -267,64 +265,12 @@ public class FieldSetAccessibleTest { } } - /* - * Filter JVMCI module and its transitive dependences - */ static Set systemModules() { - // Build module graph and inverse dependences - Set modules = new HashSet<>(); - Map> moduleToDeps = new HashMap<>(); - Map> inverseDeps = new HashMap<>(); - for (ModuleReference mref : ModuleFinder.ofSystem().findAll()) { - var md = mref.descriptor(); - modules.add(md.name()); - Set deps = md.requires().stream().map(ModuleDescriptor.Requires::name) - .collect(Collectors.toSet()); - moduleToDeps.put(md.name(), deps); - inverseDeps.put(md.name(), new HashSet<>()); - } - - // reverse edges - moduleToDeps.keySet().forEach(u -> { - moduleToDeps.get(u) - .forEach(v -> inverseDeps.get(v) - .add(u)); - }); - - Set mods = Set.of( - // All JVMCI packages other than jdk.vm.ci.services are dynamically - // exported to Graal - "jdk.graal.compiler", "jdk.graal.compiler.management" - ); - // Filters all modules that directly or indirectly require Graal modules - // as these are upgradeable and also provide APIs to add qualified exports dynamically - Set filters = mods.stream().flatMap(mn -> findDeps(mn, inverseDeps).stream()) - .collect(Collectors.toSet()); - System.out.println("Filtered modules: " + filters); - return modules.stream() - .filter(mn -> !filters.contains(mn)) - .collect(Collectors.toSet()); - } - - /* - * Traverse the graph to find all the dependences from the given name. - */ - static Set findDeps(String name, Map> graph) { - Set visited = new HashSet<>(); - Deque deque = new LinkedList<>(); - deque.add(name); - String node; - while (!deque.isEmpty()) { - node = deque.pop(); - if (visited.contains(node)) - continue; - - visited.add(node); - Set deps = graph.get(node); - if (deps != null) - deque.addAll(deps); - } - return visited; + return ModuleFinder.ofSystem() + .findAll() + .stream() + .map(mref -> mref.descriptor().name()) + .collect(Collectors.toSet()); } } } diff --git a/test/jdk/java/lang/StackWalker/LocalsAndOperands.java b/test/jdk/java/lang/StackWalker/LocalsAndOperands.java index 445a4efe649..3f01ad7043d 100644 --- a/test/jdk/java/lang/StackWalker/LocalsAndOperands.java +++ b/test/jdk/java/lang/StackWalker/LocalsAndOperands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ * @test * @bug 8020968 8147039 8156073 * @modules java.base/java.lang:open - * @requires !vm.graal.enabled * @run testng/othervm/timeout=480 -Xcomp -XX:-TieredCompilation LocalsAndOperands */ diff --git a/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java b/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java index a9f35d22597..cedf5f97882 100644 --- a/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java +++ b/test/jdk/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ import java.util.ResourceBundle; * throwing NullPointerException. The test uses --limit-module * to force the selection of one or the other. * @author danielfuchs - * @requires !vm.graal.enabled * @build LoggerFinderAPI * @run main/othervm --limit-modules java.base,java.logging * -Djava.util.logging.SimpleFormatter.format=LOG-%4$s:-[%2$s]-%5$s%6$s%n diff --git a/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java b/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java index 1ca4f3825e5..18413cca5cf 100644 --- a/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java +++ b/test/jdk/java/lang/instrument/TestAgentWithLimitMods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ /** * * @test - * @requires !vm.graal.enabled * @summary Tests that the -javaagent option adds the java.instrument into * the module graph * diff --git a/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java b/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java index f09a51e3c0e..edb308679b7 100644 --- a/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java +++ b/test/jdk/java/lang/management/ManagementFactory/DefaultManagementProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @bug 8151099 * @summary Verify platform MXBeans initialized properly with java.management * module only. No other management provider - * @requires !vm.graal.enabled * @modules java.management * @run main/othervm --limit-modules=java.management DefaultManagementProviderTest */ diff --git a/test/jdk/java/lang/management/ThreadMXBean/ThreadLists.java b/test/jdk/java/lang/management/ThreadMXBean/ThreadLists.java index 12441552900..c80c28a267e 100644 --- a/test/jdk/java/lang/management/ThreadMXBean/ThreadLists.java +++ b/test/jdk/java/lang/management/ThreadMXBean/ThreadLists.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ import java.util.TreeSet; public class ThreadLists { // Thread names permitted to appear during test: - public static final String [] permittedThreadNames = { "ForkJoinPool", "JVMCI" }; + public static final String [] permittedThreadNames = { "ForkJoinPool" }; public static boolean isPermittedNewThread(String name) { for (String s : permittedThreadNames) { diff --git a/test/jdk/java/net/SocketOption/OptionsTest.java b/test/jdk/java/net/SocketOption/OptionsTest.java index e4f64ccfe3b..004b94d5c63 100644 --- a/test/jdk/java/net/SocketOption/OptionsTest.java +++ b/test/jdk/java/net/SocketOption/OptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ * @test * @bug 8036979 8072384 8044773 8225214 8233296 8234083 * @library /test/lib - * @requires !vm.graal.enabled * @run main/othervm -Xcheck:jni OptionsTest * @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest * @run main/othervm --limit-modules=java.base OptionsTest diff --git a/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java b/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java index 0ff62c149c8..57e43d46d1d 100644 --- a/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java +++ b/test/jdk/java/net/SocketOption/UnsupportedOptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,6 @@ import jdk.test.lib.net.IPSupport; * @library /test/lib * @summary Test checks that UnsupportedOperationException for unsupported * SOCKET_OPTIONS is thrown by both getOption() and setOption() methods. - * @requires !vm.graal.enabled * @run main UnsupportedOptionsTest * @run main/othervm -Djava.net.preferIPv4Stack=true UnsupportedOptionsTest * @run main/othervm --limit-modules=java.base UnsupportedOptionsTest diff --git a/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java b/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java index 042421547b6..77115ca0720 100644 --- a/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java +++ b/test/jdk/java/nio/channels/DatagramChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ /* @test * @bug 4640544 8044773 8233435 * @summary Unit test for setOption/getOption/options methods - * @requires !vm.graal.enabled * @library /test/lib * @build jdk.test.lib.net.IPSupport * jdk.test.lib.NetworkConfiguration diff --git a/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java b/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java index 16363194d99..c0a9401e76c 100644 --- a/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java +++ b/test/jdk/java/nio/channels/ServerSocketChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @summary Unit test for ServerSocketChannel setOption/getOption/options * methods. * @modules jdk.net - * @requires !vm.graal.enabled * @run main SocketOptionTests * @run main/othervm --limit-modules=java.base SocketOptionTests */ diff --git a/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java b/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java index 38062517843..a6408b8166b 100644 --- a/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java +++ b/test/jdk/java/nio/channels/SocketChannel/SocketOptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ * methods. * @modules java.base/sun.net.ext * jdk.net - * @requires !vm.graal.enabled * @run main SocketOptionTests * @run main/othervm --limit-modules=java.base SocketOptionTests */ @@ -162,4 +161,4 @@ public class SocketOptionTests { } catch (ClosedChannelException x) { } } -} \ No newline at end of file +} diff --git a/test/jdk/java/util/concurrent/locks/Lock/OOMEInAQS.java b/test/jdk/java/util/concurrent/locks/Lock/OOMEInAQS.java index 0ed76f4b885..c2d56e0dc14 100644 --- a/test/jdk/java/util/concurrent/locks/Lock/OOMEInAQS.java +++ b/test/jdk/java/util/concurrent/locks/Lock/OOMEInAQS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,6 @@ import java.util.stream.Stream; * @summary Check that AQS-based locks, conditions, and CountDownLatches do not fail when encountering OOME * @requires vm.gc.G1 * @requires test.thread.factory == null - * @requires !(vm.graal.enabled & vm.compMode == "Xcomp") * @run main/othervm -XX:+UseG1GC -XX:-UseGCOverheadLimit -Xmx48M -XX:-UseTLAB OOMEInAQS */ diff --git a/test/jdk/java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java b/test/jdk/java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java index 1bec4f21c09..ad831a259f2 100644 --- a/test/jdk/java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java +++ b/test/jdk/java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,6 @@ import java.util.stream.Stream; * @bug 8066859 * @summary An adaptation of OOMEInAQS test for StampedLocks * @requires vm.gc.G1 - * @requires !(vm.graal.enabled & vm.compMode == "Xcomp") * @run main/othervm -XX:+UseG1GC -XX:-UseGCOverheadLimit -Xmx48M -XX:-UseTLAB OOMEInStampedLock */ diff --git a/test/jdk/javax/management/generified/GenericTest.java b/test/jdk/javax/management/generified/GenericTest.java index 226aea681d0..e69f0aa2576 100644 --- a/test/jdk/javax/management/generified/GenericTest.java +++ b/test/jdk/javax/management/generified/GenericTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,7 +79,7 @@ public class GenericTest { Set names3 = checked(((MBeanServerConnection) mbs).queryNames(null, null), ObjectName.class); - // If new MBean (e.g. Graal MBean) is registered while the test is running, names1, + // If new MBean is registered while the test is running, names1, // names2, and names3 will have different sizes. Repeat the test in this case. if (sameSize(names1, names2, names3) || isSecondAttempt) { check("Set MBeanServer.queryNames", names1.size() >= 1); @@ -102,7 +102,7 @@ public class GenericTest { Set mbeans3 = checked(((MBeanServerConnection) mbs).queryMBeans(null, null), ObjectInstance.class); - // If new MBean (e.g. Graal MBean) is registered while the test is running, mbeans1, + // If new MBean is registered while the test is running, mbeans1, // mbeans2, and mbeans3 will have different sizes. Repeat the test in this case. if (sameSize(mbeans1, mbeans2, mbeans3) || isSecondAttempt) { check("Set MBeanServer.queryMBeans", diff --git a/test/jdk/javax/management/query/CustomQueryTest.java b/test/jdk/javax/management/query/CustomQueryTest.java index 11b37efeae3..b2dc0cf6d84 100644 --- a/test/jdk/javax/management/query/CustomQueryTest.java +++ b/test/jdk/javax/management/query/CustomQueryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,7 +91,7 @@ public class CustomQueryTest { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); boolean isSecondAttempt = false; // The test may fail if some new MBean is registered while the test - // is running (e.g. Graal MBean). In this case just retry the test. + // is running. In this case just retry the test. while (true) { mbs.registerMBean(new Count(), countName); int mbeanCount = mbs.getMBeanCount(); diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java deleted file mode 100644 index 446fb891ac4..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/AnnotationTestInput.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Annotation; -import java.lang.annotation.Inherited; -import java.lang.annotation.Repeatable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -public class AnnotationTestInput { - - enum Mood { - HAPPY, - SAD, - CONFUSED; - } - - private class PrivateClass {} - - @Single(string = "a", - stringArray = {"a", "b"}, - classValue = String.class, - classArray = {String.class, Exception.class}, - byteValue = 1, - byteArray = {1, 2, Byte.MIN_VALUE, Byte.MAX_VALUE}, - charValue = 'a', - charArray = {'a', 'b', - Character.MIN_VALUE, Character.MAX_VALUE, - '\b', '\f', '\n', '\r', '\t', '\\', '\'', '\"', '\u012A'}, - doubleValue = 3.3D, - doubleArray = {3.3D, 4.4D, - Double.MIN_VALUE, Double.MAX_VALUE, - Double.NaN, - Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, - floatValue = 4.4F, - floatArray = {4.4F, 5.5F, - Float.MIN_VALUE, Float.MAX_VALUE, - Float.NaN, - Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, - intValue = 5, - intArray = {5, 6, Integer.MIN_VALUE, Integer.MAX_VALUE}, - longValue = 6L, - longArray = {6L, 7L, Long.MIN_VALUE, Long.MAX_VALUE}, - shortValue = 7, - shortArray = {7, 8, Short.MIN_VALUE, Short.MAX_VALUE}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.SAD, - moodArray = {Mood.CONFUSED, Mood.HAPPY}, - nested = @NestedAnno("nested1"), - nestedArray = {@NestedAnno("nested2"), @NestedAnno("nested3")}) - @Single(string = "A", - stringArray = {"A", "B"}, - classValue = Thread.class, - classArray = {Thread.class, PrivateClass.class}, - byteValue = -1, - byteArray = {-1, -2}, - charValue = 'A', - charArray = {'a', 'b'}, - doubleValue = -3.3D, - doubleArray = {3.3D, 4.4D}, - floatValue = -4.4F, - floatArray = {4.4F, 5.5F}, - intValue = -5, - intArray = {5, 6}, - longValue = -6L, - longArray = {6L, 7L}, - shortValue = -7, - shortArray = {7, 8}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.CONFUSED, - moodArray = {Mood.SAD, Mood.CONFUSED}, - nested = @NestedAnno("nested4"), - nestedArray = {@NestedAnno("nested5"), @NestedAnno("nested6")}) - @SingleWithDefaults - @Deprecated - @SuppressWarnings("unchecked") - public void annotatedMethod() { - } - - @Named("Super1") - public static class Super1 {} - @Named("Super2") - public static class Super2 extends Super1 {} - public static class Super3 extends Super1 {} - - @Named("NonInheritedValue") - public static class OwnName extends Super1 {} - - public static class InheritedName1 extends Super1 {} - public static class InheritedName2 extends Super2 {} - public static class InheritedName3 extends Super3 {} - - @Named("AnnotatedClass") - @Single(string = "a", - stringArray = {"a", "b"}, - classValue = String.class, - classArray = {String.class, Exception.class}, - byteValue = 1, - byteArray = {1, 2, Byte.MIN_VALUE, Byte.MAX_VALUE}, - charValue = 'a', - charArray = {'a', 'b', - Character.MIN_VALUE, Character.MAX_VALUE, - '\b', '\f', '\n', '\r', '\t', '\\', '\'', '\"', '\u012A'}, - doubleValue = 3.3D, - doubleArray = {3.3D, 4.4D, - Double.MIN_VALUE, Double.MAX_VALUE, - Double.NaN, - Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, - floatValue = 4.4F, - floatArray = {4.4F, 5.5F, - Float.MIN_VALUE, Float.MAX_VALUE, - Float.NaN, - Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, - intValue = 5, - intArray = {5, 6, Integer.MIN_VALUE, Integer.MAX_VALUE}, - longValue = 6L, - longArray = {6L, 7L, Long.MIN_VALUE, Long.MAX_VALUE}, - shortValue = 7, - shortArray = {7, 8, Short.MIN_VALUE, Short.MAX_VALUE}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.SAD, - moodArray = {Mood.CONFUSED, Mood.HAPPY}, - nested = @NestedAnno("nested7"), - nestedArray = {@NestedAnno("nested8"), @NestedAnno("nested9")}) - @Single(string = "A", - stringArray = {"A", "B"}, - classValue = Thread.class, - classArray = {Thread.class, PrivateClass.class}, - byteValue = -1, - byteArray = {-1, -2}, - charValue = 'A', - charArray = {'a', 'b'}, - doubleValue = -3.3D, - doubleArray = {3.3D, 4.4D}, - floatValue = -4.4F, - floatArray = {4.4F, 5.5F}, - intValue = -5, - intArray = {5, 6}, - longValue = -6L, - longArray = {6L, 7L}, - shortValue = -7, - shortArray = {7, 8}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.CONFUSED, - moodArray = {Mood.SAD, Mood.CONFUSED}, - nested = @NestedAnno("nested10"), - nestedArray = {@NestedAnno("nested11"), @NestedAnno("nested12")}) - @Deprecated - @SuppressWarnings({"rawtypes", "all"}) - public static class AnnotatedClass {} - - @Single(string = "a", - stringArray = {"a", "b"}, - classValue = String.class, - classArray = {String.class, Exception.class}, - byteValue = 1, - byteArray = {1, 2, Byte.MIN_VALUE, Byte.MAX_VALUE}, - charValue = 'a', - charArray = {'a', 'b', - Character.MIN_VALUE, Character.MAX_VALUE, - '\b', '\f', '\n', '\r', '\t', '\\', '\'', '\"', '\u012A'}, - doubleValue = 3.3D, - doubleArray = {3.3D, 4.4D, - Double.MIN_VALUE, Double.MAX_VALUE, - Double.NaN, - Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, - floatValue = 4.4F, - floatArray = {4.4F, 5.5F, - Float.MIN_VALUE, Float.MAX_VALUE, - Float.NaN, - Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, - intValue = 5, - intArray = {5, 6, Integer.MIN_VALUE, Integer.MAX_VALUE}, - longValue = 6L, - longArray = {6L, 7L, Long.MIN_VALUE, Long.MAX_VALUE}, - shortValue = 7, - shortArray = {7, 8, Short.MIN_VALUE, Short.MAX_VALUE}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.SAD, - moodArray = {Mood.CONFUSED, Mood.HAPPY}, - nested = @NestedAnno("nested12"), - nestedArray = {@NestedAnno("nested13"), @NestedAnno("nested14")}) - @Single(string = "A", - stringArray = {"A", "B"}, - classValue = Thread.class, - classArray = {Thread.class, PrivateClass.class}, - byteValue = -1, - byteArray = {-1, -2}, - charValue = 'A', - charArray = {'a', 'b'}, - doubleValue = -3.3D, - doubleArray = {3.3D, 4.4D}, - floatValue = -4.4F, - floatArray = {4.4F, 5.5F}, - intValue = -5, - intArray = {5, 6}, - longValue = -6L, - longArray = {6L, 7L}, - shortValue = -7, - shortArray = {7, 8}, - booleanValue = true, - booleanArray = {true, false}, - mood = Mood.CONFUSED, - moodArray = {Mood.SAD, Mood.CONFUSED}, - nested = @NestedAnno("nested15"), - nestedArray = {@NestedAnno("nested16"), @NestedAnno("nested17")}) - private static final int annotatedField = 45; - - @Retention(RetentionPolicy.RUNTIME) - public @interface NestedAnno { - String value(); - } - - @Inherited - @Retention(RetentionPolicy.RUNTIME) - public @interface Named { - String value(); - } - - @Retention(RetentionPolicy.RUNTIME) - @Repeatable(SingleList.class) - public @interface Single { - Class classValue(); - Class[] classArray(); - - String string(); - String[] stringArray(); - - byte byteValue(); - byte[] byteArray(); - - char charValue(); - char[] charArray(); - - double doubleValue(); - double[] doubleArray(); - - float floatValue(); - float[] floatArray(); - - int intValue(); - int[] intArray(); - - long longValue(); - long[] longArray(); - - short shortValue(); - short[] shortArray(); - - boolean booleanValue(); - boolean[] booleanArray(); - - Mood mood(); - Mood[] moodArray(); - - NestedAnno nested(); - NestedAnno[] nestedArray(); - } - - @Retention(RetentionPolicy.RUNTIME) - @interface SingleWithDefaults { - Class classValue() default SingleWithDefaults.class; - Class[] classArray() default {}; - - String string() default "anonymous"; - String[] stringArray() default {}; - - byte byteValue() default 101; - byte[] byteArray() default {}; - - char charValue() default 'Z'; - char[] charArray() default {}; - - double doubleValue() default 102.102D; - double[] doubleArray() default {}; - - float floatValue() default 103.103F; - float[] floatArray() default {}; - - int intValue() default 104; - int[] intArray() default {}; - - long longValue() default 105L; - long[] longArray() default {}; - - short shortValue() default 105; - short[] shortArray() default {}; - - boolean booleanValue() default true; - boolean[] booleanArray() default {}; - - Mood mood() default Mood.HAPPY; - Mood[] moodArray() default {}; - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface SingleList { - Single[] value(); - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface Missing {} - - @Retention(RetentionPolicy.RUNTIME) - public @interface MissingWrapper { - Missing value(); - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface MissingContainer { - Class value(); - } - - /** - * Method with a directly missing annotation. - */ - @Missing - public void missingAnnotation() {} - - /** - * Method with an indirectly missing nested annotation. - */ - @MissingWrapper(@Missing) - public void missingNestedAnnotation() {} - - /** - * Method with an annotation that has a Class member - * that cannot be resolved. - */ - @MissingContainer(Missing.class) - public void missingTypeOfClassMember() {} - - /** - * Method with an annotation that has a member - * that is deleted in a newer version of the annotation. - */ - @MemberDeleted(value = "evolving", retained = -34, deleted = 56) - public void missingMember() {} - - /** - * Method with an annotation that has a member named "any" - * whose type is changed from int to String in a newer version - * of the annotation. - */ - @MemberTypeChanged(value = "evolving", retained = -34, any = 56) - public void changeTypeOfMember() {} - -} - diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java deleted file mode 100644 index 2707886b4c7..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberDeleted.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface MemberDeleted { - String value(); - int retained(); - int deleted(); -} diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java deleted file mode 100644 index 99670e63b9a..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/MemberTypeChanged.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface MemberTypeChanged { - String value(); - int retained(); - int any(); -} diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/TestAnnotationEncodingDecoding.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/TestAnnotationEncodingDecoding.java deleted file mode 100644 index 64e559a5713..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/TestAnnotationEncodingDecoding.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @compile AnnotationTestInput.java MemberDeleted.java MemberTypeChanged.java - * @modules java.base/jdk.internal.vm - * java.base/sun.reflect.annotation - * @clean jdk.internal.vm.test.AnnotationTestInput$Missing - * @compile alt/MemberDeleted.java alt/MemberTypeChanged.java - * @run testng/othervm - * jdk.internal.vm.test.TestAnnotationEncodingDecoding - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.util.LinkedHashMap; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.TreeMap; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import sun.reflect.annotation.AnnotationSupport; -import sun.reflect.annotation.AnnotationParser; -import sun.reflect.annotation.ExceptionProxy; - -import jdk.internal.vm.VMSupport; -import jdk.internal.vm.VMSupport.AnnotationDecoder; - -public class TestAnnotationEncodingDecoding { - - @Test - public void encodeDecodeTest() throws Exception { - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredField("annotatedField")); - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("annotatedMethod")); - checkDecodedEqualsEncoded(AnnotationTestInput.AnnotatedClass.class); - - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("missingAnnotation")); - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("missingNestedAnnotation"), true); - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("missingTypeOfClassMember"), false); - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("missingMember")); - checkDecodedEqualsEncoded(AnnotationTestInput.class.getDeclaredMethod("changeTypeOfMember"), false); - } - - private void checkDecodedEqualsEncoded(AnnotatedElement annotated) { - checkDecodedEqualsEncoded(annotated, false); - } - - private void checkDecodedEqualsEncoded(AnnotatedElement annotated, boolean expectNCDFE) { - Annotation[] annotations = getAnnotations(annotated, expectNCDFE); - if (annotations == null) { - return; - } - - byte[] encoded = VMSupport.encodeAnnotations(List.of(annotations)); - MyDecoder decoder = new MyDecoder(); - List decoded = VMSupport.decodeAnnotations(encoded, decoder); - int i = 0; - for (AnnotationConst actual : decoded) { - AnnotationConst expect = new AnnotationConst(annotations[i]); - checkEquals(actual, expect); - checkEquals(actual.toString(), expect.toString()); - i++; - } - } - - private static Annotation[] getAnnotations(AnnotatedElement annotated, boolean expectNCDFE) throws AssertionError { - try { - Annotation[] annotations = annotated.getAnnotations(); - Assert.assertFalse(expectNCDFE, annotated.toString()); - return annotations; - } catch (NoClassDefFoundError e) { - if (!expectNCDFE) { - throw new AssertionError(annotated.toString(), e); - } - return null; - } - } - - private static void checkEquals(Object actual, Object expect) { - if (!actual.equals(expect)) { - throw new AssertionError(String.format("actual != expect%nactual: %s%n%nexpect: %s", actual, expect)); - } - } - - public static final class AnnotationConst { - final Class type; - final Map elements; - - AnnotationConst(Class type, Map.Entry[] elements) { - this.type = type; - this.elements = Map.ofEntries(elements); - } - - AnnotationConst(Annotation a) { - Map values = AnnotationSupport.memberValues(a); - this.type = a.annotationType(); - Map.Entry[] elements = new Map.Entry[values.size()]; - int i = 0; - for (Map.Entry e : values.entrySet()) { - elements[i++] = Map.entry(e.getKey(), decodeValue(e.getValue())); - } - this.elements = Map.ofEntries(elements); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof AnnotationConst) { - AnnotationConst that = (AnnotationConst) obj; - return this.type.equals(that.type) && - this.elements.equals(that.elements); - } - return false; - } - - @Override - public String toString() { - return "@" + type.getName() + "(" + elements + ")"; - } - - private Object decodeValue(Object value) { - Class valueType = value.getClass(); - if (value instanceof Enum) { - return new EnumConst(valueType, ((Enum) value).name()); - } else if (value instanceof Annotation) { - return new AnnotationConst((Annotation) value); - } else if (valueType.isArray()) { - int len = Array.getLength(value); - Object[] arr = new Object[len]; - for (int i = 0; i < len; i++) { - arr[i] = decodeValue(Array.get(value, i)); - } - return List.of(arr); - } else if (value instanceof ExceptionProxy) { - return new ErrorConst(value.toString()); - } else { - return value; - } - } - - public Class getType() { - return type; - } - } - - public static final class ErrorConst { - final String desc; - public ErrorConst(String desc) { - this.desc = Objects.requireNonNull(desc); - } - - @Override - public String toString() { - return desc; - } - - @Override - public int hashCode() { - return desc.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ErrorConst) { - return ((ErrorConst) obj).desc.equals(desc); - } - return false; - } - } - - public static final class EnumConst { - final Class type; - final String name; - - public EnumConst(Class type, String name) { - this.type = type; - this.name = name; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof EnumConst) { - EnumConst that = (EnumConst) obj; - return this.type.equals(that.type) && - this.name.equals(that.name); - } - return false; - } - - @Override - public String toString() { - return type.getName() + "." + name; - } - - public Class getEnumType() { - return type; - } - - public String getName() { - return name; - } - } - - static class MyDecoder implements AnnotationDecoder, AnnotationConst, EnumConst, ErrorConst> { - @Override - public Class resolveType(String name) { - try { - return Class.forName(name); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public AnnotationConst newAnnotation(Class type, Map.Entry[] elements) { - return new AnnotationConst(type, elements); - } - - @Override - public EnumConst newEnumValue(Class enumType, String name) { - return new EnumConst(enumType, name); - } - - @Override - public ErrorConst newErrorValue(String description) { - return new ErrorConst(description); - } - } -} diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java deleted file mode 100644 index c27eca83229..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberDeleted.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface MemberDeleted { - String value(); - int retained(); -} diff --git a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java b/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java deleted file mode 100644 index b0518582166..00000000000 --- a/test/jdk/jdk/internal/vm/AnnotationEncodingDecoding/alt/MemberTypeChanged.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.internal.vm.test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface MemberTypeChanged { - String value(); - int retained(); - String any(); -} diff --git a/test/jdk/jdk/internal/vm/TestTranslatedException.java b/test/jdk/jdk/internal/vm/TestTranslatedException.java deleted file mode 100644 index 0a5bfb18c23..00000000000 --- a/test/jdk/jdk/internal/vm/TestTranslatedException.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @modules java.base/jdk.internal.vm - * java.base/jdk.internal.misc - * @run testng/othervm - * jdk.internal.vm.test.TestTranslatedException - */ -package jdk.internal.vm.test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.charset.StandardCharsets; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import jdk.internal.misc.Unsafe; -import jdk.internal.vm.TranslatedException; -import jdk.internal.vm.VMSupport; - -public class TestTranslatedException { - @SuppressWarnings("serial") - public static class Untranslatable extends RuntimeException { - public Untranslatable(String message, Throwable cause) { - super(message, cause); - } - } - - @SuppressWarnings("unchecked") - @Test - public void encodeDecodeTest() throws Exception { - Throwable throwable = new ExceptionInInitializerError(new InvocationTargetException(new Untranslatable("test exception", new NullPointerException()), "invoke")); - for (int i = 0; i < 10; i++) { - throwable = new ExceptionInInitializerError(new InvocationTargetException(new RuntimeException(String.valueOf(i), throwable), "invoke")); - } - encodeDecode(throwable); - - try { - VMSupport.decodeAndThrowThrowable(0, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (NullPointerException decoded) { - // Expected - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - try { - VMSupport.decodeAndThrowThrowable(1, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (InternalError decoded) { - if (!decoded.getMessage().startsWith("native buffer could not be allocated")) { - throw new AssertionError("unexpected exception: " + decoded); - } - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - try { - VMSupport.decodeAndThrowThrowable(2, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (OutOfMemoryError decoded) { - // Expected - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - try { - VMSupport.decodeAndThrowThrowable(3, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (InternalError decoded) { - // Expected - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - try { - VMSupport.decodeAndThrowThrowable(4, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (TranslatedException decoded) { - Assert.assertEquals(decoded.getCause().getClass(), OutOfMemoryError.class); - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - try { - VMSupport.decodeAndThrowThrowable(5, 0L, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (InternalError decoded) { - // Expected - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } - - Unsafe unsafe = Unsafe.getUnsafe(); - byte[] problem = "very unlikely problem".getBytes(StandardCharsets.UTF_8); - long buffer = unsafe.allocateMemory(problem.length + 4); - try { - unsafe.putInt(buffer, problem.length); - unsafe.copyMemory(problem, Unsafe.ARRAY_BYTE_BASE_OFFSET, null, buffer + 4, problem.length); - VMSupport.decodeAndThrowThrowable(3, buffer, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (InternalError decoded) { - String msg = decoded.getMessage(); - if (!msg.endsWith("very unlikely problem")) { - throw new AssertionError("unexpected exception: " + decoded); - } - } catch (Throwable decoded) { - throw new AssertionError("unexpected exception: " + decoded); - } finally { - unsafe.freeMemory(buffer); - } - } - - private void encodeDecode(Throwable throwable) throws Exception { - Unsafe unsafe = Unsafe.getUnsafe(); - int bufferSize = 512; - int format = 0; - long buffer = 0L; - while (true) { - buffer = unsafe.allocateMemory(bufferSize); - try { - int res = VMSupport.encodeThrowable(throwable, buffer, bufferSize); - if (res < 0) { - bufferSize = -res; - } else { - try { - VMSupport.decodeAndThrowThrowable(format, buffer, true, false); - throw new AssertionError("expected decodeAndThrowThrowable to throw an exception"); - } catch (Throwable decoded) { - assertThrowableEquals(throwable, decoded.getCause()); - } - return; - } - } finally { - unsafe.freeMemory(buffer); - } - } - } - - private static void assertThrowableEquals(Throwable originalIn, Throwable decodedIn) { - Throwable original = originalIn; - Throwable decoded = decodedIn; - try { - Assert.assertEquals(original == null, decoded == null); - while (original != null) { - if (Untranslatable.class.equals(original.getClass())) { - Assert.assertEquals(decoded.getClass().getName(), "java.lang.InternalError"); - Assert.assertEquals(decoded.toString(), "java.lang.InternalError: test exception [jdk.internal.vm.test.TestTranslatedException$Untranslatable]"); - Assert.assertEquals(original.getMessage(), "test exception"); - } else { - Assert.assertEquals(decoded.getClass().getName(), original.getClass().getName()); - Assert.assertEquals(decoded.getMessage(), original.getMessage()); - } - StackTraceElement[] originalStack = original.getStackTrace(); - StackTraceElement[] decodedStack = decoded.getStackTrace(); - Assert.assertEquals(originalStack.length, decodedStack.length); - for (int i = 0, n = originalStack.length; i < n; ++i) { - StackTraceElement originalStackElement = originalStack[i]; - StackTraceElement decodedStackElement = decodedStack[i]; - Assert.assertEquals(decodedStackElement.getClassLoaderName(), originalStackElement.getClassLoaderName()); - Assert.assertEquals(decodedStackElement.getModuleName(), originalStackElement.getModuleName()); - Assert.assertEquals(decodedStackElement.getClassName(), originalStackElement.getClassName()); - Assert.assertEquals(decodedStackElement.getMethodName(), originalStackElement.getMethodName()); - Assert.assertEquals(decodedStackElement.getFileName(), originalStackElement.getFileName()); - Assert.assertEquals(decodedStackElement.getLineNumber(), originalStackElement.getLineNumber()); - } - original = original.getCause(); - decoded = decoded.getCause(); - } - } catch (AssertionError e) { - System.err.println("original:["); - originalIn.printStackTrace(System.err); - System.err.println("]"); - System.err.println("decoded:["); - decodedIn.printStackTrace(System.err); - System.err.println("]"); - throw e; - } - } -} diff --git a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java index eb19965a644..4b70a5ba455 100644 --- a/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java +++ b/test/jdk/jdk/jfr/event/compiler/TestDeoptimization.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ public class TestDeoptimization { private final static String TYPE_NAME = Dummy.class.getName().replace(".", "/"); private final static String METHOD_NAME = "dummyMethod"; private static final String METHOD_DESCRIPTOR = "(Z)V"; - private static final String[] COMPILER = { "c2", "jvmci" }; + private static final String COMPILER = "c2"; public static void main(String[] args) throws Throwable { new TestDeoptimization().doTest(); @@ -138,13 +138,12 @@ public class TestDeoptimization { private void verifyDeoptimizationEventFields(RecordedEvent event) { Events.assertEventThread(event); Events.assertField(event, "compileId").atLeast(0); - Events.assertField(event, "compiler").containsAny(COMPILER); + Events.assertField(event, "compiler").equal(COMPILER); Events.assertField(event, "lineNumber").equal(43); Events.assertField(event, "bci").atMost(1); - // Both graal and c2 traps at ifeq. c2 deopt reinterpret from unstable ifeq, while Graal deopt reinterpret from next instruction after last state change. - Events.assertField(event, "instruction").containsAny("ifeq", "iload_0"); + Events.assertField(event, "instruction").equal("ifeq"); Events.assertField(event, "action").notEmpty().equal("reinterpret"); - Events.assertField(event, "reason").notEmpty().containsAny("unstable_if", "null_assert_or_unreached0"); + Events.assertField(event, "reason").notEmpty().containsAny("unstable_if", "null_assert"); } } diff --git a/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java b/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java index 39add0e29fe..a1e5ba5fd0c 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDeprecatedEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,12 +62,6 @@ import static jdk.test.lib.Asserts.assertNotNull; * */ public class TestDeprecatedEvent { -/* - * - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI - * jdk.jfr.event.runtime.TestDeprecatedEvent JVMCI - * - */ public static String EVENT_NAME = EventNames.DeprecatedInvocation; private static String mode; public static int counter; diff --git a/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java b/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java index 4998cb29d3d..3e21ebbf49f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestModuleEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,6 @@ import jdk.test.lib.jfr.Events; * @summary Tests the JFR events related to modules * @requires vm.flagless * @requires vm.hasJFR - * @requires !vm.graal.enabled * @library /test/lib * @run main/othervm --limit-modules java.base,jdk.jfr jdk.jfr.event.runtime.TestModuleEvents */ diff --git a/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java b/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java index 9373f745591..abef38cc06f 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java +++ b/test/jdk/jdk/jfr/event/runtime/TestNativeMemoryUsageEvents.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,6 @@ public class TestNativeMemoryUsageEvents { "GC", "GCCardSet", "Compiler", - "JVMCI", "Internal", "Other", "Symbol", diff --git a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java index a22e59a39fe..96d8ab69e95 100644 --- a/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java +++ b/test/jdk/jdk/jfr/jvm/TestGetEventWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,18 +32,12 @@ import java.util.List; import jdk.jfr.Event; import jdk.jfr.FlightRecorder; import jdk.jfr.Recording; -import jdk.vm.ci.meta.MetaAccessProvider; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ConstantPool; -import jdk.vm.ci.runtime.JVMCI; /** * @test id=default * @requires vm.flagless * @requires vm.hasJFR * @library /test/lib - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime * * @compile PlaceholderEventWriter.java * @compile E.java @@ -69,28 +63,6 @@ import jdk.vm.ci.runtime.JVMCI; * jdk.jfr.jvm.TestGetEventWriter */ -/** - * @test id=jvmci - * @requires vm.flagless - * @requires vm.hasJFR - * @requires vm.jvmci - * @library /test/lib - * @modules jdk.internal.vm.ci/jdk.vm.ci.meta - * jdk.internal.vm.ci/jdk.vm.ci.runtime - * - * @compile PlaceholderEventWriter.java - * @compile E.java - * @compile NonEvent.java - * @compile RegisteredTrueEvent.java - * @compile RegisteredFalseEvent.java - * @compile MyCommitRegisteredTrueEvent.java - * @compile MyCommitRegisteredFalseEvent.java - * @compile StaticCommitEvent.java - * - * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Dtest.jvmci=true --add-exports=jdk.jfr/jdk.jfr.internal.event=ALL-UNNAMED - * jdk.jfr.jvm.TestGetEventWriter - */ - public class TestGetEventWriter { static class InitializationEvent extends Event { @@ -129,7 +101,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "commit"); return; } } @@ -144,7 +115,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "commit"); return; } } @@ -164,7 +134,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "commit"); } try { FlightRecorder.register(e.getClass()); @@ -185,7 +154,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "myCommit"); return; } } @@ -202,7 +170,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "myCommit"); } // Instrumentation added. FlightRecorder.register(e.getClass().asSubclass(Event.class)); @@ -220,7 +187,6 @@ public class TestGetEventWriter { throw new RuntimeException("Should not reach here"); } catch (IllegalAccessError iae) { // OK, as expected - maybeCheckJVMCI(e.getClass(), "commit"); } } @@ -349,56 +315,4 @@ public class TestGetEventWriter { System.out.println("About to invoke " + fullName + ".commit()"); return (T) constructor.newInstance(); } - - private static ResolvedJavaMethod findCommitMethod(MetaAccessProvider metaAccess, Class eventClass, String commitName) { - for (Method m : eventClass.getMethods()) { - if (m.getName().equals(commitName)) { - return metaAccess.lookupJavaMethod(m); - } - } - throw new AssertionError("could not find " + commitName + " method in " + eventClass); - } - - // Factor out test.jvmci system property check to reduce unecessary work in -Xcomp. - private static void maybeCheckJVMCI(Class eventClass, String commitName) throws Throwable { - if (!Boolean.getBoolean("test.jvmci")) { - return; - } - checkJVMCI(eventClass, commitName); - } - - /** - * Checks that JVMCI prevents unblessed access to {@code EventWriter.getEventWriter()}. - */ - private static void checkJVMCI(Class eventClass, String commitName) throws Throwable { - MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess(); - ResolvedJavaMethod commit = findCommitMethod(metaAccess, eventClass, commitName); - ConstantPool cp = commit.getConstantPool(); - - // Search for first INVOKESTATIC instruction in commit method which is expected - // to be the call to jdk.jfr.internal.event.EventWriter.getEventWriter(). - final int INVOKESTATIC = 184; - byte[] code = commit.getCode(); - for (int bci = 0; bci < code.length; bci++) { - int b = code[bci] & 0xff; - if (b == INVOKESTATIC) { - int cpi = ((code[bci + 1] & 0xff) << 8) | (code[bci + 2] & 0xff); - try { - cp.lookupMethod(cpi, 184, commit); - throw new AssertionError("Expected IllegalAccessError"); - } catch (IllegalAccessError e) { - } - try { - // Test looking up with null caller - cp.lookupMethod(cpi, 184, null); - throw new AssertionError("Expected IllegalAccessError"); - } catch (IllegalAccessError e) { - } - - // Ignore all subsequent instructions - return; - } - } - throw new AssertionError(eventClass + ": did not find INVOKESTATIC in " + commit.format("%H.%n(%p)")); - } } diff --git a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java index 551e3792fc2..ca7e21031fa 100644 --- a/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java +++ b/test/jdk/jdk/modules/etc/JdkQualifiedExportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,12 +69,7 @@ public class JdkQualifiedExportTest { } static Set KNOWN_EXCEPTIONS = - Set.of("jdk.internal.vm.ci/jdk.vm.ci.services", - "jdk.internal.vm.ci/jdk.vm.ci.runtime", - "jdk.internal.vm.ci/jdk.vm.ci.hotspot", - "jdk.internal.vm.ci/jdk.vm.ci.meta", - "jdk.internal.vm.ci/jdk.vm.ci.code", - "java.base/jdk.internal.javac", + Set.of("java.base/jdk.internal.javac", "java.base/jdk.internal.misc"); static void checkExports(ModuleDescriptor md) { diff --git a/test/jdk/jdk/modules/etc/UpgradeableModules.java b/test/jdk/jdk/modules/etc/UpgradeableModules.java index 14c84dbf6a5..32479ff66c3 100644 --- a/test/jdk/jdk/modules/etc/UpgradeableModules.java +++ b/test/jdk/jdk/modules/etc/UpgradeableModules.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,10 +42,7 @@ import java.util.Set; import java.util.stream.Collectors; public class UpgradeableModules { - private static final List UPGRADEABLE_MODULES = - List.of("java.compiler", - "jdk.graal.compiler", - "jdk.graal.compiler.management"); + private static final List UPGRADEABLE_MODULES = List.of("java.compiler"); public static void main(String... args) { diff --git a/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java b/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java index 3c97674871e..25fc730ee5d 100644 --- a/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ /* * @test * @summary Test --save-jlink-argfiles plugin - * @requires vm.jvmci * @library ../../lib * @library /test/lib * @modules java.base/jdk.internal.jimage @@ -58,13 +57,13 @@ public class SaveJlinkArgfilesPluginTest { Path argfile1 = Path.of("argfile1"); Path argfile2 = Path.of("argfile2"); - Files.writeString(argfile1, "--add-modules jdk.internal.vm.ci --add-options=-Dfoo=xyzzy"); + Files.writeString(argfile1, "--add-modules jdk.internal.ed --add-options=-Dfoo=xyzzy"); Files.writeString(argfile2, "--vendor-version=\"XyzzyVM 3.14.15\" --vendor-bug-url=https://bugs.xyzzy.com/"); var module = "base"; helper.generateDefaultJModule(module); var image = helper.generateDefaultImage(new String[] { - "--add-modules", "jdk.jlink,jdk.jdeps,jdk.internal.opt,jdk.compiler,java.compiler,jdk.zipfs,jdk.internal.vm.ci", + "--add-modules", "jdk.jlink,jdk.jdeps,jdk.internal.opt,jdk.compiler,java.compiler,jdk.zipfs,jdk.internal.ed", "--keep-packaged-modules", "images/base.image/jmods", "--save-jlink-argfiles", argfile1 + File.pathSeparator + argfile2 }, module) @@ -104,7 +103,7 @@ public class SaveJlinkArgfilesPluginTest { // Ensure the saved `--add-modules` option // was applied when creating the secondary image. - oa = ProcessTools.executeProcess(launcher.toString(), "-d", "jdk.internal.vm.ci"); + oa = ProcessTools.executeProcess(launcher.toString(), "-d", "jdk.internal.ed"); oa.shouldHaveExitValue(0); } } diff --git a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java index 0841402ca9a..24829e9cdc7 100644 --- a/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java +++ b/test/jdk/tools/launcher/modules/limitmods/LimitModsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /** * @test - * @requires !vm.graal.enabled * @library /test/lib * @modules java.desktop java.logging jdk.compiler * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils diff --git a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java index 9171d886158..95e1e253e33 100644 --- a/test/jdk/tools/launcher/modules/listmods/ListModsTest.java +++ b/test/jdk/tools/launcher/modules/listmods/ListModsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /** * @test - * @requires !vm.graal.enabled * @library /test/lib * @modules java.se * @build ListModsTest jdk.test.lib.compiler.CompilerUtils diff --git a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java index 547a0edae1b..4c757cc48e9 100644 --- a/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java +++ b/test/jdk/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,6 @@ /** * @test - * @requires !vm.graal.enabled * @modules jdk.jdeps jdk.zipfs * @library /test/lib * @build ShowModuleResolutionTest diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 16fd32e626b..297bc6a9f5b 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -105,8 +105,6 @@ public class VMProps implements Callable> { map.put("vm.flightRecorder", this::vmFlightRecorder); map.put("vm.simpleArch", this::vmArch); map.put("vm.debug", this::vmDebug); - map.put("vm.jvmci", this::vmJvmci); - map.put("vm.jvmci.enabled", this::vmJvmciEnabled); // vm.hasSA is "true" if the VM contains the serviceability agent // and jhsdb. map.put("vm.hasSA", this::vmHasSA); @@ -128,12 +126,7 @@ public class VMProps implements Callable> { map.put("vm.cds.write.mapped.java.heap", this::vmCDSCanWriteMappedArchivedJavaHeap); map.put("vm.cds.write.streamed.java.heap", this::vmCDSCanWriteStreamedArchivedJavaHeap); map.put("vm.continuations", this::vmContinuations); - // vm.graal.enabled is true if Graal is used as JIT - map.put("vm.graal.enabled", this::isGraalEnabled); - // jdk.hasLibgraal is true if the libgraal shared library file is present - map.put("jdk.hasLibgraal", this::hasLibgraal); map.put("java.enablePreview", this::isPreviewEnabled); - map.put("vm.libgraal.jit", this::isLibgraalJIT); map.put("vm.compiler1.enabled", this::isCompiler1Enabled); map.put("vm.compiler2.enabled", this::isCompiler2Enabled); map.put("container.support", this::containerSupport); @@ -263,41 +256,6 @@ public class VMProps implements Callable> { } } - /** - * @return true if VM supports JVMCI and false otherwise - */ - protected String vmJvmci() { - // builds with jvmci have this flag - if (WB.getBooleanVMFlag("EnableJVMCI") == null) { - return "false"; - } - - // Not all GCs have full JVMCI support - if (!WB.isJVMCISupportedByGC()) { - return "false"; - } - - // Interpreted mode cannot enable JVMCI - if (vmCompMode().equals("Xint")) { - return "false"; - } - - return "true"; - } - - - /** - * @return true if JVMCI is enabled - */ - protected String vmJvmciEnabled() { - // builds with jvmci have this flag - if ("false".equals(vmJvmci())) { - return "false"; - } - - return "" + Compiler.isJVMCIEnabled(); - } - /** * @return supported CPU features */ @@ -315,9 +273,7 @@ public class VMProps implements Callable> { * @param map - property-value pairs */ protected void vmGC(SafeMap map) { - var isJVMCIEnabled = Compiler.isJVMCIEnabled(); Predicate vmGCProperty = (GC gc) -> (gc.isSupported() - && (!isJVMCIEnabled || gc.isSupportedByJVMCICompiler()) && (gc.isSelected() || GC.isSelectedErgonomically())); for (GC gc: GC.values()) { map.put("vm.gc." + gc.name(), () -> "" + vmGCProperty.test(gc)); @@ -370,7 +326,6 @@ public class VMProps implements Callable> { vmOptFinalFlag(map, "ClassUnloading"); vmOptFinalFlag(map, "ClassUnloadingWithConcurrentMark"); vmOptFinalFlag(map, "CriticalJNINatives"); - vmOptFinalFlag(map, "EnableJVMCI"); vmOptFinalFlag(map, "EliminateAllocations"); vmOptFinalFlag(map, "UnlockExperimentalVMOptions"); vmOptFinalFlag(map, "UseAdaptiveSizePolicy"); @@ -510,7 +465,6 @@ public class VMProps implements Callable> { protected String vmCDSSupportsAOTCodeCaching() { if ("true".equals(vmCDSSupportsAOTClassLinking()) && !"zero".equals(vmFlavor()) && - "false".equals(vmJvmciEnabled()) && (Platform.isX64() || Platform.isAArch64())) { return "true"; } else { @@ -536,33 +490,6 @@ public class VMProps implements Callable> { return "" + WB.getVMPageSize(); } - /** - * Check if Graal is used as JIT compiler. - * - * @return true if Graal is used as JIT compiler. - */ - protected String isGraalEnabled() { - return "" + Compiler.isGraalEnabled(); - } - - /** - * Check if the libgraal shared library file is present. - * - * @return true if the libgraal shared library file is present. - */ - protected String hasLibgraal() { - return "" + WB.hasLibgraal(); - } - - /** - * Check if libgraal is used as JIT compiler. - * - * @return true if libgraal is used as JIT compiler. - */ - protected String isLibgraalJIT() { - return "" + Compiler.isLibgraalJIT(); - } - /** * Check if Compiler1 is present. * diff --git a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java index cb480901885..e3c9fb94951 100644 --- a/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java +++ b/test/langtools/jdk/javadoc/doclet/testSearchScript/TestSearchScript.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,19 +60,12 @@ public class TestSearchScript extends JavadocTester { } private Invocable getEngine() throws ScriptException, IOException, NoSuchMethodException { - // For installing and using GraalVM JS on stock JDK see - // https://github.com/oracle/graaljs/blob/master/docs/user/RunOnJDK.md - // and https://github.com/graalvm/graal-js-jdk11-maven-demo ScriptEngineManager engineManager = new ScriptEngineManager(); // Use "js" engine name to use any available JavaScript engine. ScriptEngine engine = engineManager.getEngineByName("js"); if (engine == null) { throw new SkippedException("JavaScript engine is not available."); } - // Set Nashorn compatibility mode via Bindings for use with GraalVM JS, - // see https://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md - Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE); - bindings.put("polyglot.js.nashorn-compat", true); engine.eval(Files.newBufferedReader(Path.of(testSrc).resolve("javadoc-search.js"))); Invocable inv = (Invocable) engine; inv.invokeFunction("loadIndexFiles", outputDir.toAbsolutePath().toString()); diff --git a/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp b/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp index 3832d934b1e..4ed946b243d 100644 --- a/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp +++ b/test/lib/jdk/test/lib/jvmti/jvmti_common.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -798,11 +798,6 @@ int isThreadExpected(jvmtiEnv *jvmti, jthread thread) { static const char *vm_jfr_buffer_thread_name = "VM JFR Buffer Thread"; static const char *jfr_request_timer_thread_name = "JFR request timer"; - static const char *graal_management_bean_registration_thread_name = - "HotSpotGraalManagement Bean Registration"; - static const char *graal_compiler_thread_name_prefix = "JVMCI CompilerThread"; - static const size_t graal_prefix_length = strlen(graal_compiler_thread_name_prefix); - static const char *unparker_thread_name_prefix = "VirtualThread-unparker"; static const size_t unparker_prefix_length = strlen(unparker_thread_name_prefix); @@ -818,13 +813,6 @@ isThreadExpected(jvmtiEnv *jvmti, jthread thread) { if (strcmp(threadinfo.name, jfr_request_timer_thread_name) == 0) { return 0; } - if (strcmp(threadinfo.name, graal_management_bean_registration_thread_name) == 0) - return 0; - - if ((strlen(threadinfo.name) > graal_prefix_length) && - strncmp(threadinfo.name, graal_compiler_thread_name_prefix, graal_prefix_length) == 0) { - return 0; - } if (strncmp(threadinfo.name, unparker_thread_name_prefix, unparker_prefix_length) == 0) { return 0; } diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java index c915cee41b0..311502a16e2 100644 --- a/test/lib/jdk/test/whitebox/WhiteBox.java +++ b/test/lib/jdk/test/whitebox/WhiteBox.java @@ -336,11 +336,6 @@ public class WhiteBox { // Compiler - // Determines if the libgraal shared library file is present. - public native boolean hasLibgraal(); - public native boolean isC2OrJVMCIIncluded(); - public native boolean isJVMCISupportedByGC(); - public native int matchesMethod(Executable method, String pattern); public native int matchesInline(Executable method, String pattern); public native boolean shouldPrintAssembly(Executable method, int comp_level); @@ -564,7 +559,6 @@ public class WhiteBox { // Don't use these methods directly // Use jdk.test.whitebox.gc.GC class instead. public native boolean isGCSupported(int name); - public native boolean isGCSupportedByJVMCICompiler(int name); public native boolean isGCSelected(int name); public native boolean isGCSelectedErgonomically(); diff --git a/test/lib/jdk/test/whitebox/code/Compiler.java b/test/lib/jdk/test/whitebox/code/Compiler.java index b9e4da2188e..333ca42782c 100644 --- a/test/lib/jdk/test/whitebox/code/Compiler.java +++ b/test/lib/jdk/test/whitebox/code/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,79 +34,6 @@ public class Compiler { private static final WhiteBox WB = WhiteBox.getWhiteBox(); - /** - * Check if C2 or JVMCI were included in the VM build - * - * @return true if either C2 or JVMCI were included in the VM build. - */ - public static boolean isC2OrJVMCIIncluded() { - return WB.isC2OrJVMCIIncluded(); - } - - /** - * Check if JVMCI is enabled. - * - * @return true if JVMCI is enabled - */ - public static boolean isJVMCIEnabled() { - Boolean enableJvmci = WB.getBooleanVMFlag("EnableJVMCI"); - if (enableJvmci == null || !enableJvmci) { - return false; - } - - return true; - } - - /** - * Check if Graal is used as JIT compiler. - * - * Graal is enabled if following conditions are true: - * - we are not in Interpreter mode - * - UseJVMCICompiler flag is true - * - TieredCompilation is not used or TieredStopAtLevel is greater than 3 - * No need to check client mode because it set UseJVMCICompiler to false. - * - * @return true if Graal is used as JIT compiler. - */ - public static boolean isGraalEnabled() { - Boolean useCompiler = WB.getBooleanVMFlag("UseCompiler"); - if (useCompiler == null || !useCompiler) { - return false; - } - Boolean useJvmciComp = WB.getBooleanVMFlag("UseJVMCICompiler"); - if (useJvmciComp == null || !useJvmciComp) { - return false; - } - - Boolean tieredCompilation = WB.getBooleanVMFlag("TieredCompilation"); - Long compLevel = WB.getIntxVMFlag("TieredStopAtLevel"); - // if TieredCompilation is enabled and compilation level is <= 3 then no Graal is used - if (tieredCompilation != null && tieredCompilation && - compLevel != null && compLevel <= 3) { - return false; - } - return true; - } - - /** - * Check if libgraal is used as JIT compiler. - * - * libraal JIT is enabled if isGraalEnabled is true and: - * - UseJVMCINativeLibrary flag is true - * - * @return true if libgraal is used as JIT compiler. - */ - public static boolean isLibgraalJIT() { - if (!isGraalEnabled()) { - return false; - } - Boolean useJvmciNativeLibrary = WB.getBooleanVMFlag("UseJVMCINativeLibrary"); - if (useJvmciNativeLibrary == null || !useJvmciNativeLibrary) { - return false; - } - return true; - } - /** * Check if C2 is used as JIT compiler. * @@ -114,7 +41,6 @@ public class Compiler { * - we are not in Interpreter mode * - we are in Server compilation mode * - TieredCompilation is not used or TieredStopAtLevel is greater than 3 - * - Graal is not used * * @return true if C2 is used as JIT compiler. */ @@ -130,16 +56,12 @@ public class Compiler { Boolean tieredCompilation = WB.getBooleanVMFlag("TieredCompilation"); Long compLevel = WB.getIntxVMFlag("TieredStopAtLevel"); - // if TieredCompilation is enabled and compilation level is <= 3 then no Graal is used + // if TieredCompilation is enabled and compilation level is <= 3 then C2 is not used if (tieredCompilation != null && tieredCompilation && compLevel != null && compLevel <= 3) { return false; } - if (isGraalEnabled()) { - return false; - } - return true; } diff --git a/test/lib/jdk/test/whitebox/gc/GC.java b/test/lib/jdk/test/whitebox/gc/GC.java index ddcb6e554d4..22655ddd15f 100644 --- a/test/lib/jdk/test/whitebox/gc/GC.java +++ b/test/lib/jdk/test/whitebox/gc/GC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2026, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,13 +55,6 @@ public enum GC { return WB.isGCSupported(name); } - /** - * @return true if this GC is supported by the JVMCI compiler - */ - public boolean isSupportedByJVMCICompiler() { - return WB.isGCSupportedByJVMCICompiler(name); - } - /** * @return true if this GC is currently selected/used */