Skip to content

Commit 5111063

Browse files
committed
Update CRC32C acceleration for off-heap
The acceleration was initially disabled because it added array header size to the array object, which was required to reach the elements. However, this is unnecessary for off-heap mode. As a result, the evaluator has been updated to add the array header size exclusively for non-off-heap mode, while in off-heap mode, it now retrieves the data element address directly from the array header, enabling acceleration in off-heap mode. Signed-off-by: Shubham Verma <[email protected]>
1 parent 7df76af commit 5111063

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

runtime/compiler/z/codegen/J9CodeGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3734,7 +3734,7 @@ J9::Z::CodeGenerator::suppressInliningOfRecognizedMethod(TR::RecognizedMethod me
37343734
}
37353735

37363736
static bool disableCRC32CAcceleration = (feGetEnv("TR_DisableCRC32CAcceleration") != NULL);
3737-
if (!disableCRC32CAcceleration && self()->getSupportsVectorRegisters() && !TR::Compiler->om.canGenerateArraylets() && !TR::Compiler->om.isOffHeapAllocationEnabled())
3737+
if (!disableCRC32CAcceleration && self()->getSupportsVectorRegisters() && !TR::Compiler->om.canGenerateArraylets())
37383738
{
37393739
if (method == TR::java_util_zip_CRC32C_updateBytes ||
37403740
method == TR::java_util_zip_CRC32C_updateDirectByteBuffer)

runtime/compiler/z/codegen/J9TreeEvaluator.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,10 +2231,27 @@ J9::Z::TreeEvaluator::inlineCRC32CUpdateBytes(TR::Node *node, TR::CodeGenerator
22312231
generateRREInstruction(cg, TR::InstOpCode::LLGFR, node, offset, offset);
22322232
generateRREInstruction(cg, TR::InstOpCode::LLGFR, node, end, end);
22332233

2234+
// Offset to be added to array object pointer to get to the data elements
2235+
int32_t offsetToDataElements = isDirectBuffer ? 0 : TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
2236+
#ifdef J9VM_GC_SPARSE_HEAP_ALLOCATION
2237+
if (TR::Compiler->om.isOffHeapAllocationEnabled())
2238+
{
2239+
// Load first data element address
2240+
generateRXInstruction(cg,
2241+
TR::InstOpCode::getLoadOpCode(),
2242+
node,
2243+
array,
2244+
generateS390MemoryReference(array, cg->comp()->fej9()->getOffsetOfContiguousDataAddrField(), cg));
2245+
2246+
// Since the first data element address is retrieved from the array header, the offset is set to 0
2247+
offsetToDataElements = 0;
2248+
}
2249+
#endif /* J9VM_GC_SPARSE_HEAP_ALLOCATION */
2250+
22342251
// Calculate buffer pointer = array + offset
2235-
// For updateBytes need to account for array header size
2252+
// For updateBytes, in non off-heap mode, need to account for array header size
22362253
TR::Register* buffer = cg->allocateRegister();
2237-
generateRXInstruction(cg, TR::InstOpCode::getLoadAddressOpCode(), node, buffer, generateS390MemoryReference(array, offset, isDirectBuffer ? 0 : TR::Compiler->om.contiguousArrayHeaderSizeInBytes(), cg));
2254+
generateRXInstruction(cg, TR::InstOpCode::getLoadAddressOpCode(), node, buffer, generateS390MemoryReference(array, offset, offsetToDataElements, cg));
22382255

22392256
// Adjust remaining count for offset index
22402257
generateRRRInstruction(cg, TR::InstOpCode::getSubtractThreeRegOpCode(), node, remaining, end, offset);

0 commit comments

Comments
 (0)