Skip to content

Commit

Permalink
Use NASM_ASSEMBLER macro to decide the version of JIT helper names
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nbhuiyan committed Nov 23, 2018
1 parent 313b106 commit 36ef459
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 35 deletions.
4 changes: 2 additions & 2 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/VMJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion runtime/compiler/runtime/CRuntimeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions runtime/compiler/runtime/JitRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down
36 changes: 19 additions & 17 deletions runtime/compiler/runtime/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -338,36 +338,38 @@ 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);
#else
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);
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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions runtime/compiler/runtime/asmprotos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 36ef459

Please sign in to comment.