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 "interpreter/interpreter.hpp"
27 #include "jvmtifiles/jvmtiEnv.hpp"
28 #include "logging/log.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "prims/jvmtiEventController.hpp"
31 #include "prims/jvmtiEventController.inline.hpp"
32 #include "prims/jvmtiExport.hpp"
33 #include "prims/jvmtiImpl.hpp"
34 #include "prims/jvmtiThreadState.inline.hpp"
35 #include "runtime/frame.hpp"
36 #include "runtime/thread.hpp"
37 #include "runtime/vframe.hpp"
38 #include "runtime/vframe_hp.hpp"
39 #include "runtime/vmThread.hpp"
40 #include "runtime/vm_operations.hpp"
41
42 #ifdef JVMTI_TRACE
43 #define EC_TRACE(out) do { \
44 if (JvmtiTrace::trace_event_controller()) { \
45 SafeResourceMark rm; \
46 log_trace(jvmti) out; \
47 } \
48 } while (0)
49 #else
50 #define EC_TRACE(out)
51 #endif /*JVMTI_TRACE */
52
53 // bits for standard events
54
55 static const jlong SINGLE_STEP_BIT = (((jlong)1) << (JVMTI_EVENT_SINGLE_STEP - TOTAL_MIN_EVENT_TYPE_VAL));
56 static const jlong FRAME_POP_BIT = (((jlong)1) << (JVMTI_EVENT_FRAME_POP - TOTAL_MIN_EVENT_TYPE_VAL));
563 assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
564
565 // event enabled for any thread in any environment
566 julong was_any_env_thread_enabled = JvmtiEventController::_universal_global_event_enabled.get_bits();
567 julong any_env_thread_enabled = 0;
568
569 EC_TRACE(("[-] # recompute enabled - before " JULONG_FORMAT_X, was_any_env_thread_enabled));
570
571 // compute non-thread-filters events.
572 // This must be done separately from thread-filtered events, since some
573 // events can occur before any threads exist.
574 JvmtiEnvIterator it;
575 for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) {
576 any_env_thread_enabled |= recompute_env_enabled(env);
577 }
578
579 // We need to create any missing jvmti_thread_state if there are globally set thread
580 // filtered events and there weren't last time
581 if ( (any_env_thread_enabled & THREAD_FILTERED_EVENT_BITS) != 0 &&
582 (was_any_env_thread_enabled & THREAD_FILTERED_EVENT_BITS) == 0) {
583 {
584 MutexLocker mu(Threads_lock); //hold the Threads_lock for the iteration
585 for (JavaThread *tp = Threads::first(); tp != NULL; tp = tp->next()) {
586 // state_for_while_locked() makes tp->is_exiting() check
587 JvmtiThreadState::state_for_while_locked(tp); // create the thread state if missing
588 }
589 }// release Threads_lock
590 }
591
592 // compute and set thread-filtered events
593 for (JvmtiThreadState *state = JvmtiThreadState::first(); state != NULL; state = state->next()) {
594 any_env_thread_enabled |= recompute_thread_enabled(state);
595 }
596
597 // set universal state (across all envs and threads)
598 jlong delta = any_env_thread_enabled ^ was_any_env_thread_enabled;
599 if (delta != 0) {
600 JvmtiExport::set_should_post_field_access((any_env_thread_enabled & FIELD_ACCESS_BIT) != 0);
601 JvmtiExport::set_should_post_field_modification((any_env_thread_enabled & FIELD_MODIFICATION_BIT) != 0);
602 JvmtiExport::set_should_post_class_load((any_env_thread_enabled & CLASS_LOAD_BIT) != 0);
603 JvmtiExport::set_should_post_class_file_load_hook((any_env_thread_enabled & CLASS_FILE_LOAD_HOOK_BIT) != 0);
604 JvmtiExport::set_should_post_native_method_bind((any_env_thread_enabled & NATIVE_METHOD_BIND_BIT) != 0);
605 JvmtiExport::set_should_post_dynamic_code_generated((any_env_thread_enabled & DYNAMIC_CODE_GENERATED_BIT) != 0);
606 JvmtiExport::set_should_post_data_dump((any_env_thread_enabled & DATA_DUMP_BIT) != 0);
607 JvmtiExport::set_should_post_class_prepare((any_env_thread_enabled & CLASS_PREPARE_BIT) != 0);
608 JvmtiExport::set_should_post_class_unload((any_env_thread_enabled & CLASS_UNLOAD_BIT) != 0);
609 JvmtiExport::set_should_post_monitor_contended_enter((any_env_thread_enabled & MONITOR_CONTENDED_ENTER_BIT) != 0);
|
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 "interpreter/interpreter.hpp"
27 #include "jvmtifiles/jvmtiEnv.hpp"
28 #include "logging/log.hpp"
29 #include "memory/resourceArea.hpp"
30 #include "prims/jvmtiEventController.hpp"
31 #include "prims/jvmtiEventController.inline.hpp"
32 #include "prims/jvmtiExport.hpp"
33 #include "prims/jvmtiImpl.hpp"
34 #include "prims/jvmtiThreadState.inline.hpp"
35 #include "runtime/frame.hpp"
36 #include "runtime/thread.inline.hpp"
37 #include "runtime/threadSMR.hpp"
38 #include "runtime/vframe.hpp"
39 #include "runtime/vframe_hp.hpp"
40 #include "runtime/vmThread.hpp"
41 #include "runtime/vm_operations.hpp"
42
43 #ifdef JVMTI_TRACE
44 #define EC_TRACE(out) do { \
45 if (JvmtiTrace::trace_event_controller()) { \
46 SafeResourceMark rm; \
47 log_trace(jvmti) out; \
48 } \
49 } while (0)
50 #else
51 #define EC_TRACE(out)
52 #endif /*JVMTI_TRACE */
53
54 // bits for standard events
55
56 static const jlong SINGLE_STEP_BIT = (((jlong)1) << (JVMTI_EVENT_SINGLE_STEP - TOTAL_MIN_EVENT_TYPE_VAL));
57 static const jlong FRAME_POP_BIT = (((jlong)1) << (JVMTI_EVENT_FRAME_POP - TOTAL_MIN_EVENT_TYPE_VAL));
564 assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check");
565
566 // event enabled for any thread in any environment
567 julong was_any_env_thread_enabled = JvmtiEventController::_universal_global_event_enabled.get_bits();
568 julong any_env_thread_enabled = 0;
569
570 EC_TRACE(("[-] # recompute enabled - before " JULONG_FORMAT_X, was_any_env_thread_enabled));
571
572 // compute non-thread-filters events.
573 // This must be done separately from thread-filtered events, since some
574 // events can occur before any threads exist.
575 JvmtiEnvIterator it;
576 for (JvmtiEnvBase* env = it.first(); env != NULL; env = it.next(env)) {
577 any_env_thread_enabled |= recompute_env_enabled(env);
578 }
579
580 // We need to create any missing jvmti_thread_state if there are globally set thread
581 // filtered events and there weren't last time
582 if ( (any_env_thread_enabled & THREAD_FILTERED_EVENT_BITS) != 0 &&
583 (was_any_env_thread_enabled & THREAD_FILTERED_EVENT_BITS) == 0) {
584 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *tp = jtiwh.next(); ) {
585 // state_for_while_locked() makes tp->is_exiting() check
586 JvmtiThreadState::state_for_while_locked(tp); // create the thread state if missing
587 }
588 }
589
590 // compute and set thread-filtered events
591 for (JvmtiThreadState *state = JvmtiThreadState::first(); state != NULL; state = state->next()) {
592 any_env_thread_enabled |= recompute_thread_enabled(state);
593 }
594
595 // set universal state (across all envs and threads)
596 jlong delta = any_env_thread_enabled ^ was_any_env_thread_enabled;
597 if (delta != 0) {
598 JvmtiExport::set_should_post_field_access((any_env_thread_enabled & FIELD_ACCESS_BIT) != 0);
599 JvmtiExport::set_should_post_field_modification((any_env_thread_enabled & FIELD_MODIFICATION_BIT) != 0);
600 JvmtiExport::set_should_post_class_load((any_env_thread_enabled & CLASS_LOAD_BIT) != 0);
601 JvmtiExport::set_should_post_class_file_load_hook((any_env_thread_enabled & CLASS_FILE_LOAD_HOOK_BIT) != 0);
602 JvmtiExport::set_should_post_native_method_bind((any_env_thread_enabled & NATIVE_METHOD_BIND_BIT) != 0);
603 JvmtiExport::set_should_post_dynamic_code_generated((any_env_thread_enabled & DYNAMIC_CODE_GENERATED_BIT) != 0);
604 JvmtiExport::set_should_post_data_dump((any_env_thread_enabled & DATA_DUMP_BIT) != 0);
605 JvmtiExport::set_should_post_class_prepare((any_env_thread_enabled & CLASS_PREPARE_BIT) != 0);
606 JvmtiExport::set_should_post_class_unload((any_env_thread_enabled & CLASS_UNLOAD_BIT) != 0);
607 JvmtiExport::set_should_post_monitor_contended_enter((any_env_thread_enabled & MONITOR_CONTENDED_ENTER_BIT) != 0);
|