Skip to content

Commit

Permalink
Initialize fieldClassReg for static unresolved reads
Browse files Browse the repository at this point in the history
When generating code for a watched field event, if an unresolved
static field is being read, we do not intialize the fieldClassReg
correctly. The fieldClassReg is used to test if a field is being
watched. Failure to initialize this register correctly results in
an invalid test being generated at runtime, causing a bug.

This commit correctly initializes the fieldClassReg for the missing
corner case.

Signed-off-by: Dhruv Chopra <[email protected]>
  • Loading branch information
dchopra001 committed Jun 27, 2019
1 parent 8bf50f5 commit cf5e106
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions runtime/compiler/x/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12760,11 +12760,15 @@ J9::X86::TreeEvaluator::generateTestAndReportFieldWatchInstructions(TR::CodeGene
}
else
{
fieldClassReg = cg->allocateRegister();
if (isWrite)
{
fieldClassReg = cg->allocateRegister();
generateRegMemInstruction(LRegMem(), node, fieldClassReg, generateX86MemoryReference(sideEffectRegister, fej9->getOffsetOfClassFromJavaLangClassField(), cg), cg);
}
else
{
fieldClassReg = sideEffectRegister;
}
classFlagsMemRef = generateX86MemoryReference(fieldClassReg, fej9->getOffsetOfClassFlags(), cg);
}
}
Expand All @@ -12787,7 +12791,7 @@ J9::X86::TreeEvaluator::generateTestAndReportFieldWatchInstructions(TR::CodeGene
deps->stopAddingConditions();
generateLabelInstruction(LABEL, node, endLabel, deps, cg);

if (isInstanceField || (!isResolved) || isAOTCompile)
if (isInstanceField || (!isResolved && isWrite) || isAOTCompile)
{
cg->stopUsingRegister(fieldClassReg);
}
Expand Down

0 comments on commit cf5e106

Please sign in to comment.