src/hotspot/share/runtime/rtmLocking.cpp
author dholmes
Sat, 23 Jun 2018 01:32:41 -0400
changeset 50735 2f2af62dfac7
parent 47216 71c04702a3d5
child 54807 33fe50b6d707
permissions -rw-r--r--
8010319: Implementation of JEP 181: Nest-Based Access Control Reviewed-by: alanb, psandoz, mchung, coleenp, acorn, mcimadamore, forax, jlahoda, sspitsyn, abuckley Contributed-by: alex.buckley@oracle.com, maurizio.mimadamore@oracle.com, mandy.chung@oracle.com, tobias.hartmann@oracle.com, david.holmes@oracle.com, vladimir.x.ivanov@oracle.com, karen.kinnear@oracle.com, vladimir.kozlov@oracle.com, john.r.rose@oracle.com, daniel.smith@oracle.com, serguei.spitsyn@oracle.com, kumardotsrinivasan@gmail.com, boris.ulasevich@bell-sw.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30221
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     1
/*
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     4
 *
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     8
 *
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    13
 * accompanied this code).
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    14
 *
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    18
 *
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    21
 * questions.
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    22
 *
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    23
 */
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    24
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    25
#include "precompiled.hpp"
42040
70ec5a09a0d5 8166377: is_compiled_by_jvmci hot in some profiles - improve nmethod compiler type detection
neliasso
parents: 30221
diff changeset
    26
#include "compiler/compilerDefinitions.hpp"
30221
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    27
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    28
#if INCLUDE_RTM_OPT
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    29
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    30
#include "memory/allocation.inline.hpp"
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    31
#include "runtime/task.hpp"
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    32
#include "runtime/rtmLocking.hpp"
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    33
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    34
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    35
// One-shot PeriodicTask subclass for enabling RTM locking
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    36
uintx RTMLockingCounters::_calculation_flag = 0;
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    37
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    38
class RTMLockingCalculationTask : public PeriodicTask {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    39
 public:
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    40
  RTMLockingCalculationTask(size_t interval_time) : PeriodicTask(interval_time){  }
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    41
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    42
  virtual void task() {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    43
    RTMLockingCounters::_calculation_flag = 1;
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    44
    // Reclaim our storage and disenroll ourself
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    45
    delete this;
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    46
  }
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    47
};
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    48
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    49
void RTMLockingCounters::init() {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    50
  if (UseRTMLocking && RTMLockingCalculationDelay > 0) {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    51
    RTMLockingCalculationTask* task = new RTMLockingCalculationTask(RTMLockingCalculationDelay);
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    52
    task->enroll();
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    53
  } else {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    54
    _calculation_flag = 1;
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    55
  }
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    56
}
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    57
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    58
//------------------------------print_on-------------------------------
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    59
void RTMLockingCounters::print_on(outputStream* st) {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    60
  tty->print_cr("# rtm locks total (estimated): " UINTX_FORMAT, _total_count * RTMTotalCountIncrRate);
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    61
  tty->print_cr("# rtm lock aborts  : " UINTX_FORMAT, _abort_count);
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    62
  for (int i = 0; i < ABORT_STATUS_LIMIT; i++) {
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    63
    tty->print_cr("# rtm lock aborts %d: " UINTX_FORMAT, i, _abortX_count[i]);
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    64
  }
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    65
}
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    66
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    67
#endif