2012-02-23 14:58:35 +01:00
/*
2020-01-08 14:36:48 +01:00
* Copyright ( c ) 2012 , 2020 , Oracle and / or its affiliates . All rights reserved .
2012-02-23 14:58:35 +01:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
*
* This code is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License version 2 only , as
* published by the Free Software Foundation .
*
* This code is distributed in the hope that it will be useful , but WITHOUT
* ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE . See the GNU General Public License
* version 2 for more details ( a copy is included in the LICENSE file that
* accompanied this code ) .
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work ; if not , write to the Free Software Foundation ,
* Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA .
*
* Please contact Oracle , 500 Oracle Parkway , Redwood Shores , CA 94065 USA
* or visit www . oracle . com if you need additional information or have any
* questions .
*
*/
# include "precompiled.hpp"
2014-11-10 19:04:38 +03:00
# include <new>
2018-09-28 16:07:39 -04:00
# include "classfile/classLoaderDataGraph.hpp"
2020-05-07 14:09:20 +02:00
# include "classfile/javaClasses.inline.hpp"
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
# include "classfile/modules.hpp"
2018-08-31 10:22:04 -04:00
# include "classfile/protectionDomainCache.hpp"
2014-11-12 12:41:59 +01:00
# include "classfile/stringTable.hpp"
2019-05-09 14:28:30 +02:00
# include "classfile/symbolTable.hpp"
2014-07-04 11:46:01 +02:00
# include "code/codeCache.hpp"
2019-10-09 12:43:32 -07:00
# include "compiler/compilationPolicy.hpp"
2015-09-18 10:11:11 +02:00
# include "compiler/methodMatcher.hpp"
2016-03-03 16:21:16 +01:00
# include "compiler/directivesParser.hpp"
2020-03-06 18:42:13 -05:00
# include "gc/shared/concurrentGCBreakpoints.hpp"
2018-03-28 11:38:47 +02:00
# include "gc/shared/gcConfig.hpp"
2019-04-15 11:47:46 +02:00
# include "gc/shared/genArguments.hpp"
2018-03-23 18:54:12 +01:00
# include "gc/shared/genCollectedHeap.hpp"
2014-11-26 18:01:10 +01:00
# include "jvmtifiles/jvmtiEnv.hpp"
2020-06-24 17:48:53 -04:00
# include "logging/log.hpp"
2019-05-17 08:29:55 -07:00
# include "memory/filemap.hpp"
2018-10-09 15:58:07 -04:00
# include "memory/heapShared.inline.hpp"
# include "memory/metaspaceShared.hpp"
2014-07-07 10:12:40 +02:00
# include "memory/metadataFactory.hpp"
2016-03-15 10:11:02 +01:00
# include "memory/iterator.hpp"
2016-04-04 12:57:48 -04:00
# include "memory/resourceArea.hpp"
2012-02-23 14:58:35 +01:00
# include "memory/universe.hpp"
2016-04-20 19:54:51 +03:00
# include "memory/oopFactory.hpp"
2017-05-10 08:37:17 -04:00
# include "oops/array.hpp"
2019-05-09 14:26:03 +02:00
# include "oops/compressedOops.hpp"
2018-03-05 10:29:23 -05:00
# include "oops/constantPool.inline.hpp"
# include "oops/method.inline.hpp"
2017-01-19 11:49:30 +01:00
# include "oops/objArrayKlass.hpp"
# include "oops/objArrayOop.inline.hpp"
2012-02-23 14:58:35 +01:00
# include "oops/oop.inline.hpp"
2018-02-15 23:45:15 +01:00
# include "oops/typeArrayOop.inline.hpp"
2018-08-29 10:46:59 -04:00
# include "prims/resolvedMethodTable.hpp"
2012-03-15 13:37:13 +01:00
# include "prims/wbtestmethods/parserTests.hpp"
2018-03-16 09:12:13 -04:00
# include "prims/whitebox.inline.hpp"
2013-09-11 16:25:02 +02:00
# include "runtime/arguments.hpp"
2019-11-26 10:47:46 +01:00
# include "runtime/atomic.hpp"
2014-11-10 19:04:38 +03:00
# include "runtime/deoptimization.hpp"
2018-08-20 13:58:23 -07:00
# include "runtime/fieldDescriptor.inline.hpp"
2018-04-26 11:19:05 -05:00
# include "runtime/flags/jvmFlag.hpp"
2020-09-22 06:04:31 +00:00
# include "runtime/flags/jvmFlagAccess.hpp"
2018-03-21 19:45:24 -04:00
# include "runtime/frame.inline.hpp"
2019-01-31 10:31:39 +01:00
# include "runtime/handles.inline.hpp"
2017-08-31 10:00:28 +02:00
# include "runtime/handshake.hpp"
2018-03-16 09:12:13 -04:00
# include "runtime/interfaceSupport.inline.hpp"
2015-05-13 15:16:06 +02:00
# include "runtime/javaCalls.hpp"
2018-03-01 16:51:22 -05:00
# include "runtime/jniHandles.inline.hpp"
2012-02-23 14:58:35 +01:00
# include "runtime/os.hpp"
2014-11-10 19:04:38 +03:00
# include "runtime/sweeper.hpp"
2020-06-01 23:37:14 -04:00
# include "runtime/synchronizer.hpp"
2014-11-12 12:41:59 +01:00
# include "runtime/thread.hpp"
2017-11-22 17:54:50 -08:00
# include "runtime/threadSMR.hpp"
2014-07-04 11:46:01 +02:00
# include "runtime/vm_version.hpp"
2018-03-15 21:29:36 +01:00
# include "services/memoryService.hpp"
2017-07-05 11:33:17 +02:00
# include "utilities/align.hpp"
2012-02-23 14:58:35 +01:00
# include "utilities/debug.hpp"
2018-02-14 17:20:59 -05:00
# include "utilities/elfFile.hpp"
2018-02-21 07:49:36 -05:00
# include "utilities/exceptions.hpp"
2014-11-12 12:41:59 +01:00
# include "utilities/macros.hpp"
2017-11-27 20:21:34 -08:00
# if INCLUDE_CDS
# include "prims/cdsoffsets.hpp"
# endif // INCLUDE_CDS
2018-05-04 11:41:35 +02:00
# if INCLUDE_G1GC
2019-04-15 11:47:46 +02:00
# include "gc/g1/g1Arguments.hpp"
2015-05-13 15:16:06 +02:00
# include "gc/g1/g1CollectedHeap.inline.hpp"
2016-02-05 16:03:56 +01:00
# include "gc/g1/g1ConcurrentMark.hpp"
2018-04-04 10:12:02 +02:00
# include "gc/g1/g1ConcurrentMarkThread.hpp"
2015-05-13 15:16:06 +02:00
# include "gc/g1/heapRegionRemSet.hpp"
2018-12-21 08:18:59 -08:00
# include "gc/g1/heterogeneousHeapRegionManager.hpp"
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_G1GC
# if INCLUDE_PARALLELGC
2015-05-13 15:16:06 +02:00
# include "gc/parallel/parallelScavengeHeap.inline.hpp"
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_PARALLELGC
2014-08-07 12:18:58 -07:00
# if INCLUDE_NMT
# include "services/mallocSiteTable.hpp"
2013-02-01 23:48:08 +01:00
# include "services/memTracker.hpp"
2014-08-07 12:18:58 -07:00
# include "utilities/nativeCallStack.hpp"
2013-02-01 23:48:08 +01:00
# endif // INCLUDE_NMT
2019-01-23 16:36:45 -08:00
# if INCLUDE_AOT
# include "aot/aotLoader.hpp"
# endif // INCLUDE_AOT
2013-02-01 23:48:08 +01:00
2017-09-25 23:42:58 -04:00
# ifdef LINUX
2017-11-16 19:01:01 -08:00
# include "osContainer_linux.hpp"
2020-02-25 12:17:26 +01:00
# include "cgroupSubsystem_linux.hpp"
2017-09-25 23:42:58 -04:00
# endif
2013-02-13 08:29:04 -08:00
2013-11-08 16:48:21 +01:00
# define SIZE_T_MAX_VALUE ((size_t) -1)
2018-03-16 09:12:13 -04:00
# define CHECK_JNI_EXCEPTION_(env, value) \
do { \
JavaThread * THREAD = JavaThread : : thread_from_jni_environment ( env ) ; \
2018-05-29 17:21:31 -04:00
THREAD - > clear_pending_jni_exception_check ( ) ; \
2018-03-16 09:12:13 -04:00
if ( HAS_PENDING_EXCEPTION ) { \
return ( value ) ; \
} \
} while ( 0 )
# define CHECK_JNI_EXCEPTION(env) \
do { \
JavaThread * THREAD = JavaThread : : thread_from_jni_environment ( env ) ; \
2018-05-29 17:21:31 -04:00
THREAD - > clear_pending_jni_exception_check ( ) ; \
2018-03-16 09:12:13 -04:00
if ( HAS_PENDING_EXCEPTION ) { \
return ; \
} \
} while ( 0 )
2012-02-23 14:58:35 +01:00
bool WhiteBox : : _used = false ;
2014-11-10 19:04:38 +03:00
volatile bool WhiteBox : : compilation_locked = false ;
2012-02-23 14:58:35 +01:00
2014-12-16 17:56:24 +03:00
class VM_WhiteBoxOperation : public VM_Operation {
public :
VM_WhiteBoxOperation ( ) { }
VMOp_Type type ( ) const { return VMOp_WhiteBoxOperation ; }
bool allow_nested_vm_operations ( ) const { return true ; }
} ;
2012-02-23 14:58:35 +01:00
WB_ENTRY ( jlong , WB_GetObjectAddress ( JNIEnv * env , jobject o , jobject obj ) )
return ( jlong ) ( void * ) JNIHandles : : resolve ( obj ) ;
WB_END
WB_ENTRY ( jint , WB_GetHeapOopSize ( JNIEnv * env , jobject o ) )
return heapOopSize ;
WB_END
2014-11-26 10:32:21 -08:00
WB_ENTRY ( jint , WB_GetVMPageSize ( JNIEnv * env , jobject o ) )
return os : : vm_page_size ( ) ;
WB_END
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
2015-06-24 09:42:45 +02:00
WB_ENTRY ( jlong , WB_GetVMAllocationGranularity ( JNIEnv * env , jobject o ) )
return os : : vm_allocation_granularity ( ) ;
WB_END
2015-04-07 10:53:51 +02:00
WB_ENTRY ( jlong , WB_GetVMLargePageSize ( JNIEnv * env , jobject o ) )
return os : : large_page_size ( ) ;
WB_END
2018-08-31 07:03:46 -04:00
class WBIsKlassAliveClosure : public LockedClassesDo {
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
Symbol * _name ;
2020-01-17 06:56:29 -05:00
int _count ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
public :
2020-01-17 06:56:29 -05:00
WBIsKlassAliveClosure ( Symbol * name ) : _name ( name ) , _count ( 0 ) { }
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
void do_klass ( Klass * k ) {
Symbol * ksym = k - > name ( ) ;
if ( ksym - > fast_compare ( _name ) = = 0 ) {
2020-01-17 06:56:29 -05:00
_count + + ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
}
}
2020-01-17 06:56:29 -05:00
int count ( ) const {
return _count ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
}
} ;
2020-01-17 06:56:29 -05:00
WB_ENTRY ( jint , WB_CountAliveClasses ( JNIEnv * env , jobject target , jstring name ) )
2017-02-15 22:59:57 -05:00
oop h_name = JNIHandles : : resolve ( name ) ;
if ( h_name = = NULL ) return false ;
2019-05-14 11:29:18 -04:00
Symbol * sym = java_lang_String : : as_symbol ( h_name ) ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
TempNewSymbol tsym ( sym ) ; // Make sure to decrement reference count on sym on return
WBIsKlassAliveClosure closure ( sym ) ;
ClassLoaderDataGraph : : classes_do ( & closure ) ;
2020-01-17 06:56:29 -05:00
// Return the count of alive classes with this name.
return closure . count ( ) ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
WB_END
2018-09-14 12:10:28 -04:00
WB_ENTRY ( jint , WB_GetSymbolRefcount ( JNIEnv * env , jobject unused , jstring name ) )
oop h_name = JNIHandles : : resolve ( name ) ;
if ( h_name = = NULL ) return false ;
2019-05-14 11:29:18 -04:00
Symbol * sym = java_lang_String : : as_symbol ( h_name ) ;
2018-09-14 12:10:28 -04:00
TempNewSymbol tsym ( sym ) ; // Make sure to decrement reference count on sym on return
return ( jint ) sym - > refcount ( ) ;
WB_END
2014-11-18 03:38:50 -08:00
WB_ENTRY ( void , WB_AddToBootstrapClassLoaderSearch ( JNIEnv * env , jobject o , jstring segment ) ) {
# if INCLUDE_JVMTI
2014-11-19 19:31:13 -08:00
ResourceMark rm ;
const char * seg = java_lang_String : : as_utf8_string ( JNIHandles : : resolve_non_null ( segment ) ) ;
2014-11-18 03:38:50 -08:00
JvmtiEnv * jvmti_env = JvmtiEnv : : create_a_jvmti ( JVMTI_VERSION ) ;
jvmtiError err = jvmti_env - > AddToBootstrapClassLoaderSearch ( seg ) ;
assert ( err = = JVMTI_ERROR_NONE , " must not fail " ) ;
# endif
}
WB_END
WB_ENTRY ( void , WB_AddToSystemClassLoaderSearch ( JNIEnv * env , jobject o , jstring segment ) ) {
# if INCLUDE_JVMTI
2014-11-19 19:31:13 -08:00
ResourceMark rm ;
const char * seg = java_lang_String : : as_utf8_string ( JNIHandles : : resolve_non_null ( segment ) ) ;
2014-11-18 03:38:50 -08:00
JvmtiEnv * jvmti_env = JvmtiEnv : : create_a_jvmti ( JVMTI_VERSION ) ;
jvmtiError err = jvmti_env - > AddToSystemClassLoaderSearch ( seg ) ;
assert ( err = = JVMTI_ERROR_NONE , " must not fail " ) ;
# endif
}
WB_END
2013-09-11 16:25:02 +02:00
WB_ENTRY ( jlong , WB_GetCompressedOopsMaxHeapSize ( JNIEnv * env , jobject o ) ) {
return ( jlong ) Arguments : : max_heap_for_compressed_oops ( ) ;
}
WB_END
2013-05-06 17:19:42 +02:00
WB_ENTRY ( void , WB_PrintHeapSizes ( JNIEnv * env , jobject o ) ) {
2019-04-15 11:47:46 +02:00
tty - > print_cr ( " Minimum heap " SIZE_FORMAT " Initial heap " SIZE_FORMAT " "
" Maximum heap " SIZE_FORMAT " Space alignment " SIZE_FORMAT " Heap alignment " SIZE_FORMAT ,
MinHeapSize ,
InitialHeapSize ,
MaxHeapSize ,
SpaceAlignment ,
HeapAlignment ) ;
2013-05-06 17:19:42 +02:00
}
WB_END
2013-11-08 16:48:21 +01:00
# ifndef PRODUCT
// Forward declaration
void TestReservedSpace_test ( ) ;
void TestReserveMemorySpecial_test ( ) ;
void TestVirtualSpace_test ( ) ;
# endif
WB_ENTRY ( void , WB_RunMemoryUnitTests ( JNIEnv * env , jobject o ) )
# ifndef PRODUCT
TestReservedSpace_test ( ) ;
TestReserveMemorySpecial_test ( ) ;
TestVirtualSpace_test ( ) ;
# endif
WB_END
WB_ENTRY ( void , WB_ReadFromNoaccessArea ( JNIEnv * env , jobject o ) )
size_t granularity = os : : vm_allocation_granularity ( ) ;
2015-01-05 12:07:37 -05:00
ReservedHeapSpace rhs ( 100 * granularity , granularity , false ) ;
2013-11-08 16:48:21 +01:00
VirtualSpace vs ;
vs . initialize ( rhs , 50 * granularity ) ;
2015-01-05 12:07:37 -05:00
// Check if constraints are complied
2013-11-08 16:48:21 +01:00
if ( ! ( UseCompressedOops & & rhs . base ( ) ! = NULL & &
2019-05-09 14:26:03 +02:00
CompressedOops : : base ( ) ! = NULL & &
CompressedOops : : use_implicit_null_checks ( ) ) ) {
2013-11-08 16:48:21 +01:00
tty - > print_cr ( " WB_ReadFromNoaccessArea method is useless: \n "
" \t UseCompressedOops is %d \n "
2015-06-24 12:12:25 -04:00
" \t rhs.base() is " PTR_FORMAT " \n "
2019-05-09 14:26:03 +02:00
" \t CompressedOops::base() is " PTR_FORMAT " \n "
" \t CompressedOops::use_implicit_null_checks() is %d " ,
2013-11-08 16:48:21 +01:00
UseCompressedOops ,
2015-10-09 09:42:33 +02:00
p2i ( rhs . base ( ) ) ,
2019-05-09 14:26:03 +02:00
p2i ( CompressedOops : : base ( ) ) ,
CompressedOops : : use_implicit_null_checks ( ) ) ;
2013-11-08 16:48:21 +01:00
return ;
}
tty - > print_cr ( " Reading from no access area... " ) ;
tty - > print_cr ( " *(vs.low_boundary() - rhs.noaccess_prefix() / 2 ) = %c " ,
* ( vs . low_boundary ( ) - rhs . noaccess_prefix ( ) / 2 ) ) ;
WB_END
static jint wb_stress_virtual_space_resize ( size_t reserved_space_size ,
size_t magnitude , size_t iterations ) {
size_t granularity = os : : vm_allocation_granularity ( ) ;
2015-01-05 12:07:37 -05:00
ReservedHeapSpace rhs ( reserved_space_size * granularity , granularity , false ) ;
2013-11-08 16:48:21 +01:00
VirtualSpace vs ;
if ( ! vs . initialize ( rhs , 0 ) ) {
tty - > print_cr ( " Failed to initialize VirtualSpace. Can't proceed. " ) ;
return 3 ;
}
2017-06-28 16:14:20 -04:00
int seed = os : : random ( ) ;
tty - > print_cr ( " Random seed is %d " , seed ) ;
2013-11-08 16:48:21 +01:00
os : : init_random ( seed ) ;
for ( size_t i = 0 ; i < iterations ; i + + ) {
// Whether we will shrink or grow
bool shrink = os : : random ( ) % 2L = = 0 ;
// Get random delta to resize virtual space
size_t delta = ( size_t ) os : : random ( ) % magnitude ;
// If we are about to shrink virtual space below zero, then expand instead
if ( shrink & & vs . committed_size ( ) < delta ) {
shrink = false ;
}
// Resizing by delta
if ( shrink ) {
vs . shrink_by ( delta ) ;
} else {
// If expanding fails expand_by will silently return false
vs . expand_by ( delta , true ) ;
}
}
return 0 ;
}
WB_ENTRY ( jint , WB_StressVirtualSpaceResize ( JNIEnv * env , jobject o ,
jlong reserved_space_size , jlong magnitude , jlong iterations ) )
2015-06-24 12:12:25 -04:00
tty - > print_cr ( " reservedSpaceSize= " JLONG_FORMAT " , magnitude= " JLONG_FORMAT " , "
" iterations= " JLONG_FORMAT " \n " , reserved_space_size , magnitude ,
2013-11-08 16:48:21 +01:00
iterations ) ;
if ( reserved_space_size < 0 | | magnitude < 0 | | iterations < 0 ) {
tty - > print_cr ( " One of variables printed above is negative. Can't proceed. \n " ) ;
return 1 ;
}
// sizeof(size_t) depends on whether OS is 32bit or 64bit. sizeof(jlong) is
// always 8 byte. That's why we should avoid overflow in case of 32bit platform.
if ( sizeof ( size_t ) < sizeof ( jlong ) ) {
jlong size_t_max_value = ( jlong ) SIZE_T_MAX_VALUE ;
if ( reserved_space_size > size_t_max_value | | magnitude > size_t_max_value
| | iterations > size_t_max_value ) {
tty - > print_cr ( " One of variables printed above overflows size_t. Can't proceed. \n " ) ;
return 2 ;
}
}
return wb_stress_virtual_space_resize ( ( size_t ) reserved_space_size ,
( size_t ) magnitude , ( size_t ) iterations ) ;
WB_END
2018-03-28 11:38:47 +02:00
WB_ENTRY ( jboolean , WB_IsGCSupported ( JNIEnv * env , jobject o , jint name ) )
return GCConfig : : is_gc_supported ( ( CollectedHeap : : Name ) name ) ;
2016-05-30 19:56:27 +04:00
WB_END
2018-03-28 11:38:47 +02:00
WB_ENTRY ( jboolean , WB_IsGCSelected ( JNIEnv * env , jobject o , jint name ) )
return GCConfig : : is_gc_selected ( ( CollectedHeap : : Name ) name ) ;
2016-05-30 19:56:27 +04:00
WB_END
2018-03-28 11:38:47 +02:00
WB_ENTRY ( jboolean , WB_IsGCSelectedErgonomically ( JNIEnv * env , jobject o ) )
return GCConfig : : is_gc_selected_ergonomically ( ) ;
2016-05-30 19:56:27 +04:00
WB_END
2014-08-21 16:44:41 +02:00
WB_ENTRY ( jboolean , WB_isObjectInOldGen ( JNIEnv * env , jobject o , jobject obj ) )
oop p = JNIHandles : : resolve ( obj ) ;
2018-05-04 11:41:35 +02:00
# if INCLUDE_G1GC
2014-08-21 16:44:41 +02:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
const HeapRegion * hr = g1h - > heap_region_containing ( p ) ;
2014-08-21 16:44:41 +02:00
if ( hr = = NULL ) {
return false ;
}
return ! ( hr - > is_young ( ) ) ;
2018-05-04 11:41:35 +02:00
}
# endif
# if INCLUDE_PARALLELGC
if ( UseParallelGC ) {
2014-08-21 16:44:41 +02:00
ParallelScavengeHeap * psh = ParallelScavengeHeap : : heap ( ) ;
return ! psh - > is_in_young ( p ) ;
}
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Erik Osterlund <erik.osterlund@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Kim Barrett <kim.barrett@oracle.com>
Co-authored-by: Nils Eliasson <nils.eliasson@oracle.com>
Co-authored-by: Rickard Backman <rickard.backman@oracle.com>
Co-authored-by: Roland Westrelin <rwestrel@redhat.com>
Co-authored-by: Coleen Phillimore <coleen.phillimore@oracle.com>
Co-authored-by: Robbin Ehn <robbin.ehn@oracle.com>
Co-authored-by: Gerard Ziemski <gerard.ziemski@oracle.com>
Co-authored-by: Hugh Wilkinson <hugh.wilkinson@intel.com>
Co-authored-by: Sandhya Viswanathan <sandhya.viswanathan@intel.com>
Co-authored-by: Bill Wheeler <bill.npo.wheeler@intel.com>
Co-authored-by: Vinay K. Awasthi <vinay.k.awasthi@intel.com>
Co-authored-by: Yasumasa Suenaga <yasuenag@gmail.com>
Reviewed-by: pliden, stefank, eosterlund, ehelin, sjohanss, rbackman, coleenp, ihse, jgeorge, lmesnik, rkennke
2018-06-12 17:40:28 +02:00
# endif
# if INCLUDE_ZGC
if ( UseZGC ) {
return Universe : : heap ( ) - > is_in ( p ) ;
}
# endif
2014-08-21 16:44:41 +02:00
GenCollectedHeap * gch = GenCollectedHeap : : heap ( ) ;
return ! gch - > is_in_young ( p ) ;
WB_END
WB_ENTRY ( jlong , WB_GetObjectSize ( JNIEnv * env , jobject o , jobject obj ) )
oop p = JNIHandles : : resolve ( obj ) ;
2020-07-13 07:39:39 +02:00
return p - > size ( ) * HeapWordSize ;
2014-08-21 16:44:41 +02:00
WB_END
2015-09-01 21:38:07 +03:00
WB_ENTRY ( jlong , WB_GetHeapSpaceAlignment ( JNIEnv * env , jobject o ) )
2019-04-15 11:47:46 +02:00
return ( jlong ) SpaceAlignment ;
2015-09-01 21:38:07 +03:00
WB_END
2016-08-02 15:22:41 +03:00
WB_ENTRY ( jlong , WB_GetHeapAlignment ( JNIEnv * env , jobject o ) )
2019-04-15 11:47:46 +02:00
return ( jlong ) HeapAlignment ;
2016-08-02 15:22:41 +03:00
WB_END
2020-03-06 18:42:13 -05:00
WB_ENTRY ( jboolean , WB_SupportsConcurrentGCBreakpoints ( JNIEnv * env , jobject o ) )
return Universe : : heap ( ) - > supports_concurrent_gc_breakpoints ( ) ;
2017-04-13 16:38:39 -04:00
WB_END
2020-03-06 18:42:13 -05:00
WB_ENTRY ( void , WB_ConcurrentGCAcquireControl ( JNIEnv * env , jobject o ) )
ConcurrentGCBreakpoints : : acquire_control ( ) ;
WB_END
WB_ENTRY ( void , WB_ConcurrentGCReleaseControl ( JNIEnv * env , jobject o ) )
ConcurrentGCBreakpoints : : release_control ( ) ;
WB_END
WB_ENTRY ( void , WB_ConcurrentGCRunToIdle ( JNIEnv * env , jobject o ) )
ConcurrentGCBreakpoints : : run_to_idle ( ) ;
WB_END
WB_ENTRY ( jboolean , WB_ConcurrentGCRunTo ( JNIEnv * env , jobject o , jobject at ) )
Handle h_name ( THREAD , JNIHandles : : resolve ( at ) ) ;
2017-04-13 16:38:39 -04:00
ResourceMark rm ;
const char * c_name = java_lang_String : : as_utf8_string ( h_name ( ) ) ;
2020-03-06 18:42:13 -05:00
return ConcurrentGCBreakpoints : : run_to ( c_name ) ;
2017-04-13 16:38:39 -04:00
WB_END
2018-05-04 11:41:35 +02:00
# if INCLUDE_G1GC
2012-02-23 14:58:35 +01:00
WB_ENTRY ( jboolean , WB_G1IsHumongous ( JNIEnv * env , jobject o , jobject obj ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2017-03-20 16:01:33 +03:00
oop result = JNIHandles : : resolve ( obj ) ;
2018-04-18 11:36:48 +02:00
const HeapRegion * hr = g1h - > heap_region_containing ( result ) ;
2017-03-20 16:01:33 +03:00
return hr - > is_humongous ( ) ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1IsHumongous: G1 GC is not enabled " ) ;
2012-02-23 14:58:35 +01:00
WB_END
2015-12-17 16:46:41 +03:00
WB_ENTRY ( jboolean , WB_G1BelongsToHumongousRegion ( JNIEnv * env , jobject o , jlong addr ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
const HeapRegion * hr = g1h - > heap_region_containing ( ( void * ) addr ) ;
2017-03-20 16:01:33 +03:00
return hr - > is_humongous ( ) ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1BelongsToHumongousRegion: G1 GC is not enabled " ) ;
2015-12-17 16:46:41 +03:00
WB_END
WB_ENTRY ( jboolean , WB_G1BelongsToFreeRegion ( JNIEnv * env , jobject o , jlong addr ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
const HeapRegion * hr = g1h - > heap_region_containing ( ( void * ) addr ) ;
2017-03-20 16:01:33 +03:00
return hr - > is_free ( ) ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1BelongsToFreeRegion: G1 GC is not enabled " ) ;
2015-12-17 16:46:41 +03:00
WB_END
2015-03-16 17:51:28 +03:00
WB_ENTRY ( jlong , WB_G1NumMaxRegions ( JNIEnv * env , jobject o ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
size_t nr = g1h - > max_regions ( ) ;
2017-03-20 16:01:33 +03:00
return ( jlong ) nr ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1NumMaxRegions: G1 GC is not enabled " ) ;
2015-03-16 17:51:28 +03:00
WB_END
2012-02-23 14:58:35 +01:00
WB_ENTRY ( jlong , WB_G1NumFreeRegions ( JNIEnv * env , jobject o ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
2018-04-18 11:36:48 +02:00
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
size_t nr = g1h - > num_free_regions ( ) ;
2017-03-20 16:01:33 +03:00
return ( jlong ) nr ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1NumFreeRegions: G1 GC is not enabled " ) ;
2012-02-23 14:58:35 +01:00
WB_END
WB_ENTRY ( jboolean , WB_G1InConcurrentMark ( JNIEnv * env , jobject o ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2017-10-23 11:46:12 +02:00
return g1h - > concurrent_mark ( ) - > cm_thread ( ) - > during_cycle ( ) ;
2017-03-20 16:01:33 +03:00
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1InConcurrentMark: G1 GC is not enabled " ) ;
2014-11-28 09:33:48 +01:00
WB_END
WB_ENTRY ( jboolean , WB_G1StartMarkCycle ( JNIEnv * env , jobject o ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2017-10-23 11:46:12 +02:00
if ( ! g1h - > concurrent_mark ( ) - > cm_thread ( ) - > during_cycle ( ) ) {
2017-03-20 16:01:33 +03:00
g1h - > collect ( GCCause : : _wb_conc_mark ) ;
return true ;
}
return false ;
2014-11-28 09:33:48 +01:00
}
2017-03-20 16:01:33 +03:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1StartMarkCycle: G1 GC is not enabled " ) ;
2012-02-23 14:58:35 +01:00
WB_END
WB_ENTRY ( jint , WB_G1RegionSize ( JNIEnv * env , jobject o ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
return ( jint ) HeapRegion : : GrainBytes ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1RegionSize: G1 GC is not enabled " ) ;
2012-02-23 14:58:35 +01:00
WB_END
2015-03-16 17:51:28 +03:00
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_G1GC
2018-12-21 08:23:55 -08:00
# if INCLUDE_G1GC || INCLUDE_PARALLELGC
2018-12-21 08:18:59 -08:00
WB_ENTRY ( jlong , WB_DramReservedStart ( JNIEnv * env , jobject o ) )
2018-12-22 15:46:54 +01:00
# if INCLUDE_G1GC
2018-12-21 08:18:59 -08:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2020-09-02 10:07:03 +02:00
HeapWord * base = g1h - > reserved ( ) . start ( ) ;
2019-03-04 11:49:16 +01:00
if ( g1h - > is_heterogeneous_heap ( ) ) {
2018-12-21 08:18:59 -08:00
uint start_region = HeterogeneousHeapRegionManager : : manager ( ) - > start_index_of_dram ( ) ;
2020-09-02 10:07:03 +02:00
return ( jlong ) ( base + start_region * HeapRegion : : GrainBytes ) ;
2018-12-21 08:18:59 -08:00
} else {
2020-09-02 10:07:03 +02:00
return ( jlong ) base ;
2018-12-21 08:18:59 -08:00
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_G1GC
# if INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
if ( UseParallelGC ) {
ParallelScavengeHeap * ps_heap = ParallelScavengeHeap : : heap ( ) ;
if ( AllocateOldGenAt ! = NULL ) {
MemRegion reserved = ps_heap - > young_gen ( ) - > reserved ( ) ;
return ( jlong ) reserved . start ( ) ;
} else {
return ( jlong ) ps_heap - > base ( ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_DramReservedStart: enabled only for G1 and Parallel GC " ) ;
2018-12-21 08:18:59 -08:00
WB_END
WB_ENTRY ( jlong , WB_DramReservedEnd ( JNIEnv * env , jobject o ) )
2018-12-22 15:46:54 +01:00
# if INCLUDE_G1GC
2018-12-21 08:18:59 -08:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2020-09-02 10:07:03 +02:00
HeapWord * base = g1h - > reserved ( ) . start ( ) ;
2019-03-04 11:49:16 +01:00
if ( g1h - > is_heterogeneous_heap ( ) ) {
2018-12-21 08:18:59 -08:00
uint end_region = HeterogeneousHeapRegionManager : : manager ( ) - > end_index_of_dram ( ) ;
2020-09-02 10:07:03 +02:00
return ( jlong ) ( base + ( end_region + 1 ) * HeapRegion : : GrainBytes - 1 ) ;
2018-12-21 08:18:59 -08:00
} else {
2020-09-02 10:07:03 +02:00
return ( jlong ) base + G1Arguments : : heap_max_size_bytes ( ) ;
2018-12-21 08:18:59 -08:00
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_G1GC
# if INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
if ( UseParallelGC ) {
ParallelScavengeHeap * ps_heap = ParallelScavengeHeap : : heap ( ) ;
if ( AllocateOldGenAt ! = NULL ) {
MemRegion reserved = ps_heap - > young_gen ( ) - > reserved ( ) ;
return ( jlong ) reserved . end ( ) ;
} else {
return ( jlong ) ps_heap - > reserved_region ( ) . end ( ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_DramReservedEnd: enabled only for G1 and Parallel GC " ) ;
2018-12-21 08:18:59 -08:00
WB_END
WB_ENTRY ( jlong , WB_NvdimmReservedStart ( JNIEnv * env , jobject o ) )
2018-12-22 15:46:54 +01:00
# if INCLUDE_G1GC
2018-12-21 08:18:59 -08:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2019-03-04 11:49:16 +01:00
if ( g1h - > is_heterogeneous_heap ( ) ) {
2018-12-21 08:18:59 -08:00
uint start_region = HeterogeneousHeapRegionManager : : manager ( ) - > start_index_of_nvdimm ( ) ;
2020-09-02 10:07:03 +02:00
return ( jlong ) ( g1h - > reserved ( ) . start ( ) + start_region * HeapRegion : : GrainBytes ) ;
2018-12-21 08:18:59 -08:00
} else {
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedStart: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag " ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_G1GC
# if INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
if ( UseParallelGC ) {
ParallelScavengeHeap * ps_heap = ParallelScavengeHeap : : heap ( ) ;
if ( AllocateOldGenAt ! = NULL ) {
MemRegion reserved = ps_heap - > old_gen ( ) - > reserved ( ) ;
return ( jlong ) reserved . start ( ) ;
} else {
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedStart: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag " ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedStart: enabled only for G1 and Parallel GC " ) ;
2018-12-21 08:18:59 -08:00
WB_END
WB_ENTRY ( jlong , WB_NvdimmReservedEnd ( JNIEnv * env , jobject o ) )
2018-12-22 15:46:54 +01:00
# if INCLUDE_G1GC
2018-12-21 08:18:59 -08:00
if ( UseG1GC ) {
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
2019-03-04 11:49:16 +01:00
if ( g1h - > is_heterogeneous_heap ( ) ) {
2018-12-21 08:18:59 -08:00
uint end_region = HeterogeneousHeapRegionManager : : manager ( ) - > start_index_of_nvdimm ( ) ;
2020-09-02 10:07:03 +02:00
return ( jlong ) ( g1h - > reserved ( ) . start ( ) + ( end_region + 1 ) * HeapRegion : : GrainBytes - 1 ) ;
2018-12-21 08:18:59 -08:00
} else {
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedEnd: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag " ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_G1GC
# if INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
if ( UseParallelGC ) {
ParallelScavengeHeap * ps_heap = ParallelScavengeHeap : : heap ( ) ;
if ( AllocateOldGenAt ! = NULL ) {
MemRegion reserved = ps_heap - > old_gen ( ) - > reserved ( ) ;
return ( jlong ) reserved . end ( ) ;
} else {
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedEnd: Old gen is not allocated on NV-DIMM using AllocateOldGenAt flag " ) ;
}
}
2018-12-22 15:46:54 +01:00
# endif // INCLUDE_PARALLELGC
2018-12-21 08:23:55 -08:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_NvdimmReservedEnd: enabled only for G1 and Parallel GC " ) ;
2018-12-21 08:18:59 -08:00
WB_END
2018-12-21 08:23:55 -08:00
# endif // INCLUDE_G1GC || INCLUDE_PARALLELGC
2018-12-21 08:18:59 -08:00
2018-05-04 11:41:35 +02:00
# if INCLUDE_PARALLELGC
2015-09-01 21:38:07 +03:00
WB_ENTRY ( jlong , WB_PSVirtualSpaceAlignment ( JNIEnv * env , jobject o ) )
2016-08-02 15:22:41 +03:00
if ( UseParallelGC ) {
2020-04-21 10:10:23 +02:00
return GenAlignment ;
2016-08-02 15:22:41 +03:00
}
2017-03-20 16:01:33 +03:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_PSVirtualSpaceAlignment: Parallel GC is not enabled " ) ;
2015-09-01 21:38:07 +03:00
WB_END
WB_ENTRY ( jlong , WB_PSHeapGenerationAlignment ( JNIEnv * env , jobject o ) )
2016-08-02 15:22:41 +03:00
if ( UseParallelGC ) {
2019-04-15 11:47:46 +02:00
return GenAlignment ;
2016-08-02 15:22:41 +03:00
}
2017-03-20 16:01:33 +03:00
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_PSHeapGenerationAlignment: Parallel GC is not enabled " ) ;
2015-09-01 21:38:07 +03:00
WB_END
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_PARALLELGC
# if INCLUDE_G1GC
2015-03-16 17:51:28 +03:00
WB_ENTRY ( jobject , WB_G1AuxiliaryMemoryUsage ( JNIEnv * env ) )
2017-03-20 16:01:33 +03:00
if ( UseG1GC ) {
ResourceMark rm ( THREAD ) ;
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
MemoryUsage usage = g1h - > get_auxiliary_data_memory_usage ( ) ;
Handle h = MemoryService : : create_MemoryUsage_obj ( usage , CHECK_NULL ) ;
2020-07-22 01:27:08 -04:00
return JNIHandles : : make_local ( THREAD , h ( ) ) ;
2017-03-20 16:01:33 +03:00
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1AuxiliaryMemoryUsage: G1 GC is not enabled " ) ;
2015-03-16 17:51:28 +03:00
WB_END
2016-04-20 19:54:51 +03:00
2019-11-13 10:49:12 -08:00
WB_ENTRY ( jint , WB_G1ActiveMemoryNodeCount ( JNIEnv * env , jobject o ) )
if ( UseG1GC ) {
G1NUMA * numa = G1NUMA : : numa ( ) ;
return ( jint ) numa - > num_active_nodes ( ) ;
}
THROW_MSG_0 ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1ActiveMemoryNodeCount: G1 GC is not enabled " ) ;
WB_END
WB_ENTRY ( jintArray , WB_G1MemoryNodeIds ( JNIEnv * env , jobject o ) )
if ( UseG1GC ) {
G1NUMA * numa = G1NUMA : : numa ( ) ;
int num_node_ids = ( int ) numa - > num_active_nodes ( ) ;
const int * node_ids = numa - > node_ids ( ) ;
typeArrayOop result = oopFactory : : new_intArray ( num_node_ids , CHECK_NULL ) ;
for ( int i = 0 ; i < num_node_ids ; i + + ) {
result - > int_at_put ( i , ( jint ) node_ids [ i ] ) ;
}
2020-07-22 01:27:08 -04:00
return ( jintArray ) JNIHandles : : make_local ( THREAD , result ) ;
2019-11-13 10:49:12 -08:00
}
THROW_MSG_NULL ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1MemoryNodeIds: G1 GC is not enabled " ) ;
WB_END
2016-04-20 19:54:51 +03:00
class OldRegionsLivenessClosure : public HeapRegionClosure {
private :
const int _liveness ;
size_t _total_count ;
size_t _total_memory ;
size_t _total_memory_to_free ;
public :
OldRegionsLivenessClosure ( int liveness ) :
_liveness ( liveness ) ,
_total_count ( 0 ) ,
_total_memory ( 0 ) ,
_total_memory_to_free ( 0 ) { }
size_t total_count ( ) { return _total_count ; }
size_t total_memory ( ) { return _total_memory ; }
size_t total_memory_to_free ( ) { return _total_memory_to_free ; }
2018-02-09 13:09:55 +01:00
bool do_heap_region ( HeapRegion * r ) {
2016-04-20 19:54:51 +03:00
if ( r - > is_old ( ) ) {
size_t prev_live = r - > marked_bytes ( ) ;
size_t live = r - > live_bytes ( ) ;
size_t size = r - > used ( ) ;
size_t reg_size = HeapRegion : : GrainBytes ;
if ( size > 0 & & ( ( int ) ( live * 100 / size ) < _liveness ) ) {
_total_memory + = size ;
+ + _total_count ;
if ( size = = reg_size ) {
// we don't include non-full regions since they are unlikely included in mixed gc
// for testing purposes it's enough to have lowest estimation of total memory that is expected to be freed
_total_memory_to_free + = size - prev_live ;
}
}
}
return false ;
}
} ;
WB_ENTRY ( jlongArray , WB_G1GetMixedGCInfo ( JNIEnv * env , jobject o , jint liveness ) )
if ( ! UseG1GC ) {
2017-03-20 16:01:33 +03:00
THROW_MSG_NULL ( vmSymbols : : java_lang_UnsupportedOperationException ( ) , " WB_G1GetMixedGCInfo: G1 GC is not enabled " ) ;
2016-04-20 19:54:51 +03:00
}
if ( liveness < 0 ) {
THROW_MSG_NULL ( vmSymbols : : java_lang_IllegalArgumentException ( ) , " liveness value should be non-negative " ) ;
}
G1CollectedHeap * g1h = G1CollectedHeap : : heap ( ) ;
OldRegionsLivenessClosure rli ( liveness ) ;
g1h - > heap_region_iterate ( & rli ) ;
typeArrayOop result = oopFactory : : new_longArray ( 3 , CHECK_NULL ) ;
result - > long_at_put ( 0 , rli . total_count ( ) ) ;
result - > long_at_put ( 1 , rli . total_memory ( ) ) ;
result - > long_at_put ( 2 , rli . total_memory_to_free ( ) ) ;
2020-07-22 01:27:08 -04:00
return ( jlongArray ) JNIHandles : : make_local ( THREAD , result ) ;
2016-04-20 19:54:51 +03:00
WB_END
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_G1GC
2012-02-23 14:58:35 +01:00
2013-08-23 12:36:32 -07:00
# if INCLUDE_NMT
2013-02-01 23:48:08 +01:00
// Alloc memory using the test memory type so that we can use that to see if
// NMT picks it up correctly
2013-04-03 21:41:33 +02:00
WB_ENTRY ( jlong , WB_NMTMalloc ( JNIEnv * env , jobject o , jlong size ) )
jlong addr = 0 ;
2014-11-05 13:20:09 -08:00
addr = ( jlong ) ( uintptr_t ) os : : malloc ( size , mtTest ) ;
2013-04-03 21:41:33 +02:00
return addr ;
2013-02-01 23:48:08 +01:00
WB_END
2014-08-07 12:18:58 -07:00
// Alloc memory with pseudo call stack. The test can create psudo malloc
// allocation site to stress the malloc tracking.
WB_ENTRY ( jlong , WB_NMTMallocWithPseudoStack ( JNIEnv * env , jobject o , jlong size , jint pseudo_stack ) )
address pc = ( address ) ( size_t ) pseudo_stack ;
NativeCallStack stack ( & pc , 1 ) ;
2014-11-05 13:20:09 -08:00
return ( jlong ) ( uintptr_t ) os : : malloc ( size , mtTest , stack ) ;
2014-08-07 12:18:58 -07:00
WB_END
2019-02-08 14:03:09 -05:00
// Alloc memory with pseudo call stack and specific memory type.
WB_ENTRY ( jlong , WB_NMTMallocWithPseudoStackAndType ( JNIEnv * env , jobject o , jlong size , jint pseudo_stack , jint type ) )
address pc = ( address ) ( size_t ) pseudo_stack ;
NativeCallStack stack ( & pc , 1 ) ;
return ( jlong ) ( uintptr_t ) os : : malloc ( size , ( MEMFLAGS ) type , stack ) ;
WB_END
2013-02-01 23:48:08 +01:00
// Free the memory allocated by NMTAllocTest
2013-04-03 21:41:33 +02:00
WB_ENTRY ( void , WB_NMTFree ( JNIEnv * env , jobject o , jlong mem ) )
2014-12-01 12:16:15 -05:00
os : : free ( ( void * ) ( uintptr_t ) mem ) ;
2013-04-03 21:41:33 +02:00
WB_END
2013-02-01 23:48:08 +01:00
2013-04-03 21:41:33 +02:00
WB_ENTRY ( jlong , WB_NMTReserveMemory ( JNIEnv * env , jobject o , jlong size ) )
jlong addr = 0 ;
2014-11-10 19:04:38 +03:00
addr = ( jlong ) ( uintptr_t ) os : : reserve_memory ( size ) ;
MemTracker : : record_virtual_memory_type ( ( address ) addr , mtTest ) ;
2013-02-01 23:48:08 +01:00
2013-04-03 21:41:33 +02:00
return addr ;
WB_END
2013-02-01 23:48:08 +01:00
2018-02-21 12:40:07 +01:00
WB_ENTRY ( jlong , WB_NMTAttemptReserveMemoryAt ( JNIEnv * env , jobject o , jlong addr , jlong size ) )
addr = ( jlong ) ( uintptr_t ) os : : attempt_reserve_memory_at ( ( size_t ) size , ( char * ) ( uintptr_t ) addr ) ;
MemTracker : : record_virtual_memory_type ( ( address ) addr , mtTest ) ;
return addr ;
WB_END
2013-04-03 21:41:33 +02:00
WB_ENTRY ( void , WB_NMTCommitMemory ( JNIEnv * env , jobject o , jlong addr , jlong size ) )
2013-06-13 11:16:38 -07:00
os : : commit_memory ( ( char * ) ( uintptr_t ) addr , size , ! ExecMem ) ;
2013-04-03 21:41:33 +02:00
MemTracker : : record_virtual_memory_type ( ( address ) ( uintptr_t ) addr , mtTest ) ;
WB_END
WB_ENTRY ( void , WB_NMTUncommitMemory ( JNIEnv * env , jobject o , jlong addr , jlong size ) )
os : : uncommit_memory ( ( char * ) ( uintptr_t ) addr , size ) ;
WB_END
WB_ENTRY ( void , WB_NMTReleaseMemory ( JNIEnv * env , jobject o , jlong addr , jlong size ) )
os : : release_memory ( ( char * ) ( uintptr_t ) addr , size ) ;
2013-02-01 23:48:08 +01:00
WB_END
2014-10-10 19:36:12 +00:00
WB_ENTRY ( jboolean , WB_NMTChangeTrackingLevel ( JNIEnv * env ) )
// Test that we can downgrade NMT levels but not upgrade them.
if ( MemTracker : : tracking_level ( ) = = NMT_off ) {
MemTracker : : transition_to ( NMT_off ) ;
return MemTracker : : tracking_level ( ) = = NMT_off ;
} else {
assert ( MemTracker : : tracking_level ( ) = = NMT_detail , " Should start out as detail tracking " ) ;
MemTracker : : transition_to ( NMT_summary ) ;
assert ( MemTracker : : tracking_level ( ) = = NMT_summary , " Should be summary now " ) ;
// Can't go to detail once NMT is set to summary.
MemTracker : : transition_to ( NMT_detail ) ;
assert ( MemTracker : : tracking_level ( ) = = NMT_summary , " Should still be summary now " ) ;
// Shutdown sets tracking level to minimal.
MemTracker : : shutdown ( ) ;
assert ( MemTracker : : tracking_level ( ) = = NMT_minimal , " Should be minimal now " ) ;
2013-08-23 12:36:32 -07:00
2014-10-10 19:36:12 +00:00
// Once the tracking level is minimal, we cannot increase to summary.
// The code ignores this request instead of asserting because if the malloc site
// table overflows in another thread, it tries to change the code to summary.
MemTracker : : transition_to ( NMT_summary ) ;
assert ( MemTracker : : tracking_level ( ) = = NMT_minimal , " Should still be minimal now " ) ;
// Really can never go up to detail, verify that the code would never do this.
MemTracker : : transition_to ( NMT_detail ) ;
assert ( MemTracker : : tracking_level ( ) = = NMT_minimal , " Should still be minimal now " ) ;
return MemTracker : : tracking_level ( ) = = NMT_minimal ;
}
WB_END
2014-11-05 08:22:17 -08:00
WB_ENTRY ( jint , WB_NMTGetHashSize ( JNIEnv * env , jobject o ) )
int hash_size = MallocSiteTable : : hash_buckets ( ) ;
assert ( hash_size > 0 , " NMT hash_size should be > 0 " ) ;
return ( jint ) hash_size ;
WB_END
2019-11-26 09:27:16 -05:00
WB_ENTRY ( jlong , WB_NMTNewArena ( JNIEnv * env , jobject o , jlong init_size ) )
Arena * arena = new ( mtTest ) Arena ( mtTest , size_t ( init_size ) ) ;
return ( jlong ) arena ;
WB_END
WB_ENTRY ( void , WB_NMTFreeArena ( JNIEnv * env , jobject o , jlong arena ) )
Arena * a = ( Arena * ) arena ;
delete a ;
WB_END
WB_ENTRY ( void , WB_NMTArenaMalloc ( JNIEnv * env , jobject o , jlong arena , jlong size ) )
Arena * a = ( Arena * ) arena ;
a - > Amalloc ( size_t ( size ) ) ;
WB_END
2013-02-01 23:48:08 +01:00
# endif // INCLUDE_NMT
2013-02-13 08:29:04 -08:00
static jmethodID reflected_method_to_jmid ( JavaThread * thread , JNIEnv * env , jobject method ) {
assert ( method ! = NULL , " method should not be null " ) ;
ThreadToNativeFromVM ttn ( thread ) ;
return env - > FromReflectedMethod ( method ) ;
}
2020-02-26 00:07:21 -05:00
static CompLevel highestCompLevel ( ) {
return TieredCompilation ? MIN2 ( ( CompLevel ) TieredStopAtLevel , CompLevel_highest_tier ) : CompLevel_highest_tier ;
}
2014-12-16 17:56:24 +03:00
// Deoptimizes all compiled frames and makes nmethods not entrant if it's requested
class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
private :
int _result ;
const bool _make_not_entrant ;
public :
VM_WhiteBoxDeoptimizeFrames ( bool make_not_entrant ) :
_result ( 0 ) , _make_not_entrant ( make_not_entrant ) { }
int result ( ) const { return _result ; }
void doit ( ) {
2017-11-22 17:54:50 -08:00
for ( JavaThreadIteratorWithHandle jtiwh ; JavaThread * t = jtiwh . next ( ) ; ) {
2014-12-16 17:56:24 +03:00
if ( t - > has_last_Java_frame ( ) ) {
2020-02-12 09:18:37 +01:00
for ( StackFrameStream fst ( t , false ) ; ! fst . is_done ( ) ; fst . next ( ) ) {
2014-12-16 17:56:24 +03:00
frame * f = fst . current ( ) ;
if ( f - > can_be_deoptimized ( ) & & ! f - > is_deoptimized_frame ( ) ) {
2020-02-12 09:18:37 +01:00
Deoptimization : : deoptimize ( t , * f ) ;
2014-12-16 17:56:24 +03:00
if ( _make_not_entrant ) {
2016-04-26 10:28:51 +02:00
CompiledMethod * cm = CodeCache : : find_compiled ( f - > pc ( ) ) ;
assert ( cm ! = NULL , " sanity check " ) ;
cm - > make_not_entrant ( ) ;
2014-12-16 17:56:24 +03:00
}
+ + _result ;
}
}
}
}
}
} ;
WB_ENTRY ( jint , WB_DeoptimizeFrames ( JNIEnv * env , jobject o , jboolean make_not_entrant ) )
VM_WhiteBoxDeoptimizeFrames op ( make_not_entrant = = JNI_TRUE ) ;
VMThread : : execute ( & op ) ;
return op . result ( ) ;
WB_END
2013-02-13 08:29:04 -08:00
WB_ENTRY ( void , WB_DeoptimizeAll ( JNIEnv * env , jobject o ) )
CodeCache : : mark_all_nmethods_for_deoptimization ( ) ;
2019-09-19 10:52:22 +02:00
Deoptimization : : deoptimize_all_marked ( ) ;
2013-02-13 08:29:04 -08:00
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jint , WB_DeoptimizeMethod ( JNIEnv * env , jobject o , jobject method , jboolean is_osr ) )
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
int result = 0 ;
CHECK_JNI_EXCEPTION_ ( env , result ) ;
2019-04-25 10:56:31 -04:00
MutexLocker mu ( Compile_lock ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2013-08-14 23:50:23 +04:00
if ( is_osr ) {
2014-10-30 13:03:30 +01:00
result + = mh - > mark_osr_nmethods ( ) ;
} else if ( mh - > code ( ) ! = NULL ) {
mh - > code ( ) - > mark_for_deoptimization ( ) ;
2013-02-13 08:29:04 -08:00
+ + result ;
}
result + = CodeCache : : mark_for_deoptimization ( mh ( ) ) ;
if ( result > 0 ) {
2019-09-19 10:52:22 +02:00
Deoptimization : : deoptimize_all_marked ( ) ;
2013-02-13 08:29:04 -08:00
}
return result ;
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jboolean , WB_IsMethodCompiled ( JNIEnv * env , jobject o , jobject method , jboolean is_osr ) )
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
2019-04-25 10:56:31 -04:00
MutexLocker mu ( Compile_lock ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2016-04-26 10:28:51 +02:00
CompiledMethod * code = is_osr ? mh - > lookup_osr_nmethod_for ( InvocationEntryBci , CompLevel_none , false ) : mh - > code ( ) ;
2013-02-13 08:29:04 -08:00
if ( code = = NULL ) {
return JNI_FALSE ;
}
return ( code - > is_alive ( ) & & ! code - > is_marked_for_deoptimization ( ) ) ;
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jboolean , WB_IsMethodCompilable ( JNIEnv * env , jobject o , jobject method , jint comp_level , jboolean is_osr ) )
2020-02-26 00:07:21 -05:00
if ( method = = NULL | | comp_level > highestCompLevel ( ) ) {
2017-01-17 21:38:07 -08:00
return false ;
}
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
2019-04-25 10:56:31 -04:00
MutexLocker mu ( Compile_lock ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2013-08-14 23:50:23 +04:00
if ( is_osr ) {
return CompilationPolicy : : can_be_osr_compiled ( mh , comp_level ) ;
} else {
return CompilationPolicy : : can_be_compiled ( mh , comp_level ) ;
}
2013-02-13 08:29:04 -08:00
WB_END
WB_ENTRY ( jboolean , WB_IsMethodQueuedForCompilation ( JNIEnv * env , jobject o , jobject method ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
2019-04-25 10:56:31 -04:00
MutexLocker mu ( Compile_lock ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
return mh - > queued_for_compilation ( ) ;
WB_END
2015-07-28 19:20:42 +02:00
WB_ENTRY ( jboolean , WB_IsIntrinsicAvailable ( JNIEnv * env , jobject o , jobject method , jobject compilation_context , jint compLevel ) )
2020-02-26 00:07:21 -05:00
if ( compLevel < CompLevel_none | | compLevel > highestCompLevel ( ) ) {
2015-07-28 19:20:42 +02:00
return false ; // Intrinsic is not available on a non-existent compilation level.
}
jmethodID method_id , compilation_context_id ;
method_id = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( method_id ) ) ;
2015-10-20 18:07:28 +02:00
DirectiveSet * directive ;
2016-01-14 13:24:03 +01:00
AbstractCompiler * comp = CompileBroker : : compiler ( ( int ) compLevel ) ;
2016-08-04 08:58:22 +02:00
assert ( comp ! = NULL , " compiler not available " ) ;
2015-07-28 19:20:42 +02:00
if ( compilation_context ! = NULL ) {
compilation_context_id = reflected_method_to_jmid ( thread , env , compilation_context ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
methodHandle cch ( THREAD , Method : : checked_resolve_jmethod_id ( compilation_context_id ) ) ;
2016-01-14 13:24:03 +01:00
directive = DirectivesStack : : getMatchingDirective ( cch , comp ) ;
2015-07-28 19:20:42 +02:00
} else {
2015-10-20 18:07:28 +02:00
// Calling with NULL matches default directive
2016-01-14 13:24:03 +01:00
directive = DirectivesStack : : getDefaultDirective ( comp ) ;
2015-07-28 19:20:42 +02:00
}
2016-08-04 08:58:22 +02:00
bool result = comp - > is_intrinsic_available ( mh , directive ) ;
2015-10-20 18:07:28 +02:00
DirectivesStack : : release ( directive ) ;
return result ;
2015-07-28 19:20:42 +02:00
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jint , WB_GetMethodCompilationLevel ( JNIEnv * env , jobject o , jobject method , jboolean is_osr ) )
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , CompLevel_none ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2016-04-26 10:28:51 +02:00
CompiledMethod * code = is_osr ? mh - > lookup_osr_nmethod_for ( InvocationEntryBci , CompLevel_none , false ) : mh - > code ( ) ;
2013-02-13 08:29:04 -08:00
return ( code ! = NULL ? code - > comp_level ( ) : CompLevel_none ) ;
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( void , WB_MakeMethodNotCompilable ( JNIEnv * env , jobject o , jobject method , jint comp_level , jboolean is_osr ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION ( env ) ;
2013-08-14 23:50:23 +04:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
if ( is_osr ) {
2019-06-04 12:44:53 -07:00
mh - > set_not_osr_compilable ( " WhiteBox " , comp_level ) ;
2013-08-14 23:50:23 +04:00
} else {
2019-06-04 12:44:53 -07:00
mh - > set_not_compilable ( " WhiteBox " , comp_level ) ;
2013-08-14 23:50:23 +04:00
}
WB_END
2013-02-13 08:29:04 -08:00
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jint , WB_GetMethodEntryBci ( JNIEnv * env , jobject o , jobject method ) )
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , InvocationEntryBci ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2016-04-26 10:28:51 +02:00
CompiledMethod * code = mh - > lookup_osr_nmethod_for ( InvocationEntryBci , CompLevel_none , false ) ;
2013-08-14 23:50:23 +04:00
return ( code ! = NULL & & code - > is_osr_method ( ) ? code - > osr_entry_bci ( ) : InvocationEntryBci ) ;
2013-02-13 08:29:04 -08:00
WB_END
2013-04-09 09:54:17 -07:00
WB_ENTRY ( jboolean , WB_TestSetDontInlineMethod ( JNIEnv * env , jobject o , jobject method , jboolean value ) )
2013-02-13 08:29:04 -08:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
2013-02-13 08:29:04 -08:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
bool result = mh - > dont_inline ( ) ;
mh - > set_dont_inline ( value = = JNI_TRUE ) ;
return result ;
WB_END
2013-08-14 23:50:23 +04:00
WB_ENTRY ( jint , WB_GetCompileQueueSize ( JNIEnv * env , jobject o , jint comp_level ) )
if ( comp_level = = CompLevel_any ) {
return CompileBroker : : queue_size ( CompLevel_full_optimization ) /* C2 */ +
CompileBroker : : queue_size ( CompLevel_full_profile ) /* C1 */ ;
} else {
return CompileBroker : : queue_size ( comp_level ) ;
}
2013-02-13 08:29:04 -08:00
WB_END
2013-04-09 09:54:17 -07:00
WB_ENTRY ( jboolean , WB_TestSetForceInlineMethod ( JNIEnv * env , jobject o , jobject method , jboolean value ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
2013-04-09 09:54:17 -07:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
bool result = mh - > force_inline ( ) ;
mh - > set_force_inline ( value = = JNI_TRUE ) ;
return result ;
WB_END
2020-02-25 12:17:26 +01:00
# ifdef LINUX
bool WhiteBox : : validate_cgroup ( const char * proc_cgroups ,
const char * proc_self_cgroup ,
const char * proc_self_mountinfo ,
u1 * cg_flags ) {
CgroupInfo cg_infos [ 4 ] ;
return CgroupSubsystemFactory : : determine_type ( cg_infos , proc_cgroups ,
proc_self_cgroup ,
proc_self_mountinfo , cg_flags ) ;
}
# endif
2016-04-07 16:51:37 +02:00
bool WhiteBox : : compile_method ( Method * method , int comp_level , int bci , Thread * THREAD ) {
// Screen for unavailable/bad comp level or null method
2018-03-21 08:18:54 +01:00
AbstractCompiler * comp = CompileBroker : : compiler ( comp_level ) ;
2018-06-26 09:14:49 -07:00
if ( method = = NULL ) {
tty - > print_cr ( " WB error: request to compile NULL method " ) ;
return false ;
}
2020-02-26 00:07:21 -05:00
if ( comp_level > highestCompLevel ( ) ) {
2018-06-26 09:14:49 -07:00
tty - > print_cr ( " WB error: invalid compilation level %d " , comp_level ) ;
return false ;
}
if ( comp = = NULL ) {
tty - > print_cr ( " WB error: no compiler for requested compilation level %d " , comp_level ) ;
2016-03-03 16:21:16 +01:00
return false ;
}
2018-03-21 08:18:54 +01:00
// Check if compilation is blocking
2016-04-07 16:51:37 +02:00
methodHandle mh ( THREAD , method ) ;
2018-03-21 08:18:54 +01:00
DirectiveSet * directive = DirectivesStack : : getMatchingDirective ( mh , comp ) ;
bool is_blocking = ! directive - > BackgroundCompilationOption ;
DirectivesStack : : release ( directive ) ;
// Compile method and check result
2020-09-18 05:48:14 +00:00
nmethod * nm = CompileBroker : : compile_method ( mh , bci , comp_level , mh , mh - > invocation_count ( ) , CompileTask : : Reason_Whitebox , CHECK_false ) ;
2020-01-16 13:48:23 +00:00
MutexLocker mu ( THREAD , Compile_lock ) ;
2018-06-26 09:14:49 -07:00
bool is_queued = mh - > queued_for_compilation ( ) ;
if ( ( ! is_blocking & & is_queued ) | | nm ! = NULL ) {
return true ;
}
tty - > print ( " WB error: failed to %s compile at level %d method " , is_blocking ? " blocking " : " " , comp_level ) ;
mh - > print_short_name ( tty ) ;
tty - > cr ( ) ;
if ( is_blocking & & is_queued ) {
tty - > print_cr ( " WB error: blocking compilation is still in queue! " ) ;
}
return false ;
2016-04-07 16:51:37 +02:00
}
WB_ENTRY ( jboolean , WB_EnqueueMethodForCompilation ( JNIEnv * env , jobject o , jobject method , jint comp_level , jint bci ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
return WhiteBox : : compile_method ( Method : : checked_resolve_jmethod_id ( jmid ) , comp_level , bci , THREAD ) ;
WB_END
WB_ENTRY ( jboolean , WB_EnqueueInitializerForCompilation ( JNIEnv * env , jobject o , jclass klass , jint comp_level ) )
2017-03-15 10:25:37 -04:00
InstanceKlass * ik = InstanceKlass : : cast ( java_lang_Class : : as_Klass ( JNIHandles : : resolve ( klass ) ) ) ;
2018-11-15 14:01:10 -08:00
Method * clinit = ik - > class_initializer ( ) ;
if ( clinit = = NULL ) {
return false ;
}
return WhiteBox : : compile_method ( clinit , comp_level , InvocationEntryBci , THREAD ) ;
2013-04-09 09:54:17 -07:00
WB_END
2016-02-25 10:42:42 +01:00
WB_ENTRY ( jboolean , WB_ShouldPrintAssembly ( JNIEnv * env , jobject o , jobject method , jint comp_level ) )
2015-10-20 18:07:28 +02:00
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2016-02-25 10:42:42 +01:00
DirectiveSet * directive = DirectivesStack : : getMatchingDirective ( mh , CompileBroker : : compiler ( comp_level ) ) ;
2015-10-20 18:07:28 +02:00
bool result = directive - > PrintAssemblyOption ;
DirectivesStack : : release ( directive ) ;
return result ;
WB_END
WB_ENTRY ( jint , WB_MatchesInline ( JNIEnv * env , jobject o , jobject method , jstring pattern ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2020-01-16 13:48:23 +00:00
ResourceMark rm ( THREAD ) ;
2015-10-20 18:07:28 +02:00
const char * error_msg = NULL ;
char * method_str = java_lang_String : : as_utf8_string ( JNIHandles : : resolve_non_null ( pattern ) ) ;
InlineMatcher * m = InlineMatcher : : parse_inline_pattern ( method_str , error_msg ) ;
if ( m = = NULL ) {
assert ( error_msg ! = NULL , " Always have an error message " ) ;
tty - > print_cr ( " Got error: %s " , error_msg ) ;
return - 1 ; // Pattern failed
}
// Pattern works - now check if it matches
int result ;
if ( m - > match ( mh , InlineMatcher : : force_inline ) ) {
result = 2 ; // Force inline match
} else if ( m - > match ( mh , InlineMatcher : : dont_inline ) ) {
result = 1 ; // Dont inline match
} else {
result = 0 ; // No match
}
delete m ;
return result ;
WB_END
2015-09-18 10:11:11 +02:00
WB_ENTRY ( jint , WB_MatchesMethod ( JNIEnv * env , jobject o , jobject method , jstring pattern ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , JNI_FALSE ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
ResourceMark rm ;
char * method_str = java_lang_String : : as_utf8_string ( JNIHandles : : resolve_non_null ( pattern ) ) ;
const char * error_msg = NULL ;
BasicMatcher * m = BasicMatcher : : parse_method_pattern ( method_str , error_msg ) ;
if ( m = = NULL ) {
assert ( error_msg ! = NULL , " Must have error_msg " ) ;
tty - > print_cr ( " Got error: %s " , error_msg ) ;
return - 1 ;
}
// Pattern works - now check if it matches
int result = m - > matches ( mh ) ;
delete m ;
assert ( result = = 0 | | result = = 1 , " Result out of range " ) ;
return result ;
WB_END
2019-05-07 09:17:03 +02:00
WB_ENTRY ( void , WB_MarkMethodProfiled ( JNIEnv * env , jobject o , jobject method ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION ( env ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
MethodData * mdo = mh - > method_data ( ) ;
if ( mdo = = NULL ) {
Method : : build_interpreter_method_data ( mh , CHECK_AND_CLEAR ) ;
mdo = mh - > method_data ( ) ;
}
mdo - > init ( ) ;
InvocationCounter * icnt = mdo - > invocation_counter ( ) ;
InvocationCounter * bcnt = mdo - > backedge_counter ( ) ;
// set i-counter according to TieredThresholdPolicy::is_method_profiled
2020-02-12 20:53:48 +01:00
icnt - > set ( Tier4MinInvocationThreshold ) ;
bcnt - > set ( Tier4CompileThreshold ) ;
2019-05-07 09:17:03 +02:00
WB_END
2013-04-09 09:54:17 -07:00
WB_ENTRY ( void , WB_ClearMethodState ( JNIEnv * env , jobject o , jobject method ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
2014-02-12 12:01:45 -08:00
CHECK_JNI_EXCEPTION ( env ) ;
2013-04-09 09:54:17 -07:00
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2020-01-16 13:48:23 +00:00
MutexLocker mu ( THREAD , Compile_lock ) ;
2013-04-09 09:54:17 -07:00
MethodData * mdo = mh - > method_data ( ) ;
2013-04-15 21:25:23 -04:00
MethodCounters * mcs = mh - > method_counters ( ) ;
2013-04-09 09:54:17 -07:00
if ( mdo ! = NULL ) {
mdo - > init ( ) ;
2020-01-16 13:48:23 +00:00
ResourceMark rm ( THREAD ) ;
2013-04-09 09:54:17 -07:00
int arg_count = mdo - > method ( ) - > size_of_parameters ( ) ;
for ( int i = 0 ; i < arg_count ; i + + ) {
mdo - > set_arg_modified ( i , 0 ) ;
}
2020-01-16 13:48:23 +00:00
MutexLocker mu ( THREAD , mdo - > extra_data_lock ( ) ) ;
2018-04-18 13:37:39 -04:00
mdo - > clean_method_data ( /*always_clean*/ true ) ;
2013-04-09 09:54:17 -07:00
}
mh - > clear_not_c1_compilable ( ) ;
mh - > clear_not_c2_compilable ( ) ;
mh - > clear_not_c2_osr_compilable ( ) ;
NOT_PRODUCT ( mh - > set_compiled_invocation_count ( 0 ) ) ;
2013-04-15 21:25:23 -04:00
if ( mcs ! = NULL ) {
mcs - > backedge_counter ( ) - > init ( ) ;
mcs - > invocation_counter ( ) - > init ( ) ;
mcs - > set_interpreter_invocation_count ( 0 ) ;
mcs - > set_interpreter_throwout_count ( 0 ) ;
2013-04-09 09:54:17 -07:00
# ifdef TIERED
2013-04-15 21:25:23 -04:00
mcs - > set_rate ( 0.0F ) ;
2014-03-11 15:06:34 +04:00
mh - > set_prev_event_count ( 0 ) ;
mh - > set_prev_time ( 0 ) ;
2013-04-09 09:54:17 -07:00
# endif
2013-04-15 21:25:23 -04:00
}
2013-04-09 09:54:17 -07:00
WB_END
2020-09-22 06:04:31 +00:00
template < typename T , int type_enum >
static bool GetVMFlag ( JavaThread * thread , JNIEnv * env , jstring name , T * value ) {
2014-05-30 17:20:48 +04:00
if ( name = = NULL ) {
return false ;
}
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
const char * flag_name = env - > GetStringUTFChars ( name , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , false ) ;
2019-08-26 09:15:43 +02:00
const JVMFlag * flag = JVMFlag : : find_declared_flag ( flag_name ) ;
2020-09-22 06:04:31 +00:00
JVMFlag : : Error result = JVMFlagAccess : : get < T , type_enum > ( flag , value ) ;
2014-05-30 17:20:48 +04:00
env - > ReleaseStringUTFChars ( name , flag_name ) ;
2018-04-26 11:19:05 -05:00
return ( result = = JVMFlag : : SUCCESS ) ;
2014-05-30 17:20:48 +04:00
}
2020-09-22 06:04:31 +00:00
template < typename T , int type_enum >
static bool SetVMFlag ( JavaThread * thread , JNIEnv * env , jstring name , T * value ) {
2014-05-30 17:20:48 +04:00
if ( name = = NULL ) {
return false ;
}
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
const char * flag_name = env - > GetStringUTFChars ( name , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , false ) ;
2019-08-26 09:15:43 +02:00
JVMFlag * flag = JVMFlag : : find_flag ( flag_name ) ;
2020-09-22 06:04:31 +00:00
JVMFlag : : Error result = JVMFlagAccess : : set < T , type_enum > ( flag , value , JVMFlag : : INTERNAL ) ;
2014-05-30 17:20:48 +04:00
env - > ReleaseStringUTFChars ( name , flag_name ) ;
2018-04-26 11:19:05 -05:00
return ( result = = JVMFlag : : SUCCESS ) ;
2014-05-30 17:20:48 +04:00
}
template < typename T >
static jobject box ( JavaThread * thread , JNIEnv * env , Symbol * name , Symbol * sig , T value ) {
ResourceMark rm ( thread ) ;
jclass clazz = env - > FindClass ( name - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
jmethodID methodID = env - > GetStaticMethodID ( clazz ,
vmSymbols : : valueOf_name ( ) - > as_C_string ( ) ,
sig - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
jobject result = env - > CallStaticObjectMethod ( clazz , methodID , value ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
return result ;
}
static jobject booleanBox ( JavaThread * thread , JNIEnv * env , jboolean value ) {
return box ( thread , env , vmSymbols : : java_lang_Boolean ( ) , vmSymbols : : Boolean_valueOf_signature ( ) , value ) ;
}
static jobject integerBox ( JavaThread * thread , JNIEnv * env , jint value ) {
return box ( thread , env , vmSymbols : : java_lang_Integer ( ) , vmSymbols : : Integer_valueOf_signature ( ) , value ) ;
}
static jobject longBox ( JavaThread * thread , JNIEnv * env , jlong value ) {
return box ( thread , env , vmSymbols : : java_lang_Long ( ) , vmSymbols : : Long_valueOf_signature ( ) , value ) ;
}
/* static jobject floatBox(JavaThread* thread, JNIEnv* env, jfloat value) {
return box ( thread , env , vmSymbols : : java_lang_Float ( ) , vmSymbols : : Float_valueOf_signature ( ) , value ) ;
} */
static jobject doubleBox ( JavaThread * thread , JNIEnv * env , jdouble value ) {
return box ( thread , env , vmSymbols : : java_lang_Double ( ) , vmSymbols : : Double_valueOf_signature ( ) , value ) ;
}
2019-08-26 09:15:43 +02:00
static const JVMFlag * getVMFlag ( JavaThread * thread , JNIEnv * env , jstring name ) {
2014-10-24 08:22:33 +02:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
const char * flag_name = env - > GetStringUTFChars ( name , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2019-08-26 09:15:43 +02:00
const JVMFlag * result = JVMFlag : : find_declared_flag ( flag_name ) ;
2014-10-24 08:22:33 +02:00
env - > ReleaseStringUTFChars ( name , flag_name ) ;
return result ;
}
WB_ENTRY ( jboolean , WB_IsConstantVMFlag ( JNIEnv * env , jobject o , jstring name ) )
2019-08-26 09:15:43 +02:00
const JVMFlag * flag = getVMFlag ( thread , env , name ) ;
2014-10-24 08:22:33 +02:00
return ( flag ! = NULL ) & & flag - > is_constant_in_binary ( ) ;
WB_END
WB_ENTRY ( jboolean , WB_IsLockedVMFlag ( JNIEnv * env , jobject o , jstring name ) )
2019-08-26 09:15:43 +02:00
const JVMFlag * flag = getVMFlag ( thread , env , name ) ;
2014-10-24 08:22:33 +02:00
return ( flag ! = NULL ) & & ! ( flag - > is_unlocked ( ) | | flag - > is_unlocker ( ) ) ;
WB_END
2014-05-30 17:20:48 +04:00
WB_ENTRY ( jobject , WB_GetBooleanVMFlag ( JNIEnv * env , jobject o , jstring name ) )
bool result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( bool ) > ( thread , env , name , & result ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return booleanBox ( thread , env , result ) ;
}
return NULL ;
WB_END
2015-06-04 14:29:34 +02:00
WB_ENTRY ( jobject , WB_GetIntVMFlag ( JNIEnv * env , jobject o , jstring name ) )
int result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( int ) > ( thread , env , name , & result ) ) {
2015-06-04 14:29:34 +02:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetUintVMFlag ( JNIEnv * env , jobject o , jstring name ) )
uint result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( uint ) > ( thread , env , name , & result ) ) {
2015-06-04 14:29:34 +02:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
2014-05-30 17:20:48 +04:00
WB_ENTRY ( jobject , WB_GetIntxVMFlag ( JNIEnv * env , jobject o , jstring name ) )
intx result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( intx ) > ( thread , env , name , & result ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetUintxVMFlag ( JNIEnv * env , jobject o , jstring name ) )
uintx result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( uintx ) > ( thread , env , name , & result ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetUint64VMFlag ( JNIEnv * env , jobject o , jstring name ) )
uint64_t result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( uint64_t ) > ( thread , env , name , & result ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
2014-08-11 14:03:06 +02:00
WB_ENTRY ( jobject , WB_GetSizeTVMFlag ( JNIEnv * env , jobject o , jstring name ) )
2018-06-19 10:00:39 -04:00
size_t result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( size_t ) > ( thread , env , name , & result ) ) {
2014-08-11 14:03:06 +02:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
2014-05-30 17:20:48 +04:00
WB_ENTRY ( jobject , WB_GetDoubleVMFlag ( JNIEnv * env , jobject o , jstring name ) )
double result ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( double ) > ( thread , env , name , & result ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
return doubleBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jstring , WB_GetStringVMFlag ( JNIEnv * env , jobject o , jstring name ) )
ccstr ccstrResult ;
2020-09-22 06:04:31 +00:00
if ( GetVMFlag < JVM_FLAG_TYPE ( ccstr ) > ( thread , env , name , & ccstrResult ) ) {
2014-05-30 17:20:48 +04:00
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
jstring result = env - > NewStringUTF ( ccstrResult ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
return result ;
}
return NULL ;
WB_END
WB_ENTRY ( void , WB_SetBooleanVMFlag ( JNIEnv * env , jobject o , jstring name , jboolean value ) )
bool result = value = = JNI_TRUE ? true : false ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( bool ) > ( thread , env , name , & result ) ;
2014-05-30 17:20:48 +04:00
WB_END
2015-06-04 14:29:34 +02:00
WB_ENTRY ( void , WB_SetIntVMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
int result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( int ) > ( thread , env , name , & result ) ;
2015-06-04 14:29:34 +02:00
WB_END
WB_ENTRY ( void , WB_SetUintVMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
uint result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( uint ) > ( thread , env , name , & result ) ;
2015-06-04 14:29:34 +02:00
WB_END
2014-05-30 17:20:48 +04:00
WB_ENTRY ( void , WB_SetIntxVMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
intx result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( intx ) > ( thread , env , name , & result ) ;
2014-05-30 17:20:48 +04:00
WB_END
WB_ENTRY ( void , WB_SetUintxVMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
uintx result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( uintx ) > ( thread , env , name , & result ) ;
2014-05-30 17:20:48 +04:00
WB_END
WB_ENTRY ( void , WB_SetUint64VMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
uint64_t result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( uint64_t ) > ( thread , env , name , & result ) ;
2014-05-30 17:20:48 +04:00
WB_END
2014-08-11 14:03:06 +02:00
WB_ENTRY ( void , WB_SetSizeTVMFlag ( JNIEnv * env , jobject o , jstring name , jlong value ) )
size_t result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( size_t ) > ( thread , env , name , & result ) ;
2014-08-11 14:03:06 +02:00
WB_END
2014-05-30 17:20:48 +04:00
WB_ENTRY ( void , WB_SetDoubleVMFlag ( JNIEnv * env , jobject o , jstring name , jdouble value ) )
double result = value ;
2020-09-22 06:04:31 +00:00
SetVMFlag < JVM_FLAG_TYPE ( double ) > ( thread , env , name , & result ) ;
2014-05-30 17:20:48 +04:00
WB_END
WB_ENTRY ( void , WB_SetStringVMFlag ( JNIEnv * env , jobject o , jstring name , jstring value ) )
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
2016-09-13 09:04:44 +02:00
const char * ccstrValue ;
if ( value = = NULL ) {
ccstrValue = NULL ;
}
else {
ccstrValue = env - > GetStringUTFChars ( value , NULL ) ;
CHECK_JNI_EXCEPTION ( env ) ;
}
2014-05-30 17:20:48 +04:00
ccstr ccstrResult = ccstrValue ;
bool needFree ;
{
ThreadInVMfromNative ttvfn ( thread ) ; // back to VM
2020-09-22 06:04:31 +00:00
needFree = SetVMFlag < JVM_FLAG_TYPE ( ccstr ) > ( thread , env , name , & ccstrResult ) ;
2014-05-30 17:20:48 +04:00
}
if ( value ! = NULL ) {
env - > ReleaseStringUTFChars ( value , ccstrValue ) ;
}
if ( needFree ) {
2014-12-01 12:16:15 -05:00
FREE_C_HEAP_ARRAY ( char , ccstrResult ) ;
2014-05-30 17:20:48 +04:00
}
WB_END
2014-11-10 19:04:38 +03:00
WB_ENTRY ( void , WB_LockCompilation ( JNIEnv * env , jobject o , jlong timeout ) )
WhiteBox : : compilation_locked = true ;
WB_END
WB_ENTRY ( void , WB_UnlockCompilation ( JNIEnv * env , jobject o ) )
2019-04-25 10:56:31 -04:00
MonitorLocker mo ( Compilation_lock , Mutex : : _no_safepoint_check_flag ) ;
2014-11-10 19:04:38 +03:00
WhiteBox : : compilation_locked = false ;
mo . notify_all ( ) ;
WB_END
2015-03-30 07:54:23 +02:00
WB_ENTRY ( void , WB_ForceNMethodSweep ( JNIEnv * env , jobject o ) )
// Force a code cache sweep and block until it finished
NMethodSweeper : : force_sweep ( ) ;
2014-11-10 19:04:38 +03:00
WB_END
2013-04-02 11:28:33 +02:00
WB_ENTRY ( jboolean , WB_IsInStringTable ( JNIEnv * env , jobject o , jstring javaString ) )
ResourceMark rm ( THREAD ) ;
int len ;
2013-04-29 16:13:57 -04:00
jchar * name = java_lang_String : : as_unicode_string ( JNIHandles : : resolve ( javaString ) , len , CHECK_false ) ;
return ( StringTable : : lookup ( name , len ) ! = NULL ) ;
2013-04-02 11:28:33 +02:00
WB_END
WB_ENTRY ( void , WB_FullGC ( JNIEnv * env , jobject o ) )
2018-02-22 18:36:07 +01:00
Universe : : heap ( ) - > soft_ref_policy ( ) - > set_should_clear_all_soft_refs ( true ) ;
2016-03-18 13:18:58 +01:00
Universe : : heap ( ) - > collect ( GCCause : : _wb_full_gc ) ;
2018-05-04 11:41:35 +02:00
# if INCLUDE_G1GC
2014-09-08 15:24:10 +02:00
if ( UseG1GC ) {
// Needs to be cleared explicitly for G1
2018-02-22 18:36:07 +01:00
Universe : : heap ( ) - > soft_ref_policy ( ) - > set_should_clear_all_soft_refs ( false ) ;
2014-09-08 15:24:10 +02:00
}
2018-05-04 11:41:35 +02:00
# endif // INCLUDE_G1GC
2013-04-02 11:28:33 +02:00
WB_END
2014-08-21 16:44:41 +02:00
WB_ENTRY ( void , WB_YoungGC ( JNIEnv * env , jobject o ) )
Universe : : heap ( ) - > collect ( GCCause : : _wb_young_gc ) ;
WB_END
2013-04-29 11:03:49 -07:00
2013-05-21 09:43:23 -07:00
WB_ENTRY ( void , WB_ReadReservedMemory ( JNIEnv * env , jobject o ) )
// static+volatile in order to force the read to happen
// (not be eliminated by the compiler)
static char c ;
static volatile char * p ;
p = os : : reserve_memory ( os : : vm_allocation_granularity ( ) , NULL , 0 ) ;
if ( p = = NULL ) {
THROW_MSG ( vmSymbols : : java_lang_OutOfMemoryError ( ) , " Failed to reserve memory " ) ;
}
c = * p ;
2013-04-29 11:03:49 -07:00
WB_END
2014-03-22 00:26:48 +04:00
WB_ENTRY ( jstring , WB_GetCPUFeatures ( JNIEnv * env , jobject o ) )
2015-12-23 20:19:42 -10:00
const char * features = VM_Version : : features_string ( ) ;
2014-03-22 00:26:48 +04:00
ThreadToNativeFromVM ttn ( thread ) ;
2015-12-23 20:19:42 -10:00
jstring features_string = env - > NewStringUTF ( features ) ;
2014-03-22 00:26:48 +04:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
return features_string ;
WB_END
2014-11-10 19:04:38 +03:00
int WhiteBox : : get_blob_type ( const CodeBlob * code ) {
2014-12-02 12:36:03 +03:00
guarantee ( WhiteBoxAPI , " internal testing API :: WhiteBox has to be enabled " ) ;
2016-12-11 19:07:04 -08:00
if ( code - > is_aot ( ) ) {
return - 1 ;
}
2014-11-10 19:04:38 +03:00
return CodeCache : : get_code_heap ( code ) - > code_blob_type ( ) ;
}
CodeHeap * WhiteBox : : get_code_heap ( int blob_type ) {
2014-12-02 12:36:03 +03:00
guarantee ( WhiteBoxAPI , " internal testing API :: WhiteBox has to be enabled " ) ;
2014-11-10 19:04:38 +03:00
return CodeCache : : get_code_heap ( blob_type ) ;
}
struct CodeBlobStub {
CodeBlobStub ( const CodeBlob * blob ) :
name ( os : : strdup ( blob - > name ( ) ) ) ,
size ( blob - > size ( ) ) ,
2015-11-04 07:23:23 -10:00
blob_type ( WhiteBox : : get_blob_type ( blob ) ) ,
address ( ( jlong ) blob ) { }
2014-11-10 19:04:38 +03:00
~ CodeBlobStub ( ) { os : : free ( ( void * ) name ) ; }
const char * const name ;
2015-11-04 07:23:23 -10:00
const jint size ;
const jint blob_type ;
const jlong address ;
2014-11-10 19:04:38 +03:00
} ;
static jobjectArray codeBlob2objectArray ( JavaThread * thread , JNIEnv * env , CodeBlobStub * cb ) {
2020-03-20 17:37:52 -07:00
ResourceMark rm ;
2014-11-10 19:04:38 +03:00
jclass clazz = env - > FindClass ( vmSymbols : : java_lang_Object ( ) - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2015-11-04 07:23:23 -10:00
jobjectArray result = env - > NewObjectArray ( 4 , clazz , NULL ) ;
2014-11-10 19:04:38 +03:00
jstring name = env - > NewStringUTF ( cb - > name ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
env - > SetObjectArrayElement ( result , 0 , name ) ;
jobject obj = integerBox ( thread , env , cb - > size ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
env - > SetObjectArrayElement ( result , 1 , obj ) ;
obj = integerBox ( thread , env , cb - > blob_type ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
env - > SetObjectArrayElement ( result , 2 , obj ) ;
2015-11-04 07:23:23 -10:00
obj = longBox ( thread , env , cb - > address ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
env - > SetObjectArrayElement ( result , 3 , obj ) ;
2014-11-10 19:04:38 +03:00
return result ;
}
2014-03-27 11:17:26 +04:00
WB_ENTRY ( jobjectArray , WB_GetNMethod ( JNIEnv * env , jobject o , jobject method , jboolean is_osr ) )
ResourceMark rm ( THREAD ) ;
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
methodHandle mh ( THREAD , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
2016-04-26 10:28:51 +02:00
CompiledMethod * code = is_osr ? mh - > lookup_osr_nmethod_for ( InvocationEntryBci , CompLevel_none , false ) : mh - > code ( ) ;
2014-03-27 11:17:26 +04:00
jobjectArray result = NULL ;
if ( code = = NULL ) {
return result ;
}
2016-12-11 19:07:04 -08:00
int comp_level = code - > comp_level ( ) ;
int insts_size = comp_level = = CompLevel_aot ? code - > code_end ( ) - code - > code_begin ( ) : code - > insts_size ( ) ;
2014-03-27 11:17:26 +04:00
ThreadToNativeFromVM ttn ( thread ) ;
jclass clazz = env - > FindClass ( vmSymbols : : java_lang_Object ( ) - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2015-10-08 12:49:30 -10:00
result = env - > NewObjectArray ( 5 , clazz , NULL ) ;
2014-03-27 11:17:26 +04:00
if ( result = = NULL ) {
return result ;
}
2014-11-10 19:04:38 +03:00
CodeBlobStub stub ( code ) ;
jobjectArray codeBlob = codeBlob2objectArray ( thread , env , & stub ) ;
2016-01-18 08:50:57 +01:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
env - > SetObjectArrayElement ( result , 0 , codeBlob ) ;
2016-12-11 19:07:04 -08:00
jobject level = integerBox ( thread , env , comp_level ) ;
2014-03-27 11:17:26 +04:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
env - > SetObjectArrayElement ( result , 1 , level ) ;
2014-03-27 11:17:26 +04:00
jbyteArray insts = env - > NewByteArray ( insts_size ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
env - > SetByteArrayRegion ( insts , 0 , insts_size , ( jbyte * ) code - > insts_begin ( ) ) ;
2014-11-10 19:04:38 +03:00
env - > SetObjectArrayElement ( result , 2 , insts ) ;
2014-03-27 11:17:26 +04:00
2014-10-31 16:51:57 -07:00
jobject id = integerBox ( thread , env , code - > compile_id ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
env - > SetObjectArrayElement ( result , 3 , id ) ;
2015-11-04 07:23:23 -10:00
jobject entry_point = longBox ( thread , env , ( jlong ) code - > entry_point ( ) ) ;
2015-10-08 12:49:30 -10:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2015-11-04 07:23:23 -10:00
env - > SetObjectArrayElement ( result , 4 , entry_point ) ;
2015-10-08 12:49:30 -10:00
2014-11-10 19:04:38 +03:00
return result ;
WB_END
CodeBlob * WhiteBox : : allocate_code_blob ( int size , int blob_type ) {
2014-12-02 12:36:03 +03:00
guarantee ( WhiteBoxAPI , " internal testing API :: WhiteBox has to be enabled " ) ;
2014-11-10 19:04:38 +03:00
BufferBlob * blob ;
int full_size = CodeBlob : : align_code_offset ( sizeof ( BufferBlob ) ) ;
if ( full_size < size ) {
2017-04-13 09:57:51 +02:00
full_size + = align_up ( size - full_size , oopSize ) ;
2014-11-10 19:04:38 +03:00
}
{
2019-04-25 10:56:31 -04:00
MutexLocker mu ( CodeCache_lock , Mutex : : _no_safepoint_check_flag ) ;
2014-11-10 19:04:38 +03:00
blob = ( BufferBlob * ) CodeCache : : allocate ( full_size , blob_type ) ;
2018-04-24 10:26:54 -07:00
if ( blob ! = NULL ) {
: : new ( blob ) BufferBlob ( " WB::DummyBlob " , full_size ) ;
}
2014-11-10 19:04:38 +03:00
}
// Track memory usage statistic after releasing CodeCache_lock
MemoryService : : track_code_cache_memory_usage ( ) ;
return blob ;
}
WB_ENTRY ( jlong , WB_AllocateCodeBlob ( JNIEnv * env , jobject o , jint size , jint blob_type ) )
2015-09-11 16:11:07 +03:00
if ( size < 0 ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalArgumentException ( ) ,
err_msg ( " WB_AllocateCodeBlob: size is negative: " INT32_FORMAT , size ) ) ;
}
return ( jlong ) WhiteBox : : allocate_code_blob ( size , blob_type ) ;
2014-11-10 19:04:38 +03:00
WB_END
2014-10-31 16:51:57 -07:00
2014-11-10 19:04:38 +03:00
WB_ENTRY ( void , WB_FreeCodeBlob ( JNIEnv * env , jobject o , jlong addr ) )
2015-09-11 16:11:07 +03:00
if ( addr = = 0 ) {
return ;
}
BufferBlob : : free ( ( BufferBlob * ) addr ) ;
2014-11-10 19:04:38 +03:00
WB_END
WB_ENTRY ( jobjectArray , WB_GetCodeHeapEntries ( JNIEnv * env , jobject o , jint blob_type ) )
ResourceMark rm ;
GrowableArray < CodeBlobStub * > blobs ;
{
2019-04-25 10:56:31 -04:00
MutexLocker mu ( CodeCache_lock , Mutex : : _no_safepoint_check_flag ) ;
2014-11-10 19:04:38 +03:00
CodeHeap * heap = WhiteBox : : get_code_heap ( blob_type ) ;
if ( heap = = NULL ) {
return NULL ;
}
for ( CodeBlob * cb = ( CodeBlob * ) heap - > first ( ) ;
cb ! = NULL ; cb = ( CodeBlob * ) heap - > next ( cb ) ) {
CodeBlobStub * stub = NEW_RESOURCE_OBJ ( CodeBlobStub ) ;
new ( stub ) CodeBlobStub ( cb ) ;
blobs . append ( stub ) ;
}
}
ThreadToNativeFromVM ttn ( thread ) ;
jobjectArray result = NULL ;
jclass clazz = env - > FindClass ( vmSymbols : : java_lang_Object ( ) - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
result = env - > NewObjectArray ( blobs . length ( ) , clazz , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
if ( result = = NULL ) {
return result ;
}
int i = 0 ;
for ( GrowableArrayIterator < CodeBlobStub * > it = blobs . begin ( ) ;
it ! = blobs . end ( ) ; + + it ) {
jobjectArray obj = codeBlob2objectArray ( thread , env , * it ) ;
2016-01-18 08:50:57 +01:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
env - > SetObjectArrayElement ( result , i , obj ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
2014-11-10 19:04:38 +03:00
+ + i ;
}
2014-03-27 11:17:26 +04:00
return result ;
WB_END
2014-11-21 17:27:11 +03:00
WB_ENTRY ( jint , WB_GetCompilationActivityMode ( JNIEnv * env , jobject o ) )
return CompileBroker : : get_compilation_activity_mode ( ) ;
WB_END
WB_ENTRY ( jobjectArray , WB_GetCodeBlob ( JNIEnv * env , jobject o , jlong addr ) )
2015-09-11 16:11:07 +03:00
if ( addr = = 0 ) {
THROW_MSG_NULL ( vmSymbols : : java_lang_NullPointerException ( ) ,
" WB_GetCodeBlob: addr is null " ) ;
}
ThreadToNativeFromVM ttn ( thread ) ;
CodeBlobStub stub ( ( CodeBlob * ) addr ) ;
return codeBlob2objectArray ( thread , env , & stub ) ;
2014-11-21 17:27:11 +03:00
WB_END
2015-10-08 12:49:30 -10:00
WB_ENTRY ( jlong , WB_GetMethodData ( JNIEnv * env , jobject wv , jobject method ) )
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
methodHandle mh ( thread , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
return ( jlong ) mh - > method_data ( ) ;
WB_END
2014-05-24 00:04:21 +04:00
WB_ENTRY ( jlong , WB_GetThreadStackSize ( JNIEnv * env , jobject o ) )
2020-07-22 01:27:08 -04:00
return ( jlong ) thread - > stack_size ( ) ;
2014-05-24 00:04:21 +04:00
WB_END
WB_ENTRY ( jlong , WB_GetThreadRemainingStackSize ( JNIEnv * env , jobject o ) )
2020-07-22 01:27:08 -04:00
return ( jlong ) thread - > stack_available ( os : : current_stack_pointer ( ) ) - ( jlong ) JavaThread : : stack_shadow_zone_size ( ) ;
2014-05-24 00:04:21 +04:00
WB_END
2015-10-08 12:49:30 -10:00
2014-07-07 10:12:40 +02:00
int WhiteBox : : array_bytes_to_length ( size_t bytes ) {
return Array < u1 > : : bytes_to_length ( bytes ) ;
}
WB_ENTRY ( jlong , WB_AllocateMetaspace ( JNIEnv * env , jobject wb , jobject class_loader , jlong size ) )
if ( size < 0 ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalArgumentException ( ) ,
err_msg ( " WB_AllocateMetaspace: size is negative: " JLONG_FORMAT , size ) ) ;
}
oop class_loader_oop = JNIHandles : : resolve ( class_loader ) ;
ClassLoaderData * cld = class_loader_oop ! = NULL
2018-09-11 09:42:27 -04:00
? java_lang_ClassLoader : : loader_data_acquire ( class_loader_oop )
2014-07-07 10:12:40 +02:00
: ClassLoaderData : : the_null_class_loader_data ( ) ;
2017-08-02 18:06:38 -07:00
void * metadata = MetadataFactory : : new_array < u1 > ( cld , WhiteBox : : array_bytes_to_length ( ( size_t ) size ) , thread ) ;
2014-07-07 10:12:40 +02:00
return ( jlong ) ( uintptr_t ) metadata ;
WB_END
WB_ENTRY ( void , WB_FreeMetaspace ( JNIEnv * env , jobject wb , jobject class_loader , jlong addr , jlong size ) )
oop class_loader_oop = JNIHandles : : resolve ( class_loader ) ;
ClassLoaderData * cld = class_loader_oop ! = NULL
2018-09-11 09:42:27 -04:00
? java_lang_ClassLoader : : loader_data_acquire ( class_loader_oop )
2014-07-07 10:12:40 +02:00
: ClassLoaderData : : the_null_class_loader_data ( ) ;
MetadataFactory : : free_array ( cld , ( Array < u1 > * ) ( uintptr_t ) addr ) ;
WB_END
2017-04-24 12:08:28 -04:00
WB_ENTRY ( void , WB_DefineModule ( JNIEnv * env , jobject o , jobject module , jboolean is_open ,
jstring version , jstring location , jobjectArray packages ) )
2020-04-18 19:45:45 +02:00
Modules : : define_module ( module , is_open , version , location , packages , CHECK ) ;
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_END
WB_ENTRY ( void , WB_AddModuleExports ( JNIEnv * env , jobject o , jobject from_module , jstring package , jobject to_module ) )
2020-04-18 19:45:45 +02:00
Modules : : add_module_exports_qualified ( from_module , package , to_module , CHECK ) ;
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_END
WB_ENTRY ( void , WB_AddModuleExportsToAllUnnamed ( JNIEnv * env , jobject o , jclass module , jstring package ) )
2020-04-18 19:45:45 +02:00
Modules : : add_module_exports_to_all_unnamed ( module , package , CHECK ) ;
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_END
WB_ENTRY ( void , WB_AddModuleExportsToAll ( JNIEnv * env , jobject o , jclass module , jstring package ) )
2020-04-18 19:45:45 +02:00
Modules : : add_module_exports ( module , package , NULL , CHECK ) ;
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_END
WB_ENTRY ( void , WB_AddReadsModule ( JNIEnv * env , jobject o , jobject from_module , jobject source_module ) )
Modules : : add_reads_module ( from_module , source_module , CHECK ) ;
WB_END
2014-10-01 16:09:01 +02:00
WB_ENTRY ( jlong , WB_IncMetaspaceCapacityUntilGC ( JNIEnv * env , jobject wb , jlong inc ) )
if ( inc < 0 ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalArgumentException ( ) ,
err_msg ( " WB_IncMetaspaceCapacityUntilGC: inc is negative: " JLONG_FORMAT , inc ) ) ;
}
jlong max_size_t = ( jlong ) ( ( size_t ) - 1 ) ;
if ( inc > max_size_t ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalArgumentException ( ) ,
err_msg ( " WB_IncMetaspaceCapacityUntilGC: inc does not fit in size_t: " JLONG_FORMAT , inc ) ) ;
}
size_t new_cap_until_GC = 0 ;
2017-07-04 15:58:10 +02:00
size_t aligned_inc = align_down ( ( size_t ) inc , Metaspace : : commit_alignment ( ) ) ;
2014-10-01 16:09:01 +02:00
bool success = MetaspaceGC : : inc_capacity_until_GC ( aligned_inc , & new_cap_until_GC ) ;
if ( ! success ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalStateException ( ) ,
" WB_IncMetaspaceCapacityUntilGC: could not increase capacity until GC "
" due to contention with another thread " ) ;
}
return ( jlong ) new_cap_until_GC ;
WB_END
WB_ENTRY ( jlong , WB_MetaspaceCapacityUntilGC ( JNIEnv * env , jobject wb ) )
return ( jlong ) MetaspaceGC : : capacity_until_GC ( ) ;
WB_END
2017-08-02 18:06:38 -07:00
WB_ENTRY ( jlong , WB_MetaspaceReserveAlignment ( JNIEnv * env , jobject wb ) )
return ( jlong ) Metaspace : : reserve_alignment ( ) ;
WB_END
2015-06-25 18:25:19 +02:00
2014-12-30 11:07:49 +03:00
WB_ENTRY ( jboolean , WB_IsMonitorInflated ( JNIEnv * env , jobject wb , jobject obj ) )
oop obj_oop = JNIHandles : : resolve ( obj ) ;
2019-08-06 10:48:21 +02:00
return ( jboolean ) obj_oop - > mark ( ) . has_monitor ( ) ;
2014-12-30 11:07:49 +03:00
WB_END
2020-06-24 17:48:53 -04:00
WB_ENTRY ( jboolean , WB_DeflateIdleMonitors ( JNIEnv * env , jobject wb ) )
log_info ( monitorinflation ) ( " WhiteBox initiated DeflateIdleMonitors " ) ;
return ObjectSynchronizer : : request_deflate_idle_monitors ( ) ;
WB_END
2014-12-30 11:07:49 +03:00
WB_ENTRY ( void , WB_ForceSafepoint ( JNIEnv * env , jobject wb ) )
VM_ForceSafepoint force_safepoint_op ;
VMThread : : execute ( & force_safepoint_op ) ;
WB_END
2015-11-03 20:12:51 +03:00
WB_ENTRY ( jlong , WB_GetConstantPool ( JNIEnv * env , jobject wb , jclass klass ) )
2017-03-15 10:25:37 -04:00
InstanceKlass * ik = InstanceKlass : : cast ( java_lang_Class : : as_Klass ( JNIHandles : : resolve ( klass ) ) ) ;
return ( jlong ) ik - > constants ( ) ;
2015-10-08 12:49:30 -10:00
WB_END
2016-02-20 11:44:14 +03:00
WB_ENTRY ( jint , WB_GetConstantPoolCacheIndexTag ( JNIEnv * env , jobject wb ) )
return ConstantPool : : CPCACHE_INDEX_TAG ;
WB_END
WB_ENTRY ( jint , WB_GetConstantPoolCacheLength ( JNIEnv * env , jobject wb , jclass klass ) )
2017-03-15 10:25:37 -04:00
InstanceKlass * ik = InstanceKlass : : cast ( java_lang_Class : : as_Klass ( JNIHandles : : resolve ( klass ) ) ) ;
ConstantPool * cp = ik - > constants ( ) ;
2016-02-20 11:44:14 +03:00
if ( cp - > cache ( ) = = NULL ) {
return - 1 ;
}
return cp - > cache ( ) - > length ( ) ;
WB_END
WB_ENTRY ( jint , WB_ConstantPoolRemapInstructionOperandFromCache ( JNIEnv * env , jobject wb , jclass klass , jint index ) )
2017-03-15 10:25:37 -04:00
InstanceKlass * ik = InstanceKlass : : cast ( java_lang_Class : : as_Klass ( JNIHandles : : resolve ( klass ) ) ) ;
ConstantPool * cp = ik - > constants ( ) ;
2016-02-20 11:44:14 +03:00
if ( cp - > cache ( ) = = NULL ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalStateException ( ) , " Constant pool does not have a cache " ) ;
}
jint cpci = index ;
jint cpciTag = ConstantPool : : CPCACHE_INDEX_TAG ;
if ( cpciTag > cpci | | cpci > = cp - > cache ( ) - > length ( ) + cpciTag ) {
THROW_MSG_0 ( vmSymbols : : java_lang_IllegalArgumentException ( ) , " Constant pool cache index is out of range " ) ;
}
jint cpi = cp - > remap_instruction_operand_from_cache ( cpci ) ;
return cpi ;
WB_END
WB_ENTRY ( jint , WB_ConstantPoolEncodeIndyIndex ( JNIEnv * env , jobject wb , jint index ) )
return ConstantPool : : encode_invokedynamic_index ( index ) ;
WB_END
2016-04-05 01:46:40 -07:00
WB_ENTRY ( void , WB_ClearInlineCaches ( JNIEnv * env , jobject wb , jboolean preserve_static_stubs ) )
VM_ClearICs clear_ics ( preserve_static_stubs = = JNI_TRUE ) ;
2015-12-04 23:46:19 +03:00
VMThread : : execute ( & clear_ics ) ;
WB_END
2015-03-12 19:11:25 +03:00
template < typename T >
static bool GetMethodOption ( JavaThread * thread , JNIEnv * env , jobject method , jstring name , T * value ) {
assert ( value ! = NULL , " sanity " ) ;
if ( method = = NULL | | name = = NULL ) {
return false ;
}
jmethodID jmid = reflected_method_to_jmid ( thread , env , method ) ;
CHECK_JNI_EXCEPTION_ ( env , false ) ;
methodHandle mh ( thread , Method : : checked_resolve_jmethod_id ( jmid ) ) ;
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
const char * flag_name = env - > GetStringUTFChars ( name , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , false ) ;
2015-03-12 19:11:25 +03:00
bool result = CompilerOracle : : has_option_value ( mh , flag_name , * value ) ;
env - > ReleaseStringUTFChars ( name , flag_name ) ;
return result ;
}
WB_ENTRY ( jobject , WB_GetMethodBooleaneOption ( JNIEnv * env , jobject wb , jobject method , jstring name ) )
bool result ;
if ( GetMethodOption < bool > ( thread , env , method , name , & result ) ) {
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
return booleanBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetMethodIntxOption ( JNIEnv * env , jobject wb , jobject method , jstring name ) )
intx result ;
if ( GetMethodOption < intx > ( thread , env , method , name , & result ) ) {
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetMethodUintxOption ( JNIEnv * env , jobject wb , jobject method , jstring name ) )
uintx result ;
if ( GetMethodOption < uintx > ( thread , env , method , name , & result ) ) {
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
return longBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetMethodDoubleOption ( JNIEnv * env , jobject wb , jobject method , jstring name ) )
double result ;
if ( GetMethodOption < double > ( thread , env , method , name , & result ) ) {
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
return doubleBox ( thread , env , result ) ;
}
return NULL ;
WB_END
WB_ENTRY ( jobject , WB_GetMethodStringOption ( JNIEnv * env , jobject wb , jobject method , jstring name ) )
ccstr ccstrResult ;
if ( GetMethodOption < ccstr > ( thread , env , method , name , & ccstrResult ) ) {
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
jstring result = env - > NewStringUTF ( ccstrResult ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
return result ;
}
return NULL ;
WB_END
2018-10-05 18:56:11 -04:00
WB_ENTRY ( jobject , WB_GetDefaultArchivePath ( JNIEnv * env , jobject wb ) )
const char * p = Arguments : : get_default_shared_archive_path ( ) ;
ThreadToNativeFromVM ttn ( thread ) ;
jstring path_string = env - > NewStringUTF ( p ) ;
CHECK_JNI_EXCEPTION_ ( env , NULL ) ;
return path_string ;
WB_END
WB_ENTRY ( jboolean , WB_IsSharingEnabled ( JNIEnv * env , jobject wb ) )
return UseSharedSpaces ;
WB_END
2019-05-17 08:29:55 -07:00
WB_ENTRY ( jboolean , WB_CDSMemoryMappingFailed ( JNIEnv * env , jobject wb ) )
return FileMapInfo : : memory_mapping_failed ( ) ;
WB_END
2015-06-12 17:29:14 -04:00
WB_ENTRY ( jboolean , WB_IsShared ( JNIEnv * env , jobject wb , jobject obj ) )
oop obj_oop = JNIHandles : : resolve ( obj ) ;
2018-10-09 15:58:07 -04:00
return HeapShared : : is_archived_object ( obj_oop ) ;
2015-06-12 17:29:14 -04:00
WB_END
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_ENTRY ( jboolean , WB_IsSharedClass ( JNIEnv * env , jobject wb , jclass clazz ) )
2018-01-16 16:57:53 -08:00
return ( jboolean ) MetaspaceShared : : is_in_shared_metaspace ( java_lang_Class : : as_Klass ( JNIHandles : : resolve_non_null ( clazz ) ) ) ;
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
WB_END
2015-06-17 21:44:48 +00:00
WB_ENTRY ( jboolean , WB_AreSharedStringsIgnored ( JNIEnv * env ) )
2018-11-03 15:40:19 -04:00
return ! HeapShared : : closed_archive_heap_region_mapped ( ) ;
2017-08-14 14:32:17 -04:00
WB_END
WB_ENTRY ( jobject , WB_GetResolvedReferences ( JNIEnv * env , jobject wb , jclass clazz ) )
Klass * k = java_lang_Class : : as_Klass ( JNIHandles : : resolve_non_null ( clazz ) ) ;
if ( k - > is_instance_klass ( ) ) {
InstanceKlass * ik = InstanceKlass : : cast ( k ) ;
ConstantPool * cp = ik - > constants ( ) ;
objArrayOop refs = cp - > resolved_references ( ) ;
2020-07-22 01:27:08 -04:00
return ( jobject ) JNIHandles : : make_local ( THREAD , refs ) ;
2017-08-14 14:32:17 -04:00
} else {
return NULL ;
}
2015-06-17 21:44:48 +00:00
WB_END
2019-05-17 08:29:55 -07:00
WB_ENTRY ( void , WB_LinkClass ( JNIEnv * env , jobject wb , jclass clazz ) )
Klass * k = java_lang_Class : : as_Klass ( JNIHandles : : resolve_non_null ( clazz ) ) ;
if ( ! k - > is_instance_klass ( ) ) {
return ;
}
InstanceKlass * ik = InstanceKlass : : cast ( k ) ;
ik - > link_class ( THREAD ) ; // may throw verification error
WB_END
2017-11-07 18:48:17 -05:00
WB_ENTRY ( jboolean , WB_AreOpenArchiveHeapObjectsMapped ( JNIEnv * env ) )
2018-10-09 15:58:07 -04:00
return HeapShared : : open_archive_heap_region_mapped ( ) ;
2017-11-07 18:48:17 -05:00
WB_END
2017-08-03 10:24:34 +02:00
WB_ENTRY ( jboolean , WB_IsCDSIncludedInVmBuild ( JNIEnv * env ) )
# if INCLUDE_CDS
return true ;
# else
return false ;
2017-12-04 08:59:47 -08:00
# endif // INCLUDE_CDS
2017-08-03 10:24:34 +02:00
WB_END
2020-01-08 14:36:48 +01:00
WB_ENTRY ( jboolean , WB_isC2OrJVMCIIncludedInVmBuild ( JNIEnv * env ) )
# if COMPILER2_OR_JVMCI
return true ;
# else
return false ;
# endif
WB_END
2018-02-15 11:39:42 -08:00
WB_ENTRY ( jboolean , WB_IsJavaHeapArchiveSupported ( JNIEnv * env ) )
2018-10-09 15:58:07 -04:00
return HeapShared : : is_heap_object_archiving_allowed ( ) ;
2018-02-15 11:39:42 -08:00
WB_END
2017-11-27 20:21:34 -08:00
2018-07-20 09:46:57 +02:00
WB_ENTRY ( jboolean , WB_IsJFRIncludedInVmBuild ( JNIEnv * env ) )
# if INCLUDE_JFR
return true ;
# else
return false ;
# endif // INCLUDE_JFR
WB_END
2017-11-27 20:21:34 -08:00
# if INCLUDE_CDS
WB_ENTRY ( jint , WB_GetOffsetForName ( JNIEnv * env , jobject o , jstring name ) )
ResourceMark rm ;
char * c_name = java_lang_String : : as_utf8_string ( JNIHandles : : resolve_non_null ( name ) ) ;
int result = CDSOffsets : : find_offset ( c_name ) ;
return ( jint ) result ;
WB_END
# endif // INCLUDE_CDS
2017-08-31 10:00:28 +02:00
WB_ENTRY ( jint , WB_HandshakeWalkStack ( JNIEnv * env , jobject wb , jobject thread_handle , jboolean all_threads ) )
2019-12-03 15:32:41 +01:00
class TraceSelfClosure : public HandshakeClosure {
2017-08-31 10:00:28 +02:00
jint _num_threads_completed ;
void do_thread ( Thread * th ) {
2020-09-11 01:31:32 +00:00
JavaThread * jt = th - > as_Java_thread ( ) ;
2017-08-31 10:00:28 +02:00
ResourceMark rm ;
jt - > print_on ( tty ) ;
jt - > print_stack_on ( tty ) ;
tty - > cr ( ) ;
Atomic : : inc ( & _num_threads_completed ) ;
}
public :
2020-07-30 10:41:31 -04:00
TraceSelfClosure ( Thread * thread ) : HandshakeClosure ( " WB_TraceSelf " ) , _num_threads_completed ( 0 ) { }
2017-08-31 10:00:28 +02:00
jint num_threads_completed ( ) const { return _num_threads_completed ; }
} ;
2020-07-30 10:41:31 -04:00
TraceSelfClosure tsc ( Thread : : current ( ) ) ;
2017-08-31 10:00:28 +02:00
if ( all_threads ) {
Handshake : : execute ( & tsc ) ;
} else {
oop thread_oop = JNIHandles : : resolve ( thread_handle ) ;
if ( thread_oop ! = NULL ) {
JavaThread * target = java_lang_Thread : : thread ( thread_oop ) ;
Handshake : : execute ( & tsc , target ) ;
}
}
return tsc . num_threads_completed ( ) ;
WB_END
2012-03-15 13:37:13 +01:00
//Some convenience methods to deal with objects from java
int WhiteBox : : offset_for_field ( const char * field_name , oop object ,
Symbol * signature_symbol ) {
assert ( field_name ! = NULL & & strlen ( field_name ) > 0 , " Field name not valid " ) ;
Thread * THREAD = Thread : : current ( ) ;
//Get the class of our object
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
Klass * arg_klass = object - > klass ( ) ;
2012-03-15 13:37:13 +01:00
//Turn it into an instance-klass
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
InstanceKlass * ik = InstanceKlass : : cast ( arg_klass ) ;
2012-03-15 13:37:13 +01:00
//Create symbols to look for in the class
2019-05-14 11:29:18 -04:00
TempNewSymbol name_symbol = SymbolTable : : new_symbol ( field_name ) ;
2012-03-15 13:37:13 +01:00
//To be filled in with an offset of the field we're looking for
fieldDescriptor fd ;
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
Klass * res = ik - > find_field ( name_symbol , signature_symbol , & fd ) ;
2012-03-15 13:37:13 +01:00
if ( res = = NULL ) {
tty - > print_cr ( " Invalid layout of %s at %s " , ik - > external_name ( ) ,
name_symbol - > as_C_string ( ) ) ;
2016-04-29 22:40:51 -04:00
vm_exit_during_initialization ( " Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class " ) ;
2012-03-15 13:37:13 +01:00
}
//fetch the field at the offset we've found
int dest_offset = fd . offset ( ) ;
return dest_offset ;
}
const char * WhiteBox : : lookup_jstring ( const char * field_name , oop object ) {
int offset = offset_for_field ( field_name , object ,
vmSymbols : : string_signature ( ) ) ;
oop string = object - > obj_field ( offset ) ;
2012-06-28 11:37:28 +02:00
if ( string = = NULL ) {
return NULL ;
}
2012-03-15 13:37:13 +01:00
const char * ret = java_lang_String : : as_utf8_string ( string ) ;
return ret ;
}
bool WhiteBox : : lookup_bool ( const char * field_name , oop object ) {
int offset =
offset_for_field ( field_name , object , vmSymbols : : bool_signature ( ) ) ;
bool ret = ( object - > bool_field ( offset ) = = JNI_TRUE ) ;
return ret ;
}
2014-09-08 15:24:10 +02:00
void WhiteBox : : register_methods ( JNIEnv * env , jclass wbclass , JavaThread * thread , JNINativeMethod * method_array , int method_count ) {
ResourceMark rm ;
ThreadToNativeFromVM ttnfv ( thread ) ; // can't be in VM when we call JNI
// one by one registration natives for exception catching
jclass no_such_method_error_klass = env - > FindClass ( vmSymbols : : java_lang_NoSuchMethodError ( ) - > as_C_string ( ) ) ;
CHECK_JNI_EXCEPTION ( env ) ;
for ( int i = 0 , n = method_count ; i < n ; + + i ) {
// Skip dummy entries
if ( method_array [ i ] . fnPtr = = NULL ) continue ;
if ( env - > RegisterNatives ( wbclass , & method_array [ i ] , 1 ) ! = 0 ) {
jthrowable throwable_obj = env - > ExceptionOccurred ( ) ;
if ( throwable_obj ! = NULL ) {
env - > ExceptionClear ( ) ;
if ( env - > IsInstanceOf ( throwable_obj , no_such_method_error_klass ) ) {
// NoSuchMethodError is thrown when a method can't be found or a method is not native.
// Ignoring the exception since it is not preventing use of other WhiteBox methods.
tty - > print_cr ( " Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s " ,
method_array [ i ] . name , method_array [ i ] . signature ) ;
}
} else {
// Registration failed unexpectedly.
tty - > print_cr ( " Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered " ,
method_array [ i ] . name , method_array [ i ] . signature ) ;
env - > UnregisterNatives ( wbclass ) ;
break ;
}
}
}
}
2012-03-15 13:37:13 +01:00
2016-03-03 16:21:16 +01:00
WB_ENTRY ( jint , WB_AddCompilerDirective ( JNIEnv * env , jobject o , jstring compDirect ) )
// can't be in VM when we call JNI
ThreadToNativeFromVM ttnfv ( thread ) ;
const char * dir = env - > GetStringUTFChars ( compDirect , NULL ) ;
2016-09-13 09:04:44 +02:00
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
2016-03-03 16:21:16 +01:00
int ret ;
{
ThreadInVMfromNative ttvfn ( thread ) ; // back to VM
ret = DirectivesParser : : parse_string ( dir , tty ) ;
}
env - > ReleaseStringUTFChars ( compDirect , dir ) ;
// -1 for error parsing directive. Return 0 as number of directives added.
if ( ret = = - 1 ) {
ret = 0 ;
}
return ( jint ) ret ;
WB_END
WB_ENTRY ( void , WB_RemoveCompilerDirective ( JNIEnv * env , jobject o , jint count ) )
DirectivesStack : : pop ( count ) ;
WB_END
2017-09-25 23:42:58 -04:00
// Checks that the library libfile has the noexecstack bit set.
WB_ENTRY ( jboolean , WB_CheckLibSpecifiesNoexecstack ( JNIEnv * env , jobject o , jstring libfile ) )
jboolean ret = false ;
# ifdef LINUX
// Can't be in VM when we call JNI.
ThreadToNativeFromVM ttnfv ( thread ) ;
const char * lf = env - > GetStringUTFChars ( libfile , NULL ) ;
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
ret = ( jboolean ) ElfFile : : specifies_noexecstack ( lf ) ;
env - > ReleaseStringUTFChars ( libfile , lf ) ;
# endif
return ret ;
WB_END
2017-11-16 19:01:01 -08:00
WB_ENTRY ( jboolean , WB_IsContainerized ( JNIEnv * env , jobject o ) )
LINUX_ONLY ( return OSContainer : : is_containerized ( ) ; )
return false ;
WB_END
2020-02-25 12:17:26 +01:00
WB_ENTRY ( jint , WB_ValidateCgroup ( JNIEnv * env ,
jobject o ,
jstring proc_cgroups ,
jstring proc_self_cgroup ,
jstring proc_self_mountinfo ) )
jint ret = 0 ;
# ifdef LINUX
ThreadToNativeFromVM ttnfv ( thread ) ;
const char * p_cgroups = env - > GetStringUTFChars ( proc_cgroups , NULL ) ;
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
const char * p_s_cgroup = env - > GetStringUTFChars ( proc_self_cgroup , NULL ) ;
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
const char * p_s_mountinfo = env - > GetStringUTFChars ( proc_self_mountinfo , NULL ) ;
CHECK_JNI_EXCEPTION_ ( env , 0 ) ;
u1 cg_type_flags = 0 ;
// This sets cg_type_flags
WhiteBox : : validate_cgroup ( p_cgroups , p_s_cgroup , p_s_mountinfo , & cg_type_flags ) ;
ret = ( jint ) cg_type_flags ;
env - > ReleaseStringUTFChars ( proc_cgroups , p_cgroups ) ;
env - > ReleaseStringUTFChars ( proc_self_cgroup , p_s_cgroup ) ;
env - > ReleaseStringUTFChars ( proc_self_mountinfo , p_s_mountinfo ) ;
# endif
return ret ;
WB_END
2017-11-16 19:01:01 -08:00
WB_ENTRY ( void , WB_PrintOsInfo ( JNIEnv * env , jobject o ) )
os : : print_os_info ( tty ) ;
WB_END
2018-02-14 17:20:59 -05:00
// Elf decoder
WB_ENTRY ( void , WB_DisableElfSectionCache ( JNIEnv * env ) )
2018-02-16 11:33:13 +01:00
# if !defined(_WINDOWS) && !defined(__APPLE__) && !defined(_AIX)
2018-02-14 17:20:59 -05:00
ElfFile : : _do_not_cache_elf_section = true ;
# endif
WB_END
2019-04-10 15:41:04 +02:00
WB_ENTRY ( jlong , WB_ResolvedMethodItemsCount ( JNIEnv * env , jobject o ) )
return ( jlong ) ResolvedMethodTable : : items_count ( ) ;
2018-08-29 10:46:59 -04:00
WB_END
2018-08-31 10:22:04 -04:00
WB_ENTRY ( jint , WB_ProtectionDomainRemovedCount ( JNIEnv * env , jobject o ) )
return ( jint ) SystemDictionary : : pd_cache_table ( ) - > removed_entries_count ( ) ;
WB_END
2019-01-23 16:36:45 -08:00
WB_ENTRY ( jint , WB_AotLibrariesCount ( JNIEnv * env , jobject o ) )
jint result = 0 ;
# if INCLUDE_AOT
result = ( jint ) AOTLoader : : heaps_count ( ) ;
# endif
return result ;
WB_END
2020-01-09 17:38:41 -05:00
WB_ENTRY ( jint , WB_GetKlassMetadataSize ( JNIEnv * env , jobject wb , jclass mirror ) )
Klass * k = java_lang_Class : : as_Klass ( JNIHandles : : resolve ( mirror ) ) ;
// Return size in bytes.
return k - > size ( ) * wordSize ;
WB_END
2020-05-13 22:29:54 -04:00
// See test/hotspot/jtreg/runtime/Thread/ThreadObjAccessAtExit.java.
// It explains how the thread's priority field is used for test state coordination.
//
WB_ENTRY ( void , WB_CheckThreadObjOfTerminatingThread ( JNIEnv * env , jobject wb , jobject target_handle ) )
oop target_oop = JNIHandles : : resolve_non_null ( target_handle ) ;
jlong tid = java_lang_Thread : : thread_id ( target_oop ) ;
JavaThread * target = java_lang_Thread : : thread ( target_oop ) ;
// Grab a ThreadsListHandle to protect the target thread whilst terminating
ThreadsListHandle tlh ;
// Look up the target thread by tid to ensure it is present
JavaThread * t = tlh . list ( ) - > find_JavaThread_from_java_tid ( tid ) ;
if ( t = = NULL ) {
THROW_MSG ( vmSymbols : : java_lang_RuntimeException ( ) , " Target thread not found in ThreadsList! " ) ;
}
tty - > print_cr ( " WB_CheckThreadObjOfTerminatingThread: target thread is protected " ) ;
// Allow target to terminate by boosting priority
java_lang_Thread : : set_priority ( t - > threadObj ( ) , ThreadPriority ( NormPriority + 1 ) ) ;
// Now wait for the target to terminate
while ( ! target - > is_terminated ( ) ) {
ThreadBlockInVM tbivm ( thread ) ; // just in case target is involved in a safepoint
os : : naked_short_sleep ( 0 ) ;
}
tty - > print_cr ( " WB_CheckThreadObjOfTerminatingThread: target thread is terminated " ) ;
// Now release the GC inducing thread - we have to re-resolve the external oop that
// was passed in as GC may have occurred and we don't know if we can trust t->threadObj() now.
oop original = JNIHandles : : resolve_non_null ( target_handle ) ;
java_lang_Thread : : set_priority ( original , ThreadPriority ( NormPriority + 2 ) ) ;
tty - > print_cr ( " WB_CheckThreadObjOfTerminatingThread: GC has been initiated - checking threadObj: " ) ;
// The Java code should be creating garbage and triggering GC, which would potentially move
// the threadObj oop. If the exiting thread is properly protected then its threadObj should
// remain valid and equal to our initial target_handle. Loop a few times to give GC a chance to
// kick in.
for ( int i = 0 ; i < 5 ; i + + ) {
oop original = JNIHandles : : resolve_non_null ( target_handle ) ;
oop current = t - > threadObj ( ) ;
if ( original ! = current ) {
tty - > print_cr ( " WB_CheckThreadObjOfTerminatingThread: failed comparison on iteration %d " , i ) ;
THROW_MSG ( vmSymbols : : java_lang_RuntimeException ( ) , " Target thread oop has changed! " ) ;
} else {
tty - > print_cr ( " WB_CheckThreadObjOfTerminatingThread: successful comparison on iteration %d " , i ) ;
ThreadBlockInVM tbivm ( thread ) ;
os : : naked_short_sleep ( 50 ) ;
}
}
WB_END
2020-08-21 15:49:09 -07:00
WB_ENTRY ( jboolean , WB_IsJVMTIIncluded ( JNIEnv * env , jobject wb ) )
return INCLUDE_JVMTI ? JNI_TRUE : JNI_FALSE ;
WB_END
2012-02-23 14:58:35 +01:00
# define CC (char*)
static JNINativeMethod methods [ ] = {
2015-06-24 09:42:45 +02:00
{ CC " getObjectAddress0 " , CC " (Ljava/lang/Object;)J " , ( void * ) & WB_GetObjectAddress } ,
{ CC " getObjectSize0 " , CC " (Ljava/lang/Object;)J " , ( void * ) & WB_GetObjectSize } ,
{ CC " isObjectInOldGen0 " , CC " (Ljava/lang/Object;)Z " , ( void * ) & WB_isObjectInOldGen } ,
{ CC " getHeapOopSize " , CC " ()I " , ( void * ) & WB_GetHeapOopSize } ,
{ CC " getVMPageSize " , CC " ()I " , ( void * ) & WB_GetVMPageSize } ,
{ CC " getVMAllocationGranularity " , CC " ()J " , ( void * ) & WB_GetVMAllocationGranularity } ,
{ CC " getVMLargePageSize " , CC " ()J " , ( void * ) & WB_GetVMLargePageSize } ,
2015-09-01 21:38:07 +03:00
{ CC " getHeapSpaceAlignment " , CC " ()J " , ( void * ) & WB_GetHeapSpaceAlignment } ,
2016-08-02 15:22:41 +03:00
{ CC " getHeapAlignment " , CC " ()J " , ( void * ) & WB_GetHeapAlignment } ,
2020-01-17 06:56:29 -05:00
{ CC " countAliveClasses0 " , CC " (Ljava/lang/String;)I " , ( void * ) & WB_CountAliveClasses } ,
2018-09-14 12:10:28 -04:00
{ CC " getSymbolRefcount " , CC " (Ljava/lang/String;)I " , ( void * ) & WB_GetSymbolRefcount } ,
2015-04-02 18:53:45 +03:00
{ CC " parseCommandLine0 " ,
2014-11-28 16:33:57 +01:00
CC " (Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object; " ,
2012-03-15 13:37:13 +01:00
( void * ) & WB_ParseCommandLine
} ,
2015-04-02 18:53:45 +03:00
{ CC " addToBootstrapClassLoaderSearch0 " , CC " (Ljava/lang/String;)V " ,
2014-11-18 03:38:50 -08:00
( void * ) & WB_AddToBootstrapClassLoaderSearch } ,
2015-04-02 18:53:45 +03:00
{ CC " addToSystemClassLoaderSearch0 " , CC " (Ljava/lang/String;)V " ,
2014-11-18 03:38:50 -08:00
( void * ) & WB_AddToSystemClassLoaderSearch } ,
2013-09-11 16:25:02 +02:00
{ CC " getCompressedOopsMaxHeapSize " , CC " ()J " ,
( void * ) & WB_GetCompressedOopsMaxHeapSize } ,
2013-05-06 17:19:42 +02:00
{ CC " printHeapSizes " , CC " ()V " , ( void * ) & WB_PrintHeapSizes } ,
2013-11-08 16:48:21 +01:00
{ CC " runMemoryUnitTests " , CC " ()V " , ( void * ) & WB_RunMemoryUnitTests } ,
{ CC " readFromNoaccessArea " , CC " ()V " , ( void * ) & WB_ReadFromNoaccessArea } ,
{ CC " stressVirtualSpaceResize " , CC " (JJJ)I " , ( void * ) & WB_StressVirtualSpaceResize } ,
2017-11-27 20:21:34 -08:00
# if INCLUDE_CDS
{ CC " getOffsetForName0 " , CC " (Ljava/lang/String;)I " , ( void * ) & WB_GetOffsetForName } ,
# endif
2018-05-04 11:41:35 +02:00
# if INCLUDE_G1GC
2012-02-23 14:58:35 +01:00
{ CC " g1InConcurrentMark " , CC " ()Z " , ( void * ) & WB_G1InConcurrentMark } ,
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
{ CC " g1IsHumongous0 " , CC " (Ljava/lang/Object;)Z " , ( void * ) & WB_G1IsHumongous } ,
2015-12-17 16:46:41 +03:00
{ CC " g1BelongsToHumongousRegion0 " , CC " (J)Z " , ( void * ) & WB_G1BelongsToHumongousRegion } ,
{ CC " g1BelongsToFreeRegion0 " , CC " (J)Z " , ( void * ) & WB_G1BelongsToFreeRegion } ,
2015-03-16 17:51:28 +03:00
{ CC " g1NumMaxRegions " , CC " ()J " , ( void * ) & WB_G1NumMaxRegions } ,
2012-02-23 14:58:35 +01:00
{ CC " g1NumFreeRegions " , CC " ()J " , ( void * ) & WB_G1NumFreeRegions } ,
{ CC " g1RegionSize " , CC " ()I " , ( void * ) & WB_G1RegionSize } ,
2014-11-28 09:33:48 +01:00
{ CC " g1StartConcMarkCycle " , CC " ()Z " , ( void * ) & WB_G1StartMarkCycle } ,
2015-03-16 17:51:28 +03:00
{ CC " g1AuxiliaryMemoryUsage " , CC " ()Ljava/lang/management/MemoryUsage; " ,
( void * ) & WB_G1AuxiliaryMemoryUsage } ,
2019-11-13 10:49:12 -08:00
{ CC " g1ActiveMemoryNodeCount " , CC " ()I " , ( void * ) & WB_G1ActiveMemoryNodeCount } ,
{ CC " g1MemoryNodeIds " , CC " ()[I " , ( void * ) & WB_G1MemoryNodeIds } ,
2018-05-04 11:41:35 +02:00
{ CC " g1GetMixedGCInfo " , CC " (I)[J " , ( void * ) & WB_G1GetMixedGCInfo } ,
2018-12-21 08:23:55 -08:00
# endif // INCLUDE_G1GC
# if INCLUDE_G1GC || INCLUDE_PARALLELGC
2018-12-21 08:18:59 -08:00
{ CC " dramReservedStart " , CC " ()J " , ( void * ) & WB_DramReservedStart } ,
{ CC " dramReservedEnd " , CC " ()J " , ( void * ) & WB_DramReservedEnd } ,
{ CC " nvdimmReservedStart " , CC " ()J " , ( void * ) & WB_NvdimmReservedStart } ,
{ CC " nvdimmReservedEnd " , CC " ()J " , ( void * ) & WB_NvdimmReservedEnd } ,
2018-12-21 08:23:55 -08:00
# endif // INCLUDE_G1GC || INCLUDE_PARALLELGC
2018-05-04 11:41:35 +02:00
# if INCLUDE_PARALLELGC
2015-09-01 21:38:07 +03:00
{ CC " psVirtualSpaceAlignment " , CC " ()J " , ( void * ) & WB_PSVirtualSpaceAlignment } ,
{ CC " psHeapGenerationAlignment " , CC " ()J " , ( void * ) & WB_PSHeapGenerationAlignment } ,
2018-05-04 11:41:35 +02:00
# endif
2013-08-23 12:36:32 -07:00
# if INCLUDE_NMT
2013-04-03 21:41:33 +02:00
{ CC " NMTMalloc " , CC " (J)J " , ( void * ) & WB_NMTMalloc } ,
2014-08-07 12:18:58 -07:00
{ CC " NMTMallocWithPseudoStack " , CC " (JI)J " , ( void * ) & WB_NMTMallocWithPseudoStack } ,
2019-02-08 14:03:09 -05:00
{ CC " NMTMallocWithPseudoStackAndType " , CC " (JII)J " , ( void * ) & WB_NMTMallocWithPseudoStackAndType } ,
2013-04-03 21:41:33 +02:00
{ CC " NMTFree " , CC " (J)V " , ( void * ) & WB_NMTFree } ,
{ CC " NMTReserveMemory " , CC " (J)J " , ( void * ) & WB_NMTReserveMemory } ,
2018-02-21 12:40:07 +01:00
{ CC " NMTAttemptReserveMemoryAt " , CC " (JJ)J " , ( void * ) & WB_NMTAttemptReserveMemoryAt } ,
2013-04-03 21:41:33 +02:00
{ CC " NMTCommitMemory " , CC " (JJ)V " , ( void * ) & WB_NMTCommitMemory } ,
{ CC " NMTUncommitMemory " , CC " (JJ)V " , ( void * ) & WB_NMTUncommitMemory } ,
{ CC " NMTReleaseMemory " , CC " (JJ)V " , ( void * ) & WB_NMTReleaseMemory } ,
2014-10-10 19:36:12 +00:00
{ CC " NMTChangeTrackingLevel " , CC " ()Z " , ( void * ) & WB_NMTChangeTrackingLevel } ,
2014-11-05 08:22:17 -08:00
{ CC " NMTGetHashSize " , CC " ()I " , ( void * ) & WB_NMTGetHashSize } ,
2019-11-26 09:27:16 -05:00
{ CC " NMTNewArena " , CC " (J)J " , ( void * ) & WB_NMTNewArena } ,
{ CC " NMTFreeArena " , CC " (J)V " , ( void * ) & WB_NMTFreeArena } ,
{ CC " NMTArenaMalloc " , CC " (JJ)V " , ( void * ) & WB_NMTArenaMalloc } ,
2013-02-01 23:48:08 +01:00
# endif // INCLUDE_NMT
2014-12-16 17:56:24 +03:00
{ CC " deoptimizeFrames " , CC " (Z)I " , ( void * ) & WB_DeoptimizeFrames } ,
2013-02-13 08:29:04 -08:00
{ CC " deoptimizeAll " , CC " ()V " , ( void * ) & WB_DeoptimizeAll } ,
2016-02-25 10:42:42 +01:00
{ CC " deoptimizeMethod0 " , CC " (Ljava/lang/reflect/Executable;Z)I " ,
( void * ) & WB_DeoptimizeMethod } ,
2015-04-02 18:53:45 +03:00
{ CC " isMethodCompiled0 " , CC " (Ljava/lang/reflect/Executable;Z)Z " ,
2013-02-13 08:29:04 -08:00
( void * ) & WB_IsMethodCompiled } ,
2015-04-02 18:53:45 +03:00
{ CC " isMethodCompilable0 " , CC " (Ljava/lang/reflect/Executable;IZ)Z " ,
2013-02-13 08:29:04 -08:00
( void * ) & WB_IsMethodCompilable } ,
2015-04-02 18:53:45 +03:00
{ CC " isMethodQueuedForCompilation0 " ,
2013-04-16 10:04:01 -07:00
CC " (Ljava/lang/reflect/Executable;)Z " , ( void * ) & WB_IsMethodQueuedForCompilation } ,
2015-07-28 19:20:42 +02:00
{ CC " isIntrinsicAvailable0 " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/reflect/Executable;I)Z " ,
( void * ) & WB_IsIntrinsicAvailable } ,
2015-04-02 18:53:45 +03:00
{ CC " makeMethodNotCompilable0 " ,
2013-08-14 23:50:23 +04:00
CC " (Ljava/lang/reflect/Executable;IZ)V " , ( void * ) & WB_MakeMethodNotCompilable } ,
2015-04-02 18:53:45 +03:00
{ CC " testSetDontInlineMethod0 " ,
2013-04-16 10:04:01 -07:00
CC " (Ljava/lang/reflect/Executable;Z)Z " , ( void * ) & WB_TestSetDontInlineMethod } ,
2015-04-02 18:53:45 +03:00
{ CC " getMethodCompilationLevel0 " ,
2013-08-14 23:50:23 +04:00
CC " (Ljava/lang/reflect/Executable;Z)I " , ( void * ) & WB_GetMethodCompilationLevel } ,
2015-04-02 18:53:45 +03:00
{ CC " getMethodEntryBci0 " ,
2013-08-14 23:50:23 +04:00
CC " (Ljava/lang/reflect/Executable;)I " , ( void * ) & WB_GetMethodEntryBci } ,
{ CC " getCompileQueueSize " ,
CC " (I)I " , ( void * ) & WB_GetCompileQueueSize } ,
2015-04-02 18:53:45 +03:00
{ CC " testSetForceInlineMethod0 " ,
2013-04-16 10:04:01 -07:00
CC " (Ljava/lang/reflect/Executable;Z)Z " , ( void * ) & WB_TestSetForceInlineMethod } ,
2015-04-02 18:53:45 +03:00
{ CC " enqueueMethodForCompilation0 " ,
2013-08-14 23:50:23 +04:00
CC " (Ljava/lang/reflect/Executable;II)Z " , ( void * ) & WB_EnqueueMethodForCompilation } ,
2016-04-07 16:51:37 +02:00
{ CC " enqueueInitializerForCompilation0 " ,
CC " (Ljava/lang/Class;I)Z " , ( void * ) & WB_EnqueueInitializerForCompilation } ,
2019-05-07 09:17:03 +02:00
{ CC " markMethodProfiled " ,
CC " (Ljava/lang/reflect/Executable;)V " , ( void * ) & WB_MarkMethodProfiled } ,
2015-04-02 18:53:45 +03:00
{ CC " clearMethodState0 " ,
2013-04-16 10:04:01 -07:00
CC " (Ljava/lang/reflect/Executable;)V " , ( void * ) & WB_ClearMethodState } ,
2014-11-10 19:04:38 +03:00
{ CC " lockCompilation " , CC " ()V " , ( void * ) & WB_LockCompilation } ,
{ CC " unlockCompilation " , CC " ()V " , ( void * ) & WB_UnlockCompilation } ,
2015-09-18 10:11:11 +02:00
{ CC " matchesMethod " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)I " ,
( void * ) & WB_MatchesMethod } ,
2015-10-20 18:07:28 +02:00
{ CC " matchesInline " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)I " ,
( void * ) & WB_MatchesInline } ,
{ CC " shouldPrintAssembly " ,
2016-02-25 10:42:42 +01:00
CC " (Ljava/lang/reflect/Executable;I)Z " ,
2015-10-20 18:07:28 +02:00
( void * ) & WB_ShouldPrintAssembly } ,
2014-10-24 08:22:33 +02:00
{ CC " isConstantVMFlag " , CC " (Ljava/lang/String;)Z " , ( void * ) & WB_IsConstantVMFlag } ,
{ CC " isLockedVMFlag " , CC " (Ljava/lang/String;)Z " , ( void * ) & WB_IsLockedVMFlag } ,
2014-05-30 17:20:48 +04:00
{ CC " setBooleanVMFlag " , CC " (Ljava/lang/String;Z)V " , ( void * ) & WB_SetBooleanVMFlag } ,
2015-06-04 14:29:34 +02:00
{ CC " setIntVMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetIntVMFlag } ,
{ CC " setUintVMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetUintVMFlag } ,
2014-05-30 17:20:48 +04:00
{ CC " setIntxVMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetIntxVMFlag } ,
{ CC " setUintxVMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetUintxVMFlag } ,
{ CC " setUint64VMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetUint64VMFlag } ,
2014-08-11 14:03:06 +02:00
{ CC " setSizeTVMFlag " , CC " (Ljava/lang/String;J)V " , ( void * ) & WB_SetSizeTVMFlag } ,
2014-05-30 17:20:48 +04:00
{ CC " setDoubleVMFlag " , CC " (Ljava/lang/String;D)V " , ( void * ) & WB_SetDoubleVMFlag } ,
{ CC " setStringVMFlag " , CC " (Ljava/lang/String;Ljava/lang/String;)V " ,
( void * ) & WB_SetStringVMFlag } ,
{ CC " getBooleanVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Boolean; " ,
( void * ) & WB_GetBooleanVMFlag } ,
2015-06-04 14:29:34 +02:00
{ CC " getIntVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetIntVMFlag } ,
{ CC " getUintVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetUintVMFlag } ,
2014-05-30 17:20:48 +04:00
{ CC " getIntxVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetIntxVMFlag } ,
{ CC " getUintxVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetUintxVMFlag } ,
{ CC " getUint64VMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetUint64VMFlag } ,
2014-08-11 14:03:06 +02:00
{ CC " getSizeTVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetSizeTVMFlag } ,
2014-05-30 17:20:48 +04:00
{ CC " getDoubleVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/Double; " ,
( void * ) & WB_GetDoubleVMFlag } ,
{ CC " getStringVMFlag " , CC " (Ljava/lang/String;)Ljava/lang/String; " ,
( void * ) & WB_GetStringVMFlag } ,
{ CC " isInStringTable " , CC " (Ljava/lang/String;)Z " , ( void * ) & WB_IsInStringTable } ,
2013-04-02 11:28:33 +02:00
{ CC " fullGC " , CC " ()V " , ( void * ) & WB_FullGC } ,
2014-08-21 16:44:41 +02:00
{ CC " youngGC " , CC " ()V " , ( void * ) & WB_YoungGC } ,
2013-05-21 09:43:23 -07:00
{ CC " readReservedMemory " , CC " ()V " , ( void * ) & WB_ReadReservedMemory } ,
2014-07-07 10:12:40 +02:00
{ CC " allocateMetaspace " ,
CC " (Ljava/lang/ClassLoader;J)J " , ( void * ) & WB_AllocateMetaspace } ,
{ CC " freeMetaspace " ,
CC " (Ljava/lang/ClassLoader;JJ)V " , ( void * ) & WB_FreeMetaspace } ,
2014-10-01 16:09:01 +02:00
{ CC " incMetaspaceCapacityUntilGC " , CC " (J)J " , ( void * ) & WB_IncMetaspaceCapacityUntilGC } ,
{ CC " metaspaceCapacityUntilGC " , CC " ()J " , ( void * ) & WB_MetaspaceCapacityUntilGC } ,
2017-08-02 18:06:38 -07:00
{ CC " metaspaceReserveAlignment " , CC " ()J " , ( void * ) & WB_MetaspaceReserveAlignment } ,
2014-03-22 00:26:48 +04:00
{ CC " getCPUFeatures " , CC " ()Ljava/lang/String; " , ( void * ) & WB_GetCPUFeatures } ,
2015-04-02 18:53:45 +03:00
{ CC " getNMethod0 " , CC " (Ljava/lang/reflect/Executable;Z)[Ljava/lang/Object; " ,
2014-03-27 11:17:26 +04:00
( void * ) & WB_GetNMethod } ,
2015-03-30 07:54:23 +02:00
{ CC " forceNMethodSweep " , CC " ()V " , ( void * ) & WB_ForceNMethodSweep } ,
2014-11-10 19:04:38 +03:00
{ CC " allocateCodeBlob " , CC " (II)J " , ( void * ) & WB_AllocateCodeBlob } ,
{ CC " freeCodeBlob " , CC " (J)V " , ( void * ) & WB_FreeCodeBlob } ,
{ CC " getCodeHeapEntries " , CC " (I)[Ljava/lang/Object; " , ( void * ) & WB_GetCodeHeapEntries } ,
2014-11-21 17:27:11 +03:00
{ CC " getCompilationActivityMode " ,
CC " ()I " , ( void * ) & WB_GetCompilationActivityMode } ,
2015-10-08 12:49:30 -10:00
{ CC " getMethodData0 " , CC " (Ljava/lang/reflect/Executable;)J " ,
( void * ) & WB_GetMethodData } ,
2014-11-21 17:27:11 +03:00
{ CC " getCodeBlob " , CC " (J)[Ljava/lang/Object; " , ( void * ) & WB_GetCodeBlob } ,
2014-05-24 00:04:21 +04:00
{ CC " getThreadStackSize " , CC " ()J " , ( void * ) & WB_GetThreadStackSize } ,
{ CC " getThreadRemainingStackSize " , CC " ()J " , ( void * ) & WB_GetThreadRemainingStackSize } ,
2017-04-24 12:08:28 -04:00
{ CC " DefineModule " , CC " (Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V " ,
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
( void * ) & WB_DefineModule } ,
{ CC " AddModuleExports " , CC " (Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V " ,
( void * ) & WB_AddModuleExports } ,
{ CC " AddReadsModule " , CC " (Ljava/lang/Object;Ljava/lang/Object;)V " ,
( void * ) & WB_AddReadsModule } ,
{ CC " AddModuleExportsToAllUnnamed " , CC " (Ljava/lang/Object;Ljava/lang/String;)V " ,
( void * ) & WB_AddModuleExportsToAllUnnamed } ,
{ CC " AddModuleExportsToAll " , CC " (Ljava/lang/Object;Ljava/lang/String;)V " ,
( void * ) & WB_AddModuleExportsToAll } ,
2020-06-24 17:48:53 -04:00
{ CC " deflateIdleMonitors " , CC " ()Z " , ( void * ) & WB_DeflateIdleMonitors } ,
2015-06-25 18:25:19 +02:00
{ CC " isMonitorInflated0 " , CC " (Ljava/lang/Object;)Z " , ( void * ) & WB_IsMonitorInflated } ,
2014-12-30 11:07:49 +03:00
{ CC " forceSafepoint " , CC " ()V " , ( void * ) & WB_ForceSafepoint } ,
2015-10-08 12:49:30 -10:00
{ CC " getConstantPool0 " , CC " (Ljava/lang/Class;)J " , ( void * ) & WB_GetConstantPool } ,
2016-02-20 11:44:14 +03:00
{ CC " getConstantPoolCacheIndexTag0 " , CC " ()I " , ( void * ) & WB_GetConstantPoolCacheIndexTag } ,
{ CC " getConstantPoolCacheLength0 " , CC " (Ljava/lang/Class;)I " , ( void * ) & WB_GetConstantPoolCacheLength } ,
{ CC " remapInstructionOperandFromCPCache0 " ,
CC " (Ljava/lang/Class;I)I " , ( void * ) & WB_ConstantPoolRemapInstructionOperandFromCache } ,
{ CC " encodeConstantPoolIndyIndex0 " ,
CC " (I)I " , ( void * ) & WB_ConstantPoolEncodeIndyIndex } ,
2015-03-12 19:11:25 +03:00
{ CC " getMethodBooleanOption " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean; " ,
( void * ) & WB_GetMethodBooleaneOption } ,
{ CC " getMethodIntxOption " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetMethodIntxOption } ,
{ CC " getMethodUintxOption " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long; " ,
( void * ) & WB_GetMethodUintxOption } ,
{ CC " getMethodDoubleOption " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double; " ,
( void * ) & WB_GetMethodDoubleOption } ,
{ CC " getMethodStringOption " ,
CC " (Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String; " ,
( void * ) & WB_GetMethodStringOption } ,
2018-10-05 18:56:11 -04:00
{ CC " getDefaultArchivePath " , CC " ()Ljava/lang/String; " ,
( void * ) & WB_GetDefaultArchivePath } ,
{ CC " isSharingEnabled " , CC " ()Z " , ( void * ) & WB_IsSharingEnabled } ,
2015-06-12 17:29:14 -04:00
{ CC " isShared " , CC " (Ljava/lang/Object;)Z " , ( void * ) & WB_IsShared } ,
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
{ CC " isSharedClass " , CC " (Ljava/lang/Class;)Z " , ( void * ) & WB_IsSharedClass } ,
2015-06-17 21:44:48 +00:00
{ CC " areSharedStringsIgnored " , CC " ()Z " , ( void * ) & WB_AreSharedStringsIgnored } ,
2017-08-14 14:32:17 -04:00
{ CC " getResolvedReferences " , CC " (Ljava/lang/Class;)Ljava/lang/Object; " , ( void * ) & WB_GetResolvedReferences } ,
2019-05-17 08:29:55 -07:00
{ CC " linkClass " , CC " (Ljava/lang/Class;)V " , ( void * ) & WB_LinkClass } ,
2017-11-07 18:48:17 -05:00
{ CC " areOpenArchiveHeapObjectsMapped " , CC " ()Z " , ( void * ) & WB_AreOpenArchiveHeapObjectsMapped } ,
2017-08-03 10:24:34 +02:00
{ CC " isCDSIncludedInVmBuild " , CC " ()Z " , ( void * ) & WB_IsCDSIncludedInVmBuild } ,
2018-07-20 09:46:57 +02:00
{ CC " isJFRIncludedInVmBuild " , CC " ()Z " , ( void * ) & WB_IsJFRIncludedInVmBuild } ,
2020-01-08 14:36:48 +01:00
{ CC " isC2OrJVMCIIncludedInVmBuild " , CC " ()Z " , ( void * ) & WB_isC2OrJVMCIIncludedInVmBuild } ,
2019-05-17 08:29:55 -07:00
{ CC " isJavaHeapArchiveSupported " , CC " ()Z " , ( void * ) & WB_IsJavaHeapArchiveSupported } ,
{ CC " cdsMemoryMappingFailed " , CC " ()Z " , ( void * ) & WB_CDSMemoryMappingFailed } ,
2018-02-15 11:39:42 -08:00
2016-04-05 01:46:40 -07:00
{ CC " clearInlineCaches0 " , CC " (Z)V " , ( void * ) & WB_ClearInlineCaches } ,
2017-08-31 10:00:28 +02:00
{ CC " handshakeWalkStack " , CC " (Ljava/lang/Thread;Z)I " , ( void * ) & WB_HandshakeWalkStack } ,
2020-05-13 22:29:54 -04:00
{ CC " checkThreadObjOfTerminatingThread " , CC " (Ljava/lang/Thread;)V " , ( void * ) & WB_CheckThreadObjOfTerminatingThread } ,
2016-03-03 16:21:16 +01:00
{ CC " addCompilerDirective " , CC " (Ljava/lang/String;)I " ,
( void * ) & WB_AddCompilerDirective } ,
2018-03-28 11:38:47 +02:00
{ CC " removeCompilerDirective " , CC " (I)V " , ( void * ) & WB_RemoveCompilerDirective } ,
{ CC " isGCSupported " , CC " (I)Z " , ( void * ) & WB_IsGCSupported } ,
{ CC " isGCSelected " , CC " (I)Z " , ( void * ) & WB_IsGCSelected } ,
{ CC " isGCSelectedErgonomically " , CC " ()Z " , ( void * ) & WB_IsGCSelectedErgonomically } ,
2020-03-06 18:42:13 -05:00
{ CC " supportsConcurrentGCBreakpoints " , CC " ()Z " , ( void * ) & WB_SupportsConcurrentGCBreakpoints } ,
{ CC " concurrentGCAcquireControl0 " , CC " ()V " , ( void * ) & WB_ConcurrentGCAcquireControl } ,
{ CC " concurrentGCReleaseControl0 " , CC " ()V " , ( void * ) & WB_ConcurrentGCReleaseControl } ,
{ CC " concurrentGCRunToIdle0 " , CC " ()V " , ( void * ) & WB_ConcurrentGCRunToIdle } ,
{ CC " concurrentGCRunTo0 " , CC " (Ljava/lang/String;)Z " ,
( void * ) & WB_ConcurrentGCRunTo } ,
2017-09-25 23:42:58 -04:00
{ CC " checkLibSpecifiesNoexecstack " , CC " (Ljava/lang/String;)Z " ,
( void * ) & WB_CheckLibSpecifiesNoexecstack } ,
2017-11-16 19:01:01 -08:00
{ CC " isContainerized " , CC " ()Z " , ( void * ) & WB_IsContainerized } ,
2020-02-25 12:17:26 +01:00
{ CC " validateCgroup " ,
CC " (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I " ,
( void * ) & WB_ValidateCgroup } ,
2017-11-16 19:01:01 -08:00
{ CC " printOsInfo " , CC " ()V " , ( void * ) & WB_PrintOsInfo } ,
2018-02-14 17:20:59 -05:00
{ CC " disableElfSectionCache " , CC " ()V " , ( void * ) & WB_DisableElfSectionCache } ,
2019-04-10 15:41:04 +02:00
{ CC " resolvedMethodItemsCount " , CC " ()J " , ( void * ) & WB_ResolvedMethodItemsCount } ,
2018-08-31 10:22:04 -04:00
{ CC " protectionDomainRemovedCount " , CC " ()I " , ( void * ) & WB_ProtectionDomainRemovedCount } ,
2019-01-23 16:36:45 -08:00
{ CC " aotLibrariesCount " , CC " ()I " , ( void * ) & WB_AotLibrariesCount } ,
2020-01-09 17:38:41 -05:00
{ CC " getKlassMetadataSize " , CC " (Ljava/lang/Class;)I " , ( void * ) & WB_GetKlassMetadataSize } ,
2020-08-21 15:49:09 -07:00
{ CC " isJVMTIIncluded " , CC " ()Z " , ( void * ) & WB_IsJVMTIIncluded } ,
2012-02-23 14:58:35 +01:00
} ;
2017-11-16 19:01:01 -08:00
2012-02-23 14:58:35 +01:00
# undef CC
JVM_ENTRY ( void , JVM_RegisterWhiteBoxMethods ( JNIEnv * env , jclass wbclass ) )
{
if ( WhiteBoxAPI ) {
// Make sure that wbclass is loaded by the null classloader
2020-06-17 07:40:09 -07:00
InstanceKlass * ik = InstanceKlass : : cast ( java_lang_Class : : as_Klass ( JNIHandles : : resolve ( wbclass ) ) ) ;
2017-03-15 10:25:37 -04:00
Handle loader ( THREAD , ik - > class_loader ( ) ) ;
2012-02-23 14:58:35 +01:00
if ( loader . is_null ( ) ) {
2014-09-08 15:24:10 +02:00
WhiteBox : : register_methods ( env , wbclass , thread , methods , sizeof ( methods ) / sizeof ( methods [ 0 ] ) ) ;
WhiteBox : : set_used ( ) ;
2012-02-23 14:58:35 +01:00
}
}
}
JVM_END