< prev index next >

src/hotspot/share/prims/whitebox.cpp

Print this page




  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 #include "precompiled.hpp"
  26 
  27 #include <new>
  28 
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/modules.hpp"

  31 #include "classfile/stringTable.hpp"
  32 #include "code/codeCache.hpp"
  33 #include "compiler/methodMatcher.hpp"
  34 #include "compiler/directivesParser.hpp"
  35 #include "gc/shared/gcConfig.hpp"
  36 #include "gc/shared/genCollectedHeap.hpp"
  37 #include "jvmtifiles/jvmtiEnv.hpp"
  38 #include "memory/metadataFactory.hpp"
  39 #include "memory/metaspaceShared.hpp"
  40 #include "memory/iterator.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "memory/universe.hpp"
  43 #include "memory/oopFactory.hpp"
  44 #include "oops/array.hpp"
  45 #include "oops/constantPool.inline.hpp"
  46 #include "oops/method.inline.hpp"
  47 #include "oops/objArrayKlass.hpp"
  48 #include "oops/objArrayOop.inline.hpp"
  49 #include "oops/oop.inline.hpp"
  50 #include "oops/typeArrayOop.inline.hpp"


1960 WB_ENTRY(jboolean, WB_IsContainerized(JNIEnv* env, jobject o))
1961   LINUX_ONLY(return OSContainer::is_containerized();)
1962   return false;
1963 WB_END
1964 
1965 WB_ENTRY(void, WB_PrintOsInfo(JNIEnv* env, jobject o))
1966   os::print_os_info(tty);
1967 WB_END
1968 
1969 // Elf decoder
1970 WB_ENTRY(void, WB_DisableElfSectionCache(JNIEnv* env))
1971 #if !defined(_WINDOWS) && !defined(__APPLE__) && !defined(_AIX)
1972   ElfFile::_do_not_cache_elf_section = true;
1973 #endif
1974 WB_END
1975 
1976 WB_ENTRY(jint, WB_ResolvedMethodRemovedCount(JNIEnv* env, jobject o))
1977   return (jint) ResolvedMethodTable::removed_entries_count();
1978 WB_END
1979 




1980 
1981 #define CC (char*)
1982 
1983 static JNINativeMethod methods[] = {
1984   {CC"getObjectAddress0",                CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress  },
1985   {CC"getObjectSize0",                   CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize     },
1986   {CC"isObjectInOldGen0",                CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen  },
1987   {CC"getHeapOopSize",                   CC"()I",                   (void*)&WB_GetHeapOopSize    },
1988   {CC"getVMPageSize",                    CC"()I",                   (void*)&WB_GetVMPageSize     },
1989   {CC"getVMAllocationGranularity",       CC"()J",                   (void*)&WB_GetVMAllocationGranularity },
1990   {CC"getVMLargePageSize",               CC"()J",                   (void*)&WB_GetVMLargePageSize},
1991   {CC"getHeapSpaceAlignment",            CC"()J",                   (void*)&WB_GetHeapSpaceAlignment},
1992   {CC"getHeapAlignment",                 CC"()J",                   (void*)&WB_GetHeapAlignment},
1993   {CC"isClassAlive0",                    CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive      },
1994   {CC"parseCommandLine0",
1995       CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
1996       (void*) &WB_ParseCommandLine
1997   },
1998   {CC"addToBootstrapClassLoaderSearch0", CC"(Ljava/lang/String;)V",
1999                                                       (void*)&WB_AddToBootstrapClassLoaderSearch},


2182 
2183   {CC"clearInlineCaches0",  CC"(Z)V",                 (void*)&WB_ClearInlineCaches },
2184   {CC"handshakeWalkStack", CC"(Ljava/lang/Thread;Z)I", (void*)&WB_HandshakeWalkStack },
2185   {CC"addCompilerDirective",    CC"(Ljava/lang/String;)I",
2186                                                       (void*)&WB_AddCompilerDirective },
2187   {CC"removeCompilerDirective",   CC"(I)V",           (void*)&WB_RemoveCompilerDirective },
2188   {CC"isGCSupported",             CC"(I)Z",           (void*)&WB_IsGCSupported},
2189   {CC"isGCSelected",              CC"(I)Z",           (void*)&WB_IsGCSelected},
2190   {CC"isGCSelectedErgonomically", CC"()Z",            (void*)&WB_IsGCSelectedErgonomically},
2191   {CC"supportsConcurrentGCPhaseControl", CC"()Z",     (void*)&WB_SupportsConcurrentGCPhaseControl},
2192   {CC"getConcurrentGCPhases",     CC"()[Ljava/lang/String;",
2193                                                       (void*)&WB_GetConcurrentGCPhases},
2194   {CC"requestConcurrentGCPhase0", CC"(Ljava/lang/String;)Z",
2195                                                       (void*)&WB_RequestConcurrentGCPhase},
2196   {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z",
2197                                                       (void*)&WB_CheckLibSpecifiesNoexecstack},
2198   {CC"isContainerized",           CC"()Z",            (void*)&WB_IsContainerized },
2199   {CC"printOsInfo",               CC"()V",            (void*)&WB_PrintOsInfo },
2200   {CC"disableElfSectionCache",    CC"()V",            (void*)&WB_DisableElfSectionCache },
2201   {CC"resolvedMethodRemovedCount",     CC"()I",       (void*)&WB_ResolvedMethodRemovedCount },

2202 };
2203 
2204 
2205 #undef CC
2206 
2207 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
2208   {
2209     if (WhiteBoxAPI) {
2210       // Make sure that wbclass is loaded by the null classloader
2211       InstanceKlass* ik = InstanceKlass::cast(JNIHandles::resolve(wbclass)->klass());
2212       Handle loader(THREAD, ik->class_loader());
2213       if (loader.is_null()) {
2214         WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
2215         WhiteBox::set_used();
2216       }
2217     }
2218   }
2219 JVM_END


  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 #include "precompiled.hpp"
  26 
  27 #include <new>
  28 
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/modules.hpp"
  31 #include "classfile/protectionDomainCache.hpp"
  32 #include "classfile/stringTable.hpp"
  33 #include "code/codeCache.hpp"
  34 #include "compiler/methodMatcher.hpp"
  35 #include "compiler/directivesParser.hpp"
  36 #include "gc/shared/gcConfig.hpp"
  37 #include "gc/shared/genCollectedHeap.hpp"
  38 #include "jvmtifiles/jvmtiEnv.hpp"
  39 #include "memory/metadataFactory.hpp"
  40 #include "memory/metaspaceShared.hpp"
  41 #include "memory/iterator.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "memory/universe.hpp"
  44 #include "memory/oopFactory.hpp"
  45 #include "oops/array.hpp"
  46 #include "oops/constantPool.inline.hpp"
  47 #include "oops/method.inline.hpp"
  48 #include "oops/objArrayKlass.hpp"
  49 #include "oops/objArrayOop.inline.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "oops/typeArrayOop.inline.hpp"


1961 WB_ENTRY(jboolean, WB_IsContainerized(JNIEnv* env, jobject o))
1962   LINUX_ONLY(return OSContainer::is_containerized();)
1963   return false;
1964 WB_END
1965 
1966 WB_ENTRY(void, WB_PrintOsInfo(JNIEnv* env, jobject o))
1967   os::print_os_info(tty);
1968 WB_END
1969 
1970 // Elf decoder
1971 WB_ENTRY(void, WB_DisableElfSectionCache(JNIEnv* env))
1972 #if !defined(_WINDOWS) && !defined(__APPLE__) && !defined(_AIX)
1973   ElfFile::_do_not_cache_elf_section = true;
1974 #endif
1975 WB_END
1976 
1977 WB_ENTRY(jint, WB_ResolvedMethodRemovedCount(JNIEnv* env, jobject o))
1978   return (jint) ResolvedMethodTable::removed_entries_count();
1979 WB_END
1980 
1981 WB_ENTRY(jint, WB_ProtectionDomainRemovedCount(JNIEnv* env, jobject o))
1982   return (jint) SystemDictionary::pd_cache_table()->removed_entries_count();
1983 WB_END
1984 
1985 
1986 #define CC (char*)
1987 
1988 static JNINativeMethod methods[] = {
1989   {CC"getObjectAddress0",                CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectAddress  },
1990   {CC"getObjectSize0",                   CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize     },
1991   {CC"isObjectInOldGen0",                CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen  },
1992   {CC"getHeapOopSize",                   CC"()I",                   (void*)&WB_GetHeapOopSize    },
1993   {CC"getVMPageSize",                    CC"()I",                   (void*)&WB_GetVMPageSize     },
1994   {CC"getVMAllocationGranularity",       CC"()J",                   (void*)&WB_GetVMAllocationGranularity },
1995   {CC"getVMLargePageSize",               CC"()J",                   (void*)&WB_GetVMLargePageSize},
1996   {CC"getHeapSpaceAlignment",            CC"()J",                   (void*)&WB_GetHeapSpaceAlignment},
1997   {CC"getHeapAlignment",                 CC"()J",                   (void*)&WB_GetHeapAlignment},
1998   {CC"isClassAlive0",                    CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive      },
1999   {CC"parseCommandLine0",
2000       CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
2001       (void*) &WB_ParseCommandLine
2002   },
2003   {CC"addToBootstrapClassLoaderSearch0", CC"(Ljava/lang/String;)V",
2004                                                       (void*)&WB_AddToBootstrapClassLoaderSearch},


2187 
2188   {CC"clearInlineCaches0",  CC"(Z)V",                 (void*)&WB_ClearInlineCaches },
2189   {CC"handshakeWalkStack", CC"(Ljava/lang/Thread;Z)I", (void*)&WB_HandshakeWalkStack },
2190   {CC"addCompilerDirective",    CC"(Ljava/lang/String;)I",
2191                                                       (void*)&WB_AddCompilerDirective },
2192   {CC"removeCompilerDirective",   CC"(I)V",           (void*)&WB_RemoveCompilerDirective },
2193   {CC"isGCSupported",             CC"(I)Z",           (void*)&WB_IsGCSupported},
2194   {CC"isGCSelected",              CC"(I)Z",           (void*)&WB_IsGCSelected},
2195   {CC"isGCSelectedErgonomically", CC"()Z",            (void*)&WB_IsGCSelectedErgonomically},
2196   {CC"supportsConcurrentGCPhaseControl", CC"()Z",     (void*)&WB_SupportsConcurrentGCPhaseControl},
2197   {CC"getConcurrentGCPhases",     CC"()[Ljava/lang/String;",
2198                                                       (void*)&WB_GetConcurrentGCPhases},
2199   {CC"requestConcurrentGCPhase0", CC"(Ljava/lang/String;)Z",
2200                                                       (void*)&WB_RequestConcurrentGCPhase},
2201   {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z",
2202                                                       (void*)&WB_CheckLibSpecifiesNoexecstack},
2203   {CC"isContainerized",           CC"()Z",            (void*)&WB_IsContainerized },
2204   {CC"printOsInfo",               CC"()V",            (void*)&WB_PrintOsInfo },
2205   {CC"disableElfSectionCache",    CC"()V",            (void*)&WB_DisableElfSectionCache },
2206   {CC"resolvedMethodRemovedCount",     CC"()I",       (void*)&WB_ResolvedMethodRemovedCount },
2207   {CC"protectionDomainRemovedCount",   CC"()I",       (void*)&WB_ProtectionDomainRemovedCount },
2208 };
2209 
2210 
2211 #undef CC
2212 
2213 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
2214   {
2215     if (WhiteBoxAPI) {
2216       // Make sure that wbclass is loaded by the null classloader
2217       InstanceKlass* ik = InstanceKlass::cast(JNIHandles::resolve(wbclass)->klass());
2218       Handle loader(THREAD, ik->class_loader());
2219       if (loader.is_null()) {
2220         WhiteBox::register_methods(env, wbclass, thread, methods, sizeof(methods) / sizeof(methods[0]));
2221         WhiteBox::set_used();
2222       }
2223     }
2224   }
2225 JVM_END
< prev index next >