Path: blob/master/runtime/gc_check/CheckMonitorTable.cpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* 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-exception21*******************************************************************************/2223#include "j9.h"24#include "j9cfg.h"2526#include "CheckEngine.hpp"27#include "CheckMonitorTable.hpp"28#include "ModronTypes.hpp"29#include "ScanFormatter.hpp"3031GC_Check *32GC_CheckMonitorTable::newInstance(J9JavaVM *javaVM, GC_CheckEngine *engine)33{34MM_Forge *forge = MM_GCExtensions::getExtensions(javaVM)->getForge();3536GC_CheckMonitorTable *check = (GC_CheckMonitorTable *) forge->allocate(sizeof(GC_CheckMonitorTable), MM_AllocationCategory::DIAGNOSTIC, J9_GET_CALLSITE());37if(check) {38new(check) GC_CheckMonitorTable(javaVM, engine);39}40return check;41}4243void44GC_CheckMonitorTable::kill()45{46MM_Forge *forge = MM_GCExtensions::getExtensions(_javaVM)->getForge();47forge->free(this);48}4950void51GC_CheckMonitorTable::check()52{53J9ObjectMonitor *objectMonitor = NULL;54J9MonitorTableListEntry *monitorTableList = _javaVM->monitorTableList;55while (NULL != monitorTableList) {56J9HashTable *table = monitorTableList->monitorTable;57if (NULL != table) {58GC_HashTableIterator iterator(table);59while (NULL != (objectMonitor = (J9ObjectMonitor*)iterator.nextSlot())) {60J9ThreadAbstractMonitor * monitor = (J9ThreadAbstractMonitor *)objectMonitor->monitor;61J9Object **slotPtr = (J9Object**)&monitor->userData;62if(_engine->checkSlotPool(_javaVM, slotPtr, table) != J9MODRON_SLOT_ITERATOR_OK ) {63return;64}65}66}67monitorTableList = monitorTableList->next;68}69}7071void72GC_CheckMonitorTable::print()73{74J9ObjectMonitor *objectMonitor = NULL;75J9MonitorTableListEntry *monitorTableList = _javaVM->monitorTableList;7677GC_ScanFormatter formatter(_portLibrary, "MonitorTableList", (void *)monitorTableList);787980while (NULL != monitorTableList) {81J9HashTable *table = monitorTableList->monitorTable;82if (NULL != table) {83formatter.section("MonitorTable", (void *)table);8485GC_HashTableIterator iterator(table);86while (NULL != (objectMonitor = (J9ObjectMonitor*)iterator.nextSlot())) {87J9ThreadAbstractMonitor * monitor = (J9ThreadAbstractMonitor *)objectMonitor->monitor;88J9Object *objectPtr = (J9Object *)monitor->userData;89formatter.entry((void *) objectPtr);90}91formatter.endSection();92}93monitorTableList = monitorTableList->next;94}9596formatter.end("MonitorTableList", (void *)monitorTableList);97}9899100