< prev index next >

src/hotspot/share/runtime/interfaceSupport.inline.hpp

Print this page




   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
  26 #define SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
  27 
  28 #include "gc/shared/gcLocker.hpp"
  29 #include "runtime/handles.inline.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "runtime/orderAccess.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/safepointMechanism.inline.hpp"
  34 #include "runtime/thread.inline.hpp"
  35 #include "runtime/vmThread.hpp"
  36 #include "utilities/globalDefinitions.hpp"
  37 #include "utilities/macros.hpp"
  38 #include "utilities/preserveException.hpp"
  39 
  40 // Wrapper for all entry points to the virtual machine.
  41 // The HandleMarkCleaner is a faster version of HandleMark.
  42 // It relies on the fact that there is a HandleMark further
  43 // down the stack (in JavaCalls::call_helper), and just resets
  44 // to the saved values in that HandleMark.
  45 
  46 class HandleMarkCleaner: public StackObj {
  47  private:
  48   Thread* _thread;
  49  public:
  50   HandleMarkCleaner(Thread* thread) {
  51     _thread = thread;
  52     _thread->last_handle_mark()->push();
  53   }
  54   ~HandleMarkCleaner() {
  55     _thread->last_handle_mark()->pop_and_restore();
  56   }
  57 
  58  private:
  59   inline void* operator new(size_t size, void* ptr) throw() {
  60     return ptr;
  61   }
  62 };
  63 
  64 // InterfaceSupport provides functionality used by the VM_LEAF_BASE and
  65 // VM_ENTRY_BASE macros. These macros are used to guard entry points into
  66 // the VM and perform checks upon leave of the VM.
  67 
  68 
  69 class InterfaceSupport: AllStatic {
  70 # ifdef ASSERT
  71  public:
  72   static long _scavenge_alot_counter;
  73   static long _fullgc_alot_counter;
  74   static long _number_of_calls;
  75   static long _fullgc_alot_invocation;
  76 
  77   // Helper methods used to implement +ScavengeALot and +FullGCALot
  78   static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
  79   static void gc_alot();
  80 
  81   static void walk_stack_from(vframe* start_vf);
  82   static void walk_stack();


 340     // NOTE: We do not check for pending. async. exceptions.
 341     // If we did and moved the pending async exception over into the
 342     // pending exception field, we would need to deopt (currently C2
 343     // only). However, to do so would require that we transition back
 344     // to the _thread_in_vm state. Instead we postpone the handling of
 345     // the async exception.
 346 
 347 
 348     // Check for pending. suspends only.
 349     if (_thread->has_special_runtime_exit_condition())
 350       _thread->handle_special_runtime_exit_condition(false);
 351   }
 352 };
 353 
 354 // Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
 355 // Can be used to verify properties on enter/exit of the VM.
 356 
 357 #ifdef ASSERT
 358 class VMEntryWrapper {
 359  public:
 360   VMEntryWrapper() {
 361     if (VerifyLastFrame) {
 362       InterfaceSupport::verify_last_frame();
 363     }
 364   }
 365 
 366   ~VMEntryWrapper() {
 367     InterfaceSupport::check_gc_alot();
 368     if (WalkStackALot) {
 369       InterfaceSupport::walk_stack();
 370     }
 371 #ifdef COMPILER2
 372     // This option is not used by Compiler 1
 373     if (StressDerivedPointers) {
 374       InterfaceSupport::stress_derived_pointers();
 375     }
 376 #endif
 377     if (DeoptimizeALot || DeoptimizeRandom) {
 378       InterfaceSupport::deoptimizeAll();
 379     }
 380     if (ZombieALot) {
 381       InterfaceSupport::zombieAll();
 382     }
 383     if (UnlinkSymbolsALot) {
 384       InterfaceSupport::unlinkSymbols();
 385     }
 386     // do verification AFTER potential deoptimization
 387     if (VerifyStack) {
 388       InterfaceSupport::verify_stack();
 389     }
 390 
 391   }
 392 };
 393 
 394 
 395 class VMNativeEntryWrapper {
 396  public:
 397   VMNativeEntryWrapper() {
 398     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
 399   }
 400 
 401   ~VMNativeEntryWrapper() {
 402     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
 403   }
 404 };
 405 
 406 #endif
 407 
 408 
 409 // VM-internal runtime interface support
 410 
 411 #ifdef ASSERT


 603     VM_QUICK_ENTRY_BASE(result_type, header, thread)
 604 
 605 
 606 #define JVM_LEAF(result_type, header)                                \
 607 extern "C" {                                                         \
 608   result_type JNICALL header {                                       \
 609     VM_Exit::block_if_vm_exited();                                   \
 610     VM_LEAF_BASE(result_type, header)
 611 
 612 
 613 #define JVM_ENTRY_FROM_LEAF(env, result_type, header)                \
 614   { {                                                                \
 615     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
 616     ThreadInVMfromNative __tiv(thread);                              \
 617     debug_only(VMNativeEntryWrapper __vew;)                          \
 618     VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread)
 619 
 620 
 621 #define JVM_END } }
 622 
 623 #endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_INLINE_HPP
  26 #define SHARE_VM_RUNTIME_INTERFACESUPPORT_INLINE_HPP
  27 
  28 #include "gc/shared/gcLocker.hpp"
  29 #include "runtime/handles.inline.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "runtime/orderAccess.hpp"
  32 #include "runtime/os.hpp"
  33 #include "runtime/safepointMechanism.inline.hpp"
  34 #include "runtime/thread.hpp"

  35 #include "utilities/globalDefinitions.hpp"
  36 #include "utilities/macros.hpp"
  37 #include "utilities/preserveException.hpp"
  38 
  39 // Wrapper for all entry points to the virtual machine.






















  40 
  41 // InterfaceSupport provides functionality used by the VM_LEAF_BASE and
  42 // VM_ENTRY_BASE macros. These macros are used to guard entry points into
  43 // the VM and perform checks upon leave of the VM.
  44 
  45 
  46 class InterfaceSupport: AllStatic {
  47 # ifdef ASSERT
  48  public:
  49   static long _scavenge_alot_counter;
  50   static long _fullgc_alot_counter;
  51   static long _number_of_calls;
  52   static long _fullgc_alot_invocation;
  53 
  54   // Helper methods used to implement +ScavengeALot and +FullGCALot
  55   static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
  56   static void gc_alot();
  57 
  58   static void walk_stack_from(vframe* start_vf);
  59   static void walk_stack();


 317     // NOTE: We do not check for pending. async. exceptions.
 318     // If we did and moved the pending async exception over into the
 319     // pending exception field, we would need to deopt (currently C2
 320     // only). However, to do so would require that we transition back
 321     // to the _thread_in_vm state. Instead we postpone the handling of
 322     // the async exception.
 323 
 324 
 325     // Check for pending. suspends only.
 326     if (_thread->has_special_runtime_exit_condition())
 327       _thread->handle_special_runtime_exit_condition(false);
 328   }
 329 };
 330 
 331 // Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
 332 // Can be used to verify properties on enter/exit of the VM.
 333 
 334 #ifdef ASSERT
 335 class VMEntryWrapper {
 336  public:
 337   VMEntryWrapper();
 338   ~VMEntryWrapper();






























 339 };
 340 
 341 
 342 class VMNativeEntryWrapper {
 343  public:
 344   VMNativeEntryWrapper() {
 345     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
 346   }
 347 
 348   ~VMNativeEntryWrapper() {
 349     if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
 350   }
 351 };
 352 
 353 #endif
 354 
 355 
 356 // VM-internal runtime interface support
 357 
 358 #ifdef ASSERT


 550     VM_QUICK_ENTRY_BASE(result_type, header, thread)
 551 
 552 
 553 #define JVM_LEAF(result_type, header)                                \
 554 extern "C" {                                                         \
 555   result_type JNICALL header {                                       \
 556     VM_Exit::block_if_vm_exited();                                   \
 557     VM_LEAF_BASE(result_type, header)
 558 
 559 
 560 #define JVM_ENTRY_FROM_LEAF(env, result_type, header)                \
 561   { {                                                                \
 562     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
 563     ThreadInVMfromNative __tiv(thread);                              \
 564     debug_only(VMNativeEntryWrapper __vew;)                          \
 565     VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread)
 566 
 567 
 568 #define JVM_END } }
 569 
 570 #endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_INLINE_HPP
< prev index next >