Skip to content

Commit b5a6b60

Browse files
authored
Merge pull request #21621 from jdmpapin/latin1-inflate-uninit-temps
Ensure temps are initialized for StringLatin1.inflate([BI[BII)V
2 parents f4b5007 + 700e4e1 commit b5a6b60

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

runtime/compiler/optimizer/J9RecognizedCallTransformer.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ void J9::RecognizedCallTransformer::process_java_lang_StringLatin1_inflate_BIBII
306306

307307
TR_ASSERT_FATAL(comp()->cg()->getSupportsArrayTranslateTROTNoBreak(), "Support for arraytranslateTROTNoBreak is required");
308308

309+
// Anchor a copy of the call node just before treetop so that all of the
310+
// children will be commoned across the split point, and all of the temps
311+
// will be initialized before the first opportunity to go to the fallback
312+
// path. Otherwise, the fallback path could end up using temps that are
313+
// sometimes uninitialized. This copy will be removed just after splitting.
314+
TR::TreeTop *callCopyTT = TR::TreeTop::create(
315+
comp(), TR::Node::create(node, TR::treetop, 1, node->duplicateTree(false)));
316+
317+
treetop->insertBefore(callCopyTT);
318+
309319
bool is64BitTarget = comp()->target().is64Bit();
310320

311321
TR::Node *srcObj = node->getChild(0);
@@ -377,6 +387,8 @@ void J9::RecognizedCallTransformer::process_java_lang_StringLatin1_inflate_BIBII
377387
TR::Block *fallbackPathBlock = fallThroughPathBlock->split(treetop, cfg, true /* fixUpCommoning */, true /* copyExceptionSuccessors */);
378388
TR::Block *tailBlock = fallbackPathBlock->split(treetop->getNextTreeTop(), cfg, true /* fixUpCommoning */, true /* copyExceptionSuccessors */);
379389

390+
TR::TransformUtil::removeTree(comp(), callCopyTT);
391+
380392
// Go to the tail block from the fall-through block
381393
TR::Node *gotoNode = TR::Node::create(node, TR::Goto);
382394
TR::TreeTop *gotoTree = TR::TreeTop::create(comp(), gotoNode, NULL, NULL);

0 commit comments

Comments
 (0)