From 2699193b76475182e752f45b7059fe332ca92cdf Mon Sep 17 00:00:00 2001 From: Rahil Shah Date: Thu, 6 Sep 2018 13:03:19 -0400 Subject: [PATCH] IBM Z Codegen changes to support Condy in jdk11 This commit contains changes to suppport Constant Dynamic in JIT Compiled code on Z platform. Signed-off-by: Rahil Shah --- runtime/compiler/runtime/Runtime.cpp | 3 ++ .../z/codegen/J9UnresolvedDataSnippet.cpp | 10 ++++- runtime/compiler/z/runtime/PicBuilder.m4 | 42 ++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/runtime/compiler/runtime/Runtime.cpp b/runtime/compiler/runtime/Runtime.cpp index 1997a8a5bb0..7c689209fed 100644 --- a/runtime/compiler/runtime/Runtime.cpp +++ b/runtime/compiler/runtime/Runtime.cpp @@ -619,6 +619,7 @@ JIT_HELPER(_interpreterFloatStaticGlue); JIT_HELPER(_interpreterSyncFloatStaticGlue); JIT_HELPER(_interpreterDoubleStaticGlue); JIT_HELPER(_interpreterSyncDoubleStaticGlue); +JIT_HELPER(_jitResolveConstantDynamic); JIT_HELPER(_nativeStaticHelper); JIT_HELPER(jitLookupInterfaceMethod); JIT_HELPER(jitMethodIsNative); @@ -1547,6 +1548,7 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_S390interfaceCallHelper, (void *) _interfaceCallHelper, TR_Helper); SET(TR_S390interfaceCallHelperSingleDynamicSlot, (void *) _interfaceCallHelperSingleDynamicSlot, TR_Helper); SET(TR_S390interfaceCallHelperMultiSlots, (void *) _interfaceCallHelperMultiSlots, TR_Helper); + SET(TR_S390jitResolveConstantDynamicGlue, (void *) _jitResolveConstantDynamic, TR_Helper); SET(TR_S390icallVMprJavaSendVirtual0, (void *) icallVMprJavaSendVirtual0, TR_Helper); SET(TR_S390icallVMprJavaSendVirtual1, (void *) icallVMprJavaSendVirtual1, TR_Helper); SET(TR_S390icallVMprJavaSendVirtualJ, (void *) icallVMprJavaSendVirtualJ, TR_Helper); @@ -1557,6 +1559,7 @@ void initializeCodeRuntimeHelperTable(J9JITConfig *jitConfig, char isSMP) SET(TR_S390jitMethodIsSync, (void *) jitMethodIsSync, TR_Helper); SET(TR_S390jitResolveClass, (void *) jitResolveClass, TR_Helper); SET(TR_S390jitResolveClassFromStaticField, (void *) jitResolveClassFromStaticField, TR_Helper); + SET(TR_S390jitResolveConstantDynamic, (void *) jitResolveConstantDynamic, TR_Helper); SET(TR_S390jitResolveField, (void *) jitResolveField, TR_Helper); SET(TR_S390jitResolveFieldSetter, (void *) jitResolveFieldSetter, TR_Helper); SET(TR_S390jitResolveInterfaceMethod, (void *) jitResolveInterfaceMethod, TR_Helper); diff --git a/runtime/compiler/z/codegen/J9UnresolvedDataSnippet.cpp b/runtime/compiler/z/codegen/J9UnresolvedDataSnippet.cpp index a28541abd9d..1ce7e75d4d4 100644 --- a/runtime/compiler/z/codegen/J9UnresolvedDataSnippet.cpp +++ b/runtime/compiler/z/codegen/J9UnresolvedDataSnippet.cpp @@ -216,6 +216,10 @@ J9::Z::UnresolvedDataSnippet::emitSnippetBody() { glueRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_interpreterUnresolvedMethodTypeTableEntryGlue, false, false, false); } + else if (getDataSymbol()->isConstantDynamic()) + { + glueRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_S390jitResolveConstantDynamicGlue, false, false, false); + } else // must be static data { if (resolveForStore()) @@ -503,7 +507,10 @@ TR_Debug::print(TR::FILE *pOutFile, TR::UnresolvedDataSnippet * snippet) { glueRef = _cg->getSymRef(TR_interpreterUnresolvedMethodTypeTableEntryGlue); } - + else if (snippet->getDataSymbol()->isConstantDynamic()) + { + glueRef = _cg->getSymRef(TR_S390jitResolveConstantDynamicGlue); + } else // the data symbol is static { if (snippet->resolveForStore()) @@ -516,6 +523,7 @@ TR_Debug::print(TR::FILE *pOutFile, TR::UnresolvedDataSnippet * snippet) } } + printPrefix(pOutFile, NULL, bufferPos, sizeof(intptrj_t)); trfprintf(pOutFile, "DC \t%s", getName(glueRef)); bufferPos += sizeof(intptrj_t); diff --git a/runtime/compiler/z/runtime/PicBuilder.m4 b/runtime/compiler/z/runtime/PicBuilder.m4 index dbdb2fccab6..721e47e86e9 100644 --- a/runtime/compiler/z/runtime/PicBuilder.m4 +++ b/runtime/compiler/z/runtime/PicBuilder.m4 @@ -4,7 +4,7 @@ define(`ZZ',`**') define(`ZZ',`##') ')dnl -ZZ Copyright (c) 2000, 2017 IBM Corp. and others +ZZ Copyright (c) 2000, 2018 IBM Corp. and others ZZ ZZ This program and the accompanying materials are made ZZ available under the terms of the Eclipse Public License 2.0 @@ -1702,6 +1702,46 @@ LABEL(L_virtualDispatchExit) END_FUNC(_virtualUnresolvedHelper,virUH,7) +ZZ ================================================ +ZZ PICBuilderRoutine : _jitResolveConstantDynamic +ZZ ================================================ + START_FUNC(_jitResolveConstantDynamic,jRCD) + +LABEL(_jitResolveConstantDynamicBody) +ZZ Loading arguments for JIT helper +ZZ R1 - Address of Constant Pool +ZZ R2 - CPIndex +ZZ R3 - JIT'd code Return Address + L_GPR r1,eq_cp_inDataSnippet(,r14) + LGF_GPR r2,eq_cpindex_inDataSnippet(,r14) + L_GPR r3,eq_codeRA_inDataSnippet(,r14) + +ZZ Following snippet prepares JIT helper call sequence +ZZ which needs r14 to be free which holds address of +ZZ Snippet from where this is called. +ZZ As jitResolveConstantDynamic is called via +ZZ SLOW_PATH_ONLY_HELPER glue, it is guranteed that +ZZ all the registers (volatile and non-volatile) are preserved. +ZZ This allows us to use R0 to preserve R14 +LOAD_ADDR_FROM_TOC(rEP,TR_S390jitResolveConstantDynamic) + LR_GPR r0,r14 + BASR r14,rEP + LR_GPR r14,r0 + +ZZ Load the address of literal pool +ZZ Store the return value of helper call which +ZZ is address of resolved constant dynamic +ZZ into the Literal Pool + L_GPR r1,eq_literalPoolAddr_inDataSnippet(r14) + ST_GPR r2,0(,r1) + + L_GPR r14,eq_codeRA_inDataSnippet(,r14) # Get mainline RA + +ZZ Branch instruction in mainline will be patched here with NOP + LHI r1,HEX(04) + STCY r1,-5(r14) + BR r14 # Return + END_FUNC(_jitResolveConstantDynamic,jRCD,6) ZZ =================================================================== ZZ PICBuider routine - _interfaceCallHelper