diff --git a/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp b/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp index 3e9d74e25eb..01e199cae0f 100644 --- a/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp +++ b/runtime/compiler/z/codegen/J9AheadOfTimeCompile.cpp @@ -676,6 +676,32 @@ uint8_t *J9::Z::AheadOfTimeCompile::initializeAOTRelocationHeader(TR::IteratedEx #endif } break; + + case TR_DebugCounter: + { + TR::DebugCounterBase *counter = (TR::DebugCounterBase *) relocation->getTargetAddress(); + if (!counter || !counter->getReloData() || !counter->getName()) + comp()->failCompilation("Failed to generate debug counter relo data"); + + TR::DebugCounterReloData *counterReloData = counter->getReloData(); + + uintptrj_t offset = (uintptrj_t)fej9->sharedCache()->rememberDebugCounterName(counter->getName()); + + *(uintptrj_t *)cursor = (uintptrj_t)counterReloData->_callerIndex; + cursor += SIZEPOINTER; + *(uintptrj_t *)cursor = (uintptrj_t)counterReloData->_bytecodeIndex; + cursor += SIZEPOINTER; + *(uintptrj_t *)cursor = offset; + cursor += SIZEPOINTER; + *(uintptrj_t *)cursor = (uintptrj_t)counterReloData->_delta; + cursor += SIZEPOINTER; + *(uintptrj_t *)cursor = (uintptrj_t)counterReloData->_fidelity; + cursor += SIZEPOINTER; + *(uintptrj_t *)cursor = (uintptrj_t)counterReloData->_staticDelta; + cursor += SIZEPOINTER; + } + break; + } return cursor; } @@ -986,6 +1012,7 @@ uint32_t J9::Z::AheadOfTimeCompile::_relocationTargetTypeToHeaderSizeMap[TR_NumE 0, // TR_NativeMethodAbsolute = 56, 0, // TR_NativeMethodRelative = 57, 32, // TR_ArbitraryClassAddress = 58, + 56, // TR_DebugCounter = 59 }; #else @@ -1051,6 +1078,7 @@ uint32_t J9::Z::AheadOfTimeCompile::_relocationTargetTypeToHeaderSizeMap[TR_NumE 0, // TR_NativeMethodAbsolute = 56, 0, // TR_NativeMethodRelative = 57, 16, // TR_ArbitraryClassAddress = 58, + 28 // TR_DebugCounter = 59 }; #endif diff --git a/runtime/compiler/z/codegen/S390AOTRelocation.cpp b/runtime/compiler/z/codegen/S390AOTRelocation.cpp index a6535aaa7c5..50a0ffd02cf 100644 --- a/runtime/compiler/z/codegen/S390AOTRelocation.cpp +++ b/runtime/compiler/z/codegen/S390AOTRelocation.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 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 @@ -27,6 +27,7 @@ #include "env/jittypes.h" #include "il/Node.hpp" #include "il/Node_inlines.hpp" +#include "il/symbol/StaticSymbol.hpp" #include "z/codegen/S390Instruction.hpp" #include "env/VMJ9.h" @@ -124,6 +125,18 @@ void TR::S390EncodingRelocation::addRelocation(TR::CodeGenerator *cg, uint8_t *c file, line, node); } } + else if (_reloType==TR_DebugCounter) + { + TR::DebugCounterBase *counter = cg->comp()->getCounterFromStaticAddress(_symbolReference); + if (counter == NULL) + { + cg->comp()->failCompilation("Could not generate relocation for debug counter in TR::S390EncodingRelocation::addRelocation\n"); + } + TR::DebugCounter::generateRelocation(cg->comp(), + cursor, + node, + counter); + } else { TR_ASSERT(0,"relocation type [%d] not handled yet", _reloType);