src/share/vm/prims/jvmtiImpl.hpp
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.hpp

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) 1999, 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  *


 416 //
 417 // Convenience routines for suspending and resuming threads.
 418 //
 419 // All attempts by JVMTI to suspend and resume threads must go through the
 420 // JvmtiSuspendControl interface.
 421 //
 422 // methods return true if successful
 423 //
 424 class JvmtiSuspendControl : public AllStatic {
 425 public:
 426   // suspend the thread, taking it to a safepoint
 427   static bool suspend(JavaThread *java_thread);
 428   // resume the thread
 429   static bool resume(JavaThread *java_thread);
 430 
 431   static void print();
 432 };
 433 
 434 #endif // !JVMTI_KERNEL
 435 

















































































 436 // Utility macro that checks for NULL pointers:
 437 #define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }
 438 
 439 #endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP
   1 /*
   2  * Copyright (c) 1999, 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  *


 416 //
 417 // Convenience routines for suspending and resuming threads.
 418 //
 419 // All attempts by JVMTI to suspend and resume threads must go through the
 420 // JvmtiSuspendControl interface.
 421 //
 422 // methods return true if successful
 423 //
 424 class JvmtiSuspendControl : public AllStatic {
 425 public:
 426   // suspend the thread, taking it to a safepoint
 427   static bool suspend(JavaThread *java_thread);
 428   // resume the thread
 429   static bool resume(JavaThread *java_thread);
 430 
 431   static void print();
 432 };
 433 
 434 #endif // !JVMTI_KERNEL
 435 
 436 /**
 437  * When a thread (such as the compiler thread or VM thread) cannot post a
 438  * JVMTI event itself because the event needs to be posted from a Java
 439  * thread, then it can defer the event to the Service thread for posting.
 440  * The information needed to post the event is encapsulated into this class
 441  * and then enqueued onto the JvmtiDeferredEventQueue, where the Service
 442  * thread will pick it up and post it.
 443  *
 444  * This is currently only used for posting compiled-method-load events, which
 445  * we don't want posted from the compiler thread.
 446  */
 447 class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
 448  private:
 449   typedef enum { TYPE_NONE, TYPE_COMPILED_METHOD_LOAD } Type;
 450 
 451   Type _type;
 452   union {
 453     nmethod* _compiled_method_loaded;
 454   } _event_data;
 455 
 456   JvmtiDeferredEvent() : _type(TYPE_NONE) {}
 457   JvmtiDeferredEvent(Type t) : _type(t) {}
 458 
 459   void set_compiled_method_loaded(nmethod* nm) {
 460     assert(_type == TYPE_COMPILED_METHOD_LOAD, "must be");
 461     _event_data._compiled_method_loaded = nm;
 462   }
 463 
 464   nmethod* compiled_method_loaded() const {
 465     assert(_type == TYPE_COMPILED_METHOD_LOAD, "must be");
 466     return _event_data._compiled_method_loaded;
 467   }
 468 
 469  public:
 470 
 471   static JvmtiDeferredEvent null_event() {
 472     return JvmtiDeferredEvent();
 473   }
 474 
 475   static JvmtiDeferredEvent compiled_method_load(nmethod* nm) {
 476     JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD);
 477     event.set_compiled_method_loaded(nm);
 478     return event;
 479   }
 480 
 481   // Actually posts the event.
 482   void post();
 483 };
 484 
 485 /**
 486  * Events enqueued on this queue wake up the Service thread which dequeues
 487  * and posts the events.  The Service_lock is required to be held
 488  * when enqueuing.
 489  */
 490 class JvmtiDeferredEventQueue : AllStatic {
 491  private:
 492   class QueueNode : public CHeapObj {
 493    private:
 494     JvmtiDeferredEvent _event;
 495     QueueNode* _next;
 496 
 497    public:
 498     QueueNode() : _event(JvmtiDeferredEvent::null_event()), _next(NULL) {}
 499 
 500     const JvmtiDeferredEvent& event() const { return _event; }
 501     QueueNode* next() const { return _next; }
 502 
 503     void set_event(const JvmtiDeferredEvent& ev) { _event = ev; }
 504     void set_next(QueueNode* next) { _next = next; }
 505   };
 506 
 507   static QueueNode* _queue;
 508   static QueueNode* _free_list;
 509 
 510  public:
 511   // Must be holding Service_lock when calling these
 512   static bool has_events() KERNEL_RETURN_(false);
 513   static void enqueue(const JvmtiDeferredEvent& event) KERNEL_RETURN;
 514   static JvmtiDeferredEvent dequeue() KERNEL_RETURN;
 515 };
 516 
 517 // Utility macro that checks for NULL pointers:
 518 #define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }
 519 
 520 #endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP
src/share/vm/prims/jvmtiImpl.hpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File