1 /*
   2  * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved.
   3  * 
   4  * This file is part of the Lock Contention Tracing Subsystem for the HotSpot
   5  * Virtual Machine, which is developed at Christian Doppler Laboratory on
   6  * Monitoring and Evolution of Very-Large-Scale Software Systems. Please
   7  * contact us at <http://mevss.jku.at/> if you need additional information
   8  * or have any questions.
   9  *
  10  * This code is free software; you can redistribute it and/or modify it
  11  * under the terms of the GNU General Public License version 2 only, as
  12  * published by the Free Software Foundation.
  13  *
  14  * This code is distributed in the hope that it will be useful, but WITHOUT
  15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  17  * version 2 for more details (a copy is included in the LICENSE file that
  18  * accompanied this code).
  19  *
  20  * You should have received a copy of the GNU General Public License version
  21  * 2 along with this work. If not, see <http://www.gnu.org/licenses/>.
  22  *
  23  */ 
  24 package sun.evtracing.processing.statistics;
  25 
  26 import sun.evtracing.parser.metadata.JavaStack;
  27 import sun.evtracing.parser.metadata.JavaStackFrame;
  28 import sun.evtracing.parser.metadata.JavaThread;
  29 import sun.evtracing.processing.Sanity;
  30 import sun.evtracing.processing.statistics.aggregator.ContentionProcessor;
  31 import sun.evtracing.processing.statistics.metadata.ParkEventTuple;
  32 
  33 public class ParkBlockerReentrantReadWriteLockAnalyser extends ParkBlockerAbstractQueuedSynchronizerAnalyser {
  34         public ParkBlockerReentrantReadWriteLockAnalyser(ContentionProcessor cproc) {
  35                 super(cproc);
  36         }
  37 
  38         @Override
  39         boolean isShared(ParkEventTuple cur) {
  40                 for (JavaStackFrame f : cur.unpark().stack().metadata()) {
  41                         switch (f.method().clazz().name()) {
  42                         case "java/util/concurrent/locks/ReentrantReadWriteLock$ReadLock":
  43                                 return true;
  44                         case "java/util/concurrent/locks/ReentrantReadWriteLock$WriteLock":
  45                                 return false;
  46                         }
  47                 }
  48                 Sanity.warn("unknown lock type, maybe spurious wakeup");
  49                 return false;
  50         }
  51 
  52         @Override
  53         JavaThread sharedThread() {
  54                 return JavaThread.READERS;
  55         }
  56 
  57         @Override
  58         JavaStack sharedSite() {
  59                 return JavaStack.READERS;
  60         }
  61 }