< prev index next >

src/hotspot/share/runtime/vframe.cpp

Print this page
rev 59077 : 8153224.v2.09b.patch combined with 8153224.v2.10.patch; merge with jdk-15+21.
rev 59078 : eosterlund v2.10 CR: reorganize deflate_monitor_using_JT() to use "early exit" style; dcubed - clarify/fix/rearrange a few comments in deflate_monitor_using_JT(); eosterlund v2.10 CR: simplify install_displaced_markword_in_object() and save_om_ptr(); save_om_ptr()'s call to install_displaced_markword_in_object() can race with the deflater thread's clearing of the object field so handle that; fold 8153224.OMHandle_experiment into 8153224.v2.11.patch; merge with jdk-15+21.
   1 /*
   2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 105 javaVFrame* vframe::java_sender() const {
 106   vframe* f = sender();
 107   while (f != NULL) {
 108     if (f->is_java_frame()) return javaVFrame::cast(f);
 109     f = f->sender();
 110   }
 111   return NULL;
 112 }
 113 
 114 // ------------- javaVFrame --------------
 115 
 116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
 117   assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
 118          "must be at safepoint or it's a java frame of the current thread");
 119 
 120   GrowableArray<MonitorInfo*>* mons = monitors();
 121   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
 122   if (mons->is_empty()) return result;
 123 
 124   bool found_first_monitor = false;
 125   ObjectMonitor *pending_monitor = thread()->current_pending_monitor();


 126   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();




 127   oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
 128   oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
 129 
 130   for (int index = (mons->length()-1); index >= 0; index--) {
 131     MonitorInfo* monitor = mons->at(index);
 132     if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
 133     oop obj = monitor->owner();
 134     if (obj == NULL) continue; // skip unowned monitor
 135     //
 136     // Skip the monitor that the thread is blocked to enter or waiting on
 137     //
 138     if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
 139       continue;
 140     }
 141     found_first_monitor = true;
 142     result->append(monitor);
 143   }
 144   return result;
 145 }
 146 


 214           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 215         } else {
 216           Handle obj(THREAD, monitor->owner());
 217           if (obj() != NULL) {
 218             print_locked_object_class_name(st, obj, "eliminated");
 219           }
 220         }
 221         continue;
 222       }
 223       if (monitor->owner() != NULL) {
 224         // the monitor is associated with an object, i.e., it is locked
 225 
 226         const char *lock_state = "locked"; // assume we have the monitor locked
 227         if (!found_first_monitor && frame_count == 0) {
 228           // If this is the first frame and we haven't found an owned
 229           // monitor before, then we need to see if we have completed
 230           // the lock or if we are blocked trying to acquire it. Only
 231           // an inflated monitor that is first on the monitor list in
 232           // the first frame can block us on a monitor enter.
 233           markWord mark = monitor->owner()->mark();


 234           if (mark.has_monitor() &&
 235               ( // we have marked ourself as pending on this monitor
 236                 mark.monitor() == thread()->current_pending_monitor() ||
 237                 // we are not the owner of this monitor
 238                 !mark.monitor()->is_entered(thread())
 239               )) {
 240             lock_state = "waiting to lock";
 241           }
 242         }
 243         print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
 244 
 245         found_first_monitor = true;
 246       }
 247     }
 248   }
 249 }
 250 
 251 // ------------- interpretedVFrame --------------
 252 
 253 u_char* interpretedVFrame::bcp() const {


   1 /*
   2  * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 105 javaVFrame* vframe::java_sender() const {
 106   vframe* f = sender();
 107   while (f != NULL) {
 108     if (f->is_java_frame()) return javaVFrame::cast(f);
 109     f = f->sender();
 110   }
 111   return NULL;
 112 }
 113 
 114 // ------------- javaVFrame --------------
 115 
 116 GrowableArray<MonitorInfo*>* javaVFrame::locked_monitors() {
 117   assert(SafepointSynchronize::is_at_safepoint() || JavaThread::current() == thread(),
 118          "must be at safepoint or it's a java frame of the current thread");
 119 
 120   GrowableArray<MonitorInfo*>* mons = monitors();
 121   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(mons->length());
 122   if (mons->is_empty()) return result;
 123 
 124   bool found_first_monitor = false;
 125   // The ObjectMonitor* can't be async deflated since we are either
 126   // at a safepoint or the calling thread is operating on itself so
 127   // it cannot leave the underlying wait()/enter() call.
 128   ObjectMonitor *waiting_monitor = thread()->current_waiting_monitor();
 129   ObjectMonitor *pending_monitor = NULL;
 130   if (waiting_monitor == NULL) {
 131     pending_monitor = thread()->current_pending_monitor();
 132   }
 133   oop pending_obj = (pending_monitor != NULL ? (oop) pending_monitor->object() : (oop) NULL);
 134   oop waiting_obj = (waiting_monitor != NULL ? (oop) waiting_monitor->object() : (oop) NULL);
 135 
 136   for (int index = (mons->length()-1); index >= 0; index--) {
 137     MonitorInfo* monitor = mons->at(index);
 138     if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
 139     oop obj = monitor->owner();
 140     if (obj == NULL) continue; // skip unowned monitor
 141     //
 142     // Skip the monitor that the thread is blocked to enter or waiting on
 143     //
 144     if (!found_first_monitor && (obj == pending_obj || obj == waiting_obj)) {
 145       continue;
 146     }
 147     found_first_monitor = true;
 148     result->append(monitor);
 149   }
 150   return result;
 151 }
 152 


 220           st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
 221         } else {
 222           Handle obj(THREAD, monitor->owner());
 223           if (obj() != NULL) {
 224             print_locked_object_class_name(st, obj, "eliminated");
 225           }
 226         }
 227         continue;
 228       }
 229       if (monitor->owner() != NULL) {
 230         // the monitor is associated with an object, i.e., it is locked
 231 
 232         const char *lock_state = "locked"; // assume we have the monitor locked
 233         if (!found_first_monitor && frame_count == 0) {
 234           // If this is the first frame and we haven't found an owned
 235           // monitor before, then we need to see if we have completed
 236           // the lock or if we are blocked trying to acquire it. Only
 237           // an inflated monitor that is first on the monitor list in
 238           // the first frame can block us on a monitor enter.
 239           markWord mark = monitor->owner()->mark();
 240           // The first stage of async deflation does not affect any field
 241           // used by this comparison so the ObjectMonitor* is usable here.
 242           if (mark.has_monitor() &&
 243               ( // we have marked ourself as pending on this monitor
 244                 mark.monitor() == thread()->current_pending_monitor() ||
 245                 // we are not the owner of this monitor
 246                 !mark.monitor()->is_entered(thread())
 247               )) {
 248             lock_state = "waiting to lock";
 249           }
 250         }
 251         print_locked_object_class_name(st, Handle(THREAD, monitor->owner()), lock_state);
 252 
 253         found_first_monitor = true;
 254       }
 255     }
 256   }
 257 }
 258 
 259 // ------------- interpretedVFrame --------------
 260 
 261 u_char* interpretedVFrame::bcp() const {


< prev index next >