Path: blob/master/runtime/compiler/infra/J9MonitorTable.hpp
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#ifndef TRJ9_MONITORTABLE_INCL23#define TRJ9_MONITORTABLE_INCL2425#ifndef TRJ9_MONITORTABLE_CONNECTOR26#define TRJ9_MONITORTABLE_CONNECTOR27namespace J9 { class MonitorTable; }28namespace J9 { typedef MonitorTable MonitorTableConnector; }29#endif303132#include "infra/OMRMonitorTable.hpp"33#include "infra/Link.hpp"34#include "infra/Monitor.hpp"35#include "infra/RWMonitor.hpp"3637struct J9PortLibrary;38struct J9JavaVM;39struct J9VMThread;40namespace TR { class MonitorTable; }4142namespace J943{4445class OMR_EXTENSIBLE MonitorTable : public OMR::MonitorTableConnector46{47public:4849void *operator new(size_t size, void *p) {return p;}5051static TR::MonitorTable *init(J9PortLibrary *portLib, J9JavaVM *javaVM);5253void free();5455J9::RWMonitor *getClassUnloadMonitor() { return &_classUnloadMonitor; }56TR::Monitor *getClassTableMutex() { return &_classTableMutex; }57TR::Monitor *getIProfilerPersistenceMonitor() { return &_iprofilerPersistenceMonitor; }58void removeAndDestroy(TR::Monitor *monitor);5960bool isThreadInSafeMonitorState(J9VMThread *vmThread);61TR::Monitor *monitorHeldByCurrentThread();62int32_t readAcquireClassUnloadMonitor(int32_t compThreadIndex);63int32_t readReleaseClassUnloadMonitor(int32_t compThreadIndex);64int32_t getClassUnloadMonitorHoldCount(int32_t i) const { return _classUnloadMonitorHolders[i]; }6566bool allocInitClassUnloadMonitorHolders(uint32_t allowedTotalCompThreads);6768private:6970friend class TR::Monitor;71friend class J9::Monitor;72friend class J9::RWMonitor;73friend class TR::MonitorTable;7475TR::Monitor *create(char *name);76void insert(TR::Monitor *monitor);7778J9PortLibrary *_portLib;79TR_LinkHead0<TR::Monitor> _monitors;8081TR::Monitor _tableMonitor;82TR::Monitor _j9ScratchMemoryPoolMonitor;83J9::RWMonitor _classUnloadMonitor;84TR::Monitor _classTableMutex; // JavaVM's class table mutex85TR::Monitor _iprofilerPersistenceMonitor;8687// To detect which thread has locked the classUnloadMonitor we will keep an array of integers88// Each entry corresponds to a determined compilation thread. This way we avoid any89// concurrency issues. Each number represents how many times the compilation thread has entered90// the classUnloadmonitor. Normally it should not be more than 191//92int32_t *_classUnloadMonitorHolders;93uint32_t _numCompThreads;94};9596}9798#endif99100101