Path: blob/master/src/hotspot/share/runtime/jniPeriodicChecker.cpp
40951 views
/*1* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "memory/allocation.inline.hpp"26#include "runtime/jniPeriodicChecker.hpp"27#include "runtime/task.hpp"282930// --------------------------------------------------------31// Class to aid in periodic checking under CheckJNICalls32class JniPeriodicCheckerTask : public PeriodicTask {33public:34JniPeriodicCheckerTask(int interval_time) : PeriodicTask(interval_time) {}35void task() { os::run_periodic_checks(); }36static void engage();37static void disengage();38};394041//----------------------------------------------------------42// Implementation of JniPeriodicChecker4344JniPeriodicCheckerTask* JniPeriodicChecker::_task = NULL;4546/*47* The engage() method is called at initialization time via48* Thread::create_vm() to initialize the JniPeriodicChecker and49* register it with the WatcherThread as a periodic task.50*/51void JniPeriodicChecker::engage() {52if (CheckJNICalls && !is_active()) {53// start up the periodic task54_task = new JniPeriodicCheckerTask(10);55_task->enroll();56}57}585960/*61* the disengage() method is responsible for deactivating the periodic62* task. This method is called from before_exit() in java.cpp and is only called63* after the WatcherThread has been stopped.64*/65void JniPeriodicChecker::disengage() {66if (CheckJNICalls && is_active()) {67// remove JniPeriodicChecker68_task->disenroll();69delete _task;70_task = NULL;71}72}7374void jniPeriodicChecker_exit() {75if (!CheckJNICalls) return;76}777879