hotspot/src/share/vm/runtime/jniPeriodicChecker.cpp
author sla
Wed, 18 Dec 2013 08:39:06 +0100
changeset 22190 d306a75a70d3
parent 7397 5b173b4ca846
permissions -rw-r--r--
8029726: On OS X some dtrace probe names are mismatched with Solaris 8029727: On OS X dtrace probes Call<type>MethodA/Call<type>MethodV are not fired. 8029728: On OS X dtrace probes SetStaticBooleanField are not fired Reviewed-by: kamg, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "runtime/jniPeriodicChecker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "runtime/task.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// --------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Class to aid in periodic checking under CheckJNICalls
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class JniPeriodicCheckerTask : public PeriodicTask {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
     JniPeriodicCheckerTask(int interval_time) : PeriodicTask(interval_time) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
     void task() { os::run_periodic_checks(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
     static void engage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
     static void disengage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//----------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// Implementation of JniPeriodicChecker
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
JniPeriodicCheckerTask*              JniPeriodicChecker::_task   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 * The engage() method is called at initialization time via
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
 * Thread::create_vm() to initialize the JniPeriodicChecker and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
 * register it with the WatcherThread as a periodic task.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
void JniPeriodicChecker::engage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  if (CheckJNICalls && !is_active()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    // start up the periodic task
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _task = new JniPeriodicCheckerTask(10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    _task->enroll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
 * the disengage() method is responsible for deactivating the periodic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 * task. This  method is called from before_exit() in java.cpp and is only called
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 * after the WatcherThread has been stopped.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
void JniPeriodicChecker::disengage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  if (CheckJNICalls && is_active()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    // remove JniPeriodicChecker
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _task->disenroll();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    delete _task;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    _task = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
void jniPeriodicChecker_exit() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  if (!CheckJNICalls) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}