36 #include "classfile/javaClasses.inline.hpp"
37 #include "classfile/modules.hpp"
38 #include "classfile/protectionDomainCache.hpp"
39 #include "classfile/stringTable.hpp"
40 #include "classfile/symbolTable.hpp"
41 #include "classfile/systemDictionary.hpp"
42 #include "classfile/vmSymbols.hpp"
43 #include "code/codeCache.hpp"
44 #include "compiler/compilationPolicy.hpp"
45 #include "compiler/compilerOracle.hpp"
46 #include "compiler/directivesParser.hpp"
47 #include "compiler/methodMatcher.hpp"
48 #include "gc/shared/concurrentGCBreakpoints.hpp"
49 #include "gc/shared/gcConfig.hpp"
50 #include "gc/shared/gcLocker.inline.hpp"
51 #include "gc/shared/genArguments.hpp"
52 #include "jvmtifiles/jvmtiEnv.hpp"
53 #include "logging/log.hpp"
54 #include "memory/iterator.hpp"
55 #include "memory/metadataFactory.hpp"
56 #include "memory/metaspace/testHelpers.hpp"
57 #include "memory/metaspaceUtils.hpp"
58 #include "memory/oopFactory.hpp"
59 #include "memory/resourceArea.hpp"
60 #include "memory/universe.hpp"
61 #include "nmt/mallocSiteTable.hpp"
62 #include "nmt/memTracker.hpp"
63 #include "oops/array.hpp"
64 #include "oops/compressedOops.hpp"
65 #include "oops/constantPool.inline.hpp"
66 #include "oops/klass.inline.hpp"
67 #include "oops/method.inline.hpp"
68 #include "oops/methodData.inline.hpp"
69 #include "oops/objArrayKlass.hpp"
70 #include "oops/objArrayOop.inline.hpp"
71 #include "oops/oop.inline.hpp"
72 #include "oops/typeArrayOop.inline.hpp"
73 #include "prims/jvmtiEnvBase.hpp"
74 #include "prims/resolvedMethodTable.hpp"
75 #include "prims/wbtestmethods/parserTests.hpp"
76 #include "prims/whitebox.inline.hpp"
77 #include "runtime/arguments.hpp"
78 #include "runtime/atomic.hpp"
79 #include "runtime/deoptimization.hpp"
80 #include "runtime/fieldDescriptor.inline.hpp"
81 #include "runtime/flags/jvmFlag.hpp"
82 #include "runtime/flags/jvmFlagAccess.hpp"
83 #include "runtime/frame.inline.hpp"
84 #include "runtime/handles.inline.hpp"
85 #include "runtime/handshake.hpp"
86 #include "runtime/interfaceSupport.inline.hpp"
87 #include "runtime/javaCalls.hpp"
88 #include "runtime/javaThread.inline.hpp"
89 #include "runtime/jniHandles.inline.hpp"
90 #include "runtime/lockStack.hpp"
91 #include "runtime/os.hpp"
1885 VMThread::execute(&force_safepoint_op);
1886 WB_END
1887
1888 WB_ENTRY(void, WB_ForceClassLoaderStatsSafepoint(JNIEnv* env, jobject wb))
1889 nullStream dev_null;
1890 ClassLoaderStatsVMOperation force_op(&dev_null);
1891 VMThread::execute(&force_op);
1892 WB_END
1893
1894 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1895 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1896 return (jlong) ik->constants();
1897 WB_END
1898
1899 WB_ENTRY(jobjectArray, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass klass))
1900 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1901 objArrayOop resolved_refs= ik->constants()->resolved_references();
1902 return (jobjectArray)JNIHandles::make_local(THREAD, resolved_refs);
1903 WB_END
1904
1905 WB_ENTRY(jint, WB_getFieldEntriesLength(JNIEnv* env, jobject wb, jclass klass))
1906 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1907 ConstantPool* cp = ik->constants();
1908 if (cp->cache() == nullptr) {
1909 return -1;
1910 }
1911 return cp->resolved_field_entries_length();
1912 WB_END
1913
1914 WB_ENTRY(jint, WB_getFieldCPIndex(JNIEnv* env, jobject wb, jclass klass, jint index))
1915 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1916 ConstantPool* cp = ik->constants();
1917 if (cp->cache() == nullptr) {
1918 return -1;
1919 }
1920 return cp->resolved_field_entry_at(index)->constant_pool_index();
1921 WB_END
1922
1923 WB_ENTRY(jint, WB_getMethodEntriesLength(JNIEnv* env, jobject wb, jclass klass))
1924 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
2859 {CC"getThreadRemainingStackSize", CC"()J", (void*)&WB_GetThreadRemainingStackSize },
2860 {CC"DefineModule", CC"(Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V",
2861 (void*)&WB_DefineModule },
2862 {CC"AddModuleExports", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V",
2863 (void*)&WB_AddModuleExports },
2864 {CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
2865 (void*)&WB_AddReadsModule },
2866 {CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
2867 (void*)&WB_AddModuleExportsToAllUnnamed },
2868 {CC"AddModuleExportsToAll", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
2869 (void*)&WB_AddModuleExportsToAll },
2870 {CC"deflateIdleMonitors", CC"()Z", (void*)&WB_DeflateIdleMonitors },
2871 {CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated },
2872 {CC"getInUseMonitorCount", CC"()J", (void*)&WB_getInUseMonitorCount },
2873 {CC"getLockStackCapacity", CC"()I", (void*)&WB_getLockStackCapacity },
2874 {CC"supportsRecursiveLightweightLocking", CC"()Z", (void*)&WB_supportsRecursiveLightweightLocking },
2875 {CC"forceSafepoint", CC"()V", (void*)&WB_ForceSafepoint },
2876 {CC"forceClassLoaderStatsSafepoint", CC"()V", (void*)&WB_ForceClassLoaderStatsSafepoint },
2877 {CC"getConstantPool0", CC"(Ljava/lang/Class;)J", (void*)&WB_GetConstantPool },
2878 {CC"getResolvedReferences0", CC"(Ljava/lang/Class;)[Ljava/lang/Object;", (void*)&WB_GetResolvedReferences},
2879 {CC"getFieldEntriesLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getFieldEntriesLength},
2880 {CC"getFieldCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getFieldCPIndex},
2881 {CC"getMethodEntriesLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getMethodEntriesLength},
2882 {CC"getMethodCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getMethodCPIndex},
2883 {CC"getIndyInfoLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getIndyInfoLength},
2884 {CC"getIndyCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getIndyCPIndex},
2885 {CC"printClasses0", CC"(Ljava/lang/String;I)Ljava/lang/String;", (void*)&WB_printClasses},
2886 {CC"printMethods0", CC"(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;", (void*)&WB_printMethods},
2887 {CC"getMethodBooleanOption",
2888 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
2889 (void*)&WB_GetMethodBooleaneOption},
2890 {CC"getMethodIntxOption",
2891 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2892 (void*)&WB_GetMethodIntxOption},
2893 {CC"getMethodUintxOption",
2894 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2895 (void*)&WB_GetMethodUintxOption},
2896 {CC"getMethodDoubleOption",
2897 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
2898 (void*)&WB_GetMethodDoubleOption},
|
36 #include "classfile/javaClasses.inline.hpp"
37 #include "classfile/modules.hpp"
38 #include "classfile/protectionDomainCache.hpp"
39 #include "classfile/stringTable.hpp"
40 #include "classfile/symbolTable.hpp"
41 #include "classfile/systemDictionary.hpp"
42 #include "classfile/vmSymbols.hpp"
43 #include "code/codeCache.hpp"
44 #include "compiler/compilationPolicy.hpp"
45 #include "compiler/compilerOracle.hpp"
46 #include "compiler/directivesParser.hpp"
47 #include "compiler/methodMatcher.hpp"
48 #include "gc/shared/concurrentGCBreakpoints.hpp"
49 #include "gc/shared/gcConfig.hpp"
50 #include "gc/shared/gcLocker.inline.hpp"
51 #include "gc/shared/genArguments.hpp"
52 #include "jvmtifiles/jvmtiEnv.hpp"
53 #include "logging/log.hpp"
54 #include "memory/iterator.hpp"
55 #include "memory/metadataFactory.hpp"
56 #include "memory/iterator.inline.hpp"
57 #include "memory/metaspace/testHelpers.hpp"
58 #include "memory/metaspaceUtils.hpp"
59 #include "memory/oopFactory.hpp"
60 #include "memory/resourceArea.hpp"
61 #include "memory/universe.hpp"
62 #include "nmt/mallocSiteTable.hpp"
63 #include "nmt/memTracker.hpp"
64 #include "oops/array.hpp"
65 #include "oops/compressedOops.hpp"
66 #include "oops/compressedOops.inline.hpp"
67 #include "oops/constantPool.inline.hpp"
68 #include "oops/klass.inline.hpp"
69 #include "oops/method.inline.hpp"
70 #include "oops/methodData.inline.hpp"
71 #include "oops/objArrayKlass.hpp"
72 #include "oops/objArrayOop.inline.hpp"
73 #include "oops/oop.inline.hpp"
74 #include "oops/objArrayOop.inline.hpp"
75 #include "oops/typeArrayOop.inline.hpp"
76 #include "prims/jvmtiEnvBase.hpp"
77 #include "prims/resolvedMethodTable.hpp"
78 #include "prims/wbtestmethods/parserTests.hpp"
79 #include "prims/whitebox.inline.hpp"
80 #include "runtime/arguments.hpp"
81 #include "runtime/atomic.hpp"
82 #include "runtime/deoptimization.hpp"
83 #include "runtime/fieldDescriptor.inline.hpp"
84 #include "runtime/flags/jvmFlag.hpp"
85 #include "runtime/flags/jvmFlagAccess.hpp"
86 #include "runtime/frame.inline.hpp"
87 #include "runtime/handles.inline.hpp"
88 #include "runtime/handshake.hpp"
89 #include "runtime/interfaceSupport.inline.hpp"
90 #include "runtime/javaCalls.hpp"
91 #include "runtime/javaThread.inline.hpp"
92 #include "runtime/jniHandles.inline.hpp"
93 #include "runtime/lockStack.hpp"
94 #include "runtime/os.hpp"
1888 VMThread::execute(&force_safepoint_op);
1889 WB_END
1890
1891 WB_ENTRY(void, WB_ForceClassLoaderStatsSafepoint(JNIEnv* env, jobject wb))
1892 nullStream dev_null;
1893 ClassLoaderStatsVMOperation force_op(&dev_null);
1894 VMThread::execute(&force_op);
1895 WB_END
1896
1897 WB_ENTRY(jlong, WB_GetConstantPool(JNIEnv* env, jobject wb, jclass klass))
1898 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1899 return (jlong) ik->constants();
1900 WB_END
1901
1902 WB_ENTRY(jobjectArray, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass klass))
1903 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1904 objArrayOop resolved_refs= ik->constants()->resolved_references();
1905 return (jobjectArray)JNIHandles::make_local(THREAD, resolved_refs);
1906 WB_END
1907
1908 WB_ENTRY(jobjectArray, WB_getObjectsViaKlassOopMaps(JNIEnv* env, jobject wb, jobject thing))
1909 oop aoop = JNIHandles::resolve(thing);
1910 if (!aoop->is_instance()) {
1911 return nullptr;
1912 }
1913 instanceHandle ih(THREAD, (instanceOop) aoop);
1914 InstanceKlass* klass = InstanceKlass::cast(ih->klass());
1915 if (klass->nonstatic_oop_map_count() == 0) {
1916 return nullptr;
1917 }
1918 const OopMapBlock* map = klass->start_of_nonstatic_oop_maps();
1919 const OopMapBlock* const end = map + klass->nonstatic_oop_map_count();
1920 int oop_count = 0;
1921 while (map < end) {
1922 oop_count += map->count();
1923 map++;
1924 }
1925
1926 objArrayHandle result_array =
1927 oopFactory::new_objArray_handle(vmClasses::Object_klass(), oop_count, CHECK_NULL);
1928 map = klass->start_of_nonstatic_oop_maps();
1929 int index = 0;
1930 while (map < end) {
1931 int offset = map->offset();
1932 for (unsigned int j = 0; j < map->count(); j++) {
1933 result_array->obj_at_put(index++, ih->obj_field(offset));
1934 offset += heapOopSize;
1935 }
1936 map++;
1937 }
1938 return (jobjectArray)JNIHandles::make_local(THREAD, result_array());
1939 WB_END
1940
1941 class CollectOops : public BasicOopIterateClosure {
1942 public:
1943 GrowableArray<Handle>* array;
1944
1945 jobjectArray create_jni_result(JNIEnv* env, TRAPS) {
1946 objArrayHandle result_array =
1947 oopFactory::new_objArray_handle(vmClasses::Object_klass(), array->length(), CHECK_NULL);
1948 for (int i = 0 ; i < array->length(); i++) {
1949 result_array->obj_at_put(i, array->at(i)());
1950 }
1951 return (jobjectArray)JNIHandles::make_local(THREAD, result_array());
1952 }
1953
1954 void add_oop(oop o) {
1955 Handle oh = Handle(Thread::current(), o);
1956 // Value might be oop, but JLS can't see as Object, just iterate through it...
1957 if (oh != nullptr && oh->is_inline_type()) {
1958 oh->oop_iterate(this);
1959 } else {
1960 array->append(oh);
1961 }
1962 }
1963
1964 void do_oop(oop* o) { add_oop(HeapAccess<>::oop_load(o)); }
1965 void do_oop(narrowOop* v) { add_oop(HeapAccess<>::oop_load(v)); }
1966 };
1967
1968 WB_ENTRY(jobjectArray, WB_getObjectsViaOopIterator(JNIEnv* env, jobject wb, jobject thing))
1969 ResourceMark rm(thread);
1970 Handle objh(thread, JNIHandles::resolve(thing));
1971 GrowableArray<Handle>* array = new GrowableArray<Handle>(128);
1972 CollectOops collectOops;
1973 collectOops.array = array;
1974 objh->oop_iterate(&collectOops);
1975 return collectOops.create_jni_result(env, THREAD);
1976 WB_END
1977
1978 WB_ENTRY(jobjectArray, WB_getObjectsViaFrameOopIterator(JNIEnv* env, jobject wb, jint depth))
1979 ResourceMark rm(THREAD);
1980 GrowableArray<Handle>* array = new GrowableArray<Handle>(128);
1981 CollectOops collectOops;
1982 collectOops.array = array;
1983 StackFrameStream sfs(thread, false /* update */, true /* process_frames */);
1984 while (depth > 0) { // Skip the native WB API frame
1985 sfs.next();
1986 frame* f = sfs.current();
1987 f->oops_do(&collectOops, nullptr, sfs.register_map());
1988 depth--;
1989 }
1990 return collectOops.create_jni_result(env, THREAD);
1991 WB_END
1992
1993 WB_ENTRY(jint, WB_getFieldEntriesLength(JNIEnv* env, jobject wb, jclass klass))
1994 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
1995 ConstantPool* cp = ik->constants();
1996 if (cp->cache() == nullptr) {
1997 return -1;
1998 }
1999 return cp->resolved_field_entries_length();
2000 WB_END
2001
2002 WB_ENTRY(jint, WB_getFieldCPIndex(JNIEnv* env, jobject wb, jclass klass, jint index))
2003 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
2004 ConstantPool* cp = ik->constants();
2005 if (cp->cache() == nullptr) {
2006 return -1;
2007 }
2008 return cp->resolved_field_entry_at(index)->constant_pool_index();
2009 WB_END
2010
2011 WB_ENTRY(jint, WB_getMethodEntriesLength(JNIEnv* env, jobject wb, jclass klass))
2012 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass)));
2947 {CC"getThreadRemainingStackSize", CC"()J", (void*)&WB_GetThreadRemainingStackSize },
2948 {CC"DefineModule", CC"(Ljava/lang/Object;ZLjava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)V",
2949 (void*)&WB_DefineModule },
2950 {CC"AddModuleExports", CC"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V",
2951 (void*)&WB_AddModuleExports },
2952 {CC"AddReadsModule", CC"(Ljava/lang/Object;Ljava/lang/Object;)V",
2953 (void*)&WB_AddReadsModule },
2954 {CC"AddModuleExportsToAllUnnamed", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
2955 (void*)&WB_AddModuleExportsToAllUnnamed },
2956 {CC"AddModuleExportsToAll", CC"(Ljava/lang/Object;Ljava/lang/String;)V",
2957 (void*)&WB_AddModuleExportsToAll },
2958 {CC"deflateIdleMonitors", CC"()Z", (void*)&WB_DeflateIdleMonitors },
2959 {CC"isMonitorInflated0", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated },
2960 {CC"getInUseMonitorCount", CC"()J", (void*)&WB_getInUseMonitorCount },
2961 {CC"getLockStackCapacity", CC"()I", (void*)&WB_getLockStackCapacity },
2962 {CC"supportsRecursiveLightweightLocking", CC"()Z", (void*)&WB_supportsRecursiveLightweightLocking },
2963 {CC"forceSafepoint", CC"()V", (void*)&WB_ForceSafepoint },
2964 {CC"forceClassLoaderStatsSafepoint", CC"()V", (void*)&WB_ForceClassLoaderStatsSafepoint },
2965 {CC"getConstantPool0", CC"(Ljava/lang/Class;)J", (void*)&WB_GetConstantPool },
2966 {CC"getResolvedReferences0", CC"(Ljava/lang/Class;)[Ljava/lang/Object;", (void*)&WB_GetResolvedReferences},
2967 {CC"getObjectsViaKlassOopMaps0",
2968 CC"(Ljava/lang/Object;)[Ljava/lang/Object;", (void*)&WB_getObjectsViaKlassOopMaps},
2969 {CC"getObjectsViaOopIterator0",
2970 CC"(Ljava/lang/Object;)[Ljava/lang/Object;",(void*)&WB_getObjectsViaOopIterator},
2971 {CC"getObjectsViaFrameOopIterator",
2972 CC"(I)[Ljava/lang/Object;", (void*)&WB_getObjectsViaFrameOopIterator},
2973 {CC"getFieldEntriesLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getFieldEntriesLength},
2974 {CC"getFieldCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getFieldCPIndex},
2975 {CC"getMethodEntriesLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getMethodEntriesLength},
2976 {CC"getMethodCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getMethodCPIndex},
2977 {CC"getIndyInfoLength0", CC"(Ljava/lang/Class;)I", (void*)&WB_getIndyInfoLength},
2978 {CC"getIndyCPIndex0", CC"(Ljava/lang/Class;I)I", (void*)&WB_getIndyCPIndex},
2979 {CC"printClasses0", CC"(Ljava/lang/String;I)Ljava/lang/String;", (void*)&WB_printClasses},
2980 {CC"printMethods0", CC"(Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;", (void*)&WB_printMethods},
2981 {CC"getMethodBooleanOption",
2982 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
2983 (void*)&WB_GetMethodBooleaneOption},
2984 {CC"getMethodIntxOption",
2985 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2986 (void*)&WB_GetMethodIntxOption},
2987 {CC"getMethodUintxOption",
2988 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2989 (void*)&WB_GetMethodUintxOption},
2990 {CC"getMethodDoubleOption",
2991 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
2992 (void*)&WB_GetMethodDoubleOption},
|