src/share/vm/prims/jvmtiImpl.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6766644 Sdiff src/share/vm/prims

src/share/vm/prims/jvmtiImpl.cpp

Print this page
rev 2029 : 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
Summary: Defer posting events from the compiler thread -- use service thread
Reviewed-by:
* * *
   1 /*
   2  * Copyright (c) 2003, 2010, 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  *


 893 #ifndef PRODUCT
 894   MutexLocker mu(Threads_lock);
 895   ResourceMark rm;
 896 
 897   tty->print("Suspended Threads: [");
 898   for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
 899 #if JVMTI_TRACE
 900     const char *name   = JvmtiTrace::safe_get_thread_name(thread);
 901 #else
 902     const char *name   = "";
 903 #endif /*JVMTI_TRACE */
 904     tty->print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
 905     if (!thread->has_last_Java_frame()) {
 906       tty->print("no stack");
 907     }
 908     tty->print(") ");
 909   }
 910   tty->print_cr("]");
 911 #endif
 912 }








































































   1 /*
   2  * Copyright (c) 2003, 2011, 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  *


 893 #ifndef PRODUCT
 894   MutexLocker mu(Threads_lock);
 895   ResourceMark rm;
 896 
 897   tty->print("Suspended Threads: [");
 898   for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
 899 #if JVMTI_TRACE
 900     const char *name   = JvmtiTrace::safe_get_thread_name(thread);
 901 #else
 902     const char *name   = "";
 903 #endif /*JVMTI_TRACE */
 904     tty->print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
 905     if (!thread->has_last_Java_frame()) {
 906       tty->print("no stack");
 907     }
 908     tty->print(") ");
 909   }
 910   tty->print_cr("]");
 911 #endif
 912 }
 913 
 914 #ifndef KERNEL
 915 
 916 void JvmtiDeferredEvent::post() {
 917   switch(_type) {
 918     case TYPE_COMPILED_METHOD_LOAD:
 919       JvmtiExport::post_compiled_method_load(compiled_method_loaded());
 920       break;
 921     default:
 922       ShouldNotReachHere();
 923   }
 924 }
 925 
 926 JvmtiDeferredEventQueue::QueueNode* JvmtiDeferredEventQueue::_free_list = NULL;
 927 JvmtiDeferredEventQueue::QueueNode* JvmtiDeferredEventQueue::_queue = NULL;
 928 
 929 bool JvmtiDeferredEventQueue::has_events() {
 930   return _queue != NULL;
 931 }
 932 
 933 void JvmtiDeferredEventQueue::enqueue(const JvmtiDeferredEvent& event) {
 934   assert(Service_lock->owned_by_self(), "Must own Service_lock");
 935 
 936   QueueNode* node = _free_list;
 937   if (node == NULL) {
 938     node = new QueueNode();
 939   } else {
 940     _free_list = node->next();
 941   }
 942 
 943   node->set_event(event);
 944   node->set_next(_queue);
 945 
 946   _queue = node;
 947 
 948   Service_lock->notify_all();
 949 }
 950 
 951 JvmtiDeferredEvent JvmtiDeferredEventQueue::dequeue() {
 952   assert(Service_lock->owned_by_self(), "Must own Service_lock");
 953   assert(_queue != NULL, "Nothing to dequeue");
 954 
 955   if (_queue == NULL) {
 956     // Just in case this happens in product; it shouldn't be let's not crash
 957     return JvmtiDeferredEvent::null_event();
 958   }
 959 
 960   // Events need to be processed in FIFO order, so take the last event.
 961   QueueNode* node = _queue->next();
 962   if (node == NULL) {
 963     // Only one item in the queue
 964     node = _queue;
 965     _queue = NULL;
 966   } else {
 967     QueueNode* prev = _queue;
 968     while (node->next() != NULL) {
 969       prev = node;
 970       node = node->next();
 971     }
 972     prev->set_next(NULL);
 973   }
 974 
 975   JvmtiDeferredEvent event = node->event();
 976 
 977   // Stick the node on the freelist for reuse.
 978   node->set_next(_free_list);
 979   _free_list = node;
 980 
 981   return event;
 982 }
 983 
 984 #endif // ndef KERNEL
src/share/vm/prims/jvmtiImpl.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File