1 /* 2 * Copyright (c) 2017, 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 #ifndef SHARE_GC_Z_ZALLOCATIONFLAGS_HPP 25 #define SHARE_GC_Z_ZALLOCATIONFLAGS_HPP 26 27 #include "gc/z/zBitField.hpp" 28 #include "memory/allocation.hpp" 29 30 // 31 // Allocation flags layout 32 // ----------------------- 33 // 34 // 7 4 3 2 1 0 35 // +---+-+-+-+-+-+ 36 // |000|1|1|1|1|1| 37 // +---+-+-+-+-+-+ 38 // | | | | | | 39 // | | | | | * 0-0 Java Thread Flag (1-bit) 40 // | | | | | 41 // | | | | * 1-1 Worker Thread Flag (1-bit) 42 // | | | | 43 // | | | * 2-2 Non-Blocking Flag (1-bit) 44 // | | | 45 // | | * 3-3 Relocation Flag (1-bit) 46 // | | 47 // | * 4-4 No Reserve Flag (1-bit) 48 // | 49 // * 7-5 Unused (3-bits) 50 // 51 52 class ZAllocationFlags VALUE_OBJ_CLASS_SPEC { 53 private: 54 typedef ZBitField<uint8_t, bool, 0, 1> field_java_thread; 55 typedef ZBitField<uint8_t, bool, 1, 1> field_worker_thread; 56 typedef ZBitField<uint8_t, bool, 2, 1> field_non_blocking; 57 typedef ZBitField<uint8_t, bool, 3, 1> field_relocation; 58 typedef ZBitField<uint8_t, bool, 4, 1> field_no_reserve; 59 60 uint8_t _flags; 61 62 public: 63 ZAllocationFlags() : 64 _flags(0) {} 65 66 void set_java_thread() { 67 _flags |= field_java_thread::encode(true); 68 } 69 70 void set_worker_thread() { 71 _flags |= field_worker_thread::encode(true); 72 } 73 74 void set_non_blocking() { 75 _flags |= field_non_blocking::encode(true); 76 } 77 78 void set_relocation() { 79 _flags |= field_relocation::encode(true); 80 } 81 82 void set_no_reserve() { 83 _flags |= field_no_reserve::encode(true); 84 } 85 86 bool java_thread() const { 87 return field_java_thread::decode(_flags); 88 } 89 90 bool worker_thread() const { 91 return field_worker_thread::decode(_flags); 92 } 93 94 bool non_blocking() const { 95 return field_non_blocking::decode(_flags); 96 } 97 98 bool relocation() const { 99 return field_relocation::decode(_flags); 100 } 101 102 bool no_reserve() const { 103 return field_no_reserve::decode(_flags); 104 } 105 }; 106 107 #endif // SHARE_GC_Z_ZALLOCATIONFLAGS_HPP