Path: blob/master/runtime/compiler/env/J9JitMemory.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 <stdint.h>23#include "jilconsts.h"24#include "compile/Compilation.hpp"25#include "env/jittypes.h"26#include "env/VerboseLog.hpp"27#include "infra/Monitor.hpp"28#include "runtime/RuntimeAssumptions.hpp"29#include "control/CompilationRuntime.hpp"30#include "control/CompilationThread.hpp"31#include "env/J9JitMemory.hpp"32#include "env/VMJ9.h"3334void preventAllocationOfBTLMemory(J9MemorySegment * &segment, J9JavaVM * javaVM, TR_AllocationKind segmentType, bool freeSegmentOverride)35{36#if defined(J9ZOS390)37// Special code for zOS. If we allocated BTL memory (first 16MB), then we must38// release this segment, failing the compilation and forcing to use only one compilation thread39if (TR::Options::getCmdLineOptions()->getOption(TR_DontAllocateScratchBTL) &&40segment && ((uintptr_t)(segment->heapBase) < (uintptr_t)(1 << 24)))41{42// If applicable, reduce the number of compilation threads to 143TR::CompilationInfo * compInfo = TR::CompilationInfo::get((J9JITConfig*)jitConfig);44if (compInfo)45{46if (!compInfo->getRampDownMCT())47{48compInfo->setRampDownMCT();49if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCompilationThreads))50{51TR_VerboseLog::writeLineLocked(TR_Vlog_INFO, "t=%u setRampDownMCT because JIT allocated BTL memory", (uint32_t)compInfo->getPersistentInfo()->getElapsedTime());52}53}54else55{56// Perhaps we should consider lowering the compilation aggressiveness57if (!TR::Options::getAOTCmdLineOptions()->getOption(TR_NoOptServer))58{59TR::Options::getAOTCmdLineOptions()->setOption(TR_NoOptServer);60}61if (!TR::Options::getJITCmdLineOptions()->getOption(TR_NoOptServer))62{63TR::Options::getJITCmdLineOptions()->setOption(TR_NoOptServer);64}65}6667// For scratch memory refuse to return memory below the line. Free the segment and let the compilation fail68// Compilation will be retried at lower opt level.69if (freeSegmentOverride || segmentType == heapAlloc || segmentType == stackAlloc)70{71J9VMThread *crtVMThread = javaVM->internalVMFunctions->currentVMThread(javaVM);72if (compInfo->getCompInfoForThread(crtVMThread))73{74javaVM->internalVMFunctions->freeMemorySegment(javaVM, segment, TRUE);75segment = NULL;76}77}78}79}80#endif // defined(J9ZOS390)81}828384