src/share/vm/runtime/interfaceSupport.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2007, 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  *
  23  */
  24 























  25 // Wrapper for all entry points to the virtual machine.
  26 // The HandleMarkCleaner is a faster version of HandleMark.
  27 // It relies on the fact that there is a HandleMark further
  28 // down the stack (in JavaCalls::call_helper), and just resets
  29 // to the saved values in that HandleMark.
  30 
  31 class HandleMarkCleaner: public StackObj {
  32  private:
  33   Thread* _thread;
  34  public:
  35   HandleMarkCleaner(Thread* thread) {
  36     _thread = thread;
  37     _thread->last_handle_mark()->push();
  38   }
  39   ~HandleMarkCleaner() {
  40     _thread->last_handle_mark()->pop_and_restore();
  41   }
  42 
  43  private:
  44   inline void* operator new(size_t size, void* ptr) {


  65   // Helper methods used to implement +ScavengeALot and +FullGCALot
  66   static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
  67   static void gc_alot();
  68 
  69   static void walk_stack_from(vframe* start_vf);
  70   static void walk_stack();
  71 
  72 # ifdef ENABLE_ZAP_DEAD_LOCALS
  73   static void zap_dead_locals_old();
  74 # endif
  75 
  76   static void zombieAll();
  77   static void deoptimizeAll();
  78   static void stress_derived_pointers();
  79   static void verify_stack();
  80   static void verify_last_frame();
  81 # endif
  82 
  83  public:
  84   // OS dependent stuff
  85   #include "incls/_interfaceSupport_pd.hpp.incl"









  86 };
  87 
  88 
  89 // Basic class for all thread transition classes.
  90 
  91 class ThreadStateTransition : public StackObj {
  92  protected:
  93   JavaThread* _thread;
  94  public:
  95   ThreadStateTransition(JavaThread *thread) {
  96     _thread = thread;
  97     assert(thread != NULL && thread->is_Java_thread(), "must be Java thread");
  98   }
  99 
 100   // Change threadstate in a manner, so safepoint can detect changes.
 101   // Time-critical: called on exit from every runtime routine
 102   static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
 103     assert(from != _thread_in_Java, "use transition_from_java");
 104     assert(from != _thread_in_native, "use transition_from_native");
 105     assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");


 549     __ENTRY(result_type, header, thread)
 550 
 551 
 552 #define JVM_QUICK_ENTRY(result_type, header)                         \
 553 extern "C" {                                                         \
 554   result_type JNICALL header {                                       \
 555     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
 556     ThreadInVMfromNative __tiv(thread);                              \
 557     debug_only(VMNativeEntryWrapper __vew;)                          \
 558     __QUICK_ENTRY(result_type, header, thread)
 559 
 560 
 561 #define JVM_LEAF(result_type, header)                                \
 562 extern "C" {                                                         \
 563   result_type JNICALL header {                                       \
 564     VM_Exit::block_if_vm_exited();                                   \
 565     __LEAF(result_type, header)
 566 
 567 
 568 #define JVM_END } }


   1 /*
   2  * Copyright (c) 1997, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
  26 #define SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
  27 
  28 #include "memory/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/safepoint.hpp"
  34 #include "runtime/vmThread.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 #include "utilities/preserveException.hpp"
  37 #include "utilities/top.hpp"
  38 #ifdef TARGET_OS_FAMILY_linux
  39 # include "thread_linux.inline.hpp"
  40 #endif
  41 #ifdef TARGET_OS_FAMILY_solaris
  42 # include "thread_solaris.inline.hpp"
  43 #endif
  44 #ifdef TARGET_OS_FAMILY_windows
  45 # include "thread_windows.inline.hpp"
  46 #endif
  47 
  48 // Wrapper for all entry points to the virtual machine.
  49 // The HandleMarkCleaner is a faster version of HandleMark.
  50 // It relies on the fact that there is a HandleMark further
  51 // down the stack (in JavaCalls::call_helper), and just resets
  52 // to the saved values in that HandleMark.
  53 
  54 class HandleMarkCleaner: public StackObj {
  55  private:
  56   Thread* _thread;
  57  public:
  58   HandleMarkCleaner(Thread* thread) {
  59     _thread = thread;
  60     _thread->last_handle_mark()->push();
  61   }
  62   ~HandleMarkCleaner() {
  63     _thread->last_handle_mark()->pop_and_restore();
  64   }
  65 
  66  private:
  67   inline void* operator new(size_t size, void* ptr) {


  88   // Helper methods used to implement +ScavengeALot and +FullGCALot
  89   static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
  90   static void gc_alot();
  91 
  92   static void walk_stack_from(vframe* start_vf);
  93   static void walk_stack();
  94 
  95 # ifdef ENABLE_ZAP_DEAD_LOCALS
  96   static void zap_dead_locals_old();
  97 # endif
  98 
  99   static void zombieAll();
 100   static void deoptimizeAll();
 101   static void stress_derived_pointers();
 102   static void verify_stack();
 103   static void verify_last_frame();
 104 # endif
 105 
 106  public:
 107   // OS dependent stuff
 108 #ifdef TARGET_OS_FAMILY_linux
 109 # include "interfaceSupport_linux.hpp"
 110 #endif
 111 #ifdef TARGET_OS_FAMILY_solaris
 112 # include "interfaceSupport_solaris.hpp"
 113 #endif
 114 #ifdef TARGET_OS_FAMILY_windows
 115 # include "interfaceSupport_windows.hpp"
 116 #endif
 117 
 118 };
 119 
 120 
 121 // Basic class for all thread transition classes.
 122 
 123 class ThreadStateTransition : public StackObj {
 124  protected:
 125   JavaThread* _thread;
 126  public:
 127   ThreadStateTransition(JavaThread *thread) {
 128     _thread = thread;
 129     assert(thread != NULL && thread->is_Java_thread(), "must be Java thread");
 130   }
 131 
 132   // Change threadstate in a manner, so safepoint can detect changes.
 133   // Time-critical: called on exit from every runtime routine
 134   static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
 135     assert(from != _thread_in_Java, "use transition_from_java");
 136     assert(from != _thread_in_native, "use transition_from_native");
 137     assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");


 581     __ENTRY(result_type, header, thread)
 582 
 583 
 584 #define JVM_QUICK_ENTRY(result_type, header)                         \
 585 extern "C" {                                                         \
 586   result_type JNICALL header {                                       \
 587     JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
 588     ThreadInVMfromNative __tiv(thread);                              \
 589     debug_only(VMNativeEntryWrapper __vew;)                          \
 590     __QUICK_ENTRY(result_type, header, thread)
 591 
 592 
 593 #define JVM_LEAF(result_type, header)                                \
 594 extern "C" {                                                         \
 595   result_type JNICALL header {                                       \
 596     VM_Exit::block_if_vm_exited();                                   \
 597     __LEAF(result_type, header)
 598 
 599 
 600 #define JVM_END } }
 601 
 602 #endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP