1 /*
  2  * Copyright (c) 2022, 2023, 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_RUNTIME_CONTINUATIONJAVACLASSES_HPP
 26 #define SHARE_RUNTIME_CONTINUATIONJAVACLASSES_HPP
 27 
 28 #include "memory/allStatic.hpp"
 29 #include "oops/oopsHierarchy.hpp"
 30 #include "utilities/globalDefinitions.hpp"
 31 #include "utilities/macros.hpp"
 32 
 33 class SerializeClosure;
 34 
 35 // Interface to jdk.internal.vm.ContinuationScope objects
 36 class jdk_internal_vm_ContinuationScope: AllStatic {
 37   friend class JavaClasses;
 38  private:
 39   static int _name_offset;
 40 
 41   static void compute_offsets();
 42  public:
 43   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 44 };
 45 
 46 // Interface to jdk.internal.vm.Continuation objects
 47 class jdk_internal_vm_Continuation: AllStatic {
 48   friend class JavaClasses;
 49  private:
 50   static int _scope_offset;
 51   static int _target_offset;
 52   static int _parent_offset;
 53   static int _yieldInfo_offset;
 54   static int _tail_offset;
 55   static int _mounted_offset;
 56   static int _done_offset;
 57   static int _preempted_offset;
 58 
 59   static void compute_offsets();
 60  public:
 61   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 62   // Accessors
 63   static inline oop scope(oop continuation);
 64   static inline oop parent(oop continuation);
 65   static inline stackChunkOop tail(oop continuation);
 66   static inline void set_tail(oop continuation, stackChunkOop value);
 67   static inline bool done(oop continuation);
 68   static inline bool is_preempted(oop continuation);
 69   static inline void set_preempted(oop continuation, bool value);
 70 };
 71 
 72 // Interface to jdk.internal.vm.StackChunk objects
 73 #define STACKCHUNK_INJECTED_FIELDS(macro)                                          \
 74   macro(jdk_internal_vm_StackChunk, cont,           continuation_signature, false) \
 75   macro(jdk_internal_vm_StackChunk, flags,          byte_signature,         false) \
 76   macro(jdk_internal_vm_StackChunk, pc,             intptr_signature,       false) \
 77   macro(jdk_internal_vm_StackChunk, maxThawingSize, int_signature,          false) \


 78 
 79 class jdk_internal_vm_StackChunk: AllStatic {
 80   friend class JavaClasses;
 81  private:
 82   static int _parent_offset;
 83   static int _size_offset;
 84   static int _sp_offset;
 85   static int _pc_offset;
 86   static int _bottom_offset;
 87   static int _flags_offset;
 88   static int _maxThawingSize_offset;


 89   static int _cont_offset;
 90 
 91 
 92   static void compute_offsets();
 93  public:
 94   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
 95 
 96   static inline int parent_offset() { return _parent_offset; }
 97   static inline int cont_offset()   { return _cont_offset; }
 98 
 99   // Accessors
100   static inline oop parent(oop chunk);
101   static inline void set_parent(oop chunk, oop value);
102   template<typename P>
103   static inline void set_parent_raw(oop chunk, oop value);
104   template<DecoratorSet decorators>
105   static inline void set_parent_access(oop chunk, oop value);
106 
107   static inline int size(oop chunk);
108   static inline void set_size(HeapWord* chunk, int value);
109 
110   static inline int sp(oop chunk);
111   static inline void set_sp(oop chunk, int value);
112   static inline void set_sp(HeapWord* chunk, int value); // used while allocating
113   static inline address pc(oop chunk);
114   static inline void set_pc(oop chunk, address value);
115   static inline int bottom(oop chunk);
116   static inline void set_bottom(oop chunk, int value);
117   static inline void set_bottom(HeapWord* chunk, int value);
118   static inline uint8_t flags(oop chunk);
119   static inline void set_flags(oop chunk, uint8_t value);
120   static inline uint8_t flags_acquire(oop chunk);
121   static inline void release_set_flags(oop chunk, uint8_t value);
122   static inline bool try_set_flags(oop chunk, uint8_t expected_value, uint8_t new_value);
123 
124   static inline int maxThawingSize(oop chunk);
125   static inline void set_maxThawingSize(oop chunk, int value);
126 






127   // cont oop's processing is essential for the chunk's GC protocol
128   static inline oop cont(oop chunk);
129   template<typename P>
130   static inline oop cont_raw(oop chunk);
131   static inline void set_cont(oop chunk, oop value);
132   template<typename P>
133   static inline void set_cont_raw(oop chunk, oop value);
134   template<DecoratorSet decorators>
135   static inline void set_cont_access(oop chunk, oop value);
136 };
137 
138 #endif // SHARE_RUNTIME_CONTINUATIONJAVACLASSES_HPP
--- EOF ---