1 /* |
1 /* |
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
501 ts = ts->next(); |
501 ts = ts->next(); |
502 delete p; |
502 delete p; |
503 } |
503 } |
504 } |
504 } |
505 |
505 |
506 |
506 ThreadSnapshot* ThreadDumpResult::add_thread_snapshot() { |
507 void ThreadDumpResult::add_thread_snapshot(ThreadSnapshot* ts) { |
507 ThreadSnapshot* ts = new ThreadSnapshot(); |
|
508 link_thread_snapshot(ts); |
|
509 return ts; |
|
510 } |
|
511 |
|
512 ThreadSnapshot* ThreadDumpResult::add_thread_snapshot(JavaThread* thread) { |
|
513 // Note: it is very important that the ThreadSnapshot* gets linked before |
|
514 // ThreadSnapshot::initialize gets called. This is to ensure that |
|
515 // ThreadSnapshot::oops_do can get called prior to the field |
|
516 // ThreadSnapshot::_threadObj being assigned a value (to prevent a dangling |
|
517 // oop). |
|
518 ThreadSnapshot* ts = new ThreadSnapshot(); |
|
519 link_thread_snapshot(ts); |
|
520 ts->initialize(t_list(), thread); |
|
521 return ts; |
|
522 } |
|
523 |
|
524 void ThreadDumpResult::link_thread_snapshot(ThreadSnapshot* ts) { |
508 assert(_num_threads == 0 || _num_snapshots < _num_threads, |
525 assert(_num_threads == 0 || _num_snapshots < _num_threads, |
509 "_num_snapshots must be less than _num_threads"); |
526 "_num_snapshots must be less than _num_threads"); |
510 _num_snapshots++; |
527 _num_snapshots++; |
511 if (_snapshots == NULL) { |
528 if (_snapshots == NULL) { |
512 _snapshots = ts; |
529 _snapshots = ts; |
829 _count_pending_reset = false; |
846 _count_pending_reset = false; |
830 _timer_pending_reset = false; |
847 _timer_pending_reset = false; |
831 memset((void*) _perf_recursion_counts, 0, sizeof(_perf_recursion_counts)); |
848 memset((void*) _perf_recursion_counts, 0, sizeof(_perf_recursion_counts)); |
832 } |
849 } |
833 |
850 |
834 ThreadSnapshot::ThreadSnapshot(ThreadsList * t_list, JavaThread* thread) { |
851 void ThreadSnapshot::initialize(ThreadsList * t_list, JavaThread* thread) { |
835 _thread = thread; |
852 _thread = thread; |
836 _threadObj = thread->threadObj(); |
853 _threadObj = thread->threadObj(); |
837 _stack_trace = NULL; |
|
838 _concurrent_locks = NULL; |
|
839 _next = NULL; |
|
840 |
854 |
841 ThreadStatistics* stat = thread->get_thread_stat(); |
855 ThreadStatistics* stat = thread->get_thread_stat(); |
842 _contended_enter_ticks = stat->contended_enter_ticks(); |
856 _contended_enter_ticks = stat->contended_enter_ticks(); |
843 _contended_enter_count = stat->contended_enter_count(); |
857 _contended_enter_count = stat->contended_enter_count(); |
844 _monitor_wait_ticks = stat->monitor_wait_ticks(); |
858 _monitor_wait_ticks = stat->monitor_wait_ticks(); |
845 _monitor_wait_count = stat->monitor_wait_count(); |
859 _monitor_wait_count = stat->monitor_wait_count(); |
846 _sleep_ticks = stat->sleep_ticks(); |
860 _sleep_ticks = stat->sleep_ticks(); |
847 _sleep_count = stat->sleep_count(); |
861 _sleep_count = stat->sleep_count(); |
848 |
|
849 _blocker_object = NULL; |
|
850 _blocker_object_owner = NULL; |
|
851 |
862 |
852 _thread_status = java_lang_Thread::get_thread_status(_threadObj); |
863 _thread_status = java_lang_Thread::get_thread_status(_threadObj); |
853 _is_ext_suspended = thread->is_being_ext_suspended(); |
864 _is_ext_suspended = thread->is_being_ext_suspended(); |
854 _is_in_native = (thread->thread_state() == _thread_in_native); |
865 _is_in_native = (thread->thread_state() == _thread_in_native); |
855 |
866 |