From c6c8af3b7f45b4820092083ab545ce042ce94824 Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Wed, 6 Sep 2023 08:15:11 -0700 Subject: [PATCH] Guard a call to VMwrtbarWithoutStoreEvaluator Guard a call to VMwrtbarWithoutStoreEvaluator (which is only compatible with non-realtime GC) to ensure it is not called under realtime GC. Signed-off-by: Dylan Tuttle --- .../compiler/x/codegen/J9TreeEvaluator.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp index 78f1824ecee..ce0d8508bb8 100644 --- a/runtime/compiler/x/codegen/J9TreeEvaluator.cpp +++ b/runtime/compiler/x/codegen/J9TreeEvaluator.cpp @@ -9703,11 +9703,24 @@ static TR::Register* inlineCompareAndSwapObjectNative(TR::Node* node, TR::CodeGe generateRegInstruction(TR::InstOpCode::SETE1Reg, node, result, cg); generateRegRegInstruction(TR::InstOpCode::MOVZXReg4Reg1, node, result, result, cg); - // We could insert a runtime test for whether the write actually succeeded or not. - // However, since in practice it will almost always succeed we do not want to - // penalize general runtime performance especially if it is still correct to do - // a write barrier even if the store never actually happened. - TR::TreeEvaluator::VMwrtbarWithoutStoreEvaluator(node, objectNode, newValueNode, NULL, cg->generateScratchRegisterManager(), cg); + // Non-realtime: Generate a write barrier for this kind of object. + // + if (!comp->getOptions()->realTimeGC()) + { + // We could insert a runtime test for whether the write actually succeeded or not. + // However, since in practice it will almost always succeed we do not want to + // penalize general runtime performance especially if it is still correct to do + // a write barrier even if the store never actually happened. + TR_X86ScratchRegisterManager *scratchRegisterManager = cg->generateScratchRegisterManager(); + + TR::TreeEvaluator::VMwrtbarWithoutStoreEvaluator( + node, + objectNode, + newValueNode, + NULL, + scratchRegisterManager, + cg); + } cg->stopUsingRegister(tmp); cg->stopUsingRegister(EAX);