Path: blob/master/runtime/compiler/env/J9CompilerEnv.cpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#include "env/CompilerEnv.hpp"23#include "env/RawAllocator.hpp"24#include "env/defines.h"25#include "env/CPU.hpp"26#include "j9.h"27#if defined(J9VM_OPT_JITSERVER)28#include "control/CompilationRuntime.hpp"29#endif /* defined(J9VM_OPT_JITSERVER) */3031J9::CompilerEnv::CompilerEnv(J9JavaVM *vm, TR::RawAllocator raw, const TR::PersistentAllocatorKit &persistentAllocatorKit) :32#if defined(TR_HOST_ARM)33OMR::CompilerEnvConnector(raw, persistentAllocatorKit),34#else35OMR::CompilerEnvConnector(raw, persistentAllocatorKit, OMRPORT_FROM_J9PORT(vm->portLibrary)),36#endif37portLib(vm->portLibrary),38javaVM(vm)39{40}4142void43J9::CompilerEnv::initializeTargetEnvironment()44{45OMR::CompilerEnvConnector::initializeTargetEnvironment();46}4748/**49* \brief Determines whether methods are compiled and the generated code simply50* "tossed" without execution.51* \return true if compiles have been requested to be tossed; false otherwise.52*/53bool54J9::CompilerEnv::isCodeTossed()55{56J9JITConfig *jitConfig = javaVM->jitConfig;5758if (jitConfig == NULL)59{60return false;61}6263if (jitConfig->runtimeFlags & J9JIT_TOSS_CODE)64{65return true;66}6768return false;69}7071TR::PersistentAllocator &72J9::CompilerEnv::persistentAllocator()73{74#if defined(J9VM_OPT_JITSERVER)75if (J9::PersistentInfo::_remoteCompilationMode == JITServer::SERVER)76{77auto compInfoPT = TR::compInfoPT;78if (compInfoPT && compInfoPT->getPerClientPersistentMemory())79{80// Returns per-client allocator after enterPerClientPersistentAllocator() is called81return compInfoPT->getPerClientPersistentMemory()->_persistentAllocator.get();82}83}84#endif85return OMR::CompilerEnv::persistentAllocator();86}8788TR_PersistentMemory *89J9::CompilerEnv::persistentMemory()90{91#if defined(J9VM_OPT_JITSERVER)92if (J9::PersistentInfo::_remoteCompilationMode == JITServer::SERVER)93{94auto compInfoPT = TR::compInfoPT;95if (compInfoPT && compInfoPT->getPerClientPersistentMemory())96{97// Returns per-client persistent memory after enterPerClientPersistentAllocator() is called98return compInfoPT->getPerClientPersistentMemory();99}100}101#endif102return OMR::CompilerEnv::persistentMemory();103}104105#if defined(J9VM_OPT_JITSERVER)106107TR::PersistentAllocator &108J9::CompilerEnv::persistentGlobalAllocator()109{110return OMR::CompilerEnv::persistentAllocator();111}112113TR_PersistentMemory *114J9::CompilerEnv::persistentGlobalMemory()115{116return OMR::CompilerEnv::persistentMemory();117}118119#endif /* defined(J9VM_OPT_JITSERVER) */120121122