diff --git a/runtime/compiler/control/CompilationRuntime.hpp b/runtime/compiler/control/CompilationRuntime.hpp index 44386e9d452..67ebb84abae 100644 --- a/runtime/compiler/control/CompilationRuntime.hpp +++ b/runtime/compiler/control/CompilationRuntime.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corp. and others + * Copyright (c) 2000, 2020 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 @@ -1014,8 +1014,6 @@ class CompilationInfo void markCHTableUpdateDone(uint8_t threadId) { _chTableUpdateFlags |= (1 << threadId); } void resetCHTableUpdateDone(uint8_t threadId) { _chTableUpdateFlags &= ~(1 << threadId); } uint8_t getCHTableUpdateDone() const { return _chTableUpdateFlags; } - uint32_t getLocalGCCounter() const { return _localGCCounter; } - void incrementLocalGCCounter() { _localGCCounter++; } const PersistentVector &getJITServerSslKeys() const { return _sslKeys; } void addJITServerSslKey(const std::string &key) { _sslKeys.push_back(key); } diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index 54efc7deee9..ba0ac26ea8f 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corp. and others + * Copyright (c) 2000, 2020 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 @@ -1049,8 +1049,6 @@ TR::CompilationInfoPerThread::CompilationInfoPerThread(TR::CompilationInfo &comp { _classesThatShouldNotBeNewlyExtended = NULL; } - - _lastLocalGCCounter = 0; #endif /* defined(JITSERVER_SUPPORT) */ } @@ -12854,12 +12852,6 @@ TR::CompilationInfo::canRelocateMethod(TR::Compilation *comp) } #if defined(JITSERVER_SUPPORT) -void -TR::CompilationInfoPerThread::updateLastLocalGCCounter() - { - _lastLocalGCCounter = getCompilationInfo()->getLocalGCCounter(); - } - // This method is executed by the JITServer to queue a placeholder for // a compilation request received from the client. At the time the new // entry is queued we do not know any details about the compilation request. diff --git a/runtime/compiler/control/CompilationThread.hpp b/runtime/compiler/control/CompilationThread.hpp index 6d86a26f743..abeb5dc62f1 100644 --- a/runtime/compiler/control/CompilationThread.hpp +++ b/runtime/compiler/control/CompilationThread.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corp. and others + * Copyright (c) 2000, 2020 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 @@ -393,8 +393,6 @@ class CompilationInfoPerThread : public TR::CompilationInfoPerThreadBase J9ROMClass *getAndCacheRemoteROMClass(J9Class *, TR_Memory *trMemory=NULL); J9ROMClass *getRemoteROMClassIfCached(J9Class *); PersistentUnorderedSet *getClassesThatShouldNotBeNewlyExtended() const { return _classesThatShouldNotBeNewlyExtended; } - uint32_t getLastLocalGCCounter() const { return _lastLocalGCCounter; } - void updateLastLocalGCCounter(); #endif /* defined(JITSERVER_SUPPORT) */ protected: @@ -418,7 +416,6 @@ class CompilationInfoPerThread : public TR::CompilationInfoPerThreadBase // The following hastable caches --> mappings // The cache only lives during a compilation due to class unloading concerns PersistentUnorderedSet *_classesThatShouldNotBeNewlyExtended; - uint32_t _lastLocalGCCounter; #endif /* defined(JITSERVER_SUPPORT) */ }; // CompilationInfoPerThread diff --git a/runtime/compiler/control/HookedByTheJit.cpp b/runtime/compiler/control/HookedByTheJit.cpp index fef9a49009f..2244749af99 100644 --- a/runtime/compiler/control/HookedByTheJit.cpp +++ b/runtime/compiler/control/HookedByTheJit.cpp @@ -1563,11 +1563,6 @@ static void jitHookLocalGCEnd(J9HookInterface * * hookInterface, UDATA eventNum, if (jitConfig->runtimeFlags & J9JIT_GC_NOTIFY) printf("}"); - -#if defined(JITSERVER_SUPPORT) - TR::CompilationInfo *compInfo = TR::CompilationInfo::get(jitConfig); - compInfo->incrementLocalGCCounter(); -#endif } static void initThreadAfterCreation(J9VMThread *vmThread) diff --git a/runtime/compiler/control/JITClientCompilationThread.cpp b/runtime/compiler/control/JITClientCompilationThread.cpp index 11a1bb0f2a4..a53c6514e04 100644 --- a/runtime/compiler/control/JITClientCompilationThread.cpp +++ b/runtime/compiler/control/JITClientCompilationThread.cpp @@ -656,16 +656,10 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::VM_getInt32FieldAt: { - if (compInfoPT->getLastLocalGCCounter() != compInfoPT->getCompilationInfo()->getLocalGCCounter()) - { - // GC happened, fail compilation - auto comp = compInfoPT->getCompilation(); - comp->failCompilation("Compilation interrupted due to GC"); - } - auto recv = client->getRecvData(); uintptrj_t objectPointer = std::get<0>(recv); uintptrj_t fieldOffset = std::get<1>(recv); + TR::VMAccessCriticalSection getInt32FieldAt(fe); client->write(response, fe->getInt32FieldAt(objectPointer, fieldOffset)); } break; @@ -674,6 +668,7 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes auto recv = client->getRecvData(); uintptrj_t objectPointer = std::get<0>(recv); uintptrj_t fieldOffset = std::get<1>(recv); + TR::VMAccessCriticalSection getInt64FieldAt(fe); client->write(response, fe->getInt64FieldAt(objectPointer, fieldOffset)); } break; @@ -699,14 +694,8 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::VM_getArrayLengthInElements: { - if (compInfoPT->getLastLocalGCCounter() != compInfoPT->getCompilationInfo()->getLocalGCCounter()) - { - // GC happened, fail compilation - auto comp = compInfoPT->getCompilation(); - comp->failCompilation("Compilation interrupted due to GC"); - } - uintptrj_t objectPointer = std::get<0>(client->getRecvData()); + TR::VMAccessCriticalSection getArrayLengthInElements(fe); client->write(response, fe->getArrayLengthInElements(objectPointer)); } break; @@ -2063,26 +2052,13 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes client->write(response, ptr); } break; - case MessageType::runFEMacro_derefUintptrjPtr: - { - TR::VMAccessCriticalSection deref(fe); - compInfoPT->updateLastLocalGCCounter(); - client->write(response, *std::get<0>(client->getRecvData())); - } - break; case MessageType::runFEMacro_invokeILGenMacrosInvokeExactAndFixup: { - auto recv = client->getRecvData(); + auto recv = client->getRecvData >(); TR::VMAccessCriticalSection invokeILGenMacrosInvokeExactAndFixup(fe); - - if (compInfoPT->getLastLocalGCCounter() != compInfoPT->getCompilationInfo()->getLocalGCCounter()) - { - // GC happened, fail compilation - auto comp = compInfoPT->getCompilation(); - comp->failCompilation("Compilation interrupted due to GC"); - } - - uintptrj_t methodHandle = std::get<0>(recv); + uintptrj_t receiverHandle = *std::get<0>(recv); + const std::vector& listOfOffsets = std::get<1>(recv); + uintptrj_t methodHandle = listOfOffsets.size() == 0 ? receiverHandle : JITServerHelpers::walkReferenceChainWithOffsets(fe, listOfOffsets, receiverHandle); uintptrj_t methodDescriptorRef = fe->getReferenceField(fe->getReferenceField( methodHandle, "type", "Ljava/lang/invoke/MethodType;"), @@ -2096,9 +2072,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes case MessageType::runFEMacro_invokeCollectHandleNumArgsToCollect: { auto recv = client->getRecvData(); + TR::VMAccessCriticalSection invokeCollectHandleNumArgsToCollect(fe); uintptrj_t methodHandle = *std::get<0>(recv); bool getPos = std::get<1>(recv); - TR::VMAccessCriticalSection invokeCollectHandleNumArgsToCollect(fe); int32_t collectArraySize = fe->getInt32Field(methodHandle, "collectArraySize"); uintptrj_t arguments = fe->getReferenceField( fe->getReferenceField(methodHandle, "type", "Ljava/lang/invoke/MethodType;"), @@ -2141,9 +2117,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes case MessageType::runFEMacro_targetTypeL: { auto recv = client->getRecvData(); - int32_t argIndex = std::get<1>(recv); TR::VMAccessCriticalSection targetTypeL(fe); uintptrj_t methodHandle = *std::get<0>(recv); + int32_t argIndex = std::get<1>(recv); uintptrj_t targetArguments = fe->getReferenceField(fe->getReferenceField(fe->getReferenceField( methodHandle, "next", "Ljava/lang/invoke/MethodHandle;"), @@ -2192,8 +2168,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeSpreadHandleArrayArg: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeSpreadHandleArrayArg(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t arrayClass = fe->getReferenceField(methodHandle, "arrayClass", "Ljava/lang/Class;"); J9ArrayClass *arrayJ9Class = (J9ArrayClass*)(intptrj_t)fe->getInt64Field(arrayClass, "vmRef" /* should use fej9->getOffsetOfClassFromJavaLangClassField() */); @@ -2213,10 +2190,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes case MessageType::runFEMacro_invokeSpreadHandle: { auto recv = client->getRecvData(); + TR::VMAccessCriticalSection invokeSpreadHandle(fe); uintptrj_t methodHandle = *std::get<0>(recv); bool getSpreadPosition = std::get<1>(recv); - - TR::VMAccessCriticalSection invokeSpreadHandle(fe); uintptrj_t arguments = fe->getReferenceField(fe->methodHandle_type(methodHandle), "arguments", "[Ljava/lang/Class;"); int32_t numArguments = (int32_t)fe->getArrayLengthInElements(arguments); uintptrj_t next = fe->getReferenceField(methodHandle, "next", "Ljava/lang/invoke/MethodHandle;"); @@ -2231,8 +2207,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeInsertHandle: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeInsertHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); int32_t insertionIndex = fe->getInt32Field(methodHandle, "insertionIndex"); uintptrj_t arguments = fe->getReferenceField(fe->getReferenceField(methodHandle, "type", "Ljava/lang/invoke/MethodType;"), "arguments", "[Ljava/lang/Class;"); @@ -2244,8 +2221,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeFoldHandle: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeFoldHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t argIndices = fe->getReferenceField(methodHandle, "argumentIndices", "[I"); int32_t arrayLength = (int32_t)fe->getArrayLengthInElements(argIndices); int32_t foldPosition = fe->getInt32Field(methodHandle, "foldPosition"); @@ -2270,16 +2248,42 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeFoldHandle2: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeFoldHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); int32_t foldPosition = fe->getInt32Field(methodHandle, "foldPosition"); client->write(response, foldPosition); } break; + case MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleArgumentIndices: + { + auto recv = client->getRecvData(); + TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); + uintptrj_t argumentIndices = fe->getReferenceField(methodHandle, "argumentIndices", "[I"); + int32_t arrayLength = fe->getArrayLengthInElements(argumentIndices); + std::vector argIndices(arrayLength); + for (int i = arrayLength - 1; i >= 0; i--) + { + argIndices[i] = fe->getInt32Element(argumentIndices, i); + } + client->write(response, arrayLength, argIndices); + } + break; + case MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleFilterPosition: + { + auto recv = client->getRecvData(); + TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); + int32_t filterPosition = fe->getInt32Field(methodHandle, "filterPosition"); + client->write(response, filterPosition); + } + break; case MessageType::runFEMacro_invokeFinallyHandle: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeFinallyHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t finallyTarget = fe->getReferenceField(methodHandle, "finallyTarget", "Ljava/lang/invoke/MethodHandle;"); uintptrj_t finallyType = fe->getReferenceField(finallyTarget, "type", "Ljava/lang/invoke/MethodType;"); uintptrj_t arguments = fe->getReferenceField(finallyType, "arguments", "[Ljava/lang/Class;"); @@ -2292,11 +2296,22 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes client->write(response, numArgsPassToFinallyTarget, std::string(methodDescriptor, methodDescriptorLength)); } break; + case MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleNumSuffixArgs: + { + auto recv = client->getRecvData(); + TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); + uintptrj_t arguments = fe->getReferenceField(fe->methodHandle_type(methodHandle), "arguments", "[Ljava/lang/Class;"); + int32_t numArguments = (int32_t)fe->getArrayLengthInElements(arguments); + int32_t filterPos = (int32_t)fe->getInt32Field(methodHandle, "filterPosition"); + client->write(response, numArguments, filterPos); + } + break; case MessageType::runFEMacro_invokeFilterArgumentsHandle: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeFilterArgumentsHandle(fe); - + uintptrj_t methodHandle = *std::get<0>(recv); int32_t startPos = (int32_t)fe->getInt32Field(methodHandle, "startPos"); uintptrj_t filters = fe->getReferenceField(methodHandle, "filters", "[Ljava/lang/invoke/MethodHandle;"); @@ -2321,8 +2336,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeFilterArgumentsHandle2: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeFilderArgumentsHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t arguments = fe->getReferenceField(fe->methodHandle_type(methodHandle), "arguments", "[Ljava/lang/Class;"); int32_t numArguments = (int32_t)fe->getArrayLengthInElements(arguments); int32_t startPos = (int32_t)fe->getInt32Field(methodHandle, "startPos"); @@ -2333,8 +2349,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeCatchHandle: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeCatchHandle(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t catchTarget = fe->getReferenceField(methodHandle, "catchTarget", "Ljava/lang/invoke/MethodHandle;"); uintptrj_t catchArguments = fe->getReferenceField(fe->getReferenceField( catchTarget, @@ -2346,8 +2363,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokeArgumentMoverHandlePermuteArgs: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokeArgumentMoverHandlePermuteArgs(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t methodDescriptorRef = fe->getReferenceField(fe->getReferenceField(fe->getReferenceField( methodHandle, "next", "Ljava/lang/invoke/MethodHandle;"), @@ -2361,8 +2379,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes break; case MessageType::runFEMacro_invokePermuteHandlePermuteArgs: { - uintptrj_t methodHandle = *std::get<0>(client->getRecvData()); + auto recv = client->getRecvData(); TR::VMAccessCriticalSection invokePermuteHandlePermuteArgs(fe); + uintptrj_t methodHandle = *std::get<0>(recv); uintptrj_t permuteArray = fe->getReferenceField(methodHandle, "permute", "[I"); int32_t permuteLength = fe->getArrayLengthInElements(permuteArray); std::vector argIndices(permuteLength); @@ -2373,17 +2392,13 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes client->write(response, permuteLength, argIndices); } break; - case MessageType::runFEMacro_invokeILGenMacros: + case MessageType::runFEMacro_invokeILGenMacrosParameterCount: { - if (compInfoPT->getLastLocalGCCounter() != compInfoPT->getCompilationInfo()->getLocalGCCounter()) - { - // GC happened, fail compilation - auto comp = compInfoPT->getCompilation(); - comp->failCompilation("Compilation interrupted due to GC"); - } - - uintptrj_t methodHandle = std::get<0>(client->getRecvData()); - TR::VMAccessCriticalSection invokeILGenMacros(fe); + auto recv = client->getRecvData >(); + TR::VMAccessCriticalSection invokeILGenMacrosParameterCount(fe); + uintptrj_t receiverHandle = *std::get<0>(recv); + const std::vector& listOfOffsets = std::get<1>(recv); + uintptrj_t methodHandle = JITServerHelpers::walkReferenceChainWithOffsets(fe, listOfOffsets, receiverHandle); uintptrj_t arguments = fe->getReferenceField(fe->getReferenceField( methodHandle, "type", "Ljava/lang/invoke/MethodType;"), @@ -2392,7 +2407,29 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes client->write(response, parameterCount); } break; - + case MessageType::runFEMacro_invokeILGenMacrosArrayLength: + { + auto recv = client->getRecvData >(); + TR::VMAccessCriticalSection invokeILGenMacrosArrayLength(fe); + uintptrj_t receiverHandle = *std::get<0>(recv); + const std::vector& listOfOffsets = std::get<1>(recv); + uintptrj_t array = JITServerHelpers::walkReferenceChainWithOffsets(fe, listOfOffsets, receiverHandle); + int32_t arrayLength = (int32_t)fe->getArrayLengthInElements(array); + client->write(response, arrayLength); + } + break; + case MessageType::runFEMacro_invokeILGenMacrosGetField: + { + auto recv = client->getRecvData >(); + TR::VMAccessCriticalSection invokeILGenMacrosGetField(fe); + uintptrj_t receiverHandle = *std::get<0>(recv); + uintptrj_t fieldOffset = std::get<1>(recv); + const std::vector& listOfOffsets = std::get<2>(recv); + uintptrj_t baseObject = JITServerHelpers::walkReferenceChainWithOffsets(fe, listOfOffsets, receiverHandle); + int32_t result = fe->getInt32FieldAt(baseObject, fieldOffset); + client->write(response, result); + } + break; case MessageType::CHTable_getAllClassInfo: { client->getRecvData(); diff --git a/runtime/compiler/control/JITServerHelpers.cpp b/runtime/compiler/control/JITServerHelpers.cpp index 20345b2e885..15aadbb7889 100644 --- a/runtime/compiler/control/JITServerHelpers.cpp +++ b/runtime/compiler/control/JITServerHelpers.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2019 IBM Corp. and others + * Copyright (c) 2019, 2020 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 "control/MethodToBeCompiled.hpp" #include "infra/CriticalSection.hpp" + uint32_t JITServerHelpers::serverMsgTypeCount[] = {}; uint64_t JITServerHelpers::_waitTimeMs = 1000; bool JITServerHelpers::_serverAvailable = true; @@ -549,3 +550,16 @@ JITServerHelpers::isAddressInROMClass(const void *address, const J9ROMClass *rom { return ((address >= romClass) && (address < (((uint8_t*) romClass) + romClass->romSize))); } + + +uintptrj_t +JITServerHelpers::walkReferenceChainWithOffsets(TR_J9VM * fe, const std::vector& listOfOffsets, uintptrj_t receiver) + { + uintptrj_t result = receiver; + for (size_t i = 0; i < listOfOffsets.size(); i++) + { + result = fe->getReferenceFieldAt(result, listOfOffsets[i]); + } + return result; + } + diff --git a/runtime/compiler/control/JITServerHelpers.hpp b/runtime/compiler/control/JITServerHelpers.hpp index 3d518cbbe32..3cacfbc67a1 100644 --- a/runtime/compiler/control/JITServerHelpers.hpp +++ b/runtime/compiler/control/JITServerHelpers.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2019 IBM Corp. and others + * Copyright (c) 2019, 2020 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 @@ -97,6 +97,8 @@ class JITServerHelpers static bool isAddressInROMClass(const void *address, const J9ROMClass *romClass); + static uintptrj_t walkReferenceChainWithOffsets(TR_J9VM * fe, const std::vector& listOfOffsets, uintptrj_t receiver); + private: static void getROMClassData(const ClientSessionData::ClassInfo &classInfo, ClassInfoDataType dataType, void *data); static TR::Monitor *getClientStreamMonitor() diff --git a/runtime/compiler/env/j9method.cpp b/runtime/compiler/env/j9method.cpp index 16c0212643e..d47f5a63c60 100644 --- a/runtime/compiler/env/j9method.cpp +++ b/runtime/compiler/env/j9method.cpp @@ -65,6 +65,7 @@ #include "env/JSR292Methods.h" #include "control/MethodToBeCompiled.hpp" + #if defined(_MSC_VER) #include #endif @@ -7789,11 +7790,13 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) #if defined(JITSERVER_SUPPORT) if (comp()->isOutOfProcessCompilation()) { + std::vector listOfOffsets; + if (!returnFromArchetype) + { + packReferenceChainOffsets(methodHandleExpression, listOfOffsets); + } auto stream = TR::CompilationInfo::getStream(); - stream->write(JITServer::MessageType::runFEMacro_derefUintptrjPtr, thunkDetails->getHandleRef()); - receiverHandle = std::get<0>(stream->read()); - methodHandle = returnFromArchetype ? receiverHandle : walkReferenceChain(methodHandleExpression, receiverHandle); - stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacrosInvokeExactAndFixup, methodHandle); + stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacrosInvokeExactAndFixup, thunkDetails->getHandleRef(), listOfOffsets); auto recv = stream->read(); std::string methodDescriptorString = std::get<0>(recv); methodDescriptorLength = methodDescriptorString.length(); @@ -8627,6 +8630,24 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) uintptrj_t methodHandle; uintptrj_t argumentIndices; + +#if defined(JITSERVER_SUPPORT) + if (comp()->isOutOfProcessCompilation()) + { + auto stream = TR::CompilationInfo::getStream(); + stream->write(JITServer::MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleArgumentIndices, thunkDetails->getHandleRef()); + + auto recv = stream->read>(); + int32_t arrayLength = std::get<0>(recv); + std::vector argIndices = std::get<1>(recv); + // Push the indices in reverse order + for (int i = arrayLength - 1; i >= 0; i--) { + loadConstant(TR::iconst, argIndices[i]); + } + loadConstant(TR::iconst, arrayLength); // number of arguments + } + else +#endif /* defined(JITSERVER_SUPPORT) */ { TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fej9); methodHandle = *thunkDetails->getHandleRef(); @@ -8680,6 +8701,16 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) uintptrj_t methodHandle; int32_t filterPosition; + +#if defined(JITSERVER_SUPPORT) + if (comp()->isOutOfProcessCompilation()) + { + auto stream = TR::CompilationInfo::getStream(); + stream->write(JITServer::MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleFilterPosition, thunkDetails->getHandleRef()); + filterPosition = std::get<0>(stream->read()); + } + else +#endif /* defined(JITSERVER_SUPPORT) */ { TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fej9); methodHandle = *thunkDetails->getHandleRef(); @@ -8785,6 +8816,17 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) int32_t numArguments; int32_t filterPos; +#if defined(JITSERVER_SUPPORT) + if (comp()->isOutOfProcessCompilation()) + { + auto stream = TR::CompilationInfo::getStream(); + stream->write(JITServer::MessageType::runFEMacro_invokeFilterArgumentsWithCombinerHandleNumSuffixArgs, thunkDetails->getHandleRef()); + auto recv = stream->read(); + numArguments = std::get<0>(recv); + filterPos = std::get<1>(recv); + } + else +#endif /* defined(JITSERVER_SUPPORT) */ { TR::VMAccessCriticalSection invokeFilterArgumentsWithCombinerHandle(fej9); methodHandle = *thunkDetails->getHandleRef(); @@ -9050,11 +9092,9 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) if (comp()->isOutOfProcessCompilation()) { auto stream = TR::CompilationInfo::getStream(); - stream->write(JITServer::MessageType::runFEMacro_derefUintptrjPtr, thunkDetails->getHandleRef()); - uintptrj_t receiverHandle = std::get<0>(stream->read()); - uintptrj_t methodHandle = walkReferenceChain(pop(), receiverHandle); - - stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacros, methodHandle); + std::vector listOfOffsets; + packReferenceChainOffsets(pop(), listOfOffsets); + stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacrosParameterCount, thunkDetails->getHandleRef(), listOfOffsets); parameterCount = std::get<0>(stream->read()); } else @@ -9085,10 +9125,10 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) if (comp()->isOutOfProcessCompilation()) { auto stream = TR::CompilationInfo::getStream(); - stream->write(JITServer::MessageType::runFEMacro_derefUintptrjPtr, thunkDetails->getHandleRef()); - uintptrj_t receiverHandle = std::get<0>(stream->read()); - uintptrj_t array = walkReferenceChain(pop(), receiverHandle); - arrayLength = (int32_t)fej9->getArrayLengthInElements(array); + std::vector listOfOffsets; + packReferenceChainOffsets(pop(), listOfOffsets); + stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacrosArrayLength, thunkDetails->getHandleRef(), listOfOffsets); + arrayLength = std::get<0>(stream->read()); } else #endif /* defined(JITSERVER_SUPPORT) */ @@ -9122,11 +9162,11 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef) if (comp()->isOutOfProcessCompilation()) { auto stream = TR::CompilationInfo::getStream(); - stream->write(JITServer::MessageType::runFEMacro_derefUintptrjPtr, thunkDetails->getHandleRef()); - uintptrj_t receiverHandle = std::get<0>(stream->read()); - uintptrj_t baseObject = walkReferenceChain(baseObjectNode, receiverHandle); + std::vector listOfOffsets; + packReferenceChainOffsets(baseObjectNode, listOfOffsets); TR_ASSERT(fieldSym->getDataType() == TR::Int32, "ILGenMacros.getField expecting int field; found load of %s", comp()->getDebug()->getName(symRef)); - result = fej9->getInt32FieldAt(baseObject, fieldOffset); // TODO: Handle types other than int32 + stream->write(JITServer::MessageType::runFEMacro_invokeILGenMacrosGetField, thunkDetails->getHandleRef(), fieldOffset, listOfOffsets); + result = std::get<0>(stream->read()); } else #endif /* defined(JITSERVER_SUPPORT) */ @@ -9180,7 +9220,7 @@ TR_J9ByteCodeIlGenerator::walkReferenceChain(TR::Node *node, uintptrj_t receiver } TR::Symbol *sym = symRef->getSymbol(); TR_ASSERT(sym->isShadow() && symRef->getCPIndex() > 0, "walkReferenceChain expecting field load; found load of %s", comp()->getDebug()->getName(symRef)); - uintptrj_t fieldOffset = symRef->getOffset() - TR::Compiler->om.objectHeaderSizeInBytes(); // blah + uintptrj_t fieldOffset = symRef->getOffset() - TR::Compiler->om.objectHeaderSizeInBytes(); result = fej9->getReferenceFieldAt(walkReferenceChain(node->getFirstChild(), receiver), fieldOffset); } else @@ -9200,3 +9240,45 @@ TR_J9ByteCodeIlGenerator::walkReferenceChain(TR::Node *node, uintptrj_t receiver return result; } + + +#if defined(JITSERVER_SUPPORT) +void +TR_J9ByteCodeIlGenerator::packReferenceChainOffsets(TR::Node *node, std::vector& listOfOffsets) + { + if (node->getOpCode().isLoadDirect() && node->getType() == TR::Address) + { + TR_ASSERT(node->getSymbolReference()->getCPIndex() == 0, "walkReferenceChain expecting aload of 'this'; found aload of %s", comp()->getDebug()->getName(node->getSymbolReference())); + return; + } + else if (node->getOpCode().isLoadIndirect() && node->getType() == TR::Address) + { + TR::SymbolReference *symRef = node->getSymbolReference(); + if (symRef->isUnresolved()) + { + if (comp()->getOption(TR_TraceILGen)) + traceMsg(comp(), " walkReferenceChain hit unresolved symref %s; aborting\n", symRef->getName(comp()->getDebug())); + comp()->failCompilation("Symbol reference is unresolved"); + } + TR::Symbol *sym = symRef->getSymbol(); + TR_ASSERT(sym->isShadow() && symRef->getCPIndex() > 0, "walkReferenceChain expecting field load; found load of %s", comp()->getDebug()->getName(symRef)); + uintptrj_t fieldOffset = symRef->getOffset() - TR::Compiler->om.objectHeaderSizeInBytes(); + packReferenceChainOffsets(node->getFirstChild(), listOfOffsets); + listOfOffsets.push_back(fieldOffset); + } + else + { + TR_ASSERT(0, "Unexpected opcode in walkReferenceChain: %s", node->getOpCode().getName()); + comp()->failCompilation("Unexpected opcode in walkReferenceChain"); + } + + if (comp()->getOption(TR_TraceILGen)) + { + TR_ASSERT(node->getOpCode().hasSymbolReference(), "Can't get here without a symref"); + traceMsg(comp(), " walkReferenceChain(%s) // %s\n", + comp()->getDebug()->getName(node), + comp()->getDebug()->getName(node->getSymbolReference())); + } + return; + } +#endif diff --git a/runtime/compiler/ilgen/J9ByteCodeIlGenerator.hpp b/runtime/compiler/ilgen/J9ByteCodeIlGenerator.hpp index 59394baa892..6a62d303187 100644 --- a/runtime/compiler/ilgen/J9ByteCodeIlGenerator.hpp +++ b/runtime/compiler/ilgen/J9ByteCodeIlGenerator.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2019 IBM Corp. and others + * Copyright (c) 2000, 2020 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 @@ -342,6 +342,10 @@ class TR_J9ByteCodeIlGenerator : public TR_IlGenerator, public TR_J9ByteCodeIter bool replaceStatic(TR::Node* node, char* dstClassName, char* staticName, char* type); uintptrj_t walkReferenceChain(TR::Node *node, uintptrj_t receiver); +#if defined(JITSERVER_SUPPORT) + void packReferenceChainOffsets(TR::Node *node, std::vector& listOfOffsets); +#endif + bool hasFPU(); // data diff --git a/runtime/compiler/net/CommunicationStream.hpp b/runtime/compiler/net/CommunicationStream.hpp index 22c0b34dbf0..7c87651315f 100644 --- a/runtime/compiler/net/CommunicationStream.hpp +++ b/runtime/compiler/net/CommunicationStream.hpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2019 IBM Corp. and others + * Copyright (c) 2018, 2020 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 @@ -158,7 +158,7 @@ class CommunicationStream ZeroCopyOutputStream *_outputStream; static const uint8_t MAJOR_NUMBER = 0; - static const uint16_t MINOR_NUMBER = 1; + static const uint16_t MINOR_NUMBER = 2; static const uint8_t PATCH_NUMBER = 0; static uint32_t CONFIGURATION_FLAGS; }; diff --git a/runtime/compiler/net/protos/compile.proto b/runtime/compiler/net/protos/compile.proto index f0e8dcc2638..d8b276ce802 100644 --- a/runtime/compiler/net/protos/compile.proto +++ b/runtime/compiler/net/protos/compile.proto @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2019 IBM Corp. and others + * Copyright (c) 2018, 2020 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 @@ -281,8 +281,12 @@ enum MessageType runFEMacro_invokeFilterArgumentsHandle = 714; runFEMacro_invokeFilterArgumentsHandle2 = 715; runFEMacro_invokeCatchHandle = 716; - runFEMacro_invokeILGenMacros = 717; - runFEMacro_derefUintptrjPtr = 718; + runFEMacro_invokeILGenMacrosParameterCount = 717; + runFEMacro_invokeILGenMacrosArrayLength = 718; + runFEMacro_invokeILGenMacrosGetField = 719; + runFEMacro_invokeFilterArgumentsWithCombinerHandleNumSuffixArgs = 720; + runFEMacro_invokeFilterArgumentsWithCombinerHandleFilterPosition = 721; + runFEMacro_invokeFilterArgumentsWithCombinerHandleArgumentIndices = 722; // for JITServerPersistentCHTable CHTable_getAllClassInfo = 800;