From 36ef459d957499a759f64f9788f8fa6864ed28aa Mon Sep 17 00:00:00 2001 From: Nazim Uddin Bhuiyan Date: Fri, 23 Nov 2018 14:29:40 -0500 Subject: [PATCH] Use NASM_ASSEMBLER macro to decide the version of JIT helper names x86 platforms that use the NASM assembly files should not use leading underscores in the JIT helper names. NASM_ASSEMBLER is defined in asmprotos.h for platforms making use of the NASM assembly files, and simplifies the preprocessor checks done to use the correct version of the helper names. Signed-off-by: Nazim Uddin Bhuiyan --- .../compiler/control/CompilationThread.cpp | 4 +-- runtime/compiler/env/VMJ9.cpp | 4 +-- runtime/compiler/runtime/CRuntimeImpl.cpp | 3 +- runtime/compiler/runtime/JitRuntime.cpp | 26 +++++++------- runtime/compiler/runtime/Runtime.cpp | 36 ++++++++++--------- runtime/compiler/runtime/asmprotos.h | 13 +++++++ 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index f427fb18d70..f245cca0c34 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -4708,7 +4708,7 @@ bool TR::CompilationInfo::isQueuedForCompilation(J9Method * method, void *oldSta return linkageInfo->isBeingCompiled(); } -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(initialInvokeExactThunkGlue); #else JIT_HELPER(_initialInvokeExactThunkGlue); @@ -4742,7 +4742,7 @@ void *TR::CompilationInfo::startPCIfAlreadyCompiled(J9VMThread * vmThread, TR::I initialInvokeExactThunkGlueAddress = (void*)TOC_UNWRAP_ADDRESS(_initialInvokeExactThunkGlue); #elif defined(TR_HOST_POWER) && (defined(TR_HOST_64BIT) || defined(AIXPPC)) && !defined(__LITTLE_ENDIAN__) initialInvokeExactThunkGlueAddress = (*(void **)_initialInvokeExactThunkGlue); -#elif defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#elif defined(NASM_ASSEMBLER) initialInvokeExactThunkGlueAddress = (void*)initialInvokeExactThunkGlue; #else initialInvokeExactThunkGlueAddress = (void*)_initialInvokeExactThunkGlue; diff --git a/runtime/compiler/env/VMJ9.cpp b/runtime/compiler/env/VMJ9.cpp index b87a8009858..3930c788138 100644 --- a/runtime/compiler/env/VMJ9.cpp +++ b/runtime/compiler/env/VMJ9.cpp @@ -9530,7 +9530,7 @@ TR_J9VMBase::classNameChars(TR::Compilation *comp, TR::SymbolReference * symRef, // Native method bodies // -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(initialInvokeExactThunkGlue); #else JIT_HELPER(_initialInvokeExactThunkGlue); @@ -9543,7 +9543,7 @@ JNIEXPORT jlong JNICALL Java_java_lang_invoke_ThunkTuple_initialInvokeExactThunk return (jlong)TOC_UNWRAP_ADDRESS(_initialInvokeExactThunkGlue); #elif defined(TR_HOST_POWER) && (defined(TR_HOST_64BIT) || defined(AIXPPC)) && !defined(__LITTLE_ENDIAN__) return (jlong)(*(void **)_initialInvokeExactThunkGlue); -#elif defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#elif defined(NASM_ASSEMBLER) return (jlong)initialInvokeExactThunkGlue; #else return (jlong)_initialInvokeExactThunkGlue; diff --git a/runtime/compiler/runtime/CRuntimeImpl.cpp b/runtime/compiler/runtime/CRuntimeImpl.cpp index a5f06516239..75b69bb5228 100644 --- a/runtime/compiler/runtime/CRuntimeImpl.cpp +++ b/runtime/compiler/runtime/CRuntimeImpl.cpp @@ -38,10 +38,11 @@ #include "env/jittypes.h" #include "runtime/MethodMetaData.h" #include "env/VMJ9.h" +#include "runtime/asmprotos.h" // To transfer control to VM during OSR extern "C" { -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) void prepareForOSR(uintptrj_t vmThreadArg, int32_t currentInlinedSiteIndex, int32_t slotData) #else void _prepareForOSR(uintptrj_t vmThreadArg, int32_t currentInlinedSiteIndex, int32_t slotData) diff --git a/runtime/compiler/runtime/JitRuntime.cpp b/runtime/compiler/runtime/JitRuntime.cpp index ee929287c28..3f02c3e4073 100644 --- a/runtime/compiler/runtime/JitRuntime.cpp +++ b/runtime/compiler/runtime/JitRuntime.cpp @@ -1106,26 +1106,26 @@ extern "C" void _patchJNICallSite(J9Method *method, uint8_t *pc, uint8_t *newAdd } #endif -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(prepareForOSR); #else JIT_HELPER(_prepareForOSR); -#endif /* OSX */ +#endif #ifdef TR_HOST_X86 -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(countingRecompileMethod); JIT_HELPER(samplingRecompileMethod); JIT_HELPER(countingPatchCallSite); JIT_HELPER(samplingPatchCallSite); JIT_HELPER(induceRecompilation); -#else +#else /* NASM_ASSEMBLER */ JIT_HELPER(_countingRecompileMethod); JIT_HELPER(_samplingRecompileMethod); JIT_HELPER(_countingPatchCallSite); JIT_HELPER(_samplingPatchCallSite); JIT_HELPER(_induceRecompilation); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ #elif defined(TR_HOST_POWER) @@ -1209,28 +1209,28 @@ void initializeJitRuntimeHelperTable(char isSMP) #if defined(J9ZOS390) SET_CONST(TR_prepareForOSR, (void *)_prepareForOSR); -#elif defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#elif defined(NASM_ASSEMBLER) SET(TR_prepareForOSR, (void *)prepareForOSR, TR_Helper); #else SET(TR_prepareForOSR, (void *)_prepareForOSR, TR_Helper); -#endif +#endif /* NASM_ASSEMBLER */ #ifdef TR_HOST_X86 #if defined(TR_HOST_64BIT) -#if defined(OSX) || defined(LINUX) +#if defined(NASM_ASSEMBLER) SET(TR_AMD64samplingRecompileMethod, (void *)samplingRecompileMethod, TR_Helper); SET(TR_AMD64countingRecompileMethod, (void *)countingRecompileMethod, TR_Helper); SET(TR_AMD64samplingPatchCallSite, (void *)samplingPatchCallSite, TR_Helper); SET(TR_AMD64countingPatchCallSite, (void *)countingPatchCallSite, TR_Helper); SET(TR_AMD64induceRecompilation, (void *)induceRecompilation, TR_Helper); -#else /* OSX */ +#else /* NASM_ASSEMBLER */ SET(TR_AMD64samplingRecompileMethod, (void *)_samplingRecompileMethod, TR_Helper); SET(TR_AMD64countingRecompileMethod, (void *)_countingRecompileMethod, TR_Helper); SET(TR_AMD64samplingPatchCallSite, (void *)_samplingPatchCallSite, TR_Helper); SET(TR_AMD64countingPatchCallSite, (void *)_countingPatchCallSite, TR_Helper); SET(TR_AMD64induceRecompilation, (void *)_induceRecompilation, TR_Helper); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ #else /* TR_HOST_64BIT */ SET(TR_IA32samplingRecompileMethod, (void *)_samplingRecompileMethod, TR_Helper); SET(TR_IA32countingRecompileMethod, (void *)_countingRecompileMethod, TR_Helper); @@ -1611,7 +1611,7 @@ uint8_t *compileMethodHandleThunk(j9object_t methodHandle, j9object_t arg, J9VMT return startPC; } -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(initialInvokeExactThunkGlue); #else JIT_HELPER(_initialInvokeExactThunkGlue); @@ -1683,7 +1683,7 @@ void *initialInvokeExactThunk(j9object_t methodHandle, J9VMThread *vmThread) else { uintptrj_t fieldOffset = fej9->getInstanceFieldOffset(fej9->getObjectClass(thunkTuple), "invokeExactThunk", "J"); -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) bool success = fej9->compareAndSwapInt64Field(thunkTuple, "invokeExactThunk", (uint64_t)(uintptrj_t)initialInvokeExactThunkGlue, (uint64_t)(uintptrj_t)addressToDispatch); if (details) @@ -1696,7 +1696,7 @@ void *initialInvokeExactThunk(j9object_t methodHandle, J9VMThread *vmThread) if (details) TR_VerboseLog::writeLineLocked(TR_Vlog_MHD, "%p %s updating ThunkTuple %p field %+d from %p to %p", vmThread, success? "Succeeded" : "Failed", thunkTuple, (int)fieldOffset, _initialInvokeExactThunkGlue, addressToDispatch); -#endif +#endif /* NASM_ASSEMBLER */ } return addressToDispatch; } diff --git a/runtime/compiler/runtime/Runtime.cpp b/runtime/compiler/runtime/Runtime.cpp index f1ec2a64c2a..0a070630f04 100644 --- a/runtime/compiler/runtime/Runtime.cpp +++ b/runtime/compiler/runtime/Runtime.cpp @@ -244,7 +244,7 @@ JIT_HELPER(callGPU); // -------------------------------------------------------------------------------- // X86 COMMON // -------------------------------------------------------------------------------- -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(doubleToLong); JIT_HELPER(doubleToInt); JIT_HELPER(floatToLong); @@ -254,7 +254,7 @@ JIT_HELPER(_doubleToLong); JIT_HELPER(_doubleToInt); JIT_HELPER(_floatToLong); JIT_HELPER(_floatToInt); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ JIT_HELPER(interpreterUnresolvedClassGlue); JIT_HELPER(interpreterUnresolvedClassFromStaticFieldGlue); @@ -269,7 +269,7 @@ JIT_HELPER(interpreterUnresolvedFieldGlue); JIT_HELPER(interpreterUnresolvedFieldSetterGlue); JIT_HELPER(interpreterUnresolvedConstantDynamicGlue); -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(SMPinterpreterUnresolvedStaticGlue); JIT_HELPER(SMPinterpreterUnresolvedSpecialGlue); JIT_HELPER(SMPinterpreterUnresolvedDirectVirtualGlue); @@ -299,7 +299,7 @@ JIT_HELPER(_SMPinterpreterUnresolvedStaticDataGlue); JIT_HELPER(_SMPinterpreterUnresolvedStaticStoreDataGlue); JIT_HELPER(_SMPinterpreterUnresolvedInstanceDataGlue); JIT_HELPER(_SMPinterpreterUnresolvedInstanceStoreDataGlue); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ JIT_HELPER(resolveIPicClass); JIT_HELPER(populateIPicSlotClass); @@ -338,7 +338,7 @@ JIT_HELPER(newPrefetchTLH); JIT_HELPER(outlinedNewObject); JIT_HELPER(outlinedNewArray); -#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined(NASM_ASSEMBLER) JIT_HELPER(arrayTranslateTRTO); JIT_HELPER(arrayTranslateTROTNoBreak); JIT_HELPER(arrayTranslateTROT); @@ -346,20 +346,22 @@ JIT_HELPER(arrayTranslateTROT); JIT_HELPER(_arrayTranslateTRTO); JIT_HELPER(_arrayTranslateTROTNoBreak); JIT_HELPER(_arrayTranslateTROT); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ // -------------------------------------------------------------------------------- // AMD64 // -------------------------------------------------------------------------------- #ifdef TR_HOST_64BIT -#if defined(OSX) || defined(LINUX) + +#if defined(NASM_ASSEMBLER) JIT_HELPER(SSEdoubleRemainder); JIT_HELPER(SSEfloatRemainder); #else JIT_HELPER(_SSEdoubleRemainder); JIT_HELPER(_SSEfloatRemainder); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ + JIT_HELPER(icallVMprJavaSendVirtual0); JIT_HELPER(icallVMprJavaSendVirtual1); JIT_HELPER(icallVMprJavaSendVirtualJ); @@ -367,7 +369,7 @@ JIT_HELPER(icallVMprJavaSendVirtualL); JIT_HELPER(icallVMprJavaSendVirtualF); JIT_HELPER(icallVMprJavaSendVirtualD); -#if defined(OSX) || defined(LINUX) +#if defined(NASM_ASSEMBLER) JIT_HELPER(compressString); JIT_HELPER(compressStringNoCheck); JIT_HELPER(compressStringJ); @@ -383,16 +385,16 @@ JIT_HELPER(_compressStringNoCheckJ); JIT_HELPER(_andORString); JIT_HELPER(_encodeUTF16Big); JIT_HELPER(_encodeUTF16Little); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ #ifdef J9VM_OPT_JAVA_CRYPTO_ACCELERATION -#if defined (OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#if defined (NASM_ASSEMBLER) JIT_HELPER(doAESENCEncrypt); JIT_HELPER(doAESENCDecrypt); #else JIT_HELPER(_doAESENCEncrypt); JIT_HELPER(_doAESENCDecrypt); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ #endif /* J9VM_OPT_JAVA_CRYPTO_ACCELERATION */ JIT_HELPER(interpreterEAXStaticGlue); @@ -1222,13 +1224,13 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_X86interpreterSyncDoubleStaticGlue, (void *)interpreterSyncXMM0DStaticGlue, TR_Helper); SET(TR_X86interpreterAddressStaticGlue, (void *)interpreterRAXStaticGlue, TR_Helper); SET(TR_X86interpreterSyncAddressStaticGlue, (void *)interpreterSyncRAXStaticGlue, TR_Helper); -#if defined(OSX) || defined(LINUX) +#if defined(NASM_ASSEMBLER) SET(TR_AMD64floatRemainder, (void *)SSEfloatRemainder, TR_Helper); SET(TR_AMD64doubleRemainder, (void *)SSEdoubleRemainder, TR_Helper); #else SET(TR_AMD64floatRemainder, (void *)_SSEfloatRemainder, TR_Helper); SET(TR_AMD64doubleRemainder, (void *)_SSEdoubleRemainder, TR_Helper); -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ SET(TR_AMD64icallVMprJavaSendVirtual0, (void *)icallVMprJavaSendVirtual0, TR_Helper); SET(TR_AMD64icallVMprJavaSendVirtual1, (void *)icallVMprJavaSendVirtual1, TR_Helper); @@ -1238,7 +1240,7 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_AMD64icallVMprJavaSendVirtualD, (void *)icallVMprJavaSendVirtualD, TR_Helper); SET(TR_AMD64jitCollapseJNIReferenceFrame, (void *)jitCollapseJNIReferenceFrame, TR_Helper); -#if defined(OSX) || defined(LINUX) +#if defined(NASM_ASSEMBLER) SET(TR_AMD64compressString, (void *)compressString, TR_Helper); SET(TR_AMD64compressStringNoCheck, (void *)compressStringNoCheck, TR_Helper); SET(TR_AMD64compressStringJ, (void *)compressStringJ, TR_Helper); @@ -1253,7 +1255,7 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_AMD64doAESENCEncrypt, (void *)doAESENCEncrypt, TR_Helper); SET(TR_AMD64doAESENCDecrypt, (void *)doAESENCDecrypt, TR_Helper); #endif /* J9VM_OPT_JAVA_CRYPTO_ACCELERATION */ -#else /* OSX */ +#else /* NASM_ASSEMBLER */ SET(TR_AMD64compressString, (void *)_compressString, TR_Helper); SET(TR_AMD64compressStringNoCheck, (void *)_compressStringNoCheck, TR_Helper); SET(TR_AMD64compressStringJ, (void *)_compressStringJ, TR_Helper); @@ -1268,7 +1270,7 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_AMD64doAESENCEncrypt, (void *)_doAESENCEncrypt, TR_Helper); SET(TR_AMD64doAESENCDecrypt, (void *)_doAESENCDecrypt, TR_Helper); #endif /* J9VM_OPT_JAVA_CRYPTO_ACCELERATION */ -#endif /* OSX */ +#endif /* NASM_ASSEMBLER */ #if defined(LINUX) SET(TR_AMD64clockGetTime, (void *)clock_gettime, TR_System); #endif diff --git a/runtime/compiler/runtime/asmprotos.h b/runtime/compiler/runtime/asmprotos.h index 68a9914f307..445720cbc61 100644 --- a/runtime/compiler/runtime/asmprotos.h +++ b/runtime/compiler/runtime/asmprotos.h @@ -55,6 +55,19 @@ extern "C" { #define JIT_HELPER(x) extern "C" void x() #endif +/** + * Many X86 helpers have been named with leading underscores. + * With the move to using the NASM Assembler across X86, a more consistent + * naming is being adopted, where there would be no leading + * underscores in any of the X86 helper names for making a single + * version of the NASM files cross-compatible across X86. NASM_ASSEMBLER + * is set for OS variants that currently use NASM and is used to + * decide the version of helper names to use. + */ +#if defined(OSX) || (defined(LINUX) && defined(TR_HOST_64BIT)) +#define NASM_ASSEMBLER +#endif + /* #include "VM.hpp" */ JIT_HELPER(jitAcquireVMAccess); // asm calling-convention helper