From 09434fe5613ed68238114e342f296ed95094363b Mon Sep 17 00:00:00 2001 From: Nick Kamal Date: Tue, 19 Nov 2024 13:16:54 -0500 Subject: [PATCH] Squashed commit of the following: commit 44766dec0a8236b92dc7102b0dcdbd36bb2aa319 Merge: 975e7417e7 fe89ec5749 Author: Marius Pirvu Date: Tue Nov 19 09:18:48 2024 -0500 Merge pull request #20614 from JamesKingdon/trampolineResetFix Reset trampoline pointers to top of space commit 975e7417e7699ecc3f123f7705026e8be75ccbef Merge: 9618d90941 9f566fa504 Author: Peter Shipton Date: Tue Nov 19 08:34:48 2024 -0500 Merge pull request #20631 from tajila/jfr3 Disable JFR JCL APIs commit 9618d909413ef167bee9234d8493fe9054b16f6d Merge: 8f240e6cba 36dc3965f0 Author: Dmitri Pivkine Date: Mon Nov 18 21:45:37 2024 -0500 Merge pull request #20630 from amicic/VLHGC_barrier_32bit Don't use Offheap APIs for 32 bit commit 9f566fa5041bad3463a81b0f84a77829c7ae9dfe Author: tajila Date: Mon Nov 18 20:05:47 2024 -0500 Disable JFR JCL APIs Disable JFR JCL APIs until JFR natives are implemented. Related to: https://github.com/eclipse-openj9/openj9/issues/20607 Signed-off-by: tajila commit 8f240e6cba1d60201be8d7472308d81a83145967 Merge: 7534b4ebb1 6662a08ee0 Author: Keith W. Campbell Date: Mon Nov 18 20:05:46 2024 -0500 Merge pull request #20621 from tajila/jfr2 Fix conditon in JFR buffer test commit 6662a08ee07ae75c769a197facd21960f456461d Author: tajila Date: Mon Nov 18 15:49:59 2024 -0500 Fix conditon in JFR buffer test Signed-off-by: tajila commit 36dc3965f0a243bfd44ca8ab96c0a91466faee77 Author: Aleksandar Micic Date: Mon Nov 18 19:11:09 2024 -0500 Don't use Offheap APIs for 32 bit A couple of Offheap APIs are guarded with 64 bit compile flag. A more accurate fix would be to guard them with Offheap specific build flag (and do not compile the whole dir for 32bit), but it would require more complex changes. Signed-off-by: Aleksandar Micic commit 7534b4ebb11197ba6a358335e7cb6b574b1ae56a Merge: 3d719d4df9 276f38ffc3 Author: Graham Chapman Date: Mon Nov 18 18:14:00 2024 -0500 Merge pull request #20620 from tajila/jfr3 Release jfrSampler lock before acquiring VMaccess commit 3d719d4df9464e2e45968d0c3106ee11d750e14a Merge: 247d6ec8be c0ff1fc4a2 Author: Peter Shipton Date: Mon Nov 18 17:17:42 2024 -0500 Merge pull request #20622 from AdamBrousseau/cuda_docker_non_dockerhub Pull cuda image from nvcr commit 247d6ec8bed3e46e7e42add9dfe2533d8f25fca2 Merge: 068838e8fb fee4aeb413 Author: Aleksandar Micic Date: Mon Nov 18 16:55:50 2024 -0500 Merge pull request #20514 from LinHu2016/coding-std-update2 Clean up MethodTypesIterator class commit 068838e8fb2594e9040b7e72f9af4181924de2a6 Merge: d98d498e5c 3dc8eb48be Author: Aleksandar Micic Date: Mon Nov 18 16:46:15 2024 -0500 Merge pull request #20564 from LinHu2016/off-heap-incremental4 New vm/gc API j9gc_objaccess_indexableDataDisplacement commit c0ff1fc4a2b4887980a750e8304f06143b002e55 Author: Adam Brousseau Date: Mon Nov 18 16:03:35 2024 -0500 Pull cuda image from nvcr In the event we are rate-limited or restricted from pulling from DockerHub, this should work around the problem by pulling from Nvidia's site. Issue runtimes/automation/122 Signed-off-by: Adam Brousseau commit 3dc8eb48be448b53efdcaccb967b996e8245ba21 Author: lhu Date: Fri Nov 8 11:50:32 2024 -0500 New vm/gc API j9gc_objaccess_indexableDataDisplacement new API j9gc_objaccess_indexableDataDisplacement used by the JIT. Returns the displacement for the data of moved array object. For adjacent Array and 0 size array, displacement = dst - src For Off-heap Array, displacement = 0 should only be called for off-heap eanbled case. Signed-off-by: lhu commit d98d498e5cb217b9190780758030c5dc3e9e7bc4 Merge: 77f153d1ba ee35ed542c Author: Graham Chapman Date: Mon Nov 18 14:52:20 2024 -0500 Merge pull request #20611 from tajila/jfr2 Prevent writes to free'd JFR buffer commit 77f153d1ba71d56cd125eeddcf6caf437c47937c Merge: 038df3616f 326a800cd7 Author: Marius Pirvu Date: Mon Nov 18 14:09:15 2024 -0500 Merge pull request #20592 from luke-li-2003/ServerCacheReflectClass Cache Client's Reflect Class Pointers at JITServer commit 276f38ffc33bb39e5a04e9d0ff9b9553889ccdd5 Author: tajila Date: Mon Nov 18 13:59:52 2024 -0500 Release jfrSampler lock before acquiring VMaccess Signed-off-by: tajila commit ee35ed542c38410fa818a50ab0fa7038e84efca7 Author: tajila Date: Sun Nov 17 16:06:08 2024 -0500 Prevent writes to free'd JFR buffer Also, check that threadObject is not NULL before dereference. Signed-off-by: tajila commit 038df3616f6fd7d9affc5b0dd0908d88814eb312 Merge: 224374df7a 05731070d9 Author: Aleksandar Micic Date: Mon Nov 18 11:12:43 2024 -0500 Merge pull request #20596 from LinHu2016/off-heap-incremental6 Update verbose GC for off-heap commit 224374df7a224b41ecc23cf4eb205bb6c2a6a593 Merge: 6289c288b2 d56338f4a4 Author: Babneet Singh Date: Mon Nov 18 10:20:28 2024 -0500 Merge pull request #20606 from ThanHenderson/omr-unnamed Fix OMR_GLUE unnamed spelling mistake commit 6289c288b247ab7b3bcc5dd771ff43d14471bdbe Merge: efaa4f6141 1af50970c2 Author: Tobi Date: Mon Nov 18 09:56:54 2024 -0500 Merge pull request #20605 from pshipton/cracbean Move CRaCMXBeanImpl and export jdk.crac.management commit 1af50970c23bd52221f2b084638d05e43cc19142 Author: Peter Shipton Date: Fri Nov 15 14:28:45 2024 -0500 Move CRaCMXBeanImpl and export jdk.crac.management Issue https://github.com/eclipse-openj9/openj9/issues/20587 Signed-off-by: Peter Shipton commit 326a800cd799daf459642f1fd9146c684167b82f Author: Luke Li Date: Thu Nov 14 16:13:54 2024 -0500 Remove J9Class Occurrences in Vector API Substitute uses of J9Class in the vector API with TR_OpaqueClassBlock with frontend references. The Vector API, being a part of the optimizer, should never use the inside of a J9Class Signed-off-by: Luke Li commit a97a4ba2bae3164b2409d98b3900b726a21206d6 Author: Luke Li Date: Mon Oct 28 09:31:53 2024 -0400 Remove Server VM Access Request in VectorAPIExpansion.cpp The server should make a specific request to the client in getJ9ClassFromClassNode() and getVectorSizeFromVectorSpecies(), instead of requesting a pointer from the KnownObjectTable as that requires VM Access and will cause a fatal assertion fail at J9KnownObjectTable.cpp:207. Signed-off-by: Luke Li commit fe89ec57492a0abb3a3f10f2c88a8cd0c26b75d2 Author: James Kingdon Date: Fri Nov 15 15:24:35 2024 -0500 Reset trampoline pointers to top of space After flushing the code cache under FSD there is a call to resetTrampolines. The _trampolineAllocationMark and _trampolineReservationMark need to be reset to their starting positions but were incorrectly set to the end of the trampoline space. As a result all active segments at the time of the cache flush are marked as full (assuming a platform that uses trampolines). This can be seen by taking a JIT verbose log with option `codecache` which will show CODECACHE: CodeCache 00007E759000C660 marked as full in reserveSpaceForTrampoline commit d56338f4a4d2b8676e3fdf756141f9a569ff8fb9 Author: Nathan Henderson Date: Fri Nov 15 11:32:46 2024 -0800 Fix OMR_GLUE unnamed spelling mistake Signed-off-by: Nathan Henderson commit 05731070d9ff8513f60ffd9dbdcd61eddea0d7b8 Author: lhu Date: Tue Nov 12 12:09:29 2024 -0500 Update verbose GC for off-heap -new outputOffHeapInfo in CopyForward and Mark for balancedGC " - output offheap-objects in MemoryInfo Signed-off-by: lhu commit fee4aeb413c7eec602eaaff8855016dc6c934108 Author: lhu Date: Tue Nov 5 10:51:09 2024 -0500 Clean up MethodTypesIterator class Use consistent data types and code formatting Signed-off-by: lhu --- buildenv/jenkins/common/build.groovy | 2 +- .../share/classes/java/lang/System.java | 3 + .../management/internal/ManagementUtils.java | 2 +- .../internal/PlatformMBeanProvider.java | 2 +- .../jdk/crac/management/CRaCMXBean.java | 1 + .../{ => internal}/CRaCMXBeanImpl.java | 3 +- .../share/classes/module-info.java.extra | 5 +- .../control/JITClientCompilationThread.cpp | 45 ++++++++++ runtime/compiler/env/VMJ9.cpp | 29 ++++++- runtime/compiler/env/VMJ9.h | 1 + runtime/compiler/env/VMJ9Server.cpp | 59 +++++++++++++ runtime/compiler/env/VMJ9Server.hpp | 3 + runtime/compiler/net/CommunicationStream.hpp | 2 +- runtime/compiler/net/MessageTypes.cpp | 2 + runtime/compiler/net/MessageTypes.hpp | 5 ++ .../compiler/optimizer/VectorAPIExpansion.cpp | 85 ++++++++++++------- .../compiler/optimizer/VectorAPIExpansion.hpp | 3 +- runtime/compiler/runtime/J9CodeCache.cpp | 6 +- runtime/compiler/runtime/JITClientSession.hpp | 10 +++ runtime/gc/gctable.c | 1 + runtime/gc_base/ObjectAccessBarrier.hpp | 4 + runtime/gc_base/accessBarrier.cpp | 18 ++++ runtime/gc_base/gc_internal.h | 1 + runtime/gc_glue_java/ArrayletObjectModel.cpp | 16 ++++ runtime/gc_glue_java/ArrayletObjectModel.hpp | 20 +++++ runtime/gc_glue_java/UtilGlue.c | 2 +- runtime/gc_realtime/RealtimeAccessBarrier.hpp | 7 ++ runtime/gc_stats/CopyForwardStats.hpp | 16 ++++ runtime/gc_stats/MarkVLHGCStats.hpp | 16 ++++ runtime/gc_structs/MethodTypesIterator.hpp | 26 +++--- .../VerboseHandlerOutputVLHGC.cpp | 29 ++++++- .../VerboseHandlerOutputVLHGC.hpp | 11 +++ runtime/gc_vlhgc/VLHGCAccessBarrier.cpp | 16 ++++ runtime/gc_vlhgc/VLHGCAccessBarrier.hpp | 2 + runtime/oti/j9nonbuilder.h | 1 + runtime/vm/JFRConstantPoolTypes.cpp | 20 +++-- runtime/vm/jfr.cpp | 38 +++++++-- 37 files changed, 437 insertions(+), 75 deletions(-) rename jcl/src/jdk.management/share/classes/jdk/crac/management/{ => internal}/CRaCMXBeanImpl.java (96%) diff --git a/buildenv/jenkins/common/build.groovy b/buildenv/jenkins/common/build.groovy index f01d26b12ff..f3f2056ba7a 100644 --- a/buildenv/jenkins/common/build.groovy +++ b/buildenv/jenkins/common/build.groovy @@ -828,7 +828,7 @@ def create_docker_image_locally() echo 'ARG image ARG cuda_ver=12.2.0 ARG cuda_distro=ubi8 - FROM nvidia/cuda:${cuda_ver}-devel-${cuda_distro} as cuda + FROM nvcr.io/nvidia/cuda:${cuda_ver}-devel-${cuda_distro} as cuda FROM $image RUN mkdir -p /usr/local/cuda/nvvm COPY --from=cuda /usr/local/cuda/include /usr/local/cuda/include diff --git a/jcl/src/java.base/share/classes/java/lang/System.java b/jcl/src/java.base/share/classes/java/lang/System.java index 40ed484a719..411b7efa2f8 100644 --- a/jcl/src/java.base/share/classes/java/lang/System.java +++ b/jcl/src/java.base/share/classes/java/lang/System.java @@ -736,7 +736,10 @@ private static void ensureProperties(boolean isInitialization) { /*[ENDIF] CRIU_SUPPORT */ /*[IF JFR_SUPPORT]*/ + /* Enables openj9 JFR tests. */ initializedProperties.put("org.eclipse.openj9.jfr.isJFREnabled", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + /* TODO disable JFR JCL APIs until JFR natives are implemented. */ + initializedProperties.put("jfr.unsupported.vm", "true"); //$NON-NLS-1$ //$NON-NLS-2$ /*[ENDIF] JFR_SUPPORT */ String[] list = getPropertyList(); diff --git a/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/ManagementUtils.java b/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/ManagementUtils.java index 800cbd8ab9f..e5307a950ae 100644 --- a/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/ManagementUtils.java +++ b/jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/ManagementUtils.java @@ -775,7 +775,7 @@ static void registerAll() { .validateAndRegister(); /*[IF CRAC_SUPPORT]*/ - create(jdk.crac.management.CRaCMXBean.CRAC_MXBEAN_NAME, jdk.crac.management.CRaCMXBeanImpl.getInstance()) + create(jdk.crac.management.CRaCMXBean.CRAC_MXBEAN_NAME, jdk.crac.management.internal.CRaCMXBeanImpl.getInstance()) .addInterface(jdk.crac.management.CRaCMXBean.class) .validateAndRegister(); /*[ENDIF] CRAC_SUPPORT */ diff --git a/jcl/src/jdk.management/share/classes/com/ibm/lang/management/internal/PlatformMBeanProvider.java b/jcl/src/jdk.management/share/classes/com/ibm/lang/management/internal/PlatformMBeanProvider.java index 53002fd2578..5d5511077e7 100644 --- a/jcl/src/jdk.management/share/classes/com/ibm/lang/management/internal/PlatformMBeanProvider.java +++ b/jcl/src/jdk.management/share/classes/com/ibm/lang/management/internal/PlatformMBeanProvider.java @@ -112,7 +112,7 @@ public final class PlatformMBeanProvider extends sun.management.spi.PlatformMBea } /*[IF CRAC_SUPPORT]*/ - ComponentBuilder.create(jdk.crac.management.CRaCMXBean.CRAC_MXBEAN_NAME, jdk.crac.management.CRaCMXBeanImpl.getInstance()) // $NON-NLS-1$ + ComponentBuilder.create(jdk.crac.management.CRaCMXBean.CRAC_MXBEAN_NAME, jdk.crac.management.internal.CRaCMXBeanImpl.getInstance()) // $NON-NLS-1$ .addInterface(jdk.crac.management.CRaCMXBean.class) .register(allComponents); /*[ENDIF] CRAC_SUPPORT */ diff --git a/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBean.java b/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBean.java index d3f8d672cc8..f64c4c9b808 100644 --- a/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBean.java +++ b/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBean.java @@ -23,6 +23,7 @@ package jdk.crac.management; import java.lang.management.PlatformManagedObject; +import jdk.crac.management.internal.CRaCMXBeanImpl; /** * A management interface of the CRaC functionality in the Java virtual machine. diff --git a/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBeanImpl.java b/jcl/src/jdk.management/share/classes/jdk/crac/management/internal/CRaCMXBeanImpl.java similarity index 96% rename from jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBeanImpl.java rename to jcl/src/jdk.management/share/classes/jdk/crac/management/internal/CRaCMXBeanImpl.java index 5addf07ec2a..9a9179f267b 100644 --- a/jcl/src/jdk.management/share/classes/jdk/crac/management/CRaCMXBeanImpl.java +++ b/jcl/src/jdk.management/share/classes/jdk/crac/management/internal/CRaCMXBeanImpl.java @@ -20,11 +20,12 @@ * * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 */ -package jdk.crac.management; +package jdk.crac.management.internal; import java.util.concurrent.TimeUnit; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import jdk.crac.management.CRaCMXBean; import openj9.internal.criu.InternalCRIUSupport; /** diff --git a/jcl/src/jdk.management/share/classes/module-info.java.extra b/jcl/src/jdk.management/share/classes/module-info.java.extra index 31f6fd97c31..fc369eea52a 100644 --- a/jcl/src/jdk.management/share/classes/module-info.java.extra +++ b/jcl/src/jdk.management/share/classes/module-info.java.extra @@ -22,6 +22,9 @@ */ exports com.ibm.lang.management; -exports openj9.lang.management; exports com.ibm.virtualization.management; +/*[IF CRAC_SUPPORT]*/ +exports jdk.crac.management; +/*[ENDIF] CRAC_SUPPORT */ +exports openj9.lang.management; provides sun.management.spi.PlatformMBeanProvider with com.ibm.lang.management.internal.PlatformMBeanProvider; diff --git a/runtime/compiler/control/JITClientCompilationThread.cpp b/runtime/compiler/control/JITClientCompilationThread.cpp index 904638975a8..5343e0b20d7 100644 --- a/runtime/compiler/control/JITClientCompilationThread.cpp +++ b/runtime/compiler/control/JITClientCompilationThread.cpp @@ -555,6 +555,16 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes #else vmInfo._isNonPortableRestoreMode = false; #endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ + vmInfo._voidReflectClassPtr = javaVM->voidReflectClass; + vmInfo._booleanReflectClassPtr = javaVM->booleanReflectClass; + vmInfo._charReflectClassPtr = javaVM->charReflectClass; + vmInfo._floatReflectClassPtr = javaVM->floatReflectClass; + vmInfo._doubleReflectClassPtr = javaVM->doubleReflectClass; + vmInfo._byteReflectClassPtr = javaVM->byteReflectClass; + vmInfo._shortReflectClassPtr = javaVM->shortReflectClass; + vmInfo._intReflectClassPtr = javaVM->intReflectClass; + vmInfo._longReflectClassPtr = javaVM->longReflectClass; + client->write(response, vmInfo, listOfCacheDescriptors, comp->getPersistentInfo()->getJITServerAOTCacheName()); } break; @@ -2885,6 +2895,41 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes client->write(response, knownObjectTableDumpInfoList); } break; + case MessageType::KnownObjectTable_getOpaqueClass: + { + TR::KnownObjectTable::Index knotIndex = + std::get<0>(client->getRecvData()); + + uintptr_t clazz = 0; + { + TR::VMAccessCriticalSection getJ9ClassFromKnownObjectIndex(fe); + + uintptr_t javaLangClass = knot->getPointer(knotIndex); + clazz = (uintptr_t)fe->getInt64Field(javaLangClass, "vmRef"); + } + + client->write(response, clazz); + } + break; + case MessageType::KnownObjectTable_getVectorBitSize: + { + TR::KnownObjectTable::Index knotIndex = + std::get<0>(client->getRecvData()); + + int32_t vectorBitSize = 0; + { + TR::VMAccessCriticalSection getVBSFromKnownObjectIndex(fe); + + uintptr_t vectorSpeciesLocation = knot->getPointer(knotIndex); + uintptr_t vectorShapeLocation = fe->getReferenceField(vectorSpeciesLocation, + "vectorShape", + "Ljdk/incubator/vector/VectorShape;"); + vectorBitSize = fe->getInt32Field(vectorShapeLocation, "vectorBitSize"); + } + + client->write(response, vectorBitSize); + } + break; case MessageType::AOTCache_getROMClassBatch: { auto recv = client->getRecvData>(); diff --git a/runtime/compiler/env/VMJ9.cpp b/runtime/compiler/env/VMJ9.cpp index 8402b66032a..30b6be88750 100644 --- a/runtime/compiler/env/VMJ9.cpp +++ b/runtime/compiler/env/VMJ9.cpp @@ -1307,11 +1307,13 @@ TR_J9VMBase::getReferenceElement(uintptr_t objectPointer, intptr_t elementIndex) return (uintptr_t)J9JAVAARRAYOFOBJECT_LOAD(vmThread(), objectPointer, elementIndex); } -TR_arrayTypeCode TR_J9VMBase::getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* clazz) +TR_arrayTypeCode +TR_J9VMBase::getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* clazz) { TR_ASSERT(isPrimitiveClass(clazz), "Expect primitive class in TR_J9VMBase::getPrimitiveArrayType"); J9Class* j9clazz = (J9Class*)clazz; + if (j9clazz == jitConfig->javaVM->booleanReflectClass) return atype_boolean; else if (j9clazz == jitConfig->javaVM->charReflectClass) @@ -1335,6 +1337,31 @@ TR_arrayTypeCode TR_J9VMBase::getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* cla } } +TR::DataType +TR_J9VMBase::getClassPrimitiveDataType(TR_OpaqueClassBlock* clazz) + { + J9Class *j9class = TR::Compiler->cls.convertClassOffsetToClassPtr(clazz); + if (!j9class) + return TR::NoType; + + J9JavaVM *vm = getJ9JITConfig()->javaVM; + + if (j9class == vm->floatReflectClass) + return TR::Float; + else if (j9class == vm->doubleReflectClass) + return TR::Double; + else if (j9class == vm->byteReflectClass) + return TR::Int8; + else if (j9class == vm->shortReflectClass) + return TR::Int16; + else if (j9class == vm->intReflectClass) + return TR::Int32; + else if (j9class == vm->longReflectClass) + return TR::Int64; + else + return TR::NoType; + } + TR_OpaqueClassBlock * TR_J9VMBase::getClassFromJavaLangClass(uintptr_t objectPointer) { diff --git a/runtime/compiler/env/VMJ9.h b/runtime/compiler/env/VMJ9.h index 959d3a2c7f9..05d9a76e8c1 100644 --- a/runtime/compiler/env/VMJ9.h +++ b/runtime/compiler/env/VMJ9.h @@ -669,6 +669,7 @@ class TR_J9VMBase : public TR_FrontEnd virtual TR_OpaqueClassBlock *getClassFromJavaLangClass(uintptr_t objectPointer); virtual TR_arrayTypeCode getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* clazz); + virtual TR::DataType getClassPrimitiveDataType(TR_OpaqueClassBlock* clazz); virtual TR_OpaqueClassBlock * getSystemClassFromClassName(const char * name, int32_t length, bool callSiteVettedForAOT=false) { return 0; } virtual TR_OpaqueClassBlock * getByteArrayClass(); diff --git a/runtime/compiler/env/VMJ9Server.cpp b/runtime/compiler/env/VMJ9Server.cpp index 0bc52f25216..6d37deefa34 100644 --- a/runtime/compiler/env/VMJ9Server.cpp +++ b/runtime/compiler/env/VMJ9Server.cpp @@ -2616,6 +2616,65 @@ TR_J9ServerVM::isOffHeapAllocationEnabled() return vmInfo->_isOffHeapAllocationEnabled; } + +TR_arrayTypeCode +TR_J9ServerVM::getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* clazz) + { + TR_ASSERT(isPrimitiveClass(clazz), "Expect primitive class in TR_J9VMBase::getPrimitiveArrayType"); + + J9Class* j9clazz = (J9Class*)clazz; + + auto stream = _compInfoPT->getStream(); + auto vmInfo = _compInfoPT->getClientData()->getOrCacheVMInfo(stream); + if (j9clazz == vmInfo->_booleanReflectClassPtr) + return atype_boolean; + else if (j9clazz == vmInfo->_charReflectClassPtr) + return atype_char; + else if (j9clazz == vmInfo->_floatReflectClassPtr) + return atype_float; + else if (j9clazz == vmInfo->_doubleReflectClassPtr) + return atype_double; + else if (j9clazz == vmInfo->_byteReflectClassPtr) + return atype_byte; + else if (j9clazz == vmInfo->_shortReflectClassPtr) + return atype_short; + else if (j9clazz == vmInfo->_intReflectClassPtr) + return atype_int; + else if (j9clazz == vmInfo->_longReflectClassPtr) + return atype_long; + else + { + TR_ASSERT(false, "TR_arrayTypeCode is not defined for the j9clazz"); + return (TR_arrayTypeCode)0; + } + } + +TR::DataType +TR_J9ServerVM::getClassPrimitiveDataType(TR_OpaqueClassBlock* clazz) + { + J9Class *j9class = TR::Compiler->cls.convertClassOffsetToClassPtr(clazz); + + if (!j9class) return TR::NoType; + + auto vmInfo = _compInfoPT->getClientData()->getOrCacheVMInfo(_compInfoPT->getStream()); + + if (j9class == vmInfo->_floatReflectClassPtr) + return TR::Float; + else if (j9class == vmInfo->_doubleReflectClassPtr) + return TR::Double; + else if (j9class == vmInfo->_byteReflectClassPtr) + return TR::Int8; + else if (j9class == vmInfo->_shortReflectClassPtr) + return TR::Int16; + else if (j9class == vmInfo->_intReflectClassPtr) + return TR::Int32; + else if (j9class == vmInfo->_longReflectClassPtr) + return TR::Int64; + else + return TR::NoType; + } + + bool TR_J9SharedCacheServerVM::isClassLibraryMethod(TR_OpaqueMethodBlock *method, bool vettedForAOT) { diff --git a/runtime/compiler/env/VMJ9Server.hpp b/runtime/compiler/env/VMJ9Server.hpp index 24c98494fc1..1248c847750 100644 --- a/runtime/compiler/env/VMJ9Server.hpp +++ b/runtime/compiler/env/VMJ9Server.hpp @@ -265,6 +265,9 @@ class TR_J9ServerVM: public TR_J9VM virtual bool isIndexableDataAddrPresent() override; virtual bool isOffHeapAllocationEnabled() override; + virtual TR_arrayTypeCode getPrimitiveArrayTypeCode(TR_OpaqueClassBlock* clazz) override; + virtual TR::DataType getClassPrimitiveDataType(TR_OpaqueClassBlock* clazz) override; + private: bool instanceOfOrCheckCastHelper(J9Class *instanceClass, J9Class* castClass, bool cacheUpdate); bool checkCHTableIfClassInfoExistsAndHasBeenExtended(TR_OpaqueClassBlock *clazz, bool &bClassHasBeenExtended); diff --git a/runtime/compiler/net/CommunicationStream.hpp b/runtime/compiler/net/CommunicationStream.hpp index afbcaf2ef70..6f4631f0c76 100644 --- a/runtime/compiler/net/CommunicationStream.hpp +++ b/runtime/compiler/net/CommunicationStream.hpp @@ -128,7 +128,7 @@ class CommunicationStream // likely to lose an increment when merging/rebasing/etc. // static const uint8_t MAJOR_NUMBER = 1; - static const uint16_t MINOR_NUMBER = 71; // ID:1QMsN16q0acJzn1qRQHY + static const uint16_t MINOR_NUMBER = 72; // ID: PB545sJS3QOBXIIPV5JZ static const uint8_t PATCH_NUMBER = 0; static uint32_t CONFIGURATION_FLAGS; diff --git a/runtime/compiler/net/MessageTypes.cpp b/runtime/compiler/net/MessageTypes.cpp index 7b9f312e008..35a0629603a 100644 --- a/runtime/compiler/net/MessageTypes.cpp +++ b/runtime/compiler/net/MessageTypes.cpp @@ -259,6 +259,8 @@ const char *messageNames[] = "KnownObjectTable_createSymRefWithKnownObject", "KnownObjectTable_getReferenceField", "KnownObjectTable_getKnownObjectTableDumpInfo", + "KnownObjectTable_getOpaqueClass", + "KnownObjectTable_getVectorBitSize", "AOTCache_getROMClassBatch", "AOTCacheMap_request", "AOTCacheMap_reply" diff --git a/runtime/compiler/net/MessageTypes.hpp b/runtime/compiler/net/MessageTypes.hpp index 5b8a679a17c..e6d42d0686d 100644 --- a/runtime/compiler/net/MessageTypes.hpp +++ b/runtime/compiler/net/MessageTypes.hpp @@ -284,12 +284,17 @@ enum MessageType : uint16_t KnownObjectTable_createSymRefWithKnownObject, KnownObjectTable_getReferenceField, KnownObjectTable_getKnownObjectTableDumpInfo, + // for getting a J9Class from KnownObjectTable + KnownObjectTable_getOpaqueClass, + // for getting a vectorBitSize from KnownObjectTable + KnownObjectTable_getVectorBitSize, AOTCache_getROMClassBatch, AOTCacheMap_request, AOTCacheMap_reply, + MessageType_MAXTYPE }; extern const char *messageNames[]; diff --git a/runtime/compiler/optimizer/VectorAPIExpansion.cpp b/runtime/compiler/optimizer/VectorAPIExpansion.cpp index d47e862cbc6..db4e844279e 100644 --- a/runtime/compiler/optimizer/VectorAPIExpansion.cpp +++ b/runtime/compiler/optimizer/VectorAPIExpansion.cpp @@ -637,12 +637,32 @@ TR_VectorAPIExpansion::getVectorSizeFromVectorSpecies(TR::Node *vectorSpeciesNod { if (vSpeciesSymRef->hasKnownObjectIndex()) { - TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp()->fe()); - TR::VMAccessCriticalSection getVectorSizeFromVectorSpeciesSection(fej9); + int32_t vectorBitSize = 0; +#if defined(J9VM_OPT_JITSERVER) + if (comp()->isOutOfProcessCompilation()) /* In server mode */ + { + auto stream = comp()->getStream(); + stream->write(JITServer::MessageType::KnownObjectTable_getVectorBitSize, + vSpeciesSymRef->getKnownObjectIndex()); + vectorBitSize = std::get<0>(stream->read()); + } + else +#endif /* defined(J9VM_OPT_JITSERVER) */ + { + TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp()->fe()); + + TR::VMAccessCriticalSection getVectorSizeFromVectorSpeciesSection(fej9); + + uintptr_t vectorSpeciesLocation = + comp()->getKnownObjectTable()->getPointer(vSpeciesSymRef->getKnownObjectIndex()); + uintptr_t vectorShapeLocation = + fej9->getReferenceField(vectorSpeciesLocation, + "vectorShape", + "Ljdk/incubator/vector/VectorShape;"); + vectorBitSize = fej9->getInt32Field(vectorShapeLocation, "vectorBitSize"); + } + - uintptr_t vectorSpeciesLocation = comp()->getKnownObjectTable()->getPointer(vSpeciesSymRef->getKnownObjectIndex()); - uintptr_t vectorShapeLocation = fej9->getReferenceField(vectorSpeciesLocation, "vectorShape", "Ljdk/incubator/vector/VectorShape;"); - int32_t vectorBitSize = fej9->getInt32Field(vectorShapeLocation, "vectorBitSize"); return (vec_sz_t)vectorBitSize; } } @@ -650,8 +670,8 @@ TR_VectorAPIExpansion::getVectorSizeFromVectorSpecies(TR::Node *vectorSpeciesNod } -J9Class * -TR_VectorAPIExpansion::getJ9ClassFromClassNode(TR::Compilation *comp, TR::Node *classNode) +TR_OpaqueClassBlock * +TR_VectorAPIExpansion::getOpaqueClassBlockFromClassNode(TR::Compilation *comp, TR::Node *classNode) { if (!classNode->getOpCode().hasSymbolReference()) return NULL; @@ -671,14 +691,27 @@ TR_VectorAPIExpansion::getJ9ClassFromClassNode(TR::Compilation *comp, TR::Node * if (knownObjectIndex != TR::KnownObjectTable::UNKNOWN) { - TR_J9VMBase *fej9 = comp->fej9(); + TR_OpaqueClassBlock *clazz = NULL; +#if defined(J9VM_OPT_JITSERVER) + if (comp->isOutOfProcessCompilation()) /* In server mode */ + { + auto stream = comp->getStream(); + stream->write(JITServer::MessageType::KnownObjectTable_getOpaqueClass, + symRef->getKnownObjectIndex()); + clazz = (TR_OpaqueClassBlock *)std::get<0>(stream->read()); + } + else +#endif /* defined(J9VM_OPT_JITSERVER) */ + { + TR_J9VMBase *fej9 = comp->fej9(); - TR::VMAccessCriticalSection getDataTypeFromClassNodeSection(fej9); + TR::VMAccessCriticalSection getDataTypeFromClassNodeSection(fej9); - uintptr_t javaLangClass = comp->getKnownObjectTable()->getPointer(knownObjectIndex); - J9Class *j9class = (J9Class *)(intptr_t)fej9->getInt64Field(javaLangClass, "vmRef"); + uintptr_t javaLangClass = comp->getKnownObjectTable()->getPointer(knownObjectIndex); + clazz = (TR_OpaqueClassBlock *)(intptr_t)fej9->getInt64Field(javaLangClass, "vmRef"); + } - return j9class; + return clazz; } return NULL; @@ -688,38 +721,24 @@ TR_VectorAPIExpansion::getJ9ClassFromClassNode(TR::Compilation *comp, TR::Node * TR::DataType TR_VectorAPIExpansion::getDataTypeFromClassNode(TR::Compilation *comp, TR::Node *classNode) { - J9Class *j9class = getJ9ClassFromClassNode(comp, classNode); + TR_OpaqueClassBlock *clazz = getOpaqueClassBlockFromClassNode(comp, classNode); - if (!j9class) return TR::NoType; + if (!clazz) return TR::NoType; TR_J9VMBase *fej9 = comp->fej9(); - J9JavaVM *vm = fej9->getJ9JITConfig()->javaVM; - - if (j9class == vm->floatReflectClass) - return TR::Float; - else if (j9class == vm->doubleReflectClass) - return TR::Double; - else if (j9class == vm->byteReflectClass) - return TR::Int8; - else if (j9class == vm->shortReflectClass) - return TR::Int16; - else if (j9class == vm->intReflectClass) - return TR::Int32; - else if (j9class == vm->longReflectClass) - return TR::Int64; - else - return TR::NoType; + return fej9->getClassPrimitiveDataType(clazz); } TR_VectorAPIExpansion::vapiObjType TR_VectorAPIExpansion::getObjectTypeFromClassNode(TR::Compilation *comp, TR::Node *classNode) { - J9Class *j9class = getJ9ClassFromClassNode(comp, classNode); + TR_OpaqueClassBlock *clazz = getOpaqueClassBlockFromClassNode(comp, classNode); - if (!j9class) return Unknown; + if (!clazz) return Unknown; - J9UTF8 *className = J9ROMCLASS_CLASSNAME(j9class->romClass); + J9ROMClass *romClass = TR::Compiler->cls.romClassOf(clazz); + J9UTF8 *className = J9ROMCLASS_CLASSNAME(romClass); int32_t length = J9UTF8_LENGTH(className); char *classNameChars = (char*)J9UTF8_DATA(className); diff --git a/runtime/compiler/optimizer/VectorAPIExpansion.hpp b/runtime/compiler/optimizer/VectorAPIExpansion.hpp index d59bb5c7d48..4d9ddd0822d 100644 --- a/runtime/compiler/optimizer/VectorAPIExpansion.hpp +++ b/runtime/compiler/optimizer/VectorAPIExpansion.hpp @@ -584,7 +584,8 @@ class TR_VectorAPIExpansion : public TR::Optimization * \param classNode * Node that loads \c java/lang/Class */ - static J9Class *getJ9ClassFromClassNode(TR::Compilation *comp, TR::Node *classNode); + static TR_OpaqueClassBlock *getOpaqueClassBlockFromClassNode(TR::Compilation *comp, + TR::Node *classNode); /** \brief diff --git a/runtime/compiler/runtime/J9CodeCache.cpp b/runtime/compiler/runtime/J9CodeCache.cpp index 6cf07feb679..a8615e30050 100644 --- a/runtime/compiler/runtime/J9CodeCache.cpp +++ b/runtime/compiler/runtime/J9CodeCache.cpp @@ -749,8 +749,10 @@ J9::CodeCache::resetTrampolines() } //reset the trampoline marks back to their starting positions - _trampolineAllocationMark = _trampolineBase; - _trampolineReservationMark = _trampolineBase; + // Note that permanent trampolines are allocated from _tempTrampolineBase downwards + // see initialize in OMRCodeCache.cpp + _trampolineAllocationMark = _tempTrampolineBase; + _trampolineReservationMark = _tempTrampolineBase; OMR::CodeCacheTempTrampolineSyncBlock *syncBlock; if (!_tempTrampolinesMax) diff --git a/runtime/compiler/runtime/JITClientSession.hpp b/runtime/compiler/runtime/JITClientSession.hpp index dbcc1d72e44..ad90105b93f 100644 --- a/runtime/compiler/runtime/JITClientSession.hpp +++ b/runtime/compiler/runtime/JITClientSession.hpp @@ -335,6 +335,16 @@ class ClientSessionData bool _isPortableRestoreMode; bool _isSnapshotModeEnabled; bool _isNonPortableRestoreMode; + // The reflect class pointers for the server to identify the classes + void *_voidReflectClassPtr; + void *_booleanReflectClassPtr; + void *_charReflectClassPtr; + void *_floatReflectClassPtr; + void *_doubleReflectClassPtr; + void *_byteReflectClassPtr; + void *_shortReflectClassPtr; + void *_intReflectClassPtr; + void *_longReflectClassPtr; }; // struct VMInfo /** diff --git a/runtime/gc/gctable.c b/runtime/gc/gctable.c index c42aa2b1d0c..f81308ae981 100644 --- a/runtime/gc/gctable.c +++ b/runtime/gc/gctable.c @@ -143,6 +143,7 @@ J9MemoryManagerFunctions MemoryManagerFunctions = { #endif /* !J9VM_ENV_DATA64 */ j9gc_objaccess_indexableStoreObject, j9gc_objaccess_indexableStoreAddress, + j9gc_objaccess_indexableDataDisplacement, j9gc_objaccess_mixedObjectReadI32, j9gc_objaccess_mixedObjectReadU32, j9gc_objaccess_mixedObjectReadI64, diff --git a/runtime/gc_base/ObjectAccessBarrier.hpp b/runtime/gc_base/ObjectAccessBarrier.hpp index e79ba09f46f..e4ceaf62848 100644 --- a/runtime/gc_base/ObjectAccessBarrier.hpp +++ b/runtime/gc_base/ObjectAccessBarrier.hpp @@ -226,6 +226,10 @@ class MM_ObjectAccessBarrier : public MM_BaseVirtual virtual void staticStoreU64(J9VMThread *vmThread, J9Class *clazz, U_64 *destSlot, U_64 value, bool isVolatile=false); virtual void staticStoreI64(J9VMThread *vmThread, J9Class *clazz, I_64 *destSlot, I_64 value, bool isVolatile=false); + MMINLINE virtual IDATA indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst) + { + return (IDATA)(((UDATA)dst) - ((UDATA)src)); + } virtual U_8 *getArrayObjectDataAddress(J9VMThread *vmThread, J9IndexableObject *arrayObject); virtual j9objectmonitor_t *getLockwordAddress(J9VMThread *vmThread, J9Object *object); virtual void cloneObject(J9VMThread *vmThread, J9Object *srcObject, J9Object *destObject); diff --git a/runtime/gc_base/accessBarrier.cpp b/runtime/gc_base/accessBarrier.cpp index b51463ca7a2..870f201dcaa 100644 --- a/runtime/gc_base/accessBarrier.cpp +++ b/runtime/gc_base/accessBarrier.cpp @@ -341,6 +341,24 @@ j9gc_objaccess_staticStoreU64Split(J9VMThread *vmThread, J9Class *clazz, U_64 *d barrier->staticStoreU64(vmThread, clazz, destSlot, value64, 0 != isVolatile); } +/** + * Returns the displacement for the data of moved array object. + * Used by the JIT, should only be called for off heap enabled cases, + * For adjacent Array, displacement = dst - src + * For Off-heap Array, displacement = 0. + * + * @param vmThread Pointer to the current J9VMThread + * @param src Pointer to the array object before moving + * @param dst Pointer to the array object after moving + * @return displacement + */ +IDATA +j9gc_objaccess_indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst) +{ + MM_ObjectAccessBarrier *barrier = MM_GCExtensions::getExtensions(vmThread)->accessBarrier; + return barrier->indexableDataDisplacement(vmThread, src, dst); + +} /* TODO: After all array accesses in the VM have been made arraylet safe, * it should be possible to delete this method + its associated ENVY and diff --git a/runtime/gc_base/gc_internal.h b/runtime/gc_base/gc_internal.h index 734475bc51c..df2f25aebf9 100644 --- a/runtime/gc_base/gc_internal.h +++ b/runtime/gc_base/gc_internal.h @@ -101,6 +101,7 @@ extern J9_CFUNC BOOLEAN j9gc_hot_reference_field_required(J9JavaVM *javaVM); extern J9_CFUNC BOOLEAN j9gc_off_heap_allocation_enabled(J9JavaVM *javaVM); extern J9_CFUNC uint32_t j9gc_max_hot_field_list_length(J9JavaVM *javaVM); extern J9_CFUNC void j9gc_objaccess_indexableStoreAddress(J9VMThread *vmThread, J9IndexableObject *destObject, I_32 index, void *value, UDATA isVolatile); +extern J9_CFUNC IDATA j9gc_objaccess_indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst); extern J9_CFUNC void j9gc_objaccess_mixedObjectStoreAddress(J9VMThread *vmThread, j9object_t destObject, UDATA offset, void *value, UDATA isVolatile); extern J9_CFUNC void j9gc_objaccess_cloneObject(J9VMThread *vmThread, j9object_t srcObject, j9object_t destObject); extern J9_CFUNC void j9gc_objaccess_copyObjectFields(J9VMThread *vmThread, J9Class *valueClass, J9Object *srcObject, UDATA srcOffset, J9Object *destObject, UDATA destOffset, MM_objectMapFunction objectMapFunction, void *objectMapData, UDATA initializeLockWord); diff --git a/runtime/gc_glue_java/ArrayletObjectModel.cpp b/runtime/gc_glue_java/ArrayletObjectModel.cpp index 9aa8470f7c7..39536cdf8bd 100644 --- a/runtime/gc_glue_java/ArrayletObjectModel.cpp +++ b/runtime/gc_glue_java/ArrayletObjectModel.cpp @@ -154,6 +154,22 @@ GC_ArrayletObjectModel::fixupInternalLeafPointersAfterCopy(J9IndexableObject *de } #if defined(J9VM_ENV_DATA64) +bool +GC_ArrayletObjectModel::isDataAdjacentToHeader(J9IndexableObject *arrayPtr) +{ + uintptr_t dataSizeInBytes = getDataSizeInBytes(arrayPtr); + return isDataAdjacentToHeader(dataSizeInBytes); +} + +bool +GC_ArrayletObjectModel::isDataAdjacentToHeader(uintptr_t dataSizeInBytes) +{ + MM_GCExtensionsBase *extensions = MM_GCExtensionsBase::getExtensions(_omrVM); + uintptr_t minimumSpineSizeAfterGrowing = extensions->getObjectAlignmentInBytes(); + return ((UDATA_MAX == _largestDesirableArraySpineSize) + || (dataSizeInBytes <= (_largestDesirableArraySpineSize - minimumSpineSizeAfterGrowing - contiguousIndexableHeaderSize()))); +} + void GC_ArrayletObjectModel::AssertArrayPtrIsIndexable(J9IndexableObject *arrayPtr) { diff --git a/runtime/gc_glue_java/ArrayletObjectModel.hpp b/runtime/gc_glue_java/ArrayletObjectModel.hpp index 1d7547fb907..e6ca7aee4ec 100644 --- a/runtime/gc_glue_java/ArrayletObjectModel.hpp +++ b/runtime/gc_glue_java/ArrayletObjectModel.hpp @@ -1307,6 +1307,26 @@ class GC_ArrayletObjectModel : public GC_ArrayletObjectModelBase */ void fixupInternalLeafPointersAfterCopy(J9IndexableObject *destinationPtr, J9IndexableObject *sourcePtr); +#if defined(J9VM_ENV_DATA64) + /** + * Used to determine if the array data is adjacent to its header or in offheap. + * The determination is based on the actual value of dataAddr field in the header. + * + * @param arrayPtr Pointer to the indexable object + * @return true if the arraylet data is adjacent to the header, false otherwise + */ + bool isDataAdjacentToHeader(J9IndexableObject *arrayPtr); + + /** + * Used to determine if the array data should be adjacent to its header or in offheap. + * The determination is based on the size, same how it would be done during the allocation of an object of such a size. + * + * @param dataSizeInBytes the size of data in an indexable object, in bytes, including leaves and alignment padding + * @return true if based on the value of dataSizeInBytes, the arraylet data is adjacent to the header, false otherwise + */ + bool isDataAdjacentToHeader(uintptr_t dataSizeInBytes); +#endif /* defined(J9VM_ENV_DATA64) */ + /** * Initialize the receiver, a new instance of GC_ObjectModel * diff --git a/runtime/gc_glue_java/UtilGlue.c b/runtime/gc_glue_java/UtilGlue.c index a1fa4167c11..2b1257abb86 100644 --- a/runtime/gc_glue_java/UtilGlue.c +++ b/runtime/gc_glue_java/UtilGlue.c @@ -39,7 +39,7 @@ OMR_Glue_GetVMDirectoryToken(void **token) * Provides the thread name to be used when no name is given. */ char * -OMR_Glue_GetThreadNameForUnamedThread(OMR_VMThread *vmThread) +OMR_Glue_GetThreadNameForUnnamedThread(OMR_VMThread *vmThread) { OMRPORT_ACCESS_FROM_OMRVMTHREAD(vmThread); return (char *)omrnls_lookup_message( diff --git a/runtime/gc_realtime/RealtimeAccessBarrier.hpp b/runtime/gc_realtime/RealtimeAccessBarrier.hpp index 274207052a4..fbfcc246816 100644 --- a/runtime/gc_realtime/RealtimeAccessBarrier.hpp +++ b/runtime/gc_realtime/RealtimeAccessBarrier.hpp @@ -156,6 +156,13 @@ class MM_RealtimeAccessBarrier : public MM_ObjectAccessBarrier virtual I_32 backwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots); virtual I_32 forwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots); + virtual IDATA + indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst) + { + Assert_MM_unreachable(); + return 0; + } + virtual bool checkStringConstantsLive(J9JavaVM *javaVM, j9object_t stringOne, j9object_t stringTwo); virtual bool checkStringConstantLive(J9JavaVM *javaVM, j9object_t string); diff --git a/runtime/gc_stats/CopyForwardStats.hpp b/runtime/gc_stats/CopyForwardStats.hpp index 93be6a3efca..cb87d0b90c7 100644 --- a/runtime/gc_stats/CopyForwardStats.hpp +++ b/runtime/gc_stats/CopyForwardStats.hpp @@ -74,6 +74,10 @@ class MM_CopyForwardStats : public MM_CopyForwardStatsCore uintptr_t _doubleMappedArrayletsCleared; /**< The number of double mapped arraylets that have been cleared durign marking */ uintptr_t _doubleMappedArrayletsCandidates; /**< The number of double mapped arraylets that have been visited during marking */ #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + uintptr_t _offHeapRegionsCleared; /**< The number of sparse heap allocated regions that have been cleared during marking */ + uintptr_t _offHeapRegionCandidates; /**< The number of sparse heap allocated regions that have been visited during marking */ +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ uint64_t _cycleStartTime; /**< The start time of a copy forward cycle */ @@ -111,6 +115,10 @@ class MM_CopyForwardStats : public MM_CopyForwardStatsCore _doubleMappedArrayletsCleared = 0; _doubleMappedArrayletsCandidates = 0; #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + _offHeapRegionsCleared = 0; + _offHeapRegionCandidates = 0; +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ } /** @@ -140,6 +148,10 @@ class MM_CopyForwardStats : public MM_CopyForwardStatsCore _doubleMappedArrayletsCleared += stats->_doubleMappedArrayletsCleared; _doubleMappedArrayletsCandidates += stats->_doubleMappedArrayletsCandidates; #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + _offHeapRegionsCleared += stats->_offHeapRegionsCleared; + _offHeapRegionCandidates += stats->_offHeapRegionCandidates; +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ } MM_CopyForwardStats() : @@ -161,6 +173,10 @@ class MM_CopyForwardStats : public MM_CopyForwardStatsCore , _doubleMappedArrayletsCleared(0) , _doubleMappedArrayletsCandidates(0) #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + , _offHeapRegionsCleared(0) + , _offHeapRegionCandidates(0) +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ {} }; diff --git a/runtime/gc_stats/MarkVLHGCStats.hpp b/runtime/gc_stats/MarkVLHGCStats.hpp index cbb154b4e95..5cbdb7c3031 100644 --- a/runtime/gc_stats/MarkVLHGCStats.hpp +++ b/runtime/gc_stats/MarkVLHGCStats.hpp @@ -78,6 +78,10 @@ class MM_MarkVLHGCStats : public MM_MarkVLHGCStatsCore uintptr_t _doubleMappedArrayletsCleared; /**< The number of double mapped arraylets that have been cleared durign marking */ uintptr_t _doubleMappedArrayletsCandidates; /**< The number of double mapped arraylets that have been visited during marking */ #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + uintptr_t _offHeapRegionsCleared; /**< The number of or sparse heap allocated regions that have been cleared during marking */ + uintptr_t _offHeapRegionCandidates; /**< The number of or sparse heap allocated regions that have been visited during marking */ +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ #if defined(J9MODRON_TGC_PARALLEL_STATISTICS) uintptr_t _splitArraysProcessed; /**< The number of array chunks (not counting parts smaller than the split size) processed by this thread */ @@ -118,6 +122,10 @@ class MM_MarkVLHGCStats : public MM_MarkVLHGCStatsCore _doubleMappedArrayletsCleared = 0; _doubleMappedArrayletsCandidates = 0; #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + _offHeapRegionsCleared = 0; + _offHeapRegionCandidates = 0; +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ #if defined(J9MODRON_TGC_PARALLEL_STATISTICS) _splitArraysProcessed = 0; @@ -156,6 +164,10 @@ class MM_MarkVLHGCStats : public MM_MarkVLHGCStatsCore _doubleMappedArrayletsCleared += statsToMerge->_doubleMappedArrayletsCleared; _doubleMappedArrayletsCandidates += statsToMerge->_doubleMappedArrayletsCandidates; #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + _offHeapRegionsCleared += statsToMerge->_offHeapRegionsCleared; + _offHeapRegionCandidates += statsToMerge->_offHeapRegionCandidates; +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ _concurrentGCThreadsCPUStartTimeSum += statsToMerge->_concurrentGCThreadsCPUStartTimeSum; _concurrentGCThreadsCPUEndTimeSum += statsToMerge->_concurrentGCThreadsCPUEndTimeSum; @@ -187,6 +199,10 @@ class MM_MarkVLHGCStats : public MM_MarkVLHGCStatsCore ,_doubleMappedArrayletsCleared(0) ,_doubleMappedArrayletsCandidates(0) #endif /* J9VM_GC_ENABLE_DOUBLE_MAP */ +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + ,_offHeapRegionsCleared(0) + ,_offHeapRegionCandidates(0) +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ #if defined(J9MODRON_TGC_PARALLEL_STATISTICS) ,_splitArraysProcessed(0) #endif /* J9MODRON_TGC_PARALLEL_STATISTICS */ diff --git a/runtime/gc_structs/MethodTypesIterator.hpp b/runtime/gc_structs/MethodTypesIterator.hpp index 5175f3c4bf8..c1b7a0cf88e 100644 --- a/runtime/gc_structs/MethodTypesIterator.hpp +++ b/runtime/gc_structs/MethodTypesIterator.hpp @@ -39,23 +39,23 @@ */ class GC_MethodTypesIterator { - U_32 _methodTypeTotal; - U_32 _methodTypeCount; + uint32_t _methodTypeTotal; + uint32_t _methodTypeCount; j9object_t *_methodTypePtr; public: - GC_MethodTypesIterator(U_32 methodTypeCount, j9object_t *methodTypes) : - _methodTypeCount(methodTypeCount), - _methodTypePtr(methodTypes) + GC_MethodTypesIterator(uint32_t methodTypeCount, j9object_t *methodTypes) + : _methodTypeCount(methodTypeCount) + , _methodTypePtr(methodTypes) { /* check if the class's MethodTypes have been abandoned due to hot * code replace. If so, this class has no MethodTypes of its own */ - if (_methodTypePtr == NULL) { + if (NULL == _methodTypePtr) { _methodTypeCount = 0; } _methodTypeTotal = _methodTypeCount; - }; + } /** * @return the next MethodType slot in the class containing an object reference @@ -64,15 +64,13 @@ class GC_MethodTypesIterator j9object_t * nextSlot() { - j9object_t *slotPtr; + j9object_t *slotPtr = NULL; - if(0 == _methodTypeCount) { - return NULL; + if (0 != _methodTypeCount) { + _methodTypeCount -= 1; + slotPtr = _methodTypePtr++; } - _methodTypeCount -= 1; - slotPtr = _methodTypePtr++; - return slotPtr; } @@ -81,7 +79,7 @@ class GC_MethodTypesIterator * @return zero based MethodType index of the entry returned by the last call of nextSlot. * @return -1 if nextSlot has yet to be called. */ - MMINLINE IDATA getIndex() { + MMINLINE intptr_t getIndex() { return _methodTypeTotal - _methodTypeCount - 1; } }; diff --git a/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.cpp b/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.cpp index df3f98f5525..d74ccaa1c56 100644 --- a/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.cpp +++ b/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.cpp @@ -30,6 +30,10 @@ #include "EnvironmentBase.hpp" #include "GCExtensions.hpp" #include "MarkVLHGCStats.hpp" +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) +#include "SparseAddressOrderedFixedSizeDataPool.hpp" +#include "SparseVirtualMemory.hpp" +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ #include "ReferenceStats.hpp" #include "VerboseManager.hpp" #include "VerboseWriterChain.hpp" @@ -282,6 +286,16 @@ MM_VerboseHandlerOutputVLHGC::outputContinuationInfo(MM_EnvironmentBase *env, UD } } +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) +void +MM_VerboseHandlerOutputVLHGC::outputOffHeapInfo(MM_EnvironmentBase *env, UDATA indent, UDATA offHeapRegionCandidates, UDATA offHeapRegionsCleared) +{ + if (0 != offHeapRegionCandidates) { + _manager->getWriterChain()->formatAndOutput(env, indent, "", offHeapRegionCandidates, offHeapRegionsCleared); + } +} +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ + void MM_VerboseHandlerOutputVLHGC::outputContinuationObjectInfo(MM_EnvironmentBase *env, uintptr_t indent) { @@ -347,7 +361,14 @@ MM_VerboseHandlerOutputVLHGC::outputMemoryInfoInnerStanza(MM_EnvironmentBase *en stats->_edenFreeHeapSize, stats->_edenHeapSize, ((UDATA)(((U_64)stats->_edenFreeHeapSize*100) / (U_64)stats->_edenHeapSize))); } - +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env->getOmrVM()); + if (extensions->isVirtualLargeObjectHeapEnabled) { + writer->formatAndOutput(env, indent, "", + extensions->largeObjectVirtualMemory->getSparseDataPool()->getAllocObjectCount(), + extensions->largeObjectVirtualMemory->getSparseDataPool()->getFreeListPoolAllocBytes()); + } +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ if (0 != stats->_arrayletReferenceObjects) { writer->formatAndOutput(env, indent, "", stats->_arrayletReferenceObjects, stats->_arrayletReferenceLeaves, stats->_largestReferenceArraylet); @@ -439,6 +460,9 @@ MM_VerboseHandlerOutputVLHGC::handleCopyForwardEnd(J9HookInterface** hook, UDATA } outputRememberedSetClearedInfo(env, irrsStats); +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + outputOffHeapInfo(env, 1, copyForwardStats->_offHeapRegionCandidates, copyForwardStats->_offHeapRegionsCleared); +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ outputUnfinalizedInfo(env, 1, copyForwardStats->_unfinalizedCandidates, copyForwardStats->_unfinalizedEnqueued); outputOwnableSynchronizerInfo(env, 1, copyForwardStats->_ownableSynchronizerCandidates, (copyForwardStats->_ownableSynchronizerCandidates-copyForwardStats->_ownableSynchronizerSurvived)); outputContinuationInfo(env, 1, copyForwardStats->_continuationCandidates, copyForwardStats->_continuationCleared); @@ -587,6 +611,9 @@ MM_VerboseHandlerOutputVLHGC::outputMarkSummary(MM_EnvironmentBase *env, const c outputRememberedSetClearedInfo(env, irrsStats); } +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + outputOffHeapInfo(env, 1, markStats->_offHeapRegionCandidates, markStats->_offHeapRegionsCleared); +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ outputUnfinalizedInfo(env, 1, markStats->_unfinalizedCandidates, markStats->_unfinalizedEnqueued); outputOwnableSynchronizerInfo(env, 1, markStats->_ownableSynchronizerCandidates, markStats->_ownableSynchronizerCleared); outputContinuationInfo(env, 1, markStats->_continuationCandidates, markStats->_continuationCleared); diff --git a/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.hpp b/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.hpp index 1e21848c017..f3de4d400fc 100644 --- a/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.hpp +++ b/runtime/gc_verbose_handler_vlhgc/VerboseHandlerOutputVLHGC.hpp @@ -66,6 +66,17 @@ class MM_VerboseHandlerOutputVLHGC : public MM_VerboseHandlerOutput void outputContinuationInfo(MM_EnvironmentBase *env, UDATA indent, UDATA continuationCandidates, UDATA continuationCleared); void outputContinuationObjectInfo(MM_EnvironmentBase *env, uintptr_t indent); +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + /** + * Output off-heap processing summary. + * @param env GC thread used for output. + * @param indent base level of indentation for the summary. + * @param offHeapRegionCandidates number of off-heap regions encountered. + * @param offHeapRegionsCleared number of off-heap regions cleared. + */ + void outputOffHeapInfo(MM_EnvironmentBase *env, UDATA indent, UDATA offHeapRegionCandidates, UDATA offHeapRegionsCleared); +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ + /** * Output reference processing summary. * @param env GC thread used for output. diff --git a/runtime/gc_vlhgc/VLHGCAccessBarrier.cpp b/runtime/gc_vlhgc/VLHGCAccessBarrier.cpp index a3df59931c3..291b2567305 100644 --- a/runtime/gc_vlhgc/VLHGCAccessBarrier.cpp +++ b/runtime/gc_vlhgc/VLHGCAccessBarrier.cpp @@ -271,6 +271,22 @@ MM_VLHGCAccessBarrier::copyArrayCritical(J9VMThread *vmThread, GC_ArrayObjectMod } } +IDATA +MM_VLHGCAccessBarrier::indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst) +{ + IDATA displacement = 0; + +#if defined(J9VM_ENV_DATA64) + Assert_MM_true(vmThread->isVirtualLargeObjectHeapEnabled); + /* Adjacency check against dst object since src object may be overwritten during sliding compaction. */ + if (_extensions->indexableObjectModel.isDataAdjacentToHeader(dst)) +#endif /* defined(J9VM_ENV_DATA64) */ + { + displacement = MM_ObjectAccessBarrier::indexableDataDisplacement(vmThread, src, dst); + } + return displacement; +} + void* MM_VLHGCAccessBarrier::jniGetPrimitiveArrayCritical(J9VMThread* vmThread, jarray array, jboolean *isCopy) { diff --git a/runtime/gc_vlhgc/VLHGCAccessBarrier.hpp b/runtime/gc_vlhgc/VLHGCAccessBarrier.hpp index 1fac62182c2..6ec5ded0fec 100644 --- a/runtime/gc_vlhgc/VLHGCAccessBarrier.hpp +++ b/runtime/gc_vlhgc/VLHGCAccessBarrier.hpp @@ -87,6 +87,8 @@ class MM_VLHGCAccessBarrier : public MM_ObjectAccessBarrier virtual I_32 backwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots); virtual I_32 forwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots); + virtual IDATA indexableDataDisplacement(J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst); + virtual void* jniGetPrimitiveArrayCritical(J9VMThread* vmThread, jarray array, jboolean *isCopy); virtual void jniReleasePrimitiveArrayCritical(J9VMThread* vmThread, jarray array, void * elems, jint mode); virtual const jchar* jniGetStringCritical(J9VMThread* vmThread, jstring str, jboolean *isCopy); diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index 289f2384fd5..ccbc0ec905c 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -4693,6 +4693,7 @@ typedef struct J9MemoryManagerFunctions { #endif /* !defined(J9VM_ENV_DATA64) */ void ( *j9gc_objaccess_indexableStoreObject)(struct J9VMThread *vmThread, J9IndexableObject *destObject, I_32 index, j9object_t value, UDATA isVolatile) ; void ( *j9gc_objaccess_indexableStoreAddress)(struct J9VMThread *vmThread, J9IndexableObject *destObject, I_32 index, void *value, UDATA isVolatile) ; + IDATA ( *j9gc_objaccess_indexableDataDisplacement)(struct J9VMThread *vmThread, J9IndexableObject *src, J9IndexableObject *dst) ; IDATA ( *j9gc_objaccess_mixedObjectReadI32)(struct J9VMThread *vmThread, j9object_t srcObject, UDATA offset, UDATA isVolatile) ; UDATA ( *j9gc_objaccess_mixedObjectReadU32)(struct J9VMThread *vmThread, j9object_t srcObject, UDATA offset, UDATA isVolatile) ; I_64 ( *j9gc_objaccess_mixedObjectReadI64)(struct J9VMThread *vmThread, j9object_t srcObject, UDATA offset, UDATA isVolatile) ; diff --git a/runtime/vm/JFRConstantPoolTypes.cpp b/runtime/vm/JFRConstantPoolTypes.cpp index 7079cee0eea..beb757b8b7c 100644 --- a/runtime/vm/JFRConstantPoolTypes.cpp +++ b/runtime/vm/JFRConstantPoolTypes.cpp @@ -774,6 +774,7 @@ VM_JFRConstantPoolTypes::addThreadEntry(J9VMThread *vmThread) entry->vmThread = vmThread; _buildResult = OK; omrthread_t osThread = vmThread->osThread; + j9object_t threadObject = vmThread->threadObject; entry = (ThreadEntry *) hashTableFind(_threadTable, entry); if (NULL != entry) { @@ -784,19 +785,22 @@ VM_JFRConstantPoolTypes::addThreadEntry(J9VMThread *vmThread) } entry->osTID = ((J9AbstractThread*)osThread)->tid; - entry->javaTID = J9VMJAVALANGTHREAD_TID(_currentThread, vmThread->threadObject); + if (NULL != threadObject) { + entry->javaTID = J9VMJAVALANGTHREAD_TID(_currentThread, threadObject); - entry->javaThreadName = copyStringToJ9UTF8WithMemAlloc(_currentThread, J9VMJAVALANGTHREAD_NAME(_currentThread, vmThread->threadObject), J9_STR_NONE, "", 0, NULL, 0); + entry->javaThreadName = copyStringToJ9UTF8WithMemAlloc(_currentThread, J9VMJAVALANGTHREAD_NAME(_currentThread, threadObject), J9_STR_NONE, "", 0, NULL, 0); - /* TODO is this always true? */ - entry->osThreadName = entry->javaThreadName; - if (isResultNotOKay()) goto done; + if (isResultNotOKay()) goto done; #if JAVA_SPEC_VERSION >= 19 - entry->threadGroupIndex = addThreadGroupEntry(J9VMJAVALANGTHREADFIELDHOLDER_GROUP(_currentThread, (J9VMJAVALANGTHREAD_HOLDER(_currentThread, vmThread->threadObject)))); + entry->threadGroupIndex = addThreadGroupEntry(J9VMJAVALANGTHREADFIELDHOLDER_GROUP(_currentThread, (J9VMJAVALANGTHREAD_HOLDER(_currentThread, threadObject)))); #else /* JAVA_SPEC_VERSION >= 19 */ - entry->threadGroupIndex = addThreadGroupEntry(J9VMJAVALANGTHREAD_GROUP(_currentThread, vmThread->threadObject)); + entry->threadGroupIndex = addThreadGroupEntry(J9VMJAVALANGTHREAD_GROUP(_currentThread, threadObject)); #endif /* JAVA_SPEC_VERSION >= 19 */ - if (isResultNotOKay()) goto done; + if (isResultNotOKay()) goto done; + } + + /* TODO is this always true? */ + entry->osThreadName = entry->javaThreadName; entry->index = _threadCount; _threadCount++; diff --git a/runtime/vm/jfr.cpp b/runtime/vm/jfr.cpp index c51a975f3da..1cb13a7b72a 100644 --- a/runtime/vm/jfr.cpp +++ b/runtime/vm/jfr.cpp @@ -58,7 +58,7 @@ static void initializeEventFields(J9VMThread *currentThread, J9JFREvent *jfrEven static int J9THREAD_PROC jfrSamplingThreadProc(void *entryArg); static void jfrExecutionSampleCallback(J9VMThread *currentThread, IDATA handlerKey, void *userData); static void jfrThreadCPULoadCallback(J9VMThread *currentThread, IDATA handlerKey, void *userData); - +static bool areJFRBuffersReadyForWrite(J9VMThread *currentThread); /** * Calculate the size in bytes of a JFR event. * @@ -129,6 +129,22 @@ jfrBufferNextDo(J9JFRBufferWalkState *walkState) return (J9JFREvent*)next; } +static bool +areJFRBuffersReadyForWrite(J9VMThread *currentThread) +{ + bool result = true; + J9JavaVM *vm = currentThread->javaVM; + + if ((!vm->jfrState.isStarted) + || (NULL == currentThread->jfrBuffer.bufferStart) + || (NULL == vm->jfrBuffer.bufferCurrent) + ) { + result = false; + } + + return result; +} + /** * Write out the contents of the global JFR buffer. * @@ -148,16 +164,18 @@ writeOutGlobalBuffer(J9VMThread *currentThread, bool finalWrite) j9tty_printf(PORTLIB, "\n!!! writing global buffer %p of size %p\n", currentThread, vm->jfrBuffer.bufferSize - vm->jfrBuffer.bufferRemaining); #endif /* defined(DEBUG) */ - VM_JFRWriter::flushJFRDataToFile(currentThread, finalWrite); + if (areJFRBuffersReadyForWrite(currentThread)) { + VM_JFRWriter::flushJFRDataToFile(currentThread, finalWrite); - /* Reset the buffer */ - vm->jfrBuffer.bufferRemaining = vm->jfrBuffer.bufferSize; - vm->jfrBuffer.bufferCurrent = vm->jfrBuffer.bufferStart; + /* Reset the buffer */ + vm->jfrBuffer.bufferRemaining = vm->jfrBuffer.bufferSize; + vm->jfrBuffer.bufferCurrent = vm->jfrBuffer.bufferStart; #if defined(DEBUG) - memset(vm->jfrBuffer.bufferStart, 0, J9JFR_GLOBAL_BUFFER_SIZE); + memset(vm->jfrBuffer.bufferStart, 0, J9JFR_GLOBAL_BUFFER_SIZE); #endif /* defined(DEBUG) */ + } return true; } @@ -180,7 +198,7 @@ flushBufferToGlobal(J9VMThread *currentThread, J9VMThread *flushThread) UDATA bufferSize = flushThread->jfrBuffer.bufferCurrent - flushThread->jfrBuffer.bufferStart; bool success = true; - if (NULL == flushThread->jfrBuffer.bufferStart) { + if (!areJFRBuffersReadyForWrite(currentThread)) { goto done; } @@ -284,7 +302,9 @@ reserveBuffer(J9VMThread *currentThread, UDATA size) Assert_VM_true(((currentThread)->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS) || ((J9_XACCESS_EXCLUSIVE == vm->exclusiveAccessState) || (J9_XACCESS_EXCLUSIVE == vm->safePointState))); - + if (!areJFRBuffersReadyForWrite(currentThread)) { + goto done; + } /* If the event is larger than the buffer, fail without attemptiong to flush */ if (size <= currentThread->jfrBuffer.bufferSize) { @@ -959,9 +979,11 @@ jfrSamplingThreadProc(void *entryArg) while (J9JFR_SAMPLER_STATE_STOP != vm->jfrSamplerState) { J9SignalAsyncEvent(vm, NULL, vm->jfrAsyncKey); if (0 == (count % 100)) { // 1 second + omrthread_monitor_exit(vm->jfrSamplerMutex); internalAcquireVMAccess(currentThread); jfrCPULoad(currentThread); internalReleaseVMAccess(currentThread); + omrthread_monitor_enter(vm->jfrSamplerMutex); if (0 == (count % 1000)) { // 10 seconds J9SignalAsyncEvent(vm, NULL, vm->jfrThreadCPULoadAsyncKey); }