--- /dev/null 2016-10-25 08:46:44.038854975 +0200 +++ new/src/share/vm/evtrace/traceBuffer.inline.hpp 2016-10-25 10:40:13.401780322 +0200 @@ -0,0 +1,66 @@ +/* + * 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 . + * + */ + +#ifndef SHARE_VM_EVTRACE_TRACEBUFFER_INLINE_HPP +#define SHARE_VM_EVTRACE_TRACEBUFFER_INLINE_HPP + +#include "runtime/thread.hpp" + +inline TraceBuffer::TraceBuffer(size_t capacity) + : end(data + capacity), + queue_next(NULL) +{ + reset(); +} + +inline void TraceBuffer::reset() { + top = data; + owner = NULL; + owner_id = 0; + DEBUG_ONLY(for (uint8_t *p = data; p != end; p++) *p = 0;) +} + +inline bool TraceBuffer::reserve(size_t nbytes) { + assert(top >= data, "top before data area"); + assert(top <= end, "top after data area"); + assert(owner != NULL, "has no owner"); + assert(Thread::current() == owner, "current thread is not the owner"); + + u1 *new_top = top + nbytes; + if (new_top > end) { + return false; + } + top = new_top; + return true; +} + +inline void* TraceBuffer::operator new(size_t size, size_t capacity) throw () { + return CHeapObj::operator new(size + capacity, CALLER_PC); +} + +inline size_t TraceBuffer::filled_size() const { + return (size_t) (top - data); +} + +#endif /* SHARE_VM_EVTRACE_TRACEBUFFER_INLINE_HPP */