39 #include "gc/shared/workgroup.hpp"
40 #include "interpreter/interpreter.hpp"
41 #include "interpreter/linkResolver.hpp"
42 #include "interpreter/oopMapCache.hpp"
43 #include "jfr/jfrEvents.hpp"
44 #include "jvmtifiles/jvmtiEnv.hpp"
45 #include "logging/log.hpp"
46 #include "logging/logConfiguration.hpp"
47 #include "logging/logStream.hpp"
48 #include "memory/allocation.inline.hpp"
49 #include "memory/metaspaceShared.hpp"
50 #include "memory/oopFactory.hpp"
51 #include "memory/resourceArea.hpp"
52 #include "memory/universe.hpp"
53 #include "oops/access.inline.hpp"
54 #include "oops/instanceKlass.hpp"
55 #include "oops/objArrayOop.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "oops/symbol.hpp"
58 #include "oops/typeArrayOop.inline.hpp"
59 #include "oops/verifyOopClosure.hpp"
60 #include "prims/jvm_misc.hpp"
61 #include "prims/jvmtiExport.hpp"
62 #include "prims/jvmtiThreadState.hpp"
63 #include "runtime/arguments.hpp"
64 #include "runtime/atomic.hpp"
65 #include "runtime/biasedLocking.hpp"
66 #include "runtime/fieldDescriptor.inline.hpp"
67 #include "runtime/flags/jvmFlagConstraintList.hpp"
68 #include "runtime/flags/jvmFlagRangeList.hpp"
69 #include "runtime/flags/jvmFlagWriteableList.hpp"
70 #include "runtime/deoptimization.hpp"
71 #include "runtime/frame.inline.hpp"
72 #include "runtime/handles.inline.hpp"
73 #include "runtime/handshake.hpp"
74 #include "runtime/init.hpp"
75 #include "runtime/interfaceSupport.inline.hpp"
76 #include "runtime/java.hpp"
77 #include "runtime/javaCalls.hpp"
78 #include "runtime/jniHandles.inline.hpp"
1580 }
1581 }
1582 }
1583 }
1584
1585 #endif // INCLUDE_JVMCI
1586
1587 // A JavaThread is a normal Java thread
1588
1589 void JavaThread::initialize() {
1590 // Initialize fields
1591
1592 set_saved_exception_pc(NULL);
1593 set_threadObj(NULL);
1594 _anchor.clear();
1595 set_entry_point(NULL);
1596 set_jni_functions(jni_functions());
1597 set_callee_target(NULL);
1598 set_vm_result(NULL);
1599 set_vm_result_2(NULL);
1600 set_vframe_array_head(NULL);
1601 set_vframe_array_last(NULL);
1602 set_deferred_locals(NULL);
1603 set_deopt_mark(NULL);
1604 set_deopt_compiled_method(NULL);
1605 clear_must_deopt_id();
1606 set_monitor_chunks(NULL);
1607 set_next(NULL);
1608 _on_thread_list = false;
1609 set_thread_state(_thread_new);
1610 _terminated = _not_terminated;
1611 _array_for_gc = NULL;
1612 _suspend_equivalent = false;
1613 _in_deopt_handler = 0;
1614 _doing_unsafe_access = false;
1615 _stack_guard_state = stack_guard_unused;
1616 #if INCLUDE_JVMCI
1617 _pending_monitorenter = false;
1618 _pending_deoptimization = -1;
1619 _pending_failed_speculation = 0;
2760 guarantee(base < os::current_stack_pointer(), "Error calculating stack red zone");
2761
2762 if (!os::guard_memory((char *) base, stack_red_zone_size())) {
2763 warning("Attempt to guard stack red zone failed.");
2764 }
2765 }
2766
2767 void JavaThread::disable_stack_red_zone() {
2768 // The base notation is from the stacks point of view, growing downward.
2769 // We need to adjust it to work correctly with guard_memory()
2770 assert(_stack_guard_state != stack_guard_unused, "must be using guard pages.");
2771 address base = stack_red_zone_base() - stack_red_zone_size();
2772 if (!os::unguard_memory((char *)base, stack_red_zone_size())) {
2773 warning("Attempt to unguard stack red zone failed.");
2774 }
2775 }
2776
2777 void JavaThread::frames_do(void f(frame*, const RegisterMap* map)) {
2778 // ignore is there is no stack
2779 if (!has_last_Java_frame()) return;
2780 // traverse the stack frames. Starts from top frame.
2781 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2782 frame* fr = fst.current();
2783 f(fr, fst.register_map());
2784 }
2785 }
2786
2787
2788 #ifndef PRODUCT
2789 // Deoptimization
2790 // Function for testing deoptimization
2791 void JavaThread::deoptimize() {
2792 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2793 StackFrameStream fst(this, UseBiasedLocking);
2794 bool deopt = false; // Dump stack only if a deopt actually happens.
2795 bool only_at = strlen(DeoptimizeOnlyAt) > 0;
2796 // Iterate over all frames in the thread and deoptimize
2797 for (; !fst.is_done(); fst.next()) {
2798 if (fst.current()->can_be_deoptimized()) {
2799
|
39 #include "gc/shared/workgroup.hpp"
40 #include "interpreter/interpreter.hpp"
41 #include "interpreter/linkResolver.hpp"
42 #include "interpreter/oopMapCache.hpp"
43 #include "jfr/jfrEvents.hpp"
44 #include "jvmtifiles/jvmtiEnv.hpp"
45 #include "logging/log.hpp"
46 #include "logging/logConfiguration.hpp"
47 #include "logging/logStream.hpp"
48 #include "memory/allocation.inline.hpp"
49 #include "memory/metaspaceShared.hpp"
50 #include "memory/oopFactory.hpp"
51 #include "memory/resourceArea.hpp"
52 #include "memory/universe.hpp"
53 #include "oops/access.inline.hpp"
54 #include "oops/instanceKlass.hpp"
55 #include "oops/objArrayOop.hpp"
56 #include "oops/oop.inline.hpp"
57 #include "oops/symbol.hpp"
58 #include "oops/typeArrayOop.inline.hpp"
59 #include "oops/valueKlass.hpp"
60 #include "oops/verifyOopClosure.hpp"
61 #include "prims/jvm_misc.hpp"
62 #include "prims/jvmtiExport.hpp"
63 #include "prims/jvmtiThreadState.hpp"
64 #include "runtime/arguments.hpp"
65 #include "runtime/atomic.hpp"
66 #include "runtime/biasedLocking.hpp"
67 #include "runtime/fieldDescriptor.inline.hpp"
68 #include "runtime/flags/jvmFlagConstraintList.hpp"
69 #include "runtime/flags/jvmFlagRangeList.hpp"
70 #include "runtime/flags/jvmFlagWriteableList.hpp"
71 #include "runtime/deoptimization.hpp"
72 #include "runtime/frame.inline.hpp"
73 #include "runtime/handles.inline.hpp"
74 #include "runtime/handshake.hpp"
75 #include "runtime/init.hpp"
76 #include "runtime/interfaceSupport.inline.hpp"
77 #include "runtime/java.hpp"
78 #include "runtime/javaCalls.hpp"
79 #include "runtime/jniHandles.inline.hpp"
1581 }
1582 }
1583 }
1584 }
1585
1586 #endif // INCLUDE_JVMCI
1587
1588 // A JavaThread is a normal Java thread
1589
1590 void JavaThread::initialize() {
1591 // Initialize fields
1592
1593 set_saved_exception_pc(NULL);
1594 set_threadObj(NULL);
1595 _anchor.clear();
1596 set_entry_point(NULL);
1597 set_jni_functions(jni_functions());
1598 set_callee_target(NULL);
1599 set_vm_result(NULL);
1600 set_vm_result_2(NULL);
1601 set_return_buffered_value(NULL);
1602 set_vframe_array_head(NULL);
1603 set_vframe_array_last(NULL);
1604 set_deferred_locals(NULL);
1605 set_deopt_mark(NULL);
1606 set_deopt_compiled_method(NULL);
1607 clear_must_deopt_id();
1608 set_monitor_chunks(NULL);
1609 set_next(NULL);
1610 _on_thread_list = false;
1611 set_thread_state(_thread_new);
1612 _terminated = _not_terminated;
1613 _array_for_gc = NULL;
1614 _suspend_equivalent = false;
1615 _in_deopt_handler = 0;
1616 _doing_unsafe_access = false;
1617 _stack_guard_state = stack_guard_unused;
1618 #if INCLUDE_JVMCI
1619 _pending_monitorenter = false;
1620 _pending_deoptimization = -1;
1621 _pending_failed_speculation = 0;
2762 guarantee(base < os::current_stack_pointer(), "Error calculating stack red zone");
2763
2764 if (!os::guard_memory((char *) base, stack_red_zone_size())) {
2765 warning("Attempt to guard stack red zone failed.");
2766 }
2767 }
2768
2769 void JavaThread::disable_stack_red_zone() {
2770 // The base notation is from the stacks point of view, growing downward.
2771 // We need to adjust it to work correctly with guard_memory()
2772 assert(_stack_guard_state != stack_guard_unused, "must be using guard pages.");
2773 address base = stack_red_zone_base() - stack_red_zone_size();
2774 if (!os::unguard_memory((char *)base, stack_red_zone_size())) {
2775 warning("Attempt to unguard stack red zone failed.");
2776 }
2777 }
2778
2779 void JavaThread::frames_do(void f(frame*, const RegisterMap* map)) {
2780 // ignore is there is no stack
2781 if (!has_last_Java_frame()) return;
2782 // Because this method is used to verify oops, it must support
2783 // oops in buffered values
2784
2785 // traverse the stack frames. Starts from top frame.
2786 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
2787 frame* fr = fst.current();
2788 f(fr, fst.register_map());
2789 }
2790 }
2791
2792
2793 #ifndef PRODUCT
2794 // Deoptimization
2795 // Function for testing deoptimization
2796 void JavaThread::deoptimize() {
2797 // BiasedLocking needs an updated RegisterMap for the revoke monitors pass
2798 StackFrameStream fst(this, UseBiasedLocking);
2799 bool deopt = false; // Dump stack only if a deopt actually happens.
2800 bool only_at = strlen(DeoptimizeOnlyAt) > 0;
2801 // Iterate over all frames in the thread and deoptimize
2802 for (; !fst.is_done(); fst.next()) {
2803 if (fst.current()->can_be_deoptimized()) {
2804
|