hotspot/src/share/vm/runtime/objectMonitor.cpp
changeset 13728 882756847a04
parent 10739 91935236600e
child 14583 d70ee55535f4
equal deleted inserted replaced
13727:caf5eb7dd4a7 13728:882756847a04
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    67 
    67 
    68 // Only bother with this argument setup if dtrace is available
    68 // Only bother with this argument setup if dtrace is available
    69 // TODO-FIXME: probes should not fire when caller is _blocked.  assert() accordingly.
    69 // TODO-FIXME: probes should not fire when caller is _blocked.  assert() accordingly.
    70 
    70 
    71 
    71 
    72 #define DTRACE_MONITOR_PROBE_COMMON(klassOop, thread)                      \
    72 #define DTRACE_MONITOR_PROBE_COMMON(obj, thread)                           \
    73   char* bytes = NULL;                                                      \
    73   char* bytes = NULL;                                                      \
    74   int len = 0;                                                             \
    74   int len = 0;                                                             \
    75   jlong jtid = SharedRuntime::get_java_tid(thread);                        \
    75   jlong jtid = SharedRuntime::get_java_tid(thread);                        \
    76   Symbol* klassname = ((oop)(klassOop))->klass()->klass_part()->name();    \
    76   Symbol* klassname = ((oop)obj)->klass()->name();                         \
    77   if (klassname != NULL) {                                                 \
    77   if (klassname != NULL) {                                                 \
    78     bytes = (char*)klassname->bytes();                                     \
    78     bytes = (char*)klassname->bytes();                                     \
    79     len = klassname->utf8_length();                                        \
    79     len = klassname->utf8_length();                                        \
    80   }
    80   }
    81 
    81 
    90 HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__entered,
    90 HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__entered,
    91   jlong, uintptr_t, char*, int);
    91   jlong, uintptr_t, char*, int);
    92 HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit,
    92 HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit,
    93   jlong, uintptr_t, char*, int);
    93   jlong, uintptr_t, char*, int);
    94 
    94 
    95 #define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
    95 #define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis)       \
    96   {                                                                        \
    96   {                                                                        \
    97     if (DTraceMonitorProbes) {                                            \
    97     if (DTraceMonitorProbes) {                                            \
    98       DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
    98       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                       \
    99       HS_DTRACE_PROBE5(hotspot, monitor__wait, jtid,                       \
    99       HS_DTRACE_PROBE5(hotspot, monitor__wait, jtid,                       \
   100                        (monitor), bytes, len, (millis));                   \
   100                        (monitor), bytes, len, (millis));                   \
   101     }                                                                      \
   101     }                                                                      \
   102   }
   102   }
   103 
   103 
   104 #define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread)             \
   104 #define DTRACE_MONITOR_PROBE(probe, monitor, obj, thread)             \
   105   {                                                                        \
   105   {                                                                        \
   106     if (DTraceMonitorProbes) {                                            \
   106     if (DTraceMonitorProbes) {                                            \
   107       DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
   107       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                       \
   108       HS_DTRACE_PROBE4(hotspot, monitor__##probe, jtid,                    \
   108       HS_DTRACE_PROBE4(hotspot, monitor__##probe, jtid,                    \
   109                        (uintptr_t)(monitor), bytes, len);                  \
   109                        (uintptr_t)(monitor), bytes, len);                  \
   110     }                                                                      \
   110     }                                                                      \
   111   }
   111   }
   112 
   112 
   113 #else /* USDT2 */
   113 #else /* USDT2 */
   114 
   114 
   115 #define DTRACE_MONITOR_WAIT_PROBE(monitor, klassOop, thread, millis)       \
   115 #define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis)            \
   116   {                                                                        \
   116   {                                                                        \
   117     if (DTraceMonitorProbes) {                                            \
   117     if (DTraceMonitorProbes) {                                            \
   118       DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
   118       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                            \
   119       HOTSPOT_MONITOR_WAIT(jtid,                                           \
   119       HOTSPOT_MONITOR_WAIT(jtid,                                           \
   120                        (monitor), bytes, len, (millis));                   \
   120                        (monitor), bytes, len, (millis));                   \
   121     }                                                                      \
   121     }                                                                      \
   122   }
   122   }
   123 
   123 
   125 #define HOTSPOT_MONITOR_contended__entered HOTSPOT_MONITOR_CONTENDED_ENTERED
   125 #define HOTSPOT_MONITOR_contended__entered HOTSPOT_MONITOR_CONTENDED_ENTERED
   126 #define HOTSPOT_MONITOR_contended__exit HOTSPOT_MONITOR_CONTENDED_EXIT
   126 #define HOTSPOT_MONITOR_contended__exit HOTSPOT_MONITOR_CONTENDED_EXIT
   127 #define HOTSPOT_MONITOR_notify HOTSPOT_MONITOR_NOTIFY
   127 #define HOTSPOT_MONITOR_notify HOTSPOT_MONITOR_NOTIFY
   128 #define HOTSPOT_MONITOR_notifyAll HOTSPOT_MONITOR_NOTIFYALL
   128 #define HOTSPOT_MONITOR_notifyAll HOTSPOT_MONITOR_NOTIFYALL
   129 
   129 
   130 #define DTRACE_MONITOR_PROBE(probe, monitor, klassOop, thread)             \
   130 #define DTRACE_MONITOR_PROBE(probe, monitor, obj, thread)                  \
   131   {                                                                        \
   131   {                                                                        \
   132     if (DTraceMonitorProbes) {                                            \
   132     if (DTraceMonitorProbes) {                                            \
   133       DTRACE_MONITOR_PROBE_COMMON(klassOop, thread);                       \
   133       DTRACE_MONITOR_PROBE_COMMON(obj, thread);                            \
   134       HOTSPOT_MONITOR_##probe(jtid,                                               \
   134       HOTSPOT_MONITOR_##probe(jtid,                                               \
   135                        (uintptr_t)(monitor), bytes, len);                  \
   135                        (uintptr_t)(monitor), bytes, len);                  \
   136     }                                                                      \
   136     }                                                                      \
   137   }
   137   }
   138 
   138 
   139 #endif /* USDT2 */
   139 #endif /* USDT2 */
   140 #else //  ndef DTRACE_ENABLED
   140 #else //  ndef DTRACE_ENABLED
   141 
   141 
   142 #define DTRACE_MONITOR_WAIT_PROBE(klassOop, thread, millis, mon)    {;}
   142 #define DTRACE_MONITOR_WAIT_PROBE(obj, thread, millis, mon)    {;}
   143 #define DTRACE_MONITOR_PROBE(probe, klassOop, thread, mon)          {;}
   143 #define DTRACE_MONITOR_PROBE(probe, obj, thread, mon)          {;}
   144 
   144 
   145 #endif // ndef DTRACE_ENABLED
   145 #endif // ndef DTRACE_ENABLED
   146 
   146 
   147 // Tunables ...
   147 // Tunables ...
   148 // The knob* variables are effectively final.  Once set they should
   148 // The knob* variables are effectively final.  Once set they should