From 5242df175673dffedb99b87f676206d5b647d6ab Mon Sep 17 00:00:00 2001 From: Abdulrahman Alattas Date: Fri, 21 Jun 2024 10:22:50 -0400 Subject: [PATCH] Add offHeapCopyMemory in VP DelayedTransformations --- compiler/optimizer/OMRValuePropagation.cpp | 16 ++++++++++++++++ compiler/optimizer/OMRValuePropagation.hpp | 1 + compiler/optimizer/ValuePropagationCommon.cpp | 1 + 3 files changed, 18 insertions(+) diff --git a/compiler/optimizer/OMRValuePropagation.cpp b/compiler/optimizer/OMRValuePropagation.cpp index 24fe9d382f8..6dbf92f7707 100644 --- a/compiler/optimizer/OMRValuePropagation.cpp +++ b/compiler/optimizer/OMRValuePropagation.cpp @@ -7264,6 +7264,22 @@ void OMR::ValuePropagation::doDelayedTransformations() } _scalarizedArrayCopies.deleteAll(); +#if defined(J9_PROJECT_SPECIFIC) && defined(OMR_GC_SPARSE_HEAP_ALLOCATION) + // Transform Unsafe.copyMemory in OffHeap + if (TR::Compiler->om.isOffHeapAllocationEnabled()) + { + ListIterator copyMemoryIt(&_offHeapCopyMemory); + TR_TreeTopNodePair *copyMemoryPair; + for (copyMemoryPair = copyMemoryIt.getFirst(); + copyMemoryPair; copyMemoryPair = copyMemoryIt.getNext()) + { + if (performTransformation(comp(), "O^O Call arraycopy instead of Unsafe.copyMemory: %p\n", copyMemoryPair->_node)) + TR::TransformUtil::transformUnsafeCopyMemorytoArrayCopyForOffHeap(self()->comp(), copyMemoryPair->_treetop, copyMemoryPair->_node); + } + _offHeapCopyMemory.deleteAll(); + } +#endif + // NOTE: the array copy spine checks are processed before the reference, realtime, and // unknown arraycopies because it refactors the CFG at a higher (outer) level // than the others. To simplify the CFG it should be run first. diff --git a/compiler/optimizer/OMRValuePropagation.hpp b/compiler/optimizer/OMRValuePropagation.hpp index edb077d2b94..0b0276eecec 100644 --- a/compiler/optimizer/OMRValuePropagation.hpp +++ b/compiler/optimizer/OMRValuePropagation.hpp @@ -994,6 +994,7 @@ class ValuePropagation : public TR::Optimization List _arrayCopySpineCheck; List _multiLeafCallsToInline; List _scalarizedArrayCopies; + List _offHeapCopyMemory; List _converterCalls; List _objectCloneCalls; List _arrayCloneCalls; diff --git a/compiler/optimizer/ValuePropagationCommon.cpp b/compiler/optimizer/ValuePropagationCommon.cpp index d29f095ff30..db72db85811 100644 --- a/compiler/optimizer/ValuePropagationCommon.cpp +++ b/compiler/optimizer/ValuePropagationCommon.cpp @@ -120,6 +120,7 @@ OMR::ValuePropagation::ValuePropagation(TR::OptimizationManager *manager) _javaLangClassGetComponentTypeCalls(trMemory()), _unknownTypeArrayCopyTrees(trMemory()), _scalarizedArrayCopies(trMemory()), + _offHeapCopyMemory(trMemory()), _predictedThrows(trMemory()), _prexClasses(trMemory()), _prexMethods(trMemory()),