1 /* 2 * Copyright (c) 2016, 2019, 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_JFRPOSITION_HPP 26 #define SHARE_VM_JFR_WRITERS_JFRPOSITION_HPP 27 28 #include "utilities/debug.hpp" 29 #include "utilities/globalDefinitions.hpp" 30 31 template <typename AP> // AllocationPolicy 32 class Position : public AP { 33 private: 34 const u1* _start_pos; // logical start 35 u1* _current_pos; 36 const u1* _end_pos; 37 38 protected: 39 const u1* start_pos() const; 40 void set_start_pos(const u1* position); 41 u1* current_pos(); 42 void set_current_pos(const u1* new_position); 43 void set_current_pos(size_t size); 44 const u1* end_pos() const; 45 void set_end_pos(const u1* position); 46 Position(const u1* start_pos, size_t size); 47 Position(); 48 49 public: 50 size_t available_size() const; 51 intptr_t used_offset() const; 52 intptr_t current_offset() const; 53 size_t used_size() const; 54 void reset(); 55 }; 56 57 #endif // SHARE_VM_JFR_WRITERS_JFRPOSITION_HPP