6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.inline.hpp"
29 #include "classfile/javaAssertions.hpp"
30 #include "classfile/javaClasses.inline.hpp"
31 #include "classfile/moduleEntry.hpp"
32 #include "classfile/modules.hpp"
33 #include "classfile/packageEntry.hpp"
34 #include "classfile/stringTable.hpp"
35 #include "classfile/systemDictionary.hpp"
36 #include "classfile/vmSymbols.hpp"
37 #include "gc/shared/barrierSet.inline.hpp"
38 #include "gc/shared/collectedHeap.inline.hpp"
39 #include "interpreter/bytecode.hpp"
40 #include "memory/oopFactory.hpp"
41 #include "memory/resourceArea.hpp"
42 #include "memory/universe.inline.hpp"
43 #include "oops/fieldStreams.hpp"
44 #include "oops/instanceKlass.hpp"
45 #include "oops/method.hpp"
46 #include "oops/objArrayKlass.hpp"
47 #include "oops/objArrayOop.inline.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "prims/jvm.h"
50 #include "prims/jvm_misc.hpp"
51 #include "prims/jvmtiExport.hpp"
52 #include "prims/jvmtiThreadState.hpp"
53 #include "prims/nativeLookup.hpp"
54 #include "prims/privilegedStack.hpp"
55 #include "prims/stackwalk.hpp"
56 #include "runtime/arguments.hpp"
57 #include "runtime/atomic.hpp"
58 #include "runtime/handles.inline.hpp"
59 #include "runtime/init.hpp"
60 #include "runtime/interfaceSupport.hpp"
61 #include "runtime/java.hpp"
62 #include "runtime/javaCalls.hpp"
63 #include "runtime/jfieldIDWorkaround.hpp"
64 #include "runtime/orderAccess.inline.hpp"
65 #include "runtime/os.inline.hpp"
66 #include "runtime/perfData.hpp"
67 #include "runtime/reflection.hpp"
68 #include "runtime/thread.inline.hpp"
69 #include "runtime/vframe.hpp"
198 log_debug(class, resolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace);
199 } else {
200 log_debug(class, resolve)("%s %s (%s)", from, to, trace);
201 }
202 }
203 }
204 }
205
206 void trace_class_resolution(Klass* to_class) {
207 EXCEPTION_MARK;
208 trace_class_resolution_impl(to_class, THREAD);
209 if (HAS_PENDING_EXCEPTION) {
210 CLEAR_PENDING_EXCEPTION;
211 }
212 }
213
214 // Wrapper to trace JVM functions
215
216 #ifdef ASSERT
217 Histogram* JVMHistogram;
218 volatile jint JVMHistogram_lock = 0;
219
220 class JVMHistogramElement : public HistogramElement {
221 public:
222 JVMHistogramElement(const char* name);
223 };
224
225 JVMHistogramElement::JVMHistogramElement(const char* elementName) {
226 _name = elementName;
227 uintx count = 0;
228
229 while (Atomic::cmpxchg(1, &JVMHistogram_lock, 0) != 0) {
230 while (OrderAccess::load_acquire(&JVMHistogram_lock) != 0) {
231 count +=1;
232 if ( (WarnOnStalledSpinLock > 0)
233 && (count % WarnOnStalledSpinLock == 0)) {
234 warning("JVMHistogram_lock seems to be stalled");
235 }
236 }
237 }
238
3749 sym = ik->constants()->symbol_at(
3750 extract_high_short_from_int(
3751 ik->constants()->name_and_type_at(encl_method_method_idx)));
3752 str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
3753 dest->obj_at_put(2, str());
3754 }
3755 return (jobjectArray) JNIHandles::make_local(dest());
3756 }
3757 JVM_END
3758
3759 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size))
3760 {
3761 memset(info, 0, info_size);
3762
3763 info->jvm_version = Abstract_VM_Version::jvm_version();
3764 info->patch_version = Abstract_VM_Version::vm_patch_version();
3765
3766 // when we add a new capability in the jvm_version_info struct, we should also
3767 // consider to expose this new capability in the sun.rt.jvmCapabilities jvmstat
3768 // counter defined in runtimeService.cpp.
3769 info->is_attachable = AttachListener::is_attach_supported();
3770 }
3771 JVM_END
3772
3773 // Returns an array of java.lang.String objects containing the input arguments to the VM.
3774 JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))
3775 ResourceMark rm(THREAD);
3776
3777 if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) {
3778 return NULL;
3779 }
3780
3781 char** vm_flags = Arguments::jvm_flags_array();
3782 char** vm_args = Arguments::jvm_args_array();
3783 int num_flags = Arguments::num_jvm_flags();
3784 int num_args = Arguments::num_jvm_args();
3785
3786 InstanceKlass* ik = SystemDictionary::String_klass();
3787 objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL);
3788 objArrayHandle result_h(THREAD, r);
3789
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "jvm.h"
27 #include "classfile/classFileStream.hpp"
28 #include "classfile/classLoader.hpp"
29 #include "classfile/classLoaderData.inline.hpp"
30 #include "classfile/javaAssertions.hpp"
31 #include "classfile/javaClasses.inline.hpp"
32 #include "classfile/moduleEntry.hpp"
33 #include "classfile/modules.hpp"
34 #include "classfile/packageEntry.hpp"
35 #include "classfile/stringTable.hpp"
36 #include "classfile/systemDictionary.hpp"
37 #include "classfile/vmSymbols.hpp"
38 #include "gc/shared/barrierSet.inline.hpp"
39 #include "gc/shared/collectedHeap.inline.hpp"
40 #include "interpreter/bytecode.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "memory/resourceArea.hpp"
43 #include "memory/universe.inline.hpp"
44 #include "oops/fieldStreams.hpp"
45 #include "oops/instanceKlass.hpp"
46 #include "oops/method.hpp"
47 #include "oops/objArrayKlass.hpp"
48 #include "oops/objArrayOop.inline.hpp"
49 #include "oops/oop.inline.hpp"
50 #include "prims/jvm_misc.hpp"
51 #include "prims/jvmtiExport.hpp"
52 #include "prims/jvmtiThreadState.hpp"
53 #include "prims/nativeLookup.hpp"
54 #include "prims/privilegedStack.hpp"
55 #include "prims/stackwalk.hpp"
56 #include "runtime/arguments.hpp"
57 #include "runtime/atomic.hpp"
58 #include "runtime/handles.inline.hpp"
59 #include "runtime/init.hpp"
60 #include "runtime/interfaceSupport.hpp"
61 #include "runtime/java.hpp"
62 #include "runtime/javaCalls.hpp"
63 #include "runtime/jfieldIDWorkaround.hpp"
64 #include "runtime/orderAccess.inline.hpp"
65 #include "runtime/os.inline.hpp"
66 #include "runtime/perfData.hpp"
67 #include "runtime/reflection.hpp"
68 #include "runtime/thread.inline.hpp"
69 #include "runtime/vframe.hpp"
198 log_debug(class, resolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace);
199 } else {
200 log_debug(class, resolve)("%s %s (%s)", from, to, trace);
201 }
202 }
203 }
204 }
205
206 void trace_class_resolution(Klass* to_class) {
207 EXCEPTION_MARK;
208 trace_class_resolution_impl(to_class, THREAD);
209 if (HAS_PENDING_EXCEPTION) {
210 CLEAR_PENDING_EXCEPTION;
211 }
212 }
213
214 // Wrapper to trace JVM functions
215
216 #ifdef ASSERT
217 Histogram* JVMHistogram;
218 volatile int JVMHistogram_lock = 0;
219
220 class JVMHistogramElement : public HistogramElement {
221 public:
222 JVMHistogramElement(const char* name);
223 };
224
225 JVMHistogramElement::JVMHistogramElement(const char* elementName) {
226 _name = elementName;
227 uintx count = 0;
228
229 while (Atomic::cmpxchg(1, &JVMHistogram_lock, 0) != 0) {
230 while (OrderAccess::load_acquire(&JVMHistogram_lock) != 0) {
231 count +=1;
232 if ( (WarnOnStalledSpinLock > 0)
233 && (count % WarnOnStalledSpinLock == 0)) {
234 warning("JVMHistogram_lock seems to be stalled");
235 }
236 }
237 }
238
3749 sym = ik->constants()->symbol_at(
3750 extract_high_short_from_int(
3751 ik->constants()->name_and_type_at(encl_method_method_idx)));
3752 str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
3753 dest->obj_at_put(2, str());
3754 }
3755 return (jobjectArray) JNIHandles::make_local(dest());
3756 }
3757 JVM_END
3758
3759 JVM_ENTRY(void, JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size))
3760 {
3761 memset(info, 0, info_size);
3762
3763 info->jvm_version = Abstract_VM_Version::jvm_version();
3764 info->patch_version = Abstract_VM_Version::vm_patch_version();
3765
3766 // when we add a new capability in the jvm_version_info struct, we should also
3767 // consider to expose this new capability in the sun.rt.jvmCapabilities jvmstat
3768 // counter defined in runtimeService.cpp.
3769 info->is_attach_supported = AttachListener::is_attach_supported();
3770 }
3771 JVM_END
3772
3773 // Returns an array of java.lang.String objects containing the input arguments to the VM.
3774 JVM_ENTRY(jobjectArray, JVM_GetVmArguments(JNIEnv *env))
3775 ResourceMark rm(THREAD);
3776
3777 if (Arguments::num_jvm_args() == 0 && Arguments::num_jvm_flags() == 0) {
3778 return NULL;
3779 }
3780
3781 char** vm_flags = Arguments::jvm_flags_array();
3782 char** vm_args = Arguments::jvm_args_array();
3783 int num_flags = Arguments::num_jvm_flags();
3784 int num_args = Arguments::num_jvm_args();
3785
3786 InstanceKlass* ik = SystemDictionary::String_klass();
3787 objArrayOop r = oopFactory::new_objArray(ik, num_args + num_flags, CHECK_NULL);
3788 objArrayHandle result_h(THREAD, r);
3789
|