src/cpu/x86/vm/rtmLocking.cpp

Thu, 20 Mar 2014 17:49:27 -0700

author
kvn
date
Thu, 20 Mar 2014 17:49:27 -0700
changeset 6429
606acabe7b5c
child 6430
52b37289e3be
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

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

mercurial