< prev index next >

src/share/vm/gc/parallel/gcTaskThread.cpp

Print this page
rev 12781 : imported patch 8177963-gctasktimestampentries
rev 12782 : [mq]: 8177963-gctasktimestampentries-reviews

*** 1,7 **** /* ! * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 52,84 **** if (_time_stamps != NULL) { FREE_C_HEAP_ARRAY(GCTaskTimeStamp, _time_stamps); } } GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) { ! guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries"); if (_time_stamps == NULL) { // We allocate the _time_stamps array lazily since logging can be enabled dynamically GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC); void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL); if (old != NULL) { // Someone already setup the time stamps FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps); } } - return &(_time_stamps[index]); } void GCTaskThread::print_task_time_stamps() { assert(log_is_enabled(Debug, gc, task, time), "Sanity"); // Since _time_stamps is now lazily allocated we need to check that it // has in fact been allocated when calling this function. if (_time_stamps != NULL) { ! log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index); ! for(uint i=0; i<_time_stamp_index; i++) { GCTaskTimeStamp* time_stamp = time_stamp_at(i); log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]", time_stamp->name(), time_stamp->entry_time(), time_stamp->exit_time()); --- 52,104 ---- if (_time_stamps != NULL) { FREE_C_HEAP_ARRAY(GCTaskTimeStamp, _time_stamps); } } + void GCTaskThread::add_task_timestamp(const char* name, jlong t_entry, jlong t_exit) { + if (_time_stamp_index < GCTaskTimeStampEntries) { + GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index); + time_stamp->set_name(name); + time_stamp->set_entry_time(t_entry); + time_stamp->set_exit_time(t_exit); + } else { + if (_time_stamp_index == GCTaskTimeStampEntries) { + log_warning(gc, task, time)("GC-thread %u: Too many timestamps, ignoring future ones. " + "Increase GCTaskTimeStampEntries to get more info.", + id()); + } + // Let _time_stamp_index keep counting to give the user an idea about how many + // are needed. + } + _time_stamp_index++; + } + GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) { ! assert(index < GCTaskTimeStampEntries, "Precondition"); if (_time_stamps == NULL) { // We allocate the _time_stamps array lazily since logging can be enabled dynamically GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC); void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL); if (old != NULL) { // Someone already setup the time stamps FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps); } } return &(_time_stamps[index]); } void GCTaskThread::print_task_time_stamps() { assert(log_is_enabled(Debug, gc, task, time), "Sanity"); // Since _time_stamps is now lazily allocated we need to check that it // has in fact been allocated when calling this function. if (_time_stamps != NULL) { ! log_debug(gc, task, time)("GC-Thread %u entries: %d%s", id(), ! _time_stamp_index, ! _time_stamp_index >= GCTaskTimeStampEntries ? " (overflow)" : ""); ! const uint max_index = MIN2(_time_stamp_index, GCTaskTimeStampEntries); ! for (uint i = 0; i < max_index; i++) { GCTaskTimeStamp* time_stamp = time_stamp_at(i); log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]", time_stamp->name(), time_stamp->entry_time(), time_stamp->exit_time());
*** 142,161 **** if (!is_idle_task) { manager()->note_completion(which()); if (log_is_enabled(Debug, gc, task, time)) { timer.update(); ! ! GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index); ! ! time_stamp->set_name(name); ! time_stamp->set_entry_time(entry_time); ! time_stamp->set_exit_time(timer.ticks()); ! ! // Update the index after we have set up the entry correctly since ! // GCTaskThread::print_task_time_stamps() may read this value concurrently. ! _time_stamp_index++; } } else { // idle tasks complete outside the normal accounting // so that a task can complete without waiting for idle tasks. // They have to be terminated separately. --- 162,172 ---- if (!is_idle_task) { manager()->note_completion(which()); if (log_is_enabled(Debug, gc, task, time)) { timer.update(); ! add_task_timestamp(name, entry_time, timer.ticks()); } } else { // idle tasks complete outside the normal accounting // so that a task can complete without waiting for idle tasks. // They have to be terminated separately.
< prev index next >