From c191852fca96806cab6c7d31161da8df151dca90 Mon Sep 17 00:00:00 2001 From: Abdulrahman Alattas Date: Wed, 2 Oct 2024 11:42:20 -0400 Subject: [PATCH] Assert dstObj in arraycopyEval is not a dataAddrPtr in X/Z Signed-off-by: Abdulrahman Alattas --- runtime/compiler/x/codegen/J9TreeEvaluator.cpp | 6 ++++++ runtime/compiler/z/codegen/J9TreeEvaluator.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp index 7b368f4d2e1..1a17970bafe 100644 --- a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp @@ -1851,6 +1851,12 @@ TR::Register *J9::X86::TreeEvaluator::arraycopyEvaluator(TR::Node *node, TR::Cod auto dstReg = cg->evaluate(node->getChild(3)); auto sizeReg = cg->evaluate(node->getChild(4)); +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + if (TR::Compiler->om.isOffHeapAllocationEnabled()) + // For correct card-marking calculation, the dstObjNode should be the baseObj not the dataAddrPointer + TR_ASSERT_FATAL(!node->getChild(1)->isDataAddrPointer(), "The byteDstObjNode child of arraycopy cannot be a dataAddrPointer"); +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ + if (comp->target().is64Bit() && !TR::TreeEvaluator::getNodeIs64Bit(node->getChild(4), cg)) { generateRegRegInstruction(TR::InstOpCode::MOVZXReg8Reg4, node, sizeReg, sizeReg, cg); diff --git a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp index 99d02b60f3b..4f1c724d877 100644 --- a/runtime/compiler/z/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/z/codegen/J9TreeEvaluator.cpp @@ -14257,6 +14257,12 @@ J9::Z::TreeEvaluator::referenceArraycopyEvaluator(TR::Node * node, TR::CodeGener TR::Node* byteDstNode = node->getChild(3); TR::Node* byteLenNode = node->getChild(4); +#if defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) + if (TR::Compiler->om.isOffHeapAllocationEnabled()) + // For correct card-marking calculation, the dstObjNode should be the baseObj not the dataAddrPointer + TR_ASSERT_FATAL(!byteDstObjNode->isDataAddrPointer(), "The byteDstObjNode child of arraycopy cannot be a dataAddrPointer"); +#endif /* defined(J9VM_GC_SPARSE_HEAP_ALLOCATION) */ + TR::Register* byteSrcObjReg = cg->evaluate(byteSrcObjNode); TR::Register* byteDstObjReg = cg->evaluate(byteDstObjNode);