hotspot/src/cpu/x86/vm/rtmLocking.cpp
author duke
Wed, 05 Jul 2017 20:10:48 +0200
changeset 27963 88d7c7c376e9
parent 23494 950d6469ff05
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23491
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     1
/*
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     4
 *
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     8
 *
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    13
 * accompanied this code).
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    14
 *
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    18
 *
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    21
 * questions.
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    22
 *
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    23
 */
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    24
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    25
#include "precompiled.hpp"
23494
950d6469ff05 8038181: Can't build product VM without precompiled header
kvn
parents: 23491
diff changeset
    26
#include "memory/allocation.inline.hpp"
23491
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    27
#include "runtime/task.hpp"
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    28
#include "runtime/rtmLocking.hpp"
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    29
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    30
// One-shot PeriodicTask subclass for enabling RTM locking
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    31
uintx RTMLockingCounters::_calculation_flag = 0;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    32
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    33
class RTMLockingCalculationTask : public PeriodicTask {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    34
 public:
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    35
  RTMLockingCalculationTask(size_t interval_time) : PeriodicTask(interval_time){  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    36
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    37
  virtual void task() {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    38
    RTMLockingCounters::_calculation_flag = 1;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    39
    // Reclaim our storage and disenroll ourself
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    40
    delete this;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    41
  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    42
};
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    43
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    44
void RTMLockingCounters::init() {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    45
  if (UseRTMLocking && RTMLockingCalculationDelay > 0) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    46
    RTMLockingCalculationTask* task = new RTMLockingCalculationTask(RTMLockingCalculationDelay);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    47
    task->enroll();
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    48
  } else {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    49
    _calculation_flag = 1;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    50
  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    51
}
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    52
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    53
//------------------------------print_on-------------------------------
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    54
void RTMLockingCounters::print_on(outputStream* st) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    55
  tty->print_cr("# rtm locks total (estimated): " UINTX_FORMAT, _total_count * RTMTotalCountIncrRate);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    56
  tty->print_cr("# rtm lock aborts  : " UINTX_FORMAT, _abort_count);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    57
  for (int i = 0; i < ABORT_STATUS_LIMIT; i++) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    58
    tty->print_cr("# rtm lock aborts %d: " UINTX_FORMAT, i, _abortX_count[i]);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    59
  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    60
}