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 */ 24 25 #ifndef SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP 26 #define SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP 27 28 #include "jni.h" 29 #include "utilities/globalDefinitions.hpp" 30 31 class ClassLoaderData; 32 class Klass; 33 class Method; 34 class ModuleEntry; 35 class PackageEntry; 36 class Thread; 37 38 // BE == Base Encoder 39 // IE == Integer Encoder 40 template <typename BE, typename IE, typename WriterPolicyImpl > 41 class WriterHost : public WriterPolicyImpl { 42 private: 43 const bool _compressed_integers; 44 45 template <typename T> 46 void write_padded(T value); 47 template <typename T> 48 void write_padded(const T* value, size_t len); 49 template <typename T> 50 u1* write_padded(const T* value, size_t len, u1* pos); 51 template <typename T> 52 void write(const T* value, size_t len); 53 template <typename T> 54 u1* write(const T* value, size_t len, u1* pos); 55 void write_utf8(const char* value); 56 void write_utf16(const jchar* value, jint len); 57 58 protected: 59 template <typename T> 60 void be_write(T value); 61 template <typename T> 62 void be_write(const T* value, size_t len); 63 template <typename StorageType> 64 WriterHost(StorageType* storage, Thread* thread); 65 template <typename StorageType> 66 WriterHost(StorageType* storage, size_t size); 67 WriterHost(Thread* thread); 68 u1* ensure_size(size_t requested_size); 69 70 public: 71 template <typename T> 72 void write(T value); 73 void write(bool value); 74 void write(float value); 75 void write(double value); 76 void write(const char* value); 77 void write(char* value); 78 void write(jstring value); 79 void write(const ClassLoaderData* cld); 80 void write(const Klass* klass); 81 void write(const Method* method); 82 void write(const ModuleEntry* module); 83 void write(const PackageEntry* package); 84 void write(const Symbol* symbol); 85 void write(const Ticks& time); 86 void write(const Tickspan& time); 87 void bytes(const void* buf, size_t len); 88 void write_utf8_u2_len(const char* value); 89 template <typename T> 90 void write_padded_at_offset(T value, intptr_t offset); 91 template <typename T> 92 void write_at_offset(T value, intptr_t offset); 93 template <typename T> 94 void write_be_at_offset(T value, intptr_t offset); 95 intptr_t reserve(size_t size); 96 }; 97 98 #endif // SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP