Skip to content

Commit

Permalink
Merge pull request #2248 from 0dvictor/cleanup
Browse files Browse the repository at this point in the history
Clean up deprecated recognized method inlining
  • Loading branch information
andrewcraik committed Jul 5, 2018
2 parents 268a2fb + 6b6cbdb commit c76c527
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 731 deletions.
2 changes: 0 additions & 2 deletions runtime/compiler/codegen/J9RecognizedMethodsEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
java_lang_Math_tanh,
java_lang_Object_init,
java_lang_Object_getClass,
java_lang_Object_hashCodeImpl,
java_lang_Object_clone,
java_lang_Object_newInstancePrototype,
java_lang_Object_getAddressAsPrimitive,
Expand Down Expand Up @@ -696,7 +695,6 @@
com_ibm_jit_JITHelpers_getClassFromJ9Class64,
com_ibm_jit_JITHelpers_getAddressAsPrimitive32,
com_ibm_jit_JITHelpers_getAddressAsPrimitive64,
com_ibm_jit_JITHelpers_hashCodeImpl,
com_ibm_jit_JITHelpers_optimizedClone,
com_ibm_jit_JITHelpers_getSuperclass,
com_ibm_jit_JITHelpers_getPackedDataSizeFromJ9Class32,
Expand Down
25 changes: 12 additions & 13 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,6 @@ TR_ResolvedJ9Method::TR_ResolvedJ9Method(TR_OpaqueMethodBlock * aMethod, TR_Fron
{
{TR::java_lang_Object_init, 6, "<init>", (int16_t)-1, "*"},
{x(TR::java_lang_Object_getClass, "getClass", "()Ljava/lang/Class;")},
{x(TR::java_lang_Object_hashCodeImpl, "hashCode", "()I")},
{x(TR::java_lang_Object_clone, "clone", "()Ljava/lang/Object;")},
{x(TR::java_lang_Object_newInstancePrototype, "newInstancePrototype", "(Ljava/lang/Class;)Ljava/lang/Object;")},
{x(TR::java_lang_Object_getAddressAsPrimitive, "getAddressAsPrimitive", "(Ljava/lang/Object;)I")},
Expand Down Expand Up @@ -3260,7 +3259,6 @@ TR_ResolvedJ9Method::TR_ResolvedJ9Method(TR_OpaqueMethodBlock * aMethod, TR_Fron
{x(TR::com_ibm_jit_JITHelpers_getClassFromJ9Class64, "getClassFromJ9Class64", "(J)Ljava/lang/Class;")},
{x(TR::com_ibm_jit_JITHelpers_getAddressAsPrimitive64, "getAddressAsPrimitive64", "(Ljava/lang/Object;)J")},
#endif
{x(TR::com_ibm_jit_JITHelpers_hashCodeImpl, "hashCodeImpl", "(Ljava/lang/Object;)I")},
{x(TR::com_ibm_jit_JITHelpers_getSuperclass, "getSuperclass", "(Ljava/lang/Class;)Ljava/lang/Class;")},
{x(TR::com_ibm_jit_JITHelpers_optimizedClone, "optimizedClone", "(Ljava/lang/Object;)Ljava/lang/Object;")},
{x(TR::com_ibm_jit_JITHelpers_getPackedDataSizeFromJ9Class32, "getPackedDataSizeFromJ9Class32", "(I)I")},
Expand Down Expand Up @@ -4596,12 +4594,18 @@ TR_ResolvedJ9Method::setRecognizedMethodInfo(TR::RecognizedMethod rm)
}
}

if (TR::Options::getCmdLineOptions()->getOption(TR_FullSpeedDebug) &&
((rm == TR::com_ibm_jit_JITHelpers_hashCodeImpl) ||
(rm == TR::com_ibm_jit_JITHelpers_getSuperclass) ||
(rm == TR::com_ibm_jit_DecimalFormatHelper_formatAsDouble) ||
(rm == TR::com_ibm_jit_DecimalFormatHelper_formatAsFloat)))
return;
if (TR::Options::getCmdLineOptions()->getOption(TR_FullSpeedDebug))
{
switch (rm)
{
case TR::com_ibm_jit_JITHelpers_getSuperclass:
case TR::com_ibm_jit_DecimalFormatHelper_formatAsDouble:
case TR::com_ibm_jit_DecimalFormatHelper_formatAsFloat:
return;
default:
break;
}
}

if ( isMethodInValidLibrary(fej9(),this) &&
!failBecauseOfHCR) // With HCR, non-native methods can change, so we shouldn't "recognize" them
Expand All @@ -4619,10 +4623,6 @@ TR_ResolvedJ9Method::setRecognizedMethodInfo(TR::RecognizedMethod rm)
if (disableRecMethods && fej9()->isAOT_DEPRECATED_DO_NOT_USE()) // AOT_JIT_GAP
{
switch (rm) {
#if defined(TR_TARGET_X86)
case TR::java_lang_System_currentTimeMillis: // This needs AOT relocation. For now, only implemented on x86
#endif
//|| rm == TR::java_lang_J9VMInternals_identityHashCode
case TR::java_lang_Thread_currentThread:
case TR::sun_misc_Unsafe_compareAndSwapInt_jlObjectJII_Z:
case TR::sun_misc_Unsafe_compareAndSwapLong_jlObjectJJJ_Z:
Expand Down Expand Up @@ -4800,7 +4800,6 @@ TR_ResolvedJ9Method::setRecognizedMethodInfo(TR::RecognizedMethod rm)
case TR::java_lang_Object_clone:

case TR::java_lang_System_nanoTime:
case TR::java_lang_Object_hashCodeImpl:
case TR::java_lang_String_hashCodeImplCompressed:
case TR::java_lang_String_hashCodeImplDecompressed:
case TR::sun_nio_ch_NativeThread_current:
Expand Down
30 changes: 0 additions & 30 deletions runtime/compiler/ilgen/Walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5324,36 +5324,6 @@ break
else if (resolvedMethodSymbol->getRecognizedMethod() == TR::com_ibm_jit_JITHelpers_getAddressAsPrimitive64)
isCallAddressAsPrimitive64 = true;
}

///if (!strncmp(comp()->getCurrentMethod()->nameChars(), "hashCodeImpl", 12) &&
/// isCallGetLength)
if (_methodSymbol->getRecognizedMethod() == TR::com_ibm_jit_JITHelpers_hashCodeImpl)
{
if (isCallGetLength)
{
// fold away Array.getLength because its guaranteed that the parm is an array
//
TR::Node::recreate(callNode, TR::arraylength);
callNode->setArrayStride(sizeof(intptrj_t));
if (treeTopNode->getOpCode().isResolveOrNullCheck())
{
TR::Node::recreate(treeTopNode, TR::NULLCHK);
treeTopNode->setSymbolReference(comp()->getSymRefTab()->findOrCreateNullCheckSymbolRef(_methodSymbol));
}
}
else if (isCallAddressAsPrimitive32)
{
// the first child is a instance of JITHelpers, should be removed since the new node is no longer a method call
callNode->removeChild(0);
TR::Node::recreate(callNode, TR::a2i);
}
else if (isCallAddressAsPrimitive64)
{
// the first child is a instance of JITHelpers, should be removed since the new node is no longer a method call
callNode->removeChild(0);
TR::Node::recreate(callNode, TR::a2l);
}
}
}

if (resolvedMethodSymbol &&
Expand Down
13 changes: 1 addition & 12 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3161,18 +3161,7 @@ bool TR_MultipleCallTargetInliner::inlineCallTargets(TR::ResolvedMethodSymbol *c
// dont inline into cold blocks
if (block->isCold() || !block->getExceptionPredecessors().empty())
{
TR::RecognizedMethod rm = callerSymbol->getRecognizedMethod();
if (rm == TR::com_ibm_jit_JITHelpers_hashCodeImpl)
{
//printf("cold block in %s\n", sig);
heuristicTrace(tracer(),"METHOD: %s NOT marking cold block: parent=%p\n", tracer()->traceSignature(callerSymbol), parent);
}
else
{
//tt = block->getExit();
//continue;
isCold = true;
}
isCold = true;
}

// FIXME: the following assumes that catch blocks are at the end of the method
Expand Down
83 changes: 1 addition & 82 deletions runtime/compiler/optimizer/J9Simplifier.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -328,16 +328,6 @@ J9::Simplifier::simplifylCallMethods(TR::Node * node, TR::Block * block)
}
}
}
else if (comp()->cg()->getSupportsFastCTM() && node->getNumChildren() == 0 && node->getReferenceCount() == 2)
{
TR::ResolvedMethodSymbol * methodSymbol = node->getSymbol()->getResolvedMethodSymbol();
if (methodSymbol &&
(methodSymbol->getRecognizedMethod() == TR::java_lang_System_currentTimeMillis) &&
(methodSymbol->isVMInternalNative() || methodSymbol->isJITInternalNative()))
{
node = foldLongStoreOfCurrentTimeMillis(node, block);
}
}
else
{
TR::MethodSymbol * symbol = node->getSymbol()->castToMethodSymbol();
Expand Down Expand Up @@ -485,77 +475,6 @@ TR::Node *J9::Simplifier::convertNanoTime(TR::Node * node, TR::Block * block)
return node;
}

TR::Node *J9::Simplifier::foldLongStoreOfCurrentTimeMillis(TR::Node * node, TR::Block * block)
{
// Walk the block to find this node
//
TR::TreeTop * tt;
TR::TreeTop * exitTree = block->getExit();
for (tt = block->getEntry(); tt != exitTree; tt = tt->getNextRealTreeTop())
{
if (((tt->getNode()->getOpCodeValue() == TR::treetop) || (tt->getNode()->getOpCodeValue() == TR::ResolveCHK)) &&
tt->getNode()->getFirstChild() == node)
break;
}

if (tt != exitTree) // found the call tree
{
// check if the next tree top is a [i]lstore with this value
//
TR::Node * nextNode = tt->getNextRealTreeTop()->getNode();
TR::ILOpCodes opCode = nextNode->getOpCodeValue();
if ((opCode == TR::lstorei || opCode == TR::lstore) &&
nextNode->getOpCode().hasSymbolReference() &&
!nextNode->mightHaveVolatileSymbolReference())
{
TR::Node *valueChild;
TR::Node * addressChild;
if (opCode == TR::lstorei)
{
valueChild = nextNode->getSecondChild();
addressChild = nextNode->getFirstChild();
}
else
{
valueChild = nextNode->getFirstChild();
addressChild = 0;
}

if (node == valueChild &&
performTransformation(comp(), "%sFolded long store of currentTimeMillis to use address of destination as argument on node [%p]\n", optDetailString(), node))
{
node->setNumChildren(1);
TR::Node * storeAddressNode;
if (addressChild)
{
if (TR::Compiler->target.is64Bit())
{
TR::Node* offsetNode = TR::Node::create(node, TR::lconst);
offsetNode->setLongInt((int64_t)nextNode->getSymbolReference()->getOffset());
storeAddressNode = TR::Node::create(TR::aladd, 2, addressChild, offsetNode);
}
else
{
storeAddressNode = TR::Node::create(TR::aiadd, 2, addressChild,
TR::Node::create(node, TR::iconst, 0, (int32_t)nextNode->getSymbolReference()->getOffset()));
}
}
else
{
storeAddressNode = TR::Node::create(node, TR::loadaddr);
storeAddressNode->setSymbolReference(nextNode->getSymbolReference());
}

node->setAndIncChild(0, storeAddressNode);
nextNode->setNOPLongStore(true);
//_invalidateUseDefInfo = true;
_alteredBlock = true;
}
}
}
return node;
}

TR::Node *
J9::Simplifier::simplifyaCallMethods(TR::Node * node, TR::Block * block)
{
Expand Down
11 changes: 1 addition & 10 deletions runtime/compiler/optimizer/J9Simplifier.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -86,15 +86,6 @@ class Simplifier : public OMR::Simplifier
* \return Node that points to the transformed subtree
*/
TR::Node *convertNanoTime(TR::Node * node, TR::Block * block);

/*! \brief Fold long store of currentTimeMillis to use address of destination as an argument
*
* \param node The "System.currentTimeMillis()" lcall node
* \param block The corresponding basic block
*
* \return Node that points to the transformed subtree
*/
TR::Node *foldLongStoreOfCurrentTimeMillis(TR::Node * node, TR::Block * block);
};

}
Expand Down
8 changes: 0 additions & 8 deletions runtime/compiler/runtime/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,10 +1179,8 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP)
SET(TR_AMD64doAESENCDecrypt, (void *)_doAESENCDecrypt, TR_Helper);
#endif
#if defined(LINUX)
SET(TR_AMD64getTimeOfDay, (void *)gettimeofday, TR_System);
SET(TR_AMD64clockGetTime, (void *)clock_gettime, TR_System);
#elif defined(WINDOWS)
SET(TR_AMD64GetSystemTimeAsFileTime, (void *)GetSystemTimeAsFileTime, TR_System);
SET(TR_AMD64QueryPerformanceCounter, (void *)QueryPerformanceCounter, TR_System);
SET(TR_AMD64GetTickCount, (void *)GetTickCount, TR_System);
#endif
Expand Down Expand Up @@ -1279,12 +1277,6 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP)
SET(TR_IA32JitMethodMonitorExitPreservingReservation, (void *)jitMethodMonitorExitPreservingReservation, TR_CHelper);
SET(TR_IA32JitMethodMonitorExitReservedPrimitive, (void *)jitMethodMonitorExitReservedPrimitive, TR_CHelper);
SET(TR_IA32JitMethodMonitorExitReserved, (void *)jitMethodMonitorExitReserved, TR_CHelper);
#if defined(LINUX)
SET(TR_IA32getTimeOfDay, (void *)gettimeofday, TR_System);
#elif defined(WINDOWS)
SET(TR_IA32GetSystemTimeAsFileTime, (void *)GetSystemTimeAsFileTime, TR_System);
#endif


#endif
#elif defined(TR_HOST_POWER)
Expand Down
16 changes: 0 additions & 16 deletions runtime/compiler/x/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,6 @@ J9::X86::CodeGenerator::CodeGenerator() :
}
}

// We do not support fast CTM in mimic interpreter stack mode because it causes problems when
// a stack slot is shared between a reference and a long value. The specific case is that there is
// a reference value in a stack slot first and then there is supposed to be the long value that is
// the result from a fast CTM call. At the point where we store the CTM value into the stack slot as a long
// code we have in CodeGenerator.cpp for mimicing interpreter stack and getting GC maps right should
// reset the stack map bit for the reference value that used to be there so that we do not crash during GC.
// However if we do fast CTM this store is not present in the IL, instead we get the address of the long slot
// passed to the fast CTM call; while the fast CTM helper does effectively do a store this store is not visible in the
// IL and so the stack map bit does not get reset leading to a crash in the GC later on, when it sees a long value
// in what looks like a collected slot (but ought not to be at that program point).
//
if (!comp->getOption(TR_MimicInterpreterFrameShape))
{
cg->setSupportsFastCTM();
}

/*
* "Statically" initialize the FE-specific tree evaluator functions.
* This code only needs to execute once per JIT lifetime.
Expand Down
Loading

0 comments on commit c76c527

Please sign in to comment.