--- /dev/null 2019-01-28 17:48:40.000000000 +0800 +++ new/src/share/vm/jfr/writers/jfrWriterHost.hpp 2019-01-28 17:48:40.000000000 +0800 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * 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, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP +#define SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP + +#include "jni.h" +#include "utilities/globalDefinitions.hpp" + +class ClassLoaderData; +class Klass; +class Method; +class Thread; + +// BE == Base Encoder +// IE == Integer Encoder +template +class WriterHost : public WriterPolicyImpl { + private: + const bool _compressed_integers; + + template + void write_padded(T value); + template + void write_padded(const T* value, size_t len); + template + u1* write_padded(const T* value, size_t len, u1* pos); + template + void write(const T* value, size_t len); + template + u1* write(const T* value, size_t len, u1* pos); + void write_utf8(const char* value); + void write_utf16(const jchar* value, jint len); + + protected: + template + void be_write(T value); + template + void be_write(const T* value, size_t len); + template + WriterHost(StorageType* storage, Thread* thread); + template + WriterHost(StorageType* storage, size_t size); + WriterHost(Thread* thread); + u1* ensure_size(size_t requested_size); + + public: + template + void write(T value); + void write(bool value); + void write(float value); + void write(double value); + void write(const char* value); + void write(char* value); + void write(jstring value); + void write(const ClassLoaderData* cld); + void write(const Klass* klass); + void write(const Method* method); + void write(const Symbol* symbol); + void write(const Ticks& time); + void write(const Tickspan& time); + void bytes(const void* buf, size_t len); + void write_utf8_u2_len(const char* value); + template + void write_padded_at_offset(T value, intptr_t offset); + template + void write_at_offset(T value, intptr_t offset); + template + void write_be_at_offset(T value, intptr_t offset); + intptr_t reserve(size_t size); +}; + +#endif // SHARE_VM_JFR_WRITERS_JFRWRITERHOST_HPP