29 #include "classfile/stringTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "gc/shared/barrierSet.inline.hpp"
33 #include "gc/shared/collectedHeap.inline.hpp"
34 #include "interpreter/bytecode.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "memory/universe.inline.hpp"
37 #include "oops/fieldStreams.hpp"
38 #include "oops/instanceKlass.hpp"
39 #include "oops/method.hpp"
40 #include "oops/objArrayKlass.hpp"
41 #include "oops/objArrayOop.inline.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "prims/jvm.h"
44 #include "prims/jvm_misc.hpp"
45 #include "prims/jvmtiExport.hpp"
46 #include "prims/jvmtiThreadState.hpp"
47 #include "prims/nativeLookup.hpp"
48 #include "prims/privilegedStack.hpp"
49 #include "runtime/arguments.hpp"
50 #include "runtime/atomic.inline.hpp"
51 #include "runtime/handles.inline.hpp"
52 #include "runtime/init.hpp"
53 #include "runtime/interfaceSupport.hpp"
54 #include "runtime/java.hpp"
55 #include "runtime/javaCalls.hpp"
56 #include "runtime/jfieldIDWorkaround.hpp"
57 #include "runtime/orderAccess.inline.hpp"
58 #include "runtime/os.inline.hpp"
59 #include "runtime/perfData.hpp"
60 #include "runtime/reflection.hpp"
61 #include "runtime/thread.inline.hpp"
62 #include "runtime/vframe.hpp"
63 #include "runtime/vm_operations.hpp"
64 #include "runtime/vm_version.hpp"
65 #include "services/attachListener.hpp"
66 #include "services/management.hpp"
67 #include "services/threadService.hpp"
68 #include "trace/tracing.hpp"
530 java_lang_Throwable::fill_in_stack_trace(exception);
531 JVM_END
532
533
534 JVM_ENTRY(jint, JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable))
535 JVMWrapper("JVM_GetStackTraceDepth");
536 oop exception = JNIHandles::resolve(throwable);
537 return java_lang_Throwable::get_stack_trace_depth(exception, THREAD);
538 JVM_END
539
540
541 JVM_ENTRY(jobject, JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index))
542 JVMWrapper("JVM_GetStackTraceElement");
543 JvmtiVMObjectAllocEventCollector oam; // This ctor (throughout this module) may trigger a safepoint/GC
544 oop exception = JNIHandles::resolve(throwable);
545 oop element = java_lang_Throwable::get_stack_trace_element(exception, index, CHECK_NULL);
546 return JNIHandles::make_local(env, element);
547 JVM_END
548
549
550 // java.lang.Object ///////////////////////////////////////////////
551
552
553 JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle))
554 JVMWrapper("JVM_IHashCode");
555 // as implemented in the classic virtual machine; return 0 if object is NULL
556 return handle == NULL ? 0 : ObjectSynchronizer::FastHashCode (THREAD, JNIHandles::resolve_non_null(handle)) ;
557 JVM_END
558
559
560 JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms))
561 JVMWrapper("JVM_MonitorWait");
562 Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
563 JavaThreadInObjectWaitState jtiows(thread, ms != 0);
564 if (JvmtiExport::should_post_monitor_wait()) {
565 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms);
566
567 // The current thread already owns the monitor and it has not yet
568 // been added to the wait queue so the current thread cannot be
569 // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT
|
29 #include "classfile/stringTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "gc/shared/barrierSet.inline.hpp"
33 #include "gc/shared/collectedHeap.inline.hpp"
34 #include "interpreter/bytecode.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "memory/universe.inline.hpp"
37 #include "oops/fieldStreams.hpp"
38 #include "oops/instanceKlass.hpp"
39 #include "oops/method.hpp"
40 #include "oops/objArrayKlass.hpp"
41 #include "oops/objArrayOop.inline.hpp"
42 #include "oops/oop.inline.hpp"
43 #include "prims/jvm.h"
44 #include "prims/jvm_misc.hpp"
45 #include "prims/jvmtiExport.hpp"
46 #include "prims/jvmtiThreadState.hpp"
47 #include "prims/nativeLookup.hpp"
48 #include "prims/privilegedStack.hpp"
49 #include "prims/stackwalk.hpp"
50 #include "runtime/arguments.hpp"
51 #include "runtime/atomic.inline.hpp"
52 #include "runtime/handles.inline.hpp"
53 #include "runtime/init.hpp"
54 #include "runtime/interfaceSupport.hpp"
55 #include "runtime/java.hpp"
56 #include "runtime/javaCalls.hpp"
57 #include "runtime/jfieldIDWorkaround.hpp"
58 #include "runtime/orderAccess.inline.hpp"
59 #include "runtime/os.inline.hpp"
60 #include "runtime/perfData.hpp"
61 #include "runtime/reflection.hpp"
62 #include "runtime/thread.inline.hpp"
63 #include "runtime/vframe.hpp"
64 #include "runtime/vm_operations.hpp"
65 #include "runtime/vm_version.hpp"
66 #include "services/attachListener.hpp"
67 #include "services/management.hpp"
68 #include "services/threadService.hpp"
69 #include "trace/tracing.hpp"
531 java_lang_Throwable::fill_in_stack_trace(exception);
532 JVM_END
533
534
535 JVM_ENTRY(jint, JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable))
536 JVMWrapper("JVM_GetStackTraceDepth");
537 oop exception = JNIHandles::resolve(throwable);
538 return java_lang_Throwable::get_stack_trace_depth(exception, THREAD);
539 JVM_END
540
541
542 JVM_ENTRY(jobject, JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index))
543 JVMWrapper("JVM_GetStackTraceElement");
544 JvmtiVMObjectAllocEventCollector oam; // This ctor (throughout this module) may trigger a safepoint/GC
545 oop exception = JNIHandles::resolve(throwable);
546 oop element = java_lang_Throwable::get_stack_trace_element(exception, index, CHECK_NULL);
547 return JNIHandles::make_local(env, element);
548 JVM_END
549
550
551 // java.lang.StackWalker //////////////////////////////////////////////////////
552
553
554 JVM_ENTRY(jobject, JVM_CallStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
555 jint skip_frames, jint frame_count, jint start_index,
556 jobjectArray classes,
557 jobjectArray frames))
558 JVMWrapper("JVM_CallStackWalk");
559 JavaThread* jt = (JavaThread*) THREAD;
560 if (!jt->is_Java_thread() || !jt->has_last_Java_frame()) {
561 THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: no stack trace", NULL);
562 }
563
564 Handle stackStream_h(THREAD, JNIHandles::resolve_non_null(stackStream));
565 objArrayOop ca = objArrayOop(JNIHandles::resolve_non_null(classes));
566 objArrayHandle classes_array_h(THREAD, ca);
567
568 // frames array is null when only getting caller reference
569 objArrayOop fa = objArrayOop(JNIHandles::resolve(frames));
570 objArrayHandle frames_array_h(THREAD, fa);
571
572 int limit = start_index+frame_count;
573 if (classes_array_h->length() < limit) {
574 THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers", NULL);
575 }
576
577 Handle result = StackWalk::walk(stackStream_h, mode, skip_frames, frame_count,
578 start_index, classes_array_h,
579 frames_array_h, CHECK_NULL);
580 return JNIHandles::make_local(env, result());
581 JVM_END
582
583
584 JVM_ENTRY(jint, JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
585 jint frame_count, jint start_index,
586 jobjectArray classes,
587 jobjectArray frames))
588 JVMWrapper("JVM_MoreStackWalk");
589 JavaThread* jt = (JavaThread*) THREAD;
590 objArrayOop ca = objArrayOop(JNIHandles::resolve_non_null(classes));
591 objArrayHandle classes_array_h(THREAD, ca);
592
593 // frames array is null when only getting caller reference
594 objArrayOop fa = objArrayOop(JNIHandles::resolve(frames));
595 objArrayHandle frames_array_h(THREAD, fa);
596
597 int limit = start_index+frame_count;
598 if (classes_array_h->length() < limit) {
599 THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "not enough space in buffers");
600 }
601
602 Handle stackStream_h(THREAD, JNIHandles::resolve_non_null(stackStream));
603 return StackWalk::moreFrames(stackStream_h, mode, anchor, frame_count,
604 start_index, classes_array_h,
605 frames_array_h, THREAD);
606 JVM_END
607
608 JVM_ENTRY(void, JVM_FillStackFrames(JNIEnv *env, jclass stackStream,
609 jint start_index,
610 jobjectArray frames,
611 jint from_index, jint to_index))
612 JVMWrapper("JVM_FillStackFrames");
613 if (TraceStackWalk) {
614 tty->print("JVM_FillStackFrames() start_index=%d from_index=%d to_index=%d\n",
615 start_index, from_index, to_index);
616 }
617
618 JavaThread* jt = (JavaThread*) THREAD;
619
620 objArrayOop fa = objArrayOop(JNIHandles::resolve_non_null(frames));
621 objArrayHandle frames_array_h(THREAD, fa);
622
623 if (frames_array_h->length() < to_index) {
624 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "array length not matched");
625 }
626
627 for (int i = from_index; i < to_index; i++) {
628 Handle stackFrame(THREAD, frames_array_h->obj_at(i));
629 java_lang_StackFrameInfo::fill_methodInfo(stackFrame, CHECK);
630 }
631 JVM_END
632
633 JVM_ENTRY(void, JVM_SetMethodInfo(JNIEnv *env, jobject frame))
634 JVMWrapper("JVM_SetMethodInfo");
635 Handle stackFrame(THREAD, JNIHandles::resolve(frame));
636 java_lang_StackFrameInfo::fill_methodInfo(stackFrame, THREAD);
637 JVM_END
638
639 // java.lang.Object ///////////////////////////////////////////////
640
641
642 JVM_ENTRY(jint, JVM_IHashCode(JNIEnv* env, jobject handle))
643 JVMWrapper("JVM_IHashCode");
644 // as implemented in the classic virtual machine; return 0 if object is NULL
645 return handle == NULL ? 0 : ObjectSynchronizer::FastHashCode (THREAD, JNIHandles::resolve_non_null(handle)) ;
646 JVM_END
647
648
649 JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms))
650 JVMWrapper("JVM_MonitorWait");
651 Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
652 JavaThreadInObjectWaitState jtiows(thread, ms != 0);
653 if (JvmtiExport::should_post_monitor_wait()) {
654 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms);
655
656 // The current thread already owns the monitor and it has not yet
657 // been added to the wait queue so the current thread cannot be
658 // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT
|