Skip to content

Commit

Permalink
Merge pull request #16556 from nbhuiyan/16161-fix
Browse files Browse the repository at this point in the history
Override isCompilable for TR_ResolveRelocatableJ9Method
  • Loading branch information
0xdaryl committed Jan 20, 2023
2 parents dd11c3c + 4b76721 commit df81cf8
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 29 deletions.
4 changes: 2 additions & 2 deletions runtime/compiler/control/CompilationRuntime.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corp. and others
* Copyright (c) 2000, 2023 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 @@ -1082,6 +1082,7 @@ class CompilationInfo
bool importantMethodForStartup(J9Method *method);
bool shouldDowngradeCompReq(TR_MethodToBeCompiled *entry);

bool isMethodIneligibleForAot(J9Method *method);

int32_t computeDynamicDumbInlinerBytecodeSizeCutoff(TR::Options *options);
TR_YesNoMaybe shouldActivateNewCompThread();
Expand Down Expand Up @@ -1533,4 +1534,3 @@ class CompilationInfo


#endif // COMPILATIONRUNTIME_HPP

46 changes: 23 additions & 23 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,28 @@ bool TR::CompilationInfo::importantMethodForStartup(J9Method *method)
return false;
}

bool
TR::CompilationInfo::isMethodIneligibleForAot(J9Method *method)
{
const J9ROMMethod *romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
const J9ROMClass *romClass = J9_CLASS_FROM_METHOD(method)->romClass;
J9UTF8 *className = J9ROMCLASS_CLASSNAME(romClass);

// Don't AOT-compile anything in j/l/i for now
if (strncmp(utf8Data(className), "java/lang/invoke/", sizeof("java/lang/invoke/") - 1) == 0)
return true;

if (J9UTF8_LENGTH(className) == 36 &&
0 == memcmp(utf8Data(className), "com/ibm/rmi/io/FastPathForCollocated", 36))
{
J9UTF8 *utf8 = J9ROMMETHOD_NAME(romMethod);
if (J9UTF8_LENGTH(utf8) == 21 &&
0 == memcmp(J9UTF8_DATA(utf8), "isVMDeepCopySupported", 21))
return true;
}
return false;
}


bool TR::CompilationInfo::shouldDowngradeCompReq(TR_MethodToBeCompiled *entry)
{
Expand Down Expand Up @@ -7147,28 +7169,6 @@ TR::CompilationInfoPerThreadBase::findAotBodyInSCC(J9VMThread *vmThread, const J
return NULL;
}

bool
TR::CompilationInfoPerThreadBase::isMethodIneligibleForAot(J9Method *method)
{
const J9ROMMethod *romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
const J9ROMClass *romClass = J9_CLASS_FROM_METHOD(method)->romClass;
J9UTF8 *className = J9ROMCLASS_CLASSNAME(romClass);

// Don't AOT-compile anything in j/l/i for now
if (strncmp(utf8Data(className), "java/lang/invoke/", sizeof("java/lang/invoke/") - 1) == 0)
return true;

if (J9UTF8_LENGTH(className) == 36 &&
0 == memcmp(utf8Data(className), "com/ibm/rmi/io/FastPathForCollocated", 36))
{
J9UTF8 *utf8 = J9ROMMETHOD_NAME(romMethod);
if (J9UTF8_LENGTH(utf8) == 21 &&
0 == memcmp(J9UTF8_DATA(utf8), "isVMDeepCopySupported", 21))
return true;
}
return false;
}

#if defined(J9VM_OPT_JITSERVER)

bool
Expand Down Expand Up @@ -7585,7 +7585,7 @@ TR::CompilationInfoPerThreadBase::preCompilationTasks(J9VMThread * vmThread,
// Eligibility checks
&& !entry->_doNotUseAotCodeFromSharedCache
&& fe->sharedCache()->isROMClassInSharedCache(J9_CLASS_FROM_METHOD(method)->romClass)
&& !isMethodIneligibleForAot(method)
&& !_compInfo.isMethodIneligibleForAot(method)
&& (!TR::Options::getAOTCmdLineOptions()->getOption(TR_AOTCompileOnlyFromBootstrap)
|| fe->isClassLibraryMethod((TR_OpaqueMethodBlock *)method), true)

Expand Down
3 changes: 1 addition & 2 deletions runtime/compiler/control/CompilationThread.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corp. and others
* Copyright (c) 2000, 2023 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 @@ -179,7 +179,6 @@ class CompilationInfoPerThreadBase
bool eligibleForRelocatableCompile,
TR_RelocationRuntime *reloRuntime);
const void* findAotBodyInSCC(J9VMThread *vmThread, const J9ROMMethod *romMethod);
bool isMethodIneligibleForAot(J9Method *method);

#if defined(J9VM_OPT_SHARED_CLASSES) && defined(J9VM_INTERP_AOT_RUNTIME_SUPPORT)
TR_MethodMetaData *installAotCachedMethod(
Expand Down
13 changes: 12 additions & 1 deletion runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corp. and others
* Copyright (c) 2000, 2023 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 @@ -1129,6 +1129,17 @@ TR_ResolvedRelocatableJ9Method::isInterpretedForHeuristics()
return TR_ResolvedJ9Method::isInterpreted();
}

bool
TR_ResolvedRelocatableJ9Method::isCompilable(TR_Memory * trMemory)
{
TR::CompilationInfo *compInfo = TR::CompilationInfo::get(fej9()->_jitConfig);

if (compInfo->isMethodIneligibleForAot(ramMethod()))
return false;

return TR_ResolvedJ9Method::isCompilable(trMemory);
}

void *
TR_ResolvedRelocatableJ9Method::startAddressForJittedMethod()
{
Expand Down
9 changes: 8 additions & 1 deletion runtime/compiler/env/j9method.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corp. and others
* Copyright (c) 2000, 2023 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 @@ -577,6 +577,13 @@ class TR_ResolvedRelocatableJ9Method : public TR_ResolvedJ9Method
virtual bool isObjectConstructor();
virtual bool isNonEmptyObjectConstructor();

/**
* @brief Check if method is a compilable method
*
* @param[in] TR_Memory *
*/
virtual bool isCompilable(TR_Memory *);

virtual void * startAddressForJittedMethod();
virtual void * startAddressForJNIMethod( TR::Compilation *);
virtual void * startAddressForJITInternalNativeMethod();
Expand Down

0 comments on commit df81cf8

Please sign in to comment.