kvn@6429: /* kvn@6429: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. kvn@6429: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. kvn@6429: * kvn@6429: * This code is free software; you can redistribute it and/or modify it kvn@6429: * under the terms of the GNU General Public License version 2 only, as kvn@6429: * published by the Free Software Foundation. kvn@6429: * kvn@6429: * This code is distributed in the hope that it will be useful, but WITHOUT kvn@6429: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or kvn@6429: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License kvn@6429: * version 2 for more details (a copy is included in the LICENSE file that kvn@6429: * accompanied this code). kvn@6429: * kvn@6429: * You should have received a copy of the GNU General Public License version kvn@6429: * 2 along with this work; if not, write to the Free Software Foundation, kvn@6429: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. kvn@6429: * kvn@6429: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA kvn@6429: * or visit www.oracle.com if you need additional information or have any kvn@6429: * questions. kvn@6429: * kvn@6429: */ kvn@6429: kvn@6429: #include "precompiled.hpp" kvn@6430: #include "memory/allocation.inline.hpp" kvn@6429: #include "runtime/task.hpp" kvn@6429: #include "runtime/rtmLocking.hpp" kvn@6429: kvn@6429: // One-shot PeriodicTask subclass for enabling RTM locking kvn@6429: uintx RTMLockingCounters::_calculation_flag = 0; kvn@6429: kvn@6429: class RTMLockingCalculationTask : public PeriodicTask { kvn@6429: public: kvn@6429: RTMLockingCalculationTask(size_t interval_time) : PeriodicTask(interval_time){ } kvn@6429: kvn@6429: virtual void task() { kvn@6429: RTMLockingCounters::_calculation_flag = 1; kvn@6429: // Reclaim our storage and disenroll ourself kvn@6429: delete this; kvn@6429: } kvn@6429: }; kvn@6429: kvn@6429: void RTMLockingCounters::init() { kvn@6429: if (UseRTMLocking && RTMLockingCalculationDelay > 0) { kvn@6429: RTMLockingCalculationTask* task = new RTMLockingCalculationTask(RTMLockingCalculationDelay); kvn@6429: task->enroll(); kvn@6429: } else { kvn@6429: _calculation_flag = 1; kvn@6429: } kvn@6429: } kvn@6429: kvn@6429: //------------------------------print_on------------------------------- kvn@6429: void RTMLockingCounters::print_on(outputStream* st) { kvn@6429: tty->print_cr("# rtm locks total (estimated): " UINTX_FORMAT, _total_count * RTMTotalCountIncrRate); kvn@6429: tty->print_cr("# rtm lock aborts : " UINTX_FORMAT, _abort_count); kvn@6429: for (int i = 0; i < ABORT_STATUS_LIMIT; i++) { kvn@6429: tty->print_cr("# rtm lock aborts %d: " UINTX_FORMAT, i, _abortX_count[i]); kvn@6429: } kvn@6429: }