/* * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved. * * This file is part of the Lock Contention Tracing Subsystem for the HotSpot * Virtual Machine, which is developed at Christian Doppler Laboratory on * Monitoring and Evolution of Very-Large-Scale Software Systems. Please * contact us at if you need additional information * or have any questions. * * 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work. If not, see . * */ #include "evtrace/traceMetadata.hpp" TraceMetadata::TraceMetadata() { _stack_cache = new TraceStackCache(this); _last_stack_id = 0; _last_global_seq = 0; } TraceMetadata::~TraceMetadata() { delete _stack_cache; } class TraceMetadata::MarkKlassUnknownClosure: public KlassClosure { static void mark_unknown(Method *m) { m->reset_tracing_known(); } public: virtual void do_klass(Klass *k) { k->reset_tracing_known(); if (k->oop_is_instance()) { InstanceKlass::cast(k)->methods_do(mark_unknown); } } }; class TraceMetadata::ClearInvalidatedMementoStacksClosure: public ThreadClosure { virtual void do_thread(Thread *t) { assert(t != NULL, "null thread"); if (t->memento_stack_trace() != NULL && !t->memento_stack_trace()->is_valid()) { t->set_memento_stack_trace(NULL); } } }; void TraceMetadata::purge_all() { assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(), "must be done in VM thread at safepoint"); MarkKlassUnknownClosure mark_unknown; ClassLoaderDataGraph::classes_do(&mark_unknown); _stack_cache->purge_all(); } void TraceMetadata::do_maintenance() { assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(), "must be done in VM thread at safepoint"); if (_stack_cache->has_invalid_stacks()) { ClearInvalidatedMementoStacksClosure clear_invalid; Threads::threads_do(&clear_invalid); } _stack_cache->do_maintenance(); assert(!_stack_cache->has_invalid_stacks(), "sanity"); }