hotspot/src/share/vm/runtime/rtmLocking.cpp
author coleenp
Wed, 28 Oct 2015 09:47:23 -0400
changeset 33611 9abd65805e19
parent 30221 70dab4a0cd45
child 42040 70ec5a09a0d5
permissions -rw-r--r--
8139203: Consistent naming for klass type predicates 8138923: Remove oop coupling with InstanceKlass subclasses Summary: Renamed oop_is_instance and friends, removed the functions in oop that dug down into InstanceKlass. Reviewed-by: jrose, lfoltan, stefank
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"
70dab4a0cd45 8077618: Move rtmLocking.cpp to shared directory.
goetz
parents:
diff changeset
    26
#include "utilities/globalDefinitions.hpp"
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