src/share/vm/jfr/writers/jfrEventWriterHost.inline.hpp

Tue, 16 Jun 2020 11:03:04 +0800

author
bulasevich
date
Tue, 16 Jun 2020 11:03:04 +0800
changeset 9947
db357034b763
parent 9858
b985cbb00e68
permissions
-rw-r--r--

8217647: JFR: recordings on 32-bit systems unreadable
Reviewed-by: egahlin
Contributed-by: boris.ulasevich@bell-sw.com, markus.gronlund@oracle.com

     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_JFR_WRITERS_JFREVENTWRITERHOST_INLINE_HPP
    26 #define SHARE_VM_JFR_WRITERS_JFREVENTWRITERHOST_INLINE_HPP
    28 #include "jfr/writers/jfrEventWriterHost.hpp"
    30 template <typename BE, typename IE, typename WriterPolicyImpl>
    31 template <typename StorageType>
    32 inline EventWriterHost<BE, IE, WriterPolicyImpl>::
    33 EventWriterHost(StorageType* storage, Thread* thread) : WriterHost<BE, IE, WriterPolicyImpl>(storage, thread) {}
    35 template <typename BE, typename IE, typename WriterPolicyImpl>
    36 inline EventWriterHost<BE, IE, WriterPolicyImpl>::EventWriterHost(Thread* thread) : WriterHost<BE, IE, WriterPolicyImpl>(thread) {
    37 }
    39 template <typename BE, typename IE, typename WriterPolicyImpl>
    40 inline void EventWriterHost<BE, IE, WriterPolicyImpl>::begin_write() {
    41   assert(this->is_valid(), "invariant");
    42   assert(!this->is_acquired(), "calling begin with writer already in acquired state!");
    43   this->acquire();
    44   assert(this->used_offset() == 0, "invariant");
    45   assert(this->is_acquired(), "invariant");
    46 }
    48 template <typename BE, typename IE, typename WriterPolicyImpl>
    49 inline intptr_t EventWriterHost<BE, IE, WriterPolicyImpl>::end_write(void) {
    50   assert(this->is_acquired(),
    51     "state corruption, calling end with writer with non-acquired state!");
    52   return this->is_valid() ? (intptr_t)this->used_offset() : 0;
    53 }
    55 template <typename BE, typename IE, typename WriterPolicyImpl>
    56 inline void EventWriterHost<BE, IE, WriterPolicyImpl>::begin_event_write() {
    57   assert(this->is_valid(), "invariant");
    58   assert(!this->is_acquired(), "calling begin with writer already in acquired state!");
    59   this->begin_write();
    60   this->reserve(sizeof(u4)); // reserve the event size slot
    61 }
    63 template <typename BE, typename IE, typename WriterPolicyImpl>
    64 inline intptr_t EventWriterHost<BE, IE, WriterPolicyImpl>::end_event_write() {
    65   assert(this->is_acquired(), "invariant");
    66   if (!this->is_valid()) {
    67     this->release();
    68     return 0;
    69   }
    70   const u4 written = (u4)end_write();
    71   if (written > sizeof(u4)) { // larger than header reserve
    72     this->write_padded_at_offset(written, 0);
    73     this->commit();
    74   }
    75   this->release();
    76   assert(!this->is_acquired(), "invariant");
    77   return written;
    78 }
    80 template <typename BE, typename IE, typename WriterPolicyImpl>
    81 template <typename StorageType>
    82 inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::
    83 StackEventWriterHost(StorageType* storage, Thread* thread) : EventWriterHost<BE, IE, WriterPolicyImpl>(storage, thread) {
    84   this->begin_event_write();
    85 }
    87 template <typename BE, typename IE, typename WriterPolicyImpl>
    88 inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::StackEventWriterHost(Thread* thread) : EventWriterHost<BE, IE, WriterPolicyImpl>(thread) {
    89   this->begin_event_write();
    90 }
    92 template <typename BE, typename IE, typename WriterPolicyImpl>
    93 inline StackEventWriterHost<BE, IE, WriterPolicyImpl>::~StackEventWriterHost() {
    94   this->end_event_write();
    95 }
    97 #endif // SHARE_VM_JFR_WRITERS_JFREVENTWRITERHOST_INLINE_HPP

mercurial