32 #include "code/codeCache.hpp"
33 #include "compiler/methodMatcher.hpp"
34 #include "compiler/directivesParser.hpp"
35 #include "jvmtifiles/jvmtiEnv.hpp"
36 #include "memory/metadataFactory.hpp"
37 #include "memory/metaspaceShared.hpp"
38 #include "memory/iterator.hpp"
39 #include "memory/resourceArea.hpp"
40 #include "memory/universe.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "oops/array.hpp"
43 #include "oops/constantPool.hpp"
44 #include "oops/objArrayKlass.hpp"
45 #include "oops/objArrayOop.inline.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "prims/wbtestmethods/parserTests.hpp"
48 #include "prims/whitebox.hpp"
49 #include "runtime/arguments.hpp"
50 #include "runtime/compilationPolicy.hpp"
51 #include "runtime/deoptimization.hpp"
52 #include "runtime/interfaceSupport.hpp"
53 #include "runtime/javaCalls.hpp"
54 #include "runtime/os.hpp"
55 #include "runtime/sweeper.hpp"
56 #include "runtime/thread.hpp"
57 #include "runtime/vm_version.hpp"
58 #include "utilities/align.hpp"
59 #include "utilities/debug.hpp"
60 #include "utilities/exceptions.hpp"
61 #include "utilities/macros.hpp"
62 #if INCLUDE_ALL_GCS
63 #include "gc/g1/concurrentMarkThread.hpp"
64 #include "gc/g1/g1CollectedHeap.inline.hpp"
65 #include "gc/g1/g1ConcurrentMark.hpp"
66 #include "gc/g1/heapRegionRemSet.hpp"
67 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
68 #include "gc/parallel/adjoiningGenerations.hpp"
69 #endif // INCLUDE_ALL_GCS
70 #if INCLUDE_NMT
71 #include "services/mallocSiteTable.hpp"
1706 WB_ENTRY(jobject, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass clazz))
1707 Klass *k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
1708 if (k->is_instance_klass()) {
1709 InstanceKlass *ik = InstanceKlass::cast(k);
1710 ConstantPool *cp = ik->constants();
1711 objArrayOop refs = cp->resolved_references();
1712 return (jobject)JNIHandles::make_local(env, refs);
1713 } else {
1714 return NULL;
1715 }
1716 WB_END
1717
1718 WB_ENTRY(jboolean, WB_IsCDSIncludedInVmBuild(JNIEnv* env))
1719 #if INCLUDE_CDS
1720 return true;
1721 #else
1722 return false;
1723 #endif
1724 WB_END
1725
1726 //Some convenience methods to deal with objects from java
1727 int WhiteBox::offset_for_field(const char* field_name, oop object,
1728 Symbol* signature_symbol) {
1729 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
1730 Thread* THREAD = Thread::current();
1731
1732 //Get the class of our object
1733 Klass* arg_klass = object->klass();
1734 //Turn it into an instance-klass
1735 InstanceKlass* ik = InstanceKlass::cast(arg_klass);
1736
1737 //Create symbols to look for in the class
1738 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
1739 THREAD);
1740
1741 //To be filled in with an offset of the field we're looking for
1742 fieldDescriptor fd;
1743
1744 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
1745 if (res == NULL) {
2016 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
2017 (void*)&WB_GetMethodBooleaneOption},
2018 {CC"getMethodIntxOption",
2019 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2020 (void*)&WB_GetMethodIntxOption},
2021 {CC"getMethodUintxOption",
2022 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2023 (void*)&WB_GetMethodUintxOption},
2024 {CC"getMethodDoubleOption",
2025 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
2026 (void*)&WB_GetMethodDoubleOption},
2027 {CC"getMethodStringOption",
2028 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String;",
2029 (void*)&WB_GetMethodStringOption},
2030 {CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
2031 {CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass },
2032 {CC"areSharedStringsIgnored", CC"()Z", (void*)&WB_AreSharedStringsIgnored },
2033 {CC"getResolvedReferences", CC"(Ljava/lang/Class;)Ljava/lang/Object;", (void*)&WB_GetResolvedReferences},
2034 {CC"isCDSIncludedInVmBuild", CC"()Z", (void*)&WB_IsCDSIncludedInVmBuild },
2035 {CC"clearInlineCaches0", CC"(Z)V", (void*)&WB_ClearInlineCaches },
2036 {CC"addCompilerDirective", CC"(Ljava/lang/String;)I",
2037 (void*)&WB_AddCompilerDirective },
2038 {CC"removeCompilerDirective", CC"(I)V", (void*)&WB_RemoveCompilerDirective },
2039 {CC"currentGC", CC"()I", (void*)&WB_CurrentGC},
2040 {CC"allSupportedGC", CC"()I", (void*)&WB_AllSupportedGC},
2041 {CC"gcSelectedByErgo", CC"()Z", (void*)&WB_GCSelectedByErgo},
2042 {CC"supportsConcurrentGCPhaseControl", CC"()Z", (void*)&WB_SupportsConcurrentGCPhaseControl},
2043 {CC"getConcurrentGCPhases", CC"()[Ljava/lang/String;",
2044 (void*)&WB_GetConcurrentGCPhases},
2045 {CC"requestConcurrentGCPhase0", CC"(Ljava/lang/String;)Z",
2046 (void*)&WB_RequestConcurrentGCPhase},
2047 {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z",
2048 (void*)&WB_CheckLibSpecifiesNoexecstack},
2049 };
2050
2051 #undef CC
2052
2053 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
2054 {
2055 if (WhiteBoxAPI) {
|
32 #include "code/codeCache.hpp"
33 #include "compiler/methodMatcher.hpp"
34 #include "compiler/directivesParser.hpp"
35 #include "jvmtifiles/jvmtiEnv.hpp"
36 #include "memory/metadataFactory.hpp"
37 #include "memory/metaspaceShared.hpp"
38 #include "memory/iterator.hpp"
39 #include "memory/resourceArea.hpp"
40 #include "memory/universe.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "oops/array.hpp"
43 #include "oops/constantPool.hpp"
44 #include "oops/objArrayKlass.hpp"
45 #include "oops/objArrayOop.inline.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "prims/wbtestmethods/parserTests.hpp"
48 #include "prims/whitebox.hpp"
49 #include "runtime/arguments.hpp"
50 #include "runtime/compilationPolicy.hpp"
51 #include "runtime/deoptimization.hpp"
52 #include "runtime/handshake.hpp"
53 #include "runtime/interfaceSupport.hpp"
54 #include "runtime/javaCalls.hpp"
55 #include "runtime/os.hpp"
56 #include "runtime/sweeper.hpp"
57 #include "runtime/thread.hpp"
58 #include "runtime/vm_version.hpp"
59 #include "utilities/align.hpp"
60 #include "utilities/debug.hpp"
61 #include "utilities/exceptions.hpp"
62 #include "utilities/macros.hpp"
63 #if INCLUDE_ALL_GCS
64 #include "gc/g1/concurrentMarkThread.hpp"
65 #include "gc/g1/g1CollectedHeap.inline.hpp"
66 #include "gc/g1/g1ConcurrentMark.hpp"
67 #include "gc/g1/heapRegionRemSet.hpp"
68 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
69 #include "gc/parallel/adjoiningGenerations.hpp"
70 #endif // INCLUDE_ALL_GCS
71 #if INCLUDE_NMT
72 #include "services/mallocSiteTable.hpp"
1707 WB_ENTRY(jobject, WB_GetResolvedReferences(JNIEnv* env, jobject wb, jclass clazz))
1708 Klass *k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));
1709 if (k->is_instance_klass()) {
1710 InstanceKlass *ik = InstanceKlass::cast(k);
1711 ConstantPool *cp = ik->constants();
1712 objArrayOop refs = cp->resolved_references();
1713 return (jobject)JNIHandles::make_local(env, refs);
1714 } else {
1715 return NULL;
1716 }
1717 WB_END
1718
1719 WB_ENTRY(jboolean, WB_IsCDSIncludedInVmBuild(JNIEnv* env))
1720 #if INCLUDE_CDS
1721 return true;
1722 #else
1723 return false;
1724 #endif
1725 WB_END
1726
1727 WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_handle, jboolean all_threads))
1728 class TraceSelfClosure : public ThreadClosure {
1729 jint _num_threads_completed;
1730
1731 void do_thread(Thread* th) {
1732 assert(th->is_Java_thread(), "sanity");
1733 JavaThread* jt = (JavaThread*)th;
1734 ResourceMark rm;
1735
1736 jt->print_on(tty);
1737 jt->print_stack_on(tty);
1738 tty->cr();
1739 Atomic::inc(&_num_threads_completed);
1740 }
1741
1742 public:
1743 TraceSelfClosure() : _num_threads_completed(0) {}
1744
1745 jint num_threads_completed() const { return _num_threads_completed; }
1746 };
1747 TraceSelfClosure tsc;
1748
1749 if (all_threads) {
1750 Handshake::execute(&tsc);
1751 } else {
1752 oop thread_oop = JNIHandles::resolve(thread_handle);
1753 if (thread_oop != NULL) {
1754 JavaThread* target = java_lang_Thread::thread(thread_oop);
1755 Handshake::execute(&tsc, target);
1756 }
1757 }
1758 return tsc.num_threads_completed();
1759 WB_END
1760
1761 //Some convenience methods to deal with objects from java
1762 int WhiteBox::offset_for_field(const char* field_name, oop object,
1763 Symbol* signature_symbol) {
1764 assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
1765 Thread* THREAD = Thread::current();
1766
1767 //Get the class of our object
1768 Klass* arg_klass = object->klass();
1769 //Turn it into an instance-klass
1770 InstanceKlass* ik = InstanceKlass::cast(arg_klass);
1771
1772 //Create symbols to look for in the class
1773 TempNewSymbol name_symbol = SymbolTable::lookup(field_name, (int) strlen(field_name),
1774 THREAD);
1775
1776 //To be filled in with an offset of the field we're looking for
1777 fieldDescriptor fd;
1778
1779 Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);
1780 if (res == NULL) {
2051 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Boolean;",
2052 (void*)&WB_GetMethodBooleaneOption},
2053 {CC"getMethodIntxOption",
2054 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2055 (void*)&WB_GetMethodIntxOption},
2056 {CC"getMethodUintxOption",
2057 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Long;",
2058 (void*)&WB_GetMethodUintxOption},
2059 {CC"getMethodDoubleOption",
2060 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/Double;",
2061 (void*)&WB_GetMethodDoubleOption},
2062 {CC"getMethodStringOption",
2063 CC"(Ljava/lang/reflect/Executable;Ljava/lang/String;)Ljava/lang/String;",
2064 (void*)&WB_GetMethodStringOption},
2065 {CC"isShared", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsShared },
2066 {CC"isSharedClass", CC"(Ljava/lang/Class;)Z", (void*)&WB_IsSharedClass },
2067 {CC"areSharedStringsIgnored", CC"()Z", (void*)&WB_AreSharedStringsIgnored },
2068 {CC"getResolvedReferences", CC"(Ljava/lang/Class;)Ljava/lang/Object;", (void*)&WB_GetResolvedReferences},
2069 {CC"isCDSIncludedInVmBuild", CC"()Z", (void*)&WB_IsCDSIncludedInVmBuild },
2070 {CC"clearInlineCaches0", CC"(Z)V", (void*)&WB_ClearInlineCaches },
2071 {CC"handshakeWalkStack", CC"(Ljava/lang/Thread;Z)I", (void*)&WB_HandshakeWalkStack },
2072 {CC"addCompilerDirective", CC"(Ljava/lang/String;)I",
2073 (void*)&WB_AddCompilerDirective },
2074 {CC"removeCompilerDirective", CC"(I)V", (void*)&WB_RemoveCompilerDirective },
2075 {CC"currentGC", CC"()I", (void*)&WB_CurrentGC},
2076 {CC"allSupportedGC", CC"()I", (void*)&WB_AllSupportedGC},
2077 {CC"gcSelectedByErgo", CC"()Z", (void*)&WB_GCSelectedByErgo},
2078 {CC"supportsConcurrentGCPhaseControl", CC"()Z", (void*)&WB_SupportsConcurrentGCPhaseControl},
2079 {CC"getConcurrentGCPhases", CC"()[Ljava/lang/String;",
2080 (void*)&WB_GetConcurrentGCPhases},
2081 {CC"requestConcurrentGCPhase0", CC"(Ljava/lang/String;)Z",
2082 (void*)&WB_RequestConcurrentGCPhase},
2083 {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z",
2084 (void*)&WB_CheckLibSpecifiesNoexecstack},
2085 };
2086
2087 #undef CC
2088
2089 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
2090 {
2091 if (WhiteBoxAPI) {
|