hotspot/src/cpu/x86/vm/rtmLocking.cpp
author kvn
Thu, 20 Mar 2014 17:49:27 -0700
changeset 23491 f690330b10b9
child 23494 950d6469ff05
permissions -rw-r--r--
8031320: Use Intel RTM instructions for locks Summary: Use RTM for inflated locks and stack locks. Reviewed-by: iveresov, twisti, roland, dcubed
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"
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    26
#include "runtime/task.hpp"
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    27
#include "runtime/rtmLocking.hpp"
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    28
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    29
// One-shot PeriodicTask subclass for enabling RTM locking
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    30
uintx RTMLockingCounters::_calculation_flag = 0;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    31
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    32
class RTMLockingCalculationTask : public PeriodicTask {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    33
 public:
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    34
  RTMLockingCalculationTask(size_t interval_time) : PeriodicTask(interval_time){  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    35
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    36
  virtual void task() {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    37
    RTMLockingCounters::_calculation_flag = 1;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    38
    // Reclaim our storage and disenroll ourself
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    39
    delete this;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    40
  }
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
void RTMLockingCounters::init() {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    44
  if (UseRTMLocking && RTMLockingCalculationDelay > 0) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    45
    RTMLockingCalculationTask* task = new RTMLockingCalculationTask(RTMLockingCalculationDelay);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    46
    task->enroll();
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    47
  } else {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    48
    _calculation_flag = 1;
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    49
  }
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
//------------------------------print_on-------------------------------
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    53
void RTMLockingCounters::print_on(outputStream* st) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    54
  tty->print_cr("# rtm locks total (estimated): " UINTX_FORMAT, _total_count * RTMTotalCountIncrRate);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    55
  tty->print_cr("# rtm lock aborts  : " UINTX_FORMAT, _abort_count);
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    56
  for (int i = 0; i < ABORT_STATUS_LIMIT; i++) {
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    57
    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
    58
  }
f690330b10b9 8031320: Use Intel RTM instructions for locks
kvn
parents:
diff changeset
    59
}