Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/jfr/writers/jfrEventWriterHost.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_JFREVENTWRITERHOST_INLINE_HPP25#define SHARE_VM_JFR_WRITERS_JFREVENTWRITERHOST_INLINE_HPP2627#include "jfr/writers/jfrEventWriterHost.hpp"2829template <typename BE, typename IE, typename WriterPolicyImpl>30template <typename StorageType>31inline EventWriterHost<BE, IE, WriterPolicyImpl>::32EventWriterHost(StorageType* storage, Thread* thread) : WriterHost<BE, IE, WriterPolicyImpl>(storage, thread) {}3334template <typename BE, typename IE, typename WriterPolicyImpl>35inline EventWriterHost<BE, IE, WriterPolicyImpl>::EventWriterHost(Thread* thread) : WriterHost<BE, IE, WriterPolicyImpl>(thread) {36}3738template <typename BE, typename IE, typename WriterPolicyImpl>39inline void EventWriterHost<BE, IE, WriterPolicyImpl>::begin_write() {40assert(this->is_valid(), "invariant");41assert(!this->is_acquired(), "calling begin with writer already in acquired state!");42this->acquire();43assert(this->used_offset() == 0, "invariant");44assert(this->is_acquired(), "invariant");45}4647template <typename BE, typename IE, typename WriterPolicyImpl>48inline intptr_t EventWriterHost<BE, IE, WriterPolicyImpl>::end_write(void) {49assert(this->is_acquired(),50"state corruption, calling end with writer with non-acquired state!");51return this->is_valid() ? (intptr_t)this->used_offset() : 0;52}5354template <typename BE, typename IE, typename WriterPolicyImpl>55inline void EventWriterHost<BE, IE, WriterPolicyImpl>::begin_event_write() {56assert(this->is_valid(), "invariant");57assert(!this->is_acquired(), "calling begin with writer already in acquired state!");58this->begin_write();59this->reserve(sizeof(u4)); // reserve the event size slot60}6162template <typename BE, typename IE, typename WriterPolicyImpl>63inline intptr_t EventWriterHost<BE, IE, WriterPolicyImpl>::end_event_write() {64assert(this->is_acquired(), "invariant");65if (!this->is_valid()) {66this->release();67return 0;68}69const u4 written = (u4)end_write();70if (written > sizeof(u4)) { // larger than header reserve71this->write_padded_at_offset(written, 0);72this->commit();73}74this->release();75assert(!this->is_acquired(), "invariant");76return written;77}7879template <typename BE, typename IE, typename WriterPolicyImpl>80template <typename StorageType>81inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::82StackEventWriterHost(StorageType* storage, Thread* thread) : EventWriterHost<BE, IE, WriterPolicyImpl>(storage, thread) {83this->begin_event_write();84}8586template <typename BE, typename IE, typename WriterPolicyImpl>87inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::StackEventWriterHost(Thread* thread) : EventWriterHost<BE, IE, WriterPolicyImpl>(thread) {88this->begin_event_write();89}9091template <typename BE, typename IE, typename WriterPolicyImpl>92inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::~StackEventWriterHost() {93this->end_event_write();94}9596#endif // SHARE_VM_JFR_WRITERS_JFREVENTWRITERHOST_INLINE_HPP979899