Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/writers/jfrMemoryWriterHost.inline.hpp
38920 views
/*1* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP25#define SHARE_VM_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP2627#include "jfr/writers/jfrMemoryWriterHost.hpp"2829template <typename Adapter, typename AP, typename AccessAssert>30inline void MemoryWriterHost<Adapter, AP, AccessAssert>::bytes(void* dest, const void* buf, size_t len) {31assert(dest != NULL, "invariant");32memcpy(dest, buf, len); // no encoding33this->set_current_pos(len);34}3536template <typename Adapter, typename AP, typename AccessAssert>37inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :38StorageHost<Adapter, AP>(storage, thread) {39}4041template <typename Adapter, typename AP, typename AccessAssert>42inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :43StorageHost<Adapter, AP>(storage, size) {44}4546template <typename Adapter, typename AP, typename AccessAssert>47inline MemoryWriterHost<Adapter, AP, AccessAssert>::MemoryWriterHost(Thread* thread) :48StorageHost<Adapter, AP>(thread) {49}5051template <typename Adapter, typename AP, typename AccessAssert>52inline void MemoryWriterHost<Adapter, AP, AccessAssert>::acquire() {53debug_only(_access.acquire();)54if (!this->is_valid()) {55this->flush();56}57debug_only(is_acquired();)58}5960template <typename Adapter, typename AP, typename AccessAssert>61inline void MemoryWriterHost<Adapter, AP, AccessAssert>::release() {62debug_only(is_acquired();)63StorageHost<Adapter, AP>::release();64debug_only(_access.release();)65}6667#ifdef ASSERT68template <typename Adapter, typename AP, typename AccessAssert>69inline bool MemoryWriterHost<Adapter, AP, AccessAssert>::is_acquired() const {70return _access.is_acquired();71}72#endif7374template <typename Adapter, typename AP>75inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, Thread* thread) :76MemoryWriterHost<Adapter, AP>(storage, thread) {77this->acquire();78}7980template <typename Adapter, typename AP>81inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(typename Adapter::StorageType* storage, size_t size) :82MemoryWriterHost<Adapter, AP>(storage, size) {83this->acquire();84}8586template <typename Adapter, typename AP>87inline AcquireReleaseMemoryWriterHost<Adapter, AP>::AcquireReleaseMemoryWriterHost(Thread* thread) :88MemoryWriterHost<Adapter, AP>(thread) {89this->acquire();90}9192template <typename Adapter, typename AP>93inline AcquireReleaseMemoryWriterHost<Adapter, AP>::~AcquireReleaseMemoryWriterHost() {94assert(this->is_acquired(), "invariant");95this->release();96}9798#endif // SHARE_VM_JFR_WRITERS_JFRMEMORYWRITERHOST_INLINE_HPP99100101